Skip to content

Commit 0944829

Browse files
kaecheledtor
authored andcommitted
Input: himax_hx83112b - implement MCU register reading
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 <felix@kaechele.ca> Link: https://lore.kernel.org/r/20240620145019.156187-4-felix@kaechele.ca Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
1 parent 05eab54 commit 0944829

1 file changed

Lines changed: 47 additions & 3 deletions

File tree

drivers/input/touchscreen/himax_hx83112b.c

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,13 @@
2727
#define HIMAX_AHB_ADDR_BYTE_0 0x00
2828
#define HIMAX_AHB_ADDR_RDATA_BYTE_0 0x08
2929
#define HIMAX_AHB_ADDR_ACCESS_DIRECTION 0x0c
30+
#define HIMAX_AHB_ADDR_INCR4 0x0d
31+
#define HIMAX_AHB_ADDR_CONTI 0x13
3032
#define HIMAX_AHB_ADDR_EVENT_STACK 0x30
3133

3234
#define HIMAX_AHB_CMD_ACCESS_DIRECTION_READ 0x00
35+
#define HIMAX_AHB_CMD_INCR4 0x10
36+
#define HIMAX_AHB_CMD_CONTI 0x31
3337

3438
#define HIMAX_REG_ADDR_ICID 0x900000d0
3539

@@ -65,10 +69,34 @@ static const struct regmap_config himax_regmap_config = {
6569
.val_format_endian = REGMAP_ENDIAN_LITTLE,
6670
};
6771

68-
static int himax_read_config(struct himax_ts_data *ts, u32 address, u32 *dst)
72+
static int himax_bus_enable_burst(struct himax_ts_data *ts)
6973
{
7074
int error;
7175

76+
error = regmap_write(ts->regmap, HIMAX_AHB_ADDR_CONTI,
77+
HIMAX_AHB_CMD_CONTI);
78+
if (error)
79+
return error;
80+
81+
error = regmap_write(ts->regmap, HIMAX_AHB_ADDR_INCR4,
82+
HIMAX_AHB_CMD_INCR4);
83+
if (error)
84+
return error;
85+
86+
return 0;
87+
}
88+
89+
static int himax_bus_read(struct himax_ts_data *ts, u32 address, void *dst,
90+
size_t length)
91+
{
92+
int error;
93+
94+
if (length > 4) {
95+
error = himax_bus_enable_burst(ts);
96+
if (error)
97+
return error;
98+
}
99+
72100
error = regmap_write(ts->regmap, HIMAX_AHB_ADDR_BYTE_0, address);
73101
if (error)
74102
return error;
@@ -78,7 +106,23 @@ static int himax_read_config(struct himax_ts_data *ts, u32 address, u32 *dst)
78106
if (error)
79107
return error;
80108

81-
error = regmap_read(ts->regmap, HIMAX_AHB_ADDR_RDATA_BYTE_0, dst);
109+
if (length > 4)
110+
error = regmap_noinc_read(ts->regmap, HIMAX_AHB_ADDR_RDATA_BYTE_0,
111+
dst, length);
112+
else
113+
error = regmap_read(ts->regmap, HIMAX_AHB_ADDR_RDATA_BYTE_0,
114+
dst);
115+
if (error)
116+
return error;
117+
118+
return 0;
119+
}
120+
121+
static int himax_read_mcu(struct himax_ts_data *ts, u32 address, u32 *dst)
122+
{
123+
int error;
124+
125+
error = himax_bus_read(ts, address, dst, sizeof(dst));
82126
if (error)
83127
return error;
84128

@@ -104,7 +148,7 @@ static int himax_read_product_id(struct himax_ts_data *ts, u32 *product_id)
104148
{
105149
int error;
106150

107-
error = himax_read_config(ts, HIMAX_REG_ADDR_ICID, product_id);
151+
error = himax_read_mcu(ts, HIMAX_REG_ADDR_ICID, product_id);
108152
if (error)
109153
return error;
110154

0 commit comments

Comments
 (0)