mbox series

[v2,0/9] add support for pf1550 PMIC MFD-based drivers

Message ID cover.1747409892.git.samuel.kayode@savoirfairelinux.com
Headers show
Series add support for pf1550 PMIC MFD-based drivers | expand

Message

Samuel Kayode May 16, 2025, 6:29 p.m. UTC
This series adds support for pf1550 PMIC. It provides the core mfd driver and a
set of three sub-drivers for the regulator, power supply and input subsystems.

Patches 1-4 add the DT binding documents. Patches 5-8 add all drivers. Last
patch adds a MAINTAINERS entry for this device.

Changes since v1 [1]:
   1. DT bindings for all devices included
   2. Add onkey driver
   3. Add driver for the regulators
   4. Ensure charger is activated as some variants have it off by default
   5. Update mfd and charger driver per feedback from eballetbo@gmail.com
   6. Add myself as maintainer for these drivers

[1]: v1: https://lore.kernel.org/1523974819-8711-1-git-send-email-abel.vesa@nxp.com/

Samuel Kayode (9):
  dt-bindings: power: supply: add pf1550
  dt-bindings: regulator: add pf1550
  dt-bindings: input: add pf1550
  dt-bindings: mfd: add pf1550
  mfd: pf1550: add core mfd driver
  regulator: pf1550: add support for regulator
  input: pf1550: add onkey support
  power: supply: pf1550: add battery charger support
  MAINTAINERS: add an entry for pf1550 mfd driver

 .../bindings/input/pf1550_onkey.yaml          |  31 +
 .../devicetree/bindings/mfd/pf1550.yaml       | 122 ++++
 .../bindings/power/supply/pf1550_charger.yaml |  44 ++
 .../devicetree/bindings/regulator/pf1550.yaml |  35 +
 MAINTAINERS                                   |  11 +
 drivers/input/keyboard/Kconfig                |   8 +
 drivers/input/keyboard/Makefile               |   1 +
 drivers/input/keyboard/pf1550_onkey.c         | 200 ++++++
 drivers/mfd/Kconfig                           |  14 +
 drivers/mfd/Makefile                          |   2 +
 drivers/mfd/pf1550.c                          | 254 +++++++
 drivers/power/supply/Kconfig                  |   6 +
 drivers/power/supply/Makefile                 |   1 +
 drivers/power/supply/pf1550_charger.c         | 656 ++++++++++++++++++
 drivers/regulator/Kconfig                     |   7 +
 drivers/regulator/Makefile                    |   1 +
 drivers/regulator/pf1550.c                    | 380 ++++++++++
 include/linux/mfd/pf1550.h                    | 246 +++++++
 18 files changed, 2019 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/input/pf1550_onkey.yaml
 create mode 100644 Documentation/devicetree/bindings/mfd/pf1550.yaml
 create mode 100644 Documentation/devicetree/bindings/power/supply/pf1550_charger.yaml
 create mode 100644 Documentation/devicetree/bindings/regulator/pf1550.yaml
 create mode 100644 drivers/input/keyboard/pf1550_onkey.c
 create mode 100644 drivers/mfd/pf1550.c
 create mode 100644 drivers/power/supply/pf1550_charger.c
 create mode 100644 drivers/regulator/pf1550.c
 create mode 100644 include/linux/mfd/pf1550.h


base-commit: b1d8766052eb0534b27edda8af1865d53621bd6a

Comments

Krzysztof Kozlowski May 17, 2025, 11:12 a.m. UTC | #1
On 16/05/2025 20:47, Samuel Kayode wrote:
> Add the DT binding document for the battery charger module of pf1550.
> 
> Signed-off-by: Samuel Kayode <samuel.kayode@savoirfairelinux.com>
> ---
>  .../bindings/power/supply/pf1550_charger.yaml | 44 +++++++++++++++++++
>  1 file changed, 44 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/power/supply/pf1550_charger.yaml

Filename matching compatible.

> 
> diff --git a/Documentation/devicetree/bindings/power/supply/pf1550_charger.yaml b/Documentation/devicetree/bindings/power/supply/pf1550_charger.yaml
> new file mode 100644
> index 000000000000..10fc0b35917c
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/power/supply/pf1550_charger.yaml
> @@ -0,0 +1,44 @@
> +# SPDX-License-Identifier: GPL-2.0
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/power/supply/pf1550_charger.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Battery charger driver for PF1550 PMIC from NXP.
Describe hardware, not driver.

Also drop full stop.


<form letter>
Please use scripts/get_maintainers.pl to get a list of necessary people
and lists to CC. It might happen, that command when run on an older
kernel, gives you outdated entries. Therefore please be sure you base
your patches on recent Linux kernel.

Tools like b4 or scripts/get_maintainer.pl provide you proper list of
people, so fix your workflow. Tools might also fail if you work on some
ancient tree (don't, instead use mainline) or work on fork of kernel
(don't, instead use mainline). Just use b4 and everything should be
fine, although remember about `b4 prep --auto-to-cc` if you added new
patches to the patchset.

You missed at least devicetree list (maybe more), so this won't be
tested by automated tooling. Performing review on untested code might be
a waste of time.

Please kindly resend and include all necessary To/Cc entries.
</form letter>


Best regards,
Krzysztof
Krzysztof Kozlowski May 17, 2025, 11:14 a.m. UTC | #2
On 16/05/2025 20:52, Samuel Kayode wrote:
> Add the DT binding document for the onkey module of pf1550.
> 
> Signed-off-by: Samuel Kayode <samuel.kayode@savoirfairelinux.com>
> ---
>  .../bindings/input/pf1550_onkey.yaml          | 31 +++++++++++++++++++

Same comments as for other patch.

Best regards,
Krzysztof
Krzysztof Kozlowski May 17, 2025, 11:18 a.m. UTC | #3
On 16/05/2025 20:54, Samuel Kayode wrote:
> +
> +static int pf1550_i2c_probe(struct i2c_client *i2c)
> +{
> +	struct pf1550_dev *pf1550;
> +	unsigned int reg_data = 0;
> +	int ret = 0;
> +
> +	pf1550 = devm_kzalloc(&i2c->dev,
> +			      sizeof(struct pf1550_dev), GFP_KERNEL);

sizeof(*)

> +	if (!pf1550)
> +		return -ENOMEM;
> +
> +	i2c_set_clientdata(i2c, pf1550);
> +	pf1550->dev = &i2c->dev;
> +	pf1550->i2c = i2c;
> +	pf1550->irq = i2c->irq;
> +
> +	pf1550->regmap = devm_regmap_init_i2c(i2c, &pf1550_regmap_config);
> +	if (IS_ERR(pf1550->regmap)) {
> +		ret = PTR_ERR(pf1550->regmap);
> +		dev_err(pf1550->dev, "failed to allocate register map: %d\n",
> +			ret);


Syntax is always: return dev_err_probe

> +		return ret;
> +	}
> +
> +	ret = regmap_read(pf1550->regmap, PF1550_PMIC_REG_DEVICE_ID, &reg_data);
> +	if (ret < 0 || reg_data != PF1550_DEVICE_ID) {
> +		dev_err(pf1550->dev, "device not found!\n");
> +		return ret;

Syntax is always: return dev_err_probe

> +	}
> +
> +	pf1550->type = PF1550;
> +	dev_info(pf1550->dev, "pf1550 found.\n");

Drop. Drivers should be silent. This is really useless and just pollutes
log. See also coding style.

> +
> +	ret = devm_regmap_add_irq_chip(pf1550->dev, pf1550->regmap,
> +				       pf1550->irq,
> +				IRQF_ONESHOT | IRQF_SHARED |
> +				IRQF_TRIGGER_FALLING, 0,
> +				&pf1550_regulator_irq_chip,
> +				&pf1550->irq_data_regulator);
> +	if (ret) {
> +		dev_err(pf1550->dev, "failed to add irq1 chip: %d\n", ret);
> +		return ret;

Syntax is always: return dev_err_probe

> +	}
> +
> +	ret = devm_regmap_add_irq_chip(pf1550->dev, pf1550->regmap,
> +				       pf1550->irq,
> +				IRQF_ONESHOT | IRQF_SHARED |
> +				IRQF_TRIGGER_FALLING, 0,
> +				&pf1550_onkey_irq_chip,
> +				&pf1550->irq_data_onkey);
> +	if (ret) {
> +		dev_err(pf1550->dev, "failed to add irq3 chip: %d\n", ret);
> +		return ret;

Syntax is always: return dev_err_probe

> +	}
> +
> +	ret = devm_regmap_add_irq_chip(pf1550->dev, pf1550->regmap,
> +				       pf1550->irq,
> +				IRQF_ONESHOT | IRQF_SHARED |
> +				IRQF_TRIGGER_FALLING, 0,
> +				&pf1550_charger_irq_chip,
> +				&pf1550->irq_data_charger);
> +	if (ret) {
> +		dev_err(pf1550->dev, "failed to add irq4 chip: %d\n", ret);
> +		return ret;

Syntax is always: return dev_err_probe

> +	}
> +
> +	return devm_mfd_add_devices(pf1550->dev, -1, pf1550_devs,
> +			      ARRAY_SIZE(pf1550_devs), NULL, 0, NULL);
> +}
> +
> +static const struct i2c_device_id pf1550_i2c_id[] = {
> +	{ "pf1550", PF1550 },
> +	{ /* sentinel */ }
> +};
> +MODULE_DEVICE_TABLE(i2c, pf1550_i2c_id);

Table IDs are next to each other.

> +
> +static int pf1550_suspend(struct device *dev)
> +{
> +	struct i2c_client *i2c = container_of(dev, struct i2c_client, dev);
> +	struct pf1550_dev *pf1550 = i2c_get_clientdata(i2c);
> +
> +	if (device_may_wakeup(dev)) {
> +		enable_irq_wake(pf1550->irq);
> +		disable_irq(pf1550->irq);
> +	}
> +
> +	return 0;
> +}
> +
> +static int pf1550_resume(struct device *dev)
> +{
> +	struct i2c_client *i2c = container_of(dev, struct i2c_client, dev);
> +	struct pf1550_dev *pf1550 = i2c_get_clientdata(i2c);
> +
> +	if (device_may_wakeup(dev)) {
> +		disable_irq_wake(pf1550->irq);
> +		enable_irq(pf1550->irq);
> +	}
> +
> +	return 0;
> +}
> +
> +static DEFINE_SIMPLE_DEV_PM_OPS(pf1550_pm, pf1550_suspend, pf1550_resume);
> +
> +static const struct of_device_id pf1550_dt_match[] = {
> +	{ .compatible = "fsl,pf1550" },
> +	{ /* sentinel */ }
> +};
> +MODULE_DEVICE_TABLE(of, pf1550_dt_match);
> +
> +static struct i2c_driver pf1550_i2c_driver = {
> +	.driver = {
> +		   .name = "pf1550",
> +		   .pm = pm_sleep_ptr(&pf1550_pm),
> +		   .of_match_table = of_match_ptr(pf1550_dt_match),


Drop of_match_ptr, you have warnings here.

> +	},
> +	.probe = pf1550_i2c_probe,
> +	.id_table = pf1550_i2c_id,
> +};
> +
> +module_i2c_driver(pf1550_i2c_driver);
> +
> +MODULE_DESCRIPTION("Freescale PF1550 multi-function core driver");
> +MODULE_AUTHOR("Robin Gong <yibin.gong@freescale.com>");
> +MODULE_LICENSE("GPL v2");
Best regards,
Krzysztof