devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
To: Zeynep Arslanbenzer <Zeynep.Arslanbenzer@analog.com>,
	lee@kernel.org, robh+dt@kernel.org,
	krzysztof.kozlowski+dt@linaro.org, sre@kernel.org,
	lgirdwood@gmail.com, broonie@kernel.org
Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org,
	linux-pm@vger.kernel.org,
	Nurettin Bolucu <Nurettin.Bolucu@analog.com>
Subject: Re: [PATCH v3 7/7] mfd: max77658: Add ADI MAX77643/54/58/59 MFD Support
Date: Mon, 8 May 2023 22:09:11 +0200	[thread overview]
Message-ID: <7636f1c7-ce54-af9f-03c8-aa124dd26561@linaro.org> (raw)
In-Reply-To: <20230508131045.9399-8-Zeynep.Arslanbenzer@analog.com>

On 08/05/2023 15:10, Zeynep Arslanbenzer wrote:
> MFD driver for MAX77643/54/58/59 to enable its sub
> devices.
> 
> The MAX77643 is a multi-function devices. It includes
> regulator.
> 
> The MAX77654 is a multi-function devices. It includes
> regulator and charger.
> 
> The MAX77658 is a multi-function devices. It includes
> regulator, charger and battery.
> 
> The MAX77659 is a multi-function devices. It includes
> regulator and charger.
> 
> Signed-off-by: Nurettin Bolucu <Nurettin.Bolucu@analog.com>
> Signed-off-by: Zeynep Arslanbenzer <Zeynep.Arslanbenzer@analog.com>
> ---
>  drivers/mfd/Kconfig          |  13 ++
>  drivers/mfd/Makefile         |   1 +
>  drivers/mfd/max77658.c       | 426 +++++++++++++++++++++++++++++++++++
>  include/linux/mfd/max77658.h |  80 +++++++
>  4 files changed, 520 insertions(+)
>  create mode 100644 drivers/mfd/max77658.c
>  create mode 100644 include/linux/mfd/max77658.h
> 
> diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
> index 8b93856de432..aa1630a6d33a 100644
> --- a/drivers/mfd/Kconfig
> +++ b/drivers/mfd/Kconfig
> @@ -821,6 +821,19 @@ config MFD_MAX77650
>  	  the following functionalities of the device: GPIO, regulator,
>  	  charger, LED, onkey.
>  

...
			glbl1_chip, &max77658->irqc_glbl1);
> +}
> +
> +static int max77658_i2c_probe(struct i2c_client *client,
> +			      const struct i2c_device_id *id)
> +{
> +	struct device *dev = &client->dev;
> +	struct max77658_dev *max77658;
> +	const struct mfd_cell *cells;
> +	struct i2c_client *fuel;
> +	int ret, n_devs;
> +
> +	max77658 = devm_kzalloc(dev, sizeof(*max77658), GFP_KERNEL);
> +	if (!max77658)
> +		return -ENOMEM;
> +
> +	i2c_set_clientdata(client, max77658);
> +	max77658->irq = client->irq;
> +
> +	max77658->id  = (enum max77658_ids)device_get_match_data(dev);

Double space -> One space.

> +	if (!max77658->id)
> +		max77658->id  = (enum max77658_ids)id->driver_data;
> +
> +	if (!max77658->id)
> +		return -EINVAL;
> +
> +	max77658->regmap = devm_regmap_init_i2c(client,
> +						&max77658_regmap_config);
> +	if (IS_ERR(max77658->regmap))
> +		return dev_err_probe(dev, PTR_ERR(max77658->regmap),
> +				     "Failed to initialize regmap\n");
> +
> +	fuel = i2c_new_dummy_device(client->adapter, I2C_ADDR_FUEL_GAUGE);
> +	if (IS_ERR(fuel))
> +		return dev_err_probe(dev, PTR_ERR(fuel),
> +				     "Failed to create I2C device[0x%Xh]\n",
> +				      I2C_ADDR_FUEL_GAUGE);

Where do you free "fuel" instance?

> +
> +	i2c_set_clientdata(fuel, max77658);
> +
> +	max77658->regmap_fg = devm_regmap_init_i2c(fuel,
> +						   &max77658_regmap_config_fg);
> +	if (IS_ERR(max77658->regmap_fg))
> +		return dev_err_probe(dev,
> +				     PTR_ERR(max77658->regmap_fg),
> +				     "Failed to initialize I2C device[0x%Xh]\n",
> +				     I2C_ADDR_FUEL_GAUGE);
> +
> +	ret = max77658_pmic_irq_init(dev);
> +	if (ret < 0)
> +		return dev_err_probe(dev, ret, "Failed to initialize IRQ\n");
> +
> +	switch (max77658->id) {
> +	case ID_MAX77643:
> +		cells = max77643_devs;
> +		n_devs = ARRAY_SIZE(max77643_devs);
> +		break;
> +	case ID_MAX77654:
> +		cells = max77654_devs;
> +		n_devs = ARRAY_SIZE(max77654_devs);
> +		break;
> +	case ID_MAX77658:
> +		cells = max77658_devs;
> +		n_devs = ARRAY_SIZE(max77658_devs);
> +		break;
> +	case ID_MAX77659:
> +		cells = max77659_devs;
> +		n_devs = ARRAY_SIZE(max77659_devs);
> +		break;
> +	default:
> +		return -EINVAL;
> +	}
> +
> +	ret = devm_mfd_add_devices(dev, -1, cells, n_devs,  NULL, 0, NULL);
> +	if (ret)
> +		return dev_err_probe(dev, ret, "Failed to add sub-devices\n");
> +
> +	return device_init_wakeup(dev, true);
> +}

Best regards,
Krzysztof


      reply	other threads:[~2023-05-08 20:10 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-08 13:10 [PATCH v3 0/7] Add MAX77643/MAX77654/MAX77658/MAX77659 PMIC Support Zeynep Arslanbenzer
2023-05-08 13:10 ` [PATCH v3 1/7] regulator: max77658: Add ADI MAX77643/54/58/59 Regulator Support Zeynep Arslanbenzer
2023-05-08 13:10 ` [PATCH v3 2/7] dt-bindings: power: supply: max77658: Add ADI MAX77654/58/59 Charger Zeynep Arslanbenzer
2023-05-08 14:32   ` Krzysztof Kozlowski
2023-05-08 14:36     ` Krzysztof Kozlowski
2023-05-08 19:45   ` Krzysztof Kozlowski
2023-05-08 19:55     ` Krzysztof Kozlowski
2023-05-08 13:10 ` [PATCH v3 3/7] power: supply: max77658: Add ADI MAX77654/58/59 Charger Support Zeynep Arslanbenzer
2023-05-08 19:51   ` Krzysztof Kozlowski
2023-05-08 20:22   ` Krzysztof Kozlowski
2023-06-16 10:39     ` Arslanbenzer, Zeynep
2023-05-08 13:10 ` [PATCH v3 4/7] dt-bindings: power: supply: max77658: Add ADI MAX77658 Battery Zeynep Arslanbenzer
2023-05-08 14:31   ` Krzysztof Kozlowski
2023-05-08 19:54   ` Krzysztof Kozlowski
2023-05-08 13:10 ` [PATCH v3 5/7] power: supply: max77658: Add ADI MAX77658 Battery Support Zeynep Arslanbenzer
2023-05-08 19:57   ` Krzysztof Kozlowski
2023-05-08 20:15   ` Krzysztof Kozlowski
2023-05-08 13:10 ` [PATCH v3 6/7] dt-bindings: mfd: max77658: Add ADI MAX77658 Zeynep Arslanbenzer
2023-05-08 14:31   ` Krzysztof Kozlowski
2023-05-08 20:02   ` Krzysztof Kozlowski
2023-05-08 13:10 ` [PATCH v3 7/7] mfd: max77658: Add ADI MAX77643/54/58/59 MFD Support Zeynep Arslanbenzer
2023-05-08 20:09   ` Krzysztof Kozlowski [this message]

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=7636f1c7-ce54-af9f-03c8-aa124dd26561@linaro.org \
    --to=krzysztof.kozlowski@linaro.org \
    --cc=Nurettin.Bolucu@analog.com \
    --cc=Zeynep.Arslanbenzer@analog.com \
    --cc=broonie@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=lee@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=robh+dt@kernel.org \
    --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 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).