devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sebastian Reichel <sre@kernel.org>
To: Matt Ranostay <matt@ranostay.consulting>
Cc: Tony Lindgren <tony@atomide.com>,
	devicetree@vger.kernel.org, linux-pm@vger.kernel.org
Subject: Re: [PATCH v2 3/3] power: bq27xxx: add support for NVRAM R/W access
Date: Fri, 6 Jan 2017 18:28:59 +0100	[thread overview]
Message-ID: <20170106172858.wro233hduyecou5p@earth> (raw)
In-Reply-To: <CAJ_EiSQjRn=rot7Zu+oB80DruN0qexd+3_PxjXS6_JaF7CY1Bw@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 3093 bytes --]

Hi,

On Thu, Jan 05, 2017 at 07:23:48PM -0800, Matt Ranostay wrote:
> On Thu, Jan 5, 2017 at 6:34 PM, Matt Ranostay <matt@ranostay.consulting> wrote:
> > On Thu, Jan 5, 2017 at 5:53 PM, Sebastian Reichel <sre@kernel.org> wrote:
> >> On Wed, Jan 04, 2017 at 06:10:07PM -0800, Matt Ranostay wrote:
> >>> Initial support for access and modification of the non-volatile regions
> >>> of the bq27425 fuel gauge DesignEnergy, DesignCapacity, and
> >>> TerminateVoltage settings.
> >>>
> >>> This is intended for fine tuning the fuel gauge state machine for the
> >>> respective battery specifications.
> >>>
> >>> Cc: Sebastian Reichel <sre@kernel.org>
> >>> Signed-off-by: Matt Ranostay <matt@ranostay.consulting>
> >>> ---
> >>>  drivers/power/supply/bq27xxx_battery_i2c.c | 335 +++++++++++++++++++++++++++++
> >>>  include/linux/power/bq27xxx_battery.h      |   4 +
> >>>  2 files changed, 339 insertions(+)
> >>
> >> I only skipped over this one, as the changed DT binding requires
> >> quite some changes in this patch anyways. Here are a couple of
> >> comments how I would like to see this implemented:
> >>
> >> Add a patch for the power-supply core, which implements a
> >> structure for the battery info. Something like this:
> >>
> >> struct power_supply_battery_info {
> >>     uint32 energy; /* µWh */
> >>     uint32 power;  /* µAh */
> >>     uint32 nominal_voltage; /* µV */
> >>     /* ... */
> >> };
> >>
> >> And a function in the core framework, which gets the information
> >> from DT. The function itself should *not* be DT specific, so that
> >> ACPI/platformdata/whatever support can be added later without
> >> modifying every single driver.
> >>
> >> static struct power_supply_battery_info*
> >> power_supply_get_battery_info(struct power_supply *psy) {
> >>     if (psy->dt) {
> >>         /* get battery phandle or return -ENXIO */
> >>         /* fill and return struct */
> >>     }
> >>
> >>     return -ENOTSUP;
> >> }
> >>
> >> Then call power_supply_get_battery_info() during bq27xxx probe and
> >> use the struct to initialize the registers. Also I expect that
> >> functionality in bq27xxx_battery.c instead of bq27xxx_battery_i2c.c,
> >> since it's not I²C specific.
> >
> > They may not be i2c specific but they are only used by the i2c path of
> > the code currently. Do you think that platform data would ever have a
> > struct to pass with the respective data?

I think it is possible, that there will be some non-i2c bq27xxx
device in the future, that needs this feature.

> > Also it would have to be in bq27xxx_battery_setup() and not
> > bq27xxx_battery_platform_probe() since the former is only thing called
> > by both code paths.

bq27xxx_battery_setup is fine.

> Also there is no bq27xxx_battery_platform_write to even write the
> configuration data.

Just check if the callback exists.

The plan is to convert the 1wire bq27xxx to regmap at some point, so
that the bus-specific bq27xxx files can be dropped by just using
regmap in the core bq27xxx driver.

-- Sebastian

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2017-01-06 17:28 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-05  2:10 [PATCH v2 0/3] power: bq27xxx: add support for NVRAM R/W access Matt Ranostay
     [not found] ` <20170105021007.22088-1-matt-sk+viVC6FLCDq+mSdOJa79kegs52MxvZ@public.gmane.org>
2017-01-05  2:10   ` [PATCH v2 1/3] devicetree: property-units: add mWh and mAh units Matt Ranostay
     [not found]     ` <20170105021007.22088-2-matt-sk+viVC6FLCDq+mSdOJa79kegs52MxvZ@public.gmane.org>
2017-01-06  0:24       ` Sebastian Reichel
2017-01-09 17:53     ` Rob Herring
2017-01-05  2:10   ` [PATCH v2 2/3] devicetree: bq27425: add documentation for bq27425 fuel gauge Matt Ranostay
2017-01-06  0:56     ` Sebastian Reichel
     [not found]     ` <20170105021007.22088-3-matt-sk+viVC6FLCDq+mSdOJa79kegs52MxvZ@public.gmane.org>
2017-01-09 17:53       ` Rob Herring
2017-01-05  2:10 ` [PATCH v2 3/3] power: bq27xxx: add support for NVRAM R/W access Matt Ranostay
     [not found]   ` <20170105021007.22088-4-matt-sk+viVC6FLCDq+mSdOJa79kegs52MxvZ@public.gmane.org>
2017-01-06  1:53     ` Sebastian Reichel
2017-01-06  2:34       ` Matt Ranostay
2017-01-06  3:23         ` Matt Ranostay
2017-01-06 17:28           ` Sebastian Reichel [this message]
2017-01-06  3:50     ` kbuild test robot

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=20170106172858.wro233hduyecou5p@earth \
    --to=sre@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=matt@ranostay.consulting \
    --cc=tony@atomide.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;
as well as URLs for NNTP newsgroup(s).