Skip to content

Commit c636eef

Browse files
committed
Merge tag 'hwlock-v5.9' of git://git.kernel.org/pub/scm/linux/kernel/git/andersson/remoteproc
Pull hwspinlock updates from Bjorn Andersson: "This introduces a new DT binding format to describe the Qualcomm hardware mutex block and deprecates the old, invalid, one. It also cleans up the Kconfig slightly" * tag 'hwlock-v5.9' of git://git.kernel.org/pub/scm/linux/kernel/git/andersson/remoteproc: dt-bindings: hwlock: qcom: Remove invalid binding hwspinlock: qcom: Allow mmio usage in addition to syscon dt-bindings: hwlock: qcom: Allow device on mmio bus dt-bindings: hwlock: qcom: Migrate binding to YAML hwspinlock: Simplify Kconfig
2 parents 617e748 + 35efb0e commit c636eef

File tree

4 files changed

+100
-61
lines changed

4 files changed

+100
-61
lines changed

Documentation/devicetree/bindings/hwlock/qcom-hwspinlock.txt

Lines changed: 0 additions & 39 deletions
This file was deleted.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2+
%YAML 1.2
3+
---
4+
$id: http://devicetree.org/schemas/hwlock/qcom-hwspinlock.yaml#
5+
$schema: http://devicetree.org/meta-schemas/core.yaml#
6+
7+
title: Qualcomm Hardware Mutex Block
8+
9+
maintainers:
10+
- Bjorn Andersson <[email protected]>
11+
12+
description:
13+
The hardware block provides mutexes utilized between different processors on
14+
the SoC as part of the communication protocol used by these processors.
15+
16+
properties:
17+
compatible:
18+
enum:
19+
- qcom,sfpb-mutex
20+
- qcom,tcsr-mutex
21+
22+
reg:
23+
maxItems: 1
24+
25+
'#hwlock-cells':
26+
const: 1
27+
28+
required:
29+
- compatible
30+
- reg
31+
- '#hwlock-cells'
32+
33+
additionalProperties: false
34+
35+
examples:
36+
- |
37+
tcsr_mutex: hwlock@1f40000 {
38+
compatible = "qcom,tcsr-mutex";
39+
reg = <0x01f40000 0x40000>;
40+
#hwlock-cells = <1>;
41+
};
42+
...

drivers/hwspinlock/Kconfig

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66
menuconfig HWSPINLOCK
77
bool "Hardware Spinlock drivers"
88

9+
if HWSPINLOCK
10+
911
config HWSPINLOCK_OMAP
1012
tristate "OMAP Hardware Spinlock device"
11-
depends on HWSPINLOCK
1213
depends on ARCH_OMAP4 || SOC_OMAP5 || SOC_DRA7XX || SOC_AM33XX || SOC_AM43XX || ARCH_K3 || COMPILE_TEST
1314
help
1415
Say y here to support the OMAP Hardware Spinlock device (firstly
@@ -18,7 +19,6 @@ config HWSPINLOCK_OMAP
1819

1920
config HWSPINLOCK_QCOM
2021
tristate "Qualcomm Hardware Spinlock device"
21-
depends on HWSPINLOCK
2222
depends on ARCH_QCOM || COMPILE_TEST
2323
select MFD_SYSCON
2424
help
@@ -30,7 +30,6 @@ config HWSPINLOCK_QCOM
3030

3131
config HWSPINLOCK_SIRF
3232
tristate "SIRF Hardware Spinlock device"
33-
depends on HWSPINLOCK
3433
depends on ARCH_SIRF || COMPILE_TEST
3534
help
3635
Say y here to support the SIRF Hardware Spinlock device, which
@@ -43,7 +42,6 @@ config HWSPINLOCK_SIRF
4342
config HWSPINLOCK_SPRD
4443
tristate "SPRD Hardware Spinlock device"
4544
depends on ARCH_SPRD || COMPILE_TEST
46-
depends on HWSPINLOCK
4745
help
4846
Say y here to support the SPRD Hardware Spinlock device.
4947

@@ -52,19 +50,19 @@ config HWSPINLOCK_SPRD
5250
config HWSPINLOCK_STM32
5351
tristate "STM32 Hardware Spinlock device"
5452
depends on MACH_STM32MP157 || COMPILE_TEST
55-
depends on HWSPINLOCK
5653
help
5754
Say y here to support the STM32 Hardware Spinlock device.
5855

5956
If unsure, say N.
6057

6158
config HSEM_U8500
6259
tristate "STE Hardware Semaphore functionality"
63-
depends on HWSPINLOCK
6460
depends on ARCH_U8500 || COMPILE_TEST
6561
help
6662
Say y here to support the STE Hardware Semaphore functionality, which
6763
provides a synchronisation mechanism for the various processor on the
6864
SoC.
6965

7066
If unsure, say N.
67+
68+
endif # HWSPINLOCK

drivers/hwspinlock/qcom_hwspinlock.c

Lines changed: 54 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -70,41 +70,79 @@ static const struct of_device_id qcom_hwspinlock_of_match[] = {
7070
};
7171
MODULE_DEVICE_TABLE(of, qcom_hwspinlock_of_match);
7272

73-
static int qcom_hwspinlock_probe(struct platform_device *pdev)
73+
static struct regmap *qcom_hwspinlock_probe_syscon(struct platform_device *pdev,
74+
u32 *base, u32 *stride)
7475
{
75-
struct hwspinlock_device *bank;
7676
struct device_node *syscon;
77-
struct reg_field field;
7877
struct regmap *regmap;
79-
size_t array_size;
80-
u32 stride;
81-
u32 base;
8278
int ret;
83-
int i;
8479

8580
syscon = of_parse_phandle(pdev->dev.of_node, "syscon", 0);
86-
if (!syscon) {
87-
dev_err(&pdev->dev, "no syscon property\n");
88-
return -ENODEV;
89-
}
81+
if (!syscon)
82+
return ERR_PTR(-ENODEV);
9083

9184
regmap = syscon_node_to_regmap(syscon);
9285
of_node_put(syscon);
9386
if (IS_ERR(regmap))
94-
return PTR_ERR(regmap);
87+
return regmap;
9588

96-
ret = of_property_read_u32_index(pdev->dev.of_node, "syscon", 1, &base);
89+
ret = of_property_read_u32_index(pdev->dev.of_node, "syscon", 1, base);
9790
if (ret < 0) {
9891
dev_err(&pdev->dev, "no offset in syscon\n");
99-
return -EINVAL;
92+
return ERR_PTR(-EINVAL);
10093
}
10194

102-
ret = of_property_read_u32_index(pdev->dev.of_node, "syscon", 2, &stride);
95+
ret = of_property_read_u32_index(pdev->dev.of_node, "syscon", 2, stride);
10396
if (ret < 0) {
10497
dev_err(&pdev->dev, "no stride syscon\n");
105-
return -EINVAL;
98+
return ERR_PTR(-EINVAL);
10699
}
107100

101+
return regmap;
102+
}
103+
104+
static const struct regmap_config tcsr_mutex_config = {
105+
.reg_bits = 32,
106+
.reg_stride = 4,
107+
.val_bits = 32,
108+
.max_register = 0x40000,
109+
.fast_io = true,
110+
};
111+
112+
static struct regmap *qcom_hwspinlock_probe_mmio(struct platform_device *pdev,
113+
u32 *offset, u32 *stride)
114+
{
115+
struct device *dev = &pdev->dev;
116+
void __iomem *base;
117+
118+
/* All modern platform has offset 0 and stride of 4k */
119+
*offset = 0;
120+
*stride = 0x1000;
121+
122+
base = devm_platform_ioremap_resource(pdev, 0);
123+
if (IS_ERR(base))
124+
return ERR_CAST(base);
125+
126+
return devm_regmap_init_mmio(dev, base, &tcsr_mutex_config);
127+
}
128+
129+
static int qcom_hwspinlock_probe(struct platform_device *pdev)
130+
{
131+
struct hwspinlock_device *bank;
132+
struct reg_field field;
133+
struct regmap *regmap;
134+
size_t array_size;
135+
u32 stride;
136+
u32 base;
137+
int i;
138+
139+
regmap = qcom_hwspinlock_probe_syscon(pdev, &base, &stride);
140+
if (IS_ERR(regmap) && PTR_ERR(regmap) == -ENODEV)
141+
regmap = qcom_hwspinlock_probe_mmio(pdev, &base, &stride);
142+
143+
if (IS_ERR(regmap))
144+
return PTR_ERR(regmap);
145+
108146
array_size = QCOM_MUTEX_NUM_LOCKS * sizeof(struct hwspinlock);
109147
bank = devm_kzalloc(&pdev->dev, sizeof(*bank) + array_size, GFP_KERNEL);
110148
if (!bank)

0 commit comments

Comments
 (0)