Raspberry PI 4 V3D enablement
Subsystems (8)
v4 cover Raspberry PI 4 V3D enablement
This is purely a rebased of Nicolas's v3 patch set from around a year ago.
I've tested this using mesa 21.3.x and Wayland/Gnome on Fedora 35, it's more or less stable with basic testing.
From his original cover letter:
This series attempts to enable V3D on BCM2711, the SoC available on the Raspberry Pi 4 family of boards.
Due to the lack of documentation some things are taken as it from testing/downstream implementation[1], which I'm hilighting here:
- It's not clear that the following is 100% true, maybe someone can confirm:
"In BCM2711 the new ARGON ASB took over V3D. The old ASB is still present with the ISP and H264 bits, and V3D is in the same place in the new ASB as the old one."
- Patch #9 ("soc: bcm: bcm2835-power: Bypass power_on/off() calls"), I took as is from the downstream implementation, I can't really provide an exact explanation on what changed HW wise.
- Ultimately, I need confirmation from the Broadcom folks that they are alright with patch #11 ("drm/v3d: Get rid of pm code")
---
Changes since v3:
- Rebase to 5.17-rc1
Changes since v2:
- Correct ASB names
- Address dt-binding comments
Changes since v1:
- Use 'reg-names'
- Correct ASB names
- Add missing binding patch for V3D
- Address Stefan's comments
Nicolas Saenz Julienne (11):
dt-bindings: soc: bcm: bcm2835-pm: Convert bindings to DT schema
dt-bindings: soc: bcm: bcm2835-pm: Introduce reg-names
dt-bindings: soc: bcm: bcm2835-pm: Add support for bcm2711
ARM: dts: bcm2835/bcm2711: Introduce reg-names in watchdog node
ARM: dts: bcm2711: Use proper compatible in PM/Watchdog node
mfd: bcm2835-pm: Use 'reg-names' to get resources
mfd: bcm2835-pm: Add support for BCM2711
soc: bcm: bcm2835-power: Add support for BCM2711's RPiVid ASB
soc: bcm: bcm2835-power: Bypass power_on/off() calls
dt-bindings: gpu: v3d: Add BCM2711's compatible
arm64: config: Enable DRM_V3D
Peter Robinson (4):
drm/v3d: Get rid of pm code
drm/v3d: Add support for bcm2711
ARM: dts: bcm2711: Enable V3D
ARM: configs: Enable DRM_V3D
.../devicetree/bindings/gpu/brcm,bcm-v3d.yaml | 1 + .../bindings/soc/bcm/brcm,bcm2835-pm.txt | 46 ---------- .../bindings/soc/bcm/brcm,bcm2835-pm.yaml | 87 +++++++++++++++++++ arch/arm/boot/dts/bcm2711.dtsi | 15 +++- arch/arm/boot/dts/bcm2835-common.dtsi | 1 + arch/arm/configs/multi_v7_defconfig | 1 + arch/arm64/configs/defconfig | 1 + drivers/gpu/drm/v3d/Kconfig | 2 +- drivers/gpu/drm/v3d/v3d_debugfs.c | 18 +--- drivers/gpu/drm/v3d/v3d_drv.c | 12 +-- drivers/gpu/drm/v3d/v3d_gem.c | 12 +-- drivers/mfd/bcm2835-pm.c | 80 ++++++++++++----- drivers/soc/bcm/bcm2835-power.c | 74 ++++++++++------ include/linux/mfd/bcm2835-pm.h | 1 + 14 files changed, 218 insertions(+), 133 deletions(-) delete mode 100644 Documentation/devicetree/bindings/soc/bcm/brcm,bcm2835-pm.txt create mode 100644 Documentation/devicetree/bindings/soc/bcm/brcm,bcm2835-pm.yaml
Signature · 1 line
2.35.1
PATCH v4 1/15 dt-bindings: soc: bcm: bcm2835-pm: Convert bindings to DT schema
From: Nicolas Saenz Julienne <[email protected]>
This converts the brcm,bcm2835-pm bindings from text to proper schema.
--- .../bindings/soc/bcm/brcm,bcm2835-pm.txt | 46 ----------- .../bindings/soc/bcm/brcm,bcm2835-pm.yaml | 79 +++++++++++++++++++ 2 files changed, 79 insertions(+), 46 deletions(-) delete mode 100644 Documentation/devicetree/bindings/soc/bcm/brcm,bcm2835-pm.txt create mode 100644 Documentation/devicetree/bindings/soc/bcm/brcm,bcm2835-pm.yaml
Documentation/devicetree/bindings/soc/bcm/brcm,bcm2835-pm.txt deleted +0 -46
@@ -1,46 +0,0 @@ -BCM2835 PM (Power domains, watchdog) - -The PM block controls power domains and some reset lines, and includes -a watchdog timer. This binding supersedes the brcm,bcm2835-pm-wdt -binding which covered some of PM's register range and functionality. - -Required properties: - -- compatible: Should be "brcm,bcm2835-pm" -- reg: Specifies base physical address and size of the two - register ranges ("PM" and "ASYNC_BRIDGE" in that - order) -- clocks: a) v3d: The V3D clock from CPRMAN - b) peri_image: The PERI_IMAGE clock from CPRMAN - c) h264: The H264 clock from CPRMAN - d) isp: The ISP clock from CPRMAN -- #reset-cells: Should be 1. This property follows the reset controller - bindings[1]. -- #power-domain-cells: Should be 1. This property follows the power domain - bindings[2]. - -Optional properties: - -- timeout-sec: Contains the watchdog timeout in seconds -- system-power-controller: Whether the watchdog is controlling the - system power. This node follows the power controller bindings[3]. - -[1] Documentation/devicetree/bindings/reset/reset.txt -[2] Documentation/devicetree/bindings/power/power-domain.yaml -[3] Documentation/devicetree/bindings/power/power-controller.txt - -Example: - -pm { - compatible = "brcm,bcm2835-pm", "brcm,bcm2835-pm-wdt"; - #power-domain-cells = <1>; - #reset-cells = <1>; - reg = <0x7e100000 0x114>, - <0x7e00a000 0x24>; - clocks = <&clocks BCM2835_CLOCK_V3D>, - <&clocks BCM2835_CLOCK_PERI_IMAGE>, - <&clocks BCM2835_CLOCK_H264>, - <&clocks BCM2835_CLOCK_ISP>; - clock-names = "v3d", "peri_image", "h264", "isp"; - system-power-controller; -};
Documentation/devicetree/bindings/soc/bcm/brcm,bcm2835-pm.yaml new file +79 -0
79 lines not on this page · raw message
Signature · 1 line
2.35.1
Rob Herring
maintainerRe: [PATCH v4 01/15] dt-bindings: soc: bcm: bcm2835-pm: Convert bindings to DT schema
Quoted 7 lines · Peter Robinson
From: Nicolas Saenz Julienne <[email protected]>
This converts the brcm,bcm2835-pm bindings from text to proper schema.
Signed-off-by Nicolas Saenz Julienne <[email protected]>Reviewed-by Rob Herring <[email protected]>Signed-off-by Peter Robinson <[email protected]>
Quoted 7 lines
--- .../bindings/soc/bcm/brcm,bcm2835-pm.txt | 46 ----------- .../bindings/soc/bcm/brcm,bcm2835-pm.yaml | 79 +++++++++++++++++++ 2 files changed, 79 insertions(+), 46 deletions(-) delete mode 100644 Documentation/devicetree/bindings/soc/bcm/brcm,bcm2835-pm.txt create mode 100644 Documentation/devicetree/bindings/soc/bcm/brcm,bcm2835-pm.yaml
My bot found errors running 'make DT_CHECKER_FLAGS=-m dt_binding_check' on your patch (DT_CHECKER_FLAGS is new in v5.13):
yamllint warnings/errors:
dtschema/dtc warnings/errors:
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/soc/bcm/brcm,bcm2835-pm.yaml: properties:reg: {'minItems': 1, 'maxItems': 2, 'items': [{'description': 'PM registers'}, {'description': 'ASB registers'}]} should not be valid under {'required': ['maxItems']}
hint: "maxItems" is not needed with an "items" list
from schema $id: http://devicetree.org/meta-schemas/items.yaml#
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/soc/bcm/brcm,bcm2835-pm.yaml: ignoring, error in schema: properties: regDocumentation/devicetree/bindings/soc/bcm/brcm,bcm2835-pm.example.dt.yaml:0:0: /example-0/watchdog@7e100000: failed to match any schema with compatible: ['brcm,bcm2835-pm', 'brcm,bcm2835-pm-wdt'] Documentation/devicetree/bindings/soc/bcm/brcm,bcm2835-pm.example.dt.yaml:0:0: /example-0/watchdog@7e100000: failed to match any schema with compatible: ['brcm,bcm2835-pm', 'brcm,bcm2835-pm-wdt']
doc reference errors (make refcheckdocs):
See https://patchwork.ozlabs.org/patch/1592167
This check can fail if there are any dependencies. The base for a patch series is generally the most recent rc1.
If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:
pip3 install dtschema --upgrade
Please check and re-submit.
PATCH v4 2/15 dt-bindings: soc: bcm: bcm2835-pm: Introduce reg-names
In reply to Peter RobinsonFrom: Nicolas Saenz Julienne <[email protected]>
Anticipating the introduction of BCM2711, of which we'll need to support its new RPiVid ASB, introduce reg-names into bcm2835-pm's binding. This will help to have a consistent mapping between resources and their meaning.
--- .../devicetree/bindings/soc/bcm/brcm,bcm2835-pm.yaml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/soc/bcm/brcm,bcm2835-pm.yaml +7 -2
@@ -25,9 +25,13 @@ properties: reg: minItems: 1 maxItems: 2 + + reg-names: + minItems: 1 + maxItems: 2 items: - - description: PM registers - - description: ASB registers + - const: pm + - const: asb "#power-domain-cells": const: 1
@@ -70,6 +74,7 @@ examples: #reset-cells = <1>; reg = <0x7e100000 0x114>, <0x7e00a000 0x24>; + reg-names = "pm", "asb"; clocks = <&clocks BCM2835_CLOCK_V3D>, <&clocks BCM2835_CLOCK_PERI_IMAGE>, <&clocks BCM2835_CLOCK_H264>,
Signature · 1 line
2.35.1
PATCH v4 3/15 dt-bindings: soc: bcm: bcm2835-pm: Add support for bcm2711
In reply to Peter RobinsonFrom: Nicolas Saenz Julienne <[email protected]>
Add a new compatible string for BCM2711 and the option to provide a third reg property for the board's new RPiVid ASB.
In BCM2711 the new RPiVid ASB took over V3D, which is our only consumer of this driver so far. The old ASB is still be present with ISP and H264 bits but no V3D.
---
Changes since v2:
- Correct names s/argon/rpivid/
.../devicetree/bindings/soc/bcm/brcm,bcm2835-pm.yaml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
Documentation/devicetree/bindings/soc/bcm/brcm,bcm2835-pm.yaml +7 -4
@@ -19,19 +19,22 @@ allOf: properties: compatible: items: - - const: brcm,bcm2835-pm + - enum: + - brcm,bcm2835-pm + - brcm,bcm2711-pm - const: brcm,bcm2835-pm-wdt reg: minItems: 1 - maxItems: 2 + maxItems: 3 reg-names: minItems: 1 - maxItems: 2 + maxItems: 3 items: - const: pm - const: asb + - const: rpivid_asb "#power-domain-cells": const: 1
@@ -74,7 +77,7 @@ examples: #reset-cells = <1>; reg = <0x7e100000 0x114>, <0x7e00a000 0x24>; - reg-names = "pm", "asb"; + reg-names = "pm", "asb", "rpivid_asb"; clocks = <&clocks BCM2835_CLOCK_V3D>, <&clocks BCM2835_CLOCK_PERI_IMAGE>, <&clocks BCM2835_CLOCK_H264>,
Signature · 1 line
2.35.1
Re: [PATCH v4 03/15] dt-bindings: soc: bcm: bcm2835-pm: Add support for bcm2711
Hi,
Am 13.02.22 um 23:56 schrieb Peter Robinson:
Quoted 50 lines
From: Nicolas Saenz Julienne <[email protected]>
Add a new compatible string for BCM2711 and the option to provide a third reg property for the board's new RPiVid ASB.
In BCM2711 the new RPiVid ASB took over V3D, which is our only consumer of this driver so far. The old ASB is still be present with ISP and H264 bits but no V3D.
Signed-off-by Nicolas Saenz Julienne <[email protected]>Reviewed-by Rob Herring <[email protected]>Signed-off-by Peter Robinson <[email protected]>---
Changes since v2:
- Correct names s/argon/rpivid/.../devicetree/bindings/soc/bcm/brcm,bcm2835-pm.yaml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)Documentation/devicetree/bindings/soc/bcm/brcm,bcm2835-pm.yaml +6
-3@@ -19,19 +19,22 @@ allOf: properties: compatible: items: - - const: brcm,bcm2835-pm + - enum: + - brcm,bcm2835-pm + - brcm,bcm2711-pm - const: brcm,bcm2835-pm-wdt reg: minItems: 1 - maxItems: 2 + maxItems: 3 reg-names: minItems: 1 - maxItems: 2 + maxItems: 3 items: - const: pm - const: asb + - const: rpivid_asb "#power-domain-cells": const: 1
Documentation/devicetree/bindings/soc/bcm/brcm,bcm2835-pm.yaml examples: · line 80
Quoted 5 lines
Documentation/devicetree/bindings/soc/bcm/brcm,bcm2835-pm.yaml +1
-1@@ -74,7 +77,7 @@ examples: #reset-cells = <1>; reg = <0x7e100000 0x114>, <0x7e00a000 0x24>; - reg-names = "pm", "asb"; + reg-names = "pm", "asb", "rpivid_asb";
since the example is about the bcm2835, there is no rpivid_asb on this SoC. So this change should be dropped.
Best regards
Quoted 3 lines
Documentation/devicetree/bindings/soc/bcm/brcm,bcm2835-pm.yaml +0
-0clocks = <&clocks BCM2835_CLOCK_V3D>, <&clocks BCM2835_CLOCK_PERI_IMAGE>, <&clocks BCM2835_CLOCK_H264>,
PATCH v4 4/15 ARM: dts: bcm2835/bcm2711: Introduce reg-names in watchdog node
In reply to Peter RobinsonFrom: Nicolas Saenz Julienne <[email protected]>
bcm2835-pm's bindings now support explicitly setting 'reg-names,' so use them.
--- arch/arm/boot/dts/bcm2711.dtsi | 1 + arch/arm/boot/dts/bcm2835-common.dtsi | 1 + 2 files changed, 2 insertions(+)
arch/arm/boot/dts/bcm2711.dtsi +1 -0
@@ -113,6 +113,7 @@ pm: watchdog@7e100000 { reg = <0x7e100000 0x114>, <0x7e00a000 0x24>, <0x7ec11000 0x20>; + reg-names = "pm", "asb", "rpivid_asb"; clocks = <&clocks BCM2835_CLOCK_V3D>, <&clocks BCM2835_CLOCK_PERI_IMAGE>, <&clocks BCM2835_CLOCK_H264>,
arch/arm/boot/dts/bcm2835-common.dtsi +1 -0
@@ -62,6 +62,7 @@ pm: watchdog@7e100000 { #reset-cells = <1>; reg = <0x7e100000 0x114>, <0x7e00a000 0x24>; + reg-names = "pm", "asb"; clocks = <&clocks BCM2835_CLOCK_V3D>, <&clocks BCM2835_CLOCK_PERI_IMAGE>, <&clocks BCM2835_CLOCK_H264>,
Signature · 1 line
2.35.1
PATCH v4 5/15 ARM: dts: bcm2711: Use proper compatible in PM/Watchdog node
In reply to Peter RobinsonFrom: Nicolas Saenz Julienne <[email protected]>
A new compatible string was introduced specifically for BCM2711, so make use of it.
--- arch/arm/boot/dts/bcm2711.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/boot/dts/bcm2711.dtsi +1 -1
@@ -107,7 +107,7 @@ dma: dma@7e007000 { }; pm: watchdog@7e100000 { - compatible = "brcm,bcm2835-pm", "brcm,bcm2835-pm-wdt"; + compatible = "brcm,bcm2711-pm", "brcm,bcm2835-pm-wdt"; #power-domain-cells = <1>; #reset-cells = <1>; reg = <0x7e100000 0x114>,
Signature · 1 line
2.35.1
PATCH v4 6/15 mfd: bcm2835-pm: Use 'reg-names' to get resources
In reply to Peter RobinsonFrom: Nicolas Saenz Julienne <[email protected]>
If available in firmware, find resources by their 'reg-names' position instead of relying on hardcoded offsets. Care is taken to support old firmware nonetheless.
---
Changes since v2:
- correct names
drivers/mfd/bcm2835-pm.c | 55 ++++++++++++++++++++++++++-------------- 1 file changed, 36 insertions(+), 19 deletions(-)
drivers/mfd/bcm2835-pm.c +36 -19
@@ -25,9 +25,37 @@ static const struct mfd_cell bcm2835_power_devs[] = { { .name = "bcm2835-power" }, }; +static int bcm2835_pm_get_pdata (struct platform_device *pdev, +struct bcm2835_pm *pm) +{ +/* If no 'reg-names' property is found we can assume we're using old +* firmware. +*/ +if (!of_find_property (pm->dev->of_node,"reg-names" ,NULL )) { +dev_warn (pm->dev,"Old devicetree detected, please update your firmware.\n" ); + + pm->base =devm_platform_ioremap_resource (pdev,0 ); +if (IS_ERR (pm->base)) +return PTR_ERR (pm->base); + + pm->asb =devm_platform_ioremap_resource (pdev,1 ); +if (IS_ERR (pm->asb)) + pm->asb =NULL ; + }else { + pm->base =devm_platform_ioremap_resource_byname (pdev,"pm" ); +if (IS_ERR (pm->base)) +return PTR_ERR (pm->base); + + pm->asb =devm_platform_ioremap_resource_byname (pdev,"asb" ); +if (IS_ERR (pm->base)) + pm->asb =NULL ; + } + +return 0 ; +} +static int bcm2835_pm_probe (struct platform_device *pdev) { -struct resource *res;struct device *dev = &pdev->dev;struct bcm2835_pm *pm;int ret;
@@ -39,10 +67,9 @@ static int bcm2835_pm_probe(struct platform_device *pdev) pm->dev = dev; - res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); - pm->base =devm_ioremap_resource (dev, res); -if (IS_ERR (pm->base)) -return PTR_ERR (pm->base); + ret =bcm2835_pm_get_pdata (pdev, pm); +if (ret) +return ret; ret = devm_mfd_add_devices(dev, -1, bcm2835_pm_devs, ARRAY_SIZE(bcm2835_pm_devs),
@@ -54,20 +81,10 @@ static int bcm2835_pm_probe(struct platform_device *pdev)* bcm2835-pm binding as the key for whether we can reference * the full PM register range and support power domains. */ - res =platform_get_resource (pdev,IORESOURCE_MEM ,1 ); -if (res) { - pm->asb =devm_ioremap_resource (dev, res); -if (IS_ERR (pm->asb)) -return PTR_ERR (pm->asb); - - ret =devm_mfd_add_devices (dev,-1 , - bcm2835_power_devs, -ARRAY_SIZE (bcm2835_power_devs), -NULL ,0 ,NULL ); -if (ret) -return ret; - } - +if (pm->asb) +return devm_mfd_add_devices (dev,-1 , bcm2835_power_devs, +ARRAY_SIZE (bcm2835_power_devs), +NULL ,0 ,NULL );return 0 ; }
Signature · 1 line
2.35.1
PATCH v4 7/15 mfd: bcm2835-pm: Add support for BCM2711
In reply to Peter RobinsonFrom: Nicolas Saenz Julienne <[email protected]>
In BCM2711 the new RPiVid ASB took over V3D. The old ASB is still present with the ISP and H264 bits, and V3D is in the same place in the new ASB as the old one.
As per the devicetree bindings, BCM2711 will provide both the old and new ASB resources, so get both of them and pass them into 'bcm2835-power,' which will take care of selecting which one to use accordingly.
Since the RPiVid ASB's resources were being provided prior to formalizing the bindings[1], also support the old firmwares that didn't use 'reg-names.'
[1] See: 7dbe8c62ceeb ("ARM: dts: Add minimal Raspberry Pi 4 support")
---
Changes since v2:
- Correct names again!
Changes since v1:
- Use reg-names
- Correct ASB names
drivers/mfd/bcm2835-pm.c | 25 +++++++++++++++++++++++-- include/linux/mfd/bcm2835-pm.h | 1 + 2 files changed, 24 insertions(+), 2 deletions(-)
drivers/mfd/bcm2835-pm.c +23 -2
@@ -6,6 +6,7 @@* the WDT and power drivers. */ +#include <linux/bits.h> #include <linux/delay.h> #include <linux/io.h> #include <linux/mfd/bcm2835-pm.h>
@@ -17,6 +18,9 @@#include <linux/types.h> #include <linux/watchdog.h> +#define BCM2835 BIT(1) +#define BCM2711 BIT(2) +static const struct mfd_cell bcm2835_pm_devs[] = { { .name ="bcm2835-wdt" }, };
@@ -28,6 +32,8 @@ static const struct mfd_cell bcm2835_power_devs[] = {static int bcm2835_pm_get_pdata (struct platform_device *pdev,struct bcm2835_pm *pm) { +bool is_bcm2711 = (uintptr_t )device_get_match_data (pm->dev) &BCM2711 ; +/* If no 'reg-names' property is found we can assume we're using old * firmware. */
@@ -41,6 +47,10 @@ static int bcm2835_pm_get_pdata(struct platform_device *pdev, pm->asb =devm_platform_ioremap_resource (pdev,1 );if (IS_ERR (pm->asb)) pm->asb =NULL ; + + pm->rpivid_asb =devm_platform_ioremap_resource (pdev,2 ); +if (IS_ERR (pm->rpivid_asb)) + pm->rpivid_asb =NULL ; }else { pm->base =devm_platform_ioremap_resource_byname (pdev,"pm" );if (IS_ERR (pm->base))
@@ -49,6 +59,16 @@ static int bcm2835_pm_get_pdata(struct platform_device *pdev, pm->asb =devm_platform_ioremap_resource_byname (pdev,"asb" );if (IS_ERR (pm->base)) pm->asb =NULL ; + + pm->rpivid_asb =devm_platform_ioremap_resource_byname (pdev, +"rpivid_asb" ); +if (IS_ERR (pm->base)) + pm->rpivid_asb =NULL ; + +if (pm->rpivid_asb && !is_bcm2711) { +dev_err (pm->dev,"RPiVid ASB support only present in BCM2711\n" ); +return -EINVAL ; + } }return 0 ;
@@ -89,8 +109,9 @@ static int bcm2835_pm_probe(struct platform_device *pdev) }static const struct of_device_id bcm2835_pm_of_match[] = { - { .compatible ="brcm,bcm2835-pm-wdt" , }, - { .compatible ="brcm,bcm2835-pm" , }, + { .compatible ="brcm,bcm2835-pm-wdt" , .data = (void *)BCM2835 }, + { .compatible ="brcm,bcm2835-pm" , .data = (void *)BCM2835 }, + { .compatible ="brcm,bcm2711-pm" , .data = (void *)BCM2711 }, {}, };MODULE_DEVICE_TABLE (of, bcm2835_pm_of_match);
include/linux/mfd/bcm2835-pm.h +1 -0
@@ -9,6 +9,7 @@ struct bcm2835_pm {struct device *dev;void __iomem *base;void __iomem *asb; + void __iomem *rpivid_asb; };#endif /* BCM2835_MFD_PM_H */
Signature · 1 line
2.35.1
Re: [PATCH v4 07/15] mfd: bcm2835-pm: Add support for BCM2711
Am 13.02.22 um 23:56 schrieb Peter Robinson:
Quoted 45 lines
From: Nicolas Saenz Julienne <[email protected]>
In BCM2711 the new RPiVid ASB took over V3D. The old ASB is still present with the ISP and H264 bits, and V3D is in the same place in the new ASB as the old one.
As per the devicetree bindings, BCM2711 will provide both the old and new ASB resources, so get both of them and pass them into 'bcm2835-power,' which will take care of selecting which one to use accordingly.
Since the RPiVid ASB's resources were being provided prior to formalizing the bindings[1], also support the old firmwares that didn't use 'reg-names.'
Signed-off-by Nicolas Saenz Julienne <[email protected]>Signed-off-by Peter Robinson <[email protected]>[1] See:
7dbe8c62ceeb("ARM: dts: Add minimal Raspberry Pi 4 support")---
Changes since v2:
- Correct names again!Changes since v1:
- Use reg-names
- Correct ASB namesdrivers/mfd/bcm2835-pm.c | 25 +++++++++++++++++++++++-- include/linux/mfd/bcm2835-pm.h | 1 + 2 files changed, 24 insertions(+), 2 deletions(-)drivers/mfd/bcm2835-pm.c +1
-0@@ -6,6 +6,7 @@* the WDT and power drivers. */ +#include <linux/bits.h> #include <linux/delay.h> #include <linux/io.h> #include <linux/mfd/bcm2835-pm.h>
drivers/mfd/bcm2835-pm.c line 23
Quoted 6 lines
drivers/mfd/bcm2835-pm.c +3
-0@@ -17,6 +18,9 @@#include <linux/types.h> #include <linux/watchdog.h> +#define BCM2835 BIT(1) +#define BCM2711 BIT(2) +
Unfortunately, i don't remember the decision to use bits here. It's just unexpected, no strong opinion.
PATCH v4 8/15 soc: bcm: bcm2835-power: Add support for BCM2711's RPiVid ASB
In reply to Peter RobinsonFrom: Nicolas Saenz Julienne <[email protected]>
In BCM2711 the new RPiVid ASB took over V3D. The old ASB is still present with the ISP and H264 bits, and V3D is in the same place in the new ASB as the old one.
Use the fact that 'pm->rpivid_asb' is populated as a hint that we're on BCM2711. On top of that introduce the macro ASB_BASE() which will select the correct ASB register base, based on whether we're trying to access V3D and which platform we're on.
---
Changes since v2:
- Correct names again
Changes since v1:
- Correct names
drivers/soc/bcm/bcm2835-power.c | 66 ++++++++++++++++++++------------- 1 file changed, 41 insertions(+), 25 deletions(-)
drivers/soc/bcm/bcm2835-power.c +41 -25
@@ -126,8 +126,9 @@#define ASB_AXI_BRDG_ID 0x20 -#define ASB_READ (reg) readl(power->asb + (reg)) -#define ASB_WRITE (reg, val) writel(PM_PASSWORD | (val), power->asb + (reg)) +#define ASB_BASE (is_v3d) (is_v3d && power->rpivid_asb ? power->rpivid_asb : power->asb) +#define ASB_READ (reg, is_v3d) readl(ASB_BASE(is_v3d) + (reg)) +#define ASB_WRITE (reg, val, is_v3d) writel(PM_PASSWORD | (val), ASB_BASE(is_v3d) + (reg))struct bcm2835_power_domain {struct generic_pm_domain base;
@@ -142,13 +143,16 @@ struct bcm2835_power {void __iomem *base;/* AXI Async bridge registers. */ void __iomem *asb; +/* RPiVid bridge registers. */ +void __iomem *rpivid_asb;struct genpd_onecell_data pd_xlate;struct bcm2835_power_domain domains[BCM2835_POWER_DOMAIN_COUNT ];struct reset_controller_dev reset; }; -static int bcm2835_asb_enable (struct bcm2835_power *power,u32 reg) +static int bcm2835_asb_enable (struct bcm2835_power *power,u32 reg, +bool is_v3d) {u64 start;
@@ -158,8 +162,8 @@ static int bcm2835_asb_enable(struct bcm2835_power *power, u32 reg) start =ktime_get_ns ();/* Enable the module's async AXI bridges. */ -ASB_WRITE (reg,ASB_READ (reg) & ~ASB_REQ_STOP ); -while (ASB_READ (reg) &ASB_ACK ) { +ASB_WRITE (reg,ASB_READ (reg, is_v3d) & ~ASB_REQ_STOP , is_v3d); +while (ASB_READ (reg, is_v3d) &ASB_ACK ) {cpu_relax ();if (ktime_get_ns () - start >=1000 )return -ETIMEDOUT ;
@@ -168,7 +172,8 @@ static int bcm2835_asb_enable(struct bcm2835_power *power, u32 reg)return 0 ; } -static int bcm2835_asb_disable (struct bcm2835_power *power,u32 reg) +static int bcm2835_asb_disable (struct bcm2835_power *power,u32 reg, +bool is_v3d) {u64 start;
@@ -178,8 +183,8 @@ static int bcm2835_asb_disable(struct bcm2835_power *power, u32 reg) start =ktime_get_ns ();/* Enable the module's async AXI bridges. */ -ASB_WRITE (reg,ASB_READ (reg) |ASB_REQ_STOP ); -while (!(ASB_READ (reg) &ASB_ACK )) { +ASB_WRITE (reg,ASB_READ (reg, is_v3d) |ASB_REQ_STOP , is_v3d); +while (!(ASB_READ (reg, is_v3d) &ASB_ACK )) {cpu_relax ();if (ktime_get_ns () - start >=1000 )return -ETIMEDOUT ;
@@ -274,7 +279,8 @@ static int bcm2835_asb_power_on(struct bcm2835_power_domain *pd,u32 pm_reg, u32 asb_m_reg, u32 asb_s_reg, - u32 reset_flags) + u32 reset_flags, + bool is_v3d) { struct bcm2835_power *power = pd->power;int ret;
@@ -301,13 +307,13 @@ static int bcm2835_asb_power_on(struct bcm2835_power_domain *pd, goto err_enable_resets; } - ret =bcm2835_asb_enable (power, asb_m_reg); + ret =bcm2835_asb_enable (power, asb_m_reg, is_v3d);if (ret) {dev_err (power->dev,"Failed to enable ASB master for %s\n" , pd->base.name); goto err_disable_clk; } - ret =bcm2835_asb_enable (power, asb_s_reg); + ret =bcm2835_asb_enable (power, asb_s_reg, is_v3d);if (ret) {dev_err (power->dev,"Failed to enable ASB slave for %s\n" , pd->base.name);
@@ -317,7 +323,7 @@ static int bcm2835_asb_power_on(struct bcm2835_power_domain *pd,return 0 ; err_disable_asb_master: -bcm2835_asb_disable (power, asb_m_reg); +bcm2835_asb_disable (power, asb_m_reg, is_v3d); err_disable_clk:clk_disable_unprepare (pd->clk); err_enable_resets:
@@ -329,22 +335,23 @@ static int bcm2835_asb_power_off(struct bcm2835_power_domain *pd,u32 pm_reg, u32 asb_m_reg, u32 asb_s_reg, - u32 reset_flags) + u32 reset_flags, + bool is_v3d) { struct bcm2835_power *power = pd->power;int ret; - ret =bcm2835_asb_disable (power, asb_s_reg); + ret =bcm2835_asb_disable (power, asb_s_reg, is_v3d);if (ret) {dev_warn (power->dev,"Failed to disable ASB slave for %s\n" , pd->base.name);return ret; } - ret =bcm2835_asb_disable (power, asb_m_reg); + ret =bcm2835_asb_disable (power, asb_m_reg, is_v3d);if (ret) {dev_warn (power->dev,"Failed to disable ASB master for %s\n" , pd->base.name); -bcm2835_asb_enable (power, asb_s_reg); +bcm2835_asb_enable (power, asb_s_reg, is_v3d);return ret; }
@@ -369,7 +376,7 @@ static int bcm2835_power_pd_power_on(struct generic_pm_domain *domain)case BCM2835_POWER_DOMAIN_GRAFX_V3D :return bcm2835_asb_power_on (pd,PM_GRAFX ,ASB_V3D_M_CTRL ,ASB_V3D_S_CTRL , -PM_V3DRSTN ); +PM_V3DRSTN , true);case BCM2835_POWER_DOMAIN_IMAGE :return bcm2835_power_power_on (pd,PM_IMAGE );
@@ -377,17 +384,17 @@ static int bcm2835_power_pd_power_on(struct generic_pm_domain *domain)case BCM2835_POWER_DOMAIN_IMAGE_PERI :return bcm2835_asb_power_on (pd,PM_IMAGE ,0 ,0 , -PM_PERIRSTN ); +PM_PERIRSTN , false);case BCM2835_POWER_DOMAIN_IMAGE_ISP :return bcm2835_asb_power_on (pd,PM_IMAGE ,ASB_ISP_M_CTRL ,ASB_ISP_S_CTRL , -PM_ISPRSTN ); +PM_ISPRSTN , false);case BCM2835_POWER_DOMAIN_IMAGE_H264 :return bcm2835_asb_power_on (pd,PM_IMAGE ,ASB_H264_M_CTRL ,ASB_H264_S_CTRL , -PM_H264RSTN ); +PM_H264RSTN , false);case BCM2835_POWER_DOMAIN_USB :PM_WRITE (PM_USB ,PM_USB_CTRLEN );
@@ -435,7 +442,7 @@ static int bcm2835_power_pd_power_off(struct generic_pm_domain *domain)case BCM2835_POWER_DOMAIN_GRAFX_V3D :return bcm2835_asb_power_off (pd,PM_GRAFX ,ASB_V3D_M_CTRL ,ASB_V3D_S_CTRL , -PM_V3DRSTN ); +PM_V3DRSTN , true);case BCM2835_POWER_DOMAIN_IMAGE :return bcm2835_power_power_off (pd,PM_IMAGE );
@@ -443,17 +450,17 @@ static int bcm2835_power_pd_power_off(struct generic_pm_domain *domain)case BCM2835_POWER_DOMAIN_IMAGE_PERI :return bcm2835_asb_power_off (pd,PM_IMAGE ,0 ,0 , -PM_PERIRSTN ); +PM_PERIRSTN , false);case BCM2835_POWER_DOMAIN_IMAGE_ISP :return bcm2835_asb_power_off (pd,PM_IMAGE ,ASB_ISP_M_CTRL ,ASB_ISP_S_CTRL , -PM_ISPRSTN ); +PM_ISPRSTN , false);case BCM2835_POWER_DOMAIN_IMAGE_H264 :return bcm2835_asb_power_off (pd,PM_IMAGE ,ASB_H264_M_CTRL ,ASB_H264_S_CTRL , -PM_H264RSTN ); +PM_H264RSTN , false);case BCM2835_POWER_DOMAIN_USB :PM_WRITE (PM_USB ,0 );
@@ -626,13 +633,22 @@ static int bcm2835_power_probe(struct platform_device *pdev) power->dev = dev; power->base = pm->base; power->asb = pm->asb; + power->rpivid_asb = pm->rpivid_asb; - id =ASB_READ (ASB_AXI_BRDG_ID ); + id =ASB_READ (ASB_AXI_BRDG_ID , false);if (id !=0x62726467 /* "BRDG" */ ) {dev_err (dev,"ASB register ID returned 0x%08x\n" , id);return -ENODEV ; } +if (pm->rpivid_asb) { + id =ASB_READ (ASB_AXI_BRDG_ID , true); +if (id !=0x62726467 /* "BRDG" */ ) { +dev_err (dev,"RPiVid ASB register ID returned 0x%08x\n" , id); +return -ENODEV ; + } + } + power->pd_xlate.domains = devm_kcalloc(dev, ARRAY_SIZE(power_domain_names), sizeof(*power->pd_xlate.domains),
Signature · 1 line
2.35.1
Re: [PATCH v4 08/15] soc: bcm: bcm2835-power: Add support for BCM2711's RPiVid ASB
Hi Peter,
Am 13.02.22 um 23:56 schrieb Peter Robinson:
Quoted 28 lines
From: Nicolas Saenz Julienne <[email protected]>
In BCM2711 the new RPiVid ASB took over V3D. The old ASB is still present with the ISP and H264 bits, and V3D is in the same place in the new ASB as the old one.
Use the fact that '
pm->rpivid_asb' is populated as a hint that we're on BCM2711. On top of that introduce the macroASB_BASE()which will select the correct ASB register base, based on whether we're trying to access V3D and which platform we're on.Signed-off-by Nicolas Saenz Julienne <[email protected]>Signed-off-by Peter Robinson <[email protected]>---
Changes since v2:
- Correct names againChanges since v1:
- Correct namesdrivers/soc/bcm/bcm2835-power.c | 66 ++++++++++++++++++++------------- 1 file changed, 41 insertions(+), 25 deletions(-)drivers/soc/bcm/bcm2835-power.c +0
-0
drivers/soc/bcm/bcm2835-power.c line 131
Quoted 8 lines
drivers/soc/bcm/bcm2835-power.c +3
-2@@ -126,8 +126,9 @@#define ASB_AXI_BRDG_ID 0x20 -#define ASB_READ (reg) readl(power->asb + (reg)) -#define ASB_WRITE (reg, val) writel(PM_PASSWORD | (val), power->asb + (reg)) +#define ASB_BASE (is_v3d) (is_v3d && power->rpivid_asb ? power->rpivid_asb : power->asb) +#define ASB_READ (reg, is_v3d) readl(ASB_BASE(is_v3d) + (reg)) +#define ASB_WRITE (reg, val, is_v3d) writel(PM_PASSWORD | (val), ASB_BASE(is_v3d) + (reg))
just a general note: passing parameter to decide which register should be used is not the preferred way. It's harder to maintain. A more data driven approach is better in the long run.
Quoted 182 lines
drivers/soc/bcm/bcm2835-power.c +29
-22struct bcm2835_power_domain {struct generic_pm_domain base;@@ -142,13 +143,16 @@ struct bcm2835_power {void __iomem *base;/* AXI Async bridge registers. */ void __iomem *asb; +/* RPiVid bridge registers. */ +void __iomem *rpivid_asb;struct genpd_onecell_data pd_xlate;struct bcm2835_power_domain domains[BCM2835_POWER_DOMAIN_COUNT ];struct reset_controller_dev reset; }; -static int bcm2835_asb_enable (struct bcm2835_power *power,u32 reg) +static int bcm2835_asb_enable (struct bcm2835_power *power,u32 reg, +bool is_v3d) {u64 start;@@ -158,8 +162,8 @@ static int bcm2835_asb_enable(struct bcm2835_power *power, u32 reg) start =ktime_get_ns ();/* Enable the module's async AXI bridges. */ -ASB_WRITE (reg,ASB_READ (reg) & ~ASB_REQ_STOP ); -while (ASB_READ (reg) &ASB_ACK ) { +ASB_WRITE (reg,ASB_READ (reg, is_v3d) & ~ASB_REQ_STOP , is_v3d); +while (ASB_READ (reg, is_v3d) &ASB_ACK ) {cpu_relax ();if (ktime_get_ns () - start >=1000 )return -ETIMEDOUT ;@@ -168,7 +172,8 @@ static int bcm2835_asb_enable(struct bcm2835_power *power, u32 reg)return 0 ; } -static int bcm2835_asb_disable (struct bcm2835_power *power,u32 reg) +static int bcm2835_asb_disable (struct bcm2835_power *power,u32 reg, +bool is_v3d) {u64 start;@@ -178,8 +183,8 @@ static int bcm2835_asb_disable(struct bcm2835_power *power, u32 reg) start =ktime_get_ns ();/* Enable the module's async AXI bridges. */ -ASB_WRITE (reg,ASB_READ (reg) |ASB_REQ_STOP ); -while (!(ASB_READ (reg) &ASB_ACK )) { +ASB_WRITE (reg,ASB_READ (reg, is_v3d) |ASB_REQ_STOP , is_v3d); +while (!(ASB_READ (reg, is_v3d) &ASB_ACK )) {cpu_relax ();if (ktime_get_ns () - start >=1000 )return -ETIMEDOUT ;@@ -274,7 +279,8 @@ static int bcm2835_asb_power_on(struct bcm2835_power_domain *pd,u32 pm_reg, u32 asb_m_reg, u32 asb_s_reg, - u32 reset_flags) + u32 reset_flags, + bool is_v3d) { struct bcm2835_power *power = pd->power;int ret;@@ -301,13 +307,13 @@ static int bcm2835_asb_power_on(struct bcm2835_power_domain *pd, goto err_enable_resets; } - ret =bcm2835_asb_enable (power, asb_m_reg); + ret =bcm2835_asb_enable (power, asb_m_reg, is_v3d);if (ret) {dev_err (power->dev,"Failed to enable ASB master for %s\n" , pd->base.name); goto err_disable_clk; } - ret =bcm2835_asb_enable (power, asb_s_reg); + ret =bcm2835_asb_enable (power, asb_s_reg, is_v3d);if (ret) {dev_err (power->dev,"Failed to enable ASB slave for %s\n" , pd->base.name);@@ -317,7 +323,7 @@ static int bcm2835_asb_power_on(struct bcm2835_power_domain *pd,return 0 ; err_disable_asb_master: -bcm2835_asb_disable (power, asb_m_reg); +bcm2835_asb_disable (power, asb_m_reg, is_v3d); err_disable_clk:clk_disable_unprepare (pd->clk); err_enable_resets:@@ -329,22 +335,23 @@ static int bcm2835_asb_power_off(struct bcm2835_power_domain *pd,u32 pm_reg, u32 asb_m_reg, u32 asb_s_reg, - u32 reset_flags) + u32 reset_flags, + bool is_v3d) { struct bcm2835_power *power = pd->power;int ret; - ret =bcm2835_asb_disable (power, asb_s_reg); + ret =bcm2835_asb_disable (power, asb_s_reg, is_v3d);if (ret) {dev_warn (power->dev,"Failed to disable ASB slave for %s\n" , pd->base.name);return ret; } - ret =bcm2835_asb_disable (power, asb_m_reg); + ret =bcm2835_asb_disable (power, asb_m_reg, is_v3d);if (ret) {dev_warn (power->dev,"Failed to disable ASB master for %s\n" , pd->base.name); -bcm2835_asb_enable (power, asb_s_reg); +bcm2835_asb_enable (power, asb_s_reg, is_v3d);return ret; }@@ -369,7 +376,7 @@ static int bcm2835_power_pd_power_on(struct generic_pm_domain *domain)case BCM2835_POWER_DOMAIN_GRAFX_V3D :return bcm2835_asb_power_on (pd,PM_GRAFX ,ASB_V3D_M_CTRL ,ASB_V3D_S_CTRL , -PM_V3DRSTN ); +PM_V3DRSTN , true);case BCM2835_POWER_DOMAIN_IMAGE :return bcm2835_power_power_on (pd,PM_IMAGE );@@ -377,17 +384,17 @@ static int bcm2835_power_pd_power_on(struct generic_pm_domain *domain)case BCM2835_POWER_DOMAIN_IMAGE_PERI :return bcm2835_asb_power_on (pd,PM_IMAGE ,0 ,0 , -PM_PERIRSTN ); +PM_PERIRSTN , false);case BCM2835_POWER_DOMAIN_IMAGE_ISP :return bcm2835_asb_power_on (pd,PM_IMAGE ,ASB_ISP_M_CTRL ,ASB_ISP_S_CTRL , -PM_ISPRSTN ); +PM_ISPRSTN , false);case BCM2835_POWER_DOMAIN_IMAGE_H264 :return bcm2835_asb_power_on (pd,PM_IMAGE ,ASB_H264_M_CTRL ,ASB_H264_S_CTRL , -PM_H264RSTN ); +PM_H264RSTN , false);case BCM2835_POWER_DOMAIN_USB :PM_WRITE (PM_USB ,PM_USB_CTRLEN );@@ -435,7 +442,7 @@ static int bcm2835_power_pd_power_off(struct generic_pm_domain *domain)case BCM2835_POWER_DOMAIN_GRAFX_V3D :return bcm2835_asb_power_off (pd,PM_GRAFX ,ASB_V3D_M_CTRL ,ASB_V3D_S_CTRL , -PM_V3DRSTN ); +PM_V3DRSTN , true);case BCM2835_POWER_DOMAIN_IMAGE :return bcm2835_power_power_off (pd,PM_IMAGE );@@ -443,17 +450,17 @@ static int bcm2835_power_pd_power_off(struct generic_pm_domain *domain)case BCM2835_POWER_DOMAIN_IMAGE_PERI :return bcm2835_asb_power_off (pd,PM_IMAGE ,0 ,0 , -PM_PERIRSTN ); +PM_PERIRSTN , false);case BCM2835_POWER_DOMAIN_IMAGE_ISP :return bcm2835_asb_power_off (pd,PM_IMAGE ,ASB_ISP_M_CTRL ,ASB_ISP_S_CTRL , -PM_ISPRSTN ); +PM_ISPRSTN , false);case BCM2835_POWER_DOMAIN_IMAGE_H264 :return bcm2835_asb_power_off (pd,PM_IMAGE ,ASB_H264_M_CTRL ,ASB_H264_S_CTRL , -PM_H264RSTN ); +PM_H264RSTN , false);case BCM2835_POWER_DOMAIN_USB :PM_WRITE (PM_USB ,0 );@@ -626,13 +633,22 @@ static int bcm2835_power_probe(struct platform_device *pdev) power->dev = dev; power->base = pm->base; power->asb = pm->asb; + power->rpivid_asb = pm->rpivid_asb;
drivers/soc/bcm/bcm2835-power.c static int bcm2835_power_probe(struct platform_device *pdev) · line 646
Quoted 10 lines
drivers/soc/bcm/bcm2835-power.c +4
-1- id =ASB_READ (ASB_AXI_BRDG_ID ); + id =ASB_READ (ASB_AXI_BRDG_ID , false);if (id !=0x62726467 /* "BRDG" */ ) {dev_err (dev,"ASB register ID returned 0x%08x\n" , id);return -ENODEV ; } +if (pm->rpivid_asb) { + id =ASB_READ (ASB_AXI_BRDG_ID , true); +if (id !=0x62726467 /* "BRDG" */ ) {
It would be nice to use a define for this id, since we use it twice.
Best regards
Quoted 8 lines
drivers/soc/bcm/bcm2835-power.c +5
-0+dev_err (dev,"RPiVid ASB register ID returned 0x%08x\n" , id); +return -ENODEV ; + } + } + power->pd_xlate.domains = devm_kcalloc(dev, ARRAY_SIZE(power_domain_names), sizeof(*power->pd_xlate.domains),
Re: [PATCH v4 08/15] soc: bcm: bcm2835-power: Add support for BCM2711's RPiVid ASB
Hi Stefan,
Quoted 232 lines · Stefan Wahren
Hi Peter,
Am 13.02.22 um 23:56 schrieb Peter Robinson:
Quoted 28 lines
From: Nicolas Saenz Julienne <[email protected]>
In BCM2711 the new RPiVid ASB took over V3D. The old ASB is still present with the ISP and H264 bits, and V3D is in the same place in the new ASB as the old one.
Use the fact that '
pm->rpivid_asb' is populated as a hint that we're on BCM2711. On top of that introduce the macroASB_BASE()which will select the correct ASB register base, based on whether we're trying to access V3D and which platform we're on.Signed-off-by Nicolas Saenz Julienne <[email protected]>Signed-off-by Peter Robinson <[email protected]>---
Changes since v2:
- Correct names againChanges since v1:
- Correct namesdrivers/soc/bcm/bcm2835-power.c | 66 ++++++++++++++++++++------------- 1 file changed, 41 insertions(+), 25 deletions(-)drivers/soc/bcm/bcm2835-power.c +0
-0drivers/soc/bcm/bcm2835-power.c line 131
Quoted 8 lines
drivers/soc/bcm/bcm2835-power.c +3
-2@@ -126,8 +126,9 @@#define ASB_AXI_BRDG_ID 0x20 -#define ASB_READ (reg) readl(power->asb + (reg)) -#define ASB_WRITE (reg, val) writel(PM_PASSWORD | (val), power->asb + (reg)) +#define ASB_BASE (is_v3d) (is_v3d && power->rpivid_asb ? power->rpivid_asb : power->asb) +#define ASB_READ (reg, is_v3d) readl(ASB_BASE(is_v3d) + (reg)) +#define ASB_WRITE (reg, val, is_v3d) writel(PM_PASSWORD | (val), ASB_BASE(is_v3d) + (reg))just a general note: passing parameter to decide which register should be used is not the preferred way. It's harder to maintain. A more data driven approach is better in the long run.
Quoted 189 lines
drivers/soc/bcm/bcm2835-power.c +30
-23struct bcm2835_power_domain {struct generic_pm_domain base;@@ -142,13 +143,16 @@ struct bcm2835_power {void __iomem *base;/* AXI Async bridge registers. */ void __iomem *asb; +/* RPiVid bridge registers. */ +void __iomem *rpivid_asb;struct genpd_onecell_data pd_xlate;struct bcm2835_power_domain domains[BCM2835_POWER_DOMAIN_COUNT ];struct reset_controller_dev reset; }; -static int bcm2835_asb_enable (struct bcm2835_power *power,u32 reg) +static int bcm2835_asb_enable (struct bcm2835_power *power,u32 reg, +bool is_v3d) {u64 start;@@ -158,8 +162,8 @@ static int bcm2835_asb_enable(struct bcm2835_power *power, u32 reg) start =ktime_get_ns ();/* Enable the module's async AXI bridges. */ -ASB_WRITE (reg,ASB_READ (reg) & ~ASB_REQ_STOP ); -while (ASB_READ (reg) &ASB_ACK ) { +ASB_WRITE (reg,ASB_READ (reg, is_v3d) & ~ASB_REQ_STOP , is_v3d); +while (ASB_READ (reg, is_v3d) &ASB_ACK ) {cpu_relax ();if (ktime_get_ns () - start >=1000 )return -ETIMEDOUT ;@@ -168,7 +172,8 @@ static int bcm2835_asb_enable(struct bcm2835_power *power, u32 reg)return 0 ; } -static int bcm2835_asb_disable (struct bcm2835_power *power,u32 reg) +static int bcm2835_asb_disable (struct bcm2835_power *power,u32 reg, +bool is_v3d) {u64 start;@@ -178,8 +183,8 @@ static int bcm2835_asb_disable(struct bcm2835_power *power, u32 reg) start =ktime_get_ns ();/* Enable the module's async AXI bridges. */ -ASB_WRITE (reg,ASB_READ (reg) |ASB_REQ_STOP ); -while (!(ASB_READ (reg) &ASB_ACK )) { +ASB_WRITE (reg,ASB_READ (reg, is_v3d) |ASB_REQ_STOP , is_v3d); +while (!(ASB_READ (reg, is_v3d) &ASB_ACK )) {cpu_relax ();if (ktime_get_ns () - start >=1000 )return -ETIMEDOUT ;@@ -274,7 +279,8 @@ static int bcm2835_asb_power_on(struct bcm2835_power_domain *pd,u32 pm_reg, u32 asb_m_reg, u32 asb_s_reg, - u32 reset_flags) + u32 reset_flags, + bool is_v3d) { struct bcm2835_power *power = pd->power;int ret;@@ -301,13 +307,13 @@ static int bcm2835_asb_power_on(struct bcm2835_power_domain *pd, goto err_enable_resets; } - ret =bcm2835_asb_enable (power, asb_m_reg); + ret =bcm2835_asb_enable (power, asb_m_reg, is_v3d);if (ret) {dev_err (power->dev,"Failed to enable ASB master for %s\n" , pd->base.name); goto err_disable_clk; } - ret =bcm2835_asb_enable (power, asb_s_reg); + ret =bcm2835_asb_enable (power, asb_s_reg, is_v3d);if (ret) {dev_err (power->dev,"Failed to enable ASB slave for %s\n" , pd->base.name);@@ -317,7 +323,7 @@ static int bcm2835_asb_power_on(struct bcm2835_power_domain *pd,return 0 ; err_disable_asb_master: -bcm2835_asb_disable (power, asb_m_reg); +bcm2835_asb_disable (power, asb_m_reg, is_v3d); err_disable_clk:clk_disable_unprepare (pd->clk); err_enable_resets:@@ -329,22 +335,23 @@ static int bcm2835_asb_power_off(struct bcm2835_power_domain *pd,u32 pm_reg, u32 asb_m_reg, u32 asb_s_reg, - u32 reset_flags) + u32 reset_flags, + bool is_v3d) { struct bcm2835_power *power = pd->power;int ret; - ret =bcm2835_asb_disable (power, asb_s_reg); + ret =bcm2835_asb_disable (power, asb_s_reg, is_v3d);if (ret) {dev_warn (power->dev,"Failed to disable ASB slave for %s\n" , pd->base.name);return ret; } - ret =bcm2835_asb_disable (power, asb_m_reg); + ret =bcm2835_asb_disable (power, asb_m_reg, is_v3d);if (ret) {dev_warn (power->dev,"Failed to disable ASB master for %s\n" , pd->base.name); -bcm2835_asb_enable (power, asb_s_reg); +bcm2835_asb_enable (power, asb_s_reg, is_v3d);return ret; }@@ -369,7 +376,7 @@ static int bcm2835_power_pd_power_on(struct generic_pm_domain *domain)case BCM2835_POWER_DOMAIN_GRAFX_V3D :return bcm2835_asb_power_on (pd,PM_GRAFX ,ASB_V3D_M_CTRL ,ASB_V3D_S_CTRL , -PM_V3DRSTN ); +PM_V3DRSTN , true);case BCM2835_POWER_DOMAIN_IMAGE :return bcm2835_power_power_on (pd,PM_IMAGE );@@ -377,17 +384,17 @@ static int bcm2835_power_pd_power_on(struct generic_pm_domain *domain)case BCM2835_POWER_DOMAIN_IMAGE_PERI :return bcm2835_asb_power_on (pd,PM_IMAGE ,0 ,0 , -PM_PERIRSTN ); +PM_PERIRSTN , false);case BCM2835_POWER_DOMAIN_IMAGE_ISP :return bcm2835_asb_power_on (pd,PM_IMAGE ,ASB_ISP_M_CTRL ,ASB_ISP_S_CTRL , -PM_ISPRSTN ); +PM_ISPRSTN , false);case BCM2835_POWER_DOMAIN_IMAGE_H264 :return bcm2835_asb_power_on (pd,PM_IMAGE ,ASB_H264_M_CTRL ,ASB_H264_S_CTRL , -PM_H264RSTN ); +PM_H264RSTN , false);case BCM2835_POWER_DOMAIN_USB :PM_WRITE (PM_USB ,PM_USB_CTRLEN );@@ -435,7 +442,7 @@ static int bcm2835_power_pd_power_off(struct generic_pm_domain *domain)case BCM2835_POWER_DOMAIN_GRAFX_V3D :return bcm2835_asb_power_off (pd,PM_GRAFX ,ASB_V3D_M_CTRL ,ASB_V3D_S_CTRL , -PM_V3DRSTN ); +PM_V3DRSTN , true);case BCM2835_POWER_DOMAIN_IMAGE :return bcm2835_power_power_off (pd,PM_IMAGE );@@ -443,17 +450,17 @@ static int bcm2835_power_pd_power_off(struct generic_pm_domain *domain)case BCM2835_POWER_DOMAIN_IMAGE_PERI :return bcm2835_asb_power_off (pd,PM_IMAGE ,0 ,0 , -PM_PERIRSTN ); +PM_PERIRSTN , false);case BCM2835_POWER_DOMAIN_IMAGE_ISP :return bcm2835_asb_power_off (pd,PM_IMAGE ,ASB_ISP_M_CTRL ,ASB_ISP_S_CTRL , -PM_ISPRSTN ); +PM_ISPRSTN , false);case BCM2835_POWER_DOMAIN_IMAGE_H264 :return bcm2835_asb_power_off (pd,PM_IMAGE ,ASB_H264_M_CTRL ,ASB_H264_S_CTRL , -PM_H264RSTN ); +PM_H264RSTN , false);case BCM2835_POWER_DOMAIN_USB :PM_WRITE (PM_USB ,0 );@@ -626,13 +633,22 @@ static int bcm2835_power_probe(struct platform_device *pdev) power->dev = dev; power->base = pm->base; power->asb = pm->asb; + power->rpivid_asb = pm->rpivid_asb; - id =ASB_READ (ASB_AXI_BRDG_ID ); + id =ASB_READ (ASB_AXI_BRDG_ID , false);if (id !=0x62726467 /* "BRDG" */ ) {dev_err (dev,"ASB register ID returned 0x%08x\n" , id);return -ENODEV ; }
Quoted 5 lines
drivers/soc/bcm/bcm2835-power.c static int bcm2835_power_probe(struct platform_device *pdev) · line 646
Quoted 3 lines
drivers/soc/bcm/bcm2835-power.c +3
-0+if (pm->rpivid_asb) { + id =ASB_READ (ASB_AXI_BRDG_ID , true); +if (id !=0x62726467 /* "BRDG" */ ) {It would be nice to use a define for this id, since we use it twice.
Any preferences or suggestion as to what it should be called?
Also are you prepared to add/ok if I add your reviewed-by to the patches you've reviewed?
Peter
Quoted 11 lines
Best regards
Quoted 8 lines
drivers/soc/bcm/bcm2835-power.c +5
-0+dev_err (dev,"RPiVid ASB register ID returned 0x%08x\n" , id); +return -ENODEV ; + } + } + power->pd_xlate.domains = devm_kcalloc(dev, ARRAY_SIZE(power_domain_names), sizeof(*power->pd_xlate.domains),
Re: [PATCH v4 08/15] soc: bcm: bcm2835-power: Add support for BCM2711's RPiVid ASB
Hi Peter,
Am 20.02.22 um 20:27 schrieb Peter Robinson:
Quoted 233 lines
Hi Stefan,
Quoted 230 lines · Stefan Wahren
Hi Peter,
Am 13.02.22 um 23:56 schrieb Peter Robinson:
Quoted 28 lines
From: Nicolas Saenz Julienne <[email protected]>
In BCM2711 the new RPiVid ASB took over V3D. The old ASB is still present with the ISP and H264 bits, and V3D is in the same place in the new ASB as the old one.
Use the fact that '
pm->rpivid_asb' is populated as a hint that we're on BCM2711. On top of that introduce the macroASB_BASE()which will select the correct ASB register base, based on whether we're trying to access V3D and which platform we're on.Signed-off-by Nicolas Saenz Julienne <[email protected]>Signed-off-by Peter Robinson <[email protected]>---
Changes since v2:
- Correct names againChanges since v1:
- Correct namesdrivers/soc/bcm/bcm2835-power.c | 66 ++++++++++++++++++++------------- 1 file changed, 41 insertions(+), 25 deletions(-)drivers/soc/bcm/bcm2835-power.c +0
-0drivers/soc/bcm/bcm2835-power.c line 131
Quoted 8 lines
drivers/soc/bcm/bcm2835-power.c +3
-2@@ -126,8 +126,9 @@#define ASB_AXI_BRDG_ID 0x20 -#define ASB_READ (reg) readl(power->asb + (reg)) -#define ASB_WRITE (reg, val) writel(PM_PASSWORD | (val), power->asb + (reg)) +#define ASB_BASE (is_v3d) (is_v3d && power->rpivid_asb ? power->rpivid_asb : power->asb) +#define ASB_READ (reg, is_v3d) readl(ASB_BASE(is_v3d) + (reg)) +#define ASB_WRITE (reg, val, is_v3d) writel(PM_PASSWORD | (val), ASB_BASE(is_v3d) + (reg))just a general note: passing parameter to decide which register should be used is not the preferred way. It's harder to maintain. A more data driven approach is better in the long run.
Quoted 188 lines
drivers/soc/bcm/bcm2835-power.c +30
-23struct bcm2835_power_domain {struct generic_pm_domain base;@@ -142,13 +143,16 @@ struct bcm2835_power {void __iomem *base;/* AXI Async bridge registers. */ void __iomem *asb; +/* RPiVid bridge registers. */ +void __iomem *rpivid_asb;struct genpd_onecell_data pd_xlate;struct bcm2835_power_domain domains[BCM2835_POWER_DOMAIN_COUNT ];struct reset_controller_dev reset; }; -static int bcm2835_asb_enable (struct bcm2835_power *power,u32 reg) +static int bcm2835_asb_enable (struct bcm2835_power *power,u32 reg, +bool is_v3d) {u64 start;@@ -158,8 +162,8 @@ static int bcm2835_asb_enable(struct bcm2835_power *power, u32 reg) start =ktime_get_ns ();/* Enable the module's async AXI bridges. */ -ASB_WRITE (reg,ASB_READ (reg) & ~ASB_REQ_STOP ); -while (ASB_READ (reg) &ASB_ACK ) { +ASB_WRITE (reg,ASB_READ (reg, is_v3d) & ~ASB_REQ_STOP , is_v3d); +while (ASB_READ (reg, is_v3d) &ASB_ACK ) {cpu_relax ();if (ktime_get_ns () - start >=1000 )return -ETIMEDOUT ;@@ -168,7 +172,8 @@ static int bcm2835_asb_enable(struct bcm2835_power *power, u32 reg)return 0 ; } -static int bcm2835_asb_disable (struct bcm2835_power *power,u32 reg) +static int bcm2835_asb_disable (struct bcm2835_power *power,u32 reg, +bool is_v3d) {u64 start;@@ -178,8 +183,8 @@ static int bcm2835_asb_disable(struct bcm2835_power *power, u32 reg) start =ktime_get_ns ();/* Enable the module's async AXI bridges. */ -ASB_WRITE (reg,ASB_READ (reg) |ASB_REQ_STOP ); -while (!(ASB_READ (reg) &ASB_ACK )) { +ASB_WRITE (reg,ASB_READ (reg, is_v3d) |ASB_REQ_STOP , is_v3d); +while (!(ASB_READ (reg, is_v3d) &ASB_ACK )) {cpu_relax ();if (ktime_get_ns () - start >=1000 )return -ETIMEDOUT ;@@ -274,7 +279,8 @@ static int bcm2835_asb_power_on(struct bcm2835_power_domain *pd,u32 pm_reg, u32 asb_m_reg, u32 asb_s_reg, - u32 reset_flags) + u32 reset_flags, + bool is_v3d) { struct bcm2835_power *power = pd->power;int ret;@@ -301,13 +307,13 @@ static int bcm2835_asb_power_on(struct bcm2835_power_domain *pd, goto err_enable_resets; } - ret =bcm2835_asb_enable (power, asb_m_reg); + ret =bcm2835_asb_enable (power, asb_m_reg, is_v3d);if (ret) {dev_err (power->dev,"Failed to enable ASB master for %s\n" , pd->base.name); goto err_disable_clk; } - ret =bcm2835_asb_enable (power, asb_s_reg); + ret =bcm2835_asb_enable (power, asb_s_reg, is_v3d);if (ret) {dev_err (power->dev,"Failed to enable ASB slave for %s\n" , pd->base.name);@@ -317,7 +323,7 @@ static int bcm2835_asb_power_on(struct bcm2835_power_domain *pd,return 0 ; err_disable_asb_master: -bcm2835_asb_disable (power, asb_m_reg); +bcm2835_asb_disable (power, asb_m_reg, is_v3d); err_disable_clk:clk_disable_unprepare (pd->clk); err_enable_resets:@@ -329,22 +335,23 @@ static int bcm2835_asb_power_off(struct bcm2835_power_domain *pd,u32 pm_reg, u32 asb_m_reg, u32 asb_s_reg, - u32 reset_flags) + u32 reset_flags, + bool is_v3d) { struct bcm2835_power *power = pd->power;int ret; - ret =bcm2835_asb_disable (power, asb_s_reg); + ret =bcm2835_asb_disable (power, asb_s_reg, is_v3d);if (ret) {dev_warn (power->dev,"Failed to disable ASB slave for %s\n" , pd->base.name);return ret; } - ret =bcm2835_asb_disable (power, asb_m_reg); + ret =bcm2835_asb_disable (power, asb_m_reg, is_v3d);if (ret) {dev_warn (power->dev,"Failed to disable ASB master for %s\n" , pd->base.name); -bcm2835_asb_enable (power, asb_s_reg); +bcm2835_asb_enable (power, asb_s_reg, is_v3d);return ret; }@@ -369,7 +376,7 @@ static int bcm2835_power_pd_power_on(struct generic_pm_domain *domain)case BCM2835_POWER_DOMAIN_GRAFX_V3D :return bcm2835_asb_power_on (pd,PM_GRAFX ,ASB_V3D_M_CTRL ,ASB_V3D_S_CTRL , -PM_V3DRSTN ); +PM_V3DRSTN , true);case BCM2835_POWER_DOMAIN_IMAGE :return bcm2835_power_power_on (pd,PM_IMAGE );@@ -377,17 +384,17 @@ static int bcm2835_power_pd_power_on(struct generic_pm_domain *domain)case BCM2835_POWER_DOMAIN_IMAGE_PERI :return bcm2835_asb_power_on (pd,PM_IMAGE ,0 ,0 , -PM_PERIRSTN ); +PM_PERIRSTN , false);case BCM2835_POWER_DOMAIN_IMAGE_ISP :return bcm2835_asb_power_on (pd,PM_IMAGE ,ASB_ISP_M_CTRL ,ASB_ISP_S_CTRL , -PM_ISPRSTN ); +PM_ISPRSTN , false);case BCM2835_POWER_DOMAIN_IMAGE_H264 :return bcm2835_asb_power_on (pd,PM_IMAGE ,ASB_H264_M_CTRL ,ASB_H264_S_CTRL , -PM_H264RSTN ); +PM_H264RSTN , false);case BCM2835_POWER_DOMAIN_USB :PM_WRITE (PM_USB ,PM_USB_CTRLEN );@@ -435,7 +442,7 @@ static int bcm2835_power_pd_power_off(struct generic_pm_domain *domain)case BCM2835_POWER_DOMAIN_GRAFX_V3D :return bcm2835_asb_power_off (pd,PM_GRAFX ,ASB_V3D_M_CTRL ,ASB_V3D_S_CTRL , -PM_V3DRSTN ); +PM_V3DRSTN , true);case BCM2835_POWER_DOMAIN_IMAGE :return bcm2835_power_power_off (pd,PM_IMAGE );@@ -443,17 +450,17 @@ static int bcm2835_power_pd_power_off(struct generic_pm_domain *domain)case BCM2835_POWER_DOMAIN_IMAGE_PERI :return bcm2835_asb_power_off (pd,PM_IMAGE ,0 ,0 , -PM_PERIRSTN ); +PM_PERIRSTN , false);case BCM2835_POWER_DOMAIN_IMAGE_ISP :return bcm2835_asb_power_off (pd,PM_IMAGE ,ASB_ISP_M_CTRL ,ASB_ISP_S_CTRL , -PM_ISPRSTN ); +PM_ISPRSTN , false);case BCM2835_POWER_DOMAIN_IMAGE_H264 :return bcm2835_asb_power_off (pd,PM_IMAGE ,ASB_H264_M_CTRL ,ASB_H264_S_CTRL , -PM_H264RSTN ); +PM_H264RSTN , false);case BCM2835_POWER_DOMAIN_USB :PM_WRITE (PM_USB ,0 );@@ -626,13 +633,22 @@ static int bcm2835_power_probe(struct platform_device *pdev) power->dev = dev; power->base = pm->base; power->asb = pm->asb; + power->rpivid_asb = pm->rpivid_asb; - id =ASB_READ (ASB_AXI_BRDG_ID ); + id =ASB_READ (ASB_AXI_BRDG_ID , false);if (id !=0x62726467 /* "BRDG" */ ) {dev_err (dev,"ASB register ID returned 0x%08x\n" , id);return -ENODEV ; }
Quoted 5 lines
Quoted 4 lines
drivers/soc/bcm/bcm2835-power.c static int bcm2835_power_probe(struct platform_device *pdev) · line 646
Quoted 3 lines
drivers/soc/bcm/bcm2835-power.c +3
-0+if (pm->rpivid_asb) { + id =ASB_READ (ASB_AXI_BRDG_ID , true); +if (id !=0x62726467 /* "BRDG" */ ) {It would be nice to use a define for this id, since we use it twice.
Any preferences or suggestion as to what it should be called?
Unfortunately i don't have any insight into these register. So a suggestion would be BCM2835_BRDG_ID
Quoted 3 lines
Also are you prepared to add/ok if I add your reviewed-by to the patches you've reviewed?
I will give my reviewed-by to the next version. I hope we will get more feedback. So please add <[email protected]> and <[email protected]> for the next round.
Best regards
Quoted 17 lines
Peter
Quoted 10 lines
Best regards
Quoted 8 lines
drivers/soc/bcm/bcm2835-power.c +5
-0+dev_err (dev,"RPiVid ASB register ID returned 0x%08x\n" , id); +return -ENODEV ; + } + } + power->pd_xlate.domains = devm_kcalloc(dev, ARRAY_SIZE(power_domain_names), sizeof(*power->pd_xlate.domains),_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v4 9/15 soc: bcm: bcm2835-power: Bypass power_on/off() calls
In reply to Peter RobinsonFrom: Nicolas Saenz Julienne <[email protected]>
Bypass power_on/power_off() when running on BCM2711 as they are not needed.
---
Changes since v2:
- Correct names
drivers/soc/bcm/bcm2835-power.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/soc/bcm/bcm2835-power.c +8 -0
@@ -197,6 +197,10 @@ static int bcm2835_power_power_off(struct bcm2835_power_domain *pd, u32 pm_reg) {struct bcm2835_power *power = pd->power; +/* We don't run this on BCM2711 */ +if (power->rpivid_asb) +return 0 ; +/* Enable functional isolation */ PM_WRITE (pm_reg,PM_READ (pm_reg) & ~PM_ISFUNC );
@@ -218,6 +222,10 @@ static int bcm2835_power_power_on(struct bcm2835_power_domain *pd, u32 pm_reg)int inrush;bool powok; +/* We don't run this on BCM2711 */ +if (power->rpivid_asb) +return 0 ; +/* If it was already powered on by the fw, leave it that way. */ if (PM_READ (pm_reg) &PM_POWUP )return 0 ;
Signature · 1 line
2.35.1
PATCH v4 10/15 dt-bindings: gpu: v3d: Add BCM2711's compatible
In reply to Peter RobinsonFrom: Nicolas Saenz Julienne <[email protected]>
BCM2711, Raspberry Pi 4's SoC, contains a V3D core. So add its specific compatible to the bindings.
--- Documentation/devicetree/bindings/gpu/brcm,bcm-v3d.yaml | 1 + 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/gpu/brcm,bcm-v3d.yaml +1 -0
@@ -18,6 +18,7 @@ properties: enum: - brcm,7268-v3d - brcm,7278-v3d + - brcm,bcm2711-v3d reg: items:
Signature · 1 line
2.35.1
PATCH v4 11/15 drm/v3d: Get rid of pm code
In reply to Peter RobinsonRuntime PM doesn't seem to work correctly on this driver. On top of that, commit 8b6864e3e138 ("drm/v3d/v3d_drv: Remove unused static variable 'v3d_v3d_pm_ops'") hints that it most likely never did as the driver's PM ops were not hooked-up.
So, in order to support regular operation with V3D on BCM2711 (Raspberry Pi 4), get rid of the PM code. PM will be reinstated once we figure out the underlying issues.
---
Changes since v3:
- Minor updates for rebase
drivers/gpu/drm/v3d/v3d_debugfs.c | 18 +----------------- drivers/gpu/drm/v3d/v3d_drv.c | 11 ----------- drivers/gpu/drm/v3d/v3d_gem.c | 12 +----------- 3 files changed, 2 insertions(+), 39 deletions(-)
drivers/gpu/drm/v3d/v3d_debugfs.c +1 -17
@@ -4,7 +4,6 @@#include <linux/circ_buf.h> #include <linux/ctype.h> #include <linux/debugfs.h> -#include <linux/pm_runtime.h> #include <linux/seq_file.h> #include <drm/drm_debugfs.h>
@@ -130,11 +129,7 @@ static int v3d_v3d_debugfs_ident(struct seq_file *m, void *unused)struct drm_device *dev = node->minor->dev;struct v3d_dev *v3d =to_v3d_dev (dev);u32 ident0, ident1, ident2, ident3, cores; -int ret, core; - - ret =pm_runtime_get_sync (v3d->drm.dev); -if (ret <0 ) -return ret; +int core; ident0 =V3D_READ (V3D_HUB_IDENT0 ); ident1 =V3D_READ (V3D_HUB_IDENT1 );
@@ -187,9 +182,6 @@ static int v3d_v3d_debugfs_ident(struct seq_file *m, void *unused) (misccfg & V3D_MISCCFG_OVRTMUOUT) != 0); } -pm_runtime_mark_last_busy (v3d->drm.dev); -pm_runtime_put_autosuspend (v3d->drm.dev); -return 0 ; }
@@ -217,11 +209,6 @@ static int v3d_measure_clock(struct seq_file *m, void *unused)uint32_t cycles;int core =0 ;int measure_ms =1000 ; -int ret; - - ret =pm_runtime_get_sync (v3d->drm.dev); -if (ret <0 ) -return ret;if (v3d->ver >=40 ) { V3D_CORE_WRITE(core, V3D_V4_PCTR_0_SRC_0_3,
@@ -245,9 +232,6 @@ static int v3d_measure_clock(struct seq_file *m, void *unused) cycles / (measure_ms *1000 ), (cycles / (measure_ms * 100)) % 10); -pm_runtime_mark_last_busy (v3d->drm.dev); -pm_runtime_put_autosuspend (v3d->drm.dev); -return 0 ; }
drivers/gpu/drm/v3d/v3d_drv.c +0 -11
@@ -19,7 +19,6 @@#include <linux/module.h> #include <linux/of_platform.h> #include <linux/platform_device.h> -#include <linux/pm_runtime.h> #include <linux/reset.h> #include <drm/drm_drv.h>
@@ -43,7 +42,6 @@ static int v3d_get_param_ioctl(struct drm_device *dev, void *data, {struct v3d_dev *v3d =to_v3d_dev (dev);struct drm_v3d_get_param *args = data; -int ret;static const u32 reg_map[] = { [DRM_V3D_PARAM_V3D_UIFCFG ] =V3D_HUB_UIFCFG , [DRM_V3D_PARAM_V3D_HUB_IDENT1 ] =V3D_HUB_IDENT1 ,
@@ -69,17 +67,12 @@ static int v3d_get_param_ioctl(struct drm_device *dev, void *data,if (args->value !=0 )return -EINVAL ; - ret =pm_runtime_get_sync (v3d->drm.dev); -if (ret <0 ) -return ret;if (args->param >=DRM_V3D_PARAM_V3D_CORE0_IDENT0 && args->param <=DRM_V3D_PARAM_V3D_CORE0_IDENT2 ) { args->value =V3D_CORE_READ (0 , offset); }else { args->value =V3D_READ (offset); } -pm_runtime_mark_last_busy (v3d->drm.dev); -pm_runtime_put_autosuspend (v3d->drm.dev);return 0 ; }
@@ -276,10 +269,6 @@ static int v3d_platform_drm_probe(struct platform_device *pdev)return -ENOMEM ; } -pm_runtime_use_autosuspend (dev); -pm_runtime_set_autosuspend_delay (dev,50 ); -pm_runtime_enable (dev); - ret =v3d_gem_init (drm);if (ret) goto dma_free;
drivers/gpu/drm/v3d/v3d_gem.c +1 -11
@@ -6,7 +6,6 @@#include <linux/io.h> #include <linux/module.h> #include <linux/platform_device.h> -#include <linux/pm_runtime.h> #include <linux/reset.h> #include <linux/sched/signal.h> #include <linux/uaccess.h>
@@ -367,9 +366,6 @@ v3d_job_free(struct kref *ref)dma_fence_put (job->irq_fence);dma_fence_put (job->done_fence); -pm_runtime_mark_last_busy (job->v3d->drm.dev); -pm_runtime_put_autosuspend (job->v3d->drm.dev); -if (job->perfmon)v3d_perfmon_put (job->perfmon);
@@ -471,14 +467,10 @@ v3d_job_init(struct v3d_dev *v3d, struct drm_file *file_priv, job->v3d = v3d; job->free = free; - ret =pm_runtime_get_sync (v3d->drm.dev); -if (ret <0 ) - goto fail; - ret =drm_sched_job_init (&job->base, &v3d_priv->sched_entity[queue], v3d_priv);if (ret) - goto fail_job; + goto fail;if (has_multisync) {if (se->in_sync_count && se->wait_stage == queue) {
@@ -509,8 +501,6 @@ v3d_job_init(struct v3d_dev *v3d, struct drm_file *file_priv, fail_deps:drm_sched_job_cleanup (&job->base); -fail_job: -pm_runtime_put_autosuspend (v3d->drm.dev); fail:kfree (*container); *container =NULL ;
Signature · 1 line
2.35.1
PATCH v4 12/15 drm/v3d: Add support for bcm2711
In reply to Peter RobinsonAdd compatible string and Kconfig options for bcm2711.
---
Changes since v3:
- Minor updates for rebase
drivers/gpu/drm/v3d/Kconfig | 2 +- drivers/gpu/drm/v3d/v3d_drv.c | 1 + 2 files changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/v3d/Kconfig +1 -1
@@ -1,7 +1,7 @@ # SPDX-License-Identifier: GPL-2.0-only config DRM_V3D tristate "Broadcom V3D 3.x and newer" - depends on ARCH_BCM || ARCH_BRCMSTB || COMPILE_TEST + depends on ARCH_BCM || ARCH_BRCMSTB || ARCH_BCM2835 || COMPILE_TEST depends on DRM depends on COMMON_CLK depends on MMU
drivers/gpu/drm/v3d/v3d_drv.c +1 -0
@@ -193,6 +193,7 @@ static const struct drm_driver v3d_drm_driver = {static const struct of_device_id v3d_of_match[] = { { .compatible ="brcm,7268-v3d" }, { .compatible ="brcm,7278-v3d" }, + { .compatible ="brcm,bcm2711-v3d" }, {}, };MODULE_DEVICE_TABLE (of, v3d_of_match);
Signature · 1 line
2.35.1
Re: [PATCH v4 12/15] drm/v3d: Add support for bcm2711
Hi,
drivers/gpu/drm/v3d/v3d_drv.c static const struct drm_driver v3d_drm_driver = { · line 198
Quoted 7 lines
drivers/gpu/drm/v3d/v3d_drv.c +1
-0@@ -193,6 +193,7 @@ static const struct drm_driver v3d_drm_driver = {static const struct of_device_id v3d_of_match[] = { { .compatible ="brcm,7268-v3d" }, { .compatible ="brcm,7278-v3d" }, + { .compatible ="brcm,bcm2711-v3d" }, {}, };
The downstream tree [1] uses 'brcm,2711-v3d'. Is there a reason for not using the same compatible string ? Having the same string would allow using downstream dtbs (and overlays) with the upstream kernel.
Adrien
[1] https://github.com/raspberrypi/linux/blob/rpi-5.15.y/drivers/gpu/drm/v3d/v3d_drv.c
PATCH v4 13/15 ARM: dts: bcm2711: Enable V3D
In reply to Peter RobinsonThis enables V3D for bcm2711 (used in the Raspberry Pi 4).
---
Changes since v3:
- Minor updates for rebase
Changes since v1:
- Correct node's name address
arch/arm/boot/dts/bcm2711.dtsi | 12 ++++++++++++ 1 file changed, 12 insertions(+)
arch/arm/boot/dts/bcm2711.dtsi +12 -0
@@ -551,6 +551,18 @@ genet_mdio: mdio@e14 { #size-cells = <0x0>; }; }; + + v3d: gpu@7ec00000 { + compatible = "brcm,bcm2711-v3d"; + reg = <0x0 0x7ec00000 0x4000>, + <0x0 0x7ec04000 0x4000>; + reg-names = "hub", "core0"; + + power-domains = <&pm BCM2835_POWER_DOMAIN_GRAFX_V3D>; + resets = <&pm BCM2835_RESET_V3D>; + clocks = <&firmware_clocks 5>; + interrupts = <GIC_SPI 74 IRQ_TYPE_LEVEL_HIGH>; + }; }; };
Signature · 1 line
2.35.1
Re: [PATCH v4 13/15] ARM: dts: bcm2711: Enable V3D
Hi Peter,
Am 13.02.22 um 23:56 schrieb Peter Robinson:
Quoted 22 lines
This enables V3D for bcm2711 (used in the Raspberry Pi 4).
Signed-off-by Nicolas Saenz Julienne <[email protected]>Signed-off-by Peter Robinson <[email protected]>---
Changes since v3:
- Minor updates for rebaseChanges since v1:
- Correct node's name addressarch/arm/boot/dts/bcm2711.dtsi | 12 ++++++++++++ 1 file changed, 12 insertions(+)arch/arm/boot/dts/bcm2711.dtsi +0
-0@@ -551,6 +551,18 @@ genet_mdio: mdio@e14 { #size-cells = <0x0>; }; };
arch/arm/boot/dts/bcm2711.dtsi genet_mdio: mdio@e14 { · line 563
Quoted 10 lines
arch/arm/boot/dts/bcm2711.dtsi +10
-0+ + v3d: gpu@7ec00000 { + compatible = "brcm,bcm2711-v3d"; + reg = <0x0 0x7ec00000 0x4000>, + <0x0 0x7ec04000 0x4000>; + reg-names = "hub", "core0"; + + power-domains = <&pm BCM2835_POWER_DOMAIN_GRAFX_V3D>; + resets = <&pm BCM2835_RESET_V3D>; + clocks = <&firmware_clocks 5>;
please move the firmware clock usage to bcm2711-rpi.dtsi, because it's not defined here.
Best regards
arch/arm/boot/dts/bcm2711.dtsi genet_mdio: mdio@e14 { · line 568
Quoted 5 lines
arch/arm/boot/dts/bcm2711.dtsi +2
-0+ interrupts = <GIC_SPI 74 IRQ_TYPE_LEVEL_HIGH>; + }; }; };
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v4 14/15 ARM: configs: Enable DRM_V3D
In reply to Peter RobinsonBCM2711, the SoC used on the Raspberry Pi 4 has a different GPU than its predecessors. Enable it.
---
Changes since v1:
- Correct node's name address
arch/arm/configs/multi_v7_defconfig | 1 + 1 file changed, 1 insertion(+)
arch/arm/configs/multi_v7_defconfig +1 -0
@@ -706,6 +706,7 @@ CONFIG_DRM_IMX_PARALLEL_DISPLAY=m CONFIG_DRM_IMX_TVE=m CONFIG_DRM_IMX_LDB=m CONFIG_DRM_IMX_HDMI=m +CONFIG_DRM_V3D=m CONFIG_DRM_VC4=m CONFIG_DRM_ETNAVIV=m CONFIG_DRM_MXSFB=m
Signature · 1 line
2.35.1
Re: [PATCH v4 14/15] ARM: configs: Enable DRM_V3D
Hi Peter,
Am 13.02.22 um 23:56 schrieb Peter Robinson:
Quoted 2 lines
BCM2711, the SoC used on the Raspberry Pi 4 has a different GPU than its predecessors. Enable it.
Marek Szyprowski enabled Raspberry Pi 4 support in bcm2835_defconfig. Could you please enabled V3D there too?
Quoted 22 lines
Signed-off-by Nicolas Saenz Julienne <[email protected]>Signed-off-by Peter Robinson <[email protected]>---
Changes since v1:
- Correct node's name addressarch/arm/configs/multi_v7_defconfig | 1 + 1 file changed, 1 insertion(+)arch/arm/configs/multi_v7_defconfig +1
-0@@ -706,6 +706,7 @@ CONFIG_DRM_IMX_PARALLEL_DISPLAY=m CONFIG_DRM_IMX_TVE=m CONFIG_DRM_IMX_LDB=m CONFIG_DRM_IMX_HDMI=m +CONFIG_DRM_V3D=m CONFIG_DRM_VC4=m CONFIG_DRM_ETNAVIV=m CONFIG_DRM_MXSFB=m
PATCH v4 15/15 arm64: config: Enable DRM_V3D
In reply to Peter RobinsonFrom: Nicolas Saenz Julienne <[email protected]>
BCM2711, the SoC used on the Raspberry Pi 4 has a different GPU than its predecessors. Enable it.
--- arch/arm64/configs/defconfig | 1 + 1 file changed, 1 insertion(+)
arch/arm64/configs/defconfig +1 -0
@@ -725,6 +725,7 @@ CONFIG_DRM_I2C_ADV7511_AUDIO=y CONFIG_DRM_DW_HDMI_AHB_AUDIO=m CONFIG_DRM_DW_HDMI_CEC=m CONFIG_DRM_IMX_DCSS=m +CONFIG_DRM_V3D=m CONFIG_DRM_VC4=m CONFIG_DRM_ETNAVIV=m CONFIG_DRM_HISI_HIBMC=m
Signature · 1 line
2.35.1
Hi Peter,
Am 13.02.22 um 23:56 schrieb Peter Robinson:
Quoted 4 lines
This is purely a rebased of Nicolas's v3 patch set from around a year ago.
I've tested this using mesa 21.3.x and Wayland/Gnome on Fedora 35, it's more or less stable with basic testing.
do you plan to submit a follow-up series?
Quoted 9 lines · Stefan Wahren
Hi Peter,
Am 13.02.22 um 23:56 schrieb Peter Robinson:
Quoted 4 lines
This is purely a rebased of Nicolas's v3 patch set from around a year ago.
I've tested this using mesa 21.3.x and Wayland/Gnome on Fedora 35, it's more or less stable with basic testing.
do you plan to submit a follow-up series?
You mean a v5 of this one? Yes, I was just awaiting to see if I get any more feedback, I will probably get time to do it tomorrow.