linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] Add support for Imagis IST3038B
@ 2022-05-04 15:24 Markuss Broks
  2022-05-04 15:24 ` [PATCH 1/3] input/touchscreen: imagis: Correct the maximum touch area value Markuss Broks
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Markuss Broks @ 2022-05-04 15:24 UTC (permalink / raw)
  To: linux-kernel
  Cc: phone-devel, ~postmarketos/upstreaming, Markuss Broks,
	Lin Meng-Bo, Dmitry Torokhov, Rob Herring, Krzysztof Kozlowski,
	Henrik Rydberg, linux-input, devicetree

This series adds support for Imagis IST3038B IC support, which
is a variant of Imagis IST3038 IC. It has a different register map
(labeled protocol b), but otherwise it seems to be the same IC.
It is also possible to support various other Imagis ICs using
protocol b, such as (but not limited to) IST3044B, IST3026, IST3032,
IST3026B, IST3032B. However, most of them (all except IST3044B)
use a different coordinate format, so extra effort would be needed
to support those.

Tested by Lin Meng-Bo on Samsung Galaxy Core Prime.

Cc: Lin Meng-Bo <linmengbo0689@protonmail.com>

Markuss Broks (3):
  input/touchscreen: imagis: Correct the maximum touch area value
  dt-bindings: input/touchscreen: Add compatible for IST3038B
  input/touchscreen: imagis: Add support for Imagis IST3038B

 .../input/touchscreen/imagis,ist3038c.yaml    |  1 +
 drivers/input/touchscreen/imagis.c            | 60 +++++++++++++++----
 2 files changed, 49 insertions(+), 12 deletions(-)

-- 
2.35.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/3] input/touchscreen: imagis: Correct the maximum touch area value
  2022-05-04 15:24 [PATCH 0/3] Add support for Imagis IST3038B Markuss Broks
@ 2022-05-04 15:24 ` Markuss Broks
  2022-05-04 15:24 ` [PATCH 2/3] dt-bindings: input/touchscreen: Add compatible for IST3038B Markuss Broks
  2022-05-04 15:24 ` [PATCH 3/3] input/touchscreen: imagis: Add support for Imagis IST3038B Markuss Broks
  2 siblings, 0 replies; 6+ messages in thread
From: Markuss Broks @ 2022-05-04 15:24 UTC (permalink / raw)
  To: linux-kernel
  Cc: phone-devel, ~postmarketos/upstreaming, Markuss Broks,
	Lin Meng-Bo, Dmitry Torokhov, Rob Herring, Krzysztof Kozlowski,
	Henrik Rydberg, linux-input, devicetree

As specified in downstream IST3038B driver and proved by testing,
the correct maximum reported value of touch area is 16.

Signed-off-by: Markuss Broks <markuss.broks@gmail.com>
---
 drivers/input/touchscreen/imagis.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/input/touchscreen/imagis.c b/drivers/input/touchscreen/imagis.c
index e2697e6c6d2a..b667914a44f1 100644
--- a/drivers/input/touchscreen/imagis.c
+++ b/drivers/input/touchscreen/imagis.c
@@ -210,7 +210,7 @@ static int imagis_init_input_dev(struct imagis_ts *ts)
 
 	input_set_capability(input_dev, EV_ABS, ABS_MT_POSITION_X);
 	input_set_capability(input_dev, EV_ABS, ABS_MT_POSITION_Y);
-	input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0);
+	input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, 16, 0, 0);
 
 	touchscreen_parse_properties(input_dev, true, &ts->prop);
 	if (!ts->prop.max_x || !ts->prop.max_y) {
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/3] dt-bindings: input/touchscreen: Add compatible for IST3038B
  2022-05-04 15:24 [PATCH 0/3] Add support for Imagis IST3038B Markuss Broks
  2022-05-04 15:24 ` [PATCH 1/3] input/touchscreen: imagis: Correct the maximum touch area value Markuss Broks
@ 2022-05-04 15:24 ` Markuss Broks
  2022-05-16 23:58   ` Rob Herring
  2022-05-04 15:24 ` [PATCH 3/3] input/touchscreen: imagis: Add support for Imagis IST3038B Markuss Broks
  2 siblings, 1 reply; 6+ messages in thread
From: Markuss Broks @ 2022-05-04 15:24 UTC (permalink / raw)
  To: linux-kernel
  Cc: phone-devel, ~postmarketos/upstreaming, Markuss Broks,
	Lin Meng-Bo, Dmitry Torokhov, Rob Herring, Krzysztof Kozlowski,
	Henrik Rydberg, linux-input, devicetree

Imagis IST3038B is a variant (firmware?) of Imagis IST3038 IC,
add the compatible for it to the IST3038C bindings.

Signed-off-by: Markuss Broks <markuss.broks@gmail.com>
---
 .../devicetree/bindings/input/touchscreen/imagis,ist3038c.yaml   | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/input/touchscreen/imagis,ist3038c.yaml b/Documentation/devicetree/bindings/input/touchscreen/imagis,ist3038c.yaml
index e3a2b871e50c..a283040cd2aa 100644
--- a/Documentation/devicetree/bindings/input/touchscreen/imagis,ist3038c.yaml
+++ b/Documentation/devicetree/bindings/input/touchscreen/imagis,ist3038c.yaml
@@ -18,6 +18,7 @@ properties:
 
   compatible:
     enum:
+      - imagis,ist3038b
       - imagis,ist3038c
 
   reg:
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/3] input/touchscreen: imagis: Add support for Imagis IST3038B
  2022-05-04 15:24 [PATCH 0/3] Add support for Imagis IST3038B Markuss Broks
  2022-05-04 15:24 ` [PATCH 1/3] input/touchscreen: imagis: Correct the maximum touch area value Markuss Broks
  2022-05-04 15:24 ` [PATCH 2/3] dt-bindings: input/touchscreen: Add compatible for IST3038B Markuss Broks
@ 2022-05-04 15:24 ` Markuss Broks
  2022-05-04 20:30   ` kernel test robot
  2 siblings, 1 reply; 6+ messages in thread
From: Markuss Broks @ 2022-05-04 15:24 UTC (permalink / raw)
  To: linux-kernel
  Cc: phone-devel, ~postmarketos/upstreaming, Markuss Broks,
	Lin Meng-Bo, Dmitry Torokhov, Rob Herring, Krzysztof Kozlowski,
	Henrik Rydberg, linux-input, devicetree

Imagis IST3038B is another variant of Imagis IST3038 IC, which has
a different register interface from IST3038C (possibly firmware defined).
This should also work for IST3044B (though untested), however other
variants using this interface/protocol(IST3026, IST3032, IST3026B,
IST3032B) have a different format for coordinates, and they'd need
additional effort to be supported by this driver.

Signed-off-by: Markuss Broks <markuss.broks@gmail.com>
---
 drivers/input/touchscreen/imagis.c | 58 ++++++++++++++++++++++++------
 1 file changed, 47 insertions(+), 11 deletions(-)

diff --git a/drivers/input/touchscreen/imagis.c b/drivers/input/touchscreen/imagis.c
index b667914a44f1..57bb8f31ac1f 100644
--- a/drivers/input/touchscreen/imagis.c
+++ b/drivers/input/touchscreen/imagis.c
@@ -13,7 +13,7 @@
 
 #define IST3038C_HIB_ACCESS		(0x800B << 16)
 #define IST3038C_DIRECT_ACCESS		BIT(31)
-#define IST3038C_REG_CHIPID		0x40001000
+#define IST3038C_REG_CHIPID		(0x40001000 | IST3038C_DIRECT_ACCESS)
 #define IST3038C_REG_HIB_BASE		0x30000100
 #define IST3038C_REG_TOUCH_STATUS	(IST3038C_REG_HIB_BASE | IST3038C_HIB_ACCESS)
 #define IST3038C_REG_TOUCH_COORD	(IST3038C_REG_HIB_BASE | IST3038C_HIB_ACCESS | 0x8)
@@ -31,8 +31,21 @@
 #define IST3038C_FINGER_COUNT_SHIFT	12
 #define IST3038C_FINGER_STATUS_MASK	GENMASK(9, 0)
 
+#define IST3038B_REG_STATUS		0x20
+#define IST3038B_REG_CHIPID		0x30
+#define IST3038B_WHOAMI			0x30380b
+
+struct imagis_properties {
+	unsigned int interrupt_msg_cmd;
+	unsigned int touch_coord_cmd;
+	unsigned int whoami_cmd;
+	unsigned int whoami_val;
+	bool protocol_b;
+};
+
 struct imagis_ts {
 	struct i2c_client *client;
+	const struct imagis_properties *tdata;
 	struct input_dev *input_dev;
 	struct touchscreen_properties prop;
 	struct regulator_bulk_data supplies[2];
@@ -84,8 +97,7 @@ static irqreturn_t imagis_interrupt(int irq, void *dev_id)
 	int i;
 	int error;
 
-	error = imagis_i2c_read_reg(ts, IST3038C_REG_INTR_MESSAGE,
-				    &intr_message);
+	error = imagis_i2c_read_reg(ts, ts->tdata->interrupt_msg_cmd, &intr_message);
 	if (error) {
 		dev_err(&ts->client->dev,
 			"failed to read the interrupt message: %d\n", error);
@@ -104,9 +116,13 @@ static irqreturn_t imagis_interrupt(int irq, void *dev_id)
 	finger_pressed = intr_message & IST3038C_FINGER_STATUS_MASK;
 
 	for (i = 0; i < finger_count; i++) {
-		error = imagis_i2c_read_reg(ts,
-					    IST3038C_REG_TOUCH_COORD + (i * 4),
-					    &finger_status);
+		if (ts->tdata->protocol_b)
+			error = imagis_i2c_read_reg(ts,
+						    ts->tdata->touch_coord_cmd, &finger_status);
+		else
+			error = imagis_i2c_read_reg(ts,
+						    ts->tdata->touch_coord_cmd + (i * 4),
+						    &finger_status);
 		if (error) {
 			dev_err(&ts->client->dev,
 				"failed to read coordinates for finger %d: %d\n",
@@ -261,6 +277,12 @@ static int imagis_probe(struct i2c_client *i2c)
 
 	ts->client = i2c;
 
+	ts->tdata = device_get_match_data(dev);
+	if (!ts->tdata) {
+		dev_err(dev, "missing chip data\n");
+		return -EINVAL;
+	}
+
 	error = imagis_init_regulators(ts);
 	if (error) {
 		dev_err(dev, "regulator init error: %d\n", error);
@@ -279,15 +301,13 @@ static int imagis_probe(struct i2c_client *i2c)
 		return error;
 	}
 
-	error = imagis_i2c_read_reg(ts,
-			IST3038C_REG_CHIPID | IST3038C_DIRECT_ACCESS,
-			&chip_id);
+	error = imagis_i2c_read_reg(ts, ts->tdata->whoami_cmd, &chip_id);
 	if (error) {
 		dev_err(dev, "chip ID read failure: %d\n", error);
 		return error;
 	}
 
-	if (chip_id != IST3038C_WHOAMI) {
+	if (chip_id != ts->tdata->whoami_val) {
 		dev_err(dev, "unknown chip ID: 0x%x\n", chip_id);
 		return -EINVAL;
 	}
@@ -343,9 +363,25 @@ static int __maybe_unused imagis_resume(struct device *dev)
 
 static SIMPLE_DEV_PM_OPS(imagis_pm_ops, imagis_suspend, imagis_resume);
 
+static const struct imagis_properties imagis_3038b_data = {
+	.interrupt_msg_cmd = IST3038B_REG_STATUS,
+	.touch_coord_cmd = IST3038B_REG_STATUS,
+	.whoami_cmd = IST3038B_REG_CHIPID,
+	.whoami_val = IST3038B_WHOAMI,
+	.protocol_b = true,
+};
+
+static const struct imagis_properties imagis_3038c_data = {
+	.interrupt_msg_cmd = IST3038C_REG_INTR_MESSAGE,
+	.touch_coord_cmd = IST3038C_REG_TOUCH_COORD,
+	.whoami_cmd = IST3038C_REG_CHIPID,
+	.whoami_val = IST3038C_WHOAMI,
+};
+
 #ifdef CONFIG_OF
 static const struct of_device_id imagis_of_match[] = {
-	{ .compatible = "imagis,ist3038c", },
+	{ .compatible = "imagis,ist3038b", .data = &imagis_3038b_data },
+	{ .compatible = "imagis,ist3038c", .data = &imagis_3038c_data },
 	{ },
 };
 MODULE_DEVICE_TABLE(of, imagis_of_match);
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 3/3] input/touchscreen: imagis: Add support for Imagis IST3038B
  2022-05-04 15:24 ` [PATCH 3/3] input/touchscreen: imagis: Add support for Imagis IST3038B Markuss Broks
@ 2022-05-04 20:30   ` kernel test robot
  0 siblings, 0 replies; 6+ messages in thread
From: kernel test robot @ 2022-05-04 20:30 UTC (permalink / raw)
  To: Markuss Broks, linux-kernel
  Cc: llvm, kbuild-all, phone-devel, ~postmarketos/upstreaming,
	Markuss Broks, Lin Meng-Bo, Dmitry Torokhov, Rob Herring,
	Krzysztof Kozlowski, Henrik Rydberg, linux-input, devicetree

Hi Markuss,

I love your patch! Perhaps something to improve:

[auto build test WARNING on dtor-input/next]
[also build test WARNING on linux/master linus/master v5.18-rc5 next-20220504]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/intel-lab-lkp/linux/commits/Markuss-Broks/Add-support-for-Imagis-IST3038B/20220504-232637
base:   https://git.kernel.org/pub/scm/linux/kernel/git/dtor/input.git next
config: hexagon-randconfig-r022-20220502 (https://download.01.org/0day-ci/archive/20220505/202205050459.Cn4Mj5ny-lkp@intel.com/config)
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project 363b3a645a1e30011cc8da624f13dac5fd915628)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/intel-lab-lkp/linux/commit/a22f360f66c82a3bc53d9861a62d2d2e5abe897c
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Markuss-Broks/Add-support-for-Imagis-IST3038B/20220504-232637
        git checkout a22f360f66c82a3bc53d9861a62d2d2e5abe897c
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=hexagon SHELL=/bin/bash drivers/input/touchscreen/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

>> drivers/input/touchscreen/imagis.c:366:39: warning: unused variable 'imagis_3038b_data' [-Wunused-const-variable]
   static const struct imagis_properties imagis_3038b_data = {
                                         ^
>> drivers/input/touchscreen/imagis.c:374:39: warning: unused variable 'imagis_3038c_data' [-Wunused-const-variable]
   static const struct imagis_properties imagis_3038c_data = {
                                         ^
   2 warnings generated.


vim +/imagis_3038b_data +366 drivers/input/touchscreen/imagis.c

   365	
 > 366	static const struct imagis_properties imagis_3038b_data = {
   367		.interrupt_msg_cmd = IST3038B_REG_STATUS,
   368		.touch_coord_cmd = IST3038B_REG_STATUS,
   369		.whoami_cmd = IST3038B_REG_CHIPID,
   370		.whoami_val = IST3038B_WHOAMI,
   371		.protocol_b = true,
   372	};
   373	
 > 374	static const struct imagis_properties imagis_3038c_data = {
   375		.interrupt_msg_cmd = IST3038C_REG_INTR_MESSAGE,
   376		.touch_coord_cmd = IST3038C_REG_TOUCH_COORD,
   377		.whoami_cmd = IST3038C_REG_CHIPID,
   378		.whoami_val = IST3038C_WHOAMI,
   379	};
   380	

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/3] dt-bindings: input/touchscreen: Add compatible for IST3038B
  2022-05-04 15:24 ` [PATCH 2/3] dt-bindings: input/touchscreen: Add compatible for IST3038B Markuss Broks
@ 2022-05-16 23:58   ` Rob Herring
  0 siblings, 0 replies; 6+ messages in thread
From: Rob Herring @ 2022-05-16 23:58 UTC (permalink / raw)
  To: Markuss Broks
  Cc: Henrik Rydberg, phone-devel, linux-input,
	~postmarketos/upstreaming, linux-kernel, devicetree, Rob Herring,
	Lin Meng-Bo, Dmitry Torokhov, Krzysztof Kozlowski

On Wed, 04 May 2022 18:24:04 +0300, Markuss Broks wrote:
> Imagis IST3038B is a variant (firmware?) of Imagis IST3038 IC,
> add the compatible for it to the IST3038C bindings.
> 
> Signed-off-by: Markuss Broks <markuss.broks@gmail.com>
> ---
>  .../devicetree/bindings/input/touchscreen/imagis,ist3038c.yaml   | 1 +
>  1 file changed, 1 insertion(+)
> 

Acked-by: Rob Herring <robh@kernel.org>

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-05-16 23:59 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-04 15:24 [PATCH 0/3] Add support for Imagis IST3038B Markuss Broks
2022-05-04 15:24 ` [PATCH 1/3] input/touchscreen: imagis: Correct the maximum touch area value Markuss Broks
2022-05-04 15:24 ` [PATCH 2/3] dt-bindings: input/touchscreen: Add compatible for IST3038B Markuss Broks
2022-05-16 23:58   ` Rob Herring
2022-05-04 15:24 ` [PATCH 3/3] input/touchscreen: imagis: Add support for Imagis IST3038B Markuss Broks
2022-05-04 20:30   ` kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).