On Sun, Nov 14, 2021 at 8:41 PM christopher tyerman <linuxkernel@xxxxxxxxxxxxxxx> 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