On Fri, Mar 17, 2023 at 09:56:59PM +0100, Linus Walleij wrote: > On Fri, Mar 17, 2023 at 5:28 PM Mukesh Ojha <quic_mojha@xxxxxxxxxxx> wrote: > > > It was released by Srinivas K. that there is a need of > > read-modify-write scm exported function so that it can > > be used by multiple clients. > > > > Let's introduce qcom_scm_io_update_field() which masks > > out the bits and write the passed value to that > > bit-offset. Subsequent patch will use this function. > > > > Suggested-by: Srinivas Kandagatla <srinivas.kandagatla@xxxxxxxxxx> > > Signed-off-by: Mukesh Ojha <quic_mojha@xxxxxxxxxxx> > > This is starting to reimplement regmap. > In this case regmap_update_bits(). > > What about just using regmap as accessor for these > registers instead? > I'm not sure it would be beneficial... The regmap interface provides a standardized representation of a block of registers, with the suitable accessors backing it. But in both cases touched upon in this series, the addressed registers are part of regions already handled by the kernel. So it wouldn't be suitable to create a regmap-abstraction for "a block of secure registers", at best that would give us two kinds of regmaps abstracting the same register block. Instead I believe we'd need to extend the struct regmap_config to introduce a new table telling a new secure-or-unsecure-mmio-regmap which accessor (secure or unsecure read/write) shoudl be used, and then have e.g. pinctrl-msm register such regmap, passing the information about which registers in its memory region is secure. We'd still need qcom_scm_io_readl() and qcom_scm_io_writel() exported to implement the new custom regmap implementation - and the struct regmap_config needed in just pinctrl-msm alone would be larger than the one function it replaces. But please let me know if I'm missing something? Regards, Bjorn