[v7,05/10] clk: bd718x7: Support ROHM BD70528 clk block

Message ID 88c49b30bbb4b1f3ecc24d333647585e2c82f4e4.1549444366.git.matti.vaittinen@fi.rohmeurope.com
State New
Headers show
Series
  • support ROHM BD70528 PMIC
Related show

Commit Message

Matti Vaittinen Feb. 6, 2019, 9:39 a.m.
ROHM BD70528 is an ultra low power PMIC with similar 32K clk as
bd718x7. Only difference (from clk perspective) is register address.
Add support for controlling BD70528 clk using bd718x7 driver.

Signed-off-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
---
 drivers/clk/Kconfig       |  6 +++---
 drivers/clk/clk-bd718x7.c | 21 +++++++++++++++++----
 2 files changed, 20 insertions(+), 7 deletions(-)

Comments

Stephen Boyd Feb. 6, 2019, 5:31 p.m. | #1
Quoting Matti Vaittinen (2019-02-06 01:39:38)
> @@ -86,9 +87,21 @@ static int bd71837_clk_probe(struct platform_device *pdev)
>                 dev_err(&pdev->dev, "No parent clk found\n");
>                 return -EINVAL;
>         }
> -
> -       c->reg = BD718XX_REG_OUT32K;
> -       c->mask = BD718XX_OUT32K_EN;
> +       switch (mfd->chip_type) {
> +       case ROHM_CHIP_TYPE_BD71837:
> +       case ROHM_CHIP_TYPE_BD71847:
> +

Nitpick: why the extra newline above?

> +               c->reg = BD718XX_REG_OUT32K;
> +               c->mask = BD718XX_OUT32K_EN;
> +               break;
> +       case ROHM_CHIP_TYPE_BD70528:
> +               c->reg = BD70528_REG_CLK_OUT;
> +               c->mask = BD70528_CLK_OUT_EN_MASK;
> +               break;
> +       default:
> +               dev_err(&pdev->dev, "Unknown clk chip\n");
> +               return -EINVAL;
> +       }
>         c->mfd = mfd;
>         c->pdev = pdev;
>         c->hw.init = &init;
Matti Vaittinen Feb. 7, 2019, 6:01 a.m. | #2
On Wed, Feb 06, 2019 at 09:31:27AM -0800, Stephen Boyd wrote:
> Quoting Matti Vaittinen (2019-02-06 01:39:38)
> > @@ -86,9 +87,21 @@ static int bd71837_clk_probe(struct platform_device *pdev)
> >                 dev_err(&pdev->dev, "No parent clk found\n");
> >                 return -EINVAL;
> >         }
> > -
> > -       c->reg = BD718XX_REG_OUT32K;
> > -       c->mask = BD718XX_OUT32K_EN;
> > +       switch (mfd->chip_type) {
> > +       case ROHM_CHIP_TYPE_BD71837:
> > +       case ROHM_CHIP_TYPE_BD71847:
> > +
> 
> Nitpick: why the extra newline above?
For no obvious reason. I'll fix this as I need to create new version
anyways. I'll squash the first 3 patches and fix some issues pointed out
by the 0-Day test suite.

Br,
	Matti Vaittinen

Patch

diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig
index e5b2fe80eab4..992cfb86f2ca 100644
--- a/drivers/clk/Kconfig
+++ b/drivers/clk/Kconfig
@@ -285,10 +285,10 @@  config COMMON_CLK_STM32H7
 
 config COMMON_CLK_BD718XX
 	tristate "Clock driver for ROHM BD718x7 PMIC"
-	depends on MFD_ROHM_BD718XX
+	depends on MFD_ROHM_BD718XX || MFD_ROHM_BD70528
 	help
-	  This driver supports ROHM BD71837 and ROHM BD71847
-	  PMICs clock gates.
+	  This driver supports ROHM BD71837, ROHM BD71847 and
+	  ROHM BD70528 PMICs clock gates.
 
 source "drivers/clk/actions/Kconfig"
 source "drivers/clk/bcm/Kconfig"
diff --git a/drivers/clk/clk-bd718x7.c b/drivers/clk/clk-bd718x7.c
index 461228ebf703..41c1374f4217 100644
--- a/drivers/clk/clk-bd718x7.c
+++ b/drivers/clk/clk-bd718x7.c
@@ -8,6 +8,7 @@ 
 #include <linux/platform_device.h>
 #include <linux/slab.h>
 #include <linux/mfd/rohm-bd718x7.h>
+#include <linux/mfd/rohm-bd70528.h>
 #include <linux/clk-provider.h>
 #include <linux/clkdev.h>
 #include <linux/regmap.h>
@@ -86,9 +87,21 @@  static int bd71837_clk_probe(struct platform_device *pdev)
 		dev_err(&pdev->dev, "No parent clk found\n");
 		return -EINVAL;
 	}
-
-	c->reg = BD718XX_REG_OUT32K;
-	c->mask = BD718XX_OUT32K_EN;
+	switch (mfd->chip_type) {
+	case ROHM_CHIP_TYPE_BD71837:
+	case ROHM_CHIP_TYPE_BD71847:
+
+		c->reg = BD718XX_REG_OUT32K;
+		c->mask = BD718XX_OUT32K_EN;
+		break;
+	case ROHM_CHIP_TYPE_BD70528:
+		c->reg = BD70528_REG_CLK_OUT;
+		c->mask = BD70528_CLK_OUT_EN_MASK;
+		break;
+	default:
+		dev_err(&pdev->dev, "Unknown clk chip\n");
+		return -EINVAL;
+	}
 	c->mfd = mfd;
 	c->pdev = pdev;
 	c->hw.init = &init;
@@ -119,5 +132,5 @@  static struct platform_driver bd71837_clk = {
 module_platform_driver(bd71837_clk);
 
 MODULE_AUTHOR("Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>");
-MODULE_DESCRIPTION("BD71837/BD71847 chip clk driver");
+MODULE_DESCRIPTION("BD71837/BD71847/BD70528 chip clk driver");
 MODULE_LICENSE("GPL");