linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v6 0/4]  mfd: lp873x: Add lp873x PMIC support
@ 2016-08-08  5:46 Keerthy
  2016-08-08  5:46 ` [PATCH v6 1/4] Documentation: mfd: LP873X: Add information for the mfd driver Keerthy
                   ` (3 more replies)
  0 siblings, 4 replies; 15+ messages in thread
From: Keerthy @ 2016-08-08  5:46 UTC (permalink / raw)
  To: broonie, lee.jones, tony
  Cc: j-keerthy, linus.walleij, gnurou, linux-omap, linux-kernel,
	devicetree, linux-gpio, robh+dt

The LP873X chip is a power management IC for Portable Navigation Systems
    and Tablet Computing devices. It contains the following components:

     - Regulators.
     - Configurable General Purpose Output Signals(GPO).

PMIC interacts with the main processor through i2c. PMIC has
couple of LDOs(Linear Regulators), couple of BUCKs (Step-Down DC-DC
Converter Cores) and GPOs(General Purpose Output Signals).

The regulator patch is already queued:
http://marc.info/?l=linux-kernel&m=146298767110771&w=2

Hence posting the remaining patches of the series with
the comments fixed on mfd driver.

Changes in v6:

Series depends on: http://www.gossamer-threads.com/lists/linux/kernel/2457552
probe_new used.

Chnages in v4:

Added GPO driver support.

Keerthy (4):
  Documentation: mfd: LP873X: Add information for the mfd driver
  mfd: lp873x: Add lp873x PMIC support
  gpio: lp873x: Add support for General Purpose Outputs
  regulator: lp873x: Change the MFD config option as per latest naming

 Documentation/devicetree/bindings/mfd/lp873x.txt |  59 +++++
 drivers/gpio/Kconfig                             |  10 +
 drivers/gpio/Makefile                            |   1 +
 drivers/gpio/gpio-lp873x.c                       | 185 ++++++++++++++++
 drivers/mfd/Kconfig                              |  14 ++
 drivers/mfd/Makefile                             |   2 +
 drivers/mfd/lp873x.c                             |  89 ++++++++
 drivers/regulator/Kconfig                        |   2 +-
 include/linux/mfd/lp873x.h                       | 264 +++++++++++++++++++++++
 9 files changed, 625 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/mfd/lp873x.txt
 create mode 100644 drivers/gpio/gpio-lp873x.c
 create mode 100644 drivers/mfd/lp873x.c
 create mode 100644 include/linux/mfd/lp873x.h

-- 
1.9.1

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH v6 1/4] Documentation: mfd: LP873X: Add information for the mfd driver
  2016-08-08  5:46 [PATCH v6 0/4] mfd: lp873x: Add lp873x PMIC support Keerthy
@ 2016-08-08  5:46 ` Keerthy
  2016-08-09 12:50   ` Lee Jones
  2016-08-08  5:46 ` [PATCH v6 2/4] mfd: lp873x: Add lp873x PMIC support Keerthy
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 15+ messages in thread
From: Keerthy @ 2016-08-08  5:46 UTC (permalink / raw)
  To: broonie, lee.jones, tony
  Cc: j-keerthy, linus.walleij, gnurou, linux-omap, linux-kernel,
	devicetree, linux-gpio, robh+dt

The lp873x series of PMICs have a bunch of regulators and a couple
of GPO(General Purpose Outputs).
Add information for the MFD and regulator drivers.

Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Keerthy <j-keerthy@ti.com>
---
Changes in v6:

  * Added more formating for properties.

Changes in v4:

  * Added the GPIO properties.

Changes in v3:

  * Changed the example node lable to pmic from lp8733.

 Documentation/devicetree/bindings/mfd/lp873x.txt | 59 ++++++++++++++++++++++++
 1 file changed, 59 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/lp873x.txt

diff --git a/Documentation/devicetree/bindings/mfd/lp873x.txt b/Documentation/devicetree/bindings/mfd/lp873x.txt
new file mode 100644
index 0000000..1377c25
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/lp873x.txt
@@ -0,0 +1,59 @@
+TI LP873X PMIC MFD driver
+
+Required properties:
+  - compatible:	"ti,lp8732", "ti,lp8733"
+  - reg:		I2C slave address.
+  - gpio-controller:	Marks the device node as a GPIO Controller.
+  - #gpio-cells:	Should be two.  The first cell is the pin number and
+			the second cell is used to specify flags.
+			See ../gpio/gpio.txt for more information.
+  - regulators:	List of child nodes that specify the regulator
+			initialization data.
+Example:
+
+pmic: lp8733@60 {
+	compatible = "ti,lp8733";
+	reg = <0x60>;
+	gpio-controller;
+	#gpio-cells = <2>;
+
+	regulators {
+		lp8733_buck0: buck0 {
+			regulator-name = "lp8733-buck0";
+			regulator-min-microvolt = <800000>;
+			regulator-max-microvolt = <1400000>;
+			regulator-min-microamp = <1500000>;
+			regulator-max-microamp = <4000000>;
+			regulator-ramp-delay = <10000>;
+			regulator-always-on;
+			regulator-boot-on;
+		};
+
+		lp8733_buck1: buck1 {
+			regulator-name = "lp8733-buck1";
+			regulator-min-microvolt = <800000>;
+			regulator-max-microvolt = <1400000>;
+			regulator-min-microamp = <1500000>;
+			regulator-max-microamp = <4000000>;
+			regulator-ramp-delay = <10000>;
+			regulator-boot-on;
+			regulator-always-on;
+		};
+
+		lp8733_ldo0: ldo0 {
+			regulator-name = "lp8733-ldo0";
+			regulator-min-microvolt = <800000>;
+			regulator-max-microvolt = <3000000>;
+			regulator-boot-on;
+			regulator-always-on;
+		};
+
+		lp8733_ldo1: ldo1 {
+			regulator-name = "lp8733-ldo1";
+			regulator-min-microvolt = <800000>;
+			regulator-max-microvolt = <3000000>;
+			regulator-always-on;
+			regulator-boot-on;
+		};
+	};
+};
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH v6 2/4] mfd: lp873x: Add lp873x PMIC support
  2016-08-08  5:46 [PATCH v6 0/4] mfd: lp873x: Add lp873x PMIC support Keerthy
  2016-08-08  5:46 ` [PATCH v6 1/4] Documentation: mfd: LP873X: Add information for the mfd driver Keerthy
@ 2016-08-08  5:46 ` Keerthy
  2016-08-08  6:26   ` kbuild test robot
                     ` (2 more replies)
  2016-08-08  5:46 ` [PATCH v6 3/4] gpio: lp873x: Add support for General Purpose Outputs Keerthy
  2016-08-08  5:46 ` [PATCH v6 4/4] regulator: lp873x: Change the MFD config option as per latest naming Keerthy
  3 siblings, 3 replies; 15+ messages in thread
From: Keerthy @ 2016-08-08  5:46 UTC (permalink / raw)
  To: broonie, lee.jones, tony
  Cc: j-keerthy, linus.walleij, gnurou, linux-omap, linux-kernel,
	devicetree, linux-gpio, robh+dt

The LP873X chip is a power management IC for Portable Navigation Systems
    and Tablet Computing devices. It contains the following components:

     - Regulators.
     - Configurable General Purpose Output Signals(GPO).

PMIC interacts with the main processor through i2c. PMIC has
couple of LDOs(Linear Regulators), couple of BUCKs (Step-Down DC-DC
Converter Cores) and GPOs(General Purpose Output Signals).

Signed-off-by: Keerthy <j-keerthy@ti.com>
---
Changes in v6:

  * Rebased on top of http://www.gossamer-threads.com/lists/linux/kernel/2457552.
  * Hence added probe_new instead of probe and removed unused i2c_device_id.

Changes in v4:

  * Added Author.
  * Added the mfd_cell for gpio.

Changes in v3:

  * Reordered the probe code.
  * Fixed Typo in Kconfig description.
  * Removed unused member from struct lp873x.

 drivers/mfd/Kconfig        |  14 +++
 drivers/mfd/Makefile       |   2 +
 drivers/mfd/lp873x.c       |  89 +++++++++++++++
 include/linux/mfd/lp873x.h | 264 +++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 369 insertions(+)
 create mode 100644 drivers/mfd/lp873x.c
 create mode 100644 include/linux/mfd/lp873x.h

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 2d1fb64..45fe00a 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -1224,6 +1224,20 @@ config MFD_TPS65217
 	  This driver can also be built as a module.  If so, the module
 	  will be called tps65217.
 
+config MFD_TI_LP873X
+	tristate "TI LP873X Power Management IC"
+	depends on I2C
+	select MFD_CORE
+	select REGMAP_I2C
+	help
+	  If you say yes here then you get support for the LP873X series of
+	  Power Management Integrated Circuits(PMIC).
+	  These include voltage regulators, Thermal protection, Configurable
+	  General Purpose Outputs(GPO) that are used in portable devices.
+
+	  This driver can also be built as a module. If so, the module
+	  will be called lp873x.
+
 config MFD_TPS65218
 	tristate "TI TPS65218 Power Management chips"
 	depends on I2C
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 2ba3ba3..42acbcd 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -22,6 +22,8 @@ obj-$(CONFIG_HTC_EGPIO)		+= htc-egpio.o
 obj-$(CONFIG_HTC_PASIC3)	+= htc-pasic3.o
 obj-$(CONFIG_HTC_I2CPLD)	+= htc-i2cpld.o
 
+obj-$(CONFIG_MFD_TI_LP873X)	+= lp873x.o
+
 obj-$(CONFIG_MFD_DAVINCI_VOICECODEC)	+= davinci_voicecodec.o
 obj-$(CONFIG_MFD_DM355EVM_MSP)	+= dm355evm_msp.o
 obj-$(CONFIG_MFD_TI_AM335X_TSCADC)	+= ti_am335x_tscadc.o
diff --git a/drivers/mfd/lp873x.c b/drivers/mfd/lp873x.c
new file mode 100644
index 0000000..3c8e8d0
--- /dev/null
+++ b/drivers/mfd/lp873x.c
@@ -0,0 +1,89 @@
+/*
+ * Copyright (C) 2016 Texas Instruments Incorporated - http://www.ti.com/
+ *
+ * Author: Keerthy <j-keerthy@ti.com>
+ *
+ * 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 version 2.
+ *
+ * This program is distributed "as is" WITHOUT ANY WARRANTY of any
+ * kind, whether express or implied; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/interrupt.h>
+#include <linux/mfd/core.h>
+#include <linux/module.h>
+#include <linux/of_device.h>
+#include <linux/regmap.h>
+
+#include <linux/mfd/lp873x.h>
+
+static const struct regmap_config lp873x_regmap_config = {
+	.reg_bits = 8,
+	.val_bits = 8,
+	.max_register = LP873X_REG_MAX,
+};
+
+static const struct mfd_cell lp873x_cells[] = {
+	{ .name = "lp873x-regulator", },
+	{ .name = "lp873x-gpio", },
+};
+
+static int lp873x_probe(struct i2c_client *client)
+{
+	struct lp873x *lp873;
+	int ret;
+	unsigned int otpid;
+
+	lp873 = devm_kzalloc(&client->dev, sizeof(*lp873), GFP_KERNEL);
+	if (!lp873)
+		return -ENOMEM;
+
+	lp873->dev = &client->dev;
+
+	lp873->regmap = devm_regmap_init_i2c(client, &lp873x_regmap_config);
+	if (IS_ERR(lp873->regmap)) {
+		ret = PTR_ERR(lp873->regmap);
+		dev_err(lp873->dev,
+			"Failed to initialize register map: %d\n", ret);
+		return ret;
+	}
+
+	mutex_init(&lp873->lock);
+
+	ret = regmap_read(lp873->regmap, LP873X_REG_OTP_REV, &otpid);
+	if (ret) {
+		dev_err(lp873->dev, "Failed to read OTP ID\n");
+		return ret;
+	}
+
+	lp873->rev = otpid & LP873X_OTP_REV_OTP_ID;
+	i2c_set_clientdata(client, lp873);
+	ret = mfd_add_devices(lp873->dev, PLATFORM_DEVID_AUTO, lp873x_cells,
+			      ARRAY_SIZE(lp873x_cells), NULL, 0, NULL);
+
+	return ret;
+}
+
+static const struct of_device_id of_lp873x_match_table[] = {
+	{ .compatible = "ti,lp8733", },
+	{ .compatible = "ti,lp8732", },
+	{}
+};
+MODULE_DEVICE_TABLE(of, of_lp873x_match_table);
+
+static struct i2c_driver lp873x_driver = {
+	.driver		= {
+		.name	= "lp873x",
+		.of_match_table = of_lp873x_match_table,
+	},
+	.probe_new		= lp873x_probe,
+};
+module_i2c_driver(lp873x_driver);
+
+MODULE_AUTHOR("J Keerthy <j-keerthy@ti.com>");
+MODULE_DESCRIPTION("LP873X chip family multi-function driver");
+MODULE_LICENSE("GPL v2");
diff --git a/include/linux/mfd/lp873x.h b/include/linux/mfd/lp873x.h
new file mode 100644
index 0000000..42bebfa
--- /dev/null
+++ b/include/linux/mfd/lp873x.h
@@ -0,0 +1,264 @@
+/*
+ * Functions to access LP873X power management chip.
+ *
+ * Copyright (C) 2016 Texas Instruments Incorporated - http://www.ti.com/
+ *
+ * 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 version 2.
+ *
+ * This program is distributed "as is" WITHOUT ANY WARRANTY of any
+ * kind, whether express or implied; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#ifndef __LINUX_MFD_LP873X_H
+#define __LINUX_MFD_LP873X_H
+
+#include <linux/i2c.h>
+#include <linux/regulator/driver.h>
+#include <linux/regulator/machine.h>
+
+/* LP873x chip id list */
+#define LP873X			0x00
+
+/* All register addresses */
+#define LP873X_REG_DEV_REV		0X00
+#define LP873X_REG_OTP_REV		0X01
+#define LP873X_REG_BUCK0_CTRL_1		0X02
+#define LP873X_REG_BUCK0_CTRL_2		0X03
+#define LP873X_REG_BUCK1_CTRL_1		0X04
+#define LP873X_REG_BUCK1_CTRL_2		0X05
+#define LP873X_REG_BUCK0_VOUT		0X06
+#define LP873X_REG_BUCK1_VOUT		0X07
+#define LP873X_REG_LDO0_CTRL		0X08
+#define LP873X_REG_LDO1_CTRL            0X09
+#define LP873X_REG_LDO0_VOUT		0X0A
+#define LP873X_REG_LDO1_VOUT		0X0B
+#define LP873X_REG_BUCK0_DELAY		0X0C
+#define LP873X_REG_BUCK1_DELAY		0X0D
+#define LP873X_REG_LDO0_DELAY		0X0E
+#define LP873X_REG_LDO1_DELAY		0X0F
+#define LP873X_REG_GPO_DELAY		0X10
+#define LP873X_REG_GPO2_DELAY		0X11
+#define LP873X_REG_GPO_CTRL		0X12
+#define LP873X_REG_CONFIG		0X13
+#define LP873X_REG_PLL_CTRL		0X14
+#define LP873X_REG_PGOOD_CTRL1		0X15
+#define LP873X_REG_PGOOD_CTRL2		0X16
+#define LP873X_REG_PG_FAULT		0X17
+#define LP873X_REG_RESET		0X18
+#define LP873X_REG_INT_TOP_1		0X19
+#define LP873X_REG_INT_TOP_2		0X1A
+#define LP873X_REG_INT_BUCK		0X1B
+#define LP873X_REG_INT_LDO		0X1C
+#define LP873X_REG_TOP_STAT		0X1D
+#define LP873X_REG_BUCK_STAT		0X1E
+#define LP873X_REG_LDO_STAT		0x1F
+#define LP873X_REG_TOP_MASK_1		0x20
+#define LP873X_REG_TOP_MASK_2		0x21
+#define LP873X_REG_BUCK_MASK		0x22
+#define LP873X_REG_LDO_MASK		0x23
+#define LP873X_REG_SEL_I_LOAD		0x24
+#define LP873X_REG_I_LOAD_2		0x25
+#define LP873X_REG_I_LOAD_1		0x26
+
+#define LP873X_REG_MAX			LP873X_REG_I_LOAD_1
+
+/* Register field definitions */
+#define LP873X_DEV_REV_DEV_ID			0xC0
+#define LP873X_DEV_REV_ALL_LAYER		0x30
+#define LP873X_DEV_REV_METAL_LAYER		0x0F
+
+#define LP873X_OTP_REV_OTP_ID			0xFF
+
+#define LP873X_BUCK0_CTRL_1_BUCK0_FPWM		BIT(3)
+#define LP873X_BUCK0_CTRL_1_BUCK0_RDIS_EN	BIT(2)
+#define LP873X_BUCK0_CTRL_1_BUCK0_EN_PIN_CTRL	BIT(1)
+#define LP873X_BUCK0_CTRL_1_BUCK0_EN		BIT(0)
+
+#define LP873X_BUCK0_CTRL_2_BUCK0_ILIM		0x38
+#define LP873X_BUCK0_CTRL_2_BUCK0_SLEW_RATE	0x07
+
+#define LP873X_BUCK1_CTRL_1_BUCK1_FPWM		BIT(3)
+#define LP873X_BUCK1_CTRL_1_BUCK1_RDIS_EN	BIT(2)
+#define LP873X_BUCK1_CTRL_1_BUCK1_EN_PIN_CTRL	BIT(1)
+#define LP873X_BUCK1_CTRL_1_BUCK1_EN		BIT(0)
+
+#define LP873X_BUCK1_CTRL_2_BUCK1_ILIM		0x38
+#define LP873X_BUCK1_CTRL_2_BUCK1_SLEW_RATE	0x07
+
+#define LP873X_BUCK0_VOUT_BUCK0_VSET		0xFF
+
+#define LP873X_BUCK1_VOUT_BUCK1_VSET		0xFF
+
+#define LP873X_LDO0_CTRL_LDO0_RDIS_EN		BIT(2)
+#define LP873X_LDO0_CTRL_LDO0_EN_PIN_CTRL	BIT(1)
+#define LP873X_LDO0_CTRL_LDO0_EN		BIT(0)
+
+#define LP873X_LDO1_CTRL_LDO1_RDIS_EN		BIT(2)
+#define LP873X_LDO1_CTRL_LDO1_EN_PIN_CTRL	BIT(1)
+#define LP873X_LDO1_CTRL_LDO1_EN		BIT(0)
+
+#define LP873X_LDO0_VOUT_LDO0_VSET		0x1F
+
+#define LP873X_LDO1_VOUT_LDO1_VSET		0x1F
+
+#define LP873X_BUCK0_DELAY_BUCK0_SD_DELAY	0xF0
+#define LP873X_BUCK0_DELAY_BUCK0_SU_DELAY	0x0F
+
+#define LP873X_BUCK1_DELAY_BUCK1_SD_DELAY	0xF0
+#define LP873X_BUCK1_DELAY_BUCK1_SU_DELAY	0x0F
+
+#define LP873X_LDO0_DELAY_LDO0_SD_DELAY	0xF0
+#define LP873X_LDO0_DELAY_LDO0_SU_DELAY	0x0F
+
+#define LP873X_LDO1_DELAY_LDO1_SD_DELAY	0xF0
+#define LP873X_LDO1_DELAY_LDO1_SU_DELAY	0x0F
+
+#define LP873X_GPO_DELAY_GPO_SD_DELAY		0xF0
+#define LP873X_GPO_DELAY_GPO_SU_DELAY		0x0F
+
+#define LP873X_GPO2_DELAY_GPO2_SD_DELAY	0xF0
+#define LP873X_GPO2_DELAY_GPO2_SU_DELAY	0x0F
+
+#define LP873X_GPO_CTRL_GPO2_OD		BIT(6)
+#define LP873X_GPO_CTRL_GPO2_EN_PIN_CTRL	BIT(5)
+#define LP873X_GPO_CTRL_GPO2_EN		BIT(4)
+#define LP873X_GPO_CTRL_GPO_OD			BIT(2)
+#define LP873X_GPO_CTRL_GPO_EN_PIN_CTRL	BIT(1)
+#define LP873X_GPO_CTRL_GPO_EN			BIT(0)
+
+#define LP873X_CONFIG_SU_DELAY_SEL		BIT(6)
+#define LP873X_CONFIG_SD_DELAY_SEL		BIT(5)
+#define LP873X_CONFIG_CLKIN_PIN_SEL		BIT(4)
+#define LP873X_CONFIG_CLKIN_PD			BIT(3)
+#define LP873X_CONFIG_EN_PD			BIT(2)
+#define LP873X_CONFIG_TDIE_WARN_LEVEL		BIT(1)
+#define LP873X_EN_SPREAD_SPEC			BIT(0)
+
+#define LP873X_PLL_CTRL_EN_PLL			BIT(6)
+#define LP873X_EXT_CLK_FREQ			0x1F
+
+#define LP873X_PGOOD_CTRL1_PGOOD_POL		BIT(7)
+#define LP873X_PGOOD_CTRL1_PGOOD_OD		BIT(6)
+#define LP873X_PGOOD_CTRL1_PGOOD_WINDOW_LDO	BIT(5)
+#define LP873X_PGOOD_CTRL1_PGOOD_WINDOWN_BUCK	BIT(4)
+#define LP873X_PGOOD_CTRL1_PGOOD_EN_PGOOD_LDO1	BIT(3)
+#define LP873X_PGOOD_CTRL1_PGOOD_EN_PGOOD_LDO0	BIT(2)
+#define LP873X_PGOOD_CTRL1_PGOOD_EN_PGOOD_BUCK1	BIT(1)
+#define LP873X_PGOOD_CTRL1_PGOOD_EN_PGOOD_BUCK0	BIT(0)
+
+#define LP873X_PGOOD_CTRL2_EN_PGOOD_TWARN	BIT(2)
+#define LP873X_PGOOD_CTRL2_EN_PG_FAULT_GATE	BIT(1)
+#define LP873X_PGOOD_CTRL2_PGOOD_MODE		BIT(0)
+
+#define LP873X_PG_FAULT_PG_FAULT_LDO1		BIT(3)
+#define LP873X_PG_FAULT_PG_FAULT_LDO0		BIT(2)
+#define LP873X_PG_FAULT_PG_FAULT_BUCK1		BIT(1)
+#define LP873X_PG_FAULT_PG_FAULT_BUCK0		BIT(0)
+
+#define LP873X_RESET_SW_RESET			BIT(0)
+
+#define LP873X_INT_TOP_1_PGOOD_INT		BIT(7)
+#define LP873X_INT_TOP_1_LDO_INT		BIT(6)
+#define LP873X_INT_TOP_1_BUCK_INT		BIT(5)
+#define LP873X_INT_TOP_1_SYNC_CLK_INT		BIT(4)
+#define LP873X_INT_TOP_1_TDIE_SD_INT		BIT(3)
+#define LP873X_INT_TOP_1_TDIE_WARN_INT		BIT(2)
+#define LP873X_INT_TOP_1_OVP_INT		BIT(1)
+#define LP873X_INT_TOP_1_I_MEAS_INT		BIT(0)
+
+#define LP873X_INT_TOP_2_RESET_REG_INT		BIT(0)
+
+#define LP873X_INT_BUCK_BUCK1_PG_INT		BIT(6)
+#define LP873X_INT_BUCK_BUCK1_SC_INT		BIT(5)
+#define LP873X_INT_BUCK_BUCK1_ILIM_INT		BIT(4)
+#define LP873X_INT_BUCK_BUCK0_PG_INT		BIT(2)
+#define LP873X_INT_BUCK_BUCK0_SC_INT		BIT(1)
+#define LP873X_INT_BUCK_BUCK0_ILIM_INT		BIT(0)
+
+#define LP873X_INT_LDO_LDO1_PG_INT		BIT(6)
+#define LP873X_INT_LDO_LDO1_SC_INT		BIT(5)
+#define LP873X_INT_LDO_LDO1_ILIM_INT		BIT(4)
+#define LP873X_INT_LDO_LDO0_PG_INT		BIT(2)
+#define LP873X_INT_LDO_LDO0_SC_INT		BIT(1)
+#define LP873X_INT_LDO_LDO0_ILIM_INT		BIT(0)
+
+#define LP873X_TOP_STAT_PGOOD_STAT		BIT(7)
+#define LP873X_TOP_STAT_SYNC_CLK_STAT		BIT(4)
+#define LP873X_TOP_STAT_TDIE_SD_STAT		BIT(3)
+#define LP873X_TOP_STAT_TDIE_WARN_STAT		BIT(2)
+#define LP873X_TOP_STAT_OVP_STAT		BIT(1)
+
+#define LP873X_BUCK_STAT_BUCK1_STAT		BIT(7)
+#define LP873X_BUCK_STAT_BUCK1_PG_STAT		BIT(6)
+#define LP873X_BUCK_STAT_BUCK1_ILIM_STAT	BIT(4)
+#define LP873X_BUCK_STAT_BUCK0_STAT		BIT(3)
+#define LP873X_BUCK_STAT_BUCK0_PG_STAT		BIT(2)
+#define LP873X_BUCK_STAT_BUCK0_ILIM_STAT	BIT(0)
+
+#define LP873X_LDO_STAT_LDO1_STAT		BIT(7)
+#define LP873X_LDO_STAT_LDO1_PG_STAT		BIT(6)
+#define LP873X_LDO_STAT_LDO1_ILIM_STAT		BIT(4)
+#define LP873X_LDO_STAT_LDO0_STAT		BIT(3)
+#define LP873X_LDO_STAT_LDO0_PG_STAT		BIT(2)
+#define LP873X_LDO_STAT_LDO0_ILIM_STAT		BIT(0)
+
+#define LP873X_TOP_MASK_1_PGOOD_INT_MASK	BIT(7)
+#define LP873X_TOP_MASK_1_SYNC_CLK_MASK	BIT(4)
+#define LP873X_TOP_MASK_1_TDIE_WARN_MASK	BIT(2)
+#define LP873X_TOP_MASK_1_I_MEAS_MASK		BIT(0)
+
+#define LP873X_TOP_MASK_2_RESET_REG_MASK	BIT(0)
+
+#define LP873X_BUCK_MASK_BUCK1_PGF_MASK	BIT(7)
+#define LP873X_BUCK_MASK_BUCK1_PGR_MASK	BIT(6)
+#define LP873X_BUCK_MASK_BUCK1_ILIM_MASK	BIT(4)
+#define LP873X_BUCK_MASK_BUCK0_PGF_MASK	BIT(3)
+#define LP873X_BUCK_MASK_BUCK0_PGR_MASK	BIT(2)
+#define LP873X_BUCK_MASK_BUCK0_ILIM_MASK	BIT(0)
+
+#define LP873X_LDO_MASK_LDO1_PGF_MASK		BIT(7)
+#define LP873X_LDO_MASK_LDO1_PGR_MASK		BIT(6)
+#define LP873X_LDO_MASK_LDO1_ILIM_MASK		BIT(4)
+#define LP873X_LDO_MASK_LDO0_PGF_MASK		BIT(3)
+#define LP873X_LDO_MASK_LDO0_PGR_MASK		BIT(2)
+#define LP873X_LDO_MASK_LDO0_ILIM_MASK		BIT(0)
+
+#define LP873X_SEL_I_LOAD_CURRENT_BUCK_SELECT	BIT(0)
+
+#define LP873X_I_LOAD_2_BUCK_LOAD_CURRENT	BIT(0)
+
+#define LP873X_I_LOAD_1_BUCK_LOAD_CURRENT	0xFF
+
+#define LP873X_MAX_REG_ID		LP873X_LDO_1
+
+/* Number of step-down converters available */
+#define LP873X_NUM_BUCK		2
+/* Number of LDO voltage regulators available */
+#define LP873X_NUM_LDO		2
+/* Number of total regulators available */
+#define LP873X_NUM_REGULATOR		(LP873X_NUM_BUCK + LP873X_NUM_LDO)
+
+enum lp873x_regulator_id {
+	/* BUCK's */
+	LP873X_BUCK_0,
+	LP873X_BUCK_1,
+	/* LDOs */
+	LP873X_LDO_0,
+	LP873X_LDO_1,
+};
+
+/**
+ * struct lp873x - state holder for the lp873x driver
+ * Device data may be used to access the LP873X chip
+ */
+struct lp873x {
+	struct device *dev;
+	u8 rev;
+	struct mutex lock;	/* lock guarding the data structure */
+	struct regmap *regmap;
+};
+#endif /*  __LINUX_MFD_LP873X_H */
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH v6 3/4] gpio: lp873x: Add support for General Purpose Outputs
  2016-08-08  5:46 [PATCH v6 0/4] mfd: lp873x: Add lp873x PMIC support Keerthy
  2016-08-08  5:46 ` [PATCH v6 1/4] Documentation: mfd: LP873X: Add information for the mfd driver Keerthy
  2016-08-08  5:46 ` [PATCH v6 2/4] mfd: lp873x: Add lp873x PMIC support Keerthy
@ 2016-08-08  5:46 ` Keerthy
  2016-08-11 13:30   ` Linus Walleij
  2016-08-08  5:46 ` [PATCH v6 4/4] regulator: lp873x: Change the MFD config option as per latest naming Keerthy
  3 siblings, 1 reply; 15+ messages in thread
From: Keerthy @ 2016-08-08  5:46 UTC (permalink / raw)
  To: broonie, lee.jones, tony
  Cc: j-keerthy, linus.walleij, gnurou, linux-omap, linux-kernel,
	devicetree, linux-gpio, robh+dt

Add driver for lp873x PMIC family GPOs. Two GPOs are supported
and can be configured in Open-drain output or Push-pull output.

Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Keerthy <j-keerthy@ti.com>
---
 drivers/gpio/Kconfig       |  10 +++
 drivers/gpio/Makefile      |   1 +
 drivers/gpio/gpio-lp873x.c | 185 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 196 insertions(+)
 create mode 100644 drivers/gpio/gpio-lp873x.c

diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
index 6de9062..ff68a80 100644
--- a/drivers/gpio/Kconfig
+++ b/drivers/gpio/Kconfig
@@ -853,6 +853,16 @@ config GPIO_LP3943
 	  LP3943 can be used as a GPIO expander which provides up to 16 GPIOs.
 	  Open drain outputs are required for this usage.
 
+config GPIO_LP873X
+	tristate "TI LP873X GPO"
+	depends on MFD_TI_LP873X
+	help
+	  This driver supports the GPO on TI Lp873x PMICs. 2 GPOs are present
+	  on LP873X PMICs.
+
+	  This driver can also be built as a module. If so, the module will be
+          called gpio-lp873x.
+
 config GPIO_MAX77620
 	tristate "GPIO support for PMIC MAX77620 and MAX20024"
 	depends on MFD_MAX77620
diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile
index 2a035ed..d60432f 100644
--- a/drivers/gpio/Makefile
+++ b/drivers/gpio/Makefile
@@ -56,6 +56,7 @@ obj-$(CONFIG_GPIO_LOONGSON)	+= gpio-loongson.o
 obj-$(CONFIG_GPIO_LP3943)	+= gpio-lp3943.o
 obj-$(CONFIG_GPIO_LPC18XX)	+= gpio-lpc18xx.o
 obj-$(CONFIG_ARCH_LPC32XX)	+= gpio-lpc32xx.o
+obj-$(CONFIG_GPIO_LP873X)	+= gpio-lp873x.o
 obj-$(CONFIG_GPIO_LYNXPOINT)	+= gpio-lynxpoint.o
 obj-$(CONFIG_GPIO_MAX730X)	+= gpio-max730x.o
 obj-$(CONFIG_GPIO_MAX7300)	+= gpio-max7300.o
diff --git a/drivers/gpio/gpio-lp873x.c b/drivers/gpio/gpio-lp873x.c
new file mode 100644
index 0000000..77deaa4
--- /dev/null
+++ b/drivers/gpio/gpio-lp873x.c
@@ -0,0 +1,185 @@
+/*
+ * Copyright (C) 2016 Texas Instruments Incorporated - http://www.ti.com/
+ *	Keerthy <j-keerthy@ti.com>
+ *
+ * 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 TPS65218 driver
+ */
+
+#include <linux/gpio.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/regmap.h>
+
+#include <linux/mfd/lp873x.h>
+
+struct lp873x_gpio {
+	struct gpio_chip chip;
+	struct lp873x *lp873;
+};
+
+static int lp873x_gpio_get_direction(struct gpio_chip *chip,
+				     unsigned int offset)
+{
+	/* This device is output only */
+	return 0;
+}
+
+static int lp873x_gpio_direction_input(struct gpio_chip *chip,
+				       unsigned int offset)
+{
+	/* This device is output only */
+	return -EINVAL;
+}
+
+static int lp873x_gpio_direction_output(struct gpio_chip *chip,
+					unsigned int offset, int value)
+{
+	struct lp873x_gpio *gpio = gpiochip_get_data(chip);
+
+	/* Set the initial value */
+	return regmap_update_bits(gpio->lp873->regmap, LP873X_REG_GPO_CTRL,
+				  BIT(offset * 4), value ? BIT(offset * 4) : 0);
+}
+
+static int lp873x_gpio_get(struct gpio_chip *chip, unsigned int offset)
+{
+	struct lp873x_gpio *gpio = gpiochip_get_data(chip);
+	int ret, val;
+
+	ret = regmap_read(gpio->lp873->regmap, LP873X_REG_GPO_CTRL, &val);
+	if (ret < 0)
+		return ret;
+
+	return val & BIT(offset * 4);
+}
+
+static void lp873x_gpio_set(struct gpio_chip *chip, unsigned int offset,
+			    int value)
+{
+	struct lp873x_gpio *gpio = gpiochip_get_data(chip);
+
+	regmap_update_bits(gpio->lp873->regmap, LP873X_REG_GPO_CTRL,
+			   BIT(offset * 4), value ? BIT(offset * 4) : 0);
+}
+
+static int lp873x_gpio_request(struct gpio_chip *gc, unsigned int offset)
+{
+	struct lp873x_gpio *gpio = gpiochip_get_data(gc);
+	int ret;
+
+	switch (offset) {
+	case 0:
+		/* No MUX Set up Needed for GPO */
+		break;
+	case 1:
+		/* Setup the CLKIN_PIN_SEL MUX to GPO2 */
+		ret = regmap_update_bits(gpio->lp873->regmap, LP873X_REG_CONFIG,
+					 LP873X_CONFIG_CLKIN_PIN_SEL, 0);
+		if (ret)
+			return ret;
+
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
+static int lp873x_gpio_set_single_ended(struct gpio_chip *gc,
+					unsigned int offset,
+					enum single_ended_mode mode)
+{
+	struct lp873x_gpio *gpio = gpiochip_get_data(gc);
+
+	switch (mode) {
+	case LINE_MODE_OPEN_DRAIN:
+		return regmap_update_bits(gpio->lp873->regmap,
+					  LP873X_REG_GPO_CTRL,
+					  BIT(offset * 4 + 2),
+					  BIT(offset * 4 + 2));
+	case LINE_MODE_PUSH_PULL:
+		return regmap_update_bits(gpio->lp873->regmap,
+					  LP873X_REG_GPO_CTRL,
+					  BIT(offset * 4 + 2), 0);
+	default:
+		return -ENOTSUPP;
+	}
+}
+
+static struct gpio_chip template_chip = {
+	.label			= "lp873x-gpio",
+	.owner			= THIS_MODULE,
+	.request		= lp873x_gpio_request,
+	.get_direction		= lp873x_gpio_get_direction,
+	.direction_input	= lp873x_gpio_direction_input,
+	.direction_output	= lp873x_gpio_direction_output,
+	.get			= lp873x_gpio_get,
+	.set			= lp873x_gpio_set,
+	.set_single_ended	= lp873x_gpio_set_single_ended,
+	.base			= -1,
+	.ngpio			= 2,
+	.can_sleep		= true,
+};
+
+static int lp873x_gpio_probe(struct platform_device *pdev)
+{
+	struct lp873x_gpio *gpio;
+	int ret;
+
+	gpio = devm_kzalloc(&pdev->dev, sizeof(*gpio), GFP_KERNEL);
+	if (!gpio)
+		return -ENOMEM;
+
+	platform_set_drvdata(pdev, gpio);
+
+	gpio->lp873 = dev_get_drvdata(pdev->dev.parent);
+	gpio->chip = template_chip;
+	gpio->chip.parent = gpio->lp873->dev;
+
+	ret = gpiochip_add_data(&gpio->chip, gpio);
+	if (ret < 0) {
+		dev_err(&pdev->dev, "Could not register gpiochip, %d\n", ret);
+		return ret;
+	}
+
+	return 0;
+}
+
+static int lp873x_gpio_remove(struct platform_device *pdev)
+{
+	struct lp873x_gpio *gpio = platform_get_drvdata(pdev);
+
+	gpiochip_remove(&gpio->chip);
+
+	return 0;
+}
+
+static const struct platform_device_id lp873x_gpio_id_table[] = {
+	{ "lp873x-gpio", },
+	{ /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(platform, lp873x_gpio_id_table);
+
+static struct platform_driver lp873x_gpio_driver = {
+	.driver = {
+		.name = "lp873x-gpio",
+	},
+	.probe = lp873x_gpio_probe,
+	.remove = lp873x_gpio_remove,
+	.id_table = lp873x_gpio_id_table,
+};
+module_platform_driver(lp873x_gpio_driver);
+
+MODULE_AUTHOR("Keerthy <j-keerthy@ti.com>");
+MODULE_DESCRIPTION("LP873X GPIO driver");
+MODULE_LICENSE("GPL v2");
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH v6 4/4] regulator: lp873x: Change the MFD config option as per latest naming
  2016-08-08  5:46 [PATCH v6 0/4] mfd: lp873x: Add lp873x PMIC support Keerthy
                   ` (2 preceding siblings ...)
  2016-08-08  5:46 ` [PATCH v6 3/4] gpio: lp873x: Add support for General Purpose Outputs Keerthy
@ 2016-08-08  5:46 ` Keerthy
  2016-08-12 10:57   ` Mark Brown
  3 siblings, 1 reply; 15+ messages in thread
From: Keerthy @ 2016-08-08  5:46 UTC (permalink / raw)
  To: broonie, lee.jones, tony
  Cc: j-keerthy, linus.walleij, gnurou, linux-omap, linux-kernel,
	devicetree, linux-gpio, robh+dt

Change the MFD config option as per latest naming

Signed-off-by: Keerthy <j-keerthy@ti.com>
---
 drivers/regulator/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index 6c88e31..97dc4cc 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -323,7 +323,7 @@ config REGULATOR_LP872X
 
 config REGULATOR_LP873X
 	tristate "TI LP873X Power regulators"
-	depends on MFD_LP873X && OF
+	depends on MFD_TI_LP873X && OF
 	help
 	  This driver supports LP873X voltage regulator chips. LP873X
 	  provides two step-down converters and two general-purpose LDO
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [PATCH v6 2/4] mfd: lp873x: Add lp873x PMIC support
  2016-08-08  5:46 ` [PATCH v6 2/4] mfd: lp873x: Add lp873x PMIC support Keerthy
@ 2016-08-08  6:26   ` kbuild test robot
  2016-08-08  6:49     ` Keerthy
  2016-08-08  8:41   ` kbuild test robot
  2016-08-09 12:53   ` Lee Jones
  2 siblings, 1 reply; 15+ messages in thread
From: kbuild test robot @ 2016-08-08  6:26 UTC (permalink / raw)
  To: Keerthy
  Cc: kbuild-all, broonie, lee.jones, tony, j-keerthy, linus.walleij,
	gnurou, linux-omap, linux-kernel, devicetree, linux-gpio,
	robh+dt

[-- Attachment #1: Type: text/plain, Size: 1582 bytes --]

Hi Keerthy,

[auto build test ERROR on gpio/for-next]
[also build test ERROR on v4.8-rc1 next-20160805]
[cannot apply to ljones-mfd/for-mfd-next]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Keerthy/mfd-lp873x-Add-lp873x-PMIC-support/20160808-135204
base:   https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio.git for-next
config: i386-allmodconfig (attached as .config)
compiler: gcc-6 (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

All errors (new ones prefixed by >>):

>> drivers/mfd/lp873x.c:83:2: error: unknown field 'probe_new' specified in initializer
     .probe_new  = lp873x_probe,
     ^
>> drivers/mfd/lp873x.c:83:16: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
     .probe_new  = lp873x_probe,
                   ^~~~~~~~~~~~
   drivers/mfd/lp873x.c:83:16: note: (near initialization for 'lp873x_driver.id_table')
   cc1: some warnings being treated as errors

vim +/probe_new +83 drivers/mfd/lp873x.c

    77	
    78	static struct i2c_driver lp873x_driver = {
    79		.driver		= {
    80			.name	= "lp873x",
    81			.of_match_table = of_lp873x_match_table,
    82		},
  > 83		.probe_new		= lp873x_probe,
    84	};
    85	module_i2c_driver(lp873x_driver);
    86	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/octet-stream, Size: 55783 bytes --]

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v6 2/4] mfd: lp873x: Add lp873x PMIC support
  2016-08-08  6:26   ` kbuild test robot
@ 2016-08-08  6:49     ` Keerthy
  0 siblings, 0 replies; 15+ messages in thread
From: Keerthy @ 2016-08-08  6:49 UTC (permalink / raw)
  To: kbuild test robot, Keerthy
  Cc: kbuild-all, broonie, lee.jones, tony, linus.walleij, gnurou,
	linux-omap, linux-kernel, devicetree, linux-gpio, robh+dt



On Monday 08 August 2016 11:56 AM, kbuild test robot wrote:
> Hi Keerthy,
>
> [auto build test ERROR on gpio/for-next]
> [also build test ERROR on v4.8-rc1 next-20160805]
> [cannot apply to ljones-mfd/for-mfd-next]
> [if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
>
> url:    https://github.com/0day-ci/linux/commits/Keerthy/mfd-lp873x-Add-lp873x-PMIC-support/20160808-135204
> base:   https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio.git for-next
> config: i386-allmodconfig (attached as .config)
> compiler: gcc-6 (Debian 6.1.1-9) 6.1.1 20160705
> reproduce:
>          # save the attached .config to linux build tree
>          make ARCH=i386
>
> All errors (new ones prefixed by >>):
>
>>> drivers/mfd/lp873x.c:83:2: error: unknown field 'probe_new' specified in initializer
>       .probe_new  = lp873x_probe,
>       ^
>>> drivers/mfd/lp873x.c:83:16: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
>       .probe_new  = lp873x_probe,
>                     ^~~~~~~~~~~~
>     drivers/mfd/lp873x.c:83:16: note: (near initialization for 'lp873x_driver.id_table')
>     cc1: some warnings being treated as errors
>
> vim +/probe_new +83 drivers/mfd/lp873x.c
>
>      77	
>      78	static struct i2c_driver lp873x_driver = {
>      79		.driver		= {
>      80			.name	= "lp873x",
>      81			.of_match_table = of_lp873x_match_table,
>      82		},
>    > 83		.probe_new		= lp873x_probe,

Depends on: Rebased on top of 
http://www.gossamer-threads.com/lists/linux/kernel/2457552

As mentioned clearly.

>      84	};
>      85	module_i2c_driver(lp873x_driver);
>      86	
>
> ---
> 0-DAY kernel test infrastructure                Open Source Technology Center
> https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
>

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v6 2/4] mfd: lp873x: Add lp873x PMIC support
  2016-08-08  5:46 ` [PATCH v6 2/4] mfd: lp873x: Add lp873x PMIC support Keerthy
  2016-08-08  6:26   ` kbuild test robot
@ 2016-08-08  8:41   ` kbuild test robot
  2016-08-09 12:53   ` Lee Jones
  2 siblings, 0 replies; 15+ messages in thread
From: kbuild test robot @ 2016-08-08  8:41 UTC (permalink / raw)
  To: Keerthy
  Cc: kbuild-all, broonie, lee.jones, tony, j-keerthy, linus.walleij,
	gnurou, linux-omap, linux-kernel, devicetree, linux-gpio,
	robh+dt

[-- Attachment #1: Type: text/plain, Size: 2007 bytes --]

Hi Keerthy,

[auto build test WARNING on gpio/for-next]
[also build test WARNING on v4.8-rc1 next-20160805]
[cannot apply to ljones-mfd/for-mfd-next]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Keerthy/mfd-lp873x-Add-lp873x-PMIC-support/20160808-135204
base:   https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio.git for-next
config: cris-allyesconfig (attached as .config)
compiler: cris-linux-gcc (GCC) 4.6.3
reproduce:
        wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=cris 

All warnings (new ones prefixed by >>):

   drivers/mfd/lp873x.c:83:2: error: unknown field 'probe_new' specified in initializer
>> drivers/mfd/lp873x.c:83:2: warning: initialization from incompatible pointer type [enabled by default]
   drivers/mfd/lp873x.c:83:2: warning: (near initialization for 'lp873x_driver.id_table') [enabled by default]

vim +83 drivers/mfd/lp873x.c

    67	
    68		return ret;
    69	}
    70	
    71	static const struct of_device_id of_lp873x_match_table[] = {
    72		{ .compatible = "ti,lp8733", },
    73		{ .compatible = "ti,lp8732", },
    74		{}
    75	};
    76	MODULE_DEVICE_TABLE(of, of_lp873x_match_table);
    77	
    78	static struct i2c_driver lp873x_driver = {
    79		.driver		= {
    80			.name	= "lp873x",
    81			.of_match_table = of_lp873x_match_table,
    82		},
  > 83		.probe_new		= lp873x_probe,
    84	};
    85	module_i2c_driver(lp873x_driver);
    86	
    87	MODULE_AUTHOR("J Keerthy <j-keerthy@ti.com>");
    88	MODULE_DESCRIPTION("LP873X chip family multi-function driver");
    89	MODULE_LICENSE("GPL v2");

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/octet-stream, Size: 39202 bytes --]

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v6 1/4] Documentation: mfd: LP873X: Add information for the mfd driver
  2016-08-08  5:46 ` [PATCH v6 1/4] Documentation: mfd: LP873X: Add information for the mfd driver Keerthy
@ 2016-08-09 12:50   ` Lee Jones
  2016-08-10  2:56     ` Keerthy
  0 siblings, 1 reply; 15+ messages in thread
From: Lee Jones @ 2016-08-09 12:50 UTC (permalink / raw)
  To: Keerthy
  Cc: broonie, tony, linus.walleij, gnurou, linux-omap, linux-kernel,
	devicetree, linux-gpio, robh+dt

On Mon, 08 Aug 2016, Keerthy wrote:

> The lp873x series of PMICs have a bunch of regulators and a couple
> of GPO(General Purpose Outputs).
> Add information for the MFD and regulator drivers.
> 
> Acked-by: Rob Herring <robh@kernel.org>
> Signed-off-by: Keerthy <j-keerthy@ti.com>

These should be in chronological order.  Rob could not have Acked the
patch before you sent it.

> ---
> Changes in v6:
> 
>   * Added more formating for properties.
> 
> Changes in v4:
> 
>   * Added the GPIO properties.
> 
> Changes in v3:
> 
>   * Changed the example node lable to pmic from lp8733.
> 
>  Documentation/devicetree/bindings/mfd/lp873x.txt | 59 ++++++++++++++++++++++++
>  1 file changed, 59 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/mfd/lp873x.txt

Patch looks good though.

I'll fix the nit above.

Applied, thanks.

> diff --git a/Documentation/devicetree/bindings/mfd/lp873x.txt b/Documentation/devicetree/bindings/mfd/lp873x.txt
> new file mode 100644
> index 0000000..1377c25
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/mfd/lp873x.txt
> @@ -0,0 +1,59 @@
> +TI LP873X PMIC MFD driver
> +
> +Required properties:
> +  - compatible:	"ti,lp8732", "ti,lp8733"
> +  - reg:		I2C slave address.
> +  - gpio-controller:	Marks the device node as a GPIO Controller.
> +  - #gpio-cells:	Should be two.  The first cell is the pin number and
> +			the second cell is used to specify flags.
> +			See ../gpio/gpio.txt for more information.
> +  - regulators:	List of child nodes that specify the regulator
> +			initialization data.
> +Example:
> +
> +pmic: lp8733@60 {
> +	compatible = "ti,lp8733";
> +	reg = <0x60>;
> +	gpio-controller;
> +	#gpio-cells = <2>;
> +
> +	regulators {
> +		lp8733_buck0: buck0 {
> +			regulator-name = "lp8733-buck0";
> +			regulator-min-microvolt = <800000>;
> +			regulator-max-microvolt = <1400000>;
> +			regulator-min-microamp = <1500000>;
> +			regulator-max-microamp = <4000000>;
> +			regulator-ramp-delay = <10000>;
> +			regulator-always-on;
> +			regulator-boot-on;
> +		};
> +
> +		lp8733_buck1: buck1 {
> +			regulator-name = "lp8733-buck1";
> +			regulator-min-microvolt = <800000>;
> +			regulator-max-microvolt = <1400000>;
> +			regulator-min-microamp = <1500000>;
> +			regulator-max-microamp = <4000000>;
> +			regulator-ramp-delay = <10000>;
> +			regulator-boot-on;
> +			regulator-always-on;
> +		};
> +
> +		lp8733_ldo0: ldo0 {
> +			regulator-name = "lp8733-ldo0";
> +			regulator-min-microvolt = <800000>;
> +			regulator-max-microvolt = <3000000>;
> +			regulator-boot-on;
> +			regulator-always-on;
> +		};
> +
> +		lp8733_ldo1: ldo1 {
> +			regulator-name = "lp8733-ldo1";
> +			regulator-min-microvolt = <800000>;
> +			regulator-max-microvolt = <3000000>;
> +			regulator-always-on;
> +			regulator-boot-on;
> +		};
> +	};
> +};

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v6 2/4] mfd: lp873x: Add lp873x PMIC support
  2016-08-08  5:46 ` [PATCH v6 2/4] mfd: lp873x: Add lp873x PMIC support Keerthy
  2016-08-08  6:26   ` kbuild test robot
  2016-08-08  8:41   ` kbuild test robot
@ 2016-08-09 12:53   ` Lee Jones
  2016-08-10  2:57     ` Keerthy
  2 siblings, 1 reply; 15+ messages in thread
From: Lee Jones @ 2016-08-09 12:53 UTC (permalink / raw)
  To: Keerthy
  Cc: broonie, tony, linus.walleij, gnurou, linux-omap, linux-kernel,
	devicetree, linux-gpio, robh+dt

On Mon, 08 Aug 2016, Keerthy wrote:

> The LP873X chip is a power management IC for Portable Navigation Systems
>     and Tablet Computing devices. It contains the following components:
> 
>      - Regulators.
>      - Configurable General Purpose Output Signals(GPO).
> 
> PMIC interacts with the main processor through i2c. PMIC has
> couple of LDOs(Linear Regulators), couple of BUCKs (Step-Down DC-DC
> Converter Cores) and GPOs(General Purpose Output Signals).
> 
> Signed-off-by: Keerthy <j-keerthy@ti.com>
> ---
> Changes in v6:
> 
>   * Rebased on top of http://www.gossamer-threads.com/lists/linux/kernel/2457552.
>   * Hence added probe_new instead of probe and removed unused i2c_device_id.

No, please don't do that.  This patch-set is blocked.

Please rebase on top of a mainline release and re-send.

We still need the I2C table, for now.

> Changes in v4:
> 
>   * Added Author.
>   * Added the mfd_cell for gpio.
> 
> Changes in v3:
> 
>   * Reordered the probe code.
>   * Fixed Typo in Kconfig description.
>   * Removed unused member from struct lp873x.
> 
>  drivers/mfd/Kconfig        |  14 +++
>  drivers/mfd/Makefile       |   2 +
>  drivers/mfd/lp873x.c       |  89 +++++++++++++++
>  include/linux/mfd/lp873x.h | 264 +++++++++++++++++++++++++++++++++++++++++++++
>  4 files changed, 369 insertions(+)
>  create mode 100644 drivers/mfd/lp873x.c
>  create mode 100644 include/linux/mfd/lp873x.h
> 
> diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
> index 2d1fb64..45fe00a 100644
> --- a/drivers/mfd/Kconfig
> +++ b/drivers/mfd/Kconfig
> @@ -1224,6 +1224,20 @@ config MFD_TPS65217
>  	  This driver can also be built as a module.  If so, the module
>  	  will be called tps65217.
>  
> +config MFD_TI_LP873X
> +	tristate "TI LP873X Power Management IC"
> +	depends on I2C
> +	select MFD_CORE
> +	select REGMAP_I2C
> +	help
> +	  If you say yes here then you get support for the LP873X series of
> +	  Power Management Integrated Circuits(PMIC).
> +	  These include voltage regulators, Thermal protection, Configurable
> +	  General Purpose Outputs(GPO) that are used in portable devices.
> +
> +	  This driver can also be built as a module. If so, the module
> +	  will be called lp873x.
> +
>  config MFD_TPS65218
>  	tristate "TI TPS65218 Power Management chips"
>  	depends on I2C
> diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
> index 2ba3ba3..42acbcd 100644
> --- a/drivers/mfd/Makefile
> +++ b/drivers/mfd/Makefile
> @@ -22,6 +22,8 @@ obj-$(CONFIG_HTC_EGPIO)		+= htc-egpio.o
>  obj-$(CONFIG_HTC_PASIC3)	+= htc-pasic3.o
>  obj-$(CONFIG_HTC_I2CPLD)	+= htc-i2cpld.o
>  
> +obj-$(CONFIG_MFD_TI_LP873X)	+= lp873x.o
> +
>  obj-$(CONFIG_MFD_DAVINCI_VOICECODEC)	+= davinci_voicecodec.o
>  obj-$(CONFIG_MFD_DM355EVM_MSP)	+= dm355evm_msp.o
>  obj-$(CONFIG_MFD_TI_AM335X_TSCADC)	+= ti_am335x_tscadc.o
> diff --git a/drivers/mfd/lp873x.c b/drivers/mfd/lp873x.c
> new file mode 100644
> index 0000000..3c8e8d0
> --- /dev/null
> +++ b/drivers/mfd/lp873x.c
> @@ -0,0 +1,89 @@
> +/*
> + * Copyright (C) 2016 Texas Instruments Incorporated - http://www.ti.com/
> + *
> + * Author: Keerthy <j-keerthy@ti.com>
> + *
> + * 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 version 2.
> + *
> + * This program is distributed "as is" WITHOUT ANY WARRANTY of any
> + * kind, whether express or implied; without even the implied warranty
> + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + */
> +
> +#include <linux/interrupt.h>
> +#include <linux/mfd/core.h>
> +#include <linux/module.h>
> +#include <linux/of_device.h>
> +#include <linux/regmap.h>
> +
> +#include <linux/mfd/lp873x.h>
> +
> +static const struct regmap_config lp873x_regmap_config = {
> +	.reg_bits = 8,
> +	.val_bits = 8,
> +	.max_register = LP873X_REG_MAX,
> +};
> +
> +static const struct mfd_cell lp873x_cells[] = {
> +	{ .name = "lp873x-regulator", },
> +	{ .name = "lp873x-gpio", },
> +};
> +
> +static int lp873x_probe(struct i2c_client *client)
> +{
> +	struct lp873x *lp873;
> +	int ret;
> +	unsigned int otpid;
> +
> +	lp873 = devm_kzalloc(&client->dev, sizeof(*lp873), GFP_KERNEL);
> +	if (!lp873)
> +		return -ENOMEM;
> +
> +	lp873->dev = &client->dev;
> +
> +	lp873->regmap = devm_regmap_init_i2c(client, &lp873x_regmap_config);
> +	if (IS_ERR(lp873->regmap)) {
> +		ret = PTR_ERR(lp873->regmap);
> +		dev_err(lp873->dev,
> +			"Failed to initialize register map: %d\n", ret);
> +		return ret;
> +	}
> +
> +	mutex_init(&lp873->lock);
> +
> +	ret = regmap_read(lp873->regmap, LP873X_REG_OTP_REV, &otpid);
> +	if (ret) {
> +		dev_err(lp873->dev, "Failed to read OTP ID\n");
> +		return ret;
> +	}
> +
> +	lp873->rev = otpid & LP873X_OTP_REV_OTP_ID;
> +	i2c_set_clientdata(client, lp873);
> +	ret = mfd_add_devices(lp873->dev, PLATFORM_DEVID_AUTO, lp873x_cells,
> +			      ARRAY_SIZE(lp873x_cells), NULL, 0, NULL);
> +
> +	return ret;
> +}
> +
> +static const struct of_device_id of_lp873x_match_table[] = {
> +	{ .compatible = "ti,lp8733", },
> +	{ .compatible = "ti,lp8732", },
> +	{}
> +};
> +MODULE_DEVICE_TABLE(of, of_lp873x_match_table);
> +
> +static struct i2c_driver lp873x_driver = {
> +	.driver		= {
> +		.name	= "lp873x",
> +		.of_match_table = of_lp873x_match_table,
> +	},
> +	.probe_new		= lp873x_probe,
> +};
> +module_i2c_driver(lp873x_driver);
> +
> +MODULE_AUTHOR("J Keerthy <j-keerthy@ti.com>");
> +MODULE_DESCRIPTION("LP873X chip family multi-function driver");
> +MODULE_LICENSE("GPL v2");
> diff --git a/include/linux/mfd/lp873x.h b/include/linux/mfd/lp873x.h
> new file mode 100644
> index 0000000..42bebfa
> --- /dev/null
> +++ b/include/linux/mfd/lp873x.h
> @@ -0,0 +1,264 @@
> +/*
> + * Functions to access LP873X power management chip.
> + *
> + * Copyright (C) 2016 Texas Instruments Incorporated - http://www.ti.com/
> + *
> + * 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 version 2.
> + *
> + * This program is distributed "as is" WITHOUT ANY WARRANTY of any
> + * kind, whether express or implied; without even the implied warranty
> + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + */
> +
> +#ifndef __LINUX_MFD_LP873X_H
> +#define __LINUX_MFD_LP873X_H
> +
> +#include <linux/i2c.h>
> +#include <linux/regulator/driver.h>
> +#include <linux/regulator/machine.h>
> +
> +/* LP873x chip id list */
> +#define LP873X			0x00
> +
> +/* All register addresses */
> +#define LP873X_REG_DEV_REV		0X00
> +#define LP873X_REG_OTP_REV		0X01
> +#define LP873X_REG_BUCK0_CTRL_1		0X02
> +#define LP873X_REG_BUCK0_CTRL_2		0X03
> +#define LP873X_REG_BUCK1_CTRL_1		0X04
> +#define LP873X_REG_BUCK1_CTRL_2		0X05
> +#define LP873X_REG_BUCK0_VOUT		0X06
> +#define LP873X_REG_BUCK1_VOUT		0X07
> +#define LP873X_REG_LDO0_CTRL		0X08
> +#define LP873X_REG_LDO1_CTRL            0X09
> +#define LP873X_REG_LDO0_VOUT		0X0A
> +#define LP873X_REG_LDO1_VOUT		0X0B
> +#define LP873X_REG_BUCK0_DELAY		0X0C
> +#define LP873X_REG_BUCK1_DELAY		0X0D
> +#define LP873X_REG_LDO0_DELAY		0X0E
> +#define LP873X_REG_LDO1_DELAY		0X0F
> +#define LP873X_REG_GPO_DELAY		0X10
> +#define LP873X_REG_GPO2_DELAY		0X11
> +#define LP873X_REG_GPO_CTRL		0X12
> +#define LP873X_REG_CONFIG		0X13
> +#define LP873X_REG_PLL_CTRL		0X14
> +#define LP873X_REG_PGOOD_CTRL1		0X15
> +#define LP873X_REG_PGOOD_CTRL2		0X16
> +#define LP873X_REG_PG_FAULT		0X17
> +#define LP873X_REG_RESET		0X18
> +#define LP873X_REG_INT_TOP_1		0X19
> +#define LP873X_REG_INT_TOP_2		0X1A
> +#define LP873X_REG_INT_BUCK		0X1B
> +#define LP873X_REG_INT_LDO		0X1C
> +#define LP873X_REG_TOP_STAT		0X1D
> +#define LP873X_REG_BUCK_STAT		0X1E
> +#define LP873X_REG_LDO_STAT		0x1F
> +#define LP873X_REG_TOP_MASK_1		0x20
> +#define LP873X_REG_TOP_MASK_2		0x21
> +#define LP873X_REG_BUCK_MASK		0x22
> +#define LP873X_REG_LDO_MASK		0x23
> +#define LP873X_REG_SEL_I_LOAD		0x24
> +#define LP873X_REG_I_LOAD_2		0x25
> +#define LP873X_REG_I_LOAD_1		0x26
> +
> +#define LP873X_REG_MAX			LP873X_REG_I_LOAD_1
> +
> +/* Register field definitions */
> +#define LP873X_DEV_REV_DEV_ID			0xC0
> +#define LP873X_DEV_REV_ALL_LAYER		0x30
> +#define LP873X_DEV_REV_METAL_LAYER		0x0F
> +
> +#define LP873X_OTP_REV_OTP_ID			0xFF
> +
> +#define LP873X_BUCK0_CTRL_1_BUCK0_FPWM		BIT(3)
> +#define LP873X_BUCK0_CTRL_1_BUCK0_RDIS_EN	BIT(2)
> +#define LP873X_BUCK0_CTRL_1_BUCK0_EN_PIN_CTRL	BIT(1)
> +#define LP873X_BUCK0_CTRL_1_BUCK0_EN		BIT(0)
> +
> +#define LP873X_BUCK0_CTRL_2_BUCK0_ILIM		0x38
> +#define LP873X_BUCK0_CTRL_2_BUCK0_SLEW_RATE	0x07
> +
> +#define LP873X_BUCK1_CTRL_1_BUCK1_FPWM		BIT(3)
> +#define LP873X_BUCK1_CTRL_1_BUCK1_RDIS_EN	BIT(2)
> +#define LP873X_BUCK1_CTRL_1_BUCK1_EN_PIN_CTRL	BIT(1)
> +#define LP873X_BUCK1_CTRL_1_BUCK1_EN		BIT(0)
> +
> +#define LP873X_BUCK1_CTRL_2_BUCK1_ILIM		0x38
> +#define LP873X_BUCK1_CTRL_2_BUCK1_SLEW_RATE	0x07
> +
> +#define LP873X_BUCK0_VOUT_BUCK0_VSET		0xFF
> +
> +#define LP873X_BUCK1_VOUT_BUCK1_VSET		0xFF
> +
> +#define LP873X_LDO0_CTRL_LDO0_RDIS_EN		BIT(2)
> +#define LP873X_LDO0_CTRL_LDO0_EN_PIN_CTRL	BIT(1)
> +#define LP873X_LDO0_CTRL_LDO0_EN		BIT(0)
> +
> +#define LP873X_LDO1_CTRL_LDO1_RDIS_EN		BIT(2)
> +#define LP873X_LDO1_CTRL_LDO1_EN_PIN_CTRL	BIT(1)
> +#define LP873X_LDO1_CTRL_LDO1_EN		BIT(0)
> +
> +#define LP873X_LDO0_VOUT_LDO0_VSET		0x1F
> +
> +#define LP873X_LDO1_VOUT_LDO1_VSET		0x1F
> +
> +#define LP873X_BUCK0_DELAY_BUCK0_SD_DELAY	0xF0
> +#define LP873X_BUCK0_DELAY_BUCK0_SU_DELAY	0x0F
> +
> +#define LP873X_BUCK1_DELAY_BUCK1_SD_DELAY	0xF0
> +#define LP873X_BUCK1_DELAY_BUCK1_SU_DELAY	0x0F
> +
> +#define LP873X_LDO0_DELAY_LDO0_SD_DELAY	0xF0
> +#define LP873X_LDO0_DELAY_LDO0_SU_DELAY	0x0F
> +
> +#define LP873X_LDO1_DELAY_LDO1_SD_DELAY	0xF0
> +#define LP873X_LDO1_DELAY_LDO1_SU_DELAY	0x0F
> +
> +#define LP873X_GPO_DELAY_GPO_SD_DELAY		0xF0
> +#define LP873X_GPO_DELAY_GPO_SU_DELAY		0x0F
> +
> +#define LP873X_GPO2_DELAY_GPO2_SD_DELAY	0xF0
> +#define LP873X_GPO2_DELAY_GPO2_SU_DELAY	0x0F
> +
> +#define LP873X_GPO_CTRL_GPO2_OD		BIT(6)
> +#define LP873X_GPO_CTRL_GPO2_EN_PIN_CTRL	BIT(5)
> +#define LP873X_GPO_CTRL_GPO2_EN		BIT(4)
> +#define LP873X_GPO_CTRL_GPO_OD			BIT(2)
> +#define LP873X_GPO_CTRL_GPO_EN_PIN_CTRL	BIT(1)
> +#define LP873X_GPO_CTRL_GPO_EN			BIT(0)
> +
> +#define LP873X_CONFIG_SU_DELAY_SEL		BIT(6)
> +#define LP873X_CONFIG_SD_DELAY_SEL		BIT(5)
> +#define LP873X_CONFIG_CLKIN_PIN_SEL		BIT(4)
> +#define LP873X_CONFIG_CLKIN_PD			BIT(3)
> +#define LP873X_CONFIG_EN_PD			BIT(2)
> +#define LP873X_CONFIG_TDIE_WARN_LEVEL		BIT(1)
> +#define LP873X_EN_SPREAD_SPEC			BIT(0)
> +
> +#define LP873X_PLL_CTRL_EN_PLL			BIT(6)
> +#define LP873X_EXT_CLK_FREQ			0x1F
> +
> +#define LP873X_PGOOD_CTRL1_PGOOD_POL		BIT(7)
> +#define LP873X_PGOOD_CTRL1_PGOOD_OD		BIT(6)
> +#define LP873X_PGOOD_CTRL1_PGOOD_WINDOW_LDO	BIT(5)
> +#define LP873X_PGOOD_CTRL1_PGOOD_WINDOWN_BUCK	BIT(4)
> +#define LP873X_PGOOD_CTRL1_PGOOD_EN_PGOOD_LDO1	BIT(3)
> +#define LP873X_PGOOD_CTRL1_PGOOD_EN_PGOOD_LDO0	BIT(2)
> +#define LP873X_PGOOD_CTRL1_PGOOD_EN_PGOOD_BUCK1	BIT(1)
> +#define LP873X_PGOOD_CTRL1_PGOOD_EN_PGOOD_BUCK0	BIT(0)
> +
> +#define LP873X_PGOOD_CTRL2_EN_PGOOD_TWARN	BIT(2)
> +#define LP873X_PGOOD_CTRL2_EN_PG_FAULT_GATE	BIT(1)
> +#define LP873X_PGOOD_CTRL2_PGOOD_MODE		BIT(0)
> +
> +#define LP873X_PG_FAULT_PG_FAULT_LDO1		BIT(3)
> +#define LP873X_PG_FAULT_PG_FAULT_LDO0		BIT(2)
> +#define LP873X_PG_FAULT_PG_FAULT_BUCK1		BIT(1)
> +#define LP873X_PG_FAULT_PG_FAULT_BUCK0		BIT(0)
> +
> +#define LP873X_RESET_SW_RESET			BIT(0)
> +
> +#define LP873X_INT_TOP_1_PGOOD_INT		BIT(7)
> +#define LP873X_INT_TOP_1_LDO_INT		BIT(6)
> +#define LP873X_INT_TOP_1_BUCK_INT		BIT(5)
> +#define LP873X_INT_TOP_1_SYNC_CLK_INT		BIT(4)
> +#define LP873X_INT_TOP_1_TDIE_SD_INT		BIT(3)
> +#define LP873X_INT_TOP_1_TDIE_WARN_INT		BIT(2)
> +#define LP873X_INT_TOP_1_OVP_INT		BIT(1)
> +#define LP873X_INT_TOP_1_I_MEAS_INT		BIT(0)
> +
> +#define LP873X_INT_TOP_2_RESET_REG_INT		BIT(0)
> +
> +#define LP873X_INT_BUCK_BUCK1_PG_INT		BIT(6)
> +#define LP873X_INT_BUCK_BUCK1_SC_INT		BIT(5)
> +#define LP873X_INT_BUCK_BUCK1_ILIM_INT		BIT(4)
> +#define LP873X_INT_BUCK_BUCK0_PG_INT		BIT(2)
> +#define LP873X_INT_BUCK_BUCK0_SC_INT		BIT(1)
> +#define LP873X_INT_BUCK_BUCK0_ILIM_INT		BIT(0)
> +
> +#define LP873X_INT_LDO_LDO1_PG_INT		BIT(6)
> +#define LP873X_INT_LDO_LDO1_SC_INT		BIT(5)
> +#define LP873X_INT_LDO_LDO1_ILIM_INT		BIT(4)
> +#define LP873X_INT_LDO_LDO0_PG_INT		BIT(2)
> +#define LP873X_INT_LDO_LDO0_SC_INT		BIT(1)
> +#define LP873X_INT_LDO_LDO0_ILIM_INT		BIT(0)
> +
> +#define LP873X_TOP_STAT_PGOOD_STAT		BIT(7)
> +#define LP873X_TOP_STAT_SYNC_CLK_STAT		BIT(4)
> +#define LP873X_TOP_STAT_TDIE_SD_STAT		BIT(3)
> +#define LP873X_TOP_STAT_TDIE_WARN_STAT		BIT(2)
> +#define LP873X_TOP_STAT_OVP_STAT		BIT(1)
> +
> +#define LP873X_BUCK_STAT_BUCK1_STAT		BIT(7)
> +#define LP873X_BUCK_STAT_BUCK1_PG_STAT		BIT(6)
> +#define LP873X_BUCK_STAT_BUCK1_ILIM_STAT	BIT(4)
> +#define LP873X_BUCK_STAT_BUCK0_STAT		BIT(3)
> +#define LP873X_BUCK_STAT_BUCK0_PG_STAT		BIT(2)
> +#define LP873X_BUCK_STAT_BUCK0_ILIM_STAT	BIT(0)
> +
> +#define LP873X_LDO_STAT_LDO1_STAT		BIT(7)
> +#define LP873X_LDO_STAT_LDO1_PG_STAT		BIT(6)
> +#define LP873X_LDO_STAT_LDO1_ILIM_STAT		BIT(4)
> +#define LP873X_LDO_STAT_LDO0_STAT		BIT(3)
> +#define LP873X_LDO_STAT_LDO0_PG_STAT		BIT(2)
> +#define LP873X_LDO_STAT_LDO0_ILIM_STAT		BIT(0)
> +
> +#define LP873X_TOP_MASK_1_PGOOD_INT_MASK	BIT(7)
> +#define LP873X_TOP_MASK_1_SYNC_CLK_MASK	BIT(4)
> +#define LP873X_TOP_MASK_1_TDIE_WARN_MASK	BIT(2)
> +#define LP873X_TOP_MASK_1_I_MEAS_MASK		BIT(0)
> +
> +#define LP873X_TOP_MASK_2_RESET_REG_MASK	BIT(0)
> +
> +#define LP873X_BUCK_MASK_BUCK1_PGF_MASK	BIT(7)
> +#define LP873X_BUCK_MASK_BUCK1_PGR_MASK	BIT(6)
> +#define LP873X_BUCK_MASK_BUCK1_ILIM_MASK	BIT(4)
> +#define LP873X_BUCK_MASK_BUCK0_PGF_MASK	BIT(3)
> +#define LP873X_BUCK_MASK_BUCK0_PGR_MASK	BIT(2)
> +#define LP873X_BUCK_MASK_BUCK0_ILIM_MASK	BIT(0)
> +
> +#define LP873X_LDO_MASK_LDO1_PGF_MASK		BIT(7)
> +#define LP873X_LDO_MASK_LDO1_PGR_MASK		BIT(6)
> +#define LP873X_LDO_MASK_LDO1_ILIM_MASK		BIT(4)
> +#define LP873X_LDO_MASK_LDO0_PGF_MASK		BIT(3)
> +#define LP873X_LDO_MASK_LDO0_PGR_MASK		BIT(2)
> +#define LP873X_LDO_MASK_LDO0_ILIM_MASK		BIT(0)
> +
> +#define LP873X_SEL_I_LOAD_CURRENT_BUCK_SELECT	BIT(0)
> +
> +#define LP873X_I_LOAD_2_BUCK_LOAD_CURRENT	BIT(0)
> +
> +#define LP873X_I_LOAD_1_BUCK_LOAD_CURRENT	0xFF
> +
> +#define LP873X_MAX_REG_ID		LP873X_LDO_1
> +
> +/* Number of step-down converters available */
> +#define LP873X_NUM_BUCK		2
> +/* Number of LDO voltage regulators available */
> +#define LP873X_NUM_LDO		2
> +/* Number of total regulators available */
> +#define LP873X_NUM_REGULATOR		(LP873X_NUM_BUCK + LP873X_NUM_LDO)
> +
> +enum lp873x_regulator_id {
> +	/* BUCK's */
> +	LP873X_BUCK_0,
> +	LP873X_BUCK_1,
> +	/* LDOs */
> +	LP873X_LDO_0,
> +	LP873X_LDO_1,
> +};
> +
> +/**
> + * struct lp873x - state holder for the lp873x driver
> + * Device data may be used to access the LP873X chip
> + */
> +struct lp873x {
> +	struct device *dev;
> +	u8 rev;
> +	struct mutex lock;	/* lock guarding the data structure */
> +	struct regmap *regmap;
> +};
> +#endif /*  __LINUX_MFD_LP873X_H */

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v6 1/4] Documentation: mfd: LP873X: Add information for the mfd driver
  2016-08-09 12:50   ` Lee Jones
@ 2016-08-10  2:56     ` Keerthy
  0 siblings, 0 replies; 15+ messages in thread
From: Keerthy @ 2016-08-10  2:56 UTC (permalink / raw)
  To: Lee Jones, Keerthy
  Cc: broonie, tony, linus.walleij, gnurou, linux-omap, linux-kernel,
	devicetree, linux-gpio, robh+dt



On Tuesday 09 August 2016 06:20 PM, Lee Jones wrote:
> On Mon, 08 Aug 2016, Keerthy wrote:
>
>> The lp873x series of PMICs have a bunch of regulators and a couple
>> of GPO(General Purpose Outputs).
>> Add information for the MFD and regulator drivers.
>>
>> Acked-by: Rob Herring <robh@kernel.org>
>> Signed-off-by: Keerthy <j-keerthy@ti.com>
>
> These should be in chronological order.  Rob could not have Acked the
> patch before you sent it.
>
>> ---
>> Changes in v6:
>>
>>    * Added more formating for properties.
>>
>> Changes in v4:
>>
>>    * Added the GPIO properties.
>>
>> Changes in v3:
>>
>>    * Changed the example node lable to pmic from lp8733.
>>
>>   Documentation/devicetree/bindings/mfd/lp873x.txt | 59 ++++++++++++++++++++++++
>>   1 file changed, 59 insertions(+)
>>   create mode 100644 Documentation/devicetree/bindings/mfd/lp873x.txt
>
> Patch looks good though.
>
> I'll fix the nit above.

Okay thanks.

>
> Applied, thanks.
>
>> diff --git a/Documentation/devicetree/bindings/mfd/lp873x.txt b/Documentation/devicetree/bindings/mfd/lp873x.txt
>> new file mode 100644
>> index 0000000..1377c25
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/mfd/lp873x.txt
>> @@ -0,0 +1,59 @@
>> +TI LP873X PMIC MFD driver
>> +
>> +Required properties:
>> +  - compatible:	"ti,lp8732", "ti,lp8733"
>> +  - reg:		I2C slave address.
>> +  - gpio-controller:	Marks the device node as a GPIO Controller.
>> +  - #gpio-cells:	Should be two.  The first cell is the pin number and
>> +			the second cell is used to specify flags.
>> +			See ../gpio/gpio.txt for more information.
>> +  - regulators:	List of child nodes that specify the regulator
>> +			initialization data.
>> +Example:
>> +
>> +pmic: lp8733@60 {
>> +	compatible = "ti,lp8733";
>> +	reg = <0x60>;
>> +	gpio-controller;
>> +	#gpio-cells = <2>;
>> +
>> +	regulators {
>> +		lp8733_buck0: buck0 {
>> +			regulator-name = "lp8733-buck0";
>> +			regulator-min-microvolt = <800000>;
>> +			regulator-max-microvolt = <1400000>;
>> +			regulator-min-microamp = <1500000>;
>> +			regulator-max-microamp = <4000000>;
>> +			regulator-ramp-delay = <10000>;
>> +			regulator-always-on;
>> +			regulator-boot-on;
>> +		};
>> +
>> +		lp8733_buck1: buck1 {
>> +			regulator-name = "lp8733-buck1";
>> +			regulator-min-microvolt = <800000>;
>> +			regulator-max-microvolt = <1400000>;
>> +			regulator-min-microamp = <1500000>;
>> +			regulator-max-microamp = <4000000>;
>> +			regulator-ramp-delay = <10000>;
>> +			regulator-boot-on;
>> +			regulator-always-on;
>> +		};
>> +
>> +		lp8733_ldo0: ldo0 {
>> +			regulator-name = "lp8733-ldo0";
>> +			regulator-min-microvolt = <800000>;
>> +			regulator-max-microvolt = <3000000>;
>> +			regulator-boot-on;
>> +			regulator-always-on;
>> +		};
>> +
>> +		lp8733_ldo1: ldo1 {
>> +			regulator-name = "lp8733-ldo1";
>> +			regulator-min-microvolt = <800000>;
>> +			regulator-max-microvolt = <3000000>;
>> +			regulator-always-on;
>> +			regulator-boot-on;
>> +		};
>> +	};
>> +};
>

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v6 2/4] mfd: lp873x: Add lp873x PMIC support
  2016-08-09 12:53   ` Lee Jones
@ 2016-08-10  2:57     ` Keerthy
  2016-08-10  8:18       ` Lee Jones
  0 siblings, 1 reply; 15+ messages in thread
From: Keerthy @ 2016-08-10  2:57 UTC (permalink / raw)
  To: Lee Jones, Keerthy
  Cc: broonie, tony, linus.walleij, gnurou, linux-omap, linux-kernel,
	devicetree, linux-gpio, robh+dt



On Tuesday 09 August 2016 06:23 PM, Lee Jones wrote:
> On Mon, 08 Aug 2016, Keerthy wrote:
>
>> The LP873X chip is a power management IC for Portable Navigation Systems
>>      and Tablet Computing devices. It contains the following components:
>>
>>       - Regulators.
>>       - Configurable General Purpose Output Signals(GPO).
>>
>> PMIC interacts with the main processor through i2c. PMIC has
>> couple of LDOs(Linear Regulators), couple of BUCKs (Step-Down DC-DC
>> Converter Cores) and GPOs(General Purpose Output Signals).
>>
>> Signed-off-by: Keerthy <j-keerthy@ti.com>
>> ---
>> Changes in v6:
>>
>>    * Rebased on top of http://www.gossamer-threads.com/lists/linux/kernel/2457552.
>>    * Hence added probe_new instead of probe and removed unused i2c_device_id.
>
> No, please don't do that.  This patch-set is blocked.
>
> Please rebase on top of a mainline release and re-send.
>
> We still need the I2C table, for now.

Okay. Guess i did some testing for that series then :-P.
I will revert only that and send patch[es [2-4].

Regards,
Keerthy
>
>> Changes in v4:
>>
>>    * Added Author.
>>    * Added the mfd_cell for gpio.
>>
>> Changes in v3:
>>
>>    * Reordered the probe code.
>>    * Fixed Typo in Kconfig description.
>>    * Removed unused member from struct lp873x.
>>
>>   drivers/mfd/Kconfig        |  14 +++
>>   drivers/mfd/Makefile       |   2 +
>>   drivers/mfd/lp873x.c       |  89 +++++++++++++++
>>   include/linux/mfd/lp873x.h | 264 +++++++++++++++++++++++++++++++++++++++++++++
>>   4 files changed, 369 insertions(+)
>>   create mode 100644 drivers/mfd/lp873x.c
>>   create mode 100644 include/linux/mfd/lp873x.h
>>
>> diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
>> index 2d1fb64..45fe00a 100644
>> --- a/drivers/mfd/Kconfig
>> +++ b/drivers/mfd/Kconfig
>> @@ -1224,6 +1224,20 @@ config MFD_TPS65217
>>   	  This driver can also be built as a module.  If so, the module
>>   	  will be called tps65217.
>>
>> +config MFD_TI_LP873X
>> +	tristate "TI LP873X Power Management IC"
>> +	depends on I2C
>> +	select MFD_CORE
>> +	select REGMAP_I2C
>> +	help
>> +	  If you say yes here then you get support for the LP873X series of
>> +	  Power Management Integrated Circuits(PMIC).
>> +	  These include voltage regulators, Thermal protection, Configurable
>> +	  General Purpose Outputs(GPO) that are used in portable devices.
>> +
>> +	  This driver can also be built as a module. If so, the module
>> +	  will be called lp873x.
>> +
>>   config MFD_TPS65218
>>   	tristate "TI TPS65218 Power Management chips"
>>   	depends on I2C
>> diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
>> index 2ba3ba3..42acbcd 100644
>> --- a/drivers/mfd/Makefile
>> +++ b/drivers/mfd/Makefile
>> @@ -22,6 +22,8 @@ obj-$(CONFIG_HTC_EGPIO)		+= htc-egpio.o
>>   obj-$(CONFIG_HTC_PASIC3)	+= htc-pasic3.o
>>   obj-$(CONFIG_HTC_I2CPLD)	+= htc-i2cpld.o
>>
>> +obj-$(CONFIG_MFD_TI_LP873X)	+= lp873x.o
>> +
>>   obj-$(CONFIG_MFD_DAVINCI_VOICECODEC)	+= davinci_voicecodec.o
>>   obj-$(CONFIG_MFD_DM355EVM_MSP)	+= dm355evm_msp.o
>>   obj-$(CONFIG_MFD_TI_AM335X_TSCADC)	+= ti_am335x_tscadc.o
>> diff --git a/drivers/mfd/lp873x.c b/drivers/mfd/lp873x.c
>> new file mode 100644
>> index 0000000..3c8e8d0
>> --- /dev/null
>> +++ b/drivers/mfd/lp873x.c
>> @@ -0,0 +1,89 @@
>> +/*
>> + * Copyright (C) 2016 Texas Instruments Incorporated - http://www.ti.com/
>> + *
>> + * Author: Keerthy <j-keerthy@ti.com>
>> + *
>> + * 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 version 2.
>> + *
>> + * This program is distributed "as is" WITHOUT ANY WARRANTY of any
>> + * kind, whether express or implied; without even the implied warranty
>> + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>> + * GNU General Public License for more details.
>> + */
>> +
>> +#include <linux/interrupt.h>
>> +#include <linux/mfd/core.h>
>> +#include <linux/module.h>
>> +#include <linux/of_device.h>
>> +#include <linux/regmap.h>
>> +
>> +#include <linux/mfd/lp873x.h>
>> +
>> +static const struct regmap_config lp873x_regmap_config = {
>> +	.reg_bits = 8,
>> +	.val_bits = 8,
>> +	.max_register = LP873X_REG_MAX,
>> +};
>> +
>> +static const struct mfd_cell lp873x_cells[] = {
>> +	{ .name = "lp873x-regulator", },
>> +	{ .name = "lp873x-gpio", },
>> +};
>> +
>> +static int lp873x_probe(struct i2c_client *client)
>> +{
>> +	struct lp873x *lp873;
>> +	int ret;
>> +	unsigned int otpid;
>> +
>> +	lp873 = devm_kzalloc(&client->dev, sizeof(*lp873), GFP_KERNEL);
>> +	if (!lp873)
>> +		return -ENOMEM;
>> +
>> +	lp873->dev = &client->dev;
>> +
>> +	lp873->regmap = devm_regmap_init_i2c(client, &lp873x_regmap_config);
>> +	if (IS_ERR(lp873->regmap)) {
>> +		ret = PTR_ERR(lp873->regmap);
>> +		dev_err(lp873->dev,
>> +			"Failed to initialize register map: %d\n", ret);
>> +		return ret;
>> +	}
>> +
>> +	mutex_init(&lp873->lock);
>> +
>> +	ret = regmap_read(lp873->regmap, LP873X_REG_OTP_REV, &otpid);
>> +	if (ret) {
>> +		dev_err(lp873->dev, "Failed to read OTP ID\n");
>> +		return ret;
>> +	}
>> +
>> +	lp873->rev = otpid & LP873X_OTP_REV_OTP_ID;
>> +	i2c_set_clientdata(client, lp873);
>> +	ret = mfd_add_devices(lp873->dev, PLATFORM_DEVID_AUTO, lp873x_cells,
>> +			      ARRAY_SIZE(lp873x_cells), NULL, 0, NULL);
>> +
>> +	return ret;
>> +}
>> +
>> +static const struct of_device_id of_lp873x_match_table[] = {
>> +	{ .compatible = "ti,lp8733", },
>> +	{ .compatible = "ti,lp8732", },
>> +	{}
>> +};
>> +MODULE_DEVICE_TABLE(of, of_lp873x_match_table);
>> +
>> +static struct i2c_driver lp873x_driver = {
>> +	.driver		= {
>> +		.name	= "lp873x",
>> +		.of_match_table = of_lp873x_match_table,
>> +	},
>> +	.probe_new		= lp873x_probe,
>> +};
>> +module_i2c_driver(lp873x_driver);
>> +
>> +MODULE_AUTHOR("J Keerthy <j-keerthy@ti.com>");
>> +MODULE_DESCRIPTION("LP873X chip family multi-function driver");
>> +MODULE_LICENSE("GPL v2");
>> diff --git a/include/linux/mfd/lp873x.h b/include/linux/mfd/lp873x.h
>> new file mode 100644
>> index 0000000..42bebfa
>> --- /dev/null
>> +++ b/include/linux/mfd/lp873x.h
>> @@ -0,0 +1,264 @@
>> +/*
>> + * Functions to access LP873X power management chip.
>> + *
>> + * Copyright (C) 2016 Texas Instruments Incorporated - http://www.ti.com/
>> + *
>> + * 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 version 2.
>> + *
>> + * This program is distributed "as is" WITHOUT ANY WARRANTY of any
>> + * kind, whether express or implied; without even the implied warranty
>> + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>> + * GNU General Public License for more details.
>> + */
>> +
>> +#ifndef __LINUX_MFD_LP873X_H
>> +#define __LINUX_MFD_LP873X_H
>> +
>> +#include <linux/i2c.h>
>> +#include <linux/regulator/driver.h>
>> +#include <linux/regulator/machine.h>
>> +
>> +/* LP873x chip id list */
>> +#define LP873X			0x00
>> +
>> +/* All register addresses */
>> +#define LP873X_REG_DEV_REV		0X00
>> +#define LP873X_REG_OTP_REV		0X01
>> +#define LP873X_REG_BUCK0_CTRL_1		0X02
>> +#define LP873X_REG_BUCK0_CTRL_2		0X03
>> +#define LP873X_REG_BUCK1_CTRL_1		0X04
>> +#define LP873X_REG_BUCK1_CTRL_2		0X05
>> +#define LP873X_REG_BUCK0_VOUT		0X06
>> +#define LP873X_REG_BUCK1_VOUT		0X07
>> +#define LP873X_REG_LDO0_CTRL		0X08
>> +#define LP873X_REG_LDO1_CTRL            0X09
>> +#define LP873X_REG_LDO0_VOUT		0X0A
>> +#define LP873X_REG_LDO1_VOUT		0X0B
>> +#define LP873X_REG_BUCK0_DELAY		0X0C
>> +#define LP873X_REG_BUCK1_DELAY		0X0D
>> +#define LP873X_REG_LDO0_DELAY		0X0E
>> +#define LP873X_REG_LDO1_DELAY		0X0F
>> +#define LP873X_REG_GPO_DELAY		0X10
>> +#define LP873X_REG_GPO2_DELAY		0X11
>> +#define LP873X_REG_GPO_CTRL		0X12
>> +#define LP873X_REG_CONFIG		0X13
>> +#define LP873X_REG_PLL_CTRL		0X14
>> +#define LP873X_REG_PGOOD_CTRL1		0X15
>> +#define LP873X_REG_PGOOD_CTRL2		0X16
>> +#define LP873X_REG_PG_FAULT		0X17
>> +#define LP873X_REG_RESET		0X18
>> +#define LP873X_REG_INT_TOP_1		0X19
>> +#define LP873X_REG_INT_TOP_2		0X1A
>> +#define LP873X_REG_INT_BUCK		0X1B
>> +#define LP873X_REG_INT_LDO		0X1C
>> +#define LP873X_REG_TOP_STAT		0X1D
>> +#define LP873X_REG_BUCK_STAT		0X1E
>> +#define LP873X_REG_LDO_STAT		0x1F
>> +#define LP873X_REG_TOP_MASK_1		0x20
>> +#define LP873X_REG_TOP_MASK_2		0x21
>> +#define LP873X_REG_BUCK_MASK		0x22
>> +#define LP873X_REG_LDO_MASK		0x23
>> +#define LP873X_REG_SEL_I_LOAD		0x24
>> +#define LP873X_REG_I_LOAD_2		0x25
>> +#define LP873X_REG_I_LOAD_1		0x26
>> +
>> +#define LP873X_REG_MAX			LP873X_REG_I_LOAD_1
>> +
>> +/* Register field definitions */
>> +#define LP873X_DEV_REV_DEV_ID			0xC0
>> +#define LP873X_DEV_REV_ALL_LAYER		0x30
>> +#define LP873X_DEV_REV_METAL_LAYER		0x0F
>> +
>> +#define LP873X_OTP_REV_OTP_ID			0xFF
>> +
>> +#define LP873X_BUCK0_CTRL_1_BUCK0_FPWM		BIT(3)
>> +#define LP873X_BUCK0_CTRL_1_BUCK0_RDIS_EN	BIT(2)
>> +#define LP873X_BUCK0_CTRL_1_BUCK0_EN_PIN_CTRL	BIT(1)
>> +#define LP873X_BUCK0_CTRL_1_BUCK0_EN		BIT(0)
>> +
>> +#define LP873X_BUCK0_CTRL_2_BUCK0_ILIM		0x38
>> +#define LP873X_BUCK0_CTRL_2_BUCK0_SLEW_RATE	0x07
>> +
>> +#define LP873X_BUCK1_CTRL_1_BUCK1_FPWM		BIT(3)
>> +#define LP873X_BUCK1_CTRL_1_BUCK1_RDIS_EN	BIT(2)
>> +#define LP873X_BUCK1_CTRL_1_BUCK1_EN_PIN_CTRL	BIT(1)
>> +#define LP873X_BUCK1_CTRL_1_BUCK1_EN		BIT(0)
>> +
>> +#define LP873X_BUCK1_CTRL_2_BUCK1_ILIM		0x38
>> +#define LP873X_BUCK1_CTRL_2_BUCK1_SLEW_RATE	0x07
>> +
>> +#define LP873X_BUCK0_VOUT_BUCK0_VSET		0xFF
>> +
>> +#define LP873X_BUCK1_VOUT_BUCK1_VSET		0xFF
>> +
>> +#define LP873X_LDO0_CTRL_LDO0_RDIS_EN		BIT(2)
>> +#define LP873X_LDO0_CTRL_LDO0_EN_PIN_CTRL	BIT(1)
>> +#define LP873X_LDO0_CTRL_LDO0_EN		BIT(0)
>> +
>> +#define LP873X_LDO1_CTRL_LDO1_RDIS_EN		BIT(2)
>> +#define LP873X_LDO1_CTRL_LDO1_EN_PIN_CTRL	BIT(1)
>> +#define LP873X_LDO1_CTRL_LDO1_EN		BIT(0)
>> +
>> +#define LP873X_LDO0_VOUT_LDO0_VSET		0x1F
>> +
>> +#define LP873X_LDO1_VOUT_LDO1_VSET		0x1F
>> +
>> +#define LP873X_BUCK0_DELAY_BUCK0_SD_DELAY	0xF0
>> +#define LP873X_BUCK0_DELAY_BUCK0_SU_DELAY	0x0F
>> +
>> +#define LP873X_BUCK1_DELAY_BUCK1_SD_DELAY	0xF0
>> +#define LP873X_BUCK1_DELAY_BUCK1_SU_DELAY	0x0F
>> +
>> +#define LP873X_LDO0_DELAY_LDO0_SD_DELAY	0xF0
>> +#define LP873X_LDO0_DELAY_LDO0_SU_DELAY	0x0F
>> +
>> +#define LP873X_LDO1_DELAY_LDO1_SD_DELAY	0xF0
>> +#define LP873X_LDO1_DELAY_LDO1_SU_DELAY	0x0F
>> +
>> +#define LP873X_GPO_DELAY_GPO_SD_DELAY		0xF0
>> +#define LP873X_GPO_DELAY_GPO_SU_DELAY		0x0F
>> +
>> +#define LP873X_GPO2_DELAY_GPO2_SD_DELAY	0xF0
>> +#define LP873X_GPO2_DELAY_GPO2_SU_DELAY	0x0F
>> +
>> +#define LP873X_GPO_CTRL_GPO2_OD		BIT(6)
>> +#define LP873X_GPO_CTRL_GPO2_EN_PIN_CTRL	BIT(5)
>> +#define LP873X_GPO_CTRL_GPO2_EN		BIT(4)
>> +#define LP873X_GPO_CTRL_GPO_OD			BIT(2)
>> +#define LP873X_GPO_CTRL_GPO_EN_PIN_CTRL	BIT(1)
>> +#define LP873X_GPO_CTRL_GPO_EN			BIT(0)
>> +
>> +#define LP873X_CONFIG_SU_DELAY_SEL		BIT(6)
>> +#define LP873X_CONFIG_SD_DELAY_SEL		BIT(5)
>> +#define LP873X_CONFIG_CLKIN_PIN_SEL		BIT(4)
>> +#define LP873X_CONFIG_CLKIN_PD			BIT(3)
>> +#define LP873X_CONFIG_EN_PD			BIT(2)
>> +#define LP873X_CONFIG_TDIE_WARN_LEVEL		BIT(1)
>> +#define LP873X_EN_SPREAD_SPEC			BIT(0)
>> +
>> +#define LP873X_PLL_CTRL_EN_PLL			BIT(6)
>> +#define LP873X_EXT_CLK_FREQ			0x1F
>> +
>> +#define LP873X_PGOOD_CTRL1_PGOOD_POL		BIT(7)
>> +#define LP873X_PGOOD_CTRL1_PGOOD_OD		BIT(6)
>> +#define LP873X_PGOOD_CTRL1_PGOOD_WINDOW_LDO	BIT(5)
>> +#define LP873X_PGOOD_CTRL1_PGOOD_WINDOWN_BUCK	BIT(4)
>> +#define LP873X_PGOOD_CTRL1_PGOOD_EN_PGOOD_LDO1	BIT(3)
>> +#define LP873X_PGOOD_CTRL1_PGOOD_EN_PGOOD_LDO0	BIT(2)
>> +#define LP873X_PGOOD_CTRL1_PGOOD_EN_PGOOD_BUCK1	BIT(1)
>> +#define LP873X_PGOOD_CTRL1_PGOOD_EN_PGOOD_BUCK0	BIT(0)
>> +
>> +#define LP873X_PGOOD_CTRL2_EN_PGOOD_TWARN	BIT(2)
>> +#define LP873X_PGOOD_CTRL2_EN_PG_FAULT_GATE	BIT(1)
>> +#define LP873X_PGOOD_CTRL2_PGOOD_MODE		BIT(0)
>> +
>> +#define LP873X_PG_FAULT_PG_FAULT_LDO1		BIT(3)
>> +#define LP873X_PG_FAULT_PG_FAULT_LDO0		BIT(2)
>> +#define LP873X_PG_FAULT_PG_FAULT_BUCK1		BIT(1)
>> +#define LP873X_PG_FAULT_PG_FAULT_BUCK0		BIT(0)
>> +
>> +#define LP873X_RESET_SW_RESET			BIT(0)
>> +
>> +#define LP873X_INT_TOP_1_PGOOD_INT		BIT(7)
>> +#define LP873X_INT_TOP_1_LDO_INT		BIT(6)
>> +#define LP873X_INT_TOP_1_BUCK_INT		BIT(5)
>> +#define LP873X_INT_TOP_1_SYNC_CLK_INT		BIT(4)
>> +#define LP873X_INT_TOP_1_TDIE_SD_INT		BIT(3)
>> +#define LP873X_INT_TOP_1_TDIE_WARN_INT		BIT(2)
>> +#define LP873X_INT_TOP_1_OVP_INT		BIT(1)
>> +#define LP873X_INT_TOP_1_I_MEAS_INT		BIT(0)
>> +
>> +#define LP873X_INT_TOP_2_RESET_REG_INT		BIT(0)
>> +
>> +#define LP873X_INT_BUCK_BUCK1_PG_INT		BIT(6)
>> +#define LP873X_INT_BUCK_BUCK1_SC_INT		BIT(5)
>> +#define LP873X_INT_BUCK_BUCK1_ILIM_INT		BIT(4)
>> +#define LP873X_INT_BUCK_BUCK0_PG_INT		BIT(2)
>> +#define LP873X_INT_BUCK_BUCK0_SC_INT		BIT(1)
>> +#define LP873X_INT_BUCK_BUCK0_ILIM_INT		BIT(0)
>> +
>> +#define LP873X_INT_LDO_LDO1_PG_INT		BIT(6)
>> +#define LP873X_INT_LDO_LDO1_SC_INT		BIT(5)
>> +#define LP873X_INT_LDO_LDO1_ILIM_INT		BIT(4)
>> +#define LP873X_INT_LDO_LDO0_PG_INT		BIT(2)
>> +#define LP873X_INT_LDO_LDO0_SC_INT		BIT(1)
>> +#define LP873X_INT_LDO_LDO0_ILIM_INT		BIT(0)
>> +
>> +#define LP873X_TOP_STAT_PGOOD_STAT		BIT(7)
>> +#define LP873X_TOP_STAT_SYNC_CLK_STAT		BIT(4)
>> +#define LP873X_TOP_STAT_TDIE_SD_STAT		BIT(3)
>> +#define LP873X_TOP_STAT_TDIE_WARN_STAT		BIT(2)
>> +#define LP873X_TOP_STAT_OVP_STAT		BIT(1)
>> +
>> +#define LP873X_BUCK_STAT_BUCK1_STAT		BIT(7)
>> +#define LP873X_BUCK_STAT_BUCK1_PG_STAT		BIT(6)
>> +#define LP873X_BUCK_STAT_BUCK1_ILIM_STAT	BIT(4)
>> +#define LP873X_BUCK_STAT_BUCK0_STAT		BIT(3)
>> +#define LP873X_BUCK_STAT_BUCK0_PG_STAT		BIT(2)
>> +#define LP873X_BUCK_STAT_BUCK0_ILIM_STAT	BIT(0)
>> +
>> +#define LP873X_LDO_STAT_LDO1_STAT		BIT(7)
>> +#define LP873X_LDO_STAT_LDO1_PG_STAT		BIT(6)
>> +#define LP873X_LDO_STAT_LDO1_ILIM_STAT		BIT(4)
>> +#define LP873X_LDO_STAT_LDO0_STAT		BIT(3)
>> +#define LP873X_LDO_STAT_LDO0_PG_STAT		BIT(2)
>> +#define LP873X_LDO_STAT_LDO0_ILIM_STAT		BIT(0)
>> +
>> +#define LP873X_TOP_MASK_1_PGOOD_INT_MASK	BIT(7)
>> +#define LP873X_TOP_MASK_1_SYNC_CLK_MASK	BIT(4)
>> +#define LP873X_TOP_MASK_1_TDIE_WARN_MASK	BIT(2)
>> +#define LP873X_TOP_MASK_1_I_MEAS_MASK		BIT(0)
>> +
>> +#define LP873X_TOP_MASK_2_RESET_REG_MASK	BIT(0)
>> +
>> +#define LP873X_BUCK_MASK_BUCK1_PGF_MASK	BIT(7)
>> +#define LP873X_BUCK_MASK_BUCK1_PGR_MASK	BIT(6)
>> +#define LP873X_BUCK_MASK_BUCK1_ILIM_MASK	BIT(4)
>> +#define LP873X_BUCK_MASK_BUCK0_PGF_MASK	BIT(3)
>> +#define LP873X_BUCK_MASK_BUCK0_PGR_MASK	BIT(2)
>> +#define LP873X_BUCK_MASK_BUCK0_ILIM_MASK	BIT(0)
>> +
>> +#define LP873X_LDO_MASK_LDO1_PGF_MASK		BIT(7)
>> +#define LP873X_LDO_MASK_LDO1_PGR_MASK		BIT(6)
>> +#define LP873X_LDO_MASK_LDO1_ILIM_MASK		BIT(4)
>> +#define LP873X_LDO_MASK_LDO0_PGF_MASK		BIT(3)
>> +#define LP873X_LDO_MASK_LDO0_PGR_MASK		BIT(2)
>> +#define LP873X_LDO_MASK_LDO0_ILIM_MASK		BIT(0)
>> +
>> +#define LP873X_SEL_I_LOAD_CURRENT_BUCK_SELECT	BIT(0)
>> +
>> +#define LP873X_I_LOAD_2_BUCK_LOAD_CURRENT	BIT(0)
>> +
>> +#define LP873X_I_LOAD_1_BUCK_LOAD_CURRENT	0xFF
>> +
>> +#define LP873X_MAX_REG_ID		LP873X_LDO_1
>> +
>> +/* Number of step-down converters available */
>> +#define LP873X_NUM_BUCK		2
>> +/* Number of LDO voltage regulators available */
>> +#define LP873X_NUM_LDO		2
>> +/* Number of total regulators available */
>> +#define LP873X_NUM_REGULATOR		(LP873X_NUM_BUCK + LP873X_NUM_LDO)
>> +
>> +enum lp873x_regulator_id {
>> +	/* BUCK's */
>> +	LP873X_BUCK_0,
>> +	LP873X_BUCK_1,
>> +	/* LDOs */
>> +	LP873X_LDO_0,
>> +	LP873X_LDO_1,
>> +};
>> +
>> +/**
>> + * struct lp873x - state holder for the lp873x driver
>> + * Device data may be used to access the LP873X chip
>> + */
>> +struct lp873x {
>> +	struct device *dev;
>> +	u8 rev;
>> +	struct mutex lock;	/* lock guarding the data structure */
>> +	struct regmap *regmap;
>> +};
>> +#endif /*  __LINUX_MFD_LP873X_H */
>

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v6 2/4] mfd: lp873x: Add lp873x PMIC support
  2016-08-10  2:57     ` Keerthy
@ 2016-08-10  8:18       ` Lee Jones
  0 siblings, 0 replies; 15+ messages in thread
From: Lee Jones @ 2016-08-10  8:18 UTC (permalink / raw)
  To: Keerthy
  Cc: Keerthy, broonie, tony, linus.walleij, gnurou, linux-omap,
	linux-kernel, devicetree, linux-gpio, robh+dt

On Wed, 10 Aug 2016, Keerthy wrote:

> 
> 
> On Tuesday 09 August 2016 06:23 PM, Lee Jones wrote:
> > On Mon, 08 Aug 2016, Keerthy wrote:
> > 
> > > The LP873X chip is a power management IC for Portable Navigation Systems
> > >      and Tablet Computing devices. It contains the following components:
> > > 
> > >       - Regulators.
> > >       - Configurable General Purpose Output Signals(GPO).
> > > 
> > > PMIC interacts with the main processor through i2c. PMIC has
> > > couple of LDOs(Linear Regulators), couple of BUCKs (Step-Down DC-DC
> > > Converter Cores) and GPOs(General Purpose Output Signals).
> > > 
> > > Signed-off-by: Keerthy <j-keerthy@ti.com>
> > > ---
> > > Changes in v6:
> > > 
> > >    * Rebased on top of http://www.gossamer-threads.com/lists/linux/kernel/2457552.
> > >    * Hence added probe_new instead of probe and removed unused i2c_device_id.
> > 
> > No, please don't do that.  This patch-set is blocked.
> > 
> > Please rebase on top of a mainline release and re-send.
> > 
> > We still need the I2C table, for now.
> 
> Okay. Guess i did some testing for that series then :-P.
> I will revert only that and send patch[es [2-4].

I'm happy for you to reply with your Tested-by:

> > > Changes in v4:
> > > 
> > >    * Added Author.
> > >    * Added the mfd_cell for gpio.
> > > 
> > > Changes in v3:
> > > 
> > >    * Reordered the probe code.
> > >    * Fixed Typo in Kconfig description.
> > >    * Removed unused member from struct lp873x.
> > > 
> > >   drivers/mfd/Kconfig        |  14 +++
> > >   drivers/mfd/Makefile       |   2 +
> > >   drivers/mfd/lp873x.c       |  89 +++++++++++++++
> > >   include/linux/mfd/lp873x.h | 264 +++++++++++++++++++++++++++++++++++++++++++++
> > >   4 files changed, 369 insertions(+)
> > >   create mode 100644 drivers/mfd/lp873x.c
> > >   create mode 100644 include/linux/mfd/lp873x.h
> > > 
> > > diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
> > > index 2d1fb64..45fe00a 100644
> > > --- a/drivers/mfd/Kconfig
> > > +++ b/drivers/mfd/Kconfig
> > > @@ -1224,6 +1224,20 @@ config MFD_TPS65217
> > >   	  This driver can also be built as a module.  If so, the module
> > >   	  will be called tps65217.
> > > 
> > > +config MFD_TI_LP873X
> > > +	tristate "TI LP873X Power Management IC"
> > > +	depends on I2C
> > > +	select MFD_CORE
> > > +	select REGMAP_I2C
> > > +	help
> > > +	  If you say yes here then you get support for the LP873X series of
> > > +	  Power Management Integrated Circuits(PMIC).
> > > +	  These include voltage regulators, Thermal protection, Configurable
> > > +	  General Purpose Outputs(GPO) that are used in portable devices.
> > > +
> > > +	  This driver can also be built as a module. If so, the module
> > > +	  will be called lp873x.
> > > +
> > >   config MFD_TPS65218
> > >   	tristate "TI TPS65218 Power Management chips"
> > >   	depends on I2C
> > > diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
> > > index 2ba3ba3..42acbcd 100644
> > > --- a/drivers/mfd/Makefile
> > > +++ b/drivers/mfd/Makefile
> > > @@ -22,6 +22,8 @@ obj-$(CONFIG_HTC_EGPIO)		+= htc-egpio.o
> > >   obj-$(CONFIG_HTC_PASIC3)	+= htc-pasic3.o
> > >   obj-$(CONFIG_HTC_I2CPLD)	+= htc-i2cpld.o
> > > 
> > > +obj-$(CONFIG_MFD_TI_LP873X)	+= lp873x.o
> > > +
> > >   obj-$(CONFIG_MFD_DAVINCI_VOICECODEC)	+= davinci_voicecodec.o
> > >   obj-$(CONFIG_MFD_DM355EVM_MSP)	+= dm355evm_msp.o
> > >   obj-$(CONFIG_MFD_TI_AM335X_TSCADC)	+= ti_am335x_tscadc.o
> > > diff --git a/drivers/mfd/lp873x.c b/drivers/mfd/lp873x.c
> > > new file mode 100644
> > > index 0000000..3c8e8d0
> > > --- /dev/null
> > > +++ b/drivers/mfd/lp873x.c
> > > @@ -0,0 +1,89 @@
> > > +/*
> > > + * Copyright (C) 2016 Texas Instruments Incorporated - http://www.ti.com/
> > > + *
> > > + * Author: Keerthy <j-keerthy@ti.com>
> > > + *
> > > + * 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 version 2.
> > > + *
> > > + * This program is distributed "as is" WITHOUT ANY WARRANTY of any
> > > + * kind, whether express or implied; without even the implied warranty
> > > + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> > > + * GNU General Public License for more details.
> > > + */
> > > +
> > > +#include <linux/interrupt.h>
> > > +#include <linux/mfd/core.h>
> > > +#include <linux/module.h>
> > > +#include <linux/of_device.h>
> > > +#include <linux/regmap.h>
> > > +
> > > +#include <linux/mfd/lp873x.h>
> > > +
> > > +static const struct regmap_config lp873x_regmap_config = {
> > > +	.reg_bits = 8,
> > > +	.val_bits = 8,
> > > +	.max_register = LP873X_REG_MAX,
> > > +};
> > > +
> > > +static const struct mfd_cell lp873x_cells[] = {
> > > +	{ .name = "lp873x-regulator", },
> > > +	{ .name = "lp873x-gpio", },
> > > +};
> > > +
> > > +static int lp873x_probe(struct i2c_client *client)
> > > +{
> > > +	struct lp873x *lp873;
> > > +	int ret;
> > > +	unsigned int otpid;
> > > +
> > > +	lp873 = devm_kzalloc(&client->dev, sizeof(*lp873), GFP_KERNEL);
> > > +	if (!lp873)
> > > +		return -ENOMEM;
> > > +
> > > +	lp873->dev = &client->dev;
> > > +
> > > +	lp873->regmap = devm_regmap_init_i2c(client, &lp873x_regmap_config);
> > > +	if (IS_ERR(lp873->regmap)) {
> > > +		ret = PTR_ERR(lp873->regmap);
> > > +		dev_err(lp873->dev,
> > > +			"Failed to initialize register map: %d\n", ret);
> > > +		return ret;
> > > +	}
> > > +
> > > +	mutex_init(&lp873->lock);
> > > +
> > > +	ret = regmap_read(lp873->regmap, LP873X_REG_OTP_REV, &otpid);
> > > +	if (ret) {
> > > +		dev_err(lp873->dev, "Failed to read OTP ID\n");
> > > +		return ret;
> > > +	}
> > > +
> > > +	lp873->rev = otpid & LP873X_OTP_REV_OTP_ID;
> > > +	i2c_set_clientdata(client, lp873);
> > > +	ret = mfd_add_devices(lp873->dev, PLATFORM_DEVID_AUTO, lp873x_cells,
> > > +			      ARRAY_SIZE(lp873x_cells), NULL, 0, NULL);
> > > +
> > > +	return ret;
> > > +}
> > > +
> > > +static const struct of_device_id of_lp873x_match_table[] = {
> > > +	{ .compatible = "ti,lp8733", },
> > > +	{ .compatible = "ti,lp8732", },
> > > +	{}
> > > +};
> > > +MODULE_DEVICE_TABLE(of, of_lp873x_match_table);
> > > +
> > > +static struct i2c_driver lp873x_driver = {
> > > +	.driver		= {
> > > +		.name	= "lp873x",
> > > +		.of_match_table = of_lp873x_match_table,
> > > +	},
> > > +	.probe_new		= lp873x_probe,
> > > +};
> > > +module_i2c_driver(lp873x_driver);
> > > +
> > > +MODULE_AUTHOR("J Keerthy <j-keerthy@ti.com>");
> > > +MODULE_DESCRIPTION("LP873X chip family multi-function driver");
> > > +MODULE_LICENSE("GPL v2");
> > > diff --git a/include/linux/mfd/lp873x.h b/include/linux/mfd/lp873x.h
> > > new file mode 100644
> > > index 0000000..42bebfa
> > > --- /dev/null
> > > +++ b/include/linux/mfd/lp873x.h
> > > @@ -0,0 +1,264 @@
> > > +/*
> > > + * Functions to access LP873X power management chip.
> > > + *
> > > + * Copyright (C) 2016 Texas Instruments Incorporated - http://www.ti.com/
> > > + *
> > > + * 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 version 2.
> > > + *
> > > + * This program is distributed "as is" WITHOUT ANY WARRANTY of any
> > > + * kind, whether express or implied; without even the implied warranty
> > > + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> > > + * GNU General Public License for more details.
> > > + */
> > > +
> > > +#ifndef __LINUX_MFD_LP873X_H
> > > +#define __LINUX_MFD_LP873X_H
> > > +
> > > +#include <linux/i2c.h>
> > > +#include <linux/regulator/driver.h>
> > > +#include <linux/regulator/machine.h>
> > > +
> > > +/* LP873x chip id list */
> > > +#define LP873X			0x00
> > > +
> > > +/* All register addresses */
> > > +#define LP873X_REG_DEV_REV		0X00
> > > +#define LP873X_REG_OTP_REV		0X01
> > > +#define LP873X_REG_BUCK0_CTRL_1		0X02
> > > +#define LP873X_REG_BUCK0_CTRL_2		0X03
> > > +#define LP873X_REG_BUCK1_CTRL_1		0X04
> > > +#define LP873X_REG_BUCK1_CTRL_2		0X05
> > > +#define LP873X_REG_BUCK0_VOUT		0X06
> > > +#define LP873X_REG_BUCK1_VOUT		0X07
> > > +#define LP873X_REG_LDO0_CTRL		0X08
> > > +#define LP873X_REG_LDO1_CTRL            0X09
> > > +#define LP873X_REG_LDO0_VOUT		0X0A
> > > +#define LP873X_REG_LDO1_VOUT		0X0B
> > > +#define LP873X_REG_BUCK0_DELAY		0X0C
> > > +#define LP873X_REG_BUCK1_DELAY		0X0D
> > > +#define LP873X_REG_LDO0_DELAY		0X0E
> > > +#define LP873X_REG_LDO1_DELAY		0X0F
> > > +#define LP873X_REG_GPO_DELAY		0X10
> > > +#define LP873X_REG_GPO2_DELAY		0X11
> > > +#define LP873X_REG_GPO_CTRL		0X12
> > > +#define LP873X_REG_CONFIG		0X13
> > > +#define LP873X_REG_PLL_CTRL		0X14
> > > +#define LP873X_REG_PGOOD_CTRL1		0X15
> > > +#define LP873X_REG_PGOOD_CTRL2		0X16
> > > +#define LP873X_REG_PG_FAULT		0X17
> > > +#define LP873X_REG_RESET		0X18
> > > +#define LP873X_REG_INT_TOP_1		0X19
> > > +#define LP873X_REG_INT_TOP_2		0X1A
> > > +#define LP873X_REG_INT_BUCK		0X1B
> > > +#define LP873X_REG_INT_LDO		0X1C
> > > +#define LP873X_REG_TOP_STAT		0X1D
> > > +#define LP873X_REG_BUCK_STAT		0X1E
> > > +#define LP873X_REG_LDO_STAT		0x1F
> > > +#define LP873X_REG_TOP_MASK_1		0x20
> > > +#define LP873X_REG_TOP_MASK_2		0x21
> > > +#define LP873X_REG_BUCK_MASK		0x22
> > > +#define LP873X_REG_LDO_MASK		0x23
> > > +#define LP873X_REG_SEL_I_LOAD		0x24
> > > +#define LP873X_REG_I_LOAD_2		0x25
> > > +#define LP873X_REG_I_LOAD_1		0x26
> > > +
> > > +#define LP873X_REG_MAX			LP873X_REG_I_LOAD_1
> > > +
> > > +/* Register field definitions */
> > > +#define LP873X_DEV_REV_DEV_ID			0xC0
> > > +#define LP873X_DEV_REV_ALL_LAYER		0x30
> > > +#define LP873X_DEV_REV_METAL_LAYER		0x0F
> > > +
> > > +#define LP873X_OTP_REV_OTP_ID			0xFF
> > > +
> > > +#define LP873X_BUCK0_CTRL_1_BUCK0_FPWM		BIT(3)
> > > +#define LP873X_BUCK0_CTRL_1_BUCK0_RDIS_EN	BIT(2)
> > > +#define LP873X_BUCK0_CTRL_1_BUCK0_EN_PIN_CTRL	BIT(1)
> > > +#define LP873X_BUCK0_CTRL_1_BUCK0_EN		BIT(0)
> > > +
> > > +#define LP873X_BUCK0_CTRL_2_BUCK0_ILIM		0x38
> > > +#define LP873X_BUCK0_CTRL_2_BUCK0_SLEW_RATE	0x07
> > > +
> > > +#define LP873X_BUCK1_CTRL_1_BUCK1_FPWM		BIT(3)
> > > +#define LP873X_BUCK1_CTRL_1_BUCK1_RDIS_EN	BIT(2)
> > > +#define LP873X_BUCK1_CTRL_1_BUCK1_EN_PIN_CTRL	BIT(1)
> > > +#define LP873X_BUCK1_CTRL_1_BUCK1_EN		BIT(0)
> > > +
> > > +#define LP873X_BUCK1_CTRL_2_BUCK1_ILIM		0x38
> > > +#define LP873X_BUCK1_CTRL_2_BUCK1_SLEW_RATE	0x07
> > > +
> > > +#define LP873X_BUCK0_VOUT_BUCK0_VSET		0xFF
> > > +
> > > +#define LP873X_BUCK1_VOUT_BUCK1_VSET		0xFF
> > > +
> > > +#define LP873X_LDO0_CTRL_LDO0_RDIS_EN		BIT(2)
> > > +#define LP873X_LDO0_CTRL_LDO0_EN_PIN_CTRL	BIT(1)
> > > +#define LP873X_LDO0_CTRL_LDO0_EN		BIT(0)
> > > +
> > > +#define LP873X_LDO1_CTRL_LDO1_RDIS_EN		BIT(2)
> > > +#define LP873X_LDO1_CTRL_LDO1_EN_PIN_CTRL	BIT(1)
> > > +#define LP873X_LDO1_CTRL_LDO1_EN		BIT(0)
> > > +
> > > +#define LP873X_LDO0_VOUT_LDO0_VSET		0x1F
> > > +
> > > +#define LP873X_LDO1_VOUT_LDO1_VSET		0x1F
> > > +
> > > +#define LP873X_BUCK0_DELAY_BUCK0_SD_DELAY	0xF0
> > > +#define LP873X_BUCK0_DELAY_BUCK0_SU_DELAY	0x0F
> > > +
> > > +#define LP873X_BUCK1_DELAY_BUCK1_SD_DELAY	0xF0
> > > +#define LP873X_BUCK1_DELAY_BUCK1_SU_DELAY	0x0F
> > > +
> > > +#define LP873X_LDO0_DELAY_LDO0_SD_DELAY	0xF0
> > > +#define LP873X_LDO0_DELAY_LDO0_SU_DELAY	0x0F
> > > +
> > > +#define LP873X_LDO1_DELAY_LDO1_SD_DELAY	0xF0
> > > +#define LP873X_LDO1_DELAY_LDO1_SU_DELAY	0x0F
> > > +
> > > +#define LP873X_GPO_DELAY_GPO_SD_DELAY		0xF0
> > > +#define LP873X_GPO_DELAY_GPO_SU_DELAY		0x0F
> > > +
> > > +#define LP873X_GPO2_DELAY_GPO2_SD_DELAY	0xF0
> > > +#define LP873X_GPO2_DELAY_GPO2_SU_DELAY	0x0F
> > > +
> > > +#define LP873X_GPO_CTRL_GPO2_OD		BIT(6)
> > > +#define LP873X_GPO_CTRL_GPO2_EN_PIN_CTRL	BIT(5)
> > > +#define LP873X_GPO_CTRL_GPO2_EN		BIT(4)
> > > +#define LP873X_GPO_CTRL_GPO_OD			BIT(2)
> > > +#define LP873X_GPO_CTRL_GPO_EN_PIN_CTRL	BIT(1)
> > > +#define LP873X_GPO_CTRL_GPO_EN			BIT(0)
> > > +
> > > +#define LP873X_CONFIG_SU_DELAY_SEL		BIT(6)
> > > +#define LP873X_CONFIG_SD_DELAY_SEL		BIT(5)
> > > +#define LP873X_CONFIG_CLKIN_PIN_SEL		BIT(4)
> > > +#define LP873X_CONFIG_CLKIN_PD			BIT(3)
> > > +#define LP873X_CONFIG_EN_PD			BIT(2)
> > > +#define LP873X_CONFIG_TDIE_WARN_LEVEL		BIT(1)
> > > +#define LP873X_EN_SPREAD_SPEC			BIT(0)
> > > +
> > > +#define LP873X_PLL_CTRL_EN_PLL			BIT(6)
> > > +#define LP873X_EXT_CLK_FREQ			0x1F
> > > +
> > > +#define LP873X_PGOOD_CTRL1_PGOOD_POL		BIT(7)
> > > +#define LP873X_PGOOD_CTRL1_PGOOD_OD		BIT(6)
> > > +#define LP873X_PGOOD_CTRL1_PGOOD_WINDOW_LDO	BIT(5)
> > > +#define LP873X_PGOOD_CTRL1_PGOOD_WINDOWN_BUCK	BIT(4)
> > > +#define LP873X_PGOOD_CTRL1_PGOOD_EN_PGOOD_LDO1	BIT(3)
> > > +#define LP873X_PGOOD_CTRL1_PGOOD_EN_PGOOD_LDO0	BIT(2)
> > > +#define LP873X_PGOOD_CTRL1_PGOOD_EN_PGOOD_BUCK1	BIT(1)
> > > +#define LP873X_PGOOD_CTRL1_PGOOD_EN_PGOOD_BUCK0	BIT(0)
> > > +
> > > +#define LP873X_PGOOD_CTRL2_EN_PGOOD_TWARN	BIT(2)
> > > +#define LP873X_PGOOD_CTRL2_EN_PG_FAULT_GATE	BIT(1)
> > > +#define LP873X_PGOOD_CTRL2_PGOOD_MODE		BIT(0)
> > > +
> > > +#define LP873X_PG_FAULT_PG_FAULT_LDO1		BIT(3)
> > > +#define LP873X_PG_FAULT_PG_FAULT_LDO0		BIT(2)
> > > +#define LP873X_PG_FAULT_PG_FAULT_BUCK1		BIT(1)
> > > +#define LP873X_PG_FAULT_PG_FAULT_BUCK0		BIT(0)
> > > +
> > > +#define LP873X_RESET_SW_RESET			BIT(0)
> > > +
> > > +#define LP873X_INT_TOP_1_PGOOD_INT		BIT(7)
> > > +#define LP873X_INT_TOP_1_LDO_INT		BIT(6)
> > > +#define LP873X_INT_TOP_1_BUCK_INT		BIT(5)
> > > +#define LP873X_INT_TOP_1_SYNC_CLK_INT		BIT(4)
> > > +#define LP873X_INT_TOP_1_TDIE_SD_INT		BIT(3)
> > > +#define LP873X_INT_TOP_1_TDIE_WARN_INT		BIT(2)
> > > +#define LP873X_INT_TOP_1_OVP_INT		BIT(1)
> > > +#define LP873X_INT_TOP_1_I_MEAS_INT		BIT(0)
> > > +
> > > +#define LP873X_INT_TOP_2_RESET_REG_INT		BIT(0)
> > > +
> > > +#define LP873X_INT_BUCK_BUCK1_PG_INT		BIT(6)
> > > +#define LP873X_INT_BUCK_BUCK1_SC_INT		BIT(5)
> > > +#define LP873X_INT_BUCK_BUCK1_ILIM_INT		BIT(4)
> > > +#define LP873X_INT_BUCK_BUCK0_PG_INT		BIT(2)
> > > +#define LP873X_INT_BUCK_BUCK0_SC_INT		BIT(1)
> > > +#define LP873X_INT_BUCK_BUCK0_ILIM_INT		BIT(0)
> > > +
> > > +#define LP873X_INT_LDO_LDO1_PG_INT		BIT(6)
> > > +#define LP873X_INT_LDO_LDO1_SC_INT		BIT(5)
> > > +#define LP873X_INT_LDO_LDO1_ILIM_INT		BIT(4)
> > > +#define LP873X_INT_LDO_LDO0_PG_INT		BIT(2)
> > > +#define LP873X_INT_LDO_LDO0_SC_INT		BIT(1)
> > > +#define LP873X_INT_LDO_LDO0_ILIM_INT		BIT(0)
> > > +
> > > +#define LP873X_TOP_STAT_PGOOD_STAT		BIT(7)
> > > +#define LP873X_TOP_STAT_SYNC_CLK_STAT		BIT(4)
> > > +#define LP873X_TOP_STAT_TDIE_SD_STAT		BIT(3)
> > > +#define LP873X_TOP_STAT_TDIE_WARN_STAT		BIT(2)
> > > +#define LP873X_TOP_STAT_OVP_STAT		BIT(1)
> > > +
> > > +#define LP873X_BUCK_STAT_BUCK1_STAT		BIT(7)
> > > +#define LP873X_BUCK_STAT_BUCK1_PG_STAT		BIT(6)
> > > +#define LP873X_BUCK_STAT_BUCK1_ILIM_STAT	BIT(4)
> > > +#define LP873X_BUCK_STAT_BUCK0_STAT		BIT(3)
> > > +#define LP873X_BUCK_STAT_BUCK0_PG_STAT		BIT(2)
> > > +#define LP873X_BUCK_STAT_BUCK0_ILIM_STAT	BIT(0)
> > > +
> > > +#define LP873X_LDO_STAT_LDO1_STAT		BIT(7)
> > > +#define LP873X_LDO_STAT_LDO1_PG_STAT		BIT(6)
> > > +#define LP873X_LDO_STAT_LDO1_ILIM_STAT		BIT(4)
> > > +#define LP873X_LDO_STAT_LDO0_STAT		BIT(3)
> > > +#define LP873X_LDO_STAT_LDO0_PG_STAT		BIT(2)
> > > +#define LP873X_LDO_STAT_LDO0_ILIM_STAT		BIT(0)
> > > +
> > > +#define LP873X_TOP_MASK_1_PGOOD_INT_MASK	BIT(7)
> > > +#define LP873X_TOP_MASK_1_SYNC_CLK_MASK	BIT(4)
> > > +#define LP873X_TOP_MASK_1_TDIE_WARN_MASK	BIT(2)
> > > +#define LP873X_TOP_MASK_1_I_MEAS_MASK		BIT(0)
> > > +
> > > +#define LP873X_TOP_MASK_2_RESET_REG_MASK	BIT(0)
> > > +
> > > +#define LP873X_BUCK_MASK_BUCK1_PGF_MASK	BIT(7)
> > > +#define LP873X_BUCK_MASK_BUCK1_PGR_MASK	BIT(6)
> > > +#define LP873X_BUCK_MASK_BUCK1_ILIM_MASK	BIT(4)
> > > +#define LP873X_BUCK_MASK_BUCK0_PGF_MASK	BIT(3)
> > > +#define LP873X_BUCK_MASK_BUCK0_PGR_MASK	BIT(2)
> > > +#define LP873X_BUCK_MASK_BUCK0_ILIM_MASK	BIT(0)
> > > +
> > > +#define LP873X_LDO_MASK_LDO1_PGF_MASK		BIT(7)
> > > +#define LP873X_LDO_MASK_LDO1_PGR_MASK		BIT(6)
> > > +#define LP873X_LDO_MASK_LDO1_ILIM_MASK		BIT(4)
> > > +#define LP873X_LDO_MASK_LDO0_PGF_MASK		BIT(3)
> > > +#define LP873X_LDO_MASK_LDO0_PGR_MASK		BIT(2)
> > > +#define LP873X_LDO_MASK_LDO0_ILIM_MASK		BIT(0)
> > > +
> > > +#define LP873X_SEL_I_LOAD_CURRENT_BUCK_SELECT	BIT(0)
> > > +
> > > +#define LP873X_I_LOAD_2_BUCK_LOAD_CURRENT	BIT(0)
> > > +
> > > +#define LP873X_I_LOAD_1_BUCK_LOAD_CURRENT	0xFF
> > > +
> > > +#define LP873X_MAX_REG_ID		LP873X_LDO_1
> > > +
> > > +/* Number of step-down converters available */
> > > +#define LP873X_NUM_BUCK		2
> > > +/* Number of LDO voltage regulators available */
> > > +#define LP873X_NUM_LDO		2
> > > +/* Number of total regulators available */
> > > +#define LP873X_NUM_REGULATOR		(LP873X_NUM_BUCK + LP873X_NUM_LDO)
> > > +
> > > +enum lp873x_regulator_id {
> > > +	/* BUCK's */
> > > +	LP873X_BUCK_0,
> > > +	LP873X_BUCK_1,
> > > +	/* LDOs */
> > > +	LP873X_LDO_0,
> > > +	LP873X_LDO_1,
> > > +};
> > > +
> > > +/**
> > > + * struct lp873x - state holder for the lp873x driver
> > > + * Device data may be used to access the LP873X chip
> > > + */
> > > +struct lp873x {
> > > +	struct device *dev;
> > > +	u8 rev;
> > > +	struct mutex lock;	/* lock guarding the data structure */
> > > +	struct regmap *regmap;
> > > +};
> > > +#endif /*  __LINUX_MFD_LP873X_H */
> > 

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v6 3/4] gpio: lp873x: Add support for General Purpose Outputs
  2016-08-08  5:46 ` [PATCH v6 3/4] gpio: lp873x: Add support for General Purpose Outputs Keerthy
@ 2016-08-11 13:30   ` Linus Walleij
  0 siblings, 0 replies; 15+ messages in thread
From: Linus Walleij @ 2016-08-11 13:30 UTC (permalink / raw)
  To: Keerthy
  Cc: Mark Brown, Lee Jones, Tony Lindgren, Alexandre Courbot,
	Linux-OMAP, linux-kernel, devicetree, linux-gpio, Rob Herring

On Mon, Aug 8, 2016 at 7:46 AM, Keerthy <j-keerthy@ti.com> wrote:

> Add driver for lp873x PMIC family GPOs. Two GPOs are supported
> and can be configured in Open-drain output or Push-pull output.
>
> Acked-by: Linus Walleij <linus.walleij@linaro.org>
> Signed-off-by: Keerthy <j-keerthy@ti.com>

Still looks pretty nice, just thought of some things if
you're anyway working on the code:

> +       return regmap_update_bits(gpio->lp873->regmap, LP873X_REG_GPO_CTRL,
> +                                 BIT(offset * 4), value ? BIT(offset * 4) : 0);
(...)
(...)
> +       return val & BIT(offset * 4);
(...)
> +       regmap_update_bits(gpio->lp873->regmap, LP873X_REG_GPO_CTRL,
> +                          BIT(offset * 4), value ? BIT(offset * 4) : 0);
(...)
> +               return regmap_update_bits(gpio->lp873->regmap,
> +                                         LP873X_REG_GPO_CTRL,
> +                                         BIT(offset * 4 + 2),
> +                                         BIT(offset * 4 + 2));
> +       case LINE_MODE_PUSH_PULL:
> +               return regmap_update_bits(gpio->lp873->regmap,
> +                                         LP873X_REG_GPO_CTRL,
> +                                         BIT(offset * 4 + 2), 0);

This 4 +2 etc business is a bit hard to understand, could you create
a macro with a clever name that makes it more understandable?

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v6 4/4] regulator: lp873x: Change the MFD config option as per latest naming
  2016-08-08  5:46 ` [PATCH v6 4/4] regulator: lp873x: Change the MFD config option as per latest naming Keerthy
@ 2016-08-12 10:57   ` Mark Brown
  0 siblings, 0 replies; 15+ messages in thread
From: Mark Brown @ 2016-08-12 10:57 UTC (permalink / raw)
  To: Keerthy
  Cc: lee.jones, tony, linus.walleij, gnurou, linux-omap, linux-kernel,
	devicetree, linux-gpio, robh+dt

[-- Attachment #1: Type: text/plain, Size: 152 bytes --]

On Mon, Aug 08, 2016 at 11:16:58AM +0530, Keerthy wrote:
> Change the MFD config option as per latest naming

Acked-by: Mark Brown <broonie@kernel.org>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2016-08-12 10:58 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-08  5:46 [PATCH v6 0/4] mfd: lp873x: Add lp873x PMIC support Keerthy
2016-08-08  5:46 ` [PATCH v6 1/4] Documentation: mfd: LP873X: Add information for the mfd driver Keerthy
2016-08-09 12:50   ` Lee Jones
2016-08-10  2:56     ` Keerthy
2016-08-08  5:46 ` [PATCH v6 2/4] mfd: lp873x: Add lp873x PMIC support Keerthy
2016-08-08  6:26   ` kbuild test robot
2016-08-08  6:49     ` Keerthy
2016-08-08  8:41   ` kbuild test robot
2016-08-09 12:53   ` Lee Jones
2016-08-10  2:57     ` Keerthy
2016-08-10  8:18       ` Lee Jones
2016-08-08  5:46 ` [PATCH v6 3/4] gpio: lp873x: Add support for General Purpose Outputs Keerthy
2016-08-11 13:30   ` Linus Walleij
2016-08-08  5:46 ` [PATCH v6 4/4] regulator: lp873x: Change the MFD config option as per latest naming Keerthy
2016-08-12 10:57   ` Mark Brown

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).