Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1395658 > unrolled thread
| Started by | Krzysztof Kozlowski <k.kozlowski@samsung.com> |
|---|---|
| First post | 2016-05-06 09:30 +0200 |
| Last post | 2016-05-09 09:40 +0200 |
| Articles | 15 — 6 participants |
Back to article view | Back to linux.kernel
[PATCH v6 0/9] mfd: max8997: Add regmap support Krzysztof Kozlowski <k.kozlowski@samsung.com> - 2016-05-06 09:30 +0200
[PATCH v6 1/9] input: max8997-haptic: Fix NULL pointer dereference Krzysztof Kozlowski <k.kozlowski@samsung.com> - 2016-05-06 09:30 +0200
[PATCH v6 4/9] mfd: max8997: Change irq names to upper case Krzysztof Kozlowski <k.kozlowski@samsung.com> - 2016-05-06 09:30 +0200
[PATCH v6 8/9] ARM: dts: exynos: Fix regulator name to avoid forbidden character on exynos4210-trats Krzysztof Kozlowski <k.kozlowski@samsung.com> - 2016-05-06 09:30 +0200
[PATCH v6 3/9] mfd: max8997: handle IRQs using regmap Krzysztof Kozlowski <k.kozlowski@samsung.com> - 2016-05-06 09:30 +0200
[PATCH v6 6/9] rtc: max8997: Check for ERRNO of regmap_irq_get_virq() Krzysztof Kozlowski <k.kozlowski@samsung.com> - 2016-05-06 09:30 +0200
Re: [PATCH v6 6/9] rtc: max8997: Check for ERRNO of regmap_irq_get_virq() Alexandre Belloni <alexandre.belloni@free-electrons.com> - 2016-05-07 08:50 +0200
[PATCH v6 9/9] ARM: dts: exynos: Add interrupt line to MAX8997 PMIC on exynos4210-trats Krzysztof Kozlowski <k.kozlowski@samsung.com> - 2016-05-06 09:30 +0200
[PATCH v6 5/9] extcon: max8997: Fix handling error code of regmap_irq_get_virq() Krzysztof Kozlowski <k.kozlowski@samsung.com> - 2016-05-06 09:30 +0200
Re: [PATCH v6 5/9] extcon: max8997: Fix handling error code of regmap_irq_get_virq() Chanwoo Choi <cw00.choi@samsung.com> - 2016-05-10 03:30 +0200
[PATCH v6 7/9] extcon: max8997: Fix inconsistent indenting Krzysztof Kozlowski <k.kozlowski@samsung.com> - 2016-05-06 09:40 +0200
Re: [PATCH v6 7/9] extcon: max8997: Fix inconsistent indenting Chanwoo Choi <cw00.choi@samsung.com> - 2016-05-10 03:30 +0200
Re: [PATCH v6 2/9] mfd: max8997: Use regmap to access registers Jacek Anaszewski <j.anaszewski@samsung.com> - 2016-05-06 10:10 +0200
Re: [PATCH v6 1/9] input: max8997-haptic: Fix NULL pointer dereference Dmitry Torokhov <dmitry.torokhov@gmail.com> - 2016-05-09 18:40 +0200
Re: [PATCH v6 0/9] mfd: max8997: Add regmap support Lee Jones <lee.jones@linaro.org> - 2016-05-09 09:40 +0200
| From | Krzysztof Kozlowski <k.kozlowski@samsung.com> |
|---|---|
| Date | 2016-05-06 09:30 +0200 |
| Subject | [PATCH v6 0/9] mfd: max8997: Add regmap support |
| Message-ID | <rvIn0-P0-19@gated-at.bofh.it> |
Hi,
This is a rebase and extension of old Robert Baldyga's work. [0]
Robert no longer works in Samsung.
From the original cover letter:
"This patchset modifies max8997 driver and associated function drivers to use
register maps instead of operating directly on i2c bus. This change allowed
to simplify irq handling, and to move some initializations to individual
function drivers. Hence now when some functions are not enabled, their i2c
clients, regmaps and irqs are not registered."
My changes (since Robert's v5)
==============================
1. Rebase on v4.6-rc6.
2. Collect more acks.
3. Add few fixes:
a. Haptic fix from Marek,
b. Extcon and RTC fix from me,
c. DTS fixes from Marek.
DTS changes are independent but rest of them (extcon/input/MFD) rely
on each other.
One way of merging would be to pick everything (except DTS) through
one tree. Or use tags.
Best regards,
Krzysztof
[0] http://lkml.iu.edu/hypermail//linux/kernel/1411.1/03152.html
Krzysztof Kozlowski (3):
extcon: max8997: Fix handling error code of regmap_irq_get_virq()
rtc: max8997: Check for ERRNO of regmap_irq_get_virq()
extcon: max8997: Fix inconsistent indenting
Marek Szyprowski (3):
input: max8997-haptic: Fix NULL pointer dereference
ARM: dts: exynos: Fix regulator name to avoid forbidden character on
exynos4210-trats
ARM: dts: exynos: Add interrupt line to MAX8997 PMIC on
exynos4210-trats
Robert Baldyga (3):
mfd: max8997: Use regmap to access registers
mfd: max8997: handle IRQs using regmap
mfd: max8997: Change irq names to upper case
arch/arm/boot/dts/exynos4210-trats.dts | 4 +-
drivers/extcon/extcon-max8997.c | 72 ++++---
drivers/input/misc/max8997_haptic.c | 40 ++--
drivers/leds/leds-max8997.c | 13 +-
drivers/mfd/Kconfig | 3 +-
drivers/mfd/Makefile | 2 +-
drivers/mfd/max8997-irq.c | 383 ---------------------------------
drivers/mfd/max8997.c | 245 ++++++++++++++-------
drivers/power/max8997_charger.c | 33 +--
drivers/regulator/max8997.c | 87 ++++----
drivers/rtc/rtc-max8997.c | 60 +++---
include/linux/mfd/max8997-private.h | 82 +++++--
12 files changed, 392 insertions(+), 632 deletions(-)
delete mode 100644 drivers/mfd/max8997-irq.c
--
1.9.1
[toc] | [next] | [standalone]
| From | Krzysztof Kozlowski <k.kozlowski@samsung.com> |
|---|---|
| Date | 2016-05-06 09:30 +0200 |
| Subject | [PATCH v6 1/9] input: max8997-haptic: Fix NULL pointer dereference |
| Message-ID | <rvImZ-P0-7@gated-at.bofh.it> |
| In reply to | #1395658 |
From: Marek Szyprowski <m.szyprowski@samsung.com>
NULL pointer derefence happens when booting with DTB because the
platform data for haptic device is not set in supplied data from parent
MFD device.
The MFD device creates only platform data (from Device Tree) for itself,
not for haptic child.
Unable to handle kernel NULL pointer dereference at virtual address 0000009c
pgd = c0004000
[0000009c] *pgd=00000000
Internal error: Oops: 5 [#1] PREEMPT SMP ARM
(max8997_haptic_probe) from [<c03f9cec>] (platform_drv_probe+0x4c/0xb0)
(platform_drv_probe) from [<c03f8440>] (driver_probe_device+0x214/0x2c0)
(driver_probe_device) from [<c03f8598>] (__driver_attach+0xac/0xb0)
(__driver_attach) from [<c03f67ac>] (bus_for_each_dev+0x68/0x9c)
(bus_for_each_dev) from [<c03f7a38>] (bus_add_driver+0x1a0/0x218)
(bus_add_driver) from [<c03f8db0>] (driver_register+0x78/0xf8)
(driver_register) from [<c0101774>] (do_one_initcall+0x90/0x1d8)
(do_one_initcall) from [<c0a00dbc>] (kernel_init_freeable+0x15c/0x1fc)
(kernel_init_freeable) from [<c06bb5b4>] (kernel_init+0x8/0x114)
(kernel_init) from [<c0107938>] (ret_from_fork+0x14/0x3c)
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Cc: <stable@vger.kernel.org>
Fixes: 104594b01ce7 ("Input: add driver support for MAX8997-haptic")
[k.kozlowski: Write commit message, add CC-stable]
Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
---
drivers/input/misc/max8997_haptic.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/input/misc/max8997_haptic.c b/drivers/input/misc/max8997_haptic.c
index a806ba3818f7..8d6326d7e7be 100644
--- a/drivers/input/misc/max8997_haptic.c
+++ b/drivers/input/misc/max8997_haptic.c
@@ -255,12 +255,14 @@ static int max8997_haptic_probe(struct platform_device *pdev)
struct max8997_dev *iodev = dev_get_drvdata(pdev->dev.parent);
const struct max8997_platform_data *pdata =
dev_get_platdata(iodev->dev);
- const struct max8997_haptic_platform_data *haptic_pdata =
- pdata->haptic_pdata;
+ const struct max8997_haptic_platform_data *haptic_pdata = NULL;
struct max8997_haptic *chip;
struct input_dev *input_dev;
int error;
+ if (pdata)
+ haptic_pdata = pdata->haptic_pdata;
+
if (!haptic_pdata) {
dev_err(&pdev->dev, "no haptic platform data\n");
return -EINVAL;
--
1.9.1
[toc] | [prev] | [next] | [standalone]
| From | Krzysztof Kozlowski <k.kozlowski@samsung.com> |
|---|---|
| Date | 2016-05-06 09:30 +0200 |
| Subject | [PATCH v6 4/9] mfd: max8997: Change irq names to upper case |
| Message-ID | <rvIn0-P0-21@gated-at.bofh.it> |
| In reply to | #1395662 |
From: Robert Baldyga <r.baldyga@samsung.com>
This patch changes naming convention of MUIC interrupts form CamelCase
to upper case. It makes names more readable and consistent with another
interrupt names in max8997 driver.
Signed-off-by: Robert Baldyga <r.baldyga@samsung.com>
Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
[For the mfd part]
Acked-by: Lee Jones <lee.jones@linaro.org>
Acked-by: Chanwoo Choi <cw00.choi@samsung.com>
Acked-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
[k.kozlowski: Collect acks, rebase on v4.6-rc6]
Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
---
drivers/extcon/extcon-max8997.c | 32 ++++++++++++++++----------------
include/linux/mfd/max8997-private.h | 16 ++++++++--------
2 files changed, 24 insertions(+), 24 deletions(-)
diff --git a/drivers/extcon/extcon-max8997.c b/drivers/extcon/extcon-max8997.c
index 9d27cc23038f..68754ac2c8ea 100644
--- a/drivers/extcon/extcon-max8997.c
+++ b/drivers/extcon/extcon-max8997.c
@@ -46,15 +46,15 @@ struct max8997_muic_irq {
};
static struct max8997_muic_irq muic_irqs[] = {
- { MAX8997_MUICIRQ_ADCError, "muic-ADCERROR" },
- { MAX8997_MUICIRQ_ADCLow, "muic-ADCLOW" },
- { MAX8997_MUICIRQ_ADC, "muic-ADC" },
- { MAX8997_MUICIRQ_VBVolt, "muic-VBVOLT" },
- { MAX8997_MUICIRQ_DBChg, "muic-DBCHG" },
- { MAX8997_MUICIRQ_DCDTmr, "muic-DCDTMR" },
- { MAX8997_MUICIRQ_ChgDetRun, "muic-CHGDETRUN" },
- { MAX8997_MUICIRQ_ChgTyp, "muic-CHGTYP" },
- { MAX8997_MUICIRQ_OVP, "muic-OVP" },
+ { MAX8997_MUICIRQ_ADCERROR, "MUIC-ADCERROR" },
+ { MAX8997_MUICIRQ_ADCLOW, "MUIC-ADCLOW" },
+ { MAX8997_MUICIRQ_ADC, "MUIC-ADC" },
+ { MAX8997_MUICIRQ_VBVOLT, "MUIC-VBVOLT" },
+ { MAX8997_MUICIRQ_DBCHG, "MUIC-DBCHG" },
+ { MAX8997_MUICIRQ_DCDTMR, "MUIC-DCDTMR" },
+ { MAX8997_MUICIRQ_CHGDETRUN, "MUIC-CHGDETRUN" },
+ { MAX8997_MUICIRQ_CHGTYP, "MUIC-CHGTYP" },
+ { MAX8997_MUICIRQ_OVP, "MUIC-OVP" },
};
/* Define supported cable type */
@@ -540,17 +540,17 @@ static void max8997_muic_irq_work(struct work_struct *work)
}
switch (irq_type) {
- case MAX8997_MUICIRQ_ADCError:
- case MAX8997_MUICIRQ_ADCLow:
+ case MAX8997_MUICIRQ_ADCERROR:
+ case MAX8997_MUICIRQ_ADCLOW:
case MAX8997_MUICIRQ_ADC:
/* Handle all of cable except for charger cable */
ret = max8997_muic_adc_handler(info);
break;
- case MAX8997_MUICIRQ_VBVolt:
- case MAX8997_MUICIRQ_DBChg:
- case MAX8997_MUICIRQ_DCDTmr:
- case MAX8997_MUICIRQ_ChgDetRun:
- case MAX8997_MUICIRQ_ChgTyp:
+ case MAX8997_MUICIRQ_VBVOLT:
+ case MAX8997_MUICIRQ_DBCHG:
+ case MAX8997_MUICIRQ_DCDTMR:
+ case MAX8997_MUICIRQ_CHGDETRUN:
+ case MAX8997_MUICIRQ_CHGTYP:
/* Handle charger cable */
ret = max8997_muic_chg_handler(info);
break;
diff --git a/include/linux/mfd/max8997-private.h b/include/linux/mfd/max8997-private.h
index f42ea222988f..2817fa69383e 100644
--- a/include/linux/mfd/max8997-private.h
+++ b/include/linux/mfd/max8997-private.h
@@ -411,14 +411,14 @@ enum max8997_irq {
enum max8997_irq_muic {
MAX8997_MUICIRQ_ADC,
- MAX8997_MUICIRQ_ADCLow,
- MAX8997_MUICIRQ_ADCError,
-
- MAX8997_MUICIRQ_ChgTyp,
- MAX8997_MUICIRQ_ChgDetRun,
- MAX8997_MUICIRQ_DCDTmr,
- MAX8997_MUICIRQ_DBChg,
- MAX8997_MUICIRQ_VBVolt,
+ MAX8997_MUICIRQ_ADCLOW,
+ MAX8997_MUICIRQ_ADCERROR,
+
+ MAX8997_MUICIRQ_CHGTYP,
+ MAX8997_MUICIRQ_CHGDETRUN,
+ MAX8997_MUICIRQ_DCDTMR,
+ MAX8997_MUICIRQ_DBCHG,
+ MAX8997_MUICIRQ_VBVOLT,
MAX8997_MUICIRQ_OVP,
--
1.9.1
[toc] | [prev] | [next] | [standalone]
| From | Krzysztof Kozlowski <k.kozlowski@samsung.com> |
|---|---|
| Date | 2016-05-06 09:30 +0200 |
| Subject | [PATCH v6 8/9] ARM: dts: exynos: Fix regulator name to avoid forbidden character on exynos4210-trats |
| Message-ID | <rvIn0-P0-25@gated-at.bofh.it> |
| In reply to | #1395662 |
From: Marek Szyprowski <m.szyprowski@samsung.com>
The usage of slash character causes failure when creating regulator
debugfs entry.
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
[k.kozlowski: Write commit message]
Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
---
arch/arm/boot/dts/exynos4210-trats.dts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/arm/boot/dts/exynos4210-trats.dts b/arch/arm/boot/dts/exynos4210-trats.dts
index 1df2f0bc1d76..fed5847410d3 100644
--- a/arch/arm/boot/dts/exynos4210-trats.dts
+++ b/arch/arm/boot/dts/exynos4210-trats.dts
@@ -359,7 +359,7 @@
};
vusbdac_reg: LDO8 {
- regulator-name = "VUSB/VDAC_3.3V_C210";
+ regulator-name = "VUSB+VDAC_3.3V_C210";
regulator-min-microvolt = <3300000>;
regulator-max-microvolt = <3300000>;
};
--
1.9.1
[toc] | [prev] | [next] | [standalone]
| From | Krzysztof Kozlowski <k.kozlowski@samsung.com> |
|---|---|
| Date | 2016-05-06 09:30 +0200 |
| Subject | [PATCH v6 3/9] mfd: max8997: handle IRQs using regmap |
| Message-ID | <rvIn0-P0-27@gated-at.bofh.it> |
| In reply to | #1395662 |
From: Robert Baldyga <r.baldyga@samsung.com>
This patch modifies mfd driver to use regmap for handling interrupts.
It allows to simplify irq handling process. This modifications needed
to make small changes in function drivers, which use interrupts.
Signed-off-by: Robert Baldyga <r.baldyga@samsung.com>
Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
[For extcon part]
Acked-by: Chanwoo Choi <cw00.choi@samsung.com>
[For the mfd part]
Acked-by: Lee Jones <lee.jones@linaro.org>
Acked-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
[k.kozlowski: Collect acks, rebase on v4.6-rc6]
Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
---
drivers/extcon/extcon-max8997.c | 3 +-
drivers/mfd/Kconfig | 2 +-
drivers/mfd/Makefile | 2 +-
drivers/mfd/max8997-irq.c | 369 ------------------------------------
drivers/mfd/max8997.c | 112 ++++++++++-
drivers/rtc/rtc-max8997.c | 2 +-
include/linux/mfd/max8997-private.h | 63 +++++-
7 files changed, 165 insertions(+), 388 deletions(-)
delete mode 100644 drivers/mfd/max8997-irq.c
diff --git a/drivers/extcon/extcon-max8997.c b/drivers/extcon/extcon-max8997.c
index fc812257bfc7..9d27cc23038f 100644
--- a/drivers/extcon/extcon-max8997.c
+++ b/drivers/extcon/extcon-max8997.c
@@ -662,7 +662,8 @@ static int max8997_muic_probe(struct platform_device *pdev)
struct max8997_muic_irq *muic_irq = &muic_irqs[i];
unsigned int virq = 0;
- virq = irq_create_mapping(max8997->irq_domain, muic_irq->irq);
+ virq = regmap_irq_get_virq(max8997->irq_data_muic,
+ muic_irq->irq);
if (!virq) {
ret = -EINVAL;
goto err_irq;
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 40eae54ba663..49b7838dac76 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -597,7 +597,7 @@ config MFD_MAX8997
depends on I2C=y
select MFD_CORE
select REGMAP_I2C
- select IRQ_DOMAIN
+ select REGMAP_IRQ
help
Say yes here to add support for Maxim Semiconductor MAX8997/8966.
This is a Power Management IC with RTC, Flash, Fuel Gauge, Haptic,
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 5eaa6465d0a6..85d8ce19789f 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -134,7 +134,7 @@ obj-$(CONFIG_MFD_MAX77843) += max77843.o
obj-$(CONFIG_MFD_MAX8907) += max8907.o
max8925-objs := max8925-core.o max8925-i2c.o
obj-$(CONFIG_MFD_MAX8925) += max8925.o
-obj-$(CONFIG_MFD_MAX8997) += max8997.o max8997-irq.o
+obj-$(CONFIG_MFD_MAX8997) += max8997.o
obj-$(CONFIG_MFD_MAX8998) += max8998.o max8998-irq.o
pcf50633-objs := pcf50633-core.o pcf50633-irq.o
diff --git a/drivers/mfd/max8997-irq.c b/drivers/mfd/max8997-irq.c
deleted file mode 100644
index 6ab5f955c510..000000000000
--- a/drivers/mfd/max8997-irq.c
+++ /dev/null
@@ -1,369 +0,0 @@
-/*
- * max8997-irq.c - Interrupt controller support for MAX8997
- *
- * Copyright (C) 2011 Samsung Electronics Co.Ltd
- * MyungJoo Ham <myungjoo.ham@samsung.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; 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 max8998-irq.c
- */
-
-#include <linux/err.h>
-#include <linux/irq.h>
-#include <linux/interrupt.h>
-#include <linux/mfd/max8997.h>
-#include <linux/mfd/max8997-private.h>
-#include <linux/regmap.h>
-
-static const u8 max8997_mask_reg[] = {
- [PMIC_INT1] = MAX8997_REG_INT1MSK,
- [PMIC_INT2] = MAX8997_REG_INT2MSK,
- [PMIC_INT3] = MAX8997_REG_INT3MSK,
- [PMIC_INT4] = MAX8997_REG_INT4MSK,
- [FUEL_GAUGE] = MAX8997_REG_INVALID,
- [MUIC_INT1] = MAX8997_MUIC_REG_INTMASK1,
- [MUIC_INT2] = MAX8997_MUIC_REG_INTMASK2,
- [MUIC_INT3] = MAX8997_MUIC_REG_INTMASK3,
- [GPIO_LOW] = MAX8997_REG_INVALID,
- [GPIO_HI] = MAX8997_REG_INVALID,
- [FLASH_STATUS] = MAX8997_REG_INVALID,
-};
-
-struct max8997_irq_data {
- int mask;
- enum max8997_irq_source group;
-};
-
-#define DECLARE_IRQ(idx, _group, _mask) \
- [(idx)] = { .group = (_group), .mask = (_mask) }
-static const struct max8997_irq_data max8997_irqs[] = {
- DECLARE_IRQ(MAX8997_PMICIRQ_PWRONR, PMIC_INT1, 1 << 0),
- DECLARE_IRQ(MAX8997_PMICIRQ_PWRONF, PMIC_INT1, 1 << 1),
- DECLARE_IRQ(MAX8997_PMICIRQ_PWRON1SEC, PMIC_INT1, 1 << 3),
- DECLARE_IRQ(MAX8997_PMICIRQ_JIGONR, PMIC_INT1, 1 << 4),
- DECLARE_IRQ(MAX8997_PMICIRQ_JIGONF, PMIC_INT1, 1 << 5),
- DECLARE_IRQ(MAX8997_PMICIRQ_LOWBAT2, PMIC_INT1, 1 << 6),
- DECLARE_IRQ(MAX8997_PMICIRQ_LOWBAT1, PMIC_INT1, 1 << 7),
-
- DECLARE_IRQ(MAX8997_PMICIRQ_JIGR, PMIC_INT2, 1 << 0),
- DECLARE_IRQ(MAX8997_PMICIRQ_JIGF, PMIC_INT2, 1 << 1),
- DECLARE_IRQ(MAX8997_PMICIRQ_MR, PMIC_INT2, 1 << 2),
- DECLARE_IRQ(MAX8997_PMICIRQ_DVS1OK, PMIC_INT2, 1 << 3),
- DECLARE_IRQ(MAX8997_PMICIRQ_DVS2OK, PMIC_INT2, 1 << 4),
- DECLARE_IRQ(MAX8997_PMICIRQ_DVS3OK, PMIC_INT2, 1 << 5),
- DECLARE_IRQ(MAX8997_PMICIRQ_DVS4OK, PMIC_INT2, 1 << 6),
-
- DECLARE_IRQ(MAX8997_PMICIRQ_CHGINS, PMIC_INT3, 1 << 0),
- DECLARE_IRQ(MAX8997_PMICIRQ_CHGRM, PMIC_INT3, 1 << 1),
- DECLARE_IRQ(MAX8997_PMICIRQ_DCINOVP, PMIC_INT3, 1 << 2),
- DECLARE_IRQ(MAX8997_PMICIRQ_TOPOFFR, PMIC_INT3, 1 << 3),
- DECLARE_IRQ(MAX8997_PMICIRQ_CHGRSTF, PMIC_INT3, 1 << 5),
- DECLARE_IRQ(MAX8997_PMICIRQ_MBCHGTMEXPD, PMIC_INT3, 1 << 7),
-
- DECLARE_IRQ(MAX8997_PMICIRQ_RTC60S, PMIC_INT4, 1 << 0),
- DECLARE_IRQ(MAX8997_PMICIRQ_RTCA1, PMIC_INT4, 1 << 1),
- DECLARE_IRQ(MAX8997_PMICIRQ_RTCA2, PMIC_INT4, 1 << 2),
- DECLARE_IRQ(MAX8997_PMICIRQ_SMPL_INT, PMIC_INT4, 1 << 3),
- DECLARE_IRQ(MAX8997_PMICIRQ_RTC1S, PMIC_INT4, 1 << 4),
- DECLARE_IRQ(MAX8997_PMICIRQ_WTSR, PMIC_INT4, 1 << 5),
-
- DECLARE_IRQ(MAX8997_MUICIRQ_ADCError, MUIC_INT1, 1 << 2),
- DECLARE_IRQ(MAX8997_MUICIRQ_ADCLow, MUIC_INT1, 1 << 1),
- DECLARE_IRQ(MAX8997_MUICIRQ_ADC, MUIC_INT1, 1 << 0),
-
- DECLARE_IRQ(MAX8997_MUICIRQ_VBVolt, MUIC_INT2, 1 << 4),
- DECLARE_IRQ(MAX8997_MUICIRQ_DBChg, MUIC_INT2, 1 << 3),
- DECLARE_IRQ(MAX8997_MUICIRQ_DCDTmr, MUIC_INT2, 1 << 2),
- DECLARE_IRQ(MAX8997_MUICIRQ_ChgDetRun, MUIC_INT2, 1 << 1),
- DECLARE_IRQ(MAX8997_MUICIRQ_ChgTyp, MUIC_INT2, 1 << 0),
-
- DECLARE_IRQ(MAX8997_MUICIRQ_OVP, MUIC_INT3, 1 << 2),
-};
-
-static void max8997_irq_lock(struct irq_data *data)
-{
- struct max8997_dev *max8997 = irq_data_get_irq_chip_data(data);
-
- mutex_lock(&max8997->irqlock);
-}
-
-static void max8997_irq_sync_unlock(struct irq_data *data)
-{
- struct max8997_dev *max8997 = irq_data_get_irq_chip_data(data);
- int i;
-
- for (i = 0; i < MAX8997_IRQ_GROUP_NR; i++) {
- struct regmap *map;
- u8 mask_reg = max8997_mask_reg[i];
-
- if (i >= MUIC_INT1 && i <= MUIC_INT3)
- map = max8997->regmap_muic;
- else
- map = max8997->regmap;
-
- if (mask_reg == MAX8997_REG_INVALID ||
- IS_ERR_OR_NULL(map))
- continue;
- max8997->irq_masks_cache[i] = max8997->irq_masks_cur[i];
-
- regmap_write(map, max8997_mask_reg[i],
- max8997->irq_masks_cur[i]);
- }
-
- mutex_unlock(&max8997->irqlock);
-}
-
-static const inline struct max8997_irq_data *
-irq_to_max8997_irq(struct max8997_dev *max8997, struct irq_data *data)
-{
- return &max8997_irqs[data->hwirq];
-}
-
-static void max8997_irq_mask(struct irq_data *data)
-{
- struct max8997_dev *max8997 = irq_data_get_irq_chip_data(data);
- const struct max8997_irq_data *irq_data = irq_to_max8997_irq(max8997,
- data);
-
- max8997->irq_masks_cur[irq_data->group] |= irq_data->mask;
-}
-
-static void max8997_irq_unmask(struct irq_data *data)
-{
- struct max8997_dev *max8997 = irq_data_get_irq_chip_data(data);
- const struct max8997_irq_data *irq_data = irq_to_max8997_irq(max8997,
- data);
-
- max8997->irq_masks_cur[irq_data->group] &= ~irq_data->mask;
-}
-
-static struct irq_chip max8997_irq_chip = {
- .name = "max8997",
- .irq_bus_lock = max8997_irq_lock,
- .irq_bus_sync_unlock = max8997_irq_sync_unlock,
- .irq_mask = max8997_irq_mask,
- .irq_unmask = max8997_irq_unmask,
-};
-
-#define MAX8997_IRQSRC_PMIC (1 << 1)
-#define MAX8997_IRQSRC_FUELGAUGE (1 << 2)
-#define MAX8997_IRQSRC_MUIC (1 << 3)
-#define MAX8997_IRQSRC_GPIO (1 << 4)
-#define MAX8997_IRQSRC_FLASH (1 << 5)
-static irqreturn_t max8997_irq_thread(int irq, void *data)
-{
- struct max8997_dev *max8997 = data;
- u8 irq_reg[MAX8997_IRQ_GROUP_NR] = {};
- unsigned int irq_src;
- int ret;
- int i, cur_irq;
-
- ret = regmap_read(max8997->regmap, MAX8997_REG_INTSRC, &irq_src);
- if (ret < 0) {
- dev_err(max8997->dev, "Failed to read interrupt source: %d\n",
- ret);
- return IRQ_NONE;
- }
-
- if (irq_src & MAX8997_IRQSRC_PMIC) {
- /* PMIC INT1 ~ INT4 */
- regmap_bulk_read(max8997->regmap, MAX8997_REG_INT1,
- &irq_reg[PMIC_INT1], 4);
- }
- if (irq_src & MAX8997_IRQSRC_FUELGAUGE) {
- /*
- * TODO: FUEL GAUGE
- *
- * This is to be supported by Max17042 driver. When
- * an interrupt incurs here, it should be relayed to a
- * Max17042 device that is connected (probably by
- * platform-data). However, we do not have interrupt
- * handling in Max17042 driver currently. The Max17042 IRQ
- * driver should be ready to be used as a stand-alone device and
- * a Max8997-dependent device. Because it is not ready in
- * Max17042-side and it is not too critical in operating
- * Max8997, we do not implement this in initial releases.
- */
- irq_reg[FUEL_GAUGE] = 0;
- }
- if (irq_src & MAX8997_IRQSRC_MUIC) {
- /* MUIC INT1 ~ INT3 */
- regmap_bulk_read(max8997->regmap_muic, MAX8997_MUIC_REG_INT1,
- &irq_reg[MUIC_INT1], 3);
- }
- if (irq_src & MAX8997_IRQSRC_GPIO) {
- /* GPIO Interrupt */
- u8 gpio_info[MAX8997_NUM_GPIO];
-
- irq_reg[GPIO_LOW] = 0;
- irq_reg[GPIO_HI] = 0;
-
- regmap_bulk_read(max8997->regmap, MAX8997_REG_GPIOCNTL1,
- gpio_info, MAX8997_NUM_GPIO);
- for (i = 0; i < MAX8997_NUM_GPIO; i++) {
- bool interrupt = false;
-
- switch (gpio_info[i] & MAX8997_GPIO_INT_MASK) {
- case MAX8997_GPIO_INT_BOTH:
- if (max8997->gpio_status[i] != gpio_info[i])
- interrupt = true;
- break;
- case MAX8997_GPIO_INT_RISE:
- if ((max8997->gpio_status[i] != gpio_info[i]) &&
- (gpio_info[i] & MAX8997_GPIO_DATA_MASK))
- interrupt = true;
- break;
- case MAX8997_GPIO_INT_FALL:
- if ((max8997->gpio_status[i] != gpio_info[i]) &&
- !(gpio_info[i] & MAX8997_GPIO_DATA_MASK))
- interrupt = true;
- break;
- default:
- break;
- }
-
- if (interrupt) {
- if (i < 8)
- irq_reg[GPIO_LOW] |= (1 << i);
- else
- irq_reg[GPIO_HI] |= (1 << (i - 8));
- }
-
- }
- }
- if (irq_src & MAX8997_IRQSRC_FLASH) {
- /* Flash Status Interrupt */
- unsigned int data;
- ret = regmap_read(max8997->regmap,
- MAX8997_REG_FLASHSTATUS, &data);
- irq_reg[FLASH_STATUS] = data;
- }
-
- /* Apply masking */
- for (i = 0; i < MAX8997_IRQ_GROUP_NR; i++)
- irq_reg[i] &= ~max8997->irq_masks_cur[i];
-
- /* Report */
- for (i = 0; i < MAX8997_IRQ_NR; i++) {
- if (irq_reg[max8997_irqs[i].group] & max8997_irqs[i].mask) {
- cur_irq = irq_find_mapping(max8997->irq_domain, i);
- if (cur_irq)
- handle_nested_irq(cur_irq);
- }
- }
-
- return IRQ_HANDLED;
-}
-
-int max8997_irq_resume(struct max8997_dev *max8997)
-{
- if (max8997->irq && max8997->irq_domain)
- max8997_irq_thread(0, max8997);
- return 0;
-}
-
-static int max8997_irq_domain_map(struct irq_domain *d, unsigned int irq,
- irq_hw_number_t hw)
-{
- struct max8997_dev *max8997 = d->host_data;
-
- irq_set_chip_data(irq, max8997);
- irq_set_chip_and_handler(irq, &max8997_irq_chip, handle_edge_irq);
- irq_set_nested_thread(irq, 1);
- irq_set_noprobe(irq);
-
- return 0;
-}
-
-static const struct irq_domain_ops max8997_irq_domain_ops = {
- .map = max8997_irq_domain_map,
-};
-
-int max8997_irq_init(struct max8997_dev *max8997)
-{
- struct irq_domain *domain;
- int i;
- int ret;
- unsigned int val;
-
- if (!max8997->irq) {
- dev_warn(max8997->dev, "No interrupt specified.\n");
- return 0;
- }
-
- mutex_init(&max8997->irqlock);
-
- /* Mask individual interrupt sources */
- for (i = 0; i < MAX8997_IRQ_GROUP_NR; i++) {
- max8997->irq_masks_cur[i] = 0xff;
- max8997->irq_masks_cache[i] = 0xff;
-
- if (IS_ERR_OR_NULL(max8997->regmap))
- continue;
- if (max8997_mask_reg[i] == MAX8997_REG_INVALID)
- continue;
-
- regmap_write(max8997->regmap, max8997_mask_reg[i], 0xff);
- }
-
- for (i = 0; i < MAX8997_NUM_GPIO; i++) {
- max8997->gpio_status[i] = (regmap_read(max8997->regmap,
- MAX8997_REG_GPIOCNTL1 + i,
- &val)
- & MAX8997_GPIO_DATA_MASK) ?
- true : false;
- }
-
- domain = irq_domain_add_linear(NULL, MAX8997_IRQ_NR,
- &max8997_irq_domain_ops, max8997);
- if (!domain) {
- dev_err(max8997->dev, "could not create irq domain\n");
- return -ENODEV;
- }
- max8997->irq_domain = domain;
-
- ret = request_threaded_irq(max8997->irq, NULL, max8997_irq_thread,
- IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
- "max8997-irq", max8997);
-
- if (ret) {
- dev_err(max8997->dev, "Failed to request IRQ %d: %d\n",
- max8997->irq, ret);
- return ret;
- }
-
- if (!max8997->ono)
- return 0;
-
- ret = request_threaded_irq(max8997->ono, NULL, max8997_irq_thread,
- IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING |
- IRQF_ONESHOT, "max8997-ono", max8997);
-
- if (ret)
- dev_err(max8997->dev, "Failed to request ono-IRQ %d: %d\n",
- max8997->ono, ret);
-
- return 0;
-}
-
-void max8997_irq_exit(struct max8997_dev *max8997)
-{
- if (max8997->ono)
- free_irq(max8997->ono, max8997);
-
- if (max8997->irq)
- free_irq(max8997->irq, max8997);
-}
diff --git a/drivers/mfd/max8997.c b/drivers/mfd/max8997.c
index f1c82110b2ab..932e22c05026 100644
--- a/drivers/mfd/max8997.c
+++ b/drivers/mfd/max8997.c
@@ -65,6 +65,49 @@ static const struct regmap_config max8997_regmap_config = {
.max_register = MAX8997_REG_PMIC_END,
};
+static const struct regmap_irq max8997_irqs[] = {
+ /* PMIC_INT1 interrupts */
+ { .reg_offset = 0, .mask = PMIC_INT1_PWRONR_MASK, },
+ { .reg_offset = 0, .mask = PMIC_INT1_PWRONF_MASK, },
+ { .reg_offset = 0, .mask = PMIC_INT1_PWRON1SEC_MASK, },
+ { .reg_offset = 0, .mask = PMIC_INT1_JIGONR_MASK, },
+ { .reg_offset = 0, .mask = PMIC_INT1_JIGONF_MASK, },
+ { .reg_offset = 0, .mask = PMIC_INT1_LOWBAT2_MASK, },
+ { .reg_offset = 0, .mask = PMIC_INT1_LOWBAT1_MASK, },
+ /* PMIC_INT2 interrupts */
+ { .reg_offset = 1, .mask = PMIC_INT2_JIGR_MASK, },
+ { .reg_offset = 1, .mask = PMIC_INT2_JIGF_MASK, },
+ { .reg_offset = 1, .mask = PMIC_INT2_MR_MASK, },
+ { .reg_offset = 1, .mask = PMIC_INT2_DVS1OK_MASK, },
+ { .reg_offset = 1, .mask = PMIC_INT2_DVS2OK_MASK, },
+ { .reg_offset = 1, .mask = PMIC_INT2_DVS3OK_MASK, },
+ { .reg_offset = 1, .mask = PMIC_INT2_DVS4OK_MASK, },
+ /* PMIC_INT3 interrupts */
+ { .reg_offset = 2, .mask = PMIC_INT3_CHGINS_MASK, },
+ { .reg_offset = 2, .mask = PMIC_INT3_CHGRM_MASK, },
+ { .reg_offset = 2, .mask = PMIC_INT3_DCINOVP_MASK, },
+ { .reg_offset = 2, .mask = PMIC_INT3_TOPOFFR_MASK, },
+ { .reg_offset = 2, .mask = PMIC_INT3_CHGRSTF_MASK, },
+ { .reg_offset = 2, .mask = PMIC_INT3_MBCHGTMEXPD_MASK, },
+ /* PMIC_INT4 interrupts */
+ { .reg_offset = 3, .mask = PMIC_INT4_RTC60S_MASK, },
+ { .reg_offset = 3, .mask = PMIC_INT4_RTCA1_MASK, },
+ { .reg_offset = 3, .mask = PMIC_INT4_RTCA2_MASK, },
+ { .reg_offset = 3, .mask = PMIC_INT4_SMPL_INT_MASK, },
+ { .reg_offset = 3, .mask = PMIC_INT4_RTC1S_MASK, },
+ { .reg_offset = 3, .mask = PMIC_INT4_WTSR_MASK, },
+};
+
+static const struct regmap_irq_chip max8997_irq_chip = {
+ .name = "max8997",
+ .status_base = MAX8997_REG_INT1,
+ .mask_base = MAX8997_REG_INT1MSK,
+ .mask_invert = false,
+ .num_regs = 4,
+ .irqs = max8997_irqs,
+ .num_irqs = ARRAY_SIZE(max8997_irqs),
+};
+
static const struct regmap_config max8997_regmap_rtc_config = {
.reg_bits = 8,
.val_bits = 8,
@@ -83,6 +126,31 @@ static const struct regmap_config max8997_regmap_muic_config = {
.max_register = MAX8997_MUIC_REG_END,
};
+static const struct regmap_irq max8997_irqs_muic[] = {
+ /* MUIC_INT1 interrupts */
+ { .reg_offset = 0, .mask = MUIC_INT1_ADC_MASK, },
+ { .reg_offset = 0, .mask = MUIC_INT1_ADCLOW_MASK, },
+ { .reg_offset = 0, .mask = MUIC_INT1_ADCERROR_MASK, },
+ /* MUIC_INT2 interrupts */
+ { .reg_offset = 1, .mask = MUIC_INT2_CHGTYP_MASK, },
+ { .reg_offset = 1, .mask = MUIC_INT2_CHGDETRUN_MASK, },
+ { .reg_offset = 1, .mask = MUIC_INT2_DCDTMR_MASK, },
+ { .reg_offset = 1, .mask = MUIC_INT2_DBCHG_MASK, },
+ { .reg_offset = 1, .mask = MUIC_INT2_VBVOLT_MASK, },
+ /* MUIC_INT3 interrupts */
+ { .reg_offset = 2, .mask = MUIC_INT3_OVP_MASK, },
+};
+
+static const struct regmap_irq_chip max8997_irq_chip_muic = {
+ .name = "max8997-muic",
+ .status_base = MAX8997_MUIC_REG_INT1,
+ .mask_base = MAX8997_MUIC_REG_INTMASK1,
+ .mask_invert = true,
+ .num_regs = 3,
+ .irqs = max8997_irqs_muic,
+ .num_irqs = ARRAY_SIZE(max8997_irqs_muic),
+};
+
/*
* Only the common platform data elements for max8997 are parsed here from the
* device tree. Other sub-modules of max8997 such as pmic, rtc and others have
@@ -215,9 +283,26 @@ static int max8997_i2c_probe(struct i2c_client *i2c,
goto err_regmap;
}
- pm_runtime_set_active(max8997->dev);
+ ret = regmap_add_irq_chip(max8997->regmap, max8997->irq,
+ IRQF_ONESHOT | IRQF_SHARED |
+ IRQF_TRIGGER_FALLING, 0,
+ &max8997_irq_chip, &max8997->irq_data);
+ if (ret) {
+ dev_err(max8997->dev, "failed to add irq chip: %d\n", ret);
+ goto err_regmap;
+ }
- max8997_irq_init(max8997);
+ ret = regmap_add_irq_chip(max8997->regmap_muic, max8997->irq,
+ IRQF_ONESHOT | IRQF_SHARED |
+ IRQF_TRIGGER_FALLING, 0,
+ &max8997_irq_chip_muic,
+ &max8997->irq_data_muic);
+ if (ret) {
+ dev_err(max8997->dev, "failed to add irq chip: %d\n", ret);
+ goto err_irq_muic;
+ }
+
+ pm_runtime_set_active(max8997->dev);
ret = mfd_add_devices(max8997->dev, -1, max8997_devs,
ARRAY_SIZE(max8997_devs),
@@ -239,6 +324,9 @@ static int max8997_i2c_probe(struct i2c_client *i2c,
err_mfd:
mfd_remove_devices(max8997->dev);
+ regmap_del_irq_chip(max8997->irq, max8997->irq_data_muic);
+err_irq_muic:
+ regmap_del_irq_chip(max8997->irq, max8997->irq_data);
err_regmap:
i2c_unregister_device(max8997->muic);
err_i2c_muic:
@@ -253,6 +341,10 @@ static int max8997_i2c_remove(struct i2c_client *i2c)
struct max8997_dev *max8997 = i2c_get_clientdata(i2c);
mfd_remove_devices(max8997->dev);
+
+ regmap_del_irq_chip(max8997->irq, max8997->irq_data_muic);
+ regmap_del_irq_chip(max8997->irq, max8997->irq_data);
+
i2c_unregister_device(max8997->muic);
i2c_unregister_device(max8997->haptic);
i2c_unregister_device(max8997->rtc);
@@ -469,8 +561,11 @@ static int max8997_suspend(struct device *dev)
struct i2c_client *i2c = to_i2c_client(dev);
struct max8997_dev *max8997 = i2c_get_clientdata(i2c);
- if (device_may_wakeup(dev))
- irq_set_irq_wake(max8997->irq, 1);
+ if (device_may_wakeup(dev)) {
+ enable_irq_wake(max8997->irq);
+ disable_irq(max8997->irq);
+ }
+
return 0;
}
@@ -479,9 +574,12 @@ static int max8997_resume(struct device *dev)
struct i2c_client *i2c = to_i2c_client(dev);
struct max8997_dev *max8997 = i2c_get_clientdata(i2c);
- if (device_may_wakeup(dev))
- irq_set_irq_wake(max8997->irq, 0);
- return max8997_irq_resume(max8997);
+ if (device_may_wakeup(dev)) {
+ disable_irq_wake(max8997->irq);
+ enable_irq(max8997->irq);
+ }
+
+ return 0;
}
static const struct dev_pm_ops max8997_pm = {
diff --git a/drivers/rtc/rtc-max8997.c b/drivers/rtc/rtc-max8997.c
index d017a34a9f70..4998aee0f07f 100644
--- a/drivers/rtc/rtc-max8997.c
+++ b/drivers/rtc/rtc-max8997.c
@@ -496,7 +496,7 @@ static int max8997_rtc_probe(struct platform_device *pdev)
return ret;
}
- virq = irq_create_mapping(max8997->irq_domain, MAX8997_PMICIRQ_RTCA1);
+ virq = regmap_irq_get_virq(max8997->irq_data, MAX8997_PMICIRQ_RTCA1);
if (!virq) {
dev_err(&pdev->dev, "Failed to create mapping alarm IRQ\n");
ret = -ENXIO;
diff --git a/include/linux/mfd/max8997-private.h b/include/linux/mfd/max8997-private.h
index ea80ef80dbf8..f42ea222988f 100644
--- a/include/linux/mfd/max8997-private.h
+++ b/include/linux/mfd/max8997-private.h
@@ -333,6 +333,48 @@ enum max8997_irq_source {
MAX8997_IRQ_GROUP_NR,
};
+#define PMIC_INT1_PWRONR_MASK (0x1 << 0)
+#define PMIC_INT1_PWRONF_MASK (0x1 << 1)
+#define PMIC_INT1_PWRON1SEC_MASK (0x1 << 3)
+#define PMIC_INT1_JIGONR_MASK (0x1 << 4)
+#define PMIC_INT1_JIGONF_MASK (0x1 << 5)
+#define PMIC_INT1_LOWBAT2_MASK (0x1 << 6)
+#define PMIC_INT1_LOWBAT1_MASK (0x1 << 7)
+
+#define PMIC_INT2_JIGR_MASK (0x1 << 0)
+#define PMIC_INT2_JIGF_MASK (0x1 << 1)
+#define PMIC_INT2_MR_MASK (0x1 << 2)
+#define PMIC_INT2_DVS1OK_MASK (0x1 << 3)
+#define PMIC_INT2_DVS2OK_MASK (0x1 << 4)
+#define PMIC_INT2_DVS3OK_MASK (0x1 << 5)
+#define PMIC_INT2_DVS4OK_MASK (0x1 << 6)
+
+#define PMIC_INT3_CHGINS_MASK (0x1 << 0)
+#define PMIC_INT3_CHGRM_MASK (0x1 << 1)
+#define PMIC_INT3_DCINOVP_MASK (0x1 << 2)
+#define PMIC_INT3_TOPOFFR_MASK (0x1 << 3)
+#define PMIC_INT3_CHGRSTF_MASK (0x1 << 5)
+#define PMIC_INT3_MBCHGTMEXPD_MASK (0x1 << 7)
+
+#define PMIC_INT4_RTC60S_MASK (0x1 << 0)
+#define PMIC_INT4_RTCA1_MASK (0x1 << 1)
+#define PMIC_INT4_RTCA2_MASK (0x1 << 2)
+#define PMIC_INT4_SMPL_INT_MASK (0x1 << 3)
+#define PMIC_INT4_RTC1S_MASK (0x1 << 4)
+#define PMIC_INT4_WTSR_MASK (0x1 << 5)
+
+#define MUIC_INT1_ADC_MASK (0x1 << 0)
+#define MUIC_INT1_ADCLOW_MASK (0x1 << 1)
+#define MUIC_INT1_ADCERROR_MASK (0x1 << 2)
+
+#define MUIC_INT2_CHGTYP_MASK (0x1 << 0)
+#define MUIC_INT2_CHGDETRUN_MASK (0x1 << 1)
+#define MUIC_INT2_DCDTMR_MASK (0x1 << 2)
+#define MUIC_INT2_DBCHG_MASK (0x1 << 3)
+#define MUIC_INT2_VBVOLT_MASK (0x1 << 4)
+
+#define MUIC_INT3_OVP_MASK (0x1 << 2)
+
enum max8997_irq {
MAX8997_PMICIRQ_PWRONR,
MAX8997_PMICIRQ_PWRONF,
@@ -364,19 +406,23 @@ enum max8997_irq {
MAX8997_PMICIRQ_RTC1S,
MAX8997_PMICIRQ_WTSR,
- MAX8997_MUICIRQ_ADCError,
- MAX8997_MUICIRQ_ADCLow,
+ MAX8997_PMICIRQ_NR,
+};
+
+enum max8997_irq_muic {
MAX8997_MUICIRQ_ADC,
+ MAX8997_MUICIRQ_ADCLow,
+ MAX8997_MUICIRQ_ADCError,
- MAX8997_MUICIRQ_VBVolt,
- MAX8997_MUICIRQ_DBChg,
- MAX8997_MUICIRQ_DCDTmr,
- MAX8997_MUICIRQ_ChgDetRun,
MAX8997_MUICIRQ_ChgTyp,
+ MAX8997_MUICIRQ_ChgDetRun,
+ MAX8997_MUICIRQ_DCDTmr,
+ MAX8997_MUICIRQ_DBChg,
+ MAX8997_MUICIRQ_VBVolt,
MAX8997_MUICIRQ_OVP,
- MAX8997_IRQ_NR,
+ MAX8997_MUCIRQ_NR,
};
#define MAX8997_NUM_GPIO 12
@@ -397,9 +443,10 @@ struct max8997_dev {
struct regmap *regmap_haptic;
struct regmap *regmap_muic;
+ struct regmap_irq_chip_data *irq_data;
+ struct regmap_irq_chip_data *irq_data_muic;
int irq;
int ono;
- struct irq_domain *irq_domain;
struct mutex irqlock;
int irq_masks_cur[MAX8997_IRQ_GROUP_NR];
int irq_masks_cache[MAX8997_IRQ_GROUP_NR];
--
1.9.1
[toc] | [prev] | [next] | [standalone]
| From | Krzysztof Kozlowski <k.kozlowski@samsung.com> |
|---|---|
| Date | 2016-05-06 09:30 +0200 |
| Subject | [PATCH v6 6/9] rtc: max8997: Check for ERRNO of regmap_irq_get_virq() |
| Message-ID | <rvIn0-P0-29@gated-at.bofh.it> |
| In reply to | #1395662 |
The regmap_irq_get_virq() can return zero or negative ERRNO, so it is
insufficient to check only for non-zero value.
Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
---
drivers/rtc/rtc-max8997.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/rtc/rtc-max8997.c b/drivers/rtc/rtc-max8997.c
index 4998aee0f07f..1a06e17ebe9b 100644
--- a/drivers/rtc/rtc-max8997.c
+++ b/drivers/rtc/rtc-max8997.c
@@ -497,7 +497,7 @@ static int max8997_rtc_probe(struct platform_device *pdev)
}
virq = regmap_irq_get_virq(max8997->irq_data, MAX8997_PMICIRQ_RTCA1);
- if (!virq) {
+ if (virq <= 0) {
dev_err(&pdev->dev, "Failed to create mapping alarm IRQ\n");
ret = -ENXIO;
goto err_out;
--
1.9.1
[toc] | [prev] | [next] | [standalone]
| From | Alexandre Belloni <alexandre.belloni@free-electrons.com> |
|---|---|
| Date | 2016-05-07 08:50 +0200 |
| Subject | Re: [PATCH v6 6/9] rtc: max8997: Check for ERRNO of regmap_irq_get_virq() |
| Message-ID | <rw4dQ-4GE-3@gated-at.bofh.it> |
| In reply to | #1395666 |
On 06/05/2016 at 09:27:13 +0200, Krzysztof Kozlowski wrote :
> The regmap_irq_get_virq() can return zero or negative ERRNO, so it is
> insufficient to check only for non-zero value.
>
> Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Acked-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> ---
> drivers/rtc/rtc-max8997.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/rtc/rtc-max8997.c b/drivers/rtc/rtc-max8997.c
> index 4998aee0f07f..1a06e17ebe9b 100644
> --- a/drivers/rtc/rtc-max8997.c
> +++ b/drivers/rtc/rtc-max8997.c
> @@ -497,7 +497,7 @@ static int max8997_rtc_probe(struct platform_device *pdev)
> }
>
> virq = regmap_irq_get_virq(max8997->irq_data, MAX8997_PMICIRQ_RTCA1);
> - if (!virq) {
> + if (virq <= 0) {
> dev_err(&pdev->dev, "Failed to create mapping alarm IRQ\n");
> ret = -ENXIO;
> goto err_out;
> --
> 1.9.1
>
--
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
[toc] | [prev] | [next] | [standalone]
| From | Krzysztof Kozlowski <k.kozlowski@samsung.com> |
|---|---|
| Date | 2016-05-06 09:30 +0200 |
| Subject | [PATCH v6 9/9] ARM: dts: exynos: Add interrupt line to MAX8997 PMIC on exynos4210-trats |
| Message-ID | <rvIn0-P0-31@gated-at.bofh.it> |
| In reply to | #1395662 |
From: Marek Szyprowski <m.szyprowski@samsung.com>
MAX8997 PMIC requires interrupt and fails probing without it.
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Fixes: d105f0b1215d ("ARM: dts: Add basic dts file for Samsung Trats board")
Cc: <stable@vger.kernel.org>
[k.kozlowski: Write commit message, add CC-stable]
Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
---
arch/arm/boot/dts/exynos4210-trats.dts | 2 ++
1 file changed, 2 insertions(+)
diff --git a/arch/arm/boot/dts/exynos4210-trats.dts b/arch/arm/boot/dts/exynos4210-trats.dts
index fed5847410d3..79d983036560 100644
--- a/arch/arm/boot/dts/exynos4210-trats.dts
+++ b/arch/arm/boot/dts/exynos4210-trats.dts
@@ -298,6 +298,8 @@
compatible = "maxim,max8997-pmic";
reg = <0x66>;
+ interrupt-parent = <&gpx0>;
+ interrupts = <7 0>;
max8997,pmic-buck1-uses-gpio-dvs;
max8997,pmic-buck2-uses-gpio-dvs;
--
1.9.1
[toc] | [prev] | [next] | [standalone]
| From | Krzysztof Kozlowski <k.kozlowski@samsung.com> |
|---|---|
| Date | 2016-05-06 09:30 +0200 |
| Subject | [PATCH v6 5/9] extcon: max8997: Fix handling error code of regmap_irq_get_virq() |
| Message-ID | <rvIn0-P0-35@gated-at.bofh.it> |
| In reply to | #1395662 |
The regmap_irq_get_virq() can return negative ERRNO, so its result
should not be stored in unsigned int because error would be ignored.
Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
---
drivers/extcon/extcon-max8997.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/extcon/extcon-max8997.c b/drivers/extcon/extcon-max8997.c
index 68754ac2c8ea..0afa3e8b5dc3 100644
--- a/drivers/extcon/extcon-max8997.c
+++ b/drivers/extcon/extcon-max8997.c
@@ -660,11 +660,11 @@ static int max8997_muic_probe(struct platform_device *pdev)
for (i = 0; i < ARRAY_SIZE(muic_irqs); i++) {
struct max8997_muic_irq *muic_irq = &muic_irqs[i];
- unsigned int virq = 0;
+ int virq = 0;
virq = regmap_irq_get_virq(max8997->irq_data_muic,
muic_irq->irq);
- if (!virq) {
+ if (virq <= 0) {
ret = -EINVAL;
goto err_irq;
}
--
1.9.1
[toc] | [prev] | [next] | [standalone]
| From | Chanwoo Choi <cw00.choi@samsung.com> |
|---|---|
| Date | 2016-05-10 03:30 +0200 |
| Subject | Re: [PATCH v6 5/9] extcon: max8997: Fix handling error code of regmap_irq_get_virq() |
| Message-ID | <rx4EO-Fw-11@gated-at.bofh.it> |
| In reply to | #1395670 |
Hi Krzysztof,
On 2016년 05월 06일 16:27, Krzysztof Kozlowski wrote:
> The regmap_irq_get_virq() can return negative ERRNO, so its result
> should not be stored in unsigned int because error would be ignored.
>
> Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
> ---
> drivers/extcon/extcon-max8997.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/extcon/extcon-max8997.c b/drivers/extcon/extcon-max8997.c
> index 68754ac2c8ea..0afa3e8b5dc3 100644
> --- a/drivers/extcon/extcon-max8997.c
> +++ b/drivers/extcon/extcon-max8997.c
> @@ -660,11 +660,11 @@ static int max8997_muic_probe(struct platform_device *pdev)
>
> for (i = 0; i < ARRAY_SIZE(muic_irqs); i++) {
> struct max8997_muic_irq *muic_irq = &muic_irqs[i];
> - unsigned int virq = 0;
> + int virq = 0;
>
> virq = regmap_irq_get_virq(max8997->irq_data_muic,
> muic_irq->irq);
> - if (!virq) {
> + if (virq <= 0) {
> ret = -EINVAL;
> goto err_irq;
> }
>
Acked-by: Chanwoo Choi <cw00.choi@samsung.com>
Thanks,
Chanwoo Choi
[toc] | [prev] | [next] | [standalone]
| From | Krzysztof Kozlowski <k.kozlowski@samsung.com> |
|---|---|
| Date | 2016-05-06 09:40 +0200 |
| Subject | [PATCH v6 7/9] extcon: max8997: Fix inconsistent indenting |
| Message-ID | <rvIwF-V5-1@gated-at.bofh.it> |
| In reply to | #1395662 |
Fix smatch warning: max8997_muic_probe() warn: inconsistent indenting Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com> --- drivers/extcon/extcon-max8997.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/extcon/extcon-max8997.c b/drivers/extcon/extcon-max8997.c index 0afa3e8b5dc3..cf8de5be2405 100644 --- a/drivers/extcon/extcon-max8997.c +++ b/drivers/extcon/extcon-max8997.c @@ -737,7 +737,7 @@ static int max8997_muic_probe(struct platform_device *pdev) } /* Set initial path for UART */ - max8997_muic_set_path(info, info->path_uart, true); + max8997_muic_set_path(info, info->path_uart, true); /* Set ADC debounce time */ max8997_muic_set_debounce_time(info, ADC_DEBOUNCE_TIME_25MS); -- 1.9.1
[toc] | [prev] | [next] | [standalone]
| From | Chanwoo Choi <cw00.choi@samsung.com> |
|---|---|
| Date | 2016-05-10 03:30 +0200 |
| Subject | Re: [PATCH v6 7/9] extcon: max8997: Fix inconsistent indenting |
| Message-ID | <rx4EO-Fw-9@gated-at.bofh.it> |
| In reply to | #1395671 |
Hi Krzysztof, On 2016년 05월 06일 16:27, Krzysztof Kozlowski wrote: > Fix smatch warning: > max8997_muic_probe() warn: inconsistent indenting > > Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com> > --- > drivers/extcon/extcon-max8997.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/extcon/extcon-max8997.c b/drivers/extcon/extcon-max8997.c > index 0afa3e8b5dc3..cf8de5be2405 100644 > --- a/drivers/extcon/extcon-max8997.c > +++ b/drivers/extcon/extcon-max8997.c > @@ -737,7 +737,7 @@ static int max8997_muic_probe(struct platform_device *pdev) > } > > /* Set initial path for UART */ > - max8997_muic_set_path(info, info->path_uart, true); > + max8997_muic_set_path(info, info->path_uart, true); > > /* Set ADC debounce time */ > max8997_muic_set_debounce_time(info, ADC_DEBOUNCE_TIME_25MS); > Acked-by: Chanwoo Choi <cw00.choi@samsung.com> Thanks, Chanwoo Choi
[toc] | [prev] | [next] | [standalone]
| From | Jacek Anaszewski <j.anaszewski@samsung.com> |
|---|---|
| Date | 2016-05-06 10:10 +0200 |
| Subject | Re: [PATCH v6 2/9] mfd: max8997: Use regmap to access registers |
| Message-ID | <rvIZI-1qM-15@gated-at.bofh.it> |
| In reply to | #1395662 |
Hi Krzysztof, On 05/06/2016 09:27 AM, Krzysztof Kozlowski wrote: > From: Robert Baldyga <r.baldyga@samsung.com> > > This patch modifies max8997 driver and each associated function driver, > to use regmap instead of operating directly on i2c bus. It will allow to > simplify IRQ handling using regmap-irq. > > Signed-off-by: Robert Baldyga <r.baldyga@samsung.com> > Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com> > > [For extcon part] > Acked-by: Chanwoo Choi <cw00.choi@samsung.com> > > [For leds part] > Acked-by: Bryan Wu <cooloney@gmail.com> > Since I've replaced Bryan on the position of LED subsystem maintainer feel free to use my ack: Acked-by: Jacek Anaszewski <j.anaszewski@samsung.com> -- Best regards, Jacek Anaszewski
[toc] | [prev] | [next] | [standalone]
| From | Dmitry Torokhov <dmitry.torokhov@gmail.com> |
|---|---|
| Date | 2016-05-09 18:40 +0200 |
| Subject | Re: [PATCH v6 1/9] input: max8997-haptic: Fix NULL pointer dereference |
| Message-ID | <rwWnU-WQ-19@gated-at.bofh.it> |
| In reply to | #1395662 |
On Fri, May 06, 2016 at 09:21:21AM +0200, Krzysztof Kozlowski wrote:
> From: Marek Szyprowski <m.szyprowski@samsung.com>
>
> NULL pointer derefence happens when booting with DTB because the
> platform data for haptic device is not set in supplied data from parent
> MFD device.
>
> The MFD device creates only platform data (from Device Tree) for itself,
> not for haptic child.
>
> Unable to handle kernel NULL pointer dereference at virtual address 0000009c
> pgd = c0004000
> [0000009c] *pgd=00000000
> Internal error: Oops: 5 [#1] PREEMPT SMP ARM
> (max8997_haptic_probe) from [<c03f9cec>] (platform_drv_probe+0x4c/0xb0)
> (platform_drv_probe) from [<c03f8440>] (driver_probe_device+0x214/0x2c0)
> (driver_probe_device) from [<c03f8598>] (__driver_attach+0xac/0xb0)
> (__driver_attach) from [<c03f67ac>] (bus_for_each_dev+0x68/0x9c)
> (bus_for_each_dev) from [<c03f7a38>] (bus_add_driver+0x1a0/0x218)
> (bus_add_driver) from [<c03f8db0>] (driver_register+0x78/0xf8)
> (driver_register) from [<c0101774>] (do_one_initcall+0x90/0x1d8)
> (do_one_initcall) from [<c0a00dbc>] (kernel_init_freeable+0x15c/0x1fc)
> (kernel_init_freeable) from [<c06bb5b4>] (kernel_init+0x8/0x114)
> (kernel_init) from [<c0107938>] (ret_from_fork+0x14/0x3c)
>
> Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
> Cc: <stable@vger.kernel.org>
> Fixes: 104594b01ce7 ("Input: add driver support for MAX8997-haptic")
> [k.kozlowski: Write commit message, add CC-stable]
> Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Applied, thank you.
> ---
> drivers/input/misc/max8997_haptic.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/input/misc/max8997_haptic.c b/drivers/input/misc/max8997_haptic.c
> index a806ba3818f7..8d6326d7e7be 100644
> --- a/drivers/input/misc/max8997_haptic.c
> +++ b/drivers/input/misc/max8997_haptic.c
> @@ -255,12 +255,14 @@ static int max8997_haptic_probe(struct platform_device *pdev)
> struct max8997_dev *iodev = dev_get_drvdata(pdev->dev.parent);
> const struct max8997_platform_data *pdata =
> dev_get_platdata(iodev->dev);
> - const struct max8997_haptic_platform_data *haptic_pdata =
> - pdata->haptic_pdata;
> + const struct max8997_haptic_platform_data *haptic_pdata = NULL;
> struct max8997_haptic *chip;
> struct input_dev *input_dev;
> int error;
>
> + if (pdata)
> + haptic_pdata = pdata->haptic_pdata;
> +
> if (!haptic_pdata) {
> dev_err(&pdev->dev, "no haptic platform data\n");
> return -EINVAL;
> --
> 1.9.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-input" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
--
Dmitry
[toc] | [prev] | [next] | [standalone]
| From | Lee Jones <lee.jones@linaro.org> |
|---|---|
| Date | 2016-05-09 09:40 +0200 |
| Message-ID | <rwNXn-n9-99@gated-at.bofh.it> |
| In reply to | #1395658 |
On Fri, 06 May 2016, Krzysztof Kozlowski wrote: > This is a rebase and extension of old Robert Baldyga's work. [0] > > Robert no longer works in Samsung. > > From the original cover letter: > "This patchset modifies max8997 driver and associated function drivers to use > register maps instead of operating directly on i2c bus. This change allowed > to simplify irq handling, and to move some initializations to individual > function drivers. Hence now when some functions are not enabled, their i2c > clients, regmaps and irqs are not registered." > > > My changes (since Robert's v5) > ============================== > 1. Rebase on v4.6-rc6. > 2. Collect more acks. > 3. Add few fixes: > a. Haptic fix from Marek, > b. Extcon and RTC fix from me, > c. DTS fixes from Marek. > > DTS changes are independent but rest of them (extcon/input/MFD) rely > on each other. > > One way of merging would be to pick everything (except DTS) through > one tree. Or use tags. I'd be happy to take the set, once you have collected all Acks. > Best regards, > Krzysztof > > [0] http://lkml.iu.edu/hypermail//linux/kernel/1411.1/03152.html > > > Krzysztof Kozlowski (3): > extcon: max8997: Fix handling error code of regmap_irq_get_virq() > rtc: max8997: Check for ERRNO of regmap_irq_get_virq() > extcon: max8997: Fix inconsistent indenting > > Marek Szyprowski (3): > input: max8997-haptic: Fix NULL pointer dereference > ARM: dts: exynos: Fix regulator name to avoid forbidden character on > exynos4210-trats > ARM: dts: exynos: Add interrupt line to MAX8997 PMIC on > exynos4210-trats > > Robert Baldyga (3): > mfd: max8997: Use regmap to access registers > mfd: max8997: handle IRQs using regmap > mfd: max8997: Change irq names to upper case > > arch/arm/boot/dts/exynos4210-trats.dts | 4 +- > drivers/extcon/extcon-max8997.c | 72 ++++--- > drivers/input/misc/max8997_haptic.c | 40 ++-- > drivers/leds/leds-max8997.c | 13 +- > drivers/mfd/Kconfig | 3 +- > drivers/mfd/Makefile | 2 +- > drivers/mfd/max8997-irq.c | 383 --------------------------------- > drivers/mfd/max8997.c | 245 ++++++++++++++------- > drivers/power/max8997_charger.c | 33 +-- > drivers/regulator/max8997.c | 87 ++++---- > drivers/rtc/rtc-max8997.c | 60 +++--- > include/linux/mfd/max8997-private.h | 82 +++++-- > 12 files changed, 392 insertions(+), 632 deletions(-) > delete mode 100644 drivers/mfd/max8997-irq.c > -- Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web