8e5c0abfa0
- streamlined logic in input core for handling normal input handlers vs input filters - updates to input drivers to allocate memory with sizeof(*pointer) instead of sizeof(type) - change to ads7846 touchscreen driver to use hsync GPIO instead of requiring platform data with special method (which is not compatible with boards using device tree) - update to adc-joystick driver to handle inverted axes - cleanups in various drivers switching them to use the new "guard" and "__free()" facilities - changes to several drivers (adxl34x, atmel_mxt_ts, ati-remote2, omap-keypad, yealink) to stop creating driver-specific device attributes manually and use driver core facilities for this - update to Cypress PS/2 protocol driver to properly handle errors from the PS/2 transport as well as other cleanups - update to edt-ft5x06 driver to support ft5426 variant - update to ektf2127 driver to support ektf2232 variant - update to exc3000 driver to support EXC81W32 variant - update to imagis driver to support IST3038 variant - other assorted driver cleanups. -----BEGIN PGP SIGNATURE----- iHUEABYIAB0WIQST2eWILY88ieB2DOtAj56VGEWXnAUCZpWmqQAKCRBAj56VGEWX nE00AQDsikkxIpF5GJo3mhHLHQc5noEB/zwwLNTqEmV/ThdffwD/bQmr0C0M1dhz fOM9NqeyhwKkgGd389AIzv/dV7KIGwI= =rQCl -----END PGP SIGNATURE----- Merge tag 'input-for-v6.11-rc0' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input Pull input updates from Dmitry Torokhov: - streamlined logic in input core for handling normal input handlers vs input filters - updates to input drivers to allocate memory with sizeof(*pointer) instead of sizeof(type) - change to ads7846 touchscreen driver to use hsync GPIO instead of requiring platform data with special method (which is not compatible with boards using device tree) - update to adc-joystick driver to handle inverted axes - cleanups in various drivers switching them to use the new "guard" and "__free()" facilities - changes to several drivers (adxl34x, atmel_mxt_ts, ati-remote2, omap-keypad, yealink) to stop creating driver-specific device attributes manually and use driver core facilities for this - update to Cypress PS/2 protocol driver to properly handle errors from the PS/2 transport as well as other cleanups - update to edt-ft5x06 driver to support ft5426 variant - update to ektf2127 driver to support ektf2232 variant - update to exc3000 driver to support EXC81W32 variant - update to imagis driver to support IST3038 variant - other assorted driver cleanups. * tag 'input-for-v6.11-rc0' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input: (71 commits) Input: yealink - simplify locking in sysfs attribute handling Input: yealink - use driver core to instantiate device attributes Input: ati-remote2 - use driver core to instantiate device attributes Input: omap-keypad - use driver core to instantiate device attributes Input: atmel_mxt_ts - use driver core to instantiate device attributes Input: exc3000 - add EXC81W32 support dt-bindings: input: touchscreen: exc3000: add EXC81W32 Input: twl4030-pwrbutton - fix kernel-doc warning Input: himax_hx83112b - add support for HX83100A Input: himax_hx83112b - add himax_chip struct for multi-chip support Input: himax_hx83112b - implement MCU register reading Input: himax_hx83112b - use more descriptive register defines dt-bindings: input: touchscreen: himax,hx83112b: add HX83100A Input: do not check number of events in input_pass_values() Input: preallocate memory to hold event values Input: rearrange input_alloc_device() to prepare for preallocating of vals Input: simplify event handling logic Input: make events() method return number of events processed Input: make sure input handlers define only one processing method Input: evdev - remove ->event() method ...
210 lines
4.1 KiB
C
210 lines
4.1 KiB
C
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
/*
|
|
* linux/drivers/input/serio/ambakmi.c
|
|
*
|
|
* Copyright (C) 2000-2003 Deep Blue Solutions Ltd.
|
|
* Copyright (C) 2002 Russell King.
|
|
*/
|
|
#include <linux/module.h>
|
|
#include <linux/serio.h>
|
|
#include <linux/errno.h>
|
|
#include <linux/interrupt.h>
|
|
#include <linux/ioport.h>
|
|
#include <linux/device.h>
|
|
#include <linux/delay.h>
|
|
#include <linux/slab.h>
|
|
#include <linux/err.h>
|
|
#include <linux/amba/bus.h>
|
|
#include <linux/amba/kmi.h>
|
|
#include <linux/clk.h>
|
|
|
|
#include <asm/io.h>
|
|
#include <asm/irq.h>
|
|
|
|
#define KMI_BASE (kmi->base)
|
|
|
|
struct amba_kmi_port {
|
|
struct serio *io;
|
|
struct clk *clk;
|
|
void __iomem *base;
|
|
unsigned int irq;
|
|
unsigned int divisor;
|
|
unsigned int open;
|
|
};
|
|
|
|
static irqreturn_t amba_kmi_int(int irq, void *dev_id)
|
|
{
|
|
struct amba_kmi_port *kmi = dev_id;
|
|
unsigned int status = readb(KMIIR);
|
|
int handled = IRQ_NONE;
|
|
|
|
while (status & KMIIR_RXINTR) {
|
|
serio_interrupt(kmi->io, readb(KMIDATA), 0);
|
|
status = readb(KMIIR);
|
|
handled = IRQ_HANDLED;
|
|
}
|
|
|
|
return handled;
|
|
}
|
|
|
|
static int amba_kmi_write(struct serio *io, unsigned char val)
|
|
{
|
|
struct amba_kmi_port *kmi = io->port_data;
|
|
unsigned int timeleft = 10000; /* timeout in 100ms */
|
|
|
|
while ((readb(KMISTAT) & KMISTAT_TXEMPTY) == 0 && --timeleft)
|
|
udelay(10);
|
|
|
|
if (timeleft)
|
|
writeb(val, KMIDATA);
|
|
|
|
return timeleft ? 0 : SERIO_TIMEOUT;
|
|
}
|
|
|
|
static int amba_kmi_open(struct serio *io)
|
|
{
|
|
struct amba_kmi_port *kmi = io->port_data;
|
|
unsigned int divisor;
|
|
int ret;
|
|
|
|
ret = clk_prepare_enable(kmi->clk);
|
|
if (ret)
|
|
goto out;
|
|
|
|
divisor = clk_get_rate(kmi->clk) / 8000000 - 1;
|
|
writeb(divisor, KMICLKDIV);
|
|
writeb(KMICR_EN, KMICR);
|
|
|
|
ret = request_irq(kmi->irq, amba_kmi_int, IRQF_SHARED, "kmi-pl050",
|
|
kmi);
|
|
if (ret) {
|
|
printk(KERN_ERR "kmi: failed to claim IRQ%d\n", kmi->irq);
|
|
writeb(0, KMICR);
|
|
goto clk_disable;
|
|
}
|
|
|
|
writeb(KMICR_EN | KMICR_RXINTREN, KMICR);
|
|
|
|
return 0;
|
|
|
|
clk_disable:
|
|
clk_disable_unprepare(kmi->clk);
|
|
out:
|
|
return ret;
|
|
}
|
|
|
|
static void amba_kmi_close(struct serio *io)
|
|
{
|
|
struct amba_kmi_port *kmi = io->port_data;
|
|
|
|
writeb(0, KMICR);
|
|
|
|
free_irq(kmi->irq, kmi);
|
|
clk_disable_unprepare(kmi->clk);
|
|
}
|
|
|
|
static int amba_kmi_probe(struct amba_device *dev,
|
|
const struct amba_id *id)
|
|
{
|
|
struct amba_kmi_port *kmi;
|
|
struct serio *io;
|
|
int ret;
|
|
|
|
ret = amba_request_regions(dev, NULL);
|
|
if (ret)
|
|
return ret;
|
|
|
|
kmi = kzalloc(sizeof(*kmi), GFP_KERNEL);
|
|
io = kzalloc(sizeof(*io), GFP_KERNEL);
|
|
if (!kmi || !io) {
|
|
ret = -ENOMEM;
|
|
goto out;
|
|
}
|
|
|
|
|
|
io->id.type = SERIO_8042;
|
|
io->write = amba_kmi_write;
|
|
io->open = amba_kmi_open;
|
|
io->close = amba_kmi_close;
|
|
strscpy(io->name, dev_name(&dev->dev), sizeof(io->name));
|
|
strscpy(io->phys, dev_name(&dev->dev), sizeof(io->phys));
|
|
io->port_data = kmi;
|
|
io->dev.parent = &dev->dev;
|
|
|
|
kmi->io = io;
|
|
kmi->base = ioremap(dev->res.start, resource_size(&dev->res));
|
|
if (!kmi->base) {
|
|
ret = -ENOMEM;
|
|
goto out;
|
|
}
|
|
|
|
kmi->clk = clk_get(&dev->dev, "KMIREFCLK");
|
|
if (IS_ERR(kmi->clk)) {
|
|
ret = PTR_ERR(kmi->clk);
|
|
goto unmap;
|
|
}
|
|
|
|
kmi->irq = dev->irq[0];
|
|
amba_set_drvdata(dev, kmi);
|
|
|
|
serio_register_port(kmi->io);
|
|
return 0;
|
|
|
|
unmap:
|
|
iounmap(kmi->base);
|
|
out:
|
|
kfree(kmi);
|
|
kfree(io);
|
|
amba_release_regions(dev);
|
|
return ret;
|
|
}
|
|
|
|
static void amba_kmi_remove(struct amba_device *dev)
|
|
{
|
|
struct amba_kmi_port *kmi = amba_get_drvdata(dev);
|
|
|
|
serio_unregister_port(kmi->io);
|
|
clk_put(kmi->clk);
|
|
iounmap(kmi->base);
|
|
kfree(kmi);
|
|
amba_release_regions(dev);
|
|
}
|
|
|
|
static int amba_kmi_resume(struct device *dev)
|
|
{
|
|
struct amba_kmi_port *kmi = dev_get_drvdata(dev);
|
|
|
|
/* kick the serio layer to rescan this port */
|
|
serio_reconnect(kmi->io);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static DEFINE_SIMPLE_DEV_PM_OPS(amba_kmi_dev_pm_ops, NULL, amba_kmi_resume);
|
|
|
|
static const struct amba_id amba_kmi_idtable[] = {
|
|
{
|
|
.id = 0x00041050,
|
|
.mask = 0x000fffff,
|
|
},
|
|
{ 0, 0 }
|
|
};
|
|
|
|
MODULE_DEVICE_TABLE(amba, amba_kmi_idtable);
|
|
|
|
static struct amba_driver ambakmi_driver = {
|
|
.drv = {
|
|
.name = "kmi-pl050",
|
|
.pm = pm_sleep_ptr(&amba_kmi_dev_pm_ops),
|
|
},
|
|
.id_table = amba_kmi_idtable,
|
|
.probe = amba_kmi_probe,
|
|
.remove = amba_kmi_remove,
|
|
};
|
|
|
|
module_amba_driver(ambakmi_driver);
|
|
|
|
MODULE_AUTHOR("Russell King <rmk@arm.linux.org.uk>");
|
|
MODULE_DESCRIPTION("AMBA KMI controller driver");
|
|
MODULE_LICENSE("GPL");
|