Merge "platform: msm8916: added missing FBC macro"
diff --git a/include/platform.h b/include/platform.h
index a76c68b..c2fac94 100644
--- a/include/platform.h
+++ b/include/platform.h
@@ -60,4 +60,6 @@
 uint32_t platform_get_sclk_count(void);
 void clock_config_cdc(uint32_t interface);
 int platform_is_msm8939();
+int platform_is_msm8909();
+int boot_device_mask(int);
 #endif
diff --git a/platform/apq8084/platform.c b/platform/apq8084/platform.c
index cf13b5a..923588d 100644
--- a/platform/apq8084/platform.c
+++ b/platform/apq8084/platform.c
@@ -167,3 +167,8 @@
 	/* Using 1-1 mapping on this platform. */
 	return phys_addr;
 }
+
+int boot_device_mask(int val)
+{
+	return ((val & 0x3E) >> 1);
+}
diff --git a/platform/msm8909/platform.c b/platform/msm8909/platform.c
index 1ea030a..6479681 100644
--- a/platform/msm8909/platform.c
+++ b/platform/msm8909/platform.c
@@ -184,3 +184,27 @@
 		return MSM_SHARED_BASE;
 }
 
+int platform_is_msm8909()
+{
+	uint32_t platform = board_platform_id();
+	uint32_t ret = 0;
+
+	switch(platform)
+	{
+		case MSM8909:
+		case MSM8209:
+		case MSM8208:
+		case APQ8009:
+			ret = 1;
+			break;
+		default:
+			ret = 0;
+	};
+
+	return ret;
+}
+
+int boot_device_mask(int val)
+{
+	return ((val & 0x0E) >> 1);
+}
diff --git a/platform/msm8994/platform.c b/platform/msm8994/platform.c
index 8c6d5f4..e2e3aa8 100644
--- a/platform/msm8994/platform.c
+++ b/platform/msm8994/platform.c
@@ -182,3 +182,8 @@
 	else
 		return ((addr_t)BS_INFO_ADDR2);
 }
+
+int boot_device_mask(int val)
+{
+	return ((val & 0x3E) >> 1);
+}
diff --git a/platform/msm_shared/include/boot_device.h b/platform/msm_shared/include/boot_device.h
index 1f195b9..ad17f75 100644
--- a/platform/msm_shared/include/boot_device.h
+++ b/platform/msm_shared/include/boot_device.h
@@ -30,11 +30,12 @@
 #define __BOOT_DEVICE_H
 
 #include <sys/types.h>
+#include <platform.h>
 
 #if USE_MDM_BOOT_CFG
 #define BOOT_DEVICE_MASK(val)   ((val & 0x1E) >> 1)
 #else
-#define BOOT_DEVICE_MASK(val)   ((val & 0x3E) >> 1)
+#define BOOT_DEVICE_MASK(val)   boot_device_mask(val)
 #endif
 
 /* Boot device */
diff --git a/project/msm8909.mk b/project/msm8909.mk
index b0e0cf0..007499a 100644
--- a/project/msm8909.mk
+++ b/project/msm8909.mk
@@ -14,7 +14,7 @@
 
 EMMC_BOOT := 1
 
-#ENABLE_SMD_SUPPORT := 1
+ENABLE_SMD_SUPPORT := 1
 ENABLE_PWM_SUPPORT := true
 #ENABLE_BOOT_CONFIG_SUPPORT := 1
 
diff --git a/target/msm8909/regulator.c b/target/msm8909/regulator.c
new file mode 100644
index 0000000..e421b42
--- /dev/null
+++ b/target/msm8909/regulator.c
@@ -0,0 +1,94 @@
+/* Copyright (c) 2014, The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *     * Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ *       copyright notice, this list of conditions and the following
+ *       disclaimer in the documentation and/or other materials provided
+ *       with the distribution.
+ *     * Neither the name of The Linux Fundation, Inc. nor the names of its
+ *       contributors may be used to endorse or promote products derived
+ *       from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#include <regulator.h>
+#include <rpm-smd.h>
+#include <debug.h>
+
+static uint32_t ldo2[][11]=
+{
+	{
+		LDOA_RES_TYPE, 2,
+		KEY_SOFTWARE_ENABLE, 4, GENERIC_DISABLE,
+		KEY_MICRO_VOLT, 4, 0,
+		KEY_CURRENT, 4, 0,
+	},
+
+	{
+		LDOA_RES_TYPE, 2,
+		KEY_SOFTWARE_ENABLE, 4, GENERIC_ENABLE,
+		KEY_MICRO_VOLT, 4, 1200000,
+		KEY_CURRENT, 4, 40,
+	},
+};
+
+static uint32_t ldo6[][11]=
+{
+	{
+		LDOA_RES_TYPE, 6,
+		KEY_SOFTWARE_ENABLE, 4, GENERIC_DISABLE,
+		KEY_MICRO_VOLT, 4, 0,
+		KEY_CURRENT, 4, 0,
+	},
+
+	{
+		LDOA_RES_TYPE, 6,
+		KEY_SOFTWARE_ENABLE, 4, GENERIC_ENABLE,
+		KEY_MICRO_VOLT, 4, 1800000,
+		KEY_CURRENT, 4, 150,
+	},
+};
+
+
+static uint32_t ldo17[][11]=
+{
+	{
+		LDOA_RES_TYPE, 17,
+		KEY_SOFTWARE_ENABLE, 4, GENERIC_DISABLE,
+		KEY_MICRO_VOLT, 4, 0,
+		KEY_CURRENT, 4, 0,
+	},
+
+	{
+		LDOA_RES_TYPE, 17,
+		KEY_SOFTWARE_ENABLE, 4, GENERIC_ENABLE,
+		KEY_MICRO_VOLT, 4, 2850000,
+		KEY_CURRENT, 4, 40,
+	},
+};
+
+void regulator_enable()
+{
+	rpm_send_data(&ldo2[GENERIC_ENABLE][0], 36, RPM_REQUEST_TYPE);
+
+	rpm_send_data(&ldo17[GENERIC_ENABLE][0], 36, RPM_REQUEST_TYPE);
+
+	rpm_send_data(&ldo6[GENERIC_ENABLE][0], 36, RPM_REQUEST_TYPE);
+
+}
diff --git a/target/msm8909/rules.mk b/target/msm8909/rules.mk
index b076247..5753859 100644
--- a/target/msm8909/rules.mk
+++ b/target/msm8909/rules.mk
@@ -35,3 +35,8 @@
 	$(LOCAL_DIR)/meminfo.o \
 	$(LOCAL_DIR)/target_display.o \
 	$(LOCAL_DIR)/oem_panel.o
+
+ifeq ($(ENABLE_SMD_SUPPORT),1)
+OBJS += \
+    $(LOCAL_DIR)/regulator.o
+endif