Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1167607 > unrolled thread
| Started by | Bjorn Andersson <bjorn.andersson@sonymobile.com> |
|---|---|
| First post | 2015-06-18 09:00 +0200 |
| Last post | 2015-06-18 09:40 +0200 |
| Articles | 2 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH 7/8] mfd: pm8921: Implement irq_get_irqchip_state Bjorn Andersson <bjorn.andersson@sonymobile.com> - 2015-06-18 09:00 +0200
Re: [PATCH 7/8] mfd: pm8921: Implement irq_get_irqchip_state Marc Zyngier <marc.zyngier@arm.com> - 2015-06-18 09:40 +0200
| From | Bjorn Andersson <bjorn.andersson@sonymobile.com> |
|---|---|
| Date | 2015-06-18 09:00 +0200 |
| Subject | [PATCH 7/8] mfd: pm8921: Implement irq_get_irqchip_state |
| Message-ID | <pCBXP-Or-9@gated-at.bofh.it> |
Implement irq_chip->irq_get_irqchip_state to make it possible for PMIC
block drivers to access the IRQ real time status bits. The status bits
are used for various kinds of input signals, e.g. GPIO.
Signed-off-by: Bjorn Andersson <bjorn.andersson@sonymobile.com>
---
This patch can be picked up independently of the rest of the series.
drivers/mfd/pm8921-core.c | 43 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 43 insertions(+)
diff --git a/drivers/mfd/pm8921-core.c b/drivers/mfd/pm8921-core.c
index 5a92646a2ccb..5f81ba0c50f5 100644
--- a/drivers/mfd/pm8921-core.c
+++ b/drivers/mfd/pm8921-core.c
@@ -236,11 +236,54 @@ static int pm8xxx_irq_set_type(struct irq_data *d, unsigned int flow_type)
return pm8xxx_config_irq(chip, block, config);
}
+static int pm8xxx_irq_get_irqchip_state(struct irq_data *d,
+ enum irqchip_irq_state which,
+ bool *state)
+{
+ struct pm_irq_chip *chip = irq_data_get_irq_chip_data(d);
+ unsigned int pmirq = irqd_to_hwirq(d);
+ unsigned int bits;
+ int irq_bit;
+ u8 block;
+ int rc;
+
+ if (!chip) {
+ pr_err("Failed to resolve pm_irq_chip\n");
+ return -EINVAL;
+ }
+
+ if (which != IRQCHIP_STATE_LINE_LEVEL)
+ return -EINVAL;
+
+ block = pmirq / 8;
+ irq_bit = pmirq % 8;
+
+ spin_lock(&chip->pm_irq_lock);
+ rc = regmap_write(chip->regmap, SSBI_REG_ADDR_IRQ_BLK_SEL, block);
+ if (rc) {
+ pr_err("Failed Selecting Block %d rc=%d\n", block, rc);
+ goto bail;
+ }
+
+ rc = regmap_read(chip->regmap, SSBI_REG_ADDR_IRQ_RT_STATUS, &bits);
+ if (rc) {
+ pr_err("Failed Reading Status rc=%d\n", rc);
+ goto bail;
+ }
+
+ *state = !!(bits & BIT(irq_bit));
+bail:
+ spin_unlock(&chip->pm_irq_lock);
+
+ return rc ? rc : 0;
+}
+
static struct irq_chip pm8xxx_irq_chip = {
.name = "pm8xxx",
.irq_mask_ack = pm8xxx_irq_mask_ack,
.irq_unmask = pm8xxx_irq_unmask,
.irq_set_type = pm8xxx_irq_set_type,
+ .irq_get_irqchip_state = pm8xxx_irq_get_irqchip_state,
.flags = IRQCHIP_MASK_ON_SUSPEND | IRQCHIP_SKIP_SET_WAKE,
};
--
1.8.2.2
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [next] | [standalone]
| From | Marc Zyngier <marc.zyngier@arm.com> |
|---|---|
| Date | 2015-06-18 09:40 +0200 |
| Message-ID | <pCCAy-1Mb-17@gated-at.bofh.it> |
| In reply to | #1167607 |
Hi Bjorn,
On 18/06/15 07:47, Bjorn Andersson wrote:
> Implement irq_chip->irq_get_irqchip_state to make it possible for PMIC
> block drivers to access the IRQ real time status bits. The status bits
> are used for various kinds of input signals, e.g. GPIO.
>
> Signed-off-by: Bjorn Andersson <bjorn.andersson@sonymobile.com>
> ---
>
> This patch can be picked up independently of the rest of the series.
>
> drivers/mfd/pm8921-core.c | 43 +++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 43 insertions(+)
>
> diff --git a/drivers/mfd/pm8921-core.c b/drivers/mfd/pm8921-core.c
> index 5a92646a2ccb..5f81ba0c50f5 100644
> --- a/drivers/mfd/pm8921-core.c
> +++ b/drivers/mfd/pm8921-core.c
> @@ -236,11 +236,54 @@ static int pm8xxx_irq_set_type(struct irq_data *d, unsigned int flow_type)
> return pm8xxx_config_irq(chip, block, config);
> }
>
> +static int pm8xxx_irq_get_irqchip_state(struct irq_data *d,
> + enum irqchip_irq_state which,
> + bool *state)
> +{
> + struct pm_irq_chip *chip = irq_data_get_irq_chip_data(d);
> + unsigned int pmirq = irqd_to_hwirq(d);
> + unsigned int bits;
> + int irq_bit;
> + u8 block;
> + int rc;
> +
> + if (!chip) {
> + pr_err("Failed to resolve pm_irq_chip\n");
> + return -EINVAL;
> + }
Why do you need to check this? Is there any code path that could
actually trigger this?
> +
> + if (which != IRQCHIP_STATE_LINE_LEVEL)
> + return -EINVAL;
> +
> + block = pmirq / 8;
> + irq_bit = pmirq % 8;
> +
> + spin_lock(&chip->pm_irq_lock);
> + rc = regmap_write(chip->regmap, SSBI_REG_ADDR_IRQ_BLK_SEL, block);
> + if (rc) {
> + pr_err("Failed Selecting Block %d rc=%d\n", block, rc);
> + goto bail;
> + }
> +
> + rc = regmap_read(chip->regmap, SSBI_REG_ADDR_IRQ_RT_STATUS, &bits);
> + if (rc) {
> + pr_err("Failed Reading Status rc=%d\n", rc);
> + goto bail;
> + }
> +
> + *state = !!(bits & BIT(irq_bit));
> +bail:
> + spin_unlock(&chip->pm_irq_lock);
> +
> + return rc ? rc : 0;
I think you can just have "return rc;" here.
> +}
> +
> static struct irq_chip pm8xxx_irq_chip = {
> .name = "pm8xxx",
> .irq_mask_ack = pm8xxx_irq_mask_ack,
> .irq_unmask = pm8xxx_irq_unmask,
> .irq_set_type = pm8xxx_irq_set_type,
> + .irq_get_irqchip_state = pm8xxx_irq_get_irqchip_state,
> .flags = IRQCHIP_MASK_ON_SUSPEND | IRQCHIP_SKIP_SET_WAKE,
> };
>
>
Thanks,
M.
--
Jazz is not dead. It just smells funny...
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web