at91: add kernel support for sama7g5 soc
[openwrt/openwrt.git] / target / linux / at91 / patches-5.10 / 241-clk-at91-clk-master-mask-mckr-against-layout-mask.patch
1 From 27c11c09346b7b9f67eeb39db1b943f4a9742ff3 Mon Sep 17 00:00:00 2001
2 From: Claudiu Beznea <claudiu.beznea@microchip.com>
3 Date: Mon, 11 Oct 2021 14:27:13 +0300
4 Subject: [PATCH 241/247] clk: at91: clk-master: mask mckr against layout->mask
5
6 Mask values read/written from/to MCKR against layout->mask as this
7 mask may be different b/w PMC versions.
8
9 Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
10 Link: https://lore.kernel.org/r/20211011112719.3951784-10-claudiu.beznea@microchip.com
11 Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com>
12 Signed-off-by: Stephen Boyd <sboyd@kernel.org>
13 ---
14 drivers/clk/at91/clk-master.c | 7 +++++--
15 1 file changed, 5 insertions(+), 2 deletions(-)
16
17 diff --git a/drivers/clk/at91/clk-master.c b/drivers/clk/at91/clk-master.c
18 index 2093e13b5068..6da9ae34313a 100644
19 --- a/drivers/clk/at91/clk-master.c
20 +++ b/drivers/clk/at91/clk-master.c
21 @@ -186,8 +186,8 @@ static int clk_master_div_set_rate(struct clk_hw *hw, unsigned long rate,
22 if (ret)
23 goto unlock;
24
25 - tmp = mckr & master->layout->mask;
26 - tmp = (tmp >> MASTER_DIV_SHIFT) & MASTER_DIV_MASK;
27 + mckr &= master->layout->mask;
28 + tmp = (mckr >> MASTER_DIV_SHIFT) & MASTER_DIV_MASK;
29 if (tmp == div)
30 goto unlock;
31
32 @@ -384,6 +384,7 @@ static unsigned long clk_master_pres_recalc_rate(struct clk_hw *hw,
33 regmap_read(master->regmap, master->layout->offset, &val);
34 spin_unlock_irqrestore(master->lock, flags);
35
36 + val &= master->layout->mask;
37 pres = (val >> master->layout->pres_shift) & MASTER_PRES_MASK;
38 if (pres == 3 && characteristics->have_div3_pres)
39 pres = 3;
40 @@ -403,6 +404,8 @@ static u8 clk_master_pres_get_parent(struct clk_hw *hw)
41 regmap_read(master->regmap, master->layout->offset, &mckr);
42 spin_unlock_irqrestore(master->lock, flags);
43
44 + mckr &= master->layout->mask;
45 +
46 return mckr & AT91_PMC_CSS;
47 }
48
49 --
50 2.32.0
51