Received: by 2002:ab2:3141:0:b0:1ed:23cc:44d1 with SMTP id i1csp419785lqg; Fri, 1 Mar 2024 09:02:17 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXrOioNpdfCYMGsFEU0CvU9ZKoQwE2kqifGTAd4iAW+X5zphFatAyr+1g13NiXQT3DruiGIWcu/HjivHTv+PDCybNsfYRN+Lsf0RdHLfg== X-Google-Smtp-Source: AGHT+IGi8Zp7Fg8g+FxivXrT8ga5UEh84txA4TqMu4dTVnYWD/e5PU2ZYpwcbnq7MlfCW3z+aJ+r X-Received: by 2002:a17:906:fa87:b0:a44:8ea2:23fa with SMTP id lt7-20020a170906fa8700b00a448ea223famr1782424ejb.46.1709312528790; Fri, 01 Mar 2024 09:02:08 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709312528; cv=pass; d=google.com; s=arc-20160816; b=wGJhX0ur6jHEODZ79B30llKYh4jUpgxL13N7+1ko7mHnHy5qj8Mq6owyMICh+YV58o ybNXWTap5r2t1VvyP3MAA/bz/Fxie6kmrwB6FENJQDv+ZA/tgSGpUJBQ+vURredKC0Ll fFT1AexYzw/Lb2uVyrEiQF7JwPUc9tX6lLSWEh0M8oNxSPrVvk3ELOk/y8seFoCXWD0Q 1qANgqViNwnGBZTfufUETkGPEHJihccTAviOOSm3T6dBr5PZKzDMWthrTHs5zkpEZ2lb cvYkFeqo9Q3MjZJfcMT6UKizCH+Rz0+bQJZ/Fc5g2Wa/91ZNXyTof1vYqPJ/IZ6/xGKE xSqA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=UIOJbI8z5ZyOMQWDFPQDTypDMqqUoXAjCw3t6tPK0Go=; fh=3dN3s9rK30FPLMWv6b8wsC55ZALaDhhrbsSyCcljd7Q=; b=tmt7yv8CFlHCMZ18MzrW/o3vsVDbVh+SaGEPkVEutMdTKTE/VYYFwI7n5h/riFsKHX kBOugjrs35f0yXTxCMJE79+zPl/JIiAUqHTTSlb5W+kh5q0i4kD3FFVt1OP5drkucHlW hCCujztt5GZrKpG0tSShKz/LPK9sPzBJlIWy/gBJIWaIEnbKsFswUgh1avuiOI0KSeMY hxJlqJaG0DP56BygAJ6JAUdkXuyWSF9KaiNM+ncoWMe8mZV5oW2OPREMc0TraN3oXl8s 2nok7v2iZYQSQAA8xDwdevI/EywBpZpRmRPYsVjDJOmRuBdQ3UJcGIE1UgPZKyG0zqQP ISWA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gimli.ms.mff.cuni.cz header.s=gen1 header.b=IjQhgqn6; arc=pass (i=1 spf=pass spfdomain=gimli.ms.mff.cuni.cz dkim=pass dkdomain=gimli.ms.mff.cuni.cz dmarc=pass fromdomain=gimli.ms.mff.cuni.cz); spf=pass (google.com: domain of linux-kernel+bounces-88773-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88773-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gimli.ms.mff.cuni.cz Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id z26-20020a1709060ada00b00a3f1a6b346csi1603317ejf.311.2024.03.01.09.02.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 09:02:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-88773-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@gimli.ms.mff.cuni.cz header.s=gen1 header.b=IjQhgqn6; arc=pass (i=1 spf=pass spfdomain=gimli.ms.mff.cuni.cz dkim=pass dkdomain=gimli.ms.mff.cuni.cz dmarc=pass fromdomain=gimli.ms.mff.cuni.cz); spf=pass (google.com: domain of linux-kernel+bounces-88773-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88773-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gimli.ms.mff.cuni.cz Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 8DBA91F29081 for ; Fri, 1 Mar 2024 16:56:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 97D5724B2F; Fri, 1 Mar 2024 16:47:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=gimli.ms.mff.cuni.cz header.i=@gimli.ms.mff.cuni.cz header.b="IjQhgqn6" Received: from nikam.ms.mff.cuni.cz (nikam.ms.mff.cuni.cz [195.113.20.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 86990F4E1; Fri, 1 Mar 2024 16:47:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.113.20.16 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709311667; cv=none; b=jGBrT4v4BOvqWpVkM+J1YPmmFmYz/u5sbLOv4PrW4ZVsVRlKXpM5R8KDP0kEDLWdEZ5oJV4YF8qV4aDUlfMHmlDkuDwq+iYlNO6wBOvb2S+3TGef1tCs/cBn6CoJQ3lleTshNSWH+uF+rxenw2dy39J4p8mJNDEskrT/Un0SDJ0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709311667; c=relaxed/simple; bh=K8hTHNxD7+xc0Mc6CH9dFB5iscDhBxHrwGYHo/Go1Yg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CfxMpt/XmQ0PEO3WYxYsioj2OhdVLzOS29b7H/EJliwGeKiB293r2kYirRqiqcDLN4jYSinftahWvIS0Z/wYSX2rt0cIke6RwOpJMKwJOtf5E21e2RG0TQT6mwvbWKTawlY7xm5h3I1FcxBiXOnJKhoVa/16OyKwZHURz3DSnrY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gimli.ms.mff.cuni.cz; spf=pass smtp.mailfrom=gimli.ms.mff.cuni.cz; dkim=pass (1024-bit key) header.d=gimli.ms.mff.cuni.cz header.i=@gimli.ms.mff.cuni.cz header.b=IjQhgqn6; arc=none smtp.client-ip=195.113.20.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gimli.ms.mff.cuni.cz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gimli.ms.mff.cuni.cz Received: from gimli.ms.mff.cuni.cz (gimli.ms.mff.cuni.cz [195.113.20.176]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by nikam.ms.mff.cuni.cz (Postfix) with ESMTPS id 554D6284256; Fri, 1 Mar 2024 17:47:36 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gimli.ms.mff.cuni.cz; s=gen1; t=1709311656; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UIOJbI8z5ZyOMQWDFPQDTypDMqqUoXAjCw3t6tPK0Go=; b=IjQhgqn66urguwESquoCjndFHh1+oDPeuexfly/NYccDG6G8M8qDV6NgaaXTkp05QDSHJT PaZ+PwQ4uFnSCnWeZIM3lIhLG1MprIgmt690RqvXb0kEOgI0Q/reOo8l8UYrCtmcUPW9/q Y1E281nSFVy+t2ugS4RdFnX74m6375I= Received: from localhost (internet5.mraknet.com [185.200.108.250]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (prime256v1) server-signature RSA-PSS (2048 bits) server-digest SHA256) (Client did not present a certificate) (Authenticated sender: karelb) by gimli.ms.mff.cuni.cz (Postfix) with ESMTPSA id 3428A4587C6; Fri, 1 Mar 2024 17:47:36 +0100 (CET) From: Karel Balej To: Markuss Broks , Dmitry Torokhov , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Henrik Rydberg , linux-input@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: =?UTF-8?q?Duje=20Mihanovi=C4=87?= , ~postmarketos/upstreaming@lists.sr.ht, phone-devel@vger.kernel.org, karelb@gimli.ms.mff.cuni.cz Subject: [RESEND PATCH v5 3/5] input/touchscreen: imagis: Add support for Imagis IST3038B Date: Fri, 1 Mar 2024 17:41:02 +0100 Message-ID: <20240301164659.13240-4-karelb@gimli.ms.mff.cuni.cz> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240301164659.13240-1-karelb@gimli.ms.mff.cuni.cz> References: <20240301164659.13240-1-karelb@gimli.ms.mff.cuni.cz> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Markuss Broks 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 Signed-off-by: Karel Balej --- Notes: v4: * Sort the definitions in alphanumerical order. 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 e67fd3011027..9af8a6332ae6 100644 --- a/drivers/input/touchscreen/imagis.c +++ b/drivers/input/touchscreen/imagis.c @@ -11,9 +11,13 @@ #include #include +#define IST3038B_REG_STATUS 0x20 +#define IST3038B_REG_CHIPID 0x30 +#define IST3038B_WHOAMI 0x30380b + #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 +35,17 @@ #define IST3038C_FINGER_COUNT_SHIFT 12 #define IST3038C_FINGER_STATUS_MASK GENMASK(9, 0) +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 imagis_resume(struct device *dev) static DEFINE_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.44.0