Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp22877lqz; Fri, 29 Mar 2024 07:26:52 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUG1JslcjF2jtPxNheaD7U+USpjcEYonXfsoKCox7A8sdrz4gQbCi6RD0YI40De/5vSxTMgmAOvT9avGxoLsKs+eSFpEmKfJlQXIAu3lg== X-Google-Smtp-Source: AGHT+IEkqonQ0Q+DzugJ1CK/KfJxHy9/495NItHdMzyaywgc15Hq4Goh/nrDiTVNd6hwE6mcPjCj X-Received: by 2002:a50:a44a:0:b0:56c:d47:e403 with SMTP id v10-20020a50a44a000000b0056c0d47e403mr1880961edb.28.1711722412134; Fri, 29 Mar 2024 07:26:52 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711722412; cv=pass; d=google.com; s=arc-20160816; b=wVuFgClcV2rhaG+cvKANUmlTinzmzMPTcMxRCKL0sIHw49+8urFLDDlbRAzsE0YB+6 8cYoVLP3vDAW90wkxgCHDB2RNAbmONtNd5JNXLoQ/AIsp9bdXSgeCfHrd/0WRRmsLeZo 8RzMjpzn+jhoxfvefeAT3MQZRQyD8lpplxCRrMBUtPSz56RFap5BqoSmaKBB+ymvRAz4 1mPRBQf4XIVIKki6aGqh1ah6VmjQX1N5fXFZBrnBmk0fWboVBsZp8qPHUkAif0Mhi1R5 4mk64B979necuko0iY3th7dvQ36WL5sN/GFz1c4yZqtecQm6dQLjnUkoXF48ZjSXz0HY Fh0g== 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=Sscip6yGQ5MnH9oib5xNZyOvTi+AhqPA+Hqv4qxl+VM=; fh=N46RyUGc9UgsFY9qIKywDiZ7J7zlrwPvA/7H9EMqL0w=; b=lgSaR8v/vMjMTstGS45HksnzHBAeMskmmZFWpj8rwWaq9maZtl0G4GBscUN2DxRyET GcWMUpI6yxz1Q5zKTjFWENgauYPU8V9/p0DZ1StH9pVyUtsH4RJ+mu3h+4FhEC7A7sji PjxXBdRh3rYpXyKuwIVuIrrHO5jmD6/2CFSW7h00B3xNz0Fgm11hw9hD4UfBbZq6TDFk Bob3vTnxeqcpLXO8vlT3Rmesu+2N3rD6RnselQXDiUhpebSegqXlBdA4/6o+3Xd8bT5Q KUw1WM6AJGNEXnYVZMQZz7jbQ4WXqJ5Y4OwDNmO0DbDVnZFlX71jKPd4C/TenAjqJ8Lv FeLg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=bH6FnIqL; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-124921-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-124921-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id z3-20020a05640235c300b00568a4212e04si1962534edc.274.2024.03.29.07.26.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 07:26:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-124921-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=@kernel.org header.s=k20201202 header.b=bH6FnIqL; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-124921-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-124921-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 B06341F2BA00 for ; Fri, 29 Mar 2024 14:26:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C4F6736ACC4; Fri, 29 Mar 2024 12:47:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="bH6FnIqL" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 CF95014C599; Fri, 29 Mar 2024 12:47:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711716433; cv=none; b=Hq/Zt7F2dY0o0wkfoAmHwvQqkYxnSu2pCnlIIJIlZJE15BaQTojWMEkZSsc08SCnkVNs+VIenyo3WzMdhrivCZvZAK/aWprqIMxwxAynejz87oEmaGdJkcTAQJT4luQSFtpyn4Ta/ckprQWMpDs1FQ2rtZUkrG9/sGPiEKA8Td4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711716433; c=relaxed/simple; bh=BwvjFoPwdTI38aV9C9+82ru0jfWs63cpyjuUnGNysuY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ufVQAH7woEowJ9vcwh3cDRof5q1MeeGOjzyNEQdp6pIZSPSQ1orFCJbptSwsL7tcm2SJBFZQrJIlkc//A86CkgXsY0kkT/GgipDb231ywoD1xSTi30+bdZx8yXqgcpPgc6Sl+hMdo4HXHcStNH3ga62hoIXJCC15ANKhY38L4GI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=bH6FnIqL; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 992ADC43390; Fri, 29 Mar 2024 12:47:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711716433; bh=BwvjFoPwdTI38aV9C9+82ru0jfWs63cpyjuUnGNysuY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bH6FnIqLwDrp5Qf4kDdZ+D8G0xE8KmzQTSWF16Nw/w4D49fyxG9pM+rAvD4Xt8oDV PPY1aUkUFd+TwDDoFZZxWhzpTBf+ZaLDdKTSDbnxqqeGQLBW5gdDNdARHZZxyHMsM2 KskibOZV0pczt8I3TnncW6joNS4+exwDpUNBkobidD9NvLaXNnYNhnNPI4WG4EbzJM BMkgjF4yRZq4MEMVsSmdStbHvX9Ki0A2e8MJPcjTYpWXsPdKPcSX5wgiJKvmEYu9NY mamit5jHoohwqDK4PYvJmqpNvy0mnd+xpRTX8rIwj7YP0SylWrqZ9dLa3whqmCY6bB ym5akIQX1e5vw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Markuss Broks , Karel Balej , Dmitry Torokhov , Sasha Levin , linux-input@vger.kernel.org Subject: [PATCH AUTOSEL 6.1 37/52] input/touchscreen: imagis: Add support for Imagis IST3038B Date: Fri, 29 Mar 2024 08:45:31 -0400 Message-ID: <20240329124605.3091273-37-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240329124605.3091273-1-sashal@kernel.org> References: <20240329124605.3091273-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.1.83 Content-Transfer-Encoding: 8bit From: Markuss Broks [ Upstream commit 10ad7d7a428f7bb336c3cb226ab8aa0e6a947dac ] 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 Link: https://lore.kernel.org/r/20240301164659.13240-4-karelb@gimli.ms.mff.cuni.cz Signed-off-by: Dmitry Torokhov Signed-off-by: Sasha Levin --- 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 b667914a44f1d..309088eadad21 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 __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.43.0