From: Marek Vasut Date: Sat, 18 Mar 2023 11:30:53 +0000 (+0100) Subject: clk: renesas: Pack reset identifier before look up X-Git-Tag: baikal/mips/sdk5.8.2~5^2~17^2 X-Git-Url: https://git.baikalelectronics.ru/sdk/?a=commitdiff_plain;h=42f5ce2074efc7d7ae6fe15872e0f489c1fd97f9;p=uboot.git clk: renesas: Pack reset identifier before look up The reset identifier must be processed via MOD_CLK_PACK() before it is used to look up register and bit within reset_regs or reset_clear_regs arrays, otherwise completely bogus register and bit is picked from the arrays, one which may even be out of range. Fixes: 97c9d810b50 ("clk: renesas: Add and enable CPG reset driver") Signed-off-by: Marek Vasut --- diff --git a/drivers/clk/renesas/clk-rcar-gen3.c b/drivers/clk/renesas/clk-rcar-gen3.c index d778db6569..c121d82de7 100644 --- a/drivers/clk/renesas/clk-rcar-gen3.c +++ b/drivers/clk/renesas/clk-rcar-gen3.c @@ -479,8 +479,9 @@ static int gen3_reset_assert(struct reset_ctl *reset_ctl) { struct udevice *cdev = (struct udevice *)dev_get_driver_data(reset_ctl->dev); struct gen3_clk_priv *priv = dev_get_priv(cdev); - unsigned int reg = reset_ctl->id / 32; - unsigned int bit = reset_ctl->id % 32; + unsigned int packed_id = MOD_CLK_PACK(reset_ctl->id); + unsigned int reg = packed_id / 32; + unsigned int bit = packed_id % 32; u32 bitmask = BIT(bit); writel(bitmask, priv->base + priv->info->reset_regs[reg]); @@ -492,8 +493,9 @@ static int gen3_reset_deassert(struct reset_ctl *reset_ctl) { struct udevice *cdev = (struct udevice *)dev_get_driver_data(reset_ctl->dev); struct gen3_clk_priv *priv = dev_get_priv(cdev); - unsigned int reg = reset_ctl->id / 32; - unsigned int bit = reset_ctl->id % 32; + unsigned int packed_id = MOD_CLK_PACK(reset_ctl->id); + unsigned int reg = packed_id / 32; + unsigned int bit = packed_id % 32; u32 bitmask = BIT(bit); writel(bitmask, priv->base + priv->info->reset_clear_regs[reg]);