From: Martin Fuzzey <mfuzzey@gmail.com>
To: Holger Schurig <hs4233@mail.mn-solutions.de>
Cc: linux-input@vger.kernel.org, s.hauer@pengutronix.de,
linux-arm-kernel@lists.arm.linux.org.uk
Subject: Re: [PATCH, v2] input/imx2x: generic keypad handler for i.MX SoCs
Date: Fri, 5 Jun 2009 11:51:48 +0200 [thread overview]
Message-ID: <ba4215e10906050251s1b825821kef6ae4645a10bf1b@mail.gmail.com> (raw)
In-Reply-To: <200904171640.14294.hs4233@mail.mn-solutions.de>
Hi Holger,
I've got your keypad driver running on my i.MX21 board - I had a few
problems mainly when trying to use it as a module -comments below.
> --- linux.orig/arch/arm/mach-mx2/devices.c
> +++ linux/arch/arm/mach-mx2/devices.c
...
> +
> +#ifdef CONFIG_KEYBOARD_MXC
For module needs to be
#if defined(CONFIG_KEYBOARD_MXC) || defined(CONFIG_KEYBOARD_MXC_MODULE)
But I notice the other resource definitions in this file SDHC etc
aren't conditionally compiled at all - what is the policy on this?
> +static struct resource mxc_resource_keypad[] = {
> + [0] = {
> + .start = 0x10008000,
> + .end = 0x10008014,
Why not use KPP_BASE_ADDR?
> +++ linux/drivers/input/keyboard/mxc_keypad.c
> +static void mxc_keypad_scan(unsigned long data)
> +{
> + struct mxc_keypad *kp = (struct mxc_keypad *)data;
I changed this to directly take a struct mxc_keypad * rather than a
long with a cast
> + /* Quick-discharge by setting to totem-pole, */
> + /* then turn back to open-drain */
> + __raw_writew(kp->pdata->output_pins, kp->base + KPCR);
> + wmb();
> + udelay(2);
> + __raw_writew(kp->pdata->output_pins |
> + kp->pdata->input_pins, kp->base + KPCR);
> +
I think the first write should be input_pins (need to set the output
pins bits to zero in KPCR to switch to totem pole mode.
Where does the udelay(2) come from?
Also (more for my information - I'm a bit sketchy on this) why
__raw_writel + wmb() rather than plain writel ?
> + if (col_bit & kp->pdata->output_pins) {
> + __raw_writew(~col_bit, kp->base + KPDR);
> + wmb();
> + udelay(2);
> + reg = ~__raw_readw(kp->base + KPDR);
> + keystate_cur[snum] = reg & kp->pdata->input_pins;
> +
> + if (snum++ >= MAX_INPUTS)
I was getting bounces with this - increasing the udelay(2) to 10 fixed
it but I preferred to do :
if (col_bit & kp->pdata->output_pins) {
u16 last_reg = 0;
int debounce = 0;
__raw_writew(~col_bit, kp->base + KPDR);
wmb();
while (debounce < 3) {
udelay(1);
reg = ~__raw_readw(kp->base + KPDR);
if (reg == last_reg)
debounce++;
else
debounce = 0;
last_reg = reg;
}
keystate_cur[snum] = reg & kp->pdata->input_pins;
if (snum++ >= MAX_INPUTS)
On my keyboard this exits after 4-6 loops.
> +static irqreturn_t mxc_keypad_irq_handler(int irq, void *data)
> +{
> + struct mxc_keypad *kp = data;
> + u16 stat;
> +
...
> +
> + mxc_keypad_scan((unsigned long)kp);
> +
mxc_keypad_scan(kp); as mentionned above?
> +static int __devinit mxc_keypad_probe(struct platform_device *pdev)
> +{
...
> + error = request_irq(irq, mxc_keypad_irq_handler,
> + IRQF_DISABLED, pdev->name, kp);
>
..
> +failed_free_irq:
> + free_irq(irq, pdev);
This needs to be free_irq(irq, kp) to match the request_irq
> +static int __devexit mxc_keypad_remove(struct platform_device *pdev)
> +{
..
> + free_irq(kp->irq, pdev);
Idem - this caused module ulooad / reload to fail since the IRQ was
not freed and was seen as busy the second time;
Regards,
Martin
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
prev parent reply other threads:[~2009-06-05 9:51 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-17 14:40 [PATCH, v2] input/imx2x: generic keypad handler for i.MX SoCs Holger Schurig
2009-04-17 14:55 ` Holger Schurig
2009-04-17 15:47 ` Lothar Waßmann
2009-04-17 19:23 ` Holger Schurig
2009-04-18 7:51 ` Russell King - ARM Linux
2009-04-17 15:58 ` Paulius Zaleckas
2009-04-17 19:26 ` Holger Schurig
2009-04-17 16:04 ` Dmitry Torokhov
2009-04-17 19:40 ` Holger Schurig
2009-04-18 23:15 ` Dmitry Torokhov
2009-04-20 11:08 ` Holger Schurig
2009-04-18 14:27 ` Sascha Hauer
2009-06-05 9:51 ` Martin Fuzzey [this message]
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=ba4215e10906050251s1b825821kef6ae4645a10bf1b@mail.gmail.com \
--to=mfuzzey@gmail.com \
--cc=hs4233@mail.mn-solutions.de \
--cc=linux-arm-kernel@lists.arm.linux.org.uk \
--cc=linux-input@vger.kernel.org \
--cc=s.hauer@pengutronix.de \
/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).