mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Grazvydas Ignotas <notasas@gmail.com>
To: felipe.balbi@nokia.com
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Anton Vorontsov <avorontsov@ru.mvista.com>,
	Madhusudhan Chikkature <madhu.cr@ti.com>,
	"linux-omap@vger.kernel.org" <linux-omap@vger.kernel.org>
Subject: Re: [PATCH] power_supply: Add driver for TWL4030/TPS65950 BCI charger
Date: Wed, 2 Dec 2009 22:34:00 +0200	[thread overview]
Message-ID: <6ed0b2680912021234x6b5e6058p6d50d5cd20ecf019@mail.gmail.com> (raw)
In-Reply-To: <20091202173321.GA23738@nokia.com>

On Wed, Dec 2, 2009 at 7:33 PM, Felipe Balbi <felipe.balbi@nokia.com> wrote:
> Hi,
>
> On Fri, Nov 27, 2009 at 03:44:20PM +0100, ext Grazvydas Ignotas wrote:
>>
>> diff --git a/drivers/power/Makefile b/drivers/power/Makefile
>> index b96f29d..9cea9b5 100644
>> --- a/drivers/power/Makefile
>> +++ b/drivers/power/Makefile
>> @@ -29,3 +29,4 @@ obj-$(CONFIG_BATTERY_BQ27x00) += bq27x00_battery.o
>> obj-$(CONFIG_BATTERY_DA9030)   += da9030_battery.o
>> obj-$(CONFIG_BATTERY_MAX17040) += max17040_battery.o
>> obj-$(CONFIG_CHARGER_PCF50633) += pcf50633-charger.o
>> +obj-$(CONFIG_CHARGER_TWL4030)  += twl4030_charger.o
>> diff --git a/drivers/power/twl4030_charger.c
>> b/drivers/power/twl4030_charger.c
>> new file mode 100644
>> index 0000000..604dd56
>> --- /dev/null
>> +++ b/drivers/power/twl4030_charger.c
>> @@ -0,0 +1,499 @@
>> +/*
>> + * TWL4030/TPS65950 BCI (Battery Charger Interface) driver
>> + *
>> + * Copyright (C) 2009 Gražvydas Ignotas <notasas@gmail.com>
>> + *
>> + * based on twl4030_bci_battery.c by TI
>> + * Copyright (C) 2008 Texas Instruments, Inc.
>> + *
>> + * This program is free software; you can redistribute it and/or modify
>> + * it under the terms of the GNU General Public License as published by
>> + * the Free Software Foundation; either version 2 of the License, or
>> + * (at your option) any later version.
>> + */
>> +
>> +#include <linux/init.h>
>> +#include <linux/module.h>
>> +#include <linux/platform_device.h>
>> +#include <linux/interrupt.h>
>> +#include <linux/i2c/twl4030.h>
>> +#include <linux/power_supply.h>
>> +
>> +#define REG_BCIMSTATEC         0x02
>
> please prepend these defines with e.g. TWL4030_BCI_
>
> this would look like:
>
> #define TWL4030_BCI_MSTATEC     0x02

ok

<snip>

>> +
>> +#define BCI_DELAY              100
>
> 100ms ??? that's too quick for battery monitoring. Imagine that you'll have
> 10 i2c transfers per-second forever with this one. Don't you think you're
> waking up omap for nothing ??

The work item doesn't queue itself, so this is only used once after
every interrupt. The delay itself is needed because charge state
machine needs some time to switch states and is not yet in expected
state at the time VBUS/AC detect interrupt kicks.

> something like 1 second when doing heavy operation should be enough and 5 to
> 10 seconds in idle is good enough as well.
>
>> +static struct twl4030_bci_device_info twl4030_bci = {
>
> this should be allocated on probe() time.

I need to access it from twl4030charger_usb_en().. Could only leave
delayed_work global and allocate everything else in probe() if you
prefer that.

>
>> +/*
>> + * called by TWL4030 USB transceiver driver on USB_PRES interrupt.
>> + */
>> +int twl4030charger_usb_en(int enable)
>> +{
>> +       if (twl4030_bci.started)
>> +               schedule_delayed_work(&twl4030_bci.bat_work,
>> +                       msecs_to_jiffies(BCI_DELAY));
>
> I don't like the way you did this. I would expect twl4030-usb to kick the
> charger detection based on the VBUS irq. You have to consider the
> possibility of boards which won't use BCI module and will have some bq24xxx
> chip dealing with that like RX51. So instead of implementing this here and
> forcing people to have this driver enabled on e.g. RX51, you should
> implement the charger_enable_usb() logic in twl4030-usb itself. /me thinks

I don't think charging is twl4030-usb's business, also notifying
power_supply core about charge state changes that I do here.

What about just returning early from twl4030charger_usb_en() if this
driver is not started? TWL4030-core requires twl4030_bci_platform_data
to be present to even register this driver, so it won't start on RX51.
RX51 can also choose not to compile this driver in, then
twl4030charger_usb_en() call won't even be done fom twl4030-usb.

>
>> +static int __devinit twl4030_bci_probe(struct platform_device *pdev)
>> +{
>> +       int irq;
>> +       int ret;
>> +
>> +       twl4030_charger_enable_ac(true);
>> +       twl4030_charger_enable_usb(true);
>> +
>> +       irq = platform_get_irq(pdev, 0);
>> +
>> +       /* CHG_PRES irq */
>> +       ret = request_irq(irq, twl4030_charger_interrupt,
>> +               0, pdev->name, &twl4030_bci);
>
> how about using request_threaded_irq() ?? then you avoid having that
> workqueue.

I need to do some delayed processing after VBUS/AC detect interrupts
kick, delayed_work looked perfect for this. Also note that I can't get
USB_PRES interrupt (taken by twl4030-usb), only a callback from
twl4030-usb.

>
> --
> balbi
>

  reply	other threads:[~2009-12-02 20:33 UTC|newest]

Thread overview: 74+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-27 14:44 Grazvydas Ignotas
2009-11-27 14:54 ` Anton Vorontsov
2009-11-27 15:47   ` Grazvydas Ignotas
2009-11-27 16:23     ` Mark Brown
2009-11-30 18:45 ` Madhusudhan
2009-11-30 18:58   ` Anton Vorontsov
2009-12-02 20:38     ` Grazvydas Ignotas
2009-12-02 21:27       ` Anton Vorontsov
2009-12-02 21:32         ` Grazvydas Ignotas
2009-11-30 21:33   ` Grazvydas Ignotas
2009-12-02 16:59     ` Madhusudhan
2009-12-02 17:33 ` Felipe Balbi
2009-12-02 20:34   ` Grazvydas Ignotas [this message]
2009-12-02 20:49     ` Felipe Balbi
2009-12-02 21:29       ` Grazvydas Ignotas
2009-12-02 21:54         ` Anton Vorontsov
2009-12-02 22:31           ` Felipe Balbi
2009-12-02 22:59             ` Anton Vorontsov
2009-12-03  8:39               ` Felipe Balbi
2009-12-03 10:55                 ` Grazvydas Ignotas
2009-12-03 11:03                   ` Felipe Balbi
2009-12-10 14:09                     ` Grazvydas Ignotas
2009-12-10 14:18                       ` Anton Vorontsov
2009-12-10 14:21                         ` Felipe Balbi
2009-12-10 14:44                           ` Anton Vorontsov
2009-12-10 16:51                             ` Felipe Balbi
2009-12-10 20:51                               ` Grazvydas Ignotas
2009-12-11 11:31                                 ` [RFC/PATCH 0/5] usb transceiver notifier Felipe Balbi
2009-12-11 11:31                                 ` [RFC/PATCH 1/5] usb: otg: add notifier support Felipe Balbi
2009-12-11 11:55                                   ` Mark Brown
2009-12-11 11:58                                     ` Felipe Balbi
2010-01-26 11:16                                   ` David Brownell
2010-01-26 13:11                                     ` Mark Brown
2010-01-26 13:35                                       ` David Brownell
2010-01-26 14:14                                         ` Felipe Balbi
2010-01-26 14:24                                           ` Oliver Neukum
2010-01-26 14:30                                             ` Felipe Balbi
2010-01-26 15:16                                               ` David Brownell
2010-01-26 15:21                                           ` David Brownell
2010-01-26 18:50                                             ` Felipe Balbi
2010-01-26 14:21                                         ` Mark Brown
2010-01-26 15:44                                           ` David Brownell
2010-01-26 16:13                                             ` Mark Brown
2010-01-26 14:10                                     ` Felipe Balbi
2010-01-26 14:19                                       ` Felipe Balbi
2010-01-26 15:33                                         ` David Brownell
2010-01-26 15:07                                       ` David Brownell
2010-01-26 19:09                                         ` Felipe Balbi
2010-01-26 19:15                                           ` Felipe Balbi
2009-12-11 11:31                                 ` [RFC/PATCH 2/5] usb: otg: twl4030: add support for notifier Felipe Balbi
2009-12-11 17:22                                   ` sai pavan
2009-12-11 20:40                                     ` Felipe Balbi
2009-12-12 18:34                                       ` Mark Brown
2009-12-14 10:30                                         ` [RFC/PATCH 0/4] twl4030 threaded_irq support Felipe Balbi
2010-01-26  7:06                                           ` David Brownell
2010-01-26  7:36                                             ` David Brownell
2010-01-26 10:07                                             ` Mark Brown
2010-01-26 11:02                                             ` Felipe Balbi
2010-01-26 12:18                                               ` David Brownell
2009-12-14 10:30                                         ` [RFC/PATCH 1/4] input: keyboard: twl4030: move to request_threaded_irq Felipe Balbi
2009-12-14 10:30                                         ` [RFC/PATCH 2/4] input: misc: " Felipe Balbi
2009-12-14 11:31                                           ` Shilimkar, Santosh
2009-12-14 11:40                                             ` Felipe Balbi
2009-12-14 13:16                                               ` Shilimkar, Santosh
2009-12-14 10:30                                         ` [RFC/PATCH 3/4] rtc: " Felipe Balbi
2009-12-14 10:30                                         ` [RFC/PATCH 4/4] usb: otg: " Felipe Balbi
2009-12-11 11:31                                 ` [RFC/PATCH 3/5] usb: musb: add support for ulpi block Felipe Balbi
2009-12-11 11:31                                 ` [RFC/PATCH 4/5] usb: musb: isp1704: add registers from isp1704 Felipe Balbi
2009-12-11 12:35                                   ` Krogerus Heikki (EXT-Teleca/Helsinki)
2009-12-11 12:57                                     ` Felipe Balbi
2009-12-11 11:31                                 ` [RFC/PATCH 5/5] usb: musb: musb supports otg notifier Felipe Balbi
2009-12-11 11:40                                   ` Felipe Balbi
2009-12-30 19:07                             ` [PATCH] power_supply: Add driver for TWL4030/TPS65950 BCI charger Madhusudhan
2009-12-10 14:19                       ` Felipe Balbi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6ed0b2680912021234x6b5e6058p6d50d5cd20ecf019@mail.gmail.com \
    --to=notasas@gmail.com \
    --cc=avorontsov@ru.mvista.com \
    --cc=felipe.balbi@nokia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=madhu.cr@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®