Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp1041486lqo; Sat, 11 May 2024 05:13:29 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVCmzmLl3krdPfYqNI8JgMbeQzrzpx3ItlP6WZ25PTRx5A7comKBMQfJ2EiFkvf6yg1hzZzShteEqJuP1cThyV0tyfUeHnFeUfRJcMEfw== X-Google-Smtp-Source: AGHT+IFAZSuHz1BrC3Bi0yJO5RHrvVhaJs/EWLUKE9Vy713KwlYyqDH/nPYWbDn/Gc/29LPSxhrJ X-Received: by 2002:a05:6a20:3c90:b0:1ad:9394:2d30 with SMTP id adf61e73a8af0-1afde139a99mr5921652637.37.1715429609478; Sat, 11 May 2024 05:13:29 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715429609; cv=pass; d=google.com; s=arc-20160816; b=w+QvdIDKrgEMOde8xzi06Q12/Bk4Kif9pKoc6nHVFvn0KEdrCVbzjQY1QE2QEA+T/H JM/Mq9KE7OzQ/lyoMsZ9d7v5OJcrrM5rgdFFUR/V25waXX/HPg+qwXPzU88M8NWUybOn vRYwO2FPPy8hn2CDl9O3QDbzpZnStSUvRytsLVrGOwInfEoxeKHl0tkVoOALUmmgW+Q8 k/vE4aO4Ychna1v0j3LTC7o2VuFPYqtYr9k4cwqM/Ws4G2AQmdV7N0+t0ofzT3EdsPmL aR3xpLL80pVlRpnOcCpF+6/tPtQEweISjSL63f58T5/U5ShWtmaIph+3MUKwWG2AQVhW w4kA== 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:to:from:dkim-signature; bh=TrXGrAijG+t58Kj/Mka0mmJB66CA+fYU6neTTWmb2Z4=; fh=3Ml11XK5MY/MGDMKcsZeKW7JtixbKgbbbw2mRmCYf9o=; b=xS30OOOIMcKhDOmbS7P+FSagHRnga3V+g+G0fCSyjysjH48sHPmxLhxBWK53zHSYt9 gLy+Jh4o+m5JV/oV8SvJwsoJ5mvy2tXl7ZZUmI4qsRqJLlzH4u8NFOSkXyiPuw//+XyO mcqPP8Nr0rv3flUYribUzPekCgjT9goPhyHHC0wp9vd3utqx/ays+86l1qOkLBc419oj td3mUIRXnDTMECrgx753+8HAdbFDwi3qauBly3rXmAfAralzaB4Z9+RSxnUn+bPffGUQ uNzZGUmfcAtIbPvNyovAfj6fIprqdTnUw2sH/qV6YD+CG1EdH2aQctq++WbrNY8cap+8 h5NA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kaechele.ca header.s=201907 header.b=HJyAAuB6; arc=pass (i=1 spf=pass spfdomain=kaechele.ca dkim=pass dkdomain=kaechele.ca dmarc=pass fromdomain=kaechele.ca); spf=pass (google.com: domain of linux-kernel+bounces-176527-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-176527-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=kaechele.ca Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 98e67ed59e1d1-2b628fb9a94si7727690a91.136.2024.05.11.05.13.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 May 2024 05:13:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-176527-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kaechele.ca header.s=201907 header.b=HJyAAuB6; arc=pass (i=1 spf=pass spfdomain=kaechele.ca dkim=pass dkdomain=kaechele.ca dmarc=pass fromdomain=kaechele.ca); spf=pass (google.com: domain of linux-kernel+bounces-176527-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-176527-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=kaechele.ca 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 0F778282160 for ; Sat, 11 May 2024 12:13:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8A3B957C89; Sat, 11 May 2024 12:12:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=kaechele.ca header.i=@kaechele.ca header.b="HJyAAuB6" 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 4A0C755C1A; Sat, 11 May 2024 12:12:53 +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=1715429574; cv=none; b=jEt58ZhcOFeDh8TPvTWrXGuNXrCU8ZLfZZU2F4rYDdhnzyWg8JBEuxDA1nxzc7s10ShExGVi7tFxYJqGAgCUjNpi1OotB66xkw9VvBIC7iKpqSfUSBvKvsJEXlYYrxcKv+k47Gt3SLQj1B+CfklAai/DqtE/ycJWInqOfw3cN6Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715429574; c=relaxed/simple; bh=0Im4oJrr5I7E8fEuuC22T+hDHAFtUXSea3gb3fK19ao=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cwW/9g5vxCzGCdWtUiM8myol1ICSqhT4hRldJoUGnjcOYL2sdcJBH3Zo9YQsOLnN2lWoqAD4jJR7lAcP7NxdCUg+RUwcToawrRDcD5EmC24Okf+ouPP+1lvgIn+PigI+H4074TlEzYQzraaWYSsyh6exdb9QYv1cVvc78crItho= 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=HJyAAuB6; 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 Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 35720C006F; Sat, 11 May 2024 08:13:19 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kaechele.ca; s=201907; t=1715429599; h=from:subject:date:message-id:to:mime-version: content-transfer-encoding:in-reply-to:references; bh=TrXGrAijG+t58Kj/Mka0mmJB66CA+fYU6neTTWmb2Z4=; b=HJyAAuB6QJpeK5LS9m+fICEiXO/181N+/3OArSdZJOVo4sGkVRiY2G2sKUNSgpzKj75cHn lUpRDdHCYBM3ZXb9KjsJXvreF6z+MNQ+TReQNPgahHuZ/z604iXcKzMNLRfr1YVoZ2nRLb gfYt23gJaUhDHahHDe1ruo+DBm6eJ9w= 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 v2 3/5] input: himax_hx83112b: implement MCU register reading Date: Sat, 11 May 2024 08:12:24 -0400 Message-ID: <20240511121245.109644-4-felix@kaechele.ca> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240511121245.109644-1-felix@kaechele.ca> References: <20240511121245.109644-1-felix@kaechele.ca> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 2da2920d43f9..67ef3255cc8b 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; -- 2.45.0