diff mbox

[v2,3/3] RX-51: Add platform data for bq24150a charger

Message ID 1384856285-19593-4-git-send-email-pali.rohar@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Pali Rohár Nov. 19, 2013, 10:18 a.m. UTC
This patch will register bq24150a charger in RX-51 board data.

So finally charging battery on Nokia N900 (RX-51) working
automatically without any proprietary Nokia bits in userspace.

Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
---
 arch/arm/mach-omap2/board-rx51-peripherals.c |   17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

Comments

Pavel Machek Nov. 19, 2013, 1:32 p.m. UTC | #1
On Tue 2013-11-19 11:18:05, Pali Rohár wrote:
> This patch will register bq24150a charger in RX-51 board data.
> 
> So finally charging battery on Nokia N900 (RX-51) working
> automatically without any proprietary Nokia bits in userspace.
> 
> Signed-off-by: Pali Rohár <pali.rohar@gmail.com>

Reviewed-by: Pavel Machek <pavel@ucw.cz>

									Pavel
BTW, current code says:

That seems to limit charging voltage to 3.9V, with comment saying
4.11V... which means battery will not be charged fully. does it make
sense to raise limit to 4.11V here?

Aha, and actually will not 4.2V requested by
rx51_bq24150a_platform_data trigger -EINVAL?

/* set battery regulation voltage in mV */
static int bq2415x_set_battery_regulation_voltage(struct
bq2415x_device *bq,
                                                  int mV)
{
        int val = (mV/10 - 350) / 2;

        if (val < 0)
                val = 0;
        else if (val > 94) /* FIXME: Max is 94 or 122 ? Set max value
                ? */
                return -EINVAL;

        return bq2415x_i2c_write_mask(bq, BQ2415X_REG_VOLTAGE, val,
                        BQ2415X_MASK_VO, BQ2415X_SHIFT_VO);
}

> --- a/arch/arm/mach-omap2/board-rx51-peripherals.c
> +++ b/arch/arm/mach-omap2/board-rx51-peripherals.c
> @@ -1275,6 +1276,16 @@ static struct aic3x_pdata rx51_aic3x_data2 = {
>  	.gpio_reset = 60,
>  };
>  
> +static struct bq2415x_platform_data rx51_bq24150a_platform_data = {
> +	.current_limit = 100,			/* mA */
> +	.weak_battery_voltage = 3400,		/* mV */
> +	.battery_regulation_voltage = 4200,	/* mV */
> +	.charge_current = 650,			/* mA */
> +	.termination_current = 100,		/* mA */
> +	.resistor_sense = 68,			/* m ohm */
> +	.notify_device = "isp1704",
> +};
> +
>  static struct i2c_board_info __initdata rx51_peripherals_i2c_board_info_2[] = {
>  	{
>  		I2C_BOARD_INFO("tlv320aic3x", 0x18),
Pali Rohár Nov. 24, 2013, 10:28 a.m. UTC | #2
On Tuesday 19 November 2013 14:32:13 Pavel Machek wrote:
> On Tue 2013-11-19 11:18:05, Pali Rohár wrote:
> > This patch will register bq24150a charger in RX-51 board
> > data.
> > 
> > So finally charging battery on Nokia N900 (RX-51) working
> > automatically without any proprietary Nokia bits in
> > userspace.
> > 
> > Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
> 
> Reviewed-by: Pavel Machek <pavel@ucw.cz>
> 
> 									Pavel
> BTW, current code says:
> 
> That seems to limit charging voltage to 3.9V, with comment
> saying 4.11V... which means battery will not be charged
> fully. does it make sense to raise limit to 4.11V here?
> 
> Aha, and actually will not 4.2V requested by
> rx51_bq24150a_platform_data trigger -EINVAL?
> 
> /* set battery regulation voltage in mV */
> static int bq2415x_set_battery_regulation_voltage(struct
> bq2415x_device *bq,
>                                                   int mV)
> {
>         int val = (mV/10 - 350) / 2;
> 
>         if (val < 0)
>                 val = 0;
>         else if (val > 94) /* FIXME: Max is 94 or 122 ? Set
> max value ? */
>                 return -EINVAL;
> 
>         return bq2415x_i2c_write_mask(bq, BQ2415X_REG_VOLTAGE,
> val, BQ2415X_MASK_VO, BQ2415X_SHIFT_VO); }
> 

Above bq2415x_set_battery_regulation_voltage function is updated 
in 3.13, see commit 3ed5cd79b82e9a055e0df3275eeb471ea0f1e2d7.
diff mbox

Patch

diff --git a/arch/arm/mach-omap2/board-rx51-peripherals.c b/arch/arm/mach-omap2/board-rx51-peripherals.c
index 70fcaff..95e6638 100644
--- a/arch/arm/mach-omap2/board-rx51-peripherals.c
+++ b/arch/arm/mach-omap2/board-rx51-peripherals.c
@@ -25,6 +25,7 @@ 
 #include <linux/gpio_keys.h>
 #include <linux/mmc/host.h>
 #include <linux/power/isp1704_charger.h>
+#include <linux/power/bq2415x_charger.h>
 #include <linux/platform_data/spi-omap2-mcspi.h>
 #include <linux/platform_data/mtd-onenand-omap2.h>
 #include <linux/hsi/hsi.h>
@@ -1275,6 +1276,16 @@  static struct aic3x_pdata rx51_aic3x_data2 = {
 	.gpio_reset = 60,
 };
 
+static struct bq2415x_platform_data rx51_bq24150a_platform_data = {
+	.current_limit = 100,			/* mA */
+	.weak_battery_voltage = 3400,		/* mV */
+	.battery_regulation_voltage = 4200,	/* mV */
+	.charge_current = 650,			/* mA */
+	.termination_current = 100,		/* mA */
+	.resistor_sense = 68,			/* m ohm */
+	.notify_device = "isp1704",
+};
+
 static struct i2c_board_info __initdata rx51_peripherals_i2c_board_info_2[] = {
 	{
 		I2C_BOARD_INFO("tlv320aic3x", 0x18),
@@ -1302,7 +1313,11 @@  static struct i2c_board_info __initdata rx51_peripherals_i2c_board_info_2[] = {
 	{
 		I2C_BOARD_INFO("tpa6130a2", 0x60),
 		.platform_data = &rx51_tpa6130a2_data,
-	}
+	},
+	{
+		I2C_BOARD_INFO("bq24150a", 0x6b),
+		.platform_data = &rx51_bq24150a_platform_data,
+	},
 };
 
 static struct i2c_board_info __initdata rx51_peripherals_i2c_board_info_3[] = {