Merge "msm: vidc: Fixes polling on video driver." into msm-3.4
diff --git a/Documentation/devicetree/bindings/iommu/msm_iommu.txt b/Documentation/devicetree/bindings/iommu/msm_iommu.txt
index 67933e7..e246682 100644
--- a/Documentation/devicetree/bindings/iommu/msm_iommu.txt
+++ b/Documentation/devicetree/bindings/iommu/msm_iommu.txt
@@ -13,6 +13,7 @@
   - qcom,iommu-ctx-sids : List of stream identifiers associated with this
     translation context.
   - qcom,iommu-ctx-name : Name of the context bank
+  - qcom,iommu-smt-size : Number of SMR entries in the SMT of this HW block
 
 Example:
 
diff --git a/arch/arm/boot/dts/msm-pm8841.dtsi b/arch/arm/boot/dts/msm-pm8841.dtsi
index a586a90..d84c8e0 100644
--- a/arch/arm/boot/dts/msm-pm8841.dtsi
+++ b/arch/arm/boot/dts/msm-pm8841.dtsi
@@ -10,218 +10,216 @@
  * GNU General Public License for more details.
  */
 
-/ {
-	qcom,spmi@fc4c0000 {
-		#address-cells = <1>;
-		#size-cells = <0>;
-		interrupt-controller;
-		#interrupt-cells = <3>;
+&spmi_bus {
+	#address-cells = <1>;
+	#size-cells = <0>;
+	interrupt-controller;
+	#interrupt-cells = <3>;
 
-		qcom,pm8841@4 {
-			spmi-slave-container;
-			reg = <0x4>;
+	qcom,pm8841@4 {
+		spmi-slave-container;
+		reg = <0x4>;
+		#address-cells = <1>;
+		#size-cells = <1>;
+
+		pm8841_mpps {
+			spmi-dev-container;
+			compatible = "qcom,qpnp-pin";
+			gpio-controller;
+			#gpio-cells = <2>;
 			#address-cells = <1>;
 			#size-cells = <1>;
+			label = "pm8841-mpp";
 
-			pm8841_mpps {
-				spmi-dev-container;
-				compatible = "qcom,qpnp-pin";
-				gpio-controller;
-				#gpio-cells = <2>;
-				#address-cells = <1>;
-				#size-cells = <1>;
-				label = "pm8841-mpp";
+			mpp@a000 {
+				reg = <0xa000 0x100>;
+				qcom,pin-num = <1>;
+				status = "disabled";
+			};
 
-				mpp@a000 {
-					reg = <0xa000 0x100>;
-					qcom,pin-num = <1>;
-					status = "disabled";
-				};
+			mpp@a100 {
+				reg = <0xa100 0x100>;
+				qcom,pin-num = <2>;
+				status = "disabled";
+			};
 
-				mpp@a100 {
-					reg = <0xa100 0x100>;
-					qcom,pin-num = <2>;
-					status = "disabled";
-				};
+			mpp@a200 {
+				reg = <0xa200 0x100>;
+				qcom,pin-num = <3>;
+				status = "disabled";
+			};
 
-				mpp@a200 {
-					reg = <0xa200 0x100>;
-					qcom,pin-num = <3>;
-					status = "disabled";
-				};
+			mpp@a300 {
+				reg = <0xa300 0x100>;
+				qcom,pin-num = <4>;
+				status = "disabled";
+			};
+		};
+	};
 
-				mpp@a300 {
-					reg = <0xa300 0x100>;
-					qcom,pin-num = <4>;
-					status = "disabled";
-				};
+	qcom,pm8841@5 {
+		spmi-slave-container;
+		reg = <0x5>;
+		#address-cells = <1>;
+		#size-cells = <1>;
+
+		regulator@1400 {
+			regulator-name = "8841_s1";
+			spmi-dev-container;
+			#address-cells = <1>;
+			#size-cells = <1>;
+			compatible = "qcom,qpnp-regulator";
+			reg = <0x1400 0x300>;
+			status = "disabled";
+
+			qcom,ctl@1400 {
+				reg = <0x1400 0x100>;
+			};
+			qcom,ps@1500 {
+				reg = <0x1500 0x100>;
+			};
+			qcom,freq@1600 {
+				reg = <0x1600 0x100>;
 			};
 		};
 
-		qcom,pm8841@5 {
-			spmi-slave-container;
-			reg = <0x5>;
+		regulator@1700 {
+			regulator-name = "8841_s2";
+			spmi-dev-container;
 			#address-cells = <1>;
 			#size-cells = <1>;
+			compatible = "qcom,qpnp-regulator";
+			reg = <0x1700 0x300>;
+			status = "disabled";
 
-			regulator@1400 {
-				regulator-name = "8841_s1";
-				spmi-dev-container;
-				#address-cells = <1>;
-				#size-cells = <1>;
-				compatible = "qcom,qpnp-regulator";
-				reg = <0x1400 0x300>;
-				status = "disabled";
-
-				qcom,ctl@1400 {
-					reg = <0x1400 0x100>;
-				};
-				qcom,ps@1500 {
-					reg = <0x1500 0x100>;
-				};
-				qcom,freq@1600 {
-					reg = <0x1600 0x100>;
-				};
+			qcom,ctl@1700 {
+				reg = <0x1700 0x100>;
 			};
-
-			regulator@1700 {
-				regulator-name = "8841_s2";
-				spmi-dev-container;
-				#address-cells = <1>;
-				#size-cells = <1>;
-				compatible = "qcom,qpnp-regulator";
-				reg = <0x1700 0x300>;
-				status = "disabled";
-
-				qcom,ctl@1700 {
-					reg = <0x1700 0x100>;
-				};
-				qcom,ps@1800 {
-					reg = <0x1800 0x100>;
-				};
-				qcom,freq@1900 {
-					reg = <0x1900 0x100>;
-				};
+			qcom,ps@1800 {
+				reg = <0x1800 0x100>;
 			};
-
-			regulator@1a00 {
-				regulator-name = "8841_s3";
-				spmi-dev-container;
-				#address-cells = <1>;
-				#size-cells = <1>;
-				compatible = "qcom,qpnp-regulator";
-				reg = <0x1a00 0x300>;
-				status = "disabled";
-
-				qcom,ctl@1a00 {
-					reg = <0x1a00 0x100>;
-				};
-				qcom,ps@1b00 {
-					reg = <0x1b00 0x100>;
-				};
-				qcom,freq@1c00 {
-					reg = <0x1c00 0x100>;
-				};
+			qcom,freq@1900 {
+				reg = <0x1900 0x100>;
 			};
+		};
 
-			regulator@1d00 {
-				regulator-name = "8841_s4";
-				spmi-dev-container;
-				#address-cells = <1>;
-				#size-cells = <1>;
-				compatible = "qcom,qpnp-regulator";
-				reg = <0x1d00 0x300>;
-				status = "disabled";
+		regulator@1a00 {
+			regulator-name = "8841_s3";
+			spmi-dev-container;
+			#address-cells = <1>;
+			#size-cells = <1>;
+			compatible = "qcom,qpnp-regulator";
+			reg = <0x1a00 0x300>;
+			status = "disabled";
 
-				qcom,ctl@1d00 {
-					reg = <0x1d00 0x100>;
-				};
-				qcom,ps@1e00 {
-					reg = <0x1e00 0x100>;
-				};
-				qcom,freq@1f00 {
-					reg = <0x1f00 0x100>;
-				};
+			qcom,ctl@1a00 {
+				reg = <0x1a00 0x100>;
 			};
-
-			regulator@2000 {
-				regulator-name = "8841_s5";
-				spmi-dev-container;
-				#address-cells = <1>;
-				#size-cells = <1>;
-				compatible = "qcom,qpnp-regulator";
-				reg = <0x2000 0x300>;
-				status = "disabled";
-
-				qcom,ctl@0 {
-					reg = <0x2000 0x100>;
-				};
-				qcom,ps@100 {
-					reg = <0x2100 0x100>;
-				};
-				qcom,freq@200 {
-					reg = <0x2200 0x100>;
-				};
+			qcom,ps@1b00 {
+				reg = <0x1b00 0x100>;
 			};
-
-			regulator@2300 {
-				regulator-name = "8841_s6";
-				spmi-dev-container;
-				#address-cells = <1>;
-				#size-cells = <1>;
-				compatible = "qcom,qpnp-regulator";
-				reg = <0x2300 0x300>;
-				status = "disabled";
-
-				qcom,ctl@2300 {
-					reg = <0x2300 0x100>;
-				};
-				qcom,ps@2400 {
-					reg = <0x2400 0x100>;
-				};
-				qcom,freq@2500 {
-					reg = <0x2500 0x100>;
-				};
+			qcom,freq@1c00 {
+				reg = <0x1c00 0x100>;
 			};
+		};
 
-			regulator@2600 {
-				regulator-name = "8841_s7";
-				spmi-dev-container;
-				#address-cells = <1>;
-				#size-cells = <1>;
-				compatible = "qcom,qpnp-regulator";
-				reg = <0x2600 0x300>;
-				status = "disabled";
+		regulator@1d00 {
+			regulator-name = "8841_s4";
+			spmi-dev-container;
+			#address-cells = <1>;
+			#size-cells = <1>;
+			compatible = "qcom,qpnp-regulator";
+			reg = <0x1d00 0x300>;
+			status = "disabled";
 
-				qcom,ctl@2600 {
-					reg = <0x2600 0x100>;
-				};
-				qcom,ps@2700 {
-					reg = <0x2700 0x100>;
-				};
-				qcom,freq@2800 {
-					reg = <0x2800 0x100>;
-				};
+			qcom,ctl@1d00 {
+				reg = <0x1d00 0x100>;
 			};
+			qcom,ps@1e00 {
+				reg = <0x1e00 0x100>;
+			};
+			qcom,freq@1f00 {
+				reg = <0x1f00 0x100>;
+			};
+		};
 
-			regulator@2900 {
-				regulator-name = "8841_s8";
-				spmi-dev-container;
-				#address-cells = <1>;
-				#size-cells = <1>;
-				compatible = "qcom,qpnp-regulator";
-				reg = <0x2900 0x300>;
-				status = "disabled";
+		regulator@2000 {
+			regulator-name = "8841_s5";
+			spmi-dev-container;
+			#address-cells = <1>;
+			#size-cells = <1>;
+			compatible = "qcom,qpnp-regulator";
+			reg = <0x2000 0x300>;
+			status = "disabled";
 
-				qcom,ctl@2900 {
-					reg = <0x2900 0x100>;
-				};
-				qcom,ps@2a000 {
-					reg = <0x2a00 0x100>;
-				};
-				qcom,freq@2b00 {
-					reg = <0x2b00 0x100>;
-				};
+			qcom,ctl@0 {
+				reg = <0x2000 0x100>;
+			};
+			qcom,ps@100 {
+				reg = <0x2100 0x100>;
+			};
+			qcom,freq@200 {
+				reg = <0x2200 0x100>;
+			};
+		};
+
+		regulator@2300 {
+			regulator-name = "8841_s6";
+			spmi-dev-container;
+			#address-cells = <1>;
+			#size-cells = <1>;
+			compatible = "qcom,qpnp-regulator";
+			reg = <0x2300 0x300>;
+			status = "disabled";
+
+			qcom,ctl@2300 {
+				reg = <0x2300 0x100>;
+			};
+			qcom,ps@2400 {
+				reg = <0x2400 0x100>;
+			};
+			qcom,freq@2500 {
+				reg = <0x2500 0x100>;
+			};
+		};
+
+		regulator@2600 {
+			regulator-name = "8841_s7";
+			spmi-dev-container;
+			#address-cells = <1>;
+			#size-cells = <1>;
+			compatible = "qcom,qpnp-regulator";
+			reg = <0x2600 0x300>;
+			status = "disabled";
+
+			qcom,ctl@2600 {
+				reg = <0x2600 0x100>;
+			};
+			qcom,ps@2700 {
+				reg = <0x2700 0x100>;
+			};
+			qcom,freq@2800 {
+				reg = <0x2800 0x100>;
+			};
+		};
+
+		regulator@2900 {
+			regulator-name = "8841_s8";
+			spmi-dev-container;
+			#address-cells = <1>;
+			#size-cells = <1>;
+			compatible = "qcom,qpnp-regulator";
+			reg = <0x2900 0x300>;
+			status = "disabled";
+
+			qcom,ctl@2900 {
+				reg = <0x2900 0x100>;
+			};
+			qcom,ps@2a000 {
+				reg = <0x2a00 0x100>;
+			};
+			qcom,freq@2b00 {
+				reg = <0x2b00 0x100>;
 			};
 		};
 	};
diff --git a/arch/arm/boot/dts/msm-pm8941.dtsi b/arch/arm/boot/dts/msm-pm8941.dtsi
index 2714d9e..87864fd 100644
--- a/arch/arm/boot/dts/msm-pm8941.dtsi
+++ b/arch/arm/boot/dts/msm-pm8941.dtsi
@@ -10,579 +10,577 @@
  * GNU General Public License for more details.
  */
 
-/ {
-	qcom,spmi@fc4c0000 {
-		#address-cells = <1>;
-		#size-cells = <0>;
-		interrupt-controller;
-		#interrupt-cells = <3>;
+&spmi_bus {
+	#address-cells = <1>;
+	#size-cells = <0>;
+	interrupt-controller;
+	#interrupt-cells = <3>;
 
-		qcom,pm8941@0 {
-			spmi-slave-container;
-			reg = <0x0>;
+	qcom,pm8941@0 {
+		spmi-slave-container;
+		reg = <0x0>;
+		#address-cells = <1>;
+		#size-cells = <1>;
+
+		pm8941_gpios {
+			spmi-dev-container;
+			compatible = "qcom,qpnp-pin";
+			gpio-controller;
+			#gpio-cells = <2>;
 			#address-cells = <1>;
 			#size-cells = <1>;
+			label = "pm8941-gpio";
 
-			pm8941_gpios {
-				spmi-dev-container;
-				compatible = "qcom,qpnp-pin";
-				gpio-controller;
-				#gpio-cells = <2>;
-				#address-cells = <1>;
-				#size-cells = <1>;
-				label = "pm8941-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";
-				};
-
-				gpio@cd00 {
-					reg = <0xcd00 0x100>;
-					qcom,pin-num = <14>;
-					status = "disabled";
-				};
-
-				gpio@ce00 {
-					reg = <0xce00 0x100>;
-					qcom,pin-num = <15>;
-					status = "disabled";
-				};
-
-				gpio@cf00 {
-					reg = <0xcf00 0x100>;
-					qcom,pin-num = <16>;
-					status = "disabled";
-				};
-
-				gpio@d000 {
-					reg = <0xd000 0x100>;
-					qcom,pin-num = <17>;
-					status = "disabled";
-				};
-
-				gpio@d100 {
-					reg = <0xd100 0x100>;
-					qcom,pin-num = <18>;
-					status = "disabled";
-				};
-
-				gpio@d200 {
-					reg = <0xd200 0x100>;
-					qcom,pin-num = <19>;
-					status = "disabled";
-				};
-
-				gpio@d300 {
-					reg = <0xd300 0x100>;
-					qcom,pin-num = <20>;
-					status = "disabled";
-				};
-
-				gpio@d400 {
-					reg = <0xd400 0x100>;
-					qcom,pin-num = <21>;
-					status = "disabled";
-				};
-
-				gpio@d500 {
-					reg = <0xd500 0x100>;
-					qcom,pin-num = <22>;
-					status = "disabled";
-				};
-
-				gpio@d600 {
-					reg = <0xd600 0x100>;
-					qcom,pin-num = <23>;
-					status = "disabled";
-				};
-
-				gpio@d700 {
-					reg = <0xd700 0x100>;
-					qcom,pin-num = <24>;
-					status = "disabled";
-				};
-
-				gpio@d800 {
-					reg = <0xd800 0x100>;
-					qcom,pin-num = <25>;
-					status = "disabled";
-				};
-
-				gpio@d900 {
-					reg = <0xd900 0x100>;
-					qcom,pin-num = <26>;
-					status = "disabled";
-				};
-
-				gpio@da00 {
-					reg = <0xda00 0x100>;
-					qcom,pin-num = <27>;
-					status = "disabled";
-				};
-
-				gpio@db00 {
-					reg = <0xdb00 0x100>;
-					qcom,pin-num = <28>;
-					status = "disabled";
-				};
-
-				gpio@dc00 {
-					reg = <0xdc00 0x100>;
-					qcom,pin-num = <29>;
-					status = "disabled";
-				};
-
-				gpio@dd00 {
-					reg = <0xdd00 0x100>;
-					qcom,pin-num = <30>;
-					status = "disabled";
-				};
-
-				gpio@de00 {
-					reg = <0xde00 0x100>;
-					qcom,pin-num = <31>;
-					status = "disabled";
-				};
-
-				gpio@df00 {
-					reg = <0xdf00 0x100>;
-					qcom,pin-num = <32>;
-					status = "disabled";
-				};
-
-				gpio@e000 {
-					reg = <0xe000 0x100>;
-					qcom,pin-num = <33>;
-					status = "disabled";
-				};
-
-				gpio@e100 {
-					reg = <0xe100 0x100>;
-					qcom,pin-num = <34>;
-					status = "disabled";
-				};
-
-				gpio@e200 {
-					reg = <0xe200 0x100>;
-					qcom,pin-num = <35>;
-					status = "disabled";
-				};
-
-				gpio@e300 {
-					reg = <0xe300 0x100>;
-					qcom,pin-num = <36>;
-					status = "disabled";
-				};
+			gpio@c000 {
+				reg = <0xc000 0x100>;
+				qcom,pin-num = <1>;
+				status = "disabled";
 			};
 
-			pm8941_mpps {
-				spmi-dev-container;
-				compatible = "qcom,qpnp-pin";
-				gpio-controller;
-				#gpio-cells = <2>;
-				#address-cells = <1>;
-				#size-cells = <1>;
-				label = "pm8941-mpp";
+			gpio@c100 {
+				reg = <0xc100 0x100>;
+				qcom,pin-num = <2>;
+				status = "disabled";
+			};
 
-				mpp@a000 {
-					reg = <0xa000 0x100>;
-					qcom,pin-num = <1>;
-					status = "disabled";
-				};
+			gpio@c200 {
+				reg = <0xc200 0x100>;
+				qcom,pin-num = <3>;
+				status = "disabled";
+			};
 
-				mpp@a100 {
-					reg = <0xa100 0x100>;
-					qcom,pin-num = <2>;
-					status = "disabled";
-				};
+			gpio@c300 {
+				reg = <0xc300 0x100>;
+				qcom,pin-num = <4>;
+				status = "disabled";
+			};
 
-				mpp@a200 {
-					reg = <0xa200 0x100>;
-					qcom,pin-num = <3>;
-					status = "disabled";
-				};
+			gpio@c400 {
+				reg = <0xc400 0x100>;
+				qcom,pin-num = <5>;
+				status = "disabled";
+			};
 
-				mpp@a300 {
-					reg = <0xa300 0x100>;
-					qcom,pin-num = <4>;
-					status = "disabled";
-				};
+			gpio@c500 {
+				reg = <0xc500 0x100>;
+				qcom,pin-num = <6>;
+				status = "disabled";
+			};
 
-				mpp@a400 {
-					reg = <0xa400 0x100>;
-					qcom,pin-num = <5>;
-					status = "disabled";
-				};
+			gpio@c600 {
+				reg = <0xc600 0x100>;
+				qcom,pin-num = <7>;
+				status = "disabled";
+			};
 
-				mpp@a500 {
-					reg = <0xa500 0x100>;
-					qcom,pin-num = <6>;
-					status = "disabled";
-				};
+			gpio@c700 {
+				reg = <0xc700 0x100>;
+				qcom,pin-num = <8>;
+				status = "disabled";
+			};
 
-				mpp@a600 {
-					reg = <0xa600 0x100>;
-					qcom,pin-num = <7>;
-					status = "disabled";
-				};
+			gpio@c800 {
+				reg = <0xc800 0x100>;
+				qcom,pin-num = <9>;
+				status = "disabled";
+			};
 
-				mpp@a700 {
-					reg = <0xa700 0x100>;
-					qcom,pin-num = <8>;
-					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";
+			};
+
+			gpio@cd00 {
+				reg = <0xcd00 0x100>;
+				qcom,pin-num = <14>;
+				status = "disabled";
+			};
+
+			gpio@ce00 {
+				reg = <0xce00 0x100>;
+				qcom,pin-num = <15>;
+				status = "disabled";
+			};
+
+			gpio@cf00 {
+				reg = <0xcf00 0x100>;
+				qcom,pin-num = <16>;
+				status = "disabled";
+			};
+
+			gpio@d000 {
+				reg = <0xd000 0x100>;
+				qcom,pin-num = <17>;
+				status = "disabled";
+			};
+
+			gpio@d100 {
+				reg = <0xd100 0x100>;
+				qcom,pin-num = <18>;
+				status = "disabled";
+			};
+
+			gpio@d200 {
+				reg = <0xd200 0x100>;
+				qcom,pin-num = <19>;
+				status = "disabled";
+			};
+
+			gpio@d300 {
+				reg = <0xd300 0x100>;
+				qcom,pin-num = <20>;
+				status = "disabled";
+			};
+
+			gpio@d400 {
+				reg = <0xd400 0x100>;
+				qcom,pin-num = <21>;
+				status = "disabled";
+			};
+
+			gpio@d500 {
+				reg = <0xd500 0x100>;
+				qcom,pin-num = <22>;
+				status = "disabled";
+			};
+
+			gpio@d600 {
+				reg = <0xd600 0x100>;
+				qcom,pin-num = <23>;
+				status = "disabled";
+			};
+
+			gpio@d700 {
+				reg = <0xd700 0x100>;
+				qcom,pin-num = <24>;
+				status = "disabled";
+			};
+
+			gpio@d800 {
+				reg = <0xd800 0x100>;
+				qcom,pin-num = <25>;
+				status = "disabled";
+			};
+
+			gpio@d900 {
+				reg = <0xd900 0x100>;
+				qcom,pin-num = <26>;
+				status = "disabled";
+			};
+
+			gpio@da00 {
+				reg = <0xda00 0x100>;
+				qcom,pin-num = <27>;
+				status = "disabled";
+			};
+
+			gpio@db00 {
+				reg = <0xdb00 0x100>;
+				qcom,pin-num = <28>;
+				status = "disabled";
+			};
+
+			gpio@dc00 {
+				reg = <0xdc00 0x100>;
+				qcom,pin-num = <29>;
+				status = "disabled";
+			};
+
+			gpio@dd00 {
+				reg = <0xdd00 0x100>;
+				qcom,pin-num = <30>;
+				status = "disabled";
+			};
+
+			gpio@de00 {
+				reg = <0xde00 0x100>;
+				qcom,pin-num = <31>;
+				status = "disabled";
+			};
+
+			gpio@df00 {
+				reg = <0xdf00 0x100>;
+				qcom,pin-num = <32>;
+				status = "disabled";
+			};
+
+			gpio@e000 {
+				reg = <0xe000 0x100>;
+				qcom,pin-num = <33>;
+				status = "disabled";
+			};
+
+			gpio@e100 {
+				reg = <0xe100 0x100>;
+				qcom,pin-num = <34>;
+				status = "disabled";
+			};
+
+			gpio@e200 {
+				reg = <0xe200 0x100>;
+				qcom,pin-num = <35>;
+				status = "disabled";
+			};
+
+			gpio@e300 {
+				reg = <0xe300 0x100>;
+				qcom,pin-num = <36>;
+				status = "disabled";
 			};
 		};
 
-		qcom,pm8941@1 {
-			spmi-slave-container;
-			reg = <0x1>;
+		pm8941_mpps {
+			spmi-dev-container;
+			compatible = "qcom,qpnp-pin";
+			gpio-controller;
+			#gpio-cells = <2>;
 			#address-cells = <1>;
 			#size-cells = <1>;
+			label = "pm8941-mpp";
 
-			regulator@1400 {
-				regulator-name = "8941_s1";
-				spmi-dev-container;
-				#address-cells = <1>;
-				#size-cells = <1>;
-				compatible = "qcom,qpnp-regulator";
-				reg = <0x1400 0x300>;
-				status = "disabled";
-
-				qcom,ctl@1400 {
-					reg = <0x1400 0x100>;
-				};
-				qcom,ps@1500 {
-					reg = <0x1500 0x100>;
-				};
-				qcom,freq@1600 {
-					reg = <0x1600 0x100>;
-				};
-			};
-
-			regulator@1700 {
-				regulator-name = "8941_s2";
-				spmi-dev-container;
-				#address-cells = <1>;
-				#size-cells = <1>;
-				compatible = "qcom,qpnp-regulator";
-				reg = <0x1700 0x300>;
-				status = "disabled";
-
-				qcom,ctl@1700 {
-					reg = <0x1700 0x100>;
-				};
-				qcom,ps@1800 {
-					reg = <0x1800 0x100>;
-				};
-				qcom,freq@1900 {
-					reg = <0x1900 0x100>;
-				};
-			};
-
-			regulator@1a00 {
-				regulator-name = "8941_s3";
-				spmi-dev-container;
-				#address-cells = <1>;
-				#size-cells = <1>;
-				compatible = "qcom,qpnp-regulator";
-				reg = <0x1400 0x300>;
-				status = "disabled";
-
-				qcom,ctl@1a00 {
-					reg = <0x1a00 0x100>;
-				};
-				qcom,ps@1b00 {
-					reg = <0x1b00 0x100>;
-				};
-				qcom,freq@1c00 {
-					reg = <0x1c00 0x100>;
-				};
-			};
-
-			regulator@a000 {
-				regulator-name = "8941_boost";
+			mpp@a000 {
 				reg = <0xa000 0x100>;
-				compatible = "qcom,qpnp-regulator";
+				qcom,pin-num = <1>;
 				status = "disabled";
 			};
 
-			regulator@4000 {
-				regulator-name = "8941_l1";
-				reg = <0x4000 0x100>;
-				compatible = "qcom,qpnp-regulator";
+			mpp@a100 {
+				reg = <0xa100 0x100>;
+				qcom,pin-num = <2>;
 				status = "disabled";
 			};
 
-			regulator@4100 {
-				regulator-name = "8941_l2";
-				reg = <0x4100 0x100>;
-				compatible = "qcom,qpnp-regulator";
+			mpp@a200 {
+				reg = <0xa200 0x100>;
+				qcom,pin-num = <3>;
 				status = "disabled";
 			};
 
-			regulator@4200 {
-				regulator-name = "8941_l3";
-				reg = <0x4200 0x100>;
-				compatible = "qcom,qpnp-regulator";
+			mpp@a300 {
+				reg = <0xa300 0x100>;
+				qcom,pin-num = <4>;
 				status = "disabled";
 			};
 
-			regulator@4300 {
-				regulator-name = "8941_l4";
-				reg = <0x4300 0x100>;
-				compatible = "qcom,qpnp-regulator";
+			mpp@a400 {
+				reg = <0xa400 0x100>;
+				qcom,pin-num = <5>;
 				status = "disabled";
 			};
 
-			regulator@4400 {
-				regulator-name = "8941_l5";
-				reg = <0x4400 0x100>;
-				compatible = "qcom,qpnp-regulator";
+			mpp@a500 {
+				reg = <0xa500 0x100>;
+				qcom,pin-num = <6>;
 				status = "disabled";
 			};
 
-			regulator@4500 {
-				regulator-name = "8941_l6";
-				reg = <0x4500 0x100>;
-				compatible = "qcom,qpnp-regulator";
+			mpp@a600 {
+				reg = <0xa600 0x100>;
+				qcom,pin-num = <7>;
 				status = "disabled";
 			};
 
-			regulator@4600 {
-				regulator-name = "8941_l7";
-				reg = <0x4600 0x100>;
-				compatible = "qcom,qpnp-regulator";
+			mpp@a700 {
+				reg = <0xa700 0x100>;
+				qcom,pin-num = <8>;
 				status = "disabled";
 			};
+		};
+	};
 
-			regulator@4700 {
-				regulator-name = "8941_l8";
-				reg = <0x4700 0x100>;
-				compatible = "qcom,qpnp-regulator";
-				status = "disabled";
-			};
+	qcom,pm8941@1 {
+		spmi-slave-container;
+		reg = <0x1>;
+		#address-cells = <1>;
+		#size-cells = <1>;
 
-			regulator@4800 {
-				regulator-name = "8941_l9";
-				reg = <0x4800 0x100>;
-				compatible = "qcom,qpnp-regulator";
-				status = "disabled";
-			};
+		regulator@1400 {
+			regulator-name = "8941_s1";
+			spmi-dev-container;
+			#address-cells = <1>;
+			#size-cells = <1>;
+			compatible = "qcom,qpnp-regulator";
+			reg = <0x1400 0x300>;
+			status = "disabled";
 
-			regulator@4900 {
-				regulator-name = "8941_l10";
-				reg = <0x4900 0x100>;
-				compatible = "qcom,qpnp-regulator";
-				status = "disabled";
+			qcom,ctl@1400 {
+				reg = <0x1400 0x100>;
 			};
+			qcom,ps@1500 {
+				reg = <0x1500 0x100>;
+			};
+			qcom,freq@1600 {
+				reg = <0x1600 0x100>;
+			};
+		};
 
-			regulator@4a00 {
-				regulator-name = "8941_l11";
-				reg = <0x4a00 0x100>;
-				compatible = "qcom,qpnp-regulator";
-				status = "disabled";
-			};
+		regulator@1700 {
+			regulator-name = "8941_s2";
+			spmi-dev-container;
+			#address-cells = <1>;
+			#size-cells = <1>;
+			compatible = "qcom,qpnp-regulator";
+			reg = <0x1700 0x300>;
+			status = "disabled";
 
-			regulator@4b00 {
-				regulator-name = "8941_l12";
-				reg = <0x4b00 0x100>;
-				compatible = "qcom,qpnp-regulator";
-				status = "disabled";
+			qcom,ctl@1700 {
+				reg = <0x1700 0x100>;
 			};
+			qcom,ps@1800 {
+				reg = <0x1800 0x100>;
+			};
+			qcom,freq@1900 {
+				reg = <0x1900 0x100>;
+			};
+		};
 
-			regulator@4c00 {
-				regulator-name = "8941_l13";
-				reg = <0x4c00 0x100>;
-				compatible = "qcom,qpnp-regulator";
-				status = "disabled";
-			};
+		regulator@1a00 {
+			regulator-name = "8941_s3";
+			spmi-dev-container;
+			#address-cells = <1>;
+			#size-cells = <1>;
+			compatible = "qcom,qpnp-regulator";
+			reg = <0x1400 0x300>;
+			status = "disabled";
 
-			regulator@4d00 {
-				regulator-name = "8941_l14";
-				reg = <0x4d00 0x100>;
-				compatible = "qcom,qpnp-regulator";
-				status = "disabled";
+			qcom,ctl@1a00 {
+				reg = <0x1a00 0x100>;
 			};
+			qcom,ps@1b00 {
+				reg = <0x1b00 0x100>;
+			};
+			qcom,freq@1c00 {
+				reg = <0x1c00 0x100>;
+			};
+		};
 
-			regulator@4e00 {
-				regulator-name = "8941_l15";
-				reg = <0x4e00 0x100>;
-				compatible = "qcom,qpnp-regulator";
-				status = "disabled";
-			};
+		regulator@a000 {
+			regulator-name = "8941_boost";
+			reg = <0xa000 0x100>;
+			compatible = "qcom,qpnp-regulator";
+			status = "disabled";
+		};
 
-			regulator@4f00 {
-				regulator-name = "8941_l16";
-				reg = <0x4f00 0x100>;
-				compatible = "qcom,qpnp-regulator";
-				status = "disabled";
-			};
+		regulator@4000 {
+			regulator-name = "8941_l1";
+			reg = <0x4000 0x100>;
+			compatible = "qcom,qpnp-regulator";
+			status = "disabled";
+		};
 
-			regulator@5000 {
-				regulator-name = "8941_l17";
-				reg = <0x5000 0x100>;
-				compatible = "qcom,qpnp-regulator";
-				status = "disabled";
-			};
+		regulator@4100 {
+			regulator-name = "8941_l2";
+			reg = <0x4100 0x100>;
+			compatible = "qcom,qpnp-regulator";
+			status = "disabled";
+		};
 
-			regulator@5100 {
-				regulator-name = "8941_l18";
-				reg = <0x5100 0x100>;
-				compatible = "qcom,qpnp-regulator";
-				status = "disabled";
-			};
+		regulator@4200 {
+			regulator-name = "8941_l3";
+			reg = <0x4200 0x100>;
+			compatible = "qcom,qpnp-regulator";
+			status = "disabled";
+		};
 
-			regulator@5200 {
-				regulator-name = "8941_l19";
-				reg = <0x5200 0x100>;
-				compatible = "qcom,qpnp-regulator";
-				status = "disabled";
-			};
+		regulator@4300 {
+			regulator-name = "8941_l4";
+			reg = <0x4300 0x100>;
+			compatible = "qcom,qpnp-regulator";
+			status = "disabled";
+		};
 
-			regulator@5300 {
-				regulator-name = "8941_l20";
-				reg = <0x5300 0x100>;
-				compatible = "qcom,qpnp-regulator";
-				status = "disabled";
-			};
+		regulator@4400 {
+			regulator-name = "8941_l5";
+			reg = <0x4400 0x100>;
+			compatible = "qcom,qpnp-regulator";
+			status = "disabled";
+		};
 
-			regulator@5400 {
-				regulator-name = "8941_l21";
-				reg = <0x5400 0x100>;
-				compatible = "qcom,qpnp-regulator";
-				status = "disabled";
-			};
+		regulator@4500 {
+			regulator-name = "8941_l6";
+			reg = <0x4500 0x100>;
+			compatible = "qcom,qpnp-regulator";
+			status = "disabled";
+		};
 
-			regulator@5500 {
-				regulator-name = "8941_l22";
-				reg = <0x5500 0x100>;
-				compatible = "qcom,qpnp-regulator";
-				status = "disabled";
-			};
+		regulator@4600 {
+			regulator-name = "8941_l7";
+			reg = <0x4600 0x100>;
+			compatible = "qcom,qpnp-regulator";
+			status = "disabled";
+		};
 
-			regulator@5600 {
-				regulator-name = "8941_l23";
-				reg = <0x5600 0x100>;
-				compatible = "qcom,qpnp-regulator";
-				status = "disabled";
-			};
+		regulator@4700 {
+			regulator-name = "8941_l8";
+			reg = <0x4700 0x100>;
+			compatible = "qcom,qpnp-regulator";
+			status = "disabled";
+		};
 
-			regulator@5700 {
-				regulator-name = "8941_l24";
-				reg = <0x5700 0x100>;
-				compatible = "qcom,qpnp-regulator";
-				status = "disabled";
-			};
+		regulator@4800 {
+			regulator-name = "8941_l9";
+			reg = <0x4800 0x100>;
+			compatible = "qcom,qpnp-regulator";
+			status = "disabled";
+		};
 
-			regulator@8000 {
-				regulator-name = "8941_lvs1";
-				reg = <0x8000 0x100>;
-				compatible = "qcom,qpnp-regulator";
-				status = "disabled";
-			};
+		regulator@4900 {
+			regulator-name = "8941_l10";
+			reg = <0x4900 0x100>;
+			compatible = "qcom,qpnp-regulator";
+			status = "disabled";
+		};
 
-			regulator@8100 {
-				regulator-name = "8941_lvs2";
-				reg = <0x8100 0x100>;
-				compatible = "qcom,qpnp-regulator";
-				status = "disabled";
-			};
+		regulator@4a00 {
+			regulator-name = "8941_l11";
+			reg = <0x4a00 0x100>;
+			compatible = "qcom,qpnp-regulator";
+			status = "disabled";
+		};
 
-			regulator@8200 {
-				regulator-name = "8941_lvs3";
-				reg = <0x8200 0x100>;
-				compatible = "qcom,qpnp-regulator";
-				status = "disabled";
-			};
+		regulator@4b00 {
+			regulator-name = "8941_l12";
+			reg = <0x4b00 0x100>;
+			compatible = "qcom,qpnp-regulator";
+			status = "disabled";
+		};
 
-			regulator@8300 {
-				regulator-name = "8941_mvs1";
-				reg = <0x8300 0x100>;
-				compatible = "qcom,qpnp-regulator";
-				status = "disabled";
-			};
+		regulator@4c00 {
+			regulator-name = "8941_l13";
+			reg = <0x4c00 0x100>;
+			compatible = "qcom,qpnp-regulator";
+			status = "disabled";
+		};
 
-			regulator@8400 {
-				regulator-name = "8941_mvs2";
-				reg = <0x8400 0x100>;
-				compatible = "qcom,qpnp-regulator";
-				status = "disabled";
-			};
+		regulator@4d00 {
+			regulator-name = "8941_l14";
+			reg = <0x4d00 0x100>;
+			compatible = "qcom,qpnp-regulator";
+			status = "disabled";
+		};
+
+		regulator@4e00 {
+			regulator-name = "8941_l15";
+			reg = <0x4e00 0x100>;
+			compatible = "qcom,qpnp-regulator";
+			status = "disabled";
+		};
+
+		regulator@4f00 {
+			regulator-name = "8941_l16";
+			reg = <0x4f00 0x100>;
+			compatible = "qcom,qpnp-regulator";
+			status = "disabled";
+		};
+
+		regulator@5000 {
+			regulator-name = "8941_l17";
+			reg = <0x5000 0x100>;
+			compatible = "qcom,qpnp-regulator";
+			status = "disabled";
+		};
+
+		regulator@5100 {
+			regulator-name = "8941_l18";
+			reg = <0x5100 0x100>;
+			compatible = "qcom,qpnp-regulator";
+			status = "disabled";
+		};
+
+		regulator@5200 {
+			regulator-name = "8941_l19";
+			reg = <0x5200 0x100>;
+			compatible = "qcom,qpnp-regulator";
+			status = "disabled";
+		};
+
+		regulator@5300 {
+			regulator-name = "8941_l20";
+			reg = <0x5300 0x100>;
+			compatible = "qcom,qpnp-regulator";
+			status = "disabled";
+		};
+
+		regulator@5400 {
+			regulator-name = "8941_l21";
+			reg = <0x5400 0x100>;
+			compatible = "qcom,qpnp-regulator";
+			status = "disabled";
+		};
+
+		regulator@5500 {
+			regulator-name = "8941_l22";
+			reg = <0x5500 0x100>;
+			compatible = "qcom,qpnp-regulator";
+			status = "disabled";
+		};
+
+		regulator@5600 {
+			regulator-name = "8941_l23";
+			reg = <0x5600 0x100>;
+			compatible = "qcom,qpnp-regulator";
+			status = "disabled";
+		};
+
+		regulator@5700 {
+			regulator-name = "8941_l24";
+			reg = <0x5700 0x100>;
+			compatible = "qcom,qpnp-regulator";
+			status = "disabled";
+		};
+
+		regulator@8000 {
+			regulator-name = "8941_lvs1";
+			reg = <0x8000 0x100>;
+			compatible = "qcom,qpnp-regulator";
+			status = "disabled";
+		};
+
+		regulator@8100 {
+			regulator-name = "8941_lvs2";
+			reg = <0x8100 0x100>;
+			compatible = "qcom,qpnp-regulator";
+			status = "disabled";
+		};
+
+		regulator@8200 {
+			regulator-name = "8941_lvs3";
+			reg = <0x8200 0x100>;
+			compatible = "qcom,qpnp-regulator";
+			status = "disabled";
+		};
+
+		regulator@8300 {
+			regulator-name = "8941_mvs1";
+			reg = <0x8300 0x100>;
+			compatible = "qcom,qpnp-regulator";
+			status = "disabled";
+		};
+
+		regulator@8400 {
+			regulator-name = "8941_mvs2";
+			reg = <0x8400 0x100>;
+			compatible = "qcom,qpnp-regulator";
+			status = "disabled";
 		};
 	};
 };
diff --git a/arch/arm/boot/dts/msm-pm8x41-rpm-regulator.dtsi b/arch/arm/boot/dts/msm-pm8x41-rpm-regulator.dtsi
index 019112a..aced482 100644
--- a/arch/arm/boot/dts/msm-pm8x41-rpm-regulator.dtsi
+++ b/arch/arm/boot/dts/msm-pm8x41-rpm-regulator.dtsi
@@ -10,578 +10,576 @@
  * GNU General Public License for more details.
  */
 
-/ {
-	qcom,rpm-smd {
-		rpm-regulator-smpb1 {
-			qcom,resource-name = "smpb";
-			qcom,resource-id = <1>;
-			qcom,regulator-type = <1>;
-			qcom,hpm-min-load = <100000>;
-			compatible = "qcom,rpm-regulator-smd-resource";
-			status = "disabled";
+&rpm_bus {
+	rpm-regulator-smpb1 {
+		qcom,resource-name = "smpb";
+		qcom,resource-id = <1>;
+		qcom,regulator-type = <1>;
+		qcom,hpm-min-load = <100000>;
+		compatible = "qcom,rpm-regulator-smd-resource";
+		status = "disabled";
 
-			regulator-s1 {
-				regulator-name = "8841_s1";
-				qcom,set = <3>;
-				status = "disabled";
-				compatible = "qcom,rpm-regulator-smd";
-			};
+		regulator-s1 {
+			regulator-name = "8841_s1";
+			qcom,set = <3>;
+			status = "disabled";
+			compatible = "qcom,rpm-regulator-smd";
 		};
+	};
 
-		rpm-regulator-smpb2 {
-			qcom,resource-name = "smpb";
-			qcom,resource-id = <2>;
-			qcom,regulator-type = <1>;
-			qcom,hpm-min-load = <100000>;
-			compatible = "qcom,rpm-regulator-smd-resource";
+	rpm-regulator-smpb2 {
+		qcom,resource-name = "smpb";
+		qcom,resource-id = <2>;
+		qcom,regulator-type = <1>;
+		qcom,hpm-min-load = <100000>;
+		compatible = "qcom,rpm-regulator-smd-resource";
+		status = "disabled";
+
+		regulator-s2 {
+			regulator-name = "8841_s2";
+			qcom,set = <3>;
 			status = "disabled";
-
-			regulator-s2 {
-				regulator-name = "8841_s2";
-				qcom,set = <3>;
-				status = "disabled";
-				compatible = "qcom,rpm-regulator-smd";
-			};
+			compatible = "qcom,rpm-regulator-smd";
 		};
+	};
 
-		rpm-regulator-smpb3 {
-			qcom,resource-name = "smpb";
-			qcom,resource-id = <3>;
-			qcom,regulator-type = <1>;
-			qcom,hpm-min-load = <100000>;
-			compatible = "qcom,rpm-regulator-smd-resource";
+	rpm-regulator-smpb3 {
+		qcom,resource-name = "smpb";
+		qcom,resource-id = <3>;
+		qcom,regulator-type = <1>;
+		qcom,hpm-min-load = <100000>;
+		compatible = "qcom,rpm-regulator-smd-resource";
+		status = "disabled";
+
+		regulator-s3 {
+			regulator-name = "8841_s3";
+			qcom,set = <3>;
 			status = "disabled";
-
-			regulator-s3 {
-				regulator-name = "8841_s3";
-				qcom,set = <3>;
-				status = "disabled";
-				compatible = "qcom,rpm-regulator-smd";
-			};
+			compatible = "qcom,rpm-regulator-smd";
 		};
+	};
 
-		rpm-regulator-smpb4 {
-			qcom,resource-name = "smpb";
-			qcom,resource-id = <4>;
-			qcom,regulator-type = <1>;
-			qcom,hpm-min-load = <100000>;
-			compatible = "qcom,rpm-regulator-smd-resource";
+	rpm-regulator-smpb4 {
+		qcom,resource-name = "smpb";
+		qcom,resource-id = <4>;
+		qcom,regulator-type = <1>;
+		qcom,hpm-min-load = <100000>;
+		compatible = "qcom,rpm-regulator-smd-resource";
+		status = "disabled";
+
+		regulator-s4 {
+			regulator-name = "8841_s4";
+			qcom,set = <3>;
 			status = "disabled";
-
-			regulator-s4 {
-				regulator-name = "8841_s4";
-				qcom,set = <3>;
-				status = "disabled";
-				compatible = "qcom,rpm-regulator-smd";
-			};
+			compatible = "qcom,rpm-regulator-smd";
 		};
+	};
 
-		rpm-regulator-smpa1 {
-			qcom,resource-name = "smpa";
-			qcom,resource-id = <1>;
-			qcom,regulator-type = <1>;
-			qcom,hpm-min-load = <100000>;
-			compatible = "qcom,rpm-regulator-smd-resource";
+	rpm-regulator-smpa1 {
+		qcom,resource-name = "smpa";
+		qcom,resource-id = <1>;
+		qcom,regulator-type = <1>;
+		qcom,hpm-min-load = <100000>;
+		compatible = "qcom,rpm-regulator-smd-resource";
+		status = "disabled";
+
+		regulator-s1 {
+			regulator-name = "8941_s1";
+			qcom,set = <3>;
 			status = "disabled";
-
-			regulator-s1 {
-				regulator-name = "8941_s1";
-				qcom,set = <3>;
-				status = "disabled";
-				compatible = "qcom,rpm-regulator-smd";
-			};
+			compatible = "qcom,rpm-regulator-smd";
 		};
+	};
 
-		rpm-regulator-smpa2 {
-			qcom,resource-name = "smpa";
-			qcom,resource-id = <2>;
-			qcom,regulator-type = <1>;
-			qcom,hpm-min-load = <100000>;
-			compatible = "qcom,rpm-regulator-smd-resource";
+	rpm-regulator-smpa2 {
+		qcom,resource-name = "smpa";
+		qcom,resource-id = <2>;
+		qcom,regulator-type = <1>;
+		qcom,hpm-min-load = <100000>;
+		compatible = "qcom,rpm-regulator-smd-resource";
+		status = "disabled";
+
+		regulator-s2 {
+			regulator-name = "8941_s2";
+			qcom,set = <3>;
 			status = "disabled";
-
-			regulator-s2 {
-				regulator-name = "8941_s2";
-				qcom,set = <3>;
-				status = "disabled";
-				compatible = "qcom,rpm-regulator-smd";
-			};
+			compatible = "qcom,rpm-regulator-smd";
 		};
+	};
 
-		rpm-regulator-smpa3 {
-			qcom,resource-name = "smpa";
-			qcom,resource-id = <3>;
-			qcom,regulator-type = <1>;
-			qcom,hpm-min-load = <100000>;
-			compatible = "qcom,rpm-regulator-smd-resource";
+	rpm-regulator-smpa3 {
+		qcom,resource-name = "smpa";
+		qcom,resource-id = <3>;
+		qcom,regulator-type = <1>;
+		qcom,hpm-min-load = <100000>;
+		compatible = "qcom,rpm-regulator-smd-resource";
+		status = "disabled";
+
+		regulator-s3 {
+			regulator-name = "8941_s3";
+			qcom,set = <3>;
 			status = "disabled";
-
-			regulator-s3 {
-				regulator-name = "8941_s3";
-				qcom,set = <3>;
-				status = "disabled";
-				compatible = "qcom,rpm-regulator-smd";
-			};
+			compatible = "qcom,rpm-regulator-smd";
 		};
+	};
 
-		rpm-regulator-ldoa1 {
-			qcom,resource-name = "ldoa";
-			qcom,resource-id = <1>;
-			qcom,regulator-type = <0>;
-			qcom,hpm-min-load = <10000>;
-			compatible = "qcom,rpm-regulator-smd-resource";
+	rpm-regulator-ldoa1 {
+		qcom,resource-name = "ldoa";
+		qcom,resource-id = <1>;
+		qcom,regulator-type = <0>;
+		qcom,hpm-min-load = <10000>;
+		compatible = "qcom,rpm-regulator-smd-resource";
+		status = "disabled";
+
+		regulator-l1 {
+			regulator-name = "8941_l1";
+			qcom,set = <3>;
 			status = "disabled";
-
-			regulator-l1 {
-				regulator-name = "8941_l1";
-				qcom,set = <3>;
-				status = "disabled";
-				compatible = "qcom,rpm-regulator-smd";
-			};
+			compatible = "qcom,rpm-regulator-smd";
 		};
+	};
 
-		rpm-regulator-ldoa2 {
-			qcom,resource-name = "ldoa";
-			qcom,resource-id = <2>;
-			qcom,regulator-type = <0>;
-			qcom,hpm-min-load = <10000>;
-			compatible = "qcom,rpm-regulator-smd-resource";
+	rpm-regulator-ldoa2 {
+		qcom,resource-name = "ldoa";
+		qcom,resource-id = <2>;
+		qcom,regulator-type = <0>;
+		qcom,hpm-min-load = <10000>;
+		compatible = "qcom,rpm-regulator-smd-resource";
+		status = "disabled";
+
+		regulator-l2 {
+			regulator-name = "8941_l2";
+			qcom,set = <3>;
 			status = "disabled";
-
-			regulator-l2 {
-				regulator-name = "8941_l2";
-				qcom,set = <3>;
-				status = "disabled";
-				compatible = "qcom,rpm-regulator-smd";
-			};
+			compatible = "qcom,rpm-regulator-smd";
 		};
+	};
 
-		rpm-regulator-ldoa3 {
-			qcom,resource-name = "ldoa";
-			qcom,resource-id = <3>;
-			qcom,regulator-type = <0>;
-			qcom,hpm-min-load = <10000>;
-			compatible = "qcom,rpm-regulator-smd-resource";
+	rpm-regulator-ldoa3 {
+		qcom,resource-name = "ldoa";
+		qcom,resource-id = <3>;
+		qcom,regulator-type = <0>;
+		qcom,hpm-min-load = <10000>;
+		compatible = "qcom,rpm-regulator-smd-resource";
+		status = "disabled";
+
+		regulator-l3 {
+			regulator-name = "8941_l3";
+			qcom,set = <3>;
 			status = "disabled";
-
-			regulator-l3 {
-				regulator-name = "8941_l3";
-				qcom,set = <3>;
-				status = "disabled";
-				compatible = "qcom,rpm-regulator-smd";
-			};
+			compatible = "qcom,rpm-regulator-smd";
 		};
+	};
 
-		rpm-regulator-ldoa4 {
-			qcom,resource-name = "ldoa";
-			qcom,resource-id = <4>;
-			qcom,regulator-type = <0>;
-			qcom,hpm-min-load = <10000>;
-			compatible = "qcom,rpm-regulator-smd-resource";
+	rpm-regulator-ldoa4 {
+		qcom,resource-name = "ldoa";
+		qcom,resource-id = <4>;
+		qcom,regulator-type = <0>;
+		qcom,hpm-min-load = <10000>;
+		compatible = "qcom,rpm-regulator-smd-resource";
+		status = "disabled";
+
+		regulator-l4 {
+			regulator-name = "8941_l4";
+			qcom,set = <3>;
 			status = "disabled";
-
-			regulator-l4 {
-				regulator-name = "8941_l4";
-				qcom,set = <3>;
-				status = "disabled";
-				compatible = "qcom,rpm-regulator-smd";
-			};
+			compatible = "qcom,rpm-regulator-smd";
 		};
+	};
 
-		rpm-regulator-ldoa5 {
-			qcom,resource-name = "ldoa";
-			qcom,resource-id = <5>;
-			qcom,regulator-type = <0>;
-			qcom,hpm-min-load = <10000>;
-			compatible = "qcom,rpm-regulator-smd-resource";
+	rpm-regulator-ldoa5 {
+		qcom,resource-name = "ldoa";
+		qcom,resource-id = <5>;
+		qcom,regulator-type = <0>;
+		qcom,hpm-min-load = <10000>;
+		compatible = "qcom,rpm-regulator-smd-resource";
+		status = "disabled";
+
+		regulator-l5 {
+			regulator-name = "8941_l5";
+			qcom,set = <3>;
 			status = "disabled";
-
-			regulator-l5 {
-				regulator-name = "8941_l5";
-				qcom,set = <3>;
-				status = "disabled";
-				compatible = "qcom,rpm-regulator-smd";
-			};
+			compatible = "qcom,rpm-regulator-smd";
 		};
+	};
 
-		rpm-regulator-ldoa6 {
-			qcom,resource-name = "ldoa";
-			qcom,resource-id = <6>;
-			qcom,regulator-type = <0>;
-			qcom,hpm-min-load = <10000>;
-			compatible = "qcom,rpm-regulator-smd-resource";
+	rpm-regulator-ldoa6 {
+		qcom,resource-name = "ldoa";
+		qcom,resource-id = <6>;
+		qcom,regulator-type = <0>;
+		qcom,hpm-min-load = <10000>;
+		compatible = "qcom,rpm-regulator-smd-resource";
+		status = "disabled";
+
+		regulator-l6 {
+			regulator-name = "8941_l6";
+			qcom,set = <3>;
 			status = "disabled";
-
-			regulator-l6 {
-				regulator-name = "8941_l6";
-				qcom,set = <3>;
-				status = "disabled";
-				compatible = "qcom,rpm-regulator-smd";
-			};
+			compatible = "qcom,rpm-regulator-smd";
 		};
+	};
 
-		rpm-regulator-ldoa7 {
-			qcom,resource-name = "ldoa";
-			qcom,resource-id = <7>;
-			qcom,regulator-type = <0>;
-			qcom,hpm-min-load = <10000>;
-			compatible = "qcom,rpm-regulator-smd-resource";
+	rpm-regulator-ldoa7 {
+		qcom,resource-name = "ldoa";
+		qcom,resource-id = <7>;
+		qcom,regulator-type = <0>;
+		qcom,hpm-min-load = <10000>;
+		compatible = "qcom,rpm-regulator-smd-resource";
+		status = "disabled";
+
+		regulator-l7 {
+			regulator-name = "8941_l7";
+			qcom,set = <3>;
 			status = "disabled";
-
-			regulator-l7 {
-				regulator-name = "8941_l7";
-				qcom,set = <3>;
-				status = "disabled";
-				compatible = "qcom,rpm-regulator-smd";
-			};
+			compatible = "qcom,rpm-regulator-smd";
 		};
+	};
 
-		rpm-regulator-ldoa8 {
-			qcom,resource-name = "ldoa";
-			qcom,resource-id = <8>;
-			qcom,regulator-type = <0>;
-			qcom,hpm-min-load = <10000>;
-			compatible = "qcom,rpm-regulator-smd-resource";
+	rpm-regulator-ldoa8 {
+		qcom,resource-name = "ldoa";
+		qcom,resource-id = <8>;
+		qcom,regulator-type = <0>;
+		qcom,hpm-min-load = <10000>;
+		compatible = "qcom,rpm-regulator-smd-resource";
+		status = "disabled";
+
+		regulator-l8 {
+			regulator-name = "8941_l8";
+			qcom,set = <3>;
 			status = "disabled";
-
-			regulator-l8 {
-				regulator-name = "8941_l8";
-				qcom,set = <3>;
-				status = "disabled";
-				compatible = "qcom,rpm-regulator-smd";
-			};
+			compatible = "qcom,rpm-regulator-smd";
 		};
+	};
 
-		rpm-regulator-ldoa9 {
-			qcom,resource-name = "ldoa";
-			qcom,resource-id = <9>;
-			qcom,regulator-type = <0>;
-			qcom,hpm-min-load = <10000>;
-			compatible = "qcom,rpm-regulator-smd-resource";
+	rpm-regulator-ldoa9 {
+		qcom,resource-name = "ldoa";
+		qcom,resource-id = <9>;
+		qcom,regulator-type = <0>;
+		qcom,hpm-min-load = <10000>;
+		compatible = "qcom,rpm-regulator-smd-resource";
+		status = "disabled";
+
+		regulator-l9 {
+			regulator-name = "8941_l9";
+			qcom,set = <3>;
 			status = "disabled";
-
-			regulator-l9 {
-				regulator-name = "8941_l9";
-				qcom,set = <3>;
-				status = "disabled";
-				compatible = "qcom,rpm-regulator-smd";
-			};
+			compatible = "qcom,rpm-regulator-smd";
 		};
+	};
 
-		rpm-regulator-ldoa10 {
-			qcom,resource-name = "ldoa";
-			qcom,resource-id = <10>;
-			qcom,regulator-type = <0>;
-			qcom,hpm-min-load = <10000>;
-			compatible = "qcom,rpm-regulator-smd-resource";
+	rpm-regulator-ldoa10 {
+		qcom,resource-name = "ldoa";
+		qcom,resource-id = <10>;
+		qcom,regulator-type = <0>;
+		qcom,hpm-min-load = <10000>;
+		compatible = "qcom,rpm-regulator-smd-resource";
+		status = "disabled";
+
+		regulator-l10 {
+			regulator-name = "8941_l10";
+			qcom,set = <3>;
 			status = "disabled";
-
-			regulator-l10 {
-				regulator-name = "8941_l10";
-				qcom,set = <3>;
-				status = "disabled";
-				compatible = "qcom,rpm-regulator-smd";
-			};
+			compatible = "qcom,rpm-regulator-smd";
 		};
+	};
 
-		rpm-regulator-ldoa11 {
-			qcom,resource-name = "ldoa";
-			qcom,resource-id = <11>;
-			qcom,regulator-type = <0>;
-			qcom,hpm-min-load = <10000>;
-			compatible = "qcom,rpm-regulator-smd-resource";
+	rpm-regulator-ldoa11 {
+		qcom,resource-name = "ldoa";
+		qcom,resource-id = <11>;
+		qcom,regulator-type = <0>;
+		qcom,hpm-min-load = <10000>;
+		compatible = "qcom,rpm-regulator-smd-resource";
+		status = "disabled";
+
+		regulator-l11 {
+			regulator-name = "8941_l11";
+			qcom,set = <3>;
 			status = "disabled";
-
-			regulator-l11 {
-				regulator-name = "8941_l11";
-				qcom,set = <3>;
-				status = "disabled";
-				compatible = "qcom,rpm-regulator-smd";
-			};
+			compatible = "qcom,rpm-regulator-smd";
 		};
+	};
 
-		rpm-regulator-ldoa12 {
-			qcom,resource-name = "ldoa";
-			qcom,resource-id = <12>;
-			qcom,regulator-type = <0>;
-			qcom,hpm-min-load = <10000>;
-			compatible = "qcom,rpm-regulator-smd-resource";
+	rpm-regulator-ldoa12 {
+		qcom,resource-name = "ldoa";
+		qcom,resource-id = <12>;
+		qcom,regulator-type = <0>;
+		qcom,hpm-min-load = <10000>;
+		compatible = "qcom,rpm-regulator-smd-resource";
+		status = "disabled";
+
+		regulator-l12 {
+			regulator-name = "8941_l12";
+			qcom,set = <3>;
 			status = "disabled";
-
-			regulator-l12 {
-				regulator-name = "8941_l12";
-				qcom,set = <3>;
-				status = "disabled";
-				compatible = "qcom,rpm-regulator-smd";
-			};
+			compatible = "qcom,rpm-regulator-smd";
 		};
+	};
 
-		rpm-regulator-ldoa13 {
-			qcom,resource-name = "ldoa";
-			qcom,resource-id = <13>;
-			qcom,regulator-type = <0>;
-			qcom,hpm-min-load = <10000>;
-			compatible = "qcom,rpm-regulator-smd-resource";
+	rpm-regulator-ldoa13 {
+		qcom,resource-name = "ldoa";
+		qcom,resource-id = <13>;
+		qcom,regulator-type = <0>;
+		qcom,hpm-min-load = <10000>;
+		compatible = "qcom,rpm-regulator-smd-resource";
+		status = "disabled";
+
+		regulator-l13 {
+			regulator-name = "8941_l13";
+			qcom,set = <3>;
 			status = "disabled";
-
-			regulator-l13 {
-				regulator-name = "8941_l13";
-				qcom,set = <3>;
-				status = "disabled";
-				compatible = "qcom,rpm-regulator-smd";
-			};
+			compatible = "qcom,rpm-regulator-smd";
 		};
+	};
 
-		rpm-regulator-ldoa14 {
-			qcom,resource-name = "ldoa";
-			qcom,resource-id = <14>;
-			qcom,regulator-type = <0>;
-			qcom,hpm-min-load = <10000>;
-			compatible = "qcom,rpm-regulator-smd-resource";
+	rpm-regulator-ldoa14 {
+		qcom,resource-name = "ldoa";
+		qcom,resource-id = <14>;
+		qcom,regulator-type = <0>;
+		qcom,hpm-min-load = <10000>;
+		compatible = "qcom,rpm-regulator-smd-resource";
+		status = "disabled";
+
+		regulator-l14 {
+			regulator-name = "8941_l14";
+			qcom,set = <3>;
 			status = "disabled";
-
-			regulator-l14 {
-				regulator-name = "8941_l14";
-				qcom,set = <3>;
-				status = "disabled";
-				compatible = "qcom,rpm-regulator-smd";
-			};
+			compatible = "qcom,rpm-regulator-smd";
 		};
+	};
 
-		rpm-regulator-ldoa15 {
-			qcom,resource-name = "ldoa";
-			qcom,resource-id = <15>;
-			qcom,regulator-type = <0>;
-			qcom,hpm-min-load = <10000>;
-			compatible = "qcom,rpm-regulator-smd-resource";
+	rpm-regulator-ldoa15 {
+		qcom,resource-name = "ldoa";
+		qcom,resource-id = <15>;
+		qcom,regulator-type = <0>;
+		qcom,hpm-min-load = <10000>;
+		compatible = "qcom,rpm-regulator-smd-resource";
+		status = "disabled";
+
+		regulator-l15 {
+			regulator-name = "8941_l15";
+			qcom,set = <3>;
 			status = "disabled";
-
-			regulator-l15 {
-				regulator-name = "8941_l15";
-				qcom,set = <3>;
-				status = "disabled";
-				compatible = "qcom,rpm-regulator-smd";
-			};
+			compatible = "qcom,rpm-regulator-smd";
 		};
+	};
 
-		rpm-regulator-ldoa16 {
-			qcom,resource-name = "ldoa";
-			qcom,resource-id = <16>;
-			qcom,regulator-type = <0>;
-			qcom,hpm-min-load = <10000>;
-			compatible = "qcom,rpm-regulator-smd-resource";
+	rpm-regulator-ldoa16 {
+		qcom,resource-name = "ldoa";
+		qcom,resource-id = <16>;
+		qcom,regulator-type = <0>;
+		qcom,hpm-min-load = <10000>;
+		compatible = "qcom,rpm-regulator-smd-resource";
+		status = "disabled";
+
+		regulator-l16 {
+			regulator-name = "8941_l16";
+			qcom,set = <3>;
 			status = "disabled";
-
-			regulator-l16 {
-				regulator-name = "8941_l16";
-				qcom,set = <3>;
-				status = "disabled";
-				compatible = "qcom,rpm-regulator-smd";
-			};
+			compatible = "qcom,rpm-regulator-smd";
 		};
+	};
 
-		rpm-regulator-ldoa17 {
-			qcom,resource-name = "ldoa";
-			qcom,resource-id = <17>;
-			qcom,regulator-type = <0>;
-			qcom,hpm-min-load = <10000>;
-			compatible = "qcom,rpm-regulator-smd-resource";
+	rpm-regulator-ldoa17 {
+		qcom,resource-name = "ldoa";
+		qcom,resource-id = <17>;
+		qcom,regulator-type = <0>;
+		qcom,hpm-min-load = <10000>;
+		compatible = "qcom,rpm-regulator-smd-resource";
+		status = "disabled";
+
+		regulator-l17 {
+			regulator-name = "8941_l17";
+			qcom,set = <3>;
 			status = "disabled";
-
-			regulator-l17 {
-				regulator-name = "8941_l17";
-				qcom,set = <3>;
-				status = "disabled";
-				compatible = "qcom,rpm-regulator-smd";
-			};
+			compatible = "qcom,rpm-regulator-smd";
 		};
+	};
 
-		rpm-regulator-ldoa18 {
-			qcom,resource-name = "ldoa";
-			qcom,resource-id = <18>;
-			qcom,regulator-type = <0>;
-			qcom,hpm-min-load = <10000>;
-			compatible = "qcom,rpm-regulator-smd-resource";
+	rpm-regulator-ldoa18 {
+		qcom,resource-name = "ldoa";
+		qcom,resource-id = <18>;
+		qcom,regulator-type = <0>;
+		qcom,hpm-min-load = <10000>;
+		compatible = "qcom,rpm-regulator-smd-resource";
+		status = "disabled";
+
+		regulator-l18 {
+			regulator-name = "8941_l18";
+			qcom,set = <3>;
 			status = "disabled";
-
-			regulator-l18 {
-				regulator-name = "8941_l18";
-				qcom,set = <3>;
-				status = "disabled";
-				compatible = "qcom,rpm-regulator-smd";
-			};
+			compatible = "qcom,rpm-regulator-smd";
 		};
+	};
 
-		rpm-regulator-ldoa19 {
-			qcom,resource-name = "ldoa";
-			qcom,resource-id = <19>;
-			qcom,regulator-type = <0>;
-			qcom,hpm-min-load = <10000>;
-			compatible = "qcom,rpm-regulator-smd-resource";
+	rpm-regulator-ldoa19 {
+		qcom,resource-name = "ldoa";
+		qcom,resource-id = <19>;
+		qcom,regulator-type = <0>;
+		qcom,hpm-min-load = <10000>;
+		compatible = "qcom,rpm-regulator-smd-resource";
+		status = "disabled";
+
+		regulator-l19 {
+			regulator-name = "8941_l19";
+			qcom,set = <3>;
 			status = "disabled";
-
-			regulator-l19 {
-				regulator-name = "8941_l19";
-				qcom,set = <3>;
-				status = "disabled";
-				compatible = "qcom,rpm-regulator-smd";
-			};
+			compatible = "qcom,rpm-regulator-smd";
 		};
+	};
 
-		rpm-regulator-ldoa20 {
-			qcom,resource-name = "ldoa";
-			qcom,resource-id = <20>;
-			qcom,regulator-type = <0>;
-			qcom,hpm-min-load = <10000>;
-			compatible = "qcom,rpm-regulator-smd-resource";
+	rpm-regulator-ldoa20 {
+		qcom,resource-name = "ldoa";
+		qcom,resource-id = <20>;
+		qcom,regulator-type = <0>;
+		qcom,hpm-min-load = <10000>;
+		compatible = "qcom,rpm-regulator-smd-resource";
+		status = "disabled";
+
+		regulator-l20 {
+			regulator-name = "8941_l20";
+			qcom,set = <3>;
 			status = "disabled";
-
-			regulator-l20 {
-				regulator-name = "8941_l20";
-				qcom,set = <3>;
-				status = "disabled";
-				compatible = "qcom,rpm-regulator-smd";
-			};
+			compatible = "qcom,rpm-regulator-smd";
 		};
+	};
 
-		rpm-regulator-ldoa21 {
-			qcom,resource-name = "ldoa";
-			qcom,resource-id = <21>;
-			qcom,regulator-type = <0>;
-			qcom,hpm-min-load = <10000>;
-			compatible = "qcom,rpm-regulator-smd-resource";
+	rpm-regulator-ldoa21 {
+		qcom,resource-name = "ldoa";
+		qcom,resource-id = <21>;
+		qcom,regulator-type = <0>;
+		qcom,hpm-min-load = <10000>;
+		compatible = "qcom,rpm-regulator-smd-resource";
+		status = "disabled";
+
+		regulator-l21 {
+			regulator-name = "8941_l21";
+			qcom,set = <3>;
 			status = "disabled";
-
-			regulator-l21 {
-				regulator-name = "8941_l21";
-				qcom,set = <3>;
-				status = "disabled";
-				compatible = "qcom,rpm-regulator-smd";
-			};
+			compatible = "qcom,rpm-regulator-smd";
 		};
+	};
 
-		rpm-regulator-ldoa22 {
-			qcom,resource-name = "ldoa";
-			qcom,resource-id = <22>;
-			qcom,regulator-type = <0>;
-			qcom,hpm-min-load = <10000>;
-			compatible = "qcom,rpm-regulator-smd-resource";
+	rpm-regulator-ldoa22 {
+		qcom,resource-name = "ldoa";
+		qcom,resource-id = <22>;
+		qcom,regulator-type = <0>;
+		qcom,hpm-min-load = <10000>;
+		compatible = "qcom,rpm-regulator-smd-resource";
+		status = "disabled";
+
+		regulator-l22 {
+			regulator-name = "8941_l22";
+			qcom,set = <3>;
 			status = "disabled";
-
-			regulator-l22 {
-				regulator-name = "8941_l22";
-				qcom,set = <3>;
-				status = "disabled";
-				compatible = "qcom,rpm-regulator-smd";
-			};
+			compatible = "qcom,rpm-regulator-smd";
 		};
+	};
 
-		rpm-regulator-ldoa23 {
-			qcom,resource-name = "ldoa";
-			qcom,resource-id = <23>;
-			qcom,regulator-type = <0>;
-			qcom,hpm-min-load = <10000>;
-			compatible = "qcom,rpm-regulator-smd-resource";
+	rpm-regulator-ldoa23 {
+		qcom,resource-name = "ldoa";
+		qcom,resource-id = <23>;
+		qcom,regulator-type = <0>;
+		qcom,hpm-min-load = <10000>;
+		compatible = "qcom,rpm-regulator-smd-resource";
+		status = "disabled";
+
+		regulator-l23 {
+			regulator-name = "8941_l23";
+			qcom,set = <3>;
 			status = "disabled";
-
-			regulator-l23 {
-				regulator-name = "8941_l23";
-				qcom,set = <3>;
-				status = "disabled";
-				compatible = "qcom,rpm-regulator-smd";
-			};
+			compatible = "qcom,rpm-regulator-smd";
 		};
+	};
 
-		rpm-regulator-ldoa24 {
-			qcom,resource-name = "ldoa";
-			qcom,resource-id = <24>;
-			qcom,regulator-type = <0>;
-			qcom,hpm-min-load = <10000>;
-			compatible = "qcom,rpm-regulator-smd-resource";
+	rpm-regulator-ldoa24 {
+		qcom,resource-name = "ldoa";
+		qcom,resource-id = <24>;
+		qcom,regulator-type = <0>;
+		qcom,hpm-min-load = <10000>;
+		compatible = "qcom,rpm-regulator-smd-resource";
+		status = "disabled";
+
+		regulator-l24 {
+			regulator-name = "8941_l24";
+			qcom,set = <3>;
 			status = "disabled";
-
-			regulator-l24 {
-				regulator-name = "8941_l24";
-				qcom,set = <3>;
-				status = "disabled";
-				compatible = "qcom,rpm-regulator-smd";
-			};
+			compatible = "qcom,rpm-regulator-smd";
 		};
+	};
 
-		/* TODO: find out correct resource names for LVS vs MVS */
-		rpm-regulator-vsa1 {
-			qcom,resource-name = "vsa";
-			qcom,resource-id = <1>;
-			qcom,regulator-type = <2>;
-			compatible = "qcom,rpm-regulator-smd-resource";
+	/* TODO: find out correct resource names for LVS vs MVS */
+	rpm-regulator-vsa1 {
+		qcom,resource-name = "vsa";
+		qcom,resource-id = <1>;
+		qcom,regulator-type = <2>;
+		compatible = "qcom,rpm-regulator-smd-resource";
+		status = "disabled";
+
+		regulator-lvs1 {
+			regulator-name = "8941_lvs1";
+			qcom,set = <3>;
 			status = "disabled";
-
-			regulator-lvs1 {
-				regulator-name = "8941_lvs1";
-				qcom,set = <3>;
-				status = "disabled";
-				compatible = "qcom,rpm-regulator-smd";
-			};
+			compatible = "qcom,rpm-regulator-smd";
 		};
+	};
 
-		rpm-regulator-vsa2 {
-			qcom,resource-name = "vsa";
-			qcom,resource-id = <2>;
-			qcom,regulator-type = <2>;
-			compatible = "qcom,rpm-regulator-smd-resource";
+	rpm-regulator-vsa2 {
+		qcom,resource-name = "vsa";
+		qcom,resource-id = <2>;
+		qcom,regulator-type = <2>;
+		compatible = "qcom,rpm-regulator-smd-resource";
+		status = "disabled";
+
+		regulator-lvs2 {
+			regulator-name = "8941_lvs2";
+			qcom,set = <3>;
 			status = "disabled";
-
-			regulator-lvs2 {
-				regulator-name = "8941_lvs2";
-				qcom,set = <3>;
-				status = "disabled";
-				compatible = "qcom,rpm-regulator-smd";
-			};
+			compatible = "qcom,rpm-regulator-smd";
 		};
+	};
 
-		rpm-regulator-vsa3 {
-			qcom,resource-name = "vsa";
-			qcom,resource-id = <3>;
-			qcom,regulator-type = <2>;
-			compatible = "qcom,rpm-regulator-smd-resource";
+	rpm-regulator-vsa3 {
+		qcom,resource-name = "vsa";
+		qcom,resource-id = <3>;
+		qcom,regulator-type = <2>;
+		compatible = "qcom,rpm-regulator-smd-resource";
+		status = "disabled";
+
+		regulator-lvs3 {
+			regulator-name = "8941_lvs3";
+			qcom,set = <3>;
 			status = "disabled";
-
-			regulator-lvs3 {
-				regulator-name = "8941_lvs3";
-				qcom,set = <3>;
-				status = "disabled";
-				compatible = "qcom,rpm-regulator-smd";
-			};
+			compatible = "qcom,rpm-regulator-smd";
 		};
+	};
 
-		rpm-regulator-vsa4 {
-			qcom,resource-name = "vsa";
-			qcom,resource-id = <4>;
-			qcom,regulator-type = <2>;
-			compatible = "qcom,rpm-regulator-smd-resource";
+	rpm-regulator-vsa4 {
+		qcom,resource-name = "vsa";
+		qcom,resource-id = <4>;
+		qcom,regulator-type = <2>;
+		compatible = "qcom,rpm-regulator-smd-resource";
+		status = "disabled";
+
+		regulator-mvs1 {
+			regulator-name = "8941_mvs1";
+			qcom,set = <3>;
 			status = "disabled";
-
-			regulator-mvs1 {
-				regulator-name = "8941_mvs1";
-				qcom,set = <3>;
-				status = "disabled";
-				compatible = "qcom,rpm-regulator-smd";
-			};
+			compatible = "qcom,rpm-regulator-smd";
 		};
+	};
 
-		rpm-regulator-vsa5 {
-			qcom,resource-name = "vsa";
-			qcom,resource-id = <5>;
-			qcom,regulator-type = <2>;
-			compatible = "qcom,rpm-regulator-smd-resource";
+	rpm-regulator-vsa5 {
+		qcom,resource-name = "vsa";
+		qcom,resource-id = <5>;
+		qcom,regulator-type = <2>;
+		compatible = "qcom,rpm-regulator-smd-resource";
+		status = "disabled";
+
+		regulator-mvs2 {
+			regulator-name = "8941_mvs2";
+			qcom,set = <3>;
 			status = "disabled";
-
-			regulator-mvs2 {
-				regulator-name = "8941_mvs2";
-				qcom,set = <3>;
-				status = "disabled";
-				compatible = "qcom,rpm-regulator-smd";
-			};
+			compatible = "qcom,rpm-regulator-smd";
 		};
 	};
 };
diff --git a/arch/arm/boot/dts/msm8974-gpio.dtsi b/arch/arm/boot/dts/msm8974-gpio.dtsi
index 59ad8db..323fac4 100644
--- a/arch/arm/boot/dts/msm8974-gpio.dtsi
+++ b/arch/arm/boot/dts/msm8974-gpio.dtsi
@@ -10,225 +10,223 @@
  * GNU General Public License for more details.
  */
 
-/ {
-	qcom,spmi@fc4c0000 {
+&spmi_bus {
 
-		qcom,pm8941@0 {
+	qcom,pm8941@0 {
 
-			pm8941_gpios: pm8941_gpios {
+		pm8941_gpios: pm8941_gpios {
 
-				gpio@c000 {
-					status = "ok";
-				};
-
-				gpio@c100 {
-					status = "ok";
-				};
-
-				gpio@c200 {
-					status = "ok";
-				};
-
-				gpio@c300 {
-					status = "ok";
-				};
-
-				gpio@c400 {
-					status = "ok";
-				};
-
-				gpio@c500 {
-					status = "ok";
-				};
-
-				gpio@c600 {
-					status = "ok";
-				};
-
-				gpio@c700 {
-					status = "ok";
-				};
-
-				gpio@c800 {
-					status = "ok";
-				};
-
-				gpio@c900 {
-					status = "ok";
-				};
-
-				gpio@ca00 {
-					status = "ok";
-				};
-
-				gpio@cb00 {
-					status = "ok";
-				};
-
-				gpio@cc00 {
-					status = "ok";
-				};
-
-				gpio@cd00 {
-					status = "ok";
-				};
-
-				gpio@ce00 {
-					status = "ok";
-				};
-
-				gpio@cf00 {
-					status = "ok";
-				};
-
-				gpio@d000 {
-					status = "ok";
-				};
-
-				gpio@d100 {
-					status = "ok";
-				};
-
-				gpio@d200 {
-					status = "ok";
-				};
-
-				gpio@d300 {
-					status = "ok";
-				};
-
-				gpio@d400 {
-					status = "ok";
-				};
-
-				gpio@d500 {
-					status = "ok";
-				};
-
-				gpio@d600 {
-					status = "ok";
-				};
-
-				gpio@d700 {
-					status = "ok";
-				};
-
-				gpio@d800 {
-					qcom,out-strength = <1>;
-					status = "ok";
-				};
-
-				gpio@d900 {
-					qcom,out-strength = <1>;
-					status = "ok";
-				};
-
-				gpio@da00 {
-					qcom,out-strength = <1>;
-					status = "ok";
-				};
-
-				gpio@db00 {
-					qcom,out-strength = <1>;
-					status = "ok";
-				};
-
-				gpio@dc00 {
-					qcom,out-strength = <1>;
-					status = "ok";
-				};
-
-				gpio@dd00 {
-					qcom,out-strength = <1>;
-					status = "ok";
-				};
-
-				gpio@de00 {
-					qcom,out-strength = <1>;
-					status = "ok";
-				};
-
-				gpio@df00 {
-					qcom,out-strength = <1>;
-					status = "ok";
-				};
-
-				gpio@e000 {
-					qcom,out-strength = <1>;
-					status = "ok";
-				};
-
-				gpio@e100 {
-					qcom,out-strength = <1>;
-					status = "ok";
-				};
-
-				gpio@e200 {
-					qcom,out-strength = <1>;
-					status = "ok";
-				};
-
-				gpio@e300 {
-					qcom,out-strength = <1>;
-					status = "ok";
-				};
+			gpio@c000 {
+				status = "ok";
 			};
 
-			pm8941_mpps: pm8941_mpps {
+			gpio@c100 {
+				status = "ok";
+			};
 
-				mpp@a000 {
-					status = "ok";
-				};
+			gpio@c200 {
+				status = "ok";
+			};
 
-				mpp@a100 {
-					status = "ok";
-				};
+			gpio@c300 {
+				status = "ok";
+			};
 
-				mpp@a200 {
-					status = "ok";
-				};
+			gpio@c400 {
+				status = "ok";
+			};
 
-				mpp@a300 {
-					status = "ok";
-				};
+			gpio@c500 {
+				status = "ok";
+			};
 
-				mpp@a400 {
-					status = "ok";
-				};
+			gpio@c600 {
+				status = "ok";
+			};
 
-				mpp@a500 {
-					status = "ok";
-				};
+			gpio@c700 {
+				status = "ok";
+			};
 
-				mpp@a600 {
-					status = "ok";
-				};
+			gpio@c800 {
+				status = "ok";
+			};
 
-				mpp@a700 {
-					status = "ok";
-				};
+			gpio@c900 {
+				status = "ok";
+			};
+
+			gpio@ca00 {
+				status = "ok";
+			};
+
+			gpio@cb00 {
+				status = "ok";
+			};
+
+			gpio@cc00 {
+				status = "ok";
+			};
+
+			gpio@cd00 {
+				status = "ok";
+			};
+
+			gpio@ce00 {
+				status = "ok";
+			};
+
+			gpio@cf00 {
+				status = "ok";
+			};
+
+			gpio@d000 {
+				status = "ok";
+			};
+
+			gpio@d100 {
+				status = "ok";
+			};
+
+			gpio@d200 {
+				status = "ok";
+			};
+
+			gpio@d300 {
+				status = "ok";
+			};
+
+			gpio@d400 {
+				status = "ok";
+			};
+
+			gpio@d500 {
+				status = "ok";
+			};
+
+			gpio@d600 {
+				status = "ok";
+			};
+
+			gpio@d700 {
+				status = "ok";
+			};
+
+			gpio@d800 {
+				qcom,out-strength = <1>;
+				status = "ok";
+			};
+
+			gpio@d900 {
+				qcom,out-strength = <1>;
+				status = "ok";
+			};
+
+			gpio@da00 {
+				qcom,out-strength = <1>;
+				status = "ok";
+			};
+
+			gpio@db00 {
+				qcom,out-strength = <1>;
+				status = "ok";
+			};
+
+			gpio@dc00 {
+				qcom,out-strength = <1>;
+				status = "ok";
+			};
+
+			gpio@dd00 {
+				qcom,out-strength = <1>;
+				status = "ok";
+			};
+
+			gpio@de00 {
+				qcom,out-strength = <1>;
+				status = "ok";
+			};
+
+			gpio@df00 {
+				qcom,out-strength = <1>;
+				status = "ok";
+			};
+
+			gpio@e000 {
+				qcom,out-strength = <1>;
+				status = "ok";
+			};
+
+			gpio@e100 {
+				qcom,out-strength = <1>;
+				status = "ok";
+			};
+
+			gpio@e200 {
+				qcom,out-strength = <1>;
+				status = "ok";
+			};
+
+			gpio@e300 {
+				qcom,out-strength = <1>;
+				status = "ok";
 			};
 		};
 
-		qcom,pm8841@4 {
+		pm8941_mpps: pm8941_mpps {
 
-			pm8841_mpps: pm8841_mpps {
+			mpp@a000 {
+				status = "ok";
+			};
 
-				mpp@a000 {
-					status = "ok";
-				};
+			mpp@a100 {
+				status = "ok";
+			};
 
-				mpp@a100 {
-					status = "ok";
-				};
+			mpp@a200 {
+				status = "ok";
+			};
 
-				mpp@a200 {
-					status = "ok";
-				};
+			mpp@a300 {
+				status = "ok";
+			};
 
-				mpp@a300 {
-					status = "ok";
-				};
+			mpp@a400 {
+				status = "ok";
+			};
+
+			mpp@a500 {
+				status = "ok";
+			};
+
+			mpp@a600 {
+				status = "ok";
+			};
+
+			mpp@a700 {
+				status = "ok";
+			};
+		};
+	};
+
+	qcom,pm8841@4 {
+
+		pm8841_mpps: pm8841_mpps {
+
+			mpp@a000 {
+				status = "ok";
+			};
+
+			mpp@a100 {
+				status = "ok";
+			};
+
+			mpp@a200 {
+				status = "ok";
+			};
+
+			mpp@a300 {
+				status = "ok";
 			};
 		};
 	};
diff --git a/arch/arm/boot/dts/msm8974-iommu.dtsi b/arch/arm/boot/dts/msm8974-iommu.dtsi
index e1a0a9b..a115fd8 100755
--- a/arch/arm/boot/dts/msm8974-iommu.dtsi
+++ b/arch/arm/boot/dts/msm8974-iommu.dtsi
@@ -18,6 +18,7 @@
 		ranges;
 		reg = <0xfda64000 0x10000>;
 		vdd-supply = <&gdsc_jpeg>;
+		qcom,iommu-smt-size = <16>;
 
 		qcom,iommu-ctx@fda6c000 {
 			reg = <0xfda6c000 0x1000>;
@@ -46,6 +47,7 @@
 		ranges;
 		reg = <0xfd928000 0x10000>;
 		vdd-supply = <&gdsc_mdss>;
+		qcom,iommu-smt-size = <16>;
 
 		qcom,iommu-ctx@fd930000 {
 			reg = <0xfd930000 0x1000>;
@@ -68,6 +70,7 @@
 		ranges;
 		reg = <0xfdc84000 0x10000>;
 		vdd-supply = <&gdsc_venus>;
+		qcom,iommu-smt-size = <16>;
 
 		qcom,iommu-ctx@fdc8c000 {
 			reg = <0xfdc8c000 0x1000>;
diff --git a/arch/arm/boot/dts/msm8974-regulator.dtsi b/arch/arm/boot/dts/msm8974-regulator.dtsi
index 7b3893e..f0c635e 100644
--- a/arch/arm/boot/dts/msm8974-regulator.dtsi
+++ b/arch/arm/boot/dts/msm8974-regulator.dtsi
@@ -10,474 +10,474 @@
  * GNU General Public License for more details.
  */
 
-/ {
 
 /* QPNP controlled regulators: */
 
-	qcom,spmi@fc4c0000 {
+&spmi_bus {
 
-		qcom,pm8941@1 {
+	qcom,pm8941@1 {
 
-			pm8941_boost: regulator@a000 {
-				regulator-min-microvolt = <5000000>;
-				regulator-max-microvolt = <5000000>;
-				qcom,enable-time = <500>;
-				status = "okay";
-			};
-
-			pm8941_mvs1: regulator@8300 {
-				parent-supply = <&pm8941_boost>;
-				qcom,enable-time = <200>;
-				qcom,pull-down-enable = <1>;
-				status = "okay";
-			};
-
-			pm8941_mvs2: regulator@8400 {
-				parent-supply = <&pm8941_boost>;
-				qcom,enable-time = <200>;
-				qcom,pull-down-enable = <1>;
-				status = "okay";
-			};
+		pm8941_boost: regulator@a000 {
+			regulator-min-microvolt = <5000000>;
+			regulator-max-microvolt = <5000000>;
+			qcom,enable-time = <500>;
+			status = "okay";
 		};
 
-		qcom,pm8841@5 {
+		pm8941_mvs1: regulator@8300 {
+			parent-supply = <&pm8941_boost>;
+			qcom,enable-time = <200>;
+			qcom,pull-down-enable = <1>;
+			status = "okay";
+		};
 
-			pm8841_s5: regulator@2000 {
-				regulator-min-microvolt = <850000>;
-				regulator-max-microvolt = <1100000>;
-				qcom,enable-time = <500>;
-				qcom,pull-down-enable = <1>;
-				regulator-always-on;
-				status = "okay";
-			};
-
-			pm8841_s6: regulator@2300 {
-				regulator-min-microvolt = <850000>;
-				regulator-max-microvolt = <1100000>;
-				qcom,enable-time = <500>;
-				qcom,pull-down-enable = <1>;
-				status = "okay";
-			};
-
-			pm8841_s7: regulator@2600 {
-				regulator-min-microvolt = <850000>;
-				regulator-max-microvolt = <1100000>;
-				qcom,enable-time = <500>;
-				qcom,pull-down-enable = <1>;
-				status = "okay";
-			};
-
-			pm8841_s8: regulator@2900 {
-				regulator-min-microvolt = <850000>;
-				regulator-max-microvolt = <1100000>;
-				qcom,enable-time = <500>;
-				qcom,pull-down-enable = <1>;
-				status = "okay";
-			};
+		pm8941_mvs2: regulator@8400 {
+			parent-supply = <&pm8941_boost>;
+			qcom,enable-time = <200>;
+			qcom,pull-down-enable = <1>;
+			status = "okay";
 		};
 	};
 
+	qcom,pm8841@5 {
+
+		pm8841_s5: regulator@2000 {
+			regulator-min-microvolt = <850000>;
+			regulator-max-microvolt = <1100000>;
+			qcom,enable-time = <500>;
+			qcom,pull-down-enable = <1>;
+			regulator-always-on;
+			status = "okay";
+		};
+
+		pm8841_s6: regulator@2300 {
+			regulator-min-microvolt = <850000>;
+			regulator-max-microvolt = <1100000>;
+			qcom,enable-time = <500>;
+			qcom,pull-down-enable = <1>;
+			status = "okay";
+		};
+
+		pm8841_s7: regulator@2600 {
+			regulator-min-microvolt = <850000>;
+			regulator-max-microvolt = <1100000>;
+			qcom,enable-time = <500>;
+			qcom,pull-down-enable = <1>;
+			status = "okay";
+		};
+
+		pm8841_s8: regulator@2900 {
+			regulator-min-microvolt = <850000>;
+			regulator-max-microvolt = <1100000>;
+			qcom,enable-time = <500>;
+			qcom,pull-down-enable = <1>;
+			status = "okay";
+		};
+	};
+};
+
 
 /* RPM controlled regulators: */
 
-	qcom,rpm-smd {
-		rpm-regulator-smpb1 {
+&rpm_bus {
+	rpm-regulator-smpb1 {
+		status = "okay";
+		pm8841_s1: regulator-s1 {
+			regulator-min-microvolt = <675000>;
+			regulator-max-microvolt = <1050000>;
 			status = "okay";
-			pm8841_s1: regulator-s1 {
-				regulator-min-microvolt = <675000>;
-				regulator-max-microvolt = <1050000>;
-				status = "okay";
-			};
-			pm8841_s1_ao: regulator-s1-ao {
-				regulator-name = "8841_s1_ao";
-				qcom,set = <1>;
-				regulator-min-microvolt = <675000>;
-				regulator-max-microvolt = <1050000>;
-				status = "okay";
-				compatible = "qcom,rpm-regulator-smd";
-			};
 		};
-
-		rpm-regulator-smpb2 {
+		pm8841_s1_ao: regulator-s1-ao {
+			regulator-name = "8841_s1_ao";
+			qcom,set = <1>;
+			regulator-min-microvolt = <675000>;
+			regulator-max-microvolt = <1050000>;
 			status = "okay";
-			qcom,allow-atomic = <1>;
-			pm8841_s2: regulator-s2 {
-				regulator-min-microvolt = <500000>;
-				regulator-max-microvolt = <1050000>;
-				status = "okay";
-			};
-			pm8841_s2_corner: regulator-s2-corner {
-				regulator-name = "8841_s2_corner";
-				qcom,set = <3>;
-				regulator-min-microvolt = <1>;
-				regulator-max-microvolt = <6>;
-				qcom,use-voltage-corner;
-				compatible = "qcom,rpm-regulator-smd";
-				qcom,consumer-supplies = "vdd_dig", "";
-			};
-			pm8841_s2_corner_ao: regulator-s2-corner-ao {
-				regulator-name = "8841_s2_corner_ao";
-				qcom,set = <1>;
-				regulator-min-microvolt = <1>;
-				regulator-max-microvolt = <6>;
-				qcom,use-voltage-corner;
-				compatible = "qcom,rpm-regulator-smd";
-			};
-		};
-
-		rpm-regulator-smpb3 {
-			status = "okay";
-			pm8841_s3: regulator-s3 {
-				regulator-min-microvolt = <1150000>;
-				regulator-max-microvolt = <1150000>;
-				qcom,init-voltage = <1150000>;
-				status = "okay";
-			};
-		};
-
-		rpm-regulator-smpb4 {
-			status = "okay";
-			pm8841_s4: regulator-s4 {
-				regulator-min-microvolt = <900000>;
-				regulator-max-microvolt = <900000>;
-				qcom,init-voltage = <900000>;
-				status = "okay";
-			};
-		};
-
-		rpm-regulator-smpa1 {
-			status = "okay";
-			pm8941_s1: regulator-s1 {
-				regulator-min-microvolt = <1300000>;
-				regulator-max-microvolt = <1300000>;
-				qcom,init-voltage = <1300000>;
-				qcom,init-current = <100>;
-				qcom,system-load = <100000>;
-				regulator-always-on;
-				status = "okay";
-			};
-		};
-
-		rpm-regulator-smpa2 {
-			status = "okay";
-			qcom,allow-atomic = <1>;
-			pm8941_s2: regulator-s2 {
-				regulator-min-microvolt = <2150000>;
-				regulator-max-microvolt = <2150000>;
-				qcom,init-voltage = <2150000>;
-				status = "okay";
-			};
-			pm8941_s2_ao: regulator-s2-ao {
-				regulator-name = "8941_s2_ao";
-				qcom,set = <1>;
-				regulator-min-microvolt = <2150000>;
-				regulator-max-microvolt = <2150000>;
-				status = "okay";
-				compatible = "qcom,rpm-regulator-smd";
-			};
-		};
-
-		rpm-regulator-smpa3 {
-			status = "okay";
-			pm8941_s3: regulator-s3 {
-				regulator-min-microvolt = <1800000>;
-				regulator-max-microvolt = <1800000>;
-				qcom,init-voltage = <1800000>;
-				qcom,init-current = <100>;
-				qcom,system-load = <100000>;
-				regulator-always-on;
-				status = "okay";
-			};
-		};
-
-		rpm-regulator-ldoa1 {
-			status = "okay";
-			pm8941_l1: regulator-l1 {
-				parent-supply = <&pm8941_s1>;
-				regulator-min-microvolt = <1225000>;
-				regulator-max-microvolt = <1225000>;
-				qcom,init-voltage = <1225000>;
-				qcom,init-current = <10>;
-				qcom,system-load = <10000>;
-				regulator-always-on;
-				status = "okay";
-			};
-		};
-
-		rpm-regulator-ldoa2 {
-			status = "okay";
-			pm8941_l2: regulator-l2 {
-				parent-supply = <&pm8941_s3>;
-				regulator-min-microvolt = <1200000>;
-				regulator-max-microvolt = <1200000>;
-				qcom,init-voltage = <1200000>;
-				status = "okay";
-			};
-		};
-
-		rpm-regulator-ldoa3 {
-			status = "okay";
-			pm8941_l3: regulator-l3 {
-				parent-supply = <&pm8941_s1>;
-				regulator-min-microvolt = <1200000>;
-				regulator-max-microvolt = <1200000>;
-				qcom,init-voltage = <1200000>;
-				status = "okay";
-			};
-		};
-
-		rpm-regulator-ldoa4 {
-			status = "okay";
-			pm8941_l4: regulator-l4 {
-				parent-supply = <&pm8941_s1>;
-				regulator-min-microvolt = <1150000>;
-				regulator-max-microvolt = <1150000>;
-				qcom,init-voltage = <1150000>;
-				status = "okay";
-			};
-		};
-
-		rpm-regulator-ldoa5 {
-			status = "okay";
-			pm8941_l5: regulator-l5 {
-				parent-supply = <&pm8941_s2>;
-				regulator-min-microvolt = <1800000>;
-				regulator-max-microvolt = <1800000>;
-				qcom,init-voltage = <1800000>;
-				status = "okay";
-			};
-		};
-
-		rpm-regulator-ldoa6 {
-			status = "okay";
-			pm8941_l6: regulator-l6 {
-				parent-supply = <&pm8941_s2>;
-				regulator-min-microvolt = <1800000>;
-				regulator-max-microvolt = <1800000>;
-				qcom,init-voltage = <1800000>;
-				status = "okay";
-			};
-		};
-
-		rpm-regulator-ldoa7 {
-			status = "okay";
-			pm8941_l7: regulator-l7 {
-				parent-supply = <&pm8941_s2>;
-				regulator-min-microvolt = <1800000>;
-				regulator-max-microvolt = <1800000>;
-				qcom,init-voltage = <1800000>;
-				status = "okay";
-			};
-		};
-
-		rpm-regulator-ldoa8 {
-			status = "okay";
-			pm8941_l8: regulator-l8 {
-				regulator-min-microvolt = <1800000>;
-				regulator-max-microvolt = <1800000>;
-				qcom,init-voltage = <1800000>;
-				status = "okay";
-			};
-		};
-
-		rpm-regulator-ldoa9 {
-			status = "okay";
-			pm8941_l9: regulator-l9 {
-				regulator-min-microvolt = <1800000>;
-				regulator-max-microvolt = <2950000>;
-				qcom,init-voltage = <2950000>;
-				status = "okay";
-			};
-		};
-
-		rpm-regulator-ldoa10 {
-			status = "okay";
-			pm8941_l10: regulator-l10 {
-				regulator-min-microvolt = <1800000>;
-				regulator-max-microvolt = <2950000>;
-				qcom,init-voltage = <2950000>;
-				status = "okay";
-			};
-		};
-
-		rpm-regulator-ldoa11 {
-			status = "okay";
-			pm8941_l11: regulator-l11 {
-				parent-supply = <&pm8941_s1>;
-				regulator-min-microvolt = <1250000>;
-				regulator-max-microvolt = <1250000>;
-				qcom,init-voltage = <1250000>;
-				status = "okay";
-			};
-		};
-
-		rpm-regulator-ldoa12 {
-			status = "okay";
-			qcom,allow-atomic = <1>;
-			pm8941_l12: regulator-l12 {
-				parent-supply = <&pm8941_s2>;
-				regulator-min-microvolt = <1800000>;
-				regulator-max-microvolt = <1800000>;
-				status = "okay";
-			};
-			pm8941_l12_ao: regulator-l12-ao {
-				regulator-name = "8941_l12_ao";
-				parent-supply = <&pm8941_s2_ao>;
-				qcom,set = <1>;
-				regulator-min-microvolt = <1800000>;
-				regulator-max-microvolt = <1800000>;
-				status = "okay";
-				compatible = "qcom,rpm-regulator-smd";
-			};
-		};
-
-		rpm-regulator-ldoa13 {
-			status = "okay";
-			pm8941_l13: regulator-l13 {
-				regulator-min-microvolt = <1800000>;
-				regulator-max-microvolt = <2950000>;
-				qcom,init-voltage = <2950000>;
-				status = "okay";
-			};
-		};
-
-		rpm-regulator-ldoa14 {
-			status = "okay";
-			pm8941_l14: regulator-l14 {
-				parent-supply = <&pm8941_s2>;
-				regulator-min-microvolt = <1800000>;
-				regulator-max-microvolt = <1800000>;
-				qcom,init-voltage = <1800000>;
-				status = "okay";
-			};
-		};
-
-		rpm-regulator-ldoa15 {
-			status = "okay";
-			pm8941_l15: regulator-l15 {
-				parent-supply = <&pm8941_s2>;
-				regulator-min-microvolt = <2050000>;
-				regulator-max-microvolt = <2050000>;
-				qcom,init-voltage = <2050000>;
-				status = "okay";
-			};
-		};
-
-		rpm-regulator-ldoa16 {
-			status = "okay";
-			pm8941_l16: regulator-l16 {
-				regulator-min-microvolt = <2700000>;
-				regulator-max-microvolt = <2700000>;
-				qcom,init-voltage = <2700000>;
-				status = "okay";
-			};
-		};
-
-		rpm-regulator-ldoa17 {
-			status = "okay";
-			pm8941_l17: regulator-l17 {
-				regulator-min-microvolt = <2850000>;
-				regulator-max-microvolt = <2850000>;
-				qcom,init-voltage = <2850000>;
-				status = "okay";
-			};
-		};
-
-		rpm-regulator-ldoa18 {
-			status = "okay";
-			pm8941_l18: regulator-l18 {
-				regulator-min-microvolt = <2850000>;
-				regulator-max-microvolt = <2850000>;
-				qcom,init-voltage = <2850000>;
-				status = "okay";
-			};
-		};
-
-		rpm-regulator-ldoa19 {
-			status = "okay";
-			pm8941_l19: regulator-l19 {
-				regulator-min-microvolt = <2900000>;
-				regulator-max-microvolt = <2900000>;
-				qcom,init-voltage = <2900000>;
-				status = "okay";
-			};
-		};
-
-		rpm-regulator-ldoa20 {
-			status = "okay";
-			pm8941_l20: regulator-l20 {
-				regulator-min-microvolt = <2950000>;
-				regulator-max-microvolt = <2950000>;
-				qcom,init-voltage = <2950000>;
-				status = "okay";
-			};
-		};
-
-		rpm-regulator-ldoa21 {
-			status = "okay";
-			pm8941_l21: regulator-l21 {
-				regulator-min-microvolt = <2950000>;
-				regulator-max-microvolt = <2950000>;
-				qcom,init-voltage = <2950000>;
-				status = "okay";
-			};
-		};
-
-		rpm-regulator-ldoa22 {
-			status = "okay";
-			pm8941_l22: regulator-l22 {
-				regulator-min-microvolt = <3000000>;
-				regulator-max-microvolt = <3000000>;
-				qcom,init-voltage = <3000000>;
-				status = "okay";
-			};
-		};
-
-		rpm-regulator-ldoa23 {
-			status = "okay";
-			pm8941_l23: regulator-l23 {
-				regulator-min-microvolt = <3000000>;
-				regulator-max-microvolt = <3000000>;
-				qcom,init-voltage = <3000000>;
-				status = "okay";
-			};
-		};
-
-		rpm-regulator-ldoa24 {
-			status = "okay";
-			pm8941_l24: regulator-l24 {
-				regulator-min-microvolt = <3075000>;
-				regulator-max-microvolt = <3075000>;
-				qcom,init-voltage = <3075000>;
-				status = "okay";
-			};
-		};
-
-		rpm-regulator-vsa1 {
-			status = "okay";
-			pm8941_lvs1: regulator-lvs1 {
-				parent-supply = <&pm8941_s3>;
-				status = "okay";
-			};
-		};
-
-		rpm-regulator-vsa2 {
-			status = "okay";
-			pm8941_lvs2: regulator-lvs2 {
-				parent-supply = <&pm8941_s3>;
-				status = "okay";
-			};
-		};
-
-		rpm-regulator-vsa3 {
-			status = "okay";
-			pm8941_lvs3: regulator-lvs3 {
-				parent-supply = <&pm8941_s3>;
-				status = "okay";
-			};
+			compatible = "qcom,rpm-regulator-smd";
 		};
 	};
 
+	rpm-regulator-smpb2 {
+		status = "okay";
+		qcom,allow-atomic = <1>;
+		pm8841_s2: regulator-s2 {
+			regulator-min-microvolt = <500000>;
+			regulator-max-microvolt = <1050000>;
+			status = "okay";
+		};
+		pm8841_s2_corner: regulator-s2-corner {
+			regulator-name = "8841_s2_corner";
+			qcom,set = <3>;
+			regulator-min-microvolt = <1>;
+			regulator-max-microvolt = <6>;
+			qcom,use-voltage-corner;
+			compatible = "qcom,rpm-regulator-smd";
+			qcom,consumer-supplies = "vdd_dig", "";
+		};
+		pm8841_s2_corner_ao: regulator-s2-corner-ao {
+			regulator-name = "8841_s2_corner_ao";
+			qcom,set = <1>;
+			regulator-min-microvolt = <1>;
+			regulator-max-microvolt = <6>;
+			qcom,use-voltage-corner;
+			compatible = "qcom,rpm-regulator-smd";
+		};
+	};
+
+	rpm-regulator-smpb3 {
+		status = "okay";
+		pm8841_s3: regulator-s3 {
+			regulator-min-microvolt = <1150000>;
+			regulator-max-microvolt = <1150000>;
+			qcom,init-voltage = <1150000>;
+			status = "okay";
+		};
+	};
+
+	rpm-regulator-smpb4 {
+		status = "okay";
+		pm8841_s4: regulator-s4 {
+			regulator-min-microvolt = <900000>;
+			regulator-max-microvolt = <900000>;
+			qcom,init-voltage = <900000>;
+			status = "okay";
+		};
+	};
+
+	rpm-regulator-smpa1 {
+		status = "okay";
+		pm8941_s1: regulator-s1 {
+			regulator-min-microvolt = <1300000>;
+			regulator-max-microvolt = <1300000>;
+			qcom,init-voltage = <1300000>;
+			qcom,init-current = <100>;
+			qcom,system-load = <100000>;
+			regulator-always-on;
+			status = "okay";
+		};
+	};
+
+	rpm-regulator-smpa2 {
+		status = "okay";
+		qcom,allow-atomic = <1>;
+		pm8941_s2: regulator-s2 {
+			regulator-min-microvolt = <2150000>;
+			regulator-max-microvolt = <2150000>;
+			qcom,init-voltage = <2150000>;
+			status = "okay";
+		};
+		pm8941_s2_ao: regulator-s2-ao {
+			regulator-name = "8941_s2_ao";
+			qcom,set = <1>;
+			regulator-min-microvolt = <2150000>;
+			regulator-max-microvolt = <2150000>;
+			status = "okay";
+			compatible = "qcom,rpm-regulator-smd";
+		};
+	};
+
+	rpm-regulator-smpa3 {
+		status = "okay";
+		pm8941_s3: regulator-s3 {
+			regulator-min-microvolt = <1800000>;
+			regulator-max-microvolt = <1800000>;
+			qcom,init-voltage = <1800000>;
+			qcom,init-current = <100>;
+			qcom,system-load = <100000>;
+			regulator-always-on;
+			status = "okay";
+		};
+	};
+
+	rpm-regulator-ldoa1 {
+		status = "okay";
+		pm8941_l1: regulator-l1 {
+			parent-supply = <&pm8941_s1>;
+			regulator-min-microvolt = <1225000>;
+			regulator-max-microvolt = <1225000>;
+			qcom,init-voltage = <1225000>;
+			qcom,init-current = <10>;
+			qcom,system-load = <10000>;
+			regulator-always-on;
+			status = "okay";
+		};
+	};
+
+	rpm-regulator-ldoa2 {
+		status = "okay";
+		pm8941_l2: regulator-l2 {
+			parent-supply = <&pm8941_s3>;
+			regulator-min-microvolt = <1200000>;
+			regulator-max-microvolt = <1200000>;
+			qcom,init-voltage = <1200000>;
+			status = "okay";
+		};
+	};
+
+	rpm-regulator-ldoa3 {
+		status = "okay";
+		pm8941_l3: regulator-l3 {
+			parent-supply = <&pm8941_s1>;
+			regulator-min-microvolt = <1200000>;
+			regulator-max-microvolt = <1200000>;
+			qcom,init-voltage = <1200000>;
+			status = "okay";
+		};
+	};
+
+	rpm-regulator-ldoa4 {
+		status = "okay";
+		pm8941_l4: regulator-l4 {
+			parent-supply = <&pm8941_s1>;
+			regulator-min-microvolt = <1150000>;
+			regulator-max-microvolt = <1150000>;
+			qcom,init-voltage = <1150000>;
+			status = "okay";
+		};
+	};
+
+	rpm-regulator-ldoa5 {
+		status = "okay";
+		pm8941_l5: regulator-l5 {
+			parent-supply = <&pm8941_s2>;
+			regulator-min-microvolt = <1800000>;
+			regulator-max-microvolt = <1800000>;
+			qcom,init-voltage = <1800000>;
+			status = "okay";
+		};
+	};
+
+	rpm-regulator-ldoa6 {
+		status = "okay";
+		pm8941_l6: regulator-l6 {
+			parent-supply = <&pm8941_s2>;
+			regulator-min-microvolt = <1800000>;
+			regulator-max-microvolt = <1800000>;
+			qcom,init-voltage = <1800000>;
+			status = "okay";
+		};
+	};
+
+	rpm-regulator-ldoa7 {
+		status = "okay";
+		pm8941_l7: regulator-l7 {
+			parent-supply = <&pm8941_s2>;
+			regulator-min-microvolt = <1800000>;
+			regulator-max-microvolt = <1800000>;
+			qcom,init-voltage = <1800000>;
+			status = "okay";
+		};
+	};
+
+	rpm-regulator-ldoa8 {
+		status = "okay";
+		pm8941_l8: regulator-l8 {
+			regulator-min-microvolt = <1800000>;
+			regulator-max-microvolt = <1800000>;
+			qcom,init-voltage = <1800000>;
+			status = "okay";
+		};
+	};
+
+	rpm-regulator-ldoa9 {
+		status = "okay";
+		pm8941_l9: regulator-l9 {
+			regulator-min-microvolt = <1800000>;
+			regulator-max-microvolt = <2950000>;
+			qcom,init-voltage = <2950000>;
+			status = "okay";
+		};
+	};
+
+	rpm-regulator-ldoa10 {
+		status = "okay";
+		pm8941_l10: regulator-l10 {
+			regulator-min-microvolt = <1800000>;
+			regulator-max-microvolt = <2950000>;
+			qcom,init-voltage = <2950000>;
+			status = "okay";
+		};
+	};
+
+	rpm-regulator-ldoa11 {
+		status = "okay";
+		pm8941_l11: regulator-l11 {
+			parent-supply = <&pm8941_s1>;
+			regulator-min-microvolt = <1250000>;
+			regulator-max-microvolt = <1250000>;
+			qcom,init-voltage = <1250000>;
+			status = "okay";
+		};
+	};
+
+	rpm-regulator-ldoa12 {
+		status = "okay";
+		qcom,allow-atomic = <1>;
+		pm8941_l12: regulator-l12 {
+			parent-supply = <&pm8941_s2>;
+			regulator-min-microvolt = <1800000>;
+			regulator-max-microvolt = <1800000>;
+			status = "okay";
+		};
+		pm8941_l12_ao: regulator-l12-ao {
+			regulator-name = "8941_l12_ao";
+			parent-supply = <&pm8941_s2_ao>;
+			qcom,set = <1>;
+			regulator-min-microvolt = <1800000>;
+			regulator-max-microvolt = <1800000>;
+			status = "okay";
+			compatible = "qcom,rpm-regulator-smd";
+		};
+	};
+
+	rpm-regulator-ldoa13 {
+		status = "okay";
+		pm8941_l13: regulator-l13 {
+			regulator-min-microvolt = <1800000>;
+			regulator-max-microvolt = <2950000>;
+			qcom,init-voltage = <2950000>;
+			status = "okay";
+		};
+	};
+
+	rpm-regulator-ldoa14 {
+		status = "okay";
+		pm8941_l14: regulator-l14 {
+			parent-supply = <&pm8941_s2>;
+			regulator-min-microvolt = <1800000>;
+			regulator-max-microvolt = <1800000>;
+			qcom,init-voltage = <1800000>;
+			status = "okay";
+		};
+	};
+
+	rpm-regulator-ldoa15 {
+		status = "okay";
+		pm8941_l15: regulator-l15 {
+			parent-supply = <&pm8941_s2>;
+			regulator-min-microvolt = <2050000>;
+			regulator-max-microvolt = <2050000>;
+			qcom,init-voltage = <2050000>;
+			status = "okay";
+		};
+	};
+
+	rpm-regulator-ldoa16 {
+		status = "okay";
+		pm8941_l16: regulator-l16 {
+			regulator-min-microvolt = <2700000>;
+			regulator-max-microvolt = <2700000>;
+			qcom,init-voltage = <2700000>;
+			status = "okay";
+		};
+	};
+
+	rpm-regulator-ldoa17 {
+		status = "okay";
+		pm8941_l17: regulator-l17 {
+			regulator-min-microvolt = <2850000>;
+			regulator-max-microvolt = <2850000>;
+			qcom,init-voltage = <2850000>;
+			status = "okay";
+		};
+	};
+
+	rpm-regulator-ldoa18 {
+		status = "okay";
+		pm8941_l18: regulator-l18 {
+			regulator-min-microvolt = <2850000>;
+			regulator-max-microvolt = <2850000>;
+			qcom,init-voltage = <2850000>;
+			status = "okay";
+		};
+	};
+
+	rpm-regulator-ldoa19 {
+		status = "okay";
+		pm8941_l19: regulator-l19 {
+			regulator-min-microvolt = <2900000>;
+			regulator-max-microvolt = <2900000>;
+			qcom,init-voltage = <2900000>;
+			status = "okay";
+		};
+	};
+
+	rpm-regulator-ldoa20 {
+		status = "okay";
+		pm8941_l20: regulator-l20 {
+			regulator-min-microvolt = <2950000>;
+			regulator-max-microvolt = <2950000>;
+			qcom,init-voltage = <2950000>;
+			status = "okay";
+		};
+	};
+
+	rpm-regulator-ldoa21 {
+		status = "okay";
+		pm8941_l21: regulator-l21 {
+			regulator-min-microvolt = <2950000>;
+			regulator-max-microvolt = <2950000>;
+			qcom,init-voltage = <2950000>;
+			status = "okay";
+		};
+	};
+
+	rpm-regulator-ldoa22 {
+		status = "okay";
+		pm8941_l22: regulator-l22 {
+			regulator-min-microvolt = <3000000>;
+			regulator-max-microvolt = <3000000>;
+			qcom,init-voltage = <3000000>;
+			status = "okay";
+		};
+	};
+
+	rpm-regulator-ldoa23 {
+		status = "okay";
+		pm8941_l23: regulator-l23 {
+			regulator-min-microvolt = <3000000>;
+			regulator-max-microvolt = <3000000>;
+			qcom,init-voltage = <3000000>;
+			status = "okay";
+		};
+	};
+
+	rpm-regulator-ldoa24 {
+		status = "okay";
+		pm8941_l24: regulator-l24 {
+			regulator-min-microvolt = <3075000>;
+			regulator-max-microvolt = <3075000>;
+			qcom,init-voltage = <3075000>;
+			status = "okay";
+		};
+	};
+
+	rpm-regulator-vsa1 {
+		status = "okay";
+		pm8941_lvs1: regulator-lvs1 {
+			parent-supply = <&pm8941_s3>;
+			status = "okay";
+		};
+	};
+
+	rpm-regulator-vsa2 {
+		status = "okay";
+		pm8941_lvs2: regulator-lvs2 {
+			parent-supply = <&pm8941_s3>;
+			status = "okay";
+		};
+	};
+
+	rpm-regulator-vsa3 {
+		status = "okay";
+		pm8941_lvs3: regulator-lvs3 {
+			parent-supply = <&pm8941_s3>;
+			status = "okay";
+		};
+	};
+};
+
+/ {
 	krait0_vreg: regulator@f9088000 {
 		compatible = "qcom,krait-regulator";
 		regulator-name = "krait0";
diff --git a/arch/arm/boot/dts/msm8974.dtsi b/arch/arm/boot/dts/msm8974.dtsi
index 8f8deac..54f6863 100644
--- a/arch/arm/boot/dts/msm8974.dtsi
+++ b/arch/arm/boot/dts/msm8974.dtsi
@@ -12,11 +12,6 @@
 
 /include/ "skeleton.dtsi"
 /include/ "msm8974_pm.dtsi"
-/include/ "msm-pm8x41-rpm-regulator.dtsi"
-/include/ "msm-pm8841.dtsi"
-/include/ "msm-pm8941.dtsi"
-/include/ "msm8974-regulator.dtsi"
-/include/ "msm8974-gpio.dtsi"
 /include/ "msm8974-iommu.dtsi"
 /include/ "msm-gdsc.dtsi"
 
@@ -178,7 +173,7 @@
 		qcom,min-clk-gear = <10>;
 	};
 
-	qcom,spmi@fc4c0000 {
+	spmi_bus: qcom,spmi@fc4c0000 {
 		cell-index = <0>;
 		compatible = "qcom,spmi-pmic-arb";
 		reg = <0xfc4cf000 0x1000>,
@@ -428,7 +423,7 @@
 		compatible = "qcom,msm_ocmem";
 	};
 
-	qcom,rpm-smd {
+	rpm_bus: qcom,rpm-smd {
 		compatible = "qcom,rpm-smd";
 		rpm-channel-name = "rpm_requests";
 		rpm-channel-type = <15>; /* SMD_APPS_RPM */
@@ -483,3 +478,9 @@
 		qcom,firmware-max-paddr = <0xFA00000>;
 	};
 };
+
+/include/ "msm-pm8x41-rpm-regulator.dtsi"
+/include/ "msm-pm8841.dtsi"
+/include/ "msm-pm8941.dtsi"
+/include/ "msm8974-regulator.dtsi"
+/include/ "msm8974-gpio.dtsi"
diff --git a/arch/arm/configs/msm7627a-perf_defconfig b/arch/arm/configs/msm7627a-perf_defconfig
index 3cd06a2..913e084 100644
--- a/arch/arm/configs/msm7627a-perf_defconfig
+++ b/arch/arm/configs/msm7627a-perf_defconfig
@@ -62,6 +62,7 @@
 CONFIG_AEABI=y
 CONFIG_HIGHMEM=y
 CONFIG_VMALLOC_RESERVE=0xC800000
+CONFIG_COMPACTION=y
 CONFIG_CP_ACCESS=y
 CONFIG_ZBOOT_ROM_TEXT=0x0
 CONFIG_ZBOOT_ROM_BSS=0x0
diff --git a/arch/arm/configs/msm7627a_defconfig b/arch/arm/configs/msm7627a_defconfig
index 058349a..8cd091c 100644
--- a/arch/arm/configs/msm7627a_defconfig
+++ b/arch/arm/configs/msm7627a_defconfig
@@ -62,6 +62,7 @@
 CONFIG_AEABI=y
 CONFIG_HIGHMEM=y
 CONFIG_VMALLOC_RESERVE=0xC800000
+CONFIG_COMPACTION=y
 CONFIG_CP_ACCESS=y
 CONFIG_ZBOOT_ROM_TEXT=0x0
 CONFIG_ZBOOT_ROM_BSS=0x0
diff --git a/arch/arm/configs/msm7630-perf_defconfig b/arch/arm/configs/msm7630-perf_defconfig
index 262c983..1bf888b 100644
--- a/arch/arm/configs/msm7630-perf_defconfig
+++ b/arch/arm/configs/msm7630-perf_defconfig
@@ -43,6 +43,7 @@
 CONFIG_MSM_MEMORY_LOW_POWER_MODE_SUSPEND_DEEP_POWER_DOWN=y
 CONFIG_MSM_IDLE_WAIT_ON_MODEM=2000
 CONFIG_MSM_STANDALONE_POWER_COLLAPSE=y
+CONFIG_MSM_MULTIMEDIA_USE_ION=y
 CONFIG_NO_HZ=y
 CONFIG_HIGH_RES_TIMERS=y
 CONFIG_PREEMPT=y
@@ -263,6 +264,8 @@
 CONFIG_VIDEO_HELPER_CHIPS_AUTO=y
 CONFIG_V4L_PLATFORM_DRIVERS=y
 CONFIG_RADIO_TAVARUA=y
+CONFIG_ION=y
+CONFIG_ION_MSM=y
 CONFIG_MSM_KGSL=y
 CONFIG_VIDEO_OUTPUT_CONTROL=y
 CONFIG_FB=y
diff --git a/arch/arm/configs/msm7630_defconfig b/arch/arm/configs/msm7630_defconfig
index 7eaaf35..aad13b8 100644
--- a/arch/arm/configs/msm7630_defconfig
+++ b/arch/arm/configs/msm7630_defconfig
@@ -43,6 +43,7 @@
 CONFIG_MSM_MEMORY_LOW_POWER_MODE_SUSPEND_DEEP_POWER_DOWN=y
 CONFIG_MSM_IDLE_WAIT_ON_MODEM=2000
 CONFIG_MSM_STANDALONE_POWER_COLLAPSE=y
+CONFIG_MSM_MULTIMEDIA_USE_ION=y
 CONFIG_STRICT_MEMORY_RWX=y
 CONFIG_NO_HZ=y
 CONFIG_HIGH_RES_TIMERS=y
@@ -264,6 +265,8 @@
 CONFIG_VIDEOBUF2_MSM_MEM=y
 CONFIG_VIDEO_HELPER_CHIPS_AUTO=y
 CONFIG_RADIO_TAVARUA=y
+CONFIG_ION=y
+CONFIG_ION_MSM=y
 CONFIG_MSM_KGSL=y
 CONFIG_VIDEO_OUTPUT_CONTROL=y
 CONFIG_FB=y
diff --git a/arch/arm/configs/msm8974_defconfig b/arch/arm/configs/msm8974_defconfig
index 07bd8e6..9bd967b 100644
--- a/arch/arm/configs/msm8974_defconfig
+++ b/arch/arm/configs/msm8974_defconfig
@@ -51,6 +51,7 @@
 CONFIG_MSM_TZ_LOG=y
 CONFIG_MSM_DIRECT_SCLK_ACCESS=y
 CONFIG_MSM_OCMEM=y
+CONFIG_MSM_WATCHDOG_V2=y
 CONFIG_NO_HZ=y
 CONFIG_HIGH_RES_TIMERS=y
 CONFIG_SMP=y
diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S
index 313ff0b..63917d6 100644
--- a/arch/arm/kernel/head.S
+++ b/arch/arm/kernel/head.S
@@ -462,9 +462,11 @@
 	instr_sync
 	mov	r3, r3
 #ifdef CONFIG_ARCH_MSM_KRAIT
-	ldr	r3, =0xff00fc00
+	movw	r3, 0xfc00
+	movt	r3, 0xff00
 	and	r3, r9, r3
-	ldr 	r4, =0x51000400
+	movw	r4, 0x0400
+	movt 	r4, 0x5100
 	cmp	r3, r4
 	mrceq	p15, 7, r3, c15, c0, 2
 	biceq	r3, r3, #0x400
diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
index 4738d71..28d6e60 100644
--- a/arch/arm/kernel/smp.c
+++ b/arch/arm/kernel/smp.c
@@ -208,7 +208,7 @@
 	mb();
 
 	/* Tell __cpu_die() that this CPU is now safe to dispose of */
-	complete(&cpu_died);
+	RCU_NONIDLE(complete(&cpu_died));
 
 	/*
 	 * actual CPU shutdown procedure is at least platform (if not
diff --git a/arch/arm/mach-msm/Kconfig b/arch/arm/mach-msm/Kconfig
index 2acf3ce..c23bc10 100644
--- a/arch/arm/mach-msm/Kconfig
+++ b/arch/arm/mach-msm/Kconfig
@@ -64,6 +64,7 @@
 	select MSM_PROC_COMM_REGULATOR
 	select MULTI_IRQ_HANDLER
 	select MSM_PM2 if PM
+	select HOLES_IN_ZONE if SPARSEMEM
 
 config ARCH_QSD8X50
 	bool "QSD8X50"
diff --git a/arch/arm/mach-msm/Makefile b/arch/arm/mach-msm/Makefile
index 702667b..7ccdd0f 100644
--- a/arch/arm/mach-msm/Makefile
+++ b/arch/arm/mach-msm/Makefile
@@ -27,6 +27,7 @@
 obj-$(CONFIG_ARCH_MSM_SCORPION) += pmu.o
 obj-$(CONFIG_ARCH_MSM_SCORPIONMP) += perf_event_msm_l2.o
 obj-$(CONFIG_ARCH_MSM_KRAIT) += msm-krait-l2-accessors.o pmu.o perf_event_msm_krait_l2.o
+obj-$(CONFIG_ARCH_MSM_KRAIT) += krait-scm.o
 obj-$(CONFIG_ARCH_MSM7X27A) += pmu.o
 
 ifndef CONFIG_MSM_SMP
diff --git a/arch/arm/mach-msm/acpuclock-8960.c b/arch/arm/mach-msm/acpuclock-8960.c
index c9d3817..7f198d2 100644
--- a/arch/arm/mach-msm/acpuclock-8960.c
+++ b/arch/arm/mach-msm/acpuclock-8960.c
@@ -1235,10 +1235,8 @@
 	unsigned long flags;
 	int rc = 0;
 
-	if (cpu > num_possible_cpus()) {
-		rc = -EINVAL;
-		goto out;
-	}
+	if (cpu > num_possible_cpus())
+		return -EINVAL;
 
 	if (reason == SETRATE_CPUFREQ || reason == SETRATE_HOTPLUG)
 		mutex_lock(&driver_lock);
diff --git a/arch/arm/mach-msm/acpuclock-8x60.c b/arch/arm/mach-msm/acpuclock-8x60.c
index ef34b3c..f94f0b2 100644
--- a/arch/arm/mach-msm/acpuclock-8x60.c
+++ b/arch/arm/mach-msm/acpuclock-8x60.c
@@ -712,10 +712,8 @@
 	unsigned long flags;
 	int rc = 0;
 
-	if (cpu > num_possible_cpus()) {
-		rc = -EINVAL;
-		goto out;
-	}
+	if (cpu > num_possible_cpus())
+		return -EINVAL;
 
 	if (reason == SETRATE_CPUFREQ || reason == SETRATE_HOTPLUG)
 		mutex_lock(&drv_state.lock);
diff --git a/arch/arm/mach-msm/acpuclock-krait.c b/arch/arm/mach-msm/acpuclock-krait.c
index 84253b8..8bd54e3 100644
--- a/arch/arm/mach-msm/acpuclock-krait.c
+++ b/arch/arm/mach-msm/acpuclock-krait.c
@@ -385,10 +385,8 @@
 	unsigned long flags;
 	int rc = 0;
 
-	if (cpu > num_possible_cpus()) {
-		rc = -EINVAL;
-		goto out;
-	}
+	if (cpu > num_possible_cpus())
+		return -EINVAL;
 
 	if (reason == SETRATE_CPUFREQ || reason == SETRATE_HOTPLUG)
 		mutex_lock(&driver_lock);
diff --git a/arch/arm/mach-msm/bam_dmux.c b/arch/arm/mach-msm/bam_dmux.c
index 3df566c..813824e 100644
--- a/arch/arm/mach-msm/bam_dmux.c
+++ b/arch/arm/mach-msm/bam_dmux.c
@@ -183,6 +183,7 @@
 static int bam_rx_pool_len;
 static LIST_HEAD(bam_tx_pool);
 static DEFINE_SPINLOCK(bam_tx_pool_spinlock);
+static DEFINE_MUTEX(bam_pdev_mutexlock);
 
 struct bam_mux_hdr {
 	uint16_t magic_num;
@@ -433,30 +434,26 @@
 		mutex_lock(&bam_rx_pool_mutexlock);
 		list_add_tail(&info->list_node, &bam_rx_pool);
 		rx_len_cached = ++bam_rx_pool_len;
-		mutex_unlock(&bam_rx_pool_mutexlock);
-
 		ret = sps_transfer_one(bam_rx_pipe, info->dma_address,
 			BUFFER_SIZE, info,
 			SPS_IOVEC_FLAG_INT | SPS_IOVEC_FLAG_EOT);
-
 		if (ret) {
+			list_del(&info->list_node);
+			rx_len_cached = --bam_rx_pool_len;
+			mutex_unlock(&bam_rx_pool_mutexlock);
 			DMUX_LOG_KERR("%s: sps_transfer_one failed %d\n",
 				__func__, ret);
-			goto fail_transfer;
+
+			dma_unmap_single(NULL, info->dma_address, BUFFER_SIZE,
+						DMA_FROM_DEVICE);
+
+			goto fail_skb;
 		}
+		mutex_unlock(&bam_rx_pool_mutexlock);
+
 	}
 	return;
 
-fail_transfer:
-	mutex_lock(&bam_rx_pool_mutexlock);
-	list_del(&info->list_node);
-	--bam_rx_pool_len;
-	rx_len_cached = bam_rx_pool_len;
-	mutex_unlock(&bam_rx_pool_mutexlock);
-
-	dma_unmap_single(NULL, info->dma_address, BUFFER_SIZE,
-				DMA_FROM_DEVICE);
-
 fail_skb:
 	dev_kfree_skb_any(info->skb);
 
@@ -502,15 +499,24 @@
 	unsigned long flags;
 	int ret;
 
+	mutex_lock(&bam_pdev_mutexlock);
+	if (in_global_reset) {
+		bam_dmux_log("%s: open cid %d aborted due to ssr\n",
+				__func__, rx_hdr->ch_id);
+		mutex_unlock(&bam_pdev_mutexlock);
+		queue_rx();
+		return;
+	}
 	spin_lock_irqsave(&bam_ch[rx_hdr->ch_id].lock, flags);
 	bam_ch[rx_hdr->ch_id].status |= BAM_CH_REMOTE_OPEN;
 	bam_ch[rx_hdr->ch_id].num_tx_pkts = 0;
 	spin_unlock_irqrestore(&bam_ch[rx_hdr->ch_id].lock, flags);
-	queue_rx();
 	ret = platform_device_add(bam_ch[rx_hdr->ch_id].pdev);
 	if (ret)
 		pr_err("%s: platform_device_add() error: %d\n",
 				__func__, ret);
+	mutex_unlock(&bam_pdev_mutexlock);
+	queue_rx();
 }
 
 static void handle_bam_mux_cmd(struct work_struct *work)
@@ -584,16 +590,24 @@
 		/* probably should drop pending write */
 		bam_dmux_log("%s: closing cid %d\n", __func__,
 				rx_hdr->ch_id);
+		mutex_lock(&bam_pdev_mutexlock);
+		if (in_global_reset) {
+			bam_dmux_log("%s: close cid %d aborted due to ssr\n",
+					__func__, rx_hdr->ch_id);
+			mutex_unlock(&bam_pdev_mutexlock);
+			break;
+		}
 		spin_lock_irqsave(&bam_ch[rx_hdr->ch_id].lock, flags);
 		bam_ch[rx_hdr->ch_id].status &= ~BAM_CH_REMOTE_OPEN;
 		spin_unlock_irqrestore(&bam_ch[rx_hdr->ch_id].lock, flags);
-		queue_rx();
 		platform_device_unregister(bam_ch[rx_hdr->ch_id].pdev);
 		bam_ch[rx_hdr->ch_id].pdev =
 			platform_device_alloc(bam_ch[rx_hdr->ch_id].name, 2);
 		if (!bam_ch[rx_hdr->ch_id].pdev)
 			pr_err("%s: platform_device_alloc failed\n", __func__);
+		mutex_unlock(&bam_pdev_mutexlock);
 		dev_kfree_skb_any(rx_skb);
+		queue_rx();
 		break;
 	default:
 		DMUX_LOG_KERR("%s: dropping invalid hdr. magic %x"
@@ -1060,18 +1074,29 @@
 
 		mutex_lock(&bam_rx_pool_mutexlock);
 		if (unlikely(list_empty(&bam_rx_pool))) {
+			DMUX_LOG_KERR("%s: have iovec %p but rx pool empty\n",
+				__func__, (void *)iov.addr);
 			mutex_unlock(&bam_rx_pool_mutexlock);
 			continue;
 		}
 		info = list_first_entry(&bam_rx_pool, struct rx_pkt_info,
 							list_node);
+		if (info->dma_address != iov.addr) {
+			DMUX_LOG_KERR("%s: iovec %p != dma %p\n",
+				__func__,
+				(void *)iov.addr,
+				(void *)info->dma_address);
+			list_for_each_entry(info, &bam_rx_pool, list_node) {
+				DMUX_LOG_KERR("%s: dma %p\n", __func__,
+					(void *)info->dma_address);
+				if (iov.addr == info->dma_address)
+					break;
+			}
+		}
+		BUG_ON(info->dma_address != iov.addr);
 		list_del(&info->list_node);
 		--bam_rx_pool_len;
 		mutex_unlock(&bam_rx_pool_mutexlock);
-		if (info->dma_address != iov.addr)
-			DMUX_LOG_KERR("%s: iovec %p != dma %p\n",
-				__func__,
-				(void *)info->dma_address, (void *)iov.addr);
 		handle_bam_mux_cmd(&info->work);
 	}
 	return;
@@ -1105,13 +1130,30 @@
 			inactive_cycles = 0;
 			mutex_lock(&bam_rx_pool_mutexlock);
 			if (unlikely(list_empty(&bam_rx_pool))) {
+				DMUX_LOG_KERR(
+					"%s: have iovec %p but rx pool empty\n",
+					__func__, (void *)iov.addr);
 				mutex_unlock(&bam_rx_pool_mutexlock);
 				continue;
 			}
 			info = list_first_entry(&bam_rx_pool,
 					struct rx_pkt_info,	list_node);
-			--bam_rx_pool_len;
+			if (info->dma_address != iov.addr) {
+				DMUX_LOG_KERR("%s: iovec %p != dma %p\n",
+					__func__,
+					(void *)iov.addr,
+					(void *)info->dma_address);
+				list_for_each_entry(info, &bam_rx_pool,
+						list_node) {
+					DMUX_LOG_KERR("%s: dma %p\n", __func__,
+						(void *)info->dma_address);
+					if (iov.addr == info->dma_address)
+						break;
+				}
+			}
+			BUG_ON(info->dma_address != iov.addr);
 			list_del(&info->list_node);
+			--bam_rx_pool_len;
 			mutex_unlock(&bam_rx_pool_mutexlock);
 			handle_bam_mux_cmd(&info->work);
 		}
@@ -1873,6 +1915,7 @@
 	disconnect_ack = 0;
 
 	/* Cleanup Channel States */
+	mutex_lock(&bam_pdev_mutexlock);
 	for (i = 0; i < BAM_DMUX_NUM_CHANNELS; ++i) {
 		temp_remote_status = bam_ch_is_remote_open(i);
 		bam_ch[i].status &= ~BAM_CH_REMOTE_OPEN;
@@ -1885,6 +1928,7 @@
 						bam_ch[i].name, 2);
 		}
 	}
+	mutex_unlock(&bam_pdev_mutexlock);
 
 	/* Cleanup pending UL data */
 	spin_lock_irqsave(&bam_tx_pool_spinlock, flags);
diff --git a/arch/arm/mach-msm/board-8064-gpu.c b/arch/arm/mach-msm/board-8064-gpu.c
index 0f9c939..eb36a81e 100644
--- a/arch/arm/mach-msm/board-8064-gpu.c
+++ b/arch/arm/mach-msm/board-8064-gpu.c
@@ -13,10 +13,11 @@
 
 #include <linux/init.h>
 #include <linux/platform_device.h>
-#include <linux/msm_kgsl.h>
+#include <mach/kgsl.h>
 #include <mach/msm_bus_board.h>
 #include <mach/board.h>
 #include <mach/msm_dcvs.h>
+#include <mach/socinfo.h>
 
 #include "devices.h"
 #include "board-8064.h"
@@ -247,5 +248,13 @@
 
 void __init apq8064_init_gpu(void)
 {
+	unsigned int version = socinfo_get_version();
+
+	if ((SOCINFO_VERSION_MAJOR(version) == 1) &&
+		(SOCINFO_VERSION_MINOR(version) == 1))
+		kgsl_3d0_pdata.chipid = ADRENO_CHIPID(3, 2, 0, 1);
+	else
+		kgsl_3d0_pdata.chipid = ADRENO_CHIPID(3, 2, 0, 0);
+
 	platform_device_register(&device_kgsl_3d0);
 }
diff --git a/arch/arm/mach-msm/board-8930-gpu.c b/arch/arm/mach-msm/board-8930-gpu.c
index 632fc9a..105a5aa 100644
--- a/arch/arm/mach-msm/board-8930-gpu.c
+++ b/arch/arm/mach-msm/board-8930-gpu.c
@@ -13,7 +13,7 @@
 
 #include <linux/init.h>
 #include <linux/platform_device.h>
-#include <linux/msm_kgsl.h>
+#include <mach/kgsl.h>
 #include <mach/msm_bus_board.h>
 #include <mach/board.h>
 #include <mach/socinfo.h>
@@ -135,7 +135,7 @@
 			.bus_freq = 0,
 		},
 	},
-	.init_level = 0,
+	.init_level = 1,
 	.num_levels = 4,
 	.set_grp_async = NULL,
 	.idle_timeout = HZ/12,
@@ -160,8 +160,16 @@
 
 void __init msm8930_init_gpu(void)
 {
+	unsigned int version = socinfo_get_version();
+
 	if (cpu_is_msm8627())
 		kgsl_3d0_pdata.pwrlevel[0].gpu_freq = 400000000;
 
+	if ((SOCINFO_VERSION_MAJOR(version) == 1) &&
+		(SOCINFO_VERSION_MINOR(version) == 2))
+		kgsl_3d0_pdata.chipid = ADRENO_CHIPID(3, 0, 5, 2);
+	else
+		kgsl_3d0_pdata.chipid = ADRENO_CHIPID(3, 0, 5, 0);
+
 	platform_device_register(&device_kgsl_3d0);
 }
diff --git a/arch/arm/mach-msm/board-8930.c b/arch/arm/mach-msm/board-8930.c
index f63b490..ec218ac 100644
--- a/arch/arm/mach-msm/board-8930.c
+++ b/arch/arm/mach-msm/board-8930.c
@@ -26,7 +26,6 @@
 #include <linux/spi/spi.h>
 #include <linux/slimbus/slimbus.h>
 #include <linux/bootmem.h>
-#include <linux/msm_kgsl.h>
 #ifdef CONFIG_ANDROID_PMEM
 #include <linux/android_pmem.h>
 #endif
@@ -80,6 +79,7 @@
 #include <linux/fmem.h>
 #include <mach/msm_cache_dump.h>
 
+#include <mach/kgsl.h>
 #ifdef CONFIG_INPUT_MPU3050
 #include <linux/input/mpu3050.h>
 #endif
@@ -1741,7 +1741,7 @@
 #define MXT_TS_GPIO_IRQ			11
 #define MXT_TS_RESET_GPIO		52
 
-static const u8 mxt_config_data_8930[] = {
+static const u8 mxt_config_data_8930_v1[] = {
 	/* T6 Object */
 	 0, 0, 0, 0, 0, 0,
 	/* T38 Object */
@@ -1786,6 +1786,43 @@
 	 0, 0, 0, 0,
 };
 
+static const u8 mxt_config_data_8930_v2[] = {
+	/* T6 Object */
+	 0, 0, 0, 0, 0, 0,
+	/* T38 Object */
+	 15, 4, 0, 9, 7, 12, 0, 0,
+	/* T7 Object */
+	32, 16, 50,
+	/* T8 Object */
+	 30, 0, 5, 10, 0, 0, 10, 10, 0, 0,
+	/* T9 Object */
+	 131, 0, 0, 19, 11, 0, 16, 50, 1, 3,
+	 12, 7, 2, 0, 4, 5, 2, 10, 43, 4,
+	 54, 2, -25, 29, 38, 18, 143, 40, 207, 80,
+	 17, 5, 50, 50, 0,
+	/* T18 Object */
+	 0, 0,
+	/* T19 Object */
+	 0, 0, 0, 0, 0, 0,
+	/* T25 Object */
+	 0, 0, 0, 0, 0, 0,
+	/* T42 Object */
+	 3, 60, 20, 20, 150, 0, 0, 0,
+	/* T46 Object */
+	 0, 3, 28, 28, 0, 0, 1, 0, 0,
+	/* T47 Object */
+	 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+	/* T48 Object */
+	 1, 3, 82, 0, 0, 0, 0, 0, 0, 0,
+	 16, 30, 0, 6, 6, 0, 0, 124, 4, 100,
+	 0, 0, 0, 5, 0, 42, 0, 1, 0, 40,
+	 52, 20, 0, 0, 0, 50, 1, 5, 2, 1,
+	 4, 5, 3, -25, 29, 38, 18, 143, 40, 207,
+	 80, 10, 5, 2,
+	/* T55 Object */
+	0, 0, 0, 0,
+};
+
 static ssize_t mxt224e_vkeys_show(struct kobject *kobj,
 			struct kobj_attribute *attr, char *buf)
 {
@@ -1833,12 +1870,33 @@
 
 static struct mxt_config_info mxt_config_array[] = {
 	{
-		.config			= mxt_config_data_8930,
-		.config_length		= ARRAY_SIZE(mxt_config_data_8930),
+		.config			= mxt_config_data_8930_v1,
+		.config_length		= ARRAY_SIZE(mxt_config_data_8930_v1),
 		.family_id		= 0x81,
 		.variant_id		= 0x01,
 		.version		= 0x10,
 		.build			= 0xAA,
+		.bootldr_id		= MXT_BOOTLOADER_ID_224E,
+		.fw_name		= "atmel_8930_fluid_v2_0_AB.hex",
+	},
+	{
+		.config			= mxt_config_data_8930_v2,
+		.config_length		= ARRAY_SIZE(mxt_config_data_8930_v2),
+		.family_id		= 0x81,
+		.variant_id		= 0x15,
+		.version		= 0x11,
+		.build			= 0xAA,
+		.bootldr_id		= MXT_BOOTLOADER_ID_224E,
+		.fw_name		= "atmel_8930_fluid_v2_0_AB.hex",
+	},
+	{
+		.config			= mxt_config_data_8930_v2,
+		.config_length		= ARRAY_SIZE(mxt_config_data_8930_v2),
+		.family_id		= 0x81,
+		.variant_id		= 0x01,
+		.version		= 0x20,
+		.build			= 0xAB,
+		.bootldr_id		= MXT_BOOTLOADER_ID_224E,
 	},
 };
 
diff --git a/arch/arm/mach-msm/board-8960-display.c b/arch/arm/mach-msm/board-8960-display.c
index 20e9d2b..88827ab 100644
--- a/arch/arm/mach-msm/board-8960-display.c
+++ b/arch/arm/mach-msm/board-8960-display.c
@@ -1005,6 +1005,9 @@
 
 void __init msm8960_init_fb(void)
 {
+	if (cpu_is_msm8960ab())
+		mdp_pdata.mdp_rev = MDP_REV_44;
+
 	platform_device_register(&msm_fb_device);
 
 #ifdef CONFIG_FB_MSM_WRITEBACK_MSM_PANEL
diff --git a/arch/arm/mach-msm/board-8960.c b/arch/arm/mach-msm/board-8960.c
index 4721c94..925b7a1 100644
--- a/arch/arm/mach-msm/board-8960.c
+++ b/arch/arm/mach-msm/board-8960.c
@@ -26,7 +26,6 @@
 #include <linux/spi/spi.h>
 #include <linux/slimbus/slimbus.h>
 #include <linux/bootmem.h>
-#include <linux/msm_kgsl.h>
 #ifdef CONFIG_ANDROID_PMEM
 #include <linux/android_pmem.h>
 #endif
@@ -87,6 +86,7 @@
 #include <mach/scm.h>
 #include <mach/iommu_domains.h>
 
+#include <mach/kgsl.h>
 #include <linux/fmem.h>
 
 #include "timer.h"
@@ -1911,18 +1911,9 @@
 	.gest_set = CY_GEST_GRP1 | CY_GEST_GRP2 |
 				CY_GEST_GRP3 | CY_GEST_GRP4 |
 				CY_ACT_DIST,
-	/* change act_intrvl to customize the Active power state
-	 * scanning/processing refresh interval for Operating mode
-	 */
-	.act_intrvl = CY_ACT_INTRVL_DFLT,
-	/* change tch_tmout to customize the touch timeout for the
-	 * Active power state for Operating mode
-	 */
-	.tch_tmout = CY_TCH_TMOUT_DFLT,
-	/* change lp_intrvl to customize the Low Power power state
-	 * scanning/processing refresh interval for Operating mode
-	 */
-	.lp_intrvl = CY_LP_INTRVL_DFLT,
+	.act_intrvl = 10,
+	.tch_tmout = 200,
+	.lp_intrvl = 30,
 	.sleep_gpio = CYTTSP_TS_SLEEP_GPIO,
 	.resout_gpio = CYTTSP_TS_RESOUT_N_GPIO,
 	.irq_gpio = CYTTSP_TS_GPIO_IRQ,
@@ -2049,7 +2040,7 @@
 	/* T6 Object */
 	0, 0, 0, 0, 0, 0,
 	/* T38 Object */
-	12, 3, 0, 24, 5, 12, 0, 0, 0, 0,
+	12, 4, 0, 5, 7, 12, 0, 0, 0, 0,
 	0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 	0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 	0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -2062,7 +2053,7 @@
 	25, 0, 20, 20, 0, 0, 20, 50, 0, 0,
 	/* T9 Object */
 	139, 0, 0, 26, 42, 0, 32, 80, 2, 5,
-	0, 5, 5, 0, 10, 30, 10, 10, 255, 2,
+	0, 5, 5, 79, 10, 30, 10, 10, 255, 2,
 	85, 5, 10, 10, 10, 10, 135, 55, 70, 40,
 	10, 5, 0, 0, 0,
 	/* T18 Object */
@@ -2082,7 +2073,7 @@
 	0, 0, 0, 0, 0, 0, 0, 64, 0, 8,
 	16,
 	/* T46 Object */
-	64, 0, 20, 20, 0, 0, 0, 0, 0,
+	64, 0, 16, 16, 0, 0, 0, 0, 0,
 	/* T47 Object */
 	0, 0, 0, 0, 0, 0, 3, 64, 66, 0,
 	/* T48 Object */
@@ -2696,13 +2687,26 @@
 
 static void __init msm8960_gfx_init(void)
 {
+	struct kgsl_device_platform_data *kgsl_3d0_pdata =
+		msm_kgsl_3d0.dev.platform_data;
 	uint32_t soc_platform_version = socinfo_get_version();
+
 	if (SOCINFO_VERSION_MAJOR(soc_platform_version) == 1) {
-		struct kgsl_device_platform_data *kgsl_3d0_pdata =
-				msm_kgsl_3d0.dev.platform_data;
 		kgsl_3d0_pdata->pwrlevel[0].gpu_freq = 320000000;
 		kgsl_3d0_pdata->pwrlevel[1].gpu_freq = 266667000;
 	}
+	if (cpu_is_msm8960ab()) {
+		kgsl_3d0_pdata->chipid = ADRENO_CHIPID(3, 2, 1, 0);
+	} else {
+
+		/* 8960v3 GPU registers returns 5 for patch release
+		 * but it should be 6, so dummy up the chipid here
+		 * based the platform type
+		 */
+
+		if (SOCINFO_VERSION_MAJOR(soc_platform_version) >= 3)
+			kgsl_3d0_pdata->chipid = ADRENO_CHIPID(2, 2, 0, 6);
+	}
 }
 
 static struct msm_rpmrs_level msm_rpmrs_levels[] = {
diff --git a/arch/arm/mach-msm/board-msm7x30.c b/arch/arm/mach-msm/board-msm7x30.c
index bb94474..ea12570 100644
--- a/arch/arm/mach-msm/board-msm7x30.c
+++ b/arch/arm/mach-msm/board-msm7x30.c
@@ -125,6 +125,13 @@
 #define PMEM_KERNEL_EBI0_SIZE   0x600000
 #define MSM_PMEM_AUDIO_SIZE     0x200000
 
+#ifdef CONFIG_ION_MSM
+static struct platform_device ion_dev;
+#define MSM_ION_AUDIO_SIZE	(MSM_PMEM_AUDIO_SIZE + PMEM_KERNEL_EBI0_SIZE)
+#define MSM_ION_SF_SIZE		MSM_PMEM_SF_SIZE
+#define MSM_ION_HEAP_NUM	4
+#endif
+
 #define PMIC_GPIO_INT		27
 #define PMIC_VREG_WLAN_LEVEL	2900
 #define PMIC_GPIO_SD_DET	36
@@ -5481,7 +5488,10 @@
 	&msm_adc_device,
 	&msm_ebi0_thermal,
 	&msm_ebi1_thermal,
-	&msm_adsp_device
+	&msm_adsp_device,
+#ifdef CONFIG_ION_MSM
+	&ion_dev,
+#endif
 };
 
 static struct msm_gpio msm_i2c_gpios_hw[] = {
@@ -7145,6 +7155,65 @@
 }
 early_param("pmem_kernel_ebi0_size", pmem_kernel_ebi0_size_setup);
 
+#ifdef CONFIG_ION_MSM
+#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
+static struct ion_co_heap_pdata co_ion_pdata = {
+	.adjacent_mem_id = INVALID_HEAP_ID,
+	.align = PAGE_SIZE,
+};
+#endif
+
+/**
+ * These heaps are listed in the order they will be allocated.
+ * Don't swap the order unless you know what you are doing!
+ */
+static struct ion_platform_data ion_pdata = {
+	.nr = MSM_ION_HEAP_NUM,
+	.heaps = {
+		{
+			.id	= ION_SYSTEM_HEAP_ID,
+			.type	= ION_HEAP_TYPE_SYSTEM,
+			.name	= ION_VMALLOC_HEAP_NAME,
+		},
+#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
+		/* PMEM_ADSP = CAMERA */
+		{
+			.id	= ION_CAMERA_HEAP_ID,
+			.type	= ION_HEAP_TYPE_CARVEOUT,
+			.name	= ION_CAMERA_HEAP_NAME,
+			.memory_type = ION_EBI_TYPE,
+			.has_outer_cache = 1,
+			.extra_data = (void *)&co_ion_pdata,
+		},
+		/* PMEM_AUDIO */
+		{
+			.id	= ION_AUDIO_HEAP_ID,
+			.type	= ION_HEAP_TYPE_CARVEOUT,
+			.name	= ION_AUDIO_HEAP_NAME,
+			.memory_type = ION_EBI_TYPE,
+			.has_outer_cache = 1,
+			.extra_data = (void *)&co_ion_pdata,
+		},
+		/* PMEM_MDP = SF */
+		{
+			.id	= ION_SF_HEAP_ID,
+			.type	= ION_HEAP_TYPE_CARVEOUT,
+			.name	= ION_SF_HEAP_NAME,
+			.memory_type = ION_EBI_TYPE,
+			.has_outer_cache = 1,
+			.extra_data = (void *)&co_ion_pdata,
+		},
+#endif
+	}
+};
+
+static struct platform_device ion_dev = {
+	.name = "ion-msm",
+	.id = 1,
+	.dev = { .platform_data = &ion_pdata },
+};
+#endif
+
 static struct memtype_reserve msm7x30_reserve_table[] __initdata = {
 	[MEMTYPE_SMI] = {
 	},
@@ -7156,34 +7225,52 @@
 	},
 };
 
-static void __init size_pmem_devices(void)
-{
-#ifdef CONFIG_ANDROID_PMEM
-	unsigned long size;
+unsigned long size;
+unsigned long msm_ion_camera_size;
 
+static void fix_sizes(void)
+{
 	if machine_is_msm7x30_fluid()
 		size = fluid_pmem_adsp_size;
 	else
 		size = pmem_adsp_size;
+
+#ifdef CONFIG_ION_MSM
+	msm_ion_camera_size = size;
+#endif
+}
+
+static void __init size_pmem_devices(void)
+{
+#ifdef CONFIG_ANDROID_PMEM
+#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
+
 	android_pmem_adsp_pdata.size = size;
 	android_pmem_audio_pdata.size = pmem_audio_size;
 	android_pmem_pdata.size = pmem_sf_size;
 #endif
+#endif
 }
 
+#ifdef CONFIG_ANDROID_PMEM
+#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
 static void __init reserve_memory_for(struct android_pmem_platform_data *p)
 {
 	msm7x30_reserve_table[p->memory_type].size += p->size;
 }
+#endif
+#endif
 
 static void __init reserve_pmem_memory(void)
 {
 #ifdef CONFIG_ANDROID_PMEM
+#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
 	reserve_memory_for(&android_pmem_adsp_pdata);
 	reserve_memory_for(&android_pmem_audio_pdata);
 	reserve_memory_for(&android_pmem_pdata);
 	msm7x30_reserve_table[MEMTYPE_EBI0].size += pmem_kernel_ebi0_size;
 #endif
+#endif
 }
 
 static void __init reserve_mdp_memory(void)
@@ -7192,11 +7279,32 @@
 	msm7x30_reserve_table[mdp_pdata.mem_hid].size += mdp_pdata.ov0_wb_size;
 }
 
+static void __init size_ion_devices(void)
+{
+#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
+	ion_pdata.heaps[1].size = msm_ion_camera_size;
+	ion_pdata.heaps[2].size = MSM_ION_AUDIO_SIZE;
+	ion_pdata.heaps[3].size = MSM_ION_SF_SIZE;
+#endif
+}
+
+static void __init reserve_ion_memory(void)
+{
+#if defined(CONFIG_ION_MSM) && defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
+	msm7x30_reserve_table[MEMTYPE_EBI0].size += msm_ion_camera_size;
+	msm7x30_reserve_table[MEMTYPE_EBI0].size += MSM_ION_AUDIO_SIZE;
+	msm7x30_reserve_table[MEMTYPE_EBI0].size += MSM_ION_SF_SIZE;
+#endif
+}
+
 static void __init msm7x30_calculate_reserve_sizes(void)
 {
+	fix_sizes();
 	size_pmem_devices();
 	reserve_pmem_memory();
 	reserve_mdp_memory();
+	size_ion_devices();
+	reserve_ion_memory();
 }
 
 static int msm7x30_paddr_to_memtype(unsigned int paddr)
diff --git a/arch/arm/mach-msm/board-qrd7627a.c b/arch/arm/mach-msm/board-qrd7627a.c
index 5b9ea36..8182fc4 100644
--- a/arch/arm/mach-msm/board-qrd7627a.c
+++ b/arch/arm/mach-msm/board-qrd7627a.c
@@ -144,6 +144,7 @@
 
 static struct android_usb_platform_data android_usb_pdata = {
 	.update_pid_and_serial_num = usb_diag_update_pid_and_serial_num,
+	.cdrom = 1,
 };
 
 static struct platform_device android_usb_device = {
diff --git a/arch/arm/mach-msm/board-swordfish.c b/arch/arm/mach-msm/board-swordfish.c
index 45d5bb0..7262277 100644
--- a/arch/arm/mach-msm/board-swordfish.c
+++ b/arch/arm/mach-msm/board-swordfish.c
@@ -21,7 +21,7 @@
 #include <linux/delay.h>
 #include <linux/fs.h>
 #include <linux/android_pmem.h>
-#include <linux/msm_kgsl.h>
+#include <mach/kgsl.h>
 
 #include <mach/hardware.h>
 #include <asm/mach-types.h>
diff --git a/arch/arm/mach-msm/clock-8974.c b/arch/arm/mach-msm/clock-8974.c
index 6c9a566..930de81 100644
--- a/arch/arm/mach-msm/clock-8974.c
+++ b/arch/arm/mach-msm/clock-8974.c
@@ -593,10 +593,12 @@
 #define RPM_MEM_CLK_TYPE  0x326b6c63
 
 #define CXO_ID		0x0
+#define QDSS_ID		0x1
 
 #define PNOC_ID		0x0
 #define SNOC_ID		0x1
 #define CNOC_ID		0x2
+#define MMSSNOC_AHB_ID  0x4
 
 #define BIMC_ID		0x0
 #define OCMEM_ID	0x1
@@ -604,6 +606,8 @@
 DEFINE_CLK_RPM_SMD(pnoc_clk, pnoc_a_clk, RPM_BUS_CLK_TYPE, PNOC_ID, NULL);
 DEFINE_CLK_RPM_SMD(snoc_clk, snoc_a_clk, RPM_BUS_CLK_TYPE, SNOC_ID, NULL);
 DEFINE_CLK_RPM_SMD(cnoc_clk, cnoc_a_clk, RPM_BUS_CLK_TYPE, CNOC_ID, NULL);
+DEFINE_CLK_RPM_SMD(mmssnoc_ahb_clk, mmssnoc_ahb_a_clk, RPM_BUS_CLK_TYPE,
+			MMSSNOC_AHB_ID, NULL);
 
 DEFINE_CLK_RPM_SMD(bimc_clk, bimc_a_clk, RPM_MEM_CLK_TYPE, BIMC_ID, NULL);
 DEFINE_CLK_RPM_SMD(ocmemgx_clk, ocmemgx_a_clk, RPM_MEM_CLK_TYPE, OCMEM_ID,
@@ -611,6 +615,7 @@
 
 DEFINE_CLK_RPM_SMD_BRANCH(cxo_clk_src, cxo_a_clk_src,
 				RPM_MISC_CLK_TYPE, CXO_ID, 19200000);
+DEFINE_CLK_RPM_SMD_QDSS(qdss_clk, qdss_a_clk, RPM_MISC_CLK_TYPE, QDSS_ID);
 
 static struct pll_vote_clk gpll0_clk_src = {
 	.en_reg = (void __iomem *)APCS_GPLL_ENA_VOTE_REG,
@@ -4830,6 +4835,36 @@
 	CLK_LOOKUP("bus_a_clk",	ocmemnoc_clk.c,		"msm_ocmem_noc"),
 	CLK_LOOKUP("bus_clk",	mmss_mmssnoc_axi_clk.c,	"msm_mmss_noc"),
 	CLK_LOOKUP("bus_a_clk",	mmss_mmssnoc_axi_clk.c,	"msm_mmss_noc"),
+
+	CLK_LOOKUP("core_clk", qdss_clk.c, "coresight-tmc-etr"),
+	CLK_LOOKUP("core_clk", qdss_clk.c, "coresight-tpiu"),
+	CLK_LOOKUP("core_clk", qdss_clk.c, "coresight-replicator"),
+	CLK_LOOKUP("core_clk", qdss_clk.c, "coresight-tmc-etf"),
+	CLK_LOOKUP("core_clk", qdss_clk.c, "coresight-funnel-merg"),
+	CLK_LOOKUP("core_clk", qdss_clk.c, "coresight-funnel-in0"),
+	CLK_LOOKUP("core_clk", qdss_clk.c, "coresight-funnel-in1"),
+	CLK_LOOKUP("core_clk", qdss_clk.c, "coresight-funnel-kpss"),
+	CLK_LOOKUP("core_clk", qdss_clk.c, "coresight-funnel-mmss"),
+	CLK_LOOKUP("core_clk", qdss_clk.c, "coresight-stm"),
+	CLK_LOOKUP("core_clk", qdss_clk.c, "coresight-etm0"),
+	CLK_LOOKUP("core_clk", qdss_clk.c, "coresight-etm1"),
+	CLK_LOOKUP("core_clk", qdss_clk.c, "coresight-etm2"),
+	CLK_LOOKUP("core_clk", qdss_clk.c, "coresight-etm3"),
+
+	CLK_LOOKUP("core_a_clk", qdss_a_clk.c, "coresight-tmc-etr"),
+	CLK_LOOKUP("core_a_clk", qdss_a_clk.c, "coresight-tpiu"),
+	CLK_LOOKUP("core_a_clk", qdss_a_clk.c, "coresight-replicator"),
+	CLK_LOOKUP("core_a_clk", qdss_a_clk.c, "coresight-tmc-etf"),
+	CLK_LOOKUP("core_a_clk", qdss_a_clk.c, "coresight-funnel-merg"),
+	CLK_LOOKUP("core_a_clk", qdss_a_clk.c, "coresight-funnel-in0"),
+	CLK_LOOKUP("core_a_clk", qdss_a_clk.c, "coresight-funnel-in1"),
+	CLK_LOOKUP("core_a_clk", qdss_a_clk.c, "coresight-funnel-kpss"),
+	CLK_LOOKUP("core_a_clk", qdss_a_clk.c, "coresight-funnel-mmss"),
+	CLK_LOOKUP("core_a_clk", qdss_a_clk.c, "coresight-stm"),
+	CLK_LOOKUP("core_a_clk", qdss_a_clk.c, "coresight-etm0"),
+	CLK_LOOKUP("core_a_clk", qdss_a_clk.c, "coresight-etm1"),
+	CLK_LOOKUP("core_a_clk", qdss_a_clk.c, "coresight-etm2"),
+	CLK_LOOKUP("core_a_clk", qdss_a_clk.c, "coresight-etm3"),
 };
 
 static struct pll_config_regs gpll0_regs __initdata = {
@@ -5028,6 +5063,13 @@
 	clk_set_rate(&ocmemnoc_clk_src.c, 333330000);
 
 	/*
+	 * Hold an active set vote at a rate of 40MHz for the MMSS NOC AHB
+	 * source. Sleep set vote is 0.
+	 */
+	clk_set_rate(&mmssnoc_ahb_a_clk.c, 40000000);
+	clk_prepare_enable(&mmssnoc_ahb_a_clk.c);
+
+	/*
 	 * Hold an active set vote for CXO; this is because CXO is expected
 	 * to remain on whenever CPUs aren't power collapsed.
 	 */
diff --git a/arch/arm/mach-msm/clock-dss-8960.c b/arch/arm/mach-msm/clock-dss-8960.c
index d9ad103..4e17b29 100644
--- a/arch/arm/mach-msm/clock-dss-8960.c
+++ b/arch/arm/mach-msm/clock-dss-8960.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009-2011, Code Aurora Forum. All rights reserved.
+/* Copyright (c) 2009-2012, Code Aurora Forum. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 and
@@ -166,6 +166,13 @@
 			 */
 			udelay(10);
 			writel_relaxed(0x0D, HDMI_PHY_PLL_LOCKDET_CFG2);
+
+			/*
+			 * Wait for a short duration for the PLL calibration
+			 * before checking if the PLL gets locked
+			 */
+			udelay(350);
+
 			timeout_count = 1000;
 			pll_lock_retry--;
 		}
@@ -176,6 +183,7 @@
 
 	if (!pll_lock_retry) {
 		pr_err("%s: HDMI PLL not locked\n", __func__);
+		hdmi_pll_disable();
 		return -EAGAIN;
 	}
 
diff --git a/arch/arm/mach-msm/clock-rpm.c b/arch/arm/mach-msm/clock-rpm.c
index 8096c10..207dbef 100644
--- a/arch/arm/mach-msm/clock-rpm.c
+++ b/arch/arm/mach-msm/clock-rpm.c
@@ -54,15 +54,11 @@
 	return (rc < 0) ? rc : iv.value * r->factor;
 }
 
-#define RPM_SMD_KEY_RATE	0x007A484B
-#define RPM_SMD_KEY_ENABLE	0x62616E45
-
 static int clk_rpmrs_set_rate_smd(struct rpm_clk *r, uint32_t value,
 				uint32_t context, int noirq)
 {
-	u32 rpm_key = r->branch ? RPM_SMD_KEY_ENABLE : RPM_SMD_KEY_RATE;
 	struct msm_rpm_kvp kvp = {
-		.key = rpm_key,
+		.key = r->rpm_key,
 		.data = (void *)&value,
 		.length = sizeof(value),
 	};
diff --git a/arch/arm/mach-msm/clock-rpm.h b/arch/arm/mach-msm/clock-rpm.h
index ce878ce..22691c5 100644
--- a/arch/arm/mach-msm/clock-rpm.h
+++ b/arch/arm/mach-msm/clock-rpm.h
@@ -17,6 +17,10 @@
 #include <mach/rpm.h>
 #include <mach/rpm-smd.h>
 
+#define RPM_SMD_KEY_RATE	0x007A484B
+#define RPM_SMD_KEY_ENABLE	0x62616E45
+#define RPM_SMD_KEY_STATE	0x54415453
+
 struct clk_ops;
 struct clk_rpmrs_data;
 extern struct clk_ops clk_ops_rpm;
@@ -24,6 +28,7 @@
 
 struct rpm_clk {
 	const int rpm_res_type;
+	const int rpm_key;
 	const int rpm_clk_id;
 	const int rpm_status_id;
 	const bool active_only;
@@ -47,12 +52,14 @@
 extern struct clk_rpmrs_data clk_rpmrs_data;
 extern struct clk_rpmrs_data clk_rpmrs_data_smd;
 
-#define __DEFINE_CLK_RPM(name, active, type, r_id, stat_id, dep, rpmrsdata) \
+#define __DEFINE_CLK_RPM(name, active, type, r_id, stat_id, dep, key, \
+				rpmrsdata) \
 	static struct rpm_clk active; \
 	static struct rpm_clk name = { \
 		.rpm_res_type = (type), \
 		.rpm_clk_id = (r_id), \
 		.rpm_status_id = (stat_id), \
+		.rpm_key = (key), \
 		.peer = &active, \
 		.factor = 1000, \
 		.rpmrs_data = (rpmrsdata),\
@@ -67,6 +74,7 @@
 		.rpm_res_type = (type), \
 		.rpm_clk_id = (r_id), \
 		.rpm_status_id = (stat_id), \
+		.rpm_key = (key), \
 		.peer = &name, \
 		.active_only = true, \
 		.factor = 1000, \
@@ -80,12 +88,13 @@
 	};
 
 #define __DEFINE_CLK_RPM_BRANCH(name, active, type, r_id, stat_id, r, \
-					rpmrsdata) \
+					key, rpmrsdata) \
 	static struct rpm_clk active; \
 	static struct rpm_clk name = { \
 		.rpm_res_type = (type), \
 		.rpm_clk_id = (r_id), \
 		.rpm_status_id = (stat_id), \
+		.rpm_key = (key), \
 		.peer = &active, \
 		.last_set_khz = ((r) / 1000), \
 		.last_set_sleep_khz = ((r) / 1000), \
@@ -104,6 +113,7 @@
 		.rpm_res_type = (type), \
 		.rpm_clk_id = (r_id), \
 		.rpm_status_id = (stat_id), \
+		.rpm_key = (key), \
 		.peer = &name, \
 		.last_set_khz = ((r) / 1000), \
 		.active_only = true, \
@@ -119,12 +129,14 @@
 		}, \
 	};
 
-#define __DEFINE_CLK_RPM_QDSS(name, active, type, r_id, stat_id, rpmrsdata) \
+#define __DEFINE_CLK_RPM_QDSS(name, active, type, r_id, stat_id, \
+				key, rpmrsdata) \
 	static struct rpm_clk active; \
 	static struct rpm_clk name = { \
 		.rpm_res_type = (type), \
 		.rpm_clk_id = (r_id), \
 		.rpm_status_id = (stat_id), \
+		.rpm_key = (key), \
 		.peer = &active, \
 		.factor = 1, \
 		.rpmrs_data = (rpmrsdata),\
@@ -139,6 +151,7 @@
 		.rpm_res_type = (type), \
 		.rpm_clk_id = (r_id), \
 		.rpm_status_id = (stat_id), \
+		.rpm_key = (key), \
 		.peer = &name, \
 		.active_only = true, \
 		.factor = 1, \
@@ -153,21 +166,26 @@
 
 #define DEFINE_CLK_RPM(name, active, r_id, dep) \
 	__DEFINE_CLK_RPM(name, active, 0, MSM_RPM_ID_##r_id##_CLK, \
-		MSM_RPM_STATUS_ID_##r_id##_CLK, dep, &clk_rpmrs_data)
+		MSM_RPM_STATUS_ID_##r_id##_CLK, dep, 0, &clk_rpmrs_data)
 
 #define DEFINE_CLK_RPM_QDSS(name, active) \
 	__DEFINE_CLK_RPM_QDSS(name, active, 0, MSM_RPM_ID_QDSS_CLK, \
-		MSM_RPM_STATUS_ID_QDSS_CLK, &clk_rpmrs_data)
+		MSM_RPM_STATUS_ID_QDSS_CLK, 0, &clk_rpmrs_data)
 
 #define DEFINE_CLK_RPM_BRANCH(name, active, r_id, r) \
 	__DEFINE_CLK_RPM_BRANCH(name, active, 0, MSM_RPM_ID_##r_id##_CLK, \
-			MSM_RPM_STATUS_ID_##r_id##_CLK, r, &clk_rpmrs_data)
+			MSM_RPM_STATUS_ID_##r_id##_CLK, r, 0, &clk_rpmrs_data)
 
 #define DEFINE_CLK_RPM_SMD(name, active, type, r_id, dep) \
-	__DEFINE_CLK_RPM(name, active, type, r_id, 0, dep, &clk_rpmrs_data_smd)
+	__DEFINE_CLK_RPM(name, active, type, r_id, 0, dep, \
+				RPM_SMD_KEY_RATE, &clk_rpmrs_data_smd)
 
-#define DEFINE_CLK_RPM_SMD_BRANCH(name, active, type, r_id, dep) \
-	__DEFINE_CLK_RPM_BRANCH(name, active, type, r_id, 0, dep, \
-					&clk_rpmrs_data_smd)
+#define DEFINE_CLK_RPM_SMD_BRANCH(name, active, type, r_id, r) \
+	__DEFINE_CLK_RPM_BRANCH(name, active, type, r_id, 0, r, \
+				RPM_SMD_KEY_ENABLE, &clk_rpmrs_data_smd)
+
+#define DEFINE_CLK_RPM_SMD_QDSS(name, active, type, r_id) \
+	__DEFINE_CLK_RPM_QDSS(name, active, type, r_id, \
+		0, RPM_SMD_KEY_STATE, &clk_rpmrs_data_smd)
 
 #endif
diff --git a/arch/arm/mach-msm/clock.h b/arch/arm/mach-msm/clock.h
index 56d3c6f..df2aa4e 100644
--- a/arch/arm/mach-msm/clock.h
+++ b/arch/arm/mach-msm/clock.h
@@ -181,7 +181,7 @@
 int clock_debug_add(struct clk *clock);
 void clock_debug_print_enabled(void);
 #else
-static inline int clock_debug_init(struct clk_init_data *data) { return 0; }
+static inline int clock_debug_init(struct clock_init_data *data) { return 0; }
 static inline int clock_debug_add(struct clk *clock) { return 0; }
 static inline void clock_debug_print_enabled(void) { return; }
 #endif
diff --git a/arch/arm/mach-msm/devices-8960.c b/arch/arm/mach-msm/devices-8960.c
index 7d93fe7..79f8c88 100644
--- a/arch/arm/mach-msm/devices-8960.c
+++ b/arch/arm/mach-msm/devices-8960.c
@@ -19,7 +19,7 @@
 #include <linux/gpio.h>
 #include <linux/coresight.h>
 #include <asm/clkdev.h>
-#include <linux/msm_kgsl.h>
+#include <mach/kgsl.h>
 #include <linux/android_pmem.h>
 #include <mach/irqs-8960.h>
 #include <mach/dma.h>
diff --git a/arch/arm/mach-msm/devices-iommu.c b/arch/arm/mach-msm/devices-iommu.c
index 1432902..ae8a8fe 100644
--- a/arch/arm/mach-msm/devices-iommu.c
+++ b/arch/arm/mach-msm/devices-iommu.c
@@ -1011,7 +1011,7 @@
 				ARRAY_SIZE(msm_iommu_gfx2d_devs));
 	}
 
-	if (cpu_is_apq8064()) {
+	if (cpu_is_apq8064() || cpu_is_msm8960ab()) {
 		platform_add_devices(msm_iommu_jpegd_devs,
 				ARRAY_SIZE(msm_iommu_jpegd_devs));
 		platform_add_devices(msm_iommu_8064_devs,
@@ -1030,7 +1030,7 @@
 				ARRAY_SIZE(msm_iommu_gfx2d_ctx_devs));
 	}
 
-	if (cpu_is_apq8064()) {
+	if (cpu_is_apq8064() || cpu_is_msm8960ab()) {
 		platform_add_devices(msm_iommu_jpegd_ctx_devs,
 				ARRAY_SIZE(msm_iommu_jpegd_ctx_devs));
 		platform_add_devices(msm_iommu_8064_ctx_devs,
@@ -1069,7 +1069,7 @@
 			platform_device_unregister(msm_iommu_jpegd_devs[i]);
 	}
 
-	if (cpu_is_apq8064()) {
+	if (cpu_is_apq8064() || cpu_is_msm8960ab()) {
 		for (i = 0; i < ARRAY_SIZE(msm_iommu_8064_ctx_devs); i++)
 			platform_device_unregister(msm_iommu_8064_ctx_devs[i]);
 
diff --git a/arch/arm/mach-msm/devices-msm7x27.c b/arch/arm/mach-msm/devices-msm7x27.c
index 4619cca..69d7430 100644
--- a/arch/arm/mach-msm/devices-msm7x27.c
+++ b/arch/arm/mach-msm/devices-msm7x27.c
@@ -15,7 +15,7 @@
 
 #include <linux/kernel.h>
 #include <linux/platform_device.h>
-#include <linux/msm_kgsl.h>
+#include <mach/kgsl.h>
 #include <linux/regulator/machine.h>
 #include <linux/dma-mapping.h>
 #include <linux/init.h>
diff --git a/arch/arm/mach-msm/devices-msm7x27a.c b/arch/arm/mach-msm/devices-msm7x27a.c
index c159926..8912e96 100644
--- a/arch/arm/mach-msm/devices-msm7x27a.c
+++ b/arch/arm/mach-msm/devices-msm7x27a.c
@@ -13,7 +13,7 @@
 #include <linux/kernel.h>
 #include <linux/platform_device.h>
 #include <linux/dma-mapping.h>
-#include <linux/msm_kgsl.h>
+#include <mach/kgsl.h>
 #include <linux/regulator/machine.h>
 #include <linux/init.h>
 #include <linux/irq.h>
diff --git a/arch/arm/mach-msm/devices-msm7x30.c b/arch/arm/mach-msm/devices-msm7x30.c
index 4b02f7a..f04ef9d 100644
--- a/arch/arm/mach-msm/devices-msm7x30.c
+++ b/arch/arm/mach-msm/devices-msm7x30.c
@@ -17,7 +17,7 @@
 #include <linux/platform_device.h>
 #include <linux/msm_rotator.h>
 #include <linux/dma-mapping.h>
-#include <linux/msm_kgsl.h>
+#include <mach/kgsl.h>
 #include <linux/android_pmem.h>
 #include <linux/regulator/machine.h>
 #include <linux/init.h>
diff --git a/arch/arm/mach-msm/devices-msm8x60.c b/arch/arm/mach-msm/devices-msm8x60.c
index 2ced412..3920abe 100644
--- a/arch/arm/mach-msm/devices-msm8x60.c
+++ b/arch/arm/mach-msm/devices-msm8x60.c
@@ -20,7 +20,7 @@
 #include <mach/dma.h>
 #include <asm/mach/mmc.h>
 #include <asm/clkdev.h>
-#include <linux/msm_kgsl.h>
+#include <mach/kgsl.h>
 #include <linux/msm_rotator.h>
 #include <mach/msm_hsusb.h>
 #include "footswitch.h"
diff --git a/arch/arm/mach-msm/devices-qsd8x50.c b/arch/arm/mach-msm/devices-qsd8x50.c
index 2ecc852..ec4a14f 100644
--- a/arch/arm/mach-msm/devices-qsd8x50.c
+++ b/arch/arm/mach-msm/devices-qsd8x50.c
@@ -15,7 +15,7 @@
 
 #include <linux/kernel.h>
 #include <linux/platform_device.h>
-#include <linux/msm_kgsl.h>
+#include <mach/kgsl.h>
 
 #include <linux/dma-mapping.h>
 #include <asm/clkdev.h>
diff --git a/arch/arm/mach-msm/idle-v7.S b/arch/arm/mach-msm/idle-v7.S
index b75f76f..ff7af32 100644
--- a/arch/arm/mach-msm/idle-v7.S
+++ b/arch/arm/mach-msm/idle-v7.S
@@ -28,6 +28,35 @@
 #endif
 
 ENTRY(msm_arch_idle)
+#ifdef CONFIG_ARCH_MSM_KRAIT
+	mrc 	p15, 0, r0, c0, c0, 0
+	bic	r1, r0, #0xff
+	movw	r2, #0x0400
+	movt	r2, #0x511F
+	movw	r3, #0x0600
+	movt	r3, #0x510F
+	cmp	r2, r1
+	cmpne	r3, r1
+	bne	go_wfi
+
+	mrs	r0, cpsr
+	cpsid	if
+
+	mrc	p15, 7, r1, c15, c0, 5
+	bic	r2, r1, #0x20000
+	mcr	p15, 7, r2, c15, c0, 5
+	isb
+
+go_wfi:
+	wfi
+	bne	wfi_done
+	mcr	p15, 7, r1, c15, c0, 5
+	isb
+	msr	cpsr_c, r0
+
+wfi_done:
+	bx	lr
+#else
 	wfi
 #ifdef CONFIG_ARCH_MSM8X60
 	mrc	p14, 1, r1, c1, c5, 4 /* read ETM PDSR to clear sticky bit */
@@ -35,6 +64,7 @@
 	isb
 #endif
 	bx	lr
+#endif
 
 ENTRY(msm_pm_collapse)
 #if defined(CONFIG_MSM_FIQ_SUPPORT)
diff --git a/arch/arm/mach-msm/include/mach/kgsl.h b/arch/arm/mach-msm/include/mach/kgsl.h
new file mode 100644
index 0000000..a51cc46
--- /dev/null
+++ b/arch/arm/mach-msm/include/mach/kgsl.h
@@ -0,0 +1,82 @@
+/* Copyright (c) 2012, Code Aurora Forum. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT 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 _ARCH_ARM_MACH_KGSL_H
+#define _ARCH_ARM_MACH_KGSL_H
+
+/* Clock flags to show which clocks should be controled by a given platform */
+#define KGSL_CLK_SRC	0x00000001
+#define KGSL_CLK_CORE	0x00000002
+#define KGSL_CLK_IFACE	0x00000004
+#define KGSL_CLK_MEM	0x00000008
+#define KGSL_CLK_MEM_IFACE 0x00000010
+#define KGSL_CLK_AXI	0x00000020
+
+#define KGSL_MAX_PWRLEVELS 5
+
+#define KGSL_CONVERT_TO_MBPS(val) \
+	(val*1000*1000U)
+
+#define KGSL_3D0_REG_MEMORY	"kgsl_3d0_reg_memory"
+#define KGSL_3D0_IRQ		"kgsl_3d0_irq"
+#define KGSL_2D0_REG_MEMORY	"kgsl_2d0_reg_memory"
+#define KGSL_2D0_IRQ		"kgsl_2d0_irq"
+#define KGSL_2D1_REG_MEMORY	"kgsl_2d1_reg_memory"
+#define KGSL_2D1_IRQ		"kgsl_2d1_irq"
+
+#define ADRENO_CHIPID(_co, _ma, _mi, _pa) \
+	((((_co) & 0xFF) << 24) | \
+	 (((_ma) & 0xFF) << 16) | \
+	 (((_mi) & 0xFF) << 8) | \
+	 ((_pa) & 0xFF))
+
+enum kgsl_iommu_context_id {
+	KGSL_IOMMU_CONTEXT_USER = 0,
+	KGSL_IOMMU_CONTEXT_PRIV = 1,
+};
+
+struct kgsl_iommu_ctx {
+	const char *iommu_ctx_name;
+	enum kgsl_iommu_context_id ctx_id;
+};
+
+struct kgsl_device_iommu_data {
+	const struct kgsl_iommu_ctx *iommu_ctxs;
+	int iommu_ctx_count;
+	unsigned int physstart;
+	unsigned int physend;
+};
+
+struct kgsl_pwrlevel {
+	unsigned int gpu_freq;
+	unsigned int bus_freq;
+	unsigned int io_fraction;
+};
+
+struct kgsl_device_platform_data {
+	struct kgsl_pwrlevel pwrlevel[KGSL_MAX_PWRLEVELS];
+	int init_level;
+	int num_levels;
+	int (*set_grp_async)(void);
+	unsigned int idle_timeout;
+	bool strtstp_sleepwake;
+	unsigned int nap_allowed;
+	unsigned int clk_map;
+	unsigned int idle_needed;
+	struct msm_bus_scale_pdata *bus_scale_table;
+	struct kgsl_device_iommu_data *iommu_data;
+	int iommu_count;
+	struct msm_dcvs_core_info *core_info;
+	unsigned int chipid;
+};
+
+#endif
diff --git a/arch/arm/mach-msm/include/mach/msm_iomap-8960.h b/arch/arm/mach-msm/include/mach/msm_iomap-8960.h
index 54c901f..2cea3c3 100644
--- a/arch/arm/mach-msm/include/mach/msm_iomap-8960.h
+++ b/arch/arm/mach-msm/include/mach/msm_iomap-8960.h
@@ -106,11 +106,6 @@
 #define MSM8960_QFPROM_PHYS		0x00700000
 #define MSM8960_QFPROM_SIZE		SZ_4K
 
-#ifdef CONFIG_DEBUG_MSM8960_UART
-#define MSM_DEBUG_UART_BASE	0xE1040000
-#define MSM_DEBUG_UART_PHYS	0x16440000
-#endif
-
 #ifndef __ASSEMBLY__
 extern void msm_map_msm8960_io(void);
 #endif
diff --git a/arch/arm/mach-msm/include/mach/qdsp5/qdsp5audppcmdi.h b/arch/arm/mach-msm/include/mach/qdsp5/qdsp5audppcmdi.h
index 86216d4..98f20a2 100644
--- a/arch/arm/mach-msm/include/mach/qdsp5/qdsp5audppcmdi.h
+++ b/arch/arm/mach-msm/include/mach/qdsp5/qdsp5audppcmdi.h
@@ -73,6 +73,7 @@
 #define AUDPP_CMD_ENA_DEC_V         	0x4000
 #define AUDPP_CMD_DIS_DEC_V        	0x0000
 #define AUDPP_CMD_DEC_STATE_M          	0x4000
+#define AUDPP_CMD_LPA_MODE		0x2000
 
 #define AUDPP_CMD_UPDATDE_CFG_DEC	0x8000
 #define AUDPP_CMD_DONT_UPDATE_CFG_DEC	0x0000
diff --git a/arch/arm/mach-msm/include/mach/socinfo.h b/arch/arm/mach-msm/include/mach/socinfo.h
index 15aebcd..9110632 100644
--- a/arch/arm/mach-msm/include/mach/socinfo.h
+++ b/arch/arm/mach-msm/include/mach/socinfo.h
@@ -66,6 +66,7 @@
 	MSM_CPU_8X55,
 	MSM_CPU_8X60,
 	MSM_CPU_8960,
+	MSM_CPU_8960AB,
 	MSM_CPU_7X27A,
 	FSM_CPU_9XXX,
 	MSM_CPU_7X25A,
@@ -245,6 +246,15 @@
 #endif
 }
 
+static inline int cpu_is_msm8960ab(void)
+{
+#ifdef CONFIG_ARCH_MSM8960
+	return read_msm_cpu_type() == MSM_CPU_8960AB;
+#else
+	return 0;
+#endif
+}
+
 static inline int cpu_is_apq8064(void)
 {
 #ifdef CONFIG_ARCH_APQ8064
diff --git a/arch/arm/mach-msm/krait-scm.c b/arch/arm/mach-msm/krait-scm.c
new file mode 100644
index 0000000..eb48d35
--- /dev/null
+++ b/arch/arm/mach-msm/krait-scm.c
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 2012, Code Aurora Forum. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT 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/workqueue.h>
+#include <linux/percpu.h>
+#include <linux/cpu.h>
+#include <linux/smp.h>
+#include <linux/sysfs.h>
+#include <linux/sysdev.h>
+
+#include <mach/scm.h>
+
+#define CPU_CONFIG_CMD 5
+#define CPU_CONFIG_QUERY_CMD 6
+
+static int query_cpu_config(void)
+{
+	struct cpu_config_query_req_resp {
+		u32	id;
+		u32	arg0;
+		u32	arg1;
+		u32	arg2;
+	} request;
+	struct cpu_config_query_resp {
+		u32	ret0;
+		u32	ret1;
+		u32	ret2;
+		u32	ret3;
+	} response = {0};
+	int ret;
+
+	request.id = 1;
+	ret = scm_call(SCM_SVC_BOOT, CPU_CONFIG_QUERY_CMD, &request,
+			sizeof(request), &response, sizeof(response));
+	return ret ? : response.ret0;
+}
+
+static void set_cpu_config(int enable)
+{
+	struct cpu_config_req {
+		u32	id;
+		u32	arg0;
+		u32	arg1;
+		u32	arg2;
+	} request;
+
+	request.id = 1;
+	request.arg0 = enable;
+	scm_call(SCM_SVC_BOOT, CPU_CONFIG_CMD, &request, sizeof(request),
+			NULL, 0);
+}
+
+void enable_cpu_config(struct work_struct *work)
+{
+	set_cpu_config(1);
+}
+
+void disable_cpu_config(struct work_struct *work)
+{
+	set_cpu_config(0);
+}
+
+int cpu_config_on_each_cpu(bool enable)
+{
+	work_func_t func = enable ? enable_cpu_config : disable_cpu_config;
+	return schedule_on_each_cpu(func);
+}
+
+static ssize_t show_cpuctl(struct sysdev_class *class,
+		struct sysdev_class_attribute *attr, char *buf)
+{
+	return snprintf(buf, PAGE_SIZE, "%d\n", query_cpu_config());
+}
+
+static ssize_t store_cpuctl(struct sysdev_class *class,
+		struct sysdev_class_attribute *attr, const char *buf,
+		size_t count)
+{
+	unsigned val;
+	int ret;
+
+	ret = kstrtouint(buf, 10, &val);
+	if (ret < 0)
+		return ret;
+	ret = cpu_config_on_each_cpu(val);
+	if (ret < 0)
+		return ret;
+
+	return count;
+}
+
+static SYSDEV_CLASS_ATTR(cpuctl, 0600, show_cpuctl, store_cpuctl);
+
+static int __init init_scm_cpu(void)
+{
+	return sysfs_create_file(&cpu_subsys.dev_root->kobj,
+			&attr_cpuctl.attr);
+}
+module_init(init_scm_cpu);
diff --git a/arch/arm/mach-msm/msm_xo.c b/arch/arm/mach-msm/msm_xo.c
index 9825ce5..8254502 100644
--- a/arch/arm/mach-msm/msm_xo.c
+++ b/arch/arm/mach-msm/msm_xo.c
@@ -235,7 +235,8 @@
 	int is_d0 = xo == &msm_xo_sources[MSM_XO_TCXO_D0];
 	int needs_workaround = cpu_is_msm8960() || cpu_is_apq8064() ||
 			       cpu_is_msm8930() || cpu_is_msm8930aa() ||
-			       cpu_is_msm9615() || cpu_is_msm8627();
+			       cpu_is_msm9615() || cpu_is_msm8627() ||
+			       cpu_is_msm8960ab();
 
 	if (xo_voter->mode == mode)
 		return 0;
diff --git a/arch/arm/mach-msm/platsmp.c b/arch/arm/mach-msm/platsmp.c
index 48a236f..5e063a1 100644
--- a/arch/arm/mach-msm/platsmp.c
+++ b/arch/arm/mach-msm/platsmp.c
@@ -143,7 +143,7 @@
 		return krait_release_secondary_sim(0xf9088000, cpu);
 
 	if (cpu_is_msm8960() || cpu_is_msm8930() || cpu_is_msm8930aa() ||
-	    cpu_is_apq8064() || cpu_is_msm8627())
+	    cpu_is_apq8064() || cpu_is_msm8627() || cpu_is_msm8960ab())
 		return krait_release_secondary(0x02088000, cpu);
 
 	WARN(1, "unknown CPU case in release_secondary\n");
diff --git a/arch/arm/mach-msm/pm-8x60.c b/arch/arm/mach-msm/pm-8x60.c
index 15a0b6a..42616c6 100644
--- a/arch/arm/mach-msm/pm-8x60.c
+++ b/arch/arm/mach-msm/pm-8x60.c
@@ -591,7 +591,7 @@
 
 static int64_t msm_pm_timer_enter_suspend(int64_t *period)
 {
-	int time = 0;
+	int64_t time = 0;
 
 	if (msm_pm_use_qtimer)
 		return sched_clock();
@@ -808,10 +808,15 @@
 {
 	enum msm_pm_sleep_mode mode = per_cpu(msm_pm_last_slp_mode, cpu);
 
-	if (msm_pm_slp_sts)
-		if ((mode == MSM_PM_SLEEP_MODE_POWER_COLLAPSE) ||
-			(mode == MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE))
+	if (msm_pm_slp_sts) {
+		int acc_sts = __raw_readl(msm_pm_slp_sts->base_addr
+					+ cpu * msm_pm_slp_sts->cpu_offset);
+
+		if ((acc_sts & msm_pm_slp_sts->mask) &&
+			((mode == MSM_PM_SLEEP_MODE_POWER_COLLAPSE) ||
+			 (mode == MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE)))
 			return true;
+	}
 
 	return false;
 }
diff --git a/arch/arm/mach-msm/pm2.c b/arch/arm/mach-msm/pm2.c
index ae7a3cd..7a8e4c3 100644
--- a/arch/arm/mach-msm/pm2.c
+++ b/arch/arm/mach-msm/pm2.c
@@ -1280,7 +1280,7 @@
 
 static int64_t msm_pm_timer_enter_suspend(int64_t *period)
 {
-	int time = 0;
+	int64_t time = 0;
 
 	time = msm_timer_get_sclk_time(period);
 	if (!time)
diff --git a/arch/arm/mach-msm/qdsp5/audio_lpa.c b/arch/arm/mach-msm/qdsp5/audio_lpa.c
index 14a9e57..fe7b270 100644
--- a/arch/arm/mach-msm/qdsp5/audio_lpa.c
+++ b/arch/arm/mach-msm/qdsp5/audio_lpa.c
@@ -464,7 +464,8 @@
 	cfg_dec_cmd[0] = AUDPP_CMD_CFG_DEC_TYPE;
 	if (enable)
 		cfg_dec_cmd[1 + audio->dec_id] = AUDPP_CMD_UPDATDE_CFG_DEC |
-				AUDPP_CMD_ENA_DEC_V | AUDDEC_DEC_PCM;
+				AUDPP_CMD_ENA_DEC_V | AUDDEC_DEC_PCM |
+				AUDPP_CMD_LPA_MODE;
 	else
 		cfg_dec_cmd[1 + audio->dec_id] = AUDPP_CMD_UPDATDE_CFG_DEC |
 				AUDPP_CMD_DIS_DEC_V;
diff --git a/arch/arm/mach-msm/qdsp5v2/adsp.c b/arch/arm/mach-msm/qdsp5v2/adsp.c
index acd9c4c..8c1413c 100644
--- a/arch/arm/mach-msm/qdsp5v2/adsp.c
+++ b/arch/arm/mach-msm/qdsp5v2/adsp.c
@@ -883,7 +883,7 @@
 			rc = -ETIMEDOUT;
 		}
 		if (module->open_count++ == 0 && module->clk)
-			clk_enable(module->clk);
+			clk_prepare_enable(module->clk);
 
 		mutex_lock(&adsp_open_lock);
 		if (adsp_open_count++ == 0)
@@ -938,7 +938,7 @@
 		mutex_lock(&module->lock);
 		module->state = ADSP_STATE_DISABLED;
 		if (--module->open_count == 0 && module->clk)
-			clk_disable(module->clk);
+			clk_disable_unprepare(module->clk);
 		mutex_unlock(&module->lock);
 		mutex_lock(&adsp_open_lock);
 		if (--adsp_open_count == 0) {
diff --git a/arch/arm/mach-msm/qdsp5v2/lpa.c b/arch/arm/mach-msm/qdsp5v2/lpa.c
index c4e0fee..98297e3 100644
--- a/arch/arm/mach-msm/qdsp5v2/lpa.c
+++ b/arch/arm/mach-msm/qdsp5v2/lpa.c
@@ -73,7 +73,7 @@
 		MM_ERR("failed to get adsp clk\n");
 		goto error;
 	}
-	clk_enable(adsp_clk);
+	clk_prepare_enable(adsp_clk);
 	lpa_enable_codec(lpa, 0);
 	LPA_REG_WRITEL(lpa, (LPA_OBUF_RESETS_MISR_RESET |
 		LPA_OBUF_RESETS_OVERALL_RESET), LPA_OBUF_RESETS);
@@ -83,7 +83,7 @@
 
 	LPA_REG_WRITEL(lpa, LPA_OBUF_ACK_RESET_DONE_BMSK, LPA_OBUF_ACK);
 	mb();
-	clk_disable(adsp_clk);
+	clk_disable_unprepare(adsp_clk);
 	clk_put(adsp_clk);
 error:
 	return;
diff --git a/arch/arm/mach-msm/qdsp5v2/snddev_ecodec.c b/arch/arm/mach-msm/qdsp5v2/snddev_ecodec.c
index a5da912..943489a 100644
--- a/arch/arm/mach-msm/qdsp5v2/snddev_ecodec.c
+++ b/arch/arm/mach-msm/qdsp5v2/snddev_ecodec.c
@@ -60,7 +60,7 @@
 			goto done;
 		}
 		/* config clocks */
-		clk_enable(drv->lpa_core_clk);
+		clk_prepare_enable(drv->lpa_core_clk);
 
 		/*if long sync is selected in aux PCM interface
 		ecodec clock is updated to work with 128KHz,
@@ -96,7 +96,7 @@
 		}
 
 		/* enable ecodec clk */
-		clk_enable(drv->ecodec_clk);
+		clk_prepare_enable(drv->ecodec_clk);
 
 		/* let ADSP confiure AUX PCM regs */
 		aux_codec_adsp_codec_ctl_en(ADSP_CTL);
@@ -109,7 +109,7 @@
 		audio_interct_tpcm_source(AUDIO_ADSP_A);
 		audio_interct_rpcm_source(AUDIO_ADSP_A);
 
-		clk_disable(drv->lpa_core_clk);
+		clk_disable_unprepare(drv->lpa_core_clk);
 
 		/* send AUX_CODEC_CONFIG to AFE */
 		rc = afe_config_aux_codec(ecodec->data->conf_pcm_ctl_val,
@@ -126,7 +126,7 @@
 	if (IS_ERR_VALUE(rc)) {
 		if (!drv->tx_active) {
 			aux_pcm_gpios_free();
-			clk_disable(drv->ecodec_clk);
+			clk_disable_unprepare(drv->ecodec_clk);
 		}
 		goto done;
 	}
@@ -136,7 +136,7 @@
 
 error:
 	aux_pcm_gpios_free();
-	clk_disable(drv->ecodec_clk);
+	clk_disable_unprepare(drv->ecodec_clk);
 done:
 	return rc;
 }
@@ -148,7 +148,7 @@
 	/* free GPIO */
 	if (!drv->tx_active) {
 		aux_pcm_gpios_free();
-		clk_disable(drv->ecodec_clk);
+		clk_disable_unprepare(drv->ecodec_clk);
 	}
 
 	/* disable AFE */
@@ -176,7 +176,7 @@
 			goto done;
 		}
 		/* config clocks */
-		clk_enable(drv->lpa_core_clk);
+		clk_prepare_enable(drv->lpa_core_clk);
 
 		/*if long sync is selected in aux PCM interface
 		ecodec clock is updated to work with 128KHz,
@@ -212,7 +212,7 @@
 		}
 
 		/* enable ecodec clk */
-		clk_enable(drv->ecodec_clk);
+		clk_prepare_enable(drv->ecodec_clk);
 
 		/* let ADSP confiure AUX PCM regs */
 		aux_codec_adsp_codec_ctl_en(ADSP_CTL);
@@ -225,7 +225,7 @@
 		audio_interct_tpcm_source(AUDIO_ADSP_A);
 		audio_interct_rpcm_source(AUDIO_ADSP_A);
 
-		clk_disable(drv->lpa_core_clk);
+		clk_disable_unprepare(drv->lpa_core_clk);
 
 		/* send AUX_CODEC_CONFIG to AFE */
 		rc = afe_config_aux_codec(ecodec->data->conf_pcm_ctl_val,
@@ -242,7 +242,7 @@
 	if (IS_ERR_VALUE(rc)) {
 		if (!drv->rx_active) {
 			aux_pcm_gpios_free();
-			clk_disable(drv->ecodec_clk);
+			clk_disable_unprepare(drv->ecodec_clk);
 		}
 		goto done;
 	}
@@ -251,7 +251,7 @@
 	return 0;
 
 error:
-	clk_disable(drv->ecodec_clk);
+	clk_disable_unprepare(drv->ecodec_clk);
 	aux_pcm_gpios_free();
 done:
 	return rc;
@@ -264,7 +264,7 @@
 	/* free GPIO */
 	if (!drv->rx_active) {
 		aux_pcm_gpios_free();
-		clk_disable(drv->ecodec_clk);
+		clk_disable_unprepare(drv->ecodec_clk);
 	}
 
 	/* disable AFE */
diff --git a/arch/arm/mach-msm/qdsp5v2/snddev_icodec.c b/arch/arm/mach-msm/qdsp5v2/snddev_icodec.c
index 80c9a01..c416c07 100644
--- a/arch/arm/mach-msm/qdsp5v2/snddev_icodec.c
+++ b/arch/arm/mach-msm/qdsp5v2/snddev_icodec.c
@@ -199,12 +199,12 @@
 		SNDDEV_ICODEC_CLK_RATE(icodec->sample_rate));
 	if (IS_ERR_VALUE(trc))
 		goto error_invalid_freq;
-	clk_enable(drv->rx_mclk);
-	clk_enable(drv->rx_sclk);
+	clk_prepare_enable(drv->rx_mclk);
+	clk_prepare_enable(drv->rx_sclk);
 	/* clk_set_rate(drv->lpa_codec_clk, 1); */ /* Remove if use pcom */
-	clk_enable(drv->lpa_p_clk);
-	clk_enable(drv->lpa_codec_clk);
-	clk_enable(drv->lpa_core_clk);
+	clk_prepare_enable(drv->lpa_p_clk);
+	clk_prepare_enable(drv->lpa_codec_clk);
+	clk_prepare_enable(drv->lpa_core_clk);
 
 	/* Enable LPA sub system
 	 */
@@ -263,11 +263,11 @@
 error_adie:
 	lpa_put(drv->lpa);
 error_lpa:
-	clk_disable(drv->lpa_p_clk);
-	clk_disable(drv->lpa_codec_clk);
-	clk_disable(drv->lpa_core_clk);
-	clk_disable(drv->rx_sclk);
-	clk_disable(drv->rx_mclk);
+	clk_disable_unprepare(drv->lpa_p_clk);
+	clk_disable_unprepare(drv->lpa_codec_clk);
+	clk_disable_unprepare(drv->lpa_core_clk);
+	clk_disable_unprepare(drv->rx_sclk);
+	clk_disable_unprepare(drv->rx_mclk);
 error_invalid_freq:
 
 	MM_ERR("encounter error\n");
@@ -307,8 +307,8 @@
 		SNDDEV_ICODEC_CLK_RATE(icodec->sample_rate));
 	if (IS_ERR_VALUE(trc))
 		goto error_invalid_freq;
-	clk_enable(drv->tx_mclk);
-	clk_enable(drv->tx_sclk);
+	clk_prepare_enable(drv->tx_mclk);
+	clk_prepare_enable(drv->tx_sclk);
 
 	/* Set MI2S */
 	mi2s_set_codec_input_path((icodec->data->channel_mode ==
@@ -344,8 +344,8 @@
 	adie_codec_close(icodec->adie_path);
 	icodec->adie_path = NULL;
 error_adie:
-	clk_disable(drv->tx_sclk);
-	clk_disable(drv->tx_mclk);
+	clk_disable_unprepare(drv->tx_sclk);
+	clk_disable_unprepare(drv->tx_mclk);
 error_invalid_freq:
 
 	/* Disable mic bias */
@@ -414,14 +414,14 @@
 	lpa_put(drv->lpa);
 
 	/* Disable LPA clocks */
-	clk_disable(drv->lpa_p_clk);
-	clk_disable(drv->lpa_codec_clk);
-	clk_disable(drv->lpa_core_clk);
+	clk_disable_unprepare(drv->lpa_p_clk);
+	clk_disable_unprepare(drv->lpa_codec_clk);
+	clk_disable_unprepare(drv->lpa_core_clk);
 
 	/* Disable MI2S RX master block */
 	/* Disable MI2S RX bit clock */
-	clk_disable(drv->rx_sclk);
-	clk_disable(drv->rx_mclk);
+	clk_disable_unprepare(drv->rx_sclk);
+	clk_disable_unprepare(drv->rx_mclk);
 
 	icodec->enabled = 0;
 
@@ -452,8 +452,8 @@
 
 	/* Disable MI2S TX master block */
 	/* Disable MI2S TX bit clock */
-	clk_disable(drv->tx_sclk);
-	clk_disable(drv->tx_mclk);
+	clk_disable_unprepare(drv->tx_sclk);
+	clk_disable_unprepare(drv->tx_mclk);
 
 	/* Disable mic bias */
 	for (i = 0; i < icodec->data->pmctl_id_sz; i++) {
@@ -889,8 +889,8 @@
 		/* enable MI2S RX bit clock */
 		clk_set_rate(drv->rx_mclk,
 			SNDDEV_ICODEC_CLK_RATE(8000));
-		clk_enable(drv->rx_mclk);
-		clk_enable(drv->rx_sclk);
+		clk_prepare_enable(drv->rx_mclk);
+		clk_prepare_enable(drv->rx_sclk);
 
 		MM_INFO("configure ADIE RX path\n");
 		/* Configure ADIE */
@@ -905,8 +905,8 @@
 		/* enable MI2S TX bit clock */
 		clk_set_rate(drv->tx_mclk,
 			SNDDEV_ICODEC_CLK_RATE(8000));
-		clk_enable(drv->tx_mclk);
-		clk_enable(drv->tx_sclk);
+		clk_prepare_enable(drv->tx_mclk);
+		clk_prepare_enable(drv->tx_sclk);
 
 		MM_INFO("configure ADIE TX path\n");
 		/* Configure ADIE */
@@ -927,13 +927,13 @@
 
 		/* Disable MI2S RX master block */
 		/* Disable MI2S RX bit clock */
-		clk_disable(drv->rx_sclk);
-		clk_disable(drv->rx_mclk);
+		clk_disable_unprepare(drv->rx_sclk);
+		clk_disable_unprepare(drv->rx_mclk);
 
 		/* Disable MI2S TX master block */
 		/* Disable MI2S TX bit clock */
-		clk_disable(drv->tx_sclk);
-		clk_disable(drv->tx_mclk);
+		clk_disable_unprepare(drv->tx_sclk);
+		clk_disable_unprepare(drv->tx_mclk);
 	}
 }
 
@@ -955,11 +955,11 @@
 		SNDDEV_ICODEC_CLK_RATE(8000));
 		if (IS_ERR_VALUE(trc))
 			MM_ERR("failed to set clk rate\n");
-		clk_enable(drv->rx_mclk);
-		clk_enable(drv->rx_sclk);
-		clk_enable(drv->lpa_p_clk);
-		clk_enable(drv->lpa_codec_clk);
-		clk_enable(drv->lpa_core_clk);
+		clk_prepare_enable(drv->rx_mclk);
+		clk_prepare_enable(drv->rx_sclk);
+		clk_prepare_enable(drv->lpa_p_clk);
+		clk_prepare_enable(drv->lpa_codec_clk);
+		clk_prepare_enable(drv->lpa_core_clk);
 		/* Enable LPA sub system
 		 */
 		drv->lpa = lpa_get();
@@ -1003,8 +1003,8 @@
 		/* enable MI2S TX bit clock */
 		clk_set_rate(drv->tx_mclk,
 			SNDDEV_ICODEC_CLK_RATE(8000));
-		clk_enable(drv->tx_mclk);
-		clk_enable(drv->tx_sclk);
+		clk_prepare_enable(drv->tx_mclk);
+		clk_prepare_enable(drv->tx_sclk);
 		/* Set MI2S */
 		mi2s_set_codec_input_path(MI2S_CHAN_MONO_PACKED, WT_16_BIT);
 		MM_INFO("configure ADIE TX path\n");
@@ -1048,14 +1048,14 @@
 		lpa_put(drv->lpa);
 
 		/* Disable LPA clocks */
-		clk_disable(drv->lpa_p_clk);
-		clk_disable(drv->lpa_codec_clk);
-		clk_disable(drv->lpa_core_clk);
+		clk_disable_unprepare(drv->lpa_p_clk);
+		clk_disable_unprepare(drv->lpa_codec_clk);
+		clk_disable_unprepare(drv->lpa_core_clk);
 
 		/* Disable MI2S RX master block */
 		/* Disable MI2S RX bit clock */
-		clk_disable(drv->rx_sclk);
-		clk_disable(drv->rx_mclk);
+		clk_disable_unprepare(drv->rx_sclk);
+		clk_disable_unprepare(drv->rx_mclk);
 
 		pmapp_smps_mode_vote(SMPS_AUDIO_RECORD_ID,
 			PMAPP_VREG_S4, PMAPP_SMPS_MODE_VOTE_DONTCARE);
@@ -1069,8 +1069,8 @@
 		adie_codec_close(debugfs_tx_adie);
 		/* Disable MI2S TX master block */
 		/* Disable MI2S TX bit clock */
-		clk_disable(drv->tx_sclk);
-		clk_disable(drv->tx_mclk);
+		clk_disable_unprepare(drv->tx_sclk);
+		clk_disable_unprepare(drv->tx_mclk);
 		pmic_hsed_enable(PM_HSED_CONTROLLER_0, PM_HSED_ENABLE_OFF);
 		MM_INFO("AFE loopback disabled\n");
 	}
diff --git a/arch/arm/mach-msm/qdsp5v2/snddev_mi2s.c b/arch/arm/mach-msm/qdsp5v2/snddev_mi2s.c
index 939cc8b..b5f3b66 100644
--- a/arch/arm/mach-msm/qdsp5v2/snddev_mi2s.c
+++ b/arch/arm/mach-msm/qdsp5v2/snddev_mi2s.c
@@ -154,12 +154,12 @@
 			mutex_unlock(&drv->lock);
 			return -EIO;
 		}
-		clk_enable(drv->mclk);
-		clk_enable(drv->sclk);
+		clk_prepare_enable(drv->mclk);
+		clk_prepare_enable(drv->sclk);
 		drv->clocks_enabled = 1;
-		MM_DBG("%s: clks enabled \n", __func__);
+		MM_DBG("%s: clks enabled\n", __func__);
 	} else
-		MM_DBG("%s: clks already enabled \n", __func__);
+		MM_DBG("%s: clks already enabled\n", __func__);
 
 	if (snddev_mi2s_data->capability & SNDDEV_CAP_RX) {
 
@@ -225,8 +225,8 @@
 
 mi2s_data_gpio_failure:
 	if (!drv->sd_lines_used) {
-		clk_disable(drv->sclk);
-		clk_disable(drv->mclk);
+		clk_disable_unprepare(drv->sclk);
+		clk_disable_unprepare(drv->mclk);
 		drv->clocks_enabled = 0;
 		mi2s_unconfig_clk_gpio();
 	}
@@ -268,8 +268,8 @@
 	mi2s_unconfig_data_gpio(dir, snddev_mi2s_data->sd_lines);
 
 	if (!drv->sd_lines_used) {
-		clk_disable(drv->sclk);
-		clk_disable(drv->mclk);
+		clk_disable_unprepare(drv->sclk);
+		clk_disable_unprepare(drv->mclk);
 		drv->clocks_enabled = 0;
 		mi2s_unconfig_clk_gpio();
 	}
diff --git a/arch/arm/mach-msm/rpm-smd.c b/arch/arm/mach-msm/rpm-smd.c
index 0edea3f..b8bb27b 100644
--- a/arch/arm/mach-msm/rpm-smd.c
+++ b/arch/arm/mach-msm/rpm-smd.c
@@ -52,7 +52,7 @@
 #define ERR "err\0"
 #define MAX_ERR_BUFFER_SIZE 60
 
-static struct atomic_notifier_head msm_rpm_sleep_notifier;
+static ATOMIC_NOTIFIER_HEAD(msm_rpm_sleep_notifier);
 static bool standalone;
 
 int msm_rpm_register_notifier(struct notifier_block *nb)
diff --git a/arch/arm/mach-msm/rpm_resources.c b/arch/arm/mach-msm/rpm_resources.c
index 667ede0..a88e42e 100644
--- a/arch/arm/mach-msm/rpm_resources.c
+++ b/arch/arm/mach-msm/rpm_resources.c
@@ -1106,7 +1106,7 @@
 static int __init msm_rpmrs_l2_init(void)
 {
 	if (cpu_is_msm8960() || cpu_is_msm8930() || cpu_is_msm8930aa() ||
-	    cpu_is_apq8064() || cpu_is_msm8627()) {
+	    cpu_is_apq8064() || cpu_is_msm8627() || cpu_is_msm8960ab()) {
 
 		msm_pm_set_l2_flush_flag(0);
 
diff --git a/arch/arm/mach-msm/socinfo.c b/arch/arm/mach-msm/socinfo.c
index 08af4d4..281e7b8 100644
--- a/arch/arm/mach-msm/socinfo.c
+++ b/arch/arm/mach-msm/socinfo.c
@@ -259,8 +259,16 @@
 	/* 9625 IDs */
 	[134] = MSM_CPU_9625,
 
-	/* 8930AA ID */
+	/* 8960AB IDs */
+	[138] = MSM_CPU_8960AB,
+	[139] = MSM_CPU_8960AB,
+	[140] = MSM_CPU_8960AB,
+	[141] = MSM_CPU_8960AB,
+
+	/* 8930AA IDs */
 	[142] = MSM_CPU_8930AA,
+	[143] = MSM_CPU_8930AA,
+	[144] = MSM_CPU_8930AA,
 
 	/* Uninitialized IDs are not known to run Linux.
 	   MSM_CPU_UNKNOWN is set to 0 to ensure these IDs are
diff --git a/arch/arm/mach-msm/spm_devices.c b/arch/arm/mach-msm/spm_devices.c
index 9d2aedc..9e9b661 100644
--- a/arch/arm/mach-msm/spm_devices.c
+++ b/arch/arm/mach-msm/spm_devices.c
@@ -137,7 +137,7 @@
 	reg = saw_bases[cpu];
 
 	if (cpu_is_msm8960() || cpu_is_msm8930() || cpu_is_msm8930aa() ||
-	    cpu_is_apq8064() || cpu_is_msm8627()) {
+	    cpu_is_apq8064() || cpu_is_msm8627() || cpu_is_msm8960ab()) {
 		val = 0xA4;
 		reg += 0x14;
 		timeout = 512;
diff --git a/arch/arm/mach-msm/subsystem_restart.c b/arch/arm/mach-msm/subsystem_restart.c
index a9a25b3..0b6f225 100644
--- a/arch/arm/mach-msm/subsystem_restart.c
+++ b/arch/arm/mach-msm/subsystem_restart.c
@@ -569,7 +569,8 @@
 	}
 
 	if (cpu_is_msm8960() || cpu_is_msm8930() || cpu_is_msm8930aa() ||
-	    cpu_is_msm9615() || cpu_is_apq8064() || cpu_is_msm8627()) {
+	    cpu_is_msm9615() || cpu_is_apq8064() || cpu_is_msm8627() ||
+	    cpu_is_msm8960ab()) {
 		if (socinfo_get_platform_subtype() == PLATFORM_SUBTYPE_SGLTE) {
 			restart_orders = restart_orders_8960_sglte;
 			n_restart_orders =
diff --git a/arch/arm/mach-msm/timer.c b/arch/arm/mach-msm/timer.c
index 8d31683..668f4cc 100644
--- a/arch/arm/mach-msm/timer.c
+++ b/arch/arm/mach-msm/timer.c
@@ -965,7 +965,8 @@
 		return 0;
 
 	if (cpu_is_msm8x60() || cpu_is_msm8960() || cpu_is_apq8064() ||
-	    cpu_is_msm8930() || cpu_is_msm8930aa() || cpu_is_msm8627())
+	    cpu_is_msm8930() || cpu_is_msm8930aa() || cpu_is_msm8627() ||
+	    cpu_is_msm8960ab())
 		__raw_writel(DGT_CLK_CTL_DIV_4, MSM_TMR_BASE + DGT_CLK_CTL);
 
 	if (__get_cpu_var(first_boot)) {
@@ -1062,7 +1063,8 @@
 		gpt->flags |= MSM_CLOCK_FLAGS_UNSTABLE_COUNT;
 		dgt->flags |= MSM_CLOCK_FLAGS_UNSTABLE_COUNT;
 	} else if (cpu_is_msm8960() || cpu_is_apq8064() || cpu_is_msm8930() ||
-		   cpu_is_msm8930aa() || cpu_is_msm8627()) {
+		   cpu_is_msm8930aa() || cpu_is_msm8627() ||
+		   cpu_is_msm8960ab()) {
 		global_timer_offset = MSM_TMR0_BASE - MSM_TMR_BASE;
 		dgt->freq = 6750000;
 		__raw_writel(DGT_CLK_CTL_DIV_4, MSM_TMR_BASE + DGT_CLK_CTL);
@@ -1072,7 +1074,7 @@
 		gpt_hz = 32765;
 		sclk_hz = 32765;
 		if (!cpu_is_msm8930() && !cpu_is_msm8930aa() &&
-		    !cpu_is_msm8627()) {
+		    !cpu_is_msm8627() && !cpu_is_msm8960ab()) {
 			gpt->flags |= MSM_CLOCK_FLAGS_UNSTABLE_COUNT;
 			dgt->flags |= MSM_CLOCK_FLAGS_UNSTABLE_COUNT;
 		}
@@ -1123,8 +1125,9 @@
 
 		ce->irq = clock->irq;
 		if (cpu_is_msm8x60() || cpu_is_msm8960() || cpu_is_apq8064() ||
-		    cpu_is_msm8930() || cpu_is_msm8930aa() ||
-		    cpu_is_msm9615() || cpu_is_msm8625() || cpu_is_msm8627()) {
+		    cpu_is_msm8930() || cpu_is_msm9615() || cpu_is_msm8625() ||
+		    cpu_is_msm8627() || cpu_is_msm8930aa() ||
+		    cpu_is_msm8960ab()) {
 			clock->percpu_evt = alloc_percpu(struct clock_event_device *);
 			if (!clock->percpu_evt) {
 				pr_err("msm_timer_init: memory allocation "
diff --git a/arch/arm/mach-msm/wcnss-ssr-8960.c b/arch/arm/mach-msm/wcnss-ssr-8960.c
index 793ef7f..6e8d57c 100644
--- a/arch/arm/mach-msm/wcnss-ssr-8960.c
+++ b/arch/arm/mach-msm/wcnss-ssr-8960.c
@@ -158,10 +158,9 @@
 	return ret;
 }
 
-/* RAM segments for Riva SS;
- * We don't specify the full 5MB allocated for Riva. Only 3MB is specified */
+/* 5MB RAM segments for Riva SS */
 static struct ramdump_segment riva_segments[] = {{0x8f200000,
-						0x8f500000 - 0x8f200000} };
+						0x8f700000 - 0x8f200000} };
 
 static int riva_ramdump(int enable, const struct subsys_data *subsys)
 {
diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
index a20b6cb..da33be0 100644
--- a/arch/arm/mm/mmu.c
+++ b/arch/arm/mm/mmu.c
@@ -839,6 +839,79 @@
 	}
 }
 
+#ifndef CONFIG_ARM_LPAE
+
+/*
+ * The Linux PMD is made of two consecutive section entries covering 2MB
+ * (see definition in include/asm/pgtable-2level.h).  However a call to
+ * create_mapping() may optimize static mappings by using individual
+ * 1MB section mappings.  This leaves the actual PMD potentially half
+ * initialized if the top or bottom section entry isn't used, leaving it
+ * open to problems if a subsequent ioremap() or vmalloc() tries to use
+ * the virtual space left free by that unused section entry.
+ *
+ * Let's avoid the issue by inserting dummy vm entries covering the unused
+ * PMD halves once the static mappings are in place.
+ */
+
+static void __init pmd_empty_section_gap(unsigned long addr)
+{
+	struct vm_struct *vm;
+
+	vm = early_alloc_aligned(sizeof(*vm), __alignof__(*vm));
+	vm->addr = (void *)addr;
+	vm->size = SECTION_SIZE;
+	vm->flags = VM_IOREMAP | VM_ARM_STATIC_MAPPING;
+	vm->caller = pmd_empty_section_gap;
+	vm_area_add_early(vm);
+}
+
+static void __init fill_pmd_gaps(void)
+{
+	struct vm_struct *vm;
+	unsigned long addr, next = 0;
+	pmd_t *pmd;
+
+	/* we're still single threaded hence no lock needed here */
+	for (vm = vmlist; vm; vm = vm->next) {
+		if (!(vm->flags & VM_ARM_STATIC_MAPPING))
+			continue;
+		addr = (unsigned long)vm->addr;
+		if (addr < next)
+			continue;
+
+		/*
+		 * Check if this vm starts on an odd section boundary.
+		 * If so and the first section entry for this PMD is free
+		 * then we block the corresponding virtual address.
+		 */
+		if ((addr & ~PMD_MASK) == SECTION_SIZE) {
+			pmd = pmd_off_k(addr);
+			if (pmd_none(*pmd))
+				pmd_empty_section_gap(addr & PMD_MASK);
+		}
+
+		/*
+		 * Then check if this vm ends on an odd section boundary.
+		 * If so and the second section entry for this PMD is empty
+		 * then we block the corresponding virtual address.
+		 */
+		addr += vm->size;
+		if ((addr & ~PMD_MASK) == SECTION_SIZE) {
+			pmd = pmd_off_k(addr) + 1;
+			if (pmd_none(*pmd))
+				pmd_empty_section_gap(addr);
+		}
+
+		/* no need to look at any vm entry until we hit the next PMD */
+		next = (addr + PMD_SIZE - 1) & PMD_MASK;
+	}
+}
+
+#else
+#define fill_pmd_gaps() do { } while (0)
+#endif
+
 static void * __initdata vmalloc_min =
 	(void *)(VMALLOC_END - (240 << 20) - VMALLOC_OFFSET);
 
@@ -1128,6 +1201,7 @@
 	 */
 	if (mdesc->map_io)
 		mdesc->map_io();
+	fill_pmd_gaps();
 
 	/*
 	 * Finally flush the caches and tlb to ensure that we're in a
diff --git a/block/test-iosched.c b/block/test-iosched.c
index 3c38734..ce9527f 100644
--- a/block/test-iosched.c
+++ b/block/test-iosched.c
@@ -127,7 +127,7 @@
 	test_pr_info("%s: request %d completed, err=%d",
 	       __func__, test_rq->req_id, err);
 
-	test_rq->req_completed = 1;
+	test_rq->req_completed = true;
 	test_rq->req_result = err;
 
 	check_test_completion();
@@ -204,8 +204,8 @@
 		blk_put_request(rq);
 		return -ENODEV;
 	}
-	test_rq->req_completed = 0;
-	test_rq->req_result = -1;
+	test_rq->req_completed = false;
+	test_rq->req_result = -EINVAL;
 	test_rq->rq = rq;
 	test_rq->is_err_expected = is_err_expcted;
 	rq->elv.priv[0] = (void *)test_rq;
@@ -347,8 +347,8 @@
 	ptd->num_of_write_bios += num_bios;
 	test_rq->req_id = ptd->wr_rd_next_req_id++;
 
-	test_rq->req_completed = 0;
-	test_rq->req_result = -1;
+	test_rq->req_completed = false;
+	test_rq->req_result = -EINVAL;
 	test_rq->rq = rq;
 	test_rq->is_err_expected = is_err_expcted;
 	rq->elv.priv[0] = (void *)test_rq;
@@ -519,10 +519,26 @@
 static void free_test_requests(struct test_data *td)
 {
 	struct test_request *test_rq;
+	struct bio *bio;
+
 	while (!list_empty(&td->test_queue)) {
 		test_rq = list_entry(td->test_queue.next, struct test_request,
 				     queuelist);
 		list_del_init(&test_rq->queuelist);
+		/*
+		 * If the request was not completed we need to free its BIOs
+		 * and remove it from the packed list
+		 */
+		if (!test_rq->req_completed) {
+			test_pr_info(
+				"%s: Freeing memory of an uncompleted request",
+				__func__);
+			list_del_init(&test_rq->rq->queuelist);
+			while ((bio = test_rq->rq->bio) != NULL) {
+				test_rq->rq->bio = bio->bi_next;
+				bio_put(bio);
+			}
+		}
 		blk_put_request(test_rq->rq);
 		kfree(test_rq->bios_buffer);
 		kfree(test_rq);
@@ -606,7 +622,8 @@
 			test_pr_info(
 				"%s: Another test is running, try again later",
 				__func__);
-			return -EINVAL;
+			spin_unlock(&ptd->lock);
+			return -EBUSY;
 		}
 
 		if (ptd->start_sector == 0) {
@@ -698,9 +715,8 @@
 		return -EINVAL;
 
 error:
-	ptd->test_result = TEST_FAILED;
-	ptd->test_info.testcase = 0;
 	post_test(ptd);
+	ptd->test_result = TEST_FAILED;
 	return ret;
 }
 EXPORT_SYMBOL(test_iosched_start_test);
diff --git a/drivers/bluetooth/hci_smd.c b/drivers/bluetooth/hci_smd.c
index 66bd739..6030520 100644
--- a/drivers/bluetooth/hci_smd.c
+++ b/drivers/bluetooth/hci_smd.c
@@ -42,6 +42,7 @@
  */
 
 #define RX_Q_MONITOR		(500)	/* 500 milli second */
+#define HCI_REGISTER_SET	0
 
 
 static int hcismd_set;
@@ -57,7 +58,7 @@
 
 struct hci_smd_data {
 	struct hci_dev *hdev;
-
+	unsigned long flags;
 	struct smd_channel *event_channel;
 	struct smd_channel *data_channel;
 	struct wake_lock wake_lock_tx;
@@ -403,11 +404,16 @@
 	struct hci_dev *hdev;
 
 	hdev = hsmd->hdev;
-
+	if (test_and_set_bit(HCI_REGISTER_SET, &hsmd->flags)) {
+		BT_ERR("HCI device registered already");
+		return 0;
+	} else
+		BT_INFO("HCI device registration is starting");
 	if (hci_register_dev(hdev) < 0) {
 		BT_ERR("Can't register HCI device");
 		hci_free_dev(hdev);
 		hsmd->hdev = NULL;
+		clear_bit(HCI_REGISTER_SET, &hsmd->flags);
 		return -ENODEV;
 	}
 	return 0;
@@ -473,6 +479,11 @@
 {
 	tasklet_kill(&hs.rx_task);
 
+	if (!test_and_clear_bit(HCI_REGISTER_SET, &hsmd->flags)) {
+		BT_ERR("HCI device un-registered already");
+		return;
+	} else
+		BT_INFO("HCI device un-registration going on");
 	if (hsmd->hdev) {
 		if (hci_unregister_dev(hsmd->hdev) < 0)
 			BT_ERR("Can't unregister HCI device %s",
diff --git a/drivers/char/diag/diagchar.h b/drivers/char/diag/diagchar.h
index 6a7b931..2f356f0 100644
--- a/drivers/char/diag/diagchar.h
+++ b/drivers/char/diag/diagchar.h
@@ -47,7 +47,7 @@
 #define APPS_PROC		1
 #define QDSP_PROC		2
 #define WCNSS_PROC		3
-#define MSG_MASK_SIZE 9500
+#define MSG_MASK_SIZE 10000
 #define LOG_MASK_SIZE 8000
 #define EVENT_MASK_SIZE 1000
 #define USER_SPACE_DATA 8000
diff --git a/drivers/char/diag/diagfwd.c b/drivers/char/diag/diagfwd.c
index 74416e5..384c1bf 100644
--- a/drivers/char/diag/diagfwd.c
+++ b/drivers/char/diag/diagfwd.c
@@ -129,6 +129,7 @@
 		case MSM_CPU_8X60:
 			return APQ8060_TOOLS_ID;
 		case MSM_CPU_8960:
+		case MSM_CPU_8960AB:
 			return AO8960_TOOLS_ID;
 		case MSM_CPU_8064:
 			return APQ8064_TOOLS_ID;
@@ -156,6 +157,7 @@
 
 	switch (socinfo_get_msm_cpu()) {
 	case MSM_CPU_8960:
+	case MSM_CPU_8960AB:
 	case MSM_CPU_8064:
 	case MSM_CPU_8930:
 	case MSM_CPU_8930AA:
@@ -178,7 +180,8 @@
 	if (driver->use_device_tree)
 		return 1;
 	else if (cpu_is_msm8960() || cpu_is_msm8930() || cpu_is_msm8930aa() ||
-		cpu_is_msm9615() || cpu_is_apq8064() || cpu_is_msm8627())
+		cpu_is_msm9615() || cpu_is_apq8064() || cpu_is_msm8627() ||
+		cpu_is_msm8960ab())
 		return 1;
 	else
 		return 0;
@@ -513,6 +516,7 @@
 	CREATE_MSG_MASK_TBL_ROW(20);
 	CREATE_MSG_MASK_TBL_ROW(21);
 	CREATE_MSG_MASK_TBL_ROW(22);
+	CREATE_MSG_MASK_TBL_ROW(23);
 }
 
 static void diag_set_msg_mask(int rt_mask)
@@ -1231,7 +1235,8 @@
 		driver->apps_rsp_buf[1] = 0x1;
 		driver->apps_rsp_buf[2] = 0x1;
 		driver->apps_rsp_buf[3] = 0x0;
-		*(int *)(driver->apps_rsp_buf + 4) = MSG_MASK_TBL_CNT;
+		/* -1 to un-account for OEM SSID range */
+		*(int *)(driver->apps_rsp_buf + 4) = MSG_MASK_TBL_CNT - 1;
 		*(uint16_t *)(driver->apps_rsp_buf + 8) = MSG_SSID_0;
 		*(uint16_t *)(driver->apps_rsp_buf + 10) = MSG_SSID_0_LAST;
 		*(uint16_t *)(driver->apps_rsp_buf + 12) = MSG_SSID_1;
diff --git a/drivers/char/msm_rotator.c b/drivers/char/msm_rotator.c
index e783a1a..4d34362 100644
--- a/drivers/char/msm_rotator.c
+++ b/drivers/char/msm_rotator.c
@@ -171,11 +171,10 @@
 	CLK_SUSPEND,
 };
 
-int msm_rotator_iommu_map_buf(int mem_id, unsigned char src,
+int msm_rotator_iommu_map_buf(int mem_id, int domain,
 	unsigned long *start, unsigned long *len,
-	struct ion_handle **pihdl)
+	struct ion_handle **pihdl, unsigned int secure)
 {
-	int domain;
 	if (!msm_rotator_dev->client)
 		return -EINVAL;
 
@@ -187,16 +186,30 @@
 	pr_debug("%s(): ion_hdl %p, ion_fd %d\n", __func__, *pihdl,
 		ion_share_dma_buf(msm_rotator_dev->client, *pihdl));
 
-	if (rot_iommu_split_domain)
-		domain = src ? ROTATOR_SRC_DOMAIN : ROTATOR_DST_DOMAIN;
-	else
-		domain = ROTATOR_SRC_DOMAIN;
-
-	if (ion_map_iommu(msm_rotator_dev->client,
-		*pihdl,	domain, GEN_POOL,
-		SZ_4K, 0, start, len, 0, ION_IOMMU_UNMAP_DELAYED)) {
-		pr_err("ion_map_iommu() failed\n");
-		return -EINVAL;
+	if (rot_iommu_split_domain) {
+		if (secure) {
+			if (ion_phys(msm_rotator_dev->client,
+				*pihdl, start, (unsigned *)len)) {
+				pr_err("%s:%d: ion_phys map failed\n",
+					 __func__, __LINE__);
+				return -ENOMEM;
+			}
+		} else {
+			if (ion_map_iommu(msm_rotator_dev->client,
+				*pihdl,	domain, GEN_POOL,
+				SZ_4K, 0, start, len, 0,
+				ION_IOMMU_UNMAP_DELAYED)) {
+				pr_err("ion_map_iommu() failed\n");
+				return -EINVAL;
+			}
+		}
+	} else {
+		if (ion_map_iommu(msm_rotator_dev->client,
+			*pihdl,	ROTATOR_SRC_DOMAIN, GEN_POOL,
+			SZ_4K, 0, start, len, 0, ION_IOMMU_UNMAP_DELAYED)) {
+			pr_err("ion_map_iommu() failed\n");
+			return -EINVAL;
+		}
 	}
 
 	pr_debug("%s(): mem_id %d, start 0x%lx, len 0x%lx\n",
@@ -813,9 +826,9 @@
 	return 0;
 }
 
-static int get_img(struct msmfb_data *fbd, unsigned char src,
+static int get_img(struct msmfb_data *fbd, int domain,
 	unsigned long *start, unsigned long *len, struct file **p_file,
-	int *p_need, struct ion_handle **p_ihdl)
+	int *p_need, struct ion_handle **p_ihdl, unsigned int secure)
 {
 	int ret = 0;
 #ifdef CONFIG_FB
@@ -857,8 +870,8 @@
 #endif
 
 #ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
-	return msm_rotator_iommu_map_buf(fbd->memory_id, src, start,
-		len, p_ihdl);
+	return msm_rotator_iommu_map_buf(fbd->memory_id, domain, start,
+		len, p_ihdl, secure);
 #endif
 #ifdef CONFIG_ANDROID_PMEM
 	if (!get_pmem_file(fbd->memory_id, start, &vstart, len, p_file))
@@ -870,7 +883,7 @@
 }
 
 static void put_img(struct file *p_file, struct ion_handle *p_ihdl,
-	unsigned char src)
+	int domain, unsigned int secure)
 {
 #ifdef CONFIG_ANDROID_PMEM
 	if (p_file != NULL)
@@ -879,14 +892,15 @@
 
 #ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
 	if (!IS_ERR_OR_NULL(p_ihdl)) {
-		int domain;
-		if (rot_iommu_split_domain)
-			domain = src ? ROTATOR_SRC_DOMAIN : ROTATOR_DST_DOMAIN;
-		else
-			domain = ROTATOR_SRC_DOMAIN;
 		pr_debug("%s(): p_ihdl %p\n", __func__, p_ihdl);
-		ion_unmap_iommu(msm_rotator_dev->client,
-			p_ihdl, domain, GEN_POOL);
+		if (rot_iommu_split_domain) {
+			if (!secure)
+				ion_unmap_iommu(msm_rotator_dev->client,
+					p_ihdl, domain, GEN_POOL);
+		} else {
+			ion_unmap_iommu(msm_rotator_dev->client,
+				p_ihdl, ROTATOR_SRC_DOMAIN, GEN_POOL);
+		}
 
 		ion_free(msm_rotator_dev->client, p_ihdl);
 	}
@@ -953,18 +967,18 @@
 		goto do_rotate_unlock_mutex;
 	}
 
-	rc = get_img(&info.src, 1, (unsigned long *)&in_paddr,
+	rc = get_img(&info.src, ROTATOR_SRC_DOMAIN, (unsigned long *)&in_paddr,
 			(unsigned long *)&src_len, &srcp0_file, &ps0_need,
-			&srcp0_ihdl);
+			&srcp0_ihdl, 0);
 	if (rc) {
 		pr_err("%s: in get_img() failed id=0x%08x\n",
 			DRIVER_NAME, info.src.memory_id);
 		goto do_rotate_unlock_mutex;
 	}
 
-	rc = get_img(&info.dst, 0, (unsigned long *)&out_paddr,
+	rc = get_img(&info.dst, ROTATOR_DST_DOMAIN, (unsigned long *)&out_paddr,
 			(unsigned long *)&dst_len, &dstp0_file, &p_need,
-			&dstp0_ihdl);
+			&dstp0_ihdl, img_info->secure);
 	if (rc) {
 		pr_err("%s: out get_img() failed id=0x%08x\n",
 		       DRIVER_NAME, info.dst.memory_id);
@@ -992,20 +1006,20 @@
 			goto do_rotate_unlock_mutex;
 		}
 
-		rc = get_img(&info.src_chroma, 1,
+		rc = get_img(&info.src_chroma, ROTATOR_SRC_DOMAIN,
 				(unsigned long *)&in_chroma_paddr,
 				(unsigned long *)&src_len, &srcp1_file, &p_need,
-				&srcp1_ihdl);
+				&srcp1_ihdl, 0);
 		if (rc) {
 			pr_err("%s: in chroma get_img() failed id=0x%08x\n",
 				DRIVER_NAME, info.src_chroma.memory_id);
 			goto do_rotate_unlock_mutex;
 		}
 
-		rc = get_img(&info.dst_chroma, 0,
+		rc = get_img(&info.dst_chroma, ROTATOR_DST_DOMAIN,
 				(unsigned long *)&out_chroma_paddr,
 				(unsigned long *)&dst_len, &dstp1_file, &p_need,
-				&dstp1_ihdl);
+				&dstp1_ihdl, img_info->secure);
 		if (rc) {
 			pr_err("%s: out chroma get_img() failed id=0x%08x\n",
 				DRIVER_NAME, info.dst_chroma.memory_id);
@@ -1176,15 +1190,17 @@
 #endif
 	schedule_delayed_work(&msm_rotator_dev->rot_clk_work, HZ);
 do_rotate_unlock_mutex:
-	put_img(dstp1_file, dstp1_ihdl, 0);
-	put_img(srcp1_file, srcp1_ihdl, 1);
-	put_img(dstp0_file, dstp0_ihdl, 0);
+	put_img(dstp1_file, dstp1_ihdl, ROTATOR_DST_DOMAIN,
+		msm_rotator_dev->img_info[s]->secure);
+	put_img(srcp1_file, srcp1_ihdl, ROTATOR_SRC_DOMAIN, 0);
+	put_img(dstp0_file, dstp0_ihdl, ROTATOR_DST_DOMAIN,
+		msm_rotator_dev->img_info[s]->secure);
 
 	/* only source may use frame buffer */
 	if (info.src.flags & MDP_MEMORY_ID_TYPE_FB)
 		fput_light(srcp0_file, ps0_need);
 	else
-		put_img(srcp0_file, srcp0_ihdl, 1);
+		put_img(srcp0_file, srcp0_ihdl, ROTATOR_SRC_DOMAIN, 0);
 	mutex_unlock(&msm_rotator_dev->rotator_lock);
 	dev_dbg(msm_rotator_dev->device, "%s() returning rc = %d\n",
 		__func__, rc);
diff --git a/drivers/gpu/ion/ion.c b/drivers/gpu/ion/ion.c
index c31f0f0..741d4fa 100644
--- a/drivers/gpu/ion/ion.c
+++ b/drivers/gpu/ion/ion.c
@@ -1294,7 +1294,7 @@
 	valid_handle = ion_handle_validate(client, handle);
 	mutex_unlock(&client->lock);
 	if (!valid_handle) {
-		WARN("%s: invalid handle passed to share.\n", __func__);
+		WARN(1, "%s: invalid handle passed to share.\n", __func__);
 		return -EINVAL;
 	}
 
diff --git a/drivers/gpu/msm/a3xx_reg.h b/drivers/gpu/msm/a3xx_reg.h
index f5ee1d7..8ec9431 100644
--- a/drivers/gpu/msm/a3xx_reg.h
+++ b/drivers/gpu/msm/a3xx_reg.h
@@ -151,6 +151,7 @@
 #define A3XX_GRAS_CL_USER_PLANE_Y5 0xCB5
 #define A3XX_GRAS_CL_USER_PLANE_Z5 0xCB6
 #define A3XX_GRAS_CL_USER_PLANE_W5 0xCB7
+#define A3XX_VFD_PERFCOUNTER0_SELECT 0xE44
 #define A3XX_VPC_VPC_DEBUG_RAM_SEL 0xE61
 #define A3XX_VPC_VPC_DEBUG_RAM_READ 0xE62
 #define A3XX_UCHE_CACHE_INVALIDATE0_REG 0xEA0
@@ -289,6 +290,8 @@
 #define RB_CLEAR_MODE_RESOLVE 1
 #define RB_TILINGMODE_LINEAR 0
 #define RB_REF_NEVER 0
+#define RB_FRAG_LESS 1
+#define RB_REF_ALWAYS 7
 #define RB_STENCIL_KEEP 0
 #define RB_RENDERING_PASS 0
 #define RB_TILINGMODE_32X32 2
@@ -326,6 +329,7 @@
 #define GRAS_SC_SCREEN_SCISSOR_BR_BR_Y 16
 #define GRAS_SC_WINDOW_SCISSOR_BR_BR_X 0
 #define GRAS_SC_WINDOW_SCISSOR_BR_BR_Y 16
+#define GRAS_SU_CTRLMODE_LINEHALFWIDTH 03
 #define HLSQ_CONSTFSPRESERVEDRANGEREG_ENDENTRY 16
 #define HLSQ_CONSTFSPRESERVEDRANGEREG_STARTENTRY 0
 #define HLSQ_CTRL0REG_CHUNKDISABLE 26
@@ -396,6 +400,7 @@
 #define RB_STENCILCONTROL_STENCIL_ZPASS 14
 #define RB_STENCILCONTROL_STENCIL_ZPASS_BF 26
 #define SP_FSCTRLREG0_FSFULLREGFOOTPRINT 10
+#define SP_FSCTRLREG0_FSHALFREGFOOTPRINT 4
 #define SP_FSCTRLREG0_FSICACHEINVALID 2
 #define SP_FSCTRLREG0_FSINOUTREGOVERLAP 18
 #define SP_FSCTRLREG0_FSINSTRBUFFERMODE 1
@@ -408,13 +413,16 @@
 #define SP_FSCTRLREG1_FSINITIALOUTSTANDING 20
 #define SP_FSCTRLREG1_HALFPRECVAROFFSET 24
 #define SP_FSMRTREG_REGID 0
+#define SP_FSMRTREG_PRECISION 8
 #define SP_FSOUTREG_PAD0 2
 #define SP_IMAGEOUTPUTREG_MRTFORMAT 0
+#define SP_IMAGEOUTPUTREG_DEPTHOUTMODE 3
 #define SP_IMAGEOUTPUTREG_PAD0 6
 #define SP_OBJOFFSETREG_CONSTOBJECTSTARTOFFSET 16
 #define SP_OBJOFFSETREG_SHADEROBJOFFSETINIC 25
 #define SP_SHADERLENGTH_LEN 0
 #define SP_SPCTRLREG_CONSTMODE 18
+#define SP_SPCTRLREG_LOMODE 22
 #define SP_SPCTRLREG_SLEEPMODE 20
 #define SP_VSCTRLREG0_VSFULLREGFOOTPRINT 10
 #define SP_VSCTRLREG0_VSICACHEINVALID 2
@@ -455,6 +463,7 @@
 #define VFD_FETCHINSTRUCTIONS_STEPRATE 24
 #define VFD_FETCHINSTRUCTIONS_SWITCHNEXT 17
 #define VFD_THREADINGTHRESHOLD_REGID_VTXCNT 8
+#define VFD_THREADINGTHRESHOLD_REGID_THRESHOLD 0
 #define VFD_THREADINGTHRESHOLD_RESERVED6 4
 #define VPC_VPCATTR_LMSIZE 28
 #define VPC_VPCATTR_THRHDASSIGN 12
diff --git a/drivers/gpu/msm/adreno.c b/drivers/gpu/msm/adreno.c
index ecff3ea..7720df0 100644
--- a/drivers/gpu/msm/adreno.c
+++ b/drivers/gpu/msm/adreno.c
@@ -544,53 +544,16 @@
 static unsigned int
 a3xx_getchipid(struct kgsl_device *device)
 {
-	unsigned int majorid = 0, minorid = 0, patchid = 0;
+	struct kgsl_device_platform_data *pdata =
+		kgsl_device_get_drvdata(device);
 
 	/*
-	 * We could detect the chipID from the hardware but it takes multiple
-	 * registers to find the right combination. Since we traffic exclusively
-	 * in system on chips, we can be (mostly) confident that a SOC version
-	 * will match a GPU (at this juncture at least).  So do the lazy/quick
-	 * thing and set the chip_id based on the SoC
+	 * All current A3XX chipids are detected at the SOC level. Leave this
+	 * function here to support any future GPUs that have working
+	 * chip ID registers
 	 */
 
-	unsigned int version = socinfo_get_version();
-
-	if (cpu_is_apq8064()) {
-
-		/* A320 */
-		majorid = 2;
-		minorid = 0;
-
-		/*
-		 * V1.1 has some GPU work arounds that we need to communicate
-		 * up to user space via the patchid
-		 */
-
-		if ((SOCINFO_VERSION_MAJOR(version) == 1) &&
-			(SOCINFO_VERSION_MINOR(version) == 1))
-			patchid = 1;
-		else
-			patchid = 0;
-	} else if (cpu_is_msm8930() || cpu_is_msm8930aa() || cpu_is_msm8627()) {
-
-		/* A305 */
-		majorid = 0;
-		minorid = 5;
-
-		/*
-		 * V1.2 has some GPU work arounds that we need to communicate
-		 * up to user space via the patchid
-		 */
-
-		if ((SOCINFO_VERSION_MAJOR(version) == 1) &&
-			(SOCINFO_VERSION_MINOR(version) == 2))
-			patchid = 2;
-		else
-			patchid = 0;
-	}
-
-	return (0x03 << 24) | (majorid << 16) | (minorid << 8) | patchid;
+	return pdata->chipid;
 }
 
 static unsigned int
@@ -598,7 +561,13 @@
 {
 	unsigned int chipid = 0;
 	unsigned int coreid, majorid, minorid, patchid, revid;
-	uint32_t soc_platform_version = socinfo_get_version();
+	struct kgsl_device_platform_data *pdata =
+		kgsl_device_get_drvdata(device);
+
+	/* If the chip id is set at the platform level, then just use that */
+
+	if (pdata->chipid != 0)
+		return pdata->chipid;
 
 	adreno_regread(device, REG_RBBM_PERIPHID1, &coreid);
 	adreno_regread(device, REG_RBBM_PERIPHID2, &majorid);
@@ -608,7 +577,7 @@
 	* adreno 22x gpus are indicated by coreid 2,
 	* but REG_RBBM_PERIPHID1 always contains 0 for this field
 	*/
-	if (cpu_is_msm8960() || cpu_is_msm8x60())
+	if (cpu_is_msm8x60())
 		chipid = 2 << 24;
 	else
 		chipid = (coreid & 0xF) << 24;
@@ -620,13 +589,9 @@
 	patchid = ((revid >> 16) & 0xFF);
 
 	/* 8x50 returns 0 for patch release, but it should be 1 */
-	/* 8960v3 returns 5 for patch release, but it should be 6 */
 	/* 8x25 returns 0 for minor id, but it should be 1 */
 	if (cpu_is_qsd8x50())
 		patchid = 1;
-	else if (cpu_is_msm8960() &&
-			SOCINFO_VERSION_MAJOR(soc_platform_version) == 3)
-		patchid = 6;
 	else if (cpu_is_msm8625() && minorid == 0)
 		minorid = 1;
 
@@ -638,11 +603,18 @@
 static unsigned int
 adreno_getchipid(struct kgsl_device *device)
 {
-	if (cpu_is_apq8064() || cpu_is_msm8930() || cpu_is_msm8930aa() ||
-	    cpu_is_msm8627())
-		return a3xx_getchipid(device);
-	else
+	struct kgsl_device_platform_data *pdata =
+		kgsl_device_get_drvdata(device);
+
+	/*
+	 * All A3XX chipsets will have pdata set, so assume !pdata->chipid is
+	 * an A2XX processor
+	 */
+
+	if (pdata->chipid == 0 || ADRENO_CHIPID_MAJOR(pdata->chipid) == 2)
 		return a2xx_getchipid(device);
+	else
+		return a3xx_getchipid(device);
 }
 
 static inline bool _rev_match(unsigned int id, unsigned int entry)
@@ -657,10 +629,10 @@
 
 	adreno_dev->chip_id = adreno_getchipid(&adreno_dev->dev);
 
-	core = (adreno_dev->chip_id >> 24) & 0xff;
-	major = (adreno_dev->chip_id >> 16) & 0xff;
-	minor = (adreno_dev->chip_id >> 8) & 0xff;
-	patchid = (adreno_dev->chip_id & 0xff);
+	core = ADRENO_CHIPID_CORE(adreno_dev->chip_id);
+	major = ADRENO_CHIPID_MAJOR(adreno_dev->chip_id);
+	minor = ADRENO_CHIPID_MINOR(adreno_dev->chip_id);
+	patchid = ADRENO_CHIPID_PATCH(adreno_dev->chip_id);
 
 	for (i = 0; i < ARRAY_SIZE(adreno_gpulist); i++) {
 		if (core == adreno_gpulist[i].core &&
@@ -741,7 +713,8 @@
 	int status = -EINVAL;
 	struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
 
-	kgsl_pwrctrl_set_state(device, KGSL_STATE_INIT);
+	if (KGSL_STATE_DUMP_AND_RECOVER != device->state)
+		kgsl_pwrctrl_set_state(device, KGSL_STATE_INIT);
 
 	/* Power up the device */
 	kgsl_pwrctrl_enable(device);
@@ -785,7 +758,10 @@
 
 	status = adreno_ringbuffer_start(&adreno_dev->ringbuffer, init_ram);
 	if (status == 0) {
-		mod_timer(&device->idle_timer, jiffies + FIRST_TIMEOUT);
+		/* While recovery is on we do not want timer to
+		 * fire and attempt to change any device state */
+		if (KGSL_STATE_DUMP_AND_RECOVER != device->state)
+			mod_timer(&device->idle_timer, jiffies + FIRST_TIMEOUT);
 		return 0;
 	}
 
@@ -934,6 +910,8 @@
 	/* Restore valid commands in ringbuffer */
 	adreno_ringbuffer_restore(rb, rb_buffer, num_rb_contents);
 	rb->timestamp[KGSL_MEMSTORE_GLOBAL] = timestamp;
+	/* wait for idle */
+	ret = adreno_idle(device, KGSL_TIMEOUT_DEFAULT);
 done:
 	vfree(rb_buffer);
 	return ret;
@@ -1201,7 +1179,8 @@
 
 err:
 	KGSL_DRV_ERR(device, "spun too long waiting for RB to idle\n");
-	if (!adreno_dump_and_recover(device)) {
+	if (KGSL_STATE_DUMP_AND_RECOVER != device->state &&
+		!adreno_dump_and_recover(device)) {
 		wait_time = jiffies + wait_timeout;
 		goto retry;
 	}
@@ -1595,10 +1574,9 @@
 		      context_id, timestamp, context_id, ts_issued,
 		      adreno_dev->ringbuffer.wptr);
 	if (!adreno_dump_and_recover(device)) {
-		/* wait for idle after recovery as the
-		 * timestamp that this process wanted
-		 * to wait on may be invalid */
-		if (!adreno_idle(device, KGSL_TIMEOUT_DEFAULT))
+		/* The timestamp that this process wanted
+		 * to wait on may be invalid or expired now
+		 * after successful recovery */
 			status = 0;
 	}
 done:
diff --git a/drivers/gpu/msm/adreno.h b/drivers/gpu/msm/adreno.h
index e1d1eb9..04dc3d6 100644
--- a/drivers/gpu/msm/adreno.h
+++ b/drivers/gpu/msm/adreno.h
@@ -24,6 +24,11 @@
 #define ADRENO_DEVICE(device) \
 		KGSL_CONTAINER_OF(device, struct adreno_device, dev)
 
+#define ADRENO_CHIPID_CORE(_id) (((_id) >> 24) & 0xFF)
+#define ADRENO_CHIPID_MAJOR(_id) (((_id) >> 16) & 0xFF)
+#define ADRENO_CHIPID_MINOR(_id) (((_id) >> 8) & 0xFF)
+#define ADRENO_CHIPID_PATCH(_id) ((_id) & 0xFF)
+
 /* Flags to control command packet settings */
 #define KGSL_CMD_FLAGS_NONE             0x00000000
 #define KGSL_CMD_FLAGS_PMODE		0x00000001
diff --git a/drivers/gpu/msm/adreno_a3xx.c b/drivers/gpu/msm/adreno_a3xx.c
index 6eebeb8..bb89067 100644
--- a/drivers/gpu/msm/adreno_a3xx.c
+++ b/drivers/gpu/msm/adreno_a3xx.c
@@ -500,26 +500,19 @@
 	*cmds++ = _SET(VFD_DECODEINSTRUCTIONS_WRITEMASK, 0x0F) |
 		_SET(VFD_DECODEINSTRUCTIONS_CONSTFILL, 1) |
 		_SET(VFD_DECODEINSTRUCTIONS_FORMAT, 2) |
-		_SET(VFD_DECODEINSTRUCTIONS_REGID, 5) |
 		_SET(VFD_DECODEINSTRUCTIONS_SHIFTCNT, 12) |
 		_SET(VFD_DECODEINSTRUCTIONS_LASTCOMPVALID, 1);
 
 	*cmds++ = cp_type3_packet(CP_SET_CONSTANT, 5);
 	*cmds++ = CP_REG(A3XX_HLSQ_CONTROL_0_REG);
 	/* HLSQ_CONTROL_0_REG */
-	*cmds++ = _SET(HLSQ_CTRL0REG_FSTHREADSIZE, HLSQ_TWO_PIX_QUADS) |
+	*cmds++ = _SET(HLSQ_CTRL0REG_FSTHREADSIZE, HLSQ_FOUR_PIX_QUADS) |
 		_SET(HLSQ_CTRL0REG_FSSUPERTHREADENABLE, 1) |
-		_SET(HLSQ_CTRL0REG_SPSHADERRESTART, 1) |
 		_SET(HLSQ_CTRL0REG_RESERVED2, 1) |
-		_SET(HLSQ_CTRL0REG_CHUNKDISABLE, 1) |
-		_SET(HLSQ_CTRL0REG_CONSTSWITCHMODE, 1) |
-		_SET(HLSQ_CTRL0REG_LAZYUPDATEDISABLE, 1) |
-		_SET(HLSQ_CTRL0REG_SPCONSTFULLUPDATE, 1) |
-		_SET(HLSQ_CTRL0REG_TPFULLUPDATE, 1);
+		_SET(HLSQ_CTRL0REG_SPCONSTFULLUPDATE, 1);
 	/* HLSQ_CONTROL_1_REG */
 	*cmds++ = _SET(HLSQ_CTRL1REG_VSTHREADSIZE, HLSQ_TWO_VTX_QUADS) |
-		_SET(HLSQ_CTRL1REG_VSSUPERTHREADENABLE, 1) |
-		_SET(HLSQ_CTRL1REG_RESERVED1, 4);
+		_SET(HLSQ_CTRL1REG_VSSUPERTHREADENABLE, 1);
 	/* HLSQ_CONTROL_2_REG */
 	*cmds++ = _SET(HLSQ_CTRL2REG_PRIMALLOCTHRESHOLD, 31);
 	/* HLSQ_CONTROL_3_REG */
@@ -531,7 +524,7 @@
 	*cmds++ = _SET(HLSQ_VSCTRLREG_VSINSTRLENGTH, 1);
 	/* HLSQ_FS_CONTROL_REG */
 	*cmds++ = _SET(HLSQ_FSCTRLREG_FSCONSTLENGTH, 1) |
-		_SET(HLSQ_FSCTRLREG_FSCONSTSTARTOFFSET, 272) |
+		_SET(HLSQ_FSCTRLREG_FSCONSTSTARTOFFSET, 128) |
 		_SET(HLSQ_FSCTRLREG_FSINSTRLENGTH, 1);
 	/* HLSQ_CONST_VSPRESV_RANGE_REG */
 	*cmds++ = 0x00000000;
@@ -547,8 +540,8 @@
 	*cmds++ = cp_type3_packet(CP_SET_CONSTANT, 2);
 	*cmds++ = CP_REG(A3XX_SP_SP_CTRL_REG);
 	/* SP_SP_CTRL_REG */
-	*cmds++ = _SET(SP_SPCTRLREG_CONSTMODE, 1) |
-		_SET(SP_SPCTRLREG_SLEEPMODE, 1);
+	*cmds++ = _SET(SP_SPCTRLREG_SLEEPMODE, 1) |
+		_SET(SP_SPCTRLREG_LOMODE, 1);
 
 	*cmds++ = cp_type3_packet(CP_SET_CONSTANT, 12);
 	*cmds++ = CP_REG(A3XX_SP_VS_CTRL_REG0);
@@ -556,15 +549,14 @@
 	*cmds++ = _SET(SP_VSCTRLREG0_VSTHREADMODE, SP_MULTI) |
 		_SET(SP_VSCTRLREG0_VSINSTRBUFFERMODE, SP_BUFFER_MODE) |
 		_SET(SP_VSCTRLREG0_VSICACHEINVALID, 1) |
-		_SET(SP_VSCTRLREG0_VSFULLREGFOOTPRINT, 3) |
+		_SET(SP_VSCTRLREG0_VSFULLREGFOOTPRINT, 1) |
 		_SET(SP_VSCTRLREG0_VSTHREADSIZE, SP_TWO_VTX_QUADS) |
 		_SET(SP_VSCTRLREG0_VSSUPERTHREADMODE, 1) |
 		_SET(SP_VSCTRLREG0_VSLENGTH, 1);
 	/* SP_VS_CTRL_REG1 */
 	*cmds++ = _SET(SP_VSCTRLREG1_VSINITIALOUTSTANDING, 4);
 	/* SP_VS_PARAM_REG */
-	*cmds++ = _SET(SP_VSPARAMREG_POSREGID, 1) |
-		_SET(SP_VSPARAMREG_PSIZEREGID, 252);
+	*cmds++ = _SET(SP_VSPARAMREG_PSIZEREGID, 252);
 	/* SP_VS_OUT_REG_0 */
 	*cmds++ = 0x00000000;
 	/* SP_VS_OUT_REG_1 */
@@ -605,18 +597,17 @@
 	*cmds++ = _SET(SP_FSCTRLREG0_FSTHREADMODE, SP_MULTI) |
 		_SET(SP_FSCTRLREG0_FSINSTRBUFFERMODE, SP_BUFFER_MODE) |
 		_SET(SP_FSCTRLREG0_FSICACHEINVALID, 1) |
-		_SET(SP_FSCTRLREG0_FSFULLREGFOOTPRINT, 2) |
+		_SET(SP_FSCTRLREG0_FSHALFREGFOOTPRINT, 1) |
 		_SET(SP_FSCTRLREG0_FSINOUTREGOVERLAP, 1) |
-		_SET(SP_FSCTRLREG0_FSTHREADSIZE, SP_TWO_VTX_QUADS) |
+		_SET(SP_FSCTRLREG0_FSTHREADSIZE, SP_FOUR_PIX_QUADS) |
 		_SET(SP_FSCTRLREG0_FSSUPERTHREADMODE, 1) |
 		_SET(SP_FSCTRLREG0_FSLENGTH, 1);
 	/* SP_FS_CTRL_REG1 */
 	*cmds++ = _SET(SP_FSCTRLREG1_FSCONSTLENGTH, 1) |
-		_SET(SP_FSCTRLREG1_FSINITIALOUTSTANDING, 2) |
 		_SET(SP_FSCTRLREG1_HALFPRECVAROFFSET, 63);
 	/* SP_FS_OBJ_OFFSET_REG */
-	*cmds++ = _SET(SP_OBJOFFSETREG_CONSTOBJECTSTARTOFFSET, 272) |
-		_SET(SP_OBJOFFSETREG_SHADEROBJOFFSETINIC, 1);
+	*cmds++ = _SET(SP_OBJOFFSETREG_CONSTOBJECTSTARTOFFSET, 128) |
+		_SET(SP_OBJOFFSETREG_SHADEROBJOFFSETINIC, 127);
 	/* SP_FS_OBJ_START_REG */
 	*cmds++ = 0x00000000;
 
@@ -630,12 +621,13 @@
 	*cmds++ = cp_type3_packet(CP_SET_CONSTANT, 2);
 	*cmds++ = CP_REG(A3XX_SP_FS_OUTPUT_REG);
 	/* SP_FS_OUTPUT_REG */
-	*cmds++ = _SET(SP_IMAGEOUTPUTREG_PAD0, SP_PIXEL_BASED);
+	*cmds++ = _SET(SP_IMAGEOUTPUTREG_DEPTHOUTMODE, SP_PIXEL_BASED);
 
 	*cmds++ = cp_type3_packet(CP_SET_CONSTANT, 5);
 	*cmds++ = CP_REG(A3XX_SP_FS_MRT_REG_0);
 	/* SP_FS_MRT_REG_0 */
-	*cmds++ = _SET(SP_FSMRTREG_REGID, 1);
+	*cmds++ = _SET(SP_FSMRTREG_PRECISION, 1);
+
 	/* SP_FS_MRT_REG_1 */
 	*cmds++ = 0x00000000;
 	/* SP_FS_MRT_REG_2 */
@@ -676,14 +668,21 @@
 		| (0 << CP_LOADSTATE_EXTSRCADDR_SHIFT);
 
 	/* (sy)(rpt3)mov.f32f32 r0.y, (r)r1.y; */
-	*cmds++ = 0x00000005; *cmds++ = 0x30044b01;
+	*cmds++ = 0x00000000; *cmds++ = 0x13001000;
 	/* end; */
-	*cmds++ = 0x00000000; *cmds++ = 0x03000000;
+	*cmds++ = 0x00000000; *cmds++ = 0x00000000;
 	/* nop; */
 	*cmds++ = 0x00000000; *cmds++ = 0x00000000;
 	/* nop; */
 	*cmds++ = 0x00000000; *cmds++ = 0x00000000;
 
+
+	*cmds++ = cp_type0_packet(A3XX_VFD_PERFCOUNTER0_SELECT, 1);
+	*cmds++ = 0x00000000;
+
+	*cmds++ = cp_type3_packet(CP_WAIT_FOR_IDLE, 1);
+	*cmds++ = 0x00000000;
+
 	*cmds++ = cp_type3_packet(CP_LOAD_STATE, 10);
 	*cmds++ = (0 << CP_LOADSTATE_DSTOFFSET_SHIFT)
 		| (HLSQ_DIRECT << CP_LOADSTATE_STATESRC_SHIFT)
@@ -693,7 +692,7 @@
 		| (0 << CP_LOADSTATE_EXTSRCADDR_SHIFT);
 
 	/* (sy)(rpt3)mov.f32f32 r0.y, (r)c0.x; */
-	*cmds++ = 0x00000000; *cmds++ = 0x30244b01;
+	*cmds++ = 0x00000000; *cmds++ = 0x30201b00;
 	/* end; */
 	*cmds++ = 0x00000000; *cmds++ = 0x03000000;
 	/* nop; */
@@ -701,6 +700,15 @@
 	/* nop; */
 	*cmds++ = 0x00000000; *cmds++ = 0x00000000;
 
+
+
+	*cmds++ = cp_type0_packet(A3XX_VFD_PERFCOUNTER0_SELECT, 1);
+	*cmds++ = 0x00000000;
+
+	*cmds++ = cp_type3_packet(CP_WAIT_FOR_IDLE, 1);
+	*cmds++ = 0x00000000;
+
+
 	*cmds++ = cp_type3_packet(CP_SET_CONSTANT, 2);
 	*cmds++ = CP_REG(A3XX_RB_MSAA_CONTROL);
 	/* RB_MSAA_CONTROL */
@@ -713,6 +721,23 @@
 	*cmds++ = _SET(RB_DEPTHCONTROL_Z_TEST_FUNC, RB_FRAG_NEVER);
 
 	*cmds++ = cp_type3_packet(CP_SET_CONSTANT, 2);
+	*cmds++ = CP_REG(A3XX_RB_STENCIL_CONTROL);
+	/* RB_STENCIL_CONTROL */
+	*cmds++ = _SET(RB_STENCILCONTROL_STENCIL_FUNC, RB_REF_NEVER) |
+		_SET(RB_STENCILCONTROL_STENCIL_FAIL, RB_STENCIL_KEEP) |
+		_SET(RB_STENCILCONTROL_STENCIL_ZPASS, RB_STENCIL_KEEP) |
+		_SET(RB_STENCILCONTROL_STENCIL_ZFAIL, RB_STENCIL_KEEP) |
+		_SET(RB_STENCILCONTROL_STENCIL_FUNC_BF, RB_REF_NEVER) |
+		_SET(RB_STENCILCONTROL_STENCIL_FAIL_BF, RB_STENCIL_KEEP) |
+		_SET(RB_STENCILCONTROL_STENCIL_ZPASS_BF, RB_STENCIL_KEEP) |
+		_SET(RB_STENCILCONTROL_STENCIL_ZFAIL_BF, RB_STENCIL_KEEP);
+
+	*cmds++ = cp_type3_packet(CP_SET_CONSTANT, 2);
+	*cmds++ = CP_REG(A3XX_GRAS_SU_MODE_CONTROL);
+	/* GRAS_SU_MODE_CONTROL */
+	*cmds++ = 0x00000000;
+
+	*cmds++ = cp_type3_packet(CP_SET_CONSTANT, 2);
 	*cmds++ = CP_REG(A3XX_RB_MRT_CONTROL0);
 	/* RB_MRT_CONTROL0 */
 	*cmds++ = _SET(RB_MRTCONTROL_READ_DEST_ENABLE, 1) |
@@ -777,7 +802,7 @@
 	/* VFD_INDEX_MIN */
 	*cmds++ = 0x00000000;
 	/* VFD_INDEX_MAX */
-	*cmds++ = 0xFFFFFFFF;
+	*cmds++ = 0x155;
 	/* VFD_INSTANCEID_OFFSET */
 	*cmds++ = 0x00000000;
 	/* VFD_INDEX_OFFSET */
@@ -786,7 +811,7 @@
 	*cmds++ = cp_type3_packet(CP_SET_CONSTANT, 2);
 	*cmds++ = CP_REG(A3XX_VFD_VS_THREADING_THRESHOLD);
 	/* VFD_VS_THREADING_THRESHOLD */
-	*cmds++ = _SET(VFD_THREADINGTHRESHOLD_RESERVED6, 12) |
+	*cmds++ = _SET(VFD_THREADINGTHRESHOLD_REGID_THRESHOLD, 15) |
 		_SET(VFD_THREADINGTHRESHOLD_REGID_VTXCNT, 252);
 
 	*cmds++ = cp_type3_packet(CP_SET_CONSTANT, 2);
@@ -861,6 +886,46 @@
 	*cmds++ = cp_type3_packet(CP_WAIT_FOR_IDLE, 1);
 	*cmds++ = 0x00000000;
 
+
+	/* oxili_generate_context_roll_packets */
+	*cmds++ = cp_type0_packet(A3XX_SP_VS_CTRL_REG0, 1);
+	*cmds++ = 0x00000400;
+
+	*cmds++ = cp_type0_packet(A3XX_SP_FS_CTRL_REG0, 1);
+	*cmds++ = 0x00000400;
+
+	*cmds++ = cp_type0_packet(A3XX_SP_VS_PVT_MEM_SIZE_REG, 1);
+	*cmds++ = 0x00008000; /* SP_VS_MEM_SIZE_REG */
+
+	*cmds++ = cp_type0_packet(A3XX_SP_FS_PVT_MEM_SIZE_REG, 1);
+	*cmds++ = 0x00008000; /* SP_FS_MEM_SIZE_REG */
+
+	/* Clear cache invalidate bit when re-loading the shader control regs */
+	*cmds++ = cp_type0_packet(A3XX_SP_VS_CTRL_REG0, 1);
+	*cmds++ = _SET(SP_VSCTRLREG0_VSTHREADMODE, SP_MULTI) |
+		_SET(SP_VSCTRLREG0_VSINSTRBUFFERMODE, SP_BUFFER_MODE) |
+		_SET(SP_VSCTRLREG0_VSFULLREGFOOTPRINT, 1) |
+		_SET(SP_VSCTRLREG0_VSTHREADSIZE, SP_TWO_VTX_QUADS) |
+		_SET(SP_VSCTRLREG0_VSSUPERTHREADMODE, 1) |
+		_SET(SP_VSCTRLREG0_VSLENGTH, 1);
+
+	*cmds++ = cp_type0_packet(A3XX_SP_FS_CTRL_REG0, 1);
+	*cmds++ = _SET(SP_FSCTRLREG0_FSTHREADMODE, SP_MULTI) |
+		_SET(SP_FSCTRLREG0_FSINSTRBUFFERMODE, SP_BUFFER_MODE) |
+		_SET(SP_FSCTRLREG0_FSHALFREGFOOTPRINT, 1) |
+		_SET(SP_FSCTRLREG0_FSINOUTREGOVERLAP, 1) |
+		_SET(SP_FSCTRLREG0_FSTHREADSIZE, SP_FOUR_PIX_QUADS) |
+		_SET(SP_FSCTRLREG0_FSSUPERTHREADMODE, 1) |
+		_SET(SP_FSCTRLREG0_FSLENGTH, 1);
+
+	*cmds++ = cp_type0_packet(A3XX_SP_VS_PVT_MEM_SIZE_REG, 1);
+	*cmds++ = 0x00000000;		 /* SP_VS_MEM_SIZE_REG */
+
+	*cmds++ = cp_type0_packet(A3XX_SP_FS_PVT_MEM_SIZE_REG, 1);
+	*cmds++ = 0x00000000;		 /* SP_FS_MEM_SIZE_REG */
+
+	/* end oxili_generate_context_roll_packets */
+
 	/*
 	 * Resolve using two draw calls with a dummy register
 	 * write in between. This is a HLM workaround
@@ -904,7 +969,6 @@
 
 	return cmds;
 }
-
 static void build_shader_save_cmds(struct adreno_device *adreno_dev,
 				   struct adreno_context *drawctxt)
 {
@@ -1172,12 +1236,13 @@
 	*cmds++ = CP_REG(A3XX_HLSQ_CONTROL_0_REG);
 	/* HLSQ_CONTROL_0_REG */
 	*cmds++ = _SET(HLSQ_CTRL0REG_FSTHREADSIZE, HLSQ_FOUR_PIX_QUADS) |
+		_SET(HLSQ_CTRL0REG_FSSUPERTHREADENABLE, 1) |
 		_SET(HLSQ_CTRL0REG_SPSHADERRESTART, 1) |
 		_SET(HLSQ_CTRL0REG_CHUNKDISABLE, 1) |
-		_SET(HLSQ_CTRL0REG_SPCONSTFULLUPDATE, 1) |
-		_SET(HLSQ_CTRL0REG_TPFULLUPDATE, 1);
+		_SET(HLSQ_CTRL0REG_SPCONSTFULLUPDATE, 1);
 	/* HLSQ_CONTROL_1_REG */
-	*cmds++ = _SET(HLSQ_CTRL1REG_VSTHREADSIZE, HLSQ_TWO_VTX_QUADS);
+	*cmds++ = _SET(HLSQ_CTRL1REG_VSTHREADSIZE, HLSQ_TWO_VTX_QUADS) |
+		_SET(HLSQ_CTRL1REG_VSSUPERTHREADENABLE, 1);
 	/* HLSQ_CONTROL_2_REG */
 	*cmds++ = _SET(HLSQ_CTRL2REG_PRIMALLOCTHRESHOLD, 31);
 	/* HLSQ_CONTROL3_REG */
@@ -1204,6 +1269,9 @@
 	*cmds++ = 0x00000240;
 	*cmds++ = 0x00000000;
 
+	*cmds++ = cp_type0_packet(A3XX_VFD_PERFCOUNTER0_SELECT, 1);
+	*cmds++ = 0x00000000;
+
 	/* Texture memobjs */
 	*cmds++ = cp_type3_packet(CP_LOAD_STATE, 6);
 	*cmds++ = (16 << CP_LOADSTATE_DSTOFFSET_SHIFT)
@@ -1217,6 +1285,9 @@
 	*cmds++ = (shadow->pitch*4*8) << 9;
 	*cmds++ = 0x00000000;
 
+	*cmds++ = cp_type0_packet(A3XX_VFD_PERFCOUNTER0_SELECT, 1);
+	*cmds++ = 0x00000000;
+
 	/* Mipmap bases */
 	*cmds++ = cp_type3_packet(CP_LOAD_STATE, 16);
 	*cmds++ = (224 << CP_LOADSTATE_DSTOFFSET_SHIFT)
@@ -1240,6 +1311,9 @@
 	*cmds++ = 0x00000000;
 	*cmds++ = 0x00000000;
 
+	*cmds++ = cp_type0_packet(A3XX_VFD_PERFCOUNTER0_SELECT, 1);
+	*cmds++ = 0x00000000;
+
 	*cmds++ = cp_type3_packet(CP_SET_CONSTANT, 5);
 	*cmds++ = CP_REG(A3XX_HLSQ_VS_CONTROL_REG);
 	/* HLSQ_VS_CONTROL_REG */
@@ -1313,9 +1387,11 @@
 	*cmds++ = _SET(SP_FSCTRLREG0_FSTHREADMODE, SP_MULTI) |
 		_SET(SP_FSCTRLREG0_FSINSTRBUFFERMODE, SP_BUFFER_MODE) |
 		_SET(SP_FSCTRLREG0_FSICACHEINVALID, 1) |
-		_SET(SP_FSCTRLREG0_FSFULLREGFOOTPRINT, 2) |
+		_SET(SP_FSCTRLREG0_FSHALFREGFOOTPRINT, 1) |
+		_SET(SP_FSCTRLREG0_FSFULLREGFOOTPRINT, 1) |
 		_SET(SP_FSCTRLREG0_FSINOUTREGOVERLAP, 1) |
 		_SET(SP_FSCTRLREG0_FSTHREADSIZE, SP_FOUR_PIX_QUADS) |
+		_SET(SP_FSCTRLREG0_FSSUPERTHREADMODE, 1) |
 		_SET(SP_FSCTRLREG0_PIXLODENABLE, 1) |
 		_SET(SP_FSCTRLREG0_FSLENGTH, 2);
 	/* SP_FS_CTRL_REG1 */
@@ -1324,7 +1400,7 @@
 		_SET(SP_FSCTRLREG1_HALFPRECVAROFFSET, 63);
 	/* SP_FS_OBJ_OFFSET_REG */
 	*cmds++ = _SET(SP_OBJOFFSETREG_CONSTOBJECTSTARTOFFSET, 128) |
-		_SET(SP_OBJOFFSETREG_SHADEROBJOFFSETINIC, 1);
+		_SET(SP_OBJOFFSETREG_SHADEROBJOFFSETINIC, 126);
 	/* SP_FS_OBJ_START_REG */
 	*cmds++ = 0x00000000;
 
@@ -1343,7 +1419,7 @@
 	*cmds++ = cp_type3_packet(CP_SET_CONSTANT, 5);
 	*cmds++ = CP_REG(A3XX_SP_FS_MRT_REG_0);
 	/* SP_FS_MRT_REG0 */
-	*cmds++ = _SET(SP_FSMRTREG_REGID, 4);
+	*cmds++ = _SET(SP_FSMRTREG_PRECISION, 1);
 	/* SP_FS_MRT_REG1 */
 	*cmds++ = 0;
 	/* SP_FS_MRT_REG2 */
@@ -1440,7 +1516,8 @@
 	*cmds++ = cp_type3_packet(CP_SET_CONSTANT, 2);
 	*cmds++ = CP_REG(A3XX_SP_SP_CTRL_REG);
 	/* SP_SP_CTRL_REG */
-	*cmds++ = _SET(SP_SPCTRLREG_SLEEPMODE, 1);
+	*cmds++ = _SET(SP_SPCTRLREG_SLEEPMODE, 1) |
+		_SET(SP_SPCTRLREG_LOMODE, 1);
 
 	/* Load vertex shader */
 	*cmds++ = cp_type3_packet(CP_LOAD_STATE, 10);
@@ -1451,7 +1528,7 @@
 	*cmds++ = (HLSQ_SP_VS_INSTR << CP_LOADSTATE_STATETYPE_SHIFT)
 		| (0 << CP_LOADSTATE_EXTSRCADDR_SHIFT);
 	/* (sy)end; */
-	*cmds++ = 0x00000000; *cmds++ = 0x13000000;
+	*cmds++ = 0x00000000; *cmds++ = 0x13001000;
 	/* nop; */
 	*cmds++ = 0x00000000; *cmds++ = 0x00000000;
 	/* nop; */
@@ -1459,6 +1536,13 @@
 	/* nop; */
 	*cmds++ = 0x00000000; *cmds++ = 0x00000000;
 
+	*cmds++ = cp_type0_packet(A3XX_VFD_PERFCOUNTER0_SELECT, 1);
+	*cmds++ = 0x00000000;
+
+	*cmds++ = cp_type3_packet(CP_WAIT_FOR_IDLE, 1);
+	*cmds++ = 0x00000000;
+
+
 	/* Load fragment shader */
 	*cmds++ = cp_type3_packet(CP_LOAD_STATE, 18);
 	*cmds++ = (0 << CP_LOADSTATE_DSTOFFSET_SHIFT)
@@ -1468,21 +1552,27 @@
 	*cmds++ = (HLSQ_SP_FS_INSTR << CP_LOADSTATE_STATETYPE_SHIFT)
 		| (0 << CP_LOADSTATE_EXTSRCADDR_SHIFT);
 	/* (sy)(rpt1)bary.f (ei)r0.z, (r)0, r0.x; */
-	*cmds++ = 0x00002000; *cmds++ = 0x57368902;
+	*cmds++ = 0x00002000; *cmds++ = 0x57309902;
 	/* (rpt5)nop; */
 	*cmds++ = 0x00000000; *cmds++ = 0x00000500;
 	/* sam (f32)r0.xyzw, r0.z, s#0, t#0; */
 	*cmds++ = 0x00000005; *cmds++ = 0xa0c01f00;
 	/* (sy)mov.f32f32 r1.x, r0.x; */
-	*cmds++ = 0x00000000; *cmds++ = 0x30044004;
+	*cmds++ = 0x00000000; *cmds++ = 0x30040b00;
 	/* mov.f32f32 r1.y, r0.y; */
-	*cmds++ = 0x00000001; *cmds++ = 0x20044005;
-	/* mov.f32f32 r1.z, r0.z; */
-	*cmds++ = 0x00000002; *cmds++ = 0x20044006;
-	/* mov.f32f32 r1.w, r0.w; */
-	*cmds++ = 0x00000003; *cmds++ = 0x20044007;
-	/* end; */
 	*cmds++ = 0x00000000; *cmds++ = 0x03000000;
+	/* mov.f32f32 r1.z, r0.z; */
+	*cmds++ = 0x00000000; *cmds++ = 0x00000000;
+	/* mov.f32f32 r1.w, r0.w; */
+	*cmds++ = 0x00000000; *cmds++ = 0x00000000;
+	/* end; */
+	*cmds++ = 0x00000000; *cmds++ = 0x00000000;
+
+	*cmds++ = cp_type0_packet(A3XX_VFD_PERFCOUNTER0_SELECT, 1);
+	*cmds++ = 0x00000000;
+
+	*cmds++ = cp_type3_packet(CP_WAIT_FOR_IDLE, 1);
+	*cmds++ = 0x00000000;
 
 	*cmds++ = cp_type3_packet(CP_SET_CONSTANT, 3);
 	*cmds++ = CP_REG(A3XX_VFD_CONTROL_0);
@@ -1535,16 +1625,16 @@
 	*cmds++ = cp_type3_packet(CP_SET_CONSTANT, 2);
 	*cmds++ = CP_REG(A3XX_RB_DEPTH_CONTROL);
 	/* RB_DEPTH_CONTROL */
-	*cmds++ = _SET(RB_DEPTHCONTROL_Z_TEST_FUNC, RB_FRAG_NEVER);
+	*cmds++ = _SET(RB_DEPTHCONTROL_Z_TEST_FUNC, RB_FRAG_LESS);
 
 	*cmds++ = cp_type3_packet(CP_SET_CONSTANT, 2);
 	*cmds++ = CP_REG(A3XX_RB_STENCIL_CONTROL);
 	/* RB_STENCIL_CONTROL */
-	*cmds++ = _SET(RB_STENCILCONTROL_STENCIL_FUNC, RB_REF_NEVER) |
+	*cmds++ = _SET(RB_STENCILCONTROL_STENCIL_FUNC, RB_REF_ALWAYS) |
 		_SET(RB_STENCILCONTROL_STENCIL_FAIL, RB_STENCIL_KEEP) |
 		_SET(RB_STENCILCONTROL_STENCIL_ZPASS, RB_STENCIL_KEEP) |
 		_SET(RB_STENCILCONTROL_STENCIL_ZFAIL, RB_STENCIL_KEEP) |
-		_SET(RB_STENCILCONTROL_STENCIL_FUNC_BF, RB_REF_NEVER) |
+		_SET(RB_STENCILCONTROL_STENCIL_FUNC_BF, RB_REF_ALWAYS) |
 		_SET(RB_STENCILCONTROL_STENCIL_FAIL_BF, RB_STENCIL_KEEP) |
 		_SET(RB_STENCILCONTROL_STENCIL_ZPASS_BF, RB_STENCIL_KEEP) |
 		_SET(RB_STENCILCONTROL_STENCIL_ZFAIL_BF, RB_STENCIL_KEEP);
@@ -1570,9 +1660,8 @@
 	*cmds++ = cp_type3_packet(CP_SET_CONSTANT, 2);
 	*cmds++ = CP_REG(A3XX_RB_MRT_CONTROL0);
 	/* RB_MRT_CONTROL0 */
-	*cmds++ = _SET(RB_MRTCONTROL_READ_DEST_ENABLE, 1) |
-		_SET(RB_MRTCONTROL_ROP_CODE, 12) |
-		_SET(RB_MRTCONTROL_DITHER_MODE, RB_DITHER_ALWAYS) |
+	*cmds++ = _SET(RB_MRTCONTROL_ROP_CODE, 12) |
+		_SET(RB_MRTCONTROL_DITHER_MODE, RB_DITHER_DISABLE) |
 		_SET(RB_MRTCONTROL_COMPONENT_ENABLE, 0xF);
 
 	*cmds++ = cp_type3_packet(CP_SET_CONSTANT, 3);
@@ -1587,7 +1676,8 @@
 		_SET(RB_MRTBLENDCONTROL_CLAMP_ENABLE, 1);
 	/* RB_MRT_CONTROL1 */
 	*cmds++ = _SET(RB_MRTCONTROL_READ_DEST_ENABLE, 1) |
-		_SET(RB_MRTCONTROL_DITHER_MODE, RB_DITHER_DISABLE) |
+		_SET(RB_MRTCONTROL_ROP_CODE, 12) |
+		_SET(RB_MRTCONTROL_DITHER_MODE, RB_DITHER_ALWAYS) |
 		_SET(RB_MRTCONTROL_COMPONENT_ENABLE, 0xF);
 
 	*cmds++ = cp_type3_packet(CP_SET_CONSTANT, 3);
@@ -1602,7 +1692,8 @@
 		_SET(RB_MRTBLENDCONTROL_CLAMP_ENABLE, 1);
 	/* RB_MRT_CONTROL2 */
 	*cmds++ = _SET(RB_MRTCONTROL_READ_DEST_ENABLE, 1) |
-		_SET(RB_MRTCONTROL_DITHER_MODE, RB_DITHER_DISABLE) |
+		_SET(RB_MRTCONTROL_ROP_CODE, 12) |
+		_SET(RB_MRTCONTROL_DITHER_MODE, RB_DITHER_ALWAYS) |
 		_SET(RB_MRTCONTROL_COMPONENT_ENABLE, 0xF);
 
 	*cmds++ = cp_type3_packet(CP_SET_CONSTANT, 3);
@@ -1617,7 +1708,8 @@
 		_SET(RB_MRTBLENDCONTROL_CLAMP_ENABLE, 1);
 	/* RB_MRT_CONTROL3 */
 	*cmds++ = _SET(RB_MRTCONTROL_READ_DEST_ENABLE, 1) |
-		_SET(RB_MRTCONTROL_DITHER_MODE, RB_DITHER_DISABLE) |
+		_SET(RB_MRTCONTROL_ROP_CODE, 12) |
+		_SET(RB_MRTCONTROL_DITHER_MODE, RB_DITHER_ALWAYS) |
 		_SET(RB_MRTCONTROL_COMPONENT_ENABLE, 0xF);
 
 	*cmds++ = cp_type3_packet(CP_SET_CONSTANT, 2);
@@ -1636,7 +1728,7 @@
 	/* VFD_INDEX_MIN */
 	*cmds++ = 0x00000000;
 	/* VFD_INDEX_MAX */
-	*cmds++ = 0xFFFFFFFF;
+	*cmds++ = 340;
 	/* VFD_INDEX_OFFSET */
 	*cmds++ = 0x00000000;
 	/* TPL1_TP_VS_TEX_OFFSET */
@@ -1645,7 +1737,7 @@
 	*cmds++ = cp_type3_packet(CP_SET_CONSTANT, 2);
 	*cmds++ = CP_REG(A3XX_VFD_VS_THREADING_THRESHOLD);
 	/* VFD_VS_THREADING_THRESHOLD */
-	*cmds++ = _SET(VFD_THREADINGTHRESHOLD_RESERVED6, 12) |
+	*cmds++ = _SET(VFD_THREADINGTHRESHOLD_REGID_THRESHOLD, 15) |
 		_SET(VFD_THREADINGTHRESHOLD_REGID_VTXCNT, 252);
 
 	*cmds++ = cp_type3_packet(CP_SET_CONSTANT, 2);
@@ -1670,7 +1762,7 @@
 	*cmds++ = cp_type3_packet(CP_SET_CONSTANT, 2);
 	*cmds++ = CP_REG(A3XX_GRAS_SU_MODE_CONTROL);
 	/* GRAS_SU_MODE_CONTROL */
-	*cmds++ = 0x00000000;
+	*cmds++ = _SET(GRAS_SU_CTRLMODE_LINEHALFWIDTH, 2);
 
 	*cmds++ = cp_type3_packet(CP_SET_CONSTANT, 3);
 	*cmds++ = CP_REG(A3XX_GRAS_SC_WINDOW_SCISSOR_TL);
@@ -1726,6 +1818,46 @@
 		PC_DRAW_TRIANGLES) |
 		_SET(PC_PRIM_VTX_CONTROL_PROVOKING_VTX_LAST, 1);
 
+
+	/* oxili_generate_context_roll_packets */
+	*cmds++ = cp_type0_packet(A3XX_SP_VS_CTRL_REG0, 1);
+	*cmds++ = 0x00000400;
+
+	*cmds++ = cp_type0_packet(A3XX_SP_FS_CTRL_REG0, 1);
+	*cmds++ = 0x00000400;
+
+	*cmds++ = cp_type0_packet(A3XX_SP_VS_PVT_MEM_SIZE_REG, 1);
+	*cmds++ = 0x00008000; /* SP_VS_MEM_SIZE_REG */
+
+	*cmds++ = cp_type0_packet(A3XX_SP_FS_PVT_MEM_SIZE_REG, 1);
+	*cmds++ = 0x00008000; /* SP_FS_MEM_SIZE_REG */
+
+	/* Clear cache invalidate bit when re-loading the shader control regs */
+	*cmds++ = cp_type0_packet(A3XX_SP_VS_CTRL_REG0, 1);
+	*cmds++ = _SET(SP_VSCTRLREG0_VSTHREADMODE, SP_MULTI) |
+		_SET(SP_VSCTRLREG0_VSINSTRBUFFERMODE, SP_BUFFER_MODE) |
+		_SET(SP_VSCTRLREG0_VSFULLREGFOOTPRINT, 2) |
+		_SET(SP_VSCTRLREG0_VSTHREADSIZE, SP_TWO_VTX_QUADS) |
+		_SET(SP_VSCTRLREG0_VSLENGTH, 1);
+
+	*cmds++ = cp_type0_packet(A3XX_SP_FS_CTRL_REG0, 1);
+	*cmds++ = _SET(SP_FSCTRLREG0_FSTHREADMODE, SP_MULTI) |
+		_SET(SP_FSCTRLREG0_FSINSTRBUFFERMODE, SP_BUFFER_MODE) |
+		_SET(SP_FSCTRLREG0_FSHALFREGFOOTPRINT, 1) |
+		_SET(SP_FSCTRLREG0_FSFULLREGFOOTPRINT, 1) |
+		_SET(SP_FSCTRLREG0_FSINOUTREGOVERLAP, 1) |
+		_SET(SP_FSCTRLREG0_FSTHREADSIZE, SP_FOUR_PIX_QUADS) |
+		_SET(SP_FSCTRLREG0_FSSUPERTHREADMODE, 1) |
+		_SET(SP_FSCTRLREG0_FSLENGTH, 2);
+
+	*cmds++ = cp_type0_packet(A3XX_SP_VS_PVT_MEM_SIZE_REG, 1);
+	*cmds++ = 0x00000000;		 /* SP_VS_MEM_SIZE_REG */
+
+	*cmds++ = cp_type0_packet(A3XX_SP_FS_PVT_MEM_SIZE_REG, 1);
+	*cmds++ = 0x00000000;		 /* SP_FS_MEM_SIZE_REG */
+
+	/* end oxili_generate_context_roll_packets */
+
 	*cmds++ = cp_type3_packet(CP_DRAW_INDX, 3);
 	*cmds++ = 0x00000000; /* Viz query info */
 	*cmds++ = BUILD_PC_DRAW_INITIATOR(PC_DI_PT_RECTLIST,
@@ -1740,6 +1872,7 @@
 	return cmds;
 }
 
+
 static void build_regrestore_cmds(struct adreno_device *adreno_dev,
 				  struct adreno_context *drawctxt)
 {
diff --git a/drivers/gpu/msm/kgsl.h b/drivers/gpu/msm/kgsl.h
index 7ffa83b..8a3345b 100644
--- a/drivers/gpu/msm/kgsl.h
+++ b/drivers/gpu/msm/kgsl.h
@@ -23,6 +23,8 @@
 #include <linux/regulator/consumer.h>
 #include <linux/mm.h>
 
+#include <mach/kgsl.h>
+
 #define KGSL_NAME "kgsl"
 
 /* The number of memstore arrays limits the number of contexts allowed.
diff --git a/drivers/hwmon/pm8xxx-adc-scale.c b/drivers/hwmon/pm8xxx-adc-scale.c
index fb2f1d5..4a1f58c 100644
--- a/drivers/hwmon/pm8xxx-adc-scale.c
+++ b/drivers/hwmon/pm8xxx-adc-scale.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, Code Aurora Forum. All rights reserved.
+ * Copyright (c) 2011-2012, Code Aurora Forum. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 and
@@ -112,127 +112,162 @@
 };
 
 static const struct pm8xxx_adc_map_pt adcmap_pa_therm[] = {
-	{1677,	-30},
-	{1671,	-29},
-	{1663,	-28},
-	{1656,	-27},
-	{1648,	-26},
-	{1640,	-25},
-	{1632,	-24},
-	{1623,	-23},
-	{1615,	-22},
-	{1605,	-21},
-	{1596,	-20},
-	{1586,	-19},
-	{1576,	-18},
-	{1565,	-17},
-	{1554,	-16},
-	{1543,	-15},
-	{1531,	-14},
-	{1519,	-13},
-	{1507,	-12},
-	{1494,	-11},
-	{1482,	-10},
-	{1468,	-9},
-	{1455,	-8},
-	{1441,	-7},
-	{1427,	-6},
-	{1412,	-5},
-	{1398,	-4},
-	{1383,	-3},
-	{1367,	-2},
-	{1352,	-1},
-	{1336,	0},
-	{1320,	1},
-	{1304,	2},
-	{1287,	3},
-	{1271,	4},
-	{1254,	5},
-	{1237,	6},
-	{1219,	7},
-	{1202,	8},
-	{1185,	9},
-	{1167,	10},
-	{1149,	11},
-	{1131,	12},
-	{1114,	13},
-	{1096,	14},
-	{1078,	15},
-	{1060,	16},
-	{1042,	17},
-	{1024,	18},
-	{1006,	19},
-	{988,	20},
-	{970,	21},
-	{952,	22},
-	{934,	23},
-	{917,	24},
+	{1731,	-30},
+	{1726,	-29},
+	{1721,	-28},
+	{1715,	-27},
+	{1710,	-26},
+	{1703,	-25},
+	{1697,	-24},
+	{1690,	-23},
+	{1683,	-22},
+	{1675,	-21},
+	{1667,	-20},
+	{1659,	-19},
+	{1650,	-18},
+	{1641,	-17},
+	{1632,	-16},
+	{1622,	-15},
+	{1611,	-14},
+	{1600,	-13},
+	{1589,	-12},
+	{1577,	-11},
+	{1565,	-10},
+	{1552,	-9},
+	{1539,	-8},
+	{1525,	-7},
+	{1511,	-6},
+	{1496,	-5},
+	{1481,	-4},
+	{1465,	-3},
+	{1449,	-2},
+	{1432,	-1},
+	{1415,	0},
+	{1398,	1},
+	{1380,	2},
+	{1362,	3},
+	{1343,	4},
+	{1324,	5},
+	{1305,	6},
+	{1285,	7},
+	{1265,	8},
+	{1245,	9},
+	{1224,	10},
+	{1203,	11},
+	{1182,	12},
+	{1161,	13},
+	{1139,	14},
+	{1118,	15},
+	{1096,	16},
+	{1074,	17},
+	{1052,	18},
+	{1030,	19},
+	{1008,	20},
+	{986,	21},
+	{964,	22},
+	{943,	23},
+	{921,	24},
 	{899,	25},
-	{882,	26},
-	{865,	27},
-	{848,	28},
-	{831,	29},
-	{814,	30},
-	{797,	31},
-	{781,	32},
-	{764,	33},
-	{748,	34},
-	{732,	35},
-	{717,	36},
-	{701,	37},
-	{686,	38},
-	{671,	39},
-	{656,	40},
-	{642,	41},
-	{627,	42},
-	{613,	43},
-	{599,	44},
-	{586,	45},
-	{572,	46},
-	{559,	47},
-	{546,	48},
-	{534,	49},
-	{522,	50},
-	{509,	51},
-	{498,	52},
-	{486,	53},
-	{475,	54},
-	{463,	55},
-	{452,	56},
-	{442,	57},
-	{431,	58},
-	{421,	59},
-	{411,	60},
-	{401,	61},
-	{392,	62},
-	{383,	63},
-	{374,	64},
-	{365,	65},
-	{356,	66},
-	{348,	67},
-	{339,	68},
-	{331,	69},
-	{323,	70},
-	{316,	71},
-	{308,	72},
-	{301,	73},
-	{294,	74},
-	{287,	75},
-	{280,	76},
-	{273,	77},
-	{267,	78},
-	{261,	79},
-	{255,	80},
-	{249,	81},
-	{243,	82},
-	{237,	83},
-	{232,	84},
-	{226,	85},
-	{221,	86},
-	{216,	87},
-	{211,	88},
-	{206,	89},
-	{201,	90}
+	{878,	26},
+	{857,	27},
+	{836,	28},
+	{815,	29},
+	{794,	30},
+	{774,	31},
+	{754,	32},
+	{734,	33},
+	{714,	34},
+	{695,	35},
+	{676,	36},
+	{657,	37},
+	{639,	38},
+	{621,	39},
+	{604,	40},
+	{586,	41},
+	{570,	42},
+	{553,	43},
+	{537,	44},
+	{521,	45},
+	{506,	46},
+	{491,	47},
+	{476,	48},
+	{462,	49},
+	{448,	50},
+	{435,	51},
+	{421,	52},
+	{409,	53},
+	{396,	54},
+	{384,	55},
+	{372,	56},
+	{361,	57},
+	{350,	58},
+	{339,	59},
+	{329,	60},
+	{318,	61},
+	{309,	62},
+	{299,	63},
+	{290,	64},
+	{281,	65},
+	{272,	66},
+	{264,	67},
+	{256,	68},
+	{248,	69},
+	{240,	70},
+	{233,	71},
+	{226,	72},
+	{219,	73},
+	{212,	74},
+	{206,	75},
+	{199,	76},
+	{193,	77},
+	{187,	78},
+	{182,	79},
+	{176,	80},
+	{171,	81},
+	{166,	82},
+	{161,	83},
+	{156,	84},
+	{151,	85},
+	{147,	86},
+	{142,	87},
+	{138,	88},
+	{134,	89},
+	{130,	90},
+	{126,	91},
+	{122,	92},
+	{119,	93},
+	{115,	94},
+	{112,	95},
+	{109,	96},
+	{106,	97},
+	{103,	98},
+	{100,	99},
+	{97,	100},
+	{94,	101},
+	{91,	102},
+	{89,	103},
+	{86,	104},
+	{84,	105},
+	{82,	106},
+	{79,	107},
+	{77,	108},
+	{75,	109},
+	{73,	110},
+	{71,	111},
+	{69,	112},
+	{67,	113},
+	{65,	114},
+	{64,	115},
+	{62,	116},
+	{60,	117},
+	{59,	118},
+	{57,	119},
+	{56,	120},
+	{54,	121},
+	{53,	122},
+	{51,	123},
+	{50,	124},
+	{49,	125}
 };
 
 static const struct pm8xxx_adc_map_pt adcmap_ntcg_104ef_104fb[] = {
diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c
index 23317d6..1c70527 100644
--- a/drivers/input/touchscreen/atmel_mxt_ts.c
+++ b/drivers/input/touchscreen/atmel_mxt_ts.c
@@ -100,6 +100,7 @@
 #define MXT_PROCI_PALM_T41		41
 #define MXT_PROCI_TOUCHSUPPRESSION_T42	42
 #define MXT_PROCI_STYLUS_T47		47
+#define MXT_PROCI_ADAPTIVETHRESHOLD_T55 55
 #define MXT_PROCI_SHIELDLESS_T56	56
 #define MXT_PROCG_NOISESUPPRESSION_T48	48
 #define MXT_SPT_COMMSCONFIG_T18		18
@@ -228,7 +229,7 @@
 #define MXT_BACKUP_VALUE	0x55
 #define MXT_BACKUP_TIME		25	/* msec */
 #define MXT224_RESET_TIME	65	/* msec */
-#define MXT224E_RESET_TIME	22	/* msec */
+#define MXT224E_RESET_TIME	150	/* msec */
 #define MXT1386_RESET_TIME	250	/* msec */
 #define MXT_RESET_TIME		250	/* msec */
 #define MXT_RESET_NOCHGREAD	400	/* msec */
@@ -386,6 +387,7 @@
 	case MXT_SPT_USERDATA_T38:
 	case MXT_SPT_DIGITIZER_T43:
 	case MXT_SPT_CTECONFIG_T46:
+	case MXT_PROCI_ADAPTIVETHRESHOLD_T55:
 		return true;
 	default:
 		return false;
@@ -419,6 +421,7 @@
 	case MXT_SPT_USERDATA_T38:
 	case MXT_SPT_DIGITIZER_T43:
 	case MXT_SPT_CTECONFIG_T46:
+	case MXT_PROCI_ADAPTIVETHRESHOLD_T55:
 		return true;
 	default:
 		return false;
@@ -732,6 +735,36 @@
 	return __mxt_read_reg(data->client, reg + offset, 1, val);
 }
 
+static int mxt_get_object_address(struct device *dev, u8 type)
+{
+	struct mxt_data *data = dev_get_drvdata(dev);
+	u8 obj_num, obj_buf[MXT_OBJECT_SIZE];
+	u16 reg;
+	int i, error;
+
+	error = mxt_read_reg(data->client, MXT_OBJECT_NUM, &obj_num);
+
+	if (error) {
+		dev_err(dev, "reading number of objects failed\n");
+		return -EINVAL;
+	}
+
+	for (i = 0; i < obj_num; i++) {
+		reg = MXT_OBJECT_START + MXT_OBJECT_SIZE * i;
+		error = mxt_read_object_table(data->client,
+						reg, obj_buf);
+		if (error)
+			return error;
+
+		if (obj_buf[0] == type)
+			return obj_buf[2] << 8 | obj_buf[1];
+	}
+	/* If control reaches here, i = obj_num and object not found */
+	dev_err(dev, "Requested object %d not found.\n", type);
+	return -EINVAL;
+
+}
+
 static int mxt_write_object(struct mxt_data *data,
 				 u8 type, u8 offset, u8 val)
 {
@@ -1543,6 +1576,7 @@
 
 	switch (data->info.family_id) {
 	case MXT224_ID:
+	case MXT224E_ID:
 		max_frame_size = MXT_SINGLE_FW_MAX_FRAME_SIZE;
 		break;
 	case MXT1386_ID:
@@ -1681,11 +1715,12 @@
 					const char *buf, size_t count)
 {
 	struct mxt_data *data = dev_get_drvdata(dev);
-	int error;
+	int error, address;
 	const char *fw_name;
 	u8 bootldr_id;
 	u8 cfg_version[MXT_CFG_VERSION_LEN] = {0};
 
+
 	/* If fw_name is set, then the existing firmware has an upgrade */
 	if (!data->fw_name) {
 		/*
@@ -1735,6 +1770,16 @@
 		data->cfg_version_idx = 0;
 		data->update_cfg = false;
 
+		/* T38 object address might have changed, read it from
+		   touch controller */
+		address = mxt_get_object_address(dev, MXT_SPT_USERDATA_T38);
+		if (address < 0) {
+			dev_err(dev, "T38 required for touch operation\n");
+			return -EINVAL;
+		}
+
+		data->t38_start_addr = address;
+
 		error = __mxt_write_reg(data->client, data->t38_start_addr,
 				sizeof(cfg_version), cfg_version);
 		if (error)
diff --git a/drivers/input/touchscreen/cyttsp-i2c-qc.c b/drivers/input/touchscreen/cyttsp-i2c-qc.c
index 5af4534..d8881a4 100644
--- a/drivers/input/touchscreen/cyttsp-i2c-qc.c
+++ b/drivers/input/touchscreen/cyttsp-i2c-qc.c
@@ -3,6 +3,7 @@
  * drivers/input/touchscreen/cyttsp-i2c.c
  *
  * Copyright (C) 2009, 2010 Cypress Semiconductor, Inc.
+ * Copyright (c) 2012, Code Aurora Forum. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -41,6 +42,7 @@
 #include <linux/pm_runtime.h>
 #include <linux/firmware.h>
 #include <linux/mutex.h>
+#include <linux/completion.h>
 #include <linux/regulator/consumer.h>
 #ifdef CONFIG_HAS_EARLYSUSPEND
 #include <linux/earlysuspend.h>
@@ -56,6 +58,30 @@
 #define FW_FNAME_LEN 40
 #define TTSP_BUFF_SIZE 50
 
+enum cyttsp_powerstate {
+	CY_IDLE = 0,	/* IC cannot be reached */
+	CY_READY,		/* pre-operational; ready to go to ACTIVE */
+	CY_ACTIVE,	/* app is running, IC is scanning */
+	CY_LOW_PWR,	/* not currently used  */
+	CY_SLEEP,		/* app is running, IC is idle */
+	CY_BL,		/* bootloader is running */
+	CY_LDR,		/* loader is running */
+	CY_SYSINFO,	/* switching to sysinfo mode */
+	CY_INVALID,	/* always last in the list */
+};
+static char *cyttsp_powerstate_string[] = {
+	/* Order must match enum cyttsp_powerstate above */
+	"IDLE",
+	"READY",
+	"ACTIVE",
+	"LOW_PWR",
+	"SLEEP",
+	"BOOTLOADER",
+	"LOADER",
+	"SYSINFO",
+	"INVALID",
+};
+
 /* CY TTSP I2C Driver private data */
 struct cyttsp {
 	struct i2c_client *client;
@@ -65,12 +91,15 @@
 	char phys[32];
 	struct cyttsp_platform_data *platform_data;
 	u8 num_prv_st_tch;
+	u8 power_settings[3];
 	u16 fw_start_addr;
+	enum cyttsp_powerstate power_state;
 	u16 act_trk[CY_NUM_TRK_ID];
 	u16 prv_st_tch[CY_NUM_ST_TCH_ID];
 	u16 prv_mt_tch[CY_NUM_MT_TCH_ID];
 	u16 prv_mt_pos[CY_NUM_TRK_ID][2];
 	atomic_t irq_enabled;
+	struct completion si_int_running;
 	bool cyttsp_update_fw;
 	bool cyttsp_fwloader_mode;
 	bool is_suspended;
@@ -158,6 +187,67 @@
 				atomic_read(&ts->irq_enabled));
 }
 
+static int cyttsp_hndshk(struct cyttsp *ts, u8 hst_mode)
+{
+	int retval = 0;
+	u8 mode = 0;
+
+	mode = hst_mode & CY_HNDSHK_BIT ?
+		hst_mode & ~CY_HNDSHK_BIT :
+		hst_mode | CY_HNDSHK_BIT;
+
+	retval = i2c_smbus_write_i2c_block_data(ts->client,
+			CY_REG_BASE, sizeof(mode), &mode);
+
+	if (retval < 0) {
+		pr_err("%s: bus write fail on handshake r=%d\n",
+			__func__, retval);
+	}
+
+	return retval;
+}
+
+static void cyttsp_change_state(struct cyttsp *ts,
+	enum cyttsp_powerstate new_state)
+{
+	ts->power_state = new_state;
+	pr_info("%s: %s\n", __func__,
+		(ts->power_state < CY_INVALID) ?
+		cyttsp_powerstate_string[ts->power_state] :
+		"INVALID");
+}
+
+static int cyttsp_wait_ready(struct cyttsp *ts, struct completion *complete,
+	u8 *cmd, size_t cmd_size, unsigned long timeout_ms)
+{
+	unsigned long timeout = 0;
+	unsigned long uretval = 0;
+	int retval = 0;
+
+	timeout = msecs_to_jiffies(timeout_ms);
+	INIT_COMPLETION(*complete);
+	if ((cmd != NULL) && (cmd_size != 0)) {
+		retval = i2c_smbus_write_i2c_block_data(ts->client,
+				CY_REG_BASE, cmd_size, cmd);
+		if (retval < 0) {
+			pr_err("%s: bus write fail switch mode r=%d\n",
+				__func__, retval);
+			cyttsp_change_state(ts, CY_IDLE);
+			goto _cyttsp_wait_ready_exit;
+		}
+	}
+	uretval = wait_for_completion_interruptible_timeout(complete, timeout);
+	if (uretval == 0) {
+		pr_err("%s: Switch Mode Timeout waiting " \
+			"for ready interrupt - try reading regs\n", __func__);
+		/* continue anyway */
+		retval = 0;
+	}
+
+_cyttsp_wait_ready_exit:
+	return retval;
+}
+
 static ssize_t cyttsp_irq_enable(struct device *dev,
 				struct device_attribute *attr,
 				const char *buf, size_t size)
@@ -329,33 +419,41 @@
 	} while (tries++ < 10 && (retval < 0));
 }
 
-static void cyttsp_set_sysinfo_mode(struct cyttsp *ts)
+static int cyttsp_set_sysinfo_mode(struct cyttsp *ts, u8 sleep)
 {
-	int retval, tries = 0;
-	u8 host_reg = CY_SYSINFO_MODE;
+	int retval;
+	u8 mode = CY_SYSINFO_MODE + sleep;
 
-	do {
-		retval = i2c_smbus_write_i2c_block_data(ts->client,
-			CY_REG_BASE, sizeof(host_reg), &host_reg);
-		if (retval < 0)
-			msleep(20);
-	} while (tries++ < 10 && (retval < 0));
+	cyttsp_change_state(ts, CY_SYSINFO);
 
-	/* wait for TTSP Device to complete switch to SysInfo mode */
-	if (!(retval < 0)) {
-		retval = i2c_smbus_read_i2c_block_data(ts->client,
-				CY_REG_BASE,
-				sizeof(struct cyttsp_sysinfo_data_t),
-				(u8 *)&g_sysinfo_data);
-	} else
-		pr_err("%s: failed\n", __func__);
+	retval = cyttsp_wait_ready(ts, &ts->si_int_running,
+		&mode, sizeof(mode), CY_HALF_SEC_TMO_MS);
+
+	if (retval < 0) {
+		pr_err("%s: fail wait ready r=%d\n", __func__, retval);
+		goto cyttsp_set_sysinfo_mode_exit;
+	}
+
+	if (GET_HSTMODE(g_sysinfo_data.hst_mode) !=
+		GET_HSTMODE(CY_SYSINFO_MODE)) {
+		pr_err("%s: Fail enter Sysinfo mode hst_mode=0x%02X\n",
+			__func__, g_sysinfo_data.hst_mode);
+		retval = -EIO;
+	} else {
+		cyttsp_debug("%s: Enter Sysinfo mode hst_mode=0x%02X\n",
+			__func__, g_sysinfo_data.hst_mode);
+	}
+
+cyttsp_set_sysinfo_mode_exit:
+	return retval;
 }
 
-static void cyttsp_set_opmode(struct cyttsp *ts)
+static void cyttsp_set_opmode(struct cyttsp *ts, u8 sleep)
 {
 	int retval, tries = 0;
-	u8 host_reg = CY_OP_MODE;
+	u8 host_reg = CY_OP_MODE + sleep;
 
+	cyttsp_change_state(ts, CY_ACTIVE);
 	do {
 		retval = i2c_smbus_write_i2c_block_data(ts->client,
 				CY_REG_BASE, sizeof(host_reg), &host_reg);
@@ -364,6 +462,34 @@
 	} while (tries++ < 10 && (retval < 0));
 }
 
+static int cyttsp_set_lp_mode(struct cyttsp *ts)
+{
+	int retval = 0, tries = 0;
+
+	retval = cyttsp_set_sysinfo_mode(ts, CY_LOW_PWR_MODE);
+	if (retval < 0) {
+		pr_err("%s: failed to enter sysinfo mode, retval =%x\n",
+			__func__, retval);
+		goto exit_low_power_mode;
+	}
+	do {
+		retval = i2c_smbus_write_i2c_block_data(
+			ts->client,
+			CY_REG_ACT_INTRVL,
+			sizeof(ts->power_settings), ts->power_settings);
+		if (retval < 0)
+			msleep(20);
+	} while ((retval < 0) && (tries++ < 5));
+	if (retval < 0)
+		pr_err("%s: failed to write power_settings, retval =%x\n",
+			__func__, retval);
+	msleep(CY_DLY_SYSINFO);
+exit_low_power_mode:
+	cyttsp_set_opmode(ts, CY_LOW_PWR_MODE);
+	return retval;
+
+}
+
 static int str2uc(char *str, u8 *val)
 {
 	char substr[3];
@@ -740,21 +866,19 @@
 			pr_info("%s: firmware upgrade success\n", __func__);
 	}
 
-	/* enter bootloader idle mode */
-	cyttsp_soft_reset(ts);
-	/* exit bootloader mode */
-	cyttsp_exit_bl_mode(ts);
-	msleep(100);
-	/* set sysinfo details */
-	cyttsp_set_sysinfo_mode(ts);
-	/* enter application mode */
-	cyttsp_set_opmode(ts);
-
 	/* enable interrupts */
 	if (ts->client->irq == 0)
 		mod_timer(&ts->timer, jiffies + TOUCHSCREEN_TIMEOUT);
 	else
 		enable_irq(ts->client->irq);
+
+	/* enter bootloader idle mode */
+	cyttsp_soft_reset(ts);
+	/* exit bootloader mode */
+	cyttsp_exit_bl_mode(ts);
+	msleep(100);
+	/* set low power mode and enter application mode*/
+	cyttsp_set_lp_mode(ts);
 }
 
 static void cyttspfw_upgrade_start(struct cyttsp *ts, const u8 *data,
@@ -958,15 +1082,14 @@
 
 	/* compare own irq counter with the device irq counter */
 	if (ts->client->irq) {
-		u8 host_reg;
 		u8 cur_cnt;
 		if (ts->platform_data->use_hndshk) {
-
-			host_reg = g_xy_data.hst_mode & CY_HNDSHK_BIT ?
-				g_xy_data.hst_mode & ~CY_HNDSHK_BIT :
-				g_xy_data.hst_mode | CY_HNDSHK_BIT;
-			retval = i2c_smbus_write_i2c_block_data(ts->client,
-				CY_REG_BASE, sizeof(host_reg), &host_reg);
+			retval = cyttsp_hndshk(ts, g_xy_data.hst_mode);
+			if (retval < 0) {
+				pr_err("%s: Fail write handshake r=%d\n",
+					__func__, retval);
+				retval = 0;
+			}
 		}
 		cur_cnt = g_xy_data.tt_undef[CY_IRQ_CNT_REG];
 		irq_cnt_total++;
@@ -1031,6 +1154,7 @@
 				tries++ < 100);
 			cyttsp_putbl(ts, 2, true, false, false);
 		}
+		cyttsp_set_lp_mode(ts);
 		goto exit_xy_handler;
 	} else {
 		cur_tch = GET_NUM_TOUCHES(g_xy_data.tt_stat);
@@ -1891,10 +2015,40 @@
 static irqreturn_t cyttsp_irq(int irq, void *handle)
 {
 	struct cyttsp *ts = (struct cyttsp *) handle;
+	int retval = 0;
 
 	cyttsp_xdebug("%s: Got IRQ\n", CY_I2C_NAME);
-
-	cyttsp_xy_handler(ts);
+	switch (ts->power_state) {
+	case CY_SYSINFO:
+		retval = i2c_smbus_read_i2c_block_data(ts->client,
+			CY_REG_BASE,
+			sizeof(struct cyttsp_sysinfo_data_t),
+			(u8 *)&g_sysinfo_data);
+		if (retval < 0) {
+			pr_err("%s: Fail read status and version regs r=%d\n",
+				__func__, retval);
+			goto cyttsp_irq_sysinfo_exit;
+		}
+		if (ts->platform_data->use_hndshk) {
+			retval = cyttsp_hndshk(ts, g_sysinfo_data.hst_mode);
+			if (retval < 0) {
+				pr_err("%s: Fail write handshake r=%d\n",
+					__func__, retval);
+				retval = 0;
+			}
+		}
+		udelay(100);	/* irq pulse: sysinfo mode switch=50us */
+		complete(&ts->si_int_running);
+cyttsp_irq_sysinfo_exit:
+		break;
+	case CY_ACTIVE:
+		cyttsp_xy_handler(ts);
+		break;
+	default:
+		pr_err("%s: Unexpected power state with interrupt ps=%d\n",
+			__func__, ts->power_state);
+		break;
+	}
 
 	return IRQ_HANDLED;
 }
@@ -2260,102 +2414,6 @@
 	}
 
 bypass:
-	/* switch to System Information mode to read versions
-	 * and set interval registers */
-	if (!(retval < CY_OK)) {
-		cyttsp_debug("switch to sysinfo mode \n");
-		host_reg = CY_SYSINFO_MODE;
-		retval = i2c_smbus_write_i2c_block_data(ts->client,
-			CY_REG_BASE, sizeof(host_reg), &host_reg);
-		/* wait for TTSP Device to complete switch to SysInfo mode */
-		msleep(100);
-		if (!(retval < CY_OK)) {
-			retval = i2c_smbus_read_i2c_block_data(ts->client,
-				CY_REG_BASE,
-				sizeof(struct cyttsp_sysinfo_data_t),
-				(u8 *)&g_sysinfo_data);
-			cyttsp_debug("SI2: hst_mode=0x%02X mfg_cmd=0x%02X mfg_stat=0x%02X\n", \
-				g_sysinfo_data.hst_mode, \
-				g_sysinfo_data.mfg_cmd, \
-				g_sysinfo_data.mfg_stat);
-			cyttsp_debug("SI2: bl_ver=0x%02X%02X\n", \
-				g_sysinfo_data.bl_verh, \
-				g_sysinfo_data.bl_verl);
-			cyttsp_debug("SI2: sysinfo act_int=0x%02X tch_tmout=0x%02X lp_int=0x%02X\n", \
-				g_sysinfo_data.act_intrvl, \
-				g_sysinfo_data.tch_tmout, \
-				g_sysinfo_data.lp_intrvl);
-			cyttsp_info("SI%d: tver=%02X%02X a_id=%02X%02X aver=%02X%02X\n", \
-				102, \
-				g_sysinfo_data.tts_verh, \
-				g_sysinfo_data.tts_verl, \
-				g_sysinfo_data.app_idh, \
-				g_sysinfo_data.app_idl, \
-				g_sysinfo_data.app_verh, \
-				g_sysinfo_data.app_verl);
-			cyttsp_info("SI%d: c_id=%02X%02X%02X\n", \
-				103, \
-				g_sysinfo_data.cid[0], \
-				g_sysinfo_data.cid[1], \
-				g_sysinfo_data.cid[2]);
-			if (!(retval < CY_OK) &&
-				(CY_DIFF(ts->platform_data->act_intrvl,
-					CY_ACT_INTRVL_DFLT)  ||
-				CY_DIFF(ts->platform_data->tch_tmout,
-					CY_TCH_TMOUT_DFLT) ||
-				CY_DIFF(ts->platform_data->lp_intrvl,
-					CY_LP_INTRVL_DFLT))) {
-				if (!(retval < CY_OK)) {
-					u8 intrvl_ray[sizeof(ts->platform_data->act_intrvl) +
-						sizeof(ts->platform_data->tch_tmout) +
-						sizeof(ts->platform_data->lp_intrvl)];
-					u8 i = 0;
-
-					intrvl_ray[i++] =
-						ts->platform_data->act_intrvl;
-					intrvl_ray[i++] =
-						ts->platform_data->tch_tmout;
-					intrvl_ray[i++] =
-						ts->platform_data->lp_intrvl;
-
-					cyttsp_debug("SI2: platinfo act_intrvl=0x%02X tch_tmout=0x%02X lp_intrvl=0x%02X\n", \
-						ts->platform_data->act_intrvl, \
-						ts->platform_data->tch_tmout, \
-						ts->platform_data->lp_intrvl);
-					/* set intrvl registers */
-					retval = i2c_smbus_write_i2c_block_data(
-						ts->client,
-						CY_REG_ACT_INTRVL,
-						sizeof(intrvl_ray), intrvl_ray);
-					msleep(CY_DLY_SYSINFO);
-				}
-			}
-		}
-		/* switch back to Operational mode */
-		cyttsp_debug("switch back to operational mode \n");
-		if (!(retval < CY_OK)) {
-			host_reg = CY_OP_MODE/* + CY_LOW_PWR_MODE*/;
-			retval = i2c_smbus_write_i2c_block_data(ts->client,
-				CY_REG_BASE,
-				sizeof(host_reg), &host_reg);
-			/* wait for TTSP Device to complete
-			 * switch to Operational mode */
-			msleep(100);
-		}
-	}
-	/* init gesture setup;
-	 * this is required even if not using gestures
-	 * in order to set the active distance */
-	if (!(retval < CY_OK)) {
-		u8 gesture_setup;
-		cyttsp_debug("init gesture setup \n");
-		gesture_setup = ts->platform_data->gest_set;
-		retval = i2c_smbus_write_i2c_block_data(ts->client,
-			CY_REG_GEST_SET,
-			sizeof(gesture_setup), &gesture_setup);
-		msleep(CY_DLY_DFLT);
-	}
-
 	if (!(retval < CY_OK))
 		ts->platform_data->power_state = CY_ACTIVE_STATE;
 	else
@@ -2454,6 +2512,91 @@
 	return rc;
 }
 
+static void sysinfo_debug_msg(struct cyttsp *ts)
+{
+	cyttsp_debug("SI2: hst_mode=0x%02X mfg_cmd=0x%02X " \
+		"mfg_stat=0x%02X\n", \
+		g_sysinfo_data.hst_mode, \
+		g_sysinfo_data.mfg_cmd, \
+		g_sysinfo_data.mfg_stat);
+	cyttsp_debug("SI2: bl_ver=0x%02X%02X\n", \
+		g_sysinfo_data.bl_verh, \
+		g_sysinfo_data.bl_verl);
+	cyttsp_debug("SI2: sysinfo act_int=0x%02X " \
+		"tch_tmout=0x%02X lp_int=0x%02X\n", \
+		g_sysinfo_data.act_intrvl, \
+		g_sysinfo_data.tch_tmout, \
+		g_sysinfo_data.lp_intrvl);
+	cyttsp_info("SI%d: tver=%02X%02X a_id=%02X%02X " \
+		"aver=%02X%02X\n", \
+		102, \
+		g_sysinfo_data.tts_verh, \
+		g_sysinfo_data.tts_verl, \
+		g_sysinfo_data.app_idh, \
+		g_sysinfo_data.app_idl, \
+		g_sysinfo_data.app_verh, \
+		g_sysinfo_data.app_verl);
+	cyttsp_info("SI%d: c_id=%02X%02X%02X\n", \
+		103, \
+		g_sysinfo_data.cid[0], \
+		g_sysinfo_data.cid[1], \
+		g_sysinfo_data.cid[2]);
+	cyttsp_debug("SI2: platinfo " \
+		"act_intrvl=0x%02X tch_tmout=0x%02X " \
+		"lp_intrvl=0x%02X\n", \
+		ts->platform_data->act_intrvl, \
+		ts->platform_data->tch_tmout, \
+		ts->platform_data->lp_intrvl);
+}
+
+static int set_bypass_modes(struct cyttsp *ts)
+{
+	int retval = 0, tries = 0;
+
+	/* switch to System Information mode to read versions
+	 * and set interval registers */
+	retval = cyttsp_set_sysinfo_mode(ts, CY_LOW_PWR_MODE);
+	if (!(retval < CY_OK)) {
+		retval = i2c_smbus_read_i2c_block_data(ts->client,
+			CY_REG_BASE,
+			sizeof(struct cyttsp_sysinfo_data_t),
+			(u8 *)&g_sysinfo_data);
+		sysinfo_debug_msg(ts);
+		/* set power settings registers */
+		do {
+			retval = i2c_smbus_write_i2c_block_data(ts->client,
+				CY_REG_ACT_INTRVL, sizeof(ts->power_settings),
+				ts->power_settings);
+			if (retval < 0)
+				msleep(20);
+		} while ((retval < 0) && (tries++ < 5));
+		if (retval < 0)
+			pr_err("%s: failed to write  power_settings, " \
+				"retval =%x\n", __func__, retval);
+	}
+	/* switch back to Operational mode */
+	cyttsp_debug("switch back to operational mode\n");
+	if (!(retval < CY_OK)) {
+		cyttsp_set_opmode(ts, CY_LOW_PWR_MODE);
+		/* wait for TTSP Device to complete
+		 * switch to Operational mode */
+		msleep(100);
+	}
+	/* init gesture setup;
+	 * this is required even if not using gestures
+	 * in order to set the active distance */
+	if (!(retval < CY_OK)) {
+		u8 gesture_setup;
+		cyttsp_debug("init gesture setup\n");
+		gesture_setup = ts->platform_data->gest_set;
+		retval = i2c_smbus_write_i2c_block_data(ts->client,
+			CY_REG_GEST_SET,
+			sizeof(gesture_setup), &gesture_setup);
+		msleep(CY_DLY_DFLT);
+	}
+	return retval;
+}
+
 /* cyttsp_initialize: Driver Initialization. This function takes
  * care of the following tasks:
  * 1. Create and register an input device with input layer
@@ -2491,6 +2634,21 @@
 	input_device->phys = ts->phys;
 	input_device->dev.parent = &client->dev;
 
+	ts->power_state = CY_ACTIVE;
+
+	if (ts->platform_data->act_intrvl)
+		ts->power_settings[0] = ts->platform_data->act_intrvl;
+	else
+		ts->power_settings[0] = CY_ACT_INTRVL_DFLT;
+	if (ts->platform_data->tch_tmout)
+		ts->power_settings[1] = ts->platform_data->tch_tmout;
+	else
+		ts->power_settings[1] = CY_TCH_TMOUT_DFLT;
+	if (ts->platform_data->lp_intrvl)
+		ts->power_settings[2] = ts->platform_data->lp_intrvl;
+	else
+		ts->power_settings[2] = CY_LP_INTRVL_DFLT;
+
 	/* init the touch structures */
 	ts->num_prv_st_tch = CY_NTCH;
 	for (id = 0; id < CY_NUM_TRK_ID; id++) {
@@ -2712,6 +2870,7 @@
 		goto error_rm_dev_file_fupdate_fw;
 	}
 
+	set_bypass_modes(ts);
 	cyttsp_info("%s: Successful registration\n", CY_I2C_NAME);
 
 	goto success;
@@ -2799,6 +2958,8 @@
 
 		i2c_set_clientdata(client, ts);
 
+		init_completion(&ts->si_int_running);
+
 		error = cyttsp_initialize(client, ts);
 		if (error) {
 			cyttsp_xdebug1("err cyttsp_initialize\n");
@@ -2821,6 +2982,7 @@
 #endif /* CONFIG_HAS_EARLYSUSPEND */
 	device_init_wakeup(&client->dev, ts->platform_data->wakeup);
 	mutex_init(&ts->mutex);
+	retval = cyttsp_set_lp_mode(ts);
 
 	cyttsp_info("Start Probe %s\n", \
 		(retval < CY_OK) ? "FAIL" : "PASS");
@@ -2957,7 +3119,7 @@
 	cyttsp_debug("Wake Up %s\n", \
 		(retval < CY_OK) ? "FAIL" : "PASS");
 
-	return retval;
+	return cyttsp_set_lp_mode(ts);
 }
 
 /* Function to manage low power suspend */
diff --git a/drivers/iommu/msm_iommu-v2.c b/drivers/iommu/msm_iommu-v2.c
index 6e62e60..7dce40b 100644
--- a/drivers/iommu/msm_iommu-v2.c
+++ b/drivers/iommu/msm_iommu-v2.c
@@ -128,7 +128,7 @@
 	return ret;
 }
 
-static void __reset_iommu(void __iomem *base)
+static void __reset_iommu(void __iomem *base, int smt_size)
 {
 	int i;
 
@@ -143,15 +143,15 @@
 	SET_SCR1(base, 0);
 	SET_SSDR_N(base, 0, 0);
 
-	for (i = 0; i < MAX_NUM_SMR; i++)
+	for (i = 0; i < smt_size; i++)
 		SET_SMR_VALID(base, i, 0);
 
 	mb();
 }
 
-static void __program_iommu(void __iomem *base)
+static void __program_iommu(void __iomem *base, int smt_size)
 {
-	__reset_iommu(base);
+	__reset_iommu(base, smt_size);
 
 	SET_CR0_SMCFCFG(base, 1);
 	SET_CR0_USFCFG(base, 1);
@@ -182,7 +182,7 @@
 
 static void __program_context(void __iomem *base, int ctx, int ncb,
 				phys_addr_t pgtable, int redirect,
-				u32 *sids, int len)
+				u32 *sids, int len, int smt_size)
 {
 	unsigned int prrr, nmrr;
 	unsigned int pn;
@@ -227,10 +227,10 @@
 
 	/* Program the M2V tables for this context */
 	for (i = 0; i < len / sizeof(*sids); i++) {
-		for (; num < MAX_NUM_SMR; num++)
+		for (; num < smt_size; num++)
 			if (GET_SMR_VALID(base, num) == 0)
 				break;
-		BUG_ON(num >= MAX_NUM_SMR);
+		BUG_ON(num >= smt_size);
 
 		SET_SMR_VALID(base, num, 1);
 		SET_SMR_MASK(base, num, 0);
@@ -348,6 +348,7 @@
 	struct msm_iommu_ctx_drvdata *tmp_drvdata;
 	u32 sids[MAX_NUM_SMR];
 	int len = 0, ret;
+	u32 smt_size;
 
 	mutex_lock(&msm_iommu_lock);
 
@@ -377,6 +378,13 @@
 
 	of_get_property(dev->of_node, "qcom,iommu-ctx-sids", &len);
 	BUG_ON(len >= sizeof(sids));
+	if (of_property_read_u32(dev->parent->of_node, "qcom,iommu-smt-size",
+				  &smt_size)) {
+		ret = -EINVAL;
+		goto fail;
+	}
+	BUG_ON(smt_size > MAX_NUM_SMR);
+
 	if (of_property_read_u32_array(dev->of_node, "qcom,iommu-ctx-sids",
 					sids, len / sizeof(*sids))) {
 		ret = -EINVAL;
@@ -394,11 +402,11 @@
 	}
 
 	if (!msm_iommu_ctx_attached(dev->parent))
-		__program_iommu(iommu_drvdata->base);
+		__program_iommu(iommu_drvdata->base, smt_size);
 
 	__program_context(iommu_drvdata->base, ctx_drvdata->num,
 		iommu_drvdata->ncb, __pa(priv->pt.fl_table),
-		priv->pt.redirect, sids, len);
+		priv->pt.redirect, sids, len, smt_size);
 	__disable_clocks(iommu_drvdata);
 
 	list_add(&(ctx_drvdata->attached_elm), &priv->list_attached);
diff --git a/drivers/media/video/msm/msm_vfe31_v4l2.c b/drivers/media/video/msm/msm_vfe31_v4l2.c
index 2331fcc..b520a92 100644
--- a/drivers/media/video/msm/msm_vfe31_v4l2.c
+++ b/drivers/media/video/msm/msm_vfe31_v4l2.c
@@ -3138,18 +3138,6 @@
 		CDBG("%s: droppedStatsFrameCount = %d", __func__,
 			vfe31_ctrl->csStatsControl.droppedStatsFrameCount);
 	}
-	if (!(vfe31_ctrl->csStatsControl.ackPending)) {
-		vfe31_ctrl->csStatsControl.bufToRender =
-			vfe31_process_stats_irq_common(STATS_CS_NUM,
-				vfe31_ctrl->csStatsControl.nextFrameAddrBuf);
-		vfe_send_stats_msg(
-			vfe31_ctrl->csStatsControl.bufToRender,
-			STATS_CS_NUM);
-	} else {
-		vfe31_ctrl->csStatsControl.droppedStatsFrameCount++;
-		CDBG("%s: droppedStatsFrameCount = %d", __func__,
-			vfe31_ctrl->csStatsControl.droppedStatsFrameCount);
-	}
 }
 
 static void vfe31_process_stats(uint32_t status_bits)
@@ -3882,6 +3870,9 @@
 	spin_lock_init(&vfe31_ctrl->sd_notify_lock);
 	INIT_LIST_HEAD(&vfe31_ctrl->tasklet_q);
 
+	memset(&vfe31_ctrl->stats_ctrl, 0, sizeof(struct msm_stats_bufq_ctrl));
+	memset(&vfe31_ctrl->stats_ops, 0, sizeof(struct msm_stats_ops));
+
 	vfe31_ctrl->update_linear = false;
 	vfe31_ctrl->update_rolloff = false;
 	vfe31_ctrl->update_la = false;
diff --git a/drivers/media/video/msm/msm_vfe32.c b/drivers/media/video/msm/msm_vfe32.c
index 621a016..c6dd143 100644
--- a/drivers/media/video/msm/msm_vfe32.c
+++ b/drivers/media/video/msm/msm_vfe32.c
@@ -4716,6 +4716,9 @@
 	vfe32_ctrl->update_gamma = false;
 	vfe32_ctrl->hfr_mode = HFR_MODE_OFF;
 
+	memset(&vfe32_ctrl->stats_ctrl, 0, sizeof(struct msm_stats_bufq_ctrl));
+	memset(&vfe32_ctrl->stats_ops, 0, sizeof(struct msm_stats_ops));
+
 	return rc;
 }
 
diff --git a/drivers/media/video/msm/msm_vfe7x27a_v4l2.c b/drivers/media/video/msm/msm_vfe7x27a_v4l2.c
index 5fef610..96047d5 100644
--- a/drivers/media/video/msm/msm_vfe7x27a_v4l2.c
+++ b/drivers/media/video/msm/msm_vfe7x27a_v4l2.c
@@ -1970,6 +1970,8 @@
 	stopevent.state = 0;
 	vfe2x_ctrl->vfe_started = 0;
 
+	memset(&vfe2x_ctrl->stats_ctrl, 0, sizeof(struct msm_stats_bufq_ctrl));
+	memset(&vfe2x_ctrl->stats_ops, 0, sizeof(struct msm_stats_ops));
 
 	CDBG("msm_cam_clk_enable: enable vfe_clk\n");
 	rc = msm_cam_clk_enable(&vfe2x_ctrl->pdev->dev, vfe2x_clk_info,
diff --git a/drivers/media/video/msm_vidc/vidc_hal_interrupt_handler.c b/drivers/media/video/msm_vidc/vidc_hal_interrupt_handler.c
index b604d0a..ded9f11 100644
--- a/drivers/media/video/msm_vidc/vidc_hal_interrupt_handler.c
+++ b/drivers/media/video/msm_vidc/vidc_hal_interrupt_handler.c
@@ -98,6 +98,18 @@
 	cmd_done.status = VIDC_ERR_NONE;
 	cmd_done.size = sizeof(struct msm_vidc_cb_event);
 	num_properties_changed = pkt->event_data2;
+	switch (pkt->event_data1) {
+	case HFI_EVENT_DATA_SEQUENCE_CHANGED_SUFFICIENT_BUFFER_RESOURCES:
+		event_notify.hal_event_type =
+			HAL_EVENT_SEQ_CHANGED_SUFFICIENT_RESOURCES;
+		break;
+	case HFI_EVENT_DATA_SEQUENCE_CHANGED_INSUFFICIENT_BUFFER_RESOURCES:
+		event_notify.hal_event_type =
+			HAL_EVENT_SEQ_CHANGED_INSUFFICIENT_RESOURCES;
+		break;
+	default:
+		break;
+	}
 	if (num_properties_changed) {
 		data_ptr = (u8 *) &pkt->rg_ext_event_data[0];
 		do {
diff --git a/drivers/mmc/card/mmc_block_test.c b/drivers/mmc/card/mmc_block_test.c
index 0ace608..3d4b477 100644
--- a/drivers/mmc/card/mmc_block_test.c
+++ b/drivers/mmc/card/mmc_block_test.c
@@ -83,6 +83,25 @@
 	TEST_CMD23_BITS_16TO29_SET,
 	TEST_CMD23_HDR_BLK_NOT_IN_COUNT,
 	INVALID_CMD_MAX_TESTCASE = TEST_CMD23_HDR_BLK_NOT_IN_COUNT,
+
+	/*
+	 * Start of packing control test group.
+	 * in these next testcases the abbreviation FB = followed by
+	 */
+	PACKING_CONTROL_MIN_TESTCASE,
+	TEST_PACKING_EXP_ONE_OVER_TRIGGER_FB_READ =
+				PACKING_CONTROL_MIN_TESTCASE,
+	TEST_PACKING_EXP_N_OVER_TRIGGER,
+	TEST_PACKING_EXP_N_OVER_TRIGGER_FB_READ,
+	TEST_PACKING_EXP_N_OVER_TRIGGER_FLUSH_N,
+	TEST_PACKING_EXP_THRESHOLD_OVER_TRIGGER,
+	TEST_PACKING_NOT_EXP_LESS_THAN_TRIGGER_REQUESTS,
+	TEST_PACKING_NOT_EXP_TRIGGER_REQUESTS,
+	TEST_PACKING_NOT_EXP_TRIGGER_READ_TRIGGER,
+	TEST_PACKING_NOT_EXP_TRIGGER_FLUSH_TRIGGER,
+	TEST_PACK_MIX_PACKED_NO_PACKED_PACKED,
+	TEST_PACK_MIX_NO_PACKED_PACKED_NO_PACKED,
+	PACKING_CONTROL_MAX_TESTCASE = TEST_PACK_MIX_NO_PACKED_PACKED_NO_PACKED,
 };
 
 enum mmc_block_test_group {
@@ -91,6 +110,7 @@
 	TEST_SEND_WRITE_PACKING_GROUP,
 	TEST_ERR_CHECK_GROUP,
 	TEST_SEND_INVALID_GROUP,
+	TEST_PACKING_CONTROL_GROUP,
 };
 
 struct mmc_block_test_debug {
@@ -98,6 +118,7 @@
 	struct dentry *err_check_test;
 	struct dentry *send_invalid_packed_test;
 	struct dentry *random_test_seed;
+	struct dentry *packing_control_test;
 };
 
 struct mmc_block_test_data {
@@ -454,6 +475,28 @@
 		return "Test invalid - cmd23 bits [16-29] set";
 	case TEST_CMD23_HDR_BLK_NOT_IN_COUNT:
 		return "Test invalid - cmd23 header block not in count";
+	case TEST_PACKING_EXP_N_OVER_TRIGGER:
+		return "\nTest packing control - pack n";
+	case TEST_PACKING_EXP_N_OVER_TRIGGER_FB_READ:
+		return "\nTest packing control - pack n followed by read";
+	case TEST_PACKING_EXP_N_OVER_TRIGGER_FLUSH_N:
+		return "\nTest packing control - pack n followed by flush";
+	case TEST_PACKING_EXP_ONE_OVER_TRIGGER_FB_READ:
+		return "\nTest packing control - pack one followed by read";
+	case TEST_PACKING_EXP_THRESHOLD_OVER_TRIGGER:
+		return "\nTest packing control - pack threshold";
+	case TEST_PACKING_NOT_EXP_LESS_THAN_TRIGGER_REQUESTS:
+		return "\nTest packing control - no packing";
+	case TEST_PACKING_NOT_EXP_TRIGGER_REQUESTS:
+		return "\nTest packing control - no packing, trigger requests";
+	case TEST_PACKING_NOT_EXP_TRIGGER_READ_TRIGGER:
+		return "\nTest packing control - no pack, trigger-read-trigger";
+	case TEST_PACKING_NOT_EXP_TRIGGER_FLUSH_TRIGGER:
+		return "\nTest packing control- no pack, trigger-flush-trigger";
+	case TEST_PACK_MIX_PACKED_NO_PACKED_PACKED:
+		return "\nTest packing control - mix: pack -> no pack -> pack";
+	case TEST_PACK_MIX_NO_PACKED_PACKED_NO_PACKED:
+		return "\nTest packing control - mix: no pack->pack->no pack";
 	default:
 		 return "Unknown testcase";
 	}
@@ -505,7 +548,7 @@
 
 	stop_reason = mmc_packed_stats->pack_stop_reason;
 
-	for (i = 1 ; i <= max_packed_reqs ; ++i) {
+	for (i = 1; i <= max_packed_reqs; ++i) {
 		if (mmc_packed_stats->packing_events[i] !=
 		    expected_stats.packing_events[i]) {
 			test_pr_err(
@@ -710,7 +753,7 @@
 	test_pr_info("%s: Adding %d write requests, first req_id=%d", __func__,
 		     num_requests, td->wr_rd_next_req_id);
 
-	for (i = 1 ; i <= num_requests ; i++) {
+	for (i = 1; i <= num_requests; i++) {
 		start_sec = td->start_sector + 4096 * td->num_of_write_bios;
 		if (is_random)
 			pseudo_rnd_num_of_bios(bio_seed, &num_bios);
@@ -826,6 +869,185 @@
 }
 
 /*
+ * Prepare the write, read and flush requests for the packing control
+ * testcases
+ */
+static int prepare_packed_control_tests_requests(struct test_data *td,
+			int is_err_expected, int num_requests, int is_random)
+{
+	int ret = 0;
+	struct mmc_queue *mq;
+	int max_packed_reqs;
+	int temp_num_req = num_requests;
+	struct request_queue *req_q;
+	int test_packed_trigger;
+	int num_packed_reqs;
+
+	if (!td) {
+		test_pr_err("%s: NULL td\n", __func__);
+		return -EINVAL;
+	}
+
+	req_q = td->req_q;
+
+	if (!req_q) {
+		test_pr_err("%s: NULL request queue\n", __func__);
+		return -EINVAL;
+	}
+
+	mq = req_q->queuedata;
+	if (!mq) {
+		test_pr_err("%s: NULL mq", __func__);
+		return -EINVAL;
+	}
+
+	max_packed_reqs = mq->card->ext_csd.max_packed_writes;
+	test_packed_trigger = mq->num_wr_reqs_to_start_packing;
+	num_packed_reqs = num_requests - test_packed_trigger;
+
+	if (mbtd->random_test_seed == 0) {
+		mbtd->random_test_seed =
+			(unsigned int)(get_jiffies_64() & 0xFFFF);
+		test_pr_info("%s: got seed from jiffies %d",
+			     __func__, mbtd->random_test_seed);
+	}
+
+	mmc_blk_init_packed_statistics(mq->card);
+
+	if (td->test_info.testcase ==
+			TEST_PACK_MIX_NO_PACKED_PACKED_NO_PACKED) {
+		temp_num_req = num_requests;
+		num_requests = test_packed_trigger - 1;
+	}
+
+	/* Verify that the packing is disabled before starting the test */
+	mq->wr_packing_enabled = false;
+	mq->num_of_potential_packed_wr_reqs = 0;
+
+	if (td->test_info.testcase == TEST_PACK_MIX_PACKED_NO_PACKED_PACKED) {
+		mq->num_of_potential_packed_wr_reqs = test_packed_trigger + 1;
+		mq->wr_packing_enabled = true;
+		num_requests = test_packed_trigger + 2;
+	}
+
+	ret = prepare_request_add_write_reqs(td, num_requests, is_err_expected,
+					     is_random);
+	if (ret)
+		goto exit;
+
+	if (td->test_info.testcase == TEST_PACK_MIX_NO_PACKED_PACKED_NO_PACKED)
+		num_requests = temp_num_req;
+
+	memset((void *)mbtd->exp_packed_stats.pack_stop_reason, 0,
+		sizeof(mbtd->exp_packed_stats.pack_stop_reason));
+	memset(mbtd->exp_packed_stats.packing_events, 0,
+		(max_packed_reqs + 1) * sizeof(u32));
+
+	switch (td->test_info.testcase) {
+	case TEST_PACKING_EXP_N_OVER_TRIGGER_FB_READ:
+	case TEST_PACKING_EXP_ONE_OVER_TRIGGER_FB_READ:
+		ret = prepare_request_add_read(td);
+		if (ret)
+			goto exit;
+
+		mbtd->exp_packed_stats.pack_stop_reason[WRONG_DATA_DIR] = 1;
+		mbtd->exp_packed_stats.packing_events[num_packed_reqs] = 1;
+		break;
+	case TEST_PACKING_EXP_N_OVER_TRIGGER_FLUSH_N:
+		ret = prepare_request_add_flush(td);
+		if (ret)
+			goto exit;
+
+		ret = prepare_request_add_write_reqs(td, num_packed_reqs,
+					     is_err_expected, is_random);
+		if (ret)
+			goto exit;
+
+		mbtd->exp_packed_stats.pack_stop_reason[EMPTY_QUEUE] = 1;
+		mbtd->exp_packed_stats.pack_stop_reason[FLUSH_OR_DISCARD] = 1;
+		mbtd->exp_packed_stats.packing_events[num_packed_reqs] = 2;
+		break;
+	case TEST_PACKING_NOT_EXP_TRIGGER_READ_TRIGGER:
+		ret = prepare_request_add_read(td);
+		if (ret)
+			goto exit;
+
+		ret = prepare_request_add_write_reqs(td, test_packed_trigger,
+						    is_err_expected, is_random);
+		if (ret)
+			goto exit;
+
+		mbtd->exp_packed_stats.packing_events[num_packed_reqs] = 1;
+		break;
+	case TEST_PACKING_NOT_EXP_TRIGGER_FLUSH_TRIGGER:
+		ret = prepare_request_add_flush(td);
+		if (ret)
+			goto exit;
+
+		ret = prepare_request_add_write_reqs(td, test_packed_trigger,
+						    is_err_expected, is_random);
+		if (ret)
+			goto exit;
+
+		mbtd->exp_packed_stats.packing_events[num_packed_reqs] = 1;
+		break;
+	case TEST_PACK_MIX_PACKED_NO_PACKED_PACKED:
+		ret = prepare_request_add_read(td);
+		if (ret)
+			goto exit;
+
+		ret = prepare_request_add_write_reqs(td, test_packed_trigger-1,
+						    is_err_expected, is_random);
+		if (ret)
+			goto exit;
+
+		ret = prepare_request_add_write_reqs(td, num_requests,
+						    is_err_expected, is_random);
+		if (ret)
+			goto exit;
+
+		mbtd->exp_packed_stats.packing_events[num_requests] = 1;
+		mbtd->exp_packed_stats.packing_events[num_requests-1] = 1;
+		mbtd->exp_packed_stats.pack_stop_reason[WRONG_DATA_DIR] = 1;
+		mbtd->exp_packed_stats.pack_stop_reason[EMPTY_QUEUE] = 1;
+		break;
+	case TEST_PACK_MIX_NO_PACKED_PACKED_NO_PACKED:
+		ret = prepare_request_add_read(td);
+		if (ret)
+			goto exit;
+
+		ret = prepare_request_add_write_reqs(td, num_requests,
+						    is_err_expected, is_random);
+		if (ret)
+			goto exit;
+
+		ret = prepare_request_add_read(td);
+		if (ret)
+			goto exit;
+
+		ret = prepare_request_add_write_reqs(td, test_packed_trigger-1,
+						    is_err_expected, is_random);
+		if (ret)
+			goto exit;
+
+		mbtd->exp_packed_stats.pack_stop_reason[WRONG_DATA_DIR] = 1;
+		mbtd->exp_packed_stats.packing_events[num_packed_reqs] = 1;
+		break;
+	case TEST_PACKING_NOT_EXP_LESS_THAN_TRIGGER_REQUESTS:
+	case TEST_PACKING_NOT_EXP_TRIGGER_REQUESTS:
+		mbtd->exp_packed_stats.packing_events[num_packed_reqs] = 1;
+		break;
+	default:
+		mbtd->exp_packed_stats.pack_stop_reason[EMPTY_QUEUE] = 1;
+		mbtd->exp_packed_stats.packing_events[num_packed_reqs] = 1;
+	}
+	mbtd->num_requests = num_requests;
+
+exit:
+	return ret;
+}
+
+/*
  * Prepare requests for the TEST_RET_PARTIAL_FOLLOWED_BY_ABORT testcase.
  * In this testcase we have mixed error expectations from different
  * write requests, hence the special prepare function.
@@ -848,13 +1070,14 @@
 
 	mmc_blk_init_packed_statistics(mq->card);
 
-	for (i = 1 ; i <= num_requests ; i++) {
+	for (i = 1; i <= num_requests; i++) {
 		if (i > (num_requests / 2))
 			is_err_expected = 1;
 
-		start_address = td->start_sector + 4096*td->num_of_write_bios;
+		start_address = td->start_sector + 4096 * td->num_of_write_bios;
 		ret = test_iosched_add_wr_rd_test_req(is_err_expected, WRITE,
-				start_address, (i%5)+1, TEST_PATTERN_5A, NULL);
+				start_address, (i % 5) + 1, TEST_PATTERN_5A,
+				NULL);
 		if (ret) {
 			test_pr_err("%s: failed to add a write request",
 				    __func__);
@@ -888,6 +1111,8 @@
 	int num_requests;
 	int min_num_requests = 2;
 	int is_random = mbtd->is_random;
+	int max_for_double;
+	int test_packed_trigger;
 
 	req_q = test_iosched_get_req_queue();
 	if (req_q)
@@ -904,16 +1129,52 @@
 
 	max_num_requests = mq->card->ext_csd.max_packed_writes;
 	num_requests = max_num_requests - 2;
+	test_packed_trigger = mq->num_wr_reqs_to_start_packing;
+
+	/*
+	 * Here max_for_double is intended for packed control testcases
+	 * in which we issue many write requests. It's purpose is to prevent
+	 * exceeding max number of req_queue requests.
+	 */
+	max_for_double = max_num_requests - 10;
+
+	if (td->test_info.testcase ==
+				TEST_PACKING_NOT_EXP_LESS_THAN_TRIGGER_REQUESTS)
+		/* Don't expect packing, so issue up to trigger-1 reqs */
+		num_requests = test_packed_trigger - 1;
 
 	if (is_random) {
 		if (td->test_info.testcase ==
 		    TEST_RET_PARTIAL_FOLLOWED_BY_ABORT)
+			/*
+			 * Here we don't want num_requests to be less than 1
+			 * as a consequence of division by 2.
+			 */
 			min_num_requests = 3;
 
+		if (td->test_info.testcase ==
+				TEST_PACKING_NOT_EXP_LESS_THAN_TRIGGER_REQUESTS)
+			/* Don't expect packing, so issue up to trigger reqs */
+			max_num_requests = test_packed_trigger;
+
 		num_requests = pseudo_random_seed(seed, min_num_requests,
 						  max_num_requests - 1);
 	}
 
+	if (td->test_info.testcase ==
+				TEST_PACKING_NOT_EXP_LESS_THAN_TRIGGER_REQUESTS)
+		num_requests -= test_packed_trigger;
+
+	if (td->test_info.testcase == TEST_PACKING_EXP_N_OVER_TRIGGER_FLUSH_N)
+		num_requests =
+		num_requests > max_for_double ? max_for_double : num_requests;
+
+	if (mbtd->test_group == TEST_PACKING_CONTROL_GROUP)
+		num_requests += test_packed_trigger;
+
+	if (td->test_info.testcase == TEST_PACKING_NOT_EXP_TRIGGER_REQUESTS)
+		num_requests = test_packed_trigger;
+
 	return num_requests;
 }
 
@@ -929,6 +1190,7 @@
 	int num_requests = 0;
 	int ret = 0;
 	int is_random = mbtd->is_random;
+	int test_packed_trigger = mq->num_wr_reqs_to_start_packing;
 
 	if (!mq) {
 		test_pr_err("%s: NULL mq", __func__);
@@ -997,6 +1259,33 @@
 	case TEST_HDR_CMD23_PACKED_BIT_SET:
 		ret = prepare_packed_requests(td, 1, num_requests, is_random);
 		break;
+	case TEST_PACKING_EXP_N_OVER_TRIGGER:
+	case TEST_PACKING_EXP_N_OVER_TRIGGER_FB_READ:
+	case TEST_PACKING_NOT_EXP_TRIGGER_REQUESTS:
+	case TEST_PACKING_NOT_EXP_LESS_THAN_TRIGGER_REQUESTS:
+	case TEST_PACK_MIX_PACKED_NO_PACKED_PACKED:
+	case TEST_PACK_MIX_NO_PACKED_PACKED_NO_PACKED:
+		ret = prepare_packed_control_tests_requests(td, 0, num_requests,
+			is_random);
+		break;
+	case TEST_PACKING_EXP_THRESHOLD_OVER_TRIGGER:
+		ret = prepare_packed_control_tests_requests(td, 0,
+			max_num_requests, is_random);
+		break;
+	case TEST_PACKING_EXP_ONE_OVER_TRIGGER_FB_READ:
+		ret = prepare_packed_control_tests_requests(td, 0,
+			test_packed_trigger + 1,
+					is_random);
+		break;
+	case TEST_PACKING_EXP_N_OVER_TRIGGER_FLUSH_N:
+		ret = prepare_packed_control_tests_requests(td, 0, num_requests,
+			is_random);
+		break;
+	case TEST_PACKING_NOT_EXP_TRIGGER_READ_TRIGGER:
+	case TEST_PACKING_NOT_EXP_TRIGGER_FLUSH_TRIGGER:
+		ret = prepare_packed_control_tests_requests(td, 0,
+			test_packed_trigger, is_random);
+		break;
 	default:
 		test_pr_info("%s: Invalid test case...", __func__);
 		return -EINVAL;
@@ -1084,6 +1373,9 @@
 		/* disable the packing control */
 		host->caps2 &= ~MMC_CAP2_PACKED_WR_CONTROL;
 		break;
+	case TEST_PACKING_CONTROL_GROUP:
+		host->caps2 |=  MMC_CAP2_PACKED_WR_CONTROL;
+		break;
 	default:
 		break;
 	}
@@ -1135,12 +1427,12 @@
 	mbtd->test_info.get_test_case_str_fn = get_test_case_str;
 	mbtd->test_info.post_test_fn = post_test;
 
-	for (i = 0 ; i < number ; ++i) {
+	for (i = 0; i < number; ++i) {
 		test_pr_info("%s: Cycle # %d / %d", __func__, i+1, number);
 		test_pr_info("%s: ====================", __func__);
 
-		for (j = SEND_WRITE_PACKING_MIN_TESTCASE ;
-		      j <= SEND_WRITE_PACKING_MAX_TESTCASE ; j++) {
+		for (j = SEND_WRITE_PACKING_MIN_TESTCASE;
+		      j <= SEND_WRITE_PACKING_MAX_TESTCASE; j++) {
 
 			mbtd->test_info.testcase = j;
 			mbtd->is_random = RANDOM_TEST;
@@ -1233,7 +1525,7 @@
 	mbtd->test_info.get_test_case_str_fn = get_test_case_str;
 	mbtd->test_info.post_test_fn = post_test;
 
-	for (i = 0 ; i < number ; ++i) {
+	for (i = 0; i < number; ++i) {
 		test_pr_info("%s: Cycle # %d / %d", __func__, i+1, number);
 		test_pr_info("%s: ====================", __func__);
 
@@ -1332,7 +1624,7 @@
 	mbtd->test_info.get_test_case_str_fn = get_test_case_str;
 	mbtd->test_info.post_test_fn = post_test;
 
-	for (i = 0 ; i < number ; ++i) {
+	for (i = 0; i < number; ++i) {
 		test_pr_info("%s: Cycle # %d / %d", __func__, i+1, number);
 		test_pr_info("%s: ====================", __func__);
 
@@ -1408,12 +1700,123 @@
 	.read = send_invalid_packed_test_read,
 };
 
+/* packing_control TEST */
+static ssize_t write_packing_control_test_write(struct file *file,
+				const char __user *buf,
+				size_t count,
+				loff_t *ppos)
+{
+	int ret = 0;
+	int i = 0;
+	int number = -1;
+	int j = 0;
+	struct mmc_queue *mq = test_iosched_get_req_queue()->queuedata;
+	int max_num_requests = mq->card->ext_csd.max_packed_writes;
+	int test_successful = 1;
+
+	test_pr_info("%s: -- write_packing_control TEST --", __func__);
+
+	sscanf(buf, "%d", &number);
+
+	if (number <= 0)
+		number = 1;
+
+	test_pr_info("%s: max_num_requests = %d ", __func__,
+			max_num_requests);
+
+	memset(&mbtd->test_info, 0, sizeof(struct test_info));
+	mbtd->test_group = TEST_PACKING_CONTROL_GROUP;
+
+	if (validate_packed_commands_settings())
+		return count;
+
+	mbtd->test_info.data = mbtd;
+	mbtd->test_info.prepare_test_fn = prepare_test;
+	mbtd->test_info.check_test_result_fn = check_wr_packing_statistics;
+	mbtd->test_info.get_test_case_str_fn = get_test_case_str;
+
+	for (i = 0; i < number; ++i) {
+		test_pr_info("%s: Cycle # %d / %d", __func__, i+1, number);
+		test_pr_info("%s: ====================", __func__);
+
+		for (j = PACKING_CONTROL_MIN_TESTCASE;
+				j <= PACKING_CONTROL_MAX_TESTCASE; j++) {
+
+			test_successful = 1;
+			mbtd->test_info.testcase = j;
+			mbtd->is_random = RANDOM_TEST;
+			ret = test_iosched_start_test(&mbtd->test_info);
+			if (ret) {
+				test_successful = 0;
+				break;
+			}
+			/* Allow FS requests to be dispatched */
+			msleep(1000);
+
+			mbtd->test_info.testcase = j;
+			mbtd->is_random = NON_RANDOM_TEST;
+			ret = test_iosched_start_test(&mbtd->test_info);
+			if (ret) {
+				test_successful = 0;
+				break;
+			}
+			/* Allow FS requests to be dispatched */
+			msleep(1000);
+		}
+
+		if (!test_successful)
+			break;
+	}
+
+	test_pr_info("%s: Completed all the test cases.", __func__);
+
+	return count;
+}
+
+static ssize_t write_packing_control_test_read(struct file *file,
+			       char __user *buffer,
+			       size_t count,
+			       loff_t *offset)
+{
+	memset((void *)buffer, 0, count);
+
+	snprintf(buffer, count,
+		 "\nwrite_packing_control_test\n"
+		 "=========\n"
+		 "Description:\n"
+		 "This test checks the following scenarios\n"
+		 "- Packing expected - one over trigger\n"
+		 "- Packing expected - N over trigger\n"
+		 "- Packing expected - N over trigger followed by read\n"
+		 "- Packing expected - N over trigger followed by flush\n"
+		 "- Packing expected - threshold over trigger FB by flush\n"
+		 "- Packing not expected - less than trigger\n"
+		 "- Packing not expected - trigger requests\n"
+		 "- Packing not expected - trigger, read, trigger\n"
+		 "- Mixed state - packing -> no packing -> packing\n"
+		 "- Mixed state - no packing -> packing -> no packing\n");
+
+	if (message_repeat == 1) {
+		message_repeat = 0;
+		return strnlen(buffer, count);
+	} else {
+		return 0;
+	}
+}
+
+const struct file_operations write_packing_control_test_ops = {
+	.open = test_open,
+	.write = write_packing_control_test_write,
+	.read = write_packing_control_test_read,
+};
+
 static void mmc_block_test_debugfs_cleanup(void)
 {
 	debugfs_remove(mbtd->debug.random_test_seed);
 	debugfs_remove(mbtd->debug.send_write_packing_test);
 	debugfs_remove(mbtd->debug.err_check_test);
 	debugfs_remove(mbtd->debug.send_invalid_packed_test);
+	debugfs_remove(mbtd->debug.packing_control_test);
 }
 
 static int mmc_block_test_debugfs_init(void)
@@ -1465,6 +1868,16 @@
 	if (!mbtd->debug.send_invalid_packed_test)
 		goto err_nomem;
 
+	mbtd->debug.packing_control_test = debugfs_create_file(
+					"packing_control_test",
+					S_IRUGO | S_IWUGO,
+					tests_root,
+					NULL,
+					&write_packing_control_test_ops);
+
+	if (!mbtd->debug.packing_control_test)
+		goto err_nomem;
+
 	return 0;
 
 err_nomem:
diff --git a/drivers/net/usb/rmnet_usb_ctrl.c b/drivers/net/usb/rmnet_usb_ctrl.c
index 2972af0..186d07d 100644
--- a/drivers/net/usb/rmnet_usb_ctrl.c
+++ b/drivers/net/usb/rmnet_usb_ctrl.c
@@ -16,6 +16,7 @@
 #include <linux/device.h>
 #include <linux/uaccess.h>
 #include <linux/termios.h>
+#include <linux/poll.h>
 #include <linux/ratelimit.h>
 #include <linux/debugfs.h>
 #include "rmnet_usb_ctrl.h"
@@ -529,6 +530,28 @@
 	return 0;
 }
 
+static unsigned int rmnet_ctl_poll(struct file *file, poll_table *wait)
+{
+	unsigned int		mask = 0;
+	struct rmnet_ctrl_dev	*dev;
+
+	dev = file->private_data;
+	if (!dev)
+		return POLLERR;
+
+	poll_wait(file, &dev->read_wait_queue, wait);
+	if (!is_dev_connected(dev)) {
+		dev_dbg(dev->devicep, "%s: Device not connected\n",
+			__func__);
+		return POLLERR;
+	}
+
+	if (!list_empty(&dev->rx_list))
+		mask |= POLLIN | POLLRDNORM;
+
+	return mask;
+}
+
 static ssize_t rmnet_ctl_read(struct file *file, char __user *buf, size_t count,
 		loff_t *ppos)
 {
@@ -722,6 +745,7 @@
 	.unlocked_ioctl = rmnet_ctrl_ioctl,
 	.open  = rmnet_ctl_open,
 	.release = rmnet_ctl_release,
+	.poll = rmnet_ctl_poll,
 };
 
 int rmnet_usb_ctrl_probe(struct usb_interface *intf,
diff --git a/drivers/net/usb/rmnet_usb_data.c b/drivers/net/usb/rmnet_usb_data.c
index 55020a1..eb57693 100644
--- a/drivers/net/usb/rmnet_usb_data.c
+++ b/drivers/net/usb/rmnet_usb_data.c
@@ -558,6 +558,8 @@
 
 	udev = unet->udev;
 
+	usb_enable_autosuspend(udev);
+
 	/* allow modem to wake up suspended system */
 	device_set_wakeup_enable(&udev->dev, 1);
 
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 7cb4a51..57cde45 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -2348,9 +2348,12 @@
 {
 	struct regulator_dev *rdev = regulator->rdev;
 	struct regulator *consumer;
-	int ret, output_uV, input_uV, total_uA_load = 0;
+	int ret, output_uV, input_uV = 0, total_uA_load = 0;
 	unsigned int mode;
 
+	if (rdev->supply)
+		input_uV = regulator_get_voltage(rdev->supply);
+
 	mutex_lock(&rdev->mutex);
 
 	/*
@@ -2380,10 +2383,7 @@
 		goto out;
 	}
 
-	/* get input voltage */
-	input_uV = 0;
-	if (rdev->supply)
-		input_uV = regulator_get_voltage(rdev->supply);
+	/* No supply? Use constraint voltage */
 	if (input_uV <= 0)
 		input_uV = rdev->constraints->input_uV;
 	if (input_uV <= 0) {
diff --git a/drivers/usb/gadget/android.c b/drivers/usb/gadget/android.c
index a13b5da..2ed642a 100644
--- a/drivers/usb/gadget/android.c
+++ b/drivers/usb/gadget/android.c
@@ -1065,9 +1065,12 @@
 static int mass_storage_function_init(struct android_usb_function *f,
 					struct usb_composite_dev *cdev)
 {
+	struct android_dev *dev = _android_dev;
 	struct mass_storage_function_config *config;
 	struct fsg_common *common;
 	int err;
+	int i;
+	const char *name[2];
 
 	config = kzalloc(sizeof(struct mass_storage_function_config),
 								GFP_KERNEL);
@@ -1075,6 +1078,15 @@
 		return -ENOMEM;
 
 	config->fsg.nluns = 1;
+	name[0] = "lun";
+	if (dev->pdata->cdrom) {
+		config->fsg.nluns = 2;
+		config->fsg.luns[1].cdrom = 1;
+		config->fsg.luns[1].ro = 1;
+		config->fsg.luns[1].removable = 1;
+		name[1] = "lun0";
+	}
+
 	config->fsg.luns[0].removable = 1;
 
 	common = fsg_common_init(NULL, cdev, &config->fsg);
@@ -1083,18 +1095,24 @@
 		return PTR_ERR(common);
 	}
 
-	err = sysfs_create_link(&f->dev->kobj,
-				&common->luns[0].dev.kobj,
-				"lun");
-	if (err) {
-		fsg_common_release(&common->ref);
-		kfree(config);
-		return err;
+	for (i = 0; i < config->fsg.nluns; i++) {
+		err = sysfs_create_link(&f->dev->kobj,
+					&common->luns[i].dev.kobj,
+					name[i]);
+		if (err)
+			goto error;
 	}
 
 	config->common = common;
 	f->config = config;
 	return 0;
+error:
+	for (; i > 0 ; i--)
+		sysfs_remove_link(&f->dev->kobj, name[i-1]);
+
+	fsg_common_release(&common->ref);
+	kfree(config);
+	return err;
 }
 
 static void mass_storage_function_cleanup(struct android_usb_function *f)
diff --git a/drivers/usb/gadget/ci13xxx_udc.c b/drivers/usb/gadget/ci13xxx_udc.c
index 18f0721..4d15d4d 100644
--- a/drivers/usb/gadget/ci13xxx_udc.c
+++ b/drivers/usb/gadget/ci13xxx_udc.c
@@ -1957,6 +1957,8 @@
 				mReq->req.length)
 				mEpTemp = &_udc->ep0in;
 			mReq->req.complete(&mEpTemp->ep, &mReq->req);
+			if (mEp->type == USB_ENDPOINT_XFER_CONTROL)
+				mReq->req.complete = NULL;
 			spin_lock(mEp->lock);
 		}
 	}
@@ -2803,7 +2805,12 @@
 
 	dbg_event(_usb_addr(mEp), "DEQUEUE", 0);
 
-	hw_ep_flush(mEp->num, mEp->dir);
+	if ((mEp->type == USB_ENDPOINT_XFER_CONTROL)) {
+		hw_ep_flush(_udc->ep0out.num, RX);
+		hw_ep_flush(_udc->ep0in.num, TX);
+	} else {
+		hw_ep_flush(mEp->num, mEp->dir);
+	}
 
 	/* pop request */
 	list_del_init(&mReq->queue);
@@ -2821,6 +2828,8 @@
 				mReq->req.length)
 			mEpTemp = &_udc->ep0in;
 		mReq->req.complete(&mEpTemp->ep, &mReq->req);
+		if (mEp->type == USB_ENDPOINT_XFER_CONTROL)
+			mReq->req.complete = NULL;
 		spin_lock(mEp->lock);
 	}
 
diff --git a/drivers/usb/gadget/u_data_hsuart.c b/drivers/usb/gadget/u_data_hsuart.c
index b2c57c4..91b1190 100644
--- a/drivers/usb/gadget/u_data_hsuart.c
+++ b/drivers/usb/gadget/u_data_hsuart.c
@@ -1062,7 +1062,7 @@
 {
 	struct dentry	 *ghsuart_data_dfile;
 
-	ghsuart_data_dent = debugfs_create_dir("ghsic_data_xport", 0);
+	ghsuart_data_dent = debugfs_create_dir("ghsuart_data_xport", 0);
 	if (!ghsuart_data_dent || IS_ERR(ghsuart_data_dent))
 		return -ENODEV;
 
diff --git a/drivers/video/msm/hdmi_msm.c b/drivers/video/msm/hdmi_msm.c
index 877b1ff..0655daf 100644
--- a/drivers/video/msm/hdmi_msm.c
+++ b/drivers/video/msm/hdmi_msm.c
@@ -763,9 +763,18 @@
 
 static void hdmi_msm_hpd_state_work(struct work_struct *work)
 {
-	boolean hpd_state;
+	boolean hpd_state = false;
 	char *envp[2];
 
+	if (hdmi_msm_state->is_mhl_enabled) {
+		/*
+		 * HPD will be controlled from MHL
+		 */
+		envp[0] = "";
+		DEV_DBG("%s %u\n", envp[0], hpd_state);
+		return;
+	}
+
 	if (!hdmi_msm_state || !hdmi_msm_state->hpd_initialized ||
 		!MSM_HDMI_BASE) {
 		DEV_DBG("%s: ignored, probe failed\n", __func__);
@@ -4301,12 +4310,17 @@
 static int hdmi_msm_power_ctrl(boolean enable)
 {
 	int rc = 0;
-	if (!hdmi_prim_display && !external_common_state->hpd_feature_on)
-		return 0;
 
 	if (enable) {
-		DEV_DBG("%s: Turning HPD ciruitry on\n", __func__);
-		rc = hdmi_msm_hpd_on(true);
+		/*
+		 * Enable HPD only if the UI option is on or if
+		 * HDMI is configured as the primary display
+		 */
+		if (hdmi_prim_display ||
+			external_common_state->hpd_feature_on) {
+			DEV_DBG("%s: Turning HPD ciruitry on\n", __func__);
+			rc = hdmi_msm_hpd_on(true);
+		}
 	} else {
 		DEV_DBG("%s: Turning HPD ciruitry off\n", __func__);
 		hdmi_msm_hpd_off();
@@ -4356,6 +4370,50 @@
 	return 0;
 }
 
+void mhl_connect_api(boolean on)
+{
+	char *envp[2];
+
+	/* Simulating a HPD event based on MHL event */
+	hdmi_msm_state->hpd_cable_chg_detected = FALSE;
+	/* QDSP OFF preceding the HPD event notification */
+	switch_set_state(&external_common_state->sdev, 0);
+	DEV_INFO("Hdmi state switch to %d: %s\n",
+		 external_common_state->sdev.state,  __func__);
+	if (on) {
+		hdmi_msm_read_edid();
+		if (hdmi_msm_has_hdcp())
+			hdmi_msm_state->reauth = FALSE ;
+		/* Build EDID table */
+		hdmi_msm_turn_on();
+		DEV_INFO("HDMI HPD: sense CONNECTED: send ONLINE\n");
+		kobject_uevent(external_common_state->uevent_kobj,
+			       KOBJ_ONLINE);
+		hdmi_msm_hdcp_enable();
+		envp[0] = 0;
+		if (!hdmi_msm_has_hdcp()) {
+			/* Send Audio for HDMI Compliance Cases*/
+			envp[0] = "HDCP_STATE=PASS";
+			envp[1] = NULL;
+			DEV_INFO("HDMI HPD: sense : send HDCP_PASS\n");
+			kobject_uevent_env(external_common_state->uevent_kobj,
+					   KOBJ_CHANGE, envp);
+			switch_set_state(&external_common_state->sdev, 1);
+			DEV_INFO("Hdmi state switch to %d: %s\n",
+				 external_common_state->sdev.state, __func__);
+		}
+	} else {
+		DEV_INFO("HDMI HPD: sense DISCONNECTED: send OFFLINE\n"
+			);
+		kobject_uevent(external_common_state->uevent_kobj,
+			       KOBJ_OFFLINE);
+		switch_set_state(&external_common_state->sdev, 0);
+		DEV_INFO("Hdmi state switch to %d: %s\n",
+			 external_common_state->sdev.state,  __func__);
+	}
+}
+EXPORT_SYMBOL(mhl_connect_api);
+
 /* Note that power-off will also be called when the cable-remove event is
  * processed on the user-space and as a result the framebuffer is powered
  * down.  However, we are still required to be able to detect a cable-insert
@@ -4461,6 +4519,8 @@
 		goto error;
 	}
 
+	hdmi_msm_state->is_mhl_enabled = hdmi_msm_state->pd->is_mhl_enabled;
+
 	rc = check_hdmi_features();
 	if (rc) {
 		DEV_ERR("Init FAILED: check_hdmi_features rc=%d\n", rc);
@@ -4528,10 +4588,11 @@
 	} else
 		DEV_ERR("Init FAILED: failed to add fb device\n");
 
-	rc = hdmi_msm_hpd_on(true);
-	if (rc)
-		goto error;
-	DEV_INFO("HDMI HPD: ON\n");
+	if (hdmi_prim_display) {
+		rc = hdmi_msm_hpd_on(true);
+		if (rc)
+			goto error;
+	}
 
 	if (hdmi_msm_has_hdcp()) {
 		/* Don't Set Encryption in case of non HDCP builds */
@@ -4678,7 +4739,7 @@
 	}
 
 	external_common_state = &hdmi_msm_state->common;
-	external_common_state->video_resolution = HDMI_VFRMT_1920x1080p60_16_9;
+	external_common_state->video_resolution = HDMI_VFRMT_1920x1080p30_16_9;
 #ifdef CONFIG_FB_MSM_HDMI_3D
 	external_common_state->switch_3d = hdmi_msm_switch_3d;
 #endif
diff --git a/drivers/video/msm/hdmi_msm.h b/drivers/video/msm/hdmi_msm.h
index 06ebb06..243a27b 100644
--- a/drivers/video/msm/hdmi_msm.h
+++ b/drivers/video/msm/hdmi_msm.h
@@ -110,6 +110,7 @@
 	void __iomem *hdmi_io;
 
 	struct external_common_state_type common;
+	boolean is_mhl_enabled;
 };
 
 extern struct hdmi_msm_state_type *hdmi_msm_state;
@@ -134,5 +135,5 @@
 void hdmi_msm_cec_one_touch_play(void);
 void hdmi_msm_cec_msg_send(struct hdmi_msm_cec_msg *msg);
 #endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL_CEC_SUPPORT */
-
+void mhl_connect_api(boolean on);
 #endif /* __HDMI_MSM_H__ */
diff --git a/drivers/video/msm/mdp.c b/drivers/video/msm/mdp.c
index 2cbef69..3c869cc 100644
--- a/drivers/video/msm/mdp.c
+++ b/drivers/video/msm/mdp.c
@@ -848,8 +848,11 @@
 	MDP_OUTP(base + 0x0018, INTR_HIST_DONE | INTR_HIST_RESET_SEQ_DONE);
 	mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_OFF, FALSE);
 
-	mgmt->hist = NULL;
-	complete(&mgmt->mdp_hist_comp);
+	if (mgmt->hist != NULL) {
+		mgmt->hist = NULL;
+		complete(&mgmt->mdp_hist_comp);
+	}
+
 	mdp_disable_irq(mgmt->irq_term);
 	return 0;
 }
@@ -964,8 +967,10 @@
 
 	if (!mfd->panel_power_on) {
 		mgmt->mdp_is_hist_data = FALSE;
-		mgmt->hist = NULL;
-		complete(&mgmt->mdp_hist_comp);
+		if (mgmt->hist != NULL) {
+			mgmt->hist = NULL;
+			complete(&mgmt->mdp_hist_comp);
+		}
 		ret = -EINVAL;
 		goto error_lock;
 	}
@@ -1132,7 +1137,8 @@
 	 */
 	if (!ret && mgmt->mdp_is_hist_valid && mgmt->mdp_is_hist_init) {
 		mgmt->hist = NULL;
-		complete(&mgmt->mdp_hist_comp);
+		if (waitqueue_active(&mgmt->mdp_hist_comp.wait))
+			complete(&mgmt->mdp_hist_comp);
 	}
 
 	if (mgmt->mdp_is_hist_valid == FALSE)
@@ -1233,6 +1239,7 @@
 		ret = -EPERM;
 		goto error_lock;
 	}
+	INIT_COMPLETION(mgmt->mdp_hist_comp);
 	mgmt->hist = hist;
 	mutex_unlock(&mgmt->mdp_hist_mutex);
 
diff --git a/drivers/video/msm/mdp.h b/drivers/video/msm/mdp.h
index f8d54bd..3fd51ba 100644
--- a/drivers/video/msm/mdp.h
+++ b/drivers/video/msm/mdp.h
@@ -75,7 +75,8 @@
 
 struct mdp_buf_type {
 	struct ion_handle *ihdl;
-	u32 phys_addr;
+	u32 write_addr;
+	u32 read_addr;
 	u32 size;
 };
 
diff --git a/drivers/video/msm/mdp4.h b/drivers/video/msm/mdp4.h
index 1557eed..c9bdf27 100644
--- a/drivers/video/msm/mdp4.h
+++ b/drivers/video/msm/mdp4.h
@@ -26,6 +26,7 @@
 extern struct mdp4_statistic mdp4_stat;
 extern uint32 mdp4_extn_disp;
 extern char *mmss_cc_base;	/* mutimedia sub system clock control */
+extern spinlock_t dsi_clk_lock;
 
 #define MDP4_OVERLAYPROC0_BASE	0x10000
 #define MDP4_OVERLAYPROC1_BASE	0x18000
@@ -337,7 +338,8 @@
 	uint32 element1; /* 0 = C0, 1 = C1, 2 = C2, 3 = C3 */
 	uint32 element0; /* 0 = C0, 1 = C1, 2 = C2, 3 = C3 */
 	struct completion comp;
-	ulong blt_addr; /* blt mode addr */
+	ulong ov_blt_addr; /* blt mode addr */
+	ulong dma_blt_addr; /* blt mode addr */
 	ulong blt_base;
 	ulong blt_offset;
 	uint32 blt_cnt;
@@ -718,6 +720,14 @@
 				struct mdp4_overlay_pipe *pipe);
 void mdp4_dsi_cmd_overlay_restore(void);
 void mdp_dsi_cmd_overlay_suspend(struct msm_fb_data_type *mfd);
+#ifdef CONFIG_FB_MSM_MDP303
+static inline void mdp4_dsi_cmd_del_timer(void)
+{
+	/* empty */
+}
+#else
+void mdp4_dsi_cmd_del_timer(void);
+#endif
 #else
 static inline void mdp4_dsi_cmd_dma_busy_wait(struct msm_fb_data_type *mfd)
 {
diff --git a/drivers/video/msm/mdp4_overlay.c b/drivers/video/msm/mdp4_overlay.c
index 3afe28b..d045e69 100644
--- a/drivers/video/msm/mdp4_overlay.c
+++ b/drivers/video/msm/mdp4_overlay.c
@@ -346,7 +346,7 @@
 
 	MDP_OUTP(MDP_BASE + 0xb0004,
 			(pipe->src_height << 16 | pipe->src_width));
-	if (pipe->blt_addr) {
+	if (pipe->dma_blt_addr) {
 		uint32 off, bpp;
 #ifdef BLT_RGB565
 		bpp = 2; /* overlay ouput is RGB565 */
@@ -356,7 +356,7 @@
 		off = 0;
 		if (pipe->ov_cnt & 0x01)
 			off = pipe->src_height * pipe->src_width * bpp;
-		MDP_OUTP(MDP_BASE + 0xb0008, pipe->blt_addr + off);
+		MDP_OUTP(MDP_BASE + 0xb0008, pipe->dma_blt_addr + off);
 		/* RGB888, output of overlay blending */
 		MDP_OUTP(MDP_BASE + 0xb000c, pipe->src_width * bpp);
 	} else {
@@ -424,7 +424,7 @@
 	if (mdp_is_in_isr == FALSE)
 		mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_ON, FALSE);
 
-	if (pipe->blt_addr) {
+	if (pipe->dma_blt_addr) {
 #ifdef BLT_RGB565
 		bpp = 2; /* overlay ouput is RGB565 */
 #else
@@ -433,7 +433,7 @@
 		off = 0;
 		if (pipe->dmap_cnt & 0x01)
 			off = pipe->src_height * pipe->src_width * bpp;
-		MDP_OUTP(MDP_BASE + 0x90008, pipe->blt_addr + off);
+		MDP_OUTP(MDP_BASE + 0x90008, pipe->dma_blt_addr + off);
 		/* RGB888, output of overlay blending */
 		MDP_OUTP(MDP_BASE + 0x9000c, pipe->src_width * bpp);
 	} else {
@@ -1321,7 +1321,7 @@
 	/*
 	 * BLT support both primary and external external
 	 */
-	if (pipe->blt_addr) {
+	if (pipe->ov_blt_addr) {
 		int off, bpp;
 #ifdef BLT_RGB565
 		bpp = 2;  /* overlay ouput is RGB565 */
@@ -1338,10 +1338,10 @@
 			if (pipe->ov_cnt & 0x01)
 				off = pipe->src_height * pipe->src_width * bpp;
 
-			outpdw(overlay_base + 0x000c, pipe->blt_addr + off);
+			outpdw(overlay_base + 0x000c, pipe->ov_blt_addr + off);
 			/* overlay ouput is RGB888 */
 			outpdw(overlay_base + 0x0010, pipe->src_width * bpp);
-			outpdw(overlay_base + 0x001c, pipe->blt_addr + off);
+			outpdw(overlay_base + 0x001c, pipe->ov_blt_addr + off);
 			/* MDDI - BLT + on demand */
 			outpdw(overlay_base + 0x0004, 0x08);
 
@@ -1361,19 +1361,19 @@
 							pipe->src_width * bpp;
 
 				outpdw(overlay_base + 0x000c,
-						pipe->blt_addr + off);
+						pipe->ov_blt_addr + off);
 				/* overlay ouput is RGB888 */
 				outpdw(overlay_base + 0x0010,
 					((pipe->src_width << 16) |
 					 pipe->src_width));
 				outpdw(overlay_base + 0x001c,
-						pipe->blt_addr + off);
+						pipe->ov_blt_addr + off);
 				off = pipe->src_height * pipe->src_width;
 				/* align chroma to 2k address */
 				off = (off + 2047) & ~2047;
 				/* UV plane adress */
 				outpdw(overlay_base + 0x0020,
-						pipe->blt_addr + off);
+						pipe->ov_blt_addr + off);
 				/* MDDI - BLT + on demand */
 				outpdw(overlay_base + 0x0004, 0x08);
 				/* pseudo planar + writeback */
diff --git a/drivers/video/msm/mdp4_overlay_dsi_cmd.c b/drivers/video/msm/mdp4_overlay_dsi_cmd.c
index 8ebf8a0..d0ac1a6 100644
--- a/drivers/video/msm/mdp4_overlay_dsi_cmd.c
+++ b/drivers/video/msm/mdp4_overlay_dsi_cmd.c
@@ -61,12 +61,14 @@
 
 static void dsi_clock_tout(unsigned long data)
 {
+	spin_lock(&dsi_clk_lock);
 	if (mipi_dsi_clk_on) {
 		if (dsi_state == ST_DSI_PLAYING) {
 			mipi_dsi_turn_off_clks();
 			mdp4_overlay_dsi_state_set(ST_DSI_CLK_OFF);
 		}
 	}
+	spin_unlock(&dsi_clk_lock);
 }
 
 static __u32 msm_fb_line_length(__u32 fb_index, __u32 xres, int bpp)
@@ -84,6 +86,11 @@
 		return xres * bpp;
 }
 
+void mdp4_dsi_cmd_del_timer(void)
+{
+	del_timer_sync(&dsi_clock_timer);
+}
+
 void mdp4_mipi_vsync_enable(struct msm_fb_data_type *mfd,
 		struct mdp4_overlay_pipe *pipe, int which)
 {
@@ -162,7 +169,8 @@
 		dsi_pipe = pipe; /* keep it */
 
 		mdp4_init_writeback_buf(mfd, MDP4_MIXER0);
-		pipe->blt_addr = 0;
+		pipe->ov_blt_addr = 0;
+		pipe->dma_blt_addr = 0;
 
 	} else {
 		pipe = dsi_pipe;
@@ -321,24 +329,25 @@
 {
 	unsigned long flag;
 
-	pr_debug("%s: blt_end=%d blt_addr=%x pid=%d\n",
-	__func__, dsi_pipe->blt_end, (int)dsi_pipe->blt_addr, current->pid);
+	pr_debug("%s: blt_end=%d ov_blt_addr=%x pid=%d\n",
+	__func__, dsi_pipe->blt_end, (int)dsi_pipe->ov_blt_addr, current->pid);
 
 	mdp4_allocate_writeback_buf(mfd, MDP4_MIXER0);
 
-	if (mfd->ov0_wb_buf->phys_addr == 0) {
+	if (mfd->ov0_wb_buf->write_addr == 0) {
 		pr_info("%s: no blt_base assigned\n", __func__);
 		return -EBUSY;
 	}
 
-	if (dsi_pipe->blt_addr == 0) {
+	if (dsi_pipe->ov_blt_addr == 0) {
 		mdp4_dsi_cmd_dma_busy_wait(mfd);
 		spin_lock_irqsave(&mdp_spin_lock, flag);
 		dsi_pipe->blt_end = 0;
 		dsi_pipe->blt_cnt = 0;
 		dsi_pipe->ov_cnt = 0;
 		dsi_pipe->dmap_cnt = 0;
-		dsi_pipe->blt_addr = mfd->ov0_wb_buf->phys_addr;
+		dsi_pipe->ov_blt_addr = mfd->ov0_wb_buf->write_addr;
+		dsi_pipe->dma_blt_addr = mfd->ov0_wb_buf->read_addr;
 		mdp4_stat.blt_dsi_cmd++;
 		spin_unlock_irqrestore(&mdp_spin_lock, flag);
 		return 0;
@@ -352,10 +361,10 @@
 	unsigned long flag;
 
 
-	pr_debug("%s: blt_end=%d blt_addr=%x\n",
-		 __func__, dsi_pipe->blt_end, (int)dsi_pipe->blt_addr);
+	pr_debug("%s: blt_end=%d ov_blt_addr=%x\n",
+		 __func__, dsi_pipe->blt_end, (int)dsi_pipe->ov_blt_addr);
 
-	if ((dsi_pipe->blt_end == 0) && dsi_pipe->blt_addr) {
+	if ((dsi_pipe->blt_end == 0) && dsi_pipe->ov_blt_addr) {
 		spin_lock_irqsave(&mdp_spin_lock, flag);
 		dsi_pipe->blt_end = 1;	/* mark as end */
 		spin_unlock_irqrestore(&mdp_spin_lock, flag);
@@ -393,7 +402,7 @@
 	char *overlay_base;
 
 
-	if (pipe->blt_addr == 0)
+	if (pipe->ov_blt_addr == 0)
 		return;
 
 
@@ -405,7 +414,7 @@
 	off = 0;
 	if (pipe->dmap_cnt & 0x01)
 		off = pipe->src_height * pipe->src_width * bpp;
-	addr = pipe->blt_addr + off;
+	addr = pipe->dma_blt_addr + off;
 
 	/* dmap */
 	MDP_OUTP(MDP_BASE + 0x90008, addr);
@@ -413,7 +422,7 @@
 	off = 0;
 	if (pipe->ov_cnt & 0x01)
 		off = pipe->src_height * pipe->src_width * bpp;
-	addr2 = pipe->blt_addr + off;
+	addr2 = pipe->ov_blt_addr + off;
 	/* overlay 0 */
 	overlay_base = MDP_BASE + MDP4_OVERLAYPROC0_BASE;/* 0x10000 */
 	outpdw(overlay_base + 0x000c, addr2);
@@ -441,7 +450,8 @@
 		spin_unlock(&mdp_spin_lock);
 		if (dsi_pipe->blt_end) {
 			dsi_pipe->blt_end = 0;
-			dsi_pipe->blt_addr = 0;
+			dsi_pipe->dma_blt_addr = 0;
+			dsi_pipe->ov_blt_addr = 0;
 			pr_debug("%s: END, ov_cnt=%d dmap_cnt=%d\n",
 				__func__, dsi_pipe->ov_cnt, dsi_pipe->dmap_cnt);
 			mdp_intr_mask &= ~INTR_DMA_P_DONE;
@@ -479,7 +489,7 @@
 {
 	int diff;
 
-	if (dsi_pipe->blt_addr == 0) {
+	if (dsi_pipe->ov_blt_addr == 0) {
 		mdp_pipe_ctrl(MDP_OVERLAY0_BLOCK, MDP_BLOCK_POWER_OFF, TRUE);
 		spin_lock(&mdp_spin_lock);
 		dma->busy = FALSE;
@@ -539,7 +549,7 @@
 		mipi_dsi_mdp_busy_wait(dsi_mfd);
 		mdp4_overlay_update_dsi_cmd(dsi_mfd);
 
-		if (dsi_pipe->blt_addr)
+		if (dsi_pipe->ov_blt_addr)
 			mdp4_dsi_blt_dmap_busy_wait(dsi_mfd);
 		mdp4_dsi_cmd_overlay_kickoff(dsi_mfd, dsi_pipe);
 	}
@@ -588,11 +598,10 @@
 			__func__, current->pid, mipi_dsi_clk_on);
 
 	/* satrt dsi clock if necessary */
-	if (mipi_dsi_clk_on == 0) {
-		local_bh_disable();
+	spin_lock_bh(&dsi_clk_lock);
+	if (mipi_dsi_clk_on == 0)
 		mipi_dsi_turn_on_clks();
-		local_bh_enable();
-	}
+	spin_unlock_bh(&dsi_clk_lock);
 
 	spin_lock_irqsave(&mdp_spin_lock, flag);
 	if (mfd->dma->busy == TRUE) {
@@ -622,17 +631,17 @@
 	 * to be called before kickoff.
 	 * vice versa for blt disabled.
 	 */
-	if (dsi_pipe->blt_addr && dsi_pipe->blt_cnt == 0)
+	if (dsi_pipe->ov_blt_addr && dsi_pipe->blt_cnt == 0)
 		mdp4_overlay_update_dsi_cmd(mfd); /* first time */
-	else if (dsi_pipe->blt_addr == 0  && dsi_pipe->blt_cnt) {
+	else if (dsi_pipe->ov_blt_addr == 0  && dsi_pipe->blt_cnt) {
 		mdp4_overlay_update_dsi_cmd(mfd); /* last time */
 		dsi_pipe->blt_cnt = 0;
 	}
 
-	pr_debug("%s: blt_addr=%d blt_cnt=%d\n",
-		__func__, (int)dsi_pipe->blt_addr, dsi_pipe->blt_cnt);
+	pr_debug("%s: ov_blt_addr=%d blt_cnt=%d\n",
+		__func__, (int)dsi_pipe->ov_blt_addr, dsi_pipe->blt_cnt);
 
-	if (dsi_pipe->blt_addr)
+	if (dsi_pipe->ov_blt_addr)
 		mdp4_dsi_blt_dmap_busy_wait(dsi_mfd);
 
 	mdp4_dsi_cmd_overlay_kickoff(mfd, pipe);
@@ -658,7 +667,7 @@
 
 	mipi_dsi_mdp_busy_wait(mfd);
 
-	if (dsi_pipe->blt_addr == 0)
+	if (dsi_pipe->ov_blt_addr == 0)
 		mipi_dsi_cmd_mdp_start();
 
 	mdp4_overlay_dsi_state_set(ST_DSI_PLAYING);
@@ -666,7 +675,7 @@
 	spin_lock_irqsave(&mdp_spin_lock, flag);
 	mdp_enable_irq(MDP_OVERLAY0_TERM);
 	mfd->dma->busy = TRUE;
-	if (dsi_pipe->blt_addr)
+	if (dsi_pipe->ov_blt_addr)
 		mfd->dma->dmap_busy = TRUE;
 	/* start OVERLAY pipe */
 	spin_unlock_irqrestore(&mdp_spin_lock, flag);
@@ -700,7 +709,7 @@
 	if (mfd && mfd->panel_power_on) {
 		mdp4_dsi_cmd_dma_busy_wait(mfd);
 
-		if (dsi_pipe && dsi_pipe->blt_addr)
+		if (dsi_pipe && dsi_pipe->ov_blt_addr)
 			mdp4_dsi_blt_dmap_busy_wait(mfd);
 
 		mdp4_overlay_update_dsi_cmd(mfd);
diff --git a/drivers/video/msm/mdp4_overlay_dsi_video.c b/drivers/video/msm/mdp4_overlay_dsi_video.c
index b0f3e17..bc4476e 100644
--- a/drivers/video/msm/mdp4_overlay_dsi_video.c
+++ b/drivers/video/msm/mdp4_overlay_dsi_video.c
@@ -152,7 +152,8 @@
 		init_completion(&dsi_video_comp);
 
 		mdp4_init_writeback_buf(mfd, MDP4_MIXER0);
-		pipe->blt_addr = 0;
+		pipe->ov_blt_addr = 0;
+		pipe->dma_blt_addr = 0;
 
 	} else {
 		pipe = dsi_pipe;
@@ -416,7 +417,7 @@
 	char *overlay_base;
 
 
-	if (pipe->blt_addr == 0)
+	if (pipe->ov_blt_addr == 0)
 		return;
 
 
@@ -428,7 +429,7 @@
 	off = 0;
 	if (pipe->ov_cnt & 0x01)
 		off = pipe->src_height * pipe->src_width * bpp;
-	addr = pipe->blt_addr + off;
+	addr = pipe->ov_blt_addr + off;
 
 	/* overlay 0 */
 	overlay_base = MDP_BASE + MDP4_OVERLAYPROC0_BASE;/* 0x10000 */
@@ -441,7 +442,7 @@
 	uint32 off, addr;
 	int bpp;
 
-	if (pipe->blt_addr == 0)
+	if (pipe->ov_blt_addr == 0)
 		return;
 
 
@@ -453,7 +454,7 @@
 	off = 0;
 	if (pipe->dmap_cnt & 0x01)
 		off = pipe->src_height * pipe->src_width * bpp;
-	addr = pipe->blt_addr + off;
+	addr = pipe->dma_blt_addr + off;
 
 	/* dmap */
 	MDP_OUTP(MDP_BASE + 0x90008, addr);
@@ -529,7 +530,7 @@
 	if (pipe->flags & MDP_OV_PLAY_NOWAIT)
 		return;
 
-	if (dsi_pipe->blt_addr) {
+	if (dsi_pipe->ov_blt_addr) {
 		mdp4_overlay_dsi_video_dma_busy_wait(mfd);
 
 		mdp4_dsi_video_blt_ov_update(dsi_pipe);
@@ -569,10 +570,15 @@
 {
 	if (blt_cfg_changed) {
 		mdp_is_in_isr = TRUE;
-		mdp4_overlayproc_cfg(dsi_pipe);
-		mdp4_overlay_dmap_xy(dsi_pipe);
+		if (dsi_pipe->ov_blt_addr) {
+			mdp4_overlay_dmap_xy(dsi_pipe);
+			mdp4_overlayproc_cfg(dsi_pipe);
+		} else {
+			mdp4_overlayproc_cfg(dsi_pipe);
+			mdp4_overlay_dmap_xy(dsi_pipe);
+		}
 		mdp_is_in_isr = FALSE;
-		if (dsi_pipe->blt_addr) {
+		if (dsi_pipe->ov_blt_addr) {
 			mdp4_dsi_video_blt_ov_update(dsi_pipe);
 			dsi_pipe->ov_cnt++;
 			outp32(MDP_INTR_CLEAR, INTR_OVERLAY0_DONE);
@@ -595,7 +601,7 @@
 {
 	spin_lock(&mdp_spin_lock);
 	dma->busy = FALSE;
-	if (dsi_pipe->blt_addr == 0) {
+	if (dsi_pipe->ov_blt_addr == 0) {
 		spin_unlock(&mdp_spin_lock);
 		return;
 	}
@@ -618,21 +624,23 @@
 
 	mdp4_allocate_writeback_buf(mfd, MDP4_MIXER0);
 
-	if (mfd->ov0_wb_buf->phys_addr == 0) {
+	if (mfd->ov0_wb_buf->write_addr == 0) {
 		pr_info("%s: no blt_base assigned\n", __func__);
 		return;
 	}
 
 	spin_lock_irqsave(&mdp_spin_lock, flag);
-	if (enable && dsi_pipe->blt_addr == 0) {
-		dsi_pipe->blt_addr = mfd->ov0_wb_buf->phys_addr;
+	if (enable && dsi_pipe->ov_blt_addr == 0) {
+		dsi_pipe->ov_blt_addr = mfd->ov0_wb_buf->write_addr;
+		dsi_pipe->dma_blt_addr = mfd->ov0_wb_buf->read_addr;
 		dsi_pipe->blt_cnt = 0;
 		dsi_pipe->ov_cnt = 0;
 		dsi_pipe->dmap_cnt = 0;
 		mdp4_stat.blt_dsi_video++;
 		change++;
-	} else if (enable == 0 && dsi_pipe->blt_addr) {
-		dsi_pipe->blt_addr = 0;
+	} else if (enable == 0 && dsi_pipe->ov_blt_addr) {
+		dsi_pipe->ov_blt_addr = 0;
+		dsi_pipe->dma_blt_addr = 0;
 		change++;
 	}
 
@@ -641,8 +649,8 @@
 		return;
 	}
 
-	pr_debug("%s: enable=%d blt_addr=%x\n", __func__,
-			enable, (int)dsi_pipe->blt_addr);
+	pr_debug("%s: enable=%d ov_blt_addr=%x\n", __func__,
+			enable, (int)dsi_pipe->ov_blt_addr);
 	blt_cfg_changed = 1;
 
 	spin_unlock_irqrestore(&mdp_spin_lock, flag);
diff --git a/drivers/video/msm/mdp4_overlay_dtv.c b/drivers/video/msm/mdp4_overlay_dtv.c
index e26522b..b90812f 100644
--- a/drivers/video/msm/mdp4_overlay_dtv.c
+++ b/drivers/video/msm/mdp4_overlay_dtv.c
@@ -377,7 +377,8 @@
 		return -ENODEV;
 
 	mdp4_init_writeback_buf(mfd, MDP4_MIXER1);
-	dtv_pipe->blt_addr = 0;
+	dtv_pipe->ov_blt_addr = 0;
+	dtv_pipe->dma_blt_addr = 0;
 
 	return mdp4_dtv_start(mfd);
 }
@@ -408,7 +409,7 @@
 	int bpp;
 	char *overlay_base;
 
-	if (pipe->blt_addr == 0)
+	if (pipe->ov_blt_addr == 0)
 		return;
 #ifdef BLT_RGB565
 	bpp = 2; /* overlay ouput is RGB565 */
@@ -418,7 +419,7 @@
 	off = (pipe->ov_cnt & 0x01) ?
 		pipe->src_height * pipe->src_width * bpp : 0;
 
-	addr = pipe->blt_addr + off;
+	addr = pipe->ov_blt_addr + off;
 	pr_debug("%s overlay addr 0x%x\n", __func__, addr);
 	/* overlay 1 */
 	overlay_base = MDP_BASE + MDP4_OVERLAYPROC1_BASE;/* 0x18000 */
@@ -431,7 +432,7 @@
 	uint32 off, addr;
 	int bpp;
 
-	if (pipe->blt_addr == 0)
+	if (pipe->ov_blt_addr == 0)
 		return;
 
 #ifdef BLT_RGB565
@@ -441,7 +442,7 @@
 #endif
 	off =  (pipe->dmae_cnt & 0x01) ?
 		pipe->src_height * pipe->src_width * bpp : 0;
-	addr = pipe->blt_addr + off;
+	addr = pipe->dma_blt_addr + off;
 	MDP_OUTP(MDP_BASE + 0xb0008, addr);
 }
 
@@ -464,7 +465,7 @@
 		return;
 	}
 
-	if (dtv_pipe->blt_addr) {
+	if (dtv_pipe->ov_blt_addr) {
 		mdp4_dtv_blt_ov_update(dtv_pipe);
 		dtv_pipe->ov_cnt++;
 		mdp4_overlay_dtv_ov_kick_start();
@@ -524,7 +525,7 @@
 			msecs_to_jiffies(VSYNC_PERIOD * 3));
 	mdp_disable_irq(MDP_OVERLAY1_TERM);
 
-	if (dtv_pipe->blt_addr)
+	if (dtv_pipe->ov_blt_addr)
 		mdp4_overlay_dtv_wait4dmae(mfd);
 }
 
@@ -581,7 +582,7 @@
 {
 	if (!dtv_pipe)
 		return;
-	if (dtv_pipe->blt_addr) {
+	if (dtv_pipe->ov_blt_addr) {
 		mdp4_dtv_blt_dmae_update(dtv_pipe);
 		dtv_pipe->dmae_cnt++;
 	}
@@ -642,7 +643,7 @@
 	unsigned long flag;
 	int change = 0;
 
-	if (!mfd->ov1_wb_buf->phys_addr) {
+	if (!mfd->ov1_wb_buf->write_addr) {
 		pr_debug("%s: no writeback buf assigned\n", __func__);
 		return;
 	}
@@ -654,16 +655,18 @@
 	}
 
 	spin_lock_irqsave(&mdp_spin_lock, flag);
-	if (enable && dtv_pipe->blt_addr == 0) {
-		dtv_pipe->blt_addr = mfd->ov1_wb_buf->phys_addr;
+	if (enable && dtv_pipe->ov_blt_addr == 0) {
+		dtv_pipe->ov_blt_addr = mfd->ov1_wb_buf->write_addr;
+		dtv_pipe->dma_blt_addr = mfd->ov1_wb_buf->read_addr;
 		change++;
 		dtv_pipe->ov_cnt = 0;
 		dtv_pipe->dmae_cnt = 0;
-	} else if (enable == 0 && dtv_pipe->blt_addr) {
-		dtv_pipe->blt_addr = 0;
+	} else if (enable == 0 && dtv_pipe->ov_blt_addr) {
+		dtv_pipe->ov_blt_addr = 0;
+		dtv_pipe->dma_blt_addr = 0;
 		change++;
 	}
-	pr_debug("%s: blt_addr=%x\n", __func__, (int)dtv_pipe->blt_addr);
+	pr_debug("%s: ov_blt_addr=%x\n", __func__, (int)dtv_pipe->ov_blt_addr);
 	spin_unlock_irqrestore(&mdp_spin_lock, flag);
 
 	if (!change)
@@ -675,8 +678,8 @@
 		msleep(20);
 	}
 
-	mdp4_overlayproc_cfg(dtv_pipe);
 	mdp4_overlay_dmae_xy(dtv_pipe);
+	mdp4_overlayproc_cfg(dtv_pipe);
 	MDP_OUTP(MDP_BASE + DTV_BASE, 1);	/* start dtv */
 }
 
diff --git a/drivers/video/msm/mdp4_overlay_lcdc.c b/drivers/video/msm/mdp4_overlay_lcdc.c
index 98c8191..bcc4ea6 100644
--- a/drivers/video/msm/mdp4_overlay_lcdc.c
+++ b/drivers/video/msm/mdp4_overlay_lcdc.c
@@ -133,8 +133,8 @@
 		init_completion(&lcdc_comp);
 
 		mdp4_init_writeback_buf(mfd, MDP4_MIXER0);
-		pipe->blt_addr = 0;
-
+		pipe->ov_blt_addr = 0;
+		pipe->dma_blt_addr = 0;
 	} else {
 		pipe = lcdc_pipe;
 	}
@@ -325,7 +325,7 @@
 	char *overlay_base;
 
 
-	if (pipe->blt_addr == 0)
+	if (pipe->ov_blt_addr == 0)
 		return;
 
 
@@ -337,7 +337,7 @@
 	off = 0;
 	if (pipe->ov_cnt & 0x01)
 		off = pipe->src_height * pipe->src_width * bpp;
-	addr = pipe->blt_addr + off;
+	addr = pipe->ov_blt_addr + off;
 
 	/* overlay 0 */
 	overlay_base = MDP_BASE + MDP4_OVERLAYPROC0_BASE;/* 0x10000 */
@@ -350,7 +350,7 @@
 	uint32 off, addr;
 	int bpp;
 
-	if (pipe->blt_addr == 0)
+	if (pipe->ov_blt_addr == 0)
 		return;
 
 
@@ -362,7 +362,7 @@
 	off = 0;
 	if (pipe->dmap_cnt & 0x01)
 		off = pipe->src_height * pipe->src_width * bpp;
-	addr = pipe->blt_addr + off;
+	addr = pipe->dma_blt_addr + off;
 
 	/* dmap */
 	MDP_OUTP(MDP_BASE + 0x90008, addr);
@@ -438,7 +438,7 @@
 	if (pipe->flags & MDP_OV_PLAY_NOWAIT)
 		return;
 
-	if (lcdc_pipe->blt_addr) {
+	if (lcdc_pipe->ov_blt_addr) {
 		mdp4_overlay_lcdc_dma_busy_wait(mfd);
 
 		mdp4_lcdc_blt_ov_update(lcdc_pipe);
@@ -485,7 +485,7 @@
 {
 	spin_lock(&mdp_spin_lock);
 	dma->busy = FALSE;
-	if (lcdc_pipe->blt_addr == 0) {
+	if (lcdc_pipe->ov_blt_addr == 0) {
 		spin_unlock(&mdp_spin_lock);
 		return;
 	}
@@ -500,7 +500,7 @@
 {
 	unsigned long flag;
 
-	if (lcdc_pipe->blt_addr) {
+	if (lcdc_pipe->ov_blt_addr) {
 		mdp4_overlay_lcdc_dma_busy_wait(mfd);
 
 		mdp4_lcdc_blt_ov_update(lcdc_pipe);
@@ -530,24 +530,26 @@
 
 	mdp4_allocate_writeback_buf(mfd, MDP4_MIXER0);
 
-	if (!mfd->ov0_wb_buf->phys_addr) {
+	if (!mfd->ov0_wb_buf->write_addr) {
 		pr_debug("%s: no blt_base assigned\n", __func__);
 		return;
 	}
 
 	spin_lock_irqsave(&mdp_spin_lock, flag);
-	if (enable && lcdc_pipe->blt_addr == 0) {
-		lcdc_pipe->blt_addr = mfd->ov0_wb_buf->phys_addr;
+	if (enable && lcdc_pipe->ov_blt_addr == 0) {
+		lcdc_pipe->ov_blt_addr = mfd->ov0_wb_buf->write_addr;
+		lcdc_pipe->dma_blt_addr = mfd->ov0_wb_buf->read_addr;
 		change++;
 		lcdc_pipe->blt_cnt = 0;
 		lcdc_pipe->ov_cnt = 0;
 		lcdc_pipe->dmap_cnt = 0;
 		mdp4_stat.blt_lcdc++;
-	} else if (enable == 0 && lcdc_pipe->blt_addr) {
-		lcdc_pipe->blt_addr = 0;
+	} else if (enable == 0 && lcdc_pipe->ov_blt_addr) {
+		lcdc_pipe->ov_blt_addr = 0;
+		lcdc_pipe->dma_blt_addr = 0;
 		change++;
 	}
-	pr_info("%s: blt_addr=%x\n", __func__, (int)lcdc_pipe->blt_addr);
+	pr_info("%s: ov_blt_addr=%x\n", __func__, (int)lcdc_pipe->ov_blt_addr);
 	spin_unlock_irqrestore(&mdp_spin_lock, flag);
 
 	if (!change)
@@ -559,9 +561,9 @@
 		msleep(20);
 	}
 
-	mdp4_overlayproc_cfg(lcdc_pipe);
 	mdp4_overlay_dmap_xy(lcdc_pipe);
-	if (lcdc_pipe->blt_addr) {
+	mdp4_overlayproc_cfg(lcdc_pipe);
+	if (lcdc_pipe->ov_blt_addr) {
 		mdp4_overlay_lcdc_prefill(mfd);
 		mdp4_overlay_lcdc_prefill(mfd);
 	}
diff --git a/drivers/video/msm/mdp4_overlay_mddi.c b/drivers/video/msm/mdp4_overlay_mddi.c
index 82864918..c4e6793 100644
--- a/drivers/video/msm/mdp4_overlay_mddi.c
+++ b/drivers/video/msm/mdp4_overlay_mddi.c
@@ -163,7 +163,8 @@
 
 		MDP_OUTP(MDP_BASE + 0x00098, 0x01);
 		mdp4_init_writeback_buf(mfd, MDP4_MIXER0);
-		pipe->blt_addr = 0;
+		pipe->ov_blt_addr = 0;
+		pipe->dma_blt_addr = 0;
 	} else {
 		pipe = mddi_pipe;
 	}
@@ -254,23 +255,25 @@
 	unsigned long flag;
 
 	pr_debug("%s: blt_end=%d blt_addr=%x pid=%d\n",
-	__func__, mddi_pipe->blt_end, (int)mddi_pipe->blt_addr, current->pid);
+		__func__, mddi_pipe->blt_end,
+		(int)mddi_pipe->ov_blt_addr, current->pid);
 
 	mdp4_allocate_writeback_buf(mfd, MDP4_MIXER0);
 
-	if (mfd->ov0_wb_buf->phys_addr == 0) {
+	if (mfd->ov0_wb_buf->write_addr == 0) {
 		pr_info("%s: no blt_base assigned\n", __func__);
 		return -EBUSY;
 	}
 
-	if (mddi_pipe->blt_addr == 0) {
+	if (mddi_pipe->ov_blt_addr == 0) {
 		mdp4_mddi_dma_busy_wait(mfd);
 		spin_lock_irqsave(&mdp_spin_lock, flag);
 		mddi_pipe->blt_end = 0;
 		mddi_pipe->blt_cnt = 0;
 		mddi_pipe->ov_cnt = 0;
 		mddi_pipe->dmap_cnt = 0;
-		mddi_pipe->blt_addr = mfd->ov0_wb_buf->phys_addr;
+		mddi_pipe->ov_blt_addr = mfd->ov0_wb_buf->write_addr;
+		mddi_pipe->dma_blt_addr = mfd->ov0_wb_buf->write_addr;
 		mdp4_stat.blt_mddi++;
 		spin_unlock_irqrestore(&mdp_spin_lock, flag);
 	return 0;
@@ -284,9 +287,9 @@
 	unsigned long flag;
 
 	pr_debug("%s: blt_end=%d blt_addr=%x\n",
-		 __func__, mddi_pipe->blt_end, (int)mddi_pipe->blt_addr);
+		 __func__, mddi_pipe->blt_end, (int)mddi_pipe->ov_blt_addr);
 
-	if ((mddi_pipe->blt_end == 0) && mddi_pipe->blt_addr) {
+	if ((mddi_pipe->blt_end == 0) && mddi_pipe->ov_blt_addr) {
 		spin_lock_irqsave(&mdp_spin_lock, flag);
 		mddi_pipe->blt_end = 1;	/* mark as end */
 		spin_unlock_irqrestore(&mdp_spin_lock, flag);
@@ -323,7 +326,7 @@
 	int bpp;
 	char *overlay_base;
 
-	if (pipe->blt_addr == 0)
+	if (pipe->ov_blt_addr == 0)
 		return;
 
 
@@ -336,7 +339,7 @@
 	if (pipe->dmap_cnt & 0x01)
 		off = pipe->src_height * pipe->src_width * bpp;
 
-	addr = pipe->blt_addr + off;
+	addr = pipe->ov_blt_addr + off;
 
 	/* dmap */
 	MDP_OUTP(MDP_BASE + 0x90008, addr);
@@ -344,7 +347,7 @@
 	off = 0;
 	if (pipe->ov_cnt & 0x01)
 		off = pipe->src_height * pipe->src_width * bpp;
-	addr2 = pipe->blt_addr + off;
+	addr2 = pipe->ov_blt_addr + off;
 	/* overlay 0 */
 	overlay_base = MDP_BASE + MDP4_OVERLAYPROC0_BASE;/* 0x10000 */
 	outpdw(overlay_base + 0x000c, addr2);
@@ -371,7 +374,8 @@
 
 		if (mddi_pipe->blt_end) {
 			mddi_pipe->blt_end = 0;
-			mddi_pipe->blt_addr = 0;
+			mddi_pipe->ov_blt_addr = 0;
+			mddi_pipe->dma_blt_addr = 0;
 			pr_debug("%s: END, ov_cnt=%d dmap_cnt=%d\n", __func__,
 				mddi_pipe->ov_cnt, mddi_pipe->dmap_cnt);
 			mdp_intr_mask &= ~INTR_DMA_P_DONE;
@@ -406,7 +410,7 @@
 {
 	int diff;
 
-	if (mddi_pipe->blt_addr == 0) {
+	if (mddi_pipe->ov_blt_addr == 0) {
 		mdp_pipe_ctrl(MDP_OVERLAY0_BLOCK, MDP_BLOCK_POWER_OFF, TRUE);
 		spin_lock(&mdp_spin_lock);
 		dma->busy = FALSE;
@@ -473,7 +477,7 @@
 		mdp4_mddi_dma_busy_wait(mddi_mfd);
 		mdp4_overlay_update_lcd(mddi_mfd);
 
-		if (mddi_pipe->blt_addr)
+		if (mddi_pipe->ov_blt_addr)
 			mdp4_mddi_blt_dmap_busy_wait(mddi_mfd);
 		mdp4_mddi_overlay_kickoff(mddi_mfd, mddi_pipe);
 		mddi_mfd->dma_update_flag = 1;
@@ -539,17 +543,17 @@
 	 * to be called before kickoff.
 	 * vice versa for blt disabled.
 	 */
-	if (mddi_pipe->blt_addr && mddi_pipe->blt_cnt == 0)
+	if (mddi_pipe->ov_blt_addr && mddi_pipe->blt_cnt == 0)
 		mdp4_overlay_update_lcd(mfd); /* first time */
-	else if (mddi_pipe->blt_addr == 0  && mddi_pipe->blt_cnt) {
+	else if (mddi_pipe->ov_blt_addr == 0  && mddi_pipe->blt_cnt) {
 		mdp4_overlay_update_lcd(mfd); /* last time */
 		mddi_pipe->blt_cnt = 0;
 	}
 
 	pr_debug("%s: blt_addr=%d blt_cnt=%d\n",
-		__func__, (int)mddi_pipe->blt_addr, mddi_pipe->blt_cnt);
+		__func__, (int)mddi_pipe->ov_blt_addr, mddi_pipe->blt_cnt);
 
-	if (mddi_pipe->blt_addr)
+	if (mddi_pipe->ov_blt_addr)
 		mdp4_mddi_blt_dmap_busy_wait(mddi_mfd);
 	mdp4_mddi_overlay_kickoff(mfd, pipe);
 }
@@ -572,7 +576,7 @@
 	mdp_enable_irq(MDP_OVERLAY0_TERM);
 	spin_lock_irqsave(&mdp_spin_lock, flag);
 	mfd->dma->busy = TRUE;
-	if (mddi_pipe->blt_addr)
+	if (mddi_pipe->ov_blt_addr)
 		mfd->dma->dmap_busy = TRUE;
 	spin_unlock_irqrestore(&mdp_spin_lock, flag);
 	/* start OVERLAY pipe */
@@ -657,7 +661,7 @@
 
 	mdp_enable_irq(MDP_DMA_S_TERM);
 
-	if (mddi_pipe->blt_addr == 0)
+	if (mddi_pipe->ov_blt_addr == 0)
 		mfd->dma->busy = TRUE;
 
 	mfd->ibuf_flushed = TRUE;
@@ -688,7 +692,7 @@
 	if (mfd && mfd->panel_power_on) {
 		mdp4_mddi_dma_busy_wait(mfd);
 
-		if (mddi_pipe && mddi_pipe->blt_addr)
+		if (mddi_pipe && mddi_pipe->ov_blt_addr)
 			mdp4_mddi_blt_dmap_busy_wait(mfd);
 
 		mdp4_overlay_update_lcd(mfd);
diff --git a/drivers/video/msm/mdp4_overlay_writeback.c b/drivers/video/msm/mdp4_overlay_writeback.c
index f426f8c..32fe141 100644
--- a/drivers/video/msm/mdp4_overlay_writeback.c
+++ b/drivers/video/msm/mdp4_overlay_writeback.c
@@ -272,11 +272,11 @@
 	}
 	mutex_unlock(&mfd->writeback_mutex);
 
-	writeback_pipe->blt_addr = (ulong) (node ? node->addr : NULL);
+	writeback_pipe->ov_blt_addr = (ulong) (node ? node->addr : NULL);
 
-	if (!writeback_pipe->blt_addr) {
+	if (!writeback_pipe->ov_blt_addr) {
 		pr_err("%s: no writeback buffer 0x%x, %p\n", __func__,
-				(unsigned int)writeback_pipe->blt_addr, node);
+			(unsigned int)writeback_pipe->ov_blt_addr, node);
 		mutex_unlock(&mfd->unregister_mutex);
 		return;
 	}
@@ -324,13 +324,13 @@
 	}
 	mutex_unlock(&mfd->writeback_mutex);
 
-	writeback_pipe->blt_addr = (ulong) (node ? node->addr : NULL);
+	writeback_pipe->ov_blt_addr = (ulong) (node ? node->addr : NULL);
 
 	mutex_lock(&mfd->dma->ov_mutex);
 	pr_debug("%s in writeback\n", __func__);
-	if (writeback_pipe && !writeback_pipe->blt_addr) {
+	if (writeback_pipe && !writeback_pipe->ov_blt_addr) {
 		pr_err("%s: no writeback buffer 0x%x\n", __func__,
-				(unsigned int)writeback_pipe->blt_addr);
+				(unsigned int)writeback_pipe->ov_blt_addr);
 		ret = mdp4_overlay_writeback_update(mfd);
 		if (ret)
 			pr_err("%s: update failed writeback pipe NULL\n",
@@ -351,7 +351,7 @@
 		}
 
 		pr_debug("%s: in writeback pan display 0x%x\n", __func__,
-				(unsigned int)writeback_pipe->blt_addr);
+				(unsigned int)writeback_pipe->ov_blt_addr);
 		mdp4_writeback_kickoff_ui(mfd, writeback_pipe);
 		mdp4_iommu_unmap(writeback_pipe);
 
diff --git a/drivers/video/msm/mdp4_util.c b/drivers/video/msm/mdp4_util.c
index 8bd125b..4c0e28f 100644
--- a/drivers/video/msm/mdp4_util.c
+++ b/drivers/video/msm/mdp4_util.c
@@ -2559,13 +2559,14 @@
 		buf = mfd->ov1_wb_buf;
 
 	buf->ihdl = NULL;
-	buf->phys_addr = 0;
+	buf->write_addr = 0;
+	buf->read_addr = 0;
 }
 
 u32 mdp4_allocate_writeback_buf(struct msm_fb_data_type *mfd, u32 mix_num)
 {
 	struct mdp_buf_type *buf;
-	ion_phys_addr_t	addr;
+	ion_phys_addr_t	addr, read_addr = 0;
 	size_t buffer_size;
 	unsigned long len;
 
@@ -2574,7 +2575,7 @@
 	else
 		buf = mfd->ov1_wb_buf;
 
-	if (buf->phys_addr || !IS_ERR_OR_NULL(buf->ihdl))
+	if (buf->write_addr || !IS_ERR_OR_NULL(buf->ihdl))
 		return 0;
 
 	if (!buf->size) {
@@ -2592,6 +2593,12 @@
 			mfd->mem_hid);
 		if (!IS_ERR_OR_NULL(buf->ihdl)) {
 			if (mdp_iommu_split_domain) {
+				if (ion_map_iommu(mfd->iclient, buf->ihdl,
+					DISPLAY_READ_DOMAIN, GEN_POOL, SZ_4K,
+					0, &read_addr, &len, 0, 0)) {
+					pr_err("ion_map_iommu() read failed\n");
+					return -ENOMEM;
+				}
 				if (mfd->mem_hid & ION_SECURE) {
 					if (ion_phys(mfd->iclient, buf->ihdl,
 						&addr, (size_t *)&len)) {
@@ -2612,7 +2619,7 @@
 				if (ion_map_iommu(mfd->iclient, buf->ihdl,
 					DISPLAY_READ_DOMAIN, GEN_POOL, SZ_4K,
 					0, &addr, &len, 0, 0)) {
-					pr_err("ion_map_iommu() failed\n");
+					pr_err("ion_map_iommu() write failed\n");
 					return -ENOMEM;
 				}
 			}
@@ -2628,7 +2635,13 @@
 	if (addr) {
 		pr_info("allocating %d bytes at %x for mdp writeback\n",
 			buffer_size, (u32) addr);
-		buf->phys_addr = addr;
+		buf->write_addr = addr;
+
+		if (read_addr)
+			buf->read_addr = read_addr;
+		else
+			buf->read_addr = buf->write_addr;
+
 		return 0;
 	} else {
 		pr_err("%s cannot allocate memory for mdp writeback!\n",
@@ -2652,6 +2665,8 @@
 				if (!(mfd->mem_hid & ION_SECURE))
 					ion_unmap_iommu(mfd->iclient, buf->ihdl,
 						DISPLAY_WRITE_DOMAIN, GEN_POOL);
+				ion_unmap_iommu(mfd->iclient, buf->ihdl,
+					DISPLAY_READ_DOMAIN, GEN_POOL);
 			} else {
 				ion_unmap_iommu(mfd->iclient, buf->ihdl,
 					DISPLAY_READ_DOMAIN, GEN_POOL);
@@ -2662,13 +2677,14 @@
 			buf->ihdl = NULL;
 		}
 	} else {
-		if (buf->phys_addr) {
-			free_contiguous_memory_by_paddr(buf->phys_addr);
+		if (buf->write_addr) {
+			free_contiguous_memory_by_paddr(buf->write_addr);
 			pr_debug("%s:%d free writeback pmem\n", __func__,
 				__LINE__);
 		}
 	}
-	buf->phys_addr = 0;
+	buf->write_addr = 0;
+	buf->read_addr = 0;
 }
 
 static int mdp4_update_pcc_regs(uint32_t offset,
diff --git a/drivers/video/msm/mdp_dma.c b/drivers/video/msm/mdp_dma.c
index 2ba2c85..3a7513a 100644
--- a/drivers/video/msm/mdp_dma.c
+++ b/drivers/video/msm/mdp_dma.c
@@ -301,8 +301,11 @@
 
 	spin_lock_irqsave(&mdp_spin_lock, flag);
 #ifdef DSI_CLK_CTRL
+
+	spin_lock_bh(&dsi_clk_lock);
 	if (mipi_dsi_clk_on == 0)
 		mipi_dsi_turn_on_clks();
+	spin_unlock_bh(&dsi_clk_lock);
 #endif
 
 	if (mfd->dma->busy == TRUE) {
diff --git a/drivers/video/msm/mhl/mhl_8334.c b/drivers/video/msm/mhl/mhl_8334.c
index 43280a5..d6e3f6f 100644
--- a/drivers/video/msm/mhl/mhl_8334.c
+++ b/drivers/video/msm/mhl/mhl_8334.c
@@ -27,16 +27,16 @@
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/fs.h>
+#include <linux/regulator/consumer.h>
 #include <linux/device.h>
 #include <linux/platform_device.h>
 
 #include "msm_fb.h"
 #include "external_common.h"
+#include "hdmi_msm.h"
 #include "mhl_8334.h"
 #include "mhl_i2c_utils.h"
 
-#define DEBUG
-
 
 static struct i2c_device_id mhl_sii_i2c_id[] = {
 	{ MHL_DRIVER_NAME, 0 },
@@ -65,6 +65,163 @@
 	.id_table = mhl_sii_i2c_id,
 };
 
+static void mhl_sii_reset_pin(int on)
+{
+	gpio_set_value(mhl_msm_state->mhl_data->gpio_mhl_reset, on);
+	return;
+}
+
+static int mhl_sii_reg_enable(void)
+{
+	static struct regulator *reg_8038_l20;
+	static struct regulator *reg_8038_l11;
+	int rc;
+
+	pr_debug("Inside %s\n", __func__);
+	if (!reg_8038_l20) {
+		reg_8038_l20 = regulator_get(&mhl_msm_state->i2c_client->dev,
+			"mhl_avcc12");
+		if (IS_ERR(reg_8038_l20)) {
+			pr_err("could not get reg_8038_l20, rc = %ld\n",
+				PTR_ERR(reg_8038_l20));
+			return -ENODEV;
+		}
+		rc = regulator_enable(reg_8038_l20);
+		if (rc) {
+			pr_err("'%s' regulator enable failed, rc=%d\n",
+				"mhl_l20", rc);
+			return rc;
+		} else
+		       pr_debug("REGULATOR L20 ENABLED\n");
+	}
+
+	if (!reg_8038_l11) {
+		reg_8038_l11 = regulator_get(&mhl_msm_state->i2c_client->dev,
+			"mhl_iovcc18");
+		if (IS_ERR(reg_8038_l11)) {
+			pr_err("could not get reg_8038_l11, rc = %ld\n",
+				PTR_ERR(reg_8038_l11));
+			return -ENODEV;
+		}
+		rc = regulator_enable(reg_8038_l11);
+		if (rc) {
+			pr_err("'%s' regulator enable failed, rc=%d\n",
+				"mhl_l11", rc);
+			return rc;
+		} else
+			pr_debug("REGULATOR L11 ENABLED\n");
+	}
+
+	return rc;
+}
+
+
+static void mhl_sii_power_on(void)
+{
+	int ret;
+	pr_debug("MHL SII POWER ON\n");
+	if (!mhl_msm_state->mhl_data->gpio_mhl_power) {
+		pr_warn("%s: no power reqd for this platform\n", __func__);
+		return;
+	}
+
+	ret = gpio_request(mhl_msm_state->mhl_data->gpio_mhl_power, "W_PWR");
+	if (ret < 0) {
+		pr_err("MHL_POWER_GPIO req failed: %d\n",
+			ret);
+		return;
+	}
+	ret = gpio_direction_output(mhl_msm_state->mhl_data->gpio_mhl_power,
+		1);
+	if (ret < 0) {
+		pr_err(
+		"SET GPIO MHL_POWER_GPIO direction failed: %d\n",
+			ret);
+		gpio_free(mhl_msm_state->mhl_data->gpio_mhl_power);
+		return;
+	}
+	gpio_set_value(mhl_msm_state->mhl_data->gpio_mhl_power, 1);
+
+	if (mhl_sii_reg_enable())
+		pr_err("Regulator enable failed\n");
+
+	pr_debug("MHL SII POWER ON Successful\n");
+	return;
+}
+
+/*
+ * Request for GPIO allocations
+ * Set appropriate GPIO directions
+ */
+static int mhl_sii_gpio_setup(int on)
+{
+	int ret;
+	if (on) {
+		if (mhl_msm_state->mhl_data->gpio_hdmi_mhl_mux) {
+			ret = gpio_request(mhl_msm_state->\
+				mhl_data->gpio_hdmi_mhl_mux, "W_MUX");
+			if (ret < 0) {
+				pr_err("GPIO HDMI_MHL MUX req failed:%d\n",
+					ret);
+				return -EBUSY;
+			}
+			ret = gpio_direction_output(
+				mhl_msm_state->mhl_data->gpio_hdmi_mhl_mux, 0);
+			if (ret < 0) {
+				pr_err("SET GPIO HDMI_MHL dir failed:%d\n",
+					ret);
+				gpio_free(mhl_msm_state->\
+					mhl_data->gpio_hdmi_mhl_mux);
+				return -EBUSY;
+			}
+			msleep(50);
+			gpio_set_value(mhl_msm_state->\
+				mhl_data->gpio_hdmi_mhl_mux, 0);
+			pr_debug("SET GPIO HDMI MHL MUX %d to 0\n",
+				mhl_msm_state->mhl_data->gpio_hdmi_mhl_mux);
+		}
+
+		ret = gpio_request(mhl_msm_state->mhl_data->gpio_mhl_reset,
+			"W_RST#");
+		if (ret < 0) {
+			pr_err("GPIO RESET request failed: %d\n", ret);
+			return -EBUSY;
+		}
+		ret = gpio_direction_output(mhl_msm_state->\
+			mhl_data->gpio_mhl_reset, 1);
+		if (ret < 0) {
+			pr_err("SET GPIO RESET direction failed: %d\n", ret);
+			gpio_free(mhl_msm_state->mhl_data->gpio_mhl_reset);
+			gpio_free(mhl_msm_state->mhl_data->gpio_hdmi_mhl_mux);
+			return -EBUSY;
+		}
+		ret = gpio_request(mhl_msm_state->mhl_data->gpio_mhl_int,
+			"W_INT");
+		if (ret < 0) {
+			pr_err("GPIO INT request failed: %d\n", ret);
+			gpio_free(mhl_msm_state->mhl_data->gpio_mhl_reset);
+			gpio_free(mhl_msm_state->mhl_data->gpio_hdmi_mhl_mux);
+			return -EBUSY;
+		}
+		ret = gpio_direction_input(mhl_msm_state->\
+			mhl_data->gpio_mhl_int);
+		if (ret < 0) {
+			pr_err("SET GPIO INTR direction failed: %d\n", ret);
+			gpio_free(mhl_msm_state->mhl_data->gpio_mhl_reset);
+			gpio_free(mhl_msm_state->mhl_data->gpio_mhl_int);
+			gpio_free(mhl_msm_state->mhl_data->gpio_hdmi_mhl_mux);
+			return -EBUSY;
+		}
+	} else {
+		gpio_free(mhl_msm_state->mhl_data->gpio_mhl_reset);
+		gpio_free(mhl_msm_state->mhl_data->gpio_mhl_int);
+		gpio_free(mhl_msm_state->mhl_data->gpio_hdmi_mhl_mux);
+		gpio_free(mhl_msm_state->mhl_data->gpio_mhl_power);
+	}
+
+	return 0;
+}
+
 bool mhl_is_connected(void)
 {
 	return true;
@@ -194,6 +351,11 @@
 
 	/* Power up 1.2V core */
 	mhl_i2c_reg_write(TX_PAGE_L1, 0x003D, 0x3F);
+	/*
+	 * Wait for the source power to be enabled
+	 * before enabling pll clocks.
+	 */
+	msleep(50);
 	/* Enable Tx PLL Clock */
 	mhl_i2c_reg_write(TX_PAGE_2, 0x0011, 0x01);
 	/* Enable Tx Clock Path and Equalizer */
@@ -255,7 +417,7 @@
 	mhl_i2c_reg_write(TX_PAGE_3, 0x0017, 0x82);
 	mhl_i2c_reg_write(TX_PAGE_3, 0x0018, 0x24);
 	/* Pull-up resistance off for IDLE state */
-	mhl_i2c_reg_write(TX_PAGE_3, 0x0013, 0x84);
+	mhl_i2c_reg_write(TX_PAGE_3, 0x0013, 0x8C);
 	/* Enable CBUS Discovery */
 	mhl_i2c_reg_write(TX_PAGE_3, 0x0010, 0x27);
 	mhl_i2c_reg_write(TX_PAGE_3, 0x0016, 0x20);
@@ -282,9 +444,11 @@
 	pr_debug("MHL: chip rev ID read=[%x]\n", mhl_msm_state->chip_rev_id);
 
 	/* Reset the TX chip */
-	mhl_msm_state->mhl_data->reset_pin(0);
+	mhl_sii_reset_pin(1);
 	msleep(20);
-	mhl_msm_state->mhl_data->reset_pin(1);
+	mhl_sii_reset_pin(0);
+	msleep(20);
+	mhl_sii_reset_pin(1);
 	/* MHL spec requires a 100 ms wait here.  */
 	msleep(100);
 
@@ -305,34 +469,40 @@
 static int mhl_i2c_probe(struct i2c_client *client,
 	const struct i2c_device_id *id)
 {
-	int ret;
+	int ret = -ENODEV;
 	mhl_msm_state->mhl_data = kzalloc(sizeof(struct msm_mhl_platform_data),
 		GFP_KERNEL);
 	if (!(mhl_msm_state->mhl_data)) {
 		ret = -ENOMEM;
+		pr_err("MHL I2C Probe failed - no mem\n");
 		goto probe_exit;
 	}
-	pr_debug("Inside probe\n");
 	mhl_msm_state->i2c_client = client;
 
 	spin_lock_init(&mhl_state_lock);
 
 	i2c_set_clientdata(client, mhl_msm_state);
 	mhl_msm_state->mhl_data = client->dev.platform_data;
+	pr_debug("MHL: mhl_msm_state->mhl_data->irq=[%d]\n",
+		mhl_msm_state->mhl_data->irq);
 
 	/* Init GPIO stuff here */
-	ret = mhl_msm_state->mhl_data->gpio_setup(1);
+	ret = mhl_sii_gpio_setup(1);
 	if (ret == -1) {
 		pr_err("MHL: mhl_gpio_init has failed\n");
 		ret = -ENODEV;
 		goto probe_exit;
 	}
+
+	mhl_sii_power_on();
+
+	pr_debug("I2C PROBE successful\n");
 	return 0;
 
 probe_exit:
 	if (mhl_msm_state->mhl_data) {
 		/* free the gpios */
-		mhl_msm_state->mhl_data->gpio_setup(0);
+		mhl_sii_gpio_setup(0);
 		kfree(mhl_msm_state->mhl_data);
 		mhl_msm_state->mhl_data = NULL;
 	}
@@ -341,8 +511,8 @@
 
 static int mhl_i2c_remove(struct i2c_client *client)
 {
-	pr_debug("inside i2c remove\n");
-	mhl_msm_state->mhl_data->gpio_setup(0);
+	pr_debug("%s\n", __func__);
+	mhl_sii_gpio_setup(0);
 	kfree(mhl_msm_state->mhl_data);
 	return 0;
 }
@@ -351,6 +521,7 @@
 {
 	int32_t     ret;
 
+	pr_debug("%s\n", __func__);
 	mhl_msm_state = kzalloc(sizeof(struct mhl_msm_state_t), GFP_KERNEL);
 	if (!mhl_msm_state) {
 		pr_err("mhl_msm_init FAILED: out of memory\n");
@@ -366,11 +537,11 @@
 		goto init_exit;
 	} else {
 		if (mhl_msm_state->i2c_client == NULL) {
-			pr_err("JSR: I2C driver add failed\n");
+			pr_err("MHL: I2C driver add failed\n");
 			ret = -ENODEV;
 			goto init_exit;
 		}
-		pr_debug("MHL: I2C driver added\n");
+		pr_info("MHL: I2C driver added\n");
 	}
 
 	/* Request IRQ stuff here */
@@ -385,7 +556,8 @@
 			ret);
 		ret = -EACCES; /* Error code???? */
 		goto init_exit;
-	}
+	} else
+		pr_debug("request_threaded_irq succeeded\n");
 
 	mhl_msm_state->cur_state = POWER_STATE_D0_MHL;
 
@@ -482,7 +654,8 @@
 	uint8_t val;
 	unsigned long flags;
 
-	pr_err("%s: cur state = [0x%x]\n", __func__, mhl_msm_state->cur_state);
+	pr_debug("%s: cur state = [0x%x]\n", __func__,
+		mhl_msm_state->cur_state);
 
 	if (mhl_msm_state->cur_state == POWER_STATE_D0_MHL) {
 		/* Already in D0 - MHL power state */
@@ -510,7 +683,6 @@
 static void mhl_msm_disconnection(void)
 {
 	uint8_t reg;
-
 	/* Clear interrupts - REG INTR4 */
 	reg = mhl_i2c_reg_read(TX_PAGE_3, 0x0021);
 	mhl_i2c_reg_write(TX_PAGE_3, 0x0021, reg);
@@ -594,7 +766,10 @@
 	 * a previous interrupt brought us here,
 	 * do nothing.
 	 */
-	pr_debug("MHL: MRR Interrupt status is = %02X\n", (int) status);
+	if ((0x00 == status) && (mhl_msm_state->cur_state == POWER_STATE_D3)) {
+		mhl_chip_init();
+		return;
+	}
 	if (0xFF != status) {
 		if ((status & BIT0) && (mhl_msm_state->chip_rev_id < 1)) {
 			uint8_t tmds_cstat;
@@ -624,23 +799,25 @@
 		}
 
 		if (status & BIT1)
-			pr_err("MHL: INT4 BIT1 is set\n");
+			pr_debug("MHL: INT4 BIT1 is set\n");
 
 		/* MHL_EST interrupt */
 		if (status & BIT2) {
-			pr_err("MHL: Calling mhl_msm_connection() from ISR\n");
+			pr_debug("mhl_msm_connection() from ISR\n");
+			mhl_connect_api(true);
 			mhl_msm_connection();
-			pr_err("MHL Connect  Drv: INT4 Status = %02X\n",
+			pr_debug("MHL Connect  Drv: INT4 Status = %02X\n",
 				(int) status);
 		} else if (status & BIT3) {
-			pr_err("MHL: uUSB-A type device detected.\n");
+			pr_debug("MHL: uUSB-A type device detected.\n");
 			mhl_i2c_reg_write(TX_PAGE_3, 0x001C, 0x80);
 			switch_mode(POWER_STATE_D3);
 		}
 
 		if (status & BIT5) {
+			mhl_connect_api(false);
 			mhl_msm_disconnection();
-			pr_err("MHL Disconnect Drv: INT4 Status = %02X\n",
+			pr_debug("MHL Disconn Drv: INT4 Status = %02X\n",
 				(int)status);
 		}
 
@@ -734,7 +911,7 @@
 	if (regval)
 		mhl_i2c_reg_write(TX_PAGE_CBUS, 0x08, regval);
 
-	pr_err("%s: CBUS_INT = %02x\n", __func__, regval);
+	pr_debug("%s: CBUS_INT = %02x\n", __func__, regval);
 
 	/* MSC_MSG (RCP/RAP) */
 	if (regval & BIT(3)) {
@@ -755,7 +932,7 @@
 	if (regval)
 		mhl_i2c_reg_write(TX_PAGE_CBUS, 0x1E, regval);
 
-	pr_err("%s: CBUS_MSC_INT2 = %02x\n", __func__, regval);
+	pr_debug("%s: CBUS_MSC_INT2 = %02x\n", __func__, regval);
 
 	/* received SET_INT */
 	if (regval & BIT(2)) {
@@ -774,9 +951,9 @@
 	if (regval & BIT(3)) {
 		uint8_t stat;
 		stat = mhl_i2c_reg_read(TX_PAGE_CBUS, 0xB0);
-		pr_err("%s: MHL_STATUS_0 = %02x\n", __func__, stat);
+		pr_debug("%s: MHL_STATUS_0 = %02x\n", __func__, stat);
 		stat = mhl_i2c_reg_read(TX_PAGE_CBUS, 0xB1);
-		pr_err("%s: MHL_STATUS_1 = %02x\n", __func__, stat);
+		pr_debug("%s: MHL_STATUS_1 = %02x\n", __func__, stat);
 
 		mhl_i2c_reg_write(TX_PAGE_CBUS, 0xB0, 0xFF);
 		mhl_i2c_reg_write(TX_PAGE_CBUS, 0xB1, 0xFF);
@@ -797,12 +974,6 @@
 static irqreturn_t mhl_tx_isr(int irq, void *dev_id)
 {
 	/*
-	 * Check discovery interrupt
-	 * if not yet connected
-	 */
-	pr_debug("MHL: Current POWER state is [0x%x]\n",
-		mhl_msm_state->cur_state);
-	/*
 	 * Check RGND, MHL_EST, CBUS_LOCKOUT, SCDT
 	 * interrupts. In D3, we get only RGND
 	 */
diff --git a/drivers/video/msm/mhl/mhl_8334.h b/drivers/video/msm/mhl/mhl_8334.h
index c1d9030..eba544a 100644
--- a/drivers/video/msm/mhl/mhl_8334.h
+++ b/drivers/video/msm/mhl/mhl_8334.h
@@ -21,9 +21,6 @@
 #include "mhl_devcap.h"
 #include "mhl_defs.h"
 
-#define GPIO_MHL_RESET       15
-#define GPIO_MHL_INT         4
-
 #define MHL_DEVICE_NAME "sii8334"
 #define MHL_DRIVER_NAME "sii8334"
 
diff --git a/drivers/video/msm/mhl/mhl_i2c_utils.c b/drivers/video/msm/mhl/mhl_i2c_utils.c
index 596af2e..aab6e02 100644
--- a/drivers/video/msm/mhl/mhl_i2c_utils.c
+++ b/drivers/video/msm/mhl/mhl_i2c_utils.c
@@ -15,8 +15,6 @@
 #include "mhl_i2c_utils.h"
 #include "mhl_8334.h"
 
-#define DEBUG
-
 uint8_t slave_addrs[MAX_PAGES] = {
 	DEV_PAGE_TPI_0    ,
 	DEV_PAGE_TX_L0_0  ,
@@ -60,7 +58,7 @@
 		pr_err("I2C READ FAILED=[%d]\n", ret);
 		return -EACCES;
 	}
-	pr_err("Buffer is [%x]\n", buffer);
+	pr_debug("Buffer is [%x]\n", buffer);
 	return buffer;
 }
 
diff --git a/drivers/video/msm/mipi_dsi.c b/drivers/video/msm/mipi_dsi.c
index 1ba1444..ff8fd17 100644
--- a/drivers/video/msm/mipi_dsi.c
+++ b/drivers/video/msm/mipi_dsi.c
@@ -86,6 +86,7 @@
 	 */
 	if (mfd->panel_info.type == MIPI_CMD_PANEL) {
 		if (mdp_rev >= MDP_REV_41) {
+			mdp4_dsi_cmd_del_timer();
 			mdp4_dsi_cmd_dma_busy_wait(mfd);
 			mdp4_dsi_blt_dmap_busy_wait(mfd);
 			mipi_dsi_mdp_busy_wait(mfd);
@@ -119,19 +120,16 @@
 	mdp_bus_scale_update_request(0);
 #endif
 
-	local_bh_disable();
+	spin_lock_bh(&dsi_clk_lock);
 	mipi_dsi_clk_disable();
-	local_bh_enable();
 
 	/* disbale dsi engine */
 	MIPI_OUTP(MIPI_DSI_BASE + 0x0000, 0);
 
 	mipi_dsi_phy_ctrl(0);
 
-
-	local_bh_disable();
 	mipi_dsi_ahb_ctrl(0);
-	local_bh_enable();
+	spin_unlock_bh(&dsi_clk_lock);
 
 	mipi_dsi_unprepare_clocks();
 	if (mipi_dsi_pdata && mipi_dsi_pdata->dsi_power_save)
@@ -173,9 +171,7 @@
 	cont_splash_clk_ctrl(0);
 	mipi_dsi_prepare_clocks();
 
-	local_bh_disable();
 	mipi_dsi_ahb_ctrl(1);
-	local_bh_enable();
 
 	clk_rate = mfd->fbi->var.pixclock;
 	clk_rate = min(clk_rate, mfd->panel_info.clk_max);
@@ -187,9 +183,7 @@
 
 	mipi_dsi_phy_init(0, &(mfd->panel_info), target_type);
 
-	local_bh_disable();
 	mipi_dsi_clk_enable();
-	local_bh_enable();
 
 	MIPI_OUTP(MIPI_DSI_BASE + 0x114, 1);
 	MIPI_OUTP(MIPI_DSI_BASE + 0x114, 0);
diff --git a/drivers/video/msm/mipi_dsi_host.c b/drivers/video/msm/mipi_dsi_host.c
index dbf45b0..7f1a435 100644
--- a/drivers/video/msm/mipi_dsi_host.c
+++ b/drivers/video/msm/mipi_dsi_host.c
@@ -45,6 +45,7 @@
 static int dsi_irq_enabled;
 static spinlock_t dsi_irq_lock;
 static spinlock_t dsi_mdp_lock;
+spinlock_t dsi_clk_lock;
 static int dsi_mdp_busy;
 
 static struct list_head pre_kickoff_list;
@@ -90,6 +91,7 @@
 	mipi_dsi_buf_alloc(&dsi_tx_buf, DSI_BUF_SIZE);
 	spin_lock_init(&dsi_irq_lock);
 	spin_lock_init(&dsi_mdp_lock);
+	spin_lock_init(&dsi_clk_lock);
 
 	INIT_LIST_HEAD(&pre_kickoff_list);
 	INIT_LIST_HEAD(&post_kickoff_list);
@@ -146,18 +148,14 @@
 
 void mipi_dsi_turn_on_clks(void)
 {
-	local_bh_disable();
 	mipi_dsi_ahb_ctrl(1);
 	mipi_dsi_clk_enable();
-	local_bh_enable();
 }
 
 void mipi_dsi_turn_off_clks(void)
 {
-	local_bh_disable();
 	mipi_dsi_clk_disable();
 	mipi_dsi_ahb_ctrl(0);
-	local_bh_enable();
 }
 
 static void mipi_dsi_action(struct list_head *act_list)
diff --git a/drivers/video/msm/msm_fb.c b/drivers/video/msm/msm_fb.c
index 18ee3e6..5f58af7 100644
--- a/drivers/video/msm/msm_fb.c
+++ b/drivers/video/msm/msm_fb.c
@@ -107,6 +107,9 @@
 static int msm_fb_ioctl(struct fb_info *info, unsigned int cmd,
 			unsigned long arg);
 static int msm_fb_mmap(struct fb_info *info, struct vm_area_struct * vma);
+static int mdp_bl_scale_config(struct msm_fb_data_type *mfd,
+						struct mdp_bl_scale_data *data);
+static void msm_fb_scale_bl(__u32 *bl_lvl);
 
 #ifdef MSM_FB_ENABLE_DBGFS
 
@@ -116,6 +119,7 @@
 int msm_fb_debugfs_file_index;
 struct dentry *msm_fb_debugfs_root;
 struct dentry *msm_fb_debugfs_file[MSM_FB_MAX_DBGFS];
+static int bl_scale, bl_min_lvl;
 
 DEFINE_MUTEX(msm_fb_notify_update_sem);
 void msmfb_no_update_notify_timer_cb(unsigned long data)
@@ -372,6 +376,8 @@
 
 	mfd->panel_info.frame_count = 0;
 	mfd->bl_level = 0;
+	bl_scale = 1024;
+	bl_min_lvl = 255;
 #ifdef CONFIG_FB_MSM_OVERLAY
 	mfd->overlay_play_enable = 1;
 #endif
@@ -746,11 +752,41 @@
 
 static int unset_bl_level, bl_updated;
 static int bl_level_old;
+static int mdp_bl_scale_config(struct msm_fb_data_type *mfd,
+						struct mdp_bl_scale_data *data)
+{
+	int ret = 0;
+	int curr_bl = mfd->bl_level;
+	bl_scale = data->scale;
+	bl_min_lvl = data->min_lvl;
+	pr_debug("%s: update scale = %d, min_lvl = %d\n", __func__, bl_scale,
+								bl_min_lvl);
+
+	/* update current backlight to use new scaling*/
+	msm_fb_set_backlight(mfd, curr_bl);
+
+	return ret;
+}
+
+static void msm_fb_scale_bl(__u32 *bl_lvl)
+{
+	__u32 temp = *bl_lvl;
+	if (temp >= bl_min_lvl) {
+		/* bl_scale is the numerator of scaling fraction (x/1024)*/
+		temp = ((*bl_lvl) * bl_scale) / 1024;
+
+		/*if less than minimum level, use min level*/
+		if (temp < bl_min_lvl)
+			temp = bl_min_lvl;
+	}
+
+	(*bl_lvl) = temp;
+}
 
 void msm_fb_set_backlight(struct msm_fb_data_type *mfd, __u32 bkl_lvl)
 {
 	struct msm_fb_panel_data *pdata;
-
+	__u32 temp = bkl_lvl;
 	if (!mfd->panel_power_on || !bl_updated) {
 		unset_bl_level = bkl_lvl;
 		return;
@@ -758,17 +794,19 @@
 		unset_bl_level = 0;
 	}
 
+	msm_fb_scale_bl(&temp);
 	pdata = (struct msm_fb_panel_data *)mfd->pdev->dev.platform_data;
 
 	if ((pdata) && (pdata->set_backlight)) {
 		down(&mfd->sem);
-		if (bl_level_old == bkl_lvl) {
+		if (bl_level_old == temp) {
 			up(&mfd->sem);
 			return;
 		}
-		mfd->bl_level = bkl_lvl;
+		mfd->bl_level = temp;
 		pdata->set_backlight(mfd);
-		bl_level_old = mfd->bl_level;
+		mfd->bl_level = bkl_lvl;
+		bl_level_old = temp;
 		up(&mfd->sem);
 	}
 }
@@ -3133,7 +3171,8 @@
 	return 0;
 }
 
-static int msmfb_handle_pp_ioctl(struct msmfb_mdp_pp *pp_ptr)
+static int msmfb_handle_pp_ioctl(struct msm_fb_data_type *mfd,
+						struct msmfb_mdp_pp *pp_ptr)
 {
 	int ret = -1;
 
@@ -3178,6 +3217,11 @@
 						&pp_ptr->data.qseed_cfg_data);
 		break;
 #endif
+	case mdp_bl_scale_cfg:
+		ret = mdp_bl_scale_config(mfd, (struct mdp_bl_scale_data *)
+				&pp_ptr->data.bl_scale_data);
+		break;
+
 	default:
 		pr_warn("Unsupported request to MDP_PP IOCTL.\n");
 		ret = -EINVAL;
@@ -3496,7 +3540,7 @@
 		if (ret)
 			return ret;
 
-		ret = msmfb_handle_pp_ioctl(&mdp_pp);
+		ret = msmfb_handle_pp_ioctl(mfd, &mdp_pp);
 		break;
 
 	default:
diff --git a/include/linux/cyttsp-qc.h b/include/linux/cyttsp-qc.h
index 0e5cac7..e1ab6fe 100644
--- a/include/linux/cyttsp-qc.h
+++ b/include/linux/cyttsp-qc.h
@@ -356,6 +356,7 @@
 #define CY_DLY_BL			300
 #define CY_DLY_DNLOAD			100	/* ms */
 #define CY_NUM_RETRY			4	/* max num touch data read */
+#define CY_HALF_SEC_TMO_MS		500
 
 /* handshake bit in the hst_mode reg */
 #define CY_HNDSHK_BIT			0x80
diff --git a/include/linux/diagchar.h b/include/linux/diagchar.h
index 4ff1147..fbffdd2 100644
--- a/include/linux/diagchar.h
+++ b/include/linux/diagchar.h
@@ -107,7 +107,7 @@
 
 /* This needs to be modified manually now, when we add
  a new RANGE of SSIDs to the msg_mask_tbl */
-#define MSG_MASK_TBL_CNT		23
+#define MSG_MASK_TBL_CNT		24
 #define EVENT_LAST_ID			0x08AD
 
 #define MSG_SSID_0			0
@@ -156,6 +156,8 @@
 #define MSG_SSID_21_LAST		10300
 #define MSG_SSID_22			10350
 #define MSG_SSID_22_LAST		10361
+#define MSG_SSID_23			0xC000
+#define MSG_SSID_23_LAST		0xC063
 
 struct diagpkt_delay_params {
 	void *rsp_ptr;
diff --git a/include/linux/msm_kgsl.h b/include/linux/msm_kgsl.h
index e67190f..7afc896 100644
--- a/include/linux/msm_kgsl.h
+++ b/include/linux/msm_kgsl.h
@@ -49,8 +49,6 @@
 	KGSL_CTX_STAT_UNKNOWN_CONTEXT_RESET_EXT		= 0x00000003
 };
 
-#define KGSL_MAX_PWRLEVELS 5
-
 #define KGSL_CONVERT_TO_MBPS(val) \
 	(val*1000*1000U)
 
@@ -135,12 +133,6 @@
 	unsigned int flags; /* contains KGSL_FLAGS_ values */
 };
 
-struct kgsl_pwrlevel {
-	unsigned int gpu_freq;
-	unsigned int bus_freq;
-	unsigned int io_fraction;
-};
-
 struct kgsl_version {
 	unsigned int drv_major;
 	unsigned int drv_minor;
@@ -148,50 +140,6 @@
 	unsigned int dev_minor;
 };
 
-#ifdef __KERNEL__
-
-#define KGSL_3D0_REG_MEMORY	"kgsl_3d0_reg_memory"
-#define KGSL_3D0_IRQ		"kgsl_3d0_irq"
-#define KGSL_2D0_REG_MEMORY	"kgsl_2d0_reg_memory"
-#define KGSL_2D0_IRQ		"kgsl_2d0_irq"
-#define KGSL_2D1_REG_MEMORY	"kgsl_2d1_reg_memory"
-#define KGSL_2D1_IRQ		"kgsl_2d1_irq"
-
-enum kgsl_iommu_context_id {
-	KGSL_IOMMU_CONTEXT_USER = 0,
-	KGSL_IOMMU_CONTEXT_PRIV = 1,
-};
-
-struct kgsl_iommu_ctx {
-	const char *iommu_ctx_name;
-	enum kgsl_iommu_context_id ctx_id;
-};
-
-struct kgsl_device_iommu_data {
-	const struct kgsl_iommu_ctx *iommu_ctxs;
-	int iommu_ctx_count;
-	unsigned int physstart;
-	unsigned int physend;
-};
-
-struct kgsl_device_platform_data {
-	struct kgsl_pwrlevel pwrlevel[KGSL_MAX_PWRLEVELS];
-	int init_level;
-	int num_levels;
-	int (*set_grp_async)(void);
-	unsigned int idle_timeout;
-	bool strtstp_sleepwake;
-	unsigned int nap_allowed;
-	unsigned int clk_map;
-	unsigned int idle_needed;
-	struct msm_bus_scale_pdata *bus_scale_table;
-	struct kgsl_device_iommu_data *iommu_data;
-	int iommu_count;
-	struct msm_dcvs_core_info *core_info;
-};
-
-#endif
-
 /* structure holds list of ibs */
 struct kgsl_ibdesc {
 	unsigned int gpuaddr;
diff --git a/include/linux/msm_mdp.h b/include/linux/msm_mdp.h
index 19728fe..d8edbc8 100644
--- a/include/linux/msm_mdp.h
+++ b/include/linux/msm_mdp.h
@@ -434,7 +434,6 @@
 	uint32_t *data;
 };
 
-
 struct mdp_lut_cfg_data {
 	uint32_t lut_type;
 	union {
@@ -452,12 +451,17 @@
 	uint32_t *data;
 };
 
+struct mdp_bl_scale_data {
+	uint32_t min_lvl;
+	uint32_t scale;
+};
 
 enum {
 	mdp_op_pcc_cfg,
 	mdp_op_csc_cfg,
 	mdp_op_lut_cfg,
 	mdp_op_qseed_cfg,
+	mdp_bl_scale_cfg,
 	mdp_op_max,
 };
 
@@ -468,6 +472,7 @@
 		struct mdp_csc_cfg_data csc_cfg_data;
 		struct mdp_lut_cfg_data lut_cfg_data;
 		struct mdp_qseed_cfg_data qseed_cfg_data;
+		struct mdp_bl_scale_data bl_scale_data;
 	} data;
 };
 
diff --git a/include/linux/msm_rotator.h b/include/linux/msm_rotator.h
index 463e5ce..17ae867 100644
--- a/include/linux/msm_rotator.h
+++ b/include/linux/msm_rotator.h
@@ -31,6 +31,7 @@
 	unsigned char   rotations;
 	int enable;
 	unsigned int	downscale_ratio;
+	unsigned int secure;
 };
 
 struct msm_rotator_data_info {
diff --git a/include/linux/usb/android.h b/include/linux/usb/android.h
index bf65ebb..7c2b33b 100644
--- a/include/linux/usb/android.h
+++ b/include/linux/usb/android.h
@@ -21,6 +21,7 @@
 	int (*update_pid_and_serial_num)(uint32_t, const char *);
 	u32 swfi_latency;
 	u8 usb_core_id;
+	bool cdrom;
 };
 
 #endif	/* __LINUX_USB_ANDROID_H */
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 2b14423..eb5a0cc 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -2084,6 +2084,9 @@
 
 	opcode = __le16_to_cpu(ev->opcode);
 
+	if (test_bit(HCI_RESET, &hdev->flags) && (opcode != HCI_OP_RESET))
+		return;
+
 	switch (opcode) {
 	case HCI_OP_INQUIRY_CANCEL:
 		hci_cc_inquiry_cancel(hdev, skb);
diff --git a/sound/soc/msm/apq8064.c b/sound/soc/msm/apq8064.c
index 2da5c6a..a4bc2ef 100644
--- a/sound/soc/msm/apq8064.c
+++ b/sound/soc/msm/apq8064.c
@@ -1339,6 +1339,17 @@
 
 	return 0;
 }
+static int msm_proxy_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);
+
+	pr_debug("%s()\n", __func__);
+	rate->min = rate->max = 48000;
+
+	return 0;
+}
 
 static int msm_aux_pcm_get_gpios(void)
 {
@@ -1764,6 +1775,7 @@
 		.codec_dai_name = "msm-stub-rx",
 		.no_pcm = 1,
 		.be_id = MSM_BACKEND_DAI_AFE_PCM_RX,
+		.be_hw_params_fixup = msm_proxy_be_hw_params_fixup,
 		.ignore_pmdown_time = 1, /* this dainlink has playback support */
 	},
 	{
@@ -1775,6 +1787,7 @@
 		.codec_dai_name = "msm-stub-tx",
 		.no_pcm = 1,
 		.be_id = MSM_BACKEND_DAI_AFE_PCM_TX,
+		.be_hw_params_fixup = msm_proxy_be_hw_params_fixup,
 	},
 	/* AUX PCM Backend DAI Links */
 	{
diff --git a/sound/soc/msm/msm-pcm-routing.c b/sound/soc/msm/msm-pcm-routing.c
index afc14f5..7e8e282 100644
--- a/sound/soc/msm/msm-pcm-routing.c
+++ b/sound/soc/msm/msm-pcm-routing.c
@@ -2446,20 +2446,26 @@
 	{"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_3_RX"},
+	{"BE_OUT", NULL, "SLIMBUS_4_RX"},
 	{"BE_OUT", NULL, "HDMI"},
 	{"BE_OUT", NULL, "MI2S_RX"},
 	{"PRI_I2S_TX", NULL, "BE_IN"},
 	{"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" },
 	{"BE_OUT", NULL, "INT_BT_SCO_RX"},
 	{"INT_BT_SCO_TX", NULL, "BE_IN"},
 	{"BE_OUT", NULL, "INT_FM_RX"},
 	{"INT_FM_TX", NULL, "BE_IN"},
 	{"BE_OUT", NULL, "PCM_RX"},
 	{"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, "SEC_AUX_PCM_RX"},
 	{"SEC_AUX_PCM_TX", NULL, "BE_IN"},
 	{"BE_OUT", NULL, "AUX_PCM_RX"},
diff --git a/sound/soc/msm/msm8960.c b/sound/soc/msm/msm8960.c
index 5de3855..5f8a63e 100644
--- a/sound/soc/msm/msm8960.c
+++ b/sound/soc/msm/msm8960.c
@@ -1042,6 +1042,17 @@
 
 	return 0;
 }
+static int msm8960_proxy_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);
+
+	pr_debug("%s()\n", __func__);
+	rate->min = rate->max = 48000;
+
+	return 0;
+}
 static int msm8960_aux_pcm_get_gpios(void)
 {
 	int ret = 0;
@@ -1407,6 +1418,7 @@
 		.codec_dai_name = "msm-stub-rx",
 		.no_pcm = 1,
 		.be_id = MSM_BACKEND_DAI_AFE_PCM_RX,
+		.be_hw_params_fixup = msm8960_proxy_be_hw_params_fixup,
 		.ignore_pmdown_time = 1, /* this dainlink has playback support */
 	},
 	{
@@ -1418,6 +1430,7 @@
 		.codec_dai_name = "msm-stub-tx",
 		.no_pcm = 1,
 		.be_id = MSM_BACKEND_DAI_AFE_PCM_TX,
+		.be_hw_params_fixup = msm8960_proxy_be_hw_params_fixup,
 	},
 	/* AUX PCM Backend DAI Links */
 	{
@@ -1675,7 +1688,7 @@
 {
 	int ret;
 
-	if (!cpu_is_msm8960()) {
+	if (!cpu_is_msm8960() && !cpu_is_msm8960ab()) {
 		pr_debug("%s: Not the right machine type\n", __func__);
 		return -ENODEV ;
 	}
@@ -1740,7 +1753,7 @@
 
 static void __exit msm8960_audio_exit(void)
 {
-	if (!cpu_is_msm8960()) {
+	if (!cpu_is_msm8960() && !cpu_is_msm8960ab()) {
 		pr_debug("%s: Not the right machine type\n", __func__);
 		return ;
 	}
diff --git a/sound/soc/msm/qdsp6/q6asm.c b/sound/soc/msm/qdsp6/q6asm.c
index 2993e37..59c390e 100644
--- a/sound/soc/msm/qdsp6/q6asm.c
+++ b/sound/soc/msm/qdsp6/q6asm.c
@@ -3406,7 +3406,7 @@
 		pr_err("APR handle NULL\n");
 		return -EINVAL;
 	}
-	q6asm_add_hdr(ac, &hdr, sizeof(hdr), TRUE);
+	q6asm_add_hdr(ac, &hdr, sizeof(hdr), FALSE);
 	hdr.opcode = ASM_SESSION_CMD_GET_SESSION_TIME;
 	atomic_set(&ac->time_flag, 1);
 
diff --git a/sound/soc/msm/qdsp6/q6voice.c b/sound/soc/msm/qdsp6/q6voice.c
index f66a01c..1cf32aa 100644
--- a/sound/soc/msm/qdsp6/q6voice.c
+++ b/sound/soc/msm/qdsp6/q6voice.c
@@ -467,9 +467,9 @@
 			cvs_session_cmd.hdr.opcode =
 				VSS_ISTREAM_CMD_CREATE_PASSIVE_CONTROL_SESSION;
 			if (is_volte_session(v->session_id)) {
-				strlcpy(mvm_session_cmd.mvm_session.name,
+				strlcpy(cvs_session_cmd.cvs_session.name,
 				"default volte voice",
-				sizeof(mvm_session_cmd.mvm_session.name) - 1);
+				sizeof(cvs_session_cmd.cvs_session.name) - 1);
 			} else if (is_sglte_session(v->session_id)) {
 				strlcpy(cvs_session_cmd.cvs_session.name,
 				"default modem voice2",