[PATCH v5 00/10] Add RT5033 charger device driver

From: Jakob Hauser
Date: Sun May 14 2023 - 08:32:00 EST


This patchset adds the charger driver "rt5033-charger". It is part of the
multifunction device rt5033. The patchset is based on an older version by
Beomho Seo of March 2015. For more information on the history and setup of
the patchset see the cover sheet of version v1, there is a link further down
below the changelog.

Changes in v5:

General
- Rebased to torvalds/linux v6.4-rc1

Patch 5
- Removed the GPL2 text, not needed because of the SPDX license header.
- In function rt5033_charger_get_property() removed unused declaration
"int ret = 0;".
- In function *rt5033_charger_dt_init() changed
the error reporting from dev_err() to dev_err_probe().
- In function rt5033_charger_probe() replaced "charger->rt5033 = rt5033;"
by "charger->regmap = dev_get_regmap(pdev->dev.parent);" because only
the regmap is used of the parent mfd device.
- Accordingly to the previous point, replaced "charger->rt5033->regmap"
by "charger->regmap" throughout the driver file rt5033_charger.c.
- In function rt5033_charger_probe() after devm_power_supply_register()
changed dev_err() into dev_err_probe().
- Moved struct rt5033_charger and struct rt5033_charger_data from
include/linux/mfd/rt5033.h to drivers/power/supply/rt5033_charger.c.
- In struct rt5033_charger removed "struct rt5033_dev *rt5033;" and
added "struct regmap *regmap;" instead. This is related to the above
mentioned point of using "charger->regmap" instead of
"charger->rt5033->regmap".
- Removed #include <linux/mfd/rt5033.h>, it's not used anymore. Instead
added #include <linux/of_device.h> and #include <linux/regmap.h>.

Patch 6
- In function rt5033_charger_probe(), where getting the extcon device,
changed phandle string from "connector" to "richtek,usb-connector".

Patch 7 (new)
- New patch to move the struct rt5033_battery into the battery driver.

Patch 8 (former Patch 7)
- Changed the function rt5033_battery_get_status() to use
power_supply_get_property_from_supplier() instead of first
power_supply_get_by_name() and then power_supply_get_property().
- In function rt5033_battery_probe() initated "of_node" by adding the
line "psy_cfg.of_node = client->dev.of_node;".
- In function rt5033_battery_probe() after power_supply_register()
changed dev_err() into dev_err_probe().
- Removed the "Tested-by:" tag of Raymond because the patch changed a lot.

Patch 9 (new)
- In dt-bindings power/supply/richtek,rt5033-battery.yaml added property
"power-supplies". Otherwise dt_binding_check complains about not match
regular expression.

Patch 10 (former Patch 8)
- In file "richtek,rt5033-charger.yaml" fixed typo on "PMIC" in the title.
- In the charger file changed the general "connector" property into
vendor-specific "richtek,usb-connector".
- In the charger file added $ref to phandle for "monitored-battery" and
"richtek,usb-connector".
- In charger file removed line "maxItems: 1" from property
"richtek,usb-connector" because dt_binding_check complained about it.
- In the mfd example added the "power-supplies" connection between fuel-gauge
and charger. As the example fuel-gauge contains compatible
"richtek,rt5033-battery", dt_binding_check was rather picky to implement
that node completely.

v1: https://lore.kernel.org/linux-pm/cover.1677620677.git.jahau@xxxxxxxxxxxxxx/T/#t
v2: https://lore.kernel.org/linux-pm/cover.1681646904.git.jahau@xxxxxxxxxxxxxx/T/#t
v3: https://lore.kernel.org/linux-pm/cover.1682636929.git.jahau@xxxxxxxxxxxxxx/T/#t
v4: https://lore.kernel.org/linux-pm/20230506155435.3005-1-jahau@xxxxxxxxxxxxxx/T/#t

The result of the patchset v5 can be seen at:
https://github.com/Jakko3/linux/blob/rt5033-charger_v5/drivers/power/supply/rt5033_charger.c

Jakob Hauser (9):
mfd: rt5033: Fix chip revision readout
mfd: rt5033: Fix STAT_MASK, HZ_MASK and AICR defines
mfd: rt5033: Apply preparatory changes before adding rt5033-charger
driver
power: supply: rt5033_charger: Add RT5033 charger device driver
power: supply: rt5033_charger: Add cable detection and USB OTG supply
power: supply: rt5033_battery: Move struct rt5033_battery to battery
driver
power: supply: rt5033_battery: Adopt status property from charger
dt-bindings: power: supply: rt5033-battery: Add power-supplies as a
property
dt-bindings: Add rt5033 mfd, regulator and charger

Stephan Gerhold (1):
mfd: rt5033: Drop rt5033-battery sub-device

.../bindings/mfd/richtek,rt5033.yaml | 138 ++++
.../power/supply/richtek,rt5033-battery.yaml | 2 +
.../power/supply/richtek,rt5033-charger.yaml | 65 ++
drivers/mfd/rt5033.c | 8 +-
drivers/power/supply/Kconfig | 8 +
drivers/power/supply/Makefile | 1 +
drivers/power/supply/rt5033_battery.c | 38 +-
drivers/power/supply/rt5033_charger.c | 744 ++++++++++++++++++
include/linux/mfd/rt5033-private.h | 64 +-
include/linux/mfd/rt5033.h | 24 -
10 files changed, 1035 insertions(+), 57 deletions(-)
create mode 100644 Documentation/devicetree/bindings/mfd/richtek,rt5033.yaml
create mode 100644 Documentation/devicetree/bindings/power/supply/richtek,rt5033-charger.yaml
create mode 100644 drivers/power/supply/rt5033_charger.c

--
2.39.2