clk: mediatek: add array size field for id_offs_map

Add id_offs_map_size field to struct mtk_clk_tree and populate it for
all existing drivers.

Currently, there is no bounds checking when accessing the id_offs_map
array. Adding this field will allow for bounds checking in the future.

Signed-off-by: David Lechner <dlechner@baylibre.com>
This commit is contained in:
David Lechner
2026-01-07 09:50:13 -06:00
committed by Tom Rini
parent 538f72f403
commit 6094f0a040
3 changed files with 5 additions and 0 deletions

View File

@@ -996,6 +996,7 @@ static const struct mtk_gate hif_cgs[] = {
static const struct mtk_clk_tree mt7623_apmixedsys_clk_tree = {
.xtal2_rate = 26 * MHZ,
.id_offs_map = pll_id_offs_map,
.id_offs_map_size = ARRAY_SIZE(pll_id_offs_map),
.plls = apmixed_plls,
.num_plls = ARRAY_SIZE(apmixed_plls),
};
@@ -1003,6 +1004,7 @@ static const struct mtk_clk_tree mt7623_apmixedsys_clk_tree = {
static const struct mtk_clk_tree mt7623_topckgen_clk_tree = {
.xtal_rate = 26 * MHZ,
.id_offs_map = top_id_offs_map,
.id_offs_map_size = ARRAY_SIZE(top_id_offs_map),
.fdivs_offs = top_id_offs_map[CLK_TOP_SYSPLL],
.muxes_offs = top_id_offs_map[CLK_TOP_AXI_SEL],
.fclks = top_fixed_clks,
@@ -1063,6 +1065,7 @@ static int mt7623_infracfg_probe(struct udevice *dev)
static const struct mtk_clk_tree mt7623_clk_peri_tree = {
.id_offs_map = peri_id_offs_map,
.id_offs_map_size = ARRAY_SIZE(peri_id_offs_map),
.muxes_offs = peri_id_offs_map[CLK_PERI_UART0_SEL],
.gates_offs = peri_id_offs_map[CLK_PERI_NFI],
.muxes = peri_muxes,

View File

@@ -1360,6 +1360,7 @@ static const struct mtk_clk_tree mt8188_topckgen_clk_tree = {
.xtal_rate = 26 * MHZ,
.xtal2_rate = 26 * MHZ,
.id_offs_map = mt8188_id_offs_map,
.id_offs_map_size = ARRAY_SIZE(mt8188_id_offs_map),
.fdivs_offs = 8, /* CLK_TOP_MAINPLL_D3 */
.muxes_offs = 87, /* CLK_TOP_AXI */
.fclks = top_fixed_clks,

View File

@@ -252,6 +252,7 @@ struct mtk_clk_tree {
* ID for factor, mux and gates.
*/
const int *id_offs_map; /* optional, table clk.h to driver ID */
const int id_offs_map_size;
const int fdivs_offs;
const int muxes_offs;
const int gates_offs;