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
7 Allow sfpb-mutex to use mmio in addition to syscon.
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
14 drivers/hwspinlock/qcom_hwspinlock.c | 28 +++++++++++++++++++++++-----
15 1 file changed, 23 insertions(+), 5 deletions(-)
17 --- a/drivers/hwspinlock/qcom_hwspinlock.c
18 +++ b/drivers/hwspinlock/qcom_hwspinlock.c
20 #define QCOM_MUTEX_APPS_PROC_ID 1
21 #define QCOM_MUTEX_NUM_LOCKS 32
23 +struct qcom_hwspinlock_of_data {
28 static int qcom_hwspinlock_trylock(struct hwspinlock *lock)
30 struct regmap_field *field = lock->priv;
31 @@ -63,9 +68,20 @@ static const struct hwspinlock_ops qcom_
32 .unlock = qcom_hwspinlock_unlock,
35 +static const struct qcom_hwspinlock_of_data of_sfpb_mutex = {
40 +/* All modern platform has offset 0 and stride of 4k */
41 +static const struct qcom_hwspinlock_of_data of_tcsr_mutex = {
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 },
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)
58 + const struct qcom_hwspinlock_of_data *data;
59 struct device *dev = &pdev->dev;
62 - /* All modern platform has offset 0 and stride of 4k */
65 + data = of_device_get_match_data(dev);
67 + *offset = data->offset;
68 + *stride = data->stride;
70 base = devm_platform_ioremap_resource(pdev, 0);