* [PATCH V5] mfd: da9062: add support for interrupt polarity defined in device tree @ 2020-02-17 0:44 Shreyas Joshi 2020-02-21 14:23 ` Linus Walleij 2020-02-21 14:47 ` Adam Thomson 0 siblings, 2 replies; 10+ messages in thread From: Shreyas Joshi @ 2020-02-17 0:44 UTC (permalink / raw) To: lee.jones, Support.Opensource, shreyasjoshi15, Adam.Thomson.Opensource, linus.walleij Cc: linux-kernel The da9062 interrupt handler cannot necessarily be low active. Add a function to configure the interrupt type based on what is defined in the device tree. The allowable interrupt type is either low or high level trigger. Signed-off-by: Shreyas Joshi <shreyas.joshi@biamp.com> --- drivers/mfd/da9062-core.c | 43 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/drivers/mfd/da9062-core.c b/drivers/mfd/da9062-core.c index 419c73533401..cd3c4c80699e 100644 --- a/drivers/mfd/da9062-core.c +++ b/drivers/mfd/da9062-core.c @@ -21,6 +21,9 @@ #define DA9062_REG_EVENT_B_OFFSET 1 #define DA9062_REG_EVENT_C_OFFSET 2 +#define DA9062_IRQ_LOW 0 +#define DA9062_IRQ_HIGH 1 + static struct regmap_irq da9061_irqs[] = { /* EVENT A */ [DA9061_IRQ_ONKEY] = { @@ -369,6 +372,33 @@ static int da9062_get_device_type(struct da9062 *chip) return ret; } +static u32 da9062_configure_irq_type(struct da9062 *chip, int irq, u32 *trigger) +{ + u32 irq_type = 0; + struct irq_data *irq_data = irq_get_irq_data(irq); + + if (!irq_data) { + dev_err(chip->dev, "Invalid IRQ: %d\n", irq); + return -EINVAL; + } + *trigger = irqd_get_trigger_type(irq_data); + + switch (*trigger) { + case IRQ_TYPE_LEVEL_HIGH: + irq_type = DA9062_IRQ_HIGH; + break; + case IRQ_TYPE_LEVEL_LOW: + irq_type = DA9062_IRQ_LOW; + break; + default: + dev_warn(chip->dev, "Unsupported IRQ type: %d\n", *trigger); + return -EINVAL; + } + return regmap_update_bits(chip->regmap, DA9062AA_CONFIG_A, + DA9062AA_IRQ_TYPE_MASK, + irq_type << DA9062AA_IRQ_TYPE_SHIFT); +} + static const struct regmap_range da9061_aa_readable_ranges[] = { regmap_reg_range(DA9062AA_PAGE_CON, DA9062AA_STATUS_B), regmap_reg_range(DA9062AA_STATUS_D, DA9062AA_EVENT_C), @@ -417,6 +447,7 @@ static const struct regmap_range da9061_aa_writeable_ranges[] = { regmap_reg_range(DA9062AA_VBUCK1_A, DA9062AA_VBUCK4_A), regmap_reg_range(DA9062AA_VBUCK3_A, DA9062AA_VBUCK3_A), regmap_reg_range(DA9062AA_VLDO1_A, DA9062AA_VLDO4_A), + regmap_reg_range(DA9062AA_CONFIG_A, DA9062AA_CONFIG_B), regmap_reg_range(DA9062AA_VBUCK1_B, DA9062AA_VBUCK4_B), regmap_reg_range(DA9062AA_VBUCK3_B, DA9062AA_VBUCK3_B), regmap_reg_range(DA9062AA_VLDO1_B, DA9062AA_VLDO4_B), @@ -596,6 +627,7 @@ static int da9062_i2c_probe(struct i2c_client *i2c, const struct regmap_irq_chip *irq_chip; const struct regmap_config *config; int cell_num; + u32 trigger_type = 0; int ret; chip = devm_kzalloc(&i2c->dev, sizeof(*chip), GFP_KERNEL); @@ -654,10 +686,15 @@ static int da9062_i2c_probe(struct i2c_client *i2c, if (ret) return ret; + ret = da9062_configure_irq_type(chip, i2c->irq, &trigger_type); + if (ret < 0) { + dev_err(chip->dev, "Failed to configure IRQ type\n"); + return ret; + } + ret = regmap_add_irq_chip(chip->regmap, i2c->irq, - IRQF_TRIGGER_LOW | IRQF_ONESHOT | IRQF_SHARED, - -1, irq_chip, - &chip->regmap_irq); + trigger_type | IRQF_SHARED | IRQF_ONESHOT, + -1, irq_chip, &chip->regmap_irq); if (ret) { dev_err(chip->dev, "Failed to request IRQ %d: %d\n", i2c->irq, ret); -- 2.20.1 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH V5] mfd: da9062: add support for interrupt polarity defined in device tree 2020-02-17 0:44 [PATCH V5] mfd: da9062: add support for interrupt polarity defined in device tree Shreyas Joshi @ 2020-02-21 14:23 ` Linus Walleij 2020-02-21 14:47 ` Adam Thomson 1 sibling, 0 replies; 10+ messages in thread From: Linus Walleij @ 2020-02-21 14:23 UTC (permalink / raw) To: Shreyas Joshi Cc: Lee Jones, Support Opensource, shreyasjoshi15, Adam Thomson, linux-kernel On Mon, Feb 17, 2020 at 1:44 AM Shreyas Joshi <shreyas.joshi@biamp.com> wrote: > The da9062 interrupt handler cannot necessarily be low active. > Add a function to configure the interrupt type based on what is defined in the device tree. > The allowable interrupt type is either low or high level trigger. > > Signed-off-by: Shreyas Joshi <shreyas.joshi@biamp.com> This is how I imagine it must work and how I implemented this kind of stuff in the past. Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Yours, Linus Walleij ^ permalink raw reply [flat|nested] 10+ messages in thread
* RE: [PATCH V5] mfd: da9062: add support for interrupt polarity defined in device tree 2020-02-17 0:44 [PATCH V5] mfd: da9062: add support for interrupt polarity defined in device tree Shreyas Joshi 2020-02-21 14:23 ` Linus Walleij @ 2020-02-21 14:47 ` Adam Thomson 2020-02-26 1:07 ` [PATCH V6] mfd: da9062: Add " Shreyas Joshi 2020-02-26 1:21 ` Shreyas Joshi 1 sibling, 2 replies; 10+ messages in thread From: Adam Thomson @ 2020-02-21 14:47 UTC (permalink / raw) To: Shreyas Joshi, lee.jones, Support Opensource, shreyasjoshi15, Adam Thomson, linus.walleij Cc: linux-kernel On 17 February 2020 00:44, Shreyas Joshi wrote: > The da9062 interrupt handler cannot necessarily be low active. > Add a function to configure the interrupt type based on what is defined in the > device tree. > The allowable interrupt type is either low or high level trigger. > > Signed-off-by: Shreyas Joshi <shreyas.joshi@biamp.com> > --- This is V5 of the patch and there's still no revision history information here. Please add this in the future when submitting patches as it helps reviewers understand (or reminds them) what has come before. > drivers/mfd/da9062-core.c | 43 ++++++++++++++++++++++++++++++++++++-- > - > 1 file changed, 40 insertions(+), 3 deletions(-) > > diff --git a/drivers/mfd/da9062-core.c b/drivers/mfd/da9062-core.c > index 419c73533401..cd3c4c80699e 100644 > --- a/drivers/mfd/da9062-core.c > +++ b/drivers/mfd/da9062-core.c > @@ -21,6 +21,9 @@ > #define DA9062_REG_EVENT_B_OFFSET 1 > #define DA9062_REG_EVENT_C_OFFSET 2 > > +#define DA9062_IRQ_LOW 0 > +#define DA9062_IRQ_HIGH 1 > + > static struct regmap_irq da9061_irqs[] = { > /* EVENT A */ > [DA9061_IRQ_ONKEY] = { > @@ -369,6 +372,33 @@ static int da9062_get_device_type(struct da9062 *chip) > return ret; > } > > +static u32 da9062_configure_irq_type(struct da9062 *chip, int irq, u32 *trigger) > +{ > + u32 irq_type = 0; > + struct irq_data *irq_data = irq_get_irq_data(irq); > + > + if (!irq_data) { > + dev_err(chip->dev, "Invalid IRQ: %d\n", irq); > + return -EINVAL; > + } > + *trigger = irqd_get_trigger_type(irq_data); > + > + switch (*trigger) { > + case IRQ_TYPE_LEVEL_HIGH: > + irq_type = DA9062_IRQ_HIGH; > + break; > + case IRQ_TYPE_LEVEL_LOW: > + irq_type = DA9062_IRQ_LOW; > + break; > + default: > + dev_warn(chip->dev, "Unsupported IRQ type: %d\n", *trigger); > + return -EINVAL; > + } > + return regmap_update_bits(chip->regmap, DA9062AA_CONFIG_A, > + DA9062AA_IRQ_TYPE_MASK, > + irq_type << DA9062AA_IRQ_TYPE_SHIFT); > +} > + > static const struct regmap_range da9061_aa_readable_ranges[] = { > regmap_reg_range(DA9062AA_PAGE_CON, DA9062AA_STATUS_B), > regmap_reg_range(DA9062AA_STATUS_D, DA9062AA_EVENT_C), > @@ -417,6 +447,7 @@ static const struct regmap_range > da9061_aa_writeable_ranges[] = { > regmap_reg_range(DA9062AA_VBUCK1_A, DA9062AA_VBUCK4_A), > regmap_reg_range(DA9062AA_VBUCK3_A, DA9062AA_VBUCK3_A), > regmap_reg_range(DA9062AA_VLDO1_A, DA9062AA_VLDO4_A), > + regmap_reg_range(DA9062AA_CONFIG_A, DA9062AA_CONFIG_B), Hmm. I don't believe we need access to CONFIG_B here do we? Just CONFIG_A to configure polarity. Also we will need this register to be part of the aa_readable_ranges table for regmap_update_bits() to work I believe. Otherwise I think this looks ok so will give the nod once these changes have been made. > regmap_reg_range(DA9062AA_VBUCK1_B, DA9062AA_VBUCK4_B), > regmap_reg_range(DA9062AA_VBUCK3_B, DA9062AA_VBUCK3_B), > regmap_reg_range(DA9062AA_VLDO1_B, DA9062AA_VLDO4_B), > @@ -596,6 +627,7 @@ static int da9062_i2c_probe(struct i2c_client *i2c, > const struct regmap_irq_chip *irq_chip; > const struct regmap_config *config; > int cell_num; > + u32 trigger_type = 0; > int ret; > > chip = devm_kzalloc(&i2c->dev, sizeof(*chip), GFP_KERNEL); > @@ -654,10 +686,15 @@ static int da9062_i2c_probe(struct i2c_client *i2c, > if (ret) > return ret; > > + ret = da9062_configure_irq_type(chip, i2c->irq, &trigger_type); > + if (ret < 0) { > + dev_err(chip->dev, "Failed to configure IRQ type\n"); > + return ret; > + } > + > ret = regmap_add_irq_chip(chip->regmap, i2c->irq, > - IRQF_TRIGGER_LOW | IRQF_ONESHOT | IRQF_SHARED, > - -1, irq_chip, > - &chip->regmap_irq); > + trigger_type | IRQF_SHARED | IRQF_ONESHOT, > + -1, irq_chip, &chip->regmap_irq); > if (ret) { > dev_err(chip->dev, "Failed to request IRQ %d: %d\n", > i2c->irq, ret); > -- > 2.20.1 ^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH V6] mfd: da9062: Add support for interrupt polarity defined in device tree 2020-02-21 14:47 ` Adam Thomson @ 2020-02-26 1:07 ` Shreyas Joshi 2020-02-28 17:04 ` Linus Walleij 2020-03-24 11:05 ` Lee Jones 2020-02-26 1:21 ` Shreyas Joshi 1 sibling, 2 replies; 10+ messages in thread From: Shreyas Joshi @ 2020-02-26 1:07 UTC (permalink / raw) To: lee.jones, Support.Opensource, shreyasjoshi15, Adam.Thomson.Opensource, linus.walleij Cc: linux-kernel, Shreyas Joshi The da9062 interrupt handler cannot necessarily be low active. Add a function to configure the interrupt type based on what is defined in the device tree. The allowable interrupt type is either low or high level trigger. Signed-off-by: Shreyas Joshi <shreyas.joshi@biamp.com> --- V6: Changed regmap_reg_range to exclude DA9062AA_CONFIG_B for writeable Added regmap_reg_range DA9062AA_CONFIG_A for readable V5: Added #define for DA9062_IRQ_HIGH and DA9062_IRQ_LOW V4: Changed return code to EINVAL rather than EIO for incorrect irq type Corrected regmap_update_bits usage V3: Changed regmap_write to regmap_update_bits V2: Added function to update the polarity of CONFIG_A IRQ_TYPE drivers/mfd/da9062-core.c | 44 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 3 deletions(-) diff --git a/drivers/mfd/da9062-core.c b/drivers/mfd/da9062-core.c index 419c73533401..fc30726e2e27 100644 --- a/drivers/mfd/da9062-core.c +++ b/drivers/mfd/da9062-core.c @@ -21,6 +21,9 @@ #define DA9062_REG_EVENT_B_OFFSET 1 #define DA9062_REG_EVENT_C_OFFSET 2 +#define DA9062_IRQ_LOW 0 +#define DA9062_IRQ_HIGH 1 + static struct regmap_irq da9061_irqs[] = { /* EVENT A */ [DA9061_IRQ_ONKEY] = { @@ -369,6 +372,33 @@ static int da9062_get_device_type(struct da9062 *chip) return ret; } +static u32 da9062_configure_irq_type(struct da9062 *chip, int irq, u32 *trigger) +{ + u32 irq_type = 0; + struct irq_data *irq_data = irq_get_irq_data(irq); + + if (!irq_data) { + dev_err(chip->dev, "Invalid IRQ: %d\n", irq); + return -EINVAL; + } + *trigger = irqd_get_trigger_type(irq_data); + + switch (*trigger) { + case IRQ_TYPE_LEVEL_HIGH: + irq_type = DA9062_IRQ_HIGH; + break; + case IRQ_TYPE_LEVEL_LOW: + irq_type = DA9062_IRQ_LOW; + break; + default: + dev_warn(chip->dev, "Unsupported IRQ type: %d\n", *trigger); + return -EINVAL; + } + return regmap_update_bits(chip->regmap, DA9062AA_CONFIG_A, + DA9062AA_IRQ_TYPE_MASK, + irq_type << DA9062AA_IRQ_TYPE_SHIFT); +} + static const struct regmap_range da9061_aa_readable_ranges[] = { regmap_reg_range(DA9062AA_PAGE_CON, DA9062AA_STATUS_B), regmap_reg_range(DA9062AA_STATUS_D, DA9062AA_EVENT_C), @@ -388,6 +418,7 @@ static const struct regmap_range da9061_aa_readable_ranges[] = { regmap_reg_range(DA9062AA_VBUCK1_A, DA9062AA_VBUCK4_A), regmap_reg_range(DA9062AA_VBUCK3_A, DA9062AA_VBUCK3_A), regmap_reg_range(DA9062AA_VLDO1_A, DA9062AA_VLDO4_A), + regmap_reg_range(DA9062AA_CONFIG_A, DA9062AA_CONFIG_A), regmap_reg_range(DA9062AA_VBUCK1_B, DA9062AA_VBUCK4_B), regmap_reg_range(DA9062AA_VBUCK3_B, DA9062AA_VBUCK3_B), regmap_reg_range(DA9062AA_VLDO1_B, DA9062AA_VLDO4_B), @@ -417,6 +448,7 @@ static const struct regmap_range da9061_aa_writeable_ranges[] = { regmap_reg_range(DA9062AA_VBUCK1_A, DA9062AA_VBUCK4_A), regmap_reg_range(DA9062AA_VBUCK3_A, DA9062AA_VBUCK3_A), regmap_reg_range(DA9062AA_VLDO1_A, DA9062AA_VLDO4_A), + regmap_reg_range(DA9062AA_CONFIG_A, DA9062AA_CONFIG_A), regmap_reg_range(DA9062AA_VBUCK1_B, DA9062AA_VBUCK4_B), regmap_reg_range(DA9062AA_VBUCK3_B, DA9062AA_VBUCK3_B), regmap_reg_range(DA9062AA_VLDO1_B, DA9062AA_VLDO4_B), @@ -596,6 +628,7 @@ static int da9062_i2c_probe(struct i2c_client *i2c, const struct regmap_irq_chip *irq_chip; const struct regmap_config *config; int cell_num; + u32 trigger_type = 0; int ret; chip = devm_kzalloc(&i2c->dev, sizeof(*chip), GFP_KERNEL); @@ -654,10 +687,15 @@ static int da9062_i2c_probe(struct i2c_client *i2c, if (ret) return ret; + ret = da9062_configure_irq_type(chip, i2c->irq, &trigger_type); + if (ret < 0) { + dev_err(chip->dev, "Failed to configure IRQ type\n"); + return ret; + } + ret = regmap_add_irq_chip(chip->regmap, i2c->irq, - IRQF_TRIGGER_LOW | IRQF_ONESHOT | IRQF_SHARED, - -1, irq_chip, - &chip->regmap_irq); + trigger_type | IRQF_SHARED | IRQF_ONESHOT, + -1, irq_chip, &chip->regmap_irq); if (ret) { dev_err(chip->dev, "Failed to request IRQ %d: %d\n", i2c->irq, ret); -- 2.20.1 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH V6] mfd: da9062: Add support for interrupt polarity defined in device tree 2020-02-26 1:07 ` [PATCH V6] mfd: da9062: Add " Shreyas Joshi @ 2020-02-28 17:04 ` Linus Walleij 2020-03-24 11:05 ` Lee Jones 1 sibling, 0 replies; 10+ messages in thread From: Linus Walleij @ 2020-02-28 17:04 UTC (permalink / raw) To: Shreyas Joshi Cc: Lee Jones, Support Opensource, Adam Thomson, linux-kernel, Shreyas Joshi On Wed, Feb 26, 2020 at 2:08 AM Shreyas Joshi <shreyasjoshi15@gmail.com> wrote: > The da9062 interrupt handler cannot necessarily be low active. > Add a function to configure the interrupt type based on what is defined in the device tree. > The allowable interrupt type is either low or high level trigger. > > Signed-off-by: Shreyas Joshi <shreyas.joshi@biamp.com> > --- > > V6: > Changed regmap_reg_range to exclude DA9062AA_CONFIG_B for writeable > Added regmap_reg_range DA9062AA_CONFIG_A for readable Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Yours, Linus Walleij ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH V6] mfd: da9062: Add support for interrupt polarity defined in device tree 2020-02-26 1:07 ` [PATCH V6] mfd: da9062: Add " Shreyas Joshi 2020-02-28 17:04 ` Linus Walleij @ 2020-03-24 11:05 ` Lee Jones 1 sibling, 0 replies; 10+ messages in thread From: Lee Jones @ 2020-03-24 11:05 UTC (permalink / raw) To: Shreyas Joshi Cc: Support.Opensource, Adam.Thomson.Opensource, linus.walleij, linux-kernel, Shreyas Joshi On Wed, 26 Feb 2020, Shreyas Joshi wrote: > The da9062 interrupt handler cannot necessarily be low active. > Add a function to configure the interrupt type based on what is defined in the device tree. > The allowable interrupt type is either low or high level trigger. > > Signed-off-by: Shreyas Joshi <shreyas.joshi@biamp.com> > --- > > V6: > Changed regmap_reg_range to exclude DA9062AA_CONFIG_B for writeable > Added regmap_reg_range DA9062AA_CONFIG_A for readable > > V5: > Added #define for DA9062_IRQ_HIGH and DA9062_IRQ_LOW > > V4: > Changed return code to EINVAL rather than EIO for incorrect irq type > Corrected regmap_update_bits usage > > V3: > Changed regmap_write to regmap_update_bits > > V2: > Added function to update the polarity of CONFIG_A IRQ_TYPE > > drivers/mfd/da9062-core.c | 44 ++++++++++++++++++++++++++++++++++++--- > 1 file changed, 41 insertions(+), 3 deletions(-) Applied, thanks. -- Lee Jones [李琼斯] Linaro Services Technical Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog ^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH V6] mfd: da9062: Add support for interrupt polarity defined in device tree 2020-02-21 14:47 ` Adam Thomson 2020-02-26 1:07 ` [PATCH V6] mfd: da9062: Add " Shreyas Joshi @ 2020-02-26 1:21 ` Shreyas Joshi 2020-02-28 12:16 ` Adam Thomson 2020-03-17 2:11 ` Shreyas Joshi 1 sibling, 2 replies; 10+ messages in thread From: Shreyas Joshi @ 2020-02-26 1:21 UTC (permalink / raw) To: lee.jones, Support.Opensource, shreyasjoshi15, Adam.Thomson.Opensource, linus.walleij Cc: linux-kernel, Shreyas Joshi The da9062 interrupt handler cannot necessarily be low active. Add a function to configure the interrupt type based on what is defined in the device tree. The allowable interrupt type is either low or high level trigger. Signed-off-by: Shreyas Joshi <shreyas.joshi@biamp.com> --- V6: Changed regmap_reg_range to exclude DA9062AA_CONFIG_B for writeable Added regmap_reg_range DA9062AA_CONFIG_A for readable V5: Added #define for DA9062_IRQ_HIGH and DA9062_IRQ_LOW V4: Changed return code to EINVAL rather than EIO for incorrect irq type Corrected regmap_update_bits usage V3: Changed regmap_write to regmap_update_bits V2: Added function to update the polarity of CONFIG_A IRQ_TYPE drivers/mfd/da9062-core.c | 44 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 3 deletions(-) diff --git a/drivers/mfd/da9062-core.c b/drivers/mfd/da9062-core.c index 419c73533401..fc30726e2e27 100644 --- a/drivers/mfd/da9062-core.c +++ b/drivers/mfd/da9062-core.c @@ -21,6 +21,9 @@ #define DA9062_REG_EVENT_B_OFFSET 1 #define DA9062_REG_EVENT_C_OFFSET 2 +#define DA9062_IRQ_LOW 0 +#define DA9062_IRQ_HIGH 1 + static struct regmap_irq da9061_irqs[] = { /* EVENT A */ [DA9061_IRQ_ONKEY] = { @@ -369,6 +372,33 @@ static int da9062_get_device_type(struct da9062 *chip) return ret; } +static u32 da9062_configure_irq_type(struct da9062 *chip, int irq, u32 *trigger) +{ + u32 irq_type = 0; + struct irq_data *irq_data = irq_get_irq_data(irq); + + if (!irq_data) { + dev_err(chip->dev, "Invalid IRQ: %d\n", irq); + return -EINVAL; + } + *trigger = irqd_get_trigger_type(irq_data); + + switch (*trigger) { + case IRQ_TYPE_LEVEL_HIGH: + irq_type = DA9062_IRQ_HIGH; + break; + case IRQ_TYPE_LEVEL_LOW: + irq_type = DA9062_IRQ_LOW; + break; + default: + dev_warn(chip->dev, "Unsupported IRQ type: %d\n", *trigger); + return -EINVAL; + } + return regmap_update_bits(chip->regmap, DA9062AA_CONFIG_A, + DA9062AA_IRQ_TYPE_MASK, + irq_type << DA9062AA_IRQ_TYPE_SHIFT); +} + static const struct regmap_range da9061_aa_readable_ranges[] = { regmap_reg_range(DA9062AA_PAGE_CON, DA9062AA_STATUS_B), regmap_reg_range(DA9062AA_STATUS_D, DA9062AA_EVENT_C), @@ -388,6 +418,7 @@ static const struct regmap_range da9061_aa_readable_ranges[] = { regmap_reg_range(DA9062AA_VBUCK1_A, DA9062AA_VBUCK4_A), regmap_reg_range(DA9062AA_VBUCK3_A, DA9062AA_VBUCK3_A), regmap_reg_range(DA9062AA_VLDO1_A, DA9062AA_VLDO4_A), + regmap_reg_range(DA9062AA_CONFIG_A, DA9062AA_CONFIG_A), regmap_reg_range(DA9062AA_VBUCK1_B, DA9062AA_VBUCK4_B), regmap_reg_range(DA9062AA_VBUCK3_B, DA9062AA_VBUCK3_B), regmap_reg_range(DA9062AA_VLDO1_B, DA9062AA_VLDO4_B), @@ -417,6 +448,7 @@ static const struct regmap_range da9061_aa_writeable_ranges[] = { regmap_reg_range(DA9062AA_VBUCK1_A, DA9062AA_VBUCK4_A), regmap_reg_range(DA9062AA_VBUCK3_A, DA9062AA_VBUCK3_A), regmap_reg_range(DA9062AA_VLDO1_A, DA9062AA_VLDO4_A), + regmap_reg_range(DA9062AA_CONFIG_A, DA9062AA_CONFIG_A), regmap_reg_range(DA9062AA_VBUCK1_B, DA9062AA_VBUCK4_B), regmap_reg_range(DA9062AA_VBUCK3_B, DA9062AA_VBUCK3_B), regmap_reg_range(DA9062AA_VLDO1_B, DA9062AA_VLDO4_B), @@ -596,6 +628,7 @@ static int da9062_i2c_probe(struct i2c_client *i2c, const struct regmap_irq_chip *irq_chip; const struct regmap_config *config; int cell_num; + u32 trigger_type = 0; int ret; chip = devm_kzalloc(&i2c->dev, sizeof(*chip), GFP_KERNEL); @@ -654,10 +687,15 @@ static int da9062_i2c_probe(struct i2c_client *i2c, if (ret) return ret; + ret = da9062_configure_irq_type(chip, i2c->irq, &trigger_type); + if (ret < 0) { + dev_err(chip->dev, "Failed to configure IRQ type\n"); + return ret; + } + ret = regmap_add_irq_chip(chip->regmap, i2c->irq, - IRQF_TRIGGER_LOW | IRQF_ONESHOT | IRQF_SHARED, - -1, irq_chip, - &chip->regmap_irq); + trigger_type | IRQF_SHARED | IRQF_ONESHOT, + -1, irq_chip, &chip->regmap_irq); if (ret) { dev_err(chip->dev, "Failed to request IRQ %d: %d\n", i2c->irq, ret); -- 2.20.1 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* RE: [PATCH V6] mfd: da9062: Add support for interrupt polarity defined in device tree 2020-02-26 1:21 ` Shreyas Joshi @ 2020-02-28 12:16 ` Adam Thomson 2020-03-17 2:11 ` Shreyas Joshi 1 sibling, 0 replies; 10+ messages in thread From: Adam Thomson @ 2020-02-28 12:16 UTC (permalink / raw) To: Shreyas Joshi, lee.jones, Support Opensource, shreyasjoshi15, Adam Thomson, linus.walleij Cc: linux-kernel On 26 February 2020 01:21, Shreyas Joshi wrote: > The da9062 interrupt handler cannot necessarily be low active. > Add a function to configure the interrupt type based on what is defined in the > device tree. > The allowable interrupt type is either low or high level trigger. > > Signed-off-by: Shreyas Joshi <shreyas.joshi@biamp.com> Thanks for persisting: Reviewed-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com> > --- > > V6: > Changed regmap_reg_range to exclude DA9062AA_CONFIG_B for writeable > Added regmap_reg_range DA9062AA_CONFIG_A for readable > > V5: > Added #define for DA9062_IRQ_HIGH and DA9062_IRQ_LOW > > V4: > Changed return code to EINVAL rather than EIO for incorrect irq type > Corrected regmap_update_bits usage > > V3: > Changed regmap_write to regmap_update_bits > > V2: > Added function to update the polarity of CONFIG_A IRQ_TYPE > > drivers/mfd/da9062-core.c | 44 ++++++++++++++++++++++++++++++++++++-- > - > 1 file changed, 41 insertions(+), 3 deletions(-) > > diff --git a/drivers/mfd/da9062-core.c b/drivers/mfd/da9062-core.c > index 419c73533401..fc30726e2e27 100644 > --- a/drivers/mfd/da9062-core.c > +++ b/drivers/mfd/da9062-core.c > @@ -21,6 +21,9 @@ > #define DA9062_REG_EVENT_B_OFFSET 1 > #define DA9062_REG_EVENT_C_OFFSET 2 > > +#define DA9062_IRQ_LOW 0 > +#define DA9062_IRQ_HIGH 1 > + > static struct regmap_irq da9061_irqs[] = { > /* EVENT A */ > [DA9061_IRQ_ONKEY] = { > @@ -369,6 +372,33 @@ static int da9062_get_device_type(struct da9062 *chip) > return ret; > } > > +static u32 da9062_configure_irq_type(struct da9062 *chip, int irq, u32 *trigger) > +{ > + u32 irq_type = 0; > + struct irq_data *irq_data = irq_get_irq_data(irq); > + > + if (!irq_data) { > + dev_err(chip->dev, "Invalid IRQ: %d\n", irq); > + return -EINVAL; > + } > + *trigger = irqd_get_trigger_type(irq_data); > + > + switch (*trigger) { > + case IRQ_TYPE_LEVEL_HIGH: > + irq_type = DA9062_IRQ_HIGH; > + break; > + case IRQ_TYPE_LEVEL_LOW: > + irq_type = DA9062_IRQ_LOW; > + break; > + default: > + dev_warn(chip->dev, "Unsupported IRQ type: %d\n", *trigger); > + return -EINVAL; > + } > + return regmap_update_bits(chip->regmap, DA9062AA_CONFIG_A, > + DA9062AA_IRQ_TYPE_MASK, > + irq_type << DA9062AA_IRQ_TYPE_SHIFT); > +} > + > static const struct regmap_range da9061_aa_readable_ranges[] = { > regmap_reg_range(DA9062AA_PAGE_CON, DA9062AA_STATUS_B), > regmap_reg_range(DA9062AA_STATUS_D, DA9062AA_EVENT_C), > @@ -388,6 +418,7 @@ static const struct regmap_range > da9061_aa_readable_ranges[] = { > regmap_reg_range(DA9062AA_VBUCK1_A, DA9062AA_VBUCK4_A), > regmap_reg_range(DA9062AA_VBUCK3_A, DA9062AA_VBUCK3_A), > regmap_reg_range(DA9062AA_VLDO1_A, DA9062AA_VLDO4_A), > + regmap_reg_range(DA9062AA_CONFIG_A, DA9062AA_CONFIG_A), > regmap_reg_range(DA9062AA_VBUCK1_B, DA9062AA_VBUCK4_B), > regmap_reg_range(DA9062AA_VBUCK3_B, DA9062AA_VBUCK3_B), > regmap_reg_range(DA9062AA_VLDO1_B, DA9062AA_VLDO4_B), > @@ -417,6 +448,7 @@ static const struct regmap_range > da9061_aa_writeable_ranges[] = { > regmap_reg_range(DA9062AA_VBUCK1_A, DA9062AA_VBUCK4_A), > regmap_reg_range(DA9062AA_VBUCK3_A, DA9062AA_VBUCK3_A), > regmap_reg_range(DA9062AA_VLDO1_A, DA9062AA_VLDO4_A), > + regmap_reg_range(DA9062AA_CONFIG_A, DA9062AA_CONFIG_A), > regmap_reg_range(DA9062AA_VBUCK1_B, DA9062AA_VBUCK4_B), > regmap_reg_range(DA9062AA_VBUCK3_B, DA9062AA_VBUCK3_B), > regmap_reg_range(DA9062AA_VLDO1_B, DA9062AA_VLDO4_B), > @@ -596,6 +628,7 @@ static int da9062_i2c_probe(struct i2c_client *i2c, > const struct regmap_irq_chip *irq_chip; > const struct regmap_config *config; > int cell_num; > + u32 trigger_type = 0; > int ret; > > chip = devm_kzalloc(&i2c->dev, sizeof(*chip), GFP_KERNEL); > @@ -654,10 +687,15 @@ static int da9062_i2c_probe(struct i2c_client *i2c, > if (ret) > return ret; > > + ret = da9062_configure_irq_type(chip, i2c->irq, &trigger_type); > + if (ret < 0) { > + dev_err(chip->dev, "Failed to configure IRQ type\n"); > + return ret; > + } > + > ret = regmap_add_irq_chip(chip->regmap, i2c->irq, > - IRQF_TRIGGER_LOW | IRQF_ONESHOT | IRQF_SHARED, > - -1, irq_chip, > - &chip->regmap_irq); > + trigger_type | IRQF_SHARED | IRQF_ONESHOT, > + -1, irq_chip, &chip->regmap_irq); > if (ret) { > dev_err(chip->dev, "Failed to request IRQ %d: %d\n", > i2c->irq, ret); > -- > 2.20.1 ^ permalink raw reply [flat|nested] 10+ messages in thread
* RE: [PATCH V6] mfd: da9062: Add support for interrupt polarity defined in device tree 2020-02-26 1:21 ` Shreyas Joshi 2020-02-28 12:16 ` Adam Thomson @ 2020-03-17 2:11 ` Shreyas Joshi 2020-03-20 9:36 ` Adam Thomson 1 sibling, 1 reply; 10+ messages in thread From: Shreyas Joshi @ 2020-03-17 2:11 UTC (permalink / raw) To: Shreyas Joshi, lee.jones, Support.Opensource, shreyasjoshi15, Adam.Thomson.Opensource, linus.walleij Cc: linux-kernel Thanks for the review! Has it already merged now? I am using this link to see my patch - https://lore.kernel.org/patchwork/patch/1200436/ I am not aware of the process like how it goes to the mainline. Thanks Shreyas Joshi -----Original Message----- From: Shreyas Joshi <shreyas.joshi@biamp.com> Sent: Wednesday, 26 February 2020 11:22 AM To: lee.jones@linaro.org; Support.Opensource@diasemi.com; shreyasjoshi15@gmail.com; Adam.Thomson.Opensource@diasemi.com; linus.walleij@linaro.org Cc: linux-kernel@vger.kernel.org; Shreyas Joshi <Shreyas.Joshi@biamp.com> Subject: [PATCH V6] mfd: da9062: Add support for interrupt polarity defined in device tree The da9062 interrupt handler cannot necessarily be low active. Add a function to configure the interrupt type based on what is defined in the device tree. The allowable interrupt type is either low or high level trigger. Signed-off-by: Shreyas Joshi <shreyas.joshi@biamp.com> --- V6: Changed regmap_reg_range to exclude DA9062AA_CONFIG_B for writeable Added regmap_reg_range DA9062AA_CONFIG_A for readable V5: Added #define for DA9062_IRQ_HIGH and DA9062_IRQ_LOW V4: Changed return code to EINVAL rather than EIO for incorrect irq type Corrected regmap_update_bits usage V3: Changed regmap_write to regmap_update_bits V2: Added function to update the polarity of CONFIG_A IRQ_TYPE drivers/mfd/da9062-core.c | 44 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 3 deletions(-) diff --git a/drivers/mfd/da9062-core.c b/drivers/mfd/da9062-core.c index 419c73533401..fc30726e2e27 100644 --- a/drivers/mfd/da9062-core.c +++ b/drivers/mfd/da9062-core.c @@ -21,6 +21,9 @@ #define DA9062_REG_EVENT_B_OFFSET 1 #define DA9062_REG_EVENT_C_OFFSET 2 +#define DA9062_IRQ_LOW 0 +#define DA9062_IRQ_HIGH 1 + static struct regmap_irq da9061_irqs[] = { /* EVENT A */ [DA9061_IRQ_ONKEY] = { @@ -369,6 +372,33 @@ static int da9062_get_device_type(struct da9062 *chip) return ret; } +static u32 da9062_configure_irq_type(struct da9062 *chip, int irq, u32 +*trigger) { + u32 irq_type = 0; + struct irq_data *irq_data = irq_get_irq_data(irq); + + if (!irq_data) { + dev_err(chip->dev, "Invalid IRQ: %d\n", irq); + return -EINVAL; + } + *trigger = irqd_get_trigger_type(irq_data); + + switch (*trigger) { + case IRQ_TYPE_LEVEL_HIGH: + irq_type = DA9062_IRQ_HIGH; + break; + case IRQ_TYPE_LEVEL_LOW: + irq_type = DA9062_IRQ_LOW; + break; + default: + dev_warn(chip->dev, "Unsupported IRQ type: %d\n", *trigger); + return -EINVAL; + } + return regmap_update_bits(chip->regmap, DA9062AA_CONFIG_A, + DA9062AA_IRQ_TYPE_MASK, + irq_type << DA9062AA_IRQ_TYPE_SHIFT); } + static const struct regmap_range da9061_aa_readable_ranges[] = { regmap_reg_range(DA9062AA_PAGE_CON, DA9062AA_STATUS_B), regmap_reg_range(DA9062AA_STATUS_D, DA9062AA_EVENT_C), @@ -388,6 +418,7 @@ static const struct regmap_range da9061_aa_readable_ranges[] = { regmap_reg_range(DA9062AA_VBUCK1_A, DA9062AA_VBUCK4_A), regmap_reg_range(DA9062AA_VBUCK3_A, DA9062AA_VBUCK3_A), regmap_reg_range(DA9062AA_VLDO1_A, DA9062AA_VLDO4_A), + regmap_reg_range(DA9062AA_CONFIG_A, DA9062AA_CONFIG_A), regmap_reg_range(DA9062AA_VBUCK1_B, DA9062AA_VBUCK4_B), regmap_reg_range(DA9062AA_VBUCK3_B, DA9062AA_VBUCK3_B), regmap_reg_range(DA9062AA_VLDO1_B, DA9062AA_VLDO4_B), @@ -417,6 +448,7 @@ static const struct regmap_range da9061_aa_writeable_ranges[] = { regmap_reg_range(DA9062AA_VBUCK1_A, DA9062AA_VBUCK4_A), regmap_reg_range(DA9062AA_VBUCK3_A, DA9062AA_VBUCK3_A), regmap_reg_range(DA9062AA_VLDO1_A, DA9062AA_VLDO4_A), + regmap_reg_range(DA9062AA_CONFIG_A, DA9062AA_CONFIG_A), regmap_reg_range(DA9062AA_VBUCK1_B, DA9062AA_VBUCK4_B), regmap_reg_range(DA9062AA_VBUCK3_B, DA9062AA_VBUCK3_B), regmap_reg_range(DA9062AA_VLDO1_B, DA9062AA_VLDO4_B), @@ -596,6 +628,7 @@ static int da9062_i2c_probe(struct i2c_client *i2c, const struct regmap_irq_chip *irq_chip; const struct regmap_config *config; int cell_num; + u32 trigger_type = 0; int ret; chip = devm_kzalloc(&i2c->dev, sizeof(*chip), GFP_KERNEL); @@ -654,10 +687,15 @@ static int da9062_i2c_probe(struct i2c_client *i2c, if (ret) return ret; + ret = da9062_configure_irq_type(chip, i2c->irq, &trigger_type); + if (ret < 0) { + dev_err(chip->dev, "Failed to configure IRQ type\n"); + return ret; + } + ret = regmap_add_irq_chip(chip->regmap, i2c->irq, - IRQF_TRIGGER_LOW | IRQF_ONESHOT | IRQF_SHARED, - -1, irq_chip, - &chip->regmap_irq); + trigger_type | IRQF_SHARED | IRQF_ONESHOT, + -1, irq_chip, &chip->regmap_irq); if (ret) { dev_err(chip->dev, "Failed to request IRQ %d: %d\n", i2c->irq, ret); -- 2.20.1 ^ permalink raw reply [flat|nested] 10+ messages in thread
* RE: [PATCH V6] mfd: da9062: Add support for interrupt polarity defined in device tree 2020-03-17 2:11 ` Shreyas Joshi @ 2020-03-20 9:36 ` Adam Thomson 0 siblings, 0 replies; 10+ messages in thread From: Adam Thomson @ 2020-03-20 9:36 UTC (permalink / raw) To: Shreyas Joshi, lee.jones, Support Opensource, shreyasjoshi15, Adam Thomson, linus.walleij Cc: linux-kernel On 17 March 2020 02:11, Shreyas Joshi wrote: > Thanks for the review! Has it already merged now? > I am using this link to see my patch > - https://lore.kernel.org/patchwork/patch/1200436/ > I am not aware of the process like how it goes to the mainline. When Lee has had time to review and accepts the change he will send an e-mail confirming. As far as I'm aware this hasn't yet happened. Also check his fork of the kernel as well: https://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd.git/ > > Thanks > Shreyas Joshi > > > -----Original Message----- > From: Shreyas Joshi <shreyas.joshi@biamp.com> > Sent: Wednesday, 26 February 2020 11:22 AM > To: lee.jones@linaro.org; Support.Opensource@diasemi.com; > shreyasjoshi15@gmail.com; Adam.Thomson.Opensource@diasemi.com; > linus.walleij@linaro.org > Cc: linux-kernel@vger.kernel.org; Shreyas Joshi <Shreyas.Joshi@biamp.com> > Subject: [PATCH V6] mfd: da9062: Add support for interrupt polarity defined in > device tree > > The da9062 interrupt handler cannot necessarily be low active. > Add a function to configure the interrupt type based on what is defined in the > device tree. > The allowable interrupt type is either low or high level trigger. > > Signed-off-by: Shreyas Joshi <shreyas.joshi@biamp.com> > --- > > V6: > Changed regmap_reg_range to exclude DA9062AA_CONFIG_B for writeable > Added regmap_reg_range DA9062AA_CONFIG_A for readable > > V5: > Added #define for DA9062_IRQ_HIGH and DA9062_IRQ_LOW > > V4: > Changed return code to EINVAL rather than EIO for incorrect irq type > Corrected regmap_update_bits usage > > V3: > Changed regmap_write to regmap_update_bits > > V2: > Added function to update the polarity of CONFIG_A IRQ_TYPE > > drivers/mfd/da9062-core.c | 44 ++++++++++++++++++++++++++++++++++++-- > - > 1 file changed, 41 insertions(+), 3 deletions(-) > > diff --git a/drivers/mfd/da9062-core.c b/drivers/mfd/da9062-core.c index > 419c73533401..fc30726e2e27 100644 > --- a/drivers/mfd/da9062-core.c > +++ b/drivers/mfd/da9062-core.c > @@ -21,6 +21,9 @@ > #define DA9062_REG_EVENT_B_OFFSET 1 > #define DA9062_REG_EVENT_C_OFFSET 2 > > +#define DA9062_IRQ_LOW 0 > +#define DA9062_IRQ_HIGH 1 > + > static struct regmap_irq da9061_irqs[] = { > /* EVENT A */ > [DA9061_IRQ_ONKEY] = { > @@ -369,6 +372,33 @@ static int da9062_get_device_type(struct da9062 *chip) > return ret; > } > > +static u32 da9062_configure_irq_type(struct da9062 *chip, int irq, u32 > +*trigger) { > + u32 irq_type = 0; > + struct irq_data *irq_data = irq_get_irq_data(irq); > + > + if (!irq_data) { > + dev_err(chip->dev, "Invalid IRQ: %d\n", irq); > + return -EINVAL; > + } > + *trigger = irqd_get_trigger_type(irq_data); > + > + switch (*trigger) { > + case IRQ_TYPE_LEVEL_HIGH: > + irq_type = DA9062_IRQ_HIGH; > + break; > + case IRQ_TYPE_LEVEL_LOW: > + irq_type = DA9062_IRQ_LOW; > + break; > + default: > + dev_warn(chip->dev, "Unsupported IRQ type: %d\n", *trigger); > + return -EINVAL; > + } > + return regmap_update_bits(chip->regmap, DA9062AA_CONFIG_A, > + DA9062AA_IRQ_TYPE_MASK, > + irq_type << DA9062AA_IRQ_TYPE_SHIFT); } > + > static const struct regmap_range da9061_aa_readable_ranges[] = { > regmap_reg_range(DA9062AA_PAGE_CON, DA9062AA_STATUS_B), > regmap_reg_range(DA9062AA_STATUS_D, DA9062AA_EVENT_C), @@ - > 388,6 +418,7 @@ static const struct regmap_range da9061_aa_readable_ranges[] > = { > regmap_reg_range(DA9062AA_VBUCK1_A, DA9062AA_VBUCK4_A), > regmap_reg_range(DA9062AA_VBUCK3_A, DA9062AA_VBUCK3_A), > regmap_reg_range(DA9062AA_VLDO1_A, DA9062AA_VLDO4_A), > + regmap_reg_range(DA9062AA_CONFIG_A, DA9062AA_CONFIG_A), > regmap_reg_range(DA9062AA_VBUCK1_B, DA9062AA_VBUCK4_B), > regmap_reg_range(DA9062AA_VBUCK3_B, DA9062AA_VBUCK3_B), > regmap_reg_range(DA9062AA_VLDO1_B, DA9062AA_VLDO4_B), @@ - > 417,6 +448,7 @@ static const struct regmap_range > da9061_aa_writeable_ranges[] = { > regmap_reg_range(DA9062AA_VBUCK1_A, DA9062AA_VBUCK4_A), > regmap_reg_range(DA9062AA_VBUCK3_A, DA9062AA_VBUCK3_A), > regmap_reg_range(DA9062AA_VLDO1_A, DA9062AA_VLDO4_A), > + regmap_reg_range(DA9062AA_CONFIG_A, DA9062AA_CONFIG_A), > regmap_reg_range(DA9062AA_VBUCK1_B, DA9062AA_VBUCK4_B), > regmap_reg_range(DA9062AA_VBUCK3_B, DA9062AA_VBUCK3_B), > regmap_reg_range(DA9062AA_VLDO1_B, DA9062AA_VLDO4_B), @@ - > 596,6 +628,7 @@ static int da9062_i2c_probe(struct i2c_client *i2c, > const struct regmap_irq_chip *irq_chip; > const struct regmap_config *config; > int cell_num; > + u32 trigger_type = 0; > int ret; > > chip = devm_kzalloc(&i2c->dev, sizeof(*chip), GFP_KERNEL); @@ -654,10 > +687,15 @@ static int da9062_i2c_probe(struct i2c_client *i2c, > if (ret) > return ret; > > + ret = da9062_configure_irq_type(chip, i2c->irq, &trigger_type); > + if (ret < 0) { > + dev_err(chip->dev, "Failed to configure IRQ type\n"); > + return ret; > + } > + > ret = regmap_add_irq_chip(chip->regmap, i2c->irq, > - IRQF_TRIGGER_LOW | IRQF_ONESHOT | IRQF_SHARED, > - -1, irq_chip, > - &chip->regmap_irq); > + trigger_type | IRQF_SHARED | IRQF_ONESHOT, > + -1, irq_chip, &chip->regmap_irq); > if (ret) { > dev_err(chip->dev, "Failed to request IRQ %d: %d\n", > i2c->irq, ret); > -- > 2.20.1 ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2020-03-24 11:05 UTC | newest] Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2020-02-17 0:44 [PATCH V5] mfd: da9062: add support for interrupt polarity defined in device tree Shreyas Joshi 2020-02-21 14:23 ` Linus Walleij 2020-02-21 14:47 ` Adam Thomson 2020-02-26 1:07 ` [PATCH V6] mfd: da9062: Add " Shreyas Joshi 2020-02-28 17:04 ` Linus Walleij 2020-03-24 11:05 ` Lee Jones 2020-02-26 1:21 ` Shreyas Joshi 2020-02-28 12:16 ` Adam Thomson 2020-03-17 2:11 ` Shreyas Joshi 2020-03-20 9:36 ` Adam Thomson
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).