e0725a6612932389232955d7a6ee5a0f095ba81d
[openwrt/staging/stintel.git] / target / linux / ipq807x / patches-6.1 / 0008-v6.2-clk-qcom-reset-support-resetting-multiple-bits.patch
1 From 813ba3e427671ba3ff35c825087b03f0ad91cf02 Mon Sep 17 00:00:00 2001
2 From: Robert Marko <robimarko@gmail.com>
3 Date: Mon, 7 Nov 2022 14:28:59 +0100
4 Subject: [PATCH] clk: qcom: reset: support resetting multiple bits
5
6 This patch adds the support for giving the complete bitmask
7 in reset structure and reset operation will use this bitmask
8 for all reset operations.
9
10 Currently, reset structure only takes a single bit for each reset
11 and then calculates the bitmask by using the BIT() macro.
12
13 However, this is not sufficient anymore for newer SoC-s like IPQ8074,
14 IPQ6018 and more, since their networking resets require multiple bits
15 to be asserted in order to properly reset the HW block completely.
16
17 So, in order to allow asserting multiple bits add "bitmask" field to
18 qcom_reset_map, and then use that bitmask value if its populated in the
19 driver, if its not populated, then we just default to existing behaviour
20 and calculate the bitmask on the fly.
21
22 Signed-off-by: Robert Marko <robimarko@gmail.com>
23 Signed-off-by: Bjorn Andersson <andersson@kernel.org>
24 Link: https://lore.kernel.org/r/20221107132901.489240-1-robimarko@gmail.com
25 ---
26 drivers/clk/qcom/reset.c | 4 ++--
27 drivers/clk/qcom/reset.h | 1 +
28 2 files changed, 3 insertions(+), 2 deletions(-)
29
30 --- a/drivers/clk/qcom/reset.c
31 +++ b/drivers/clk/qcom/reset.c
32 @@ -30,7 +30,7 @@ qcom_reset_assert(struct reset_controlle
33
34 rst = to_qcom_reset_controller(rcdev);
35 map = &rst->reset_map[id];
36 - mask = BIT(map->bit);
37 + mask = map->bitmask ? map->bitmask : BIT(map->bit);
38
39 return regmap_update_bits(rst->regmap, map->reg, mask, mask);
40 }
41 @@ -44,7 +44,7 @@ qcom_reset_deassert(struct reset_control
42
43 rst = to_qcom_reset_controller(rcdev);
44 map = &rst->reset_map[id];
45 - mask = BIT(map->bit);
46 + mask = map->bitmask ? map->bitmask : BIT(map->bit);
47
48 return regmap_update_bits(rst->regmap, map->reg, mask, 0);
49 }
50 --- a/drivers/clk/qcom/reset.h
51 +++ b/drivers/clk/qcom/reset.h
52 @@ -12,6 +12,7 @@ struct qcom_reset_map {
53 unsigned int reg;
54 u8 bit;
55 u8 udelay;
56 + u32 bitmask;
57 };
58
59 struct regmap;