"regmap: how to handle two 'control byte' model"

From: Radoslav Kolev
Date: Tue Jun 16 2015 - 10:35:54 EST


Hello!

I need a driver for the tsc2004 I2C touch screen controller and I'm
trying to adapt the tsc2005 driver (same controller on SPI). Regmap
seems exactly the solution for this, but I'm completely new to it and
can't quite figure out how to handle one quirk of the chip.

The chip has 2 'control bytes' differentiated by the most significant
bit - 0 and 1. Control byte 0 has it's MSB as 0, a 4 bit register
address field, one unrelated configuration bit and a read/write bit.
After sending this control byte with the right register address and
direction set you read/write the register value - so it mostly fits
nicely within the regmap framework concepts (excluding the one config
bit).

Control byte 1 has its MSB as 1 followed by 7 bits selecting the chips
mode of operation, resolution and a software reset.

The problem is how to fit this 2 control bytes model within the regmap
framework? From looking at the code a possible way is to set reg_bits
to 1 and val_bits to 7 to be able to access the two 'control bytes'
and then try to get the actual data registers through a regmap_range
paged/indirect access.

Currently the lowest supported value for reg_bits seems to be 2
though, and I'll also need different val_bits for the 'control bytes'
vs regular registers and I don't think that's possible. In the end the
whole thing starts to feel like abusing the paged/indirect access
feature.

Another solution could be to use two separate regmaps - one for the
'control bytes' and one for the registers, but again there's no
support for reg/val bits 1/7 and it doesn't feel optimal either.

What is the correct/preferred way to use regmap in this situation?

Cheers!
Radoslav
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/