Re: [PATCH] power: support for Texas Instruments BQ27x00 batterymanagers.

From: Rodolfo Giometti
Date: Fri Jun 20 2008 - 02:14:44 EST


Hello,

before answering to other questions I'd like solve the following
issue.

On Fri, Jun 20, 2008 at 03:34:11AM +0400, Anton Vorontsov wrote:

> To avoid these ifdefs, I would suggest you to reconsider the model
> of this driver. How about:
>
> - drivers/power/bq27x00_battery.c:
>
> Registers two platform_drivers, first is "bq27200-bat" (I2C) and
> second is "bq27000-bat" (W1). Both are using the same probe and
> remove methods. This driver will simply register power_supply
> and will do all battery logic, separated from the underlaying
> bus.
>
> (Two platform drivers are used simply because underlaying
> I2C/W1 drivers will not know each other, thus will not able to
> pass uniqe platform_device.id in case of single driver).
>
> - include/linux/bq27x00-battery.h:
>
> Declares
> struct bq27x00_access_methods {
> /*
> * dev argument is I2C or W1 device, battery driver will use
> * platform_device->dev.parent to pass the dev argument.
> */
> int (*read)(struct device *dev, u8 reg, int *rt_value, int b_single);
> };

Where this function should be defined? Can you explain better what you
mean?

>
> - drivers/i2c/chips/bq27200.c:
>
> This driver will do all I2C stuff, and then will register
> "bq27200-bat" platform device, with .platform_data pointed
> to the allocated and filled "struct bq27x00_access_methods".
>
> - drivers/w1/slaves/bq27000.c:
>
> This driver will do all W1 stuff, and then will register
> "bq27000-bat" platform device, with .platform_data pointed
> to the allocated and filled "struct bq27x00_access_methods".
>
> Will this (not) work?

As you can see at the top of the file I based this work an previour
work by Texas Instruments people which never goes into linux vanilla
but lives into linux-omap tree. I just fixed some basic issue which
prevent the driver to compile and work properly and repropose the
driver here.

My hardware just uses the I2C chip version so I cannot test the W1 one
at all. If you agree I can remove the W1 code and provide the
bq27200.c driver only.

Maybe, as you suggested above, we can try to write the code in order
that a future W1 driver writer can write few lines. :)

Ciao,

Rodolfo

--

GNU/Linux Solutions e-mail: giometti@xxxxxxxxxxxx
Linux Device Driver giometti@xxxxxxxx
Embedded Systems phone: +39 349 2432127
UNIX programming skype: rodolfo.giometti
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/