mbox series

[v6,00/12] treewide: bd9571mwv: Add support for BD9574MWF

Message ID 1608718963-21818-1-git-send-email-yoshihiro.shimoda.uh@renesas.com
Headers show
Series treewide: bd9571mwv: Add support for BD9574MWF | expand

Message

Yoshihiro Shimoda Dec. 23, 2020, 10:22 a.m. UTC
Add BD9574MWF support into bd9571mwv gpio, mfd and regulator drivers.
Latest Ebisu-4D boards has this chip instead of BD9571MWV so that
we need this patch series to detect this chip at runtime.

Note that the patch [1/12] is a bug-fix patch for mfd driver.

Changes from v5:
 - Fix typo in the patch 5 and 8.
 https://patchwork.kernel.org/project/linux-renesas-soc/list/?series=405263

Changes from v4:
 - Add Reviwed-by in patch 1, 10, 11 and 12.
 - Keep bd9571mwv_id_table[] as-is because unused in patch 12.
 https://patchwork.kernel.org/project/linux-renesas-soc/list/?series=404657

Changes from v3:
 - Add "Acked-for-MFD-by" in patch 1, 3, 9 and 10.
 - Use "Co-developed-by" instead in patch 11.
 - In patch 11:
 -- Remove abusing kernel-doc formatting in patch.
 -- Rename bd957x_data with bd957x_ddata in patch.
 -- Remove product name printk.
 -- Rename bd9571mwv_identify() with bd957x_identify().
 -- Remove argument "part_name" from bd957x_identify().
 -- Modify dev_err() string.
 -- Rename BD9571MWV_PRODUCT_CODE_VAL with BD9571MWV_PRODUCT_CODE_BD9571MWV.
 -- Fix errno from -ENOENT to -ENODEV.
 - In patch 12:
 -- Rename "MFD driver" to "core driver".
 -- Remove unnecessary comments.
 -- Rename BD9574MWF_PRODUCT_CODE_VAL with BD9571MWV_PRODUCT_CODE_BD9574MWF.
 https://patchwork.kernel.org/project/linux-renesas-soc/list/?series=402719

Changes from v2:
 - Use devm_mfd_add_devices() to remove the mfd device in unload.
 - Update commit descriptions in patch 4 and 8.
 - Use regmap_get_device() to simplify in patch 4.
 - Remove "struct bd9571mwv" and bd9571mwv_remove().
 - Add Reviewed-by in patch 3 to 9.
 - Use devm_regmap_add_irq_chip() to simplify in patch 10.
 https://patchwork.kernel.org/project/linux-renesas-soc/list/?series=400477

Changes from v1:
 - Document BD9574MWF on the dt-binding.
 - Add ROHM_CHIP_TYPE_BD957[14] into rohm-generic.h.
 - To simplify gpio and regulator drivers, using regmap instead of
   using struct bd9571mwv.
 - Remove BD9574MWF definitions to make gpio and regulator driver
   simple to support for BD9574MWF.
 - Add BD9574MWF support for gpio and regulator drivers.
 - Add missing regmap ranges for BD9574MWF.
 - Rename "part_number" with "part_name".
 https://patchwork.kernel.org/project/linux-renesas-soc/list/?series=398059

Khiem Nguyen (2):
  mfd: bd9571mwv: Make the driver more generic
  mfd: bd9571mwv: Add support for BD9574MWF

Yoshihiro Shimoda (10):
  mfd: bd9571mwv: Use devm_mfd_add_devices()
  dt-bindings: mfd: bd9571mwv: Document BD9574MWF
  mfd: rohm-generic: Add BD9571 and BD9574
  regulator: bd9571mwv: rid of using struct bd9571mwv
  regulator: bd9571mwv: Add BD9574MWF support
  gpio: bd9571mwv: Use the SPDX license identifier
  gpio: bd9571mwv: rid of using struct bd9571mwv
  gpio: bd9571mwv: Add BD9574MWF support
  mfd: bd9571mwv: Use the SPDX license identifier
  mfd: bd9571mwv: Use devm_regmap_add_irq_chip()

 .../devicetree/bindings/mfd/bd9571mwv.txt          |   4 +-
 drivers/gpio/gpio-bd9571mwv.c                      |  35 ++--
 drivers/mfd/bd9571mwv.c                            | 194 ++++++++++++++-------
 drivers/regulator/bd9571mwv-regulator.c            |  59 ++++---
 include/linux/mfd/bd9571mwv.h                      |  45 ++---
 include/linux/mfd/rohm-generic.h                   |   2 +
 6 files changed, 201 insertions(+), 138 deletions(-)

Comments

Yoshihiro Shimoda Dec. 24, 2020, 6:46 a.m. UTC | #1
Hi Lee,

> From: Lee Jones, Sent: Thursday, December 24, 2020 12:39 AM

> On Wed, 23 Dec 2020, Yoshihiro Shimoda wrote:

> > From: Khiem Nguyen <khiem.nguyen.xt@renesas.com>

> >

> > Since the driver supports BD9571MWV PMIC only, this patch makes

> > the functions and data structure become more generic so that

> > it can support other PMIC variants as well. Also remove printing

> > part name which Lee Jones suggested.

> >

> > Signed-off-by: Khiem Nguyen <khiem.nguyen.xt@renesas.com>

> > Co-developed-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>

> > Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>

> > Reviewed-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>

> > ---

> >  drivers/mfd/bd9571mwv.c       | 89 +++++++++++++++++++++++++------------------

> >  include/linux/mfd/bd9571mwv.h | 18 +--------

> >  2 files changed, 54 insertions(+), 53 deletions(-)

> 

> Couple of small points.

> 

> Remainder looks good.


Thank you for your review!

> > diff --git a/drivers/mfd/bd9571mwv.c b/drivers/mfd/bd9571mwv.c

> > index 49e968e..c905ab4 100644

> > --- a/drivers/mfd/bd9571mwv.c

> > +++ b/drivers/mfd/bd9571mwv.c

> > @@ -3,6 +3,7 @@

> >   * ROHM BD9571MWV-M MFD driver

> >   *

> >   * Copyright (C) 2017 Marek Vasut <marek.vasut+renesas@gmail.com>

> > + * Copyright (C) 2020 Renesas Electronics Corporation

> >   *

> >   * Based on the TPS65086 driver

> >   */

> > @@ -14,6 +15,14 @@

> >

> >  #include <linux/mfd/bd9571mwv.h>

> >

> > +/* Driver data to distinguish bd957x variants */

> > +struct bd957x_ddata {

> > +	const struct regmap_config *regmap_config;

> > +	const struct regmap_irq_chip *irq_chip;

> 

> > +	const struct mfd_cell *cells;

> > +	int num_cells;

> 

> Are you using these post-probe?

> 

> If not, they're not ddata.


I'm not using all these members post-probe.
So, I'll remove ddata.

<snip>
> >  static int bd9571mwv_probe(struct i2c_client *client,

> > -			  const struct i2c_device_id *ids)

> > +			   const struct i2c_device_id *ids)

> >  {

> > -	struct bd9571mwv *bd;

> > -	int ret;

> > -

> > -	bd = devm_kzalloc(&client->dev, sizeof(*bd), GFP_KERNEL);

> > -	if (!bd)

> > -		return -ENOMEM;

> > -

> > -	i2c_set_clientdata(client, bd);

> > -	bd->dev = &client->dev;

> > -	bd->irq = client->irq;

> > +	const struct bd957x_ddata *ddata;

> > +	struct device *dev = &client->dev;

> > +	struct regmap *regmap;

> > +	struct regmap_irq_chip_data *irq_data;

> > +	int ret, irq = client->irq;

> > +

> > +	/* Read the PMIC product code */

> > +	ret = i2c_smbus_read_byte_data(client, BD9571MWV_PRODUCT_CODE);

> > +	if (ret < 0) {

> > +		dev_err(dev, "Failed to read product code\n");

> > +		return ret;

> > +	}

> 

> Nit: '\n' here.


I got it. I'll add a blank line here.

> > +	switch (ret) {

> > +	case BD9571MWV_PRODUCT_CODE_BD9571MWV:

> > +		ddata = &bd9571mwv_ddata;

> 

> Simply declare 'const struct mfd_cell *cells' locally in probe and

> assign it here instead.


I got it. I'll also add "const struct regmap_config *regmap_config;"
and "const struct regmap_irq_chip *irq_chip;" locally in probe.

Best regards,
Yoshihiro Shimoda
Lee Jones Dec. 24, 2020, 7:34 a.m. UTC | #2
On Thu, 24 Dec 2020, Yoshihiro Shimoda wrote:

> Hi Lee,

> 

> > From: Lee Jones, Sent: Thursday, December 24, 2020 12:39 AM

> > On Wed, 23 Dec 2020, Yoshihiro Shimoda wrote:

> > > From: Khiem Nguyen <khiem.nguyen.xt@renesas.com>

> > >

> > > Since the driver supports BD9571MWV PMIC only, this patch makes

> > > the functions and data structure become more generic so that

> > > it can support other PMIC variants as well. Also remove printing

> > > part name which Lee Jones suggested.

> > >

> > > Signed-off-by: Khiem Nguyen <khiem.nguyen.xt@renesas.com>

> > > Co-developed-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>

> > > Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>

> > > Reviewed-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>

> > > ---

> > >  drivers/mfd/bd9571mwv.c       | 89 +++++++++++++++++++++++++------------------

> > >  include/linux/mfd/bd9571mwv.h | 18 +--------

> > >  2 files changed, 54 insertions(+), 53 deletions(-)

> > 

> > Couple of small points.

> > 

> > Remainder looks good.

> 

> Thank you for your review!

> 

> > > diff --git a/drivers/mfd/bd9571mwv.c b/drivers/mfd/bd9571mwv.c

> > > index 49e968e..c905ab4 100644

> > > --- a/drivers/mfd/bd9571mwv.c

> > > +++ b/drivers/mfd/bd9571mwv.c

> > > @@ -3,6 +3,7 @@

> > >   * ROHM BD9571MWV-M MFD driver

> > >   *

> > >   * Copyright (C) 2017 Marek Vasut <marek.vasut+renesas@gmail.com>

> > > + * Copyright (C) 2020 Renesas Electronics Corporation

> > >   *

> > >   * Based on the TPS65086 driver

> > >   */

> > > @@ -14,6 +15,14 @@

> > >

> > >  #include <linux/mfd/bd9571mwv.h>

> > >

> > > +/* Driver data to distinguish bd957x variants */

> > > +struct bd957x_ddata {

> > > +	const struct regmap_config *regmap_config;

> > > +	const struct regmap_irq_chip *irq_chip;

> > 

> > > +	const struct mfd_cell *cells;

> > > +	int num_cells;

> > 

> > Are you using these post-probe?

> > 

> > If not, they're not ddata.

> 

> I'm not using all these members post-probe.

> So, I'll remove ddata.

> 

> <snip>

> > >  static int bd9571mwv_probe(struct i2c_client *client,

> > > -			  const struct i2c_device_id *ids)

> > > +			   const struct i2c_device_id *ids)

> > >  {

> > > -	struct bd9571mwv *bd;

> > > -	int ret;

> > > -

> > > -	bd = devm_kzalloc(&client->dev, sizeof(*bd), GFP_KERNEL);

> > > -	if (!bd)

> > > -		return -ENOMEM;

> > > -

> > > -	i2c_set_clientdata(client, bd);

> > > -	bd->dev = &client->dev;

> > > -	bd->irq = client->irq;

> > > +	const struct bd957x_ddata *ddata;

> > > +	struct device *dev = &client->dev;

> > > +	struct regmap *regmap;

> > > +	struct regmap_irq_chip_data *irq_data;

> > > +	int ret, irq = client->irq;

> > > +

> > > +	/* Read the PMIC product code */

> > > +	ret = i2c_smbus_read_byte_data(client, BD9571MWV_PRODUCT_CODE);

> > > +	if (ret < 0) {

> > > +		dev_err(dev, "Failed to read product code\n");

> > > +		return ret;

> > > +	}

> > 

> > Nit: '\n' here.

> 

> I got it. I'll add a blank line here.

> 

> > > +	switch (ret) {

> > > +	case BD9571MWV_PRODUCT_CODE_BD9571MWV:

> > > +		ddata = &bd9571mwv_ddata;

> > 

> > Simply declare 'const struct mfd_cell *cells' locally in probe and

> > assign it here instead.

> 

> I got it. I'll also add "const struct regmap_config *regmap_config;"

> and "const struct regmap_irq_chip *irq_chip;" locally in probe.


If you only use them there, then yes, that's correct.

-- 
Lee Jones [李琼斯]
Senior Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog
Yoshihiro Shimoda Dec. 24, 2020, 8:23 a.m. UTC | #3
Hi Lee,

> From: Lee Jones, Sent: Thursday, December 24, 2020 4:34 PM

> > Hi Lee,

> >

> > > From: Lee Jones, Sent: Thursday, December 24, 2020 12:39 AM

> > > On Wed, 23 Dec 2020, Yoshihiro Shimoda wrote:

> > > > From: Khiem Nguyen <khiem.nguyen.xt@renesas.com>

<snip>
> > > > +	switch (ret) {

> > > > +	case BD9571MWV_PRODUCT_CODE_BD9571MWV:

> > > > +		ddata = &bd9571mwv_ddata;

> > >

> > > Simply declare 'const struct mfd_cell *cells' locally in probe and

> > > assign it here instead.

> >

> > I got it. I'll also add "const struct regmap_config *regmap_config;"

> > and "const struct regmap_irq_chip *irq_chip;" locally in probe.

> 

> If you only use them there, then yes, that's correct.


Thank you for the reply. Yes, I only use them there.
So, I have submitted v7 patches which have such implementation.

Best regards,
Yoshihiro Shimoda
Linus Walleij Dec. 27, 2020, 9:16 p.m. UTC | #4
On Wed, Dec 23, 2020 at 11:22 AM Yoshihiro Shimoda
<yoshihiro.shimoda.uh@renesas.com> wrote:

> Add support for BD9574MWF which is similar chip with BD9571MWV.

> Note that BD9574MWF has additional features "RECOV_GPOUT",

> "FREQSEL" and "RTC_IN", but supports GPIO function only.

>

> Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>

> Reviewed-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>


Acked-by: Linus Walleij <linus.walleij@linaro.org>


This looks like it compile-time depends on the other patches right?

Yours,
Linus Walleij
Yoshihiro Shimoda Jan. 12, 2021, 4:43 a.m. UTC | #5
Hi Linus,

> From: Linus Walleij, Sent: Monday, December 28, 2020 6:16 AM

> 

> > Add support for BD9574MWF which is similar chip with BD9571MWV.

> > Note that BD9574MWF has additional features "RECOV_GPOUT",

> > "FREQSEL" and "RTC_IN", but supports GPIO function only.

> >

> > Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>

> > Reviewed-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>

> 

> Acked-by: Linus Walleij <linus.walleij@linaro.org>


Thank you for your Acked-by! I'll add your Acked-by in the next patch version as v9.

> This looks like it compile-time depends on the other patches right?


You're correct.

Best regards,
Yoshihiro Shimoda