Patchwork [U-Boot] ARM: Exynos4: ADC: Universal_C210: Enable LDO4 power line for ADC measurement

login
register
mail settings
Submitter Łukasz Majewski
Date March 13, 2012, 8:05 a.m.
Message ID <1331625959-20474-1-git-send-email-l.majewski@samsung.com>
Download mbox | patch
Permalink /patch/146358/
State Changes Requested
Delegated to: Minkyu Kang
Headers show

Comments

Łukasz Majewski - March 13, 2012, 8:05 a.m.
This patch enables LDO4 power line for preparing proper voltages to be
measured by ADC converter.
This measurement is used for determination of target board HW revision.

Test HW:
Universal_C210 (Exynos4210) rev. 0.0

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Cc: Minkyu Kang <mk7.kang@samsung.com>
---
 board/samsung/universal_c210/universal.c |   30 +++++++++++++++++++++++++++---
 include/max8998_pmic.h                   |    1 +
 2 files changed, 28 insertions(+), 3 deletions(-)
Łukasz Majewski - March 26, 2012, 1:20 p.m.
Hi Minkyu,

> This patch enables LDO4 power line for preparing proper voltages to be
> measured by ADC converter.
> This measurement is used for determination of target board HW
> revision.
> 
> Test HW:
> Universal_C210 (Exynos4210) rev. 0.0
> 
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
> Cc: Minkyu Kang <mk7.kang@samsung.com>
> ---

Any opinion/comment about this patch?
Minkyu Kang - March 27, 2012, 6:43 a.m.
Dear Lukasz Majewski,

On 13 March 2012 17:05, Lukasz Majewski <l.majewski@samsung.com> wrote:
> This patch enables LDO4 power line for preparing proper voltages to be
> measured by ADC converter.
> This measurement is used for determination of target board HW revision.
>
> Test HW:
> Universal_C210 (Exynos4210) rev. 0.0
>
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
> Cc: Minkyu Kang <mk7.kang@samsung.com>
> ---
>  board/samsung/universal_c210/universal.c |   30 +++++++++++++++++++++++++++---
>  include/max8998_pmic.h                   |    1 +
>  2 files changed, 28 insertions(+), 3 deletions(-)
>
> diff --git a/board/samsung/universal_c210/universal.c b/board/samsung/universal_c210/universal.c
> index d0ff834..f166c3e 100644
> --- a/board/samsung/universal_c210/universal.c
> +++ b/board/samsung/universal_c210/universal.c
> @@ -58,13 +58,13 @@ int board_init(void)
>        gd->bd->bi_arch_number = MACH_TYPE_UNIVERSAL_C210;
>        gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100;
>
> -       check_hw_revision();
> -       printf("HW Revision:\t0x%x\n", board_rev);
> -
>  #if defined(CONFIG_PMIC)
>        pmic_init();
>  #endif
>
> +       check_hw_revision();
> +       printf("HW Revision:\t0x%x\n", board_rev);
> +
>        return 0;
>  }
>
> @@ -109,10 +109,32 @@ static unsigned short get_adc_value(int channel)
>        return ret;
>  }
>
> +static int adc_power_control(int on)
> +{
> +       int ret;
> +       struct pmic *p = get_pmic();
> +
> +       if (pmic_probe(p))
> +               return -1;
> +
> +       if (on)

need brace at this if statement

> +               ret = pmic_set_output(p,
> +                             MAX8998_REG_ONOFF1,
> +                             MAX8998_LDO4, LDO_ON);
> +       else
> +               ret = pmic_set_output(p,
> +                             MAX8998_REG_ONOFF1,
> +                             MAX8998_LDO4, LDO_OFF);

hm, I think, you don't have to use if statement here.

ret = pmic_set_output(p, MAX8998_REG_ONOFF1, MAX8998_LDO4, !!on);

> +
> +       return ret;
> +}
> +

Thanks
Minkyu Kang.

Patch

diff --git a/board/samsung/universal_c210/universal.c b/board/samsung/universal_c210/universal.c
index d0ff834..f166c3e 100644
--- a/board/samsung/universal_c210/universal.c
+++ b/board/samsung/universal_c210/universal.c
@@ -58,13 +58,13 @@  int board_init(void)
 	gd->bd->bi_arch_number = MACH_TYPE_UNIVERSAL_C210;
 	gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100;
 
-	check_hw_revision();
-	printf("HW Revision:\t0x%x\n", board_rev);
-
 #if defined(CONFIG_PMIC)
 	pmic_init();
 #endif
 
+	check_hw_revision();
+	printf("HW Revision:\t0x%x\n", board_rev);
+
 	return 0;
 }
 
@@ -109,10 +109,32 @@  static unsigned short get_adc_value(int channel)
 	return ret;
 }
 
+static int adc_power_control(int on)
+{
+	int ret;
+	struct pmic *p = get_pmic();
+
+	if (pmic_probe(p))
+		return -1;
+
+	if (on)
+		ret = pmic_set_output(p,
+			      MAX8998_REG_ONOFF1,
+			      MAX8998_LDO4, LDO_ON);
+	else
+		ret = pmic_set_output(p,
+			      MAX8998_REG_ONOFF1,
+			      MAX8998_LDO4, LDO_OFF);
+
+	return ret;
+}
+
 static unsigned int get_hw_revision(void)
 {
 	int hwrev, mode0, mode1;
 
+	adc_power_control(1);
+
 	mode0 = get_adc_value(1);		/* HWREV_MODE0 */
 	mode1 = get_adc_value(2);		/* HWREV_MODE1 */
 
@@ -135,6 +157,8 @@  static unsigned int get_hw_revision(void)
 
 	debug("mode0: %d, mode1: %d, hwrev 0x%x\n", mode0, mode1, hwrev);
 
+	adc_power_control(0);
+
 	return hwrev;
 }
 
diff --git a/include/max8998_pmic.h b/include/max8998_pmic.h
index 10c892a..ca21f88 100644
--- a/include/max8998_pmic.h
+++ b/include/max8998_pmic.h
@@ -75,6 +75,7 @@  enum {
 };
 
 #define MAX8998_LDO3		(1 << 2)
+#define MAX8998_LDO4		(1 << 1)
 #define MAX8998_LDO8		(1 << 5)
 #define MAX8998_SAFEOUT1	(1 << 4)