From patchwork Sat May 4 02:04:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Kaechele X-Patchwork-Id: 13653769 Received: from mail.kaechele.ca (mail.kaechele.ca [54.39.219.105]) (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 5D4FC7484; Sat, 4 May 2024 02:15:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=54.39.219.105 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714788924; cv=none; b=YOxuKPBqiLlEixyCGus+ZoGT5goP9C+PLmWuU1JDQBzmhAWJBSHIC0rFjp73lVebDfbN9SAoOQFITap5GMU6jA1EYon26oDO7lq9McD68jk/ih/jadB8HVfaUHDSp+wee7CvolpYHKcQT5u8pTLp6sDJPXNDG4DMtbpp7SFaNq4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714788924; c=relaxed/simple; bh=p2TszyFmu2FkHsRRzAxyX9QqovN3gTcmuT+Tg23mkSQ=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DfQOjEVth6WLWrv3phkDdma5bOji+0gyV8k2vrfMD31umhWx34uqA1UmwsZjaOQNjugUNu/DfmvovYS3i83MFO89zmedHlyioLoKe4LLBdgdOwqqZPZbcUx2BglZqD0JJEgDajomoCOMyEjvZYsXvmH9MJFfEq3+7buAnpTlMnA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=kaechele.ca; spf=pass smtp.mailfrom=kaechele.ca; dkim=pass (1024-bit key) header.d=kaechele.ca header.i=@kaechele.ca header.b=Vz3sRLDC; arc=none smtp.client-ip=54.39.219.105 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=kaechele.ca Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kaechele.ca Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=kaechele.ca header.i=@kaechele.ca header.b="Vz3sRLDC" Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 1DC7CC006A; Fri, 3 May 2024 22:08:06 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kaechele.ca; s=201907; t=1714788486; h=from:subject:date:message-id:to:mime-version: content-transfer-encoding:in-reply-to:references; bh=uO4vCIsUirzrH7yn6QZzygawT9UuLKwK+60u/xACvr8=; b=Vz3sRLDCuP6ShnFA89j3+M8pLX9GRZs8qttQTFhg/con9N4mvuHqD1Khi/MWxSOdJEGol4 aQCJupFSQBXLdCZ3e/omrj8DtCKnLSAbSxrrm2LVVzf7IGewzjdvOpaTHVfIZRflD2L7CG wkTK2lXBDQYuH4fw1SdbM597jZLQeN8= From: Felix Kaechele To: Job Noorman , Dmitry Torokhov , Rob Herring , Krzysztof Kozlowski , Conor Dooley , linux-input@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/6] dt-bindings: input: touchscreen: himax,hx83112b: add HX83100A Date: Fri, 3 May 2024 22:04:40 -0400 Message-ID: <20240504020745.68525-2-felix@kaechele.ca> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240504020745.68525-1-felix@kaechele.ca> References: <20240504020745.68525-1-felix@kaechele.ca> Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Last-TLS-Session-Version: TLSv1.3 This adds a compatible string for the Himax HX83100A touch controller including the AVDD and VDD supply nodes used by this chip family. Signed-off-by: Felix Kaechele --- .../bindings/input/touchscreen/himax,hx83112b.yaml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Documentation/devicetree/bindings/input/touchscreen/himax,hx83112b.yaml b/Documentation/devicetree/bindings/input/touchscreen/himax,hx83112b.yaml index f42b23d532eb..5809afedb9a2 100644 --- a/Documentation/devicetree/bindings/input/touchscreen/himax,hx83112b.yaml +++ b/Documentation/devicetree/bindings/input/touchscreen/himax,hx83112b.yaml @@ -15,6 +15,7 @@ allOf: properties: compatible: enum: + - himax,hx83100a - himax,hx83112b reg: @@ -26,6 +27,12 @@ properties: reset-gpios: maxItems: 1 + avdd-supply: + description: Analog power supply regulator + + vdd-supply: + description: Digital power supply regulator + touchscreen-inverted-x: true touchscreen-inverted-y: true touchscreen-size-x: true @@ -54,6 +61,8 @@ examples: reg = <0x48>; interrupt-parent = <&tlmm>; interrupts = <65 IRQ_TYPE_LEVEL_LOW>; + avdd-supply = <&avdd_reg>; + vdd-supply = <&vdd_reg>; touchscreen-size-x = <1080>; touchscreen-size-y = <2160>; reset-gpios = <&tlmm 64 GPIO_ACTIVE_LOW>; From patchwork Sat May 4 02:04:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Kaechele X-Patchwork-Id: 13653767 Received: from mail.kaechele.ca (mail.kaechele.ca [54.39.219.105]) (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 5D4C66AC0; Sat, 4 May 2024 02:15:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=54.39.219.105 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714788923; cv=none; b=D3T6CFhz6ydunx2+hSC9bgoG4nqgAEcoT7uSTRKnCIkqaeF3ww1VP4AXM5DEM94rWc4FxOHai5bTEzwYEaV7SRsmmmhBdFpbQGCRmi8llxVIkg1uI0kRlVmQZ6zKwlKLbLavBNI6XUAJ5silNQMeikKVT5HmQial1m12bRnKvOM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714788923; c=relaxed/simple; bh=xIMubRPsKcK6KDKMCglr9VJplkobSOyIGHpSONrXlIU=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TA1/YDEwEVwawsF7UPogj6X2CB08aCHJRbM6p0VPuuneYOcltRV3ImgYv8/+zMUoYUp+n6UOuYGJB7+o6SKYRpBIBFX88ViarNrA9/MhO10PSqGZmzk1FzXjGkpssL3PuFIhp0ehWi6TQYt1BGPP+3k3JHL6NdJi7U/b/LQ/Pfk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=kaechele.ca; spf=pass smtp.mailfrom=kaechele.ca; dkim=pass (1024-bit key) header.d=kaechele.ca header.i=@kaechele.ca header.b=oFWSmhjR; arc=none smtp.client-ip=54.39.219.105 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=kaechele.ca Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kaechele.ca Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=kaechele.ca header.i=@kaechele.ca header.b="oFWSmhjR" Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 30460C006E; Fri, 3 May 2024 22:08:09 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kaechele.ca; s=201907; t=1714788489; h=from:subject:date:message-id:to:mime-version: content-transfer-encoding:in-reply-to:references; bh=iT3udjGB19kjB5NF7BrwrjkqYtlnB7WlfhROoMGd5BA=; b=oFWSmhjRH++upK+uMJ0WW9cvi74ewzT32BtIulnQ374abgVXVEu9qyXNvw9F807RIKTVU7 p6XO+FxGvXnBFaJuCbow+1Ex4NQvx21HlEmywP+y2hk+Vi5uj9WUv0++tPrgniIu4kNVuD BAHKjqRFI96kxvzujN/aVMpUvsmeO8w= From: Felix Kaechele To: Job Noorman , Dmitry Torokhov , Rob Herring , Krzysztof Kozlowski , Conor Dooley , linux-input@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/6] input: himax_hx83112b: add regulator handling Date: Fri, 3 May 2024 22:04:41 -0400 Message-ID: <20240504020745.68525-3-felix@kaechele.ca> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240504020745.68525-1-felix@kaechele.ca> References: <20240504020745.68525-1-felix@kaechele.ca> Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Last-TLS-Session-Version: TLSv1.3 Handle regulators used on this chip family, namely AVDD and VDD. These definitions are taken from the GPLv2 licensed vendor driver. Signed-off-by: Felix Kaechele Link: https://github.com/HimaxSoftware/HX83112_Android_Driver --- drivers/input/touchscreen/himax_hx83112b.c | 48 ++++++++++++++++++++-- 1 file changed, 44 insertions(+), 4 deletions(-) diff --git a/drivers/input/touchscreen/himax_hx83112b.c b/drivers/input/touchscreen/himax_hx83112b.c index 4f6609dcdef3..0a797789e548 100644 --- a/drivers/input/touchscreen/himax_hx83112b.c +++ b/drivers/input/touchscreen/himax_hx83112b.c @@ -19,10 +19,12 @@ #include #include #include +#include #define HIMAX_ID_83112B 0x83112b #define HIMAX_MAX_POINTS 10 +#define HIMAX_MAX_SUPPLIES 2 #define HIMAX_REG_CFG_SET_ADDR 0x00 #define HIMAX_REG_CFG_INIT_READ 0x0c @@ -50,6 +52,7 @@ struct himax_event { static_assert(sizeof(struct himax_event) == 56); struct himax_ts_data { + struct regulator_bulk_data supplies[HIMAX_MAX_SUPPLIES]; struct gpio_desc *gpiod_rst; struct input_dev *input_dev; struct i2c_client *client; @@ -63,6 +66,11 @@ static const struct regmap_config himax_regmap_config = { .val_format_endian = REGMAP_ENDIAN_LITTLE, }; +static const char *const himax_supply_names[] = { + "avdd", + "vdd", +}; + static int himax_read_config(struct himax_ts_data *ts, u32 address, u32 *dst) { int error; @@ -267,7 +275,7 @@ static irqreturn_t himax_irq_handler(int irq, void *dev_id) static int himax_probe(struct i2c_client *client) { - int error; + int error, i; struct device *dev = &client->dev; struct himax_ts_data *ts; @@ -290,11 +298,31 @@ static int himax_probe(struct i2c_client *client) return error; } + int num_supplies = ARRAY_SIZE(himax_supply_names); + + for (i = 0; i < num_supplies; i++) + ts->supplies[i].supply = himax_supply_names[i]; + + error = devm_regulator_bulk_get(dev, + num_supplies, + ts->supplies); + if (error) { + dev_err(dev, "Failed to get supplies: %d\n", error); + return error; + } + + error = regulator_bulk_enable(num_supplies, + ts->supplies); + if (error) { + dev_err(dev, "Failed to enable supplies: %d\n", error); + goto error_out; + } + ts->gpiod_rst = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH); error = PTR_ERR_OR_ZERO(ts->gpiod_rst); if (error) { dev_err(dev, "Failed to get reset GPIO: %d\n", error); - return error; + goto error_out; } himax_reset(ts); @@ -305,15 +333,26 @@ static int himax_probe(struct i2c_client *client) error = himax_input_register(ts); if (error) - return error; + goto error_out; error = devm_request_threaded_irq(dev, client->irq, NULL, himax_irq_handler, IRQF_ONESHOT, client->name, ts); if (error) - return error; + goto error_out; return 0; + +error_out: + regulator_bulk_disable(num_supplies, ts->supplies); + return error; +} + +static void himax_remove(struct i2c_client *client) +{ + struct himax_ts_data *ts = i2c_get_clientdata(client); + + regulator_bulk_disable(ARRAY_SIZE(himax_supply_names), ts->supplies); } static int himax_suspend(struct device *dev) @@ -350,6 +389,7 @@ MODULE_DEVICE_TABLE(of, himax_of_match); static struct i2c_driver himax_ts_driver = { .probe = himax_probe, + .remove = himax_remove, .id_table = himax_ts_id, .driver = { .name = "Himax-hx83112b-TS", From patchwork Sat May 4 02:04:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Kaechele X-Patchwork-Id: 13653770 Received: from mail.kaechele.ca (mail.kaechele.ca [54.39.219.105]) (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 5D52B8F6D; Sat, 4 May 2024 02:15:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=54.39.219.105 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714788924; cv=none; b=ft9qNMbFJqh2pcODVrsH8f91gSshPsrHt2eWWi5dc64zrbq1j/e3dESqbKLQhYTLfeCrU4N/uZo/mzNREiHFhHLjxwxNHeATNZKY0vjZ+Qq7O8zxAhd4APBGjseKeL5ALF2+jkvrLgb7QDoCaV2H/6jHnCkhxnAOm6otBfmFBg4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714788924; c=relaxed/simple; bh=ImJjYhwLeq6DoD7y9lot08dHBzE0SDmStx3VVB4Rp4Y=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=R5Bqv+ih9yZctcHLtKfTFs4a6nQRN0jYVpqDGyHV2sbFd1gQJIrH4IslGsot2RJwzixd8YRZ0t6aB4iZqbaf3+Kaqzj/s2WCtCN+8ejFRx0EfqA9cBMuq9B2OY1YP9zQZZAN9ThdaSL1Ri2ItDjceGzBg59r1GEKngf2IfCbnaE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=kaechele.ca; spf=pass smtp.mailfrom=kaechele.ca; dkim=pass (1024-bit key) header.d=kaechele.ca header.i=@kaechele.ca header.b=D0MX2+BA; arc=none smtp.client-ip=54.39.219.105 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=kaechele.ca Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kaechele.ca Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=kaechele.ca header.i=@kaechele.ca header.b="D0MX2+BA" Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 1C3D3C0070; Fri, 3 May 2024 22:08:10 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kaechele.ca; s=201907; t=1714788490; h=from:subject:date:message-id:to:mime-version: content-transfer-encoding:in-reply-to:references; bh=BG74+zku+YYoWtxycM9DdqK7wU1Re6w/HHT7DHU603Q=; b=D0MX2+BAKHFoo0B8BrQ2GjO7p68ACYlPPe8f74HerI+O5NWglTb3plAsHV+qAah0NdKcul 7otF5Gl/5jGlUx4kQ1NqNqoUGi0kpwUDNOAeDgHW38wcaejaq0F5L2p/TcnGWuzzrpbzxG F8lhv2GnkmpxhHEg2azL7xXcagW10Uw= From: Felix Kaechele To: Job Noorman , Dmitry Torokhov , Rob Herring , Krzysztof Kozlowski , Conor Dooley , linux-input@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/6] input: himax_hx83112b: use more descriptive register defines Date: Fri, 3 May 2024 22:04:42 -0400 Message-ID: <20240504020745.68525-4-felix@kaechele.ca> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240504020745.68525-1-felix@kaechele.ca> References: <20240504020745.68525-1-felix@kaechele.ca> Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Last-TLS-Session-Version: TLSv1.3 Himax uses an AHB-style bus to communicate with different parts of the display driver and touch controller system. Use more descriptive names for the register and address defines. The names were taken from a driver submission for the similar HX83102J chip. Signed-off-by: Felix Kaechele Link: https://lore.kernel.org/all/TY0PR06MB561105A3386E9D76F429110D9E0F2@TY0PR06MB5611.apcprd06.prod.outlook.com/ --- drivers/input/touchscreen/himax_hx83112b.c | 23 ++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/drivers/input/touchscreen/himax_hx83112b.c b/drivers/input/touchscreen/himax_hx83112b.c index 0a797789e548..ba5442cc0a24 100644 --- a/drivers/input/touchscreen/himax_hx83112b.c +++ b/drivers/input/touchscreen/himax_hx83112b.c @@ -26,12 +26,14 @@ #define HIMAX_MAX_POINTS 10 #define HIMAX_MAX_SUPPLIES 2 -#define HIMAX_REG_CFG_SET_ADDR 0x00 -#define HIMAX_REG_CFG_INIT_READ 0x0c -#define HIMAX_REG_CFG_READ_VALUE 0x08 -#define HIMAX_REG_READ_EVENT 0x30 +#define HIMAX_AHB_ADDR_BYTE_0 0x00 +#define HIMAX_AHB_ADDR_RDATA_BYTE_0 0x08 +#define HIMAX_AHB_ADDR_ACCESS_DIRECTION 0x0c +#define HIMAX_AHB_ADDR_EVENT_STACK 0x30 -#define HIMAX_CFG_PRODUCT_ID 0x900000d0 +#define HIMAX_AHB_CMD_ACCESS_DIRECTION_READ 0x00 + +#define HIMAX_REG_ADDR_ICID 0x900000d0 #define HIMAX_INVALID_COORD 0xffff @@ -75,15 +77,16 @@ static int himax_read_config(struct himax_ts_data *ts, u32 address, u32 *dst) { int error; - error = regmap_write(ts->regmap, HIMAX_REG_CFG_SET_ADDR, address); + error = regmap_write(ts->regmap, HIMAX_AHB_ADDR_BYTE_0, address); if (error) return error; - error = regmap_write(ts->regmap, HIMAX_REG_CFG_INIT_READ, 0x0); + error = regmap_write(ts->regmap, HIMAX_AHB_ADDR_ACCESS_DIRECTION, + HIMAX_AHB_CMD_ACCESS_DIRECTION_READ); if (error) return error; - error = regmap_read(ts->regmap, HIMAX_REG_CFG_READ_VALUE, dst); + error = regmap_read(ts->regmap, HIMAX_AHB_ADDR_RDATA_BYTE_0, dst); if (error) return error; @@ -109,7 +112,7 @@ static int himax_read_product_id(struct himax_ts_data *ts, u32 *product_id) { int error; - error = himax_read_config(ts, HIMAX_CFG_PRODUCT_ID, product_id); + error = himax_read_config(ts, HIMAX_REG_ADDR_ICID, product_id); if (error) return error; @@ -243,7 +246,7 @@ static int himax_handle_input(struct himax_ts_data *ts) int error; struct himax_event event; - error = regmap_raw_read(ts->regmap, HIMAX_REG_READ_EVENT, &event, + error = regmap_raw_read(ts->regmap, HIMAX_AHB_ADDR_EVENT_STACK, &event, sizeof(event)); if (error) { dev_err(&ts->client->dev, "Failed to read input event: %d\n", From patchwork Sat May 4 02:04:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Kaechele X-Patchwork-Id: 13653768 Received: from mail.kaechele.ca (mail.kaechele.ca [54.39.219.105]) (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 5D564AD31; Sat, 4 May 2024 02:15:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=54.39.219.105 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714788923; cv=none; b=VFSJx/F8juO9o1zKd/v7/v8nBh3BCoiNHo98xmbdfre1eKmXFGtTGFuo5jWBLFt7g3RZTtZjEwQefXKOFeIv4A3tK39yHAMnmTkpSISIFHNv3DTUYi8CKy8FS48IDJ/lNdTcUwrUJ7aZnq4lw/2/YGPE+oH02mrdiGOqHQnFoSs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714788923; c=relaxed/simple; bh=QekW4ra98idxZLFZSch4rIOC7DAEv7PojML3X6CnQXE=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QcgFAWPKEKI1HRznylfiyCvsWBkohT3YwYD0ImartosUOxfT5Dnim6iG/QADSLDU+KRctWBuZSz78+4SKaIIWzCQFJ/6n0F34BeccEz9M/VMOrhR5+HLzWNqpnLRcRHnSDKLE2k3oeDbKtizHksZhzDygtcI7wUvwtqfO9np1Q8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=kaechele.ca; spf=pass smtp.mailfrom=kaechele.ca; dkim=pass (1024-bit key) header.d=kaechele.ca header.i=@kaechele.ca header.b=Wy9YlDaq; arc=none smtp.client-ip=54.39.219.105 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=kaechele.ca Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kaechele.ca Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=kaechele.ca header.i=@kaechele.ca header.b="Wy9YlDaq" Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 5520CC0071; Fri, 3 May 2024 22:08:11 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kaechele.ca; s=201907; t=1714788491; h=from:subject:date:message-id:to:mime-version: content-transfer-encoding:in-reply-to:references; bh=9lSYqpkK/tY8uix/2anBrbdiWyUXg2DgSAxMjG5QZKc=; b=Wy9YlDaqwg4moJOujWEOfpaS6qZKy8E9jnd569vYPo1xWqcQ2/O709He8KCG8FmPWVVIcb snB9NXnFtzKvwN2xxpT00w+AKQ6Q+jZ/n4dF/PiuE3bEEMlUEWUwnnkVBf68KHQSramlhT eQzhot65+WcRPGvPaq363OLP3zVXGPE= From: Felix Kaechele To: Job Noorman , Dmitry Torokhov , Rob Herring , Krzysztof Kozlowski , Conor Dooley , linux-input@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/6] input: himax_hx83112b: implement MCU register reading Date: Fri, 3 May 2024 22:04:43 -0400 Message-ID: <20240504020745.68525-5-felix@kaechele.ca> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240504020745.68525-1-felix@kaechele.ca> References: <20240504020745.68525-1-felix@kaechele.ca> Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Last-TLS-Session-Version: TLSv1.3 Implement reading from the MCU in a more universal fashion. This allows properly handling reads of more than 4 bytes using the AHB FIFO implemented in the chip. Signed-off-by: Felix Kaechele --- drivers/input/touchscreen/himax_hx83112b.c | 51 ++++++++++++++++++++-- 1 file changed, 48 insertions(+), 3 deletions(-) diff --git a/drivers/input/touchscreen/himax_hx83112b.c b/drivers/input/touchscreen/himax_hx83112b.c index ba5442cc0a24..0173ff394a99 100644 --- a/drivers/input/touchscreen/himax_hx83112b.c +++ b/drivers/input/touchscreen/himax_hx83112b.c @@ -29,9 +29,13 @@ #define HIMAX_AHB_ADDR_BYTE_0 0x00 #define HIMAX_AHB_ADDR_RDATA_BYTE_0 0x08 #define HIMAX_AHB_ADDR_ACCESS_DIRECTION 0x0c +#define HIMAX_AHB_ADDR_INCR4 0x0d +#define HIMAX_AHB_ADDR_CONTI 0x13 #define HIMAX_AHB_ADDR_EVENT_STACK 0x30 #define HIMAX_AHB_CMD_ACCESS_DIRECTION_READ 0x00 +#define HIMAX_AHB_CMD_INCR4 0x10 +#define HIMAX_AHB_CMD_CONTI 0x31 #define HIMAX_REG_ADDR_ICID 0x900000d0 @@ -73,10 +77,34 @@ static const char *const himax_supply_names[] = { "vdd", }; -static int himax_read_config(struct himax_ts_data *ts, u32 address, u32 *dst) +static int himax_bus_enable_burst(struct himax_ts_data *ts) { int error; + error = regmap_write(ts->regmap, HIMAX_AHB_ADDR_CONTI, + HIMAX_AHB_CMD_CONTI); + if (error) + return error; + + error = regmap_write(ts->regmap, HIMAX_AHB_ADDR_INCR4, + HIMAX_AHB_CMD_INCR4); + if (error) + return error; + + return 0; +} + +static int himax_bus_read(struct himax_ts_data *ts, u32 address, void *dst, + size_t length) +{ + int error; + + if (length > 4) { + error = himax_bus_enable_burst(ts); + if (error) + return error; + } + error = regmap_write(ts->regmap, HIMAX_AHB_ADDR_BYTE_0, address); if (error) return error; @@ -86,7 +114,24 @@ static int himax_read_config(struct himax_ts_data *ts, u32 address, u32 *dst) if (error) return error; - error = regmap_read(ts->regmap, HIMAX_AHB_ADDR_RDATA_BYTE_0, dst); + if (length > 4) + error = regmap_noinc_read(ts->regmap, + HIMAX_AHB_ADDR_RDATA_BYTE_0, + dst, length); + else + error = regmap_read(ts->regmap, + HIMAX_AHB_ADDR_RDATA_BYTE_0, dst); + if (error) + return error; + + return 0; +} + +static int himax_read_mcu(struct himax_ts_data *ts, u32 address, u32 *dst) +{ + int error; + + error = himax_bus_read(ts, address, dst, sizeof(dst)); if (error) return error; @@ -112,7 +157,7 @@ static int himax_read_product_id(struct himax_ts_data *ts, u32 *product_id) { int error; - error = himax_read_config(ts, HIMAX_REG_ADDR_ICID, product_id); + error = himax_read_mcu(ts, HIMAX_REG_ADDR_ICID, product_id); if (error) return error; From patchwork Sat May 4 02:04:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Kaechele X-Patchwork-Id: 13653762 Received: from mail.kaechele.ca (mail.kaechele.ca [54.39.219.105]) (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 5B1EF210D; Sat, 4 May 2024 02:08:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=54.39.219.105 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714788484; cv=none; b=F2L0xb3avCttOTBxTfAnWxaDIjvosZgbDf1MbwnVyJIPnCbJ1/rM4zcC9DwqfGBPzGtWLHnBWIT1r+u3PxZ4CKKPeqw4udJdfPPOSASlArM78v3baCZQdEtVhZgPzR04CdLR7MDrhKn0sxg7AObU13V49l9RP86dhDtNOtkNydQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714788484; c=relaxed/simple; bh=BYyg1SiTgeo3qfXhKZEi1hR0S5PAcTSMT9TliXuH9hY=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ckx0ujMrUL8VfdRCmEfzwT6aDQGeIP0AYdzLoQKuUSTYDo2FZn4xyG2KohltCLhArvS4ndgtWE6VQ0zF1qRUWYCKPZ7o2p/E6unOUVGsRmOQi+D9hnMiH6lPtfPumSn1QgKJpCmlIeBce3L9tulqLWR1ePoO3kuGG+cVVjLeJaE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=kaechele.ca; spf=pass smtp.mailfrom=kaechele.ca; dkim=pass (1024-bit key) header.d=kaechele.ca header.i=@kaechele.ca header.b=mJ1Zhou+; arc=none smtp.client-ip=54.39.219.105 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=kaechele.ca Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kaechele.ca Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=kaechele.ca header.i=@kaechele.ca header.b="mJ1Zhou+" Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id EBDD9C0072; Fri, 3 May 2024 22:08:11 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kaechele.ca; s=201907; t=1714788492; h=from:subject:date:message-id:to:mime-version: content-transfer-encoding:in-reply-to:references; bh=urS88EVc3Y2DTRlVBr6koQ8c8bKoBQO9OBgP+LpuXV0=; b=mJ1Zhou+K7+3qsOhx6ecPzBFInJ/SuPXoVtBpzVFfi7rOLh/vxLkbEWFAHD52SO+KiuPh4 mlKn13eFDJ4DWwsqpg4jBvyli3JgfP9nnX0L3ePpo+Sv1jb7MPTSHt0p8aE83zXCVQUfxY 4+IMvNonBRXVB4ZOZmRf1qRSPdp27Lo= From: Felix Kaechele To: Job Noorman , Dmitry Torokhov , Rob Herring , Krzysztof Kozlowski , Conor Dooley , linux-input@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 5/6] input: himax_hx83112b: add himax_chip struct for multi-chip support Date: Fri, 3 May 2024 22:04:44 -0400 Message-ID: <20240504020745.68525-6-felix@kaechele.ca> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240504020745.68525-1-felix@kaechele.ca> References: <20240504020745.68525-1-felix@kaechele.ca> Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Last-TLS-Session-Version: TLSv1.3 In preparation for HX83100A support allow defining separate functions for specific chip operations. Signed-off-by: Felix Kaechele --- drivers/input/touchscreen/himax_hx83112b.c | 53 +++++++++++++++------- 1 file changed, 37 insertions(+), 16 deletions(-) diff --git a/drivers/input/touchscreen/himax_hx83112b.c b/drivers/input/touchscreen/himax_hx83112b.c index 0173ff394a99..667611c5a018 100644 --- a/drivers/input/touchscreen/himax_hx83112b.c +++ b/drivers/input/touchscreen/himax_hx83112b.c @@ -21,8 +21,6 @@ #include #include -#define HIMAX_ID_83112B 0x83112b - #define HIMAX_MAX_POINTS 10 #define HIMAX_MAX_SUPPLIES 2 @@ -57,7 +55,17 @@ struct himax_event { static_assert(sizeof(struct himax_event) == 56); +struct himax_ts_data; +struct himax_chip { + u32 id; + int (*check_id)(struct himax_ts_data *ts); + int (*read_events)(struct himax_ts_data *ts, + struct himax_event *event, + size_t length); +}; + struct himax_ts_data { + const struct himax_chip *chip; struct regulator_bulk_data supplies[HIMAX_MAX_SUPPLIES]; struct gpio_desc *gpiod_rst; struct input_dev *input_dev; @@ -176,15 +184,12 @@ static int himax_check_product_id(struct himax_ts_data *ts) dev_dbg(&ts->client->dev, "Product id: %x\n", product_id); - switch (product_id) { - case HIMAX_ID_83112B: + if (product_id == ts->chip->id) return 0; - default: - dev_err(&ts->client->dev, - "Unknown product id: %x\n", product_id); - return -EINVAL; - } + dev_err(&ts->client->dev, "Unknown product id: %x\n", + product_id); + return -EINVAL; } static int himax_input_register(struct himax_ts_data *ts) @@ -286,13 +291,20 @@ static bool himax_verify_checksum(struct himax_ts_data *ts, return true; } +static int himax_read_events(struct himax_ts_data *ts, + struct himax_event *event, + size_t length) +{ + return regmap_raw_read(ts->regmap, HIMAX_AHB_ADDR_EVENT_STACK, event, + length); +} + static int himax_handle_input(struct himax_ts_data *ts) { int error; struct himax_event event; - error = regmap_raw_read(ts->regmap, HIMAX_AHB_ADDR_EVENT_STACK, &event, - sizeof(event)); + error = ts->chip->read_events(ts, &event, sizeof(event)); if (error) { dev_err(&ts->client->dev, "Failed to read input event: %d\n", error); @@ -338,6 +350,7 @@ static int himax_probe(struct i2c_client *client) i2c_set_clientdata(client, ts); ts->client = client; + ts->chip = i2c_get_match_data(client); ts->regmap = devm_regmap_init_i2c(client, &himax_regmap_config); error = PTR_ERR_OR_ZERO(ts->regmap); @@ -375,9 +388,11 @@ static int himax_probe(struct i2c_client *client) himax_reset(ts); - error = himax_check_product_id(ts); - if (error) - return error; + if (ts->chip->check_id) { + error = himax_check_product_id(ts); + if (error) + return error; + } error = himax_input_register(ts); if (error) @@ -421,15 +436,21 @@ static int himax_resume(struct device *dev) static DEFINE_SIMPLE_DEV_PM_OPS(himax_pm_ops, himax_suspend, himax_resume); +static const struct himax_chip hx83112b_chip = { + .id = 0x83112b, + .check_id = himax_check_product_id, + .read_events = himax_read_events, +}; + static const struct i2c_device_id himax_ts_id[] = { - { "hx83112b", 0 }, + { "hx83112b", (kernel_ulong_t) &hx83112b_chip }, { /* sentinel */ } }; MODULE_DEVICE_TABLE(i2c, himax_ts_id); #ifdef CONFIG_OF static const struct of_device_id himax_of_match[] = { - { .compatible = "himax,hx83112b" }, + { .compatible = "himax,hx83112b", .data = &hx83112b_chip }, { /* sentinel */ } }; MODULE_DEVICE_TABLE(of, himax_of_match); From patchwork Sat May 4 02:04:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Kaechele X-Patchwork-Id: 13653763 Received: from mail.kaechele.ca (mail.kaechele.ca [54.39.219.105]) (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 E3183539C; Sat, 4 May 2024 02:08:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=54.39.219.105 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714788485; cv=none; b=jugULHSrd2tGjRuKFiZ/GAfXrhipIJoDcDpDrJIEXoVrRil/gqh6D3tt9gUqpUMzxQKJPu79InCIZ2iFaz+PpZ6l3V8fg2WCM+ucQSVTKqntQ5we7wzaWygtjuFk70Bx+eSEvMPOaAW9lOQ2qgeKwhK4lwsce0KD9D3LwvKpL7U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714788485; c=relaxed/simple; bh=Pe7QETLG9b6pCpN9wEnqqft2nXgNoO+6kB1TkY+IC+g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NSu6umkp4ABZOr2hYtTPXKJP24FYH7rR6MoDgA5FpVb14nBUrqBsMPMai1ohESCfqf7ZNH3FU6Sqy7aJDj1Rurngds02VIdLUJlVdGOM1ba7Fh4VCJljKxJzZZ2K9QUSVU92FkypQ4SFE+gfu6z6ufSS0QpejijpKFCRqL0+HnI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=kaechele.ca; spf=pass smtp.mailfrom=kaechele.ca; dkim=pass (1024-bit key) header.d=kaechele.ca header.i=@kaechele.ca header.b=phcGVvHB; arc=none smtp.client-ip=54.39.219.105 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=kaechele.ca Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kaechele.ca Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=kaechele.ca header.i=@kaechele.ca header.b="phcGVvHB" Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 692DDC0076; Fri, 3 May 2024 22:08:14 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kaechele.ca; s=201907; t=1714788495; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=Js+Zw4ZWqNvFMC47UtCh2KmzrfI0HQ6+4EhdmIXK07Q=; b=phcGVvHB/akJpzBsxB0+PWlrLVr9iYWsvD+PQ44gOmxos0bcl7+3hBGhQwcSG/5z/j8iZK pV0LGHODZZhNR8kDQy5CTyQ4sJ508B7AN1bAb7eiF7qtcBH9V0cZU55jogFzgLbo77sRRW ftc/DfMawSkSFfh+t/eeAkmirR9rBkc= From: Felix Kaechele To: Job Noorman , Dmitry Torokhov , Rob Herring , Krzysztof Kozlowski , Conor Dooley , linux-input@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Paul Gale Subject: [PATCH 6/6] input: himax_hx83112b: add support for HX83100A Date: Fri, 3 May 2024 22:04:45 -0400 Message-ID: <20240504020745.68525-7-felix@kaechele.ca> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240504020745.68525-1-felix@kaechele.ca> References: <20240504020745.68525-1-felix@kaechele.ca> Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Last-TLS-Session-Version: TLSv1.3 The HX83100A is a bit of an outlier in the Himax HX831xxx series of touch controllers as it requires reading touch events through the AHB interface of the MCU rather than providing a dedicated FIFO address like the other chips do. This patch implements the specific read function and introduces the HX83100A chip with an appropriate i2c ID and DT compatible string. The HX83100A doesn't have a straightforward way to do chip identification, which is why it is not implemented in this patch. Tested on: Lenovo ThinkSmart View (CD-18781Y) / Innolux P080DDD-AB2 LCM Signed-off-by: Felix Kaechele Tested-by: Paul Gale --- drivers/input/touchscreen/himax_hx83112b.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/input/touchscreen/himax_hx83112b.c b/drivers/input/touchscreen/himax_hx83112b.c index 667611c5a018..984baef495e1 100644 --- a/drivers/input/touchscreen/himax_hx83112b.c +++ b/drivers/input/touchscreen/himax_hx83112b.c @@ -4,6 +4,9 @@ * * Copyright (C) 2022 Job Noorman * + * HX83100A support + * Copyright (C) 2024 Felix Kaechele + * * This code is based on "Himax Android Driver Sample Code for QCT platform": * * Copyright (C) 2017 Himax Corporation. @@ -37,6 +40,8 @@ #define HIMAX_REG_ADDR_ICID 0x900000d0 +#define HX83100A_REG_FW_EVENT_STACK 0x90060000 + #define HIMAX_INVALID_COORD 0xffff struct himax_event_point { @@ -291,6 +296,13 @@ static bool himax_verify_checksum(struct himax_ts_data *ts, return true; } +static int hx83100a_read_events(struct himax_ts_data *ts, + struct himax_event *event, + size_t length) +{ + return himax_bus_read(ts, HX83100A_REG_FW_EVENT_STACK, event, length); +}; + static int himax_read_events(struct himax_ts_data *ts, struct himax_event *event, size_t length) @@ -436,6 +448,10 @@ static int himax_resume(struct device *dev) static DEFINE_SIMPLE_DEV_PM_OPS(himax_pm_ops, himax_suspend, himax_resume); +static const struct himax_chip hx83100a_chip = { + .read_events = hx83100a_read_events, +}; + static const struct himax_chip hx83112b_chip = { .id = 0x83112b, .check_id = himax_check_product_id, @@ -443,6 +459,7 @@ static const struct himax_chip hx83112b_chip = { }; static const struct i2c_device_id himax_ts_id[] = { + { "hx83100a", (kernel_ulong_t) &hx83100a_chip }, { "hx83112b", (kernel_ulong_t) &hx83112b_chip }, { /* sentinel */ } }; @@ -450,6 +467,7 @@ MODULE_DEVICE_TABLE(i2c, himax_ts_id); #ifdef CONFIG_OF static const struct of_device_id himax_of_match[] = { + { .compatible = "himax,hx83100a", .data = &hx83100a_chip }, { .compatible = "himax,hx83112b", .data = &hx83112b_chip }, { /* sentinel */ } };