* [PATCHv2 1/5] dt-bindings: touchscreen: Convert EETI EXC3000 touchscreen to json-schema
2020-05-19 18:24 [PATCHv2 0/5] EXC3000 Updates Sebastian Reichel
@ 2020-05-19 18:24 ` Sebastian Reichel
2020-05-19 20:38 ` Enric Balletbo i Serra
2020-05-19 18:24 ` [PATCHv2 2/5] Input: EXC3000: switch to i2c's probe_new API Sebastian Reichel
` (3 subsequent siblings)
4 siblings, 1 reply; 12+ messages in thread
From: Sebastian Reichel @ 2020-05-19 18:24 UTC (permalink / raw)
To: Dmitry Torokhov, Ahmet Inan, Martin Fuzzey
Cc: linux-input, linux-kernel, kernel, Sebastian Reichel
Convert the EETI EXC3000 binding to DT schema format using json-schema
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
---
.../bindings/input/touchscreen/exc3000.txt | 26 ---------
.../bindings/input/touchscreen/exc3000.yaml | 53 +++++++++++++++++++
2 files changed, 53 insertions(+), 26 deletions(-)
delete mode 100644 Documentation/devicetree/bindings/input/touchscreen/exc3000.txt
create mode 100644 Documentation/devicetree/bindings/input/touchscreen/exc3000.yaml
diff --git a/Documentation/devicetree/bindings/input/touchscreen/exc3000.txt b/Documentation/devicetree/bindings/input/touchscreen/exc3000.txt
deleted file mode 100644
index 68291b94fec2..000000000000
--- a/Documentation/devicetree/bindings/input/touchscreen/exc3000.txt
+++ /dev/null
@@ -1,26 +0,0 @@
-* EETI EXC3000 Multiple Touch Controller
-
-Required properties:
-- compatible: must be "eeti,exc3000"
-- reg: i2c slave address
-- interrupts: touch controller interrupt
-- touchscreen-size-x: See touchscreen.txt
-- touchscreen-size-y: See touchscreen.txt
-
-Optional properties:
-- touchscreen-inverted-x: See touchscreen.txt
-- touchscreen-inverted-y: See touchscreen.txt
-- touchscreen-swapped-x-y: See touchscreen.txt
-
-Example:
-
- touchscreen@2a {
- compatible = "eeti,exc3000";
- reg = <0x2a>;
- interrupt-parent = <&gpio1>;
- interrupts = <9 IRQ_TYPE_LEVEL_LOW>;
- touchscreen-size-x = <4096>;
- touchscreen-size-y = <4096>;
- touchscreen-inverted-x;
- touchscreen-swapped-x-y;
- };
diff --git a/Documentation/devicetree/bindings/input/touchscreen/exc3000.yaml b/Documentation/devicetree/bindings/input/touchscreen/exc3000.yaml
new file mode 100644
index 000000000000..5d2e7496d6dd
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/touchscreen/exc3000.yaml
@@ -0,0 +1,53 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/input/touchscreen/exc3000.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: EETI EXC3000 series touchscreen controller
+
+maintainers:
+ - Dmitry Torokhov <dmitry.torokhov@gmail.com>
+
+allOf:
+ - $ref: touchscreen.yaml#
+
+properties:
+ compatible:
+ const: eeti,exc3000
+ reg:
+ const: 0x2a
+ interrupts:
+ maxItems: 1
+ touchscreen-size-x: true
+ touchscreen-size-y: true
+ touchscreen-inverted-x: true
+ touchscreen-inverted-y: true
+ touchscreen-swapped-x-y: true
+
+required:
+ - compatible
+ - reg
+ - interrupts
+ - touchscreen-size-x
+ - touchscreen-size-y
+
+additionalProperties: false
+
+examples:
+ - |
+ #include "dt-bindings/interrupt-controller/irq.h"
+ i2c {
+ #address-cells = <1>;
+ #size-cells = <0>;
+ touchscreen@2a {
+ compatible = "eeti,exc3000";
+ reg = <0x2a>;
+ interrupt-parent = <&gpio1>;
+ interrupts = <9 IRQ_TYPE_LEVEL_LOW>;
+ touchscreen-size-x = <4096>;
+ touchscreen-size-y = <4096>;
+ touchscreen-inverted-x;
+ touchscreen-swapped-x-y;
+ };
+ };
--
2.26.2
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCHv2 1/5] dt-bindings: touchscreen: Convert EETI EXC3000 touchscreen to json-schema
2020-05-19 18:24 ` [PATCHv2 1/5] dt-bindings: touchscreen: Convert EETI EXC3000 touchscreen to json-schema Sebastian Reichel
@ 2020-05-19 20:38 ` Enric Balletbo i Serra
0 siblings, 0 replies; 12+ messages in thread
From: Enric Balletbo i Serra @ 2020-05-19 20:38 UTC (permalink / raw)
To: Sebastian Reichel, Dmitry Torokhov, Ahmet Inan, Martin Fuzzey
Cc: linux-input, linux-kernel, kernel
Hi Sebastian,
A minor thing.
On 19/5/20 20:24, Sebastian Reichel wrote:
> Convert the EETI EXC3000 binding to DT schema format using json-schema
>
> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
> ---
> .../bindings/input/touchscreen/exc3000.txt | 26 ---------
> .../bindings/input/touchscreen/exc3000.yaml | 53 +++++++++++++++++++
The binding name should start with the vendor, aka eeti,exc3000.yaml
> 2 files changed, 53 insertions(+), 26 deletions(-)
> delete mode 100644 Documentation/devicetree/bindings/input/touchscreen/exc3000.txt
> create mode 100644 Documentation/devicetree/bindings/input/touchscreen/exc3000.yaml
>
> diff --git a/Documentation/devicetree/bindings/input/touchscreen/exc3000.txt b/Documentation/devicetree/bindings/input/touchscreen/exc3000.txt
> deleted file mode 100644
> index 68291b94fec2..000000000000
> --- a/Documentation/devicetree/bindings/input/touchscreen/exc3000.txt
> +++ /dev/null
> @@ -1,26 +0,0 @@
> -* EETI EXC3000 Multiple Touch Controller
> -
> -Required properties:
> -- compatible: must be "eeti,exc3000"
> -- reg: i2c slave address
> -- interrupts: touch controller interrupt
> -- touchscreen-size-x: See touchscreen.txt
> -- touchscreen-size-y: See touchscreen.txt
> -
> -Optional properties:
> -- touchscreen-inverted-x: See touchscreen.txt
> -- touchscreen-inverted-y: See touchscreen.txt
> -- touchscreen-swapped-x-y: See touchscreen.txt
> -
> -Example:
> -
> - touchscreen@2a {
> - compatible = "eeti,exc3000";
> - reg = <0x2a>;
> - interrupt-parent = <&gpio1>;
> - interrupts = <9 IRQ_TYPE_LEVEL_LOW>;
> - touchscreen-size-x = <4096>;
> - touchscreen-size-y = <4096>;
> - touchscreen-inverted-x;
> - touchscreen-swapped-x-y;
> - };
> diff --git a/Documentation/devicetree/bindings/input/touchscreen/exc3000.yaml b/Documentation/devicetree/bindings/input/touchscreen/exc3000.yaml
> new file mode 100644
> index 000000000000..5d2e7496d6dd
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/input/touchscreen/exc3000.yaml
> @@ -0,0 +1,53 @@
> +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/input/touchscreen/exc3000.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: EETI EXC3000 series touchscreen controller
> +
> +maintainers:
> + - Dmitry Torokhov <dmitry.torokhov@gmail.com>
> +
> +allOf:
> + - $ref: touchscreen.yaml#
> +
> +properties:
> + compatible:
> + const: eeti,exc3000
> + reg:
> + const: 0x2a
> + interrupts:
> + maxItems: 1
> + touchscreen-size-x: true
> + touchscreen-size-y: true
> + touchscreen-inverted-x: true
> + touchscreen-inverted-y: true
> + touchscreen-swapped-x-y: true
> +
> +required:
> + - compatible
> + - reg
> + - interrupts
> + - touchscreen-size-x
> + - touchscreen-size-y
> +
> +additionalProperties: false
> +
> +examples:
> + - |
> + #include "dt-bindings/interrupt-controller/irq.h"
> + i2c {
> + #address-cells = <1>;
> + #size-cells = <0>;
> + touchscreen@2a {
> + compatible = "eeti,exc3000";
> + reg = <0x2a>;
> + interrupt-parent = <&gpio1>;
> + interrupts = <9 IRQ_TYPE_LEVEL_LOW>;
> + touchscreen-size-x = <4096>;
> + touchscreen-size-y = <4096>;
> + touchscreen-inverted-x;
> + touchscreen-swapped-x-y;
> + };
> + };
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCHv2 2/5] Input: EXC3000: switch to i2c's probe_new API
2020-05-19 18:24 [PATCHv2 0/5] EXC3000 Updates Sebastian Reichel
2020-05-19 18:24 ` [PATCHv2 1/5] dt-bindings: touchscreen: Convert EETI EXC3000 touchscreen to json-schema Sebastian Reichel
@ 2020-05-19 18:24 ` Sebastian Reichel
2020-05-19 18:24 ` [PATCHv2 3/5] Input: EXC3000: add EXC80H60 and EXC80H84 support Sebastian Reichel
` (2 subsequent siblings)
4 siblings, 0 replies; 12+ messages in thread
From: Sebastian Reichel @ 2020-05-19 18:24 UTC (permalink / raw)
To: Dmitry Torokhov, Ahmet Inan, Martin Fuzzey
Cc: linux-input, linux-kernel, kernel, Sebastian Reichel
Switch to the "new" I2C probe API.
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
---
drivers/input/touchscreen/exc3000.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/input/touchscreen/exc3000.c b/drivers/input/touchscreen/exc3000.c
index e007e2e8f626..555a14305cd4 100644
--- a/drivers/input/touchscreen/exc3000.c
+++ b/drivers/input/touchscreen/exc3000.c
@@ -145,8 +145,7 @@ static irqreturn_t exc3000_interrupt(int irq, void *dev_id)
return IRQ_HANDLED;
}
-static int exc3000_probe(struct i2c_client *client,
- const struct i2c_device_id *id)
+static int exc3000_probe(struct i2c_client *client)
{
struct exc3000_data *data;
struct input_dev *input;
@@ -210,7 +209,7 @@ static struct i2c_driver exc3000_driver = {
.of_match_table = of_match_ptr(exc3000_of_match),
},
.id_table = exc3000_id,
- .probe = exc3000_probe,
+ .probe_new = exc3000_probe,
};
module_i2c_driver(exc3000_driver);
--
2.26.2
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCHv2 3/5] Input: EXC3000: add EXC80H60 and EXC80H84 support
2020-05-19 18:24 [PATCHv2 0/5] EXC3000 Updates Sebastian Reichel
2020-05-19 18:24 ` [PATCHv2 1/5] dt-bindings: touchscreen: Convert EETI EXC3000 touchscreen to json-schema Sebastian Reichel
2020-05-19 18:24 ` [PATCHv2 2/5] Input: EXC3000: switch to i2c's probe_new API Sebastian Reichel
@ 2020-05-19 18:24 ` Sebastian Reichel
2020-05-19 23:52 ` kbuild test robot
2020-05-19 18:24 ` [PATCHv2 4/5] Input: EXC3000: Add support to query model and fw_version Sebastian Reichel
2020-05-19 18:24 ` [PATCHv2 5/5] Input: EXC3000: Add reset gpio support Sebastian Reichel
4 siblings, 1 reply; 12+ messages in thread
From: Sebastian Reichel @ 2020-05-19 18:24 UTC (permalink / raw)
To: Dmitry Torokhov, Ahmet Inan, Martin Fuzzey
Cc: linux-input, linux-kernel, kernel, Sebastian Reichel
This adds support for EXC80H60 and EXCH84 controllers, which
use a different event type id and have two extra bits for the
resolution (so the maximum is 16K instead of 4K).
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
---
.../bindings/input/touchscreen/exc3000.yaml | 5 +-
drivers/input/touchscreen/exc3000.c | 79 +++++++++++++++----
2 files changed, 69 insertions(+), 15 deletions(-)
diff --git a/Documentation/devicetree/bindings/input/touchscreen/exc3000.yaml b/Documentation/devicetree/bindings/input/touchscreen/exc3000.yaml
index 5d2e7496d6dd..d83b61e884df 100644
--- a/Documentation/devicetree/bindings/input/touchscreen/exc3000.yaml
+++ b/Documentation/devicetree/bindings/input/touchscreen/exc3000.yaml
@@ -14,7 +14,10 @@ allOf:
properties:
compatible:
- const: eeti,exc3000
+ enum:
+ - eeti,exc3000
+ - eeti,exc80h60
+ - eeti,exc80h84
reg:
const: 0x2a
interrupts:
diff --git a/drivers/input/touchscreen/exc3000.c b/drivers/input/touchscreen/exc3000.c
index 555a14305cd4..9622cba514b3 100644
--- a/drivers/input/touchscreen/exc3000.c
+++ b/drivers/input/touchscreen/exc3000.c
@@ -23,11 +23,43 @@
#define EXC3000_SLOTS_PER_FRAME 5
#define EXC3000_LEN_FRAME 66
#define EXC3000_LEN_POINT 10
-#define EXC3000_MT_EVENT 6
+
+#define EXC3000_MT1_EVENT 0x06
+#define EXC3000_MT2_EVENT 0x18
+
#define EXC3000_TIMEOUT_MS 100
+static const struct i2c_device_id exc3000_id[];
+
+struct eeti_dev_info {
+ const char *name;
+ int max_xy;
+};
+
+enum eeti_dev_id {
+ EETI_EXC3000,
+ EETI_EXC80H60,
+ EETI_EXC80H84,
+};
+
+static struct eeti_dev_info exc3000_info[] = {
+ [EETI_EXC3000] = {
+ .name = "EETI EXC3000 Touch Screen",
+ .max_xy = SZ_4K - 1,
+ },
+ [EETI_EXC80H60] = {
+ .name = "EETI EXC80H60 Touch Screen",
+ .max_xy = SZ_16K - 1,
+ },
+ [EETI_EXC80H84] = {
+ .name = "EETI EXC80H84 Touch Screen",
+ .max_xy = SZ_16K - 1,
+ },
+};
+
struct exc3000_data {
struct i2c_client *client;
+ const struct eeti_dev_info *info;
struct input_dev *input;
struct touchscreen_properties prop;
struct timer_list timer;
@@ -58,10 +90,15 @@ static void exc3000_timer(struct timer_list *t)
input_sync(data->input);
}
-static int exc3000_read_frame(struct i2c_client *client, u8 *buf)
+static int exc3000_read_frame(struct exc3000_data *data, u8 *buf)
{
+ struct i2c_client *client = data->client;
+ u8 expected_event = EXC3000_MT1_EVENT;
int ret;
+ if (data->info->max_xy == SZ_16K - 1)
+ expected_event = EXC3000_MT2_EVENT;
+
ret = i2c_master_send(client, "'", 2);
if (ret < 0)
return ret;
@@ -76,19 +113,21 @@ static int exc3000_read_frame(struct i2c_client *client, u8 *buf)
if (ret != EXC3000_LEN_FRAME)
return -EIO;
- if (get_unaligned_le16(buf) != EXC3000_LEN_FRAME ||
- buf[2] != EXC3000_MT_EVENT)
+ if (get_unaligned_le16(buf) != EXC3000_LEN_FRAME)
+ return -EINVAL;
+
+ if (buf[2] != expected_event)
return -EINVAL;
return 0;
}
-static int exc3000_read_data(struct i2c_client *client,
+static int exc3000_read_data(struct exc3000_data *data,
u8 *buf, int *n_slots)
{
int error;
- error = exc3000_read_frame(client, buf);
+ error = exc3000_read_frame(data, buf);
if (error)
return error;
@@ -98,7 +137,7 @@ static int exc3000_read_data(struct i2c_client *client,
if (*n_slots > EXC3000_SLOTS_PER_FRAME) {
/* Read 2nd frame to get the rest of the contacts. */
- error = exc3000_read_frame(client, buf + EXC3000_LEN_FRAME);
+ error = exc3000_read_frame(data, buf + EXC3000_LEN_FRAME);
if (error)
return error;
@@ -118,7 +157,7 @@ static irqreturn_t exc3000_interrupt(int irq, void *dev_id)
int slots, total_slots;
int error;
- error = exc3000_read_data(data->client, buf, &total_slots);
+ error = exc3000_read_data(data, buf, &total_slots);
if (error) {
/* Schedule a timer to release "stuck" contacts */
mod_timer(&data->timer,
@@ -149,13 +188,19 @@ static int exc3000_probe(struct i2c_client *client)
{
struct exc3000_data *data;
struct input_dev *input;
- int error;
+ int error, max_xy;
data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL);
if (!data)
return -ENOMEM;
data->client = client;
+ data->info = device_get_match_data(&client->dev);
+ if (!data->info) {
+ enum eeti_dev_id eeti_dev_id =
+ i2c_match_id(exc3000_id, client)->driver_data;
+ data->info = &exc3000_info[eeti_dev_id];
+ }
timer_setup(&data->timer, exc3000_timer, 0);
input = devm_input_allocate_device(&client->dev);
@@ -164,11 +209,13 @@ static int exc3000_probe(struct i2c_client *client)
data->input = input;
- input->name = "EETI EXC3000 Touch Screen";
+ input->name = data->info->name;
input->id.bustype = BUS_I2C;
- input_set_abs_params(input, ABS_MT_POSITION_X, 0, 4095, 0, 0);
- input_set_abs_params(input, ABS_MT_POSITION_Y, 0, 4095, 0, 0);
+ max_xy = data->info->max_xy;
+ input_set_abs_params(input, ABS_MT_POSITION_X, 0, max_xy, 0, 0);
+ input_set_abs_params(input, ABS_MT_POSITION_Y, 0, max_xy, 0, 0);
+
touchscreen_parse_properties(input, true, &data->prop);
error = input_mt_init_slots(input, EXC3000_NUM_SLOTS,
@@ -190,14 +237,18 @@ static int exc3000_probe(struct i2c_client *client)
}
static const struct i2c_device_id exc3000_id[] = {
- { "exc3000", 0 },
+ { "exc3000", EETI_EXC3000 },
+ { "exc80h60", EETI_EXC80H60 },
+ { "exc80h84", EETI_EXC80H84 },
{ }
};
MODULE_DEVICE_TABLE(i2c, exc3000_id);
#ifdef CONFIG_OF
static const struct of_device_id exc3000_of_match[] = {
- { .compatible = "eeti,exc3000" },
+ { .compatible = "eeti,exc3000", .data = &exc3000_info[EETI_EXC3000] },
+ { .compatible = "eeti,exc80h60", .data = &exc3000_info[EETI_EXC80H60] },
+ { .compatible = "eeti,exc80h84", .data = &exc3000_info[EETI_EXC80H84] },
{ }
};
MODULE_DEVICE_TABLE(of, exc3000_of_match);
--
2.26.2
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCHv2 3/5] Input: EXC3000: add EXC80H60 and EXC80H84 support
2020-05-19 18:24 ` [PATCHv2 3/5] Input: EXC3000: add EXC80H60 and EXC80H84 support Sebastian Reichel
@ 2020-05-19 23:52 ` kbuild test robot
0 siblings, 0 replies; 12+ messages in thread
From: kbuild test robot @ 2020-05-19 23:52 UTC (permalink / raw)
To: Sebastian Reichel, Dmitry Torokhov, Ahmet Inan, Martin Fuzzey
Cc: kbuild-all, linux-input, linux-kernel, kernel, Sebastian Reichel
[-- Attachment #1: Type: text/plain, Size: 6716 bytes --]
Hi Sebastian,
I love your patch! Perhaps something to improve:
[auto build test WARNING on input/next]
[also build test WARNING on v5.7-rc6 next-20200519]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Sebastian-Reichel/EXC3000-Updates/20200520-023207
base: https://git.kernel.org/pub/scm/linux/kernel/git/dtor/input.git next
config: openrisc-randconfig-r024-20200519 (attached as .config)
compiler: or1k-linux-gcc (GCC) 9.3.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=openrisc
If you fix the issue, kindly add following tag as appropriate
Reported-by: kbuild test robot <lkp@intel.com>
All warnings (new ones prefixed by >>, old ones prefixed by <<):
drivers/input/touchscreen/exc3000.c:48:13: error: 'SZ_4K' undeclared here (not in a function)
48 | .max_xy = SZ_4K - 1,
| ^~~~~
drivers/input/touchscreen/exc3000.c:52:13: error: 'SZ_16K' undeclared here (not in a function)
52 | .max_xy = SZ_16K - 1,
| ^~~~~~
In file included from arch/openrisc/include/asm/bitops.h:25,
from include/linux/bitops.h:29,
from drivers/input/touchscreen/exc3000.c:10:
drivers/input/touchscreen/exc3000.c: In function 'exc3000_read_frame':
drivers/input/touchscreen/exc3000.c:99:25: warning: comparison between pointer and integer
99 | if (data->info->max_xy == SZ_16K - 1)
| ^~
include/linux/compiler.h:58:52: note: in definition of macro '__trace_if_var'
58 | #define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) : __trace_if_value(cond))
| ^~~~
>> drivers/input/touchscreen/exc3000.c:99:2: note: in expansion of macro 'if'
99 | if (data->info->max_xy == SZ_16K - 1)
| ^~
drivers/input/touchscreen/exc3000.c:99:25: warning: comparison between pointer and integer
99 | if (data->info->max_xy == SZ_16K - 1)
| ^~
include/linux/compiler.h:58:61: note: in definition of macro '__trace_if_var'
58 | #define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) : __trace_if_value(cond))
| ^~~~
>> drivers/input/touchscreen/exc3000.c:99:2: note: in expansion of macro 'if'
99 | if (data->info->max_xy == SZ_16K - 1)
| ^~
drivers/input/touchscreen/exc3000.c:99:25: warning: comparison between pointer and integer
99 | if (data->info->max_xy == SZ_16K - 1)
| ^~
include/linux/compiler.h:69:3: note: in definition of macro '__trace_if_value'
69 | (cond) ? | ^~~~
include/linux/compiler.h:56:28: note: in expansion of macro '__trace_if_var'
56 | #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
| ^~~~~~~~~~~~~~
>> drivers/input/touchscreen/exc3000.c:99:2: note: in expansion of macro 'if'
99 | if (data->info->max_xy == SZ_16K - 1)
| ^~
vim +/if +99 drivers/input/touchscreen/exc3000.c
> 10 #include <linux/bitops.h>
11 #include <linux/device.h>
12 #include <linux/i2c.h>
13 #include <linux/input.h>
14 #include <linux/input/mt.h>
15 #include <linux/input/touchscreen.h>
16 #include <linux/interrupt.h>
17 #include <linux/module.h>
18 #include <linux/of.h>
19 #include <linux/timer.h>
20 #include <asm/unaligned.h>
21
22 #define EXC3000_NUM_SLOTS 10
23 #define EXC3000_SLOTS_PER_FRAME 5
24 #define EXC3000_LEN_FRAME 66
25 #define EXC3000_LEN_POINT 10
26
27 #define EXC3000_MT1_EVENT 0x06
28 #define EXC3000_MT2_EVENT 0x18
29
30 #define EXC3000_TIMEOUT_MS 100
31
32 static const struct i2c_device_id exc3000_id[];
33
34 struct eeti_dev_info {
35 const char *name;
36 int max_xy;
37 };
38
39 enum eeti_dev_id {
40 EETI_EXC3000,
41 EETI_EXC80H60,
42 EETI_EXC80H84,
43 };
44
45 static struct eeti_dev_info exc3000_info[] = {
46 [EETI_EXC3000] = {
47 .name = "EETI EXC3000 Touch Screen",
48 .max_xy = SZ_4K - 1,
49 },
50 [EETI_EXC80H60] = {
51 .name = "EETI EXC80H60 Touch Screen",
52 .max_xy = SZ_16K - 1,
53 },
54 [EETI_EXC80H84] = {
55 .name = "EETI EXC80H84 Touch Screen",
56 .max_xy = SZ_16K - 1,
57 },
58 };
59
60 struct exc3000_data {
61 struct i2c_client *client;
62 const struct eeti_dev_info *info;
63 struct input_dev *input;
64 struct touchscreen_properties prop;
65 struct timer_list timer;
66 u8 buf[2 * EXC3000_LEN_FRAME];
67 };
68
69 static void exc3000_report_slots(struct input_dev *input,
70 struct touchscreen_properties *prop,
71 const u8 *buf, int num)
72 {
73 for (; num--; buf += EXC3000_LEN_POINT) {
74 if (buf[0] & BIT(0)) {
75 input_mt_slot(input, buf[1]);
76 input_mt_report_slot_state(input, MT_TOOL_FINGER, true);
77 touchscreen_report_pos(input, prop,
78 get_unaligned_le16(buf + 2),
79 get_unaligned_le16(buf + 4),
80 true);
81 }
82 }
83 }
84
85 static void exc3000_timer(struct timer_list *t)
86 {
87 struct exc3000_data *data = from_timer(data, t, timer);
88
89 input_mt_sync_frame(data->input);
90 input_sync(data->input);
91 }
92
93 static int exc3000_read_frame(struct exc3000_data *data, u8 *buf)
94 {
95 struct i2c_client *client = data->client;
96 u8 expected_event = EXC3000_MT1_EVENT;
97 int ret;
98
> 99 if (data->info->max_xy == SZ_16K - 1)
100 expected_event = EXC3000_MT2_EVENT;
101
102 ret = i2c_master_send(client, "'", 2);
103 if (ret < 0)
104 return ret;
105
106 if (ret != 2)
107 return -EIO;
108
109 ret = i2c_master_recv(client, buf, EXC3000_LEN_FRAME);
110 if (ret < 0)
111 return ret;
112
113 if (ret != EXC3000_LEN_FRAME)
114 return -EIO;
115
116 if (get_unaligned_le16(buf) != EXC3000_LEN_FRAME)
117 return -EINVAL;
118
119 if (buf[2] != expected_event)
120 return -EINVAL;
121
122 return 0;
123 }
124
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 30104 bytes --]
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCHv2 4/5] Input: EXC3000: Add support to query model and fw_version
2020-05-19 18:24 [PATCHv2 0/5] EXC3000 Updates Sebastian Reichel
` (2 preceding siblings ...)
2020-05-19 18:24 ` [PATCHv2 3/5] Input: EXC3000: add EXC80H60 and EXC80H84 support Sebastian Reichel
@ 2020-05-19 18:24 ` Sebastian Reichel
2020-05-19 21:12 ` Enric Balletbo i Serra
2020-05-20 4:38 ` kbuild test robot
2020-05-19 18:24 ` [PATCHv2 5/5] Input: EXC3000: Add reset gpio support Sebastian Reichel
4 siblings, 2 replies; 12+ messages in thread
From: Sebastian Reichel @ 2020-05-19 18:24 UTC (permalink / raw)
To: Dmitry Torokhov, Ahmet Inan, Martin Fuzzey
Cc: linux-input, linux-kernel, kernel, Sebastian Reichel
Expose model and fw_version via sysfs. Also query the model
in probe to make sure, that the I2C communication with the
device works before successfully probing the driver.
This is a bit complicated, since EETI devices do not have
a sync interface. Sending the commands and directly reading
does not work. Sending the command and waiting for some time
is also not an option, since there might be touch events in
the mean time.
Last but not least we do not cache the results, since this
interface can be used to check the I2C communication is still
working as expected.
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
---
drivers/input/touchscreen/exc3000.c | 138 +++++++++++++++++++++++++++-
1 file changed, 137 insertions(+), 1 deletion(-)
diff --git a/drivers/input/touchscreen/exc3000.c b/drivers/input/touchscreen/exc3000.c
index 9622cba514b3..1ae758bbf627 100644
--- a/drivers/input/touchscreen/exc3000.c
+++ b/drivers/input/touchscreen/exc3000.c
@@ -24,6 +24,9 @@
#define EXC3000_LEN_FRAME 66
#define EXC3000_LEN_POINT 10
+#define EXC3000_LEN_MODEL_NAME 16
+#define EXC3000_LEN_FW_VERSION 16
+
#define EXC3000_MT1_EVENT 0x06
#define EXC3000_MT2_EVENT 0x18
@@ -64,6 +67,11 @@ struct exc3000_data {
struct touchscreen_properties prop;
struct timer_list timer;
u8 buf[2 * EXC3000_LEN_FRAME];
+ struct completion wait_event;
+ struct mutex query_lock;
+ int query_result;
+ char model[EXC3000_LEN_MODEL_NAME];
+ char fw_version[EXC3000_LEN_FW_VERSION];
};
static void exc3000_report_slots(struct input_dev *input,
@@ -149,6 +157,28 @@ static int exc3000_read_data(struct exc3000_data *data,
return 0;
}
+static int exc3000_query_interrupt(struct exc3000_data *data)
+{
+ u8 *buf = data->buf;
+ int err;
+
+ err = i2c_master_recv(data->client, buf, EXC3000_LEN_FRAME);
+ if (err < 0)
+ return err;
+
+ if (buf[0] != 0x42)
+ return -EPROTO;
+
+ if (buf[4] == 'E')
+ strlcpy(data->model, buf+5, sizeof(data->model));
+ else if (buf[4] == 'D')
+ strlcpy(data->fw_version, buf+5, sizeof(data->fw_version));
+ else
+ return -EPROTO;
+
+ return 0;
+}
+
static irqreturn_t exc3000_interrupt(int irq, void *dev_id)
{
struct exc3000_data *data = dev_id;
@@ -157,6 +187,12 @@ static irqreturn_t exc3000_interrupt(int irq, void *dev_id)
int slots, total_slots;
int error;
+ if (mutex_is_locked(&data->query_lock)) {
+ data->query_result = exc3000_query_interrupt(data);
+ complete(&data->wait_event);
+ goto out;
+ }
+
error = exc3000_read_data(data, buf, &total_slots);
if (error) {
/* Schedule a timer to release "stuck" contacts */
@@ -184,11 +220,94 @@ static irqreturn_t exc3000_interrupt(int irq, void *dev_id)
return IRQ_HANDLED;
}
+static int fw_version_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct exc3000_data *data = dev_get_drvdata(dev);
+ static const u8 request[68] = {
+ 0x67, 0x00, 0x42, 0x00, 0x03, 0x01, 'D', 0x00
+ };
+ struct i2c_client *client = data->client;
+ int err;
+
+ mutex_lock(&data->query_lock);
+
+ data->query_result = -ETIMEDOUT;
+ reinit_completion(&data->wait_event);
+
+ err = i2c_master_send(client, request, sizeof(request));
+ if (err < 0) {
+ mutex_unlock(&data->query_lock);
+ return err;
+ }
+
+ wait_for_completion_interruptible_timeout(&data->wait_event, 1*HZ);
+ mutex_unlock(&data->query_lock);
+
+ if (data->query_result < 0)
+ return data->query_result;
+
+ return sprintf(buf, "%s\n", data->fw_version);
+}
+static DEVICE_ATTR_RO(fw_version);
+
+static ssize_t exc3000_get_model(struct exc3000_data *data)
+{
+ static const u8 request[68] = {
+ 0x67, 0x00, 0x42, 0x00, 0x03, 0x01, 'E', 0x00
+ };
+ struct i2c_client *client = data->client;
+ int err;
+
+ mutex_lock(&data->query_lock);
+ data->query_result = -ETIMEDOUT;
+ reinit_completion(&data->wait_event);
+
+ err = i2c_master_send(client, request, sizeof(request));
+ if (err < 0) {
+ mutex_unlock(&data->query_lock);
+ return err;
+ }
+
+ wait_for_completion_interruptible_timeout(&data->wait_event, 1 * HZ);
+ mutex_unlock(&data->query_lock);
+
+ return data->query_result;
+}
+
+static ssize_t model_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct exc3000_data *data = dev_get_drvdata(dev);
+ int err = exc3000_get_model(data);
+
+ if (err < 0)
+ return err;
+
+ return sprintf(buf, "%s\n", data->model);
+}
+static DEVICE_ATTR_RO(model);
+
+static struct attribute *sysfs_attrs[] = {
+ &dev_attr_fw_version.attr,
+ &dev_attr_model.attr,
+ NULL
+};
+
+static struct attribute_group exc3000_attribute_group = {
+ .attrs = sysfs_attrs
+};
+
+static const struct attribute_group *exc3000_attribute_groups[] = {
+ &exc3000_attribute_group,
+ NULL
+};
+
static int exc3000_probe(struct i2c_client *client)
{
struct exc3000_data *data;
struct input_dev *input;
- int error, max_xy;
+ int error, max_xy, retry;
data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL);
if (!data)
@@ -202,15 +321,19 @@ static int exc3000_probe(struct i2c_client *client)
data->info = &exc3000_info[eeti_dev_id];
}
timer_setup(&data->timer, exc3000_timer, 0);
+ init_completion(&data->wait_event);
+ mutex_init(&data->query_lock);
input = devm_input_allocate_device(&client->dev);
if (!input)
return -ENOMEM;
data->input = input;
+ input_set_drvdata(input, data);
input->name = data->info->name;
input->id.bustype = BUS_I2C;
+ input->dev.groups = exc3000_attribute_groups;
max_xy = data->info->max_xy;
input_set_abs_params(input, ABS_MT_POSITION_X, 0, max_xy, 0, 0);
@@ -233,6 +356,19 @@ static int exc3000_probe(struct i2c_client *client)
if (error)
return error;
+ for (retry = 0; retry < 3; ++retry) {
+ error = exc3000_get_model(data);
+ if (!error)
+ break;
+ dev_warn(&client->dev, "Retry %d get EETI EXC3000 model: %d\n",
+ retry + 1, error);
+ }
+
+ if (error)
+ return error;
+
+ dev_dbg(&client->dev, "TS Model: %s", data->model);
+
return 0;
}
--
2.26.2
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCHv2 4/5] Input: EXC3000: Add support to query model and fw_version
2020-05-19 18:24 ` [PATCHv2 4/5] Input: EXC3000: Add support to query model and fw_version Sebastian Reichel
@ 2020-05-19 21:12 ` Enric Balletbo i Serra
2020-05-19 21:31 ` Sebastian Reichel
2020-05-20 4:38 ` kbuild test robot
1 sibling, 1 reply; 12+ messages in thread
From: Enric Balletbo i Serra @ 2020-05-19 21:12 UTC (permalink / raw)
To: Sebastian Reichel, Dmitry Torokhov, Ahmet Inan, Martin Fuzzey
Cc: linux-input, linux-kernel, kernel
Hi Sebastian,
On 19/5/20 20:24, Sebastian Reichel wrote:
> Expose model and fw_version via sysfs. Also query the model
> in probe to make sure, that the I2C communication with the
> device works before successfully probing the driver.
>
> This is a bit complicated, since EETI devices do not have
> a sync interface. Sending the commands and directly reading
> does not work. Sending the command and waiting for some time
> is also not an option, since there might be touch events in
> the mean time.
>
> Last but not least we do not cache the results, since this
> interface can be used to check the I2C communication is still
> working as expected.
>
> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
> ---
> drivers/input/touchscreen/exc3000.c | 138 +++++++++++++++++++++++++++-
> 1 file changed, 137 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/input/touchscreen/exc3000.c b/drivers/input/touchscreen/exc3000.c
> index 9622cba514b3..1ae758bbf627 100644
> --- a/drivers/input/touchscreen/exc3000.c
> +++ b/drivers/input/touchscreen/exc3000.c
> @@ -24,6 +24,9 @@
> #define EXC3000_LEN_FRAME 66
> #define EXC3000_LEN_POINT 10
>
> +#define EXC3000_LEN_MODEL_NAME 16
> +#define EXC3000_LEN_FW_VERSION 16
> +
> #define EXC3000_MT1_EVENT 0x06
> #define EXC3000_MT2_EVENT 0x18
>
> @@ -64,6 +67,11 @@ struct exc3000_data {
> struct touchscreen_properties prop;
> struct timer_list timer;
> u8 buf[2 * EXC3000_LEN_FRAME];
> + struct completion wait_event;
> + struct mutex query_lock;
> + int query_result;
> + char model[EXC3000_LEN_MODEL_NAME];
> + char fw_version[EXC3000_LEN_FW_VERSION];
> };
>
> static void exc3000_report_slots(struct input_dev *input,
> @@ -149,6 +157,28 @@ static int exc3000_read_data(struct exc3000_data *data,
> return 0;
> }
>
> +static int exc3000_query_interrupt(struct exc3000_data *data)
> +{
> + u8 *buf = data->buf;
> + int err;
> +
> + err = i2c_master_recv(data->client, buf, EXC3000_LEN_FRAME);
> + if (err < 0)
> + return err;
> +
> + if (buf[0] != 0x42)
> + return -EPROTO;
> +
> + if (buf[4] == 'E')
> + strlcpy(data->model, buf+5, sizeof(data->model));
> + else if (buf[4] == 'D')
> + strlcpy(data->fw_version, buf+5, sizeof(data->fw_version));
> + else
> + return -EPROTO;
> +
> + return 0;
> +}
> +
> static irqreturn_t exc3000_interrupt(int irq, void *dev_id)
> {
> struct exc3000_data *data = dev_id;
> @@ -157,6 +187,12 @@ static irqreturn_t exc3000_interrupt(int irq, void *dev_id)
> int slots, total_slots;
> int error;
>
> + if (mutex_is_locked(&data->query_lock)) {
> + data->query_result = exc3000_query_interrupt(data);
> + complete(&data->wait_event);
> + goto out;
> + }
> +
> error = exc3000_read_data(data, buf, &total_slots);
> if (error) {
> /* Schedule a timer to release "stuck" contacts */
> @@ -184,11 +220,94 @@ static irqreturn_t exc3000_interrupt(int irq, void *dev_id)
> return IRQ_HANDLED;
> }
>
> +static int fw_version_show(struct device *dev,
> + struct device_attribute *attr, char *buf)
> +{
> + struct exc3000_data *data = dev_get_drvdata(dev);
> + static const u8 request[68] = {
> + 0x67, 0x00, 0x42, 0x00, 0x03, 0x01, 'D', 0x00
> + };
> + struct i2c_client *client = data->client;
> + int err;
> +
> + mutex_lock(&data->query_lock);
> +
> + data->query_result = -ETIMEDOUT;
> + reinit_completion(&data->wait_event);
> +
> + err = i2c_master_send(client, request, sizeof(request));
> + if (err < 0) {
> + mutex_unlock(&data->query_lock);
> + return err;
> + }
> +
> + wait_for_completion_interruptible_timeout(&data->wait_event, 1*HZ);
> + mutex_unlock(&data->query_lock);
> +
> + if (data->query_result < 0)
> + return data->query_result;
> +
> + return sprintf(buf, "%s\n", data->fw_version);
> +}
> +static DEVICE_ATTR_RO(fw_version);
> +
You should probably document the new sysfs entries, although are self-explanatory.
> +static ssize_t exc3000_get_model(struct exc3000_data *data)
> +{
> + static const u8 request[68] = {
> + 0x67, 0x00, 0x42, 0x00, 0x03, 0x01, 'E', 0x00
> + };
> + struct i2c_client *client = data->client;
> + int err;
> +
> + mutex_lock(&data->query_lock);
> + data->query_result = -ETIMEDOUT;
> + reinit_completion(&data->wait_event);
> +
> + err = i2c_master_send(client, request, sizeof(request));
> + if (err < 0) {
> + mutex_unlock(&data->query_lock);
> + return err;
> + }
> +
> + wait_for_completion_interruptible_timeout(&data->wait_event, 1 * HZ);
> + mutex_unlock(&data->query_lock);
> +
> + return data->query_result;
> +}
> +
> +static ssize_t model_show(struct device *dev,
> + struct device_attribute *attr, char *buf)
> +{
> + struct exc3000_data *data = dev_get_drvdata(dev);
> + int err = exc3000_get_model(data);
> +
> + if (err < 0)
> + return err;
> +
> + return sprintf(buf, "%s\n", data->model);
> +}
> +static DEVICE_ATTR_RO(model);
> +
> +static struct attribute *sysfs_attrs[] = {
> + &dev_attr_fw_version.attr,
> + &dev_attr_model.attr,
> + NULL
> +};
> +
> +static struct attribute_group exc3000_attribute_group = {
> + .attrs = sysfs_attrs
> +};
> +
> +static const struct attribute_group *exc3000_attribute_groups[] = {
> + &exc3000_attribute_group,
> + NULL
> +};
> +
> static int exc3000_probe(struct i2c_client *client)
> {
> struct exc3000_data *data;
> struct input_dev *input;
> - int error, max_xy;
> + int error, max_xy, retry;
>
> data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL);
> if (!data)
> @@ -202,15 +321,19 @@ static int exc3000_probe(struct i2c_client *client)
> data->info = &exc3000_info[eeti_dev_id];
> }
> timer_setup(&data->timer, exc3000_timer, 0);
> + init_completion(&data->wait_event);
> + mutex_init(&data->query_lock);
>
> input = devm_input_allocate_device(&client->dev);
> if (!input)
> return -ENOMEM;
>
> data->input = input;
> + input_set_drvdata(input, data);
>
> input->name = data->info->name;
> input->id.bustype = BUS_I2C;
> + input->dev.groups = exc3000_attribute_groups;
>
> max_xy = data->info->max_xy;
> input_set_abs_params(input, ABS_MT_POSITION_X, 0, max_xy, 0, 0);
> @@ -233,6 +356,19 @@ static int exc3000_probe(struct i2c_client *client)
> if (error)
> return error;
>
> + for (retry = 0; retry < 3; ++retry) {
Just curious, is it known to fail and need retries?
> + error = exc3000_get_model(data);
> + if (!error)
> + break;
> + dev_warn(&client->dev, "Retry %d get EETI EXC3000 model: %d\n",
> + retry + 1, error);
> + }
> +
> + if (error)
> + return error;
> +
> + dev_dbg(&client->dev, "TS Model: %s", data->model);
> +
> return 0;
> }
>
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCHv2 4/5] Input: EXC3000: Add support to query model and fw_version
2020-05-19 21:12 ` Enric Balletbo i Serra
@ 2020-05-19 21:31 ` Sebastian Reichel
0 siblings, 0 replies; 12+ messages in thread
From: Sebastian Reichel @ 2020-05-19 21:31 UTC (permalink / raw)
To: Enric Balletbo i Serra
Cc: Dmitry Torokhov, Ahmet Inan, Martin Fuzzey, linux-input,
linux-kernel, kernel
[-- Attachment #1: Type: text/plain, Size: 7753 bytes --]
Hi,
On Tue, May 19, 2020 at 11:12:16PM +0200, Enric Balletbo i Serra wrote:
> On 19/5/20 20:24, Sebastian Reichel wrote:
> > Expose model and fw_version via sysfs. Also query the model
> > in probe to make sure, that the I2C communication with the
> > device works before successfully probing the driver.
> >
> > This is a bit complicated, since EETI devices do not have
> > a sync interface. Sending the commands and directly reading
> > does not work. Sending the command and waiting for some time
> > is also not an option, since there might be touch events in
> > the mean time.
> >
> > Last but not least we do not cache the results, since this
> > interface can be used to check the I2C communication is still
> > working as expected.
> >
> > Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
> > ---
> > drivers/input/touchscreen/exc3000.c | 138 +++++++++++++++++++++++++++-
> > 1 file changed, 137 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/input/touchscreen/exc3000.c b/drivers/input/touchscreen/exc3000.c
> > index 9622cba514b3..1ae758bbf627 100644
> > --- a/drivers/input/touchscreen/exc3000.c
> > +++ b/drivers/input/touchscreen/exc3000.c
> > @@ -24,6 +24,9 @@
> > #define EXC3000_LEN_FRAME 66
> > #define EXC3000_LEN_POINT 10
> >
> > +#define EXC3000_LEN_MODEL_NAME 16
> > +#define EXC3000_LEN_FW_VERSION 16
> > +
> > #define EXC3000_MT1_EVENT 0x06
> > #define EXC3000_MT2_EVENT 0x18
> >
> > @@ -64,6 +67,11 @@ struct exc3000_data {
> > struct touchscreen_properties prop;
> > struct timer_list timer;
> > u8 buf[2 * EXC3000_LEN_FRAME];
> > + struct completion wait_event;
> > + struct mutex query_lock;
> > + int query_result;
> > + char model[EXC3000_LEN_MODEL_NAME];
> > + char fw_version[EXC3000_LEN_FW_VERSION];
> > };
> >
> > static void exc3000_report_slots(struct input_dev *input,
> > @@ -149,6 +157,28 @@ static int exc3000_read_data(struct exc3000_data *data,
> > return 0;
> > }
> >
> > +static int exc3000_query_interrupt(struct exc3000_data *data)
> > +{
> > + u8 *buf = data->buf;
> > + int err;
> > +
> > + err = i2c_master_recv(data->client, buf, EXC3000_LEN_FRAME);
> > + if (err < 0)
> > + return err;
> > +
> > + if (buf[0] != 0x42)
> > + return -EPROTO;
> > +
> > + if (buf[4] == 'E')
> > + strlcpy(data->model, buf+5, sizeof(data->model));
> > + else if (buf[4] == 'D')
> > + strlcpy(data->fw_version, buf+5, sizeof(data->fw_version));
> > + else
> > + return -EPROTO;
> > +
> > + return 0;
> > +}
> > +
> > static irqreturn_t exc3000_interrupt(int irq, void *dev_id)
> > {
> > struct exc3000_data *data = dev_id;
> > @@ -157,6 +187,12 @@ static irqreturn_t exc3000_interrupt(int irq, void *dev_id)
> > int slots, total_slots;
> > int error;
> >
> > + if (mutex_is_locked(&data->query_lock)) {
> > + data->query_result = exc3000_query_interrupt(data);
> > + complete(&data->wait_event);
> > + goto out;
> > + }
> > +
> > error = exc3000_read_data(data, buf, &total_slots);
> > if (error) {
> > /* Schedule a timer to release "stuck" contacts */
> > @@ -184,11 +220,94 @@ static irqreturn_t exc3000_interrupt(int irq, void *dev_id)
> > return IRQ_HANDLED;
> > }
> >
> > +static int fw_version_show(struct device *dev,
> > + struct device_attribute *attr, char *buf)
> > +{
> > + struct exc3000_data *data = dev_get_drvdata(dev);
> > + static const u8 request[68] = {
> > + 0x67, 0x00, 0x42, 0x00, 0x03, 0x01, 'D', 0x00
> > + };
> > + struct i2c_client *client = data->client;
> > + int err;
> > +
> > + mutex_lock(&data->query_lock);
> > +
> > + data->query_result = -ETIMEDOUT;
> > + reinit_completion(&data->wait_event);
> > +
> > + err = i2c_master_send(client, request, sizeof(request));
> > + if (err < 0) {
> > + mutex_unlock(&data->query_lock);
> > + return err;
> > + }
> > +
> > + wait_for_completion_interruptible_timeout(&data->wait_event, 1*HZ);
> > + mutex_unlock(&data->query_lock);
> > +
> > + if (data->query_result < 0)
> > + return data->query_result;
> > +
> > + return sprintf(buf, "%s\n", data->fw_version);
> > +}
> > +static DEVICE_ATTR_RO(fw_version);
> > +
>
> You should probably document the new sysfs entries, although are
> self-explanatory.
I suppose I could create
Documentation/ABI/testing/sysfs-driver-input-exc3000 or is there a
better place for sysfs API documentation of input devices?
> > +static ssize_t exc3000_get_model(struct exc3000_data *data)
> > +{
> > + static const u8 request[68] = {
> > + 0x67, 0x00, 0x42, 0x00, 0x03, 0x01, 'E', 0x00
> > + };
> > + struct i2c_client *client = data->client;
> > + int err;
> > +
> > + mutex_lock(&data->query_lock);
> > + data->query_result = -ETIMEDOUT;
> > + reinit_completion(&data->wait_event);
> > +
> > + err = i2c_master_send(client, request, sizeof(request));
> > + if (err < 0) {
> > + mutex_unlock(&data->query_lock);
> > + return err;
> > + }
> > +
> > + wait_for_completion_interruptible_timeout(&data->wait_event, 1 * HZ);
> > + mutex_unlock(&data->query_lock);
> > +
> > + return data->query_result;
> > +}
> > +
> > +static ssize_t model_show(struct device *dev,
> > + struct device_attribute *attr, char *buf)
> > +{
> > + struct exc3000_data *data = dev_get_drvdata(dev);
> > + int err = exc3000_get_model(data);
> > +
> > + if (err < 0)
> > + return err;
> > +
> > + return sprintf(buf, "%s\n", data->model);
> > +}
> > +static DEVICE_ATTR_RO(model);
> > +
> > +static struct attribute *sysfs_attrs[] = {
> > + &dev_attr_fw_version.attr,
> > + &dev_attr_model.attr,
> > + NULL
> > +};
> > +
> > +static struct attribute_group exc3000_attribute_group = {
> > + .attrs = sysfs_attrs
> > +};
> > +
> > +static const struct attribute_group *exc3000_attribute_groups[] = {
> > + &exc3000_attribute_group,
> > + NULL
> > +};
> > +
> > static int exc3000_probe(struct i2c_client *client)
> > {
> > struct exc3000_data *data;
> > struct input_dev *input;
> > - int error, max_xy;
> > + int error, max_xy, retry;
> >
> > data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL);
> > if (!data)
> > @@ -202,15 +321,19 @@ static int exc3000_probe(struct i2c_client *client)
> > data->info = &exc3000_info[eeti_dev_id];
> > }
> > timer_setup(&data->timer, exc3000_timer, 0);
> > + init_completion(&data->wait_event);
> > + mutex_init(&data->query_lock);
> >
> > input = devm_input_allocate_device(&client->dev);
> > if (!input)
> > return -ENOMEM;
> >
> > data->input = input;
> > + input_set_drvdata(input, data);
> >
> > input->name = data->info->name;
> > input->id.bustype = BUS_I2C;
> > + input->dev.groups = exc3000_attribute_groups;
> >
> > max_xy = data->info->max_xy;
> > input_set_abs_params(input, ABS_MT_POSITION_X, 0, max_xy, 0, 0);
> > @@ -233,6 +356,19 @@ static int exc3000_probe(struct i2c_client *client)
> > if (error)
> > return error;
> >
> > + for (retry = 0; retry < 3; ++retry) {
>
> Just curious, is it known to fail and need retries?
No, but a single I²C transmission can always go bad and in that case
it makes sense to recover instead of failing to load the driver. Other
buses (e.g. PCI) handle this transparently, but I²C does not.
-- Sebastian
>
> > + error = exc3000_get_model(data);
> > + if (!error)
> > + break;
> > + dev_warn(&client->dev, "Retry %d get EETI EXC3000 model: %d\n",
> > + retry + 1, error);
> > + }
> > +
> > + if (error)
> > + return error;
> > +
> > + dev_dbg(&client->dev, "TS Model: %s", data->model);
> > +
> > return 0;
> > }
> >
> >
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCHv2 4/5] Input: EXC3000: Add support to query model and fw_version
2020-05-19 18:24 ` [PATCHv2 4/5] Input: EXC3000: Add support to query model and fw_version Sebastian Reichel
2020-05-19 21:12 ` Enric Balletbo i Serra
@ 2020-05-20 4:38 ` kbuild test robot
1 sibling, 0 replies; 12+ messages in thread
From: kbuild test robot @ 2020-05-20 4:38 UTC (permalink / raw)
To: Sebastian Reichel, Dmitry Torokhov, Ahmet Inan, Martin Fuzzey
Cc: kbuild-all, linux-input, linux-kernel, kernel, Sebastian Reichel
[-- Attachment #1: Type: text/plain, Size: 3628 bytes --]
Hi Sebastian,
I love your patch! Yet something to improve:
[auto build test ERROR on input/next]
[also build test ERROR on v5.7-rc6 next-20200519]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Sebastian-Reichel/EXC3000-Updates/20200520-023207
base: https://git.kernel.org/pub/scm/linux/kernel/git/dtor/input.git next
config: ia64-randconfig-r023-20200519 (attached as .config)
compiler: ia64-linux-gcc (GCC) 9.3.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=ia64
If you fix the issue, kindly add following tag as appropriate
Reported-by: kbuild test robot <lkp@intel.com>
All error/warnings (new ones prefixed by >>, old ones prefixed by <<):
In file included from include/linux/kobject.h:20,
from include/linux/device.h:17,
from drivers/input/touchscreen/exc3000.c:11:
>> drivers/input/touchscreen/exc3000.c:252:23: error: initialization of 'ssize_t (*)(struct device *, struct device_attribute *, char *)' {aka 'long int (*)(struct device *, struct device_attribute *, char *)'} from incompatible pointer type 'int (*)(struct device *, struct device_attribute *, char *)' [-Werror=incompatible-pointer-types]
252 | static DEVICE_ATTR_RO(fw_version);
| ^~~~~~~~~~
include/linux/sysfs.h:117:10: note: in definition of macro '__ATTR_RO'
117 | .show = _name##_show, | ^~~~~
>> drivers/input/touchscreen/exc3000.c:252:8: note: in expansion of macro 'DEVICE_ATTR_RO'
252 | static DEVICE_ATTR_RO(fw_version);
| ^~~~~~~~~~~~~~
drivers/input/touchscreen/exc3000.c:252:23: note: (near initialization for 'dev_attr_fw_version.show')
252 | static DEVICE_ATTR_RO(fw_version);
| ^~~~~~~~~~
include/linux/sysfs.h:117:10: note: in definition of macro '__ATTR_RO'
117 | .show = _name##_show, | ^~~~~
>> drivers/input/touchscreen/exc3000.c:252:8: note: in expansion of macro 'DEVICE_ATTR_RO'
252 | static DEVICE_ATTR_RO(fw_version);
| ^~~~~~~~~~~~~~
cc1: some warnings being treated as errors
vim +252 drivers/input/touchscreen/exc3000.c
222
223 static int fw_version_show(struct device *dev,
224 struct device_attribute *attr, char *buf)
225 {
226 struct exc3000_data *data = dev_get_drvdata(dev);
227 static const u8 request[68] = {
228 0x67, 0x00, 0x42, 0x00, 0x03, 0x01, 'D', 0x00
229 };
230 struct i2c_client *client = data->client;
231 int err;
232
233 mutex_lock(&data->query_lock);
234
235 data->query_result = -ETIMEDOUT;
236 reinit_completion(&data->wait_event);
237
238 err = i2c_master_send(client, request, sizeof(request));
239 if (err < 0) {
240 mutex_unlock(&data->query_lock);
241 return err;
242 }
243
244 wait_for_completion_interruptible_timeout(&data->wait_event, 1*HZ);
245 mutex_unlock(&data->query_lock);
246
247 if (data->query_result < 0)
248 return data->query_result;
249
250 return sprintf(buf, "%s\n", data->fw_version);
251 }
> 252 static DEVICE_ATTR_RO(fw_version);
253
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 36838 bytes --]
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCHv2 5/5] Input: EXC3000: Add reset gpio support
2020-05-19 18:24 [PATCHv2 0/5] EXC3000 Updates Sebastian Reichel
` (3 preceding siblings ...)
2020-05-19 18:24 ` [PATCHv2 4/5] Input: EXC3000: Add support to query model and fw_version Sebastian Reichel
@ 2020-05-19 18:24 ` Sebastian Reichel
2020-05-19 20:57 ` Enric Balletbo i Serra
4 siblings, 1 reply; 12+ messages in thread
From: Sebastian Reichel @ 2020-05-19 18:24 UTC (permalink / raw)
To: Dmitry Torokhov, Ahmet Inan, Martin Fuzzey
Cc: linux-input, linux-kernel, kernel, Sebastian Reichel
Add basic support for an optional reset gpio.
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
---
.../bindings/input/touchscreen/exc3000.yaml | 2 ++
drivers/input/touchscreen/exc3000.c | 29 +++++++++++++++----
2 files changed, 25 insertions(+), 6 deletions(-)
diff --git a/Documentation/devicetree/bindings/input/touchscreen/exc3000.yaml b/Documentation/devicetree/bindings/input/touchscreen/exc3000.yaml
index d83b61e884df..8b70b918c7ca 100644
--- a/Documentation/devicetree/bindings/input/touchscreen/exc3000.yaml
+++ b/Documentation/devicetree/bindings/input/touchscreen/exc3000.yaml
@@ -22,6 +22,8 @@ properties:
const: 0x2a
interrupts:
maxItems: 1
+ reset-gpios:
+ maxItems: 1
touchscreen-size-x: true
touchscreen-size-y: true
touchscreen-inverted-x: true
diff --git a/drivers/input/touchscreen/exc3000.c b/drivers/input/touchscreen/exc3000.c
index 1ae758bbf627..9fed66ef1719 100644
--- a/drivers/input/touchscreen/exc3000.c
+++ b/drivers/input/touchscreen/exc3000.c
@@ -8,7 +8,9 @@
*/
#include <linux/bitops.h>
+#include <linux/delay.h>
#include <linux/device.h>
+#include <linux/gpio/consumer.h>
#include <linux/i2c.h>
#include <linux/input.h>
#include <linux/input/mt.h>
@@ -32,6 +34,9 @@
#define EXC3000_TIMEOUT_MS 100
+#define EXC3000_RESET_MS 10
+#define EXC3000_READY_MS 100
+
static const struct i2c_device_id exc3000_id[];
struct eeti_dev_info {
@@ -65,6 +70,7 @@ struct exc3000_data {
const struct eeti_dev_info *info;
struct input_dev *input;
struct touchscreen_properties prop;
+ struct gpio_desc *reset;
struct timer_list timer;
u8 buf[2 * EXC3000_LEN_FRAME];
struct completion wait_event;
@@ -305,16 +311,17 @@ static const struct attribute_group *exc3000_attribute_groups[] = {
static int exc3000_probe(struct i2c_client *client)
{
+ struct device *dev = &client->dev;
struct exc3000_data *data;
struct input_dev *input;
int error, max_xy, retry;
- data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL);
+ data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
if (!data)
return -ENOMEM;
data->client = client;
- data->info = device_get_match_data(&client->dev);
+ data->info = device_get_match_data(dev);
if (!data->info) {
enum eeti_dev_id eeti_dev_id =
i2c_match_id(exc3000_id, client)->driver_data;
@@ -324,7 +331,17 @@ static int exc3000_probe(struct i2c_client *client)
init_completion(&data->wait_event);
mutex_init(&data->query_lock);
- input = devm_input_allocate_device(&client->dev);
+ data->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
+ if (IS_ERR(data->reset))
+ return PTR_ERR(data->reset);
+
+ if (data->reset) {
+ msleep(EXC3000_RESET_MS);
+ gpiod_set_value_cansleep(data->reset, 0);
+ msleep(EXC3000_READY_MS);
+ }
+
+ input = devm_input_allocate_device(dev);
if (!input)
return -ENOMEM;
@@ -350,7 +367,7 @@ static int exc3000_probe(struct i2c_client *client)
if (error)
return error;
- error = devm_request_threaded_irq(&client->dev, client->irq,
+ error = devm_request_threaded_irq(dev, client->irq,
NULL, exc3000_interrupt, IRQF_ONESHOT,
client->name, data);
if (error)
@@ -360,14 +377,14 @@ static int exc3000_probe(struct i2c_client *client)
error = exc3000_get_model(data);
if (!error)
break;
- dev_warn(&client->dev, "Retry %d get EETI EXC3000 model: %d\n",
+ dev_warn(dev, "Retry %d get EETI EXC3000 model: %d\n",
retry + 1, error);
}
if (error)
return error;
- dev_dbg(&client->dev, "TS Model: %s", data->model);
+ dev_dbg(dev, "TS Model: %s", data->model);
return 0;
}
--
2.26.2
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCHv2 5/5] Input: EXC3000: Add reset gpio support
2020-05-19 18:24 ` [PATCHv2 5/5] Input: EXC3000: Add reset gpio support Sebastian Reichel
@ 2020-05-19 20:57 ` Enric Balletbo i Serra
0 siblings, 0 replies; 12+ messages in thread
From: Enric Balletbo i Serra @ 2020-05-19 20:57 UTC (permalink / raw)
To: Sebastian Reichel, Dmitry Torokhov, Ahmet Inan, Martin Fuzzey
Cc: linux-input, linux-kernel, kernel
Hi Sebastian,
Again a minor thing
On 19/5/20 20:24, Sebastian Reichel wrote:
> Add basic support for an optional reset gpio.
>
> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
> ---
> .../bindings/input/touchscreen/exc3000.yaml | 2 ++
> drivers/input/touchscreen/exc3000.c | 29 +++++++++++++++----
> 2 files changed, 25 insertions(+), 6 deletions(-)
>
> diff --git a/Documentation/devicetree/bindings/input/touchscreen/exc3000.yaml b/Documentation/devicetree/bindings/input/touchscreen/exc3000.yaml
> index d83b61e884df..8b70b918c7ca 100644
> --- a/Documentation/devicetree/bindings/input/touchscreen/exc3000.yaml
> +++ b/Documentation/devicetree/bindings/input/touchscreen/exc3000.yaml
> @@ -22,6 +22,8 @@ properties:
> const: 0x2a
> interrupts:
> maxItems: 1
> + reset-gpios:
> + maxItems: 1
> touchscreen-size-x: true
> touchscreen-size-y: true
> touchscreen-inverted-x: true
> diff --git a/drivers/input/touchscreen/exc3000.c b/drivers/input/touchscreen/exc3000.c
> index 1ae758bbf627..9fed66ef1719 100644
> --- a/drivers/input/touchscreen/exc3000.c
> +++ b/drivers/input/touchscreen/exc3000.c
> @@ -8,7 +8,9 @@
> */
>
> #include <linux/bitops.h>
> +#include <linux/delay.h>
> #include <linux/device.h>
> +#include <linux/gpio/consumer.h>
> #include <linux/i2c.h>
> #include <linux/input.h>
> #include <linux/input/mt.h>
> @@ -32,6 +34,9 @@
>
> #define EXC3000_TIMEOUT_MS 100
>
> +#define EXC3000_RESET_MS 10
> +#define EXC3000_READY_MS 100
> +
> static const struct i2c_device_id exc3000_id[];
>
> struct eeti_dev_info {
> @@ -65,6 +70,7 @@ struct exc3000_data {
> const struct eeti_dev_info *info;
> struct input_dev *input;
> struct touchscreen_properties prop;
> + struct gpio_desc *reset;
> struct timer_list timer;
> u8 buf[2 * EXC3000_LEN_FRAME];
> struct completion wait_event;
> @@ -305,16 +311,17 @@ static const struct attribute_group *exc3000_attribute_groups[] = {
>
> static int exc3000_probe(struct i2c_client *client)
> {
> + struct device *dev = &client->dev;
This introduces more changes to the patch than the required. Is not that I am
against of this change but since what you are doing here is introduce an
optional reset I think would be better just introduce that change.
> struct exc3000_data *data;
> struct input_dev *input;
> int error, max_xy, retry;
>
> - data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL);
> + data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
> if (!data)
> return -ENOMEM;
>
> data->client = client;
> - data->info = device_get_match_data(&client->dev);
> + data->info = device_get_match_data(dev);
> if (!data->info) {
> enum eeti_dev_id eeti_dev_id =
> i2c_match_id(exc3000_id, client)->driver_data;
> @@ -324,7 +331,17 @@ static int exc3000_probe(struct i2c_client *client)
> init_completion(&data->wait_event);
> mutex_init(&data->query_lock);
>
> - input = devm_input_allocate_device(&client->dev);
> + data->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
nit: Just use &client->dev here ?
> + if (IS_ERR(data->reset))
> + return PTR_ERR(data->reset);
> +
> + if (data->reset) {
> + msleep(EXC3000_RESET_MS);
> + gpiod_set_value_cansleep(data->reset, 0);
> + msleep(EXC3000_READY_MS);
> + }
> +
> + input = devm_input_allocate_device(dev);
> if (!input)
> return -ENOMEM;
>
> @@ -350,7 +367,7 @@ static int exc3000_probe(struct i2c_client *client)
> if (error)
> return error;
>
> - error = devm_request_threaded_irq(&client->dev, client->irq,
> + error = devm_request_threaded_irq(dev, client->irq,
> NULL, exc3000_interrupt, IRQF_ONESHOT,
> client->name, data);
> if (error)
> @@ -360,14 +377,14 @@ static int exc3000_probe(struct i2c_client *client)
> error = exc3000_get_model(data);
> if (!error)
> break;
> - dev_warn(&client->dev, "Retry %d get EETI EXC3000 model: %d\n",
> + dev_warn(dev, "Retry %d get EETI EXC3000 model: %d\n",
> retry + 1, error);
> }
>
> if (error)
> return error;
>
> - dev_dbg(&client->dev, "TS Model: %s", data->model);
> + dev_dbg(dev, "TS Model: %s", data->model);
>
> return 0;
> }
>
^ permalink raw reply [flat|nested] 12+ messages in thread