On 14. 04. 25 7:09 odp., Andy Shevchenko wrote:
Now, get it...

I was a little bit confused by code of _regmap_select_page() that takes
care of selector_reg.

Btw, why is this needed? why they cannot overlap?

Let's say I have virtual range <0, 0xfff>, window <0, 0xff> and window
selector 0xff>.
1. I'm calling regmap_read(regmap, 0x8f, ...)
2. The regmap looks for the range and it finds it (0..0xfff)
3. Then it calls _regmap_select_page() that computes:
     window_offset = (0x8f - 0x000) % 0x100 = 0x8f
     window_page = (0x8f - 0x000) / 0x100 = 0
4. _regmap_select_page() set window selector to 0 and reg is updated to
     reg = window_start + window_offset = 0x8f

And for window_selector value: regmap_read(regmap, 0xff, ...) is the
same except _regmap_select_page() checks that the given address is
selector_reg and won't perform page switching.

When I think about it, in my case there is no normal page, there is only
volatile register window <0x00-0x7e> and only single direct register
that is page selector at 0x7f.
Because you are effectively messing up with cache. Also it's not
recommended in general to do such due to some registers that might
need to be accessed directly. And also note, that each time you access
this you will call a selector write_each_ time you want to write the
register in the map (if there is no cache, or if cache is messed up).

Get it fully now...

Thank you, Andy, for the explanation and for the patience.

Will send v3 soon.

Ivan


Reply via email to