Re: [PATCH v2 07/14] mfd: zl3073x: Add components versions register defs

Ivan Vecera
2025-04-11T13:17:34Z

On 11. 04. 25 1:19 odp., Ivan Vecera wrote:
> The range for regmap 1: (registers 0x000-0x4FF)
> regmap_range_cfg {
>     .range_min = 0,
>     .range_max = 10 * 128 - 1, /* 10 pages, 128 registers each */
>     .selector_reg = 0x7f,      /* page selector at each page */
>     .selector_shift = 0,       /* no shift in page selector */
>     .selector_mask = GENMASK(3, 0),    /* 4 bits for page sel */
>     .window_start = 0,         /* 128 regs from 0x00-0x7f */
>     .window_len = 128,
> };
>
> The range for regmap 2: (registers 0x500-0x77F)
> regmap_range_cfg {
>     .range_min = 10 * 128,
>     .range_max = 15 * 128 - 1, /* 5 pages, 128 registers each */
>     .selector_reg = 0x7f,      /* page selector at each page */
>     .selector_shift = 0,       /* no shift in page selector */
>     .selector_mask = GENMASK(3, 0),    /* 4 bits for page sel */
>     .window_start = 0,         /* 128 regs from 0x00-0x7f */
>     .window_len = 128,
> };
>
> Is it now OK?

No this is not good... I cannot use 2 ranges.

This is not safe... if the caller use regmap 2 to read/write something
below 0x500 (by mistake), no mapping is applied and value is directly
used as register number that's wrong :-(.

Should I use rather single mapping range to cover all pages and ensure
at driver level that regmap 2 is not used for regs < 0x500?
-or-
what would be the best approach?

I.