2021-01-12 23:32:42

by Yoshihiro Shimoda

[permalink] [raw]
Subject: [PATCH v9 00/12] treewide: bd9571mwv: Add support for BD9574MWF

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.

Hello Lee,

Now I got Acked-by from maintainers of gpio and regulator. So,
would you apply this series to your repo?

Changes from v8:
- Add Acked-by from maintainers of regulator and gpio in patch 4 to 8.
https://patchwork.kernel.org/project/linux-renesas-soc/list/?series=406323

Changes from v7:
- Fix typo in the patch 10.
- Add "Acked-for-MFD-by" in patch 2 and 11.
https://patchwork.kernel.org/project/linux-renesas-soc/list/?series=406091

Changes from v6:
- Remove "struct bd957x_ddata" because this is not used after probed.
- Add "Acked-for-MFD-by" in patch 12.
https://patchwork.kernel.org/project/linux-renesas-soc/list/?series=405725

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 | 178 ++++++++++++++-------
drivers/regulator/bd9571mwv-regulator.c | 59 ++++---
include/linux/mfd/bd9571mwv.h | 45 ++----
include/linux/mfd/rohm-generic.h | 2 +
6 files changed, 186 insertions(+), 137 deletions(-)

--
2.7.4


2021-01-12 23:33:25

by Yoshihiro Shimoda

[permalink] [raw]
Subject: [PATCH v9 11/12] mfd: bd9571mwv: Make the driver more generic

From: Khiem Nguyen <[email protected]>

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 <[email protected]>
Co-developed-by: Yoshihiro Shimoda <[email protected]>
Signed-off-by: Yoshihiro Shimoda <[email protected]>
Reviewed-by: Matti Vaittinen <[email protected]>
Acked-for-MFD-by: Lee Jones <[email protected]>
---
drivers/mfd/bd9571mwv.c | 77 +++++++++++++++++++++++--------------------
include/linux/mfd/bd9571mwv.h | 18 ++--------
2 files changed, 43 insertions(+), 52 deletions(-)

diff --git a/drivers/mfd/bd9571mwv.c b/drivers/mfd/bd9571mwv.c
index 49e968e..2c1fcbb 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 <[email protected]>
+ * Copyright (C) 2020 Renesas Electronics Corporation
*
* Based on the TPS65086 driver
*/
@@ -102,13 +103,12 @@ static struct regmap_irq_chip bd9571mwv_irq_chip = {
.num_irqs = ARRAY_SIZE(bd9571mwv_irqs),
};

-static int bd9571mwv_identify(struct bd9571mwv *bd)
+static int bd957x_identify(struct device *dev, struct regmap *regmap)
{
- struct device *dev = bd->dev;
unsigned int value;
int ret;

- ret = regmap_read(bd->regmap, BD9571MWV_VENDOR_CODE, &value);
+ ret = regmap_read(regmap, BD9571MWV_VENDOR_CODE, &value);
if (ret) {
dev_err(dev, "Failed to read vendor code register (ret=%i)\n",
ret);
@@ -121,66 +121,71 @@ static int bd9571mwv_identify(struct bd9571mwv *bd)
return -EINVAL;
}

- ret = regmap_read(bd->regmap, BD9571MWV_PRODUCT_CODE, &value);
+ ret = regmap_read(regmap, BD9571MWV_PRODUCT_CODE, &value);
if (ret) {
dev_err(dev, "Failed to read product code register (ret=%i)\n",
ret);
return ret;
}
-
- if (value != BD9571MWV_PRODUCT_CODE_VAL) {
- dev_err(dev, "Invalid product code ID %02x (expected %02x)\n",
- value, BD9571MWV_PRODUCT_CODE_VAL);
- return -EINVAL;
- }
-
- ret = regmap_read(bd->regmap, BD9571MWV_PRODUCT_REVISION, &value);
+ ret = regmap_read(regmap, BD9571MWV_PRODUCT_REVISION, &value);
if (ret) {
dev_err(dev, "Failed to read revision register (ret=%i)\n",
ret);
return ret;
}

- dev_info(dev, "Device: BD9571MWV rev. %d\n", value & 0xff);
-
return 0;
}

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;
+ const struct regmap_config *regmap_config;
+ const struct regmap_irq_chip *irq_chip;
+ const struct mfd_cell *cells;
+ struct device *dev = &client->dev;
+ struct regmap *regmap;
+ struct regmap_irq_chip_data *irq_data;
+ int ret, num_cells, 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;
+ }

- i2c_set_clientdata(client, bd);
- bd->dev = &client->dev;
- bd->irq = client->irq;
+ switch (ret) {
+ case BD9571MWV_PRODUCT_CODE_BD9571MWV:
+ regmap_config = &bd9571mwv_regmap_config;
+ irq_chip = &bd9571mwv_irq_chip;
+ cells = bd9571mwv_cells;
+ num_cells = ARRAY_SIZE(bd9571mwv_cells);
+ break;
+ default:
+ dev_err(dev, "Unsupported device 0x%x\n", ret);
+ return -ENODEV;
+ }

- bd->regmap = devm_regmap_init_i2c(client, &bd9571mwv_regmap_config);
- if (IS_ERR(bd->regmap)) {
- dev_err(bd->dev, "Failed to initialize register map\n");
- return PTR_ERR(bd->regmap);
+ regmap = devm_regmap_init_i2c(client, regmap_config);
+ if (IS_ERR(regmap)) {
+ dev_err(dev, "Failed to initialize register map\n");
+ return PTR_ERR(regmap);
}

- ret = bd9571mwv_identify(bd);
+ ret = bd957x_identify(dev, regmap);
if (ret)
return ret;

- ret = devm_regmap_add_irq_chip(bd->dev, bd->regmap, bd->irq,
- IRQF_ONESHOT, 0, &bd9571mwv_irq_chip,
- &bd->irq_data);
+ ret = devm_regmap_add_irq_chip(dev, regmap, irq, IRQF_ONESHOT, 0,
+ irq_chip, &irq_data);
if (ret) {
- dev_err(bd->dev, "Failed to register IRQ chip\n");
+ dev_err(dev, "Failed to register IRQ chip\n");
return ret;
}

- return devm_mfd_add_devices(bd->dev, PLATFORM_DEVID_AUTO,
- bd9571mwv_cells, ARRAY_SIZE(bd9571mwv_cells),
- NULL, 0, regmap_irq_get_domain(bd->irq_data));
+ return devm_mfd_add_devices(dev, PLATFORM_DEVID_AUTO, cells, num_cells,
+ NULL, 0, regmap_irq_get_domain(irq_data));
}

static const struct of_device_id bd9571mwv_of_match_table[] = {
diff --git a/include/linux/mfd/bd9571mwv.h b/include/linux/mfd/bd9571mwv.h
index bcc7092..e1716ec 100644
--- a/include/linux/mfd/bd9571mwv.h
+++ b/include/linux/mfd/bd9571mwv.h
@@ -3,6 +3,7 @@
* ROHM BD9571MWV-M driver
*
* Copyright (C) 2017 Marek Vasut <[email protected]>
+ * Copyright (C) 2020 Renesas Electronics Corporation
*
* Based on the TPS65086 driver
*/
@@ -17,7 +18,7 @@
#define BD9571MWV_VENDOR_CODE 0x00
#define BD9571MWV_VENDOR_CODE_VAL 0xdb
#define BD9571MWV_PRODUCT_CODE 0x01
-#define BD9571MWV_PRODUCT_CODE_VAL 0x60
+#define BD9571MWV_PRODUCT_CODE_BD9571MWV 0x60
#define BD9571MWV_PRODUCT_REVISION 0x02

#define BD9571MWV_I2C_FUSA_MODE 0x10
@@ -94,19 +95,4 @@ enum bd9571mwv_irqs {
BD9571MWV_IRQ_WDT_OF,
BD9571MWV_IRQ_BKUP_TRG,
};
-
-/**
- * struct bd9571mwv - state holder for the bd9571mwv driver
- *
- * Device data may be used to access the BD9571MWV chip
- */
-struct bd9571mwv {
- struct device *dev;
- struct regmap *regmap;
-
- /* IRQ Data */
- int irq;
- struct regmap_irq_chip_data *irq_data;
-};
-
#endif /* __LINUX_MFD_BD9571MWV_H */
--
2.7.4

2021-01-12 23:33:40

by Yoshihiro Shimoda

[permalink] [raw]
Subject: [PATCH v9 02/12] dt-bindings: mfd: bd9571mwv: Document BD9574MWF

Document other similar specification chip BD9574MWF.

Signed-off-by: Yoshihiro Shimoda <[email protected]>
Acked-for-MFD-by: Lee Jones <[email protected]>
---
Documentation/devicetree/bindings/mfd/bd9571mwv.txt | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/mfd/bd9571mwv.txt b/Documentation/devicetree/bindings/mfd/bd9571mwv.txt
index 8c46786..1d6413e 100644
--- a/Documentation/devicetree/bindings/mfd/bd9571mwv.txt
+++ b/Documentation/devicetree/bindings/mfd/bd9571mwv.txt
@@ -1,7 +1,7 @@
-* ROHM BD9571MWV Power Management Integrated Circuit (PMIC) bindings
+* ROHM BD9571MWV/BD9574MWF Power Management Integrated Circuit (PMIC) bindings

Required properties:
- - compatible : Should be "rohm,bd9571mwv".
+ - compatible : Should be "rohm,bd9571mwv" or "rohm,bd9574mwf".
- reg : I2C slave address.
- interrupts : The interrupt line the device is connected to.
- interrupt-controller : Marks the device node as an interrupt controller.
--
2.7.4

2021-01-12 23:34:41

by Yoshihiro Shimoda

[permalink] [raw]
Subject: [PATCH v9 10/12] mfd: bd9571mwv: Use devm_regmap_add_irq_chip()

Use devm_regmap_add_irq_chip() to simplify the code.

Signed-off-by: Yoshihiro Shimoda <[email protected]>
Acked-for-MFD-by: Lee Jones <[email protected]>
Reviewed-by: Matti Vaittinen <[email protected]>
Reviewed-by: Geert Uytterhoeven <[email protected]>
---
drivers/mfd/bd9571mwv.c | 27 ++++++---------------------
1 file changed, 6 insertions(+), 21 deletions(-)

diff --git a/drivers/mfd/bd9571mwv.c b/drivers/mfd/bd9571mwv.c
index e68c3fa..49e968e 100644
--- a/drivers/mfd/bd9571mwv.c
+++ b/drivers/mfd/bd9571mwv.c
@@ -170,31 +170,17 @@ static int bd9571mwv_probe(struct i2c_client *client,
if (ret)
return ret;

- ret = regmap_add_irq_chip(bd->regmap, bd->irq, IRQF_ONESHOT, 0,
- &bd9571mwv_irq_chip, &bd->irq_data);
+ ret = devm_regmap_add_irq_chip(bd->dev, bd->regmap, bd->irq,
+ IRQF_ONESHOT, 0, &bd9571mwv_irq_chip,
+ &bd->irq_data);
if (ret) {
dev_err(bd->dev, "Failed to register IRQ chip\n");
return ret;
}

- ret = devm_mfd_add_devices(bd->dev, PLATFORM_DEVID_AUTO,
- bd9571mwv_cells, ARRAY_SIZE(bd9571mwv_cells),
- NULL, 0, regmap_irq_get_domain(bd->irq_data));
- if (ret) {
- regmap_del_irq_chip(bd->irq, bd->irq_data);
- return ret;
- }
-
- return 0;
-}
-
-static int bd9571mwv_remove(struct i2c_client *client)
-{
- struct bd9571mwv *bd = i2c_get_clientdata(client);
-
- regmap_del_irq_chip(bd->irq, bd->irq_data);
-
- return 0;
+ return devm_mfd_add_devices(bd->dev, PLATFORM_DEVID_AUTO,
+ bd9571mwv_cells, ARRAY_SIZE(bd9571mwv_cells),
+ NULL, 0, regmap_irq_get_domain(bd->irq_data));
}

static const struct of_device_id bd9571mwv_of_match_table[] = {
@@ -215,7 +201,6 @@ static struct i2c_driver bd9571mwv_driver = {
.of_match_table = bd9571mwv_of_match_table,
},
.probe = bd9571mwv_probe,
- .remove = bd9571mwv_remove,
.id_table = bd9571mwv_id_table,
};
module_i2c_driver(bd9571mwv_driver);
--
2.7.4

2021-01-12 23:35:00

by Yoshihiro Shimoda

[permalink] [raw]
Subject: [PATCH v9 06/12] gpio: bd9571mwv: Use the SPDX license identifier

Use the SPDX license identifier instead of a local description.

Signed-off-by: Yoshihiro Shimoda <[email protected]>
Reviewed-by: Geert Uytterhoeven <[email protected]>
Reviewed-by: Linus Walleij <[email protected]>
Acked-by: Bartosz Golaszewski <[email protected]>
---
drivers/gpio/gpio-bd9571mwv.c | 10 +---------
1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/drivers/gpio/gpio-bd9571mwv.c b/drivers/gpio/gpio-bd9571mwv.c
index c0abc9c..abb622c 100644
--- a/drivers/gpio/gpio-bd9571mwv.c
+++ b/drivers/gpio/gpio-bd9571mwv.c
@@ -1,17 +1,9 @@
+// SPDX-License-Identifier: GPL-2.0-only
/*
* ROHM BD9571MWV-M GPIO driver
*
* Copyright (C) 2017 Marek Vasut <[email protected]>
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
- * kind, whether expressed or implied; without even the implied warranty
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License version 2 for more details.
- *
* Based on the TPS65086 driver
*
* NOTE: Interrupts are not supported yet.
--
2.7.4

2021-01-12 23:35:19

by Yoshihiro Shimoda

[permalink] [raw]
Subject: [PATCH v9 03/12] mfd: rohm-generic: Add BD9571 and BD9574

Add chip IDs for BD9571MWV and BD9574MWF.

Signed-off-by: Yoshihiro Shimoda <[email protected]>
Reviewed-by: Matti Vaittinen <[email protected]>
Acked-for-MFD-by: Lee Jones <[email protected]>
---
include/linux/mfd/rohm-generic.h | 2 ++
1 file changed, 2 insertions(+)

diff --git a/include/linux/mfd/rohm-generic.h b/include/linux/mfd/rohm-generic.h
index 4283b5b..affacf8 100644
--- a/include/linux/mfd/rohm-generic.h
+++ b/include/linux/mfd/rohm-generic.h
@@ -12,6 +12,8 @@ enum rohm_chip_type {
ROHM_CHIP_TYPE_BD71847,
ROHM_CHIP_TYPE_BD70528,
ROHM_CHIP_TYPE_BD71828,
+ ROHM_CHIP_TYPE_BD9571,
+ ROHM_CHIP_TYPE_BD9574,
ROHM_CHIP_TYPE_AMOUNT
};

--
2.7.4

2021-01-12 23:36:45

by Yoshihiro Shimoda

[permalink] [raw]
Subject: [PATCH v9 09/12] mfd: bd9571mwv: Use the SPDX license identifier

Use the SPDX license identifier instead of a local description.

Signed-off-by: Yoshihiro Shimoda <[email protected]>
Reviewed-by: Geert Uytterhoeven <[email protected]>
Acked-for-MFD-by: Lee Jones <[email protected]>
---
drivers/mfd/bd9571mwv.c | 10 +---------
include/linux/mfd/bd9571mwv.h | 10 +---------
2 files changed, 2 insertions(+), 18 deletions(-)

diff --git a/drivers/mfd/bd9571mwv.c b/drivers/mfd/bd9571mwv.c
index 19d57a4..e68c3fa 100644
--- a/drivers/mfd/bd9571mwv.c
+++ b/drivers/mfd/bd9571mwv.c
@@ -1,17 +1,9 @@
+// SPDX-License-Identifier: GPL-2.0-only
/*
* ROHM BD9571MWV-M MFD driver
*
* Copyright (C) 2017 Marek Vasut <[email protected]>
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
- * kind, whether expressed or implied; without even the implied warranty
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License version 2 for more details.
- *
* Based on the TPS65086 driver
*/

diff --git a/include/linux/mfd/bd9571mwv.h b/include/linux/mfd/bd9571mwv.h
index eb05569..bcc7092 100644
--- a/include/linux/mfd/bd9571mwv.h
+++ b/include/linux/mfd/bd9571mwv.h
@@ -1,17 +1,9 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
/*
* ROHM BD9571MWV-M driver
*
* Copyright (C) 2017 Marek Vasut <[email protected]>
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
- * kind, whether expressed or implied; without even the implied warranty
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License version 2 for more details.
- *
* Based on the TPS65086 driver
*/

--
2.7.4

2021-01-14 13:10:44

by Lee Jones

[permalink] [raw]
Subject: [GIT PULL] Immutable branch between MFD, GPIO and Regulator due for the v5.12 merge window

Enjoy!

The following changes since commit 5c8fe583cce542aa0b84adc939ce85293de36e5e:

Linux 5.11-rc1 (2020-12-27 15:30:22 -0800)

are available in the Git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd.git ib-mfd-gpio-regulator-v5.12

for you to fetch changes up to b2548da647bb04737196ffd945505d47a166239b:

mfd: bd9571mwv: Add support for BD9574MWF (2021-01-14 13:05:55 +0000)

----------------------------------------------------------------
Immutable branch between MFD, GPIO and Regulator due for the v5.12 merge window

----------------------------------------------------------------
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 | 178 ++++++++++++++-------
drivers/regulator/bd9571mwv-regulator.c | 59 ++++---
include/linux/mfd/bd9571mwv.h | 45 ++----
include/linux/mfd/rohm-generic.h | 2 +
6 files changed, 186 insertions(+), 137 deletions(-)

--
Lee Jones [李琼斯]
Senior Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog