Commit 8ae08dcd authored by Etienne Carriere's avatar Etienne Carriere
Browse files

drivers: stm32mp1 clocks: support shifted clock selector bit masks



The current implementation optimizes memory consumed by gateable
clock table by storing bit mask and bit shift with 1 byte each.
The issue is that register selector bit masks above the 7th LSBit
cannot be stored.

This change uses the shift info to shift the mask before it is used,
allowing clock selector register bit fields to be spread on the 32 bits
of the register as long as the mask fits in 8 contiguous bit at most.

This change is needed to add the RTC clock to the gateable clocks table.

Change-Id: I8a0fbcbf20ea383fb3d712f5064d2d307e44465d
Signed-off-by: default avatarEtienne Carriere <etienne.carriere@st.com>
parent 8fbcd9e4
......@@ -310,7 +310,8 @@ struct stm32mp1_clk_pll {
[_ ## _label ## _SEL] = { \
.offset = _rcc_selr, \
.src = _rcc_selr ## _ ## _label ## SRC_SHIFT, \
.msk = _rcc_selr ## _ ## _label ## SRC_MASK, \
.msk = (_rcc_selr ## _ ## _label ## SRC_MASK) >> \
(_rcc_selr ## _ ## _label ## SRC_SHIFT), \
.parent = (_parents), \
.nb_parent = ARRAY_SIZE(_parents) \
}
......@@ -697,7 +698,8 @@ static int stm32mp1_clk_get_parent(unsigned long id)
}
sel = clk_sel_ref(s);
p_sel = (mmio_read_32(rcc_base + sel->offset) & sel->msk) >> sel->src;
p_sel = (mmio_read_32(rcc_base + sel->offset) &
(sel->msk << sel->src)) >> sel->src;
if (p_sel < sel->nb_parent) {
return (int)sel->parent[p_sel];
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment