linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] hwspinlock: qcom: Allow dropping the intermediate TCSR mutex syscon
@ 2020-05-13  0:54 Bjorn Andersson
  2020-05-13  0:54 ` [PATCH 1/4] dt-bindings: hwlock: qcom: Migrate binding to YAML Bjorn Andersson
                   ` (3 more replies)
  0 siblings, 4 replies; 14+ messages in thread
From: Bjorn Andersson @ 2020-05-13  0:54 UTC (permalink / raw)
  To: Andy Gross, Bjorn Andersson, Ohad Ben-Cohen, Baolin Wang, Rob Herring
  Cc: linux-arm-msm, linux-remoteproc, devicetree, linux-kernel

In all modern Qualcomm platforms the mutex region of the TCSR is forked
off into its own block, all with a offset of 0 and stride of 4096.
Update the binding to allow the hardware block to be described directly
on the mmio bus, in addition to allowing the existing syscon based
definition.

Bjorn Andersson (4):
  dt-bindings: hwlock: qcom: Migrate binding to YAML
  dt-bindings: hwlock: qcom: Allow device on mmio bus
  hwspinlock: qcom: Allow mmio usage in addition to syscon
  arm64: dts: qcom: sm8250: Drop tcsr_mutex syscon

 .../bindings/hwlock/qcom-hwspinlock.yaml      | 65 +++++++++++++++++
 arch/arm64/boot/dts/qcom/sm8250.dtsi          | 11 +--
 drivers/hwspinlock/qcom_hwspinlock.c          | 72 ++++++++++++++-----
 3 files changed, 124 insertions(+), 24 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/hwlock/qcom-hwspinlock.yaml

-- 
2.26.2


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 1/4] dt-bindings: hwlock: qcom: Migrate binding to YAML
  2020-05-13  0:54 [PATCH 0/4] hwspinlock: qcom: Allow dropping the intermediate TCSR mutex syscon Bjorn Andersson
@ 2020-05-13  0:54 ` Bjorn Andersson
  2020-05-14 14:19   ` Vinod Koul
  2020-05-27 19:31   ` Rob Herring
  2020-05-13  0:54 ` [PATCH 2/4] dt-bindings: hwlock: qcom: Allow device on mmio bus Bjorn Andersson
                   ` (2 subsequent siblings)
  3 siblings, 2 replies; 14+ messages in thread
From: Bjorn Andersson @ 2020-05-13  0:54 UTC (permalink / raw)
  To: Andy Gross, Bjorn Andersson, Ohad Ben-Cohen, Baolin Wang, Rob Herring
  Cc: linux-arm-msm, linux-remoteproc, devicetree, linux-kernel

Migrate the Qualcomm TCSR mutex binding to YAML to allow validation.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
---
 .../bindings/hwlock/qcom-hwspinlock.yaml      | 51 +++++++++++++++++++
 1 file changed, 51 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/hwlock/qcom-hwspinlock.yaml

diff --git a/Documentation/devicetree/bindings/hwlock/qcom-hwspinlock.yaml b/Documentation/devicetree/bindings/hwlock/qcom-hwspinlock.yaml
new file mode 100644
index 000000000000..71e63b52edd5
--- /dev/null
+++ b/Documentation/devicetree/bindings/hwlock/qcom-hwspinlock.yaml
@@ -0,0 +1,51 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/hwlock/qcom-hwspinlock.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Qualcomm Hardware Mutex Block
+
+maintainers:
+  - Bjorn Andersson <bjorn.andersson@linaro.org>
+
+description:
+  The hardware block provides mutexes utilized between different processors on
+  the SoC as part of the communication protocol used by these processors.
+
+properties:
+  compatible:
+    enum:
+      - qcom,sfpb-mutex
+      - qcom,tcsr-mutex
+
+  '#hwlock-cells':
+    const: 1
+
+  syscon:
+    $ref: "/schemas/types.yaml#/definitions/phandle-array"
+    description:
+      Should be a triple of phandle referencing the TCSR mutex syscon, offset
+      of first mutex within the syscon and stride between each mutex.
+
+required:
+  - compatible
+  - '#hwlock-cells'
+  - syscon
+
+additionalProperties: false
+
+examples:
+  - |
+        tcsr_mutex_block: syscon@fd484000 {
+                compatible = "syscon";
+                reg = <0xfd484000 0x2000>;
+        };
+
+        hwlock {
+                compatible = "qcom,tcsr-mutex";
+                syscon = <&tcsr_mutex_block 0 0x80>;
+
+                #hwlock-cells = <1>;
+        };
+...
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 2/4] dt-bindings: hwlock: qcom: Allow device on mmio bus
  2020-05-13  0:54 [PATCH 0/4] hwspinlock: qcom: Allow dropping the intermediate TCSR mutex syscon Bjorn Andersson
  2020-05-13  0:54 ` [PATCH 1/4] dt-bindings: hwlock: qcom: Migrate binding to YAML Bjorn Andersson
@ 2020-05-13  0:54 ` Bjorn Andersson
  2020-05-14 14:19   ` Vinod Koul
  2020-05-13  0:54 ` [PATCH 3/4] hwspinlock: qcom: Allow mmio usage in addition to syscon Bjorn Andersson
  2020-05-13  0:54 ` [PATCH 4/4] arm64: dts: qcom: sm8250: Drop tcsr_mutex syscon Bjorn Andersson
  3 siblings, 1 reply; 14+ messages in thread
From: Bjorn Andersson @ 2020-05-13  0:54 UTC (permalink / raw)
  To: Andy Gross, Bjorn Andersson, Ohad Ben-Cohen, Baolin Wang, Rob Herring
  Cc: linux-arm-msm, linux-remoteproc, devicetree, linux-kernel

In all modern Qualcomm platforms the mutex region of the TCSR is forked
off into its own block, all with a offset of 0 and stride of 4096.
Update the binding to allow the hardware block to be described directly
on the mmio bus, in addition to allowing the existing syscon based
definition.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
---
 .../bindings/hwlock/qcom-hwspinlock.yaml         | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/hwlock/qcom-hwspinlock.yaml b/Documentation/devicetree/bindings/hwlock/qcom-hwspinlock.yaml
index 71e63b52edd5..88f975837588 100644
--- a/Documentation/devicetree/bindings/hwlock/qcom-hwspinlock.yaml
+++ b/Documentation/devicetree/bindings/hwlock/qcom-hwspinlock.yaml
@@ -19,6 +19,9 @@ properties:
       - qcom,sfpb-mutex
       - qcom,tcsr-mutex
 
+  reg:
+    maxItems: 1
+
   '#hwlock-cells':
     const: 1
 
@@ -31,7 +34,12 @@ properties:
 required:
   - compatible
   - '#hwlock-cells'
-  - syscon
+
+oneOf:
+  - required:
+    - reg
+  - required:
+    - syscon
 
 additionalProperties: false
 
@@ -46,6 +54,12 @@ examples:
                 compatible = "qcom,tcsr-mutex";
                 syscon = <&tcsr_mutex_block 0 0x80>;
 
+                #hwlock-cells = <1>;
+        };
+  - |
+        tcsr_mutex: hwlock@1f40000 {
+                compatible = "qcom,tcsr-mutex";
+                reg = <0x01f40000 0x40000>;
                 #hwlock-cells = <1>;
         };
 ...
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 3/4] hwspinlock: qcom: Allow mmio usage in addition to syscon
  2020-05-13  0:54 [PATCH 0/4] hwspinlock: qcom: Allow dropping the intermediate TCSR mutex syscon Bjorn Andersson
  2020-05-13  0:54 ` [PATCH 1/4] dt-bindings: hwlock: qcom: Migrate binding to YAML Bjorn Andersson
  2020-05-13  0:54 ` [PATCH 2/4] dt-bindings: hwlock: qcom: Allow device on mmio bus Bjorn Andersson
@ 2020-05-13  0:54 ` Bjorn Andersson
  2020-05-13  3:57   ` Baolin Wang
  2020-05-14 14:15   ` Vinod Koul
  2020-05-13  0:54 ` [PATCH 4/4] arm64: dts: qcom: sm8250: Drop tcsr_mutex syscon Bjorn Andersson
  3 siblings, 2 replies; 14+ messages in thread
From: Bjorn Andersson @ 2020-05-13  0:54 UTC (permalink / raw)
  To: Andy Gross, Bjorn Andersson, Ohad Ben-Cohen, Baolin Wang, Rob Herring
  Cc: linux-arm-msm, linux-remoteproc, devicetree, linux-kernel

In all modern Qualcomm platforms the mutex region of the TCSR is forked
off into its own block, all with a offset of 0 and stride of 4096. So
add support for directly memory mapping this register space, to avoid
the need to represent this block using a syscon.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
---
 drivers/hwspinlock/qcom_hwspinlock.c | 72 +++++++++++++++++++++-------
 1 file changed, 56 insertions(+), 16 deletions(-)

diff --git a/drivers/hwspinlock/qcom_hwspinlock.c b/drivers/hwspinlock/qcom_hwspinlock.c
index f0da544b14d2..d8d4d729816c 100644
--- a/drivers/hwspinlock/qcom_hwspinlock.c
+++ b/drivers/hwspinlock/qcom_hwspinlock.c
@@ -70,41 +70,81 @@ static const struct of_device_id qcom_hwspinlock_of_match[] = {
 };
 MODULE_DEVICE_TABLE(of, qcom_hwspinlock_of_match);
 
-static int qcom_hwspinlock_probe(struct platform_device *pdev)
+static struct regmap *qcom_hwspinlock_probe_syscon(struct platform_device *pdev,
+						   u32 *base, u32 *stride)
 {
-	struct hwspinlock_device *bank;
 	struct device_node *syscon;
-	struct reg_field field;
 	struct regmap *regmap;
-	size_t array_size;
-	u32 stride;
-	u32 base;
 	int ret;
-	int i;
 
 	syscon = of_parse_phandle(pdev->dev.of_node, "syscon", 0);
-	if (!syscon) {
-		dev_err(&pdev->dev, "no syscon property\n");
-		return -ENODEV;
-	}
+	if (!syscon)
+		return ERR_PTR(-ENODEV);
 
 	regmap = syscon_node_to_regmap(syscon);
 	of_node_put(syscon);
 	if (IS_ERR(regmap))
-		return PTR_ERR(regmap);
+		return regmap;
 
-	ret = of_property_read_u32_index(pdev->dev.of_node, "syscon", 1, &base);
+	ret = of_property_read_u32_index(pdev->dev.of_node, "syscon", 1, base);
 	if (ret < 0) {
 		dev_err(&pdev->dev, "no offset in syscon\n");
-		return -EINVAL;
+		return ERR_PTR(-EINVAL);
 	}
 
-	ret = of_property_read_u32_index(pdev->dev.of_node, "syscon", 2, &stride);
+	ret = of_property_read_u32_index(pdev->dev.of_node, "syscon", 2, stride);
 	if (ret < 0) {
 		dev_err(&pdev->dev, "no stride syscon\n");
-		return -EINVAL;
+		return ERR_PTR(-EINVAL);
 	}
 
+	return regmap;
+}
+
+static const struct regmap_config tcsr_mutex_config = {
+	.reg_bits		= 32,
+	.reg_stride		= 4,
+	.val_bits		= 32,
+	.max_register		= 0x40000,
+	.fast_io		= true,
+};
+
+static struct regmap *qcom_hwspinlock_probe_mmio(struct platform_device *pdev,
+						 u32 *offset, u32 *stride)
+{
+	struct device *dev = &pdev->dev;
+	struct resource *res;
+	void __iomem *base;
+
+	/* All modern platform has offset 0 and stride of 4k */
+	*offset = 0;
+	*stride = 0x1000;
+
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	base = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(base))
+		return ERR_CAST(base);
+
+	return devm_regmap_init_mmio(dev, base, &tcsr_mutex_config);
+}
+
+static int qcom_hwspinlock_probe(struct platform_device *pdev)
+{
+	struct hwspinlock_device *bank;
+	struct reg_field field;
+	struct regmap *regmap;
+	size_t array_size;
+	u32 stride;
+	u32 base;
+	int i;
+
+	regmap = qcom_hwspinlock_probe_syscon(pdev, &base, &stride);
+	if (IS_ERR(regmap) && PTR_ERR(regmap) == -ENODEV)
+		regmap = qcom_hwspinlock_probe_mmio(pdev, &base, &stride);
+
+	if (IS_ERR(regmap))
+		return PTR_ERR(regmap);
+
 	array_size = QCOM_MUTEX_NUM_LOCKS * sizeof(struct hwspinlock);
 	bank = devm_kzalloc(&pdev->dev, sizeof(*bank) + array_size, GFP_KERNEL);
 	if (!bank)
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 4/4] arm64: dts: qcom: sm8250: Drop tcsr_mutex syscon
  2020-05-13  0:54 [PATCH 0/4] hwspinlock: qcom: Allow dropping the intermediate TCSR mutex syscon Bjorn Andersson
                   ` (2 preceding siblings ...)
  2020-05-13  0:54 ` [PATCH 3/4] hwspinlock: qcom: Allow mmio usage in addition to syscon Bjorn Andersson
@ 2020-05-13  0:54 ` Bjorn Andersson
  2020-05-14 14:19   ` Vinod Koul
  3 siblings, 1 reply; 14+ messages in thread
From: Bjorn Andersson @ 2020-05-13  0:54 UTC (permalink / raw)
  To: Andy Gross, Bjorn Andersson, Ohad Ben-Cohen, Baolin Wang, Rob Herring
  Cc: linux-arm-msm, linux-remoteproc, devicetree, linux-kernel

Now that we don't need the intermediate syscon to represent the TCSR
mutexes, update the dts to describe the TCSR mutex directly.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
---
 arch/arm64/boot/dts/qcom/sm8250.dtsi | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/arch/arm64/boot/dts/qcom/sm8250.dtsi b/arch/arm64/boot/dts/qcom/sm8250.dtsi
index ecbcf725fba2..6e28754705b9 100644
--- a/arch/arm64/boot/dts/qcom/sm8250.dtsi
+++ b/arch/arm64/boot/dts/qcom/sm8250.dtsi
@@ -146,12 +146,6 @@ scm: scm {
 		};
 	};
 
-	tcsr_mutex: hwlock {
-		compatible = "qcom,tcsr-mutex";
-		syscon = <&tcsr_mutex_regs 0 0x1000>;
-		#hwlock-cells = <1>;
-	};
-
 	memory@80000000 {
 		device_type = "memory";
 		/* We expect the bootloader to fill in the size */
@@ -569,9 +563,10 @@ rpmhpd_opp_turbo_l1: opp10 {
 			};
 		};
 
-		tcsr_mutex_regs: syscon@1f40000 {
-			compatible = "syscon";
+		tcsr_mutex: hwlock@1f40000 {
+			compatible = "qcom,tcsr-mutex";
 			reg = <0x0 0x01f40000 0x0 0x40000>;
+			#hwlock-cells = <1>;
 		};
 
 		slpi: remoteproc@5c00000 {
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH 3/4] hwspinlock: qcom: Allow mmio usage in addition to syscon
  2020-05-13  0:54 ` [PATCH 3/4] hwspinlock: qcom: Allow mmio usage in addition to syscon Bjorn Andersson
@ 2020-05-13  3:57   ` Baolin Wang
  2020-05-14 17:06     ` Bjorn Andersson
  2020-05-14 14:15   ` Vinod Koul
  1 sibling, 1 reply; 14+ messages in thread
From: Baolin Wang @ 2020-05-13  3:57 UTC (permalink / raw)
  To: Bjorn Andersson
  Cc: Andy Gross, Ohad Ben-Cohen, Rob Herring, linux-arm-msm,
	linux-remoteproc, Devicetree List, LKML

On Wed, May 13, 2020 at 8:55 AM Bjorn Andersson
<bjorn.andersson@linaro.org> wrote:
>
> In all modern Qualcomm platforms the mutex region of the TCSR is forked
> off into its own block, all with a offset of 0 and stride of 4096. So
> add support for directly memory mapping this register space, to avoid
> the need to represent this block using a syscon.
>
> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
> ---
>  drivers/hwspinlock/qcom_hwspinlock.c | 72 +++++++++++++++++++++-------
>  1 file changed, 56 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/hwspinlock/qcom_hwspinlock.c b/drivers/hwspinlock/qcom_hwspinlock.c
> index f0da544b14d2..d8d4d729816c 100644
> --- a/drivers/hwspinlock/qcom_hwspinlock.c
> +++ b/drivers/hwspinlock/qcom_hwspinlock.c
> @@ -70,41 +70,81 @@ static const struct of_device_id qcom_hwspinlock_of_match[] = {
>  };
>  MODULE_DEVICE_TABLE(of, qcom_hwspinlock_of_match);
>
> -static int qcom_hwspinlock_probe(struct platform_device *pdev)
> +static struct regmap *qcom_hwspinlock_probe_syscon(struct platform_device *pdev,
> +                                                  u32 *base, u32 *stride)
>  {
> -       struct hwspinlock_device *bank;
>         struct device_node *syscon;
> -       struct reg_field field;
>         struct regmap *regmap;
> -       size_t array_size;
> -       u32 stride;
> -       u32 base;
>         int ret;
> -       int i;
>
>         syscon = of_parse_phandle(pdev->dev.of_node, "syscon", 0);
> -       if (!syscon) {
> -               dev_err(&pdev->dev, "no syscon property\n");
> -               return -ENODEV;
> -       }
> +       if (!syscon)
> +               return ERR_PTR(-ENODEV);
>
>         regmap = syscon_node_to_regmap(syscon);
>         of_node_put(syscon);
>         if (IS_ERR(regmap))
> -               return PTR_ERR(regmap);
> +               return regmap;
>
> -       ret = of_property_read_u32_index(pdev->dev.of_node, "syscon", 1, &base);
> +       ret = of_property_read_u32_index(pdev->dev.of_node, "syscon", 1, base);
>         if (ret < 0) {
>                 dev_err(&pdev->dev, "no offset in syscon\n");
> -               return -EINVAL;
> +               return ERR_PTR(-EINVAL);
>         }
>
> -       ret = of_property_read_u32_index(pdev->dev.of_node, "syscon", 2, &stride);
> +       ret = of_property_read_u32_index(pdev->dev.of_node, "syscon", 2, stride);
>         if (ret < 0) {
>                 dev_err(&pdev->dev, "no stride syscon\n");
> -               return -EINVAL;
> +               return ERR_PTR(-EINVAL);
>         }
>
> +       return regmap;
> +}
> +
> +static const struct regmap_config tcsr_mutex_config = {
> +       .reg_bits               = 32,
> +       .reg_stride             = 4,
> +       .val_bits               = 32,
> +       .max_register           = 0x40000,
> +       .fast_io                = true,
> +};
> +
> +static struct regmap *qcom_hwspinlock_probe_mmio(struct platform_device *pdev,
> +                                                u32 *offset, u32 *stride)
> +{
> +       struct device *dev = &pdev->dev;
> +       struct resource *res;
> +       void __iomem *base;
> +
> +       /* All modern platform has offset 0 and stride of 4k */
> +       *offset = 0;
> +       *stride = 0x1000;
> +
> +       res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> +       base = devm_ioremap_resource(&pdev->dev, res);

I think you can use devm_platform_ioremap_resource(pdev, 0) to
simplify your code, otherwise looks good to me.
Reviewed-by: Baolin Wang <baolin.wang7@gmail.com>

> +       if (IS_ERR(base))
> +               return ERR_CAST(base);
> +
> +       return devm_regmap_init_mmio(dev, base, &tcsr_mutex_config);
> +}
> +
> +static int qcom_hwspinlock_probe(struct platform_device *pdev)
> +{
> +       struct hwspinlock_device *bank;
> +       struct reg_field field;
> +       struct regmap *regmap;
> +       size_t array_size;
> +       u32 stride;
> +       u32 base;
> +       int i;
> +
> +       regmap = qcom_hwspinlock_probe_syscon(pdev, &base, &stride);
> +       if (IS_ERR(regmap) && PTR_ERR(regmap) == -ENODEV)
> +               regmap = qcom_hwspinlock_probe_mmio(pdev, &base, &stride);
> +
> +       if (IS_ERR(regmap))
> +               return PTR_ERR(regmap);
> +
>         array_size = QCOM_MUTEX_NUM_LOCKS * sizeof(struct hwspinlock);
>         bank = devm_kzalloc(&pdev->dev, sizeof(*bank) + array_size, GFP_KERNEL);
>         if (!bank)
> --
> 2.26.2
>


-- 
Baolin Wang

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 3/4] hwspinlock: qcom: Allow mmio usage in addition to syscon
  2020-05-13  0:54 ` [PATCH 3/4] hwspinlock: qcom: Allow mmio usage in addition to syscon Bjorn Andersson
  2020-05-13  3:57   ` Baolin Wang
@ 2020-05-14 14:15   ` Vinod Koul
  2020-05-14 17:00     ` Bjorn Andersson
  1 sibling, 1 reply; 14+ messages in thread
From: Vinod Koul @ 2020-05-14 14:15 UTC (permalink / raw)
  To: Bjorn Andersson
  Cc: Andy Gross, Ohad Ben-Cohen, Baolin Wang, Rob Herring,
	linux-arm-msm, linux-remoteproc, devicetree, linux-kernel

On 12-05-20, 17:54, Bjorn Andersson wrote:
> In all modern Qualcomm platforms the mutex region of the TCSR is forked
> off into its own block, all with a offset of 0 and stride of 4096. So
> add support for directly memory mapping this register space, to avoid
> the need to represent this block using a syscon.
> 
> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
> ---
>  drivers/hwspinlock/qcom_hwspinlock.c | 72 +++++++++++++++++++++-------
>  1 file changed, 56 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/hwspinlock/qcom_hwspinlock.c b/drivers/hwspinlock/qcom_hwspinlock.c
> index f0da544b14d2..d8d4d729816c 100644
> --- a/drivers/hwspinlock/qcom_hwspinlock.c
> +++ b/drivers/hwspinlock/qcom_hwspinlock.c
> @@ -70,41 +70,81 @@ static const struct of_device_id qcom_hwspinlock_of_match[] = {
>  };
>  MODULE_DEVICE_TABLE(of, qcom_hwspinlock_of_match);
>  
> -static int qcom_hwspinlock_probe(struct platform_device *pdev)
> +static struct regmap *qcom_hwspinlock_probe_syscon(struct platform_device *pdev,
> +						   u32 *base, u32 *stride)
>  {
> -	struct hwspinlock_device *bank;
>  	struct device_node *syscon;
> -	struct reg_field field;
>  	struct regmap *regmap;
> -	size_t array_size;
> -	u32 stride;
> -	u32 base;
>  	int ret;
> -	int i;
>  
>  	syscon = of_parse_phandle(pdev->dev.of_node, "syscon", 0);
> -	if (!syscon) {
> -		dev_err(&pdev->dev, "no syscon property\n");

any reason to drop the log?

> -		return -ENODEV;
> -	}
> +	if (!syscon)
> +		return ERR_PTR(-ENODEV);
>  
>  	regmap = syscon_node_to_regmap(syscon);
>  	of_node_put(syscon);
>  	if (IS_ERR(regmap))
> -		return PTR_ERR(regmap);
> +		return regmap;
>  
> -	ret = of_property_read_u32_index(pdev->dev.of_node, "syscon", 1, &base);
> +	ret = of_property_read_u32_index(pdev->dev.of_node, "syscon", 1, base);
>  	if (ret < 0) {
>  		dev_err(&pdev->dev, "no offset in syscon\n");
> -		return -EINVAL;
> +		return ERR_PTR(-EINVAL);
>  	}
>  
> -	ret = of_property_read_u32_index(pdev->dev.of_node, "syscon", 2, &stride);
> +	ret = of_property_read_u32_index(pdev->dev.of_node, "syscon", 2, stride);
>  	if (ret < 0) {
>  		dev_err(&pdev->dev, "no stride syscon\n");
> -		return -EINVAL;
> +		return ERR_PTR(-EINVAL);
>  	}
>  
> +	return regmap;
> +}
> +
> +static const struct regmap_config tcsr_mutex_config = {
> +	.reg_bits		= 32,
> +	.reg_stride		= 4,
> +	.val_bits		= 32,
> +	.max_register		= 0x40000,
> +	.fast_io		= true,
> +};
> +
> +static struct regmap *qcom_hwspinlock_probe_mmio(struct platform_device *pdev,
> +						 u32 *offset, u32 *stride)
> +{
> +	struct device *dev = &pdev->dev;
> +	struct resource *res;
> +	void __iomem *base;
> +
> +	/* All modern platform has offset 0 and stride of 4k */
> +	*offset = 0;
> +	*stride = 0x1000;

Wouldn't it make sense to read this from DT rather than code in kernel?

-- 
~Vinod

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 1/4] dt-bindings: hwlock: qcom: Migrate binding to YAML
  2020-05-13  0:54 ` [PATCH 1/4] dt-bindings: hwlock: qcom: Migrate binding to YAML Bjorn Andersson
@ 2020-05-14 14:19   ` Vinod Koul
  2020-05-27 19:31   ` Rob Herring
  1 sibling, 0 replies; 14+ messages in thread
From: Vinod Koul @ 2020-05-14 14:19 UTC (permalink / raw)
  To: Bjorn Andersson
  Cc: Andy Gross, Ohad Ben-Cohen, Baolin Wang, Rob Herring,
	linux-arm-msm, linux-remoteproc, devicetree, linux-kernel

On 12-05-20, 17:54, Bjorn Andersson wrote:
> Migrate the Qualcomm TCSR mutex binding to YAML to allow validation.

Reviewed-by: Vinod Koul <vkoul@kernel.org>

-- 
~Vinod

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 2/4] dt-bindings: hwlock: qcom: Allow device on mmio bus
  2020-05-13  0:54 ` [PATCH 2/4] dt-bindings: hwlock: qcom: Allow device on mmio bus Bjorn Andersson
@ 2020-05-14 14:19   ` Vinod Koul
  0 siblings, 0 replies; 14+ messages in thread
From: Vinod Koul @ 2020-05-14 14:19 UTC (permalink / raw)
  To: Bjorn Andersson
  Cc: Andy Gross, Ohad Ben-Cohen, Baolin Wang, Rob Herring,
	linux-arm-msm, linux-remoteproc, devicetree, linux-kernel

On 12-05-20, 17:54, Bjorn Andersson wrote:
> In all modern Qualcomm platforms the mutex region of the TCSR is forked
> off into its own block, all with a offset of 0 and stride of 4096.
> Update the binding to allow the hardware block to be described directly
> on the mmio bus, in addition to allowing the existing syscon based
> definition.

Reviewed-by: Vinod Koul <vkoul@kernel.org>

-- 
~Vinod

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 4/4] arm64: dts: qcom: sm8250: Drop tcsr_mutex syscon
  2020-05-13  0:54 ` [PATCH 4/4] arm64: dts: qcom: sm8250: Drop tcsr_mutex syscon Bjorn Andersson
@ 2020-05-14 14:19   ` Vinod Koul
  0 siblings, 0 replies; 14+ messages in thread
From: Vinod Koul @ 2020-05-14 14:19 UTC (permalink / raw)
  To: Bjorn Andersson
  Cc: Andy Gross, Ohad Ben-Cohen, Baolin Wang, Rob Herring,
	linux-arm-msm, linux-remoteproc, devicetree, linux-kernel

On 12-05-20, 17:54, Bjorn Andersson wrote:
> Now that we don't need the intermediate syscon to represent the TCSR
> mutexes, update the dts to describe the TCSR mutex directly.

Reviewed-by: Vinod Koul <vkoul@kernel.org>

-- 
~Vinod

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 3/4] hwspinlock: qcom: Allow mmio usage in addition to syscon
  2020-05-14 14:15   ` Vinod Koul
@ 2020-05-14 17:00     ` Bjorn Andersson
  2020-05-14 17:32       ` Vinod Koul
  0 siblings, 1 reply; 14+ messages in thread
From: Bjorn Andersson @ 2020-05-14 17:00 UTC (permalink / raw)
  To: Vinod Koul
  Cc: Andy Gross, Ohad Ben-Cohen, Baolin Wang, Rob Herring,
	linux-arm-msm, linux-remoteproc, devicetree, linux-kernel

On Thu 14 May 07:15 PDT 2020, Vinod Koul wrote:

> On 12-05-20, 17:54, Bjorn Andersson wrote:
> > In all modern Qualcomm platforms the mutex region of the TCSR is forked
> > off into its own block, all with a offset of 0 and stride of 4096. So
> > add support for directly memory mapping this register space, to avoid
> > the need to represent this block using a syscon.
> > 
> > Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
> > ---
> >  drivers/hwspinlock/qcom_hwspinlock.c | 72 +++++++++++++++++++++-------
> >  1 file changed, 56 insertions(+), 16 deletions(-)
> > 
> > diff --git a/drivers/hwspinlock/qcom_hwspinlock.c b/drivers/hwspinlock/qcom_hwspinlock.c
> > index f0da544b14d2..d8d4d729816c 100644
> > --- a/drivers/hwspinlock/qcom_hwspinlock.c
> > +++ b/drivers/hwspinlock/qcom_hwspinlock.c
> > @@ -70,41 +70,81 @@ static const struct of_device_id qcom_hwspinlock_of_match[] = {
> >  };
> >  MODULE_DEVICE_TABLE(of, qcom_hwspinlock_of_match);
> >  
> > -static int qcom_hwspinlock_probe(struct platform_device *pdev)
> > +static struct regmap *qcom_hwspinlock_probe_syscon(struct platform_device *pdev,
> > +						   u32 *base, u32 *stride)
> >  {
> > -	struct hwspinlock_device *bank;
> >  	struct device_node *syscon;
> > -	struct reg_field field;
> >  	struct regmap *regmap;
> > -	size_t array_size;
> > -	u32 stride;
> > -	u32 base;
> >  	int ret;
> > -	int i;
> >  
> >  	syscon = of_parse_phandle(pdev->dev.of_node, "syscon", 0);
> > -	if (!syscon) {
> > -		dev_err(&pdev->dev, "no syscon property\n");
> 
> any reason to drop the log?
> 

Given that we first check for the syscon and then fall back to trying to
use the reg, keeping this line would cause this log line to always show
up on targets putting this under /soc.

So I think it's better to drop the line and then require the presence of
either syscon or reg using the DT schema.

> > -		return -ENODEV;
> > -	}
> > +	if (!syscon)
> > +		return ERR_PTR(-ENODEV);
> >  
> >  	regmap = syscon_node_to_regmap(syscon);
> >  	of_node_put(syscon);
> >  	if (IS_ERR(regmap))
> > -		return PTR_ERR(regmap);
> > +		return regmap;
> >  
> > -	ret = of_property_read_u32_index(pdev->dev.of_node, "syscon", 1, &base);
> > +	ret = of_property_read_u32_index(pdev->dev.of_node, "syscon", 1, base);
> >  	if (ret < 0) {
> >  		dev_err(&pdev->dev, "no offset in syscon\n");
> > -		return -EINVAL;
> > +		return ERR_PTR(-EINVAL);
> >  	}
> >  
> > -	ret = of_property_read_u32_index(pdev->dev.of_node, "syscon", 2, &stride);
> > +	ret = of_property_read_u32_index(pdev->dev.of_node, "syscon", 2, stride);
> >  	if (ret < 0) {
> >  		dev_err(&pdev->dev, "no stride syscon\n");
> > -		return -EINVAL;
> > +		return ERR_PTR(-EINVAL);
> >  	}
> >  
> > +	return regmap;
> > +}
> > +
> > +static const struct regmap_config tcsr_mutex_config = {
> > +	.reg_bits		= 32,
> > +	.reg_stride		= 4,
> > +	.val_bits		= 32,
> > +	.max_register		= 0x40000,
> > +	.fast_io		= true,
> > +};
> > +
> > +static struct regmap *qcom_hwspinlock_probe_mmio(struct platform_device *pdev,
> > +						 u32 *offset, u32 *stride)
> > +{
> > +	struct device *dev = &pdev->dev;
> > +	struct resource *res;
> > +	void __iomem *base;
> > +
> > +	/* All modern platform has offset 0 and stride of 4k */
> > +	*offset = 0;
> > +	*stride = 0x1000;
> 
> Wouldn't it make sense to read this from DT rather than code in kernel?
> 

I did consider this as well as platform specific compatibles, but
realized that pretty much all 64-bit targets have these values. So given
that we still can represent this using the syscon approach I don't think
we need to add yet another mechanism to specify these.

Thanks,
Bjorn

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 3/4] hwspinlock: qcom: Allow mmio usage in addition to syscon
  2020-05-13  3:57   ` Baolin Wang
@ 2020-05-14 17:06     ` Bjorn Andersson
  0 siblings, 0 replies; 14+ messages in thread
From: Bjorn Andersson @ 2020-05-14 17:06 UTC (permalink / raw)
  To: Baolin Wang
  Cc: Andy Gross, Ohad Ben-Cohen, Rob Herring, linux-arm-msm,
	linux-remoteproc, Devicetree List, LKML

On Tue 12 May 20:57 PDT 2020, Baolin Wang wrote:

> On Wed, May 13, 2020 at 8:55 AM Bjorn Andersson
> <bjorn.andersson@linaro.org> wrote:
> >
> > In all modern Qualcomm platforms the mutex region of the TCSR is forked
> > off into its own block, all with a offset of 0 and stride of 4096. So
> > add support for directly memory mapping this register space, to avoid
> > the need to represent this block using a syscon.
> >
> > Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
> > ---
> >  drivers/hwspinlock/qcom_hwspinlock.c | 72 +++++++++++++++++++++-------
> >  1 file changed, 56 insertions(+), 16 deletions(-)
> >
> > diff --git a/drivers/hwspinlock/qcom_hwspinlock.c b/drivers/hwspinlock/qcom_hwspinlock.c
[..]
> > +static struct regmap *qcom_hwspinlock_probe_mmio(struct platform_device *pdev,
> > +                                                u32 *offset, u32 *stride)
> > +{
> > +       struct device *dev = &pdev->dev;
> > +       struct resource *res;
> > +       void __iomem *base;
> > +
> > +       /* All modern platform has offset 0 and stride of 4k */
> > +       *offset = 0;
> > +       *stride = 0x1000;
> > +
> > +       res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> > +       base = devm_ioremap_resource(&pdev->dev, res);
> 
> I think you can use devm_platform_ioremap_resource(pdev, 0) to
> simplify your code, otherwise looks good to me.

You're right, I better fix this before someone with Coccinelle get the
chance ;)

> Reviewed-by: Baolin Wang <baolin.wang7@gmail.com>
> 

Thanks,
Bjorn

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 3/4] hwspinlock: qcom: Allow mmio usage in addition to syscon
  2020-05-14 17:00     ` Bjorn Andersson
@ 2020-05-14 17:32       ` Vinod Koul
  0 siblings, 0 replies; 14+ messages in thread
From: Vinod Koul @ 2020-05-14 17:32 UTC (permalink / raw)
  To: Bjorn Andersson
  Cc: Andy Gross, Ohad Ben-Cohen, Baolin Wang, Rob Herring,
	linux-arm-msm, linux-remoteproc, devicetree, linux-kernel

On 14-05-20, 10:00, Bjorn Andersson wrote:
> On Thu 14 May 07:15 PDT 2020, Vinod Koul wrote:
> 
> > On 12-05-20, 17:54, Bjorn Andersson wrote:
> > > In all modern Qualcomm platforms the mutex region of the TCSR is forked
> > > off into its own block, all with a offset of 0 and stride of 4096. So
> > > add support for directly memory mapping this register space, to avoid
> > > the need to represent this block using a syscon.
> > > 
> > > Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
> > > ---
> > >  drivers/hwspinlock/qcom_hwspinlock.c | 72 +++++++++++++++++++++-------
> > >  1 file changed, 56 insertions(+), 16 deletions(-)
> > > 
> > > diff --git a/drivers/hwspinlock/qcom_hwspinlock.c b/drivers/hwspinlock/qcom_hwspinlock.c
> > > index f0da544b14d2..d8d4d729816c 100644
> > > --- a/drivers/hwspinlock/qcom_hwspinlock.c
> > > +++ b/drivers/hwspinlock/qcom_hwspinlock.c
> > > @@ -70,41 +70,81 @@ static const struct of_device_id qcom_hwspinlock_of_match[] = {
> > >  };
> > >  MODULE_DEVICE_TABLE(of, qcom_hwspinlock_of_match);
> > >  
> > > -static int qcom_hwspinlock_probe(struct platform_device *pdev)
> > > +static struct regmap *qcom_hwspinlock_probe_syscon(struct platform_device *pdev,
> > > +						   u32 *base, u32 *stride)
> > >  {
> > > -	struct hwspinlock_device *bank;
> > >  	struct device_node *syscon;
> > > -	struct reg_field field;
> > >  	struct regmap *regmap;
> > > -	size_t array_size;
> > > -	u32 stride;
> > > -	u32 base;
> > >  	int ret;
> > > -	int i;
> > >  
> > >  	syscon = of_parse_phandle(pdev->dev.of_node, "syscon", 0);
> > > -	if (!syscon) {
> > > -		dev_err(&pdev->dev, "no syscon property\n");
> > 
> > any reason to drop the log?
> > 
> 
> Given that we first check for the syscon and then fall back to trying to
> use the reg, keeping this line would cause this log line to always show
> up on targets putting this under /soc.
> 
> So I think it's better to drop the line and then require the presence of
> either syscon or reg using the DT schema.

ok

> > > -		return -ENODEV;
> > > -	}
> > > +	if (!syscon)
> > > +		return ERR_PTR(-ENODEV);
> > >  
> > >  	regmap = syscon_node_to_regmap(syscon);
> > >  	of_node_put(syscon);
> > >  	if (IS_ERR(regmap))
> > > -		return PTR_ERR(regmap);
> > > +		return regmap;
> > >  
> > > -	ret = of_property_read_u32_index(pdev->dev.of_node, "syscon", 1, &base);
> > > +	ret = of_property_read_u32_index(pdev->dev.of_node, "syscon", 1, base);
> > >  	if (ret < 0) {
> > >  		dev_err(&pdev->dev, "no offset in syscon\n");
> > > -		return -EINVAL;
> > > +		return ERR_PTR(-EINVAL);
> > >  	}
> > >  
> > > -	ret = of_property_read_u32_index(pdev->dev.of_node, "syscon", 2, &stride);
> > > +	ret = of_property_read_u32_index(pdev->dev.of_node, "syscon", 2, stride);
> > >  	if (ret < 0) {
> > >  		dev_err(&pdev->dev, "no stride syscon\n");
> > > -		return -EINVAL;
> > > +		return ERR_PTR(-EINVAL);
> > >  	}
> > >  
> > > +	return regmap;
> > > +}
> > > +
> > > +static const struct regmap_config tcsr_mutex_config = {
> > > +	.reg_bits		= 32,
> > > +	.reg_stride		= 4,
> > > +	.val_bits		= 32,
> > > +	.max_register		= 0x40000,
> > > +	.fast_io		= true,
> > > +};
> > > +
> > > +static struct regmap *qcom_hwspinlock_probe_mmio(struct platform_device *pdev,
> > > +						 u32 *offset, u32 *stride)
> > > +{
> > > +	struct device *dev = &pdev->dev;
> > > +	struct resource *res;
> > > +	void __iomem *base;
> > > +
> > > +	/* All modern platform has offset 0 and stride of 4k */
> > > +	*offset = 0;
> > > +	*stride = 0x1000;
> > 
> > Wouldn't it make sense to read this from DT rather than code in kernel?
> > 
> 
> I did consider this as well as platform specific compatibles, but
> realized that pretty much all 64-bit targets have these values. So given
> that we still can represent this using the syscon approach I don't think
> we need to add yet another mechanism to specify these.

Sounds good.

Reviewed-by: Vinod Koul <vkoul@kernel.org>

-- 
~Vinod

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 1/4] dt-bindings: hwlock: qcom: Migrate binding to YAML
  2020-05-13  0:54 ` [PATCH 1/4] dt-bindings: hwlock: qcom: Migrate binding to YAML Bjorn Andersson
  2020-05-14 14:19   ` Vinod Koul
@ 2020-05-27 19:31   ` Rob Herring
  1 sibling, 0 replies; 14+ messages in thread
From: Rob Herring @ 2020-05-27 19:31 UTC (permalink / raw)
  To: Bjorn Andersson
  Cc: Andy Gross, Ohad Ben-Cohen, Baolin Wang, linux-arm-msm,
	linux-remoteproc, devicetree, linux-kernel

On Tue, May 12, 2020 at 05:54:38PM -0700, Bjorn Andersson wrote:
> Migrate the Qualcomm TCSR mutex binding to YAML to allow validation.

Where's the deletion of the old text file?

Looks fine if this is existing. Lots of comments if this is a new 
binding...

> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
> ---
>  .../bindings/hwlock/qcom-hwspinlock.yaml      | 51 +++++++++++++++++++
>  1 file changed, 51 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/hwlock/qcom-hwspinlock.yaml
> 
> diff --git a/Documentation/devicetree/bindings/hwlock/qcom-hwspinlock.yaml b/Documentation/devicetree/bindings/hwlock/qcom-hwspinlock.yaml
> new file mode 100644
> index 000000000000..71e63b52edd5
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/hwlock/qcom-hwspinlock.yaml
> @@ -0,0 +1,51 @@
> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/hwlock/qcom-hwspinlock.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Qualcomm Hardware Mutex Block
> +
> +maintainers:
> +  - Bjorn Andersson <bjorn.andersson@linaro.org>
> +
> +description:
> +  The hardware block provides mutexes utilized between different processors on
> +  the SoC as part of the communication protocol used by these processors.
> +
> +properties:
> +  compatible:
> +    enum:
> +      - qcom,sfpb-mutex
> +      - qcom,tcsr-mutex
> +
> +  '#hwlock-cells':
> +    const: 1
> +
> +  syscon:
> +    $ref: "/schemas/types.yaml#/definitions/phandle-array"
> +    description:
> +      Should be a triple of phandle referencing the TCSR mutex syscon, offset
> +      of first mutex within the syscon and stride between each mutex.
> +
> +required:
> +  - compatible
> +  - '#hwlock-cells'
> +  - syscon
> +
> +additionalProperties: false
> +
> +examples:
> +  - |
> +        tcsr_mutex_block: syscon@fd484000 {
> +                compatible = "syscon";
> +                reg = <0xfd484000 0x2000>;
> +        };
> +
> +        hwlock {
> +                compatible = "qcom,tcsr-mutex";
> +                syscon = <&tcsr_mutex_block 0 0x80>;
> +
> +                #hwlock-cells = <1>;
> +        };
> +...
> -- 
> 2.26.2
> 

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2020-05-27 19:31 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-13  0:54 [PATCH 0/4] hwspinlock: qcom: Allow dropping the intermediate TCSR mutex syscon Bjorn Andersson
2020-05-13  0:54 ` [PATCH 1/4] dt-bindings: hwlock: qcom: Migrate binding to YAML Bjorn Andersson
2020-05-14 14:19   ` Vinod Koul
2020-05-27 19:31   ` Rob Herring
2020-05-13  0:54 ` [PATCH 2/4] dt-bindings: hwlock: qcom: Allow device on mmio bus Bjorn Andersson
2020-05-14 14:19   ` Vinod Koul
2020-05-13  0:54 ` [PATCH 3/4] hwspinlock: qcom: Allow mmio usage in addition to syscon Bjorn Andersson
2020-05-13  3:57   ` Baolin Wang
2020-05-14 17:06     ` Bjorn Andersson
2020-05-14 14:15   ` Vinod Koul
2020-05-14 17:00     ` Bjorn Andersson
2020-05-14 17:32       ` Vinod Koul
2020-05-13  0:54 ` [PATCH 4/4] arm64: dts: qcom: sm8250: Drop tcsr_mutex syscon Bjorn Andersson
2020-05-14 14:19   ` Vinod Koul

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).