* Re: [PATCH V3] Input: pm8941-pwrkey: add resin key capabilities
From: Rob Herring @ 2018-03-26 22:24 UTC (permalink / raw)
To: Tirupathi Reddy
Cc: dmitry.torokhov, bjorn.andersson, mark.rutland, linux-input,
linux-arm-msm, devicetree, linux-kernel
In-Reply-To: <1521786192-19487-1-git-send-email-tirupath@codeaurora.org>
On Fri, Mar 23, 2018 at 11:53:12AM +0530, Tirupathi Reddy wrote:
> Add resin key support to handle different types of key events
> defined in different platforms.
>
> Signed-off-by: Tirupathi Reddy <tirupath@codeaurora.org>
> ---
> .../bindings/input/qcom,pm8941-pwrkey.txt | 32 +++++++++
Reviewed-by: Rob Herring <robh@kernel.org>
> drivers/input/misc/pm8941-pwrkey.c | 81 ++++++++++++++++++++++
> 2 files changed, 113 insertions(+)
^ permalink raw reply
* Re: [PATCH] Input: alps - Report pressure of v3 and v7 trackstick
From: Dmitry Torokhov @ 2018-03-26 22:37 UTC (permalink / raw)
To: Pali Rohár; +Cc: Masaki Ota, linux-input, linux-kernel
In-Reply-To: <20180321200736.32406-1-pali.rohar@gmail.com>
Hi Pali,
On Wed, Mar 21, 2018 at 09:07:36PM +0100, Pali Rohár wrote:
> ALPS v3 and v7 packet formats reports trackstick pressure. This information
> is already parsed in unused "z" variable.
>
> ALPS SS4 S2 devices already reports trackstick pressure as ABS_PRESSURE
> attribute, therefore reports pressure in the same way also for v3 and v7.
>
> This patch also updates parsing v3 pressure information, it is also stored
> in 7 bits.
>
> Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
> ---
> drivers/input/mouse/alps.c | 10 ++++++----
> 1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/input/mouse/alps.c b/drivers/input/mouse/alps.c
> index 010c1bcdb06d..0a9e6a3a2f9f 100644
> --- a/drivers/input/mouse/alps.c
> +++ b/drivers/input/mouse/alps.c
> @@ -139,11 +139,11 @@ static const struct alps_model_info alps_model_data[] = {
> };
>
> static const struct alps_protocol_info alps_v3_protocol_data = {
> - ALPS_PROTO_V3, 0x8f, 0x8f, ALPS_DUALPOINT
> + ALPS_PROTO_V3, 0x8f, 0x8f, ALPS_DUALPOINT | ALPS_DUALPOINT_WITH_PRESSURE
It seems that with these changes we no longer have trackpoints that do
not report pressure in ALPS. Should we get rid of
ALPS_DUALPOINT_WITH_PRESSURE and clean up the code a bit?
Thanks.
> };
>
> static const struct alps_protocol_info alps_v3_rushmore_data = {
> - ALPS_PROTO_V3_RUSHMORE, 0x8f, 0x8f, ALPS_DUALPOINT
> + ALPS_PROTO_V3_RUSHMORE, 0x8f, 0x8f, ALPS_DUALPOINT | ALPS_DUALPOINT_WITH_PRESSURE
> };
>
> static const struct alps_protocol_info alps_v4_protocol_data = {
> @@ -155,7 +155,7 @@ static const struct alps_protocol_info alps_v5_protocol_data = {
> };
>
> static const struct alps_protocol_info alps_v7_protocol_data = {
> - ALPS_PROTO_V7, 0x48, 0x48, ALPS_DUALPOINT
> + ALPS_PROTO_V7, 0x48, 0x48, ALPS_DUALPOINT | ALPS_DUALPOINT_WITH_PRESSURE
> };
>
> static const struct alps_protocol_info alps_v8_protocol_data = {
> @@ -583,7 +583,7 @@ static void alps_process_trackstick_packet_v3(struct psmouse *psmouse)
>
> x = (s8)(((packet[0] & 0x20) << 2) | (packet[1] & 0x7f));
> y = (s8)(((packet[0] & 0x10) << 3) | (packet[2] & 0x7f));
> - z = (packet[4] & 0x7c) >> 2;
> + z = packet[4] & 0x7c;
>
> /*
> * The x and y values tend to be quite large, and when used
> @@ -595,6 +595,7 @@ static void alps_process_trackstick_packet_v3(struct psmouse *psmouse)
>
> input_report_rel(dev, REL_X, x);
> input_report_rel(dev, REL_Y, -y);
> + input_report_abs(dev, ABS_PRESSURE, z);
>
> /*
> * Most ALPS models report the trackstick buttons in the touchpad
> @@ -1118,6 +1119,7 @@ static void alps_process_trackstick_packet_v7(struct psmouse *psmouse)
>
> input_report_rel(dev2, REL_X, (char)x);
> input_report_rel(dev2, REL_Y, -((char)y));
> + input_report_abs(dev2, ABS_PRESSURE, z);
>
> input_report_key(dev2, BTN_LEFT, left);
> input_report_key(dev2, BTN_RIGHT, right);
> --
> 2.11.0
>
--
Dmitry
^ permalink raw reply
* Re: [PATCH] Input: alps - Report pressure of v3 and v7 trackstick
From: Pali Rohár @ 2018-03-26 22:38 UTC (permalink / raw)
To: Dmitry Torokhov; +Cc: Masaki Ota, linux-input, linux-kernel
In-Reply-To: <20180326223732.GB204225@dtor-ws>
[-- Attachment #1: Type: text/plain, Size: 3323 bytes --]
On Monday 26 March 2018 15:37:32 Dmitry Torokhov wrote:
> Hi Pali,
>
> On Wed, Mar 21, 2018 at 09:07:36PM +0100, Pali Rohár wrote:
> > ALPS v3 and v7 packet formats reports trackstick pressure. This information
> > is already parsed in unused "z" variable.
> >
> > ALPS SS4 S2 devices already reports trackstick pressure as ABS_PRESSURE
> > attribute, therefore reports pressure in the same way also for v3 and v7.
> >
> > This patch also updates parsing v3 pressure information, it is also stored
> > in 7 bits.
> >
> > Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
> > ---
> > drivers/input/mouse/alps.c | 10 ++++++----
> > 1 file changed, 6 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/input/mouse/alps.c b/drivers/input/mouse/alps.c
> > index 010c1bcdb06d..0a9e6a3a2f9f 100644
> > --- a/drivers/input/mouse/alps.c
> > +++ b/drivers/input/mouse/alps.c
> > @@ -139,11 +139,11 @@ static const struct alps_model_info alps_model_data[] = {
> > };
> >
> > static const struct alps_protocol_info alps_v3_protocol_data = {
> > - ALPS_PROTO_V3, 0x8f, 0x8f, ALPS_DUALPOINT
> > + ALPS_PROTO_V3, 0x8f, 0x8f, ALPS_DUALPOINT | ALPS_DUALPOINT_WITH_PRESSURE
>
> It seems that with these changes we no longer have trackpoints that do
> not report pressure in ALPS. Should we get rid of
Nope, we still have. See them in the alps_model_data table.
> ALPS_DUALPOINT_WITH_PRESSURE and clean up the code a bit?
>
> Thanks.
>
> > };
> >
> > static const struct alps_protocol_info alps_v3_rushmore_data = {
> > - ALPS_PROTO_V3_RUSHMORE, 0x8f, 0x8f, ALPS_DUALPOINT
> > + ALPS_PROTO_V3_RUSHMORE, 0x8f, 0x8f, ALPS_DUALPOINT | ALPS_DUALPOINT_WITH_PRESSURE
> > };
> >
> > static const struct alps_protocol_info alps_v4_protocol_data = {
> > @@ -155,7 +155,7 @@ static const struct alps_protocol_info alps_v5_protocol_data = {
> > };
> >
> > static const struct alps_protocol_info alps_v7_protocol_data = {
> > - ALPS_PROTO_V7, 0x48, 0x48, ALPS_DUALPOINT
> > + ALPS_PROTO_V7, 0x48, 0x48, ALPS_DUALPOINT | ALPS_DUALPOINT_WITH_PRESSURE
> > };
> >
> > static const struct alps_protocol_info alps_v8_protocol_data = {
> > @@ -583,7 +583,7 @@ static void alps_process_trackstick_packet_v3(struct psmouse *psmouse)
> >
> > x = (s8)(((packet[0] & 0x20) << 2) | (packet[1] & 0x7f));
> > y = (s8)(((packet[0] & 0x10) << 3) | (packet[2] & 0x7f));
> > - z = (packet[4] & 0x7c) >> 2;
> > + z = packet[4] & 0x7c;
> >
> > /*
> > * The x and y values tend to be quite large, and when used
> > @@ -595,6 +595,7 @@ static void alps_process_trackstick_packet_v3(struct psmouse *psmouse)
> >
> > input_report_rel(dev, REL_X, x);
> > input_report_rel(dev, REL_Y, -y);
> > + input_report_abs(dev, ABS_PRESSURE, z);
> >
> > /*
> > * Most ALPS models report the trackstick buttons in the touchpad
> > @@ -1118,6 +1119,7 @@ static void alps_process_trackstick_packet_v7(struct psmouse *psmouse)
> >
> > input_report_rel(dev2, REL_X, (char)x);
> > input_report_rel(dev2, REL_Y, -((char)y));
> > + input_report_abs(dev2, ABS_PRESSURE, z);
> >
> > input_report_key(dev2, BTN_LEFT, left);
> > input_report_key(dev2, BTN_RIGHT, right);
> > --
> > 2.11.0
> >
>
--
Pali Rohár
pali.rohar@gmail.com
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
^ permalink raw reply
* Re: [PATCH] Input: add bu21029 touch driver
From: Dmitry Torokhov @ 2018-03-26 22:39 UTC (permalink / raw)
To: Rob Herring
Cc: Mark Jonas, Mark Rutland, linux-input, devicetree, linux-kernel,
hs, Zhu Yi
In-Reply-To: <20180326222426.wbdjlyfy7yyan7fc@rob-hp-laptop>
On Mon, Mar 26, 2018 at 05:24:26PM -0500, Rob Herring wrote:
> On Wed, Mar 21, 2018 at 06:04:34PM +0100, Mark Jonas wrote:
> > From: Zhu Yi <yi.zhu5@cn.bosch.com>
> >
> > Add the ROHM BU21029 resistive touch panel controller
> > support with i2c interface.
> >
> > Signed-off-by: Zhu Yi <yi.zhu5@cn.bosch.com>
> > Signed-off-by: Mark Jonas <mark.jonas@de.bosch.com>
> > Reviewed-by: Heiko Schocher <hs@denx.de>
> > ---
> > .../bindings/input/touchscreen/bu21029.txt | 30 ++
> > drivers/input/touchscreen/Kconfig | 12 +
> > drivers/input/touchscreen/Makefile | 1 +
> > drivers/input/touchscreen/bu21029_ts.c | 456 +++++++++++++++++++++
> > 4 files changed, 499 insertions(+)
> > create mode 100644 Documentation/devicetree/bindings/input/touchscreen/bu21029.txt
> > create mode 100644 drivers/input/touchscreen/bu21029_ts.c
> >
> > diff --git a/Documentation/devicetree/bindings/input/touchscreen/bu21029.txt b/Documentation/devicetree/bindings/input/touchscreen/bu21029.txt
> > new file mode 100644
> > index 0000000..7b61602
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/input/touchscreen/bu21029.txt
> > @@ -0,0 +1,30 @@
> > +* Rohm BU21029 Touch Screen Controller
> > +
> > +Required properties:
> > + - compatible : must be "rohm,bu21029"
> > + - reg : i2c device address of the chip
>
> What the valid value(s)?
>
> > + - interrupt-parent : the phandle for the gpio controller
> > + - interrupts : (gpio) interrupt to which the chip is connected
> > + - reset-gpios : gpio pin to reset the chip
>
> Active high or low?
>
> > + - rohm,x-plate-ohms : x-plate resistance in ohms
>
> IIRC, we have a standard touchscreen property for this?
I do not think so: it is specific for resistive touchscreens, whereas
"standard" touchscreen properties are technology-independent ones (size,
rotation, etc).
>
> > +
> > +Optional properties:
> > + - touchscreen-max-pressure: maximum pressure value
> > +
> > +Example:
> > +
> > + &i2c1 {
> > + /* ... */
> > +
> > + bu21029: bu21029@40 {
> > + compatible = "rohm,bu21029";
> > + reg = <0x40>;
> > + interrupt-parent = <&gpio1>;
> > + interrupts = <4 IRQ_TYPE_EDGE_FALLING>;
> > + reset-gpios = <&gpio6 16 GPIO_ACTIVE_LOW>;
> > + rohm,x-plate-ohms = <600>;
> > + touchscreen-max-pressure = <4095>;
> > + };
> > +
> > + /* ... */
> > + };
--
Dmitry
^ permalink raw reply
* Re: [PATCH] Input: add bu21029 touch driver
From: Dmitry Torokhov @ 2018-03-26 22:53 UTC (permalink / raw)
To: Mark Jonas
Cc: Rob Herring, Mark Rutland, linux-input, devicetree, linux-kernel,
hs, Zhu Yi
In-Reply-To: <1521651874-15379-1-git-send-email-mark.jonas@de.bosch.com>
Hi Mark,
On Wed, Mar 21, 2018 at 06:04:34PM +0100, Mark Jonas wrote:
> From: Zhu Yi <yi.zhu5@cn.bosch.com>
>
> Add the ROHM BU21029 resistive touch panel controller
> support with i2c interface.
>
> Signed-off-by: Zhu Yi <yi.zhu5@cn.bosch.com>
> Signed-off-by: Mark Jonas <mark.jonas@de.bosch.com>
> Reviewed-by: Heiko Schocher <hs@denx.de>
> ---
> .../bindings/input/touchscreen/bu21029.txt | 30 ++
> drivers/input/touchscreen/Kconfig | 12 +
> drivers/input/touchscreen/Makefile | 1 +
> drivers/input/touchscreen/bu21029_ts.c | 456 +++++++++++++++++++++
> 4 files changed, 499 insertions(+)
> create mode 100644 Documentation/devicetree/bindings/input/touchscreen/bu21029.txt
> create mode 100644 drivers/input/touchscreen/bu21029_ts.c
>
> diff --git a/Documentation/devicetree/bindings/input/touchscreen/bu21029.txt b/Documentation/devicetree/bindings/input/touchscreen/bu21029.txt
> new file mode 100644
> index 0000000..7b61602
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/input/touchscreen/bu21029.txt
> @@ -0,0 +1,30 @@
> +* Rohm BU21029 Touch Screen Controller
> +
> +Required properties:
> + - compatible : must be "rohm,bu21029"
> + - reg : i2c device address of the chip
> + - interrupt-parent : the phandle for the gpio controller
> + - interrupts : (gpio) interrupt to which the chip is connected
> + - reset-gpios : gpio pin to reset the chip
> + - rohm,x-plate-ohms : x-plate resistance in ohms
> +
> +Optional properties:
> + - touchscreen-max-pressure: maximum pressure value
> +
> +Example:
> +
> + &i2c1 {
> + /* ... */
> +
> + bu21029: bu21029@40 {
> + compatible = "rohm,bu21029";
> + reg = <0x40>;
> + interrupt-parent = <&gpio1>;
> + interrupts = <4 IRQ_TYPE_EDGE_FALLING>;
> + reset-gpios = <&gpio6 16 GPIO_ACTIVE_LOW>;
> + rohm,x-plate-ohms = <600>;
> + touchscreen-max-pressure = <4095>;
> + };
> +
> + /* ... */
> + };
> diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig
> index 4f15496..e09fe8f 100644
> --- a/drivers/input/touchscreen/Kconfig
> +++ b/drivers/input/touchscreen/Kconfig
> @@ -151,6 +151,18 @@ config TOUCHSCREEN_BU21013
> To compile this driver as a module, choose M here: the
> module will be called bu21013_ts.
>
> +config TOUCHSCREEN_BU21029
> + tristate "Rohm BU21029 based touch panel controllers"
> + depends on I2C
> + help
> + Say Y here if you have a Rohm BU21029 touchscreen controller
> + connected to your system.
> +
> + If unsure, say N.
> +
> + To compile this driver as a module, choose M here: the
> + module will be called bu21029_ts.
> +
> config TOUCHSCREEN_CHIPONE_ICN8318
> tristate "chipone icn8318 touchscreen controller"
> depends on GPIOLIB || COMPILE_TEST
> diff --git a/drivers/input/touchscreen/Makefile b/drivers/input/touchscreen/Makefile
> index dddae79..f50624c 100644
> --- a/drivers/input/touchscreen/Makefile
> +++ b/drivers/input/touchscreen/Makefile
> @@ -18,6 +18,7 @@ obj-$(CONFIG_TOUCHSCREEN_AR1021_I2C) += ar1021_i2c.o
> obj-$(CONFIG_TOUCHSCREEN_ATMEL_MXT) += atmel_mxt_ts.o
> obj-$(CONFIG_TOUCHSCREEN_AUO_PIXCIR) += auo-pixcir-ts.o
> obj-$(CONFIG_TOUCHSCREEN_BU21013) += bu21013_ts.o
> +obj-$(CONFIG_TOUCHSCREEN_BU21029) += bu21029_ts.o
> obj-$(CONFIG_TOUCHSCREEN_CHIPONE_ICN8318) += chipone_icn8318.o
> obj-$(CONFIG_TOUCHSCREEN_CY8CTMG110) += cy8ctmg110_ts.o
> obj-$(CONFIG_TOUCHSCREEN_CYTTSP_CORE) += cyttsp_core.o
> diff --git a/drivers/input/touchscreen/bu21029_ts.c b/drivers/input/touchscreen/bu21029_ts.c
> new file mode 100644
> index 0000000..d5cbf11
> --- /dev/null
> +++ b/drivers/input/touchscreen/bu21029_ts.c
> @@ -0,0 +1,456 @@
Please add SPDX tag for the driver.
> +/*
> + * Rohm BU21029 touchscreen controller driver
> + *
> + * Copyright (C) 2015 Bosch Sicherheitssysteme GmbH
> + *
> + * 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/delay.h>
> +#include <linux/gpio.h>
> +#include <linux/i2c.h>
> +#include <linux/input.h>
> +#include <linux/interrupt.h>
> +#include <linux/kernel.h>
> +#include <linux/module.h>
> +#include <linux/of.h>
> +#include <linux/of_gpio.h>
Please use GPIOD API (and include linux/gpio/consumer.h instead of
of_gpio.h).
> +#include <linux/timer.h>
> +
> +/* HW_ID1 Register (PAGE=0, ADDR=0x0E, Reset value=0x02, Read only)
Multi-line comments start with empty comment line:
/*
* Multi
* line.
*/
> + * +--------+--------+--------+--------+--------+--------+--------+--------+
> + * | D7 | D6 | D5 | D4 | D3 | D2 | D1 | D0 |
> + * +--------+--------+--------+--------+--------+--------+--------+--------+
> + * | HW_IDH |
> + * +--------+--------+--------+--------+--------+--------+--------+--------+
> + * HW_ID2 Register (PAGE=0, ADDR=0x0F, Reset value=0x29, Read only)
> + * +--------+--------+--------+--------+--------+--------+--------+--------+
> + * | D7 | D6 | D5 | D4 | D3 | D2 | D1 | D0 |
> + * +--------+--------+--------+--------+--------+--------+--------+--------+
> + * | HW_IDL |
> + * +--------+--------+--------+--------+--------+--------+--------+--------+
> + * HW_IDH: high 8bits of IC's ID
> + * HW_IDL: low 8bits of IC's ID
> + */
> +#define BU21029_HWID_REG (0x0E << 3)
> +#define SUPPORTED_HWID 0x0229
> +
> +/* CFR0 Register (PAGE=0, ADDR=0x00, Reset value=0x20)
> + * +--------+--------+--------+--------+--------+--------+--------+--------+
> + * | D7 | D6 | D5 | D4 | D3 | D2 | D1 | D0 |
> + * +--------+--------+--------+--------+--------+--------+--------+--------+
> + * | 0 | 0 | CALIB | INTRM | 0 | 0 | 0 | 0 |
> + * +--------+--------+--------+--------+--------+--------+--------+--------+
> + * CALIB: 0 = not to use calibration result (*)
> + * 1 = use calibration result
> + * INTRM: 0 = INT output depend on "pen down" (*)
> + * 1 = INT output always "0"
> + */
> +#define BU21029_CFR0_REG (0x00 << 3)
> +#define CFR0_VALUE 0x00
> +
> +/* CFR1 Register (PAGE=0, ADDR=0x01, Reset value=0xA6)
> + * +--------+--------+--------+--------+--------+--------+--------+--------+
> + * | D7 | D6 | D5 | D4 | D3 | D2 | D1 | D0 |
> + * +--------+--------+--------+--------+--------+--------+--------+--------+
> + * | MAV | AVE[2:0] | 0 | SMPL[2:0] |
> + * +--------+--------+--------+--------+--------+--------+--------+--------+
> + * MAV: 0 = median average filter off
> + * 1 = median average filter on (*)
> + * AVE: AVE+1 = number of average samples for MAV,
> + * if AVE>SMPL, then AVE=SMPL (=3)
> + * SMPL: SMPL+1 = number of conversion samples for MAV (=7)
> + */
> +#define BU21029_CFR1_REG (0x01 << 3)
> +#define CFR1_VALUE 0xA6
> +
> +/* CFR2 Register (PAGE=0, ADDR=0x02, Reset value=0x04)
> + * +--------+--------+--------+--------+--------+--------+--------+--------+
> + * | D7 | D6 | D5 | D4 | D3 | D2 | D1 | D0 |
> + * +--------+--------+--------+--------+--------+--------+--------+--------+
> + * | INTVL_TIME[3:0] | TIME_ST_ADC[3:0] |
> + * +--------+--------+--------+--------+--------+--------+--------+--------+
> + * INTVL_TIME: waiting time between completion of conversion
> + * and start of next conversion, only usable in
> + * autoscan mode (=20.480ms)
> + * TIME_ST_ADC: waiting time between application of voltage
> + * to panel and start of A/D conversion (=100us)
> + */
> +#define BU21029_CFR2_REG (0x02 << 3)
> +#define CFR2_VALUE 0xC9
> +
> +/* CFR3 Register (PAGE=0, ADDR=0x0B, Reset value=0x72)
> + * +--------+--------+--------+--------+--------+--------+--------+--------+
> + * | D7 | D6 | D5 | D4 | D3 | D2 | D1 | D0 |
> + * +--------+--------+--------+--------+--------+--------+--------+--------+
> + * | RM8 | STRETCH| PU90K | DUAL | PIDAC_OFS[3:0] |
> + * +--------+--------+--------+--------+--------+--------+--------+--------+
> + * RM8: 0 = coordinate resolution is 12bit (*)
> + * 1 = coordinate resolution is 8bit
> + * STRETCH: 0 = SCL_STRETCH function off
> + * 1 = SCL_STRETCH function on (*)
> + * PU90K: 0 = internal pull-up resistance for touch detection is ~50kohms (*)
> + * 1 = internal pull-up resistance for touch detection is ~90kohms
> + * DUAL: 0 = dual touch detection off (*)
> + * 1 = dual touch detection on
> + * PIDAC_OFS: dual touch detection circuit adjustment, it is not necessary
> + * to change this from initial value
> + */
> +#define BU21029_CFR3_REG (0x0B << 3)
> +#define CFR3_VALUE 0x42
> +
> +/* LDO Register (PAGE=0, ADDR=0x0C, Reset value=0x00)
> + * +--------+--------+--------+--------+--------+--------+--------+--------+
> + * | D7 | D6 | D5 | D4 | D3 | D2 | D1 | D0 |
> + * +--------+--------+--------+--------+--------+--------+--------+--------+
> + * | 0 | PVDD[2:0] | 0 | AVDD[2:0] |
> + * +--------+--------+--------+--------+--------+--------+--------+--------+
> + * PVDD: output voltage of panel output regulator (=2.000V)
> + * AVDD: output voltage of analog circuit regulator (=2.000V)
> + */
> +#define BU21029_LDO_REG (0x0C << 3)
> +#define LDO_VALUE 0x77
> +
> +/* Serial Interface Command Byte 1 (CID=1)
> + * +--------+--------+--------+--------+--------+--------+--------+--------+
> + * | D7 | D6 | D5 | D4 | D3 | D2 | D1 | D0 |
> + * +--------+--------+--------+--------+--------+--------+--------+--------+
> + * | 1 | CF | CMSK | PDM | STP |
> + * +--------+--------+--------+--------+--------+--------+--------+--------+
> + * CF: conversion function, see table 3 in datasheet p6 (=0000, automatic scan)
> + * CMSK: 0 = executes convert function (*)
> + * 1 = reads the convert result
> + * PDM: 0 = power down after convert function stops (*)
> + * 1 = keep power on after convert function stops
> + * STP: 1 = abort current conversion and power down, set to "0" automatically
> + */
> +#define BU21029_AUTOSCAN 0x80
> +
> +/* The timeout value needs to be larger than INTVL_TIME + tConv4 (sample and
> + * conversion time), where tConv4 is calculated by formula:
> + * tPON + tDLY1 + (tTIME_ST_ADC + (tADC * tSMPL) * 2 + tDLY2) * 3
> + * see figure 8 in datasheet p15 for details of each field.
> + */
> +#define PEN_UP_TIMEOUT msecs_to_jiffies(50)
> +
> +#define STOP_DELAY_US 50L
> +#define START_DELAY_MS 2L
> +#define BUF_LEN 8L
> +#define SCALE_12BIT (1 << 12)
> +#define MAX_12BIT ((1 << 12) - 1)
> +#define DRIVER_NAME "bu21029"
> +
> +struct bu21029_ts_data {
> + struct i2c_client *client;
> + struct input_dev *in_dev;
> + struct timer_list timer;
> + u32 reset_gpios;
> + u32 reset_gpios_assert;
> + u32 x_plate_ohms;
> + u32 max_pressure;
> +};
> +
> +static int bu21029_touch_report(struct bu21029_ts_data *bu21029)
> +{
> + struct i2c_client *i2c = bu21029->client;
> + u8 buf[BUF_LEN];
> + u16 x, y, z1, z2;
> + u32 rz;
> +
> + /* read touch data and deassert INT (by restarting the autoscan mode) */
> + int error = i2c_smbus_read_i2c_block_data(i2c,
> + BU21029_AUTOSCAN,
> + BUF_LEN,
> + buf);
> + if (error < 0)
> + return error;
> +
> + /* compose upper 8 and lower 4 bits into a 12bit value:
> + * +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
> + * | ByteH | ByteL |
> + * +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
> + * |b07|b06|b05|b04|b03|b02|b01|b00|b07|b06|b05|b04|b03|b02|b01|b00|
> + * +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
> + * |v11|v10|v09|v08|v07|v06|v05|v04|v03|v02|v01|v00| 0 | 0 | 0 | 0 |
> + * +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
> + */
> + x = (buf[0] << 4) | (buf[1] >> 4);
> + y = (buf[2] << 4) | (buf[3] >> 4);
> + z1 = (buf[4] << 4) | (buf[5] >> 4);
> + z2 = (buf[6] << 4) | (buf[7] >> 4);
> +
> + if (z1 == 0 || z2 == 0)
> + return 0;
> +
> + /* calculate Rz (pressure resistance value) by equation:
> + * Rz = Rx * (x/Q) * ((z2/z1) - 1), where
> + * Rx is x-plate resistance,
> + * Q is the touch screen resolution (8bit = 256, 12bit = 4096)
> + * x, z1, z2 are the measured positions.
> + */
> + rz = z2 - z1;
> + rz *= x;
> + rz *= bu21029->x_plate_ohms;
> + rz /= z1;
> + rz = DIV_ROUND_CLOSEST(rz, SCALE_12BIT);
> + if (rz <= bu21029->max_pressure) {
> + input_report_abs(bu21029->in_dev, ABS_X, x);
> + input_report_abs(bu21029->in_dev, ABS_Y, y);
> + input_report_abs(bu21029->in_dev, ABS_PRESSURE, rz);
What is the values of pressure reported when finger is touching the
surface? IOW is 'rz' pressure or resistance?
> + input_report_key(bu21029->in_dev, BTN_TOUCH, 1);
> + input_sync(bu21029->in_dev);
> + }
> +
> + return 0;
> +}
> +
> +static void bu21029_touch_release(struct timer_list *t)
> +{
> + struct bu21029_ts_data *bu21029 = from_timer(bu21029, t, timer);
> +
> + input_report_abs(bu21029->in_dev, ABS_PRESSURE, 0);
> + input_report_key(bu21029->in_dev, BTN_TOUCH, 0);
> + input_sync(bu21029->in_dev);
> +}
> +
> +static irqreturn_t bu21029_touch_soft_irq(int irq, void *data)
> +{
> + struct bu21029_ts_data *bu21029 = data;
> + struct i2c_client *i2c = bu21029->client;
> +
> + /* report touch and deassert interrupt (will assert again after
> + * INTVL_TIME + tConv4 for continuous touch)
> + */
> + int error = bu21029_touch_report(bu21029);
> +
> + if (error) {
> + dev_err(&i2c->dev, "failed to report (error: %d)\n", error);
> + return IRQ_NONE;
> + }
> +
> + /* reset timer for pen up detection */
> + mod_timer(&bu21029->timer, jiffies + PEN_UP_TIMEOUT);
> +
> + return IRQ_HANDLED;
> +}
> +
> +static void bu21029_reset_chip(struct bu21029_ts_data *bu21029)
> +{
> + gpio_set_value(bu21029->reset_gpios,
> + bu21029->reset_gpios_assert);
> + udelay(STOP_DELAY_US);
> + gpio_set_value(bu21029->reset_gpios,
> + !bu21029->reset_gpios_assert);
> + mdelay(START_DELAY_MS);
> +}
> +
> +static int bu21029_init_chip(struct bu21029_ts_data *bu21029)
> +{
> + struct i2c_client *i2c = bu21029->client;
> + struct {
> + u8 reg;
> + u8 value;
> + } init_table[] = {
> + {BU21029_CFR0_REG, CFR0_VALUE},
> + {BU21029_CFR1_REG, CFR1_VALUE},
> + {BU21029_CFR2_REG, CFR2_VALUE},
> + {BU21029_CFR3_REG, CFR3_VALUE},
> + {BU21029_LDO_REG, LDO_VALUE}
> + };
> + int error, i;
> + u16 hwid;
> +
> + bu21029_reset_chip(bu21029);
> +
> + error = i2c_smbus_read_i2c_block_data(i2c,
> + BU21029_HWID_REG,
> + 2,
> + (u8 *)&hwid);
> + if (error < 0) {
> + dev_err(&i2c->dev, "failed to read HW ID\n");
> + return error;
> + }
> +
> + if (cpu_to_be16(hwid) != SUPPORTED_HWID) {
> + dev_err(&i2c->dev, "unsupported HW ID 0x%x\n", hwid);
> + return -ENODEV;
> + }
> +
> + for (i = 0; i < ARRAY_SIZE(init_table); ++i) {
> + error = i2c_smbus_write_byte_data(i2c,
> + init_table[i].reg,
> + init_table[i].value);
> + if (error < 0) {
> + dev_err(&i2c->dev,
> + "failed to write 0x%x to register 0x%x\n",
> + init_table[i].value,
> + init_table[i].reg);
> + return error;
> + }
> + }
> +
> + error = i2c_smbus_write_byte(i2c, BU21029_AUTOSCAN);
> + if (error < 0) {
> + dev_err(&i2c->dev, "failed to start autoscan\n");
> + return error;
> + }
> +
> + return 0;
> +}
> +
> +static int bu21029_parse_dt(struct bu21029_ts_data *bu21029)
> +{
> + struct device *dev = &bu21029->client->dev;
> + struct device_node *np = dev->of_node;
> + enum of_gpio_flags flags;
> + u32 val32;
> + int gpio;
> +
> + if (!np) {
> + dev_err(dev, "no device tree data\n");
> + return -EINVAL;
> + }
> +
> + gpio = of_get_named_gpio_flags(np, "reset-gpios", 0, &flags);
> + if (!gpio_is_valid(gpio)) {
> + dev_err(dev, "invalid 'reset-gpios' supplied\n");
> + return -EINVAL;
> + }
> + bu21029->reset_gpios = gpio;
> + bu21029->reset_gpios_assert = (flags & OF_GPIO_ACTIVE_LOW) ? 0 : 1;
> +
> + if (of_property_read_u32(np, "rohm,x-plate-ohms", &val32)) {
> + dev_err(dev, "invalid 'x-plate-ohms' supplied\n");
> + return -EINVAL;
> + }
> + bu21029->x_plate_ohms = val32;
> +
> + if (of_property_read_u32(np, "touchscreen-max-pressure", &val32))
> + bu21029->max_pressure = MAX_12BIT;
> + else
> + bu21029->max_pressure = val32;
Please use infrastructure form include/linux/input/touchscreen.h
so that you handle different sizes and orientations.
> +
> + return 0;
> +}
> +
> +static int bu21029_probe(struct i2c_client *client,
> + const struct i2c_device_id *id)
> +{
> + struct bu21029_ts_data *bu21029;
> + struct input_dev *in_dev;
> + int error;
> +
> + if (!i2c_check_functionality(client->adapter,
> + I2C_FUNC_SMBUS_WRITE_BYTE |
> + I2C_FUNC_SMBUS_WRITE_BYTE_DATA |
> + I2C_FUNC_SMBUS_READ_I2C_BLOCK)) {
> + dev_err(&client->dev,
> + "i2c functionality support is not sufficient\n");
> + return -EIO;
> + }
> +
> + bu21029 = devm_kzalloc(&client->dev, sizeof(*bu21029), GFP_KERNEL);
> + if (!bu21029)
> + return -ENOMEM;
> +
> + in_dev = devm_input_allocate_device(&client->dev);
> + if (!in_dev) {
> + dev_err(&client->dev, "unable to allocate input device\n");
> + return -ENOMEM;
> + }
> +
> + bu21029->client = client;
> + bu21029->in_dev = in_dev;
> + timer_setup(&bu21029->timer, bu21029_touch_release, 0);
> +
> + error = bu21029_parse_dt(bu21029);
> + if (error)
> + return error;
> +
> + error = devm_gpio_request_one(&client->dev,
> + bu21029->reset_gpios,
> + GPIOF_OUT_INIT_HIGH,
> + DRIVER_NAME);
> + if (error) {
> + dev_err(&client->dev, "unable to request reset-gpios\n");
> + return error;
> + }
> +
> + error = bu21029_init_chip(bu21029);
> + if (error) {
> + dev_err(&client->dev, "unable to config bu21029\n");
> + return error;
> + }
> +
> + in_dev->name = DRIVER_NAME;
> + in_dev->id.bustype = BUS_I2C;
> + in_dev->dev.parent = &client->dev;
Not needed with devm_input_allocate_device().
> +
> + __set_bit(EV_SYN, in_dev->evbit);
> + __set_bit(EV_KEY, in_dev->evbit);
> + __set_bit(EV_ABS, in_dev->evbit);
> + __set_bit(ABS_X, in_dev->absbit);
> + __set_bit(ABS_Y, in_dev->absbit);
> + __set_bit(ABS_PRESSURE, in_dev->absbit);
> + __set_bit(BTN_TOUCH, in_dev->keybit);
> +
> + input_set_abs_params(in_dev, ABS_X, 0, MAX_12BIT, 0, 0);
> + input_set_abs_params(in_dev, ABS_Y, 0, MAX_12BIT, 0, 0);
> + input_set_abs_params(in_dev, ABS_PRESSURE,
> + 0, bu21029->max_pressure, 0, 0);
> + input_set_drvdata(in_dev, bu21029);
> +
> + error = input_register_device(in_dev);
> + if (error) {
> + dev_err(&client->dev, "unable to register input device\n");
> + return error;
> + }
> +
> + i2c_set_clientdata(client, bu21029);
> +
> + error = devm_request_threaded_irq(&client->dev,
> + client->irq,
> + NULL,
> + bu21029_touch_soft_irq,
> + IRQF_ONESHOT,
> + DRIVER_NAME,
> + bu21029);
> + if (error) {
> + dev_err(&client->dev, "unable to request touch irq\n");
> + return error;
> + }
> +
> + return 0;
> +}
> +
> +static int bu21029_remove(struct i2c_client *client)
> +{
> + struct bu21029_ts_data *bu21029 = i2c_get_clientdata(client);
> +
> + del_timer_sync(&bu21029->timer);
If interrupt comes here kernel will be unhappy. You need to either work
canceling timer into devm unwid stream (devm_add_action_or_reset()) or
somehow make sure that you shut off interrupts before canceling the
timer.
> +
> + return 0;
> +}
> +
> +static const struct i2c_device_id bu21029_ids[] = {
> + {DRIVER_NAME, 0},
> + {}
> +};
> +MODULE_DEVICE_TABLE(i2c, bu21029_ids);
> +
> +static struct i2c_driver bu21029_driver = {
> + .driver = {
> + .name = DRIVER_NAME,
> + .owner = THIS_MODULE,
Not needed.
> + },
> + .id_table = bu21029_ids,
> + .probe = bu21029_probe,
> + .remove = bu21029_remove,
> +};
> +module_i2c_driver(bu21029_driver);
> +
> +MODULE_AUTHOR("Zhu Yi <yi.zhu5@cn.bosch.com>");
> +MODULE_DESCRIPTION("Rohm BU21029 touchscreen controller driver");
> +MODULE_LICENSE("GPL v2");
> --
> 2.7.4
>
Thanks.
--
Dmitry
^ permalink raw reply
* Re: [PATCH] Input: alps - Report pressure of v3 and v7 trackstick
From: Dmitry Torokhov @ 2018-03-26 22:55 UTC (permalink / raw)
To: Pali Rohár; +Cc: Masaki Ota, linux-input, linux-kernel
In-Reply-To: <20180326223856.asna4arlwwwbaq7p@pali>
On Tue, Mar 27, 2018 at 12:38:56AM +0200, Pali Rohár wrote:
> On Monday 26 March 2018 15:37:32 Dmitry Torokhov wrote:
> > Hi Pali,
> >
> > On Wed, Mar 21, 2018 at 09:07:36PM +0100, Pali Rohár wrote:
> > > ALPS v3 and v7 packet formats reports trackstick pressure. This information
> > > is already parsed in unused "z" variable.
> > >
> > > ALPS SS4 S2 devices already reports trackstick pressure as ABS_PRESSURE
> > > attribute, therefore reports pressure in the same way also for v3 and v7.
> > >
> > > This patch also updates parsing v3 pressure information, it is also stored
> > > in 7 bits.
> > >
> > > Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
> > > ---
> > > drivers/input/mouse/alps.c | 10 ++++++----
> > > 1 file changed, 6 insertions(+), 4 deletions(-)
> > >
> > > diff --git a/drivers/input/mouse/alps.c b/drivers/input/mouse/alps.c
> > > index 010c1bcdb06d..0a9e6a3a2f9f 100644
> > > --- a/drivers/input/mouse/alps.c
> > > +++ b/drivers/input/mouse/alps.c
> > > @@ -139,11 +139,11 @@ static const struct alps_model_info alps_model_data[] = {
> > > };
> > >
> > > static const struct alps_protocol_info alps_v3_protocol_data = {
> > > - ALPS_PROTO_V3, 0x8f, 0x8f, ALPS_DUALPOINT
> > > + ALPS_PROTO_V3, 0x8f, 0x8f, ALPS_DUALPOINT | ALPS_DUALPOINT_WITH_PRESSURE
> >
> > It seems that with these changes we no longer have trackpoints that do
> > not report pressure in ALPS. Should we get rid of
>
> Nope, we still have. See them in the alps_model_data table.
Ah, I see now, OK. Applied, thank you.
>
> > ALPS_DUALPOINT_WITH_PRESSURE and clean up the code a bit?
> >
> > Thanks.
> >
> > > };
> > >
> > > static const struct alps_protocol_info alps_v3_rushmore_data = {
> > > - ALPS_PROTO_V3_RUSHMORE, 0x8f, 0x8f, ALPS_DUALPOINT
> > > + ALPS_PROTO_V3_RUSHMORE, 0x8f, 0x8f, ALPS_DUALPOINT | ALPS_DUALPOINT_WITH_PRESSURE
> > > };
> > >
> > > static const struct alps_protocol_info alps_v4_protocol_data = {
> > > @@ -155,7 +155,7 @@ static const struct alps_protocol_info alps_v5_protocol_data = {
> > > };
> > >
> > > static const struct alps_protocol_info alps_v7_protocol_data = {
> > > - ALPS_PROTO_V7, 0x48, 0x48, ALPS_DUALPOINT
> > > + ALPS_PROTO_V7, 0x48, 0x48, ALPS_DUALPOINT | ALPS_DUALPOINT_WITH_PRESSURE
> > > };
> > >
> > > static const struct alps_protocol_info alps_v8_protocol_data = {
> > > @@ -583,7 +583,7 @@ static void alps_process_trackstick_packet_v3(struct psmouse *psmouse)
> > >
> > > x = (s8)(((packet[0] & 0x20) << 2) | (packet[1] & 0x7f));
> > > y = (s8)(((packet[0] & 0x10) << 3) | (packet[2] & 0x7f));
> > > - z = (packet[4] & 0x7c) >> 2;
> > > + z = packet[4] & 0x7c;
> > >
> > > /*
> > > * The x and y values tend to be quite large, and when used
> > > @@ -595,6 +595,7 @@ static void alps_process_trackstick_packet_v3(struct psmouse *psmouse)
> > >
> > > input_report_rel(dev, REL_X, x);
> > > input_report_rel(dev, REL_Y, -y);
> > > + input_report_abs(dev, ABS_PRESSURE, z);
> > >
> > > /*
> > > * Most ALPS models report the trackstick buttons in the touchpad
> > > @@ -1118,6 +1119,7 @@ static void alps_process_trackstick_packet_v7(struct psmouse *psmouse)
> > >
> > > input_report_rel(dev2, REL_X, (char)x);
> > > input_report_rel(dev2, REL_Y, -((char)y));
> > > + input_report_abs(dev2, ABS_PRESSURE, z);
> > >
> > > input_report_key(dev2, BTN_LEFT, left);
> > > input_report_key(dev2, BTN_RIGHT, right);
> > > --
> > > 2.11.0
> > >
> >
>
> --
> Pali Rohár
> pali.rohar@gmail.com
--
Dmitry
^ permalink raw reply
* RE: [PATCH] Input: ALPS - fix DualPoint flag for 74 03 28 devices
From: Masaki Ota @ 2018-03-27 4:37 UTC (permalink / raw)
To: Pali Rohár
Cc: Dmitry Torokhov, linux-input@vger.kernel.org,
linux-kernel@vger.kernel.org, Aaron Ma
In-Reply-To: <20180325212541.5wzpvlkcbayfktrz@pali>
Hi,
We can get OTP page 0 value by EA EA E9 commands, but we cannot get it by EA EA EA E9.
As far as I remember, Device initialization finish at EA command, then sends EA EA E9 commands.
In this case we cannot get correct OTP page 0 value.
So I changed this order. (We can get OTP page 1 value by both of EA F0 F0 E9 and F0 F0 E9.)
Best Regards,
Masaki Ota
-----Original Message-----
From: Pali Rohár [mailto:pali.rohar@gmail.com]
Sent: Monday, March 26, 2018 6:26 AM
To: 太田 真喜 Masaki Ota <masaki.ota@jp.alps.com>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>; linux-input@vger.kernel.org; linux-kernel@vger.kernel.org; Aaron Ma <aaron.ma@canonical.com>
Subject: Re: [PATCH] Input: ALPS - fix DualPoint flag for 74 03 28 devices
On Tuesday 20 March 2018 11:47:26 Dmitry Torokhov wrote:
> On Mon, Jan 29, 2018 at 2:51 PM, dmitry.torokhov@gmail.com
> <dmitry.torokhov@gmail.com> wrote:
> > Hi,
> >
> > On Thu, Nov 16, 2017 at 07:27:02AM +0000, Masaki Ota wrote:
> >> Hi, Pali, Aaron,
> >>
> >> Current code is correct device setting, previous code is wrong.
> >> If the trackstick does not work(DUALPOINT flag disable), Device Firmware setting is wrong.
> >>
> >> But recently I received the same report from Thinkpad L570 user, and I checked this device and found this device Firmware setting is wrong. Sorry for our mistake.
> >> Is your laptop L570 ?
> >>
> >> I will add code that supports the trackstick for this device.
> >
> > Sorry for resurrecting this old thread, I am just trying to
> > understand what went wrong here. Is the sequence of "f0 f0 e9" and
> > "ea ea e9" is important in getting the correct OTP data and we
> > originally got this order wrong? It is not clear from the original
> > patch and discussion that this change was intentional.
>
> Could I please get an answer to my question?
>
> Thanks!
Masaki, this question is for you ↑↑↑
> >
> > Thanks.
> >
> >>
> >> Best Regards,
> >> Masaki Ota
> >> -----Original Message-----
> >> From: Pali Rohár [mailto:pali.rohar@gmail.com]
> >> Sent: Wednesday, November 15, 2017 5:35 PM
> >> To: 太田 真喜 Masaki Ota <masaki.ota@jp.alps.com>
> >> Cc: linux-input@vger.kernel.org; linux-kernel@vger.kernel.org;
> >> dmitry.torokhov@gmail.com; Aaron Ma <aaron.ma@canonical.com>
> >> Subject: Re: [PATCH] Input: ALPS - fix DualPoint flag for 74 03 28
> >> devices
> >>
> >> On Wednesday 15 November 2017 14:34:04 Aaron Ma wrote:
> >> > There is a regression of commit 4a646580f793 ("Input: ALPS - fix
> >> > two-finger scroll breakage"), ALPS device fails with log:
> >> >
> >> > psmouse serio1: alps: Rejected trackstick packet from non
> >> > DualPoint device
> >> >
> >> > ALPS device with id "74 03 28" report OTP[0] data 0xCE after
> >> > commit 4a646580f793, after restore the OTP reading order, it
> >> > becomes to 0x10 as before and reports the right flag.
> >> >
> >> > Fixes: 4a646580f793 ("Input: ALPS - fix two-finger scroll
> >> > breakage")
> >> > Cc: <stable@vger.kernel.org>
> >> > Signed-off-by: Aaron Ma <aaron.ma@canonical.com>
> >> > ---
> >> > drivers/input/mouse/alps.c | 4 ++--
> >> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >> >
> >> > diff --git a/drivers/input/mouse/alps.c
> >> > b/drivers/input/mouse/alps.c index 579b899add26..c59b8f7ca2fc
> >> > 100644
> >> > --- a/drivers/input/mouse/alps.c
> >> > +++ b/drivers/input/mouse/alps.c
> >> > @@ -2562,8 +2562,8 @@ static int alps_set_defaults_ss4_v2(struct
> >> > psmouse *psmouse,
> >> >
> >> > memset(otp, 0, sizeof(otp));
> >> >
> >> > - if (alps_get_otp_values_ss4_v2(psmouse, 1, &otp[1][0]) ||
> >> > - alps_get_otp_values_ss4_v2(psmouse, 0, &otp[0][0]))
> >> > + if (alps_get_otp_values_ss4_v2(psmouse, 0, &otp[0][0]) ||
> >> > + alps_get_otp_values_ss4_v2(psmouse, 1, &otp[1][0]))
> >> > return -1;
> >> >
> >> > alps_update_device_area_ss4_v2(otp, priv);
> >>
> >> Masaki Ota, please look at this patch as it partially revert your
> >> commit
> >> 4a646580f793 ("Input: ALPS - fix two-finger scroll breakage"). Something smells here.
> >>
> >> --
> >> Pali Rohár
> >> pali.rohar@gmail.com
> >
> > --
> > Dmitry
>
>
>
--
Pali Rohár
pali.rohar@gmail.com
^ permalink raw reply
* Re: [PATCH] Input: add bu21029 touch driver
From: Jonas Mark (BT-FIR/ENG1) @ 2018-03-27 6:52 UTC (permalink / raw)
To: Rob Herring
Cc: Dmitry Torokhov, Mark Rutland, linux-input@vger.kernel.org,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
hs@denx.de, ZHU Yi (BT-FIR/ENG1-Zhu), Jonas Mark (BT-FIR/ENG1)
Hello Rob,
> > +* Rohm BU21029 Touch Screen Controller
> > +
> > +Required properties:
> > + - compatible : must be "rohm,bu21029"
> > + - reg : i2c device address of the chip
>
> What the valid value(s)?
The chip itself can be wired to 0x40 or 0x41. The driver can work with
any valid I2C address.
Is this what you are looking for?
- reg : i2c device address of the chip (0x40 or 0x41)
> > + - interrupt-parent : the phandle for the gpio controller
> > + - interrupts : (gpio) interrupt to which the chip is connected
> > + - reset-gpios : gpio pin to reset the chip
>
> Active high or low?
The chip itself needs an active low reset. But depending on whether
there is an inverter between the touch screen controller and the CPU or
not, the CPU's GPIO might need to be active high or active low. This
shall be configured by the polarity given in the device tree. The
driver uses this information to drive the reset appropriately.
Are you looking for documenting the required polarity of the touch
controller itself?
- reset-gpios : gpio pin to reset the chip (active low)
> > +Example:
> > +
> > + &i2c1 {
> > + /* ... */
> > +
> > + bu21029: bu21029@40 {
> > + compatible = "rohm,bu21029";
> > + reg = <0x40>;
> > + interrupt-parent = <&gpio1>;
> > + interrupts = <4 IRQ_TYPE_EDGE_FALLING>;
> > + reset-gpios = <&gpio6 16 GPIO_ACTIVE_LOW>;
> > + rohm,x-plate-ohms = <600>;
> > + touchscreen-max-pressure = <4095>;
> > + };
> > +
> > + /* ... */
> > + };
Greetings,
Mark Jonas
Building Technologies, Panel Software Fire (BT-FIR/ENG1)
Bosch Sicherheitssysteme GmbH | Postfach 11 11 | 85626 Grasbrunn | GERMANY | www.boschsecurity.com
Sitz: Stuttgart, Registergericht: Amtsgericht Stuttgart HRB 23118
Aufsichtsratsvorsitzender: Stefan Hartung; Geschäftsführung: Gert van Iperen, Andreas Bartz, Thomas Quante, Bernhard Schuster
^ permalink raw reply
* Re: [PATCH] Input: add bu21029 touch driver
From: Jonas Mark (BT-FIR/ENG1) @ 2018-03-27 6:57 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: Rob Herring, Mark Rutland, linux-input@vger.kernel.org,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
hs@denx.de, ZHU Yi (BT-FIR/ENG1-Zhu), Jonas Mark (BT-FIR/ENG1)
Hello Dmitry,
> > +++ b/drivers/input/touchscreen/bu21029_ts.c
> > @@ -0,0 +1,456 @@
>
> Please add SPDX tag for the driver.
We will do.
> Please use GPIOD API (and include linux/gpio/consumer.h instead of
> of_gpio.h).
We will do the change.
> > +/* HW_ID1 Register (PAGE=0, ADDR=0x0E, Reset value=0x02, Read only)
>
> Multi-line comments start with empty comment line:
>
> /*
> * Multi
> * line.
> */
Will be fixed.
> > + /* calculate Rz (pressure resistance value) by equation:
> > + * Rz = Rx * (x/Q) * ((z2/z1) - 1), where
> > + * Rx is x-plate resistance,
> > + * Q is the touch screen resolution (8bit = 256, 12bit = 4096)
> > + * x, z1, z2 are the measured positions.
> > + */
> > + rz = z2 - z1;
> > + rz *= x;
> > + rz *= bu21029->x_plate_ohms;
> > + rz /= z1;
> > + rz = DIV_ROUND_CLOSEST(rz, SCALE_12BIT);
> > + if (rz <= bu21029->max_pressure) {
> > + input_report_abs(bu21029->in_dev, ABS_X, x);
> > + input_report_abs(bu21029->in_dev, ABS_Y, y);
> > + input_report_abs(bu21029->in_dev, ABS_PRESSURE, rz);
>
> What is the values of pressure reported when finger is touching the
> surface? IOW is 'rz' pressure or resistance?
Rz is pressure measured in Ohms. That is, it is a resistance which
correlates with finger pressure.
I fear that I do not understand your question. Does ABS_PRESSURE have
to be reported in a specific unit, e.g. milli Newton? We thought that
it is a device specific scale and that it will be converted into a
calibrated value (just like the coordinates) in user space.
> > + if (of_property_read_u32(np, "touchscreen-max-pressure", &val32))
> > + bu21029->max_pressure = MAX_12BIT;
> > + else
> > + bu21029->max_pressure = val32;
>
> Please use infrastructure form include/linux/input/touchscreen.h
> so that you handle different sizes and orientations.
Thank you for this recommendation. We will check it out and send a new
proposal.
> > + in_dev->name = DRIVER_NAME;
> > + in_dev->id.bustype = BUS_I2C;
> > + in_dev->dev.parent = &client->dev;
>
> Not needed with devm_input_allocate_device().
We will have a look at the other drivers.
> > +static int bu21029_remove(struct i2c_client *client)
> > +{
> > + struct bu21029_ts_data *bu21029 = i2c_get_clientdata(client);
> > +
> > + del_timer_sync(&bu21029->timer);
>
> If interrupt comes here kernel will be unhappy. You need to either work
> canceling timer into devm unwid stream (devm_add_action_or_reset()) or
> somehow make sure that you shut off interrupts before canceling the
> timer.
We will work on a solution. Thank you for spotting this.
>
> > +
> > + return 0;
> > +}
> > +static struct i2c_driver bu21029_driver = {
> > + .driver = {
> > + .name = DRIVER_NAME,
> > + .owner = THIS_MODULE,
>
> Not needed.
OK, we will remove the .owner assignment.
Greetings,
Mark Jonas
Building Technologies, Panel Software Fire (BT-FIR/ENG1)
Bosch Sicherheitssysteme GmbH | Postfach 11 11 | 85626 Grasbrunn | GERMANY | www.boschsecurity.com
Sitz: Stuttgart, Registergericht: Amtsgericht Stuttgart HRB 23118
Aufsichtsratsvorsitzender: Stefan Hartung; Geschäftsführung: Gert van Iperen, Andreas Bartz, Thomas Quante, Bernhard Schuster
^ permalink raw reply
* Re: [PATCH v6 0/6] Add MediaTek PMIC keys support
From: Lee Jones @ 2018-03-27 8:05 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: Sean Wang, Rob Herring, Alexandre Belloni, Mark Rutland, a.zummo,
devicetree, linus.walleij, jcsing.lee, linux-kernel, krzk, javier,
linux-mediatek, linux-arm-kernel, linux-input, matthias.bgg,
eddie.huang, Chen.Zhong, beomho.seo, linux-rtc
In-Reply-To: <20180323185418.GD255819@dtor-ws>
On Fri, 23 Mar 2018, Dmitry Torokhov wrote:
> On Thu, Mar 22, 2018 at 10:17:53AM +0800, Sean Wang wrote:
> > Hi, Dmitry and Lee
> >
> > The series seems not being got merged. Are they good enough to be ready
> > into the your tree?
> >
> > Recently I've tested the series with focusing on pwrkey event generated
> > through interrupt when push and release the key on bpi-r2 board and then
> > finally it's working fine. but for homekey it cannot be found on the
> > board and thus I cannot have more tests more about it.
> >
> > Tested-by: Sean Wang <sean.wang@mediatek.com>
>
> You have my Ack on the input patch; I expect it go through Lee's tree as
> there are some dependencies on mfd core piece.
Are you happy for me to merge the Input dt-bindings without your Ack?
--
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
^ permalink raw reply
* Re: [PATCH v6 0/6] Add MediaTek PMIC keys support
From: Matthias Brugger @ 2018-03-27 10:47 UTC (permalink / raw)
To: Lee Jones, Dmitry Torokhov
Cc: Sean Wang, Rob Herring, Alexandre Belloni, Mark Rutland, a.zummo,
devicetree, linus.walleij, jcsing.lee, linux-kernel, krzk, javier,
linux-mediatek, linux-arm-kernel, linux-input, eddie.huang,
Chen.Zhong, beomho.seo, linux-rtc
In-Reply-To: <20180327080507.pgil6pw2mn4y2f4d@dell>
On 03/27/2018 10:05 AM, Lee Jones wrote:
> On Fri, 23 Mar 2018, Dmitry Torokhov wrote:
>> On Thu, Mar 22, 2018 at 10:17:53AM +0800, Sean Wang wrote:
>>> Hi, Dmitry and Lee
>>>
>>> The series seems not being got merged. Are they good enough to be ready
>>> into the your tree?
>>>
>>> Recently I've tested the series with focusing on pwrkey event generated
>>> through interrupt when push and release the key on bpi-r2 board and then
>>> finally it's working fine. but for homekey it cannot be found on the
>>> board and thus I cannot have more tests more about it.
>>>
>>> Tested-by: Sean Wang <sean.wang@mediatek.com>
>>
>> You have my Ack on the input patch; I expect it go through Lee's tree as
>> there are some dependencies on mfd core piece.
>
> Are you happy for me to merge the Input dt-bindings without your Ack?
>
They got both Acked in v5, but the commit message was not updated:
https://patchwork.kernel.org/patch/9973721/
https://patchwork.kernel.org/patch/9973723/
Regards,
Matthias
^ permalink raw reply
* Re: [PATCH 0/4] HID: alps: Fix some bugs and improve code around 't4_read_write_register()'
From: Jiri Kosina @ 2018-03-27 12:05 UTC (permalink / raw)
To: Christophe JAILLET
Cc: masaki.ota, benjamin.tissoires, linux-input, linux-kernel,
kernel-janitors
In-Reply-To: <cover.1521492069.git.christophe.jaillet@wanadoo.fr>
On Mon, 19 Mar 2018, Christophe JAILLET wrote:
> All is said in the subject and below.
>
> These patches are untested. Especially, patch 1 slightly changes the behavior
> of 't4_read_write_register()'.
> This looks logical to me, but please, review it carefully.
>
> Christophe JAILLET (4):
> HID: alps: Report an error if we receive invalid data in
> 't4_read_write_register()'
> HID: alps: Save a memory allocation in 't4_read_write_register()' when
> writing data
> HID: alps: Check errors returned by 't4_read_write_register()'
> HID: alps: Fix some style in 't4_read_write_register()'
>
> drivers/hid/hid-alps.c | 27 ++++++++++++++++++++++-----
> 1 file changed, 22 insertions(+), 5 deletions(-)
Masaki-san,
do you have any comments to Christophe's patchset please?
Thanks,
--
Jiri Kosina
SUSE Labs
^ permalink raw reply
* [PATCH v2 00/10] Add support for SAMA5D2 touchscreen
From: Eugen Hristev @ 2018-03-27 12:32 UTC (permalink / raw)
To: jic23, ludovic.desroches, alexandre.belloni, linux-arm-kernel,
devicetree, linux-kernel, linux-iio, linux-input, nicolas.ferre,
dmitry.torokhov
Cc: Eugen Hristev
Hello,
This patch series is a rework of my previous series named:
[PATCH 00/14] iio: triggers: add consumer support
In few words, this is the implementation of splitting the functionality
of the IP block ADC device in SAMA5D2 SoC from ADC with touchscreen
support. In order to avoid having a MFD device, two separate
drivers that would work on same register base and split the IRQ,etc,
as advised on the mailing list, I created a consumer driver for the
channels, that will connect to the ADC as described in the device tree.
I have collected feedback from everyone and here is the result:
I have added a new generic resistive touchscreen driver, which acts
as a iio consumer for the given channels and will create an input
device and report the events. It uses a callback buffer to register
to the IIO device and waits for data to be pushed.
Inside the IIO device, I have kept a similar approach with the first version
of the series, except that now the driver can take multiple buffers, and
will configure the touchscreen part of the hardware device if the specific
channels are requested.
The SAMA5D2 ADC driver registers three new channels: two for the
position on the X and Y axis, and one for the touch pressure.
When channels are requested, it will check if the touchscreen channel mask
includes the requested channels (it is possible that the consumer driver
will not request pressure for example). If it's the case, it will work
in touchscreen mode, and will refuse to do usual analog-digital conversion,
because we have a single trigger and the touchscreen needs it.
When the scan mask will include only old channels, the driver will function
in the same way as before. If the scan mask somehow is a mix of the two (the
masks intersect), the driver will refuse to work whatsoever (cannot have both
in the same time).
The driver allows reading raw data for the new channels, if claim direct
mode works: no touchscreen driver requested anything. The new channels can
act like the old ones. However, when requesting these channels, the usual
trigger will not work and will not be enabled. The touchscreen channels
require special trigger and irq configuration: pen detect, no pen detect
and a periodic trigger to sample the touchscreen position and pressure.
If the user attempts to use another trigger while there is a buffer
that already requested the touchscreen channels (thus the trigger), the
driver will refuse to comply.
In order to have defines for the channel numbers, I added a bindings include
file that goes on a separate commit :
dt-bindings: iio: adc: at91-sama5d2_adc: add channel specific consumer info
This should go in the same tree with the following commits :
ARM: dts: at91: sama5d2: add channel cells for ADC device
ARM: dts: at91: sama5d2: Add resistive touch device
as build will break because these commits depend on the binding one
which creates the included header file.
After the discussions earlier this year on the mailing list, I hope this
rework of the patches is much better and fulfills all the requirements
for this implementation.
Eugen Hristev (10):
MAINTAINERS: add generic resistive touchscreen adc
iio: Add channel for Position Relative
dt-bindings: input: touchscreen: touch_adc: create bindings
iio: inkern: add module put/get on iio dev module when requesting
channels
iio: adc: at91-sama5d2_adc: fix channel configuration for differential
channels
iio: adc: at91-sama5d2_adc: add support for position and pressure
channels
input: touchscreen: touch_adc: add generic resistive ADC touchscreen
dt-bindings: iio: adc: at91-sama5d2_adc: add channel specific consumer
info
ARM: dts: at91: sama5d2: add channel cells for ADC device
ARM: dts: at91: sama5d2: Add resistive touch device
Documentation/ABI/testing/sysfs-bus-iio | 12 +
.../bindings/iio/adc/at91-sama5d2_adc.txt | 9 +
.../bindings/input/touchscreen/touch_adc.txt | 33 ++
MAINTAINERS | 6 +
arch/arm/boot/dts/sama5d2.dtsi | 12 +
drivers/iio/adc/at91-sama5d2_adc.c | 491 ++++++++++++++++++++-
drivers/iio/industrialio-core.c | 1 +
drivers/iio/inkern.c | 8 +-
drivers/input/touchscreen/Kconfig | 13 +
drivers/input/touchscreen/Makefile | 1 +
drivers/input/touchscreen/touch_adc.c | 199 +++++++++
include/dt-bindings/iio/adc/at91-sama5d2_adc.h | 16 +
include/uapi/linux/iio/types.h | 1 +
tools/iio/iio_event_monitor.c | 2 +
14 files changed, 791 insertions(+), 13 deletions(-)
create mode 100644 Documentation/devicetree/bindings/input/touchscreen/touch_adc.txt
create mode 100644 drivers/input/touchscreen/touch_adc.c
create mode 100644 include/dt-bindings/iio/adc/at91-sama5d2_adc.h
--
2.7.4
^ permalink raw reply
* [PATCH v2 01/10] MAINTAINERS: add generic resistive touchscreen adc
From: Eugen Hristev @ 2018-03-27 12:32 UTC (permalink / raw)
To: jic23, ludovic.desroches, alexandre.belloni, linux-arm-kernel,
devicetree, linux-kernel, linux-iio, linux-input, nicolas.ferre,
dmitry.torokhov
Cc: Eugen Hristev
In-Reply-To: <1522153963-1121-1-git-send-email-eugen.hristev@microchip.com>
Add MAINTAINERS entry for generic resistive touchscreen adc
Signed-off-by: Eugen Hristev <eugen.hristev@microchip.com>
---
MAINTAINERS | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/MAINTAINERS b/MAINTAINERS
index 36f1442..ba227cc 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5943,6 +5943,12 @@ F: drivers/base/power/domain*.c
F: include/linux/pm_domain.h
F: Documentation/devicetree/bindings/power/power_domain.txt
+GENERIC RESISTIVE TOUCHSCREEN ADC DRIVER
+M: Eugen Hristev <eugen.hristev@microchip.com>
+L: linux-input@vger.kernel.org
+S: Maintained
+F: drivers/input/touchscreen/touch_adc.c
+
GENERIC UIO DRIVER FOR PCI DEVICES
M: "Michael S. Tsirkin" <mst@redhat.com>
L: kvm@vger.kernel.org
--
2.7.4
^ permalink raw reply related
* [PATCH v2 02/10] iio: Add channel for Position Relative
From: Eugen Hristev @ 2018-03-27 12:32 UTC (permalink / raw)
To: jic23, ludovic.desroches, alexandre.belloni, linux-arm-kernel,
devicetree, linux-kernel, linux-iio, linux-input, nicolas.ferre,
dmitry.torokhov
Cc: Eugen Hristev
In-Reply-To: <1522153963-1121-1-git-send-email-eugen.hristev@microchip.com>
Add new channel type for relative position on a pad.
These type of analog sensor offers the position of a pen
on a touchpad, and is represented as a voltage, which can be
converted to a position on X and Y axis on the pad.
The channel will hand the relative position on the pad in both directions.
The channel can then be consumed by a touchscreen driver or
read as-is for a raw indication of the touchpen on a touchpad.
Signed-off-by: Eugen Hristev <eugen.hristev@microchip.com>
---
Changes in v2:
- modified channel name to relative position as suggested.
- modified kernel version to 4.18 (presumable)
Documentation/ABI/testing/sysfs-bus-iio | 12 ++++++++++++
drivers/iio/industrialio-core.c | 1 +
include/uapi/linux/iio/types.h | 1 +
tools/iio/iio_event_monitor.c | 2 ++
4 files changed, 16 insertions(+)
diff --git a/Documentation/ABI/testing/sysfs-bus-iio b/Documentation/ABI/testing/sysfs-bus-iio
index 6a5f34b..42a9287 100644
--- a/Documentation/ABI/testing/sysfs-bus-iio
+++ b/Documentation/ABI/testing/sysfs-bus-iio
@@ -190,6 +190,18 @@ Description:
but should match other such assignments on device).
Units after application of scale and offset are m/s^2.
+What: /sys/bus/iio/devices/iio:deviceX/in_positionrelative_x_raw
+What: /sys/bus/iio/devices/iio:deviceX/in_positionrelative_y_raw
+KernelVersion: 4.18
+Contact: linux-iio@vger.kernel.org
+Description:
+ Relative position in direction x or y on a pad (may be
+ arbitrarily assigned but should match other such assignments on
+ device).
+ Units after application of scale and offset are milli percents
+ from the pad's size in both directions. Should be calibrated by
+ the consumer.
+
What: /sys/bus/iio/devices/iio:deviceX/in_anglvel_x_raw
What: /sys/bus/iio/devices/iio:deviceX/in_anglvel_y_raw
What: /sys/bus/iio/devices/iio:deviceX/in_anglvel_z_raw
diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
index 19bdf3d..14bf3d24 100644
--- a/drivers/iio/industrialio-core.c
+++ b/drivers/iio/industrialio-core.c
@@ -85,6 +85,7 @@ static const char * const iio_chan_type_name_spec[] = {
[IIO_COUNT] = "count",
[IIO_INDEX] = "index",
[IIO_GRAVITY] = "gravity",
+ [IIO_POSITIONRELATIVE] = "positionrelative",
};
static const char * const iio_modifier_names[] = {
diff --git a/include/uapi/linux/iio/types.h b/include/uapi/linux/iio/types.h
index 4213cdf..033c7d2 100644
--- a/include/uapi/linux/iio/types.h
+++ b/include/uapi/linux/iio/types.h
@@ -44,6 +44,7 @@ enum iio_chan_type {
IIO_COUNT,
IIO_INDEX,
IIO_GRAVITY,
+ IIO_POSITIONRELATIVE,
};
enum iio_modifier {
diff --git a/tools/iio/iio_event_monitor.c b/tools/iio/iio_event_monitor.c
index b61245e..148f69d 100644
--- a/tools/iio/iio_event_monitor.c
+++ b/tools/iio/iio_event_monitor.c
@@ -58,6 +58,7 @@ static const char * const iio_chan_type_name_spec[] = {
[IIO_PH] = "ph",
[IIO_UVINDEX] = "uvindex",
[IIO_GRAVITY] = "gravity",
+ [IIO_POSITIONRELATIVE] = "positionrelative",
};
static const char * const iio_ev_type_text[] = {
@@ -151,6 +152,7 @@ static bool event_is_known(struct iio_event_data *event)
case IIO_PH:
case IIO_UVINDEX:
case IIO_GRAVITY:
+ case IIO_POSITIONRELATIVE:
break;
default:
return false;
--
2.7.4
^ permalink raw reply related
* [PATCH v2 03/10] dt-bindings: input: touchscreen: touch_adc: create bindings
From: Eugen Hristev @ 2018-03-27 12:32 UTC (permalink / raw)
To: jic23, ludovic.desroches, alexandre.belloni, linux-arm-kernel,
devicetree, linux-kernel, linux-iio, linux-input, nicolas.ferre,
dmitry.torokhov
Cc: Eugen Hristev
In-Reply-To: <1522153963-1121-1-git-send-email-eugen.hristev@microchip.com>
Added bindings for generic resistive touchscreen ADC.
Signed-off-by: Eugen Hristev <eugen.hristev@microchip.com>
---
Changes in v2:
- modified bindings to have a generic resistive touchscreen adc driver
instead of specific architecture one.
.../bindings/input/touchscreen/touch_adc.txt | 33 ++++++++++++++++++++++
1 file changed, 33 insertions(+)
create mode 100644 Documentation/devicetree/bindings/input/touchscreen/touch_adc.txt
diff --git a/Documentation/devicetree/bindings/input/touchscreen/touch_adc.txt b/Documentation/devicetree/bindings/input/touchscreen/touch_adc.txt
new file mode 100644
index 0000000..27abcdc
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/touchscreen/touch_adc.txt
@@ -0,0 +1,33 @@
+Generic resistive touchscreen ADC
+
+Required properties:
+
+ - compatible: must be "generic-resistive-adc-touch"
+The device must be connected to an IIO device that provides channels for
+position measurement and optional pressure.
+Refer to ../iio/iio-bindings.txt for details
+ - iio-channels: must have at least two channels connected to an IIO device.
+These should correspond to the channels exposed by the IIO device and should
+have the right index as the IIO device registers them. These channels
+represent the relative position on the "x" and "y" axes.
+ - iio-channel-names: must have all the channels' names. Mandatory channels
+are "x" and "y".
+
+Optional properties:
+ - iio-channels: The third channel named "pressure" is optional and can be
+used if the IIO device also measures pressure besides position.
+If this channel is missing, pressure will be ignored and the touchscreen
+will only report position.
+ - iio-channel-names: optional channel named "pressure".
+ - generic-resistive-adc-touch,pressure-threshold: a pressure threshold for
+the touchscreen, if we are using the "pressure" channel as well.
+Represented by an integer value.
+
+Example:
+
+ resistive_touch: resistive_touch {
+ compatible = "generic-resistive-adc-touch";
+ generic-resistive-adc-touch,pressure-threshold = <10000>;
+ io-channels = <&adc 24>, <&adc 25>, <&adc 26>;
+ io-channel-names = "x", "y", "pressure";
+ };
--
2.7.4
^ permalink raw reply related
* [PATCH v2 04/10] iio: inkern: add module put/get on iio dev module when requesting channels
From: Eugen Hristev @ 2018-03-27 12:32 UTC (permalink / raw)
To: jic23, ludovic.desroches, alexandre.belloni, linux-arm-kernel,
devicetree, linux-kernel, linux-iio, linux-input, nicolas.ferre,
dmitry.torokhov
Cc: Eugen Hristev
In-Reply-To: <1522153963-1121-1-git-send-email-eugen.hristev@microchip.com>
When requesting channels for a particular consumer device,
besides requesting the device (incrementing the reference counter), also
do it for the driver module of the iio dev. This will avoid the situation
where the producer IIO device can be removed and the consumer is still
present in the kernel.
Signed-off-by: Eugen Hristev <eugen.hristev@microchip.com>
---
drivers/iio/inkern.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
index ec98790..68d9b87 100644
--- a/drivers/iio/inkern.c
+++ b/drivers/iio/inkern.c
@@ -11,6 +11,7 @@
#include <linux/slab.h>
#include <linux/mutex.h>
#include <linux/of.h>
+#include <linux/module.h>
#include <linux/iio/iio.h>
#include "iio_core.h"
@@ -152,6 +153,7 @@ static int __of_iio_channel_get(struct iio_channel *channel,
if (index < 0)
goto err_put;
channel->channel = &indio_dev->channels[index];
+ try_module_get(channel->indio_dev->driver_module);
return 0;
@@ -256,8 +258,10 @@ static struct iio_channel *of_iio_channel_get_all(struct device *dev)
return chans;
error_free_chans:
- for (i = 0; i < mapind; i++)
+ for (i = 0; i < mapind; i++) {
+ module_put(chans[i].indio_dev->driver_module);
iio_device_put(chans[i].indio_dev);
+ }
kfree(chans);
return ERR_PTR(ret);
}
@@ -351,6 +355,7 @@ void iio_channel_release(struct iio_channel *channel)
{
if (!channel)
return;
+ module_put(channel->indio_dev->driver_module);
iio_device_put(channel->indio_dev);
kfree(channel);
}
@@ -482,6 +487,7 @@ void iio_channel_release_all(struct iio_channel *channels)
struct iio_channel *chan = &channels[0];
while (chan->indio_dev) {
+ module_put(chan->indio_dev->driver_module);
iio_device_put(chan->indio_dev);
chan++;
}
--
2.7.4
^ permalink raw reply related
* [PATCH v2 05/10] iio: adc: at91-sama5d2_adc: fix channel configuration for differential channels
From: Eugen Hristev @ 2018-03-27 12:32 UTC (permalink / raw)
To: jic23, ludovic.desroches, alexandre.belloni, linux-arm-kernel,
devicetree, linux-kernel, linux-iio, linux-input, nicolas.ferre,
dmitry.torokhov
Cc: Eugen Hristev
In-Reply-To: <1522153963-1121-1-git-send-email-eugen.hristev@microchip.com>
When iterating through the channels, the index in the array is not the
scan index. Added an xlate function to translate to the proper index.
This will be used also for devicetree channel xlate
Signed-off-by: Eugen Hristev <eugen.hristev@microchip.com>
---
drivers/iio/adc/at91-sama5d2_adc.c | 41 ++++++++++++++++++++++++++++++++++----
1 file changed, 37 insertions(+), 4 deletions(-)
diff --git a/drivers/iio/adc/at91-sama5d2_adc.c b/drivers/iio/adc/at91-sama5d2_adc.c
index 4eff835..8729d65 100644
--- a/drivers/iio/adc/at91-sama5d2_adc.c
+++ b/drivers/iio/adc/at91-sama5d2_adc.c
@@ -333,6 +333,27 @@ static const struct iio_chan_spec at91_adc_channels[] = {
+ AT91_SAMA5D2_DIFF_CHAN_CNT + 1),
};
+static int at91_adc_chan_xlate(struct iio_dev *indio_dev, int chan)
+{
+ int i;
+
+ for (i = 0; i < indio_dev->num_channels; i++) {
+ if (indio_dev->channels[i].scan_index == chan)
+ return i;
+ }
+ return -EINVAL;
+}
+
+static inline struct iio_chan_spec const *
+at91_adc_chan_get(struct iio_dev *indio_dev, int chan)
+{
+ int index = at91_adc_chan_xlate(indio_dev, chan);
+
+ if (index < 0)
+ return NULL;
+ return indio_dev->channels + index;
+}
+
static int at91_adc_configure_trigger(struct iio_trigger *trig, bool state)
{
struct iio_dev *indio = iio_trigger_get_drvdata(trig);
@@ -350,8 +371,10 @@ static int at91_adc_configure_trigger(struct iio_trigger *trig, bool state)
at91_adc_writel(st, AT91_SAMA5D2_TRGR, status);
for_each_set_bit(bit, indio->active_scan_mask, indio->num_channels) {
- struct iio_chan_spec const *chan = indio->channels + bit;
+ struct iio_chan_spec const *chan = at91_adc_chan_get(indio, bit);
+ if (!chan)
+ continue;
if (state) {
at91_adc_writel(st, AT91_SAMA5D2_CHER,
BIT(chan->channel));
@@ -448,7 +471,11 @@ static int at91_adc_dma_start(struct iio_dev *indio_dev)
for_each_set_bit(bit, indio_dev->active_scan_mask,
indio_dev->num_channels) {
- struct iio_chan_spec const *chan = indio_dev->channels + bit;
+ struct iio_chan_spec const *chan =
+ at91_adc_chan_get(indio_dev, bit);
+
+ if (!chan)
+ continue;
st->dma_st.rx_buf_sz += chan->scan_type.storagebits / 8;
}
@@ -526,8 +553,11 @@ static int at91_adc_buffer_predisable(struct iio_dev *indio_dev)
*/
for_each_set_bit(bit, indio_dev->active_scan_mask,
indio_dev->num_channels) {
- struct iio_chan_spec const *chan = indio_dev->channels + bit;
+ struct iio_chan_spec const *chan =
+ at91_adc_chan_get(indio_dev, bit);
+ if (!chan)
+ continue;
if (st->dma_st.dma_chan)
at91_adc_readl(st, chan->address);
}
@@ -587,8 +617,11 @@ static void at91_adc_trigger_handler_nodma(struct iio_dev *indio_dev,
for_each_set_bit(bit, indio_dev->active_scan_mask,
indio_dev->num_channels) {
- struct iio_chan_spec const *chan = indio_dev->channels + bit;
+ struct iio_chan_spec const *chan =
+ at91_adc_chan_get(indio_dev, bit);
+ if (!chan)
+ continue;
st->buffer[i] = at91_adc_readl(st, chan->address);
i++;
}
--
2.7.4
^ permalink raw reply related
* [PATCH v2 06/10] iio: adc: at91-sama5d2_adc: add support for position and pressure channels
From: Eugen Hristev @ 2018-03-27 12:32 UTC (permalink / raw)
To: jic23, ludovic.desroches, alexandre.belloni, linux-arm-kernel,
devicetree, linux-kernel, linux-iio, linux-input, nicolas.ferre,
dmitry.torokhov
Cc: Eugen Hristev
In-Reply-To: <1522153963-1121-1-git-send-email-eugen.hristev@microchip.com>
This implements the support for position and pressure for the included
touchscreen support in the SAMA5D2 SOC ADC block.
Two position channels are added and one for pressure.
They can be read in raw format, or through a buffer.
A normal use case is for a consumer driver to register a callback buffer
for these channels.
When the touchscreen channels are in the active scan mask,
the driver will start the touchscreen sampling and push the data to the
buffer.
Some parts of this patch are based on initial original work by
Mohamed Jamsheeth Hajanajubudeen and Bandaru Venkateswara Swamy
Signed-off-by: Eugen Hristev <eugen.hristev@microchip.com>
---
Changes in v2:
- the support is now based on callback buffer.
drivers/iio/adc/at91-sama5d2_adc.c | 452 ++++++++++++++++++++++++++++++++++++-
1 file changed, 443 insertions(+), 9 deletions(-)
diff --git a/drivers/iio/adc/at91-sama5d2_adc.c b/drivers/iio/adc/at91-sama5d2_adc.c
index 8729d65..29a7fb9 100644
--- a/drivers/iio/adc/at91-sama5d2_adc.c
+++ b/drivers/iio/adc/at91-sama5d2_adc.c
@@ -102,14 +102,26 @@
#define AT91_SAMA5D2_LCDR 0x20
/* Interrupt Enable Register */
#define AT91_SAMA5D2_IER 0x24
+/* Interrupt Enable Register - TS X measurement ready */
+#define AT91_SAMA5D2_IER_XRDY BIT(20)
+/* Interrupt Enable Register - TS Y measurement ready */
+#define AT91_SAMA5D2_IER_YRDY BIT(21)
+/* Interrupt Enable Register - TS pressure measurement ready */
+#define AT91_SAMA5D2_IER_PRDY BIT(22)
/* Interrupt Enable Register - general overrun error */
#define AT91_SAMA5D2_IER_GOVRE BIT(25)
+/* Interrupt Enable Register - Pen detect */
+#define AT91_SAMA5D2_IER_PEN BIT(29)
+/* Interrupt Enable Register - No pen detect */
+#define AT91_SAMA5D2_IER_NOPEN BIT(30)
/* Interrupt Disable Register */
#define AT91_SAMA5D2_IDR 0x28
/* Interrupt Mask Register */
#define AT91_SAMA5D2_IMR 0x2c
/* Interrupt Status Register */
#define AT91_SAMA5D2_ISR 0x30
+/* Interrupt Status Register - Pen touching sense status */
+#define AT91_SAMA5D2_ISR_PENS BIT(31)
/* Last Channel Trigger Mode Register */
#define AT91_SAMA5D2_LCTMR 0x34
/* Last Channel Compare Window Register */
@@ -131,8 +143,38 @@
#define AT91_SAMA5D2_CDR0 0x50
/* Analog Control Register */
#define AT91_SAMA5D2_ACR 0x94
+/* Analog Control Register - Pen detect sensitivity mask */
+#define AT91_SAMA5D2_ACR_PENDETSENS_MASK GENMASK(1, 0)
+
/* Touchscreen Mode Register */
#define AT91_SAMA5D2_TSMR 0xb0
+/* Touchscreen Mode Register - No touch mode */
+#define AT91_SAMA5D2_TSMR_TSMODE_NONE 0
+/* Touchscreen Mode Register - 4 wire screen, no pressure measurement */
+#define AT91_SAMA5D2_TSMR_TSMODE_4WIRE_NO_PRESS 1
+/* Touchscreen Mode Register - 4 wire screen, pressure measurement */
+#define AT91_SAMA5D2_TSMR_TSMODE_4WIRE_PRESS 2
+/* Touchscreen Mode Register - 5 wire screen */
+#define AT91_SAMA5D2_TSMR_TSMODE_5WIRE 3
+/* Touchscreen Mode Register - Average samples mask */
+#define AT91_SAMA5D2_TSMR_TSAV_MASK GENMASK(5, 4)
+/* Touchscreen Mode Register - Average samples */
+#define AT91_SAMA5D2_TSMR_TSAV(x) ((x) << 4)
+/* Touchscreen Mode Register - Touch/trigger frequency ratio mask */
+#define AT91_SAMA5D2_TSMR_TSFREQ_MASK GENMASK(11, 8)
+/* Touchscreen Mode Register - Touch/trigger frequency ratio */
+#define AT91_SAMA5D2_TSMR_TSFREQ(x) ((x) << 8)
+/* Touchscreen Mode Register - Pen Debounce Time mask */
+#define AT91_SAMA5D2_TSMR_PENDBC_MASK GENMASK(31, 28)
+/* Touchscreen Mode Register - Pen Debounce Time */
+#define AT91_SAMA5D2_TSMR_PENDBC(x) ((x) << 28)
+/* Touchscreen Mode Register - No DMA for touch measurements */
+#define AT91_SAMA5D2_TSMR_NOTSDMA BIT(22)
+/* Touchscreen Mode Register - Disable pen detection */
+#define AT91_SAMA5D2_TSMR_PENDET_DIS (0 << 24)
+/* Touchscreen Mode Register - Enable pen detection */
+#define AT91_SAMA5D2_TSMR_PENDET_ENA BIT(24)
+
/* Touchscreen X Position Register */
#define AT91_SAMA5D2_XPOSR 0xb4
/* Touchscreen Y Position Register */
@@ -151,6 +193,12 @@
#define AT91_SAMA5D2_TRGR_TRGMOD_EXT_TRIG_FALL 2
/* Trigger Mode external trigger any edge */
#define AT91_SAMA5D2_TRGR_TRGMOD_EXT_TRIG_ANY 3
+/* Trigger Mode internal periodic */
+#define AT91_SAMA5D2_TRGR_TRGMOD_PERIODIC 5
+/* Trigger Mode - trigger period mask */
+#define AT91_SAMA5D2_TRGR_TRGPER_MASK GENMASK(31, 16)
+/* Trigger Mode - trigger period */
+#define AT91_SAMA5D2_TRGR_TRGPER(x) ((x) << 16)
/* Correction Select Register */
#define AT91_SAMA5D2_COSR 0xd0
@@ -169,6 +217,22 @@
#define AT91_SAMA5D2_SINGLE_CHAN_CNT 12
#define AT91_SAMA5D2_DIFF_CHAN_CNT 6
+#define AT91_SAMA5D2_TIMESTAMP_CHAN_IDX (AT91_SAMA5D2_SINGLE_CHAN_CNT + \
+ AT91_SAMA5D2_DIFF_CHAN_CNT + 1)
+
+#define AT91_SAMA5D2_TOUCH_X_CHAN_IDX (AT91_SAMA5D2_SINGLE_CHAN_CNT + \
+ AT91_SAMA5D2_DIFF_CHAN_CNT * 2)
+#define AT91_SAMA5D2_TOUCH_Y_CHAN_IDX (AT91_SAMA5D2_TOUCH_X_CHAN_IDX + 1)
+#define AT91_SAMA5D2_TOUCH_P_CHAN_IDX (AT91_SAMA5D2_TOUCH_Y_CHAN_IDX + 1)
+#define AT91_SAMA5D2_MAX_CHAN_IDX AT91_SAMA5D2_TOUCH_P_CHAN_IDX
+
+#define TOUCH_SAMPLE_PERIOD_US 2000 /* 2ms */
+#define TOUCH_PEN_DETECT_DEBOUNCE_US 200
+
+#define XYZ_MASK GENMASK(11, 0)
+
+#define MAX_POS_BITS 12
+
/*
* Maximum number of bytes to hold conversion from all channels
* without the timestamp.
@@ -222,6 +286,37 @@
.indexed = 1, \
}
+#define AT91_SAMA5D2_CHAN_TOUCH(num, name, mod) \
+ { \
+ .type = IIO_POSITIONRELATIVE, \
+ .modified = 1, \
+ .channel = num, \
+ .channel2 = mod, \
+ .scan_index = num, \
+ .scan_type = { \
+ .sign = 'u', \
+ .realbits = 12, \
+ .storagebits = 16, \
+ }, \
+ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \
+ .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ),\
+ .datasheet_name = name, \
+ }
+#define AT91_SAMA5D2_CHAN_PRESSURE(num, name) \
+ { \
+ .type = IIO_PRESSURE, \
+ .channel = num, \
+ .scan_index = num, \
+ .scan_type = { \
+ .sign = 'u', \
+ .realbits = 12, \
+ .storagebits = 16, \
+ }, \
+ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \
+ .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ),\
+ .datasheet_name = name, \
+ }
+
#define at91_adc_readl(st, reg) readl_relaxed(st->base + reg)
#define at91_adc_writel(st, reg, val) writel_relaxed(val, st->base + reg)
@@ -260,6 +355,22 @@ struct at91_adc_dma {
s64 dma_ts;
};
+/**
+ * at91_adc_touch - at91-sama5d2 touchscreen information struct
+ * @sample_period_val: the value for periodic trigger interval
+ * @touching: is the pen touching the screen or not
+ * @x_pos: temporary placeholder for pressure computation
+ * @channels_bitmask: bitmask with the touchscreen channels enabled
+ * @workq: workqueue for buffer data pushing
+ */
+struct at91_adc_touch {
+ u16 sample_period_val;
+ bool touching;
+ u16 x_pos;
+ unsigned long channels_bitmask;
+ struct work_struct workq;
+};
+
struct at91_adc_state {
void __iomem *base;
int irq;
@@ -267,6 +378,7 @@ struct at91_adc_state {
struct regulator *reg;
struct regulator *vref;
int vref_uv;
+ unsigned int current_sample_rate;
struct iio_trigger *trig;
const struct at91_adc_trigger *selected_trig;
const struct iio_chan_spec *chan;
@@ -275,6 +387,7 @@ struct at91_adc_state {
struct at91_adc_soc_info soc_info;
wait_queue_head_t wq_data_available;
struct at91_adc_dma dma_st;
+ struct at91_adc_touch touch_st;
u16 buffer[AT91_BUFFER_MAX_HWORDS];
/*
* lock to prevent concurrent 'single conversion' requests through
@@ -329,8 +442,10 @@ static const struct iio_chan_spec at91_adc_channels[] = {
AT91_SAMA5D2_CHAN_DIFF(6, 7, 0x68),
AT91_SAMA5D2_CHAN_DIFF(8, 9, 0x70),
AT91_SAMA5D2_CHAN_DIFF(10, 11, 0x78),
- IIO_CHAN_SOFT_TIMESTAMP(AT91_SAMA5D2_SINGLE_CHAN_CNT
- + AT91_SAMA5D2_DIFF_CHAN_CNT + 1),
+ IIO_CHAN_SOFT_TIMESTAMP(AT91_SAMA5D2_TIMESTAMP_CHAN_IDX),
+ AT91_SAMA5D2_CHAN_TOUCH(AT91_SAMA5D2_TOUCH_X_CHAN_IDX, "x", IIO_MOD_X),
+ AT91_SAMA5D2_CHAN_TOUCH(AT91_SAMA5D2_TOUCH_Y_CHAN_IDX, "y", IIO_MOD_Y),
+ AT91_SAMA5D2_CHAN_PRESSURE(AT91_SAMA5D2_TOUCH_P_CHAN_IDX, "pressure"),
};
static int at91_adc_chan_xlate(struct iio_dev *indio_dev, int chan)
@@ -354,6 +469,162 @@ at91_adc_chan_get(struct iio_dev *indio_dev, int chan)
return indio_dev->channels + index;
}
+static inline int at91_adc_of_xlate(struct iio_dev *indio_dev,
+ const struct of_phandle_args *iiospec)
+{
+ return at91_adc_chan_xlate(indio_dev, iiospec->args[0]);
+}
+
+static int at91_adc_configure_touch(struct at91_adc_state *st, bool state)
+{
+ u32 clk_khz = st->current_sample_rate / 1000;
+ int i = 0;
+ u16 pendbc;
+ u32 tsmr, acr;
+
+ if (!state) {
+ /* disabling touch IRQs and setting mode to no touch enabled */
+ at91_adc_writel(st, AT91_SAMA5D2_IDR,
+ AT91_SAMA5D2_IER_PEN | AT91_SAMA5D2_IER_NOPEN);
+ at91_adc_writel(st, AT91_SAMA5D2_TSMR, 0);
+ return 0;
+ }
+ /*
+ * debounce time is in microseconds, we need it in milliseconds to
+ * multiply with kilohertz, so, divide by 1000, but after the multiply.
+ * round up to make sure pendbc is at least 1
+ */
+ pendbc = round_up(TOUCH_PEN_DETECT_DEBOUNCE_US * clk_khz / 1000, 1);
+
+ /* get the required exponent */
+ while (pendbc >> i++)
+ ;
+
+ pendbc = i;
+
+ tsmr = AT91_SAMA5D2_TSMR_TSMODE_4WIRE_PRESS;
+
+ tsmr |= AT91_SAMA5D2_TSMR_TSAV(2) & AT91_SAMA5D2_TSMR_TSAV_MASK;
+ tsmr |= AT91_SAMA5D2_TSMR_PENDBC(pendbc) &
+ AT91_SAMA5D2_TSMR_PENDBC_MASK;
+ tsmr |= AT91_SAMA5D2_TSMR_NOTSDMA;
+ tsmr |= AT91_SAMA5D2_TSMR_PENDET_ENA;
+ tsmr |= AT91_SAMA5D2_TSMR_TSFREQ(2) & AT91_SAMA5D2_TSMR_TSFREQ_MASK;
+
+ at91_adc_writel(st, AT91_SAMA5D2_TSMR, tsmr);
+
+ acr = at91_adc_readl(st, AT91_SAMA5D2_ACR);
+ acr &= ~AT91_SAMA5D2_ACR_PENDETSENS_MASK;
+ acr |= 0x02 & AT91_SAMA5D2_ACR_PENDETSENS_MASK;
+ at91_adc_writel(st, AT91_SAMA5D2_ACR, acr);
+
+ /* Sample Period Time = (TRGPER + 1) / ADCClock */
+ st->touch_st.sample_period_val = round_up((TOUCH_SAMPLE_PERIOD_US *
+ clk_khz / 1000) - 1, 1);
+ /* enable pen detect IRQ */
+ at91_adc_writel(st, AT91_SAMA5D2_IER, AT91_SAMA5D2_IER_PEN);
+
+ return 0;
+}
+
+static u16 at91_adc_touch_x_pos(struct at91_adc_state *st)
+{
+ u32 val;
+ u32 xscale, x, xpos;
+
+ /* x position = (x / xscale) * max, max = 2^MAX_POS_BITS - 1 */
+ val = at91_adc_readl(st, AT91_SAMA5D2_XPOSR);
+ if (!val)
+ dev_dbg(&iio_priv_to_dev(st)->dev, "x_pos is 0\n");
+
+ xpos = val & XYZ_MASK;
+ x = (xpos << MAX_POS_BITS) - xpos;
+ xscale = (val >> 16) & XYZ_MASK;
+ if (xscale == 0) {
+ dev_err(&iio_priv_to_dev(st)->dev, "xscale is 0\n");
+ return 0;
+ }
+ x /= xscale;
+ st->touch_st.x_pos = x;
+
+ return x;
+}
+
+static u16 at91_adc_touch_y_pos(struct at91_adc_state *st)
+{
+ u32 val;
+ u32 yscale, y, ypos;
+
+ /* y position = (y / yscale) * max, max = 2^MAX_POS_BITS - 1 */
+ val = at91_adc_readl(st, AT91_SAMA5D2_YPOSR);
+ if (!val)
+ dev_dbg(&iio_priv_to_dev(st)->dev, "y_pos is 0\n");
+
+ ypos = val & XYZ_MASK;
+ y = (ypos << MAX_POS_BITS) - ypos;
+ yscale = (val >> 16) & XYZ_MASK;
+
+ if (yscale == 0) {
+ dev_err(&iio_priv_to_dev(st)->dev, "yscale is 0\n");
+ return 0;
+ }
+
+ y /= yscale;
+
+ return y;
+}
+
+static u16 at91_adc_touch_pressure(struct at91_adc_state *st)
+{
+ u32 val;
+ u32 z1, z2;
+ u32 pres;
+ u32 rxp = 1;
+ u32 factor = 1000;
+
+ /* calculate the pressure */
+ val = at91_adc_readl(st, AT91_SAMA5D2_PRESSR);
+ z1 = val & XYZ_MASK;
+ z2 = (val >> 16) & XYZ_MASK;
+
+ if (z1 != 0)
+ pres = rxp * (st->touch_st.x_pos * factor / 1024) *
+ (z2 * factor / z1 - factor) /
+ factor;
+ else
+ pres = 0xFFFF; /* no pen contact */
+
+ return pres;
+}
+
+static int at91_adc_read_position(struct at91_adc_state *st, int chan, u16 *val)
+{
+ *val = 0;
+ if (!st->touch_st.touching)
+ return -ENODATA;
+ if (chan == AT91_SAMA5D2_TOUCH_X_CHAN_IDX)
+ *val = at91_adc_touch_x_pos(st);
+ else if (chan == AT91_SAMA5D2_TOUCH_Y_CHAN_IDX)
+ *val = at91_adc_touch_y_pos(st);
+ else
+ return -ENODATA;
+
+ return IIO_VAL_INT;
+}
+
+static int at91_adc_read_pressure(struct at91_adc_state *st, int chan, u16 *val)
+{
+ *val = 0;
+ if (!st->touch_st.touching)
+ return -ENODATA;
+ if (chan == AT91_SAMA5D2_TOUCH_P_CHAN_IDX)
+ *val = at91_adc_touch_pressure(st);
+ else
+ return -ENODATA;
+
+ return IIO_VAL_INT;
+}
+
static int at91_adc_configure_trigger(struct iio_trigger *trig, bool state)
{
struct iio_dev *indio = iio_trigger_get_drvdata(trig);
@@ -373,7 +644,7 @@ static int at91_adc_configure_trigger(struct iio_trigger *trig, bool state)
for_each_set_bit(bit, indio->active_scan_mask, indio->num_channels) {
struct iio_chan_spec const *chan = at91_adc_chan_get(indio, bit);
- if (!chan)
+ if (!chan || chan->type != IIO_VOLTAGE)
continue;
if (state) {
at91_adc_writel(st, AT91_SAMA5D2_CHER,
@@ -520,7 +791,17 @@ static int at91_adc_dma_start(struct iio_dev *indio_dev)
static int at91_adc_buffer_postenable(struct iio_dev *indio_dev)
{
int ret;
+ struct at91_adc_state *st = iio_priv(indio_dev);
+ /* check if we are enabling triggered buffer or the touchscreen */
+ if (bitmap_subset(indio_dev->active_scan_mask,
+ &st->touch_st.channels_bitmask,
+ AT91_SAMA5D2_MAX_CHAN_IDX + 1)) {
+ /* touchscreen enabling */
+ at91_adc_configure_touch(st, true);
+ return 0;
+ }
+ /* we continue with the triggered buffer */
ret = at91_adc_dma_start(indio_dev);
if (ret) {
dev_err(&indio_dev->dev, "buffer postenable failed\n");
@@ -536,6 +817,16 @@ static int at91_adc_buffer_predisable(struct iio_dev *indio_dev)
int ret;
u8 bit;
+ /* check if we are disabling triggered buffer or the touchscreen */
+ if (bitmap_subset(indio_dev->active_scan_mask,
+ &st->touch_st.channels_bitmask,
+ AT91_SAMA5D2_MAX_CHAN_IDX + 1)) {
+ /* touchscreen disable */
+ at91_adc_configure_touch(st, false);
+ return 0;
+ }
+
+ /* continue with the triggered buffer */
ret = iio_triggered_buffer_predisable(indio_dev);
if (ret < 0)
dev_err(&indio_dev->dev, "buffer predisable failed\n");
@@ -556,7 +847,7 @@ static int at91_adc_buffer_predisable(struct iio_dev *indio_dev)
struct iio_chan_spec const *chan =
at91_adc_chan_get(indio_dev, bit);
- if (!chan)
+ if (!chan && chan->type != IIO_VOLTAGE)
continue;
if (st->dma_st.dma_chan)
at91_adc_readl(st, chan->address);
@@ -622,7 +913,10 @@ static void at91_adc_trigger_handler_nodma(struct iio_dev *indio_dev,
if (!chan)
continue;
- st->buffer[i] = at91_adc_readl(st, chan->address);
+ if (chan->type == IIO_VOLTAGE)
+ st->buffer[i] = at91_adc_readl(st, chan->address);
+ else
+ st->buffer[i] = 0;
i++;
}
iio_push_to_buffers_with_timestamp(indio_dev, st->buffer,
@@ -736,6 +1030,7 @@ static void at91_adc_setup_samp_freq(struct at91_adc_state *st, unsigned freq)
dev_dbg(&indio_dev->dev, "freq: %u, startup: %u, prescal: %u\n",
freq, startup, prescal);
+ st->current_sample_rate = freq;
}
static unsigned at91_adc_get_sample_freq(struct at91_adc_state *st)
@@ -751,23 +1046,109 @@ static unsigned at91_adc_get_sample_freq(struct at91_adc_state *st)
return f_adc;
}
+static void at91_adc_touch_data_handler(struct iio_dev *indio_dev)
+{
+ struct at91_adc_state *st = iio_priv(indio_dev);
+ u8 bit;
+ u16 val;
+ int i = 0;
+
+ for_each_set_bit(bit, indio_dev->active_scan_mask,
+ AT91_SAMA5D2_MAX_CHAN_IDX + 1) {
+ struct iio_chan_spec const *chan =
+ at91_adc_chan_get(indio_dev, bit);
+
+ if (chan->type == IIO_POSITIONRELATIVE)
+ at91_adc_read_position(st, chan->channel, &val);
+ else if (chan->type == IIO_PRESSURE)
+ at91_adc_read_pressure(st, chan->channel, &val);
+ else
+ continue;
+ st->buffer[i] = val;
+ i++;
+ }
+ /* schedule work to push to buffers */
+ schedule_work(&st->touch_st.workq);
+}
+
+static void at91_adc_pen_detect_interrupt(struct at91_adc_state *st)
+{
+ at91_adc_writel(st, AT91_SAMA5D2_IDR, AT91_SAMA5D2_IER_PEN);
+ at91_adc_writel(st, AT91_SAMA5D2_IER, AT91_SAMA5D2_IER_NOPEN |
+ AT91_SAMA5D2_IER_XRDY | AT91_SAMA5D2_IER_YRDY |
+ AT91_SAMA5D2_IER_PRDY);
+ at91_adc_writel(st, AT91_SAMA5D2_TRGR,
+ AT91_SAMA5D2_TRGR_TRGMOD_PERIODIC |
+ AT91_SAMA5D2_TRGR_TRGPER(st->touch_st.sample_period_val));
+ st->touch_st.touching = true;
+}
+
+static void at91_adc_no_pen_detect_interrupt(struct at91_adc_state *st)
+{
+ struct iio_dev *indio_dev = iio_priv_to_dev(st);
+
+ at91_adc_writel(st, AT91_SAMA5D2_TRGR,
+ AT91_SAMA5D2_TRGR_TRGMOD_NO_TRIGGER);
+ at91_adc_writel(st, AT91_SAMA5D2_IDR, AT91_SAMA5D2_IER_NOPEN |
+ AT91_SAMA5D2_IER_XRDY | AT91_SAMA5D2_IER_YRDY |
+ AT91_SAMA5D2_IER_PRDY);
+ st->touch_st.touching = false;
+
+ at91_adc_touch_data_handler(indio_dev);
+
+ at91_adc_writel(st, AT91_SAMA5D2_IER, AT91_SAMA5D2_IER_PEN);
+}
+
+static void at91_adc_workq_handler(struct work_struct *workq)
+{
+ struct at91_adc_touch *touch_st = container_of(workq,
+ struct at91_adc_touch, workq);
+ struct at91_adc_state *st = container_of(touch_st,
+ struct at91_adc_state, touch_st);
+ struct iio_dev *indio_dev = iio_priv_to_dev(st);
+
+ iio_push_to_buffers(indio_dev, st->buffer);
+}
+
static irqreturn_t at91_adc_interrupt(int irq, void *private)
{
struct iio_dev *indio = private;
struct at91_adc_state *st = iio_priv(indio);
u32 status = at91_adc_readl(st, AT91_SAMA5D2_ISR);
u32 imr = at91_adc_readl(st, AT91_SAMA5D2_IMR);
+ u32 rdy_mask = AT91_SAMA5D2_IER_XRDY | AT91_SAMA5D2_IER_YRDY |
+ AT91_SAMA5D2_IER_PRDY;
if (!(status & imr))
return IRQ_NONE;
-
- if (iio_buffer_enabled(indio) && !st->dma_st.dma_chan) {
+ if (status & AT91_SAMA5D2_IER_PEN) {
+ /* pen detected IRQ */
+ at91_adc_pen_detect_interrupt(st);
+ } else if ((status & AT91_SAMA5D2_IER_NOPEN)) {
+ /* nopen detected IRQ */
+ at91_adc_no_pen_detect_interrupt(st);
+ } else if ((status & AT91_SAMA5D2_ISR_PENS) &&
+ ((status & rdy_mask) == rdy_mask)) {
+ /* periodic trigger IRQ - during pen sense */
+ at91_adc_touch_data_handler(indio);
+ } else if (status & AT91_SAMA5D2_ISR_PENS) {
+ /*
+ * touching, but the measurements are not ready yet.
+ * read and ignore.
+ */
+ status = at91_adc_readl(st, AT91_SAMA5D2_XPOSR);
+ status = at91_adc_readl(st, AT91_SAMA5D2_YPOSR);
+ status = at91_adc_readl(st, AT91_SAMA5D2_PRESSR);
+ } else if (iio_buffer_enabled(indio) && !st->dma_st.dma_chan) {
+ /* triggered buffer without DMA */
disable_irq_nosync(irq);
iio_trigger_poll(indio->trig);
} else if (iio_buffer_enabled(indio) && st->dma_st.dma_chan) {
+ /* triggered buffer with DMA - should not happen */
disable_irq_nosync(irq);
WARN(true, "Unexpected irq occurred\n");
} else if (!iio_buffer_enabled(indio)) {
+ /* software requested conversion */
st->conversion_value = at91_adc_readl(st, st->chan->address);
st->conversion_done = true;
wake_up_interruptible(&st->wq_data_available);
@@ -791,6 +1172,21 @@ static int at91_adc_read_raw(struct iio_dev *indio_dev,
return ret;
mutex_lock(&st->lock);
+ if (chan->type == IIO_POSITIONRELATIVE) {
+ ret = at91_adc_read_position(st,
+ chan->channel, (u16 *)val);
+ mutex_unlock(&st->lock);
+ iio_device_release_direct_mode(indio_dev);
+ return ret;
+ }
+ if (chan->type == IIO_PRESSURE) {
+ ret = at91_adc_read_pressure(st,
+ chan->channel, (u16 *)val);
+ mutex_unlock(&st->lock);
+ iio_device_release_direct_mode(indio_dev);
+ return ret;
+ }
+
st->chan = chan;
if (chan->differential)
@@ -974,9 +1370,29 @@ static int at91_adc_set_watermark(struct iio_dev *indio_dev, unsigned int val)
return 0;
}
+static int at91_adc_update_scan_mode(struct iio_dev *indio_dev,
+ const unsigned long *scan_mask)
+{
+ struct at91_adc_state *st = iio_priv(indio_dev);
+
+ if (bitmap_subset(scan_mask, &st->touch_st.channels_bitmask,
+ AT91_SAMA5D2_MAX_CHAN_IDX + 1))
+ return 0;
+ /*
+ * if the new bitmap is a combination of touchscreen and regular
+ * channels, then we are not fine
+ */
+ if (bitmap_intersects(&st->touch_st.channels_bitmask, scan_mask,
+ AT91_SAMA5D2_MAX_CHAN_IDX + 1))
+ return -EBUSY;
+ return 0;
+}
+
static const struct iio_info at91_adc_info = {
.read_raw = &at91_adc_read_raw,
.write_raw = &at91_adc_write_raw,
+ .update_scan_mode = &at91_adc_update_scan_mode,
+ .of_xlate = &at91_adc_of_xlate,
.hwfifo_set_watermark = &at91_adc_set_watermark,
};
@@ -1044,13 +1460,20 @@ static int at91_adc_probe(struct platform_device *pdev)
indio_dev->dev.parent = &pdev->dev;
indio_dev->name = dev_name(&pdev->dev);
- indio_dev->modes = INDIO_DIRECT_MODE;
+ indio_dev->modes = INDIO_DIRECT_MODE | INDIO_BUFFER_SOFTWARE;
indio_dev->info = &at91_adc_info;
indio_dev->channels = at91_adc_channels;
indio_dev->num_channels = ARRAY_SIZE(at91_adc_channels);
st = iio_priv(indio_dev);
+ bitmap_set(&st->touch_st.channels_bitmask,
+ AT91_SAMA5D2_TOUCH_X_CHAN_IDX, 1);
+ bitmap_set(&st->touch_st.channels_bitmask,
+ AT91_SAMA5D2_TOUCH_Y_CHAN_IDX, 1);
+ bitmap_set(&st->touch_st.channels_bitmask,
+ AT91_SAMA5D2_TOUCH_P_CHAN_IDX, 1);
+
ret = of_property_read_u32(pdev->dev.of_node,
"atmel,min-sample-rate-hz",
&st->soc_info.min_sample_rate);
@@ -1100,6 +1523,7 @@ static int at91_adc_probe(struct platform_device *pdev)
init_waitqueue_head(&st->wq_data_available);
mutex_init(&st->lock);
+ INIT_WORK(&st->touch_st.workq, at91_adc_workq_handler);
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res)
@@ -1272,8 +1696,18 @@ static __maybe_unused int at91_adc_resume(struct device *dev)
at91_adc_hw_init(st);
/* reconfiguring trigger hardware state */
- if (iio_buffer_enabled(indio_dev))
+ if (!iio_buffer_enabled(indio_dev))
+ return 0;
+
+ /* check if we are enabling triggered buffer or the touchscreen */
+ if (bitmap_subset(indio_dev->active_scan_mask,
+ &st->touch_st.channels_bitmask,
+ AT91_SAMA5D2_MAX_CHAN_IDX + 1)) {
+ /* touchscreen enabling */
+ at91_adc_configure_touch(st, true);
+ } else {
at91_adc_configure_trigger(st->trig, true);
+ }
return 0;
--
2.7.4
^ permalink raw reply related
* [PATCH v2 07/10] input: touchscreen: touch_adc: add generic resistive ADC touchscreen
From: Eugen Hristev @ 2018-03-27 12:32 UTC (permalink / raw)
To: jic23, ludovic.desroches, alexandre.belloni, linux-arm-kernel,
devicetree, linux-kernel, linux-iio, linux-input, nicolas.ferre,
dmitry.torokhov
Cc: Eugen Hristev
In-Reply-To: <1522153963-1121-1-git-send-email-eugen.hristev@microchip.com>
This adds a generic resistive touchscreen (GRTS) driver, which is based
on an IIO device (an ADC). It must be connected to the channels of an ADC
to receive touch data. Then it will feed the data into the input subsystem
where it registers an input device.
It uses an IIO callback buffer to register to the IIO device
Some parts of this patch are based on initial original work by
Mohamed Jamsheeth Hajanajubudeen and Bandaru Venkateswara Swamy
Signed-off-by: Eugen Hristev <eugen.hristev@microchip.com>
---
Changes in v2:
- this is now a generic resistive adc touchscreen driver
drivers/input/touchscreen/Kconfig | 13 +++
drivers/input/touchscreen/Makefile | 1 +
drivers/input/touchscreen/touch_adc.c | 199 ++++++++++++++++++++++++++++++++++
3 files changed, 213 insertions(+)
create mode 100644 drivers/input/touchscreen/touch_adc.c
diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig
index 4f15496..afd879f 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -92,6 +92,19 @@ config TOUCHSCREEN_AD7879_SPI
To compile this driver as a module, choose M here: the
module will be called ad7879-spi.
+config TOUCHSCREEN_ADC
+ tristate "Generic ADC based resistive touchscreen"
+ depends on IIO
+ select IIO_BUFFER_CB
+ help
+ Say Y here if you want to use the generic ADC
+ resistive touchscreen driver.
+
+ If unsure, say N (but it's safe to say "Y").
+
+ To compile this driver as a module, choose M here: the
+ module will be called touch_adc.ko.
+
config TOUCHSCREEN_AR1021_I2C
tristate "Microchip AR1020/1021 i2c touchscreen"
depends on I2C && OF
diff --git a/drivers/input/touchscreen/Makefile b/drivers/input/touchscreen/Makefile
index dddae79..cbe6121 100644
--- a/drivers/input/touchscreen/Makefile
+++ b/drivers/input/touchscreen/Makefile
@@ -13,6 +13,7 @@ obj-$(CONFIG_TOUCHSCREEN_AD7877) += ad7877.o
obj-$(CONFIG_TOUCHSCREEN_AD7879) += ad7879.o
obj-$(CONFIG_TOUCHSCREEN_AD7879_I2C) += ad7879-i2c.o
obj-$(CONFIG_TOUCHSCREEN_AD7879_SPI) += ad7879-spi.o
+obj-$(CONFIG_TOUCHSCREEN_ADC) += touch_adc.o
obj-$(CONFIG_TOUCHSCREEN_ADS7846) += ads7846.o
obj-$(CONFIG_TOUCHSCREEN_AR1021_I2C) += ar1021_i2c.o
obj-$(CONFIG_TOUCHSCREEN_ATMEL_MXT) += atmel_mxt_ts.o
diff --git a/drivers/input/touchscreen/touch_adc.c b/drivers/input/touchscreen/touch_adc.c
new file mode 100644
index 0000000..de4b929
--- /dev/null
+++ b/drivers/input/touchscreen/touch_adc.c
@@ -0,0 +1,199 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * ADC generic resistive touchscreen (GRTS)
+ *
+ * Copyright (C) 2017,2018 Microchip Technology,
+ * Author: Eugen Hristev <eugen.hristev@microchip.com>
+ *
+ */
+#include <linux/input.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
+#include <linux/platform_device.h>
+#include <linux/iio/consumer.h>
+#include <linux/iio/iio.h>
+#include <linux/module.h>
+
+#define DRIVER_NAME "touch_adc"
+#define GRTS_DEFAULT_PRESSURE_THRESHOLD 10000
+#define MAX_POS_MASK GENMASK(11, 0)
+
+/**
+ * grts_state - generic resistive touch screen information struct
+ * @pressure_threshold: number representing the threshold for the pressure
+ * @pressure: are we getting pressure info or not
+ * @iio_chans: list of channels acquired
+ * @iio_cb: iio_callback buffer for the data
+ * @input: the input device structure that we register
+ */
+struct grts_state {
+ u32 pressure_threshold;
+ bool pressure;
+ struct iio_channel *iio_chans;
+ struct iio_cb_buffer *iio_cb;
+ struct input_dev *input;
+};
+
+static int grts_cb(const void *data, void *private)
+{
+ const u16 *touch_info = data;
+ struct grts_state *st = private;
+
+ unsigned int x, y, press = 0xFFFF;
+
+ /* channel data coming in buffer in the order below */
+ x = touch_info[0];
+ y = touch_info[1];
+ if (st->pressure)
+ press = touch_info[2];
+
+ if ((!x && !y) || (st->pressure && (press > st->pressure_threshold))) {
+ /* report end of touch */
+ input_report_key(st->input, BTN_TOUCH, 0);
+ input_sync(st->input);
+ return 0;
+ }
+
+ /* report proper touch to subsystem*/
+ input_report_abs(st->input, ABS_X, x);
+ input_report_abs(st->input, ABS_Y, y);
+ if (st->pressure)
+ input_report_abs(st->input, ABS_PRESSURE, press);
+ input_report_key(st->input, BTN_TOUCH, 1);
+ input_sync(st->input);
+ return 0;
+}
+
+static int grts_open(struct input_dev *dev)
+{
+ int ret;
+ struct grts_state *st = input_get_drvdata(dev);
+
+ ret = iio_channel_start_all_cb(st->iio_cb);
+ if (ret) {
+ dev_err(dev->dev.parent, "failed to start callback buffer.\n");
+ return ret;
+ }
+ return 0;
+}
+
+static void grts_close(struct input_dev *dev)
+{
+ struct grts_state *st = input_get_drvdata(dev);
+
+ iio_channel_stop_all_cb(st->iio_cb);
+}
+
+static int grts_probe(struct platform_device *pdev)
+{
+ struct grts_state *st;
+ struct input_dev *input;
+ struct device *dev = &pdev->dev;
+ struct device_node *node = dev->of_node;
+ struct iio_channel *chan;
+ int ret = 0;
+
+ st = devm_kzalloc(dev, sizeof(struct grts_state), GFP_KERNEL);
+ if (!st)
+ return -ENOMEM;
+
+ ret = of_property_read_u32(node,
+ "generic-adc-resistive-touchscreen,pressure-threshold",
+ &st->pressure_threshold);
+ if (ret < 0) {
+ dev_dbg(dev, "can't get touchscreen pressure threshold property.\n");
+ st->pressure_threshold = GRTS_DEFAULT_PRESSURE_THRESHOLD;
+ }
+
+ /* get the channels from IIO device */
+ st->iio_chans = devm_iio_channel_get_all(dev);
+
+ if (IS_ERR(st->iio_chans)) {
+ if (PTR_ERR(st->iio_chans) != -EPROBE_DEFER)
+ dev_err(dev, "can't get iio channels.\n");
+ return PTR_ERR(st->iio_chans);
+ }
+
+ chan = &st->iio_chans[0];
+ st->pressure = false;
+ while (chan && chan->indio_dev) {
+ if (!strcmp(chan->channel->datasheet_name, "pressure"))
+ st->pressure = true;
+ chan++;
+ }
+
+ input = devm_input_allocate_device(dev);
+ if (!input) {
+ dev_err(dev, "failed to allocate input device.\n");
+ return -ENOMEM;
+ }
+
+ input->name = DRIVER_NAME;
+ input->id.bustype = BUS_HOST;
+ input->dev.parent = dev;
+ input->open = grts_open;
+ input->close = grts_close;
+
+ input_set_abs_params(input, ABS_X, 0, MAX_POS_MASK - 1, 0, 0);
+ input_set_abs_params(input, ABS_Y, 0, MAX_POS_MASK - 1, 0, 0);
+ if (st->pressure)
+ input_set_abs_params(input, ABS_PRESSURE, 0, 0xffffff, 0, 0);
+
+ input->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
+ input->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);
+
+ st->input = input;
+ input_set_drvdata(input, st);
+
+ ret = input_register_device(input);
+ if (ret) {
+ dev_err(dev, "failed to register input device.");
+ return ret;
+ }
+
+ st->iio_cb = iio_channel_get_all_cb(&pdev->dev, grts_cb, st);
+
+ if (IS_ERR(st->iio_cb)) {
+ dev_err(dev, "failed to allocate callback buffer.\n");
+ ret = PTR_ERR(st->iio_cb);
+ return ret;
+ }
+
+ platform_set_drvdata(pdev, st);
+
+ return ret;
+}
+
+static int grts_remove(struct platform_device *pdev)
+{
+ struct grts_state *st = platform_get_drvdata(pdev);
+
+ iio_channel_release_all_cb(st->iio_cb);
+ input_unregister_device(st->input);
+ return 0;
+}
+
+static const struct of_device_id grts_of_match[] = {
+ {
+ .compatible = "generic-resistive-adc-touch",
+ }, {
+ /* sentinel */
+ },
+};
+
+MODULE_DEVICE_TABLE(of, grts_of_match);
+
+static struct platform_driver grts_driver = {
+ .probe = grts_probe,
+ .remove = grts_remove,
+ .driver = {
+ .name = DRIVER_NAME,
+ .of_match_table = of_match_ptr(grts_of_match),
+ },
+};
+
+module_platform_driver(grts_driver);
+
+MODULE_AUTHOR("Eugen Hristev <eugen.hristev@microchip.com>");
+MODULE_DESCRIPTION("Generic ADC Resistive Touch Driver");
+MODULE_LICENSE("GPL v2");
--
2.7.4
^ permalink raw reply related
* [PATCH v2 08/10] dt-bindings: iio: adc: at91-sama5d2_adc: add channel specific consumer info
From: Eugen Hristev @ 2018-03-27 12:32 UTC (permalink / raw)
To: jic23, ludovic.desroches, alexandre.belloni, linux-arm-kernel,
devicetree, linux-kernel, linux-iio, linux-input, nicolas.ferre,
dmitry.torokhov
Cc: Eugen Hristev
In-Reply-To: <1522153963-1121-1-git-send-email-eugen.hristev@microchip.com>
Added defines for channel consumer device-tree binding
Signed-off-by: Eugen Hristev <eugen.hristev@microchip.com>
---
.../devicetree/bindings/iio/adc/at91-sama5d2_adc.txt | 9 +++++++++
include/dt-bindings/iio/adc/at91-sama5d2_adc.h | 16 ++++++++++++++++
2 files changed, 25 insertions(+)
create mode 100644 include/dt-bindings/iio/adc/at91-sama5d2_adc.h
diff --git a/Documentation/devicetree/bindings/iio/adc/at91-sama5d2_adc.txt b/Documentation/devicetree/bindings/iio/adc/at91-sama5d2_adc.txt
index 6469a4c..4a3c1d4 100644
--- a/Documentation/devicetree/bindings/iio/adc/at91-sama5d2_adc.txt
+++ b/Documentation/devicetree/bindings/iio/adc/at91-sama5d2_adc.txt
@@ -21,6 +21,14 @@ Optional properties:
- dmas: Phandle to dma channel for the ADC.
- dma-names: Must be "rx" when dmas property is being used.
See ../../dma/dma.txt for details.
+ - #io-channel-cells: in case consumer drivers are attached, this must be 1.
+ See <Documentation/devicetree/bindings/iio/iio-bindings.txt> for details.
+
+Properties for consumer drivers:
+ - Consumer drivers can be connected to this producer device, as specified
+ in <Documentation/devicetree/bindings/iio/iio-bindings.txt>
+ - Channels exposed are specified in:
+ <dt-bindings/iio/adc/at91-sama5d2_adc.txt>
Example:
@@ -38,4 +46,5 @@ adc: adc@fc030000 {
atmel,trigger-edge-type = <IRQ_TYPE_EDGE_BOTH>;
dmas = <&dma0 (AT91_XDMAC_DT_MEM_IF(0) | AT91_XDMAC_DT_PER_IF(1) | AT91_XDMAC_DT_PERID(25))>;
dma-names = "rx";
+ #io-channel-cells = <1>;
}
diff --git a/include/dt-bindings/iio/adc/at91-sama5d2_adc.h b/include/dt-bindings/iio/adc/at91-sama5d2_adc.h
new file mode 100644
index 0000000..70f99db
--- /dev/null
+++ b/include/dt-bindings/iio/adc/at91-sama5d2_adc.h
@@ -0,0 +1,16 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * This header provides constants for configuring the AT91 SAMA5D2 ADC
+ */
+
+#ifndef _DT_BINDINGS_IIO_ADC_AT91_SAMA5D2_ADC_H
+#define _DT_BINDINGS_IIO_ADC_AT91_SAMA5D2_ADC_H
+
+/* X relative position channel index */
+#define AT91_SAMA5D2_ADC_X_CHANNEL 24
+/* Y relative position channel index */
+#define AT91_SAMA5D2_ADC_Y_CHANNEL 25
+/* pressure channel index */
+#define AT91_SAMA5D2_ADC_P_CHANNEL 26
+
+#endif
--
2.7.4
^ permalink raw reply related
* [PATCH v2 09/10] ARM: dts: at91: sama5d2: add channel cells for ADC device
From: Eugen Hristev @ 2018-03-27 12:32 UTC (permalink / raw)
To: jic23, ludovic.desroches, alexandre.belloni, linux-arm-kernel,
devicetree, linux-kernel, linux-iio, linux-input, nicolas.ferre,
dmitry.torokhov
Cc: Eugen Hristev
In-Reply-To: <1522153963-1121-1-git-send-email-eugen.hristev@microchip.com>
Preparing the ADC device to connect channel consumer drivers
Signed-off-by: Eugen Hristev <eugen.hristev@microchip.com>
---
arch/arm/boot/dts/sama5d2.dtsi | 2 ++
1 file changed, 2 insertions(+)
diff --git a/arch/arm/boot/dts/sama5d2.dtsi b/arch/arm/boot/dts/sama5d2.dtsi
index 61f68e5..f06ba99 100644
--- a/arch/arm/boot/dts/sama5d2.dtsi
+++ b/arch/arm/boot/dts/sama5d2.dtsi
@@ -47,6 +47,7 @@
#include <dt-bindings/dma/at91.h>
#include <dt-bindings/interrupt-controller/irq.h>
#include <dt-bindings/clock/at91.h>
+#include <dt-bindings/iio/adc/at91-sama5d2_adc.h>
/ {
model = "Atmel SAMA5D2 family SoC";
@@ -1437,6 +1438,7 @@
atmel,max-sample-rate-hz = <20000000>;
atmel,startup-time-ms = <4>;
atmel,trigger-edge-type = <IRQ_TYPE_EDGE_RISING>;
+ #io-channel-cells = <1>;
status = "disabled";
};
--
2.7.4
^ permalink raw reply related
* [PATCH v2 10/10] ARM: dts: at91: sama5d2: Add resistive touch device
From: Eugen Hristev @ 2018-03-27 12:32 UTC (permalink / raw)
To: jic23, ludovic.desroches, alexandre.belloni, linux-arm-kernel,
devicetree, linux-kernel, linux-iio, linux-input, nicolas.ferre,
dmitry.torokhov
Cc: Eugen Hristev
In-Reply-To: <1522153963-1121-1-git-send-email-eugen.hristev@microchip.com>
Add generic resistive touch device which is connected to ADC block
inside the SAMA5D2 SoC
Signed-off-by: Eugen Hristev <eugen.hristev@microchip.com>
---
Changes in v2:
- now added a generic resistive touchscreen node instead of architecture
specific
arch/arm/boot/dts/sama5d2.dtsi | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/arch/arm/boot/dts/sama5d2.dtsi b/arch/arm/boot/dts/sama5d2.dtsi
index f06ba99..0d87dc0 100644
--- a/arch/arm/boot/dts/sama5d2.dtsi
+++ b/arch/arm/boot/dts/sama5d2.dtsi
@@ -1442,6 +1442,16 @@
status = "disabled";
};
+ resistive_touch: resistive-touch {
+ compatible = "generic-resistive-adc-touch";
+ io-channels = <&adc AT91_SAMA5D2_ADC_X_CHANNEL>,
+ <&adc AT91_SAMA5D2_ADC_Y_CHANNEL>,
+ <&adc AT91_SAMA5D2_ADC_P_CHANNEL>;
+ io-channel-names = "x", "y", "pressure";
+ generic-resistive-adc-touch,pressure-threshold = <10000>;
+ status = "disabled";
+ };
+
pioA: pinctrl@fc038000 {
compatible = "atmel,sama5d2-pinctrl";
reg = <0xfc038000 0x600>;
--
2.7.4
^ permalink raw reply related
* Re: [PATCH] HID: google: add google hammer HID driver
From: Jiri Kosina @ 2018-03-27 12:48 UTC (permalink / raw)
To: Nicolas Boichat
Cc: Benjamin Tissoires, linux-kernel, linux-input, groeck, dtor
In-Reply-To: <20180315012825.145329-1-drinkcat@chromium.org>
On Thu, 15 Mar 2018, Nicolas Boichat wrote:
> From: Wei-Ning Huang <wnhuang@chromium.org>
>
> Add Google hammer HID driver. This driver allow us to control hammer
> keyboard backlight and support future features.
>
> Signed-off-by: Wei-Ning Huang <wnhuang@google.com>
> Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Applied to for-4.17/google-hammer.
Thanks,
--
Jiri Kosina
SUSE Labs
^ permalink raw reply
* Re: [PATCH] Input: ALPS - add support for 73 03 28 devices (Thinkpad L570)
From: Dennis Wassenberg @ 2018-03-27 13:56 UTC (permalink / raw)
To: Pali Rohár
Cc: Dmitry Torokhov, Masaki Ota, Takashi Iwai, Kees Cook, Nir Perry,
linux-input, linux-kernel
In-Reply-To: <20180323143336.v26rvflt3oq5xppn@pali>
Hi,
oh ok, understood. Thanks for this hint.
So maybe there is something wrong with the alps_update_dual_info_ss4_v2
function or the reporting of the hardware.
alps_update_dual_info_ss4_v2 detects the ThinkPad L570 as ss4plus device
but not as dualpoint device. This means that the ALPS_DUALPOINT and the
ALPS_DUALPOINT_WITH_PRESSURE flag will not be set which results in a non
function trackstick and hardware mouse buttons. Each time I touch the
trackstick I get the message: "alps: Rejected trackstick packet from non
DualPoint device".
The value of otp[0][0] inside alps_update_dual_info_ss4_v2 is 0xCE. Are
there any ideas why it is not detected as dualpoint device?
Thank you & best regards,
Dennis
On 23.03.2018 15:33, Pali Rohár wrote:
> On Friday 23 March 2018 15:23:55 Dennis Wassenberg wrote:
>> The Lenovo Thinkpad L570 uses V8 protocol.
>> Add 0x73 0x03 0x28 devices to use V8 protovol which makes
>> trackstick and mouse buttons work with Lenovo Thinkpad L570.
>>
>> Signed-off-by: Dennis Wassenberg <dennis.wassenberg@secunet.com>
>> ---
>> drivers/input/mouse/alps.c | 2 ++
>> 1 file changed, 2 insertions(+)
>>
>> diff --git a/drivers/input/mouse/alps.c b/drivers/input/mouse/alps.c
>> index dbe57da..5523d4e 100644
>> --- a/drivers/input/mouse/alps.c
>> +++ b/drivers/input/mouse/alps.c
>> @@ -136,6 +136,8 @@
>> { { 0x73, 0x02, 0x0a }, { ALPS_PROTO_V2, 0xf8, 0xf8, 0 } },
>> { { 0x73, 0x02, 0x14 }, { ALPS_PROTO_V2, 0xf8, 0xf8, ALPS_FW_BK_2 } }, /* Ahtec Laptop */
>> { { 0x73, 0x02, 0x50 }, { ALPS_PROTO_V2, 0xcf, 0xcf, ALPS_FOUR_BUTTONS } }, /* Dell Vostro 1400 */
>> + { { 0x73, 0x03, 0x28 }, { ALPS_PROTO_V8, 0x18, 0x18,
>> + ALPS_DUALPOINT | ALPS_DUALPOINT_WITH_PRESSURE | ALPS_BUTTONPAD } }, /* Lenovo L570 */
>> };
>>
>> static const struct alps_protocol_info alps_v3_protocol_data = {
>
> Hi! alps_model_data table is used for fixed identification of v1 and v2
> protocols. Why you need to add there v8 protocol which autodetection is
> already done in alps_identify() function? There is already code:
>
> } else if (e7[0] == 0x73 && e7[1] == 0x03 &&
> (e7[2] == 0x14 || e7[2] == 0x28)) {
> protocol = &alps_v8_protocol_data;
>
> Which matches above your E7 detection 0x73, 0x03, 0x28.
>
> Also you patch matches basically all v8 device and therefore has
> potential to break proper v8 autodetection for other v8 devices...
>
^ 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