OSDN Git Service

power: supply: max8903: Convert to GPIO descriptors
authorLinus Walleij <linus.walleij@linaro.org>
Sun, 10 Jan 2021 14:02:00 +0000 (15:02 +0100)
committerSebastian Reichel <sebastian.reichel@collabora.com>
Tue, 12 Jan 2021 22:23:49 +0000 (23:23 +0100)
commit50da8d04ee52a0700ec6686e745379578246a9fb
treee92b339bedade88f47fe392bdd31bbd5ac604f22
parent3188677d4901fbfb7a363ab2558e0a4bc76deecb
power: supply: max8903: Convert to GPIO descriptors

The MAX8903 uses up to 5 different GPIO lines to control and
monitor charging.

When converting to use GPIO descriptors instead of the old
GPIO numbers the following side-refactorings were done:

- Decomission the platform data container struct as all
  GPIO descriptors are now "live" members of the driver
  state container. The "dc_valid" and "usb_valid" just
  indicate the presence of a DC or USB charger detection
  line, and this can be handled by just checking if
  the optional GPIO descriptor for each is != NULL.

- The gpiolib will now respect the GPIO_ACTIVE_LOW flag
  for each of the lines, meaning gpiod_get_value() for example
  will return 1 (asserted) if a line is flagged as
  active low and is also physically low. The same applies
  to output lines, vice versa mutatis mutandis. The code
  has been augmented to account for this in all sites.

- The terse parenthesis such as this:
    gpio_set_value(pdata->cen, ta_in ? 0 :
                     (data->usb_in ? 0 : 1));
  have been expanded to more readable if / else if / else
  statements that are easier for humans to read.

- Comments were inserted to underscore polarity in each
  case where it could be confusing to users of the old code.

One thing is notable: the device tree bindings does not show
an example of polarity assigned for the line "dcm-gpios"
DC current monitor, is assumed to be flagged GPIO_ACTIVE_HIGH
and driving it high (asserted) will achieve DC charger current
limits and driving it low will achieve USB charger current
limits. Device trees with this (optional) GPIO line defined
should definately be flagged as GPIO_ACTIVE_HIGH.

Cc: Chris Lapa <chris@lapa.com.au>
Cc: MyungJoo Ham <myungjoo.ham@samsung.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
drivers/power/supply/max8903_charger.c