Re: [PATCH v2 2/2] mfd: max77693: handle IRQs using regmap

2014-04-29 Thread Lee Jones
> 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 
> ---
>  drivers/extcon/extcon-max77693.c |   3 +-
>  drivers/mfd/Kconfig  |   1 +
>  drivers/mfd/Makefile |   2 +-
>  drivers/mfd/max77693-irq.c   | 346 
> ---
>  drivers/mfd/max77693.c   | 151 ++-
>  include/linux/mfd/max77693-private.h |  47 -
>  6 files changed, 191 insertions(+), 359 deletions(-)
>  delete mode 100644 drivers/mfd/max77693-irq.c

Patch looks _mostly_ okay and the diffstat looks great.

[...]

> +static const struct regmap_irq max77693_led_irqs[] = {
> + { .mask = LED_IRQ_FLED2_OPEN, },
> + { .mask = LED_IRQ_FLED2_SHORT, },
> + { .mask = LED_IRQ_FLED1_OPEN, },
> + { .mask = LED_IRQ_FLED1_SHORT, },
> + { .mask = LED_IRQ_MAX_FLASH, },
> +};

Tiny-nit: If you can line those '}'s up, that'd be great. :)

Same below. You've already gone to the trouble with the '='s.

/me likes straight lines.

> +static const struct regmap_irq_chip max77693_led_irq_chip = {
> + .name   = "max77693-led",
> + .status_base= MAX77693_LED_REG_FLASH_INT,
> + .mask_base  = MAX77693_LED_REG_FLASH_INT_MASK,
> + .mask_invert= false,
> + .num_regs   = 1,
> + .irqs   = max77693_led_irqs,
> + .num_irqs   = ARRAY_SIZE(max77693_led_irqs),
> +};
> +
> +static const struct regmap_irq max77693_topsys_irqs[] = {
> + { .mask = TOPSYS_IRQ_T120C_INT, },
> + { .mask = TOPSYS_IRQ_T140C_INT, },
> + { .mask = TOPSYS_IRQ_LOWSYS_INT, },
> +};

[...]

> +#define LED_IRQ_FLED2_OPEN   (0x1 << 0)
> +#define LED_IRQ_FLED2_SHORT  (0x1 << 1)
> +#define LED_IRQ_FLED1_OPEN   (0x1 << 2)
> +#define LED_IRQ_FLED1_SHORT  (0x1 << 3)
> +#define LED_IRQ_MAX_FLASH(0x1 << 4)
> +
> +#define TOPSYS_IRQ_T120C_INT (0x1 << 0)
> +#define TOPSYS_IRQ_T140C_INT (0x1 << 1)
> +#define TOPSYS_IRQ_LOWSYS_INT(0x1 << 3)
> +
> +#define CHG_IRQ_BYP_I(0x1 << 0)
> +#define CHG_IRQ_THM_I(0x1 << 2)
> +#define CHG_IRQ_BAT_I(0x1 << 3)
> +#define CHG_IRQ_CHG_I(0x1 << 4)
> +#define CHG_IRQ_CHGIN_I  (0x1 << 6)
> +
> +#define MUIC_IRQ_INT1_ADC(0x1 << 0)
> +#define MUIC_IRQ_INT1_ADC_LOW(0x1 << 1)
> +#define MUIC_IRQ_INT1_ADC_ERR(0x1 << 2)
> +#define MUIC_IRQ_INT1_ADC1K  (0x1 << 3)
> +
> +#define MUIC_IRQ_INT2_CHGTYP (0x1 << 0)
> +#define MUIC_IRQ_INT2_CHGDETREUN (0x1 << 1)
> +#define MUIC_IRQ_INT2_DCDTMR (0x1 << 2)
> +#define MUIC_IRQ_INT2_DXOVP  (0x1 << 3)
> +#define MUIC_IRQ_INT2_VBVOLT (0x1 << 4)
> +#define MUIC_IRQ_INT2_VIDRM  (0x1 << 5)
> +
> +#define MUIC_IRQ_INT3_EOC(0x1 << 0)
> +#define MUIC_IRQ_INT3_CGMBC  (0x1 << 1)
> +#define MUIC_IRQ_INT3_OVP(0x1 << 2)
> +#define MUIC_IRQ_INT3_MBCCHG_ERR (0x1 << 3)
> +#define MUIC_IRQ_INT3_CHG_ENABLED(0x1 << 4)
> +#define MUIC_IRQ_INT3_BAT_DET(0x1 << 5)

Use BIT() for these.

> +
> +

One more '\n' than you need.

[...]

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2 2/2] mfd: max77693: handle IRQs using regmap

2014-04-29 Thread Krzysztof Kozlowski
On wto, 2014-04-29 at 07:48 +0200, Robert Baldyga wrote:
> 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 
> ---
>  drivers/extcon/extcon-max77693.c |   3 +-
>  drivers/mfd/Kconfig  |   1 +
>  drivers/mfd/Makefile |   2 +-
>  drivers/mfd/max77693-irq.c   | 346 
> ---
>  drivers/mfd/max77693.c   | 151 ++-
>  include/linux/mfd/max77693-private.h |  47 -
>  6 files changed, 191 insertions(+), 359 deletions(-)
>  delete mode 100644 drivers/mfd/max77693-irq.c


Reviewed-by: Krzysztof Kozlowski 

Best regards,
Krzysztof



> diff --git a/drivers/extcon/extcon-max77693.c 
> b/drivers/extcon/extcon-max77693.c
> index 0b09bf3..725190a 100644
> --- a/drivers/extcon/extcon-max77693.c
> +++ b/drivers/extcon/extcon-max77693.c
> @@ -1154,7 +1154,8 @@ static int max77693_muic_probe(struct platform_device 
> *pdev)
>   struct max77693_muic_irq *muic_irq = _irqs[i];
>   unsigned int virq = 0;
>  
> - virq = irq_create_mapping(max77693->irq_domain, muic_irq->irq);
> + virq = regmap_irq_get_virq(max77693->irq_data_muic,
> + muic_irq->irq);
>   if (!virq) {
>   ret = -EINVAL;
>   goto err_irq;
> diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
> index 67141e8..9e479d0 100644
> --- a/drivers/mfd/Kconfig
> +++ b/drivers/mfd/Kconfig
> @@ -372,6 +372,7 @@ config MFD_MAX77693
>   depends on I2C=y
>   select MFD_CORE
>   select REGMAP_I2C
> + select REGMAP_IRQ
>   help
> Say yes here to add support for Maxim Semiconductor MAX77693.
> This is a companion Power Management IC with Flash, Haptic, Charger,
> diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
> index 6d0f65e..b0c55e4 100644
> --- a/drivers/mfd/Makefile
> +++ b/drivers/mfd/Makefile
> @@ -114,7 +114,7 @@ obj-$(CONFIG_MFD_DA9063)  += da9063.o
>  
>  obj-$(CONFIG_MFD_MAX14577)   += max14577.o
>  obj-$(CONFIG_MFD_MAX77686)   += max77686.o max77686-irq.o
> -obj-$(CONFIG_MFD_MAX77693)   += max77693.o max77693-irq.o
> +obj-$(CONFIG_MFD_MAX77693)   += max77693.o
>  obj-$(CONFIG_MFD_MAX8907)+= max8907.o
>  max8925-objs := max8925-core.o max8925-i2c.o
>  obj-$(CONFIG_MFD_MAX8925)+= max8925.o
> diff --git a/drivers/mfd/max77693-irq.c b/drivers/mfd/max77693-irq.c
> deleted file mode 100644
> index 7d8f99f..000
> --- a/drivers/mfd/max77693-irq.c
> +++ /dev/null
> @@ -1,346 +0,0 @@
> -/*
> - * max77693-irq.c - Interrupt controller support for MAX77693
> - *
> - * Copyright (C) 2012 Samsung Electronics Co.Ltd
> - * SangYoung Son 
> - *
> - * This program is not provided / owned by Maxim Integrated Products.
> - *
> - * 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 
> -#include 
> -#include 
> -#include 
> -#include 
> -#include 
> -#include 
> -#include 
> -
> -static const unsigned int max77693_mask_reg[] = {
> - [LED_INT] = MAX77693_LED_REG_FLASH_INT_MASK,
> - [TOPSYS_INT] = MAX77693_PMIC_REG_TOPSYS_INT_MASK,
> - [CHG_INT] = MAX77693_CHG_REG_CHG_INT_MASK,
> - [MUIC_INT1] = MAX77693_MUIC_REG_INTMASK1,
> - [MUIC_INT2] = MAX77693_MUIC_REG_INTMASK2,
> - [MUIC_INT3] = MAX77693_MUIC_REG_INTMASK3,
> -};
> -
> -static struct regmap *max77693_get_regmap(struct max77693_dev *max77693,
> - enum max77693_irq_source src)
> -{
> - switch (src) {
> - case LED_INT ... CHG_INT:
> - return max77693->regmap;
> - case MUIC_INT1 ... MUIC_INT3:
> - return max77693->regmap_muic;
> - default:
> - return ERR_PTR(-EINVAL);
> - }
> -}
> -
> -struct max77693_irq_data {
> - int mask;
> - enum max77693_irq_source group;
> -};
> -
> -#define DECLARE_IRQ(idx, _group, _mask)  \
> - [(idx)] = { .group = (_group), .mask = (_mask) }
> -static const struct max77693_irq_data max77693_irqs[] = {
> - 

Re: [PATCH v2 2/2] mfd: max77693: handle IRQs using regmap

2014-04-29 Thread Krzysztof Kozlowski
On wto, 2014-04-29 at 07:48 +0200, Robert Baldyga wrote:
 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.bald...@samsung.com
 ---
  drivers/extcon/extcon-max77693.c |   3 +-
  drivers/mfd/Kconfig  |   1 +
  drivers/mfd/Makefile |   2 +-
  drivers/mfd/max77693-irq.c   | 346 
 ---
  drivers/mfd/max77693.c   | 151 ++-
  include/linux/mfd/max77693-private.h |  47 -
  6 files changed, 191 insertions(+), 359 deletions(-)
  delete mode 100644 drivers/mfd/max77693-irq.c


Reviewed-by: Krzysztof Kozlowski k.kozlow...@samsung.com

Best regards,
Krzysztof



 diff --git a/drivers/extcon/extcon-max77693.c 
 b/drivers/extcon/extcon-max77693.c
 index 0b09bf3..725190a 100644
 --- a/drivers/extcon/extcon-max77693.c
 +++ b/drivers/extcon/extcon-max77693.c
 @@ -1154,7 +1154,8 @@ static int max77693_muic_probe(struct platform_device 
 *pdev)
   struct max77693_muic_irq *muic_irq = muic_irqs[i];
   unsigned int virq = 0;
  
 - virq = irq_create_mapping(max77693-irq_domain, muic_irq-irq);
 + virq = regmap_irq_get_virq(max77693-irq_data_muic,
 + muic_irq-irq);
   if (!virq) {
   ret = -EINVAL;
   goto err_irq;
 diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
 index 67141e8..9e479d0 100644
 --- a/drivers/mfd/Kconfig
 +++ b/drivers/mfd/Kconfig
 @@ -372,6 +372,7 @@ config MFD_MAX77693
   depends on I2C=y
   select MFD_CORE
   select REGMAP_I2C
 + select REGMAP_IRQ
   help
 Say yes here to add support for Maxim Semiconductor MAX77693.
 This is a companion Power Management IC with Flash, Haptic, Charger,
 diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
 index 6d0f65e..b0c55e4 100644
 --- a/drivers/mfd/Makefile
 +++ b/drivers/mfd/Makefile
 @@ -114,7 +114,7 @@ obj-$(CONFIG_MFD_DA9063)  += da9063.o
  
  obj-$(CONFIG_MFD_MAX14577)   += max14577.o
  obj-$(CONFIG_MFD_MAX77686)   += max77686.o max77686-irq.o
 -obj-$(CONFIG_MFD_MAX77693)   += max77693.o max77693-irq.o
 +obj-$(CONFIG_MFD_MAX77693)   += max77693.o
  obj-$(CONFIG_MFD_MAX8907)+= max8907.o
  max8925-objs := max8925-core.o max8925-i2c.o
  obj-$(CONFIG_MFD_MAX8925)+= max8925.o
 diff --git a/drivers/mfd/max77693-irq.c b/drivers/mfd/max77693-irq.c
 deleted file mode 100644
 index 7d8f99f..000
 --- a/drivers/mfd/max77693-irq.c
 +++ /dev/null
 @@ -1,346 +0,0 @@
 -/*
 - * max77693-irq.c - Interrupt controller support for MAX77693
 - *
 - * Copyright (C) 2012 Samsung Electronics Co.Ltd
 - * SangYoung Son hello@samsung.com
 - *
 - * This program is not provided / owned by Maxim Integrated Products.
 - *
 - * 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/module.h
 -#include linux/irqdomain.h
 -#include linux/mfd/max77693.h
 -#include linux/mfd/max77693-private.h
 -#include linux/regmap.h
 -
 -static const unsigned int max77693_mask_reg[] = {
 - [LED_INT] = MAX77693_LED_REG_FLASH_INT_MASK,
 - [TOPSYS_INT] = MAX77693_PMIC_REG_TOPSYS_INT_MASK,
 - [CHG_INT] = MAX77693_CHG_REG_CHG_INT_MASK,
 - [MUIC_INT1] = MAX77693_MUIC_REG_INTMASK1,
 - [MUIC_INT2] = MAX77693_MUIC_REG_INTMASK2,
 - [MUIC_INT3] = MAX77693_MUIC_REG_INTMASK3,
 -};
 -
 -static struct regmap *max77693_get_regmap(struct max77693_dev *max77693,
 - enum max77693_irq_source src)
 -{
 - switch (src) {
 - case LED_INT ... CHG_INT:
 - return max77693-regmap;
 - case MUIC_INT1 ... MUIC_INT3:
 - return max77693-regmap_muic;
 - default:
 - return ERR_PTR(-EINVAL);
 - }
 -}
 -
 -struct max77693_irq_data {
 - int mask;
 - enum max77693_irq_source group;
 -};
 -
 -#define DECLARE_IRQ(idx, _group, _mask)  \
 - [(idx)] = { .group = (_group), .mask = (_mask) }
 -static const struct 

Re: [PATCH v2 2/2] mfd: max77693: handle IRQs using regmap

2014-04-29 Thread Lee Jones
 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.bald...@samsung.com
 ---
  drivers/extcon/extcon-max77693.c |   3 +-
  drivers/mfd/Kconfig  |   1 +
  drivers/mfd/Makefile |   2 +-
  drivers/mfd/max77693-irq.c   | 346 
 ---
  drivers/mfd/max77693.c   | 151 ++-
  include/linux/mfd/max77693-private.h |  47 -
  6 files changed, 191 insertions(+), 359 deletions(-)
  delete mode 100644 drivers/mfd/max77693-irq.c

Patch looks _mostly_ okay and the diffstat looks great.

[...]

 +static const struct regmap_irq max77693_led_irqs[] = {
 + { .mask = LED_IRQ_FLED2_OPEN, },
 + { .mask = LED_IRQ_FLED2_SHORT, },
 + { .mask = LED_IRQ_FLED1_OPEN, },
 + { .mask = LED_IRQ_FLED1_SHORT, },
 + { .mask = LED_IRQ_MAX_FLASH, },
 +};

Tiny-nit: If you can line those '}'s up, that'd be great. :)

Same below. You've already gone to the trouble with the '='s.

/me likes straight lines.

 +static const struct regmap_irq_chip max77693_led_irq_chip = {
 + .name   = max77693-led,
 + .status_base= MAX77693_LED_REG_FLASH_INT,
 + .mask_base  = MAX77693_LED_REG_FLASH_INT_MASK,
 + .mask_invert= false,
 + .num_regs   = 1,
 + .irqs   = max77693_led_irqs,
 + .num_irqs   = ARRAY_SIZE(max77693_led_irqs),
 +};
 +
 +static const struct regmap_irq max77693_topsys_irqs[] = {
 + { .mask = TOPSYS_IRQ_T120C_INT, },
 + { .mask = TOPSYS_IRQ_T140C_INT, },
 + { .mask = TOPSYS_IRQ_LOWSYS_INT, },
 +};

[...]

 +#define LED_IRQ_FLED2_OPEN   (0x1  0)
 +#define LED_IRQ_FLED2_SHORT  (0x1  1)
 +#define LED_IRQ_FLED1_OPEN   (0x1  2)
 +#define LED_IRQ_FLED1_SHORT  (0x1  3)
 +#define LED_IRQ_MAX_FLASH(0x1  4)
 +
 +#define TOPSYS_IRQ_T120C_INT (0x1  0)
 +#define TOPSYS_IRQ_T140C_INT (0x1  1)
 +#define TOPSYS_IRQ_LOWSYS_INT(0x1  3)
 +
 +#define CHG_IRQ_BYP_I(0x1  0)
 +#define CHG_IRQ_THM_I(0x1  2)
 +#define CHG_IRQ_BAT_I(0x1  3)
 +#define CHG_IRQ_CHG_I(0x1  4)
 +#define CHG_IRQ_CHGIN_I  (0x1  6)
 +
 +#define MUIC_IRQ_INT1_ADC(0x1  0)
 +#define MUIC_IRQ_INT1_ADC_LOW(0x1  1)
 +#define MUIC_IRQ_INT1_ADC_ERR(0x1  2)
 +#define MUIC_IRQ_INT1_ADC1K  (0x1  3)
 +
 +#define MUIC_IRQ_INT2_CHGTYP (0x1  0)
 +#define MUIC_IRQ_INT2_CHGDETREUN (0x1  1)
 +#define MUIC_IRQ_INT2_DCDTMR (0x1  2)
 +#define MUIC_IRQ_INT2_DXOVP  (0x1  3)
 +#define MUIC_IRQ_INT2_VBVOLT (0x1  4)
 +#define MUIC_IRQ_INT2_VIDRM  (0x1  5)
 +
 +#define MUIC_IRQ_INT3_EOC(0x1  0)
 +#define MUIC_IRQ_INT3_CGMBC  (0x1  1)
 +#define MUIC_IRQ_INT3_OVP(0x1  2)
 +#define MUIC_IRQ_INT3_MBCCHG_ERR (0x1  3)
 +#define MUIC_IRQ_INT3_CHG_ENABLED(0x1  4)
 +#define MUIC_IRQ_INT3_BAT_DET(0x1  5)

Use BIT() for these.

 +
 +

One more '\n' than you need.

[...]

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2 2/2] mfd: max77693: handle IRQs using regmap

2014-04-28 Thread Robert Baldyga
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 
---
 drivers/extcon/extcon-max77693.c |   3 +-
 drivers/mfd/Kconfig  |   1 +
 drivers/mfd/Makefile |   2 +-
 drivers/mfd/max77693-irq.c   | 346 ---
 drivers/mfd/max77693.c   | 151 ++-
 include/linux/mfd/max77693-private.h |  47 -
 6 files changed, 191 insertions(+), 359 deletions(-)
 delete mode 100644 drivers/mfd/max77693-irq.c

diff --git a/drivers/extcon/extcon-max77693.c b/drivers/extcon/extcon-max77693.c
index 0b09bf3..725190a 100644
--- a/drivers/extcon/extcon-max77693.c
+++ b/drivers/extcon/extcon-max77693.c
@@ -1154,7 +1154,8 @@ static int max77693_muic_probe(struct platform_device 
*pdev)
struct max77693_muic_irq *muic_irq = _irqs[i];
unsigned int virq = 0;
 
-   virq = irq_create_mapping(max77693->irq_domain, muic_irq->irq);
+   virq = regmap_irq_get_virq(max77693->irq_data_muic,
+   muic_irq->irq);
if (!virq) {
ret = -EINVAL;
goto err_irq;
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 67141e8..9e479d0 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -372,6 +372,7 @@ config MFD_MAX77693
depends on I2C=y
select MFD_CORE
select REGMAP_I2C
+   select REGMAP_IRQ
help
  Say yes here to add support for Maxim Semiconductor MAX77693.
  This is a companion Power Management IC with Flash, Haptic, Charger,
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 6d0f65e..b0c55e4 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -114,7 +114,7 @@ obj-$(CONFIG_MFD_DA9063)+= da9063.o
 
 obj-$(CONFIG_MFD_MAX14577) += max14577.o
 obj-$(CONFIG_MFD_MAX77686) += max77686.o max77686-irq.o
-obj-$(CONFIG_MFD_MAX77693) += max77693.o max77693-irq.o
+obj-$(CONFIG_MFD_MAX77693) += max77693.o
 obj-$(CONFIG_MFD_MAX8907)  += max8907.o
 max8925-objs   := max8925-core.o max8925-i2c.o
 obj-$(CONFIG_MFD_MAX8925)  += max8925.o
diff --git a/drivers/mfd/max77693-irq.c b/drivers/mfd/max77693-irq.c
deleted file mode 100644
index 7d8f99f..000
--- a/drivers/mfd/max77693-irq.c
+++ /dev/null
@@ -1,346 +0,0 @@
-/*
- * max77693-irq.c - Interrupt controller support for MAX77693
- *
- * Copyright (C) 2012 Samsung Electronics Co.Ltd
- * SangYoung Son 
- *
- * This program is not provided / owned by Maxim Integrated Products.
- *
- * 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 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
-static const unsigned int max77693_mask_reg[] = {
-   [LED_INT] = MAX77693_LED_REG_FLASH_INT_MASK,
-   [TOPSYS_INT] = MAX77693_PMIC_REG_TOPSYS_INT_MASK,
-   [CHG_INT] = MAX77693_CHG_REG_CHG_INT_MASK,
-   [MUIC_INT1] = MAX77693_MUIC_REG_INTMASK1,
-   [MUIC_INT2] = MAX77693_MUIC_REG_INTMASK2,
-   [MUIC_INT3] = MAX77693_MUIC_REG_INTMASK3,
-};
-
-static struct regmap *max77693_get_regmap(struct max77693_dev *max77693,
-   enum max77693_irq_source src)
-{
-   switch (src) {
-   case LED_INT ... CHG_INT:
-   return max77693->regmap;
-   case MUIC_INT1 ... MUIC_INT3:
-   return max77693->regmap_muic;
-   default:
-   return ERR_PTR(-EINVAL);
-   }
-}
-
-struct max77693_irq_data {
-   int mask;
-   enum max77693_irq_source group;
-};
-
-#define DECLARE_IRQ(idx, _group, _mask)\
-   [(idx)] = { .group = (_group), .mask = (_mask) }
-static const struct max77693_irq_data max77693_irqs[] = {
-   DECLARE_IRQ(MAX77693_LED_IRQ_FLED2_OPEN,LED_INT, 1 << 0),
-   DECLARE_IRQ(MAX77693_LED_IRQ_FLED2_SHORT,   LED_INT, 1 << 1),
-   DECLARE_IRQ(MAX77693_LED_IRQ_FLED1_OPEN,LED_INT, 1 << 2),
-   DECLARE_IRQ(MAX77693_LED_IRQ_FLED1_SHORT,   LED_INT, 1 << 3),
-   

[PATCH v2 2/2] mfd: max77693: handle IRQs using regmap

2014-04-28 Thread Robert Baldyga
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.bald...@samsung.com
---
 drivers/extcon/extcon-max77693.c |   3 +-
 drivers/mfd/Kconfig  |   1 +
 drivers/mfd/Makefile |   2 +-
 drivers/mfd/max77693-irq.c   | 346 ---
 drivers/mfd/max77693.c   | 151 ++-
 include/linux/mfd/max77693-private.h |  47 -
 6 files changed, 191 insertions(+), 359 deletions(-)
 delete mode 100644 drivers/mfd/max77693-irq.c

diff --git a/drivers/extcon/extcon-max77693.c b/drivers/extcon/extcon-max77693.c
index 0b09bf3..725190a 100644
--- a/drivers/extcon/extcon-max77693.c
+++ b/drivers/extcon/extcon-max77693.c
@@ -1154,7 +1154,8 @@ static int max77693_muic_probe(struct platform_device 
*pdev)
struct max77693_muic_irq *muic_irq = muic_irqs[i];
unsigned int virq = 0;
 
-   virq = irq_create_mapping(max77693-irq_domain, muic_irq-irq);
+   virq = regmap_irq_get_virq(max77693-irq_data_muic,
+   muic_irq-irq);
if (!virq) {
ret = -EINVAL;
goto err_irq;
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 67141e8..9e479d0 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -372,6 +372,7 @@ config MFD_MAX77693
depends on I2C=y
select MFD_CORE
select REGMAP_I2C
+   select REGMAP_IRQ
help
  Say yes here to add support for Maxim Semiconductor MAX77693.
  This is a companion Power Management IC with Flash, Haptic, Charger,
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 6d0f65e..b0c55e4 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -114,7 +114,7 @@ obj-$(CONFIG_MFD_DA9063)+= da9063.o
 
 obj-$(CONFIG_MFD_MAX14577) += max14577.o
 obj-$(CONFIG_MFD_MAX77686) += max77686.o max77686-irq.o
-obj-$(CONFIG_MFD_MAX77693) += max77693.o max77693-irq.o
+obj-$(CONFIG_MFD_MAX77693) += max77693.o
 obj-$(CONFIG_MFD_MAX8907)  += max8907.o
 max8925-objs   := max8925-core.o max8925-i2c.o
 obj-$(CONFIG_MFD_MAX8925)  += max8925.o
diff --git a/drivers/mfd/max77693-irq.c b/drivers/mfd/max77693-irq.c
deleted file mode 100644
index 7d8f99f..000
--- a/drivers/mfd/max77693-irq.c
+++ /dev/null
@@ -1,346 +0,0 @@
-/*
- * max77693-irq.c - Interrupt controller support for MAX77693
- *
- * Copyright (C) 2012 Samsung Electronics Co.Ltd
- * SangYoung Son hello@samsung.com
- *
- * This program is not provided / owned by Maxim Integrated Products.
- *
- * 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/module.h
-#include linux/irqdomain.h
-#include linux/mfd/max77693.h
-#include linux/mfd/max77693-private.h
-#include linux/regmap.h
-
-static const unsigned int max77693_mask_reg[] = {
-   [LED_INT] = MAX77693_LED_REG_FLASH_INT_MASK,
-   [TOPSYS_INT] = MAX77693_PMIC_REG_TOPSYS_INT_MASK,
-   [CHG_INT] = MAX77693_CHG_REG_CHG_INT_MASK,
-   [MUIC_INT1] = MAX77693_MUIC_REG_INTMASK1,
-   [MUIC_INT2] = MAX77693_MUIC_REG_INTMASK2,
-   [MUIC_INT3] = MAX77693_MUIC_REG_INTMASK3,
-};
-
-static struct regmap *max77693_get_regmap(struct max77693_dev *max77693,
-   enum max77693_irq_source src)
-{
-   switch (src) {
-   case LED_INT ... CHG_INT:
-   return max77693-regmap;
-   case MUIC_INT1 ... MUIC_INT3:
-   return max77693-regmap_muic;
-   default:
-   return ERR_PTR(-EINVAL);
-   }
-}
-
-struct max77693_irq_data {
-   int mask;
-   enum max77693_irq_source group;
-};
-
-#define DECLARE_IRQ(idx, _group, _mask)\
-   [(idx)] = { .group = (_group), .mask = (_mask) }
-static const struct max77693_irq_data max77693_irqs[] = {
-   DECLARE_IRQ(MAX77693_LED_IRQ_FLED2_OPEN,LED_INT, 1  0),
-   DECLARE_IRQ(MAX77693_LED_IRQ_FLED2_SHORT,   LED_INT, 1  1),
-