* Remap, SPI and parity bit
@ 2021-11-14 18:41 christopher tyerman
2021-11-15 15:14 ` Andy Shevchenko
0 siblings, 1 reply; 3+ messages in thread
From: christopher tyerman @ 2021-11-14 18:41 UTC (permalink / raw)
To: linux-spi
hello
I'm not sure if this is the correct place to be asking this, if there is
a better place please redirect me.
I'm currently working on a kernel driver for the Texas Instruments
tps92518-Q1 and tps92518HV-Q1.
This device uses 16-bit SPI Frames (7-bit control, 9-bit data).
is "Command Frame"
|1-bit command bit 5-bit Address 1-bit parity 9-bit data|
requires a parity bit
|PARITY = XNOR(CMD, A4..A0, D8..D0)|
I'm trying to use regmaps where possible and I can define a regmap, e.g.
|static struct regmap_config tps92518_regmap_config = { .reg_bits = 6,
.pad_bits = 1, // parity bit .val_bits = 9, .max_register =
tps92518_RESET, }; |
however so far i cannot currently see how to automatically calculate it
without replacing large chunks of code
e.g replacing chunks of /drivers/base/regmap/regmap-spi.c with a new
regmap_bus
some where i need to be able to calculate and insert a parity bit
is there anywhere i can setup a callback that preprocesses the spi
frames before sending?
I'm working up the chain an i can see a potential patch to regmaps that
would fix this if nothing better already exists
with regmap_config exists /@read_flag_mask/ and /@write_flag_mask/,
along the same line there could be added a "@read_parity_mask" and
"@write_parity_mask"
and an optional "@reg_parity" callback that calculates the parity
from/reg/ and /val/ similar/@reg_read/ and /@reg_write/ but without
replacing the entire read/write operations
I may even be able to write this but that is outside the spi-subsystem,
and i'm currently not sure what list regmaps fall under
i apologise if this is the wrong list and, thankyou for any responses
kind regards
christopher tyerman
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Remap, SPI and parity bit
2021-11-14 18:41 Remap, SPI and parity bit christopher tyerman
@ 2021-11-15 15:14 ` Andy Shevchenko
2021-11-15 18:36 ` Mark Brown
0 siblings, 1 reply; 3+ messages in thread
From: Andy Shevchenko @ 2021-11-15 15:14 UTC (permalink / raw)
To: christopher tyerman, Mark Brown, Lee Jones, Pavel Machek; +Cc: linux-spi
On Sun, Nov 14, 2021 at 8:41 PM christopher tyerman
<linuxkernel@fbautosys.co.uk> wrote:
> I'm not sure if this is the correct place to be asking this, if there is
> a better place please redirect me.
I guess it's induced by your (?) posts on SO?
Anyway, it's the correct place to ask, yes. I Cc'ed this to regulator,
LED, and MFD subsystem maintainers to gather their opinions.
> I'm currently working on a kernel driver for the Texas Instruments
> tps92518-Q1 and tps92518HV-Q1.
>
> This device uses 16-bit SPI Frames (7-bit control, 9-bit data).
>
> is "Command Frame"
>
> |1-bit command bit 5-bit Address 1-bit parity 9-bit data|
>
> requires a parity bit
>
> |PARITY = XNOR(CMD, A4..A0, D8..D0)|
>
> I'm trying to use regmaps where possible and I can define a regmap, e.g.
>
> |static struct regmap_config tps92518_regmap_config = { .reg_bits = 6,
> .pad_bits = 1, // parity bit .val_bits = 9, .max_register =
> tps92518_RESET, }; |
>
> however so far i cannot currently see how to automatically calculate it
> without replacing large chunks of code
>
> e.g replacing chunks of /drivers/base/regmap/regmap-spi.c with a new
> regmap_bus
>
> some where i need to be able to calculate and insert a parity bit
>
> is there anywhere i can setup a callback that preprocesses the spi
> frames before sending?
>
> I'm working up the chain an i can see a potential patch to regmaps that
> would fix this if nothing better already exists
>
> with regmap_config exists /@read_flag_mask/ and /@write_flag_mask/,
> along the same line there could be added a "@read_parity_mask" and
> "@write_parity_mask"
> and an optional "@reg_parity" callback that calculates the parity
> from/reg/ and /val/ similar/@reg_read/ and /@reg_write/ but without
> replacing the entire read/write operations
>
> I may even be able to write this but that is outside the spi-subsystem,
> and i'm currently not sure what list regmaps fall under
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Remap, SPI and parity bit
2021-11-15 15:14 ` Andy Shevchenko
@ 2021-11-15 18:36 ` Mark Brown
0 siblings, 0 replies; 3+ messages in thread
From: Mark Brown @ 2021-11-15 18:36 UTC (permalink / raw)
To: Andy Shevchenko; +Cc: christopher tyerman, Lee Jones, Pavel Machek, linux-spi
[-- Attachment #1: Type: text/plain, Size: 651 bytes --]
On Mon, Nov 15, 2021 at 05:14:52PM +0200, Andy Shevchenko wrote:
> On Sun, Nov 14, 2021 at 8:41 PM christopher tyerman
>
> > I'm trying to use regmaps where possible and I can define a regmap, e.g.
...
> > however so far i cannot currently see how to automatically calculate it
> > without replacing large chunks of code
This seems like a sign that you should be extending the core so that it
supports having a parity bit, it looks like there's at least some other
parts with this functionality. The pattern seems to be a bit that that
it's a bit at some specified offset which is the parity of all other
non-pad bits in the write.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-11-16 1:02 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-14 18:41 Remap, SPI and parity bit christopher tyerman
2021-11-15 15:14 ` Andy Shevchenko
2021-11-15 18:36 ` Mark Brown
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.