2c6f6b10c48e72bbe8cc58eac74118e5e946c8cd
[openwrt/staging/stintel.git] /
1 From cdab30b44518513003607ecfc8a22de3dbbb78ed Mon Sep 17 00:00:00 2001
2 From: Christian Marangi <ansuelsmth@gmail.com>
3 Date: Thu, 7 Jul 2022 12:20:38 +0200
4 Subject: [PATCH 1/1] hwspinlock: qcom: Add support for mmio usage to
5 sfpb-mutex
6
7 Allow sfpb-mutex to use mmio in addition to syscon.
8
9 Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
10 Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
11 Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
12 Link: https://lore.kernel.org/r/20220707102040.1859-1-ansuelsmth@gmail.com
13 ---
14 drivers/hwspinlock/qcom_hwspinlock.c | 28 +++++++++++++++++++++++-----
15 1 file changed, 23 insertions(+), 5 deletions(-)
16
17 --- a/drivers/hwspinlock/qcom_hwspinlock.c
18 +++ b/drivers/hwspinlock/qcom_hwspinlock.c
19 @@ -19,6 +19,11 @@
20 #define QCOM_MUTEX_APPS_PROC_ID 1
21 #define QCOM_MUTEX_NUM_LOCKS 32
22
23 +struct qcom_hwspinlock_of_data {
24 + u32 offset;
25 + u32 stride;
26 +};
27 +
28 static int qcom_hwspinlock_trylock(struct hwspinlock *lock)
29 {
30 struct regmap_field *field = lock->priv;
31 @@ -63,9 +68,20 @@ static const struct hwspinlock_ops qcom_
32 .unlock = qcom_hwspinlock_unlock,
33 };
34
35 +static const struct qcom_hwspinlock_of_data of_sfpb_mutex = {
36 + .offset = 0x4,
37 + .stride = 0x4,
38 +};
39 +
40 +/* All modern platform has offset 0 and stride of 4k */
41 +static const struct qcom_hwspinlock_of_data of_tcsr_mutex = {
42 + .offset = 0,
43 + .stride = 0x1000,
44 +};
45 +
46 static const struct of_device_id qcom_hwspinlock_of_match[] = {
47 - { .compatible = "qcom,sfpb-mutex" },
48 - { .compatible = "qcom,tcsr-mutex" },
49 + { .compatible = "qcom,sfpb-mutex", .data = &of_sfpb_mutex },
50 + { .compatible = "qcom,tcsr-mutex", .data = &of_tcsr_mutex },
51 { }
52 };
53 MODULE_DEVICE_TABLE(of, qcom_hwspinlock_of_match);
54 @@ -112,12 +128,14 @@ static const struct regmap_config tcsr_m
55 static struct regmap *qcom_hwspinlock_probe_mmio(struct platform_device *pdev,
56 u32 *offset, u32 *stride)
57 {
58 + const struct qcom_hwspinlock_of_data *data;
59 struct device *dev = &pdev->dev;
60 void __iomem *base;
61
62 - /* All modern platform has offset 0 and stride of 4k */
63 - *offset = 0;
64 - *stride = 0x1000;
65 + data = of_device_get_match_data(dev);
66 +
67 + *offset = data->offset;
68 + *stride = data->stride;
69
70 base = devm_platform_ioremap_resource(pdev, 0);
71 if (IS_ERR(base))