* Re: [PATCH v7 2/2] Input: add Apple SPI keyboard and trackpad driver.
From: Dmitry Torokhov @ 2019-07-16 18:47 UTC (permalink / raw)
To: Ronald Tschalär
Cc: Henrik Rydberg, Andy Shevchenko, Andrzej Hajda, Inki Dae,
Greg Kroah-Hartman, Lukas Wunner, Federico Lorenzi,
Laurent Pinchart, linux-input, dri-devel, linux-kernel
In-Reply-To: <20190419081926.13567-3-ronald@innovation.ch>
Hi Ronald,
On Fri, Apr 19, 2019 at 01:19:26AM -0700, Ronald Tschalär wrote:
> The keyboard and trackpad on recent MacBook's (since 8,1) and
> MacBookPro's (13,* and 14,*) are attached to an SPI controller instead
> of USB, as previously. The higher level protocol is not publicly
> documented and hence has been reverse engineered. As a consequence there
> are still a number of unknown fields and commands. However, the known
> parts have been working well and received extensive testing and use.
>
> In order for this driver to work, the proper SPI drivers need to be
> loaded too; for MB8,1 these are spi_pxa2xx_platform and spi_pxa2xx_pci;
> for all others they are spi_pxa2xx_platform and intel_lpss_pci. For this
> reason enabling this driver in the config implies enabling the above
> drivers.
I applied the patch (but changed __u8 to u8 as that's preferred form for
inside the kernel, and added error handling for input_mt_init_slots) but
we need to do some more work on the driver.
My main issue is with registering touchpad device asynchronously,
independent from the probe() function. This means (as far as I can tell)
that any error is not really appropriately handled (as by that time it
is too late to signal errors from probe()) and devm functions are not
going to be called, leaving remnants of the resources in memory on
driver unload. It also brings in issues with suspend/resume (what
happens if you suspend really quickly while device is not registered
yet?), etc, etc.
Can we switch to calling DEV_INFO command synchronously from probe()? If
we are concerned about it taking relatively long time we can always
annotate the driver as having probe_type = PROBE_PREFER_ASYNCHRONOUS so
that other devices can be probed simultaneously with applespi.
Thanks.
--
Dmitry
^ permalink raw reply
* Re: [PATCH v2 2/2] input: soc_button_array for newer surface devices
From: Dmitry Torokhov @ 2019-07-16 20:18 UTC (permalink / raw)
To: Maximilian Luz
Cc: linux-kernel, linux-input, platform-driver-x86, Hans de Goede,
Chen Yu, Darren Hart, Andy Shevchenko, Benjamin Tissoires
In-Reply-To: <92e13b01-7353-1430-fb38-b5098d509da2@gmail.com>
On Tue, Jul 16, 2019 at 08:19:04PM +0200, Maximilian Luz wrote:
>
> Hi,
>
> On 7/16/19 9:21 AM, Dmitry Torokhov wrote:
> > When you are saying that Pro 4 and later models use different
> > notifications, does this mean that Pro 4 does not define any GPIOs?
>
> Unfortunately, at least the Surface Book (first generation, buttons are
> handled the same way as on the Pro 4) has GPIOs defined in MSHW0040, but
> they are for different use. Specifically: They can detect if the
> clipboard (screen part of the device, the device basically has two parts
> that can be separated: clipboard and base) is being removed. Relying on
> the GPIOs was my first idea too, but that has been reported to shut down
> the Book 1 when the clipboard is detached.
>
> As far as I know, the OEM platform revision check is the easiest way to
> differentiate between those devices.
OK, fair enough. By the way, I see you are adding some #ifdef
CONFIG_ACPI and stubbing out new functions, but the driver does not
really work without ACPI (acpi_match_device() will fail in this case I
would think and that will cause probe() to abort). So maybe we just add
depends on ACPI to the driver's Kconfig entry?
Thanks.
--
Dmitry
^ permalink raw reply
* Re: [PATCH] Input: i8042 - disable KBD port on Late-2016 Razer Blade Stealth
From: Dmitry Torokhov @ 2019-07-16 20:28 UTC (permalink / raw)
To: David Laight
Cc: 'Lyude Paul', stable@vger.kernel.org, Chen-Yu Tsai,
linux-input@vger.kernel.org, linux-kernel@vger.kernel.org
In-Reply-To: <28dc38a55c45467dad6f11e9ea459172@AcuMS.aculab.com>
On Mon, Apr 08, 2019 at 09:55:00AM +0000, David Laight wrote:
> From: Lyude Paul
> > Sent: 07 April 2019 23:55
> > On Sun, 2019-04-07 at 15:10 -0700, Dmitry Torokhov wrote:
> > > Hi Lyude,
> > >
> > > On Sun, Apr 07, 2019 at 05:37:34PM -0400, Lyude Paul wrote:
> > > > The late 2016 model of the Razer Blade Stealth has a built-in USB
> > > > keyboard, but for some reason the BIOS exposes an i8042 controller with
> > > > a connected KBD port. While this fake AT Keyboard device doesn't appear
> > > > to report any events, attempting to change the state of the caps lock
> > > > LED on it from on to off causes the entire system to hang.
> > > >
> > > > So, introduce a quirk table for disabling keyboard probing by default,
> > > > i8042_dmi_nokbd_table, and add this specific model of Razer laptop to
> > > > that table.
> > >
> > > What does dmesg show about i8042 for this device? Especially line "PNP:
> > > PS/2 Controller ..."?
> > >
> >
> > Apr 07 18:42:46 malachite kernel: i8042: PNP: No PS/2 controller found.
> > Apr 07 18:42:46 malachite kernel: i8042: Probing ports directly.
> > Apr 07 18:42:46 malachite kernel: serio: i8042 KBD port at 0x60,0x64 irq 1
> > Apr 07 18:42:46 malachite kernel: serio: i8042 AUX port at 0x60,0x64 irq 12
> > Apr 07 18:42:46 malachite kernel: mousedev: PS/2 mouse device common for all mice
>
> That is the 'default' probe of the ps/2 serial ports.
> Looks like the BIOS is correct in not exposing the ps/2 controller.
> Usually they just fail to expose the mouse when it needs a ps/2 splitter :-(
>
> I do wonder what they've connected it to though.
> It is extremely unlikely they've found an x86 chipset that doesn't
> have the ps/2 serial ports at the standard io addresses.
I wonder if it is time to start trusting BIOS if it was released maybe
in Win7+ timeframe?
Thanks.
--
Dmitry
^ permalink raw reply
* [PATCH v3 0/3] mfd: mc13xxx: Fixes and enhancements for NXP's mc34708
From: Lukasz Majewski @ 2019-07-16 22:19 UTC (permalink / raw)
To: Lee Jones
Cc: linux-kernel, Dmitry Torokhov, Sascha Hauer, Enrico Weigelt,
Thomas Gleixner, Kate Stewart, linux-input, Lukasz Majewski
This patch set provides several enhancements to mc13xxx MFD family
of devices by introducing mc34708 as a separate device.
This IC has dedicated pen detection feature, which allows better
touchscreen experience.
This is the third version of this code (v3).
Discussion regarding v1 can be found here:
https://lkml.org/lkml/2018/4/12/351
https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg1661934.html
https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg1664296.html
Sascha Hauer (3):
mfd: mc13xxx: Add mc34708 adc support
input: touchscreen mc13xxx: Make platform data optional
input: touchscreen mc13xxx: Add mc34708 support
drivers/input/touchscreen/mc13783_ts.c | 71 +++++++++++++++++++----
drivers/mfd/mc13xxx-core.c | 102 ++++++++++++++++++++++++++++++++-
drivers/mfd/mc13xxx.h | 3 +
include/linux/mfd/mc34708.h | 37 ++++++++++++
4 files changed, 201 insertions(+), 12 deletions(-)
create mode 100644 include/linux/mfd/mc34708.h
--
2.11.0
^ permalink raw reply
* [PATCH v3 1/3] mfd: mc13xxx: Add mc34708 adc support
From: Lukasz Majewski @ 2019-07-16 22:19 UTC (permalink / raw)
To: Lee Jones
Cc: linux-kernel, Dmitry Torokhov, Sascha Hauer, Enrico Weigelt,
Thomas Gleixner, Kate Stewart, linux-input, Lukasz Majewski
In-Reply-To: <20190716221929.3782-1-lukma@denx.de>
From: Sascha Hauer <s.hauer@pengutronix.de>
The mc34708 has an improved adc. The older variants will always convert
a fixed order of channels. The mc34708 can do up to eight conversions
in arbitrary channel order. Currently this extended feature is not
supported. We only support touchscreen conversions now, which will
be sampled in a data format compatible to the older chips in order
to keep the API between the mfd and the touchscreen driver.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Lukasz Majewski <lukma@denx.de>
---
Changes for v3:
- None
Changes for v2:
- Change the return code patch when the mc13xxx ADC is performing conversion
- Introduce new include/linux/mfd/mc34708.h header file for mc34708 specific
defines
Changes from the original patches:
- ADC conversion functions prototypes added to fix build error
- Adjustments to make checkpatch clean (-ENOSYS, line over 80 char)
This patch applies on top of v5.2 - SHA1: 0ecfebd2b52404ae0c54a878c872bb93363ada36
---
drivers/mfd/mc13xxx-core.c | 102 +++++++++++++++++++++++++++++++++++++++++++-
drivers/mfd/mc13xxx.h | 3 ++
include/linux/mfd/mc34708.h | 37 ++++++++++++++++
3 files changed, 141 insertions(+), 1 deletion(-)
create mode 100644 include/linux/mfd/mc34708.h
diff --git a/drivers/mfd/mc13xxx-core.c b/drivers/mfd/mc13xxx-core.c
index 1abe7432aad8..01473d6fda21 100644
--- a/drivers/mfd/mc13xxx-core.c
+++ b/drivers/mfd/mc13xxx-core.c
@@ -12,6 +12,7 @@
#include <linux/of_device.h>
#include <linux/platform_device.h>
#include <linux/mfd/core.h>
+#include <linux/mfd/mc34708.h>
#include "mc13xxx.h"
@@ -45,6 +46,8 @@
#define MC13XXX_ADC2 45
+#define MC13XXX_ADC_WORKING (1 << 0)
+
void mc13xxx_lock(struct mc13xxx *mc13xxx)
{
if (!mutex_trylock(&mc13xxx->lock)) {
@@ -198,22 +201,30 @@ static void mc34708_print_revision(struct mc13xxx *mc13xxx, u32 revision)
maskval(revision, MC34708_REVISION_FAB));
}
+static int mc13xxx_adc_conversion(struct mc13xxx *, unsigned int,
+ unsigned int, u8, bool, unsigned int *);
+static int mc34708_adc_conversion(struct mc13xxx *, unsigned int,
+ unsigned int, u8, bool, unsigned int *);
+
/* These are only exported for mc13xxx-i2c and mc13xxx-spi */
struct mc13xxx_variant mc13xxx_variant_mc13783 = {
.name = "mc13783",
.print_revision = mc13xxx_print_revision,
+ .adc_do_conversion = mc13xxx_adc_conversion,
};
EXPORT_SYMBOL_GPL(mc13xxx_variant_mc13783);
struct mc13xxx_variant mc13xxx_variant_mc13892 = {
.name = "mc13892",
.print_revision = mc13xxx_print_revision,
+ .adc_do_conversion = mc13xxx_adc_conversion,
};
EXPORT_SYMBOL_GPL(mc13xxx_variant_mc13892);
struct mc13xxx_variant mc13xxx_variant_mc34708 = {
.name = "mc34708",
.print_revision = mc34708_print_revision,
+ .adc_do_conversion = mc34708_adc_conversion,
};
EXPORT_SYMBOL_GPL(mc13xxx_variant_mc34708);
@@ -249,7 +260,7 @@ static irqreturn_t mc13xxx_handler_adcdone(int irq, void *data)
#define MC13XXX_ADC_WORKING (1 << 0)
-int mc13xxx_adc_do_conversion(struct mc13xxx *mc13xxx, unsigned int mode,
+static int mc13xxx_adc_conversion(struct mc13xxx *mc13xxx, unsigned int mode,
unsigned int channel, u8 ato, bool atox,
unsigned int *sample)
{
@@ -358,6 +369,95 @@ int mc13xxx_adc_do_conversion(struct mc13xxx *mc13xxx, unsigned int mode,
return ret;
}
+
+static int mc34708_adc_conversion(struct mc13xxx *mc13xxx, unsigned int mode,
+ unsigned int channel, u8 ato, bool atox,
+ unsigned int *sample)
+{
+ int ret, i;
+ u32 adc0, adc3, adc1, old_adc0;
+ struct mc13xxx_adcdone_data adcdone_data = {
+ .mc13xxx = mc13xxx,
+ };
+
+ switch (mode) {
+ case MC13XXX_ADC_MODE_TS:
+ adc0 = MC34708_ADC0_TSEN | MC34708_ADC0_TSSTART |
+ MC34708_ADC0_TSSTOP(7);
+
+ adc1 = MC34708_ADC1_TSDLY1(0xf) |
+ MC34708_ADC1_TSDLY2(0xf) |
+ MC34708_ADC1_TSDLY3(0xf);
+
+ adc3 = MC34708_ADC3_TSSEL(0, MC34708_TS_X) |
+ MC34708_ADC3_TSSEL(1, MC34708_TS_Y) |
+ MC34708_ADC3_TSSEL(2, MC34708_TS_X) |
+ MC34708_ADC3_TSSEL(3, MC34708_TS_Y) |
+ MC34708_ADC3_TSSEL(4, MC34708_TS_X) |
+ MC34708_ADC3_TSSEL(5, MC34708_TS_R) |
+ MC34708_ADC3_TSSEL(6, MC34708_TS_Y) |
+ MC34708_ADC3_TSSEL(7, MC34708_TS_R);
+ break;
+
+ case MC13XXX_ADC_MODE_SINGLE_CHAN:
+ case MC13XXX_ADC_MODE_MULT_CHAN:
+ default:
+ return -EINVAL;
+ }
+
+ init_completion(&adcdone_data.done);
+
+ mc13xxx_lock(mc13xxx);
+
+ if (mc13xxx->adcflags & MC13XXX_ADC_WORKING) {
+ mc13xxx_unlock(mc13xxx);
+ return -EBUSY;
+ }
+
+ mc13xxx->adcflags |= MC13XXX_ADC_WORKING;
+
+ mc13xxx_reg_read(mc13xxx, MC13XXX_ADC0, &old_adc0);
+
+ mc13xxx_irq_request(mc13xxx, MC34708_IRQ_TSDONE,
+ mc13xxx_handler_adcdone, __func__, &adcdone_data);
+ mc13xxx_irq_ack(mc13xxx, MC34708_IRQ_TSDONE);
+
+ mc13xxx_reg_write(mc13xxx, MC34708_ADC3, adc3);
+ mc13xxx_reg_write(mc13xxx, MC13XXX_ADC1, adc1);
+ mc13xxx_reg_write(mc13xxx, MC13XXX_ADC0, adc0);
+
+ mc13xxx_unlock(mc13xxx);
+
+ ret = wait_for_completion_interruptible_timeout(&adcdone_data.done, HZ);
+
+ mc13xxx_lock(mc13xxx);
+
+ mc13xxx_irq_free(mc13xxx, MC34708_IRQ_TSDONE, &adcdone_data);
+
+ if (!ret) {
+ ret = -ETIMEDOUT;
+ goto out;
+ }
+
+ for (i = 0; i < 4; i++)
+ mc13xxx_reg_read(mc13xxx, MC34708_ADC4 + i, &sample[i]);
+
+out:
+ ret = mc13xxx_reg_write(mc13xxx, MC13XXX_ADC0, old_adc0);
+
+ mc13xxx->adcflags &= ~MC13XXX_ADC_WORKING;
+ mc13xxx_unlock(mc13xxx);
+
+ return ret;
+}
+
+int mc13xxx_adc_do_conversion(struct mc13xxx *mc13xxx, unsigned int mode,
+ unsigned int channel, u8 ato, bool atox,
+ unsigned int *sample)
+{
+ return mc13xxx->variant->adc_do_conversion(mc13xxx, mode, channel, ato,
+ atox, sample);
+}
EXPORT_SYMBOL_GPL(mc13xxx_adc_do_conversion);
static int mc13xxx_add_subdevice_pdata(struct mc13xxx *mc13xxx,
diff --git a/drivers/mfd/mc13xxx.h b/drivers/mfd/mc13xxx.h
index ce6eec52e8eb..0a79fbb8bcb4 100644
--- a/drivers/mfd/mc13xxx.h
+++ b/drivers/mfd/mc13xxx.h
@@ -19,6 +19,9 @@ struct mc13xxx;
struct mc13xxx_variant {
const char *name;
void (*print_revision)(struct mc13xxx *mc13xxx, u32 revision);
+ int (*adc_do_conversion)(struct mc13xxx *mc13xxx, unsigned int mode,
+ unsigned int channel, u8 ato, bool atox,
+ unsigned int *sample);
};
extern struct mc13xxx_variant
diff --git a/include/linux/mfd/mc34708.h b/include/linux/mfd/mc34708.h
new file mode 100644
index 000000000000..c812104dc53d
--- /dev/null
+++ b/include/linux/mfd/mc34708.h
@@ -0,0 +1,37 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright (C) 2019
+ * Lukasz Majewski, DENX Software Engineering, lukma@denx.de
+ */
+#ifndef __LINUX_MFD_MC34708_H
+#define __LINUX_MFD_MC34708_H
+
+#define MC34708_ADC3 46
+#define MC34708_ADC4 47
+
+#define MC34708_IRQ_TSDONE 1
+
+#define MC34708_ADC0_TSEN BIT(12)
+#define MC34708_ADC0_TSSTART BIT(13)
+#define MC34708_ADC0_TSCONT BIT(14)
+#define MC34708_ADC0_TSHOLD BIT(15)
+#define MC34708_ADC0_TSPENDETEN BIT(20)
+
+#define MC34708_ADC0_TSMASK (MC34708_ADC0_TSPENDETEN | \
+ MC34708_ADC0_TSEN | \
+ MC34708_ADC0_TSSTART | \
+ MC34708_ADC0_TSCONT | \
+ MC34708_ADC0_TSHOLD)
+
+#define MC34708_ADC0_TSSTOP(x) (((x) & 0x7) << 16)
+
+#define MC34708_ADC3_TSSEL(step, ch) ((ch) << (8 + 2 * (step)))
+#define MC34708_ADC1_TSDLY1(d) ((d) << 12)
+#define MC34708_ADC1_TSDLY2(d) ((d) << 16)
+#define MC34708_ADC1_TSDLY3(d) ((d) << 20)
+
+#define MC34708_TS_X 1
+#define MC34708_TS_Y 2
+#define MC34708_TS_R 3
+
+#endif /* __LINUX_MFD_MC34708_H */
--
2.11.0
^ permalink raw reply related
* [PATCH v3 2/3] input: touchscreen mc13xxx: Make platform data optional
From: Lukasz Majewski @ 2019-07-16 22:19 UTC (permalink / raw)
To: Lee Jones
Cc: linux-kernel, Dmitry Torokhov, Sascha Hauer, Enrico Weigelt,
Thomas Gleixner, Kate Stewart, linux-input, Lukasz Majewski
In-Reply-To: <20190716221929.3782-1-lukma@denx.de>
From: Sascha Hauer <s.hauer@pengutronix.de>
The platform data once was optional, make it optional again. This
is a first step towards device tree support for the mc13xxx touchscreen
driver.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Lukasz Majewski <lukma@denx.de>
---
Changes for v3:
- None
Changes for v2:
- None
Changes from the original patch:
- Commit message typo fixes
---
drivers/input/touchscreen/mc13783_ts.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/drivers/input/touchscreen/mc13783_ts.c b/drivers/input/touchscreen/mc13783_ts.c
index ae0d978c83bf..edd49e44e0c9 100644
--- a/drivers/input/touchscreen/mc13783_ts.c
+++ b/drivers/input/touchscreen/mc13783_ts.c
@@ -35,7 +35,8 @@ struct mc13783_ts_priv {
struct mc13xxx *mc13xxx;
struct delayed_work work;
unsigned int sample[4];
- struct mc13xxx_ts_platform_data *touch;
+ u8 ato;
+ bool atox;
};
static irqreturn_t mc13783_ts_handler(int irq, void *data)
@@ -125,7 +126,7 @@ static void mc13783_ts_work(struct work_struct *work)
if (mc13xxx_adc_do_conversion(priv->mc13xxx,
mode, channel,
- priv->touch->ato, priv->touch->atox,
+ priv->ato, priv->atox,
priv->sample) == 0)
mc13783_ts_report_sample(priv);
}
@@ -169,6 +170,7 @@ static void mc13783_ts_close(struct input_dev *dev)
static int __init mc13783_ts_probe(struct platform_device *pdev)
{
struct mc13783_ts_priv *priv;
+ struct mc13xxx_ts_platform_data *pdata = dev_get_platdata(&pdev->dev);
struct input_dev *idev;
int ret = -ENOMEM;
@@ -180,11 +182,10 @@ static int __init mc13783_ts_probe(struct platform_device *pdev)
INIT_DELAYED_WORK(&priv->work, mc13783_ts_work);
priv->mc13xxx = dev_get_drvdata(pdev->dev.parent);
priv->idev = idev;
- priv->touch = dev_get_platdata(&pdev->dev);
- if (!priv->touch) {
- dev_err(&pdev->dev, "missing platform data\n");
- ret = -ENODEV;
- goto err_free_mem;
+
+ if (pdata) {
+ priv->atox = pdata->atox;
+ priv->ato = pdata->ato;
}
idev->name = MC13783_TS_NAME;
--
2.11.0
^ permalink raw reply related
* [PATCH v3 3/3] input: touchscreen mc13xxx: Add mc34708 support
From: Lukasz Majewski @ 2019-07-16 22:19 UTC (permalink / raw)
To: Lee Jones
Cc: linux-kernel, Dmitry Torokhov, Sascha Hauer, Enrico Weigelt,
Thomas Gleixner, Kate Stewart, linux-input, Lukasz Majewski
In-Reply-To: <20190716221929.3782-1-lukma@denx.de>
From: Sascha Hauer <s.hauer@pengutronix.de>
The mc34708 has a different bit to enable pen detection. This
adds the driver data and devtype necessary to probe the device
and to distinguish between the mc13783 and the mc34708.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Lukasz Majewski <lukma@denx.de>
---
Changes for v3:
- Replace forward declaration of mc13xxx_driver_data with
structure definition
- Rename mc13xxx_driver_data with mc13xxx_chip
- Move static struct mc13xxx_chip mc13783_chip and mc34708_chip
closer to ID table
- Do not check mc13xxx device type
Changes for v2:
- Change nested if statements to a single one (with cr0 > ...)
- Replace hardcoded max resistance value (4080) with a generic driver data
value.
- Introduce new include/linux/mfd/mc34708.h header file for mc34708 specific
defines
- Define as driver data mask and value for accessing mc13xxx registers
Changes from the original patch:
- Simplify the mcXXXXX_set_pen_detection functions
- Fix checkpatch warnings
---
drivers/input/touchscreen/mc13783_ts.c | 56 +++++++++++++++++++++++++++++++---
1 file changed, 52 insertions(+), 4 deletions(-)
diff --git a/drivers/input/touchscreen/mc13783_ts.c b/drivers/input/touchscreen/mc13783_ts.c
index edd49e44e0c9..857c11235141 100644
--- a/drivers/input/touchscreen/mc13783_ts.c
+++ b/drivers/input/touchscreen/mc13783_ts.c
@@ -10,6 +10,7 @@
*/
#include <linux/platform_device.h>
#include <linux/mfd/mc13783.h>
+#include <linux/mfd/mc34708.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/input.h>
@@ -30,6 +31,18 @@ MODULE_PARM_DESC(sample_tolerance,
"is supposed to be wrong and is discarded. Set to 0 to "
"disable this check.");
+enum mc13xxx_type {
+ MC13XXX_TYPE_MC13783,
+ MC13XXX_TYPE_MC34708,
+};
+
+struct mc13xxx_chip {
+ enum mc13xxx_type type;
+ int max_resistance;
+ u32 reg_mask;
+ u32 reg_value;
+};
+
struct mc13783_ts_priv {
struct input_dev *idev;
struct mc13xxx *mc13xxx;
@@ -37,6 +50,7 @@ struct mc13783_ts_priv {
unsigned int sample[4];
u8 ato;
bool atox;
+ const struct mc13xxx_chip *chip;
};
static irqreturn_t mc13783_ts_handler(int irq, void *data)
@@ -93,6 +107,9 @@ static void mc13783_ts_report_sample(struct mc13783_ts_priv *priv)
cr0 = (cr0 + cr1) / 2;
+ if (cr0 > priv->chip->max_resistance)
+ cr0 = 0;
+
if (!cr0 || !sample_tolerance ||
(x2 - x0 < sample_tolerance &&
y2 - y0 < sample_tolerance)) {
@@ -102,14 +119,14 @@ static void mc13783_ts_report_sample(struct mc13783_ts_priv *priv)
input_report_abs(idev, ABS_Y, y1);
dev_dbg(&idev->dev, "report (%d, %d, %d)\n",
- x1, y1, 0x1000 - cr0);
+ x1, y1, priv->chip->max_resistance - cr0);
schedule_delayed_work(&priv->work, HZ / 50);
} else {
dev_dbg(&idev->dev, "report release\n");
}
input_report_abs(idev, ABS_PRESSURE,
- cr0 ? 0x1000 - cr0 : cr0);
+ cr0 ? priv->chip->max_resistance - cr0 : 0);
input_report_key(idev, BTN_TOUCH, cr0);
input_sync(idev);
} else {
@@ -146,7 +163,8 @@ static int mc13783_ts_open(struct input_dev *dev)
goto out;
ret = mc13xxx_reg_rmw(priv->mc13xxx, MC13XXX_ADC0,
- MC13XXX_ADC0_TSMOD_MASK, MC13XXX_ADC0_TSMOD0);
+ priv->chip->reg_mask,
+ priv->chip->reg_value);
if (ret)
mc13xxx_irq_free(priv->mc13xxx, MC13XXX_IRQ_TS, priv);
out:
@@ -160,7 +178,7 @@ static void mc13783_ts_close(struct input_dev *dev)
mc13xxx_lock(priv->mc13xxx);
mc13xxx_reg_rmw(priv->mc13xxx, MC13XXX_ADC0,
- MC13XXX_ADC0_TSMOD_MASK, 0);
+ priv->chip->reg_mask, 0);
mc13xxx_irq_free(priv->mc13xxx, MC13XXX_IRQ_TS, priv);
mc13xxx_unlock(priv->mc13xxx);
@@ -172,6 +190,7 @@ static int __init mc13783_ts_probe(struct platform_device *pdev)
struct mc13783_ts_priv *priv;
struct mc13xxx_ts_platform_data *pdata = dev_get_platdata(&pdev->dev);
struct input_dev *idev;
+ const struct platform_device_id *id = platform_get_device_id(pdev);
int ret = -ENOMEM;
priv = kzalloc(sizeof(*priv), GFP_KERNEL);
@@ -182,6 +201,7 @@ static int __init mc13783_ts_probe(struct platform_device *pdev)
INIT_DELAYED_WORK(&priv->work, mc13783_ts_work);
priv->mc13xxx = dev_get_drvdata(pdev->dev.parent);
priv->idev = idev;
+ priv->chip = (void *)id->driver_data;
if (pdata) {
priv->atox = pdata->atox;
@@ -228,7 +248,35 @@ static int mc13783_ts_remove(struct platform_device *pdev)
return 0;
}
+static struct mc13xxx_chip mc13783_chip = {
+ .type = MC13XXX_TYPE_MC13783,
+ .max_resistance = 4096,
+ .reg_mask = MC13XXX_ADC0_TSMOD_MASK,
+ .reg_value = MC13XXX_ADC0_TSMOD0,
+};
+
+static struct mc13xxx_chip mc34708_chip = {
+ .type = MC13XXX_TYPE_MC34708,
+ .max_resistance = 4080,
+ .reg_mask = MC34708_ADC0_TSMASK,
+ .reg_value = MC34708_ADC0_TSPENDETEN,
+};
+
+static const struct platform_device_id mc13xxx_ts_idtable[] = {
+ {
+ .name = "mc13783-ts",
+ .driver_data = (kernel_ulong_t)&mc13783_chip,
+ }, {
+ .name = "mc34708-ts",
+ .driver_data = (kernel_ulong_t)&mc34708_chip,
+ }, {
+ /* sentinel */
+ }
+};
+MODULE_DEVICE_TABLE(platform, mc13xxx_ts_idtable);
+
static struct platform_driver mc13783_ts_driver = {
+ .id_table = mc13xxx_ts_idtable,
.remove = mc13783_ts_remove,
.driver = {
.name = MC13783_TS_NAME,
--
2.11.0
^ permalink raw reply related
* Re: [PATCH v3 2/3] input: touchscreen mc13xxx: Make platform data optional
From: Dmitry Torokhov @ 2019-07-17 3:35 UTC (permalink / raw)
To: Lukasz Majewski
Cc: Lee Jones, linux-kernel, Sascha Hauer, Enrico Weigelt,
Thomas Gleixner, Kate Stewart, linux-input
In-Reply-To: <20190716221929.3782-3-lukma@denx.de>
On Wed, Jul 17, 2019 at 12:19:28AM +0200, Lukasz Majewski wrote:
> From: Sascha Hauer <s.hauer@pengutronix.de>
>
> The platform data once was optional, make it optional again. This
> is a first step towards device tree support for the mc13xxx touchscreen
> driver.
>
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> Signed-off-by: Lukasz Majewski <lukma@denx.de>
Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
I suppose it will go together with the 1st patch through Lee's MFD tree?
Thanks.
--
Dmitry
^ permalink raw reply
* Re: [PATCH v3 3/3] input: touchscreen mc13xxx: Add mc34708 support
From: Dmitry Torokhov @ 2019-07-17 3:36 UTC (permalink / raw)
To: Lukasz Majewski
Cc: Lee Jones, linux-kernel, Sascha Hauer, Enrico Weigelt,
Thomas Gleixner, Kate Stewart, linux-input
In-Reply-To: <20190716221929.3782-4-lukma@denx.de>
On Wed, Jul 17, 2019 at 12:19:29AM +0200, Lukasz Majewski wrote:
> From: Sascha Hauer <s.hauer@pengutronix.de>
>
> The mc34708 has a different bit to enable pen detection. This
> adds the driver data and devtype necessary to probe the device
> and to distinguish between the mc13783 and the mc34708.
>
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> Signed-off-by: Lukasz Majewski <lukma@denx.de>
>
> ---
> Changes for v3:
> - Replace forward declaration of mc13xxx_driver_data with
> structure definition
> - Rename mc13xxx_driver_data with mc13xxx_chip
> - Move static struct mc13xxx_chip mc13783_chip and mc34708_chip
> closer to ID table
> - Do not check mc13xxx device type
You do not even need to define or store the type. Once it is dropped
please feel free to add
Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
and merge with the other 2 patches.
--
Dmitry
^ permalink raw reply
* Re: [PATCH v3 2/3] input: touchscreen mc13xxx: Make platform data optional
From: Lukasz Majewski @ 2019-07-17 8:14 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: Lee Jones, linux-kernel, Sascha Hauer, Enrico Weigelt,
Thomas Gleixner, Kate Stewart, linux-input
In-Reply-To: <20190717033559.GB621@penguin>
[-- Attachment #1: Type: text/plain, Size: 907 bytes --]
Hi Dmitry,
> On Wed, Jul 17, 2019 at 12:19:28AM +0200, Lukasz Majewski wrote:
> > From: Sascha Hauer <s.hauer@pengutronix.de>
> >
> > The platform data once was optional, make it optional again. This
> > is a first step towards device tree support for the mc13xxx
> > touchscreen driver.
> >
> > Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> > Signed-off-by: Lukasz Majewski <lukma@denx.de>
>
> Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
>
> I suppose it will go together with the 1st patch through Lee's MFD
> tree?
I suppose that this would be the easiest way to proceed.
>
> Thanks.
>
Best regards,
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply
* Re: [PATCH v3 3/3] input: touchscreen mc13xxx: Add mc34708 support
From: Lukasz Majewski @ 2019-07-17 8:17 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: Lee Jones, linux-kernel, Sascha Hauer, Enrico Weigelt,
Thomas Gleixner, Kate Stewart, linux-input
In-Reply-To: <20190717033655.GC621@penguin>
[-- Attachment #1: Type: text/plain, Size: 1456 bytes --]
Hi Dmitry,
> On Wed, Jul 17, 2019 at 12:19:29AM +0200, Lukasz Majewski wrote:
> > From: Sascha Hauer <s.hauer@pengutronix.de>
> >
> > The mc34708 has a different bit to enable pen detection. This
> > adds the driver data and devtype necessary to probe the device
> > and to distinguish between the mc13783 and the mc34708.
> >
> > Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> > Signed-off-by: Lukasz Majewski <lukma@denx.de>
> >
> > ---
> > Changes for v3:
> > - Replace forward declaration of mc13xxx_driver_data with
> > structure definition
> > - Rename mc13xxx_driver_data with mc13xxx_chip
> > - Move static struct mc13xxx_chip mc13783_chip and mc34708_chip
> > closer to ID table
> > - Do not check mc13xxx device type
>
> You do not even need to define or store the type. Once it is dropped
> please feel free to add
Ok. I will remove the type definition.
>
> Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
>
> and merge with the other 2 patches.
>
Ok. I will squash those three patches into a single one, add your
Acked-by and wait for Lee to pull this single patch to his MFD tree.
Thanks for review and help :-).
Best regards,
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply
* Re: [PATCH v3 3/3] input: touchscreen mc13xxx: Add mc34708 support
From: Dmitry Torokhov @ 2019-07-17 8:53 UTC (permalink / raw)
To: Lukasz Majewski
Cc: Lee Jones, linux-kernel, Sascha Hauer, Enrico Weigelt,
Thomas Gleixner, Kate Stewart, linux-input
In-Reply-To: <20190717101704.2ff4d877@jawa>
Hi Lukasz,
On Wed, Jul 17, 2019 at 10:17:04AM +0200, Lukasz Majewski wrote:
> Hi Dmitry,
>
> > On Wed, Jul 17, 2019 at 12:19:29AM +0200, Lukasz Majewski wrote:
> > > From: Sascha Hauer <s.hauer@pengutronix.de>
> > >
> > > The mc34708 has a different bit to enable pen detection. This
> > > adds the driver data and devtype necessary to probe the device
> > > and to distinguish between the mc13783 and the mc34708.
> > >
> > > Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> > > Signed-off-by: Lukasz Majewski <lukma@denx.de>
> > >
> > > ---
> > > Changes for v3:
> > > - Replace forward declaration of mc13xxx_driver_data with
> > > structure definition
> > > - Rename mc13xxx_driver_data with mc13xxx_chip
> > > - Move static struct mc13xxx_chip mc13783_chip and mc34708_chip
> > > closer to ID table
> > > - Do not check mc13xxx device type
> >
> > You do not even need to define or store the type. Once it is dropped
> > please feel free to add
>
> Ok. I will remove the type definition.
>
> >
> > Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> >
> > and merge with the other 2 patches.
> >
>
> Ok. I will squash those three patches into a single one, add your
> Acked-by and wait for Lee to pull this single patch to his MFD tree.
Sorry, it looks like there is misunderstanding. I did not ask to squash
together the 3 patches, I meant that they can all go together through
the same tree (MFD). That is what I meant by them being merged together.
Sorry for being unclear.
Thanks.
--
Dmitry
^ permalink raw reply
* Re: [PATCH v3 3/3] input: touchscreen mc13xxx: Add mc34708 support
From: Lukasz Majewski @ 2019-07-17 9:07 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: Lee Jones, linux-kernel, Sascha Hauer, Enrico Weigelt,
Thomas Gleixner, Kate Stewart, linux-input
In-Reply-To: <20190717085338.GA581@penguin>
[-- Attachment #1: Type: text/plain, Size: 2048 bytes --]
Hi Dmitry,
> Hi Lukasz,
>
> On Wed, Jul 17, 2019 at 10:17:04AM +0200, Lukasz Majewski wrote:
> > Hi Dmitry,
> >
> > > On Wed, Jul 17, 2019 at 12:19:29AM +0200, Lukasz Majewski wrote:
> > > > From: Sascha Hauer <s.hauer@pengutronix.de>
> > > >
> > > > The mc34708 has a different bit to enable pen detection. This
> > > > adds the driver data and devtype necessary to probe the device
> > > > and to distinguish between the mc13783 and the mc34708.
> > > >
> > > > Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> > > > Signed-off-by: Lukasz Majewski <lukma@denx.de>
> > > >
> > > > ---
> > > > Changes for v3:
> > > > - Replace forward declaration of mc13xxx_driver_data with
> > > > structure definition
> > > > - Rename mc13xxx_driver_data with mc13xxx_chip
> > > > - Move static struct mc13xxx_chip mc13783_chip and mc34708_chip
> > > > closer to ID table
> > > > - Do not check mc13xxx device type
> > >
> > > You do not even need to define or store the type. Once it is
> > > dropped please feel free to add
> >
> > Ok. I will remove the type definition.
> >
> > >
> > > Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> > >
> > > and merge with the other 2 patches.
> > >
> >
> > Ok. I will squash those three patches into a single one, add your
> > Acked-by and wait for Lee to pull this single patch to his MFD
> > tree.
>
> Sorry, it looks like there is misunderstanding. I did not ask to
> squash together the 3 patches, I meant that they can all go together
> through the same tree (MFD). That is what I meant by them being
> merged together.
>
Thanks for the explanation.
> Sorry for being unclear.
No problem - big thanks for very prompt review.
>
> Thanks.
>
Best regards,
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply
* Re: [PATCH v7 2/2] Input: add Apple SPI keyboard and trackpad driver.
From: Life is hard, and then you die @ 2019-07-17 10:24 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: Henrik Rydberg, Andy Shevchenko, Andrzej Hajda, Inki Dae,
Greg Kroah-Hartman, Lukas Wunner, Federico Lorenzi,
Laurent Pinchart, linux-input, dri-devel, linux-kernel
In-Reply-To: <20190716184744.GC1140@penguin>
[-- Attachment #1: Type: text/plain, Size: 2555 bytes --]
Hi Dmitry,
thanks for taking a look at this!
On Tue, Jul 16, 2019 at 08:47:44PM +0200, Dmitry Torokhov wrote:
> Hi Ronald,
>
> On Fri, Apr 19, 2019 at 01:19:26AM -0700, Ronald Tschalär wrote:
> > The keyboard and trackpad on recent MacBook's (since 8,1) and
> > MacBookPro's (13,* and 14,*) are attached to an SPI controller instead
> > of USB, as previously. The higher level protocol is not publicly
> > documented and hence has been reverse engineered. As a consequence there
> > are still a number of unknown fields and commands. However, the known
> > parts have been working well and received extensive testing and use.
> >
> > In order for this driver to work, the proper SPI drivers need to be
> > loaded too; for MB8,1 these are spi_pxa2xx_platform and spi_pxa2xx_pci;
> > for all others they are spi_pxa2xx_platform and intel_lpss_pci. For this
> > reason enabling this driver in the config implies enabling the above
> > drivers.
>
> I applied the patch (but changed __u8 to u8 as that's preferred form for
> inside the kernel, and added error handling for input_mt_init_slots) but
> we need to do some more work on the driver.
Looks good.
> My main issue is with registering touchpad device asynchronously,
> independent from the probe() function. This means (as far as I can tell)
> that any error is not really appropriately handled (as by that time it
> is too late to signal errors from probe()) and devm functions are not
> going to be called, leaving remnants of the resources in memory on
> driver unload. It also brings in issues with suspend/resume (what
> happens if you suspend really quickly while device is not registered
> yet?), etc, etc.
Yes, the lack of error propagation also bothered me a bit when I
introduced the dev-info command, but I thought doing synchronous
I/O operations in a probe function wasn't kosher. Happy to rectify
that though.
> Can we switch to calling DEV_INFO command synchronously from probe()? If
> we are concerned about it taking relatively long time we can always
> annotate the driver as having probe_type = PROBE_PREFER_ASYNCHRONOUS so
> that other devices can be probed simultaneously with applespi.
Normally the dev-info retrieval takes about 15ms - I presume that's
fast enough?
Attached is a patch that does this now (on top of your changes above).
The cancelling of outstanding spi requests in the error case is a bit
ugly (I wish there were an exported spi-flush/spi-wait-for-queue-empty
function or similar), but otherwise it's fairly straightforward.
Cheers,
Ronald
[-- Attachment #2: 0001-Input-applespi-register-touchpad-device-synchronousl.patch --]
[-- Type: text/plain, Size: 7793 bytes --]
>From a03a7b42ac6ea0707165c8beba04c722984064be Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ronald=20Tschal=C3=A4r?= <ronald@innovation.ch>
Date: Wed, 17 Jul 2019 02:46:57 -0700
Subject: [PATCH] Input: applespi - register touchpad device synchronously in
probe.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This allows errors during registration to properly fail the probe
function.
Doing this requires waiting for a response from the device inside the
probe function. While this generally takes about 15ms, in case of errors
it could be arbitrarily long, and hence a 3 second timeout is used.
This also adds 3 second timeouts to the drain functions to avoid the
potential for suspend or remove hanging forever.
Signed-off-by: Ronald Tschalär <ronald@innovation.ch>
---
drivers/input/keyboard/applespi.c | 125 ++++++++++++++++++++++++------
1 file changed, 100 insertions(+), 25 deletions(-)
diff --git a/drivers/input/keyboard/applespi.c b/drivers/input/keyboard/applespi.c
index 548737e7aeda..81a733a6ba1a 100644
--- a/drivers/input/keyboard/applespi.c
+++ b/drivers/input/keyboard/applespi.c
@@ -48,12 +48,12 @@
#include <linux/efi.h>
#include <linux/input.h>
#include <linux/input/mt.h>
+#include <linux/jiffies.h>
#include <linux/leds.h>
#include <linux/module.h>
#include <linux/spinlock.h>
#include <linux/spi/spi.h>
#include <linux/wait.h>
-#include <linux/workqueue.h>
#include <asm/barrier.h>
#include <asm/unaligned.h>
@@ -411,7 +411,13 @@ struct applespi_data {
bool read_active;
bool write_active;
- struct work_struct work;
+ struct applespi_complete_info {
+ void (*complete)(void *context);
+ struct applespi_data *applespi;
+ } spi_complete[2];
+ bool cancel_spi;
+
+ wait_queue_head_t tp_info_complete;
struct touchpad_info_protocol rcvd_tp_info;
struct dentry *debugfs_root;
@@ -593,13 +599,61 @@ static void applespi_setup_write_txfrs(struct applespi_data *applespi)
spi_message_add_tail(st_t, msg);
}
+static bool applespi_async_outstanding(struct applespi_data *applespi)
+{
+ return applespi->spi_complete[0].complete ||
+ applespi->spi_complete[1].complete;
+}
+
+static void applespi_async_complete(void *context)
+{
+ struct applespi_complete_info *info = context;
+ struct applespi_data *applespi = info->applespi;
+ unsigned long flags;
+
+ info->complete(applespi);
+
+ spin_lock_irqsave(&applespi->cmd_msg_lock, flags);
+
+ info->complete = NULL;
+
+ if (applespi->cancel_spi && !applespi_async_outstanding(applespi))
+ wake_up_all(&applespi->drain_complete);
+
+ spin_unlock_irqrestore(&applespi->cmd_msg_lock, flags);
+}
+
static int applespi_async(struct applespi_data *applespi,
struct spi_message *message, void (*complete)(void *))
{
- message->complete = complete;
- message->context = applespi;
+ struct applespi_complete_info *info;
+ int sts;
+
+ if (applespi->cancel_spi) {
+ if (!applespi_async_outstanding(applespi))
+ wake_up_all(&applespi->drain_complete);
+ return -ESHUTDOWN;
+ }
+
+ /*
+ * There can only be at max 2 spi requests in flight, one for "reads"
+ * and one for "writes".
+ */
+ if (!applespi->spi_complete[0].complete)
+ info = &applespi->spi_complete[0];
+ else
+ info = &applespi->spi_complete[1];
+ info->complete = complete;
+ info->applespi = applespi;
+
+ message->complete = applespi_async_complete;
+ message->context = info;
+
+ sts = spi_async(applespi->spi, message);
+ if (sts)
+ info->complete = NULL;
- return spi_async(applespi->spi, message);
+ return sts;
}
static inline bool applespi_check_write_status(struct applespi_data *applespi,
@@ -664,6 +718,7 @@ static int applespi_setup_spi(struct applespi_data *applespi)
spin_lock_init(&applespi->cmd_msg_lock);
init_waitqueue_head(&applespi->drain_complete);
+ init_waitqueue_head(&applespi->tp_info_complete);
return 0;
}
@@ -1011,7 +1066,7 @@ static void report_tp_state(struct applespi_data *applespi,
const struct applespi_tp_info *tp_info = &applespi->tp_info;
int i, n;
- /* touchpad_input_dev is set async in worker */
+ /* touchpad_input_dev is set async in probe */
input = smp_load_acquire(&applespi->touchpad_input_dev);
if (!input)
return; /* touchpad isn't initialized yet */
@@ -1315,26 +1370,14 @@ applespi_register_touchpad_device(struct applespi_data *applespi,
return 0;
}
-static void applespi_worker(struct work_struct *work)
-{
- struct applespi_data *applespi =
- container_of(work, struct applespi_data, work);
-
- applespi_register_touchpad_device(applespi, &applespi->rcvd_tp_info);
-}
-
static void applespi_handle_cmd_response(struct applespi_data *applespi,
struct spi_packet *packet,
struct message *message)
{
if (packet->device == PACKET_DEV_INFO &&
le16_to_cpu(message->type) == 0x1020) {
- /*
- * We're not allowed to sleep here, but registering an input
- * device can sleep.
- */
applespi->rcvd_tp_info = message->tp_info;
- schedule_work(&applespi->work);
+ wake_up_all(&applespi->tp_info_complete);
return;
}
@@ -1623,6 +1666,7 @@ static int applespi_probe(struct spi_device *spi)
struct applespi_data *applespi;
acpi_handle spi_handle = ACPI_HANDLE(&spi->dev);
acpi_status acpi_sts;
+ unsigned long flags;
int sts, i;
unsigned long long gpe, usb_status;
@@ -1641,8 +1685,6 @@ static int applespi_probe(struct spi_device *spi)
applespi->spi = spi;
- INIT_WORK(&applespi->work, applespi_worker);
-
/* store the driver data */
spi_set_drvdata(spi, applespi);
@@ -1770,6 +1812,22 @@ static int applespi_probe(struct spi_device *spi)
/* trigger touchpad setup */
applespi_init(applespi, false);
+ /* set up the touchpad as a separate input device */
+ sts = wait_event_timeout(applespi->tp_info_complete,
+ applespi->rcvd_tp_info.model_no,
+ msecs_to_jiffies(3000));
+ if (!sts) {
+ dev_err(&applespi->spi->dev,
+ "Timed out waiting for device info\n");
+ sts = -ETIMEDOUT;
+ goto cancel_spi;
+ }
+
+ sts = applespi_register_touchpad_device(applespi,
+ &applespi->rcvd_tp_info);
+ if (sts)
+ goto cancel_spi;
+
/*
* By default this device is not enabled for wakeup; but USB keyboards
* generally are, so the expectation is that by default the keyboard
@@ -1820,6 +1878,19 @@ static int applespi_probe(struct spi_device *spi)
}
return 0;
+
+cancel_spi:
+ acpi_disable_gpe(NULL, applespi->gpe);
+ acpi_remove_gpe_handler(NULL, applespi->gpe, applespi_notify);
+
+ spin_lock_irqsave(&applespi->cmd_msg_lock, flags);
+ applespi->cancel_spi = true;
+ wait_event_lock_irq(applespi->drain_complete,
+ !applespi_async_outstanding(applespi),
+ applespi->cmd_msg_lock);
+ spin_unlock_irqrestore(&applespi->cmd_msg_lock, flags);
+
+ return sts;
}
static void applespi_drain_writes(struct applespi_data *applespi)
@@ -1829,8 +1900,10 @@ static void applespi_drain_writes(struct applespi_data *applespi)
spin_lock_irqsave(&applespi->cmd_msg_lock, flags);
applespi->drain = true;
- wait_event_lock_irq(applespi->drain_complete, !applespi->write_active,
- applespi->cmd_msg_lock);
+ wait_event_lock_irq_timeout(applespi->drain_complete,
+ !applespi->write_active,
+ applespi->cmd_msg_lock,
+ msecs_to_jiffies(3000));
spin_unlock_irqrestore(&applespi->cmd_msg_lock, flags);
}
@@ -1841,8 +1914,10 @@ static void applespi_drain_reads(struct applespi_data *applespi)
spin_lock_irqsave(&applespi->cmd_msg_lock, flags);
- wait_event_lock_irq(applespi->drain_complete, !applespi->read_active,
- applespi->cmd_msg_lock);
+ wait_event_lock_irq_timeout(applespi->drain_complete,
+ !applespi->read_active,
+ applespi->cmd_msg_lock,
+ msecs_to_jiffies(3000));
applespi->suspended = true;
--
2.21.0
^ permalink raw reply related
* Re: [PATCH] hid-logitech-dj: rename "gaming" receiver to "lightspeed"
From: Jiri Kosina @ 2019-07-17 11:30 UTC (permalink / raw)
To: Filipe Laíns
Cc: nlopezcasad, Benjamin Tissoires, linux-input, linux-kernel
In-Reply-To: <20190716073621.4290-1-lains@archlinux.org>
Applied, thans.
--
Jiri Kosina
SUSE Labs
^ permalink raw reply
* Re: [PATCH] hid-logitech-hidpp: add USB PID for some mice
From: Jiri Kosina @ 2019-07-17 11:31 UTC (permalink / raw)
To: Filipe Laíns
Cc: nlopezcasad, Benjamin Tissoires, linux-input, linux-kernel
In-Reply-To: <20190716073726.6726-1-lains@archlinux.org>
On Tue, 16 Jul 2019, Filipe Laíns wrote:
> Signed-off-by: Filipe Laíns <lains@archlinux.org>
We generally don't accept empty changelogs for the kernel. I've added at
least a few words, and comitted.
This applies also to your second patch to logitech-dj. Thanks,
--
Jiri Kosina
SUSE Labs
^ permalink raw reply
* Re: [PATCH] hid-logitech-hidpp: add USB PID for some mice
From: Filipe Laíns @ 2019-07-17 11:32 UTC (permalink / raw)
To: Jiri Kosina; +Cc: nlopezcasad, Benjamin Tissoires, linux-input, linux-kernel
In-Reply-To: <nycvar.YFH.7.76.1907171330320.5899@cbobk.fhfr.pm>
[-- Attachment #1: Type: text/plain, Size: 445 bytes --]
On Wed, 2019-07-17 at 13:31 +0200, Jiri Kosina wrote:
> On Tue, 16 Jul 2019, Filipe Laíns wrote:
>
> > Signed-off-by: Filipe Laíns <lains@archlinux.org>
>
> We generally don't accept empty changelogs for the kernel. I've added at
> least a few words, and comitted.
>
> This applies also to your second patch to logitech-dj. Thanks,
Will keep in mind. Thanks!
Filipe Laíns
3DCE 51D6 0930 EBA4 7858 BA41 46F6 33CB B0EB 4BF2
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply
* Re: [PATCH v2 2/2] input: soc_button_array for newer surface devices
From: Maximilian Luz @ 2019-07-17 19:23 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: linux-kernel, linux-input, platform-driver-x86, Hans de Goede,
Chen Yu, Darren Hart, Andy Shevchenko, Benjamin Tissoires
In-Reply-To: <20190716201807.GA584@penguin>
On 7/16/19 10:18 PM, Dmitry Torokhov wrote:
> OK, fair enough. By the way, I see you are adding some #ifdef
> CONFIG_ACPI and stubbing out new functions, but the driver does not
> really work without ACPI (acpi_match_device() will fail in this case I
> would think and that will cause probe() to abort). So maybe we just add
> depends on ACPI to the driver's Kconfig entry?
Makes sense, I can change that too.
Maximilian
^ permalink raw reply
* [PATCH v4 0/3] mfd: mc13xxx: Fixes and enhancements for NXP's mc34708
From: Lukasz Majewski @ 2019-07-17 22:25 UTC (permalink / raw)
To: Lee Jones
Cc: linux-kernel, Dmitry Torokhov, Sascha Hauer, Enrico Weigelt,
Thomas Gleixner, Kate Stewart, linux-input, Lukasz Majewski
This patch set provides several enhancements to mc13xxx MFD family
of devices by introducing mc34708 as a separate device.
This IC has dedicated pen detection feature, which allows better
touchscreen experience.
This is the fourth version of this code (v4).
Discussion regarding v1 can be found here:
https://lkml.org/lkml/2018/4/12/351
https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg1661934.html
https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg1664296.html
Sascha Hauer (3):
mfd: mc13xxx: Add mc34708 adc support
input: touchscreen mc13xxx: Make platform data optional
input: touchscreen mc13xxx: Add mc34708 support
drivers/input/touchscreen/mc13783_ts.c | 63 ++++++++++++++++----
drivers/mfd/mc13xxx-core.c | 102 ++++++++++++++++++++++++++++++++-
drivers/mfd/mc13xxx.h | 3 +
include/linux/mfd/mc34708.h | 37 ++++++++++++
4 files changed, 193 insertions(+), 12 deletions(-)
create mode 100644 include/linux/mfd/mc34708.h
--
2.11.0
^ permalink raw reply
* [PATCH v4 1/3] mfd: mc13xxx: Add mc34708 adc support
From: Lukasz Majewski @ 2019-07-17 22:26 UTC (permalink / raw)
To: Lee Jones
Cc: linux-kernel, Dmitry Torokhov, Sascha Hauer, Enrico Weigelt,
Thomas Gleixner, Kate Stewart, linux-input, Lukasz Majewski
In-Reply-To: <20190717222602.2912-1-lukma@denx.de>
From: Sascha Hauer <s.hauer@pengutronix.de>
The mc34708 has an improved adc. The older variants will always convert
a fixed order of channels. The mc34708 can do up to eight conversions
in arbitrary channel order. Currently this extended feature is not
supported. We only support touchscreen conversions now, which will
be sampled in a data format compatible to the older chips in order
to keep the API between the mfd and the touchscreen driver.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Lukasz Majewski <lukma@denx.de>
---
Changes for v4:
- None
Changes for v3:
- None
Changes for v2:
- Change the return code patch when the mc13xxx ADC is performing conversion
- Introduce new include/linux/mfd/mc34708.h header file for mc34708 specific
defines
Changes from the original patches:
- ADC conversion functions prototypes added to fix build error
- Adjustments to make checkpatch clean (-ENOSYS, line over 80 char)
This patch applies on top of v5.2 - SHA1: 0ecfebd2b52404ae0c54a878c872bb93363ada36
---
drivers/mfd/mc13xxx-core.c | 102 +++++++++++++++++++++++++++++++++++++++++++-
drivers/mfd/mc13xxx.h | 3 ++
include/linux/mfd/mc34708.h | 37 ++++++++++++++++
3 files changed, 141 insertions(+), 1 deletion(-)
create mode 100644 include/linux/mfd/mc34708.h
diff --git a/drivers/mfd/mc13xxx-core.c b/drivers/mfd/mc13xxx-core.c
index 1abe7432aad8..01473d6fda21 100644
--- a/drivers/mfd/mc13xxx-core.c
+++ b/drivers/mfd/mc13xxx-core.c
@@ -12,6 +12,7 @@
#include <linux/of_device.h>
#include <linux/platform_device.h>
#include <linux/mfd/core.h>
+#include <linux/mfd/mc34708.h>
#include "mc13xxx.h"
@@ -45,6 +46,8 @@
#define MC13XXX_ADC2 45
+#define MC13XXX_ADC_WORKING (1 << 0)
+
void mc13xxx_lock(struct mc13xxx *mc13xxx)
{
if (!mutex_trylock(&mc13xxx->lock)) {
@@ -198,22 +201,30 @@ static void mc34708_print_revision(struct mc13xxx *mc13xxx, u32 revision)
maskval(revision, MC34708_REVISION_FAB));
}
+static int mc13xxx_adc_conversion(struct mc13xxx *, unsigned int,
+ unsigned int, u8, bool, unsigned int *);
+static int mc34708_adc_conversion(struct mc13xxx *, unsigned int,
+ unsigned int, u8, bool, unsigned int *);
+
/* These are only exported for mc13xxx-i2c and mc13xxx-spi */
struct mc13xxx_variant mc13xxx_variant_mc13783 = {
.name = "mc13783",
.print_revision = mc13xxx_print_revision,
+ .adc_do_conversion = mc13xxx_adc_conversion,
};
EXPORT_SYMBOL_GPL(mc13xxx_variant_mc13783);
struct mc13xxx_variant mc13xxx_variant_mc13892 = {
.name = "mc13892",
.print_revision = mc13xxx_print_revision,
+ .adc_do_conversion = mc13xxx_adc_conversion,
};
EXPORT_SYMBOL_GPL(mc13xxx_variant_mc13892);
struct mc13xxx_variant mc13xxx_variant_mc34708 = {
.name = "mc34708",
.print_revision = mc34708_print_revision,
+ .adc_do_conversion = mc34708_adc_conversion,
};
EXPORT_SYMBOL_GPL(mc13xxx_variant_mc34708);
@@ -249,7 +260,7 @@ static irqreturn_t mc13xxx_handler_adcdone(int irq, void *data)
#define MC13XXX_ADC_WORKING (1 << 0)
-int mc13xxx_adc_do_conversion(struct mc13xxx *mc13xxx, unsigned int mode,
+static int mc13xxx_adc_conversion(struct mc13xxx *mc13xxx, unsigned int mode,
unsigned int channel, u8 ato, bool atox,
unsigned int *sample)
{
@@ -358,6 +369,95 @@ int mc13xxx_adc_do_conversion(struct mc13xxx *mc13xxx, unsigned int mode,
return ret;
}
+
+static int mc34708_adc_conversion(struct mc13xxx *mc13xxx, unsigned int mode,
+ unsigned int channel, u8 ato, bool atox,
+ unsigned int *sample)
+{
+ int ret, i;
+ u32 adc0, adc3, adc1, old_adc0;
+ struct mc13xxx_adcdone_data adcdone_data = {
+ .mc13xxx = mc13xxx,
+ };
+
+ switch (mode) {
+ case MC13XXX_ADC_MODE_TS:
+ adc0 = MC34708_ADC0_TSEN | MC34708_ADC0_TSSTART |
+ MC34708_ADC0_TSSTOP(7);
+
+ adc1 = MC34708_ADC1_TSDLY1(0xf) |
+ MC34708_ADC1_TSDLY2(0xf) |
+ MC34708_ADC1_TSDLY3(0xf);
+
+ adc3 = MC34708_ADC3_TSSEL(0, MC34708_TS_X) |
+ MC34708_ADC3_TSSEL(1, MC34708_TS_Y) |
+ MC34708_ADC3_TSSEL(2, MC34708_TS_X) |
+ MC34708_ADC3_TSSEL(3, MC34708_TS_Y) |
+ MC34708_ADC3_TSSEL(4, MC34708_TS_X) |
+ MC34708_ADC3_TSSEL(5, MC34708_TS_R) |
+ MC34708_ADC3_TSSEL(6, MC34708_TS_Y) |
+ MC34708_ADC3_TSSEL(7, MC34708_TS_R);
+ break;
+
+ case MC13XXX_ADC_MODE_SINGLE_CHAN:
+ case MC13XXX_ADC_MODE_MULT_CHAN:
+ default:
+ return -EINVAL;
+ }
+
+ init_completion(&adcdone_data.done);
+
+ mc13xxx_lock(mc13xxx);
+
+ if (mc13xxx->adcflags & MC13XXX_ADC_WORKING) {
+ mc13xxx_unlock(mc13xxx);
+ return -EBUSY;
+ }
+
+ mc13xxx->adcflags |= MC13XXX_ADC_WORKING;
+
+ mc13xxx_reg_read(mc13xxx, MC13XXX_ADC0, &old_adc0);
+
+ mc13xxx_irq_request(mc13xxx, MC34708_IRQ_TSDONE,
+ mc13xxx_handler_adcdone, __func__, &adcdone_data);
+ mc13xxx_irq_ack(mc13xxx, MC34708_IRQ_TSDONE);
+
+ mc13xxx_reg_write(mc13xxx, MC34708_ADC3, adc3);
+ mc13xxx_reg_write(mc13xxx, MC13XXX_ADC1, adc1);
+ mc13xxx_reg_write(mc13xxx, MC13XXX_ADC0, adc0);
+
+ mc13xxx_unlock(mc13xxx);
+
+ ret = wait_for_completion_interruptible_timeout(&adcdone_data.done, HZ);
+
+ mc13xxx_lock(mc13xxx);
+
+ mc13xxx_irq_free(mc13xxx, MC34708_IRQ_TSDONE, &adcdone_data);
+
+ if (!ret) {
+ ret = -ETIMEDOUT;
+ goto out;
+ }
+
+ for (i = 0; i < 4; i++)
+ mc13xxx_reg_read(mc13xxx, MC34708_ADC4 + i, &sample[i]);
+
+out:
+ ret = mc13xxx_reg_write(mc13xxx, MC13XXX_ADC0, old_adc0);
+
+ mc13xxx->adcflags &= ~MC13XXX_ADC_WORKING;
+ mc13xxx_unlock(mc13xxx);
+
+ return ret;
+}
+
+int mc13xxx_adc_do_conversion(struct mc13xxx *mc13xxx, unsigned int mode,
+ unsigned int channel, u8 ato, bool atox,
+ unsigned int *sample)
+{
+ return mc13xxx->variant->adc_do_conversion(mc13xxx, mode, channel, ato,
+ atox, sample);
+}
EXPORT_SYMBOL_GPL(mc13xxx_adc_do_conversion);
static int mc13xxx_add_subdevice_pdata(struct mc13xxx *mc13xxx,
diff --git a/drivers/mfd/mc13xxx.h b/drivers/mfd/mc13xxx.h
index ce6eec52e8eb..0a79fbb8bcb4 100644
--- a/drivers/mfd/mc13xxx.h
+++ b/drivers/mfd/mc13xxx.h
@@ -19,6 +19,9 @@ struct mc13xxx;
struct mc13xxx_variant {
const char *name;
void (*print_revision)(struct mc13xxx *mc13xxx, u32 revision);
+ int (*adc_do_conversion)(struct mc13xxx *mc13xxx, unsigned int mode,
+ unsigned int channel, u8 ato, bool atox,
+ unsigned int *sample);
};
extern struct mc13xxx_variant
diff --git a/include/linux/mfd/mc34708.h b/include/linux/mfd/mc34708.h
new file mode 100644
index 000000000000..c812104dc53d
--- /dev/null
+++ b/include/linux/mfd/mc34708.h
@@ -0,0 +1,37 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright (C) 2019
+ * Lukasz Majewski, DENX Software Engineering, lukma@denx.de
+ */
+#ifndef __LINUX_MFD_MC34708_H
+#define __LINUX_MFD_MC34708_H
+
+#define MC34708_ADC3 46
+#define MC34708_ADC4 47
+
+#define MC34708_IRQ_TSDONE 1
+
+#define MC34708_ADC0_TSEN BIT(12)
+#define MC34708_ADC0_TSSTART BIT(13)
+#define MC34708_ADC0_TSCONT BIT(14)
+#define MC34708_ADC0_TSHOLD BIT(15)
+#define MC34708_ADC0_TSPENDETEN BIT(20)
+
+#define MC34708_ADC0_TSMASK (MC34708_ADC0_TSPENDETEN | \
+ MC34708_ADC0_TSEN | \
+ MC34708_ADC0_TSSTART | \
+ MC34708_ADC0_TSCONT | \
+ MC34708_ADC0_TSHOLD)
+
+#define MC34708_ADC0_TSSTOP(x) (((x) & 0x7) << 16)
+
+#define MC34708_ADC3_TSSEL(step, ch) ((ch) << (8 + 2 * (step)))
+#define MC34708_ADC1_TSDLY1(d) ((d) << 12)
+#define MC34708_ADC1_TSDLY2(d) ((d) << 16)
+#define MC34708_ADC1_TSDLY3(d) ((d) << 20)
+
+#define MC34708_TS_X 1
+#define MC34708_TS_Y 2
+#define MC34708_TS_R 3
+
+#endif /* __LINUX_MFD_MC34708_H */
--
2.11.0
^ permalink raw reply related
* [PATCH v4 2/3] input: touchscreen mc13xxx: Make platform data optional
From: Lukasz Majewski @ 2019-07-17 22:26 UTC (permalink / raw)
To: Lee Jones
Cc: linux-kernel, Dmitry Torokhov, Sascha Hauer, Enrico Weigelt,
Thomas Gleixner, Kate Stewart, linux-input, Lukasz Majewski
In-Reply-To: <20190717222602.2912-1-lukma@denx.de>
From: Sascha Hauer <s.hauer@pengutronix.de>
The platform data once was optional, make it optional again. This
is a first step towards device tree support for the mc13xxx touchscreen
driver.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Lukasz Majewski <lukma@denx.de>
Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
Changes for v4:
- Add Dmitry's Acked-by:
Changes for v3:
- None
Changes for v2:
- None
Changes from the original patch:
- Commit message typo fixes
---
drivers/input/touchscreen/mc13783_ts.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/drivers/input/touchscreen/mc13783_ts.c b/drivers/input/touchscreen/mc13783_ts.c
index ae0d978c83bf..edd49e44e0c9 100644
--- a/drivers/input/touchscreen/mc13783_ts.c
+++ b/drivers/input/touchscreen/mc13783_ts.c
@@ -35,7 +35,8 @@ struct mc13783_ts_priv {
struct mc13xxx *mc13xxx;
struct delayed_work work;
unsigned int sample[4];
- struct mc13xxx_ts_platform_data *touch;
+ u8 ato;
+ bool atox;
};
static irqreturn_t mc13783_ts_handler(int irq, void *data)
@@ -125,7 +126,7 @@ static void mc13783_ts_work(struct work_struct *work)
if (mc13xxx_adc_do_conversion(priv->mc13xxx,
mode, channel,
- priv->touch->ato, priv->touch->atox,
+ priv->ato, priv->atox,
priv->sample) == 0)
mc13783_ts_report_sample(priv);
}
@@ -169,6 +170,7 @@ static void mc13783_ts_close(struct input_dev *dev)
static int __init mc13783_ts_probe(struct platform_device *pdev)
{
struct mc13783_ts_priv *priv;
+ struct mc13xxx_ts_platform_data *pdata = dev_get_platdata(&pdev->dev);
struct input_dev *idev;
int ret = -ENOMEM;
@@ -180,11 +182,10 @@ static int __init mc13783_ts_probe(struct platform_device *pdev)
INIT_DELAYED_WORK(&priv->work, mc13783_ts_work);
priv->mc13xxx = dev_get_drvdata(pdev->dev.parent);
priv->idev = idev;
- priv->touch = dev_get_platdata(&pdev->dev);
- if (!priv->touch) {
- dev_err(&pdev->dev, "missing platform data\n");
- ret = -ENODEV;
- goto err_free_mem;
+
+ if (pdata) {
+ priv->atox = pdata->atox;
+ priv->ato = pdata->ato;
}
idev->name = MC13783_TS_NAME;
--
2.11.0
^ permalink raw reply related
* [PATCH v4 3/3] input: touchscreen mc13xxx: Add mc34708 support
From: Lukasz Majewski @ 2019-07-17 22:26 UTC (permalink / raw)
To: Lee Jones
Cc: linux-kernel, Dmitry Torokhov, Sascha Hauer, Enrico Weigelt,
Thomas Gleixner, Kate Stewart, linux-input, Lukasz Majewski
In-Reply-To: <20190717222602.2912-1-lukma@denx.de>
From: Sascha Hauer <s.hauer@pengutronix.de>
The mc34708 has a different bit to enable pen detection. This
adds the driver data and devtype necessary to probe the device
and to distinguish between the mc13783 and the mc34708.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Lukasz Majewski <lukma@denx.de>
Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
Changes for v4:
- Remove type from struct mc13xx_chip
- Add Acked-by from Dmitry
Changes for v3:
- Replace forward declaration of mc13xxx_driver_data with
structure definition
- Rename mc13xxx_driver_data with mc13xxx_chip
- Move static struct mc13xxx_chip mc13783_chip and mc34708_chip
closer to ID table
- Do not check mc13xxx device type
Changes for v2:
- Change nested if statements to a single one (with cr0 > ...)
- Replace hardcoded max resistance value (4080) with a generic driver data
value.
- Introduce new include/linux/mfd/mc34708.h header file for mc34708 specific
defines
- Define as driver data mask and value for accessing mc13xxx registers
Changes from the original patch:
- Simplify the mcXXXXX_set_pen_detection functions
- Fix checkpatch warnings
---
drivers/input/touchscreen/mc13783_ts.c | 48 +++++++++++++++++++++++++++++++---
1 file changed, 44 insertions(+), 4 deletions(-)
diff --git a/drivers/input/touchscreen/mc13783_ts.c b/drivers/input/touchscreen/mc13783_ts.c
index edd49e44e0c9..1dd8ed396225 100644
--- a/drivers/input/touchscreen/mc13783_ts.c
+++ b/drivers/input/touchscreen/mc13783_ts.c
@@ -10,6 +10,7 @@
*/
#include <linux/platform_device.h>
#include <linux/mfd/mc13783.h>
+#include <linux/mfd/mc34708.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/input.h>
@@ -30,6 +31,12 @@ MODULE_PARM_DESC(sample_tolerance,
"is supposed to be wrong and is discarded. Set to 0 to "
"disable this check.");
+struct mc13xxx_chip {
+ int max_resistance;
+ u32 reg_mask;
+ u32 reg_value;
+};
+
struct mc13783_ts_priv {
struct input_dev *idev;
struct mc13xxx *mc13xxx;
@@ -37,6 +44,7 @@ struct mc13783_ts_priv {
unsigned int sample[4];
u8 ato;
bool atox;
+ const struct mc13xxx_chip *chip;
};
static irqreturn_t mc13783_ts_handler(int irq, void *data)
@@ -93,6 +101,9 @@ static void mc13783_ts_report_sample(struct mc13783_ts_priv *priv)
cr0 = (cr0 + cr1) / 2;
+ if (cr0 > priv->chip->max_resistance)
+ cr0 = 0;
+
if (!cr0 || !sample_tolerance ||
(x2 - x0 < sample_tolerance &&
y2 - y0 < sample_tolerance)) {
@@ -102,14 +113,14 @@ static void mc13783_ts_report_sample(struct mc13783_ts_priv *priv)
input_report_abs(idev, ABS_Y, y1);
dev_dbg(&idev->dev, "report (%d, %d, %d)\n",
- x1, y1, 0x1000 - cr0);
+ x1, y1, priv->chip->max_resistance - cr0);
schedule_delayed_work(&priv->work, HZ / 50);
} else {
dev_dbg(&idev->dev, "report release\n");
}
input_report_abs(idev, ABS_PRESSURE,
- cr0 ? 0x1000 - cr0 : cr0);
+ cr0 ? priv->chip->max_resistance - cr0 : 0);
input_report_key(idev, BTN_TOUCH, cr0);
input_sync(idev);
} else {
@@ -146,7 +157,8 @@ static int mc13783_ts_open(struct input_dev *dev)
goto out;
ret = mc13xxx_reg_rmw(priv->mc13xxx, MC13XXX_ADC0,
- MC13XXX_ADC0_TSMOD_MASK, MC13XXX_ADC0_TSMOD0);
+ priv->chip->reg_mask,
+ priv->chip->reg_value);
if (ret)
mc13xxx_irq_free(priv->mc13xxx, MC13XXX_IRQ_TS, priv);
out:
@@ -160,7 +172,7 @@ static void mc13783_ts_close(struct input_dev *dev)
mc13xxx_lock(priv->mc13xxx);
mc13xxx_reg_rmw(priv->mc13xxx, MC13XXX_ADC0,
- MC13XXX_ADC0_TSMOD_MASK, 0);
+ priv->chip->reg_mask, 0);
mc13xxx_irq_free(priv->mc13xxx, MC13XXX_IRQ_TS, priv);
mc13xxx_unlock(priv->mc13xxx);
@@ -172,6 +184,7 @@ static int __init mc13783_ts_probe(struct platform_device *pdev)
struct mc13783_ts_priv *priv;
struct mc13xxx_ts_platform_data *pdata = dev_get_platdata(&pdev->dev);
struct input_dev *idev;
+ const struct platform_device_id *id = platform_get_device_id(pdev);
int ret = -ENOMEM;
priv = kzalloc(sizeof(*priv), GFP_KERNEL);
@@ -182,6 +195,7 @@ static int __init mc13783_ts_probe(struct platform_device *pdev)
INIT_DELAYED_WORK(&priv->work, mc13783_ts_work);
priv->mc13xxx = dev_get_drvdata(pdev->dev.parent);
priv->idev = idev;
+ priv->chip = (void *)id->driver_data;
if (pdata) {
priv->atox = pdata->atox;
@@ -228,7 +242,33 @@ static int mc13783_ts_remove(struct platform_device *pdev)
return 0;
}
+static struct mc13xxx_chip mc13783_chip = {
+ .max_resistance = 4096,
+ .reg_mask = MC13XXX_ADC0_TSMOD_MASK,
+ .reg_value = MC13XXX_ADC0_TSMOD0,
+};
+
+static struct mc13xxx_chip mc34708_chip = {
+ .max_resistance = 4080,
+ .reg_mask = MC34708_ADC0_TSMASK,
+ .reg_value = MC34708_ADC0_TSPENDETEN,
+};
+
+static const struct platform_device_id mc13xxx_ts_idtable[] = {
+ {
+ .name = "mc13783-ts",
+ .driver_data = (kernel_ulong_t)&mc13783_chip,
+ }, {
+ .name = "mc34708-ts",
+ .driver_data = (kernel_ulong_t)&mc34708_chip,
+ }, {
+ /* sentinel */
+ }
+};
+MODULE_DEVICE_TABLE(platform, mc13xxx_ts_idtable);
+
static struct platform_driver mc13783_ts_driver = {
+ .id_table = mc13xxx_ts_idtable,
.remove = mc13783_ts_remove,
.driver = {
.name = MC13783_TS_NAME,
--
2.11.0
^ permalink raw reply related
* [PATCH] Input: applespi: Fix build error without CONFIG_PCI
From: YueHaibing @ 2019-07-18 2:06 UTC (permalink / raw)
To: dmitry.torokhov, hsweeten, robh, arnd, ronald, andriy.shevchenko
Cc: linux-kernel, linux-input, YueHaibing
If CONFIG_KEYBOARD_APPLESPI is set to y, but
CONFIG_PCI is not set, building will fails:
drivers/spi/spi-pxa2xx-pci.c: In function pxa2xx_spi_pci_probe:
drivers/spi/spi-pxa2xx-pci.c:208:8: error: implicit declaration of function pcim_enable_device;
did you mean pci_enable_device? [-Werror=implicit-function-declaration]
ret = pcim_enable_device(dev);
^~~~~~~~~~~~~~~~~~
pci_enable_device
drivers/spi/spi-pxa2xx-pci.c:239:8: error: implicit declaration of function pci_alloc_irq_vectors;
did you mean pci_alloc_consistent? [-Werror=implicit-function-declaration]
ret = pci_alloc_irq_vectors(dev, 1, 1, PCI_IRQ_ALL_TYPES);
^~~~~~~~~~~~~~~~~~~~~
Make CONFIG_KEYBOARD_APPLESPI depends on CONFIG_PCI
to fix this.
Reported-by: Hulk Robot <hulkci@huawei.com>
Fixes: b426ac045209 ("Input: add Apple SPI keyboard and trackpad driver")
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
---
drivers/input/keyboard/Kconfig | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig
index dd934c4..fefcc46 100644
--- a/drivers/input/keyboard/Kconfig
+++ b/drivers/input/keyboard/Kconfig
@@ -74,7 +74,7 @@ config ATARI_KBD_CORE
config KEYBOARD_APPLESPI
tristate "Apple SPI keyboard and trackpad"
depends on ACPI && EFI
- depends on SPI
+ depends on SPI && PCI
depends on X86 || COMPILE_TEST
imply SPI_PXA2XX
imply SPI_PXA2XX_PCI
--
2.7.4
^ permalink raw reply related
* Re: [PATCH] Input: applespi: Fix build error without CONFIG_PCI
From: Life is hard, and then you die @ 2019-07-18 11:40 UTC (permalink / raw)
To: YueHaibing
Cc: dmitry.torokhov, hsweeten, robh, arnd, andriy.shevchenko,
linux-kernel, linux-input
In-Reply-To: <20190718020654.39860-1-yuehaibing@huawei.com>
On Thu, Jul 18, 2019 at 10:06:54AM +0800, YueHaibing wrote:
> If CONFIG_KEYBOARD_APPLESPI is set to y, but
> CONFIG_PCI is not set, building will fails:
>
> drivers/spi/spi-pxa2xx-pci.c: In function pxa2xx_spi_pci_probe:
> drivers/spi/spi-pxa2xx-pci.c:208:8: error: implicit declaration of function pcim_enable_device;
> did you mean pci_enable_device? [-Werror=implicit-function-declaration]
> ret = pcim_enable_device(dev);
> ^~~~~~~~~~~~~~~~~~
> pci_enable_device
> drivers/spi/spi-pxa2xx-pci.c:239:8: error: implicit declaration of function pci_alloc_irq_vectors;
> did you mean pci_alloc_consistent? [-Werror=implicit-function-declaration]
> ret = pci_alloc_irq_vectors(dev, 1, 1, PCI_IRQ_ALL_TYPES);
> ^~~~~~~~~~~~~~~~~~~~~
>
> Make CONFIG_KEYBOARD_APPLESPI depends on CONFIG_PCI
> to fix this.
>
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Fixes: b426ac045209 ("Input: add Apple SPI keyboard and trackpad driver")
> Signed-off-by: YueHaibing <yuehaibing@huawei.com>
> ---
> drivers/input/keyboard/Kconfig | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig
> index dd934c4..fefcc46 100644
> --- a/drivers/input/keyboard/Kconfig
> +++ b/drivers/input/keyboard/Kconfig
> @@ -74,7 +74,7 @@ config ATARI_KBD_CORE
> config KEYBOARD_APPLESPI
> tristate "Apple SPI keyboard and trackpad"
> depends on ACPI && EFI
> - depends on SPI
> + depends on SPI && PCI
> depends on X86 || COMPILE_TEST
> imply SPI_PXA2XX
> imply SPI_PXA2XX_PCI
> --
> 2.7.4
I think this is more properly fixed by Dmitry's suggestion of making
SPI_PXA2XX_PCI depend on PCI, since it's that module, not applespi,
that actually needs PCI - see
https://www.spinics.net/lists/linux-input/msg62351.html
Cheers,
Ronald
^ permalink raw reply
* Re: [PATCH] Input: applespi: Fix build error without CONFIG_PCI
From: Arnd Bergmann @ 2019-07-18 11:56 UTC (permalink / raw)
To: Life is hard, and then you die
Cc: YueHaibing, Dmitry Torokhov, Hartley Sweeten, Rob Herring,
Andy Shevchenko, Linux Kernel Mailing List,
open list:HID CORE LAYER
In-Reply-To: <20190718114036.GA2872@innovation.ch>
On Thu, Jul 18, 2019 at 1:40 PM Life is hard, and then you die
<ronald@innovation.ch> wrote:
> On Thu, Jul 18, 2019 at 10:06:54AM +0800, YueHaibing wrote:
> > @@ -74,7 +74,7 @@ config ATARI_KBD_CORE
> > config KEYBOARD_APPLESPI
> > tristate "Apple SPI keyboard and trackpad"
> > depends on ACPI && EFI
> > - depends on SPI
> > + depends on SPI && PCI
> > depends on X86 || COMPILE_TEST
> > imply SPI_PXA2XX
> > imply SPI_PXA2XX_PCI
> > --
> > 2.7.4
>
> I think this is more properly fixed by Dmitry's suggestion of making
> SPI_PXA2XX_PCI depend on PCI, since it's that module, not applespi,
> that actually needs PCI - see
> https://www.spinics.net/lists/linux-input/msg62351.html
I'll put that into my randconfig setup to see if it's sufficient. I'm
a little bit
suspicious as the circular dependency was not avoided by the 'depends
on X86' for MFD_INTEL_LPSS_PCI.
Arnd
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox