diff mbox

[v3,2/5] mfd: add bcm590xx pmu driver

Message ID 1394552775-31264-3-git-send-email-mporter@linaro.org
State New
Headers show

Commit Message

Matt Porter March 11, 2014, 3:46 p.m. UTC
Add a driver for the BCM590xx PMU multi-function devices. The driver
initially supports regmap initialization and instantiation of the
voltage regulator device function of the PMU.

Signed-off-by: Matt Porter <mporter@linaro.org>
Reviewed-by: Tim Kryger <tim.kryger@linaro.org>
Reviewed-by: Markus Mayer <markus.mayer@linaro.org>
---
 drivers/mfd/Kconfig          |  8 ++++
 drivers/mfd/Makefile         |  1 +
 drivers/mfd/bcm590xx.c       | 93 ++++++++++++++++++++++++++++++++++++++++++++
 include/linux/mfd/bcm590xx.h | 31 +++++++++++++++
 4 files changed, 133 insertions(+)
 create mode 100644 drivers/mfd/bcm590xx.c
 create mode 100644 include/linux/mfd/bcm590xx.h

Comments

Lee Jones March 11, 2014, 4:08 p.m. UTC | #1
> Add a driver for the BCM590xx PMU multi-function devices. The driver
> initially supports regmap initialization and instantiation of the
> voltage regulator device function of the PMU.
> 
> Signed-off-by: Matt Porter <mporter@linaro.org>
> Reviewed-by: Tim Kryger <tim.kryger@linaro.org>
> Reviewed-by: Markus Mayer <markus.mayer@linaro.org>
> ---
>  drivers/mfd/Kconfig          |  8 ++++
>  drivers/mfd/Makefile         |  1 +
>  drivers/mfd/bcm590xx.c       | 93 ++++++++++++++++++++++++++++++++++++++++++++
>  include/linux/mfd/bcm590xx.h | 31 +++++++++++++++
>  4 files changed, 133 insertions(+)
>  create mode 100644 drivers/mfd/bcm590xx.c
>  create mode 100644 include/linux/mfd/bcm590xx.h

I have a tiny nit that 'ret' doesn't need to be initialised before
use in probe(), but apart from that...

Looks pretty sensible:
  Acked-by: Lee Jones <lee.jones@linaro.org>
Matt Porter March 11, 2014, 10:19 p.m. UTC | #2
On Tue, Mar 11, 2014 at 04:08:37PM +0000, Lee Jones wrote:
> > Add a driver for the BCM590xx PMU multi-function devices. The driver
> > initially supports regmap initialization and instantiation of the
> > voltage regulator device function of the PMU.
> > 
> > Signed-off-by: Matt Porter <mporter@linaro.org>
> > Reviewed-by: Tim Kryger <tim.kryger@linaro.org>
> > Reviewed-by: Markus Mayer <markus.mayer@linaro.org>
> > ---
> >  drivers/mfd/Kconfig          |  8 ++++
> >  drivers/mfd/Makefile         |  1 +
> >  drivers/mfd/bcm590xx.c       | 93 ++++++++++++++++++++++++++++++++++++++++++++
> >  include/linux/mfd/bcm590xx.h | 31 +++++++++++++++
> >  4 files changed, 133 insertions(+)
> >  create mode 100644 drivers/mfd/bcm590xx.c
> >  create mode 100644 include/linux/mfd/bcm590xx.h
> 
> I have a tiny nit that 'ret' doesn't need to be initialised before
> use in probe(), but apart from that...
> 
> Looks pretty sensible:
>   Acked-by: Lee Jones <lee.jones@linaro.org>

Ok, thanks. When I get back in front of my desktop I'll send a v4 of
just this patch to address that nit. Mark already applied the regulator
driver from this series, will you be taking this through your tree? For
that matter, I wonder if the binding would also go through your tree
with this driver.

-Matt
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
Lee Jones March 11, 2014, 10:45 p.m. UTC | #3
> > > Add a driver for the BCM590xx PMU multi-function devices. The driver
> > > initially supports regmap initialization and instantiation of the
> > > voltage regulator device function of the PMU.
> > > 
> > > Signed-off-by: Matt Porter <mporter@linaro.org>
> > > Reviewed-by: Tim Kryger <tim.kryger@linaro.org>
> > > Reviewed-by: Markus Mayer <markus.mayer@linaro.org>
> > > ---
> > >  drivers/mfd/Kconfig          |  8 ++++
> > >  drivers/mfd/Makefile         |  1 +
> > >  drivers/mfd/bcm590xx.c       | 93 ++++++++++++++++++++++++++++++++++++++++++++
> > >  include/linux/mfd/bcm590xx.h | 31 +++++++++++++++
> > >  4 files changed, 133 insertions(+)
> > >  create mode 100644 drivers/mfd/bcm590xx.c
> > >  create mode 100644 include/linux/mfd/bcm590xx.h
> > 
> > I have a tiny nit that 'ret' doesn't need to be initialised before
> > use in probe(), but apart from that...
> > 
> > Looks pretty sensible:
> >   Acked-by: Lee Jones <lee.jones@linaro.org>
> 
> Ok, thanks. When I get back in front of my desktop I'll send a v4 of
> just this patch to address that nit. Mark already applied the regulator
> driver from this series, will you be taking this through your tree? For
> that matter, I wonder if the binding would also go through your tree
> with this driver.

At least the MFD portion and the DT binding doc will go through the
MFD tree.

Are there any inter-patch dependencies in the set? If so, we should
know about them so we can coordinate a sensible solution.
Matt Porter March 11, 2014, 11:25 p.m. UTC | #4
On Tue, Mar 11, 2014 at 10:45:17PM +0000, Lee Jones wrote:
> > > > Add a driver for the BCM590xx PMU multi-function devices. The driver
> > > > initially supports regmap initialization and instantiation of the
> > > > voltage regulator device function of the PMU.
> > > > 
> > > > Signed-off-by: Matt Porter <mporter@linaro.org>
> > > > Reviewed-by: Tim Kryger <tim.kryger@linaro.org>
> > > > Reviewed-by: Markus Mayer <markus.mayer@linaro.org>
> > > > ---
> > > >  drivers/mfd/Kconfig          |  8 ++++
> > > >  drivers/mfd/Makefile         |  1 +
> > > >  drivers/mfd/bcm590xx.c       | 93 ++++++++++++++++++++++++++++++++++++++++++++
> > > >  include/linux/mfd/bcm590xx.h | 31 +++++++++++++++
> > > >  4 files changed, 133 insertions(+)
> > > >  create mode 100644 drivers/mfd/bcm590xx.c
> > > >  create mode 100644 include/linux/mfd/bcm590xx.h
> > > 
> > > I have a tiny nit that 'ret' doesn't need to be initialised before
> > > use in probe(), but apart from that...
> > > 
> > > Looks pretty sensible:
> > >   Acked-by: Lee Jones <lee.jones@linaro.org>
> > 
> > Ok, thanks. When I get back in front of my desktop I'll send a v4 of
> > just this patch to address that nit. Mark already applied the regulator
> > driver from this series, will you be taking this through your tree? For
> > that matter, I wonder if the binding would also go through your tree
> > with this driver.
> 
> At least the MFD portion and the DT binding doc will go through the
> MFD tree.
> 
> Are there any inter-patch dependencies in the set? If so, we should
> know about them so we can coordinate a sensible solution.

Yes, the regulator driver (3/5) that Mark applied is dependent on this
patch...the regulator driver includes include/linux/mfd/bcm590xx.h.

-Matt
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Mark Brown March 12, 2014, 12:40 a.m. UTC | #5
On Tue, Mar 11, 2014 at 07:25:45PM -0400, Matt Porter wrote:
> On Tue, Mar 11, 2014 at 10:45:17PM +0000, Lee Jones wrote:

> > Are there any inter-patch dependencies in the set? If so, we should
> > know about them so we can coordinate a sensible solution.

> Yes, the regulator driver (3/5) that Mark applied is dependent on this
> patch...the regulator driver includes include/linux/mfd/bcm590xx.h.

There's no actual dependency though - the regulator driver can only be
built if the MFD is enabled in Kconfig since it depends on it so until
the MFD is present in the tree it won't get built.
Matt Porter March 12, 2014, 12:57 a.m. UTC | #6
On Wed, Mar 12, 2014 at 12:40:30AM +0000, Mark Brown wrote:
> On Tue, Mar 11, 2014 at 07:25:45PM -0400, Matt Porter wrote:
> > On Tue, Mar 11, 2014 at 10:45:17PM +0000, Lee Jones wrote:
> 
> > > Are there any inter-patch dependencies in the set? If so, we should
> > > know about them so we can coordinate a sensible solution.
> 
> > Yes, the regulator driver (3/5) that Mark applied is dependent on this
> > patch...the regulator driver includes include/linux/mfd/bcm590xx.h.
> 
> There's no actual dependency though - the regulator driver can only be
> built if the MFD is enabled in Kconfig since it depends on it so until
> the MFD is present in the tree it won't get built.

Oh, right. Lee, no dependencies then.

-Matt
Lee Jones March 12, 2014, 9:23 a.m. UTC | #7
> > > > Are there any inter-patch dependencies in the set? If so, we should
> > > > know about them so we can coordinate a sensible solution.
> > 
> > > Yes, the regulator driver (3/5) that Mark applied is dependent on this
> > > patch...the regulator driver includes include/linux/mfd/bcm590xx.h.
> > 
> > There's no actual dependency though - the regulator driver can only be
> > built if the MFD is enabled in Kconfig since it depends on it so until
> > the MFD is present in the tree it won't get built.
> 
> Oh, right. Lee, no dependencies then.

Perfect, I'll just apply the MFD patch.

We still need the DT guys to look over your document, so nothing will
be certain until a) we receive their Ack or b) enough time passes, so
we will review it between ourselves.
Lee Jones March 12, 2014, 9:35 a.m. UTC | #8
> Add a driver for the BCM590xx PMU multi-function devices. The driver
> initially supports regmap initialization and instantiation of the
> voltage regulator device function of the PMU.
> 
> Signed-off-by: Matt Porter <mporter@linaro.org>
> Reviewed-by: Tim Kryger <tim.kryger@linaro.org>
> Reviewed-by: Markus Mayer <markus.mayer@linaro.org>
> ---
>  drivers/mfd/Kconfig          |  8 ++++
>  drivers/mfd/Makefile         |  1 +
>  drivers/mfd/bcm590xx.c       | 93 ++++++++++++++++++++++++++++++++++++++++++++
>  include/linux/mfd/bcm590xx.h | 31 +++++++++++++++
>  4 files changed, 133 insertions(+)
>  create mode 100644 drivers/mfd/bcm590xx.c
>  create mode 100644 include/linux/mfd/bcm590xx.h

Applied, thanks.
diff mbox

Patch

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 49bb445..27ff37c 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -59,6 +59,14 @@  config MFD_AAT2870_CORE
 	  additional drivers must be enabled in order to use the
 	  functionality of the device.
 
+config MFD_BCM590XX
+	tristate "Broadcom BCM590xx PMUs"
+	select MFD_CORE
+	select REGMAP_I2C
+	depends on I2C
+	help
+	  Support for the BCM590xx PMUs from Broadcom
+
 config MFD_CROS_EC
 	tristate "ChromeOS Embedded Controller"
 	select MFD_CORE
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 5aea5ef..4c342bf 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -8,6 +8,7 @@  obj-$(CONFIG_MFD_88PM800)	+= 88pm800.o 88pm80x.o
 obj-$(CONFIG_MFD_88PM805)	+= 88pm805.o 88pm80x.o
 obj-$(CONFIG_MFD_SM501)		+= sm501.o
 obj-$(CONFIG_MFD_ASIC3)		+= asic3.o tmio_core.o
+obj-$(CONFIG_MFD_BCM590XX)	+= bcm590xx.o
 obj-$(CONFIG_MFD_CROS_EC)	+= cros_ec.o
 obj-$(CONFIG_MFD_CROS_EC_I2C)	+= cros_ec_i2c.o
 obj-$(CONFIG_MFD_CROS_EC_SPI)	+= cros_ec_spi.o
diff --git a/drivers/mfd/bcm590xx.c b/drivers/mfd/bcm590xx.c
new file mode 100644
index 0000000..ebfe98a
--- /dev/null
+++ b/drivers/mfd/bcm590xx.c
@@ -0,0 +1,93 @@ 
+/*
+ * Broadcom BCM590xx PMU
+ *
+ * Copyright 2014 Linaro Limited
+ * Author: Matt Porter <mporter@linaro.org>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under  the terms of the GNU General  Public License as published by the
+ * Free Software Foundation;  either version 2 of the License, or (at your
+ * option) any later version.
+ */
+
+#include <linux/err.h>
+#include <linux/i2c.h>
+#include <linux/init.h>
+#include <linux/mfd/bcm590xx.h>
+#include <linux/mfd/core.h>
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
+#include <linux/regmap.h>
+#include <linux/slab.h>
+
+static const struct mfd_cell bcm590xx_devs[] = {
+	{
+		.name = "bcm590xx-vregs",
+	},
+};
+
+static const struct regmap_config bcm590xx_regmap_config = {
+	.reg_bits	= 8,
+	.val_bits	= 8,
+	.max_register	= BCM590XX_MAX_REGISTER,
+	.cache_type	= REGCACHE_RBTREE,
+};
+
+static int bcm590xx_i2c_probe(struct i2c_client *i2c,
+			      const struct i2c_device_id *id)
+{
+	struct bcm590xx *bcm590xx;
+	int ret = 0;
+
+	bcm590xx = devm_kzalloc(&i2c->dev, sizeof(*bcm590xx), GFP_KERNEL);
+	if (!bcm590xx)
+		return -ENOMEM;
+
+	i2c_set_clientdata(i2c, bcm590xx);
+	bcm590xx->dev = &i2c->dev;
+	bcm590xx->i2c_client = i2c;
+
+	bcm590xx->regmap = devm_regmap_init_i2c(i2c, &bcm590xx_regmap_config);
+	if (IS_ERR(bcm590xx->regmap)) {
+		ret = PTR_ERR(bcm590xx->regmap);
+		dev_err(&i2c->dev, "regmap initialization failed: %d\n", ret);
+		return ret;
+	}
+
+	ret = mfd_add_devices(&i2c->dev, -1, bcm590xx_devs,
+			      ARRAY_SIZE(bcm590xx_devs), NULL, 0, NULL);
+	if (ret < 0)
+		dev_err(&i2c->dev, "failed to add sub-devices: %d\n", ret);
+
+	return ret;
+}
+
+static const struct of_device_id bcm590xx_of_match[] = {
+	{ .compatible = "brcm,bcm59056" },
+	{ }
+};
+MODULE_DEVICE_TABLE(i2c, bcm590xx_of_match);
+
+static const struct i2c_device_id bcm590xx_i2c_id[] = {
+	{ "bcm59056" },
+	{ }
+};
+MODULE_DEVICE_TABLE(i2c, bcm590xx_i2c_id);
+
+static struct i2c_driver bcm590xx_i2c_driver = {
+	.driver = {
+		   .name = "bcm590xx",
+		   .owner = THIS_MODULE,
+		   .of_match_table = of_match_ptr(bcm590xx_of_match),
+	},
+	.probe = bcm590xx_i2c_probe,
+	.id_table = bcm590xx_i2c_id,
+};
+module_i2c_driver(bcm590xx_i2c_driver);
+
+MODULE_AUTHOR("Matt Porter <mporter@linaro.org>");
+MODULE_DESCRIPTION("BCM590xx multi-function driver");
+MODULE_LICENSE("GPL v2");
+MODULE_ALIAS("platform:bcm590xx");
diff --git a/include/linux/mfd/bcm590xx.h b/include/linux/mfd/bcm590xx.h
new file mode 100644
index 0000000..434df2d
--- /dev/null
+++ b/include/linux/mfd/bcm590xx.h
@@ -0,0 +1,31 @@ 
+/*
+ * Broadcom BCM590xx PMU
+ *
+ * Copyright 2014 Linaro Limited
+ * Author: Matt Porter <mporter@linaro.org>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under  the terms of the GNU General  Public License as published by the
+ * Free Software Foundation;  either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ */
+
+#ifndef __LINUX_MFD_BCM590XX_H
+#define __LINUX_MFD_BCM590XX_H
+
+#include <linux/device.h>
+#include <linux/i2c.h>
+#include <linux/regmap.h>
+
+/* max register address */
+#define BCM590XX_MAX_REGISTER	0xe7
+
+struct bcm590xx {
+	struct device *dev;
+	struct i2c_client *i2c_client;
+	struct regmap *regmap;
+	unsigned int id;
+};
+
+#endif /*  __LINUX_MFD_BCM590XX_H */