Skip to contentSkip to conversation

Add Maxim 77802 PMIC support

PATCH Superseded Javier Martinez Canillas 5 participants 30 messages Jun 16, 2014 – Jun 24, 2014

Subsystems (8)

v2 of 10 Superseded Latest is v10 →

lore
Share & tools
lore
#0 lore raw

v2 cover Add Maxim 77802 PMIC support

MAX77802 is a PMIC that contains 10 high efficiency Buck regulators, 32 Low-dropout (LDO) regulators, two 32kHz buffered clock outputs, a Real-Time-Clock (RTC) and a I2C interface to program the individual regulators, clocks and the RTC.

This second version of the patch-set addresses several issues pointed out by Krzysztof Kozlowski, Mark Brown and Lee Jones. The individual changes are added on each patch change log.

The series are based on drivers added by Simon Glass to the Chrome OS kernel and adds support for the Maxim 77802 Power Management IC, their regulators, clocks, RTC and I2C interface. It's composed of patches:

[PATCH v2 1/10] mfd: max77686: Convert to use regmap_irq
[PATCH v2 2/10] clk: max77686: add DT include for MAX77686 PMIC clock [PATCH v2 3/10] Documentation: dt: improve Maxim 77686 PMIC clocks binding [PATCH v2 4/10] clk: Add generic driver for Maxim PMIC clocks [PATCH v2 5/10] clk: max77686: convert to the generic max clock driver [PATCH v2 6/10] mfd: Add driver for Maxim 77802 Power Management IC [PATCH v2 7/10] regulator: Add driver for Maxim 77802 PMIC regulators [PATCH v2 8/10] clk: Add driver for Maxim 77802 PMIC clocks [PATCH v2 9/10] rtc: Add driver for Maxim 77802 PMIC Real-Time-Clock [PATCH v2 10/10] ARM: dts: Add max77802 device node for exynos5420-peach-pit

Patches 1-3 are improvements to the max77686 driver, Patch 4 adds a generic clock driver that can be shared by both max77686 and max77802 clock drivers and Patch 5 converts the former.

Patches 6-9 add support for the different 77802 devices and Patch 10 enables the MAX77802 PMIC on the Exynos5420 based Peach pit board.

The patch-set has been tested on both Daisy/Snow (max77686) and Peach pit (max77802) Chromebooks.

NOTE: Since this series convert the max77686 driver to use regmap_irq API (getting rid of drivers/mfd/max77686-irq.c) and refactor the clock driver, the amount of duplicated code between 77686 and 77802 drivers were reduced significantly since v1. Still there is room for more code consolidation if the max77686 core mfd driver is extended to support max77802 instead.

drivers/mfd/max14577.c is an example of such a combined driver that support two different Maxim PMIC (14577 and 77836) but I'm not convinced that having a single driver to support both 77686 and 77802 lead to a cleaner and more maintainable code than having two separate (and now smaller) mfd core drivers.

Thanks a lot and best regards,
Javier

#1 lore raw

PATCH v2 1/10 mfd: max77686: Convert to use regmap_irq

By using the generic IRQ support in the Register map API, it is possible to get rid of max77686-irq.c and simplify the code.

---
 drivers/mfd/Kconfig                  |   1 +
 drivers/mfd/Makefile                 |   2 +-
 drivers/mfd/max77686-irq.c           | 319 -----------------------------------
 drivers/mfd/max77686.c               |  93 +++++++++-
 drivers/rtc/rtc-max77686.c           |  27 +--
 include/linux/mfd/max77686-private.h |  26 ++-
 include/linux/mfd/max77686.h         |   2 -
 7 files changed, 119 insertions(+), 351 deletions(-)
 delete mode 100644 drivers/mfd/max77686-irq.c
drivers/mfd/Kconfig +1 -0
index ee8204c..0916447 100644
@@ -371,6 +371,7 @@ config MFD_MAX77686
 	depends on I2C=y
 	select MFD_CORE
 	select REGMAP_I2C
+	select REGMAP_IRQ
 	select IRQ_DOMAIN
 	help
 	  Say yes here to add support for Maxim Semiconductor MAX77686.
drivers/mfd/Makefile +1 -1
index 8afedba..3b3b408 100644
@@ -115,7 +115,7 @@ da9063-objs			:= da9063-core.o da9063-irq.o da9063-i2c.o
 obj-$(CONFIG_MFD_DA9063)	+= da9063.o
 
 obj-$(CONFIG_MFD_MAX14577)	+= max14577.o
-obj-$(CONFIG_MFD_MAX77686)	+= max77686.o max77686-irq.o
+obj-$(CONFIG_MFD_MAX77686)	+= max77686.o
 obj-$(CONFIG_MFD_MAX77693)	+= max77693.o max77693-irq.o
 obj-$(CONFIG_MFD_MAX8907)	+= max8907.o
 max8925-objs			:= max8925-core.o max8925-i2c.o
drivers/mfd/max77686-irq.c deleted +0 -319

319 lines not on this page · raw message

drivers/mfd/max77686.c +87 -6

129 lines not on this page · raw message

drivers/rtc/rtc-max77686.c +8 -19
index 9efe118..d20a7f0 100644
@@ -492,16 +492,11 @@ static int max77686_rtc_init_reg(struct max77686_rtc_info *info)
 	return ret;
 }
 
-static struct regmap_config max77686_rtc_regmap_config = {
-	.reg_bits = 8,
-	.val_bits = 8,
-};
-
 static int max77686_rtc_probe(struct platform_device *pdev)
 {
 	struct max77686_dev *max77686 = dev_get_drvdata(pdev->dev.parent);
 	struct max77686_rtc_info *info;
-	int ret, virq;
+	int ret;
 
 	dev_info(&pdev->dev, "%s\n", __func__);
 
@@ -514,14 +509,7 @@ static int max77686_rtc_probe(struct platform_device *pdev)
 	info->dev = &pdev->dev;
 	info->max77686 = max77686;
 	info->rtc = max77686->rtc;
-	info->max77686->rtc_regmap = devm_regmap_init_i2c(info->max77686->rtc,
-					 &max77686_rtc_regmap_config);
-	if (IS_ERR(info->max77686->rtc_regmap)) {
-		ret = PTR_ERR(info->max77686->rtc_regmap);
-		dev_err(info->max77686->dev, "Failed to allocate register map: %d\n",
-				ret);
-		return ret;
-	}
+
 	platform_set_drvdata(pdev, info);
 
 	ret = max77686_rtc_init_reg(info);
@@ -550,15 +538,16 @@ static int max77686_rtc_probe(struct platform_device *pdev)
 			ret = -EINVAL;
 		goto err_rtc;
 	}
-	virq = irq_create_mapping(max77686->irq_domain, MAX77686_RTCIRQ_RTCA1);
-	if (!virq) {
+
+	info->virq = regmap_irq_get_virq(max77686->rtc_irq_data,
+					 MAX77686_RTCIRQ_RTCA1);
+	if (!info->virq) {
 		ret = -ENXIO;
 		goto err_rtc;
 	}
-	info->virq = virq;
 
-	ret = devm_request_threaded_irq(&pdev->dev, virq, NULL,
-				max77686_rtc_alarm_irq, 0, "rtc-alarm0", info);
+	ret = devm_request_threaded_irq(&pdev->dev, info->virq, NULL,
+				max77686_rtc_alarm_irq, 0, "rtc-alarm1", info);
 	if (ret < 0)
 		dev_err(&pdev->dev, "Failed to request alarm IRQ: %d: %d\n",
 			info->virq, ret);
include/linux/mfd/max77686-private.h +22 -4
index 8c75a9c..3a810b1 100644
@@ -205,7 +205,7 @@ enum max77686_irq {
 	MAX77686_PMICIRQ_140C,
 	MAX77686_PMICIRQ_120C,
 
-	MAX77686_RTCIRQ_RTC60S,
+	MAX77686_RTCIRQ_RTC60S = 0,
 	MAX77686_RTCIRQ_RTCA1,
 	MAX77686_RTCIRQ_RTCA2,
 	MAX77686_RTCIRQ_SMPL,
@@ -215,6 +215,25 @@ enum max77686_irq {
 	MAX77686_IRQ_NR,
 };
 
+#define MAX77686_INT1_PWRONF_MSK	BIT(0)
+#define MAX77686_INT1_PWRONR_MSK	BIT(1)
+#define MAX77686_INT1_JIGONBF_MSK	BIT(2)
+#define MAX77686_INT1_JIGONBR_MSK	BIT(3)
+#define MAX77686_INT1_ACOKBF_MSK	BIT(4)
+#define MAX77686_INT1_ACOKBR_MSK	BIT(5)
+#define MAX77686_INT1_ONKEY1S_MSK	BIT(6)
+#define MAX77686_INT1_MRSTB_MSK		BIT(7)
+
+#define MAX77686_INT2_140C_MSK		BIT(0)
+#define MAX77686_INT2_120C_MSK		BIT(1)
+
+#define MAX77686_RTCINT_RTC60S_MSK	BIT(0)
+#define MAX77686_RTCINT_RTCA1_MSK	BIT(1)
+#define MAX77686_RTCINT_RTCA2_MSK	BIT(2)
+#define MAX77686_RTCINT_SMPL_MSK	BIT(3)
+#define MAX77686_RTCINT_RTC1S_MSK	BIT(4)
+#define MAX77686_RTCINT_WTSR_MSK	BIT(5)
+
 struct max77686_dev {
 	struct device *dev;
 	struct i2c_client *i2c; /* 0xcc / PMIC, Battery Control, and FLASH */
@@ -224,11 +243,10 @@ struct max77686_dev {
 
 	struct regmap *regmap;		/* regmap for mfd */
 	struct regmap *rtc_regmap;	/* regmap for rtc */
-
-	struct irq_domain *irq_domain;
+	struct regmap_irq_chip_data *irq_data;
+	struct regmap_irq_chip_data *rtc_irq_data;
 
 	int irq;
-	int irq_gpio;
 	bool wakeup;
 	struct mutex irqlock;
 	int irq_masks_cur[MAX77686_IRQ_GROUP_NR];
include/linux/mfd/max77686.h +0 -2
index 46c0f32..4cbcc13 100644
@@ -89,8 +89,6 @@ struct max77686_opmode_data {
 };
 
 struct max77686_platform_data {
-	/* IRQ */
-	int irq_gpio;
 	int ono;
 	int wakeup;
 
Signature · 1 line
2.0.0.rc2
Acked-by on v2 1/10
#2 lore raw

Re: [PATCH v2 01/10] mfd: max77686: Convert to use regmap_irq

Quoted 5 lines · Javier Martinez Canillas

By using the generic IRQ support in the Register map API, it is possible to get rid of max77686-irq.c and simplify the code.

Quoted 10 lines
---
 drivers/mfd/Kconfig                  |   1 +
 drivers/mfd/Makefile                 |   2 +-
 drivers/mfd/max77686-irq.c           | 319 -----------------------------------
 drivers/mfd/max77686.c               |  93 +++++++++-
 drivers/rtc/rtc-max77686.c           |  27 +--
 include/linux/mfd/max77686-private.h |  26 ++-
 include/linux/mfd/max77686.h         |   2 -
 7 files changed, 119 insertions(+), 351 deletions(-)
 delete mode 100644 drivers/mfd/max77686-irq.c

Nice patch - great diff.

I assume we have to wait for some of the other patches in the set, but for now:

Quoted 614 lines
drivers/mfd/Kconfig +1 -0
index ee8204c..0916447 100644
@@ -371,6 +371,7 @@ config MFD_MAX77686
 	depends on I2C=y
 	select MFD_CORE
 	select REGMAP_I2C
+	select REGMAP_IRQ
 	select IRQ_DOMAIN
 	help
 	  Say yes here to add support for Maxim Semiconductor MAX77686.
drivers/mfd/Makefile +1 -1
index 8afedba..3b3b408 100644
@@ -115,7 +115,7 @@ da9063-objs			:= da9063-core.o da9063-irq.o da9063-i2c.o
 obj-$(CONFIG_MFD_DA9063)	+= da9063.o
 
 obj-$(CONFIG_MFD_MAX14577)	+= max14577.o
-obj-$(CONFIG_MFD_MAX77686)	+= max77686.o max77686-irq.o
+obj-$(CONFIG_MFD_MAX77686)	+= max77686.o
 obj-$(CONFIG_MFD_MAX77693)	+= max77693.o max77693-irq.o
 obj-$(CONFIG_MFD_MAX8907)	+= max8907.o
 max8925-objs			:= max8925-core.o max8925-i2c.o
drivers/mfd/max77686-irq.c deleted +0 -319
deleted file mode 100644
index cdc3280..0000000
@@ -1,319 +0,0 @@
-/*
- * max77686-irq.c - Interrupt controller support for MAX77686
- *
- * Copyright (C) 2012 Samsung Electronics Co.Ltd
- * Chiwoong Byun <[email protected]>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * This driver is based on max8997-irq.c
- */
-
-#include <linux/err.h>
-#include <linux/irq.h>
-#include <linux/interrupt.h>
-#include <linux/gpio.h>
-#include <linux/mfd/max77686.h>
-#include <linux/mfd/max77686-private.h>
-#include <linux/irqdomain.h>
-#include <linux/regmap.h>
-
-enum {
-	MAX77686_DEBUG_IRQ_INFO = 1 << 0,
-	MAX77686_DEBUG_IRQ_MASK = 1 << 1,
-	MAX77686_DEBUG_IRQ_INT = 1 << 2,
-};
-
-static int debug_mask = 0;
-module_param(debug_mask, int, 0);
-MODULE_PARM_DESC(debug_mask, "Set debug_mask : 0x0=off 0x1=IRQ_INFO  0x2=IRQ_MASK 0x4=IRQ_INI)");
-
-static const u8 max77686_mask_reg[] = {
-	[PMIC_INT1] = MAX77686_REG_INT1MSK,
-	[PMIC_INT2] = MAX77686_REG_INT2MSK,
-	[RTC_INT] = MAX77686_RTC_INTM,
-};
-
-static struct regmap *max77686_get_regmap(struct max77686_dev *max77686,
-				enum max77686_irq_source src)
-{
-	switch (src) {
-	case PMIC_INT1 ... PMIC_INT2:
-		return max77686->regmap;
-	case RTC_INT:
-		return max77686->rtc_regmap;
-	default:
-		return ERR_PTR(-EINVAL);
-	}
-}
-
-struct max77686_irq_data {
-	int mask;
-	enum max77686_irq_source group;
-};
-
-#define DECLARE_IRQ(idx, _group, _mask)		\
-	[(idx)] = { .group = (_group), .mask = (_mask) }
-static const struct max77686_irq_data max77686_irqs[] = {
-	DECLARE_IRQ(MAX77686_PMICIRQ_PWRONF,	PMIC_INT1, 1 << 0),
-	DECLARE_IRQ(MAX77686_PMICIRQ_PWRONR,	PMIC_INT1, 1 << 1),
-	DECLARE_IRQ(MAX77686_PMICIRQ_JIGONBF,	PMIC_INT1, 1 << 2),
-	DECLARE_IRQ(MAX77686_PMICIRQ_JIGONBR,	PMIC_INT1, 1 << 3),
-	DECLARE_IRQ(MAX77686_PMICIRQ_ACOKBF,	PMIC_INT1, 1 << 4),
-	DECLARE_IRQ(MAX77686_PMICIRQ_ACOKBR,	PMIC_INT1, 1 << 5),
-	DECLARE_IRQ(MAX77686_PMICIRQ_ONKEY1S,	PMIC_INT1, 1 << 6),
-	DECLARE_IRQ(MAX77686_PMICIRQ_MRSTB,		PMIC_INT1, 1 << 7),
-	DECLARE_IRQ(MAX77686_PMICIRQ_140C,		PMIC_INT2, 1 << 0),
-	DECLARE_IRQ(MAX77686_PMICIRQ_120C,		PMIC_INT2, 1 << 1),
-	DECLARE_IRQ(MAX77686_RTCIRQ_RTC60S,		RTC_INT, 1 << 0),
-	DECLARE_IRQ(MAX77686_RTCIRQ_RTCA1,		RTC_INT, 1 << 1),
-	DECLARE_IRQ(MAX77686_RTCIRQ_RTCA2,		RTC_INT, 1 << 2),
-	DECLARE_IRQ(MAX77686_RTCIRQ_SMPL,		RTC_INT, 1 << 3),
-	DECLARE_IRQ(MAX77686_RTCIRQ_RTC1S,		RTC_INT, 1 << 4),
-	DECLARE_IRQ(MAX77686_RTCIRQ_WTSR,		RTC_INT, 1 << 5),
-};
-
-static void max77686_irq_lock(struct irq_data *data)
-{
-	struct max77686_dev *max77686 = irq_get_chip_data(data->irq);
-
-	if (debug_mask & MAX77686_DEBUG_IRQ_MASK)
-		pr_info("%s\n", __func__);
-
-	mutex_lock(&max77686->irqlock);
-}
-
-static void max77686_irq_sync_unlock(struct irq_data *data)
-{
-	struct max77686_dev *max77686 = irq_get_chip_data(data->irq);
-	int i;
-
-	for (i = 0; i < MAX77686_IRQ_GROUP_NR; i++) {
-		u8 mask_reg = max77686_mask_reg[i];
-		struct regmap *map = max77686_get_regmap(max77686, i);
-
-		if (debug_mask & MAX77686_DEBUG_IRQ_MASK)
-			pr_debug("%s: mask_reg[%d]=0x%x, cur=0x%x\n",
-			__func__, i, mask_reg, max77686->irq_masks_cur[i]);
-
-		if (mask_reg == MAX77686_REG_INVALID ||
-				IS_ERR_OR_NULL(map))
-			continue;
-
-		max77686->irq_masks_cache[i] = max77686->irq_masks_cur[i];
-
-		regmap_write(map, max77686_mask_reg[i],
-				max77686->irq_masks_cur[i]);
-	}
-
-	mutex_unlock(&max77686->irqlock);
-}
-
-static const inline struct max77686_irq_data *to_max77686_irq(int irq)
-{
-	struct irq_data *data = irq_get_irq_data(irq);
-	return &max77686_irqs[data->hwirq];
-}
-
-static void max77686_irq_mask(struct irq_data *data)
-{
-	struct max77686_dev *max77686 = irq_get_chip_data(data->irq);
-	const struct max77686_irq_data *irq_data = to_max77686_irq(data->irq);
-
-	max77686->irq_masks_cur[irq_data->group] |= irq_data->mask;
-
-	if (debug_mask & MAX77686_DEBUG_IRQ_MASK)
-		pr_info("%s: group=%d, cur=0x%x\n",
-			__func__, irq_data->group,
-			max77686->irq_masks_cur[irq_data->group]);
-}
-
-static void max77686_irq_unmask(struct irq_data *data)
-{
-	struct max77686_dev *max77686 = irq_get_chip_data(data->irq);
-	const struct max77686_irq_data *irq_data = to_max77686_irq(data->irq);
-
-	max77686->irq_masks_cur[irq_data->group] &= ~irq_data->mask;
-
-	if (debug_mask & MAX77686_DEBUG_IRQ_MASK)
-		pr_info("%s: group=%d, cur=0x%x\n",
-			__func__, irq_data->group,
-			max77686->irq_masks_cur[irq_data->group]);
-}
-
-static struct irq_chip max77686_irq_chip = {
-	.name			= "max77686",
-	.irq_bus_lock		= max77686_irq_lock,
-	.irq_bus_sync_unlock	= max77686_irq_sync_unlock,
-	.irq_mask		= max77686_irq_mask,
-	.irq_unmask		= max77686_irq_unmask,
-};
-
-static irqreturn_t max77686_irq_thread(int irq, void *data)
-{
-	struct max77686_dev *max77686 = data;
-	unsigned int irq_reg[MAX77686_IRQ_GROUP_NR] = {};
-	unsigned int irq_src;
-	int ret;
-	int i, cur_irq;
-
-	ret = regmap_read(max77686->regmap,  MAX77686_REG_INTSRC, &irq_src);
-	if (ret < 0) {
-		dev_err(max77686->dev, "Failed to read interrupt source: %d\n",
-				ret);
-		return IRQ_NONE;
-	}
-
-	if (debug_mask & MAX77686_DEBUG_IRQ_INT)
-		pr_info("%s: irq_src=0x%x\n", __func__, irq_src);
-
-	if (irq_src == MAX77686_IRQSRC_PMIC) {
-		ret = regmap_bulk_read(max77686->regmap,
-					 MAX77686_REG_INT1, irq_reg, 2);
-		if (ret < 0) {
-			dev_err(max77686->dev, "Failed to read interrupt source: %d\n",
-					ret);
-			return IRQ_NONE;
-		}
-
-		if (debug_mask & MAX77686_DEBUG_IRQ_INT)
-			pr_info("%s: int1=0x%x, int2=0x%x\n", __func__,
-				 irq_reg[PMIC_INT1], irq_reg[PMIC_INT2]);
-	}
-
-	if (irq_src & MAX77686_IRQSRC_RTC) {
-		ret = regmap_read(max77686->rtc_regmap,
-					MAX77686_RTC_INT, &irq_reg[RTC_INT]);
-		if (ret < 0) {
-			dev_err(max77686->dev, "Failed to read interrupt source: %d\n",
-					ret);
-			return IRQ_NONE;
-		}
-
-		if (debug_mask & MAX77686_DEBUG_IRQ_INT)
-			pr_info("%s: rtc int=0x%x\n", __func__,
-							 irq_reg[RTC_INT]);
-
-	}
-
-	for (i = 0; i < MAX77686_IRQ_GROUP_NR; i++)
-		irq_reg[i] &= ~max77686->irq_masks_cur[i];
-
-	for (i = 0; i < MAX77686_IRQ_NR; i++) {
-		if (irq_reg[max77686_irqs[i].group] & max77686_irqs[i].mask) {
-			cur_irq = irq_find_mapping(max77686->irq_domain, i);
-			if (cur_irq)
-				handle_nested_irq(cur_irq);
-		}
-	}
-
-	return IRQ_HANDLED;
-}
-
-static int max77686_irq_domain_map(struct irq_domain *d, unsigned int irq,
-					irq_hw_number_t hw)
-{
-	struct max77686_dev *max77686 = d->host_data;
-
-	irq_set_chip_data(irq, max77686);
-	irq_set_chip_and_handler(irq, &max77686_irq_chip, handle_edge_irq);
-	irq_set_nested_thread(irq, 1);
-#ifdef CONFIG_ARM
-	set_irq_flags(irq, IRQF_VALID);
-#else
-	irq_set_noprobe(irq);
-#endif
-	return 0;
-}
-
-static struct irq_domain_ops max77686_irq_domain_ops = {
-	.map = max77686_irq_domain_map,
-};
-
-int max77686_irq_init(struct max77686_dev *max77686)
-{
-	struct irq_domain *domain;
-	int i;
-	int ret;
-	int val;
-	struct regmap *map;
-
-	mutex_init(&max77686->irqlock);
-
-	if (max77686->irq_gpio && !max77686->irq) {
-		max77686->irq = gpio_to_irq(max77686->irq_gpio);
-
-		if (debug_mask & MAX77686_DEBUG_IRQ_INT) {
-			ret = gpio_request(max77686->irq_gpio, "pmic_irq");
-			if (ret < 0) {
-				dev_err(max77686->dev,
-					"Failed to request gpio %d with ret:"
-					"%d\n",	max77686->irq_gpio, ret);
-				return IRQ_NONE;
-			}
-
-			gpio_direction_input(max77686->irq_gpio);
-			val = gpio_get_value(max77686->irq_gpio);
-			gpio_free(max77686->irq_gpio);
-			pr_info("%s: gpio_irq=%x\n", __func__, val);
-		}
-	}
-
-	if (!max77686->irq) {
-		dev_err(max77686->dev, "irq is not specified\n");
-		return -ENODEV;
-	}
-
-	/* Mask individual interrupt sources */
-	for (i = 0; i < MAX77686_IRQ_GROUP_NR; i++) {
-		max77686->irq_masks_cur[i] = 0xff;
-		max77686->irq_masks_cache[i] = 0xff;
-		map = max77686_get_regmap(max77686, i);
-
-		if (IS_ERR_OR_NULL(map))
-			continue;
-		if (max77686_mask_reg[i] == MAX77686_REG_INVALID)
-			continue;
-
-		regmap_write(map, max77686_mask_reg[i], 0xff);
-	}
-	domain = irq_domain_add_linear(NULL, MAX77686_IRQ_NR,
-					&max77686_irq_domain_ops, max77686);
-	if (!domain) {
-		dev_err(max77686->dev, "could not create irq domain\n");
-		return -ENODEV;
-	}
-	max77686->irq_domain = domain;
-
-	ret = request_threaded_irq(max77686->irq, NULL, max77686_irq_thread,
-				   IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
-				   "max77686-irq", max77686);
-
-	if (ret)
-		dev_err(max77686->dev, "Failed to request IRQ %d: %d\n",
-			max77686->irq, ret);
-
-
-	if (debug_mask & MAX77686_DEBUG_IRQ_INFO)
-		pr_info("%s-\n", __func__);
-
-	return 0;
-}
-
-void max77686_irq_exit(struct max77686_dev *max77686)
-{
-	if (max77686->irq)
-		free_irq(max77686->irq, max77686);
-}
drivers/mfd/max77686.c +87 -6
index ce869ac..42eacb16 100644
@@ -25,6 +25,8 @@
 #include <linux/export.h>
 #include <linux/slab.h>
 #include <linux/i2c.h>
+#include <linux/irq.h>
+#include <linux/interrupt.h>
 #include <linux/pm_runtime.h>
 #include <linux/module.h>
 #include <linux/mfd/core.h>
@@ -46,6 +48,54 @@ static struct regmap_config max77686_regmap_config = {
 	.val_bits = 8,
 };
 
+static struct regmap_config max77686_rtc_regmap_config = {
+	.reg_bits = 8,
+	.val_bits = 8,
+};
+
+static const struct regmap_irq max77686_irqs[] = {
+	/* INT1 interrupts */
+	{ .reg_offset = 0, .mask = MAX77686_INT1_PWRONF_MSK, },
+	{ .reg_offset = 0, .mask = MAX77686_INT1_PWRONR_MSK, },
+	{ .reg_offset = 0, .mask = MAX77686_INT1_JIGONBF_MSK, },
+	{ .reg_offset = 0, .mask = MAX77686_INT1_JIGONBR_MSK, },
+	{ .reg_offset = 0, .mask = MAX77686_INT1_ACOKBF_MSK, },
+	{ .reg_offset = 0, .mask = MAX77686_INT1_ACOKBR_MSK, },
+	{ .reg_offset = 0, .mask = MAX77686_INT1_ONKEY1S_MSK, },
+	{ .reg_offset = 0, .mask = MAX77686_INT1_MRSTB_MSK, },
+	/* INT2 interrupts */
+	{ .reg_offset = 1, .mask = MAX77686_INT2_140C_MSK, },
+	{ .reg_offset = 1, .mask = MAX77686_INT2_120C_MSK, },
+};
+
+static const struct regmap_irq_chip max77686_irq_chip = {
+	.name			= "max77686-pmic",
+	.status_base		= MAX77686_REG_INT1,
+	.mask_base		= MAX77686_REG_INT1MSK,
+	.num_regs		= 2,
+	.irqs			= max77686_irqs,
+	.num_irqs		= ARRAY_SIZE(max77686_irqs),
+};
+
+static const struct regmap_irq max77686_rtc_irqs[] = {
+	/* RTC interrupts */
+	{ .reg_offset = 0, .mask = MAX77686_RTCINT_RTC60S_MSK, },
+	{ .reg_offset = 0, .mask = MAX77686_RTCINT_RTCA1_MSK, },
+	{ .reg_offset = 0, .mask = MAX77686_RTCINT_RTCA2_MSK, },
+	{ .reg_offset = 0, .mask = MAX77686_RTCINT_SMPL_MSK, },
+	{ .reg_offset = 0, .mask = MAX77686_RTCINT_RTC1S_MSK, },
+	{ .reg_offset = 0, .mask = MAX77686_RTCINT_WTSR_MSK, },
+};
+
+static const struct regmap_irq_chip max77686_rtc_irq_chip = {
+	.name			= "max77686-rtc",
+	.status_base		= MAX77686_RTC_INT,
+	.mask_base		= MAX77686_RTC_INTM,
+	.num_regs		= 1,
+	.irqs			= max77686_rtc_irqs,
+	.num_irqs		= ARRAY_SIZE(max77686_rtc_irqs),
+};
+
 #ifdef CONFIG_OF
 static const struct of_device_id max77686_pmic_dt_match[] = {
 	{.compatible = "maxim,max77686", .data = NULL},
@@ -101,7 +151,6 @@ static int max77686_i2c_probe(struct i2c_client *i2c,
 	max77686->type = id->driver_data;
 
 	max77686->wakeup = pdata->wakeup;
-	max77686->irq_gpio = pdata->irq_gpio;
 	max77686->irq = i2c->irq;
 
 	max77686->regmap = devm_regmap_init_i2c(i2c, &max77686_regmap_config);
@@ -117,8 +166,7 @@ static int max77686_i2c_probe(struct i2c_client *i2c,
 		dev_err(max77686->dev,
 			"device not found on this channel (this is not an error)\n");
 		return -ENODEV;
-	} else
-		dev_info(max77686->dev, "device found\n");
+	}
 
 	max77686->rtc = i2c_new_dummy(i2c->adapter, I2C_ADDR_RTC);
 	if (!max77686->rtc) {
@@ -127,15 +175,48 @@ static int max77686_i2c_probe(struct i2c_client *i2c,
 	}
 	i2c_set_clientdata(max77686->rtc, max77686);
 
-	max77686_irq_init(max77686);
+	max77686->rtc_regmap = devm_regmap_init_i2c(max77686->rtc,
+						    &max77686_rtc_regmap_config);
+	if (IS_ERR(max77686->rtc_regmap)) {
+		ret = PTR_ERR(max77686->rtc_regmap);
+		dev_err(max77686->dev, "failed to allocate RTC regmap: %d\n",
+			ret);
+		goto err_unregister_i2c;
+	}
+
+	ret = regmap_add_irq_chip(max77686->regmap, max77686->irq,
+				  IRQF_TRIGGER_FALLING | IRQF_ONESHOT |
+				  IRQF_SHARED, 0, &max77686_irq_chip,
+				  &max77686->irq_data);
+	if (ret != 0) {
+		dev_err(&i2c->dev, "failed to add PMIC irq chip: %d\n", ret);
+		goto err_unregister_i2c;
+	}
+	ret = regmap_add_irq_chip(max77686->rtc_regmap, max77686->irq,
+				  IRQF_TRIGGER_FALLING | IRQF_ONESHOT |
+				  IRQF_SHARED, 0, &max77686_rtc_irq_chip,
+				  &max77686->rtc_irq_data);
+	if (ret != 0) {
+		dev_err(&i2c->dev, "failed to add RTC irq chip: %d\n", ret);
+		goto err_del_irqc;
+	}
 
 	ret = mfd_add_devices(max77686->dev, -1, max77686_devs,
 			      ARRAY_SIZE(max77686_devs), NULL, 0, NULL);
 	if (ret < 0) {
-		mfd_remove_devices(max77686->dev);
-		i2c_unregister_device(max77686->rtc);
+		dev_err(&i2c->dev, "failed to add MFD devices: %d\n", ret);
+		goto err_del_rtc_irqc;
 	}
 
+	return 0;
+
+err_del_rtc_irqc:
+	regmap_del_irq_chip(max77686->irq, max77686->rtc_irq_data);
+err_del_irqc:
+	regmap_del_irq_chip(max77686->irq, max77686->irq_data);
+err_unregister_i2c:
+	i2c_unregister_device(max77686->rtc);
+
 	return ret;
 }
 
drivers/rtc/rtc-max77686.c +8 -19
index 9efe118..d20a7f0 100644
@@ -492,16 +492,11 @@ static int max77686_rtc_init_reg(struct max77686_rtc_info *info)
 	return ret;
 }
 
-static struct regmap_config max77686_rtc_regmap_config = {
-	.reg_bits = 8,
-	.val_bits = 8,
-};
-
 static int max77686_rtc_probe(struct platform_device *pdev)
 {
 	struct max77686_dev *max77686 = dev_get_drvdata(pdev->dev.parent);
 	struct max77686_rtc_info *info;
-	int ret, virq;
+	int ret;
 
 	dev_info(&pdev->dev, "%s\n", __func__);
 
@@ -514,14 +509,7 @@ static int max77686_rtc_probe(struct platform_device *pdev)
 	info->dev = &pdev->dev;
 	info->max77686 = max77686;
 	info->rtc = max77686->rtc;
-	info->max77686->rtc_regmap = devm_regmap_init_i2c(info->max77686->rtc,
-					 &max77686_rtc_regmap_config);
-	if (IS_ERR(info->max77686->rtc_regmap)) {
-		ret = PTR_ERR(info->max77686->rtc_regmap);
-		dev_err(info->max77686->dev, "Failed to allocate register map: %d\n",
-				ret);
-		return ret;
-	}
+
 	platform_set_drvdata(pdev, info);
 
 	ret = max77686_rtc_init_reg(info);
@@ -550,15 +538,16 @@ static int max77686_rtc_probe(struct platform_device *pdev)
 			ret = -EINVAL;
 		goto err_rtc;
 	}
-	virq = irq_create_mapping(max77686->irq_domain, MAX77686_RTCIRQ_RTCA1);
-	if (!virq) {
+
+	info->virq = regmap_irq_get_virq(max77686->rtc_irq_data,
+					 MAX77686_RTCIRQ_RTCA1);
+	if (!info->virq) {
 		ret = -ENXIO;
 		goto err_rtc;
 	}
-	info->virq = virq;
 
-	ret = devm_request_threaded_irq(&pdev->dev, virq, NULL,
-				max77686_rtc_alarm_irq, 0, "rtc-alarm0", info);
+	ret = devm_request_threaded_irq(&pdev->dev, info->virq, NULL,
+				max77686_rtc_alarm_irq, 0, "rtc-alarm1", info);
 	if (ret < 0)
 		dev_err(&pdev->dev, "Failed to request alarm IRQ: %d: %d\n",
 			info->virq, ret);
include/linux/mfd/max77686-private.h +22 -4
index 8c75a9c..3a810b1 100644
@@ -205,7 +205,7 @@ enum max77686_irq {
 	MAX77686_PMICIRQ_140C,
 	MAX77686_PMICIRQ_120C,
 
-	MAX77686_RTCIRQ_RTC60S,
+	MAX77686_RTCIRQ_RTC60S = 0,
 	MAX77686_RTCIRQ_RTCA1,
 	MAX77686_RTCIRQ_RTCA2,
 	MAX77686_RTCIRQ_SMPL,
@@ -215,6 +215,25 @@ enum max77686_irq {
 	MAX77686_IRQ_NR,
 };
 
+#define MAX77686_INT1_PWRONF_MSK	BIT(0)
+#define MAX77686_INT1_PWRONR_MSK	BIT(1)
+#define MAX77686_INT1_JIGONBF_MSK	BIT(2)
+#define MAX77686_INT1_JIGONBR_MSK	BIT(3)
+#define MAX77686_INT1_ACOKBF_MSK	BIT(4)
+#define MAX77686_INT1_ACOKBR_MSK	BIT(5)
+#define MAX77686_INT1_ONKEY1S_MSK	BIT(6)
+#define MAX77686_INT1_MRSTB_MSK		BIT(7)
+
+#define MAX77686_INT2_140C_MSK		BIT(0)
+#define MAX77686_INT2_120C_MSK		BIT(1)
+
+#define MAX77686_RTCINT_RTC60S_MSK	BIT(0)
+#define MAX77686_RTCINT_RTCA1_MSK	BIT(1)
+#define MAX77686_RTCINT_RTCA2_MSK	BIT(2)
+#define MAX77686_RTCINT_SMPL_MSK	BIT(3)
+#define MAX77686_RTCINT_RTC1S_MSK	BIT(4)
+#define MAX77686_RTCINT_WTSR_MSK	BIT(5)
+
 struct max77686_dev {
 	struct device *dev;
 	struct i2c_client *i2c; /* 0xcc / PMIC, Battery Control, and FLASH */
@@ -224,11 +243,10 @@ struct max77686_dev {
 
 	struct regmap *regmap;		/* regmap for mfd */
 	struct regmap *rtc_regmap;	/* regmap for rtc */
-
-	struct irq_domain *irq_domain;
+	struct regmap_irq_chip_data *irq_data;
+	struct regmap_irq_chip_data *rtc_irq_data;
 
 	int irq;
-	int irq_gpio;
 	bool wakeup;
 	struct mutex irqlock;
 	int irq_masks_cur[MAX77686_IRQ_GROUP_NR];
include/linux/mfd/max77686.h +0 -2
index 46c0f32..4cbcc13 100644
@@ -89,8 +89,6 @@ struct max77686_opmode_data {
 };
 
 struct max77686_platform_data {
-	/* IRQ */
-	int irq_gpio;
 	int ono;
 	int wakeup;
 
Signature · 4 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org ? Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
Reviewed-by Tested-by on v2 1/10
#3 lore raw

Re: [PATCH v2 01/10] mfd: max77686: Convert to use regmap_irq

In reply to Javier Martinez Canillas

Javier,

Quoted 36 lines · Javier Martinez Canillas
drivers/mfd/max77686.c +25 -3
@@ -127,15 +175,48 @@ static int max77686_i2c_probe(struct i2c_client *i2c,
        }
        i2c_set_clientdata(max77686->rtc, max77686);
 
-       max77686_irq_init(max77686);
+       max77686->rtc_regmap = devm_regmap_init_i2c(max77686->rtc,
+                                                   &max77686_rtc_regmap_config);
+       if (IS_ERR(max77686->rtc_regmap)) {
+               ret = PTR_ERR(max77686->rtc_regmap);
+               dev_err(max77686->dev, "failed to allocate RTC regmap: %d\n",
+                       ret);
+               goto err_unregister_i2c;
+       }
+
+       ret = regmap_add_irq_chip(max77686->regmap, max77686->irq,
+                                 IRQF_TRIGGER_FALLING | IRQF_ONESHOT |
+                                 IRQF_SHARED, 0, &max77686_irq_chip,
+                                 &max77686->irq_data);
+       if (ret != 0) {
+               dev_err(&i2c->dev, "failed to add PMIC irq chip: %d\n", ret);
+               goto err_unregister_i2c;
+       }
+       ret = regmap_add_irq_chip(max77686->rtc_regmap, max77686->irq,
+                                 IRQF_TRIGGER_FALLING | IRQF_ONESHOT |
+                                 IRQF_SHARED, 0, &max77686_rtc_irq_chip,
+                                 &max77686->rtc_irq_data);
+       if (ret != 0) {
+               dev_err(&i2c->dev, "failed to add RTC irq chip: %d\n", ret);
+               goto err_del_irqc;
+       }
 
        ret = mfd_add_devices(max77686->dev, -1, max77686_devs,
                              ARRAY_SIZE(max77686_devs), NULL, 0, NULL);
        if (ret < 0) {
-               mfd_remove_devices(max77686->dev);
-               i2c_unregister_device(max77686->rtc);

drivers/mfd/max77686.c static int max77686_i2c_probe(struct i2c_client *i2c, · line 216

Quoted 10 lines
drivers/mfd/max77686.c +8 -0
+               dev_err(&i2c->dev, "failed to add MFD devices: %d\n", ret);
+               goto err_del_rtc_irqc;
        }
 
+       return 0;
+
+err_del_rtc_irqc:
+       regmap_del_irq_chip(max77686->irq, max77686->rtc_irq_data);
+err_del_irqc:
+       regmap_del_irq_chip(max77686->irq, max77686->irq_data);

I would imagine you either don't need these regmap_del_irq_chip() here or that you _do_ need them in max77686_i2c_remove().

...from looking at other drivers I think the answer is to add them to max77686_i2c_remove().

Quoted 14 lines
include/linux/mfd/max77686-private.h +1 -1
index 8c75a9c..3a810b1 100644
@@ -205,7 +205,7 @@ enum max77686_irq {
        MAX77686_PMICIRQ_140C,
        MAX77686_PMICIRQ_120C,
 
-       MAX77686_RTCIRQ_RTC60S,
+       MAX77686_RTCIRQ_RTC60S = 0,
        MAX77686_RTCIRQ_RTCA1,
        MAX77686_RTCIRQ_RTCA2,
        MAX77686_RTCIRQ_SMPL,

include/linux/mfd/max77686-private.h enum max77686_irq { · line 215

Quoted 1 line
include/linux/mfd/max77686-private.h +0 -0
@@ -215,6 +215,25 @@ enum max77686_irq {
        MAX77686_IRQ_NR,

Maybe remove MAX77686_IRQ_NR which no longer makes any sense now that you start over at 0 partway through.

Overall this looks good to me, so once nits above are fixed feel to add my Reviewed-by. I've also built and booted this patch on exynos5250-snow and tested that the RTC wakealarm fires and can even wake the system up (with some additional work that I'll email you about).

#4 lore raw

Re: [PATCH v2 01/10] mfd: max77686: Convert to use regmap_irq

Hello Doug,

Quoted 54 lines · Doug Anderson

Javier,

Quoted 36 lines · Javier Martinez Canillas
drivers/mfd/max77686.c +25 -3
@@ -127,15 +175,48 @@ static int max77686_i2c_probe(struct i2c_client *i2c,
        }
        i2c_set_clientdata(max77686->rtc, max77686);
 
-       max77686_irq_init(max77686);
+       max77686->rtc_regmap = devm_regmap_init_i2c(max77686->rtc,
+                                                   &max77686_rtc_regmap_config);
+       if (IS_ERR(max77686->rtc_regmap)) {
+               ret = PTR_ERR(max77686->rtc_regmap);
+               dev_err(max77686->dev, "failed to allocate RTC regmap: %d\n",
+                       ret);
+               goto err_unregister_i2c;
+       }
+
+       ret = regmap_add_irq_chip(max77686->regmap, max77686->irq,
+                                 IRQF_TRIGGER_FALLING | IRQF_ONESHOT |
+                                 IRQF_SHARED, 0, &max77686_irq_chip,
+                                 &max77686->irq_data);
+       if (ret != 0) {
+               dev_err(&i2c->dev, "failed to add PMIC irq chip: %d\n", ret);
+               goto err_unregister_i2c;
+       }
+       ret = regmap_add_irq_chip(max77686->rtc_regmap, max77686->irq,
+                                 IRQF_TRIGGER_FALLING | IRQF_ONESHOT |
+                                 IRQF_SHARED, 0, &max77686_rtc_irq_chip,
+                                 &max77686->rtc_irq_data);
+       if (ret != 0) {
+               dev_err(&i2c->dev, "failed to add RTC irq chip: %d\n", ret);
+               goto err_del_irqc;
+       }
 
        ret = mfd_add_devices(max77686->dev, -1, max77686_devs,
                              ARRAY_SIZE(max77686_devs), NULL, 0, NULL);
        if (ret < 0) {
-               mfd_remove_devices(max77686->dev);
-               i2c_unregister_device(max77686->rtc);

drivers/mfd/max77686.c static int max77686_i2c_probe(struct i2c_client *i2c, · line 216

Quoted 10 lines
drivers/mfd/max77686.c +8 -0
+               dev_err(&i2c->dev, "failed to add MFD devices: %d\n", ret);
+               goto err_del_rtc_irqc;
        }
 
+       return 0;
+
+err_del_rtc_irqc:
+       regmap_del_irq_chip(max77686->irq, max77686->rtc_irq_data);
+err_del_irqc:
+       regmap_del_irq_chip(max77686->irq, max77686->irq_data);

I would imagine you either don't need these regmap_del_irq_chip() here or that you _do_ need them in max77686_i2c_remove().

Quoted 4 lines

...from looking at other drivers I think the answer is to add them to max77686_i2c_remove().

Yes, I forgot to do the regmap irqchip cleanup in the driver .remove function. The same issue is in the max77802 driver btw so I'll fix both on v3.

Thanks a lot for pointing this out.

Quoted 8 lines
Quoted 8 lines
include/linux/mfd/max77686-private.h +0 -0
index 8c75a9c..3a810b1 100644
@@ -205,7 +205,7 @@ enum max77686_irq {
        MAX77686_PMICIRQ_140C,
        MAX77686_PMICIRQ_120C,
 
Quoted 12 lines

include/linux/mfd/max77686-private.h enum max77686_irq { · line 215

Quoted 7 lines
include/linux/mfd/max77686-private.h +1 -1
-       MAX77686_RTCIRQ_RTC60S,
+       MAX77686_RTCIRQ_RTC60S = 0,
        MAX77686_RTCIRQ_RTCA1,
        MAX77686_RTCIRQ_RTCA2,
        MAX77686_RTCIRQ_SMPL,
@@ -215,6 +215,25 @@ enum max77686_irq {
        MAX77686_IRQ_NR,

Maybe remove MAX77686_IRQ_NR which no longer makes any sense now that you start over at 0 partway through.

Right, it is not needed anymore. I'll remove it when re-spin.

Quoted 9 lines

Overall this looks good to me, so once nits above are fixed feel to add my Reviewed-by. I've also built and booted this patch on exynos5250-snow and tested that the RTC wakealarm fires and can even wake the system up (with some additional work that I'll email you about).

Great! thanks a lot for testing.

Best regards,
Javier

#5 lore raw

PATCH v2 2/10 clk: max77686: add DT include for MAX77686 PMIC clock

In reply to Javier Martinez Canillas

This patch adds a dt-binding include for Maxim 77686 PMIC clock IDs that can be to be shared between the clk-max77686 clock driver and DeviceTree source files.

---
 drivers/clk/clk-max77686.c                 |  7 +------
 include/dt-bindings/clock/maxim,max77686.h | 23 +++++++++++++++++++++++
 2 files changed, 24 insertions(+), 6 deletions(-)
 create mode 100644 include/dt-bindings/clock/maxim,max77686.h
drivers/clk/clk-max77686.c +1 -6
index 3d7e8dd..185b611 100644
@@ -30,12 +30,7 @@
 #include <linux/mutex.h>
 #include <linux/clkdev.h>
 
-enum {
-	MAX77686_CLK_AP = 0,
-	MAX77686_CLK_CP,
-	MAX77686_CLK_PMIC,
-	MAX77686_CLKS_NUM,
-};
+#include <dt-bindings/clock/maxim,max77686.h>
 
 struct max77686_clk {
 	struct max77686_dev *iodev;
include/dt-bindings/clock/maxim,max77686.h new file +23 -0
new file mode 100644
index 0000000..7b28b09
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2014 Google, Inc
+ *
+ * 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.
+ *
+ * Device Tree binding constants clocks for the Maxim 77686 PMIC.
+ */
+
+#ifndef _DT_BINDINGS_CLOCK_MAXIM_MAX77686_CLOCK_H
+#define _DT_BINDINGS_CLOCK_MAXIM_MAX77686_CLOCK_H
+
+/* Fixed rate clocks. */
+
+#define MAX77686_CLK_AP		0
+#define MAX77686_CLK_CP		1
+#define MAX77686_CLK_PMIC	2
+
+/* Total number of clocks. */
+#define MAX77686_CLKS_NUM		(MAX77686_CLK_PMIC + 1)
+
+#endif /* _DT_BINDINGS_CLOCK_MAXIM_MAX77686_CLOCK_H */
Signature · 1 line
2.0.0.rc2
#6 lore raw

PATCH v2 3/10 Documentation: dt: improve Maxim 77686 PMIC clocks binding

In reply to Javier Martinez Canillas

Like most clock drivers, the Maxim 77686 PMIC clock binding follows the convention that the "#clock-cells" property is used to specify the number of cells in a clock provider.

But the binding document is not clear enough that it shall be set to 1 since the PMIC support multiple clocks outputs.

Also, explain that the clocks identifiers are defined in a header file that can be included by Device Tree source with client nodes to avoid using magic numbers.

---
 .../devicetree/bindings/clock/maxim,max77686.txt          | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)
Documentation/devicetree/bindings/clock/maxim,max77686.txt +10 -5
index 96ce71b..8dea305 100644
@@ -9,13 +9,18 @@ The MAX77686 contains three 32.768khz clock outputs that can be controlled
 Following properties should be presend in main device node of the MFD chip.
 
 Required properties:
-- #clock-cells: simple one-cell clock specifier format is used, where the
-  only cell is used as an index of the clock inside the provider. Following
-  indices are allowed:
+
+- #clock-cells: from common clock binding; shall be set to 1.
+
+Each clock is assigned an identifier and client nodes can use this identifier
+to specify the clock which they consume. Following indices are allowed:
     - 0: 32khz_ap clock,
     - 1: 32khz_cp clock,
     - 2: 32khz_pmic clock.
 
+Clocks are defined as preprocessor macros in dt-bindings/clock/maxim,max77686.h
+header and can be used in device tree sources.
+
 Example: Node of the MFD chip
 
 	max77686: max77686 at 09 {
@@ -33,6 +38,6 @@ Example: Clock consumer node
 	foo at 0 {
 		compatible = "bar,foo";
 		/* ... */
-		clock-names = "my-clock";
-		clocks = <&max77686 2>;
+		clock-names = "32khz_pmic";
+		clocks = <&max77686 MAX77686_CLK_PMIC>;
 	};
Signature · 1 line
2.0.0.rc2
#7 lore raw

PATCH v2 4/10 clk: Add generic driver for Maxim PMIC clocks

In reply to Javier Martinez Canillas

Maxim Integrated Power Management ICs are very similar with regard to their clock outputs. Most of the clock drivers for these chips are duplicating code and are simpler enough that can be converted to use a generic driver to consolidate code and avoid duplication.

---
 drivers/clk/Kconfig       |   3 +
 drivers/clk/Makefile      |   1 +
 drivers/clk/clk-max-gen.c | 197 ++++++++++++++++++++++++++++++++++++++++++++++
 drivers/clk/clk-max-gen.h |  32 ++++++++
 4 files changed, 233 insertions(+)
 create mode 100644 drivers/clk/clk-max-gen.c
 create mode 100644 drivers/clk/clk-max-gen.h
drivers/clk/Kconfig +3 -0
index 9f9c5ae..73f78e8 100644
@@ -32,6 +32,9 @@ config COMMON_CLK_WM831X
 
 source "drivers/clk/versatile/Kconfig"
 
+config COMMON_CLK_MAX_GEN
+        bool
+
 config COMMON_CLK_MAX77686
 	tristate "Clock driver for Maxim 77686 MFD"
 	depends on MFD_MAX77686
drivers/clk/Makefile +1 -0
index 567f102..6c1aff6 100644
@@ -18,6 +18,7 @@ obj-$(CONFIG_ARCH_BCM2835)		+= clk-bcm2835.o
 obj-$(CONFIG_ARCH_EFM32)		+= clk-efm32gg.o
 obj-$(CONFIG_ARCH_HIGHBANK)		+= clk-highbank.o
 obj-$(CONFIG_MACH_LOONGSON1)		+= clk-ls1x.o
+obj-$(CONFIG_COMMON_CLK_MAX_GEN)	+= clk-max-gen.o
 obj-$(CONFIG_COMMON_CLK_MAX77686)	+= clk-max77686.o
 obj-$(CONFIG_ARCH_MOXART)		+= clk-moxart.o
 obj-$(CONFIG_ARCH_NOMADIK)		+= clk-nomadik.o
drivers/clk/clk-max-gen.c new file +197 -0

197 lines not on this page · raw message

drivers/clk/clk-max-gen.h new file +32 -0
new file mode 100644
index 0000000..997e86f
@@ -0,0 +1,32 @@
+/*
+ * clk-max-gen.h - Generic clock driver for Maxim PMICs clocks
+ *
+ * Copyright (C) 2014 Google, Inc
+ *
+ * This program is free software; you can redistribute  it and/or modify it
+ * under  the terms of  the GNU General  Public License as published by the
+ * Free Software Foundation;  either version 2 of the  License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#ifndef __CLK_MAX_GEN_H__
+#define __CLK_MAX_GEN_H__
+
+#include <linux/types.h>
+#include <linux/device.h>
+#include <linux/clkdev.h>
+#include <linux/regmap.h>
+#include <linux/platform_device.h>
+
+int max_gen_clk_probe(struct platform_device *pdev, struct regmap *regmap,
+		      u32 reg, struct clk_init_data *clks_init, int num_init);
+int max_gen_clk_remove(struct platform_device *pdev, int num_init);
+extern struct clk_ops max_gen_clk_ops;
+
+#endif /* __CLK_MAX_GEN_H__ */
Signature · 1 line
2.0.0.rc2
#8 lore raw

PATCH v2 5/10 clk: max77686: convert to the generic max clock driver

In reply to Javier Martinez Canillas

Clocks drivers for Maxim PMIC are very similar so they can be converted to use the generic Maxim clock driver.

Also, while being there use module_platform_driver() helper macro to eliminate more boilerplate code.

---
 drivers/clk/Kconfig        |   1 +
 drivers/clk/clk-max77686.c | 176 +++------------------------------------------
 2 files changed, 9 insertions(+), 168 deletions(-)
drivers/clk/Kconfig +1 -0
index 73f78e8..3fd4270 100644
@@ -38,6 +38,7 @@ config COMMON_CLK_MAX_GEN
 config COMMON_CLK_MAX77686
 	tristate "Clock driver for Maxim 77686 MFD"
 	depends on MFD_MAX77686
+	select COMMON_CLK_MAX_GEN
 	---help---
 	  This driver supports Maxim 77686 crystal oscillator clock. 
 
drivers/clk/clk-max77686.c +8 -168

212 lines not on this page · raw message

Signature · 1 line
2.0.0.rc2
#9 lore raw

PATCH v2 6/10 mfd: Add driver for Maxim 77802 Power Management IC

In reply to Javier Martinez Canillas

Maxim MAX77802 is a power management chip that contains 10 high efficiency Buck regulators, 32 Low-dropout (LDO) regulators used to power up application processors and peripherals, a 2-channel 32kHz clock outputs, a Real-Time-Clock (RTC) and a I2C interface to program the individual regulators, clocks outputs and the RTC.

This patch adds the core support for MAX77802 PMIC and is based on a driver added by Simon Glass to the Chrome OS kernel 3.8 tree.

---

Changes since v1:
- Convert max77{686,802} to regmap irq API and get rid of max77{686,802}-irq.c suggested by Krzysztof Kozlowski.
- Don't protect max77802 mfd_cells using Kconfig options since mfd core omits devices that don't match. Suggested by Lee Jones.
- Change mfd driver to be tristate instead of boolean. Suggested by Mark Brown.
- Change binding "voltage-regulators" property to "regulators" to be consistent with other PMIC drivers. Suggested by Mark Brown.
- Use regulators node names instead of the deprecated "regulator-compatible" property. Suggested by Mark Brown.
- Use the new descriptor-based GPIO interface instead of the deprecated integer based GPIO one. Suggested by Mark Brown.
- Remove the type parameter from i2c_device_id table since was not used.
- Fix device not found error message and remove unneeded device found message.

 Documentation/devicetree/bindings/mfd/max77802.txt |  87 +++++
 drivers/mfd/Kconfig                                |  14 +
 drivers/mfd/Makefile                               |   1 +
 drivers/mfd/max77802.c                             | 362 +++++++++++++++++++++
 include/linux/mfd/max77802-private.h               | 309 ++++++++++++++++++
 include/linux/mfd/max77802.h                       | 124 +++++++
 6 files changed, 897 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/max77802.txt
 create mode 100644 drivers/mfd/max77802.c
 create mode 100644 include/linux/mfd/max77802-private.h
 create mode 100644 include/linux/mfd/max77802.h
Documentation/devicetree/bindings/mfd/max77802.txt new file +87 -0
new file mode 100644
index 0000000..e6c4860
@@ -0,0 +1,87 @@
+Maxim MAX77802 multi-function device
+
+MAX77802 is a Mulitifunction device with PMIC, RTC and Charger on chip. It is
+interfaced to host controller using i2c interface. PMIC, Charger and RTC
+submodules are addressed using same i2c slave address
+
+This document describes the binding for mfd device and PMIC submodule.
+
+Binding for the built-in 32k clock generator block is defined separately
+in bindings/clk/maxim,max77802.txt file.
+
+Required properties:
+- compatible : Must be "maxim,max77802";
+- reg : Specifies the i2c slave address of PMIC block.
+- interrupts : This i2c device has an IRQ line connected to the main SoC.
+- interrupt-parent : The parent interrupt controller.
+
+Optional properties:
+- max77802,pmic-buck-default-dvs-idx: We'll always write this DVS index in the
+  PMIC for BUCKs with DVS (Bucks 1-4, 6).
+  NOTE: at the moment these bindings don't include enough details for actual
+  GPIO-DVS--this just lets you choose which single slot to use.
+
+- max77802,pmic-buck-dvs-gpios: The DVS GPIOs. We'll try to set these GPIOs
+  to match pmic-buck-default-dvs-idx at probe time if they are defined. If
+  some or all of these GPIOs are not defined it's assumed that the board has
+  any missing GPIOs hardwired to match pmic-buck-default-dvs-idx.
+
+- max77802,pmic-buck-selb-gpios: GPIOs to enable DVS-GPIO for BUCKs.
+  Should be five values: 1, 2, 3, 4, 6.  It is strongly suggested to include
+  these GPIOs if there's any chance that changing DVS GPIOs one line at a
+  time might glitch your DVS values.
+
+Optional node:
+- regulators : The regulators of max77802 have to be instantiated
+  under subnode named "regulators" using the following format.
+
+	regulator_name {
+		standard regulator constraints....
+	};
+	refer Documentation/devicetree/bindings/regulator/regulator.txt
+
+  The regulator node name should be initialized with a string
+to get matched with their hardware counterparts as follow:
+
+	-LDOn 	:	for LDOs, where n can lie in range 1 to 35.
+			example: LDO1, LDO2, LDO35.
+	-BUCKn 	:	for BUCKs, where n can lie in range 1 to 10.
+			example: BUCK1, BUCK5, BUCK10.
+Example:
+
+	max77802 at 09 {
+		compatible = "maxim,max77802";
+		interrupt-parent = <&wakeup_eint>;
+		interrupts = <26 0>;
+		reg = <0x09>;
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		max77802,pmic-buck-default-dvs-idx = <1>;
+		max77802,pmic-buck-dvs-gpios = <&gpy7 6 0>,
+					       <&gpj4 2 0>,
+					       <&gpj4 3 0>;
+		max77802,pmic-buck-selb-gpios = <&gph0 2 0>,
+						<&gph0 3 0>,
+						<&gph0 4 0>,
+						<&gph0 5 0>,
+						<&gph0 6 0>;
+
+		regulators {
+			ldo11_reg: LDO11 {
+				regulator-compatible = "LDO11";
+				regulator-name = "vdd_ldo11";
+				regulator-min-microvolt = <1900000>;
+				regulator-max-microvolt = <1900000>;
+				regulator-always-on;
+			};
+
+			buck1_reg {
+				regulator-compatible = "BUCK1";
+				regulator-name = "vdd_mif";
+				regulator-min-microvolt = <950000>;
+				regulator-max-microvolt = <1300000>;
+				regulator-always-on;
+				regulator-boot-on;
+			};
+	};
drivers/mfd/Kconfig +14 -0
index 0916447..dcec3b7 100644
@@ -393,6 +393,20 @@ config MFD_MAX77693
 	  additional drivers must be enabled in order to use the functionality
 	  of the device.
 
+config MFD_MAX77802
+	tristate "Maxim Integrated MAX77802 PMIC Support"
+	depends on I2C=y
+	select MFD_CORE
+	select REGMAP_I2C
+	select REGMAP_IRQ
+	select IRQ_DOMAIN
+	help
+	  Say yes here to support for Maxim Integrated MAX77802.
+	  This is a Power Management IC with RTC on chip.
+	  This driver provides common support for accessing the device;
+	  additional drivers must be enabled in order to use the functionality
+	  of the device.
+
 config MFD_MAX8907
 	tristate "Maxim Semiconductor MAX8907 PMIC Support"
 	select MFD_CORE
drivers/mfd/Makefile +1 -0
index 3b3b408..8108ae6 100644
@@ -117,6 +117,7 @@ obj-$(CONFIG_MFD_DA9063)	+= da9063.o
 obj-$(CONFIG_MFD_MAX14577)	+= max14577.o
 obj-$(CONFIG_MFD_MAX77686)	+= max77686.o
 obj-$(CONFIG_MFD_MAX77693)	+= max77693.o max77693-irq.o
+obj-$(CONFIG_MFD_MAX77802)	+= max77802.o
 obj-$(CONFIG_MFD_MAX8907)	+= max8907.o
 max8925-objs			:= max8925-core.o max8925-i2c.o
 obj-$(CONFIG_MFD_MAX8925)	+= max8925.o
drivers/mfd/max77802.c new file +362 -0

362 lines not on this page · raw message

include/linux/mfd/max77802-private.h new file +309 -0

309 lines not on this page · raw message

include/linux/mfd/max77802.h new file +124 -0

124 lines not on this page · raw message

Signature · 1 line
2.0.0.rc2
maintainer
#10 lore raw

Re: [PATCH v2 06/10] mfd: Add driver for Maxim 77802 Power Management IC

Documentation/devicetree/bindings/mfd/max77802.txt line 27

Quoted 4 lines · Javier Martinez Canillas

+- max77802,pmic-buck-dvs-gpios: The DVS GPIOs. We'll try to set these GPIOs

Documentation/devicetree/bindings/mfd/max77802.txt new file +3 -0
+  to match pmic-buck-default-dvs-idx at probe time if they are defined. If
+  some or all of these GPIOs are not defined it's assumed that the board has
+  any missing GPIOs hardwired to match pmic-buck-default-dvs-idx.

I can't tell from reading this what the property means exactly - I expect it is an array of the GPIOs in some order but that order isn't specified.

Quoted 4 lines
drivers/mfd/Kconfig +4 -0
+config MFD_MAX77802
+	tristate "Maxim Integrated MAX77802 PMIC Support"
+	depends on I2C=y
+	select MFD_CORE

drivers/mfd/Kconfig config MFD_MAX77693 · line 409

Quoted 10 lines
drivers/mfd/Kconfig +10 -0
+	select REGMAP_I2C
+	select REGMAP_IRQ
+	select IRQ_DOMAIN
+	help
+	  Say yes here to support for Maxim Integrated MAX77802.
+	  This is a Power Management IC with RTC on chip.
+	  This driver provides common support for accessing the device;
+	  additional drivers must be enabled in order to use the functionality
+	  of the device.
+

It is a bit unorthodox to put the build infrastructure in the same patch
as the DT binding...
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140616/718375a8/attachment.sig>

#11 lore raw

Re: [PATCH v2 06/10] mfd: Add driver for Maxim 77802 Power Management IC

Hello Mark,

Quoted 11 lines · Mark Brown

Documentation/devicetree/bindings/mfd/max77802.txt line 27

Quoted 4 lines · Javier Martinez Canillas

+- max77802,pmic-buck-dvs-gpios: The DVS GPIOs. We'll try to set these GPIOs

Documentation/devicetree/bindings/mfd/max77802.txt new file +3 -0
+  to match pmic-buck-default-dvs-idx at probe time if they are defined. If
+  some or all of these GPIOs are not defined it's assumed that the board has
+  any missing GPIOs hardwired to match pmic-buck-default-dvs-idx.

I can't tell from reading this what the property means exactly - I expect it is an array of the GPIOs in some order but that order isn't specified.

Ok, I'll improve this property documentation.

Quoted 9 lines
Quoted 9 lines
drivers/mfd/Kconfig +9 -0
+config MFD_MAX77802
+	tristate "Maxim Integrated MAX77802 PMIC Support"
+	depends on I2C=y
+	select MFD_CORE
+	select REGMAP_I2C
+	select REGMAP_IRQ
+	select IRQ_DOMAIN
+	help
+	  Say yes here to support for Maxim Integrated MAX77802.
Quoted 9 lines

drivers/mfd/Kconfig config MFD_MAX77693 · line 409

Quoted 5 lines
drivers/mfd/Kconfig +5 -0
+	  This is a Power Management IC with RTC on chip.
+	  This driver provides common support for accessing the device;
+	  additional drivers must be enabled in order to use the functionality
+	  of the device.
+

It is a bit unorthodox to put the build infrastructure in the same patch as the DT binding...

I thought it was the opposite. That a DT binding document has to be added along with the first user of the binding but I'll separate the DT doc in another patch then if that is the right thing to do.

Thanks a lot for all your suggestions, I'll wait a little to see if there is more feedback and repost a v3 addressing all the issues you pointed out.

Best regards,
Javier

#12 lore raw

Re: [PATCH v2 06/10] mfd: Add driver for Maxim 77802 Power Management IC

Quoted 19 lines
Quoted 9 lines
Quoted 9 lines
drivers/mfd/Kconfig +9 -0
+config MFD_MAX77802
+	tristate "Maxim Integrated MAX77802 PMIC Support"
+	depends on I2C=y
+	select MFD_CORE
+	select REGMAP_I2C
+	select REGMAP_IRQ
+	select IRQ_DOMAIN
+	help
+	  Say yes here to support for Maxim Integrated MAX77802.
Quoted 9 lines

drivers/mfd/Kconfig config MFD_MAX77693 · line 409

Quoted 5 lines
drivers/mfd/Kconfig +5 -0
+	  This is a Power Management IC with RTC on chip.
+	  This driver provides common support for accessing the device;
+	  additional drivers must be enabled in order to use the functionality
+	  of the device.
+

It is a bit unorthodox to put the build infrastructure in the same patch as the DT binding...

Quoted 3 lines

I thought it was the opposite. That a DT binding document has to be added along with the first user of the binding but I'll separate the DT doc in another patch then if that is the right thing to do.

This was the 'old' method, but changed a little over a year ago.

Quoted 2 lines

Thanks a lot for all your suggestions, I'll wait a little to see if there is more feedback and repost a v3 addressing all the issues you pointed out.

Just re-post it. I'll review the next version.

Signature · 4 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org ? Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
#13 lore raw

Re: [PATCH v2 06/10] mfd: Add driver for Maxim 77802 Power Management IC

Hello Lee,

Quoted 23 lines · Lee Jones
Quoted 19 lines
Quoted 9 lines
Quoted 9 lines
drivers/mfd/Kconfig +9 -0
+config MFD_MAX77802
+	tristate "Maxim Integrated MAX77802 PMIC Support"
+	depends on I2C=y
+	select MFD_CORE
+	select REGMAP_I2C
+	select REGMAP_IRQ
+	select IRQ_DOMAIN
+	help
+	  Say yes here to support for Maxim Integrated MAX77802.
Quoted 9 lines

drivers/mfd/Kconfig config MFD_MAX77693 · line 409

Quoted 5 lines
drivers/mfd/Kconfig +5 -0
+	  This is a Power Management IC with RTC on chip.
+	  This driver provides common support for accessing the device;
+	  additional drivers must be enabled in order to use the functionality
+	  of the device.
+

It is a bit unorthodox to put the build infrastructure in the same patch as the DT binding...

Quoted 3 lines

I thought it was the opposite. That a DT binding document has to be added along with the first user of the binding but I'll separate the DT doc in another patch then if that is the right thing to do.

Quoted 7 lines

This was the 'old' method, but changed a little over a year ago.

Quoted 2 lines

Thanks a lot for all your suggestions, I'll wait a little to see if there is more feedback and repost a v3 addressing all the issues you pointed out.

Just re-post it. I'll review the next version.

Ok, will do. I was waiting for Krzysztof's feedback but he can review v3 as well.

Thanks a lot and best regards,
Javier

#14 lore raw

PATCH v2 7/10 regulator: Add driver for Maxim 77802 PMIC regulators

In reply to Javier Martinez Canillas

The MAX77802 PMIC has 10 high-efficiency Buck and 32 Low-dropout (LDO) regulators. This patch adds support for all these regulators found on the MAX77802 PMIC and is based on a driver added by Simon Glass to the Chrome OS kernel 3.8 tree.

---

Changes since v1:
- Remove unneeded check if num_regulators != MAX77802_MAX_REGULATORS.
- Fix .set_suspend_mode handler comment and split regulators ops for regulators that behave differently. Suggested by Mark Brown.
- Use module_platform_driver() instead of having init/exit functions. Suggested by Mark Brown.
- Use the new descriptor-based GPIO interface instead of the deprecated integer based GPIO one. Suggested by Mark Brown.
- Look for "regulators" child node instead of "voltage-regulators" to be consistent with other PMIC drivers. Suggested by Mark Brown.

 drivers/mfd/max77802.c       |   1 +
 drivers/regulator/Kconfig    |   9 +
 drivers/regulator/Makefile   |   1 +
 drivers/regulator/max77802.c | 701 +++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 712 insertions(+)
 create mode 100644 drivers/regulator/max77802.c
drivers/mfd/max77802.c +1 -0
index c29fcdd..c9dcbab 100644
@@ -37,6 +37,7 @@
 #include <linux/err.h>
 
 static const struct mfd_cell max77802_devs[] = {
+	{ .name = "max77802-pmic", },
 };
 
 static bool max77802_pmic_is_accessible_reg(struct device *dev,
drivers/regulator/Kconfig +9 -0
index 789eb46..17873d3 100644
@@ -377,6 +377,15 @@ config REGULATOR_MAX77693
 	  and one current regulator 'CHARGER'. This is suitable for
 	  Exynos-4x12 chips.
 
+config REGULATOR_MAX77802
+	tristate "Maxim 77802 regulator"
+	depends on MFD_MAX77802
+	help
+	  This driver controls a Maxim 77802 regulator
+	  via I2C bus. The provided regulator is suitable for
+	  Exynos-5 chips to control various voltages. It includes
+	  support for control of voltage and ramp speed.
+
 config REGULATOR_MC13XXX_CORE
 	tristate
 
drivers/regulator/Makefile +1 -0
index d461110..2aea4b6 100644
@@ -51,6 +51,7 @@ obj-$(CONFIG_REGULATOR_MAX8997) += max8997.o
 obj-$(CONFIG_REGULATOR_MAX8998) += max8998.o
 obj-$(CONFIG_REGULATOR_MAX77686) += max77686.o
 obj-$(CONFIG_REGULATOR_MAX77693) += max77693.o
+obj-$(CONFIG_REGULATOR_MAX77802) += max77802.o
 obj-$(CONFIG_REGULATOR_MC13783) += mc13783-regulator.o
 obj-$(CONFIG_REGULATOR_MC13892) += mc13892-regulator.o
 obj-$(CONFIG_REGULATOR_MC13XXX_CORE) +=  mc13xxx-regulator-core.o
drivers/regulator/max77802.c new file +701 -0

701 lines not on this page · raw message

Signature · 1 line
2.0.0.rc2
maintainer
#15 lore raw

Re: [PATCH v2 07/10] regulator: Add driver for Maxim 77802 PMIC regulators

drivers/mfd/max77802.c line 43

Quoted 10 lines · Javier Martinez Canillas
drivers/mfd/max77802.c +1 -0
@@ -37,6 +37,7 @@
 #include <linux/err.h>
 
 static const struct mfd_cell max77802_devs[] = {
+	{ .name = "max77802-pmic", },
 };
 
 static bool max77802_pmic_is_accessible_reg(struct device *dev,

Please don't do things like this, it makes it harder to apply your series. Just register all the devices in the MFD when you add the MFD driver.

drivers/mfd/max77802.c

Quoted 4 lines
drivers/mfd/max77802.c +4 -0
+	default:
+		pr_warn("%s: regulator_suspend_mode : 0x%x not supported\n",
+			rdev->desc->name, mode);
+		return -EINVAL;

dev_warn().

Quoted 7 lines
drivers/mfd/max77802.c +7 -0
+static void max77802_copy_reg(struct device *dev, struct regmap *regmap,
+			      int from_reg, int to_reg)
+{
+	int val;
+	int ret;
+
+	if (from_reg == to_reg)

drivers/mfd/max77802.c

Quoted 10 lines
drivers/mfd/max77802.c +10 -0
+		return;
+
+	ret = regmap_read(regmap, from_reg, &val);
+	if (!ret)
+		ret = regmap_write(regmap, to_reg, val);
+
+	if (ret)
+		dev_warn(dev, "Copy err %d => %d (%d)\n",
+			 from_reg, to_reg, ret);
+}

Again, this looks like it should be generic.

drivers/mfd/max77802.c

Quoted 4 lines
drivers/mfd/max77802.c +3 -0
+static int max77802_pmic_probe(struct platform_device *pdev)
+{
 
+	dev_dbg(&pdev->dev, "%s\n", __func__);

This isn't adding anything, just remove it - the core already logs probes if you want.

drivers/mfd/max77802.c

Quoted 1 line
drivers/mfd/max77802.c +1 -0
+	config.dev = &pdev->dev;

Are you sure this shouldn't be the MFD?

drivers/mfd/max77802.c

Quoted 8 lines
drivers/mfd/max77802.c +8 -0
+	for (i = 0; i < MAX77802_MAX_REGULATORS; i++) {
+		struct regulator_dev *rdev;
+		int id = pdata->regulators[i].id;
+
+		config.init_data = pdata->regulators[i].initdata;
+		config.of_node = pdata->regulators[i].of_node;
+
+		max77802->opmode[id] = MAX77802_OPMODE_NORMAL;

Why isn't this being read from the hardware, this may lead to a
configuration change the first time we pay attention?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140616/4cc76c61/attachment.sig>

#16 lore raw

Re: [PATCH v2 07/10] regulator: Add driver for Maxim 77802 PMIC regulators

Hello Mark,

Thanks a lot for your feedback.

Quoted 11 lines · Mark Brown
Quoted 9 lines · Javier Martinez Canillas
drivers/mfd/max77802.c +1 -0
@@ -37,6 +37,7 @@
 #include <linux/err.h>
 
 static const struct mfd_cell max77802_devs[] = {
+	{ .name = "max77802-pmic", },
 };
 
Quoted 6 lines

drivers/mfd/max77802.c line 43

Quoted 1 line
drivers/mfd/max77802.c +0 -0
 static bool max77802_pmic_is_accessible_reg(struct device *dev,

Please don't do things like this, it makes it harder to apply your series. Just register all the devices in the MFD when you add the MFD driver.

Ok, I'll do that. After all mfd core just omits the devices that don't match.

Quoted 7 lines

drivers/mfd/max77802.c

Quoted 4 lines
drivers/mfd/max77802.c +4 -0
+	default:
+		pr_warn("%s: regulator_suspend_mode : 0x%x not supported\n",
+			rdev->desc->name, mode);
+		return -EINVAL;

dev_warn().

Ok.

Quoted 11 lines
Quoted 11 lines
drivers/mfd/max77802.c +11 -0
+static void max77802_copy_reg(struct device *dev, struct regmap *regmap,
+			      int from_reg, int to_reg)
+{
+	int val;
+	int ret;
+
+	if (from_reg == to_reg)
+		return;
+
+	ret = regmap_read(regmap, from_reg, &val);
+	if (!ret)
Quoted 9 lines

drivers/mfd/max77802.c

Quoted 6 lines
drivers/mfd/max77802.c +6 -0
+		ret = regmap_write(regmap, to_reg, val);
+
+	if (ret)
+		dev_warn(dev, "Copy err %d => %d (%d)\n",
+			 from_reg, to_reg, ret);
+}

Again, this looks like it should be generic.

Yes, I missed this from your previous feedback, sorry about that.

I'll add a regmap_copy_reg() function to drivers/base/regmap/regmap.c instead.

Quoted 8 lines

drivers/mfd/max77802.c

Quoted 4 lines
drivers/mfd/max77802.c +3 -0
+static int max77802_pmic_probe(struct platform_device *pdev)
+{
 
+	dev_dbg(&pdev->dev, "%s\n", __func__);

This isn't adding anything, just remove it - the core already logs probes if you want.

Ok.

Quoted 4 lines

drivers/mfd/max77802.c

Quoted 1 line
drivers/mfd/max77802.c +1 -0
+	config.dev = &pdev->dev;

Are you sure this shouldn't be the MFD?

I just looked at regulator_register() and saw that it does rdev->dev.parent = dev, so yes this has to be the MFD.

Quoted 12 lines

drivers/mfd/max77802.c

Quoted 8 lines
drivers/mfd/max77802.c +8 -0
+	for (i = 0; i < MAX77802_MAX_REGULATORS; i++) {
+		struct regulator_dev *rdev;
+		int id = pdata->regulators[i].id;
+
+		config.init_data = pdata->regulators[i].initdata;
+		config.of_node = pdata->regulators[i].of_node;
+
+		max77802->opmode[id] = MAX77802_OPMODE_NORMAL;

Why isn't this being read from the hardware, this may lead to a configuration change the first time we pay attention?

The original Chrome OS driver [0] had a "regulator-op-mode" property similar to "op_mode" in Documentation/devicetree/bindings/regulator/s5m8767-regulator.txt to specify the operating mode using DT.

But I removed that since I didn't want to have a specific property for what appears to be a generic need. I wanted to re-post something along the lines of what was discussed in [1] and add operating mode support to the generic regulator code.

So, for now I thought it made sense to set the operating mode to normal on probe() but I'll change it to read from the hardware if that is better.

I guess I should check in the datasheet if a sane default operating mode for LDOs is expected when the chip is reseted or if this is left undefined and also if the bootloader already set this.

Best regards,
Javier

[0]:
https://chromium.googlesource.com/chromiumos/third_party/kernel/+/chromeos-3.8/Documentation/devicetree/bindings/mfd/max77xxx.txt
[1]: https://patchwork.kernel.org/patch/1855331/

maintainer
#17 lore raw

Re: [PATCH v2 07/10] regulator: Add driver for Maxim 77802 PMIC regulators

Quoted 8 lines · Javier Martinez Canillas
Quoted 3 lines · Mark Brown

drivers/regulator/max77802.c line 640

Quoted 1 line
drivers/regulator/max77802.c new file +1 -0
+	config.dev = &pdev->dev;

Are you sure this shouldn't be the MFD?

I just looked at regulator_register() and saw that it does rdev->dev.parent = dev, so yes this has to be the MFD.

Do the regulators manage to get their supplies?

Quoted 2 lines

So, for now I thought it made sense to set the operating mode to normal on probe() but I'll change it to read from the hardware if that is better.

Yes, otherwise if the device is configured otherwise then when we change the configuration we may break something.

Quoted 3 lines

I guess I should check in the datasheet if a sane default operating mode for LDOs is expected when the chip is reseted or if this is left undefined and also if the bootloader already set this.

You can't do anything based on the particular bootloader you're using in
your current system, this has to work in other systems.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140617/62f9e425/attachment-0001.sig>

#18 lore raw

Re: [PATCH v2 07/10] regulator: Add driver for Maxim 77802 PMIC regulators

Hello Mark,

Quoted 10 lines · Mark Brown
Quoted 8 lines · Javier Martinez Canillas
Quoted 3 lines · Mark Brown

drivers/regulator/max77802.c line 640

Quoted 1 line
drivers/regulator/max77802.c new file +1 -0
+	config.dev = &pdev->dev;

Are you sure this shouldn't be the MFD?

I just looked at regulator_register() and saw that it does rdev->dev.parent = dev, so yes this has to be the MFD.

I noticed that many drivers set config.dev = &pdev->dev. The original Chrome OS max77xxx driver and max77686 are two examples but others drivers do the same:

$ git grep "config.dev = &pdev->dev" drivers/regulator/ | wc -l
35
$ git grep "config.dev = pdev->dev.parent" drivers/regulator/ | wc -l
11

And also I see that mfd_add_device() calls devm_regulator_bulk_register_supply_alias(&pdev->dev,...) so I'm confused now about what the correct device should be...

Quoted 2 lines

Do the regulators manage to get their supplies?

There are no current support in mainline for the devices that use the regulators in this PMIC so I can't tell you if consumers manage to get their supplies correctly (e.g: if regulator_dev_lookup succeeds).

But I see in the kernel log that the regulators are registered and configured as expected [0] and also the driver in the Chrome OS 3.8 kernel is working for sure and sets config.dev to &pdev->dev instead of the MFD.

Quoted 6 lines
Quoted 2 lines

So, for now I thought it made sense to set the operating mode to normal on probe() but I'll change it to read from the hardware if that is better.

Yes, otherwise if the device is configured otherwise then when we change the configuration we may break something.

Quoted 7 lines
Quoted 3 lines

I guess I should check in the datasheet if a sane default operating mode for LDOs is expected when the chip is reseted or if this is left undefined and also if the bootloader already set this.

You can't do anything based on the particular bootloader you're using in your current system, this has to work in other systems.

Yes, that's why I thought it was a good idea to set to a default operational mode but I'll change it to read from the hardware instead.

Thanks a lot and best regards,
Javier

[0]: http://pastebin.com/raw.php?i=8yyMXcGD

maintainer
#19 lore raw

Re: [PATCH v2 07/10] regulator: Add driver for Maxim 77802 PMIC regulators

Quoted 7 lines · Javier Martinez Canillas
Quoted 2 lines · Mark Brown
Quoted 2 lines

I just looked at regulator_register() and saw that it does rdev->dev.parent = dev, so yes this has to be the MFD.

I noticed that many drivers set config.dev = &pdev->dev. The original Chrome OS max77xxx driver and max77686 are two examples but others drivers do the same:

Not all drivers are DT drivers that bother specifying supplies.

Quoted 3 lines

And also I see that mfd_add_device() calls devm_regulator_bulk_register_supply_alias(&pdev->dev,...) so I'm confused now about what the correct device should be...

Right, but to do that you need to set those aliases up - have you done so?

Quoted 5 lines
Quoted 1 line

Do the regulators manage to get their supplies?

There are no current support in mainline for the devices that use the regulators in this PMIC so I can't tell you if consumers manage to get their supplies correctly (e.g: if regulator_dev_lookup succeeds).

That's not really relevant here - I'm asking if the regulators get their
own supplies rather than if anything uses them.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140621/3900a496/attachment.sig>

#20 lore raw

Re: [PATCH v2 07/10] regulator: Add driver for Maxim 77802 PMIC regulators

Hello Mark,

Quoted 18 lines · Mark Brown
Quoted 7 lines · Javier Martinez Canillas
Quoted 2 lines · Mark Brown
Quoted 2 lines

I just looked at regulator_register() and saw that it does rdev->dev.parent = dev, so yes this has to be the MFD.

I noticed that many drivers set config.dev = &pdev->dev. The original Chrome OS max77xxx driver and max77686 are two examples but others drivers do the same:

Not all drivers are DT drivers that bother specifying supplies.

Quoted 3 lines

And also I see that mfd_add_device() calls devm_regulator_bulk_register_supply_alias(&pdev->dev,...) so I'm confused now about what the correct device should be...

Right, but to do that you need to set those aliases up - have you done so?

Quoted 9 lines
Quoted 5 lines
Quoted 1 line

Do the regulators manage to get their supplies?

There are no current support in mainline for the devices that use the regulators in this PMIC so I can't tell you if consumers manage to get their supplies correctly (e.g: if regulator_dev_lookup succeeds).

That's not really relevant here - I'm asking if the regulators get their own supplies rather than if anything uses them.

Sorry if I keep misunderstanding your question but the regulators in this PMIC don't have a parent supply/regulator node.

If by own supplies you mean the regulators power outputs (voltage/current constraints), then yes, the regulators manage to get their own voltage output correctly regardless of the value set in config.dev (&pdev->dev or pdev->dev.parent).

I see in regulator_register() that config.dev is used to set the value of struct regulator_dev .dev.parent and that is used in two places in regulator core:

1) In regulator_register() to get the regmap if config->regmap is not set.
2) In regulator_dev_lookup() checks if r->dev.parent is set.

For 1) config.regmap is explicitly set to the MFD regmap in max77802 driver so config.dev is not used in this case and for 2) the value does not matter since it only checks that it's not NULL.

Having said that, when I was preparing v3 of the patch-set I noticed that regulator_register() does:

dev = config->dev;
...
rdev->dev.parent = dev;

So I changed to use MFD device instead of &pdev->dev in the version I posted last week since the MFD device is the regulator parent.

Best regards,
Javier

maintainer
#21 lore raw

Re: [PATCH v2 07/10] regulator: Add driver for Maxim 77802 PMIC regulators

Quoted 7 lines · Javier Martinez Canillas
Quoted 2 lines · Mark Brown

That's not really relevant here - I'm asking if the regulators get their own supplies rather than if anything uses them.

Sorry if I keep misunderstanding your question but the regulators in this PMIC don't have a parent supply/regulator node.

They should, I'm pretty sure the device does actually regulate one
supply into another.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140623/89fb712b/attachment-0001.sig>

#22 lore raw

Re: [PATCH v2 07/10] regulator: Add driver for Maxim 77802 PMIC regulators

Hello Mark,

Quoted 12 lines · Mark Brown
Quoted 7 lines · Javier Martinez Canillas
Quoted 2 lines · Mark Brown

That's not really relevant here - I'm asking if the regulators get their own supplies rather than if anything uses them.

Sorry if I keep misunderstanding your question but the regulators in this PMIC don't have a parent supply/regulator node.

They should, I'm pretty sure the device does actually regulate one supply into another.

Thanks a lot for the clarification. This was not evident to me when I read the PMIC datasheet and because both the max77xxx Chrome OS 3.8 and mainline max77686 drivers used a simplistic model of the power scheme.

But Doug confirmed to me that some regulators on this PMIC do indeed use others regulators as a power supply so I'll change this in the next version of the patch-set.

Best regards,
Javier

#23 lore raw

Re: [PATCH v2 07/10] regulator: Add driver for Maxim 77802 PMIC regulators

In reply to Javier Martinez Canillas
Quoted 19 lines

The MAX77802 PMIC has 10 high-efficiency Buck and 32 Low-dropout (LDO) regulators. This patch adds support for all these regulators found on the MAX77802 PMIC and is based on a driver added by Simon Glass to the Chrome OS kernel 3.8 tree.

---

Changes since v1:
- Remove unneeded check if num_regulators != MAX77802_MAX_REGULATORS.
- Fix .set_suspend_mode handler comment and split regulators ops for regulators that behave differently. Suggested by Mark Brown.
- Use module_platform_driver() instead of having init/exit functions. Suggested by Mark Brown.
- Use the new descriptor-based GPIO interface instead of the deprecated integer based GPIO one. Suggested by Mark Brown.
- Look for "regulators" child node instead of "voltage-regulators" to be consistent with other PMIC drivers. Suggested by Mark Brown.

Quoted 1 line
 drivers/mfd/max77802.c       |   1 +

Can you remove all of the MFD changes from patches 7, 8 and 9 and create new one. That way there's no requirement for any cross subsystem messiness.

Quoted 5 lines
 drivers/regulator/Kconfig    |   9 +
 drivers/regulator/Makefile   |   1 +
 drivers/regulator/max77802.c | 701 +++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 712 insertions(+)
 create mode 100644 drivers/regulator/max77802.c
Signature · 4 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org ? Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
#24 lore raw

Re: [PATCH v2 07/10] regulator: Add driver for Maxim 77802 PMIC regulators

Hello Lee,

Thanks a lot for your feedback.

Quoted 19 lines · Lee Jones
Quoted 19 lines

The MAX77802 PMIC has 10 high-efficiency Buck and 32 Low-dropout (LDO) regulators. This patch adds support for all these regulators found on the MAX77802 PMIC and is based on a driver added by Simon Glass to the Chrome OS kernel 3.8 tree.

---

Changes since v1:
- Remove unneeded check if num_regulators != MAX77802_MAX_REGULATORS.
- Fix .set_suspend_mode handler comment and split regulators ops for regulators that behave differently. Suggested by Mark Brown.
- Use module_platform_driver() instead of having init/exit functions. Suggested by Mark Brown.
- Use the new descriptor-based GPIO interface instead of the deprecated integer based GPIO one. Suggested by Mark Brown.
- Look for "regulators" child node instead of "voltage-regulators" to be consistent with other PMIC drivers. Suggested by Mark Brown.

Quoted 6 lines
Quoted 1 line
 drivers/mfd/max77802.c       |   1 +

Can you remove all of the MFD changes from patches 7, 8 and 9 and create new one. That way there's no requirement for any cross subsystem messiness.

Sure, Mark already suggested the same and I'll do it on the next version.

But there still be some cross-subsystem dependency/messiness since the regulator, clk and rtc drivers include the mfd max77802 headers that are added in Patch 6.

So I guess you should either a) take the whole patch-set through your mfd tree or b) merge the mfd patches and create an immutable branch that can be pulled by Mark, Mike and Alessandro.

I don't know what's the preferred workflow in these cases...

Quoted 6 lines
Quoted 5 lines
 drivers/regulator/Kconfig    |   9 +
 drivers/regulator/Makefile   |   1 +
 drivers/regulator/max77802.c | 701 +++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 712 insertions(+)
 create mode 100644 drivers/regulator/max77802.c

Best regards,
Javier

#25 lore raw

Re: [PATCH v2 07/10] regulator: Add driver for Maxim 77802 PMIC regulators

Quoted 31 lines · Javier Martinez Canillas

Hello Lee,

Thanks a lot for your feedback.

Quoted 19 lines · Lee Jones
Quoted 19 lines

The MAX77802 PMIC has 10 high-efficiency Buck and 32 Low-dropout (LDO) regulators. This patch adds support for all these regulators found on the MAX77802 PMIC and is based on a driver added by Simon Glass to the Chrome OS kernel 3.8 tree.

---

Changes since v1:
- Remove unneeded check if num_regulators != MAX77802_MAX_REGULATORS.
- Fix .set_suspend_mode handler comment and split regulators ops for regulators that behave differently. Suggested by Mark Brown.
- Use module_platform_driver() instead of having init/exit functions. Suggested by Mark Brown.
- Use the new descriptor-based GPIO interface instead of the deprecated integer based GPIO one. Suggested by Mark Brown.
- Look for "regulators" child node instead of "voltage-regulators" to be consistent with other PMIC drivers. Suggested by Mark Brown.

Quoted 6 lines
Quoted 1 line
 drivers/mfd/max77802.c       |   1 +

Can you remove all of the MFD changes from patches 7, 8 and 9 and create new one. That way there's no requirement for any cross subsystem messiness.

Quoted 5 lines

Sure, Mark already suggested the same and I'll do it on the next version.

But there still be some cross-subsystem dependency/messiness since the regulator, clk and rtc drivers include the mfd max77802 headers that are added in Patch 6.

What I should have said was _avoidable_ or _unnecessary_ messiness.

Quoted 5 lines

So I guess you should either a) take the whole patch-set through your mfd tree or b) merge the mfd patches and create an immutable branch that can be pulled by Mark, Mike and Alessandro.

I don't know what's the preferred workflow in these cases...

That's fine. I'm happy to create shared branches when required.

Quoted 9 lines
Quoted 6 lines
Quoted 5 lines
 drivers/regulator/Kconfig    |   9 +
 drivers/regulator/Makefile   |   1 +
 drivers/regulator/max77802.c | 701 +++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 712 insertions(+)
 create mode 100644 drivers/regulator/max77802.c

Best regards,
Javier

Signature · 4 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org ? Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
#26 lore raw

Re: [PATCH v2 07/10] regulator: Add driver for Maxim 77802 PMIC regulators

Quoted 7 lines · On Wed, 18 Jun 2014 15:10:48 +0100 Lee Jones <[email protected]> wrote:
Quoted 5 lines

So I guess you should either a) take the whole patch-set through your mfd tree or b) merge the mfd patches and create an immutable branch that can be pulled by Mark, Mike and Alessandro.

I don't know what's the preferred workflow in these cases...

That's fine. I'm happy to create shared branches when required.

mfd tree will be ok.

Signature · 6 lines
 Best regards,

 Alessandro Zummo,
  Tower Technologies - Torino, Italy

  http://www.towertech.it
#27 lore raw

PATCH v2 8/10 clk: Add driver for Maxim 77802 PMIC clocks

In reply to Javier Martinez Canillas

The MAX77802 PMIC has two 32.768kHz Buffered Clock Outputs with Low Jitter Mode. This patch adds support for these two clocks.

---

Changes since v1:
- Use module_platform_driver() instead of having init/exit functions. Suggested by Mark Brown.
- Use the generic maxim clock driver to reduce code duplication with clk-max77686.c driver.

 .../devicetree/bindings/clock/maxim,max77802.txt   | 42 +++++++++
 drivers/clk/Kconfig                                |  7 ++
 drivers/clk/Makefile                               |  1 +
 drivers/clk/clk-max77802.c                         | 99 ++++++++++++++++++++++
 drivers/mfd/max77802.c                             |  1 +
 include/dt-bindings/clock/maxim,max77802.h         | 22 +++++
 6 files changed, 172 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/maxim,max77802.txt
 create mode 100644 drivers/clk/clk-max77802.c
 create mode 100644 include/dt-bindings/clock/maxim,max77802.h
Documentation/devicetree/bindings/clock/maxim,max77802.txt new file +42 -0
new file mode 100644
index 0000000..b2c2129
@@ -0,0 +1,42 @@
+Binding for Maxim MAX77802 32k clock generator block
+
+This is a part of device tree bindings of MAX77802 multi-function device.
+More information can be found in bindings/mfd/max77802.txt file.
+
+The MAX77802 contains two 32.768khz clock outputs that can be controlled
+(gated/ungated) over I2C.
+
+Following properties should be presend in main device node of the MFD chip.
+
+Required properties:
+
+- #clock-cells: from common clock binding; shall be set to 1.
+
+Each clock is assigned an identifier and client nodes can use this identifier
+to specify the clock which they consume. Following indices are allowed:
+     - 0: 32khz_ap clock,
+     - 1: 32khz_cp clock.
+
+Clocks are defined as preprocessor macros in dt-bindings/clock/maxim,max77802.h
+header and can be used in device tree sources.
+
+Example: Node of the MFD chip
+
+	max77802: max77802 at 09 {
+		compatible = "maxim,max77802";
+		interrupt-parent = <&wakeup_eint>;
+		interrupts = <26 0>;
+		reg = <0x09>;
+		#clock-cells = <1>;
+
+		/* ... */
+	};
+
+Example: Clock consumer node
+
+	foo at 0 {
+		compatible = "bar,foo";
+		/* ... */
+		clock-names = "32khz_ap";
+		clocks = <&max77802 MAX77802_CLK_32K_AP>;
+	};
drivers/clk/Kconfig +7 -0
index 3fd4270..221260b 100644
@@ -42,6 +42,13 @@ config COMMON_CLK_MAX77686
 	---help---
 	  This driver supports Maxim 77686 crystal oscillator clock. 
 
+config COMMON_CLK_MAX77802
+	tristate "Clock driver for Maxim 77802 MFD"
+	depends on MFD_MAX77802
+	select COMMON_CLK_MAX_GEN
+	---help---
+	  This driver supports Maxim 77802 crystal oscillator clock.
+
 config COMMON_CLK_SI5351
 	tristate "Clock driver for SiLabs 5351A/B/C"
 	depends on I2C
drivers/clk/Makefile +1 -0
index 6c1aff6..520ff76 100644
@@ -20,6 +20,7 @@ obj-$(CONFIG_ARCH_HIGHBANK)		+= clk-highbank.o
 obj-$(CONFIG_MACH_LOONGSON1)		+= clk-ls1x.o
 obj-$(CONFIG_COMMON_CLK_MAX_GEN)	+= clk-max-gen.o
 obj-$(CONFIG_COMMON_CLK_MAX77686)	+= clk-max77686.o
+obj-$(CONFIG_COMMON_CLK_MAX77802)	+= clk-max77802.o
 obj-$(CONFIG_ARCH_MOXART)		+= clk-moxart.o
 obj-$(CONFIG_ARCH_NOMADIK)		+= clk-nomadik.o
 obj-$(CONFIG_ARCH_NSPIRE)		+= clk-nspire.o
drivers/clk/clk-max77802.c new file +99 -0

99 lines not on this page · raw message

drivers/mfd/max77802.c +1 -0
index c9dcbab..ae73bb4 100644
@@ -38,6 +38,7 @@
 
 static const struct mfd_cell max77802_devs[] = {
 	{ .name = "max77802-pmic", },
+	{ .name = "max77802-clk", },
 };
 
 static bool max77802_pmic_is_accessible_reg(struct device *dev,
include/dt-bindings/clock/maxim,max77802.h new file +22 -0
new file mode 100644
index 0000000..997312e
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) 2014 Google, Inc
+ *
+ * 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.
+ *
+ * Device Tree binding constants clocks for the Maxim 77802 PMIC.
+ */
+
+#ifndef _DT_BINDINGS_CLOCK_MAXIM_MAX77802_CLOCK_H
+#define _DT_BINDINGS_CLOCK_MAXIM_MAX77802_CLOCK_H
+
+/* Fixed rate clocks. */
+
+#define MAX77802_CLK_32K_AP		0
+#define MAX77802_CLK_32K_CP		1
+
+/* Total number of clocks. */
+#define MAX77802_CLKS_NUM		(MAX77802_CLK_32K_CP + 1)
+
+#endif /* _DT_BINDINGS_CLOCK_MAXIM_MAX77802_CLOCK_H */
Signature · 1 line
2.0.0.rc2
#28 lore raw

PATCH v2 9/10 rtc: Add driver for Maxim 77802 PMIC Real-Time-Clock

In reply to Javier Martinez Canillas

The MAX7802 PMIC has a Real-Time-Clock (RTC) with two alarms. This patch adds support for the RTC and is based on a driver added by Simon Glass to the Chrome OS kernel 3.8 tree.

---
 drivers/mfd/max77802.c     |   1 +
 drivers/rtc/Kconfig        |  10 +
 drivers/rtc/Makefile       |   1 +
 drivers/rtc/rtc-max77802.c | 637 +++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 649 insertions(+)
 create mode 100644 drivers/rtc/rtc-max77802.c
drivers/mfd/max77802.c +1 -0
index ae73bb4..22bb069 100644
@@ -39,6 +39,7 @@
 static const struct mfd_cell max77802_devs[] = {
 	{ .name = "max77802-pmic", },
 	{ .name = "max77802-clk", },
+	{ .name = "max77802-rtc", },
 };
 
 static bool max77802_pmic_is_accessible_reg(struct device *dev,
drivers/rtc/Kconfig +10 -0
index 0754f5c..e0b6495 100644
@@ -288,6 +288,16 @@ config RTC_DRV_MAX77686
 	  This driver can also be built as a module. If so, the module
 	  will be called rtc-max77686.
 
+config RTC_DRV_MAX77802
+	tristate "Maxim MAX77802"
+	depends on MFD_MAX77802
+	help
+	  If you say yes here you will get support for the
+	  RTC of Maxim MAX77802 PMIC.
+
+	  This driver can also be built as a module. If so, the module
+	  will be called rtc-max77802.
+
 config RTC_DRV_RS5C372
 	tristate "Ricoh R2025S/D, RS5C372A/B, RV5C386, RV5C387A"
 	help
drivers/rtc/Makefile +1 -0
index 70347d0..247de78 100644
@@ -81,6 +81,7 @@ obj-$(CONFIG_RTC_DRV_MAX8998)	+= rtc-max8998.o
 obj-$(CONFIG_RTC_DRV_MAX8997)	+= rtc-max8997.o
 obj-$(CONFIG_RTC_DRV_MAX6902)	+= rtc-max6902.o
 obj-$(CONFIG_RTC_DRV_MAX77686)	+= rtc-max77686.o
+obj-$(CONFIG_RTC_DRV_MAX77802)  += rtc-max77802.o
 obj-$(CONFIG_RTC_DRV_MC13XXX)	+= rtc-mc13xxx.o
 obj-$(CONFIG_RTC_DRV_MCP795)	+= rtc-mcp795.o
 obj-$(CONFIG_RTC_DRV_MSM6242)	+= rtc-msm6242.o
drivers/rtc/rtc-max77802.c new file +637 -0

637 lines not on this page · raw message

Signature · 1 line
2.0.0.rc2
#29 lore raw

PATCH v2 10/10 ARM: dts: Add max77802 device node for exynos5420-peach-pit

In reply to Javier Martinez Canillas

Peach pit board uses a Maxim 77802 power management IC to drive regulators and its Real Time Clock. This patch adds support for this chip.

These are the device nodes and pinctrl configuration that is present on the Peach pit DeviceTree source file in the the Chrome OS kernel 3.8 tree.

---

Changes since v1:
- Use "regulators" for child node instead of "voltage-regulators" to be consistent with other PMIC. Suggested by Mark Brown.
- Use regulators node names instead of the deprecated "regulator-compatible" property. Suggested by Mark Brown.

 arch/arm/boot/dts/exynos5420-peach-pit.dts | 320 +++++++++++++++++++++++++++++
 1 file changed, 320 insertions(+)
arch/arm/boot/dts/exynos5420-peach-pit.dts +320 -0
index 1c5b8f9..e6dc972 100644
@@ -111,6 +111,13 @@
 		samsung,pin-drv = <0>;
 	};
 
+	max77802_irq: max77802-irq {
+		samsung,pins = "gpx3-1";
+		samsung,pin-function = <0>;
+		samsung,pin-pud = <0>;
+		samsung,pin-drv = <0>;
+	};
+
 	hdmi_hpd_irq: hdmi-hpd-irq {
 		samsung,pins = "gpx3-7";
 		samsung,pin-function = <0>;
@@ -124,6 +131,29 @@
 		samsung,pin-pud = <3>;
 		samsung,pin-drv = <0>;
 	};
+
+	pmic_dvs_1: pmic-dvs-1 {
+		samsung,pins = "gpy7-6";
+		samsung,pin-function = <1>;
+		samsung,pin-pud = <0>;
+		samsung,pin-drv = <0>;
+	};
+};
+
+&pinctrl_2 {
+	pmic_dvs_2: pmic-dvs-2 {
+		samsung,pins = "gpj4-2";
+		samsung,pin-function = <1>;
+		samsung,pin-pud = <0>;
+		samsung,pin-drv = <0>;
+	};
+
+	pmic_dvs_3: pmic-dvs-3 {
+		samsung,pins = "gpj4-3";
+		samsung,pin-function = <1>;
+		samsung,pin-pud = <0>;
+		samsung,pin-drv = <0>;
+	};
 };
 
 &pinctrl_3 {
@@ -140,6 +170,14 @@
 		samsung,pin-pud = <0>;
 		samsung,pin-drv = <0>;
 	};
+
+	pmic_selb: pmic-selb {
+		samsung,pins = "gph0-2", "gph0-3", "gph0-4", "gph0-5",
+			       "gph0-6";
+		samsung,pin-function = <1>;
+		samsung,pin-pud = <0>;
+		samsung,pin-drv = <0>;
+	};
 };
 
 &rtc {
@@ -189,6 +227,288 @@
 	};
 };
 
+&hsi2c_4 {
+	status = "okay";
+	clock-frequency = <400000>;
+
+	max77802-pmic at 9 {
+		compatible = "maxim,max77802";
+		interrupt-parent = <&gpx3>;
+		interrupts = <1 0>;
+		pinctrl-names = "default";
+		pinctrl-0 = <&max77802_irq>, <&pmic_selb>,
+			    <&pmic_dvs_1>, <&pmic_dvs_2>, <&pmic_dvs_3>;
+		wakeup-source;
+		reg = <0x9>;
+		#clock-cells = <1>;
+
+		/* Using idx 1 means warm reset will get good voltage */
+		max77802,pmic-buck-default-dvs-idx = <1>;
+		max77802,pmic-buck-dvs-gpios = <&gpy7 6 0>,
+					       <&gpj4 2 0>,
+					       <&gpj4 3 0>;
+		max77802,pmic-buck-selb-gpios = <&gph0 2 0>,
+						<&gph0 3 0>,
+						<&gph0 4 0>,
+						<&gph0 5 0>,
+						<&gph0 6 0>;
+
+		regulators {
+			ldo1_reg: LDO1 {
+				regulator-name = "vdd_1v0";
+				regulator-min-microvolt = <1000000>;
+				regulator-max-microvolt = <1000000>;
+				regulator-always-on;
+			};
+			ldo2_reg: LDO2 {
+				regulator-name = "vdd_1v2_2";
+				regulator-min-microvolt = <1200000>;
+				regulator-max-microvolt = <1200000>;
+			};
+			ldo3_reg: LDO3 {
+				regulator-name = "vdd_1v8_3";
+				regulator-min-microvolt = <1800000>;
+				regulator-max-microvolt = <1800000>;
+				regulator-always-on;
+			};
+			vqmmc_sdcard: ldo4_reg: LDO4 {
+				regulator-name = "vdd_sd";
+				regulator-min-microvolt = <1800000>;
+				regulator-max-microvolt = <2800000>;
+				regulator-always-on;
+			};
+			ldo5_reg: LDO5 {
+				regulator-name = "vdd_1v8_5";
+				regulator-min-microvolt = <1800000>;
+				regulator-max-microvolt = <1800000>;
+				regulator-always-on;
+			};
+			ldo6_reg: LDO6 {
+				regulator-name = "vdd_1v8_6";
+				regulator-min-microvolt = <1800000>;
+				regulator-max-microvolt = <1800000>;
+				regulator-always-on;
+			};
+			ldo7_reg: LDO7 {
+				regulator-name = "vdd_1v8_7";
+				regulator-min-microvolt = <1800000>;
+				regulator-max-microvolt = <1800000>;
+			};
+			ldo8_reg: LDO8 {
+				regulator-name = "vdd_ldo8";
+				regulator-min-microvolt = <1000000>;
+				regulator-max-microvolt = <1000000>;
+				regulator-always-on;
+			};
+			ldo9_reg: LDO9 {
+				regulator-name = "vdd_ldo9";
+				regulator-min-microvolt = <1800000>;
+				regulator-max-microvolt = <1800000>;
+				regulator-always-on;
+			};
+			ldo10_reg: LDO10 {
+				regulator-name = "vdd_ldo10";
+				regulator-min-microvolt = <1800000>;
+				regulator-max-microvolt = <1800000>;
+				regulator-always-on;
+			};
+			ldo11_reg: LDO11 {
+				regulator-name = "vdd_ldo11";
+				regulator-min-microvolt = <1800000>;
+				regulator-max-microvolt = <1800000>;
+				regulator-always-on;
+			};
+			ldo12_reg: LDO12 {
+				regulator-name = "vdd_ldo12";
+				regulator-min-microvolt = <3000000>;
+				regulator-max-microvolt = <3000000>;
+				regulator-always-on;
+			};
+			ldo13_reg: LDO13 {
+				regulator-name = "vdd_ldo13";
+				regulator-min-microvolt = <1800000>;
+				regulator-max-microvolt = <1800000>;
+				regulator-always-on;
+			};
+			ldo14_reg: LDO14 {
+				regulator-name = "vdd_ldo14";
+				regulator-min-microvolt = <1800000>;
+				regulator-max-microvolt = <1800000>;
+				regulator-always-on;
+			};
+			ldo15_reg: LDO15 {
+				regulator-name = "vdd_ldo15";
+				regulator-min-microvolt = <1000000>;
+				regulator-max-microvolt = <1000000>;
+				regulator-always-on;
+			};
+			ldo17_reg: LDO17 {
+				regulator-name = "vdd_g3ds";
+				regulator-min-microvolt = <900000>;
+				regulator-max-microvolt = <1400000>;
+				regulator-always-on;
+			};
+			ldo18_reg: LDO18 {
+				regulator-name = "ldo_18";
+				regulator-min-microvolt = <1800000>;
+				regulator-max-microvolt = <1800000>;
+			};
+			ldo19_reg: LDO19 {
+				regulator-name = "ldo_19";
+				regulator-min-microvolt = <1800000>;
+				regulator-max-microvolt = <1800000>;
+			};
+			ldo20_reg: LDO20 {
+				regulator-name = "ldo_20";
+				regulator-min-microvolt = <1800000>;
+				regulator-max-microvolt = <1800000>;
+				regulator-always-on;
+			};
+			ldo21_reg: LDO21 {
+				regulator-name = "ldo_21";
+				regulator-min-microvolt = <2800000>;
+				regulator-max-microvolt = <2800000>;
+			};
+			ldo23_reg: LDO23 {
+				regulator-name = "ld0_23";
+				regulator-min-microvolt = <3300000>;
+				regulator-max-microvolt = <3300000>;
+			};
+			ldo24_reg: LDO24 {
+				regulator-name = "ldo_24";
+				regulator-min-microvolt = <2800000>;
+				regulator-max-microvolt = <2800000>;
+			};
+			ldo25_reg: LDO25 {
+				regulator-name = "ldo_25";
+				regulator-min-microvolt = <3300000>;
+				regulator-max-microvolt = <3300000>;
+			};
+			ldo26_reg: LDO26 {
+				regulator-name = "ldo_26";
+				regulator-min-microvolt = <1200000>;
+				regulator-max-microvolt = <1200000>;
+			};
+			ldo27_reg: LDO27 {
+				regulator-name = "ldo_27";
+				regulator-min-microvolt = <1200000>;
+				regulator-max-microvolt = <1200000>;
+			};
+			ldo28_reg: LDO28 {
+				regulator-name = "ldo_28";
+				regulator-min-microvolt = <1800000>;
+				regulator-max-microvolt = <1800000>;
+			};
+			ldo29_reg: LDO29 {
+				regulator-name = "ldo_29";
+				regulator-min-microvolt = <1800000>;
+				regulator-max-microvolt = <1800000>;
+			};
+			ldo30_reg: LDO30 {
+				regulator-name = "vdd_mifs";
+				regulator-min-microvolt = <1000000>;
+				regulator-max-microvolt = <1000000>;
+				regulator-always-on;
+			};
+			ldo32_reg: LDO32 {
+				regulator-name = "ldo_32";
+				regulator-min-microvolt = <3000000>;
+				regulator-max-microvolt = <3000000>;
+			};
+			ldo33_reg: LDO33 {
+				regulator-name = "ldo_33";
+				regulator-min-microvolt = <2800000>;
+				regulator-max-microvolt = <2800000>;
+			};
+			ldo34_reg: LDO34 {
+				regulator-name = "ldo_34";
+				regulator-min-microvolt = <3000000>;
+				regulator-max-microvolt = <3000000>;
+			};
+			ldo35_reg: LDO35 {
+				regulator-name = "ldo_35";
+				regulator-min-microvolt = <1200000>;
+				regulator-max-microvolt = <1200000>;
+			};
+			buck1_reg: BUCK1 {
+				regulator-name = "vdd_mif";
+				regulator-min-microvolt = <800000>;
+				regulator-max-microvolt = <1300000>;
+				regulator-always-on;
+				regulator-boot-on;
+				regulator-ramp-delay = <12500>;
+			};
+			buck2_reg: BUCK2 {
+				regulator-name = "vdd_arm_real";
+				regulator-min-microvolt = <800000>;
+				regulator-max-microvolt = <1500000>;
+				regulator-always-on;
+				regulator-boot-on;
+				regulator-ramp-delay = <12500>;
+			};
+			buck3_reg: BUCK3 {
+				regulator-name = "vdd_int_real";
+				regulator-min-microvolt = <800000>;
+				regulator-max-microvolt = <1400000>;
+				regulator-always-on;
+				regulator-boot-on;
+				regulator-ramp-delay = <12500>;
+			};
+			buck4_reg: BUCK4 {
+				regulator-name = "vdd_g3d";
+				regulator-min-microvolt = <700000>;
+				regulator-max-microvolt = <1400000>;
+				regulator-always-on;
+				regulator-boot-on;
+				regulator-ramp-delay = <12500>;
+			};
+			buck5_reg: BUCK5 {
+				regulator-name = "vdd_1v2";
+				regulator-min-microvolt = <1200000>;
+				regulator-max-microvolt = <1200000>;
+				regulator-always-on;
+				regulator-boot-on;
+			};
+			buck6_reg: BUCK6 {
+				regulator-name = "vdd_kfc";
+				regulator-min-microvolt = <800000>;
+				regulator-max-microvolt = <1500000>;
+				regulator-always-on;
+				regulator-boot-on;
+				regulator-ramp-delay = <12500>;
+			};
+			buck7_reg: BUCK7 {
+				regulator-name = "vdd_1v35";
+				regulator-min-microvolt = <1350000>;
+				regulator-max-microvolt = <1350000>;
+				regulator-always-on;
+				regulator-boot-on;
+			};
+			buck8_reg: BUCK8 {
+				regulator-name = "vdd_emmc";
+				regulator-min-microvolt = <2850000>;
+				regulator-max-microvolt = <2850000>;
+				regulator-always-on;
+				regulator-boot-on;
+			};
+			buck9_reg: BUCK9 {
+				regulator-name = "vdd_2v";
+				regulator-min-microvolt = <2000000>;
+				regulator-max-microvolt = <2000000>;
+				regulator-always-on;
+				regulator-boot-on;
+			};
+			buck10_reg: BUCK10 {
+				regulator-name = "vdd_1v8";
+				regulator-min-microvolt = <1800000>;
+				regulator-max-microvolt = <1800000>;
+				regulator-always-on;
+				regulator-boot-on;
+			};
+		};
+	};
+};
+
 &hsi2c_7 {
 	status = "okay";
 
Signature · 1 line
2.0.0.rc2