linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: cbouatmailru@gmail.com (Anton Vorontsov)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 2/3] Add s3c-adc-battery driver
Date: Fri, 9 Jul 2010 19:15:35 +0400	[thread overview]
Message-ID: <20100709151535.GA14644@oksana.dev.rtsoft.ru> (raw)
In-Reply-To: <201007091707.47807.anarsoul@gmail.com>

On Fri, Jul 09, 2010 at 05:07:43PM +0300, Vasily Khoruzhick wrote:
> ? ????????? ?? 9 ???? 2010 16:53:45 ????? Anton Vorontsov ???????:
> > 
> > I guess you can remove all the cable_plugged handling from s3c
> > battery driver, and then use power_supply.external_power_changed
> > callback to get cable_plugged notification (you should fill
> > pda_power.supplied_to properly to make it work).
> > 
> > See drivers/power/ds2760_battery.c and arch/arm/mach-pxa/hx4700.c
> > as an example.
> > 
> > You probably will need to change .external_power_changed() hook
> > to accept 'pst' argument (the supply that caused the change),
> > so that you could write something like this:
> > 
> > s3c_external_power_changed(struct power_supply *psy,
> > 			   struct power_supply *ext)
> > {
> > 	...
> > 	ext->get_property(ext, ONLINE, &val);
> > 	s3c->is_plugged = val.intval;
> > 
> > 	s3c_kick_cable_plugged_handler(s3c);
> > }
> > 
> > Or, instead of ext->get_property() you could just use
> > power_supply_is_system_supplied(). Not very elegant, but
> > should work.
> 
[...reordered...]
> pda_power driver does not support 'battery_charged' pin handling, but I need 
> to handle this pin (and IRQ from it) to prevent battery overcharge

And I was not talking about 'battery_charged' pin handling. :-)
Sure, battery_charged handling should be in the battery driver.

I was talking about 'cable_plugged' handling, it is the only
thing that s3c_adc_ac_get_property() is using, see the driver
you've just posted:

+static int s3c_adc_ac_get_property(struct power_supply *psy,
+                               enum power_supply_property psp,
+                               union power_supply_propval *val)
+{
+       int ret = 0;
+
+       switch (psp) {
+       case POWER_SUPPLY_PROP_ONLINE:
+               val->intval =
+                       !gpio_get_value(main_bat.pdata->gpio_cable_plugged);
+               break;
+       default:
+               ret = -EINVAL;
+               break;
+       }
+       return ret;
+}

And cable_plugged_handler() stays in the battery driver, but it
will be called by the pda_power driver via external_power_changed
callback.

> You didn't get the point. Here's workflow:
> cable plugged -> GPF2 goes to 0, irq is generated

Handled by the pda_power driver.

> cable plugged irq handler -> cable_plugged ? enable_charger : disable_charger

pda_power driver calls power_supply_changed(), which calls
s3c battery.external_power_changed/cable_plugged_handler,
which starts charging (sets is_plugged if
power_supply_is_system_supplied() returns true).

> charging....
> battery is charged, GPF3 goes to 0, irq is generated

Yep, this is handled by the s3c driver.

> battery charged irq handler -> disable_charger

This is still s3c driver's job.

> cable unplugged -> GPF2 goest to 1, irq is generated

Handled by the pda_power driver, it again sends the 'changed'
event to s3c battery driver, and the battery driver
clears is_plugged if power_supply_is_system_supplied() returns
false.

Still think this wont work?

-- 
Anton Vorontsov
email: cbouatmailru at gmail.com
irc://irc.freenode.net/bd2

  reply	other threads:[~2010-07-09 15:15 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-09 11:27 [PATCH 0/3] s3c24xx: iPAQ rx1950 series Vasily Khoruzhick
2010-07-09 11:27 ` [PATCH 1/3] rx1950: add rx1950 LEDs driver Vasily Khoruzhick
2010-07-09 11:27 ` [PATCH 2/3] Add s3c-adc-battery driver Vasily Khoruzhick
2010-07-09 12:57   ` Anton Vorontsov
2010-07-09 13:19     ` Vasily Khoruzhick
2010-07-09 13:53       ` Anton Vorontsov
2010-07-09 14:07         ` Vasily Khoruzhick
2010-07-09 15:15           ` Anton Vorontsov [this message]
2010-07-09 15:32             ` Vasily Khoruzhick
2010-07-09 15:32               ` Vasily Khoruzhick
2010-07-09 11:27 ` [PATCH 3/3] rx1950: add battery device Vasily Khoruzhick

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=20100709151535.GA14644@oksana.dev.rtsoft.ru \
    --to=cbouatmailru@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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;
as well as URLs for NNTP newsgroup(s).