From: Lee Jones <lee.jones@linaro.org>
To: Sebastian Reichel <sre@kernel.org>
Cc: Tony Lindgren <tony@atomide.com>,
Dmitry Torokhov <dmitry.torokhov@gmail.com>,
Rob Herring <robh+dt@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
linux-input@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCHv5] mfd: cpcap: implement irq sense helper
Date: Mon, 3 Apr 2017 11:26:15 +0100 [thread overview]
Message-ID: <20170403102615.h7i53ow2dqzpxox2@dell> (raw)
In-Reply-To: <20170329121820.14237-1-sre@kernel.org>
On Wed, 29 Mar 2017, Sebastian Reichel wrote:
> CPCAP can sense if IRQ is currently set or not. This
> functionality is required for a few subdevices, such
> as the power button and usb phy modules.
>
> Acked-by: Tony Lindgren <tony@atomide.com>
> Signed-off-by: Sebastian Reichel <sre@kernel.org>
> ---
> Changes since PATCHv3:
> - add extern to function definition
> - use BIT macro for mask variable
> - avoid magic numbers
> Changes since PATCHv4:
> - rename base to irq_base
> ---
> drivers/mfd/motorola-cpcap.c | 28 ++++++++++++++++++++++++++++
> include/linux/mfd/motorola-cpcap.h | 2 ++
> 2 files changed, 30 insertions(+)
Applied, thanks.
> diff --git a/drivers/mfd/motorola-cpcap.c b/drivers/mfd/motorola-cpcap.c
> index 6aeada7d7ce5..a9097efcefa5 100644
> --- a/drivers/mfd/motorola-cpcap.c
> +++ b/drivers/mfd/motorola-cpcap.c
> @@ -23,6 +23,8 @@
>
> #define CPCAP_NR_IRQ_REG_BANKS 6
> #define CPCAP_NR_IRQ_CHIPS 3
> +#define CPCAP_REGISTER_SIZE 4
> +#define CPCAP_REGISTER_BITS 16
>
> struct cpcap_ddata {
> struct spi_device *spi;
> @@ -32,6 +34,32 @@ struct cpcap_ddata {
> struct regmap *regmap;
> };
>
> +static int cpcap_sense_irq(struct regmap *regmap, int irq)
> +{
> + int regnum = irq / CPCAP_REGISTER_BITS;
> + int mask = BIT(irq % CPCAP_REGISTER_BITS);
> + int reg = CPCAP_REG_INTS1 + (regnum * CPCAP_REGISTER_SIZE);
> + int err, val;
> +
> + if (reg < CPCAP_REG_INTS1 || reg > CPCAP_REG_INTS4)
> + return -EINVAL;
> +
> + err = regmap_read(regmap, reg, &val);
> + if (err)
> + return err;
> +
> + return !!(val & mask);
> +}
> +
> +int cpcap_sense_virq(struct regmap *regmap, int virq)
> +{
> + struct regmap_irq_chip_data *d = irq_get_chip_data(virq);
> + int irq_base = regmap_irq_chip_get_base(d);
> +
> + return cpcap_sense_irq(regmap, virq - irq_base);
> +}
> +EXPORT_SYMBOL_GPL(cpcap_sense_virq);
> +
> static int cpcap_check_revision(struct cpcap_ddata *cpcap)
> {
> u16 vendor, rev;
> diff --git a/include/linux/mfd/motorola-cpcap.h b/include/linux/mfd/motorola-cpcap.h
> index b4031c2b2214..793aa695faa0 100644
> --- a/include/linux/mfd/motorola-cpcap.h
> +++ b/include/linux/mfd/motorola-cpcap.h
> @@ -290,3 +290,5 @@ static inline int cpcap_get_vendor(struct device *dev,
>
> return 0;
> }
> +
> +extern int cpcap_sense_virq(struct regmap *regmap, int virq);
--
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
next prev parent reply other threads:[~2017-04-03 10:26 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-21 22:50 [PATCHv3 1/2] mfd: cpcap: implement irq sense helper Sebastian Reichel
2017-03-21 22:50 ` [PATCHv3 2/2] input: cpcap-pwrbutton: new driver Sebastian Reichel
[not found] ` <20170321225042.28057-1-sre-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2017-03-23 14:23 ` [PATCHv3 1/2] mfd: cpcap: implement irq sense helper Lee Jones
2017-03-24 8:42 ` [PATCHv4] " Sebastian Reichel
2017-03-28 10:27 ` Lee Jones
2017-03-28 14:54 ` Sebastian Reichel
2017-03-29 8:04 ` Lee Jones
2017-03-29 12:18 ` [PATCHv5] " Sebastian Reichel
2017-04-03 10:26 ` Lee Jones [this message]
2017-04-10 14:27 ` Sebastian Reichel
2017-04-11 14:21 ` Lee Jones
2017-04-11 14:21 ` [GIT PULL] Immutable branch between MFD and Input due for the v4.12 merge window Lee Jones
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170403102615.h7i53ow2dqzpxox2@dell \
--to=lee.jones@linaro.org \
--cc=devicetree@vger.kernel.org \
--cc=dmitry.torokhov@gmail.com \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=robh+dt@kernel.org \
--cc=sre@kernel.org \
--cc=tony@atomide.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox