diff mbox

[v2,7/8] mfd: pm8921: Implement irq_get_irqchip_state

Message ID 1436942435-25611-2-git-send-email-bjorn.andersson@sonymobile.com (mailing list archive)
State Not Applicable, archived
Delegated to: Andy Gross
Headers show

Commit Message

Bjorn Andersson July 15, 2015, 6:40 a.m. UTC
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>
---

Changes since v1:
- Drop extra check for !chip
- Simplify return value

 drivers/mfd/pm8921-core.c | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

Comments

Linus Walleij July 17, 2015, 12:33 p.m. UTC | #1
On Wed, Jul 15, 2015 at 8:40 AM, Bjorn Andersson
<bjorn.andersson@sonymobile.com> 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>
> ---
>
> Changes since v1:
> - Drop extra check for !chip
> - Simplify return value

This v2 version applied for v4.3.

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Marc Zyngier July 17, 2015, 12:44 p.m. UTC | #2
On 15/07/15 07:40, 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>

Reviewed-by: Marc Zyngier <marc.zyngier@arm.com>

	M.
Linus Walleij July 17, 2015, 7:54 p.m. UTC | #3
On Fri, Jul 17, 2015 at 2:33 PM, Linus Walleij <linus.walleij@linaro.org> wrote:
> On Wed, Jul 15, 2015 at 8:40 AM, Bjorn Andersson
> <bjorn.andersson@sonymobile.com> 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>
>> ---
>>
>> Changes since v1:
>> - Drop extra check for !chip
>> - Simplify return value
>
> This v2 version applied for v4.3.

Oh wait why did I do that, that's not my driver :)

Dropped it. Lee can take it in his MFD tree.

Acked-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Lee Jones July 23, 2015, 2:47 p.m. UTC | #4
On Tue, 14 Jul 2015, 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>
> ---
> 
> Changes since v1:
> - Drop extra check for !chip
> - Simplify return value
> 
>  drivers/mfd/pm8921-core.c | 38 ++++++++++++++++++++++++++++++++++++++
>  1 file changed, 38 insertions(+)

Applied, thanks.

> diff --git a/drivers/mfd/pm8921-core.c b/drivers/mfd/pm8921-core.c
> index 5a92646a2ccb..00856a67d34b 100644
> --- a/drivers/mfd/pm8921-core.c
> +++ b/drivers/mfd/pm8921-core.c
> @@ -236,11 +236,49 @@ 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 (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;
> +}
> +
>  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,
>  };
>
diff mbox

Patch

diff --git a/drivers/mfd/pm8921-core.c b/drivers/mfd/pm8921-core.c
index 5a92646a2ccb..00856a67d34b 100644
--- a/drivers/mfd/pm8921-core.c
+++ b/drivers/mfd/pm8921-core.c
@@ -236,11 +236,49 @@  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 (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;
+}
+
 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,
 };