From: Yingjoe Chen <yingjoe.chen-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
To: "Uwe Kleine-König"
<u.kleine-koenig-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
Cc: Chaotian Jing
<chaotian.jing-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>,
Rob Herring <robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
Matthias Brugger
<matthias.bgg-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
Chris Ball <chris-OsFVWbfNK3isTnJN9+BGXg@public.gmane.org>,
Ulf Hansson <ulf.hansson-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
Linus Walleij
<linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
Mark Rutland <mark.rutland-5wv7dgnIgG8@public.gmane.org>,
James Liao <jamesjj.liao-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>,
srv_heupstream-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org,
Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org>,
devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Hongzhou Yang
<hongzhou.yang-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>,
Catalin Marinas <catalin.marinas-5wv7dgnIgG8@public.gmane.org>,
linux-mmc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Will Deacon <will.deacon-5wv7dgnIgG8@public.gmane.org>,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-gpio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Sascha Hauer <kernel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>,
Eddie Huang <eddie.huang-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>,
bin.zhang-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
Subject: Re: [PATCH 1/7] pinctrl: mediatek: emulate GPIO interrupt on both-edges
Date: Tue, 10 Feb 2015 17:22:41 +0800 [thread overview]
Message-ID: <1423560161.24705.15.camel@mtksdaap41> (raw)
In-Reply-To: <20150210084021.GM10842-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
On Tue, 2015-02-10 at 09:40 +0100, Uwe Kleine-König wrote:
> Hello,
>
> On Tue, Jan 27, 2015 at 02:15:26PM +0800, Chaotian Jing wrote:
> > From: Yingjoe Chen <yingjoe.chen-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
> >
> > MTK EINT does not support generating interrupt on both edges.
> > Emulate this by changing edge polarity while enable irq,
> > set types and interrupt handling. This follows an example of
> > drivers/gpio/gpio-mxc.c.
<...>
> > +static int mtk_eint_flip_edge(struct mtk_pinctrl *pctl, int hwirq)
> > +{
> > + int start_level, curr_level;
> > + unsigned int reg_offset;
> > + const struct mtk_eint_offsets *eint_offsets = &(pctl->devdata->eint_offsets);
> > + u32 mask = 1 << (hwirq & 0x1f);
> > + u32 port = (hwirq >> 5) & eint_offsets->port_mask;
> > + void __iomem *reg = pctl->eint_reg_base + (port << 2);
> > + const struct mtk_desc_pin *pin;
> > +
> > + pin = mtk_find_pin_by_eint_num(pctl, hwirq);
> > + curr_level = mtk_gpio_get(pctl->chip, pin->pin.number);
> > + do {
> > + start_level = curr_level;
> > + if (start_level)
> > + reg_offset = eint_offsets->pol_clr;
> > + else
> > + reg_offset = eint_offsets->pol_set;
> > + writel(mask, reg + reg_offset);
> > +
> > + curr_level = mtk_gpio_get(pctl->chip, pin->pin.number);
> > + } while (start_level != curr_level);
> > +
> > + return start_level;
> > +}
> > +
> > static void mtk_eint_mask(struct irq_data *d)
> > {
> > struct mtk_pinctrl *pctl = irq_data_get_irq_chip_data(d);
> > @@ -814,6 +840,9 @@ static void mtk_eint_unmask(struct irq_data *d)
> > eint_offsets->mask_clr);
> >
> > writel(mask, reg);
> > +
> > + if (pctl->eint_dual_edges[d->hwirq])
> > + mtk_eint_flip_edge(pctl, d->hwirq);
> > }
> From looking at the code it seems to me that there is a bug. Consider
> the following to happen:
>
> pin changes level, say high to low, triggers irq
>
> irq is masked by writel(mask, reg) in mtk_eint_mask
>
> mtk_eint_flip_edge gets curr_level = low
>
> pin goes up
>
> writel(mask, reg + eint_offsets->pol_set);
>
> oh, pin is high, so: writel(mask, reg + eint_offsets->pol_clr
>
> So now you trigger the irq the next time when the pin goes down again.
> But that means to missed to trigger on the "pin goes up" in the above
> list, right?
Hi Uwe,
Yes, this could be a problem when irq happen. So I fix/workaround this
in mtk_eint_irq_handler() using soft-irq. When this bit is set, eint
will trigger the same interrupt again.
+ if (dual_edges) {
+ curr_level = mtk_eint_flip_edge(pctl, index);
+
+ /* If level changed, we might lost one edge
+ interrupt, raised it through soft-irq */
+ if (start_level != curr_level)
+ writel(BIT(offset), reg -
+ eint_offsets->stat +
+ eint_offsets->soft_set);
+ }
Joe.C
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2015-02-10 9:22 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-27 6:15 [RFC PATCH 0/7] msdc: Add mediatek MMC driver Chaotian Jing
2015-01-27 6:15 ` [PATCH 1/7] pinctrl: mediatek: emulate GPIO interrupt on both-edges Chaotian Jing
2015-01-27 14:21 ` Linus Walleij
2015-01-28 9:24 ` Yingjoe Chen
2015-01-29 7:29 ` Hongzhou Yang
2015-02-10 8:24 ` Linus Walleij
2015-02-10 8:40 ` Uwe Kleine-König
[not found] ` <20150210084021.GM10842-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2015-02-10 9:22 ` Yingjoe Chen [this message]
2015-01-27 6:15 ` [PATCH 2/7] mmc: mediatek: Add Mediatek MMC driver Chaotian Jing
2015-01-27 6:15 ` [PATCH 3/7] ARM: mediatek: Add Mediatek MMC support in multi_v7_defconfig Chaotian Jing
2015-01-27 6:15 ` [PATCH 4/7] arm64: mediatek: Add Mediatek MMC support in defconfig Chaotian Jing
2015-01-27 6:15 ` [PATCH 5/7] mmc: dt-bindings: add Mediatek MMC bindings Chaotian Jing
2015-01-27 6:15 ` [PATCH 6/7] dts: mediatek: Add MT8135 mmc dts Chaotian Jing
2015-01-27 6:15 ` [PATCH 7/7] arm64: dts: mediatek: Add MT8173 MMC dts Chaotian Jing
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=1423560161.24705.15.camel@mtksdaap41 \
--to=yingjoe.chen-nus5lvnupcjwk0htik3j/w@public.gmane.org \
--cc=arnd-r2nGTMty4D4@public.gmane.org \
--cc=bin.zhang-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org \
--cc=catalin.marinas-5wv7dgnIgG8@public.gmane.org \
--cc=chaotian.jing-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org \
--cc=chris-OsFVWbfNK3isTnJN9+BGXg@public.gmane.org \
--cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=eddie.huang-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org \
--cc=hongzhou.yang-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org \
--cc=jamesjj.liao-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org \
--cc=kernel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org \
--cc=linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=linux-gpio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-mmc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=mark.rutland-5wv7dgnIgG8@public.gmane.org \
--cc=matthias.bgg-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=srv_heupstream-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org \
--cc=u.kleine-koenig-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org \
--cc=ulf.hansson-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=will.deacon-5wv7dgnIgG8@public.gmane.org \
/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;
as well as URLs for NNTP newsgroup(s).