Commit a617b36b authored by Janusz Krzysztofik's avatar Janusz Krzysztofik Committed by Tony Lindgren

Input: ams_delta_serio: use IRQ resource

The driver still obtains IRQ number from a hardcoded GPIO.  Use IRQ
resource instead.

For this to work on Amstrad Delta, add the IRQ resource to
ams-delta-serio platform device structure.  Obtain the IRQ number
assigned to "keybrd_clk" GPIO pin from FIQ initialization routine.

As a benefit, the driver no longer needs to include
<mach/board-ams-delta.h>.
Signed-off-by: default avatarJanusz Krzysztofik <jmkrzyszt@gmail.com>
Acked-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: default avatarTony Lindgren <tony@atomide.com>
parent dc8fbeb0
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/platform_data/ams-delta-fiq.h> #include <linux/platform_data/ams-delta-fiq.h>
#include <linux/platform_device.h>
#include <mach/board-ams-delta.h> #include <mach/board-ams-delta.h>
...@@ -84,7 +85,8 @@ static irqreturn_t deferred_fiq(int irq, void *dev_id) ...@@ -84,7 +85,8 @@ static irqreturn_t deferred_fiq(int irq, void *dev_id)
return IRQ_HANDLED; return IRQ_HANDLED;
} }
void __init ams_delta_init_fiq(struct gpio_chip *chip) void __init ams_delta_init_fiq(struct gpio_chip *chip,
struct platform_device *serio)
{ {
struct gpio_desc *gpiod, *data = NULL, *clk = NULL; struct gpio_desc *gpiod, *data = NULL, *clk = NULL;
void *fiqhandler_start; void *fiqhandler_start;
...@@ -201,6 +203,22 @@ void __init ams_delta_init_fiq(struct gpio_chip *chip) ...@@ -201,6 +203,22 @@ void __init ams_delta_init_fiq(struct gpio_chip *chip)
val = omap_readl(OMAP_IH1_BASE + offset) | 1; val = omap_readl(OMAP_IH1_BASE + offset) | 1;
omap_writel(val, OMAP_IH1_BASE + offset); omap_writel(val, OMAP_IH1_BASE + offset);
/* Initialize serio device IRQ resource */
serio->resource[0].start = gpiod_to_irq(clk);
serio->resource[0].end = serio->resource[0].start;
/*
* Since FIQ handler performs handling of GPIO registers for
* "keybrd_clk" IRQ pin, ams_delta_serio driver used to set
* handle_simple_irq() as active IRQ handler for that pin to avoid
* bad interaction with gpio-omap driver. This is no longer needed
* as handle_simple_irq() is now the default handler for OMAP GPIO
* edge interrupts.
* This comment replaces the obsolete code which has been removed
* from the ams_delta_serio driver and stands here only as a reminder
* of that dependency on gpio-omap driver behavior.
*/
return; return;
out_gpio: out_gpio:
......
...@@ -35,7 +35,8 @@ ...@@ -35,7 +35,8 @@
#ifndef __ASSEMBLER__ #ifndef __ASSEMBLER__
extern unsigned char qwerty_fiqin_start, qwerty_fiqin_end; extern unsigned char qwerty_fiqin_start, qwerty_fiqin_end;
extern void __init ams_delta_init_fiq(struct gpio_chip *chip); extern void __init ams_delta_init_fiq(struct gpio_chip *chip,
struct platform_device *pdev);
#endif #endif
#endif #endif
...@@ -521,9 +521,24 @@ static struct platform_device cx20442_codec_device = { ...@@ -521,9 +521,24 @@ static struct platform_device cx20442_codec_device = {
.id = -1, .id = -1,
}; };
static struct resource ams_delta_serio_resources[] = {
{
.flags = IORESOURCE_IRQ,
/*
* Initialize IRQ resource with invalid IRQ number.
* It will be replaced with dynamically allocated GPIO IRQ
* obtained from GPIO chip as soon as the chip is available.
*/
.start = -EINVAL,
.end = -EINVAL,
},
};
static struct platform_device ams_delta_serio_device = { static struct platform_device ams_delta_serio_device = {
.name = "ams-delta-serio", .name = "ams-delta-serio",
.id = PLATFORM_DEVID_NONE, .id = PLATFORM_DEVID_NONE,
.num_resources = ARRAY_SIZE(ams_delta_serio_resources),
.resource = ams_delta_serio_resources,
}; };
static struct regulator_consumer_supply keybrd_pwr_consumers[] = { static struct regulator_consumer_supply keybrd_pwr_consumers[] = {
...@@ -632,7 +647,7 @@ static void __init omap_gpio_deps_init(void) ...@@ -632,7 +647,7 @@ static void __init omap_gpio_deps_init(void)
return; return;
} }
ams_delta_init_fiq(chip); ams_delta_init_fiq(chip, &ams_delta_serio_device);
} }
static void __init ams_delta_init(void) static void __init ams_delta_init(void)
......
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
* However, when used with the E3 mailboard that producecs non-standard * However, when used with the E3 mailboard that producecs non-standard
* scancodes, a custom key table must be prepared and loaded from userspace. * scancodes, a custom key table must be prepared and loaded from userspace.
*/ */
#include <linux/gpio.h>
#include <linux/irq.h> #include <linux/irq.h>
#include <linux/platform_data/ams-delta-fiq.h> #include <linux/platform_data/ams-delta-fiq.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
...@@ -29,8 +28,6 @@ ...@@ -29,8 +28,6 @@
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/module.h> #include <linux/module.h>
#include <mach/board-ams-delta.h>
#define DRIVER_NAME "ams-delta-serio" #define DRIVER_NAME "ams-delta-serio"
MODULE_AUTHOR("Matt Callow"); MODULE_AUTHOR("Matt Callow");
...@@ -113,7 +110,7 @@ static int ams_delta_serio_init(struct platform_device *pdev) ...@@ -113,7 +110,7 @@ static int ams_delta_serio_init(struct platform_device *pdev)
{ {
struct ams_delta_serio *priv; struct ams_delta_serio *priv;
struct serio *serio; struct serio *serio;
int err; int irq, err;
priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
if (!priv) if (!priv)
...@@ -139,26 +136,20 @@ static int ams_delta_serio_init(struct platform_device *pdev) ...@@ -139,26 +136,20 @@ static int ams_delta_serio_init(struct platform_device *pdev)
return err; return err;
} }
err = request_irq(gpio_to_irq(AMS_DELTA_GPIO_PIN_KEYBRD_CLK), irq = platform_get_irq(pdev, 0);
ams_delta_serio_interrupt, IRQ_TYPE_EDGE_RISING, if (irq < 0)
DRIVER_NAME, priv); return -ENXIO;
err = devm_request_irq(&pdev->dev, irq, ams_delta_serio_interrupt,
IRQ_TYPE_EDGE_RISING, DRIVER_NAME, priv);
if (err < 0) { if (err < 0) {
dev_err(&pdev->dev, "IRQ request failed (%d)\n", err); dev_err(&pdev->dev, "IRQ request failed (%d)\n", err);
return err; return err;
} }
/*
* Since GPIO register handling for keyboard clock pin is performed
* at FIQ level, switch back from edge to simple interrupt handler
* to avoid bad interaction.
*/
irq_set_handler(gpio_to_irq(AMS_DELTA_GPIO_PIN_KEYBRD_CLK),
handle_simple_irq);
serio = kzalloc(sizeof(*serio), GFP_KERNEL); serio = kzalloc(sizeof(*serio), GFP_KERNEL);
if (!serio) { if (!serio)
err = -ENOMEM; return -ENOMEM;
goto irq;
}
priv->serio = serio; priv->serio = serio;
...@@ -177,10 +168,6 @@ static int ams_delta_serio_init(struct platform_device *pdev) ...@@ -177,10 +168,6 @@ static int ams_delta_serio_init(struct platform_device *pdev)
dev_info(&serio->dev, "%s\n", serio->name); dev_info(&serio->dev, "%s\n", serio->name);
return 0; return 0;
irq:
free_irq(gpio_to_irq(AMS_DELTA_GPIO_PIN_KEYBRD_CLK), priv);
return err;
} }
static int ams_delta_serio_exit(struct platform_device *pdev) static int ams_delta_serio_exit(struct platform_device *pdev)
...@@ -188,7 +175,6 @@ static int ams_delta_serio_exit(struct platform_device *pdev) ...@@ -188,7 +175,6 @@ static int ams_delta_serio_exit(struct platform_device *pdev)
struct ams_delta_serio *priv = platform_get_drvdata(pdev); struct ams_delta_serio *priv = platform_get_drvdata(pdev);
serio_unregister_port(priv->serio); serio_unregister_port(priv->serio);
free_irq(gpio_to_irq(AMS_DELTA_GPIO_PIN_KEYBRD_CLK), 0);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment