CHROMIUM: exynos: enable ADCs only if there are used
authorVincent Palatin <vpalatin@chromium.org>
Wed, 6 Feb 2013 19:05:28 +0000 (11:05 -0800)
committerChromeBot <chrome-bot@google.com>
Fri, 8 Feb 2013 00:54:56 +0000 (16:54 -0800)
Check the presence of an ADC node in the device tree before activating
the ADCs and the NTP thermistors connected to them.

Signed-off-by: Vincent Palatin <vpalatin@chromium.org>
BUG=chrome-os-partner:16430
TEST=on Spring with SLSI PMIC, boot with adc node de-activated and
doesn't see any ADC related panic.
on Snow, boot and check the thermistor temperatures in sysfs.

Change-Id: I1603d78805a8d0877c137b92bcd2c64cbb32564d
Reviewed-on: https://gerrit.chromium.org/gerrit/42868
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
arch/arm/mach-exynos/mach-exynos5-dt.c

index afb76e3..eab7d41 100644 (file)
@@ -939,13 +939,16 @@ static struct platform_device *smdk5250_devices[] __initdata = {
 #ifdef CONFIG_DRM_EXYNOS_HDMI
        &exynos_drm_hdmi_device,
 #endif
+#ifdef CONFIG_BUSFREQ_OPP
+       &exynos5_busfreq,
+#endif
+};
+
+static struct platform_device *thermistor_devices[] __initdata = {
        &s3c_device_adc_ntc_thermistor0,
        &s3c_device_adc_ntc_thermistor1,
        &s3c_device_adc_ntc_thermistor2,
        &s3c_device_adc_ntc_thermistor3,
-#ifdef CONFIG_BUSFREQ_OPP
-       &exynos5_busfreq,
-#endif
 };
 
 static struct regulator_consumer_supply dummy_supplies[] = {
@@ -1168,13 +1171,19 @@ static void __init exynos5250_dt_machine_init(void)
 #endif
        s5p_tv_setup();
 
-       /* Enable power to ADC */
-       __raw_writel(0x1, S5P_ADC_PHY_CONTROL);
+       np = of_find_compatible_node(NULL, NULL, "samsung,exynos5-adc");
+       if (np && of_device_is_available(np)) {
+               /* Enable power to ADC */
+               __raw_writel(0x1, S5P_ADC_PHY_CONTROL);
 
-       s3c_adc_ntc_init(&s3c_device_adc_ntc_thermistor0);
-       s3c_adc_ntc_init(&s3c_device_adc_ntc_thermistor1);
-       s3c_adc_ntc_init(&s3c_device_adc_ntc_thermistor2);
-       s3c_adc_ntc_init(&s3c_device_adc_ntc_thermistor3);
+               s3c_adc_ntc_init(&s3c_device_adc_ntc_thermistor0);
+               s3c_adc_ntc_init(&s3c_device_adc_ntc_thermistor1);
+               s3c_adc_ntc_init(&s3c_device_adc_ntc_thermistor2);
+               s3c_adc_ntc_init(&s3c_device_adc_ntc_thermistor3);
+
+               platform_add_devices(thermistor_devices,
+                                    ARRAY_SIZE(thermistor_devices));
+       }
 
 #ifdef CONFIG_BUSFREQ_OPP
        dev_add(&busfreq, &exynos5_busfreq.dev);