From patchwork Thu Jun 20 14:50:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Kaechele X-Patchwork-Id: 806449 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 A38521AE083; Thu, 20 Jun 2024 14:56:19 +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=1718895381; cv=none; b=kPEmkFnQ19JZSoZBtNmkjl8MOvndOydNYvD2Tom901Ss+p69lnlNyjVrlU0FpifTt11AhkUMidV4I5X67n6zV4madDZuLX+xfV9J7gd5EmcgOGUlv9wkCtyKxO3GQbRAdtyvhIjbHjRQ0XEHlhpBzhF7Rj2QEjt65rEFApbVWHI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718895381; c=relaxed/simple; bh=HELkkarDKoiIzgewN1eHfJl5FJ8bH/Y/B9z+tSNdslE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Jg6OhHWZ1Cwblab9Gmy1ihCoO4RnMHW6zin9oldHeShkJwwdrkLRceBYIQDVYYyQy9LEPxX9em3KRpeAWfsJ8NKBvXLTlMCvT68p1IghOEH3CQrRK/B9Jb8qGErix5Z7Tqt5UGtxuNn7eFMn15h2jTk78Pc1pCO1gNAZPMpanyI= 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=VQDuihoO; 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="VQDuihoO" Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id C2DE7C006A; Thu, 20 Jun 2024 10:52:05 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kaechele.ca; s=201907; t=1718895127; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=ssK0mY4ZibiWPcJi3x1KxbtlmlbaryPSbpR5dRa8d/M=; b=VQDuihoOg2ciDxtC0nsjQITZvqJ8bEpAXylhKMfIAxQWTSKlT/jaZgLNbQU5tFmcq9nUta cH9BhFJ0VOtmlz9war3roacU/lv3Ko4e6UWn6xtzCKS41EDjeoe9Z06oYXfRkIiWJVvFmN 7vI1p/bQHBsj8/O141y2Msck+OvNlJ0= 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: Conor Dooley Subject: [PATCH v3 1/5] dt-bindings: input: touchscreen: himax,hx83112b: add HX83100A Date: Thu, 20 Jun 2024 10:50:02 -0400 Message-ID: <20240620145019.156187-2-felix@kaechele.ca> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240620145019.156187-1-felix@kaechele.ca> References: <20240620145019.156187-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 Add a compatible string for the Himax HX83100A touch controller. The HX83100A presents touch events on the internal bus rather than offering a dedicated event register like the other chips in this family do. Signed-off-by: Felix Kaechele Acked-by: Conor Dooley --- .../devicetree/bindings/input/touchscreen/himax,hx83112b.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/input/touchscreen/himax,hx83112b.yaml b/Documentation/devicetree/bindings/input/touchscreen/himax,hx83112b.yaml index f42b23d532eb..f5cfacb5e966 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: From patchwork Thu Jun 20 14:50:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Kaechele X-Patchwork-Id: 806448 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 A38F01AE875; Thu, 20 Jun 2024 14:56:19 +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=1718895381; cv=none; b=F/W262zXmmbd4A8vCZvMtOe0iMSkMY0x3RhOn+yLZtSzD3hewupa5tpxKVJLSWM8/w+qJwLt164FdJGndFvBUXJcHEsonvQFm16G8Kwa5GjlWb58DCc+Tzgf8lLEK0iNB8bSobukrLtoxK6fgyP9TuMS//dvy4Mxsu23yKkIqBA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718895381; c=relaxed/simple; bh=v45ml3qrg1Vhx3Tb6RVFRxV1+YollR6UlAHlQpqsL5I=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VCtnG1U76cVtpBBR5VlN7SC2c50tZHF1mqlcJEhFSnMaQJ8QY4LHqj1Br5ye6JVK5CGEVl1snHRvfYNgBhKIEdChYz/CjwRAcWyvO81fNIlszJBJjx6W5w0Vd4hdn5Uy51uPBtAPWucw5olMbUEIca6s+QAmkRhDFtPhoecPf2Q= 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=BtUFbhxp; 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="BtUFbhxp" Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 63C7EC006E; Thu, 20 Jun 2024 10:52:10 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kaechele.ca; s=201907; t=1718895130; h=from:subject:date:message-id:to:mime-version: content-transfer-encoding:in-reply-to:references; bh=DaqAvMZQgJwWZoTHGQT47OiyxpPitTDwP3ZrPha3UNk=; b=BtUFbhxpaCWPb4Ct9QGF6XsihiCnilgfYEv2gKN/QXC2i0wo6GK0atNhyMGPLEyTNtQZPC pomHvqwRC6TJD1de/jnP5sR4oyxXFTPH2hzotS3ialvEKyYZQsslR8jzul2ozjuZ5kYrkJ Yac1Dzqgr15GC98ZqdjW+oqIhAJXDgg= 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 v3 2/5] input: himax_hx83112b: use more descriptive register defines Date: Thu, 20 Jun 2024 10:50:03 -0400 Message-ID: <20240620145019.156187-3-felix@kaechele.ca> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240620145019.156187-1-felix@kaechele.ca> References: <20240620145019.156187-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 bafabd06dabc..d6c4a68eac23 100644 --- a/drivers/input/touchscreen/himax_hx83112b.c +++ b/drivers/input/touchscreen/himax_hx83112b.c @@ -24,12 +24,14 @@ #define HIMAX_MAX_POINTS 10 -#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 @@ -67,15 +69,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; @@ -101,7 +104,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; @@ -235,7 +238,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 Thu Jun 20 14:50:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Kaechele X-Patchwork-Id: 806097 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 B06441AE87B; Thu, 20 Jun 2024 14:56:19 +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=1718895381; cv=none; b=eSRthLXf0zg0As7kRfPo9Vz9fxBZ+qfdmkpEfLS3Ceih+V1rfML+HLlYL7+UV0OpQaIvZqLo2ww4eceoII6NmxKlWn71amfhtR1GLY/J6BcQ9wjwfIeQBMOXIFVi5+oZ0aM+CWjUDIH9H3yLJcXiXAgSxrMb8uMtJtiU+LbtrCw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718895381; c=relaxed/simple; bh=P6ZB7eRoL9WbM2pQ1OT1O5ZVJyTNiQWzqQ/G5mHIpRc=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=asuCeeLijK7TKmFlejCsb6j308P2JVClsnpP2mLV7/pOU0JOvXetuY3yoPNydFRGMgJZHhog9A2tAXs/6+4oAPhgc12nDHNhRsD4G0drqESLcUM7KeyumHXQezLCVHtWb66gALkEW5ktd6NlNpFKom4bQk3KYZhCM9Ba8lvtE7s= 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=nX/Yyaj/; 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="nX/Yyaj/" Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 4F749C006F; Thu, 20 Jun 2024 10:52:11 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kaechele.ca; s=201907; t=1718895131; h=from:subject:date:message-id:to:mime-version: content-transfer-encoding:in-reply-to:references; bh=D5fyFObgeas/78EcwxhU0nwIdPJp396uaXo7hzaSXjE=; b=nX/Yyaj/558YycxrJdcN9vsnp39pS9FY90rvC4+6m9feaowGJT7U+7qmP8j9Nu3cN2G+FF /VBGj2joIPOJDX1O7u6Ky770OzUNdLLAWkARnXvN5n6C+tDbA9h+FL+DtQMGtQzhcgSwfy F3dfRDJly++Ap5goAWA4vyK/BrWpO3I= 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 v3 3/5] input: himax_hx83112b: implement MCU register reading Date: Thu, 20 Jun 2024 10:50:04 -0400 Message-ID: <20240620145019.156187-4-felix@kaechele.ca> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240620145019.156187-1-felix@kaechele.ca> References: <20240620145019.156187-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 | 50 ++++++++++++++++++++-- 1 file changed, 47 insertions(+), 3 deletions(-) diff --git a/drivers/input/touchscreen/himax_hx83112b.c b/drivers/input/touchscreen/himax_hx83112b.c index d6c4a68eac23..c9cc69bf242a 100644 --- a/drivers/input/touchscreen/himax_hx83112b.c +++ b/drivers/input/touchscreen/himax_hx83112b.c @@ -27,9 +27,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 @@ -65,10 +69,34 @@ static const struct regmap_config himax_regmap_config = { .val_format_endian = REGMAP_ENDIAN_LITTLE, }; -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; @@ -78,7 +106,23 @@ 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; @@ -104,7 +148,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 Thu Jun 20 14:50:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Kaechele X-Patchwork-Id: 806450 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 0FABE1A00E8; Thu, 20 Jun 2024 14:50:31 +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=1718895035; cv=none; b=PzTGFApON5KrrKwih0nxXDFXTQNrGMNyzjHt186imCC9TV111BQjfP/6Jud2TgjIdzk/CTHQ74cHpDh3Hlszk9rcCxcqOXXT0xEL1XOFlbiD3xI3D9AH+8uCA38g58aYcKjTki9SKgSIS8ryOQYTQZePtJ4SVEFwfPYPYlhSNak= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718895035; c=relaxed/simple; bh=e7ET5z0NH76O9Cj6VARop7hsLimA/o/QRhe+lUYgjas=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OHrvyzOiKvYlfJdx1JXRS3vxsLXrdtcshEUi4cg8sBInrXutNbb1BDfo4rGdi3XIx83zii0pUpP9qJppQas6F06J3aSX/F2cDyHFCripmjK33UXTw6JjlgfSMeeqjkmAJLjUDS4yZ4d5IWEExzdIIetGV24PITNx56l4ku0podY= 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=fOXy4Vrc; 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="fOXy4Vrc" Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 885D1C0070; Thu, 20 Jun 2024 10:52:12 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kaechele.ca; s=201907; t=1718895132; h=from:subject:date:message-id:to:mime-version: content-transfer-encoding:in-reply-to:references; bh=h7BDR8ebm7wi5ol2mXXhFOPU8d2goNXVwlQM/DNXqhQ=; b=fOXy4VrcrSmvZVmXj2uQIqsUxnVIrcgn9A6d7f1WRTcKY/T6cAJ/AEgJDou77wgqskRnIN 9PCY7O9/ZkMBQziYIphwWFgpXXmExJoHxe+ciHfD0xOsyLifsGNXGrMUad9fUtN5XrqF4p DjDll9mpx4KXPBTkM3wdiu6CCRLukGw= 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 v3 4/5] input: himax_hx83112b: add himax_chip struct for multi-chip support Date: Thu, 20 Jun 2024 10:50:05 -0400 Message-ID: <20240620145019.156187-5-felix@kaechele.ca> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240620145019.156187-1-felix@kaechele.ca> References: <20240620145019.156187-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 | 51 +++++++++++++++------- 1 file changed, 35 insertions(+), 16 deletions(-) diff --git a/drivers/input/touchscreen/himax_hx83112b.c b/drivers/input/touchscreen/himax_hx83112b.c index c9cc69bf242a..5092a357c332 100644 --- a/drivers/input/touchscreen/himax_hx83112b.c +++ b/drivers/input/touchscreen/himax_hx83112b.c @@ -20,8 +20,6 @@ #include #include -#define HIMAX_ID_83112B 0x83112b - #define HIMAX_MAX_POINTS 10 #define HIMAX_AHB_ADDR_BYTE_0 0x00 @@ -55,7 +53,16 @@ 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 gpio_desc *gpiod_rst; struct input_dev *input_dev; struct i2c_client *client; @@ -167,15 +174,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) @@ -277,13 +281,19 @@ 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); @@ -329,6 +339,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); @@ -346,9 +357,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) @@ -381,15 +394,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" }, + { "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 Thu Jun 20 14:50:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Kaechele X-Patchwork-Id: 806098 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 E1FFD1AE08E; Thu, 20 Jun 2024 14:50:32 +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=1718895036; cv=none; b=OKtuNqa/R8ht6WHzQ9K3RPtI+Xcoh85sxqJWgfVYkb3g9eL9uVCo8tFvSf3KDtYo3VWPB2xU2vPDGcTSrkZw/uCtg2XgGL8AVeOf+45zD3hBx1rLH/cBNDXjz69Q5OhelwV+YeJ4wkiqWE3atwOxlvfoQSRRj4TTCZxsax7Q9wE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718895036; c=relaxed/simple; bh=2DzxvjV6MvKhNUdCZmu80xYkWaZG1Zm5C2Gtma+Iq1A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=r1z7vxm16aWWsCoMmwL3+GFjfamk6HJIFdeb0dHs7LqRyq32dJhs2k89mkgRaihwAjfJWf2rVRBb9F39yje0ofFdO5r2zz4EKhDBLYDXt8WW+eCb2aP7jxmIYk5qT7H8L8MX7da6+uUV8K+tX8ImJWBjPshw7xR0wqOXkU/9U1M= 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=E9rXJphZ; 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="E9rXJphZ" Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 60CFDC0072; Thu, 20 Jun 2024 10:52:13 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kaechele.ca; s=201907; t=1718895134; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=K6yI03A8YX5AxufGKnNrR+pc9BLu4Q5cOZcnXlwV5G4=; b=E9rXJphZGhN4S6CmjEvA6PdMbMcrSpFkJaoiDBfr68ID8nM6Iw15+dWQv/AXLUg7MsF156 E660eXuJftvqEpcp8WtJEY/1XwKXT0IWDxPDIu6HMxcFgUMmoCjV0UsntS1ae7fHIEStOn jZR584DHqM0+FnSHDq53ilscClvaWLE= 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 v3 5/5] input: himax_hx83112b: add support for HX83100A Date: Thu, 20 Jun 2024 10:50:06 -0400 Message-ID: <20240620145019.156187-6-felix@kaechele.ca> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240620145019.156187-1-felix@kaechele.ca> References: <20240620145019.156187-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 | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/drivers/input/touchscreen/himax_hx83112b.c b/drivers/input/touchscreen/himax_hx83112b.c index 5092a357c332..9ed3bccde4ac 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. @@ -35,6 +38,8 @@ #define HIMAX_REG_ADDR_ICID 0x900000d0 +#define HX83100A_REG_FW_EVENT_STACK 0x90060000 + #define HIMAX_INVALID_COORD 0xffff struct himax_event_point { @@ -288,6 +293,12 @@ static int himax_read_events(struct himax_ts_data *ts, length); } +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_handle_input(struct himax_ts_data *ts) { int error; @@ -394,6 +405,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, @@ -401,6 +416,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 */ } }; @@ -408,6 +424,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 */ } };