All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Felix Kaechele <felix@kaechele.ca>, Mark Brown <broonie@kernel.org>
Cc: Job Noorman <job@noorman.info>, Rob Herring <robh+dt@kernel.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
	Conor Dooley <conor+dt@kernel.org>,
	linux-input@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 3/5] input: himax_hx83112b: implement MCU register reading
Date: Mon, 13 May 2024 16:01:59 -0700	[thread overview]
Message-ID: <ZkKb5_SRNwG1pRou@google.com> (raw)
In-Reply-To: <20240511121245.109644-4-felix@kaechele.ca>

On Sat, May 11, 2024 at 08:12:24AM -0400, Felix Kaechele wrote:
> 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.

Mark, do we have anything in regmap to support this better or having a
wrapper is the best solution here?

Thanks!

> 
> Signed-off-by: Felix Kaechele <felix@kaechele.ca>
> ---
>  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
> 

-- 
Dmitry

  reply	other threads:[~2024-05-13 23:02 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-11 12:12 [PATCH v2 0/5] input: himax_hx83112b: add support for HX83100A Felix Kaechele
2024-05-11 12:12 ` [PATCH v2 1/5] dt-bindings: input: touchscreen: himax,hx83112b: add HX83100A Felix Kaechele
2024-05-11 12:38   ` Conor Dooley
2024-05-11 14:10     ` Felix Kaechele
2024-05-12 12:04       ` Conor Dooley
2024-05-11 12:12 ` [PATCH v2 2/5] input: himax_hx83112b: use more descriptive register defines Felix Kaechele
2024-05-11 12:12 ` [PATCH v2 3/5] input: himax_hx83112b: implement MCU register reading Felix Kaechele
2024-05-13 23:01   ` Dmitry Torokhov [this message]
2024-05-14  9:46     ` Mark Brown
2024-05-14 14:01       ` Felix Kaechele
2024-05-29 23:07         ` Felix Kaechele
2024-05-11 12:12 ` [PATCH v2 4/5] input: himax_hx83112b: add himax_chip struct for multi-chip support Felix Kaechele
2024-05-11 12:12 ` [PATCH v2 5/5] input: himax_hx83112b: add support for HX83100A Felix Kaechele

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZkKb5_SRNwG1pRou@google.com \
    --to=dmitry.torokhov@gmail.com \
    --cc=broonie@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=felix@kaechele.ca \
    --cc=job@noorman.info \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robh+dt@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.