msm: board-8930: Add regulator board file for MSM8930+PM8917

Add the board file board-8930-regulator-pm8917.c to capture
regulator configuration and mappings for MSM8930 targets which
utilize a PM8917.  Add code into other MSM8930 board files to
conditionally switch to the new regulator configuration values
if PM8917 is detected at runtime.

Change-Id: I68c1025bae45d77d1a04a8935dc7ecb2d857b8ef
Signed-off-by: David Collins <collinsd@codeaurora.org>
(cherry picked from commit 4614cb939178736abca452d468bd291272afbf86)
diff --git a/arch/arm/mach-msm/board-8930.c b/arch/arm/mach-msm/board-8930.c
index 889f6f1..5313fbd 100644
--- a/arch/arm/mach-msm/board-8930.c
+++ b/arch/arm/mach-msm/board-8930.c
@@ -2150,7 +2150,7 @@
 	.name	= "saw-regulator",
 	.id	= 0,
 	.dev	= {
-		.platform_data = &msm8930_saw_regulator_core0_pdata,
+		.platform_data = &msm8930_pm8038_saw_regulator_core0_pdata,
 	},
 };
 
@@ -2158,7 +2158,7 @@
 	.name	= "saw-regulator",
 	.id	= 1,
 	.dev	= {
-		.platform_data = &msm8930_saw_regulator_core1_pdata,
+		.platform_data = &msm8930_pm8038_saw_regulator_core1_pdata,
 	},
 };
 
@@ -2215,8 +2215,8 @@
 	.name	= GPIO_REGULATOR_DEV_NAME,
 	.id	= 63,
 	.dev	= {
-		.platform_data =
-		     &msm8930_gpio_regulator_pdata[MSM8930_GPIO_VREG_ID_EXT_5V],
+		.platform_data = &msm8930_pm8038_gpio_regulator_pdata[
+					MSM8930_GPIO_VREG_ID_EXT_5V],
 	},
 };
 
@@ -2224,8 +2224,8 @@
 	.name	= GPIO_REGULATOR_DEV_NAME,
 	.id	= 97,
 	.dev	= {
-		.platform_data =
-		 &msm8930_gpio_regulator_pdata[MSM8930_GPIO_VREG_ID_EXT_OTG_SW],
+		.platform_data = &msm8930_pm8038_gpio_regulator_pdata[
+					MSM8930_GPIO_VREG_ID_EXT_OTG_SW],
 	},
 };
 
@@ -2238,18 +2238,22 @@
 #ifndef MSM8930_PHASE_2
 		.platform_data = &msm_rpm_regulator_pdata,
 #else
-		.platform_data = &msm8930_rpm_regulator_pdata,
+		.platform_data = &msm8930_pm8038_rpm_regulator_pdata,
 #endif
 	},
 };
 
-static struct platform_device *common_devices[] __initdata = {
+static struct platform_device *early_common_devices[] __initdata = {
 	&msm8960_device_dmov,
 	&msm_device_smd,
 	&msm8960_device_uart_gsbi5,
 	&msm_device_uart_dm6,
 	&msm_device_saw_core0,
 	&msm_device_saw_core1,
+};
+
+/* ext_5v and ext_otg_sw are present when using PM8038 */
+static struct platform_device *pmic_pm8038_devices[] __initdata = {
 	&msm8930_device_ext_5v_vreg,
 #ifndef MSM8930_PHASE_2
 	&msm8930_device_ext_l2_vreg,
@@ -2258,6 +2262,14 @@
 #ifdef MSM8930_PHASE_2
 	&msm8930_device_ext_otg_sw_vreg,
 #endif
+};
+
+/* ext_5v and ext_otg_sw are not present when using PM8917 */
+static struct platform_device *pmic_pm8917_devices[] __initdata = {
+	&msm8960_device_ssbi_pmic,
+};
+
+static struct platform_device *common_devices[] __initdata = {
 	&msm_8960_q6_lpass,
 	&msm_8960_q6_mss_fw,
 	&msm_8960_q6_mss_sw,
@@ -2650,6 +2662,14 @@
 
 	gpio_keys_8930_pdata.buttons = keys_8930_pm8917;
 	gpio_keys_8930_pdata.nbuttons = ARRAY_SIZE(keys_8930_pm8917);
+
+	msm_device_saw_core0.dev.platform_data
+		= &msm8930_pm8038_saw_regulator_core0_pdata;
+	msm_device_saw_core1.dev.platform_data
+		= &msm8930_pm8038_saw_regulator_core1_pdata;
+
+	msm8930_device_rpm_regulator.dev.platform_data
+		= &msm8930_pm8917_rpm_regulator_pdata;
 }
 
 static void __init msm8930_cdp_init(void)
@@ -2706,6 +2726,14 @@
 		platform_device_register(&msm8930_device_acpuclk);
 	else if (cpu_is_msm8930aa())
 		platform_device_register(&msm8930aa_device_acpuclk);
+	platform_add_devices(early_common_devices,
+				ARRAY_SIZE(early_common_devices));
+	if (socinfo_get_pmic_model() != PMIC_MODEL_PM8917)
+		platform_add_devices(pmic_pm8038_devices,
+					ARRAY_SIZE(pmic_pm8038_devices));
+	else
+		platform_add_devices(pmic_pm8917_devices,
+					ARRAY_SIZE(pmic_pm8917_devices));
 	platform_add_devices(common_devices, ARRAY_SIZE(common_devices));
 	msm8930_add_vidc_device();
 	/*