Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

+105 -66
-39
Documentation/devicetree/bindings/hwlock/qcom-hwspinlock.txt
··· 1 - Qualcomm Hardware Mutex Block: 2 - 3 - The hardware block provides mutexes utilized between different processors on 4 - the SoC as part of the communication protocol used by these processors. 5 - 6 - - compatible: 7 - Usage: required 8 - Value type: <string> 9 - Definition: must be one of: 10 - "qcom,sfpb-mutex", 11 - "qcom,tcsr-mutex" 12 - 13 - - syscon: 14 - Usage: required 15 - Value type: <prop-encoded-array> 16 - Definition: one cell containing: 17 - syscon phandle 18 - offset of the hwmutex block within the syscon 19 - stride of the hwmutex registers 20 - 21 - - #hwlock-cells: 22 - Usage: required 23 - Value type: <u32> 24 - Definition: must be 1, the specified cell represent the lock id 25 - (hwlock standard property, see hwlock.txt) 26 - 27 - Example: 28 - 29 - tcsr_mutex_block: syscon@fd484000 { 30 - compatible = "syscon"; 31 - reg = <0xfd484000 0x2000>; 32 - }; 33 - 34 - hwlock@fd484000 { 35 - compatible = "qcom,tcsr-mutex"; 36 - syscon = <&tcsr_mutex_block 0 0x80>; 37 - 38 - #hwlock-cells = <1>; 39 - };
+42
Documentation/devicetree/bindings/hwlock/qcom-hwspinlock.yaml
··· 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 <bjorn.andersson@linaro.org> 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 + ...
+4 -6
drivers/hwspinlock/Kconfig
··· 6 6 menuconfig HWSPINLOCK 7 7 bool "Hardware Spinlock drivers" 8 8 9 + if HWSPINLOCK 10 + 9 11 config HWSPINLOCK_OMAP 10 12 tristate "OMAP Hardware Spinlock device" 11 - depends on HWSPINLOCK 12 13 depends on ARCH_OMAP4 || SOC_OMAP5 || SOC_DRA7XX || SOC_AM33XX || SOC_AM43XX || ARCH_K3 || COMPILE_TEST 13 14 help 14 15 Say y here to support the OMAP Hardware Spinlock device (firstly ··· 19 18 20 19 config HWSPINLOCK_QCOM 21 20 tristate "Qualcomm Hardware Spinlock device" 22 - depends on HWSPINLOCK 23 21 depends on ARCH_QCOM || COMPILE_TEST 24 22 select MFD_SYSCON 25 23 help ··· 30 30 31 31 config HWSPINLOCK_SIRF 32 32 tristate "SIRF Hardware Spinlock device" 33 - depends on HWSPINLOCK 34 33 depends on ARCH_SIRF || COMPILE_TEST 35 34 help 36 35 Say y here to support the SIRF Hardware Spinlock device, which ··· 42 43 config HWSPINLOCK_SPRD 43 44 tristate "SPRD Hardware Spinlock device" 44 45 depends on ARCH_SPRD || COMPILE_TEST 45 - depends on HWSPINLOCK 46 46 help 47 47 Say y here to support the SPRD Hardware Spinlock device. 48 48 ··· 50 52 config HWSPINLOCK_STM32 51 53 tristate "STM32 Hardware Spinlock device" 52 54 depends on MACH_STM32MP157 || COMPILE_TEST 53 - depends on HWSPINLOCK 54 55 help 55 56 Say y here to support the STM32 Hardware Spinlock device. 56 57 ··· 57 60 58 61 config HSEM_U8500 59 62 tristate "STE Hardware Semaphore functionality" 60 - depends on HWSPINLOCK 61 63 depends on ARCH_U8500 || COMPILE_TEST 62 64 help 63 65 Say y here to support the STE Hardware Semaphore functionality, which ··· 64 68 SoC. 65 69 66 70 If unsure, say N. 71 + 72 + endif # HWSPINLOCK
+59 -21
drivers/hwspinlock/qcom_hwspinlock.c
··· 70 70 }; 71 71 MODULE_DEVICE_TABLE(of, qcom_hwspinlock_of_match); 72 72 73 + static struct regmap *qcom_hwspinlock_probe_syscon(struct platform_device *pdev, 74 + u32 *base, u32 *stride) 75 + { 76 + struct device_node *syscon; 77 + struct regmap *regmap; 78 + int ret; 79 + 80 + syscon = of_parse_phandle(pdev->dev.of_node, "syscon", 0); 81 + if (!syscon) 82 + return ERR_PTR(-ENODEV); 83 + 84 + regmap = syscon_node_to_regmap(syscon); 85 + of_node_put(syscon); 86 + if (IS_ERR(regmap)) 87 + return regmap; 88 + 89 + ret = of_property_read_u32_index(pdev->dev.of_node, "syscon", 1, base); 90 + if (ret < 0) { 91 + dev_err(&pdev->dev, "no offset in syscon\n"); 92 + return ERR_PTR(-EINVAL); 93 + } 94 + 95 + ret = of_property_read_u32_index(pdev->dev.of_node, "syscon", 2, stride); 96 + if (ret < 0) { 97 + dev_err(&pdev->dev, "no stride syscon\n"); 98 + return ERR_PTR(-EINVAL); 99 + } 100 + 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 + 73 129 static int qcom_hwspinlock_probe(struct platform_device *pdev) 74 130 { 75 131 struct hwspinlock_device *bank; 76 - struct device_node *syscon; 77 132 struct reg_field field; 78 133 struct regmap *regmap; 79 134 size_t array_size; 80 135 u32 stride; 81 136 u32 base; 82 - int ret; 83 137 int i; 84 138 85 - 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 - } 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); 90 142 91 - regmap = syscon_node_to_regmap(syscon); 92 - of_node_put(syscon); 93 143 if (IS_ERR(regmap)) 94 144 return PTR_ERR(regmap); 95 - 96 - ret = of_property_read_u32_index(pdev->dev.of_node, "syscon", 1, &base); 97 - if (ret < 0) { 98 - dev_err(&pdev->dev, "no offset in syscon\n"); 99 - return -EINVAL; 100 - } 101 - 102 - ret = of_property_read_u32_index(pdev->dev.of_node, "syscon", 2, &stride); 103 - if (ret < 0) { 104 - dev_err(&pdev->dev, "no stride syscon\n"); 105 - return -EINVAL; 106 - } 107 145 108 146 array_size = QCOM_MUTEX_NUM_LOCKS * sizeof(struct hwspinlock); 109 147 bank = devm_kzalloc(&pdev->dev, sizeof(*bank) + array_size, GFP_KERNEL);