Patchwork [U-Boot,v5,20/26] arm:trats:pmic: Support for charging battery at Samsung's TRATS board

login
register
mail settings
Submitter Łukasz Majewski
Date Nov. 5, 2012, 5:28 p.m.
Message ID <1352136508-14198-21-git-send-email-l.majewski@samsung.com>
Download mbox | patch
Permalink /patch/197248/
State Superseded
Delegated to: Minkyu Kang
Headers show

Comments

Łukasz Majewski - Nov. 5, 2012, 5:28 p.m.
The battery connected to Samsung's Trats development board is now
charged when voltage drops below threshold.

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>
---
Changes for v2:
- Define separate *p_{} pointer instances for each power device available
  at Trats
- Only basic checks performed
- Core responsible for battery charging moved to separate file -
  ./drivers/power/bat_trats.c

Changes for v3:
- change code according to struct pmic redesign
Changes for v4:
- None
Changes for v5:
- None
---
 board/samsung/trats/trats.c |   29 +++++++++++++++++++++++++++++
 1 files changed, 29 insertions(+), 0 deletions(-)
Minkyu Kang - Nov. 8, 2012, 10:17 a.m.
On 06/11/12 02:28, Lukasz Majewski wrote:
> The battery connected to Samsung's Trats development board is now
> charged when voltage drops below threshold.
> 
> 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>
> ---
> Changes for v2:
> - Define separate *p_{} pointer instances for each power device available
>   at Trats
> - Only basic checks performed
> - Core responsible for battery charging moved to separate file -
>   ./drivers/power/bat_trats.c
> 
> Changes for v3:
> - change code according to struct pmic redesign
> Changes for v4:
> - None
> Changes for v5:
> - None
> ---
>  board/samsung/trats/trats.c |   29 +++++++++++++++++++++++++++++
>  1 files changed, 29 insertions(+), 0 deletions(-)
> 
> diff --git a/board/samsung/trats/trats.c b/board/samsung/trats/trats.c
> index a8a97bf..8252a00 100644
> --- a/board/samsung/trats/trats.c
> +++ b/board/samsung/trats/trats.c
> @@ -281,12 +281,41 @@ static int pmic_init_max8997(void)
>  
>  int power_init_board(void)
>  {
> +	int chrg;
> +	struct power_battery *pb;
> +	struct pmic *p_fg, *p_chrg, *p_muic, *p_bat;

space here?

>  	pmic_init(I2C_5);
>  
>  	pmic_init_max8997();
>  	power_fg_init(I2C_9);
>  	power_muic_init(I2C_5);
>  	power_bat_init(0);
> +	p_fg = pmic_get("MAX17042_FG");
> +	p_chrg = pmic_get("MAX8997_PMIC");
> +	p_muic = pmic_get("MAX8997_MUIC");
> +	p_bat = pmic_get("BAT_TRATS");
> +
> +	p_fg->parent =  p_bat;
> +	p_chrg->parent = p_bat;
> +	p_muic->parent = p_bat;
> +
> +	p_bat->low_power_mode = trats_low_power_mode;
> +	p_bat->pbat->battery_init(p_bat, p_fg, p_chrg, p_muic);
> +
> +	pb = p_bat->pbat;
> +	chrg = p_muic->chrg->chrg_type(p_muic);
> +	debug("CHARGER TYPE: %d\n", chrg);
> +
> +	if (!p_chrg->chrg->chrg_bat_present(p_chrg)) {
> +		puts("No battery detected\n");
> +		return -1;
> +	}
> +
> +	p_fg->fg->fg_battery_check(p_fg, p_bat);
> +
> +	if (pb->bat->state == CHARGE && chrg == CHARGER_USB)
> +		puts("CHARGE Battery !\n");
> +
>  	return 0;
>  }
>  
> 

Acked-by: Minkyu Kang <mk7.kang@samsung.com>

Thanks.
Minkyu Kang.
Łukasz Majewski - Nov. 8, 2012, 10:49 a.m.
Hi Minkyu,

> On 06/11/12 02:28, Lukasz Majewski wrote:
> > The battery connected to Samsung's Trats development board is now
> > charged when voltage drops below threshold.
> > 
> > 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>
> > ---
> > Changes for v2:
> > - Define separate *p_{} pointer instances for each power device
> > available at Trats
> > - Only basic checks performed
> > - Core responsible for battery charging moved to separate file -
> >   ./drivers/power/bat_trats.c
> > 
> > Changes for v3:
> > - change code according to struct pmic redesign
> > Changes for v4:
> > - None
> > Changes for v5:
> > - None
> > ---
> >  board/samsung/trats/trats.c |   29 +++++++++++++++++++++++++++++
> >  1 files changed, 29 insertions(+), 0 deletions(-)
> > 
> > diff --git a/board/samsung/trats/trats.c
> > b/board/samsung/trats/trats.c index a8a97bf..8252a00 100644
> > --- a/board/samsung/trats/trats.c
> > +++ b/board/samsung/trats/trats.c
> > @@ -281,12 +281,41 @@ static int pmic_init_max8997(void)
> >  
> >  int power_init_board(void)
> >  {
> > +	int chrg;
> > +	struct power_battery *pb;
> > +	struct pmic *p_fg, *p_chrg, *p_muic, *p_bat;
> 
> space here?

I will add space here.

> 
> >  	pmic_init(I2C_5);
> >  
> >  	pmic_init_max8997();
> >  	power_fg_init(I2C_9);
> >  	power_muic_init(I2C_5);
> >  	power_bat_init(0);
> > +	p_fg = pmic_get("MAX17042_FG");
> > +	p_chrg = pmic_get("MAX8997_PMIC");
> > +	p_muic = pmic_get("MAX8997_MUIC");
> > +	p_bat = pmic_get("BAT_TRATS");
> > +
> > +	p_fg->parent =  p_bat;
> > +	p_chrg->parent = p_bat;
> > +	p_muic->parent = p_bat;
> > +
> > +	p_bat->low_power_mode = trats_low_power_mode;
> > +	p_bat->pbat->battery_init(p_bat, p_fg, p_chrg, p_muic);
> > +
> > +	pb = p_bat->pbat;
> > +	chrg = p_muic->chrg->chrg_type(p_muic);
> > +	debug("CHARGER TYPE: %d\n", chrg);
> > +
> > +	if (!p_chrg->chrg->chrg_bat_present(p_chrg)) {
> > +		puts("No battery detected\n");
> > +		return -1;
> > +	}
> > +
> > +	p_fg->fg->fg_battery_check(p_fg, p_bat);
> > +
> > +	if (pb->bat->state == CHARGE && chrg == CHARGER_USB)
> > +		puts("CHARGE Battery !\n");
> > +
> >  	return 0;
> >  }
> >  
> > 
> 
> Acked-by: Minkyu Kang <mk7.kang@samsung.com>
> 
> Thanks.
> Minkyu Kang.
>

Patch

diff --git a/board/samsung/trats/trats.c b/board/samsung/trats/trats.c
index a8a97bf..8252a00 100644
--- a/board/samsung/trats/trats.c
+++ b/board/samsung/trats/trats.c
@@ -281,12 +281,41 @@  static int pmic_init_max8997(void)
 
 int power_init_board(void)
 {
+	int chrg;
+	struct power_battery *pb;
+	struct pmic *p_fg, *p_chrg, *p_muic, *p_bat;
 	pmic_init(I2C_5);
 
 	pmic_init_max8997();
 	power_fg_init(I2C_9);
 	power_muic_init(I2C_5);
 	power_bat_init(0);
+	p_fg = pmic_get("MAX17042_FG");
+	p_chrg = pmic_get("MAX8997_PMIC");
+	p_muic = pmic_get("MAX8997_MUIC");
+	p_bat = pmic_get("BAT_TRATS");
+
+	p_fg->parent =  p_bat;
+	p_chrg->parent = p_bat;
+	p_muic->parent = p_bat;
+
+	p_bat->low_power_mode = trats_low_power_mode;
+	p_bat->pbat->battery_init(p_bat, p_fg, p_chrg, p_muic);
+
+	pb = p_bat->pbat;
+	chrg = p_muic->chrg->chrg_type(p_muic);
+	debug("CHARGER TYPE: %d\n", chrg);
+
+	if (!p_chrg->chrg->chrg_bat_present(p_chrg)) {
+		puts("No battery detected\n");
+		return -1;
+	}
+
+	p_fg->fg->fg_battery_check(p_fg, p_bat);
+
+	if (pb->bat->state == CHARGE && chrg == CHARGER_USB)
+		puts("CHARGE Battery !\n");
+
 	return 0;
 }