All of lore.kernel.org
 help / color / mirror / Atom feed
From: Liam Breck <liam@networkimprov.net>
To: "Andrew F. Davis" <afd@ti.com>
Cc: Sebastian Reichel <sre@kernel.org>,
	linux-pm@vger.kernel.org,
	Matt Ranostay <matt@ranostay.consulting>,
	Liam Breck <kernel@networkimprov.net>
Subject: Re: [PATCH v7 8/9] power: bq27xxx_battery: Add print_dm() to log chip memory
Date: Wed, 22 Feb 2017 13:36:09 -0800	[thread overview]
Message-ID: <CAKvHMgS-1+P2LcW=USftbLb-Bd84wHZ1YR5kZFe0jAZY9G91rA@mail.gmail.com> (raw)
In-Reply-To: <c8f3b791-abe8-6993-c760-92303f7e2867@ti.com>

On Wed, Feb 22, 2017 at 12:39 PM, Andrew F. Davis <afd@ti.com> wrote:
> On 02/21/2017 03:30 PM, Liam Breck wrote:
>> From: Liam Breck <kernel@networkimprov.net>
>>
>
> Do you prefer kernel@ or liam@, you should probably pick one and use it
> uniformly.
>
> This patch is nice for debugging, but not upstreamable, it is full of
> checkpatch and formatting issues, it should probably just be dropped
> from this series.

Your hw developer customers will want this.

It's up to you whether every line of code in bq27xxx must fit the
format guidelines. I can adjust the format. Or leave it in commented
out?

>> Enable listing of chip RAM and/or NVM at startup, for debugging use.
>> Intially supports BQ27425 State NVM, subclass 82.
>> Support for other chips may be added.
>>
>> Signed-off-by: Liam Breck <kernel@networkimprov.net>
>> ---
>>  drivers/power/supply/bq27xxx_battery.c | 51 ++++++++++++++++++++++++++++++++++
>>  1 file changed, 51 insertions(+)
>>
>> diff --git a/drivers/power/supply/bq27xxx_battery.c b/drivers/power/supply/bq27xxx_battery.c
>> index 8085d4a..bfb3aa9 100644
>> --- a/drivers/power/supply/bq27xxx_battery.c
>> +++ b/drivers/power/supply/bq27xxx_battery.c
>> @@ -664,6 +664,55 @@ static int bq27xxx_battery_read_dm_block(struct bq27xxx_device_info *di,
>>       return ret;
>>  }
>>
>> +/* Translate f4 floating point values to/from hexadecimal:
>> + *   perl -e 'printf("%08x\n", unpack("I", pack("f", 3.93e-4   )))' # 39ce0b91
>> + *   perl -e 'printf("%f\n"  , unpack("f", pack("I", 0x39ce0b91)))' # 0.000393
>> + */
>> +
>> +#define BQ27XXX_REG(f,o,v) dev_info(di->dev, "offset %d, " f "\n", o, v)
>> +
>> +static void bq27xxx_battery_print_dm(struct bq27xxx_device_info *di) {
>> +     enum { h1, h2, i2, u1, f4 };
>> +
>> +     struct dm_reg { int offset, type; }
>> +             /* each array row describes one data block */
>> +             c425_s82[][10] = {
>> +                     { { 2,h1},{ 3,i2},{ 5,h2},{12,i2},{14,i2},{18,i2},{22,i2},{29,u1},{30,i2},{99,0} },
>> +                     { {32,i2},{34,i2},{36,i2},{38,u1},{39,u1},{40,f4},{99,0} },
>> +             };
>> +             /* add more subclass maps here */
>> +
>> +     struct dm_class { int id, len; struct dm_reg (*reg)[10]; }
>> +             c425[] = {
>> +                     { .id = 82, .len = 2, .reg = c425_s82 },
>> +             };
>> +             /* add more chip maps here */
>> +
>> +     struct dm_class *chip = c425; /* set to your chip */
>> +
>> +     struct bq27xxx_dm_buf buf = { };
>> +     int c, b, r;
>> +     for (c=0; c < 1; ++c) {
>> +             buf.class = chip[c].id;
>> +             dev_info(di->dev, "subclass %d registers...\n", chip[c].id);
>> +             for (b=0; b < chip[c].len; ++b) {
>> +                     buf.block = b;
>> +                     bq27xxx_battery_read_dm_block(di, &buf);
>> +                     for (r=0; chip[c].reg[b][r].offset != 99; ++r) {
>> +                             int o = chip[c].reg[b][r].offset;
>> +                             u8* p = &buf.a[o % sizeof buf.a];
>> +                             switch (chip[c].reg[b][r].type) {
>> +                             case h1: BQ27XXX_REG("%02x", o,      *p); break;
>> +                             case h2: BQ27XXX_REG("%04x", o,      be16_to_cpup((u16*)p)); break;
>> +                             case i2: BQ27XXX_REG("%d",   o, (s16)be16_to_cpup((u16*)p)); break;
>> +                             case u1: BQ27XXX_REG("%u",   o,      *p); break;
>> +                             case f4: BQ27XXX_REG("%08x", o,      be32_to_cpup((u32*)p)); break;
>> +                             }
>> +                     }
>> +             }
>> +     }
>> +}
>> +
>>  static void bq27xxx_battery_print_config(struct bq27xxx_device_info *di)
>>  {
>>       struct bq27xxx_dm_reg *reg = bq27xxx_dm_regs[di->chip];
>> @@ -683,6 +732,8 @@ static void bq27xxx_battery_print_config(struct bq27xxx_device_info *di)
>>               else
>>                       dev_warn(di->dev, "unsupported config register %s\n", str);
>>       }
>> +     /* bq27xxx_battery_print_dm(di); uncomment for debugging */
>> +     (void)bq27xxx_battery_print_dm; /* prevent compiler warning */
>>  }
>>
>>  static void bq27xxx_battery_update_dm_block(struct bq27xxx_device_info *di,
>>

  reply	other threads:[~2017-02-22 21:36 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-21 21:29 [PATCH v7 0/9] devicetree battery support and client bq27xxx_battery Liam Breck
     [not found] ` <20170221213008.30044-1-liam-RYWXG+zxWwBdeoIcmNTgJF6hYfS7NtTn@public.gmane.org>
2017-02-21 21:30   ` [PATCH v7 1/9] devicetree: power: Add battery.txt Liam Breck
     [not found]     ` <20170221213008.30044-2-liam-RYWXG+zxWwBdeoIcmNTgJF6hYfS7NtTn@public.gmane.org>
2017-02-22 20:05       ` Andrew F. Davis
     [not found]         ` <bd747560-8780-3294-86dd-f7f7f4de1736-l0cyMroinI0@public.gmane.org>
2017-02-22 21:39           ` Liam Breck
2017-02-21 21:30   ` [PATCH v7 3/9] devicetree: power: bq27xxx: Add monitored-battery documentation Liam Breck
2017-02-21 21:30 ` [PATCH v7 2/9] devicetree: property-units: Add uWh and uAh units Liam Breck
2017-02-21 21:30   ` Liam Breck
2017-02-21 21:30 ` [PATCH v7 4/9] power: power_supply: Add power_supply_battery_info and API Liam Breck
2017-02-21 21:30 ` [PATCH v7 5/9] power: bq27xxx_battery: Define access methods to write chip registers Liam Breck
2017-02-21 21:30 ` [PATCH v7 6/9] power: bq27xxx_battery: Add BQ27425 chip id Liam Breck
2017-02-22 20:15   ` Andrew F. Davis
2017-02-21 21:30 ` [PATCH v7 7/9] power: bq27xxx_battery: Add power_supply_battery_info support Liam Breck
2017-02-22 20:35   ` Andrew F. Davis
2017-02-22 21:29     ` Liam Breck
2017-02-23  0:30       ` Andrew F. Davis
2017-02-23  0:54         ` Liam Breck
2017-02-23 15:17           ` Andrew F. Davis
2017-02-23 15:49             ` Liam Breck
2017-02-23 16:08               ` Andrew F. Davis
2017-02-23 16:38                 ` Liam Breck
2017-02-23 16:53                   ` Andrew F. Davis
2017-02-23 17:36                     ` Liam Breck
2017-02-23 18:02                       ` Andrew F. Davis
2017-02-23 21:28                         ` Liam Breck
2017-02-24 14:51                           ` Andrew F. Davis
2017-02-23 21:15     ` Liam Breck
2017-02-24 14:47       ` Andrew F. Davis
2017-02-21 21:30 ` [PATCH v7 8/9] power: bq27xxx_battery: Add print_dm() to log chip memory Liam Breck
2017-02-22 20:39   ` Andrew F. Davis
2017-02-22 21:36     ` Liam Breck [this message]
2017-02-23  0:34       ` Andrew F. Davis
2017-02-21 21:30 ` [PATCH v7 9/9] power: bq27xxx_battery_i2c: Add I2C bulk read/write functions Liam Breck
2017-03-02 22:52 ` [PATCH v7 0/9] devicetree battery support and client bq27xxx_battery Liam Breck
2017-03-02 23:04   ` Andrew F. Davis

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='CAKvHMgS-1+P2LcW=USftbLb-Bd84wHZ1YR5kZFe0jAZY9G91rA@mail.gmail.com' \
    --to=liam@networkimprov.net \
    --cc=afd@ti.com \
    --cc=kernel@networkimprov.net \
    --cc=linux-pm@vger.kernel.org \
    --cc=matt@ranostay.consulting \
    --cc=sre@kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.