Commit 5306c6ad authored by Olof Johansson's avatar Olof Johansson

Merge tag 'omap-for-v4.19/omap1-v2-signed' of...

Merge tag 'omap-for-v4.19/omap1-v2-signed' of git://git.kernel.org/pub/scm/linux/kernel/git/tmlind/linux-omap into next/soc

SoC updates for omap1 for v4.19 merge window

Mostly a series by Janusz Krzysztofik to clean up the
GPIO and input handling for ams-delta. Because of the
platform data changes, we decided that it's best to
merge the related input changes also via the arm-soc
tree so Dmitry Torokhov has acked the input changes.

Also included is a change to constify gpio_leds from
Arvind Yadav.

* tag 'omap-for-v4.19/omap1-v2-signed' of git://git.kernel.org/pub/scm/linux/kernel/git/tmlind/linux-omap:
  ARM: OMAP1: ams-delta: move late devices back to init_machine
  Input: ams_delta_serio: Get FIQ buffer from platform_data
  Input: ams_delta_serio: use IRQ resource
  ARM: OMAP1: Get rid of <mach/ams-delta-fiq.h>
  ARM: OMAP1: ams-delta FIQ: Keep serio input GPIOs requested
  ARM: OMAP1: ams-delta FIQ: don't use static GPIO numbers
  ARM: OMAP1: ams-delta: Hog "keybrd_dataout" GPIO pin
  Input: ams_delta_serio: Replace power GPIO with regulator
  Input: ams_delta_serio: use private structure
  Input: ams_delta_serio: convert to platform driver
  ARM: OMAP1: ams-delta: drop GPIO lookup table for serio device
  ARM: OMAP1: ams-delta: assign LED GPIO numbers from descriptors
  ARM: OMAP1: ams-delta: refactor late_init()
  ARM: OMAP1: constify gpio_led
Signed-off-by: default avatarOlof Johansson <olof@lixom.net>
parents 9f40beb2 d08605a6
...@@ -10406,6 +10406,7 @@ F: arch/arm/plat-omap/ ...@@ -10406,6 +10406,7 @@ F: arch/arm/plat-omap/
F: arch/arm/configs/omap1_defconfig F: arch/arm/configs/omap1_defconfig
F: drivers/i2c/busses/i2c-omap.c F: drivers/i2c/busses/i2c-omap.c
F: include/linux/platform_data/i2c-omap.h F: include/linux/platform_data/i2c-omap.h
F: include/linux/platform_data/ams-delta-fiq.h
OMAP2+ SUPPORT OMAP2+ SUPPORT
M: Tony Lindgren <tony@atomide.com> M: Tony Lindgren <tony@atomide.com>
......
...@@ -14,11 +14,12 @@ ...@@ -14,11 +14,12 @@
*/ */
#include <linux/linkage.h> #include <linux/linkage.h>
#include <asm/assembler.h> #include <linux/platform_data/ams-delta-fiq.h>
#include <asm/assembler.h>
#include <mach/board-ams-delta.h> #include <mach/board-ams-delta.h>
#include <mach/ams-delta-fiq.h>
#include "ams-delta-fiq.h"
#include "iomap.h" #include "iomap.h"
#include "soc.h" #include "soc.h"
......
...@@ -13,17 +13,20 @@ ...@@ -13,17 +13,20 @@
* under the terms of the GNU General Public License version 2 as published by * under the terms of the GNU General Public License version 2 as published by
* the Free Software Foundation. * the Free Software Foundation.
*/ */
#include <linux/gpio.h> #include <linux/gpio/consumer.h>
#include <linux/gpio/driver.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/irq.h> #include <linux/irq.h>
#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_device.h>
#include <mach/board-ams-delta.h> #include <mach/board-ams-delta.h>
#include <asm/fiq.h> #include <asm/fiq.h>
#include <mach/ams-delta-fiq.h> #include "ams-delta-fiq.h"
static struct fiq_handler fh = { static struct fiq_handler fh = {
.name = "ams-delta-fiq" .name = "ams-delta-fiq"
...@@ -34,20 +37,24 @@ static struct fiq_handler fh = { ...@@ -34,20 +37,24 @@ static struct fiq_handler fh = {
* The FIQ and IRQ isrs can both read and write it. * The FIQ and IRQ isrs can both read and write it.
* It is structured as a header section several 32bit slots, * It is structured as a header section several 32bit slots,
* followed by the circular buffer where the FIQ isr stores * followed by the circular buffer where the FIQ isr stores
* keystrokes received from the qwerty keyboard. * keystrokes received from the qwerty keyboard. See
* See ams-delta-fiq.h for details of offsets. * <linux/platform_data/ams-delta-fiq.h> for details of offsets.
*/ */
unsigned int fiq_buffer[1024]; static unsigned int fiq_buffer[1024];
EXPORT_SYMBOL(fiq_buffer);
static struct irq_chip *irq_chip;
static struct irq_data *irq_data[16];
static unsigned int irq_counter[16]; static unsigned int irq_counter[16];
static const char *pin_name[16] __initconst = {
[AMS_DELTA_GPIO_PIN_KEYBRD_DATA] = "keybrd_data",
[AMS_DELTA_GPIO_PIN_KEYBRD_CLK] = "keybrd_clk",
};
static irqreturn_t deferred_fiq(int irq, void *dev_id) static irqreturn_t deferred_fiq(int irq, void *dev_id)
{ {
struct irq_data *d;
int gpio, irq_num, fiq_count; int gpio, irq_num, fiq_count;
struct irq_chip *irq_chip;
irq_chip = irq_get_chip(gpio_to_irq(AMS_DELTA_GPIO_PIN_KEYBRD_CLK));
/* /*
* For each handled GPIO interrupt, keep calling its interrupt handler * For each handled GPIO interrupt, keep calling its interrupt handler
...@@ -55,24 +62,21 @@ static irqreturn_t deferred_fiq(int irq, void *dev_id) ...@@ -55,24 +62,21 @@ static irqreturn_t deferred_fiq(int irq, void *dev_id)
*/ */
for (gpio = AMS_DELTA_GPIO_PIN_KEYBRD_CLK; for (gpio = AMS_DELTA_GPIO_PIN_KEYBRD_CLK;
gpio <= AMS_DELTA_GPIO_PIN_HOOK_SWITCH; gpio++) { gpio <= AMS_DELTA_GPIO_PIN_HOOK_SWITCH; gpio++) {
irq_num = gpio_to_irq(gpio); d = irq_data[gpio];
irq_num = d->irq;
fiq_count = fiq_buffer[FIQ_CNT_INT_00 + gpio]; fiq_count = fiq_buffer[FIQ_CNT_INT_00 + gpio];
if (irq_counter[gpio] < fiq_count && if (irq_counter[gpio] < fiq_count &&
gpio != AMS_DELTA_GPIO_PIN_KEYBRD_CLK) { gpio != AMS_DELTA_GPIO_PIN_KEYBRD_CLK) {
struct irq_data *d = irq_get_irq_data(irq_num);
/* /*
* handle_simple_irq() that OMAP GPIO edge * handle_simple_irq() that OMAP GPIO edge
* interrupts default to since commit 80ac93c27441 * interrupts default to since commit 80ac93c27441
* requires interrupt already acked and unmasked. * requires interrupt already acked and unmasked.
*/ */
if (irq_chip) { if (irq_chip->irq_ack)
if (irq_chip->irq_ack) irq_chip->irq_ack(d);
irq_chip->irq_ack(d); if (irq_chip->irq_unmask)
if (irq_chip->irq_unmask) irq_chip->irq_unmask(d);
irq_chip->irq_unmask(d);
}
} }
for (; irq_counter[gpio] < fiq_count; irq_counter[gpio]++) for (; irq_counter[gpio] < fiq_count; irq_counter[gpio]++)
generic_handle_irq(irq_num); generic_handle_irq(irq_num);
...@@ -80,14 +84,56 @@ static irqreturn_t deferred_fiq(int irq, void *dev_id) ...@@ -80,14 +84,56 @@ static irqreturn_t deferred_fiq(int irq, void *dev_id)
return IRQ_HANDLED; return IRQ_HANDLED;
} }
void __init ams_delta_init_fiq(void) void __init ams_delta_init_fiq(struct gpio_chip *chip,
struct platform_device *serio)
{ {
struct gpio_desc *gpiod, *data = NULL, *clk = NULL;
void *fiqhandler_start; void *fiqhandler_start;
unsigned int fiqhandler_length; unsigned int fiqhandler_length;
struct pt_regs FIQ_regs; struct pt_regs FIQ_regs;
unsigned long val, offset; unsigned long val, offset;
int i, retval; int i, retval;
/* Store irq_chip location for IRQ handler use */
irq_chip = chip->irq.chip;
if (!irq_chip) {
pr_err("%s: GPIO chip %s is missing IRQ function\n", __func__,
chip->label);
return;
}
for (i = 0; i < ARRAY_SIZE(irq_data); i++) {
gpiod = gpiochip_request_own_desc(chip, i, pin_name[i]);
if (IS_ERR(gpiod)) {
pr_err("%s: failed to get GPIO pin %d (%ld)\n",
__func__, i, PTR_ERR(gpiod));
return;
}
/* Store irq_data location for IRQ handler use */
irq_data[i] = irq_get_irq_data(gpiod_to_irq(gpiod));
/*
* FIQ handler takes full control over serio data and clk GPIO
* pins. Initiaize them and keep requested so nobody can
* interfere. Fail if any of those two couldn't be requested.
*/
switch (i) {
case AMS_DELTA_GPIO_PIN_KEYBRD_DATA:
data = gpiod;
gpiod_direction_input(data);
break;
case AMS_DELTA_GPIO_PIN_KEYBRD_CLK:
clk = gpiod;
gpiod_direction_input(clk);
break;
default:
gpiochip_free_own_desc(gpiod);
break;
}
}
if (!data || !clk)
goto out_gpio;
fiqhandler_start = &qwerty_fiqin_start; fiqhandler_start = &qwerty_fiqin_start;
fiqhandler_length = &qwerty_fiqin_end - &qwerty_fiqin_start; fiqhandler_length = &qwerty_fiqin_end - &qwerty_fiqin_start;
pr_info("Installing fiq handler from %p, length 0x%x\n", pr_info("Installing fiq handler from %p, length 0x%x\n",
...@@ -97,7 +143,7 @@ void __init ams_delta_init_fiq(void) ...@@ -97,7 +143,7 @@ void __init ams_delta_init_fiq(void)
if (retval) { if (retval) {
pr_err("ams_delta_init_fiq(): couldn't claim FIQ, ret=%d\n", pr_err("ams_delta_init_fiq(): couldn't claim FIQ, ret=%d\n",
retval); retval);
return; goto out_gpio;
} }
retval = request_irq(INT_DEFERRED_FIQ, deferred_fiq, retval = request_irq(INT_DEFERRED_FIQ, deferred_fiq,
...@@ -105,7 +151,7 @@ void __init ams_delta_init_fiq(void) ...@@ -105,7 +151,7 @@ void __init ams_delta_init_fiq(void)
if (retval < 0) { if (retval < 0) {
pr_err("Failed to get deferred_fiq IRQ, ret=%d\n", retval); pr_err("Failed to get deferred_fiq IRQ, ret=%d\n", retval);
release_fiq(&fh); release_fiq(&fh);
return; goto out_gpio;
} }
/* /*
* Since no set_type() method is provided by OMAP irq chip, * Since no set_type() method is provided by OMAP irq chip,
...@@ -155,4 +201,29 @@ void __init ams_delta_init_fiq(void) ...@@ -155,4 +201,29 @@ void __init ams_delta_init_fiq(void)
offset = IRQ_ILR0_REG_OFFSET + (INT_GPIO_BANK1 - NR_IRQS_LEGACY) * 0x4; offset = IRQ_ILR0_REG_OFFSET + (INT_GPIO_BANK1 - NR_IRQS_LEGACY) * 0x4;
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 and platform_data */
serio->resource[0].start = gpiod_to_irq(clk);
serio->resource[0].end = serio->resource[0].start;
serio->dev.platform_data = fiq_buffer;
/*
* 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;
out_gpio:
if (data)
gpiochip_free_own_desc(data);
if (clk)
gpiochip_free_own_desc(clk);
} }
/* SPDX-License-Identifier: GPL-2.0 */
/*
* arch/arm/mach-omap1/ams-delta-fiq.h
*
* Taken from the original Amstrad modifications to fiq.h
*
* Copyright (c) 2004 Amstrad Plc
* Copyright (c) 2006 Matt Callow
* Copyright (c) 2010 Janusz Krzysztofik
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#ifndef __AMS_DELTA_FIQ_H
#define __AMS_DELTA_FIQ_H
#include <mach/irqs.h>
/*
* Interrupt number used for passing control from FIQ to IRQ.
* IRQ12, described as reserved, has been selected.
*/
#define INT_DEFERRED_FIQ INT_1510_RES12
/*
* Base address of an interrupt handler that the INT_DEFERRED_FIQ belongs to.
*/
#if (INT_DEFERRED_FIQ < IH2_BASE)
#define DEFERRED_FIQ_IH_BASE OMAP_IH1_BASE
#else
#define DEFERRED_FIQ_IH_BASE OMAP_IH2_BASE
#endif
#ifndef __ASSEMBLER__
extern unsigned char qwerty_fiqin_start, qwerty_fiqin_end;
extern void __init ams_delta_init_fiq(struct gpio_chip *chip,
struct platform_device *pdev);
#endif
#endif
This diff is collapsed.
...@@ -274,7 +274,7 @@ static struct platform_device h2_kp_device = { ...@@ -274,7 +274,7 @@ static struct platform_device h2_kp_device = {
.resource = h2_kp_resources, .resource = h2_kp_resources,
}; };
static struct gpio_led h2_gpio_led_pins[] = { static const struct gpio_led h2_gpio_led_pins[] = {
{ {
.name = "h2:red", .name = "h2:red",
.default_trigger = "heartbeat", .default_trigger = "heartbeat",
......
...@@ -326,7 +326,7 @@ static struct spi_board_info h3_spi_board_info[] __initdata = { ...@@ -326,7 +326,7 @@ static struct spi_board_info h3_spi_board_info[] __initdata = {
}, },
}; };
static struct gpio_led h3_gpio_led_pins[] = { static const struct gpio_led h3_gpio_led_pins[] = {
{ {
.name = "h3:red", .name = "h3:red",
.default_trigger = "heartbeat", .default_trigger = "heartbeat",
......
...@@ -292,7 +292,7 @@ static struct platform_device herald_gpiokeys_device = { ...@@ -292,7 +292,7 @@ static struct platform_device herald_gpiokeys_device = {
}; };
/* LEDs for the Herald. These connect to the HTCPLD GPIO device. */ /* LEDs for the Herald. These connect to the HTCPLD GPIO device. */
static struct gpio_led gpio_leds[] = { static const struct gpio_led gpio_leds[] = {
{"dpad", NULL, HTCPLD_GPIO_LED_DPAD, 0, 0, LEDS_GPIO_DEFSTATE_OFF}, {"dpad", NULL, HTCPLD_GPIO_LED_DPAD, 0, 0, LEDS_GPIO_DEFSTATE_OFF},
{"kbd", NULL, HTCPLD_GPIO_LED_KBD, 0, 0, LEDS_GPIO_DEFSTATE_OFF}, {"kbd", NULL, HTCPLD_GPIO_LED_KBD, 0, 0, LEDS_GPIO_DEFSTATE_OFF},
{"vibrate", NULL, HTCPLD_GPIO_LED_VIBRATE, 0, 0, LEDS_GPIO_DEFSTATE_OFF}, {"vibrate", NULL, HTCPLD_GPIO_LED_VIBRATE, 0, 0, LEDS_GPIO_DEFSTATE_OFF},
......
...@@ -167,7 +167,7 @@ static struct platform_device *osk5912_devices[] __initdata = { ...@@ -167,7 +167,7 @@ static struct platform_device *osk5912_devices[] __initdata = {
&osk5912_cf_device, &osk5912_cf_device,
}; };
static struct gpio_led tps_leds[] = { static const struct gpio_led tps_leds[] = {
/* NOTE: D9 and D2 have hardware blink support. /* NOTE: D9 and D2 have hardware blink support.
* Also, D9 requires non-battery power. * Also, D9 requires non-battery power.
*/ */
...@@ -385,7 +385,7 @@ static struct platform_device osk5912_lcd_device = { ...@@ -385,7 +385,7 @@ static struct platform_device osk5912_lcd_device = {
.id = -1, .id = -1,
}; };
static struct gpio_led mistral_gpio_led_pins[] = { static const struct gpio_led mistral_gpio_led_pins[] = {
{ {
.name = "mistral:red", .name = "mistral:red",
.default_trigger = "heartbeat", .default_trigger = "heartbeat",
......
...@@ -20,32 +20,33 @@ ...@@ -20,32 +20,33 @@
* 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_device.h>
#include <linux/regulator/consumer.h>
#include <linux/serio.h> #include <linux/serio.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/module.h> #include <linux/module.h>
#include <asm/mach-types.h> #define DRIVER_NAME "ams-delta-serio"
#include <mach/board-ams-delta.h>
#include <mach/ams-delta-fiq.h>
MODULE_AUTHOR("Matt Callow"); MODULE_AUTHOR("Matt Callow");
MODULE_DESCRIPTION("AMS Delta (E3) keyboard port driver"); MODULE_DESCRIPTION("AMS Delta (E3) keyboard port driver");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
static struct serio *ams_delta_serio; struct ams_delta_serio {
struct serio *serio;
struct regulator *vcc;
unsigned int *fiq_buffer;
};
static int check_data(int data) static int check_data(struct serio *serio, int data)
{ {
int i, parity = 0; int i, parity = 0;
/* check valid stop bit */ /* check valid stop bit */
if (!(data & 0x400)) { if (!(data & 0x400)) {
dev_warn(&ams_delta_serio->dev, dev_warn(&serio->dev, "invalid stop bit, data=0x%X\n", data);
"invalid stop bit, data=0x%X\n",
data);
return SERIO_FRAME; return SERIO_FRAME;
} }
/* calculate the parity */ /* calculate the parity */
...@@ -55,9 +56,9 @@ static int check_data(int data) ...@@ -55,9 +56,9 @@ static int check_data(int data)
} }
/* it should be odd */ /* it should be odd */
if (!(parity & 0x01)) { if (!(parity & 0x01)) {
dev_warn(&ams_delta_serio->dev, dev_warn(&serio->dev,
"parity check failed, data=0x%X parity=0x%X\n", "parity check failed, data=0x%X parity=0x%X\n", data,
data, parity); parity);
return SERIO_PARITY; return SERIO_PARITY;
} }
return 0; return 0;
...@@ -65,127 +66,130 @@ static int check_data(int data) ...@@ -65,127 +66,130 @@ static int check_data(int data)
static irqreturn_t ams_delta_serio_interrupt(int irq, void *dev_id) static irqreturn_t ams_delta_serio_interrupt(int irq, void *dev_id)
{ {
int *circ_buff = &fiq_buffer[FIQ_CIRC_BUFF]; struct ams_delta_serio *priv = dev_id;
int *circ_buff = &priv->fiq_buffer[FIQ_CIRC_BUFF];
int data, dfl; int data, dfl;
u8 scancode; u8 scancode;
fiq_buffer[FIQ_IRQ_PEND] = 0; priv->fiq_buffer[FIQ_IRQ_PEND] = 0;
/* /*
* Read data from the circular buffer, check it * Read data from the circular buffer, check it
* and then pass it on the serio * and then pass it on the serio
*/ */
while (fiq_buffer[FIQ_KEYS_CNT] > 0) { while (priv->fiq_buffer[FIQ_KEYS_CNT] > 0) {
data = circ_buff[fiq_buffer[FIQ_HEAD_OFFSET]++]; data = circ_buff[priv->fiq_buffer[FIQ_HEAD_OFFSET]++];
fiq_buffer[FIQ_KEYS_CNT]--; priv->fiq_buffer[FIQ_KEYS_CNT]--;
if (fiq_buffer[FIQ_HEAD_OFFSET] == fiq_buffer[FIQ_BUF_LEN]) if (priv->fiq_buffer[FIQ_HEAD_OFFSET] ==
fiq_buffer[FIQ_HEAD_OFFSET] = 0; priv->fiq_buffer[FIQ_BUF_LEN])
priv->fiq_buffer[FIQ_HEAD_OFFSET] = 0;
dfl = check_data(data); dfl = check_data(priv->serio, data);
scancode = (u8) (data >> 1) & 0xFF; scancode = (u8) (data >> 1) & 0xFF;
serio_interrupt(ams_delta_serio, scancode, dfl); serio_interrupt(priv->serio, scancode, dfl);
} }
return IRQ_HANDLED; return IRQ_HANDLED;
} }
static int ams_delta_serio_open(struct serio *serio) static int ams_delta_serio_open(struct serio *serio)
{ {
/* enable keyboard */ struct ams_delta_serio *priv = serio->port_data;
gpio_set_value(AMS_DELTA_GPIO_PIN_KEYBRD_PWR, 1);
return 0; /* enable keyboard */
return regulator_enable(priv->vcc);
} }
static void ams_delta_serio_close(struct serio *serio) static void ams_delta_serio_close(struct serio *serio)
{ {
struct ams_delta_serio *priv = serio->port_data;
/* disable keyboard */ /* disable keyboard */
gpio_set_value(AMS_DELTA_GPIO_PIN_KEYBRD_PWR, 0); regulator_disable(priv->vcc);
} }
static const struct gpio ams_delta_gpios[] __initconst_or_module = { static int ams_delta_serio_init(struct platform_device *pdev)
{
.gpio = AMS_DELTA_GPIO_PIN_KEYBRD_DATA,
.flags = GPIOF_DIR_IN,
.label = "serio-data",
},
{
.gpio = AMS_DELTA_GPIO_PIN_KEYBRD_CLK,
.flags = GPIOF_DIR_IN,
.label = "serio-clock",
},
{
.gpio = AMS_DELTA_GPIO_PIN_KEYBRD_PWR,
.flags = GPIOF_OUT_INIT_LOW,
.label = "serio-power",
},
{
.gpio = AMS_DELTA_GPIO_PIN_KEYBRD_DATAOUT,
.flags = GPIOF_OUT_INIT_LOW,
.label = "serio-dataout",
},
};
static int __init ams_delta_serio_init(void)
{ {
int err; struct ams_delta_serio *priv;
struct serio *serio;
if (!machine_is_ams_delta()) int irq, err;
return -ENODEV;
ams_delta_serio = kzalloc(sizeof(struct serio), GFP_KERNEL); priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
if (!ams_delta_serio) if (!priv)
return -ENOMEM; return -ENOMEM;
ams_delta_serio->id.type = SERIO_8042; priv->fiq_buffer = pdev->dev.platform_data;
ams_delta_serio->open = ams_delta_serio_open; if (!priv->fiq_buffer)
ams_delta_serio->close = ams_delta_serio_close; return -EINVAL;
strlcpy(ams_delta_serio->name, "AMS DELTA keyboard adapter",
sizeof(ams_delta_serio->name)); priv->vcc = devm_regulator_get(&pdev->dev, "vcc");
strlcpy(ams_delta_serio->phys, "GPIO/serio0", if (IS_ERR(priv->vcc)) {
sizeof(ams_delta_serio->phys)); err = PTR_ERR(priv->vcc);
dev_err(&pdev->dev, "regulator request failed (%d)\n", err);
err = gpio_request_array(ams_delta_gpios, /*
ARRAY_SIZE(ams_delta_gpios)); * When running on a non-dt platform and requested regulator
if (err) { * is not available, devm_regulator_get() never returns
pr_err("ams_delta_serio: Couldn't request gpio pins\n"); * -EPROBE_DEFER as it is not able to justify if the regulator
goto serio; * may still appear later. On the other hand, the board can
* still set full constriants flag at late_initcall in order
* to instruct devm_regulator_get() to returnn a dummy one
* if sufficient. Hence, if we get -ENODEV here, let's convert
* it to -EPROBE_DEFER and wait for the board to decide or
* let Deferred Probe infrastructure handle this error.
*/
if (err == -ENODEV)
err = -EPROBE_DEFER;
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)
"ams-delta-serio", 0); 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) {
pr_err("ams_delta_serio: couldn't request gpio interrupt %d\n", dev_err(&pdev->dev, "IRQ request failed (%d)\n", err);
gpio_to_irq(AMS_DELTA_GPIO_PIN_KEYBRD_CLK)); return err;
goto gpio;
} }
/*
* 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_register_port(ams_delta_serio); serio = kzalloc(sizeof(*serio), GFP_KERNEL);
dev_info(&ams_delta_serio->dev, "%s\n", ams_delta_serio->name); if (!serio)
return -ENOMEM;
priv->serio = serio;
serio->id.type = SERIO_8042;
serio->open = ams_delta_serio_open;
serio->close = ams_delta_serio_close;
strlcpy(serio->name, "AMS DELTA keyboard adapter", sizeof(serio->name));
strlcpy(serio->phys, dev_name(&pdev->dev), sizeof(serio->phys));
serio->dev.parent = &pdev->dev;
serio->port_data = priv;
serio_register_port(serio);
platform_set_drvdata(pdev, priv);
dev_info(&serio->dev, "%s\n", serio->name);
return 0; return 0;
gpio:
gpio_free_array(ams_delta_gpios,
ARRAY_SIZE(ams_delta_gpios));
serio:
kfree(ams_delta_serio);
return err;
} }
module_init(ams_delta_serio_init);
static void __exit ams_delta_serio_exit(void) static int ams_delta_serio_exit(struct platform_device *pdev)
{ {
serio_unregister_port(ams_delta_serio); struct ams_delta_serio *priv = platform_get_drvdata(pdev);
free_irq(gpio_to_irq(AMS_DELTA_GPIO_PIN_KEYBRD_CLK), 0);
gpio_free_array(ams_delta_gpios, serio_unregister_port(priv->serio);
ARRAY_SIZE(ams_delta_gpios));
return 0;
} }
module_exit(ams_delta_serio_exit);
static struct platform_driver ams_delta_serio_driver = {
.probe = ams_delta_serio_init,
.remove = ams_delta_serio_exit,
.driver = {
.name = DRIVER_NAME
},
};
module_platform_driver(ams_delta_serio_driver);
/* SPDX-License-Identifier: GPL-2.0 */
/* /*
* arch/arm/mach-omap1/include/ams-delta-fiq.h * include/linux/platform_data/ams-delta-fiq.h
* *
* Taken from the original Amstrad modifications to fiq.h * Taken from the original Amstrad modifications to fiq.h
* *
...@@ -11,24 +13,8 @@ ...@@ -11,24 +13,8 @@
* it under the terms of the GNU General Public License version 2 as * it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation. * published by the Free Software Foundation.
*/ */
#ifndef __AMS_DELTA_FIQ_H #ifndef __LINUX_PLATFORM_DATA_AMS_DELTA_FIQ_H
#define __AMS_DELTA_FIQ_H #define __LINUX_PLATFORM_DATA_AMS_DELTA_FIQ_H
#include <mach/irqs.h>
/*
* Interrupt number used for passing control from FIQ to IRQ.
* IRQ12, described as reserved, has been selected.
*/
#define INT_DEFERRED_FIQ INT_1510_RES12
/*
* Base address of an interrupt handler that the INT_DEFERRED_FIQ belongs to.
*/
#if (INT_DEFERRED_FIQ < IH2_BASE)
#define DEFERRED_FIQ_IH_BASE OMAP_IH1_BASE
#else
#define DEFERRED_FIQ_IH_BASE OMAP_IH2_BASE
#endif
/* /*
* These are the offsets from the beginning of the fiq_buffer. They are put here * These are the offsets from the beginning of the fiq_buffer. They are put here
...@@ -69,11 +55,4 @@ ...@@ -69,11 +55,4 @@
#define FIQ_CIRC_BUFF 30 /*Start of circular buffer */ #define FIQ_CIRC_BUFF 30 /*Start of circular buffer */
#ifndef __ASSEMBLER__
extern unsigned int fiq_buffer[];
extern unsigned char qwerty_fiqin_start, qwerty_fiqin_end;
extern void __init ams_delta_init_fiq(void);
#endif
#endif #endif
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