Merge branch 'next' into for-linus
Prepare first round of input updates for 3.17.
This commit is contained in:
@@ -471,6 +471,18 @@ config TOUCHSCREEN_HP7XX
|
||||
To compile this driver as a module, choose M here: the
|
||||
module will be called jornada720_ts.
|
||||
|
||||
config TOUCHSCREEN_IPAQ_MICRO
|
||||
tristate "HP iPAQ Atmel Micro ASIC touchscreen"
|
||||
depends on MFD_IPAQ_MICRO
|
||||
help
|
||||
Say Y here to enable support for the touchscreen attached to
|
||||
the Atmel Micro peripheral controller on iPAQ h3100/h3600/h3700
|
||||
|
||||
If unsure, say N.
|
||||
|
||||
To compile this driver as a module, choose M here: the
|
||||
module will be called ipaq-micro-ts.
|
||||
|
||||
config TOUCHSCREEN_HTCPEN
|
||||
tristate "HTC Shift X9500 touchscreen"
|
||||
depends on ISA
|
||||
@@ -555,18 +567,6 @@ config TOUCHSCREEN_TI_AM335X_TSC
|
||||
To compile this driver as a module, choose M here: the
|
||||
module will be called ti_am335x_tsc.
|
||||
|
||||
config TOUCHSCREEN_ATMEL_TSADCC
|
||||
tristate "Atmel Touchscreen Interface"
|
||||
depends on ARCH_AT91
|
||||
help
|
||||
Say Y here if you have a 4-wire touchscreen connected to the
|
||||
ADC Controller on your Atmel SoC.
|
||||
|
||||
If unsure, say N.
|
||||
|
||||
To compile this driver as a module, choose M here: the
|
||||
module will be called atmel_tsadcc.
|
||||
|
||||
config TOUCHSCREEN_UCB1400
|
||||
tristate "Philips UCB1400 touchscreen"
|
||||
depends on AC97_BUS
|
||||
|
@@ -14,7 +14,6 @@ obj-$(CONFIG_TOUCHSCREEN_AD7879_I2C) += ad7879-i2c.o
|
||||
obj-$(CONFIG_TOUCHSCREEN_AD7879_SPI) += ad7879-spi.o
|
||||
obj-$(CONFIG_TOUCHSCREEN_ADS7846) += ads7846.o
|
||||
obj-$(CONFIG_TOUCHSCREEN_ATMEL_MXT) += atmel_mxt_ts.o
|
||||
obj-$(CONFIG_TOUCHSCREEN_ATMEL_TSADCC) += atmel_tsadcc.o
|
||||
obj-$(CONFIG_TOUCHSCREEN_AUO_PIXCIR) += auo-pixcir-ts.o
|
||||
obj-$(CONFIG_TOUCHSCREEN_BU21013) += bu21013_ts.o
|
||||
obj-$(CONFIG_TOUCHSCREEN_CY8CTMG110) += cy8ctmg110_ts.o
|
||||
@@ -47,6 +46,7 @@ obj-$(CONFIG_TOUCHSCREEN_MTOUCH) += mtouch.o
|
||||
obj-$(CONFIG_TOUCHSCREEN_MK712) += mk712.o
|
||||
obj-$(CONFIG_TOUCHSCREEN_HP600) += hp680_ts_input.o
|
||||
obj-$(CONFIG_TOUCHSCREEN_HP7XX) += jornada720_ts.o
|
||||
obj-$(CONFIG_TOUCHSCREEN_IPAQ_MICRO) += ipaq-micro-ts.o
|
||||
obj-$(CONFIG_TOUCHSCREEN_HTCPEN) += htcpen.o
|
||||
obj-$(CONFIG_TOUCHSCREEN_USB_COMPOSITE) += usbtouchscreen.o
|
||||
obj-$(CONFIG_TOUCHSCREEN_PCAP) += pcap_ts.o
|
||||
|
@@ -1302,8 +1302,10 @@ static int ads7846_probe(struct spi_device *spi)
|
||||
pdata = dev_get_platdata(&spi->dev);
|
||||
if (!pdata) {
|
||||
pdata = ads7846_probe_dt(&spi->dev);
|
||||
if (IS_ERR(pdata))
|
||||
return PTR_ERR(pdata);
|
||||
if (IS_ERR(pdata)) {
|
||||
err = PTR_ERR(pdata);
|
||||
goto err_free_mem;
|
||||
}
|
||||
}
|
||||
|
||||
ts->model = pdata->model ? : 7846;
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -1,358 +0,0 @@
|
||||
/*
|
||||
* Atmel Touch Screen Driver
|
||||
*
|
||||
* Copyright (c) 2008 ATMEL
|
||||
* Copyright (c) 2008 Dan Liang
|
||||
* Copyright (c) 2008 TimeSys Corporation
|
||||
* Copyright (c) 2008 Justin Waters
|
||||
*
|
||||
* Based on touchscreen code from Atmel Corporation.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
#include <linux/err.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/input.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/clk.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/io.h>
|
||||
#include <linux/platform_data/atmel.h>
|
||||
#include <mach/cpu.h>
|
||||
|
||||
/* Register definitions based on AT91SAM9RL64 preliminary draft datasheet */
|
||||
|
||||
#define ATMEL_TSADCC_CR 0x00 /* Control register */
|
||||
#define ATMEL_TSADCC_SWRST (1 << 0) /* Software Reset*/
|
||||
#define ATMEL_TSADCC_START (1 << 1) /* Start conversion */
|
||||
|
||||
#define ATMEL_TSADCC_MR 0x04 /* Mode register */
|
||||
#define ATMEL_TSADCC_TSAMOD (3 << 0) /* ADC mode */
|
||||
#define ATMEL_TSADCC_TSAMOD_ADC_ONLY_MODE (0x0) /* ADC Mode */
|
||||
#define ATMEL_TSADCC_TSAMOD_TS_ONLY_MODE (0x1) /* Touch Screen Only Mode */
|
||||
#define ATMEL_TSADCC_LOWRES (1 << 4) /* Resolution selection */
|
||||
#define ATMEL_TSADCC_SLEEP (1 << 5) /* Sleep mode */
|
||||
#define ATMEL_TSADCC_PENDET (1 << 6) /* Pen Detect selection */
|
||||
#define ATMEL_TSADCC_PRES (1 << 7) /* Pressure Measurement Selection */
|
||||
#define ATMEL_TSADCC_PRESCAL (0x3f << 8) /* Prescalar Rate Selection */
|
||||
#define ATMEL_TSADCC_EPRESCAL (0xff << 8) /* Prescalar Rate Selection (Extended) */
|
||||
#define ATMEL_TSADCC_STARTUP (0x7f << 16) /* Start Up time */
|
||||
#define ATMEL_TSADCC_SHTIM (0xf << 24) /* Sample & Hold time */
|
||||
#define ATMEL_TSADCC_PENDBC (0xf << 28) /* Pen Detect debouncing time */
|
||||
|
||||
#define ATMEL_TSADCC_TRGR 0x08 /* Trigger register */
|
||||
#define ATMEL_TSADCC_TRGMOD (7 << 0) /* Trigger mode */
|
||||
#define ATMEL_TSADCC_TRGMOD_NONE (0 << 0)
|
||||
#define ATMEL_TSADCC_TRGMOD_EXT_RISING (1 << 0)
|
||||
#define ATMEL_TSADCC_TRGMOD_EXT_FALLING (2 << 0)
|
||||
#define ATMEL_TSADCC_TRGMOD_EXT_ANY (3 << 0)
|
||||
#define ATMEL_TSADCC_TRGMOD_PENDET (4 << 0)
|
||||
#define ATMEL_TSADCC_TRGMOD_PERIOD (5 << 0)
|
||||
#define ATMEL_TSADCC_TRGMOD_CONTINUOUS (6 << 0)
|
||||
#define ATMEL_TSADCC_TRGPER (0xffff << 16) /* Trigger period */
|
||||
|
||||
#define ATMEL_TSADCC_TSR 0x0C /* Touch Screen register */
|
||||
#define ATMEL_TSADCC_TSFREQ (0xf << 0) /* TS Frequency in Interleaved mode */
|
||||
#define ATMEL_TSADCC_TSSHTIM (0xf << 24) /* Sample & Hold time */
|
||||
|
||||
#define ATMEL_TSADCC_CHER 0x10 /* Channel Enable register */
|
||||
#define ATMEL_TSADCC_CHDR 0x14 /* Channel Disable register */
|
||||
#define ATMEL_TSADCC_CHSR 0x18 /* Channel Status register */
|
||||
#define ATMEL_TSADCC_CH(n) (1 << (n)) /* Channel number */
|
||||
|
||||
#define ATMEL_TSADCC_SR 0x1C /* Status register */
|
||||
#define ATMEL_TSADCC_EOC(n) (1 << ((n)+0)) /* End of conversion for channel N */
|
||||
#define ATMEL_TSADCC_OVRE(n) (1 << ((n)+8)) /* Overrun error for channel N */
|
||||
#define ATMEL_TSADCC_DRDY (1 << 16) /* Data Ready */
|
||||
#define ATMEL_TSADCC_GOVRE (1 << 17) /* General Overrun Error */
|
||||
#define ATMEL_TSADCC_ENDRX (1 << 18) /* End of RX Buffer */
|
||||
#define ATMEL_TSADCC_RXBUFF (1 << 19) /* TX Buffer full */
|
||||
#define ATMEL_TSADCC_PENCNT (1 << 20) /* Pen contact */
|
||||
#define ATMEL_TSADCC_NOCNT (1 << 21) /* No contact */
|
||||
|
||||
#define ATMEL_TSADCC_LCDR 0x20 /* Last Converted Data register */
|
||||
#define ATMEL_TSADCC_DATA (0x3ff << 0) /* Channel data */
|
||||
|
||||
#define ATMEL_TSADCC_IER 0x24 /* Interrupt Enable register */
|
||||
#define ATMEL_TSADCC_IDR 0x28 /* Interrupt Disable register */
|
||||
#define ATMEL_TSADCC_IMR 0x2C /* Interrupt Mask register */
|
||||
#define ATMEL_TSADCC_CDR0 0x30 /* Channel Data 0 */
|
||||
#define ATMEL_TSADCC_CDR1 0x34 /* Channel Data 1 */
|
||||
#define ATMEL_TSADCC_CDR2 0x38 /* Channel Data 2 */
|
||||
#define ATMEL_TSADCC_CDR3 0x3C /* Channel Data 3 */
|
||||
#define ATMEL_TSADCC_CDR4 0x40 /* Channel Data 4 */
|
||||
#define ATMEL_TSADCC_CDR5 0x44 /* Channel Data 5 */
|
||||
|
||||
#define ATMEL_TSADCC_XPOS 0x50
|
||||
#define ATMEL_TSADCC_Z1DAT 0x54
|
||||
#define ATMEL_TSADCC_Z2DAT 0x58
|
||||
|
||||
#define PRESCALER_VAL(x) ((x) >> 8)
|
||||
|
||||
#define ADC_DEFAULT_CLOCK 100000
|
||||
|
||||
struct atmel_tsadcc {
|
||||
struct input_dev *input;
|
||||
char phys[32];
|
||||
struct clk *clk;
|
||||
int irq;
|
||||
unsigned int prev_absx;
|
||||
unsigned int prev_absy;
|
||||
unsigned char bufferedmeasure;
|
||||
};
|
||||
|
||||
static void __iomem *tsc_base;
|
||||
|
||||
#define atmel_tsadcc_read(reg) __raw_readl(tsc_base + (reg))
|
||||
#define atmel_tsadcc_write(reg, val) __raw_writel((val), tsc_base + (reg))
|
||||
|
||||
static irqreturn_t atmel_tsadcc_interrupt(int irq, void *dev)
|
||||
{
|
||||
struct atmel_tsadcc *ts_dev = (struct atmel_tsadcc *)dev;
|
||||
struct input_dev *input_dev = ts_dev->input;
|
||||
|
||||
unsigned int status;
|
||||
unsigned int reg;
|
||||
|
||||
status = atmel_tsadcc_read(ATMEL_TSADCC_SR);
|
||||
status &= atmel_tsadcc_read(ATMEL_TSADCC_IMR);
|
||||
|
||||
if (status & ATMEL_TSADCC_NOCNT) {
|
||||
/* Contact lost */
|
||||
reg = atmel_tsadcc_read(ATMEL_TSADCC_MR) | ATMEL_TSADCC_PENDBC;
|
||||
|
||||
atmel_tsadcc_write(ATMEL_TSADCC_MR, reg);
|
||||
atmel_tsadcc_write(ATMEL_TSADCC_TRGR, ATMEL_TSADCC_TRGMOD_NONE);
|
||||
atmel_tsadcc_write(ATMEL_TSADCC_IDR,
|
||||
ATMEL_TSADCC_EOC(3) | ATMEL_TSADCC_NOCNT);
|
||||
atmel_tsadcc_write(ATMEL_TSADCC_IER, ATMEL_TSADCC_PENCNT);
|
||||
|
||||
input_report_key(input_dev, BTN_TOUCH, 0);
|
||||
ts_dev->bufferedmeasure = 0;
|
||||
input_sync(input_dev);
|
||||
|
||||
} else if (status & ATMEL_TSADCC_PENCNT) {
|
||||
/* Pen detected */
|
||||
reg = atmel_tsadcc_read(ATMEL_TSADCC_MR);
|
||||
reg &= ~ATMEL_TSADCC_PENDBC;
|
||||
|
||||
atmel_tsadcc_write(ATMEL_TSADCC_IDR, ATMEL_TSADCC_PENCNT);
|
||||
atmel_tsadcc_write(ATMEL_TSADCC_MR, reg);
|
||||
atmel_tsadcc_write(ATMEL_TSADCC_IER,
|
||||
ATMEL_TSADCC_EOC(3) | ATMEL_TSADCC_NOCNT);
|
||||
atmel_tsadcc_write(ATMEL_TSADCC_TRGR,
|
||||
ATMEL_TSADCC_TRGMOD_PERIOD | (0x0FFF << 16));
|
||||
|
||||
} else if (status & ATMEL_TSADCC_EOC(3)) {
|
||||
/* Conversion finished */
|
||||
|
||||
if (ts_dev->bufferedmeasure) {
|
||||
/* Last measurement is always discarded, since it can
|
||||
* be erroneous.
|
||||
* Always report previous measurement */
|
||||
input_report_abs(input_dev, ABS_X, ts_dev->prev_absx);
|
||||
input_report_abs(input_dev, ABS_Y, ts_dev->prev_absy);
|
||||
input_report_key(input_dev, BTN_TOUCH, 1);
|
||||
input_sync(input_dev);
|
||||
} else
|
||||
ts_dev->bufferedmeasure = 1;
|
||||
|
||||
/* Now make new measurement */
|
||||
ts_dev->prev_absx = atmel_tsadcc_read(ATMEL_TSADCC_CDR3) << 10;
|
||||
ts_dev->prev_absx /= atmel_tsadcc_read(ATMEL_TSADCC_CDR2);
|
||||
|
||||
ts_dev->prev_absy = atmel_tsadcc_read(ATMEL_TSADCC_CDR1) << 10;
|
||||
ts_dev->prev_absy /= atmel_tsadcc_read(ATMEL_TSADCC_CDR0);
|
||||
}
|
||||
|
||||
return IRQ_HANDLED;
|
||||
}
|
||||
|
||||
/*
|
||||
* The functions for inserting/removing us as a module.
|
||||
*/
|
||||
|
||||
static int atmel_tsadcc_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct atmel_tsadcc *ts_dev;
|
||||
struct input_dev *input_dev;
|
||||
struct resource *res;
|
||||
struct at91_tsadcc_data *pdata = dev_get_platdata(&pdev->dev);
|
||||
int err;
|
||||
unsigned int prsc;
|
||||
unsigned int reg;
|
||||
|
||||
if (!pdata)
|
||||
return -EINVAL;
|
||||
|
||||
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
||||
if (!res) {
|
||||
dev_err(&pdev->dev, "no mmio resource defined.\n");
|
||||
return -ENXIO;
|
||||
}
|
||||
|
||||
/* Allocate memory for device */
|
||||
ts_dev = kzalloc(sizeof(struct atmel_tsadcc), GFP_KERNEL);
|
||||
if (!ts_dev) {
|
||||
dev_err(&pdev->dev, "failed to allocate memory.\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
platform_set_drvdata(pdev, ts_dev);
|
||||
|
||||
input_dev = input_allocate_device();
|
||||
if (!input_dev) {
|
||||
dev_err(&pdev->dev, "failed to allocate input device.\n");
|
||||
err = -EBUSY;
|
||||
goto err_free_mem;
|
||||
}
|
||||
|
||||
ts_dev->irq = platform_get_irq(pdev, 0);
|
||||
if (ts_dev->irq < 0) {
|
||||
dev_err(&pdev->dev, "no irq ID is designated.\n");
|
||||
err = -ENODEV;
|
||||
goto err_free_dev;
|
||||
}
|
||||
|
||||
if (!request_mem_region(res->start, resource_size(res),
|
||||
"atmel tsadcc regs")) {
|
||||
dev_err(&pdev->dev, "resources is unavailable.\n");
|
||||
err = -EBUSY;
|
||||
goto err_free_dev;
|
||||
}
|
||||
|
||||
tsc_base = ioremap(res->start, resource_size(res));
|
||||
if (!tsc_base) {
|
||||
dev_err(&pdev->dev, "failed to map registers.\n");
|
||||
err = -ENOMEM;
|
||||
goto err_release_mem;
|
||||
}
|
||||
|
||||
err = request_irq(ts_dev->irq, atmel_tsadcc_interrupt, 0,
|
||||
pdev->dev.driver->name, ts_dev);
|
||||
if (err) {
|
||||
dev_err(&pdev->dev, "failed to allocate irq.\n");
|
||||
goto err_unmap_regs;
|
||||
}
|
||||
|
||||
ts_dev->clk = clk_get(&pdev->dev, "tsc_clk");
|
||||
if (IS_ERR(ts_dev->clk)) {
|
||||
dev_err(&pdev->dev, "failed to get ts_clk\n");
|
||||
err = PTR_ERR(ts_dev->clk);
|
||||
goto err_free_irq;
|
||||
}
|
||||
|
||||
ts_dev->input = input_dev;
|
||||
ts_dev->bufferedmeasure = 0;
|
||||
|
||||
snprintf(ts_dev->phys, sizeof(ts_dev->phys),
|
||||
"%s/input0", dev_name(&pdev->dev));
|
||||
|
||||
input_dev->name = "atmel touch screen controller";
|
||||
input_dev->phys = ts_dev->phys;
|
||||
input_dev->dev.parent = &pdev->dev;
|
||||
|
||||
__set_bit(EV_ABS, input_dev->evbit);
|
||||
input_set_abs_params(input_dev, ABS_X, 0, 0x3FF, 0, 0);
|
||||
input_set_abs_params(input_dev, ABS_Y, 0, 0x3FF, 0, 0);
|
||||
|
||||
input_set_capability(input_dev, EV_KEY, BTN_TOUCH);
|
||||
|
||||
/* clk_enable() always returns 0, no need to check it */
|
||||
clk_enable(ts_dev->clk);
|
||||
|
||||
prsc = clk_get_rate(ts_dev->clk);
|
||||
dev_info(&pdev->dev, "Master clock is set at: %d Hz\n", prsc);
|
||||
|
||||
if (!pdata->adc_clock)
|
||||
pdata->adc_clock = ADC_DEFAULT_CLOCK;
|
||||
|
||||
prsc = (prsc / (2 * pdata->adc_clock)) - 1;
|
||||
|
||||
/* saturate if this value is too high */
|
||||
if (cpu_is_at91sam9rl()) {
|
||||
if (prsc > PRESCALER_VAL(ATMEL_TSADCC_PRESCAL))
|
||||
prsc = PRESCALER_VAL(ATMEL_TSADCC_PRESCAL);
|
||||
} else {
|
||||
if (prsc > PRESCALER_VAL(ATMEL_TSADCC_EPRESCAL))
|
||||
prsc = PRESCALER_VAL(ATMEL_TSADCC_EPRESCAL);
|
||||
}
|
||||
|
||||
dev_info(&pdev->dev, "Prescaler is set at: %d\n", prsc);
|
||||
|
||||
reg = ATMEL_TSADCC_TSAMOD_TS_ONLY_MODE |
|
||||
((0x00 << 5) & ATMEL_TSADCC_SLEEP) | /* Normal Mode */
|
||||
((0x01 << 6) & ATMEL_TSADCC_PENDET) | /* Enable Pen Detect */
|
||||
(prsc << 8) |
|
||||
((0x26 << 16) & ATMEL_TSADCC_STARTUP) |
|
||||
((pdata->pendet_debounce << 28) & ATMEL_TSADCC_PENDBC);
|
||||
|
||||
atmel_tsadcc_write(ATMEL_TSADCC_CR, ATMEL_TSADCC_SWRST);
|
||||
atmel_tsadcc_write(ATMEL_TSADCC_MR, reg);
|
||||
atmel_tsadcc_write(ATMEL_TSADCC_TRGR, ATMEL_TSADCC_TRGMOD_NONE);
|
||||
atmel_tsadcc_write(ATMEL_TSADCC_TSR,
|
||||
(pdata->ts_sample_hold_time << 24) & ATMEL_TSADCC_TSSHTIM);
|
||||
|
||||
atmel_tsadcc_read(ATMEL_TSADCC_SR);
|
||||
atmel_tsadcc_write(ATMEL_TSADCC_IER, ATMEL_TSADCC_PENCNT);
|
||||
|
||||
/* All went ok, so register to the input system */
|
||||
err = input_register_device(input_dev);
|
||||
if (err)
|
||||
goto err_fail;
|
||||
|
||||
return 0;
|
||||
|
||||
err_fail:
|
||||
clk_disable(ts_dev->clk);
|
||||
clk_put(ts_dev->clk);
|
||||
err_free_irq:
|
||||
free_irq(ts_dev->irq, ts_dev);
|
||||
err_unmap_regs:
|
||||
iounmap(tsc_base);
|
||||
err_release_mem:
|
||||
release_mem_region(res->start, resource_size(res));
|
||||
err_free_dev:
|
||||
input_free_device(input_dev);
|
||||
err_free_mem:
|
||||
kfree(ts_dev);
|
||||
return err;
|
||||
}
|
||||
|
||||
static int atmel_tsadcc_remove(struct platform_device *pdev)
|
||||
{
|
||||
struct atmel_tsadcc *ts_dev = platform_get_drvdata(pdev);
|
||||
struct resource *res;
|
||||
|
||||
free_irq(ts_dev->irq, ts_dev);
|
||||
|
||||
input_unregister_device(ts_dev->input);
|
||||
|
||||
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
||||
iounmap(tsc_base);
|
||||
release_mem_region(res->start, resource_size(res));
|
||||
|
||||
clk_disable(ts_dev->clk);
|
||||
clk_put(ts_dev->clk);
|
||||
|
||||
kfree(ts_dev);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct platform_driver atmel_tsadcc_driver = {
|
||||
.probe = atmel_tsadcc_probe,
|
||||
.remove = atmel_tsadcc_remove,
|
||||
.driver = {
|
||||
.name = "atmel_tsadcc",
|
||||
},
|
||||
};
|
||||
module_platform_driver(atmel_tsadcc_driver);
|
||||
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_DESCRIPTION("Atmel TouchScreen Driver");
|
||||
MODULE_AUTHOR("Dan Liang <dan.liang@atmel.com>");
|
||||
|
@@ -733,8 +733,7 @@ edt_ft5x06_ts_prepare_debugfs(struct edt_ft5x06_ts_data *tsdata,
|
||||
static void
|
||||
edt_ft5x06_ts_teardown_debugfs(struct edt_ft5x06_ts_data *tsdata)
|
||||
{
|
||||
if (tsdata->debug_dir)
|
||||
debugfs_remove_recursive(tsdata->debug_dir);
|
||||
debugfs_remove_recursive(tsdata->debug_dir);
|
||||
kfree(tsdata->raw_buffer);
|
||||
}
|
||||
|
||||
|
166
drivers/input/touchscreen/ipaq-micro-ts.c
Normal file
166
drivers/input/touchscreen/ipaq-micro-ts.c
Normal file
@@ -0,0 +1,166 @@
|
||||
/*
|
||||
* 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.
|
||||
*
|
||||
* h3600 atmel micro companion support, touchscreen subdevice
|
||||
* Author : Alessandro Gardich <gremlin@gremlin.it>
|
||||
* Author : Dmitry Artamonow <mad_soft@inbox.ru>
|
||||
* Author : Linus Walleij <linus.walleij@linaro.org>
|
||||
*
|
||||
*/
|
||||
|
||||
#include <asm/byteorder.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/pm.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/device.h>
|
||||
#include <linux/input.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/mfd/ipaq-micro.h>
|
||||
|
||||
struct touchscreen_data {
|
||||
struct input_dev *input;
|
||||
struct ipaq_micro *micro;
|
||||
};
|
||||
|
||||
static void micro_ts_receive(void *data, int len, unsigned char *msg)
|
||||
{
|
||||
struct touchscreen_data *ts = data;
|
||||
|
||||
if (len == 4) {
|
||||
input_report_abs(ts->input, ABS_X,
|
||||
be16_to_cpup((__be16 *) &msg[2]));
|
||||
input_report_abs(ts->input, ABS_Y,
|
||||
be16_to_cpup((__be16 *) &msg[0]));
|
||||
input_report_key(ts->input, BTN_TOUCH, 1);
|
||||
input_sync(ts->input);
|
||||
} else if (len == 0) {
|
||||
input_report_abs(ts->input, ABS_X, 0);
|
||||
input_report_abs(ts->input, ABS_Y, 0);
|
||||
input_report_key(ts->input, BTN_TOUCH, 0);
|
||||
input_sync(ts->input);
|
||||
}
|
||||
}
|
||||
|
||||
static void micro_ts_toggle_receive(struct touchscreen_data *ts, bool enable)
|
||||
{
|
||||
struct ipaq_micro *micro = ts->micro;
|
||||
|
||||
spin_lock_irq(µ->lock);
|
||||
|
||||
if (enable) {
|
||||
micro->ts = micro_ts_receive;
|
||||
micro->ts_data = ts;
|
||||
} else {
|
||||
micro->ts = NULL;
|
||||
micro->ts_data = NULL;
|
||||
}
|
||||
|
||||
spin_unlock_irq(&ts->micro->lock);
|
||||
}
|
||||
|
||||
static int micro_ts_open(struct input_dev *input)
|
||||
{
|
||||
struct touchscreen_data *ts = input_get_drvdata(input);
|
||||
|
||||
micro_ts_toggle_receive(ts, true);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void micro_ts_close(struct input_dev *input)
|
||||
{
|
||||
struct touchscreen_data *ts = input_get_drvdata(input);
|
||||
|
||||
micro_ts_toggle_receive(ts, false);
|
||||
}
|
||||
|
||||
static int micro_ts_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct ipaq_micro *micro = dev_get_drvdata(pdev->dev.parent);
|
||||
struct touchscreen_data *ts;
|
||||
int error;
|
||||
|
||||
ts = devm_kzalloc(&pdev->dev, sizeof(*ts), GFP_KERNEL);
|
||||
if (!ts)
|
||||
return -ENOMEM;
|
||||
|
||||
ts->micro = micro;
|
||||
|
||||
ts->input = devm_input_allocate_device(&pdev->dev);
|
||||
if (!ts->input) {
|
||||
dev_err(&pdev->dev, "failed to allocate input device\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
ts->input->name = "ipaq micro ts";
|
||||
ts->input->open = micro_ts_open;
|
||||
ts->input->close = micro_ts_close;
|
||||
|
||||
input_set_drvdata(ts->input, ts);
|
||||
|
||||
input_set_capability(ts->input, EV_KEY, BTN_TOUCH);
|
||||
input_set_capability(ts->input, EV_ABS, ABS_X);
|
||||
input_set_capability(ts->input, EV_ABS, ABS_Y);
|
||||
input_set_abs_params(ts->input, ABS_X, 0, 1023, 0, 0);
|
||||
input_set_abs_params(ts->input, ABS_Y, 0, 1023, 0, 0);
|
||||
|
||||
error = input_register_device(ts->input);
|
||||
if (error) {
|
||||
dev_err(&pdev->dev, "error registering touch input\n");
|
||||
return error;
|
||||
}
|
||||
|
||||
platform_set_drvdata(pdev, ts);
|
||||
|
||||
dev_info(&pdev->dev, "iPAQ micro touchscreen\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PM_SLEEP
|
||||
static int micro_ts_suspend(struct device *dev)
|
||||
{
|
||||
struct touchscreen_data *ts = dev_get_drvdata(dev);
|
||||
|
||||
micro_ts_toggle_receive(ts, false);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int micro_ts_resume(struct device *dev)
|
||||
{
|
||||
struct touchscreen_data *ts = dev_get_drvdata(dev);
|
||||
struct input_dev *input = ts->input;
|
||||
|
||||
mutex_lock(&input->mutex);
|
||||
|
||||
if (input->users)
|
||||
micro_ts_toggle_receive(ts, true);
|
||||
|
||||
mutex_unlock(&input->mutex);
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
static const struct dev_pm_ops micro_ts_dev_pm_ops = {
|
||||
SET_SYSTEM_SLEEP_PM_OPS(micro_ts_suspend, micro_ts_resume)
|
||||
};
|
||||
|
||||
static struct platform_driver micro_ts_device_driver = {
|
||||
.driver = {
|
||||
.name = "ipaq-micro-ts",
|
||||
.pm = µ_ts_dev_pm_ops,
|
||||
},
|
||||
.probe = micro_ts_probe,
|
||||
};
|
||||
module_platform_driver(micro_ts_device_driver);
|
||||
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_DESCRIPTION("driver for iPAQ Atmel micro touchscreen");
|
||||
MODULE_ALIAS("platform:ipaq-micro-ts");
|
@@ -36,22 +36,21 @@ struct jornada_ts {
|
||||
|
||||
static void jornada720_ts_collect_data(struct jornada_ts *jornada_ts)
|
||||
{
|
||||
/* 3 low word X samples */
|
||||
jornada_ts->x_data[0] = jornada_ssp_byte(TXDUMMY);
|
||||
jornada_ts->x_data[1] = jornada_ssp_byte(TXDUMMY);
|
||||
jornada_ts->x_data[2] = jornada_ssp_byte(TXDUMMY);
|
||||
|
||||
/* 3 low word X samples */
|
||||
jornada_ts->x_data[0] = jornada_ssp_byte(TXDUMMY);
|
||||
jornada_ts->x_data[1] = jornada_ssp_byte(TXDUMMY);
|
||||
jornada_ts->x_data[2] = jornada_ssp_byte(TXDUMMY);
|
||||
/* 3 low word Y samples */
|
||||
jornada_ts->y_data[0] = jornada_ssp_byte(TXDUMMY);
|
||||
jornada_ts->y_data[1] = jornada_ssp_byte(TXDUMMY);
|
||||
jornada_ts->y_data[2] = jornada_ssp_byte(TXDUMMY);
|
||||
|
||||
/* 3 low word Y samples */
|
||||
jornada_ts->y_data[0] = jornada_ssp_byte(TXDUMMY);
|
||||
jornada_ts->y_data[1] = jornada_ssp_byte(TXDUMMY);
|
||||
jornada_ts->y_data[2] = jornada_ssp_byte(TXDUMMY);
|
||||
/* combined x samples bits */
|
||||
jornada_ts->x_data[3] = jornada_ssp_byte(TXDUMMY);
|
||||
|
||||
/* combined x samples bits */
|
||||
jornada_ts->x_data[3] = jornada_ssp_byte(TXDUMMY);
|
||||
|
||||
/* combined y samples bits */
|
||||
jornada_ts->y_data[3] = jornada_ssp_byte(TXDUMMY);
|
||||
/* combined y samples bits */
|
||||
jornada_ts->y_data[3] = jornada_ssp_byte(TXDUMMY);
|
||||
}
|
||||
|
||||
static int jornada720_ts_average(int coords[4])
|
||||
@@ -104,13 +103,13 @@ static int jornada720_ts_probe(struct platform_device *pdev)
|
||||
struct input_dev *input_dev;
|
||||
int error;
|
||||
|
||||
jornada_ts = kzalloc(sizeof(struct jornada_ts), GFP_KERNEL);
|
||||
input_dev = input_allocate_device();
|
||||
jornada_ts = devm_kzalloc(&pdev->dev, sizeof(*jornada_ts), GFP_KERNEL);
|
||||
if (!jornada_ts)
|
||||
return -ENOMEM;
|
||||
|
||||
if (!jornada_ts || !input_dev) {
|
||||
error = -ENOMEM;
|
||||
goto fail1;
|
||||
}
|
||||
input_dev = devm_input_allocate_device(&pdev->dev);
|
||||
if (!input_dev)
|
||||
return -ENOMEM;
|
||||
|
||||
platform_set_drvdata(pdev, jornada_ts);
|
||||
|
||||
@@ -126,36 +125,18 @@ static int jornada720_ts_probe(struct platform_device *pdev)
|
||||
input_set_abs_params(input_dev, ABS_X, 270, 3900, 0, 0);
|
||||
input_set_abs_params(input_dev, ABS_Y, 180, 3700, 0, 0);
|
||||
|
||||
error = request_irq(IRQ_GPIO9,
|
||||
jornada720_ts_interrupt,
|
||||
IRQF_TRIGGER_RISING,
|
||||
"HP7XX Touchscreen driver", pdev);
|
||||
error = devm_request_irq(&pdev->dev, IRQ_GPIO9,
|
||||
jornada720_ts_interrupt,
|
||||
IRQF_TRIGGER_RISING,
|
||||
"HP7XX Touchscreen driver", pdev);
|
||||
if (error) {
|
||||
printk(KERN_INFO "HP7XX TS : Unable to acquire irq!\n");
|
||||
goto fail1;
|
||||
dev_err(&pdev->dev, "HP7XX TS : Unable to acquire irq!\n");
|
||||
return error;
|
||||
}
|
||||
|
||||
error = input_register_device(jornada_ts->dev);
|
||||
if (error)
|
||||
goto fail2;
|
||||
|
||||
return 0;
|
||||
|
||||
fail2:
|
||||
free_irq(IRQ_GPIO9, pdev);
|
||||
fail1:
|
||||
input_free_device(input_dev);
|
||||
kfree(jornada_ts);
|
||||
return error;
|
||||
}
|
||||
|
||||
static int jornada720_ts_remove(struct platform_device *pdev)
|
||||
{
|
||||
struct jornada_ts *jornada_ts = platform_get_drvdata(pdev);
|
||||
|
||||
free_irq(IRQ_GPIO9, pdev);
|
||||
input_unregister_device(jornada_ts->dev);
|
||||
kfree(jornada_ts);
|
||||
return error;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -165,7 +146,6 @@ MODULE_ALIAS("platform:jornada_ts");
|
||||
|
||||
static struct platform_driver jornada720_ts_driver = {
|
||||
.probe = jornada720_ts_probe,
|
||||
.remove = jornada720_ts_remove,
|
||||
.driver = {
|
||||
.name = "jornada_ts",
|
||||
.owner = THIS_MODULE,
|
||||
|
@@ -248,8 +248,7 @@ static int mcs5000_ts_probe(struct i2c_client *client,
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PM
|
||||
static int mcs5000_ts_suspend(struct device *dev)
|
||||
static int __maybe_unused mcs5000_ts_suspend(struct device *dev)
|
||||
{
|
||||
struct i2c_client *client = to_i2c_client(dev);
|
||||
|
||||
@@ -259,7 +258,7 @@ static int mcs5000_ts_suspend(struct device *dev)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int mcs5000_ts_resume(struct device *dev)
|
||||
static int __maybe_unused mcs5000_ts_resume(struct device *dev)
|
||||
{
|
||||
struct i2c_client *client = to_i2c_client(dev);
|
||||
struct mcs5000_ts_data *data = i2c_get_clientdata(client);
|
||||
@@ -269,7 +268,6 @@ static int mcs5000_ts_resume(struct device *dev)
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
static SIMPLE_DEV_PM_OPS(mcs5000_ts_pm, mcs5000_ts_suspend, mcs5000_ts_resume);
|
||||
|
||||
|
@@ -23,22 +23,51 @@
|
||||
#include <linux/slab.h>
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/input.h>
|
||||
#include <linux/input/mt.h>
|
||||
#include <linux/input/pixcir_ts.h>
|
||||
#include <linux/gpio.h>
|
||||
#include <linux/of.h>
|
||||
#include <linux/of_gpio.h>
|
||||
#include <linux/of_device.h>
|
||||
|
||||
#define PIXCIR_MAX_SLOTS 5 /* Max fingers supported by driver */
|
||||
|
||||
struct pixcir_i2c_ts_data {
|
||||
struct i2c_client *client;
|
||||
struct input_dev *input;
|
||||
const struct pixcir_ts_platform_data *chip;
|
||||
const struct pixcir_ts_platform_data *pdata;
|
||||
bool running;
|
||||
int max_fingers; /* Max fingers supported in this instance */
|
||||
};
|
||||
|
||||
static void pixcir_ts_poscheck(struct pixcir_i2c_ts_data *data)
|
||||
struct pixcir_touch {
|
||||
int x;
|
||||
int y;
|
||||
int id;
|
||||
};
|
||||
|
||||
struct pixcir_report_data {
|
||||
int num_touches;
|
||||
struct pixcir_touch touches[PIXCIR_MAX_SLOTS];
|
||||
};
|
||||
|
||||
static void pixcir_ts_parse(struct pixcir_i2c_ts_data *tsdata,
|
||||
struct pixcir_report_data *report)
|
||||
{
|
||||
struct pixcir_i2c_ts_data *tsdata = data;
|
||||
u8 rdbuf[10], wrbuf[1] = { 0 };
|
||||
u8 rdbuf[2 + PIXCIR_MAX_SLOTS * 5];
|
||||
u8 wrbuf[1] = { 0 };
|
||||
u8 *bufptr;
|
||||
u8 touch;
|
||||
int ret;
|
||||
int ret, i;
|
||||
int readsize;
|
||||
const struct pixcir_i2c_chip_data *chip = &tsdata->pdata->chip;
|
||||
|
||||
memset(report, 0, sizeof(struct pixcir_report_data));
|
||||
|
||||
i = chip->has_hw_ids ? 1 : 0;
|
||||
readsize = 2 + tsdata->max_fingers * (4 + i);
|
||||
if (readsize > sizeof(rdbuf))
|
||||
readsize = sizeof(rdbuf);
|
||||
|
||||
ret = i2c_master_send(tsdata->client, wrbuf, sizeof(wrbuf));
|
||||
if (ret != sizeof(wrbuf)) {
|
||||
@@ -48,7 +77,7 @@ static void pixcir_ts_poscheck(struct pixcir_i2c_ts_data *data)
|
||||
return;
|
||||
}
|
||||
|
||||
ret = i2c_master_recv(tsdata->client, rdbuf, sizeof(rdbuf));
|
||||
ret = i2c_master_recv(tsdata->client, rdbuf, readsize);
|
||||
if (ret != sizeof(rdbuf)) {
|
||||
dev_err(&tsdata->client->dev,
|
||||
"%s: i2c_master_recv failed(), ret=%d\n",
|
||||
@@ -56,45 +85,103 @@ static void pixcir_ts_poscheck(struct pixcir_i2c_ts_data *data)
|
||||
return;
|
||||
}
|
||||
|
||||
touch = rdbuf[0];
|
||||
if (touch) {
|
||||
u16 posx1 = (rdbuf[3] << 8) | rdbuf[2];
|
||||
u16 posy1 = (rdbuf[5] << 8) | rdbuf[4];
|
||||
u16 posx2 = (rdbuf[7] << 8) | rdbuf[6];
|
||||
u16 posy2 = (rdbuf[9] << 8) | rdbuf[8];
|
||||
touch = rdbuf[0] & 0x7;
|
||||
if (touch > tsdata->max_fingers)
|
||||
touch = tsdata->max_fingers;
|
||||
|
||||
input_report_key(tsdata->input, BTN_TOUCH, 1);
|
||||
input_report_abs(tsdata->input, ABS_X, posx1);
|
||||
input_report_abs(tsdata->input, ABS_Y, posy1);
|
||||
report->num_touches = touch;
|
||||
bufptr = &rdbuf[2];
|
||||
|
||||
input_report_abs(tsdata->input, ABS_MT_POSITION_X, posx1);
|
||||
input_report_abs(tsdata->input, ABS_MT_POSITION_Y, posy1);
|
||||
input_mt_sync(tsdata->input);
|
||||
for (i = 0; i < touch; i++) {
|
||||
report->touches[i].x = (bufptr[1] << 8) | bufptr[0];
|
||||
report->touches[i].y = (bufptr[3] << 8) | bufptr[2];
|
||||
|
||||
if (touch == 2) {
|
||||
input_report_abs(tsdata->input,
|
||||
ABS_MT_POSITION_X, posx2);
|
||||
input_report_abs(tsdata->input,
|
||||
ABS_MT_POSITION_Y, posy2);
|
||||
input_mt_sync(tsdata->input);
|
||||
if (chip->has_hw_ids) {
|
||||
report->touches[i].id = bufptr[4];
|
||||
bufptr = bufptr + 5;
|
||||
} else {
|
||||
bufptr = bufptr + 4;
|
||||
}
|
||||
} else {
|
||||
input_report_key(tsdata->input, BTN_TOUCH, 0);
|
||||
}
|
||||
}
|
||||
|
||||
static void pixcir_ts_report(struct pixcir_i2c_ts_data *ts,
|
||||
struct pixcir_report_data *report)
|
||||
{
|
||||
struct input_mt_pos pos[PIXCIR_MAX_SLOTS];
|
||||
int slots[PIXCIR_MAX_SLOTS];
|
||||
struct pixcir_touch *touch;
|
||||
int n, i, slot;
|
||||
struct device *dev = &ts->client->dev;
|
||||
const struct pixcir_i2c_chip_data *chip = &ts->pdata->chip;
|
||||
|
||||
n = report->num_touches;
|
||||
if (n > PIXCIR_MAX_SLOTS)
|
||||
n = PIXCIR_MAX_SLOTS;
|
||||
|
||||
if (!chip->has_hw_ids) {
|
||||
for (i = 0; i < n; i++) {
|
||||
touch = &report->touches[i];
|
||||
pos[i].x = touch->x;
|
||||
pos[i].y = touch->y;
|
||||
}
|
||||
|
||||
input_mt_assign_slots(ts->input, slots, pos, n);
|
||||
}
|
||||
|
||||
input_sync(tsdata->input);
|
||||
for (i = 0; i < n; i++) {
|
||||
touch = &report->touches[i];
|
||||
|
||||
if (chip->has_hw_ids) {
|
||||
slot = input_mt_get_slot_by_key(ts->input, touch->id);
|
||||
if (slot < 0) {
|
||||
dev_dbg(dev, "no free slot for id 0x%x\n",
|
||||
touch->id);
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
slot = slots[i];
|
||||
}
|
||||
|
||||
input_mt_slot(ts->input, slot);
|
||||
input_mt_report_slot_state(ts->input,
|
||||
MT_TOOL_FINGER, true);
|
||||
|
||||
input_event(ts->input, EV_ABS, ABS_MT_POSITION_X, touch->x);
|
||||
input_event(ts->input, EV_ABS, ABS_MT_POSITION_Y, touch->y);
|
||||
|
||||
dev_dbg(dev, "%d: slot %d, x %d, y %d\n",
|
||||
i, slot, touch->x, touch->y);
|
||||
}
|
||||
|
||||
input_mt_sync_frame(ts->input);
|
||||
input_sync(ts->input);
|
||||
}
|
||||
|
||||
static irqreturn_t pixcir_ts_isr(int irq, void *dev_id)
|
||||
{
|
||||
struct pixcir_i2c_ts_data *tsdata = dev_id;
|
||||
const struct pixcir_ts_platform_data *pdata = tsdata->chip;
|
||||
const struct pixcir_ts_platform_data *pdata = tsdata->pdata;
|
||||
struct pixcir_report_data report;
|
||||
|
||||
while (tsdata->running) {
|
||||
pixcir_ts_poscheck(tsdata);
|
||||
/* parse packet */
|
||||
pixcir_ts_parse(tsdata, &report);
|
||||
|
||||
if (gpio_get_value(pdata->gpio_attb))
|
||||
/* report it */
|
||||
pixcir_ts_report(tsdata, &report);
|
||||
|
||||
if (gpio_get_value(pdata->gpio_attb)) {
|
||||
if (report.num_touches) {
|
||||
/*
|
||||
* Last report with no finger up?
|
||||
* Do it now then.
|
||||
*/
|
||||
input_mt_sync_frame(tsdata->input);
|
||||
input_sync(tsdata->input);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
msleep(20);
|
||||
}
|
||||
@@ -323,16 +410,69 @@ unlock:
|
||||
static SIMPLE_DEV_PM_OPS(pixcir_dev_pm_ops,
|
||||
pixcir_i2c_ts_suspend, pixcir_i2c_ts_resume);
|
||||
|
||||
#ifdef CONFIG_OF
|
||||
static const struct of_device_id pixcir_of_match[];
|
||||
|
||||
static struct pixcir_ts_platform_data *pixcir_parse_dt(struct device *dev)
|
||||
{
|
||||
struct pixcir_ts_platform_data *pdata;
|
||||
struct device_node *np = dev->of_node;
|
||||
const struct of_device_id *match;
|
||||
|
||||
match = of_match_device(of_match_ptr(pixcir_of_match), dev);
|
||||
if (!match)
|
||||
return ERR_PTR(-EINVAL);
|
||||
|
||||
pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
|
||||
if (!pdata)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
pdata->chip = *(const struct pixcir_i2c_chip_data *)match->data;
|
||||
|
||||
pdata->gpio_attb = of_get_named_gpio(np, "attb-gpio", 0);
|
||||
/* gpio_attb validity is checked in probe */
|
||||
|
||||
if (of_property_read_u32(np, "touchscreen-size-x", &pdata->x_max)) {
|
||||
dev_err(dev, "Failed to get touchscreen-size-x property\n");
|
||||
return ERR_PTR(-EINVAL);
|
||||
}
|
||||
pdata->x_max -= 1;
|
||||
|
||||
if (of_property_read_u32(np, "touchscreen-size-y", &pdata->y_max)) {
|
||||
dev_err(dev, "Failed to get touchscreen-size-y property\n");
|
||||
return ERR_PTR(-EINVAL);
|
||||
}
|
||||
pdata->y_max -= 1;
|
||||
|
||||
dev_dbg(dev, "%s: x %d, y %d, gpio %d\n", __func__,
|
||||
pdata->x_max + 1, pdata->y_max + 1, pdata->gpio_attb);
|
||||
|
||||
return pdata;
|
||||
}
|
||||
#else
|
||||
static struct pixcir_ts_platform_data *pixcir_parse_dt(struct device *dev)
|
||||
{
|
||||
return ERR_PTR(-EINVAL);
|
||||
}
|
||||
#endif
|
||||
|
||||
static int pixcir_i2c_ts_probe(struct i2c_client *client,
|
||||
const struct i2c_device_id *id)
|
||||
{
|
||||
const struct pixcir_ts_platform_data *pdata =
|
||||
dev_get_platdata(&client->dev);
|
||||
struct device *dev = &client->dev;
|
||||
struct device_node *np = dev->of_node;
|
||||
struct pixcir_i2c_ts_data *tsdata;
|
||||
struct input_dev *input;
|
||||
int error;
|
||||
|
||||
if (np && !pdata) {
|
||||
pdata = pixcir_parse_dt(dev);
|
||||
if (IS_ERR(pdata))
|
||||
return PTR_ERR(pdata);
|
||||
}
|
||||
|
||||
if (!pdata) {
|
||||
dev_err(&client->dev, "platform data not defined\n");
|
||||
return -EINVAL;
|
||||
@@ -343,6 +483,11 @@ static int pixcir_i2c_ts_probe(struct i2c_client *client,
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (!pdata->chip.max_fingers) {
|
||||
dev_err(dev, "Invalid max_fingers in pdata\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
tsdata = devm_kzalloc(dev, sizeof(*tsdata), GFP_KERNEL);
|
||||
if (!tsdata)
|
||||
return -ENOMEM;
|
||||
@@ -355,7 +500,7 @@ static int pixcir_i2c_ts_probe(struct i2c_client *client,
|
||||
|
||||
tsdata->client = client;
|
||||
tsdata->input = input;
|
||||
tsdata->chip = pdata;
|
||||
tsdata->pdata = pdata;
|
||||
|
||||
input->name = client->name;
|
||||
input->id.bustype = BUS_I2C;
|
||||
@@ -371,6 +516,20 @@ static int pixcir_i2c_ts_probe(struct i2c_client *client,
|
||||
input_set_abs_params(input, ABS_MT_POSITION_X, 0, pdata->x_max, 0, 0);
|
||||
input_set_abs_params(input, ABS_MT_POSITION_Y, 0, pdata->y_max, 0, 0);
|
||||
|
||||
tsdata->max_fingers = tsdata->pdata->chip.max_fingers;
|
||||
if (tsdata->max_fingers > PIXCIR_MAX_SLOTS) {
|
||||
tsdata->max_fingers = PIXCIR_MAX_SLOTS;
|
||||
dev_info(dev, "Limiting maximum fingers to %d\n",
|
||||
tsdata->max_fingers);
|
||||
}
|
||||
|
||||
error = input_mt_init_slots(input, tsdata->max_fingers,
|
||||
INPUT_MT_DIRECT | INPUT_MT_DROP_UNUSED);
|
||||
if (error) {
|
||||
dev_err(dev, "Error initializing Multi-Touch slots\n");
|
||||
return error;
|
||||
}
|
||||
|
||||
input_set_drvdata(input, tsdata);
|
||||
|
||||
error = devm_gpio_request_one(dev, pdata->gpio_attb,
|
||||
@@ -419,15 +578,36 @@ static int pixcir_i2c_ts_remove(struct i2c_client *client)
|
||||
|
||||
static const struct i2c_device_id pixcir_i2c_ts_id[] = {
|
||||
{ "pixcir_ts", 0 },
|
||||
{ "pixcir_tangoc", 0 },
|
||||
{ }
|
||||
};
|
||||
MODULE_DEVICE_TABLE(i2c, pixcir_i2c_ts_id);
|
||||
|
||||
#ifdef CONFIG_OF
|
||||
static const struct pixcir_i2c_chip_data pixcir_ts_data = {
|
||||
.max_fingers = 2,
|
||||
/* no hw id support */
|
||||
};
|
||||
|
||||
static const struct pixcir_i2c_chip_data pixcir_tangoc_data = {
|
||||
.max_fingers = 5,
|
||||
.has_hw_ids = true,
|
||||
};
|
||||
|
||||
static const struct of_device_id pixcir_of_match[] = {
|
||||
{ .compatible = "pixcir,pixcir_ts", .data = &pixcir_ts_data },
|
||||
{ .compatible = "pixcir,pixcir_tangoc", .data = &pixcir_tangoc_data },
|
||||
{ }
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, pixcir_of_match);
|
||||
#endif
|
||||
|
||||
static struct i2c_driver pixcir_i2c_ts_driver = {
|
||||
.driver = {
|
||||
.owner = THIS_MODULE,
|
||||
.name = "pixcir_ts",
|
||||
.pm = &pixcir_dev_pm_ops,
|
||||
.of_match_table = of_match_ptr(pixcir_of_match),
|
||||
},
|
||||
.probe = pixcir_i2c_ts_probe,
|
||||
.remove = pixcir_i2c_ts_remove,
|
||||
|
@@ -264,7 +264,7 @@ static int s3c2410ts_probe(struct platform_device *pdev)
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
clk_enable(ts.clock);
|
||||
clk_prepare_enable(ts.clock);
|
||||
dev_dbg(dev, "got and enabled clocks\n");
|
||||
|
||||
ts.irq_tc = ret = platform_get_irq(pdev, 0);
|
||||
@@ -369,7 +369,7 @@ static int s3c2410ts_remove(struct platform_device *pdev)
|
||||
free_irq(ts.irq_tc, ts.input);
|
||||
del_timer_sync(&touch_timer);
|
||||
|
||||
clk_disable(ts.clock);
|
||||
clk_disable_unprepare(ts.clock);
|
||||
clk_put(ts.clock);
|
||||
|
||||
input_unregister_device(ts.input);
|
||||
|
@@ -29,6 +29,8 @@
|
||||
#include <linux/sysfs.h>
|
||||
#include <linux/input/mt.h>
|
||||
#include <linux/platform_data/zforce_ts.h>
|
||||
#include <linux/regulator/consumer.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/of.h>
|
||||
#include <linux/of_gpio.h>
|
||||
|
||||
@@ -117,6 +119,8 @@ struct zforce_ts {
|
||||
const struct zforce_ts_platdata *pdata;
|
||||
char phys[32];
|
||||
|
||||
struct regulator *reg_vdd;
|
||||
|
||||
bool suspending;
|
||||
bool suspended;
|
||||
bool boot_complete;
|
||||
@@ -690,6 +694,11 @@ static void zforce_reset(void *data)
|
||||
struct zforce_ts *ts = data;
|
||||
|
||||
gpio_set_value(ts->pdata->gpio_rst, 0);
|
||||
|
||||
udelay(10);
|
||||
|
||||
if (!IS_ERR(ts->reg_vdd))
|
||||
regulator_disable(ts->reg_vdd);
|
||||
}
|
||||
|
||||
static struct zforce_ts_platdata *zforce_parse_dt(struct device *dev)
|
||||
@@ -765,10 +774,32 @@ static int zforce_probe(struct i2c_client *client,
|
||||
return ret;
|
||||
}
|
||||
|
||||
ts->reg_vdd = devm_regulator_get_optional(&client->dev, "vdd");
|
||||
if (IS_ERR(ts->reg_vdd)) {
|
||||
ret = PTR_ERR(ts->reg_vdd);
|
||||
if (ret == -EPROBE_DEFER)
|
||||
return ret;
|
||||
} else {
|
||||
ret = regulator_enable(ts->reg_vdd);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
/*
|
||||
* according to datasheet add 100us grace time after regular
|
||||
* regulator enable delay.
|
||||
*/
|
||||
udelay(100);
|
||||
}
|
||||
|
||||
ret = devm_add_action(&client->dev, zforce_reset, ts);
|
||||
if (ret) {
|
||||
dev_err(&client->dev, "failed to register reset action, %d\n",
|
||||
ret);
|
||||
|
||||
/* hereafter the regulator will be disabled by the action */
|
||||
if (!IS_ERR(ts->reg_vdd))
|
||||
regulator_disable(ts->reg_vdd);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user