From: "Pali Rohár" <pali.rohar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Pavel Machek <pavel-+ZI9xUNit7I@public.gmane.org>
Cc: sre-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
kernel list
<linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
linux-arm-kernel
<linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org>,
linux-omap-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org,
khilman-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
aaro.koskinen-X3B1VOXEql0@public.gmane.org,
ivo.g.dimitrov.75-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
patrikbachan-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
serge-A9i7LUbDfNHQT0dZR+AlfA@public.gmane.org,
abcloriens-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
clayton-fehKsxFhGzZIf6P1QZMOBw@public.gmane.org,
martijn-28JJ9oSIdodmR6Xm/wNWPw@public.gmane.org,
sakari.ailus-VuQAYsv1563Yd54FQh9/CA@public.gmane.org,
afd-l0cyMroinI0@public.gmane.org,
kernel-RYWXG+zxWwBdeoIcmNTgJF6hYfS7NtTn@public.gmane.org,
devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org
Subject: Re: [PATCH] Add support for bq27521 battery monitor
Date: Thu, 9 Nov 2017 22:52:36 +0100 [thread overview]
Message-ID: <20171109215236.ntmrgoobrs5k7ufh@pali> (raw)
In-Reply-To: <20171109214540.GB23376@amd>
On Thursday 09 November 2017 22:45:40 Pavel Machek wrote:
> On Thu 2017-11-09 22:29:45, Pali Rohár wrote:
> > On Thursday 09 November 2017 22:06:15 Pavel Machek wrote:
> > > diff --git a/drivers/power/supply/bq27xxx_battery.c b/drivers/power/supply/bq27xxx_battery.c
> > > index ed44439..ee2851a 100644
> > > --- a/drivers/power/supply/bq27xxx_battery.c
> > > +++ b/drivers/power/supply/bq27xxx_battery.c
> > > @@ -381,6 +381,30 @@ static u8 bq27xxx_regs[][BQ27XXX_REG_MAX] = {
> > > [BQ27XXX_REG_AP] = INVALID_REG_ADDR,
> > > BQ27XXX_DM_REG_ROWS,
> > > },
> > > + [BQ27521] = { /* FIXME */
> > > + [BQ27XXX_REG_CTRL] = 0x02,
> > > + [BQ27XXX_REG_TEMP] = 0x0a,
> > > + [BQ27XXX_REG_INT_TEMP] = INVALID_REG_ADDR,
> > > + [BQ27XXX_REG_VOLT] = 0x0c,
> > > + [BQ27XXX_REG_AI] = 0x0e,
> > > + [BQ27XXX_REG_FLAGS] = 0x08,
> > > + [BQ27XXX_REG_TTE] = INVALID_REG_ADDR,
> > > + [BQ27XXX_REG_TTF] = INVALID_REG_ADDR,
> > > + [BQ27XXX_REG_TTES] = INVALID_REG_ADDR,
> > > + [BQ27XXX_REG_TTECP] = INVALID_REG_ADDR,
> > > + [BQ27XXX_REG_NAC] = INVALID_REG_ADDR,
> > > + [BQ27XXX_REG_FCC] = INVALID_REG_ADDR,
> > > + [BQ27XXX_REG_CYCT] = INVALID_REG_ADDR,
> > > + [BQ27XXX_REG_AE] = INVALID_REG_ADDR,
> > > + [BQ27XXX_REG_SOC] = INVALID_REG_ADDR,
> > > + [BQ27XXX_REG_DCAP] = INVALID_REG_ADDR,
> > > + [BQ27XXX_REG_AP] = INVALID_REG_ADDR,
> > > + [BQ27XXX_DM_CTRL] = INVALID_REG_ADDR,
> > > + [BQ27XXX_DM_CLASS] = INVALID_REG_ADDR,
> > > + [BQ27XXX_DM_BLOCK] = INVALID_REG_ADDR,
> > > + [BQ27XXX_DM_DATA] = INVALID_REG_ADDR,
> > > + [BQ27XXX_DM_CKSUM] = INVALID_REG_ADDR,
> > > + },
> > > [BQ27530] = {
> > > [BQ27XXX_REG_CTRL] = 0x00,
> > > [BQ27XXX_REG_TEMP] = 0x06,
> >
> > Hi! IIRC those registers are valid only for sn27521 chip in revision 14
> > (or new). For older revision is used different register map. And
> > detection of chip revision is somehow possible via some registers.
>
> Yes, I know.. I even had this, but as I can't test it, and early N950
> samples should be very very rare, I'd prefer the patch as is.
>
> @@ -1905,6 +1940,23 @@ int bq27xxx_battery_setup(struct bq27xxx_device_info *di)
>
> dev_info(di->dev, "support ver. %s enabled\n", DRIVER_VERSION);
>
> + if (di->chip == BQ27521) {
> + int val;
> + val = di->bus.read(di, 0x32, false);
> + if (val == 0x2100) {
> + printk("rev. 13 chip detected; add support\n");
> + /* https://elinux.org/N950 has details */
> + return PTR_ERR(ENODEV);
> + }
> +
> + val = di->bus.read(di, 0x34, false);
> + if ((val & 0xff00) != 0x2100) {
> + printk("rev. 14 chip not detected?!\n");
> + return PTR_ERR(EINVAL);
> + }
> + printk("verified chip rev. 14\n");
> + }
> +
> bq27xxx_battery_settings(di);
> bq27xxx_battery_update(di);
This change could be useful, specially if somebody got device with
sn27521 chip which is not in revision 14 (no idea if in world are those
chips used) -- at least would get message that current driver does not
support it.
--
Pali Rohár
pali.rohar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2017-11-09 21:52 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-09 21:06 [PATCH] Add support for bq27521 battery monitor Pavel Machek
2017-11-09 21:29 ` Pali Rohár
2017-11-09 21:45 ` Pavel Machek
2017-11-09 21:52 ` Pali Rohár [this message]
2017-11-10 10:39 ` [PATCH v4.14] " Pavel Machek
2017-12-01 23:06 ` Pavel Machek
2017-12-04 15:20 ` Andrew F. Davis
[not found] ` <cfa89227-e08a-849f-c886-723268ae657c-l0cyMroinI0@public.gmane.org>
2017-12-08 17:06 ` Sebastian Reichel
2017-12-13 8:39 ` Lithium battery protection was " Pavel Machek
2017-11-15 19:20 ` [PATCH] " Rob Herring
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=20171109215236.ntmrgoobrs5k7ufh@pali \
--to=pali.rohar-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
--cc=aaro.koskinen-X3B1VOXEql0@public.gmane.org \
--cc=abcloriens-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=afd-l0cyMroinI0@public.gmane.org \
--cc=clayton-fehKsxFhGzZIf6P1QZMOBw@public.gmane.org \
--cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=ivo.g.dimitrov.75-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=kernel-RYWXG+zxWwBdeoIcmNTgJF6hYfS7NtTn@public.gmane.org \
--cc=khilman-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-omap-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=martijn-28JJ9oSIdodmR6Xm/wNWPw@public.gmane.org \
--cc=patrikbachan-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=pavel-+ZI9xUNit7I@public.gmane.org \
--cc=robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=sakari.ailus-VuQAYsv1563Yd54FQh9/CA@public.gmane.org \
--cc=serge-A9i7LUbDfNHQT0dZR+AlfA@public.gmane.org \
--cc=sre-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.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).