From patchwork Fri Aug 30 14:04:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 824486 Received: from mail-lj1-f174.google.com (mail-lj1-f174.google.com [209.85.208.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1E3651B2EC0 for ; Fri, 30 Aug 2024 14:04:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725026679; cv=none; b=UZe3ZgD2FXomEm0RnlmPwEkpMLFoNjyPuShGOKJjn9vLtfc4DD4z9elx0UcHlHNWrC4Zqun4ZTMOA1iDrx+3rWI0j4Zx29ytJNhyj9SDj4Pfk1rjwegKB2+qfSUMIoMMBJEMm2NdT+a9aX+fIhmf7BgT/4QzedBTJd2PWr9zNYQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725026679; c=relaxed/simple; bh=LjFHjn+Y7YtRnQVaacjI7LDbGXTKAI3Ki3bx4k66SbE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=j3QuW4n9tEgdxE3ejnUoL7XsczMOh+3OAGu5a98jSFgyVyjovLikUXW/C1sVjRWpWo4zQSIAuIzig1kNsOX2vMG4r77XZRqv4FyVL4hWSv/5q/amx1a8IKvU4inEWPtSnVk8AvxkmgSKkxBi3b3kcUJaBx4A1hnxE58xF83R+QA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=qmMF0kl2; arc=none smtp.client-ip=209.85.208.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="qmMF0kl2" Received: by mail-lj1-f174.google.com with SMTP id 38308e7fff4ca-2f3f90295a9so21269231fa.0 for ; Fri, 30 Aug 2024 07:04:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1725026675; x=1725631475; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=bldFDzJUn/k2Bt8f74T3d+f2wRvuEAT5t+HNQ8xZJH8=; b=qmMF0kl2f5kgPfx4zlizp9UFRgxOjyBeD+9XojGZDsA2EsVQ1AAN6b0f5xpva0Q2FH AUqGhIkt1y5MwhNpsgPpn+LR75zGGFS8b8k5tnQW8LSG7QBhhwHztOJ1B9Et/VIiEqg9 0iBAvSyZqi5MGTt/mj1eva7CrlgF7tma5UfQQIbSaJvpgPXKL5xFxfijr6/QvzryBbiP AdbbL05rX5PQSDi0RZsbhBEs/Cd2jiaWR6Ywt8n4lD/xLQoQvJ7KCPksTrqNlFFbZ35+ T1ZBPVApuXl0QRs6KeNsmAgSi1ygihBP3OoL9hymvt7T5EGv737viji8rklnF/EmDRPz mTIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725026675; x=1725631475; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bldFDzJUn/k2Bt8f74T3d+f2wRvuEAT5t+HNQ8xZJH8=; b=E3BIjAL5USWHtUXPhHp0yhOPVg6nJyj1DHMaQ3KSik2CHmJqaKvljvHU3yLeHA512e foLhZRamTmXSmC99m228XcA9jxSBmOmlYQHz5zCltM2sBgkucmxxWcnDUC663FmE5MvM 5pShryD2mWR8GOzTwua9RM6kOnT5Ji3FtO0XEqJGbIsKI8fEoWPSg2zuaBurnr6ffGqV 4JdxdZ3zO8FfUwGQxt/4lbgHenEFSVVa6hDCiwG+YZtarKFPGHBfntH/p8GMQzdey7CW N6xMn7MmoBvShHTmHu7/SXy3RuKKa0C08F+bZ7NWEsoGKGPMTfvZLgj5Ny4yh9lSevhk UZjQ== X-Gm-Message-State: AOJu0YyJu3Bs5mTLnlFPR3gNmFXIb7YzJIHrUceN5qCjGvuSBY/gQYyX G4RsLJmeatf3vfCcy3/pIAPYggo8j27NIHhQ65wPMMtZ8gFcgvQVyr8ldshwMu4= X-Google-Smtp-Source: AGHT+IHv5mXRP97AwaUJFidIZZ86IhE1DwuNQ1qw4H4asZOp7h2/u9+in9unkHyTtSVIKvgypJwSiA== X-Received: by 2002:a05:6512:694:b0:52c:a016:5405 with SMTP id 2adb3069b0e04-53546aef3e9mr1912932e87.8.1725026674334; Fri, 30 Aug 2024 07:04:34 -0700 (PDT) Received: from Fecusia.lan (c-21d3225c.014-348-6c756e10.bbcust.telenor.se. [92.34.211.33]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5354084118dsm616826e87.217.2024.08.30.07.04.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Aug 2024 07:04:34 -0700 (PDT) From: Linus Walleij Date: Fri, 30 Aug 2024 16:04:27 +0200 Subject: [PATCH v2 1/2] Input: zinitix - Read and cache device version numbers Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240830-zinitix-tk-versions-v2-1-90eae6817eda@linaro.org> References: <20240830-zinitix-tk-versions-v2-0-90eae6817eda@linaro.org> In-Reply-To: <20240830-zinitix-tk-versions-v2-0-90eae6817eda@linaro.org> To: Dmitry Torokhov , Nikita Travkin Cc: linux-input@vger.kernel.org, Linus Walleij X-Mailer: b4 0.12.4 The chip hardware revision, firmware version and regdata revision is needed to discern because for example touchkeys are handled by different registers on different versions of the chip. Example output from BT404: Zinitix-TS 3-0020: chip revision 4040 firmware version 0088 regdata version 0004 Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Move read status into the per-device struct. --- drivers/input/touchscreen/zinitix.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/drivers/input/touchscreen/zinitix.c b/drivers/input/touchscreen/zinitix.c index 1df93c96f6bf..e47e0bff80db 100644 --- a/drivers/input/touchscreen/zinitix.c +++ b/drivers/input/touchscreen/zinitix.c @@ -150,6 +150,10 @@ struct bt541_ts_data { u32 zinitix_mode; u32 keycodes[MAX_SUPPORTED_BUTTON_NUM]; int num_keycodes; + bool read_versioninfo; + u16 chip_revision; + u16 firmware_version; + u16 regdata_version; }; static int zinitix_read_data(struct i2c_client *client, @@ -194,6 +198,18 @@ static int zinitix_write_cmd(struct i2c_client *client, u16 reg) return 0; } +static u16 zinitix_get_u16_reg(struct bt541_ts_data *bt541, u16 vreg) +{ + struct i2c_client *client = bt541->client; + int error; + __le16 val; + + error = zinitix_read_data(client, vreg, (void *)&val, 2); + if (error) + return U8_MAX; + return le16_to_cpu(val); +} + static int zinitix_init_touch(struct bt541_ts_data *bt541) { struct i2c_client *client = bt541->client; @@ -207,6 +223,24 @@ static int zinitix_init_touch(struct bt541_ts_data *bt541) return error; } + /* + * Read and cache the chip revision and firmware version the first time + * we get here. + */ + if (!bt541->read_versioninfo) { + bt541->chip_revision = zinitix_get_u16_reg(bt541, + ZINITIX_CHIP_REVISION); + bt541->firmware_version = zinitix_get_u16_reg(bt541, + ZINITIX_FIRMWARE_VERSION); + bt541->regdata_version = zinitix_get_u16_reg(bt541, + ZINITIX_DATA_VERSION_REG); + dev_dbg(&client->dev, + "chip revision %04x firmware version %04x regdata version %04x\n", + bt541->chip_revision, bt541->firmware_version, + bt541->regdata_version); + bt541->read_versioninfo = true; + } + error = zinitix_write_u16(client, ZINITIX_INT_ENABLE_FLAG, 0x0); if (error) { dev_err(&client->dev, From patchwork Fri Aug 30 14:04:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 824485 Received: from mail-lf1-f54.google.com (mail-lf1-f54.google.com [209.85.167.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6D6861B1D79 for ; Fri, 30 Aug 2024 14:04:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725026680; cv=none; b=US0QJrV4L7T0S/6e77AkMtGGcZgOLT63tZJDKkKMDDhi3fSlvR6yBwBkHchfYtnBVZa2HumxTx9JRnWnZm8tiDV/DFOtDGRi9WgPeLh2xSgxCdEZp5Q3IshO7fzEzg5aT1XqPCWCE2SbTJznVei2nnMJ/X41gFVyqqrFgdWLpCM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725026680; c=relaxed/simple; bh=bUSAlReA5HCO5Hbs+U36cEM1lcuyKt/jW8z+UxbrTMI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=kHXNQWjLEGegi1f0teiIdOxfL+UyflBe73+C1NhSoHLmHUnnAe6iGhKZOUKAdHftJoj1FzVgVZf7rIB8brgDH5D0Zuw/Z5bmXe78ak/Jj0uty3GNhNQ+3SIB79Q7l0TTM++ZXYQczW0/laCSELGNUAFc0j5zRkriAPqiWbTRcrc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=NgDB6If4; arc=none smtp.client-ip=209.85.167.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="NgDB6If4" Received: by mail-lf1-f54.google.com with SMTP id 2adb3069b0e04-5353cd2fa28so2427985e87.3 for ; Fri, 30 Aug 2024 07:04:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1725026676; x=1725631476; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=fwZj4nHmi3YA+XCByv/flCbspNw18pXfJDWZvmz0uO4=; b=NgDB6If43opF6F+tD6QppqTMw5IqP9Vj5FqlPHEw5XojmFi2Uk6NxSd15mAxfn8mvc As7EqQAM/F8m4LUn9UecrZOzcAb7+GpYDbPbCvzkk2RdS9/YXnRBKLxclR9htLCuNsNz ZNuxVs8WA8/bPGVW2t3CrhbdduuAnwzHbTCRG4E47eg0h/dbsgjDtZiUsPbQ26x5a+AI oBUf+GSkSQ0UlSTarU+SPYeek63oxj+R+ZimNhZCALrAxU3OyI9bZZ+MLB9Wh1INdbPe SBtPMlww/6nXJNi1Vq/SrE/C7ZWjeWFLKhQ2hgVW1OkiKGHktLT0BGm+SpP2qUmYY5o4 +UnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725026676; x=1725631476; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fwZj4nHmi3YA+XCByv/flCbspNw18pXfJDWZvmz0uO4=; b=UnIsyj370M9AbAOjenT96n17I8A9Kxb4abXoe9T95ejha4aetzk7Xonpl9NO7aBwFZ ZyT68NwiPnlcX4ST+PtT7tqI0F8AhX34XQbLq3unjdlEAJEdbSBwPR7+m5Ay2pxytwHc medtpDW86J0tGgy1P8gM87jw6GFrspLYeNWbH27I8OTqPbDUPu4p6jemR7t/Nt3lB59d GGkETmRt59YazHUQ4mm2IPuGPlomMKuYJ0TgmUDHXDvtAh8N1E7h0RDxGnyqywVFFiAj NxrPWVbuSO3eI7xazNXgPSJ3f2lwfRjmdJZiP/oOOGLeMRDkOX1uj9Qe7IbGk4HySHO+ dCSw== X-Gm-Message-State: AOJu0YyC5eZTR1kCL4b8sGRd9qoNsQyGUQ1i+l1VGXJTf4UZbh7wgQ7V Znj9CgzoSCGr6ioYkOrQvOiTRRscyPVYS/RJD9d3V/Dr9cq2PuKKEA0rJqMqRyQ= X-Google-Smtp-Source: AGHT+IEIDCCPohsfd6Zso0VznQ3mvvEWhBtIgd633g3IeF9np2aS5n9uDfYEht1/pzwWg6nyrWUH/w== X-Received: by 2002:a05:6512:3e06:b0:52c:dfa0:dca0 with SMTP id 2adb3069b0e04-53546ba0eabmr1464475e87.43.1725026674829; Fri, 30 Aug 2024 07:04:34 -0700 (PDT) Received: from Fecusia.lan (c-21d3225c.014-348-6c756e10.bbcust.telenor.se. [92.34.211.33]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5354084118dsm616826e87.217.2024.08.30.07.04.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Aug 2024 07:04:34 -0700 (PDT) From: Linus Walleij Date: Fri, 30 Aug 2024 16:04:28 +0200 Subject: [PATCH v2 2/2] Input: zinitix - Varying icon status registers Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240830-zinitix-tk-versions-v2-2-90eae6817eda@linaro.org> References: <20240830-zinitix-tk-versions-v2-0-90eae6817eda@linaro.org> In-Reply-To: <20240830-zinitix-tk-versions-v2-0-90eae6817eda@linaro.org> To: Dmitry Torokhov , Nikita Travkin Cc: linux-input@vger.kernel.org, Linus Walleij X-Mailer: b4 0.12.4 The different revisions of the Zinitix BTXXX touchscreens place the icon status register (to read out touchkey status) in different places. Use the chip revision bits to discern between the different versions at runtime. This makes touchkeys work on the BT404 on the Samsung Codina GT-I8160 mobile phone. Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - No changes --- drivers/input/touchscreen/zinitix.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/drivers/input/touchscreen/zinitix.c b/drivers/input/touchscreen/zinitix.c index e47e0bff80db..b6b380f5aed5 100644 --- a/drivers/input/touchscreen/zinitix.c +++ b/drivers/input/touchscreen/zinitix.c @@ -35,7 +35,13 @@ #define ZINITIX_DEBUG_REG 0x0115 /* 0~7 */ #define ZINITIX_TOUCH_MODE 0x0010 + #define ZINITIX_CHIP_REVISION 0x0011 +#define ZINITIX_CHIP_BTX0X_MASK 0xF0F0 +#define ZINITIX_CHIP_BT4X2 0x4020 +#define ZINITIX_CHIP_BT4X3 0x4030 +#define ZINITIX_CHIP_BT4X4 0x4040 + #define ZINITIX_FIRMWARE_VERSION 0x0012 #define ZINITIX_USB_DETECT 0x116 @@ -63,7 +69,11 @@ #define ZINITIX_Y_RESOLUTION 0x00C1 #define ZINITIX_POINT_STATUS_REG 0x0080 -#define ZINITIX_ICON_STATUS_REG 0x00AA + +#define ZINITIX_BT4X2_ICON_STATUS_REG 0x009A +#define ZINITIX_BT4X3_ICON_STATUS_REG 0x00A0 +#define ZINITIX_BT4X4_ICON_STATUS_REG 0x00A0 +#define ZINITIX_BT5XX_ICON_STATUS_REG 0x00AA #define ZINITIX_POINT_COORD_REG (ZINITIX_POINT_STATUS_REG + 2) @@ -425,7 +435,18 @@ static irqreturn_t zinitix_ts_irq_handler(int irq, void *bt541_handler) } if (le16_to_cpu(touch_event.status) & BIT_ICON_EVENT) { - error = zinitix_read_data(bt541->client, ZINITIX_ICON_STATUS_REG, + u16 iconstatus; + + if ((bt541->chip_revision & ZINITIX_CHIP_BTX0X_MASK) == ZINITIX_CHIP_BT4X2) + iconstatus = ZINITIX_BT4X2_ICON_STATUS_REG; + else if ((bt541->chip_revision & ZINITIX_CHIP_BTX0X_MASK) == ZINITIX_CHIP_BT4X3) + iconstatus = ZINITIX_BT4X3_ICON_STATUS_REG; + else if ((bt541->chip_revision & ZINITIX_CHIP_BTX0X_MASK) == ZINITIX_CHIP_BT4X4) + iconstatus = ZINITIX_BT4X4_ICON_STATUS_REG; + else + iconstatus = ZINITIX_BT5XX_ICON_STATUS_REG; + + error = zinitix_read_data(bt541->client, iconstatus, &icon_events, sizeof(icon_events)); if (error) { dev_err(&client->dev, "Failed to read icon events\n");