drm/vc4: Support BCM2711 Display Pipeline
Subsystems (13)
cover drm/vc4: Support BCM2711 Display Pipeline
Hi everyone,
Here's a (pretty long) series to introduce support in the VC4 DRM driver for the display pipeline found in the BCM2711 (and thus the RaspberryPi 4).
The main differences are that there's two HDMI controllers and that there's more pixelvalve now. Those pixelvalve come with a mux in the HVS that still have only 3 FIFOs. Both of those differences are breaking a bunch of expectations in the driver, so we first need a good bunch of cleanup and reworks to introduce support for the new controllers.
Similarly, the HDMI controller has all its registers shuffled and split in multiple controllers now, so we need a bunch of changes to support this as well.
Only the HDMI support is enabled for now (even though the DPI output has been tested too). There's a couple of rough edges still that should be addressed in the next versions:
- Dual output doesn't work
- The transposer (and thus writeback) doesn't work either and conflicts with the output mux too.
Let me know if you have any comments
Maxime
Dave Stevenson (2):
drm/vc4: drv: Add support for the BCM2711 HVS5
drm/vc4: plane: Improve LBM usage
Maxime Ripard (87):
dt-bindings: i2c: brcmstb: Convert the BRCMSTB binding to a schema
dt-bindings: i2c: brcmstb: Add BCM2711 BSC/AUTO-I2C binding
i2c: brcmstb: Support BCM2711 HDMI BSC controllers
i2c: brcmstb: Allow to compile it on BCM2835
clk: Return error code when of provider pointer is NULL
dt-bindings: clock: Add a binding for the RPi Firmware clocks
clk: bcm: rpi: Allow the driver to be probed by DT
clk: bcm: rpi: Statically init clk_init_data
clk: bcm: rpi: Use clk_hw_register for pllb_arm
clk: bcm: rpi: Remove global pllb_arm clock pointer
clk: bcm: rpi: Make sure pllb_arm is removed
clk: bcm: rpi: Remove pllb_arm_lookup global pointer
clk: bcm: rpi: Switch to clk_hw_register_clkdev
clk: bcm: rpi: Make sure the clkdev lookup is removed
clk: bcm: rpi: Create a data structure for the clocks
clk: bcm: rpi: Add clock id to data
clk: bcm: rpi: Pass the clocks data to the firmware function
clk: bcm: rpi: Rename is_prepared function
clk: bcm: rpi: Split pllb clock hooks
clk: bcm: rpi: Make the PLLB registration function return a clk_hw
clk: bcm: rpi: Add DT provider for the clocks
clk: bcm: rpi: Discover the firmware clocks
ARM: dts: bcm2711: Add firmware clocks node
reset: Move reset-simple header out of drivers/reset
reset: simple: Add reset callback
dt-bindings: clock: Add BCM2711 DVP binding
clk: bcm: Add BCM2711 DVP driver
ARM: dts: bcm2711: Add HDMI DVP
dt-bindings: display: Convert VC4 bindings to schemas
dt-bindings: display: vc4: dpi: Add missing clock-names property
dt-bindings: display: vc4: dsi: Add missing clock properties
dt-bindings: display: vc4: hdmi: Add missing clock-names property
dt-bindings: display: vc4: Document BCM2711 VC5
drm/vc4: drv: Add include guards
drm/vc4: drv: Support BCM2711
drm/vc4: plane: Move planes creation to its own function drm/vc4: plane: Move additional planes creation to driver drm/vc4: plane: Register all the planes at once
drm/vc4: plane: Create overlays for any CRTC
drm/vc4: plane: Create more planes
drm/vc4: crtc: Rename SoC data structures
drm/vc4: crtc: Move crtc state to common header
drm/vc4: crtc: Deal with different number of pixel per clock drm/vc4: crtc: Use a shared interrupt
drm/vc4: crtc: Turn static const variable into a define drm/vc4: crtc: Move the cob allocation outside of bind drm/vc4: crtc: Rename HVS channel to output
drm/vc4: crtc: Use local chan variable
drm/vc4: crtc: Enable and disable the PV in atomic_enable / disable drm/vc4: crtc: Assign output to channel automatically drm/vc4: crtc: Add FIFO depth to vc4_crtc_data
drm/vc4: crtc: Add function to compute FIFO level bits drm/vc4: crtc: Rename HDMI encoder type to HDMI0
drm/vc4: crtc: Add HDMI1 encoder type
drm/vc4: crtc: Remove redundant call to drm_crtc_enable_color_mgmt drm/vc4: crtc: Disable color management for HVS5
dt-bindings: display: vc4: pv: Add BCM2711 pixel valves drm/vc4: crtc: Add BCM2711 pixelvalves
drm/vc4: hdmi: Use debugfs private field
drm/vc4: hdmi: Move structure to header
drm/vc4: hdmi: rework connectors and encoders
drm/vc4: hdmi: Remove DDC argument to connector_init drm/vc4: hdmi: Rename hdmi to vc4_hdmi
drm/vc4: hdmi: Move accessors to vc4_hdmi
drm/vc4: hdmi: Use local vc4_hdmi directly
drm/vc4: hdmi: Add container_of macros for encoders and connectors drm/vc4: hdmi: Pass vc4_hdmi to CEC code
drm/vc4: hdmi: Remove vc4_dev hdmi pointer
drm/vc4: hdmi: Remove vc4_hdmi_connector
drm/vc4: hdmi: Introduce resource init and variant drm/vc4: hdmi: Implement a register layout abstraction drm/vc4: hdmi: Add reset callback
drm/vc4: hdmi: Add PHY init and disable function
drm/vc4: hdmi: Add PHY RNG enable / disable function drm/vc4: hdmi: Add a CSC setup callback
drm/vc4: hdmi: Add a set_timings callback
drm/vc4: hdmi: Add HDMI ID
drm/vc4: hdmi: Deal with multiple debugfs files
drm/vc4: hdmi: Add an audio support flag
drm/vc4: hdmi: Move CEC init to its own function
drm/vc4: hdmi: Add CEC support flag
drm/vc4: hdmi: Remove unused CEC_CLOCK_DIV define
drm/vc4: hdmi: Rename drm_encoder pointer in mode_valid drm/vc4: hdmi: Adjust HSM clock rate depending on pixel rate drm/vc4: hdmi: Support the BCM2711 HDMI controllers
dt-bindings: display: vc4: hdmi: Add BCM2711 HDMI controllers bindings
ARM: dts: bcm2711: Enable the display pipeline
Documentation/devicetree/bindings/clock/brcm,bcm2711-dvp.yaml | 47 ++- Documentation/devicetree/bindings/clock/raspberrypi,firmware-clocks.yaml | 39 ++- Documentation/devicetree/bindings/display/brcm,bcm-vc4.txt | 174 +--------- Documentation/devicetree/bindings/display/brcm,bcm2835-dpi.yaml | 72 ++++- Documentation/devicetree/bindings/display/brcm,bcm2835-dsi0.yaml | 84 ++++- Documentation/devicetree/bindings/display/brcm,bcm2835-hdmi.yaml | 180 ++++++++++- Documentation/devicetree/bindings/display/brcm,bcm2835-hvs.yaml | 37 ++- Documentation/devicetree/bindings/display/brcm,bcm2835-pixelvalve0.yaml | 45 ++- Documentation/devicetree/bindings/display/brcm,bcm2835-txp.yaml | 37 ++- Documentation/devicetree/bindings/display/brcm,bcm2835-v3d.yaml | 42 ++- Documentation/devicetree/bindings/display/brcm,bcm2835-vc4.yaml | 35 ++- Documentation/devicetree/bindings/display/brcm,bcm2835-vec.yaml | 44 ++- Documentation/devicetree/bindings/i2c/brcm,brcmstb-i2c.yaml | 97 +++++- Documentation/devicetree/bindings/i2c/i2c-brcmstb.txt | 26 +- MAINTAINERS | 4 +- arch/arm/boot/dts/bcm2711-rpi-4-b.dts | 40 ++- arch/arm/boot/dts/bcm2711.dtsi | 132 +++++++- drivers/clk/bcm/Kconfig | 1 +- drivers/clk/bcm/Makefile | 1 +- drivers/clk/bcm/clk-bcm2711-dvp.c | 113 ++++++- drivers/clk/bcm/clk-raspberrypi.c | 271 ++++++++++---- drivers/clk/clk.c | 14 +- drivers/gpu/drm/vc4/Makefile | 1 +- drivers/gpu/drm/vc4/vc4_crtc.c | 328 ++++++++++------- drivers/gpu/drm/vc4/vc4_drv.c | 5 +- drivers/gpu/drm/vc4/vc4_drv.h | 56 ++- drivers/gpu/drm/vc4/vc4_hdmi.c | 1364 ++++++++++++++++++++++++++++++++++++++++++------------------------------ drivers/gpu/drm/vc4/vc4_hdmi.h | 175 +++++++++- drivers/gpu/drm/vc4/vc4_hdmi_phy.c | 509 +++++++++++++++++++++++++++- drivers/gpu/drm/vc4/vc4_hdmi_regs.h | 445 +++++++++++++++++++++++- drivers/gpu/drm/vc4/vc4_hvs.c | 17 +- drivers/gpu/drm/vc4/vc4_kms.c | 175 ++++++++- drivers/gpu/drm/vc4/vc4_plane.c | 271 ++++++++++---- drivers/gpu/drm/vc4/vc4_regs.h | 173 ++++----- drivers/i2c/busses/Kconfig | 2 +- drivers/i2c/busses/i2c-brcmstb.c | 33 ++- drivers/reset/reset-simple.c | 24 +- drivers/reset/reset-simple.h | 41 +-- drivers/reset/reset-socfpga.c | 3 +- drivers/reset/reset-sunxi.c | 3 +- drivers/reset/reset-uniphier-glue.c | 3 +- include/linux/reset/reset-simple.h | 45 ++- include/soc/bcm2835/raspberrypi-firmware.h | 5 +- 43 files changed, 4020 insertions(+), 1193 deletions(-) create mode 100644 Documentation/devicetree/bindings/clock/brcm,bcm2711-dvp.yaml create mode 100644 Documentation/devicetree/bindings/clock/raspberrypi,firmware-clocks.yaml delete mode 100644 Documentation/devicetree/bindings/display/brcm,bcm-vc4.txt create mode 100644 Documentation/devicetree/bindings/display/brcm,bcm2835-dpi.yaml create mode 100644 Documentation/devicetree/bindings/display/brcm,bcm2835-dsi0.yaml create mode 100644 Documentation/devicetree/bindings/display/brcm,bcm2835-hdmi.yaml create mode 100644 Documentation/devicetree/bindings/display/brcm,bcm2835-hvs.yaml create mode 100644 Documentation/devicetree/bindings/display/brcm,bcm2835-pixelvalve0.yaml create mode 100644 Documentation/devicetree/bindings/display/brcm,bcm2835-txp.yaml create mode 100644 Documentation/devicetree/bindings/display/brcm,bcm2835-v3d.yaml create mode 100644 Documentation/devicetree/bindings/display/brcm,bcm2835-vc4.yaml create mode 100644 Documentation/devicetree/bindings/display/brcm,bcm2835-vec.yaml create mode 100644 Documentation/devicetree/bindings/i2c/brcm,brcmstb-i2c.yaml delete mode 100644 Documentation/devicetree/bindings/i2c/i2c-brcmstb.txt create mode 100644 drivers/clk/bcm/clk-bcm2711-dvp.c create mode 100644 drivers/gpu/drm/vc4/vc4_hdmi.h create mode 100644 drivers/gpu/drm/vc4/vc4_hdmi_phy.c create mode 100644 drivers/gpu/drm/vc4/vc4_hdmi_regs.h delete mode 100644 drivers/reset/reset-simple.h create mode 100644 include/linux/reset/reset-simple.h
base-commit: fca8fce14e6ce96f4d22783ab8ddea09c0f4de34
Signature · 6 lines
git-series 0.9.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH 1/89 dt-bindings: i2c: brcmstb: Convert the BRCMSTB binding to a schema
Switch the DT binding to a YAML schema to enable the DT validation.
--- Documentation/devicetree/bindings/i2c/brcm,brcmstb-i2c.yaml | 59 +++++++- Documentation/devicetree/bindings/i2c/i2c-brcmstb.txt | 26 +--- MAINTAINERS | 2 +- 3 files changed, 60 insertions(+), 27 deletions(-) create mode 100644 Documentation/devicetree/bindings/i2c/brcm,brcmstb-i2c.yaml delete mode 100644 Documentation/devicetree/bindings/i2c/i2c-brcmstb.txt
Documentation/devicetree/bindings/i2c/brcm,brcmstb-i2c.yaml new file +59 -0
@@ -0,0 +1,59 @@ +# SPDX-License-Identifier: GPL-2.0 +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/i2c/brcm,brcmstb-i2c.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Broadcom STB BSC IIC Master Controller + +maintainers: + - Kamal Dasu <[email protected]> + +allOf: + - $ref: /schemas/i2c/i2c-controller.yaml# + +properties: + compatible: + enum: + - brcm,brcmstb-i2c + - brcm,brcmper-i2c + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + interrupt-names: + maxItems: 1 + + clock-frequency: + enum: + - 46875 + - 50000 + - 93750 + - 97500 + - 187500 + - 200000 + - 375000 + - 390000 + +required: + - compatible + - reg + - clock-frequency + +unevaluatedProperties: false + +examples: + - | + bsca: i2c@f0406200 { + clock-frequency = <390000>; + compatible = "brcm,brcmstb-i2c"; + interrupt-parent = <&irq0_intc>; + reg = <0xf0406200 0x58>; + interrupts = <0x18>; + interrupt-names = "upg_bsca"; + }; + +...
Documentation/devicetree/bindings/i2c/i2c-brcmstb.txt deleted +0 -26
@@ -1,26 +0,0 @@ -Broadcom stb bsc iic master controller - -Required properties: - -- compatible: should be "brcm,brcmstb-i2c" or "brcm,brcmper-i2c" -- clock-frequency: 32-bit decimal value of iic master clock freqency in Hz - valid values are 375000, 390000, 187500, 200000 - 93750, 97500, 46875 and 50000 -- reg: specifies the base physical address and size of the registers - -Optional properties : - -- interrupts: specifies the interrupt number, the irq line to be used -- interrupt-names: Interrupt name string - -Example: - -bsca: i2c@f0406200 { - clock-frequency = <390000>; - compatible = "brcm,brcmstb-i2c"; - interrupt-parent = <&irq0_intc>; - reg = <0xf0406200 0x58>; - interrupts = <0x18>; - interrupt-names = "upg_bsca"; -}; -
MAINTAINERS +1 -1
@@ -3431,7 +3431,7 @@ L: [email protected] L: [email protected] S: Supported F: drivers/i2c/busses/i2c-brcmstb.c -F: Documentation/devicetree/bindings/i2c/i2c-brcmstb.txt +F: Documentation/devicetree/bindings/i2c/brcm,brcmstb-i2c.yaml BROADCOM BRCMSTB USB2 and USB3 PHY DRIVER M: Al Cooper <[email protected]>
Signature · 1 line
git-series 0.9.1
Re: [PATCH 01/89] dt-bindings: i2c: brcmstb: Convert the BRCMSTB binding to a schema
Quoted 10 lines · Maxime Ripard
Switch the DT binding to a YAML schema to enable the DT validation.
Cc Kamal Dasu <[email protected]>Cc Florian Fainelli <[email protected]>Cc Rob Herring <[email protected]>Cc Wolfram Sang <[email protected]>Signed-off-by Maxime Ripard <[email protected]>
Signature · 1 line
Florian
Re: [PATCH 01/89] dt-bindings: i2c: brcmstb: Convert the BRCMSTB binding to a schema
In reply to Maxime RipardQuoted 10 lines · Maxime Ripard
Switch the DT binding to a YAML schema to enable the DT validation.
Cc Kamal Dasu <[email protected]>Cc Florian Fainelli <[email protected]>Cc Rob Herring <[email protected]>Cc Wolfram Sang <wsa-z923LK4zBo2bacvFa/[email protected]>Cc bcm-kernel-feedback-list-dY08KVG/lbpWk0Htik3J/[email protected]Signed-off-by Maxime Ripard <[email protected]>
Quoted 8 lines
--- Documentation/devicetree/bindings/i2c/brcm,brcmstb-i2c.yaml | 59 +++++++- Documentation/devicetree/bindings/i2c/i2c-brcmstb.txt | 26 +--- MAINTAINERS | 2 +- 3 files changed, 60 insertions(+), 27 deletions(-) create mode 100644 Documentation/devicetree/bindings/i2c/brcm,brcmstb-i2c.yaml delete mode 100644 Documentation/devicetree/bindings/i2c/i2c-brcmstb.txt
Re: [PATCH 01/89] dt-bindings: i2c: brcmstb: Convert the BRCMSTB binding to a schema
In reply to Maxime RipardQuoted 10 lines · Maxime Ripard
Switch the DT binding to a YAML schema to enable the DT validation.
Cc Kamal Dasu <[email protected]>Cc Florian Fainelli <[email protected]>Cc Rob Herring <[email protected]>Cc Wolfram Sang <[email protected]>Signed-off-by Maxime Ripard <[email protected]>
I didn't get the cover letter, so I assume I shall pick the I2C patches. Please let me have the cover letter next time.
Wolfram Sang
AppliedRe: [PATCH 01/89] dt-bindings: i2c: brcmstb: Convert the BRCMSTB binding to a schema
In reply to Maxime RipardQuoted 10 lines · Maxime Ripard
Switch the DT binding to a YAML schema to enable the DT validation.
Cc Kamal Dasu <[email protected]>Cc Florian Fainelli <[email protected]>Cc Rob Herring <[email protected]>Cc Wolfram Sang <wsa-z923LK4zBo2bacvFa/[email protected]>Cc bcm-kernel-feedback-list-dY08KVG/lbpWk0Htik3J/[email protected]Signed-off-by Maxime Ripard <[email protected]>
Applied to for-next, thanks!
PATCH 2/89 dt-bindings: i2c: brcmstb: Add BCM2711 BSC/AUTO-I2C binding
In reply to Maxime RipardThe HDMI blocks in the BCM2771 have an i2c controller to retrieve the EDID. This block is split into two parts, the BSC and the AUTO_I2C, lying in two separate register areas.
The AUTO_I2C block has a mailbox-like interface and will take away the BSC control from the CPU if enabled. However, the BSC is the actually the same controller than the one supported by the brcmstb driver, and the AUTO_I2C doesn't really bring any immediate benefit.
We can model it in the DT as a single device with two register range, which will allow us to use or or the other in the driver without changing anything in the DT.
--- Documentation/devicetree/bindings/i2c/brcm,brcmstb-i2c.yaml | 40 ++++++- 1 file changed, 39 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/i2c/brcm,brcmstb-i2c.yaml +39 -1
@@ -15,11 +15,21 @@ allOf: properties: compatible: enum: + - brcm,bcm2711-hdmi-i2c - brcm,brcmstb-i2c - brcm,brcmper-i2c reg: - maxItems: 1 + minItems: 1 + maxItems: 2 + items: + - description: BSC register range + - description: Auto-I2C register range + + reg-names: + items: + - const: bsc + - const: auto-i2c interrupts: maxItems: 1
@@ -45,6 +55,26 @@ required: unevaluatedProperties: false +if: + properties: + compatible: + contains: + enum: + - brcm,bcm2711-hdmi-i2c + +then: + properties: + reg: + minItems: 2 + + required: + - reg-names + +else: + properties: + reg: + maxItems: 1 + examples: - | bsca: i2c@f0406200 {
@@ -56,4 +86,12 @@ examples: interrupt-names = "upg_bsca"; }; + - | + ddc0: i2c@7ef04500 { + compatible = "brcm,bcm2711-hdmi-i2c"; + reg = <0x7ef04500 0x100>, <0x7ef00b00 0x300>; + reg-names = "bsc", "auto-i2c"; + clock-frequency = <390000>; + }; + ...
Signature · 1 line
git-series 0.9.1
Re: [PATCH 02/89] dt-bindings: i2c: brcmstb: Add BCM2711 BSC/AUTO-I2C binding
Quoted 13 lines · Maxime Ripard
The HDMI blocks in the BCM2771 have an i2c controller to retrieve the EDID. This block is split into two parts, the BSC and the
AUTO_I2C, lying in two separate register areas.The
AUTO_I2Cblock has a mailbox-like interface and will take away the BSC control from the CPU if enabled. However, the BSC is the actually the same controller than the one supported by the brcmstb driver, and theAUTO_I2Cdoesn't really bring any immediate benefit.We can model it in the DT as a single device with two register range, which will allow us to use or or the other in the driver without changing anything in the DT.
Quoted 8 lines
Cc Kamal Dasu <[email protected]>Cc Florian Fainelli <[email protected]>Cc Rob Herring <[email protected]>Cc Wolfram Sang <wsa-z923LK4zBo2bacvFa/[email protected]>Cc bcm-kernel-feedback-list-dY08KVG/lbpWk0Htik3J/[email protected]Signed-off-by Maxime Ripard <[email protected]>
Signature · 1 line
Florian
Re: [PATCH 02/89] dt-bindings: i2c: brcmstb: Add BCM2711 BSC/AUTO-I2C binding
In reply to Maxime RipardQuoted 21 lines · Maxime Ripard
The HDMI blocks in the BCM2771 have an i2c controller to retrieve the EDID. This block is split into two parts, the BSC and the
AUTO_I2C, lying in two separate register areas.The
AUTO_I2Cblock has a mailbox-like interface and will take away the BSC control from the CPU if enabled. However, the BSC is the actually the same controller than the one supported by the brcmstb driver, and theAUTO_I2Cdoesn't really bring any immediate benefit.We can model it in the DT as a single device with two register range, which will allow us to use or or the other in the driver without changing anything in the DT.
Cc Kamal Dasu <[email protected]>Cc Florian Fainelli <[email protected]>Cc Rob Herring <[email protected]>Cc Wolfram Sang <[email protected]>Signed-off-by Maxime Ripard <[email protected]>
Quoted 4 lines
--- Documentation/devicetree/bindings/i2c/brcm,brcmstb-i2c.yaml | 40 ++++++- 1 file changed, 39 insertions(+), 1 deletion(-)
Wolfram Sang
AppliedRe: [PATCH 02/89] dt-bindings: i2c: brcmstb: Add BCM2711 BSC/AUTO-I2C binding
In reply to Maxime RipardQuoted 13 lines · Maxime Ripard
The HDMI blocks in the BCM2771 have an i2c controller to retrieve the EDID. This block is split into two parts, the BSC and the
AUTO_I2C, lying in two separate register areas.The
AUTO_I2Cblock has a mailbox-like interface and will take away the BSC control from the CPU if enabled. However, the BSC is the actually the same controller than the one supported by the brcmstb driver, and theAUTO_I2Cdoesn't really bring any immediate benefit.We can model it in the DT as a single device with two register range, which will allow us to use or or the other in the driver without changing anything in the DT.
Quoted 8 lines
Cc Kamal Dasu <[email protected]>Cc Florian Fainelli <[email protected]>Cc Rob Herring <[email protected]>Cc Wolfram Sang <wsa-z923LK4zBo2bacvFa/[email protected]>Cc bcm-kernel-feedback-list-dY08KVG/lbpWk0Htik3J/[email protected]Signed-off-by Maxime Ripard <[email protected]>
Applied to for-next, thanks!
PATCH 3/89 i2c: brcmstb: Support BCM2711 HDMI BSC controllers
In reply to Maxime RipardThe HDMI blocks in the BCM2771 have an i2c controller to retrieve the EDID. This block is split into two parts, the BSC and the AUTO_I2C, lying in two separate register areas.
The AUTO_I2C block has a mailbox-like interface and will take away the BSC control from the CPU if enabled. However, the BSC is the actually the same controller than the one supported by the brcmstb driver, and the AUTO_I2C doesn't really bring any immediate benefit.
Let's use the BSC then, but let's also tie the AUTO_I2C registers with a separate compatible so that we can enable AUTO_I2C if needed in the future.
The AUTO_I2C is enabled by default at boot though, so we first need to release the BSC from the AUTO_I2C control.
--- drivers/i2c/busses/i2c-brcmstb.c | 33 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+)
drivers/i2c/busses/i2c-brcmstb.c +33 -0
@@ -580,6 +580,31 @@ static void brcmstb_i2c_set_bsc_reg_defaults(struct brcmstb_i2c_dev *dev)brcmstb_i2c_set_bus_speed (dev); } +#define AUTOI2C_CTRL0 0x26c +#define AUTOI2C_CTRL0_RELEASE_BSC BIT(1) + +static int bcm2711_release_bsc (struct brcmstb_i2c_dev *dev) +{ +struct platform_device *pdev =to_platform_device (dev->device); +struct resource *iomem; +void __iomem *autoi2c; + +/* Map hardware registers */ + iomem =platform_get_resource_byname (pdev,IORESOURCE_MEM ,"auto-i2c" ); + autoi2c =devm_ioremap_resource (&pdev->dev, iomem); +if (IS_ERR (autoi2c)) +return PTR_ERR (autoi2c); + +writel (AUTOI2C_CTRL0_RELEASE_BSC , autoi2c +AUTOI2C_CTRL0 ); +devm_iounmap (&pdev->dev, autoi2c); + +/* We need to reset the controller after the release */ + dev->bsc_regmap->iic_enable =0 ; +bsc_writel (dev, dev->bsc_regmap->iic_enable, iic_enable); + +return 0 ; +} +static int brcmstb_i2c_probe (struct platform_device *pdev) {int rc =0 ;
@@ -609,6 +634,13 @@ static int brcmstb_i2c_probe(struct platform_device *pdev) goto probe_errorout; } +if (of_device_is_compatible (dev->device->of_node, +"brcm,bcm2711-hdmi-i2c" )) { + rc =bcm2711_release_bsc (dev); +if (rc) + goto probe_errorout; + } + rc =of_property_read_string (dev->device->of_node,"interrupt-names" , &int_name);if (rc <0 )
@@ -705,6 +737,7 @@ static SIMPLE_DEV_PM_OPS(brcmstb_i2c_pm, brcmstb_i2c_suspend,static const struct of_device_id brcmstb_i2c_of_match[] = { {.compatible ="brcm,brcmstb-i2c" }, {.compatible ="brcm,brcmper-i2c" }, + {.compatible ="brcm,bcm2711-hdmi-i2c" }, {}, };MODULE_DEVICE_TABLE (of, brcmstb_i2c_of_match);
Signature · 1 line
git-series 0.9.1
Re: [PATCH 03/89] i2c: brcmstb: Support BCM2711 HDMI BSC controllers
Quoted 22 lines · Maxime Ripard
The HDMI blocks in the BCM2771 have an i2c controller to retrieve the EDID. This block is split into two parts, the BSC and the
AUTO_I2C, lying in two separate register areas.The
AUTO_I2Cblock has a mailbox-like interface and will take away the BSC control from the CPU if enabled. However, the BSC is the actually the same controller than the one supported by the brcmstb driver, and theAUTO_I2Cdoesn't really bring any immediate benefit.Let's use the BSC then, but let's also tie the
AUTO_I2Cregisters with a separate compatible so that we can enableAUTO_I2Cif needed in the future.The
AUTO_I2Cis enabled by default at boot though, so we first need to release the BSC from theAUTO_I2Ccontrol.Cc Kamal Dasu <[email protected]>Cc Florian Fainelli <[email protected]>Cc Wolfram Sang <[email protected]>Signed-off-by Maxime Ripard <[email protected]>
[snip]
drivers/i2c/busses/i2c-brcmstb.c static SIMPLE_DEV_PM_OPS(brcmstb_i2c_pm, brcmstb_i2c_suspend, · line 740
Quoted 5 lines
drivers/i2c/busses/i2c-brcmstb.c +1
-0@@ -705,6 +737,7 @@ static SIMPLE_DEV_PM_OPS(brcmstb_i2c_pm, brcmstb_i2c_suspend,static const struct of_device_id brcmstb_i2c_of_match[] = { {.compatible ="brcm,brcmstb-i2c" }, {.compatible ="brcm,brcmper-i2c" }, + {.compatible ="brcm,bcm2711-hdmi-i2c" },
You could have added the bcm2711_release_bsc here as a function attached with the of_device_id::data member of the structure and do:
if (data && data->init_func)
rc = data->init_func(dev);
But we can defer that until we have a second compatible string that requires the same approach.
Signature · 1 line
Florian
Re: [PATCH 03/89] i2c: brcmstb: Support BCM2711 HDMI BSC controllers
In reply to Maxime RipardQuoted 16 lines · Maxime Ripard
The HDMI blocks in the BCM2771 have an i2c controller to retrieve the EDID. This block is split into two parts, the BSC and the
AUTO_I2C, lying in two separate register areas.The
AUTO_I2Cblock has a mailbox-like interface and will take away the BSC control from the CPU if enabled. However, the BSC is the actually the same controller than the one supported by the brcmstb driver, and theAUTO_I2Cdoesn't really bring any immediate benefit.Let's use the BSC then, but let's also tie the
AUTO_I2Cregisters with a separate compatible so that we can enableAUTO_I2Cif needed in the future.The
AUTO_I2Cis enabled by default at boot though, so we first need to release the BSC from theAUTO_I2Ccontrol.
Quoted 6 lines
Cc Kamal Dasu <[email protected]>Cc Florian Fainelli <[email protected]>Cc Wolfram Sang <[email protected]>Signed-off-by Maxime Ripard <[email protected]>
Fixed the acked-by and applied to for-next, thanks!
FYI, cppcheck rightfully warned about this in the driver:
drivers/i2c/busses/i2c-brcmstb.c:319:7: warning: Condition 'CMD_RD' is always true [knownConditionTrueFalse]
if ((CMD_RD || CMD_WR) &&
^
drivers/i2c/busses/i2c-brcmstb.c:319:17: warning: Condition 'CMD_WR' is always false [knownConditionTrueFalse]
if ((CMD_RD || CMD_WR) &&
^drivers/i2c/busses/i2c-brcmstb.c:464:0: warning: Variable 'len' is assigned a value that is never used. [unreadVariable]
int len = 0;
Not related to this patch, but maybe one of you is interested...
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 4/89 i2c: brcmstb: Allow to compile it on BCM2835
In reply to Maxime RipardThe BCM2711, supported by ARCH_BCM2835, also has a controller by the brcmstb driver so let's allow it to be compiled on that platform.
--- drivers/i2c/busses/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i2c/busses/Kconfig +1 -1
@@ -476,7 +476,7 @@ config I2C_BCM_KONA config I2C_BRCMSTB tristate "BRCM Settop/DSL I2C controller" depends on ARCH_BRCMSTB || BMIPS_GENERIC || ARCH_BCM_63XX || \ - COMPILE_TEST + COMPILE_TEST || ARCH_BCM2835 default y help If you say yes to this option, support will be included for the
Signature · 1 line
git-series 0.9.1
Re: [PATCH 04/89] i2c: brcmstb: Allow to compile it on BCM2835
Quoted 9 lines · Maxime Ripard
The BCM2711, supported by
ARCH_BCM2835, also has a controller by the brcmstb driver so let's allow it to be compiled on that platform.Cc Kamal Dasu <[email protected]>Cc Florian Fainelli <[email protected]>Cc Wolfram Sang <[email protected]>Signed-off-by Maxime Ripard <[email protected]>
Signature · 1 line
Florian
Re: [PATCH 04/89] i2c: brcmstb: Allow to compile it on BCM2835
In reply to Maxime Riparddrivers/i2c/busses/Kconfig config I2C_BCM_KONA · line 479
Quoted 6 lines
config
I2C_BRCMSTBdrivers/i2c/busses/Kconfig +1
-1tristate "BRCM Settop/DSL I2C controller" depends on ARCH_BRCMSTB || BMIPS_GENERIC || ARCH_BCM_63XX || \ - COMPILE_TEST + COMPILE_TEST || ARCH_BCM2835
Can you please sort if for easier maintenance?
PATCH 5/89 clk: Return error code when of provider pointer is NULL
In reply to Maxime RipardThe clock framework DT provider helpers don't check the pointers in the array registered by the clock provider before returning it.
This means that if the array is sparse, we will end up returning a NULL pointer while the caller expects an error pointer, resulting in a crash.
Let's test the pointer returned and properly return an error if the pointer is NULL.
--- drivers/clk/clk.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
drivers/clk/clk.c +12 -2
@@ -4318,13 +4318,18 @@ struct clk *of_clk_src_onecell_get(struct of_phandle_args *clkspec, void *data) {struct clk_onecell_data *clk_data = data;unsigned int idx = clkspec->args[0 ]; +struct clk *clk;if (idx >= clk_data->clk_num) {pr_err ("%s: invalid clock index %u\n" , __func__, idx);return ERR_PTR (-EINVAL ); } -return clk_data->clks[idx]; + clk = clk_data->clks[idx]; +if (!clk) +return ERR_PTR (-ENODEV ); + +return clk; }EXPORT_SYMBOL_GPL (of_clk_src_onecell_get);
@@ -4333,13 +4338,18 @@ of_clk_hw_onecell_get(struct of_phandle_args *clkspec, void *data) {struct clk_hw_onecell_data *hw_data = data;unsigned int idx = clkspec->args[0 ]; +struct clk_hw *hw;if (idx >= hw_data->num) {pr_err ("%s: invalid index %u\n" , __func__, idx);return ERR_PTR (-EINVAL ); } -return hw_data->hws[idx]; + hw = hw_data->hws[idx]; +if (!hw) +return ERR_PTR (-ENODEV ); + +return hw; }EXPORT_SYMBOL_GPL (of_clk_hw_onecell_get);
Signature · 6 lines
git-series 0.9.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Stephen Boyd
maintainerRe: [PATCH 05/89] clk: Return error code when of provider pointer is NULL
Quoting Maxime Ripard (2020-02-24 01:06:07)
Quoted 25 lines
The clock framework DT provider helpers don't check the pointers in the array registered by the clock provider before returning it.
This means that if the array is sparse, we will end up returning a NULL pointer while the caller expects an error pointer, resulting in a crash.
Let's test the pointer returned and properly return an error if the pointer is NULL.
Cc Michael Turquette <[email protected]>Cc Stephen Boyd <[email protected]>Signed-off-by Maxime Ripard <[email protected]>--- drivers/clk/clk.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)drivers/clk/clk.c +0
-0@@ -4318,13 +4318,18 @@ struct clk *of_clk_src_onecell_get(struct of_phandle_args *clkspec, void *data) {struct clk_onecell_data *clk_data = data;unsigned int idx = clkspec->args[0 ];
drivers/clk/clk.c struct clk *of_clk_src_onecell_get(struct of_phandle_args *clkspec, void *data) · line 4329
Quoted 10 lines
drivers/clk/clk.c +3
-1+struct clk *clk;if (idx >= clk_data->clk_num) {pr_err ("%s: invalid clock index %u\n" , __func__, idx);return ERR_PTR (-EINVAL ); } -return clk_data->clks[idx]; + clk = clk_data->clks[idx]; +if (!clk)
NULL is a valid clk. That should keep working and not be overriden with an error pointer. If you want to return an error pointer either fill it in with an error pointer or write your own version of this.
Quoted 10 lines
drivers/clk/clk.c +3
-0+return ERR_PTR (-ENODEV ); + +return clk; }EXPORT_SYMBOL_GPL (of_clk_src_onecell_get);@@ -4333,13 +4338,18 @@ of_clk_hw_onecell_get(struct of_phandle_args *clkspec, void *data) {struct clk_hw_onecell_data *hw_data = data;unsigned int idx = clkspec->args[0 ];
drivers/clk/clk.c of_clk_hw_onecell_get(struct of_phandle_args *clkspec, void *data) · line 4349
Quoted 10 lines
drivers/clk/clk.c +3
-1+struct clk_hw *hw;if (idx >= hw_data->num) {pr_err ("%s: invalid index %u\n" , __func__, idx);return ERR_PTR (-EINVAL ); } -return hw_data->hws[idx]; + hw = hw_data->hws[idx]; +if (!hw)
And this one is the same. We let NULL be returned so that it can be returned as a NULL pointer to the caller if desired. That indicates a clk that does nothing when used.
Quoted 5 lines
drivers/clk/clk.c +3
-0+return ERR_PTR (-ENODEV ); + +return hw; }EXPORT_SYMBOL_GPL (of_clk_hw_onecell_get);
PATCH 6/89 dt-bindings: clock: Add a binding for the RPi Firmware clocks
In reply to Maxime RipardThe firmare running on the RPi VideoCore can be used to discover and change the various clocks running in the BCM2711. Since devices will need to use them through the DT, let's add a pretty simple binding.
--- Documentation/devicetree/bindings/clock/raspberrypi,firmware-clocks.yaml | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/raspberrypi,firmware-clocks.yaml
Documentation/devicetree/bindings/clock/raspberrypi,firmware-clocks.yaml new file +39 -0
@@ -0,0 +1,39 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/clock/raspberrypi,firmware-clocks.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: RaspberryPi Firmware Clocks Device Tree Bindings + +maintainers: + - Maxime Ripard <[email protected]> + +properties: + "#clock-cells": + const: 1 + + compatible: + const: raspberrypi,firmware-clocks + + raspberrypi,firmware: + $ref: /schemas/types.yaml#/definitions/phandle + description: > + Phandle to the mailbox node to communicate with the firmware. + +required: + - "#clock-cells" + - compatible + - raspberrypi,firmware + +additionalProperties: false + +examples: + - | + firmware_clocks: firmware-clocks { + compatible = "raspberrypi,firmware-clocks"; + raspberrypi,firmware = <&firmware>; + #clock-cells = <1>; + }; + +...
Signature · 6 lines
git-series 0.9.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Rob Herring
maintainerRe: [PATCH 06/89] dt-bindings: clock: Add a binding for the RPi Firmware clocks
Quoted 33 lines · Maxime Ripard
The firmare running on the RPi VideoCore can be used to discover and change the various clocks running in the BCM2711. Since devices will need to use them through the DT, let's add a pretty simple binding.
Cc Michael Turquette <[email protected]>Cc Stephen Boyd <[email protected]>Cc Rob Herring <[email protected]>Signed-off-by Maxime Ripard <[email protected]>--- Documentation/devicetree/bindings/clock/raspberrypi,firmware-clocks.yaml | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/raspberrypi,firmware-clocks.yamlDocumentation/devicetree/bindings/clock/raspberrypi,firmware-clocks.yaml new file +12
-0@@ -0,0 +1,39 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/clock/raspberrypi,firmware-clocks.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: RaspberryPi Firmware Clocks Device Tree Bindings + +maintainers: + - Maxime Ripard <[email protected]> + +properties:
Documentation/devicetree/bindings/clock/raspberrypi,firmware-clocks.yaml line 22
Quoted 10 lines
Documentation/devicetree/bindings/clock/raspberrypi,firmware-clocks.yaml new file +10
-0+ "#clock-cells": + const: 1 + + compatible: + const: raspberrypi,firmware-clocks + + raspberrypi,firmware: + $ref: /schemas/types.yaml#/definitions/phandle + description: > + Phandle to the mailbox node to communicate with the firmware.
Can't this be a child node of the phandle instead? Or just add '#clock-cells' to the firmware node.
Quoted 24 lines
Documentation/devicetree/bindings/clock/raspberrypi,firmware-clocks.yaml new file +17
-0+ +required: + - "#clock-cells" + - compatible + - raspberrypi,firmware + +additionalProperties: false + +examples: + - | + firmware_clocks: firmware-clocks { + compatible = "raspberrypi,firmware-clocks"; + raspberrypi,firmware = <&firmware>; + #clock-cells = <1>; + }; + +...Signature · 6 lines
git-series 0.9.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Stephen Boyd
maintainerRe: [PATCH 06/89] dt-bindings: clock: Add a binding for the RPi Firmware clocks
Quoting Rob Herring (2020-02-25 10:16:54)
Quoted 39 lines · Maxime Ripard
Quoted 38 lines
The firmare running on the RPi VideoCore can be used to discover and change the various clocks running in the BCM2711. Since devices will need to use them through the DT, let's add a pretty simple binding.
Cc Michael Turquette <[email protected]>Cc Stephen Boyd <[email protected]>Cc Rob Herring <[email protected]>Signed-off-by Maxime Ripard <[email protected]>--- Documentation/devicetree/bindings/clock/raspberrypi,firmware-clocks.yaml | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/raspberrypi,firmware-clocks.yamlDocumentation/devicetree/bindings/clock/raspberrypi,firmware-clocks.yaml new file +17
-0@@ -0,0 +1,39 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/clock/raspberrypi,firmware-clocks.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: RaspberryPi Firmware Clocks Device Tree Bindings + +maintainers: + - Maxime Ripard <[email protected]> + +properties: + "#clock-cells": + const: 1 + + compatible: + const: raspberrypi,firmware-clocks
Quoted 8 lines
Documentation/devicetree/bindings/clock/raspberrypi,firmware-clocks.yaml line 22
Quoted 5 lines
Documentation/devicetree/bindings/clock/raspberrypi,firmware-clocks.yaml new file +5
-0+ + raspberrypi,firmware: + $ref: /schemas/types.yaml#/definitions/phandle + description: > + Phandle to the mailbox node to communicate with the firmware.Can't this be a child node of the phandle instead? Or just add '#clock-cells' to the firmware node.
Yeah, just add the clock-cells to the firmware node unless that doesn't work for some reason?
PATCH 7/89 clk: bcm: rpi: Allow the driver to be probed by DT
In reply to Maxime RipardThe current firmware clock driver for the RaspberryPi can only be probed by manually registering an associated platform_device.
While this works fine for cpufreq where the device gets attached a clkdev lookup, it would be tedious to maintain a table of all the devices using one of the clocks exposed by the firmware.
Since the DT on the other hand is the perfect place to store those associations, make the firmware clocks driver probe-able through the device tree so that we can represent it as a node.
--- drivers/clk/bcm/clk-raspberrypi.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/clk/bcm/clk-raspberrypi.c +8 -3
@@ -255,15 +255,13 @@ static int raspberrypi_clk_probe(struct platform_device *pdev)struct raspberrypi_clk *rpi;int ret; - firmware_node =of_find_compatible_node (NULL ,NULL , -"raspberrypi,bcm2835-firmware" ); + firmware_node =of_parse_phandle (dev->of_node,"raspberrypi,firmware" ,0 );if (!firmware_node) {dev_err (dev,"Missing firmware node\n" );return -ENOENT ; } firmware =rpi_firmware_get (firmware_node); -of_node_put (firmware_node);if (!firmware)return -EPROBE_DEFER ;
@@ -300,9 +298,16 @@ static int raspberrypi_clk_remove(struct platform_device *pdev)return 0 ; } +static const struct of_device_id raspberrypi_clk_match[] = { + { .compatible ="raspberrypi,firmware-clocks" }, + { }, +}; +MODULE_DEVICE_TABLE (of, raspberrypi_clk_match); +static struct platform_driver raspberrypi_clk_driver = { .driver = { .name ="raspberrypi-clk" , + .of_match_table = raspberrypi_clk_match, }, .probe = raspberrypi_clk_probe, .remove = raspberrypi_clk_remove,
Signature · 1 line
git-series 0.9.1
Re: [PATCH 07/89] clk: bcm: rpi: Allow the driver to be probed by DT
Hi Maxime,
Quoted 10 lines · Maxime Ripard
The current firmware clock driver for the RaspberryPi can only be probed by manually registering an associated
platform_device.While this works fine for cpufreq where the device gets attached a clkdev lookup, it would be tedious to maintain a table of all the devices using one of the clocks exposed by the firmware.
Since the DT on the other hand is the perfect place to store those associations, make the firmware clocks driver probe-able through the device tree so that we can represent it as a node.
I'm not convinced this is the right approach, and if we decide to go this way, there are more changes to take into account.
For one, if we create a dt node for this driver, we'd have to delete the platform device creation in firmware/raspberrypi.c and then we'd be even able to bypass raspberrypi-cpufreq altogether by creating opp tables in dt. But there are reasons we didn't go that way at the time.
We've made an effort to avoid using dt for firmware interfaces whenever possible as, on one hand, it's arguable they don't fit device-tree's hardware description paradigm and, on the other, the lack of flexibility they impose once the binding is defined. VC4's firmware interfaces are not set in stone, nor standardized like SCMI, so the more flexible we are to future changes the better.
Another thing I'm not all that happy about it's how dynamic clock registering is handled in patch #22 (but I'll keep it here as relevant to the discussion):
- Some of those fw managed clocks you're creating have their mmio counterpart being registered by clk-bcm238. IMO either register one or the other, giving precedence to the mmio counterpart. Note that for pllb, we deleted the relevant code from clk-bcm2385.
- The same way we were able to map the fw CPU clock into the clk tree (pllb/pllb_arm) there are no reasons we shouldn't be able to do the same for the VPU clocks. It's way nicer and less opaque to users (this being a learning platform adds to the argument).
- On top of that, having a special case for the CPU clock registration is nasty. Lets settle for one solution and make everyone follow it.
- I don't see what's so bad about creating clock lookups. IIUC there are only two clocks that need this special handling CPU & HDMI, It's manageable. You don't even have to mess with the consumer driver, if there was ever to be a dt provided mmio option to this clock.
Quoted 9 lines
drivers/clk/bcm/clk-raspberrypi.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)drivers/clk/bcm/clk- renamed from drivers/clk/bcm/clk-raspberrypi.c +0
-0
raspberrypi.c
index1654fd0eedc9..94870234824c100644
drivers/clk/bcm/clk-raspberrypi.c static int raspberrypi_clk_probe(struct platform_device · line 260
Quoted 8 lines
drivers/clk/bcm/clk-raspberrypi.c +1
-2@@ -255,15 +255,13 @@ static int raspberrypi_clk_probe(struct platform_device *pdev)struct raspberrypi_clk *rpi;int ret; - firmware_node =of_find_compatible_node (NULL ,NULL , -"raspberrypi,bcm2835-firmware" ); + firmware_node =of_parse_phandle (dev->of_node,"raspberrypi,firmware" ,0 );
There is no such phandle in the upstream device tree. Maybe this was aimed at the downstream dt?
Regards,
Nicolas
Re: [PATCH 07/89] clk: bcm: rpi: Allow the driver to be probed by DT
Hi Nicolas,
Quoted 8 lines · Nicolas Saenz Julienne
Quoted 7 lines · Maxime Ripard
The current firmware clock driver for the RaspberryPi can only be probed by manually registering an associated
platform_device.While this works fine for cpufreq where the device gets attached a clkdev lookup, it would be tedious to maintain a table of all the devices using one of the clocks exposed by the firmware.
Quoted 6 lines
Quoted 3 lines
Since the DT on the other hand is the perfect place to store those associations, make the firmware clocks driver probe-able through the device tree so that we can represent it as a node.
I'm not convinced this is the right approach, and if we decide to go this way, there are more changes to take into account.
This was actually a shameless bait to start that discussion, so I'm glad it worked ;)
Quoted 4 lines
For one, if we create a dt node for this driver, we'd have to delete the platform device creation in
firmware/raspberrypi.cand then we'd be even able to bypass raspberrypi-cpufreq altogether by creating opp tables in dt. But there are reasons we didn't go that way at the time.
Right, I missed that one since the check for the firmware phandle was preventing the double-probe to happen, but it's bad indeed.
Quoted 6 lines
We've made an effort to avoid using dt for firmware interfaces whenever possible as, on one hand, it's arguable they don't fit device-tree's hardware description paradigm and, on the other, the lack of flexibility they impose once the binding is defined. VC4's firmware interfaces are not set in stone, nor standardized like SCMI, so the more flexible we are to future changes the better.
The device tree isn't just about the hardware though, but also contains the state the bootloader / firmware left the hardware in. You're mentionning SCMI, and SCMI clocks IDs are stored in the device tree. Just like pen release addresses, PSCI function ids, etc.
The firmware IDs of these clocks shouldn't change too.
But you also raise a valid point with the lack of flexibility, especially since the clock tree isn't that well understood.
Quoted 7 lines
Another thing I'm not all that happy about it's how dynamic clock registering is handled in patch #22 (but I'll keep it here as relevant to the discussion):
- Some of those fw managed clocks you're creating have their mmio counterpart being registered by clk-bcm238. IMO either register one or the other, giving precedence to the mmio counterpart. Note that for pllb, we deleted the relevant code from clk-bcm2385.
Indeed, and it's really that part of the discussion I wanted to start. For some reason, it looks like a good chunk of those clocks are non-functional at the moment (they all report 0). If we're going to use the firmware clocks as I did here, we'd have to modify most of the device clocks used so far (UART, especially) to derive from the core clock.
I wasn't really sure of the implications though, since it's my first experience with the RPi clock tree.
Quoted 4 lines
- The same way we were able to map the fw CPU clock into the clk tree (pllb/pllb_arm) there are no reasons we shouldn't be able to do the same for the VPU clocks. It's way nicer and less opaque to users (this being a learning platform adds to the argument).
This would make the Linux clock tree match the one in hardware, which would indeed be more readable to a beginner, but I see three main drawbacks with this:
- The parent / child relationship is already encoded in the firmware discovery mechanism. It's not used yet by the driver, because the firmware reports all of them as root clocks, but that's pretty easy to fix.
- It would make the code far more complicated and confusing than it could, especially to beginners. And as far as I know, only the RPi is doing that, while pretty much all the other platforms either have the clock tree entirely defined, or rely on the firmware, but don't have an hybrid. So they would learn something that cannot really be applied to anywhere else.
- I have no idea what the clock tree is supposed to look like :)
Quoted 2 lines
- On top of that, having a special case for the CPU clock registration is nasty. Lets settle for one solution and make everyone follow it.
It seemed to me that the CPU clock had a factor between the actual CPU frequency and its clock? If not, then yeah we should definitely get rid of it.
Quoted 4 lines
- I don't see what's so bad about creating clock lookups. IIUC there are only two clocks that need this special handling CPU & HDMI, It's manageable. You don't even have to mess with the consumer driver, if there was ever to be a dt provided mmio option to this clock.
V3D needs one too, and I might have missed a bunch of them in that series given how the current debugging of the remaining issues turn out to be. And clk_lookups are local to devices, so you need to factor that by the number of devices you have.
Sure, it works, but it feels to me like that's going to be an issue pretty fast, especially with the lookups on the way out?
Quoted 13 lines
Quoted 13 lines
drivers/clk/bcm/clk-raspberrypi.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)drivers/clk/bcm/clk- renamed from drivers/clk/bcm/clk-raspberrypi.c +0
-0
raspberrypi.c
index1654fd0eedc9..94870234824c100644drivers/clk/bcm/clk-raspberrypi.c +0
-0@@ -255,15 +255,13 @@ static int raspberrypi_clk_probe(struct platform_device *pdev)struct raspberrypi_clk *rpi;int ret;
Quoted 7 lines
drivers/clk/bcm/clk-raspberrypi.c static int raspberrypi_clk_probe(struct platform_device *pdev)
Quoted 4 lines
drivers/clk/bcm/clk-raspberrypi.c +1
-2- firmware_node =of_find_compatible_node (NULL ,NULL , -"raspberrypi,bcm2835-firmware" ); + firmware_node =of_parse_phandle (dev->of_node,"raspberrypi,firmware" ,0 );There is no such phandle in the upstream device tree. Maybe this was aimed at the downstream dt?
raspberrypi,firmware is the property, it points to the /soc/firmware node that is defined in bcm2835-rpi.dtsi
Maxime
Re: [PATCH 07/89] clk: bcm: rpi: Allow the driver to be probed by DT
Hi Maxime,
On Wed, 2020-02-26 at 16:01 +0100, Maxime Ripard wrote:
[...]
Quoted 2 lines
This was actually a shameless bait to start that discussion, so I'm glad it worked ;)
:)
[...]
Quoted 10 lines
Quoted 6 lines
- Some of those fw managed clocks you're creating have their mmio counterpart
being registered by clk-bcm238. IMO either register one or the other,
giving
precedence to the mmio counterpart. Note that for pllb, we deleted the relevant code from clk-bcm2385.Indeed, and it's really that part of the discussion I wanted to start. For some reason, it looks like a good chunk of those clocks are non-functional at the moment (they all report 0).
Yes, although they should be alright. I think it's just a matter of passing the right flags to the clk framework (disable caching and so on), but never found the time to investigate further.
Quoted 5 lines
If we're going to
use the firmware clocks as I did here, we'd have to modify most of the device clocks used so far (UART, especially) to derive from the core clock. I wasn't really sure of the implications though, since it's my first experience with the RPi clock tree.
That's something I'm confused about. I played around with your code and the HSM clock changes seem to be completely unrelated to the VPU clock. Actually it seems it's derived from 'plld_per' (here Florian can maybe contradict me). I found out by feeding the mmio HSM clock to your driver, which actually seemed to work (albeit maybe just out of luck since the FW already set up everything).
Bare in mind, we disable turbo mode upstream so as for the firmware not to change the VPU frequencies on par with CPU changes (controlled by a special bit in the CPU clock mailbox property). So, if I'm not wrong, this simplifies things. As we don't have to worry about re-clocking all peripherals with every resolution change.
This even opens up another question. Which clocks is the firmware interface monitoring for DVFS? If it's just the VPU and CPU we could be over-complicating things here, and MMIO clks could be an option, isn't it?
On the subject of re-clocking, I had a word with the clk maintainers on how to properly implement it, see the two last paragraphs here if curious:
https://www.spinics.net/lists/linux-clk/msg36937.html
Quoted 6 lines
Quoted 5 lines
- The same way we were able to map the fw CPU clock into the clk tree (pllb/pllb_arm) there are no reasons we shouldn't be able to do the same
for
the VPU clocks. It's way nicer and less opaque to users (this being a learning platform adds to the argument).
Quoted 8 lines
This would make the Linux clock tree match the one in hardware, which would indeed be more readable to a beginner, but I see three main drawbacks with this:
- The parent / child relationship is already encoded in the firmware discovery mechanism. It's not used yet by the driver, because the firmware reports all of them as root clocks, but that's pretty easy to fix.
Had a look at this, they all return root as their parent. Which is somewhat true from the fw interface perspective (only leaves are represented), but not too endearing.
Quoted 6 lines
- It would make the code far more complicated and confusing than it could, especially to beginners. And as far as I know, only the RPi is doing that, while pretty much all the other platforms either have the clock tree entirely defined, or rely on the firmware, but don't have an hybrid. So they would learn something that cannot really be applied to anywhere else.
Fair enough. Still, for now, I think I prefer a hybrid clk tree approach.
Quoted 1 line
- I have no idea what the clock tree is supposed to look like :)
I don't have access to the official clock tree either. The closest we have is whatever the mmio clk driver exposes.
Quoted 6 lines
Quoted 2 lines
- On top of that, having a special case for the CPU clock registration is nasty. Lets settle for one solution and make everyone follow it.
It seemed to me that the CPU clock had a factor between the actual CPU frequency and its clock? If not, then yeah we should definitely get rid of it.
Yes, IIRC, there is a factor because the CPU clock firmware interface actually controls the underlying PLL frequency which is then divided by 2 before reaching the CPU. Which kind of breaks the FW interface design if you ask me (alongside this turbo mode thing).
Quoted 11 lines
Quoted 7 lines
- I don't see what's so bad about creating clock lookups. IIUC there are only
two clocks that need this special handling CPU & HDMI, It's manageable.
You
don't even have to mess with the consumer driver, if there was ever to be
a
dt provided mmio option to this clock.V3D needs one too, and I might have missed a bunch of them in that series given how the current debugging of the remaining issues turn out to be.
Would be nice to see if V3D is also affected by DVFS, and the rest of clocks for that matter.
Quoted 3 lines
And
clk_lookupsare local to devices, so you need to factor that by the number of devices you have. Sure, it works, but it feels to me like that's going to be an issue pretty fast, especially with the lookups on the way out?
I see your point, TBH I don't mind moving it into the device-tree if things are going to get nasty.
Quoted 23 lines
Quoted 14 lines
Quoted 14 lines
drivers/clk/bcm/clk-raspberrypi.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)drivers/clk/bcm/clk- renamed from drivers/clk/bcm/clk-raspberrypi.c +0
-0
raspberrypi.c
index1654fd0eedc9..94870234824c100644drivers/clk/bcm/clk-raspberrypi.c +0
-0@@ -255,15 +255,13 @@ static int raspberrypi_clk_probe(struct
platform_device
*pdev)drivers/clk/bcm/clk-raspberrypi.c +0
-0struct raspberrypi_clk *rpi;int ret;Quoted 8 lines
Quoted 4 lines
drivers/clk/bcm/clk-raspberrypi.c +1
-2- firmware_node =of_find_compatible_node (NULL ,NULL , -"raspberrypi,bcm2835-firmware" ); + firmware_node = of_parse_phandle(dev->of_node, "raspberrypi,firmware",0);
There is no such phandle in the upstream device tree. Maybe this was aimed at
the downstream dt?
Quoted 2 lines
raspberrypi,firmware is the property, it points to the /soc/firmware node that is defined in
bcm2835-rpi.dtsi
Yes, my bad. On that topic, I kind of like Robh's suggestion of making this driver a child of the firmware node (see an example in input/touchscreen/raspberrypi-ts.c).
Regards,
Nicolas
Re: [PATCH 07/89] clk: bcm: rpi: Allow the driver to be probed by DT
In reply to Maxime RipardHi Maxime,
Am 24.02.20 um 10:06 schrieb Maxime Ripard:
Quoted 7 lines
The current firmware clock driver for the RaspberryPi can only be probed by manually registering an associated
platform_device.While this works fine for cpufreq where the device gets attached a clkdev lookup, it would be tedious to maintain a table of all the devices using one of the clocks exposed by the firmware.
Quoted 8 lines
Since the DT on the other hand is the perfect place to store those associations, make the firmware clocks driver probe-able through the device tree so that we can represent it as a node.
Cc Michael Turquette <[email protected]>Cc Stephen Boyd <[email protected]>Signed-off-by Maxime Ripard <[email protected]>
FWIW i want to mention that starting with this commit, X doesn't start on my Raspberry Pi 3A (applied on top of linux-next using multi_v7_defconfig).
Regards
Stefan
Re: [PATCH 07/89] clk: bcm: rpi: Allow the driver to be probed by DT
Hi Stefan,
Quoted 14 lines · Stefan Wahren
Hi Maxime,
Am 24.02.20 um 10:06 schrieb Maxime Ripard:
Quoted 11 lines
The current firmware clock driver for the RaspberryPi can only be probed by manually registering an associated
platform_device.While this works fine for cpufreq where the device gets attached a clkdev lookup, it would be tedious to maintain a table of all the devices using one of the clocks exposed by the firmware.
Since the DT on the other hand is the perfect place to store those associations, make the firmware clocks driver probe-able through the device tree so that we can represent it as a node.
Quoted 8 lines
Quoted 4 lines
Cc Michael Turquette <[email protected]>Cc Stephen Boyd <[email protected]>Signed-off-by Maxime Ripard <[email protected]>FWIW i want to mention that starting with this commit, X doesn't start on my Raspberry Pi 3A (applied on top of linux-next using
multi_v7_defconfig).
Was this the same issue you reported with the HSM clock rate, or truly an issue with my series?
Maxime
PATCH 8/89 clk: bcm: rpi: Statically init clk_init_data
In reply to Maxime RipardInstead of declaring the clk_init_data and then calling memset on it, just initialise properly.
--- drivers/clk/bcm/clk-raspberrypi.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/clk/bcm/clk-raspberrypi.c +1 -2
@@ -175,11 +175,10 @@ static const struct clk_ops raspberrypi_firmware_pll_clk_ops = {static int raspberrypi_register_pllb (struct raspberrypi_clk *rpi) { +struct clk_init_data init = {};u32 min_rate =0 , max_rate =0 ; -struct clk_init_data init;int ret; -memset (&init,0 ,sizeof (init));/* All of the PLLs derive from the external oscillator. */ init.parent_names = (const char *[]){"osc" };
Signature · 6 lines
git-series 0.9.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH 08/89] clk: bcm: rpi: Statically init clk_init_data
Quoted 8 lines · Maxime Ripard
Instead of declaring the
clk_init_dataand then calling memset on it, just initialise properly.Cc Michael Turquette <[email protected]>Cc Stephen Boyd <[email protected]>Signed-off-by Maxime Ripard <[email protected]>---
Thanks!
Nicolas
PATCH 9/89 clk: bcm: rpi: Use clk_hw_register for pllb_arm
In reply to Maxime RipardThe pllb_arm clock is defined as a fixed factor clock with the pllb clock as a parent. However, all its configuration is entirely static, and thus we don't really need to call clk_hw_register_fixed_factor but can simply call clk_hw_register with a static clk_fixed_factor structure.
--- drivers/clk/bcm/clk-raspberrypi.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-)
drivers/clk/bcm/clk-raspberrypi.c +18 -6
@@ -225,16 +225,28 @@ static int raspberrypi_register_pllb(struct raspberrypi_clk *rpi)return devm_clk_hw_register (rpi->dev, &rpi->pllb); } +static struct clk_fixed_factor raspberrypi_clk_pllb_arm = { + .mult =1 , + .div =2 , + .hw.init = &(struct clk_init_data ) { + .name ="pllb_arm" , + .parent_names = (const char *[]){"pllb" }, + .num_parents =1 , + .ops = &clk_fixed_factor_ops, + .flags =CLK_SET_RATE_PARENT |CLK_GET_RATE_NOCACHE , + }, +}; +static int raspberrypi_register_pllb_arm (struct raspberrypi_clk *rpi) { - rpi->pllb_arm =clk_hw_register_fixed_factor (rpi->dev, -"pllb_arm" ,"pllb" , -CLK_SET_RATE_PARENT |CLK_GET_RATE_NOCACHE , -1 ,2 ); -if (IS_ERR (rpi->pllb_arm)) { +int ret; + + ret =clk_hw_register (rpi->dev, &raspberrypi_clk_pllb_arm.hw); +if (ret) {dev_err (rpi->dev,"Failed to initialize pllb_arm\n" ); -return PTR_ERR (rpi->pllb_arm); +return ret; } + rpi->pllb_arm = &raspberrypi_clk_pllb_arm.hw; rpi->pllb_arm_lookup =clkdev_hw_create (rpi->pllb_arm,NULL ,"cpu0" );if (!rpi->pllb_arm_lookup) {
Signature · 1 line
git-series 0.9.1
Re: [PATCH 09/89] clk: bcm: rpi: Use clk_hw_register for pllb_arm
Quoted 9 lines · Maxime Ripard
The
pllb_armclock is defined as a fixed factor clock with the pllb clock as a parent. However, all its configuration is entirely static, and thus we don't really need to callclk_hw_register_fixed_factorbut can simply callclk_hw_registerwith a staticclk_fixed_factorstructure.Cc Michael Turquette <[email protected]>Cc Stephen Boyd <[email protected]>Signed-off-by Maxime Ripard <[email protected]>
Thanks!
Nicolas
Re: [PATCH 09/89] clk: bcm: rpi: Use clk_hw_register for pllb_arm
In reply to Maxime RipardQuoting Maxime Ripard (2020-02-24 01:06:11)
Quoted 4 lines
The
pllb_armclock is defined as a fixed factor clock with the pllb clock as a parent. However, all its configuration is entirely static, and thus we don't really need to callclk_hw_register_fixed_factorbut can simply callclk_hw_registerwith a staticclk_fixed_factorstructure.
Please add () to things like clk_hw_register_fixed_factor() and clk_hw_register().
Quoted 6 lines
Cc Michael Turquette <[email protected]>Cc Stephen Boyd <[email protected]>Signed-off-by Maxime Ripard <[email protected]>---
PATCH 10/89 clk: bcm: rpi: Remove global pllb_arm clock pointer
In reply to Maxime RipardThe pllb_arm clk_hw pointer in the raspberry_clk structure isn't used anywhere but in the raspberrypi_register_pllb_arm.
Let's remove it, this will make our lives easier in future patches.
--- drivers/clk/bcm/clk-raspberrypi.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/clk/bcm/clk-raspberrypi.c +3 -4
@@ -40,7 +40,6 @@ struct raspberrypi_clk {unsigned long max_rate;struct clk_hw pllb; -struct clk_hw *pllb_arm;struct clk_lookup *pllb_arm_lookup; };
@@ -246,12 +245,12 @@ static int raspberrypi_register_pllb_arm(struct raspberrypi_clk *rpi)dev_err (rpi->dev,"Failed to initialize pllb_arm\n" );return ret; } - rpi->pllb_arm = &raspberrypi_clk_pllb_arm.hw; - rpi->pllb_arm_lookup =clkdev_hw_create (rpi->pllb_arm,NULL ,"cpu0" ); + rpi->pllb_arm_lookup =clkdev_hw_create (&raspberrypi_clk_pllb_arm.hw, +NULL ,"cpu0" );if (!rpi->pllb_arm_lookup) {dev_err (rpi->dev,"Failed to initialize pllb_arm_lookup\n" ); -clk_hw_unregister_fixed_factor (rpi->pllb_arm); +clk_hw_unregister_fixed_factor (&raspberrypi_clk_pllb_arm.hw);return -ENOMEM ; }
Signature · 1 line
git-series 0.9.1
Re: [PATCH 10/89] clk: bcm: rpi: Remove global pllb_arm clock pointer
Quoted 9 lines · Maxime Ripard
The
pllb_armclk_hwpointer in theraspberry_clkstructure isn't used anywhere but in theraspberrypi_register_pllb_arm.Let's remove it, this will make our lives easier in future patches.
Cc Michael Turquette <[email protected]>Cc Stephen Boyd <[email protected]>Signed-off-by Maxime Ripard <[email protected]>
Thanks!
Nicolas
Re: [PATCH 10/89] clk: bcm: rpi: Remove global pllb_arm clock pointer
Hi Nicolas,
Quoted 4 lines · Nicolas Saenz Julienne
Quoted 3 lines · Maxime Ripard
The
pllb_armclk_hwpointer in theraspberry_clkstructure isn't used anywhere but in theraspberrypi_register_pllb_arm.
Quoted 8 lines
Quoted 6 lines
Let's remove it, this will make our lives easier in future patches.
Cc Michael Turquette <[email protected]>Cc Stephen Boyd <[email protected]>Signed-off-by Maxime Ripard <[email protected]>Signed-off-by Nicolas Saenz Julienne <[email protected]>
I guess you meant Acked or Reviewed-by?
Maxime
Nicolas Saenz Julienne
Acked-byRe: [PATCH 10/89] clk: bcm: rpi: Remove global pllb_arm clock pointer
Quoted 9 lines · Maxime Ripard
Hi Nicolas,
Quoted 6 lines · Nicolas Saenz Julienne
Quoted 5 lines · Maxime Ripard
The
pllb_armclk_hwpointer in theraspberry_clkstructure isn't used anywhere but in theraspberrypi_register_pllb_arm.Let's remove it, this will make our lives easier in future patches.
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Cc Michael Turquette <[email protected]>Cc Stephen Boyd <[email protected]>Signed-off-by Maxime Ripard <[email protected]>Signed-off-by Nicolas Saenz Julienne <[email protected]>I guess you meant Acked or Reviewed-by?
Yes sorry, I ran the wrong macro in vim.
Thanks!
Nicolas
PATCH 11/89 clk: bcm: rpi: Make sure pllb_arm is removed
In reply to Maxime RipardThe pllb_arm clock was created at probe time, but was never removed if something went wrong later in probe, or if the driver was ever removed from the system.
Now that we are using clk_hw_register, we can just use its managed variant to take care of that for us.
--- drivers/clk/bcm/clk-raspberrypi.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/clk/bcm/clk-raspberrypi.c +1 -2
@@ -240,7 +240,7 @@ static int raspberrypi_register_pllb_arm(struct raspberrypi_clk *rpi) {int ret; - ret =clk_hw_register (rpi->dev, &raspberrypi_clk_pllb_arm.hw); + ret =devm_clk_hw_register (rpi->dev, &raspberrypi_clk_pllb_arm.hw);if (ret) {dev_err (rpi->dev,"Failed to initialize pllb_arm\n" );return ret;
@@ -250,7 +250,6 @@ static int raspberrypi_register_pllb_arm(struct raspberrypi_clk *rpi) NULL, "cpu0");if (!rpi->pllb_arm_lookup) {dev_err (rpi->dev,"Failed to initialize pllb_arm_lookup\n" ); -clk_hw_unregister_fixed_factor (&raspberrypi_clk_pllb_arm.hw);return -ENOMEM ; }
Signature · 1 line
git-series 0.9.1
Re: [PATCH 11/89] clk: bcm: rpi: Make sure pllb_arm is removed
Quoted 11 lines · Maxime Ripard
The
pllb_armclock was created at probe time, but was never removed if something went wrong later in probe, or if the driver was ever removed from the system.Now that we are using
clk_hw_register, we can just use its managed variant to take care of that for us.Cc Michael Turquette <[email protected]>Cc Stephen Boyd <[email protected]>Signed-off-by Maxime Ripard <[email protected]>
Thanks!
Nicolas
Re: [PATCH 11/89] clk: bcm: rpi: Make sure pllb_arm is removed
In reply to Maxime RipardQuoting Maxime Ripard (2020-02-24 01:06:13)
Quoted 4 lines
The
pllb_armclock was created at probe time, but was never removed if something went wrong later in probe, or if the driver was ever removed from the system.
Quoted 8 lines
Now that we are using
clk_hw_register, we can just use its managed variant to take care of that for us.Cc Michael Turquette <[email protected]>Cc Stephen Boyd <[email protected]>Signed-off-by Maxime Ripard <[email protected]>---
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 12/89 clk: bcm: rpi: Remove pllb_arm_lookup global pointer
In reply to Maxime RipardThe pllb_arm_lookup pointer in the struct raspberrypi_clk is not used for anything but to store the returned pointer to clkdev_hw_create, and is not used anywhere else in the driver.
Let's remove that global pointer from the structure.
--- drivers/clk/bcm/clk-raspberrypi.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/clk/bcm/clk-raspberrypi.c +4 -4
@@ -40,7 +40,6 @@ struct raspberrypi_clk {unsigned long max_rate;struct clk_hw pllb; -struct clk_lookup *pllb_arm_lookup; };/*
@@ -238,6 +237,7 @@ static struct clk_fixed_factor raspberrypi_clk_pllb_arm = {static int raspberrypi_register_pllb_arm (struct raspberrypi_clk *rpi) { +struct clk_lookup *pllb_arm_lookup;int ret; ret =devm_clk_hw_register (rpi->dev, &raspberrypi_clk_pllb_arm.hw);
@@ -246,9 +246,9 @@ static int raspberrypi_register_pllb_arm(struct raspberrypi_clk *rpi)return ret; } - rpi->pllb_arm_lookup =clkdev_hw_create (&raspberrypi_clk_pllb_arm.hw, -NULL ,"cpu0" ); -if (!rpi->pllb_arm_lookup) { + pllb_arm_lookup =clkdev_hw_create (&raspberrypi_clk_pllb_arm.hw, +NULL ,"cpu0" ); +if (!pllb_arm_lookup) {dev_err (rpi->dev,"Failed to initialize pllb_arm_lookup\n" );return -ENOMEM ; }
Signature · 1 line
git-series 0.9.1
Re: [PATCH 12/89] clk: bcm: rpi: Remove pllb_arm_lookup global pointer
Quoted 10 lines · Maxime Ripard
The
pllb_arm_lookuppointer in the structraspberrypi_clkis not used for anything but to store the returned pointer toclkdev_hw_create, and is not used anywhere else in the driver.Let's remove that global pointer from the structure.
Cc Michael Turquette <[email protected]>Cc Stephen Boyd <[email protected]>Signed-off-by Maxime Ripard <[email protected]>
Thanks!
Nicolas
Re: [PATCH 12/89] clk: bcm: rpi: Remove pllb_arm_lookup global pointer
In reply to Maxime RipardQuoting Maxime Ripard (2020-02-24 01:06:14)
Quoted 11 lines
The
pllb_arm_lookuppointer in the structraspberrypi_clkis not used for anything but to store the returned pointer toclkdev_hw_create, and is not used anywhere else in the driver.Let's remove that global pointer from the structure.
Cc Michael Turquette <[email protected]>Cc Stephen Boyd <[email protected]>Signed-off-by Maxime Ripard <[email protected]>---
Re: [PATCH 12/89] clk: bcm: rpi: Remove pllb_arm_lookup global pointer
In reply to Maxime RipardQuoting Maxime Ripard (2020-02-24 01:06:14)
Quoted 11 lines
The
pllb_arm_lookuppointer in the structraspberrypi_clkis not used for anything but to store the returned pointer toclkdev_hw_create, and is not used anywhere else in the driver.Let's remove that global pointer from the structure.
Cc Michael Turquette <[email protected]>Cc Stephen Boyd <[email protected]>Signed-off-by Maxime Ripard <[email protected]>---
PATCH 13/89 clk: bcm: rpi: Switch to clk_hw_register_clkdev
In reply to Maxime RipardSince we don't care about retrieving the clk_lookup structure pointer returned by clkdev_hw_create, we can just use the clk_hw_register_clkdev function.
--- drivers/clk/bcm/clk-raspberrypi.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/clk/bcm/clk-raspberrypi.c +5 -6
@@ -237,7 +237,6 @@ static struct clk_fixed_factor raspberrypi_clk_pllb_arm = {static int raspberrypi_register_pllb_arm (struct raspberrypi_clk *rpi) { -struct clk_lookup *pllb_arm_lookup;int ret; ret =devm_clk_hw_register (rpi->dev, &raspberrypi_clk_pllb_arm.hw);
@@ -246,11 +245,11 @@ static int raspberrypi_register_pllb_arm(struct raspberrypi_clk *rpi)return ret; } - pllb_arm_lookup =clkdev_hw_create (&raspberrypi_clk_pllb_arm.hw, -NULL ,"cpu0" ); -if (!pllb_arm_lookup) { -dev_err (rpi->dev,"Failed to initialize pllb_arm_lookup\n" ); -return -ENOMEM ; + ret =clk_hw_register_clkdev (&raspberrypi_clk_pllb_arm.hw, +NULL ,"cpu0" ); +if (ret) { +dev_err (rpi->dev,"Failed to initialize clkdev\n" ); +return ret; }return 0 ;
Signature · 1 line
git-series 0.9.1
Re: [PATCH 13/89] clk: bcm: rpi: Switch to clk_hw_register_clkdev
Quoted 8 lines · Maxime Ripard
Since we don't care about retrieving the
clk_lookupstructure pointer returned byclkdev_hw_create, we can just use theclk_hw_register_clkdevfunction.Cc Michael Turquette <[email protected]>Cc Stephen Boyd <[email protected]>Signed-off-by Maxime Ripard <[email protected]>
Thanks!
Nicolas
Re: [PATCH 13/89] clk: bcm: rpi: Switch to clk_hw_register_clkdev
In reply to Maxime RipardQuoting Maxime Ripard (2020-02-24 01:06:15)
Quoted 9 lines
Since we don't care about retrieving the
clk_lookupstructure pointer returned byclkdev_hw_create, we can just use theclk_hw_register_clkdevfunction.Cc Michael Turquette <[email protected]>Cc Stephen Boyd <[email protected]>Signed-off-by Maxime Ripard <[email protected]>---
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 14/89 clk: bcm: rpi: Make sure the clkdev lookup is removed
In reply to Maxime RipardThe clkdev lookup created for the cpufreq device is never removed if there's an issue later in probe or at module removal time.
Let's convert to the managed variant of the clk_hw_register_clkdev function to make sure it happens.
--- drivers/clk/bcm/clk-raspberrypi.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/clk/bcm/clk-raspberrypi.c +3 -2
@@ -245,8 +245,9 @@ static int raspberrypi_register_pllb_arm(struct raspberrypi_clk *rpi)return ret; } - ret =clk_hw_register_clkdev (&raspberrypi_clk_pllb_arm.hw, -NULL ,"cpu0" ); + ret =devm_clk_hw_register_clkdev (rpi->dev, + &raspberrypi_clk_pllb_arm.hw, +NULL ,"cpu0" );if (ret) {dev_err (rpi->dev,"Failed to initialize clkdev\n" );return ret;
Signature · 1 line
git-series 0.9.1
Re: [PATCH 14/89] clk: bcm: rpi: Make sure the clkdev lookup is removed
Quoted 10 lines · Maxime Ripard
The clkdev lookup created for the cpufreq device is never removed if there's an issue later in probe or at module removal time.
Let's convert to the managed variant of the
clk_hw_register_clkdevfunction to make sure it happens.Cc Michael Turquette <[email protected]>Cc Stephen Boyd <[email protected]>Signed-off-by Maxime Ripard <[email protected]>
Thanks!
Nicolas
Re: [PATCH 14/89] clk: bcm: rpi: Make sure the clkdev lookup is removed
In reply to Maxime RipardQuoting Maxime Ripard (2020-02-24 01:06:16)
Quoted 11 lines
The clkdev lookup created for the cpufreq device is never removed if there's an issue later in probe or at module removal time.
Let's convert to the managed variant of the
clk_hw_register_clkdevfunction to make sure it happens.Cc Michael Turquette <[email protected]>Cc Stephen Boyd <[email protected]>Signed-off-by Maxime Ripard <[email protected]>---
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 15/89 clk: bcm: rpi: Create a data structure for the clocks
In reply to Maxime RipardSo far the driver has really only been providing a single clock, and stored both the data associated to that clock in particular with the data associated to the "controller".
Since we will change that in the future, let's decouple the clock data from the provider data.
--- drivers/clk/bcm/clk-raspberrypi.c | 40 ++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 14 deletions(-)
drivers/clk/bcm/clk-raspberrypi.c +26 -14
@@ -35,11 +35,15 @@ struct raspberrypi_clk {struct device *dev;struct rpi_firmware *firmware;struct platform_device *cpufreq; +}; + +struct raspberrypi_clk_data { +struct clk_hw hw;unsigned long min_rate;unsigned long max_rate; -struct clk_hw pllb; +struct raspberrypi_clk *rpi; };/*
@@ -83,8 +87,9 @@ static int raspberrypi_clock_property(struct rpi_firmware *firmware, u32 tag,static int raspberrypi_fw_pll_is_on (struct clk_hw *hw) { - struct raspberrypi_clk *rpi = container_of(hw, struct raspberrypi_clk, - pllb); +struct raspberrypi_clk_data *data = + container_of(hw, struct raspberrypi_clk_data, hw); +struct raspberrypi_clk *rpi = data->rpi;u32 val =0 ;int ret;
@@ -101,8 +106,9 @@ static int raspberrypi_fw_pll_is_on(struct clk_hw *hw)static unsigned long raspberrypi_fw_pll_get_rate (struct clk_hw *hw,unsigned long parent_rate) { - struct raspberrypi_clk *rpi = container_of(hw, struct raspberrypi_clk, - pllb); +struct raspberrypi_clk_data *data = + container_of(hw, struct raspberrypi_clk_data, hw); +struct raspberrypi_clk *rpi = data->rpi;u32 val =0 ;int ret;
@@ -119,8 +125,9 @@ static unsigned long raspberrypi_fw_pll_get_rate(struct clk_hw *hw,static int raspberrypi_fw_pll_set_rate (struct clk_hw *hw,unsigned long rate,unsigned long parent_rate) { - struct raspberrypi_clk *rpi = container_of(hw, struct raspberrypi_clk, - pllb); +struct raspberrypi_clk_data *data = + container_of(hw, struct raspberrypi_clk_data, hw); +struct raspberrypi_clk *rpi = data->rpi;u32 new_rate = rate /RPI_FIRMWARE_PLLB_ARM_DIV_RATE ;int ret;
@@ -142,13 +149,13 @@ static int raspberrypi_fw_pll_set_rate(struct clk_hw *hw, unsigned long rate,static int raspberrypi_pll_determine_rate (struct clk_hw *hw,struct clk_rate_request *req) { - struct raspberrypi_clk *rpi = container_of(hw, struct raspberrypi_clk, - pllb); +struct raspberrypi_clk_data *data = + container_of(hw, struct raspberrypi_clk_data, hw);u64 div, final_rate;u32 ndiv, fdiv;/* We can't use req->rate directly as it would overflow */ - final_rate =clamp (req->rate, rpi->min_rate, rpi->max_rate); + final_rate =clamp (req->rate, data->min_rate, data->max_rate); div = (u64 )final_rate <<A2W_PLL_FRAC_BITS ;do_div (div, req->best_parent_rate);
@@ -173,10 +180,15 @@ static const struct clk_ops raspberrypi_firmware_pll_clk_ops = {static int raspberrypi_register_pllb (struct raspberrypi_clk *rpi) { +struct raspberrypi_clk_data *data;struct clk_init_data init = {};u32 min_rate =0 , max_rate =0 ;int ret; + data =devm_kzalloc (rpi->dev,sizeof (*data),GFP_KERNEL ); +if (!data) +return -ENOMEM ; + data->rpi = rpi;/* All of the PLLs derive from the external oscillator. */ init.parent_names = (const char *[]){"osc" };
@@ -215,12 +227,12 @@ static int raspberrypi_register_pllb(struct raspberrypi_clk *rpi)dev_info (rpi->dev,"CPU frequency range: min %u, max %u\n" , min_rate, max_rate); - rpi->min_rate = min_rate *RPI_FIRMWARE_PLLB_ARM_DIV_RATE ; - rpi->max_rate = max_rate *RPI_FIRMWARE_PLLB_ARM_DIV_RATE ; + data->min_rate = min_rate *RPI_FIRMWARE_PLLB_ARM_DIV_RATE ; + data->max_rate = max_rate *RPI_FIRMWARE_PLLB_ARM_DIV_RATE ; - rpi->pllb.init = &init; + data->hw.init = &init; -return devm_clk_hw_register (rpi->dev, &rpi->pllb); +return devm_clk_hw_register (rpi->dev, &data->hw); }static struct clk_fixed_factor raspberrypi_clk_pllb_arm = {
Signature · 1 line
git-series 0.9.1
Re: [PATCH 15/89] clk: bcm: rpi: Create a data structure for the clocks
Quoted 11 lines · Maxime Ripard
So far the driver has really only been providing a single clock, and stored both the data associated to that clock in particular with the data associated to the "controller".
Since we will change that in the future, let's decouple the clock data from the provider data.
Cc Michael Turquette <[email protected]>Cc Stephen Boyd <[email protected]>Signed-off-by Maxime Ripard <[email protected]>
Thanks!
Nicolas
Re: [PATCH 15/89] clk: bcm: rpi: Create a data structure for the clocks
In reply to Maxime RipardQuoting Maxime Ripard (2020-02-24 01:06:17)
Quoted 4 lines
So far the driver has really only been providing a single clock, and stored both the data associated to that clock in particular with the data associated to the "controller".
Quoted 8 lines
Since we will change that in the future, let's decouple the clock data from the provider data.
Cc Michael Turquette <[email protected]>Cc Stephen Boyd <[email protected]>Signed-off-by Maxime Ripard <[email protected]>---
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 16/89 clk: bcm: rpi: Add clock id to data
In reply to Maxime RipardThe driver has really only supported one clock so far and has hardcoded the ID used in communications with the firmware in all the functions implementing the clock framework hooks. Let's store that in the clock data structure so that we can support more clocks later on.
--- drivers/clk/bcm/clk-raspberrypi.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-)
drivers/clk/bcm/clk-raspberrypi.c +7 -9
@@ -39,6 +39,7 @@ struct raspberrypi_clk {struct raspberrypi_clk_data {struct clk_hw hw; +unsigned id;unsigned long min_rate;unsigned long max_rate;
@@ -95,7 +96,7 @@ static int raspberrypi_fw_pll_is_on(struct clk_hw *hw) ret =raspberrypi_clock_property (rpi->firmware,RPI_FIRMWARE_GET_CLOCK_STATE , -RPI_FIRMWARE_ARM_CLK_ID , &val); + data->id, &val);if (ret)return 0 ;
@@ -114,8 +115,7 @@ static unsigned long raspberrypi_fw_pll_get_rate(struct clk_hw *hw, ret =raspberrypi_clock_property (rpi->firmware,RPI_FIRMWARE_GET_CLOCK_RATE , -RPI_FIRMWARE_ARM_CLK_ID , - &val); + data->id, &val);if (ret)return ret;
@@ -133,8 +133,7 @@ static int raspberrypi_fw_pll_set_rate(struct clk_hw *hw, unsigned long rate, ret =raspberrypi_clock_property (rpi->firmware,RPI_FIRMWARE_SET_CLOCK_RATE , -RPI_FIRMWARE_ARM_CLK_ID , - &new_rate); + data->id, &new_rate);if (ret)dev_err_ratelimited (rpi->dev,"Failed to change %s frequency: %d" ,clk_hw_get_name (hw), ret);
@@ -189,6 +188,7 @@ static int raspberrypi_register_pllb(struct raspberrypi_clk *rpi)if (!data)return -ENOMEM ; data->rpi = rpi; + data->id =RPI_FIRMWARE_ARM_CLK_ID ;/* All of the PLLs derive from the external oscillator. */ init.parent_names = (const char *[]){"osc" };
@@ -200,8 +200,7 @@ static int raspberrypi_register_pllb(struct raspberrypi_clk *rpi)/* Get min & max rates set by the firmware */ ret =raspberrypi_clock_property (rpi->firmware,RPI_FIRMWARE_GET_MIN_CLOCK_RATE , -RPI_FIRMWARE_ARM_CLK_ID , - &min_rate); + data->id, &min_rate);if (ret) {dev_err (rpi->dev,"Failed to get %s min freq: %d\n" , init.name, ret);
@@ -210,8 +209,7 @@ static int raspberrypi_register_pllb(struct raspberrypi_clk *rpi) ret =raspberrypi_clock_property (rpi->firmware,RPI_FIRMWARE_GET_MAX_CLOCK_RATE , -RPI_FIRMWARE_ARM_CLK_ID , - &max_rate); + data->id, &max_rate);if (ret) {dev_err (rpi->dev,"Failed to get %s max freq: %d\n" , init.name, ret);
Signature · 1 line
git-series 0.9.1
Re: [PATCH 16/89] clk: bcm: rpi: Add clock id to data
Hi Maxime,
Am 24.02.20 um 10:06 schrieb Maxime Ripard:
Quoted 4 lines
The driver has really only supported one clock so far and has hardcoded the ID used in communications with the firmware in all the functions implementing the clock framework hooks. Let's store that in the clock data structure so that we can support more clocks later on.
thank you for this series. I looked through it but i couldn't find an explanation why we need to expose firmware clocks via DT instead of extending clk-bcm2835. The whole pllb / clk-raspberrypi stuff was an exception to get cpufreq working. I prefer to keep it an exception.
Regards
Stefan
Re: [PATCH 16/89] clk: bcm: rpi: Add clock id to data
Hi Stefan,
Quoted 8 lines · Stefan Wahren
Hi Maxime,
Am 24.02.20 um 10:06 schrieb Maxime Ripard:
Quoted 4 lines
The driver has really only supported one clock so far and has hardcoded the ID used in communications with the firmware in all the functions implementing the clock framework hooks. Let's store that in the clock data structure so that we can support more clocks later on.
Quoted 4 lines
thank you for this series. I looked through it but i couldn't find an explanation why we need to expose firmware clocks via DT instead of extending clk-bcm2835. The whole pllb / clk-raspberrypi stuff was an exception to get cpufreq working. I prefer to keep it an exception.
Thanks for pointing this out, I indeed forgot to address it in my cover letter or my commit log.
I'm not quite sure what the situation was with the previous RaspberryPi, but the RPi4 firmware does a bunch of things under the hood to make sure that everything works as expected:
- The HSM (and V3D) clocks will be reparented to multiple PLLs depending on the rate being asked for.
- Still depending on the rate, the firmware will adjust the voltage of the various PLLs.
- Depending on the temperature of the CPU and GPU, the firmware will change the rate of clocks to throttle in case of the cores overheating, with all the fallout that might happen to clocks deriving from it.
- No matter what we choose to do in Linux, this will happen so whether or not we want to do it, so doing it behind the firmware's back (or the firmware doing it behind Linux's back) will only result in troubles, with voltages too low, or the firmware trying to access the same register at the same time than the Linux driver would, etc.
So all in all, it just seems much easier and safer to use the firmware clocks.
Maxime
Re: [PATCH 16/89] clk: bcm: rpi: Add clock id to data
Hi Maxime,
Quoted 39 lines · Maxime Ripard
Hi Stefan,
Quoted 9 lines · Stefan Wahren
Hi Maxime,
Am 24.02.20 um 10:06 schrieb Maxime Ripard:
Quoted 5 lines
The driver has really only supported one clock so far and has hardcoded the
ID used in communications with the firmware in all the functions implementing the clock framework hooks. Let's store that in the clock data structure so that we can support more clocks later on.Quoted 4 lines
thank you for this series. I looked through it but i couldn't find an explanation why we need to expose firmware clocks via DT instead of extending clk-bcm2835. The whole pllb / clk-raspberrypi stuff was an exception to get cpufreq working. I prefer to keep it an exception.
Thanks for pointing this out, I indeed forgot to address it in my cover letter or my commit log.
I'm not quite sure what the situation was with the previous RaspberryPi, but the RPi4 firmware does a bunch of things under the hood to make sure that everything works as expected:
- The HSM (and V3D) clocks will be reparented to multiple PLLs depending on the rate being asked for.
- Still depending on the rate, the firmware will adjust the voltage of the various PLLs.
- Depending on the temperature of the CPU and GPU, the firmware will change the rate of clocks to throttle in case of the cores overheating, with all the fallout that might happen to clocks deriving from it.
- No matter what we choose to do in Linux, this will happen so whether or not we want to do it, so doing it behind the firmware's back (or the firmware doing it behind Linux's back) will only result in troubles, with voltages too low, or the firmware trying to access the same register at the same time than the Linux driver would, etc.
Quoted 2 lines
So all in all, it just seems much easier and safer to use the firmware clocks.
I agree with your assesment. Both DVFS and overheating/overvoltage protections will cause trouble, if not, make a Linux solution impossible while using the Foundation's firmware.
Please note that, as Stefan says, it'd be nice to keep track of those arguments somewhere in the commit messages.
Regards,
Nicolas
Re: [PATCH 16/89] clk: bcm: rpi: Add clock id to data
In reply to Maxime RipardQuoted 9 lines · Maxime Ripard
The driver has really only supported one clock so far and has hardcoded the ID used in communications with the firmware in all the functions implementing the clock framework hooks. Let's store that in the clock data structure so that we can support more clocks later on.
Cc Michael Turquette <[email protected]>Cc Stephen Boyd <[email protected]>Signed-off-by Maxime Ripard <[email protected]>
Thanks!
Nicolas
Re: [PATCH 16/89] clk: bcm: rpi: Add clock id to data
In reply to Maxime RipardQuoting Maxime Ripard (2020-02-24 01:06:18)
Quoted 10 lines
The driver has really only supported one clock so far and has hardcoded the ID used in communications with the firmware in all the functions implementing the clock framework hooks. Let's store that in the clock data structure so that we can support more clocks later on.
Cc Michael Turquette <[email protected]>Cc Stephen Boyd <[email protected]>Signed-off-by Maxime Ripard <[email protected]>---
PATCH 17/89 clk: bcm: rpi: Pass the clocks data to the firmware function
In reply to Maxime RipardThe raspberry_clock_property only takes the clock ID as an argument, but now that we have a clock data structure it makes more sense to just pass that structure instead.
--- drivers/clk/bcm/clk-raspberrypi.c | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-)
drivers/clk/bcm/clk-raspberrypi.c +14 -15
@@ -67,11 +67,12 @@ struct raspberrypi_firmware_prop {__le32 disable_turbo; } __packed; -static int raspberrypi_clock_property (struct rpi_firmware *firmware,u32 tag, -u32 clk,u32 *val) +static int raspberrypi_clock_property (struct rpi_firmware *firmware, +struct raspberrypi_clk_data *data, +u32 tag,u32 *val) {struct raspberrypi_firmware_prop msg = { - .id =cpu_to_le32 (clk), + .id =cpu_to_le32 (data->id), .val =cpu_to_le32 (*val), .disable_turbo =cpu_to_le32 (1 ), };
@@ -94,9 +95,8 @@ static int raspberrypi_fw_pll_is_on(struct clk_hw *hw)u32 val =0 ;int ret; - ret =raspberrypi_clock_property (rpi->firmware, -RPI_FIRMWARE_GET_CLOCK_STATE , - data->id, &val); + ret =raspberrypi_clock_property (rpi->firmware, data, +RPI_FIRMWARE_GET_CLOCK_STATE , &val);if (ret)return 0 ;
@@ -113,9 +113,8 @@ static unsigned long raspberrypi_fw_pll_get_rate(struct clk_hw *hw,u32 val =0 ;int ret; - ret =raspberrypi_clock_property (rpi->firmware, -RPI_FIRMWARE_GET_CLOCK_RATE , - data->id, &val); + ret =raspberrypi_clock_property (rpi->firmware, data, +RPI_FIRMWARE_GET_CLOCK_RATE , &val);if (ret)return ret;
@@ -131,9 +130,9 @@ static int raspberrypi_fw_pll_set_rate(struct clk_hw *hw, unsigned long rate,u32 new_rate = rate /RPI_FIRMWARE_PLLB_ARM_DIV_RATE ;int ret; - ret =raspberrypi_clock_property (rpi->firmware, + ret =raspberrypi_clock_property (rpi->firmware, data,RPI_FIRMWARE_SET_CLOCK_RATE , - data->id, &new_rate); + &new_rate);if (ret)dev_err_ratelimited (rpi->dev,"Failed to change %s frequency: %d" ,clk_hw_get_name (hw), ret);
@@ -198,18 +197,18 @@ static int raspberrypi_register_pllb(struct raspberrypi_clk *rpi) init.flags =CLK_GET_RATE_NOCACHE |CLK_IGNORE_UNUSED ;/* Get min & max rates set by the firmware */ - ret =raspberrypi_clock_property (rpi->firmware, + ret =raspberrypi_clock_property (rpi->firmware, data,RPI_FIRMWARE_GET_MIN_CLOCK_RATE , - data->id, &min_rate); + &min_rate);if (ret) {dev_err (rpi->dev,"Failed to get %s min freq: %d\n" , init.name, ret);return ret; } - ret =raspberrypi_clock_property (rpi->firmware, + ret =raspberrypi_clock_property (rpi->firmware, data,RPI_FIRMWARE_GET_MAX_CLOCK_RATE , - data->id, &max_rate); + &max_rate);if (ret) {dev_err (rpi->dev,"Failed to get %s max freq: %d\n" , init.name, ret);
Signature · 1 line
git-series 0.9.1
Re: [PATCH 17/89] clk: bcm: rpi: Pass the clocks data to the firmware function
Quoted 8 lines · Maxime Ripard
The
raspberry_clock_propertyonly takes the clock ID as an argument, but now that we have a clock data structure it makes more sense to just pass that structure instead.Cc Michael Turquette <[email protected]>Cc Stephen Boyd <[email protected]>Signed-off-by Maxime Ripard <[email protected]>
Thanks!
Nicolas
Stephen Boyd
maintainerRe: [PATCH 17/89] clk: bcm: rpi: Pass the clocks data to the firmware function
In reply to Maxime RipardQuoting Maxime Ripard (2020-02-24 01:06:19)
Quoted 17 lines
The
raspberry_clock_propertyonly takes the clock ID as an argument, but now that we have a clock data structure it makes more sense to just pass that structure instead.Cc Michael Turquette <[email protected]>Cc Stephen Boyd <[email protected]>Signed-off-by Maxime Ripard <[email protected]>--- drivers/clk/bcm/clk-raspberrypi.c | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-)drivers/clk/bcm/clk-raspberrypi.c +0
-0
drivers/clk/bcm/clk-raspberrypi.c struct raspberrypi_firmware_prop { · line 71
Quoted 7 lines
drivers/clk/bcm/clk-raspberrypi.c +2
-2@@ -67,11 +67,12 @@ struct raspberrypi_firmware_prop {__le32 disable_turbo; } __packed; -static int raspberrypi_clock_property (struct rpi_firmware *firmware,u32 tag, -u32 clk,u32 *val) +static int raspberrypi_clock_property(struct rpi_firmware *firmware, + struct raspberrypi_clk_data *data,
Can data be const?
Quoted 8 lines
drivers/clk/bcm/clk-raspberrypi.c +2
-1+ u32 tag, u32 *val) { struct raspberrypi_firmware_prop msg = { - .id =cpu_to_le32 (clk), + .id =cpu_to_le32 (data->id), .val =cpu_to_le32 (*val), .disable_turbo =cpu_to_le32 (1 ), };
PATCH 18/89 clk: bcm: rpi: Rename is_prepared function
In reply to Maxime RipardThe raspberrypi_fw_pll_is_on function doesn't only apply to PLL registered in the driver, but any clock exposed by the firmware.
Since we also implement the is_prepared hook, make the function consistent with the other function names, and drop the fw from the function name.
--- drivers/clk/bcm/clk-raspberrypi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/clk/bcm/clk-raspberrypi.c +2 -2
@@ -87,7 +87,7 @@ static int raspberrypi_clock_property(struct rpi_firmware *firmware,return 0 ; } -static int raspberrypi_fw_pll_is_on (struct clk_hw *hw) +static int raspberrypi_fw_is_prepared (struct clk_hw *hw) {struct raspberrypi_clk_data *data = container_of(hw, struct raspberrypi_clk_data, hw);
@@ -170,7 +170,7 @@ static int raspberrypi_pll_determine_rate(struct clk_hw *hw, }static const struct clk_ops raspberrypi_firmware_pll_clk_ops = { - .is_prepared = raspberrypi_fw_pll_is_on, + .is_prepared = raspberrypi_fw_is_prepared, .recalc_rate = raspberrypi_fw_pll_get_rate, .set_rate = raspberrypi_fw_pll_set_rate, .determine_rate = raspberrypi_pll_determine_rate,
Signature · 1 line
git-series 0.9.1
Re: [PATCH 18/89] clk: bcm: rpi: Rename is_prepared function
Quoted 6 lines · Maxime Ripard
The
raspberrypi_fw_pll_is_onfunction doesn't only apply to PLL registered in the driver, but any clock exposed by the firmware.Since we also implement the
is_preparedhook, make the function consistent with the other function names, and drop the fw from the function name.
It seems you didn't :)
As it does use the fw interface I'd say keep it in the name, with that:
Thanks!
Nicolas
Quoted 6 lines
Cc Michael Turquette <[email protected]>Cc Stephen Boyd <[email protected]>Signed-off-by Maxime Ripard <[email protected]>---
Re: [PATCH 18/89] clk: bcm: rpi: Rename is_prepared function
In reply to Maxime RipardQuoting Maxime Ripard (2020-02-24 01:06:20)
Quoted 7 lines
The
raspberrypi_fw_pll_is_onfunction doesn't only apply to PLL registered in the driver, but any clock exposed by the firmware.Since we also implement the
is_preparedhook, make the function consistent with the other function names, and drop the fw from the function name.
Quoted 5 lines
Cc Michael Turquette <[email protected]>Cc Stephen Boyd <[email protected]>Signed-off-by Maxime Ripard <[email protected]>---
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 19/89 clk: bcm: rpi: Split pllb clock hooks
In reply to Maxime RipardThe driver only supports the pllb for now and all the clock framework hooks are a mix of the generic firmware interface and the specifics of the pllb. Since we will support more clocks in the future let's split the generic and specific hooks
--- drivers/clk/bcm/clk-raspberrypi.c | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-)
drivers/clk/bcm/clk-raspberrypi.c +22 -8
@@ -104,8 +104,8 @@ static int raspberrypi_fw_is_prepared(struct clk_hw *hw) } -static unsigned long raspberrypi_fw_pll_get_rate (struct clk_hw *hw, -unsigned long parent_rate) +static unsigned long raspberrypi_fw_get_rate (struct clk_hw *hw, +unsigned long parent_rate) {struct raspberrypi_clk_data *data = container_of(hw, struct raspberrypi_clk_data, hw);
@@ -118,21 +118,27 @@ static unsigned long raspberrypi_fw_pll_get_rate(struct clk_hw *hw,if (ret)return ret; -return val *RPI_FIRMWARE_PLLB_ARM_DIV_RATE ; +return val; } -static int raspberrypi_fw_pll_set_rate (struct clk_hw *hw,unsigned long rate, -unsigned long parent_rate) +static unsigned long raspberrypi_fw_pll_get_rate (struct clk_hw *hw, +unsigned long parent_rate) +{ +return raspberrypi_fw_get_rate (hw, parent_rate) * +RPI_FIRMWARE_PLLB_ARM_DIV_RATE ; +} + +static int raspberrypi_fw_set_rate (struct clk_hw *hw,unsigned long rate, +unsigned long parent_rate) {struct raspberrypi_clk_data *data = container_of(hw, struct raspberrypi_clk_data, hw);struct raspberrypi_clk *rpi = data->rpi; -u32 new_rate = rate /RPI_FIRMWARE_PLLB_ARM_DIV_RATE ; +u32 _rate = rate;int ret; ret =raspberrypi_clock_property (rpi->firmware, data, -RPI_FIRMWARE_SET_CLOCK_RATE , - &new_rate); +RPI_FIRMWARE_SET_CLOCK_RATE , &_rate);if (ret)dev_err_ratelimited (rpi->dev,"Failed to change %s frequency: %d" ,clk_hw_get_name (hw), ret);
@@ -140,6 +146,14 @@ static int raspberrypi_fw_pll_set_rate(struct clk_hw *hw, unsigned long rate,return ret; } +static int raspberrypi_fw_pll_set_rate (struct clk_hw *hw,unsigned long rate, +unsigned long parent_rate) +{ +u32 new_rate = rate /RPI_FIRMWARE_PLLB_ARM_DIV_RATE ; + +return raspberrypi_fw_set_rate (hw, new_rate, parent_rate); +} +/* * Sadly there is no firmware rate rounding interface. We borrowed it from * clk-bcm2835.
Signature · 1 line
git-series 0.9.1
Re: [PATCH 19/89] clk: bcm: rpi: Split pllb clock hooks
Quoting Maxime Ripard (2020-02-24 01:06:21)
Quoted 10 lines
The driver only supports the pllb for now and all the clock framework hooks are a mix of the generic firmware interface and the specifics of the pllb. Since we will support more clocks in the future let's split the generic and specific hooks
Cc Michael Turquette <[email protected]>Cc Stephen Boyd <[email protected]>Signed-off-by Maxime Ripard <[email protected]>---
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 20/89 clk: bcm: rpi: Make the PLLB registration function return a clk_hw
In reply to Maxime RipardThe raspberrypi_register_pllb has been returning an integer so far to notify whether the functions has exited successfully or not.
However, the OF provider functions in the clock framework require access to the clk_hw structure so that we can expose those clocks to device tree consumers.
Since we'll want that for the future clocks, let's return a clk_hw pointer instead of the return code.
--- drivers/clk/bcm/clk-raspberrypi.c | 40 +++++++++++++++++--------------- 1 file changed, 22 insertions(+), 18 deletions(-)
drivers/clk/bcm/clk-raspberrypi.c +22 -18
@@ -190,7 +190,7 @@ static const struct clk_ops raspberrypi_firmware_pll_clk_ops = { .determine_rate = raspberrypi_pll_determine_rate, }; -static int raspberrypi_register_pllb (struct raspberrypi_clk *rpi) +static struct clk_hw *raspberrypi_register_pllb (struct raspberrypi_clk *rpi) {struct raspberrypi_clk_data *data;struct clk_init_data init = {};
@@ -199,7 +199,7 @@ static int raspberrypi_register_pllb(struct raspberrypi_clk *rpi) data =devm_kzalloc (rpi->dev,sizeof (*data),GFP_KERNEL );if (!data) -return -ENOMEM ; +return ERR_PTR (-ENOMEM ); data->rpi = rpi; data->id =RPI_FIRMWARE_ARM_CLK_ID ;
@@ -217,7 +217,7 @@ static int raspberrypi_register_pllb(struct raspberrypi_clk *rpi)if (ret) {dev_err (rpi->dev,"Failed to get %s min freq: %d\n" , init.name, ret); -return ret; +return ERR_PTR (ret); } ret = raspberrypi_clock_property(rpi->firmware, data,
@@ -226,13 +226,13 @@ static int raspberrypi_register_pllb(struct raspberrypi_clk *rpi)if (ret) {dev_err (rpi->dev,"Failed to get %s max freq: %d\n" , init.name, ret); -return ret; +return ERR_PTR (ret); }if (!min_rate || !max_rate) {dev_err (rpi->dev,"Unexpected frequency range: min %u, max %u\n" , min_rate, max_rate); -return -EINVAL ; +return ERR_PTR (-EINVAL ); } dev_info(rpi->dev, "CPU frequency range: min %u, max %u\n",
@@ -243,7 +243,11 @@ static int raspberrypi_register_pllb(struct raspberrypi_clk *rpi) data->hw.init = &init; -return devm_clk_hw_register (rpi->dev, &data->hw); + ret =devm_clk_hw_register (rpi->dev, &data->hw); +if (ret) +return ERR_PTR (ret); + +return &data->hw; }static struct clk_fixed_factor raspberrypi_clk_pllb_arm = {
@@ -258,14 +262,14 @@ static struct clk_fixed_factor raspberrypi_clk_pllb_arm = { }, }; -static int raspberrypi_register_pllb_arm (struct raspberrypi_clk *rpi) +static struct clk_hw *raspberrypi_register_pllb_arm (struct raspberrypi_clk *rpi) {int ret; ret =devm_clk_hw_register (rpi->dev, &raspberrypi_clk_pllb_arm.hw);if (ret) {dev_err (rpi->dev,"Failed to initialize pllb_arm\n" ); -return ret; +return ERR_PTR (ret); } ret = devm_clk_hw_register_clkdev(rpi->dev,
@@ -273,10 +277,10 @@ static int raspberrypi_register_pllb_arm(struct raspberrypi_clk *rpi) NULL, "cpu0");if (ret) {dev_err (rpi->dev,"Failed to initialize clkdev\n" ); -return ret; +return ERR_PTR (ret); } -return 0 ; +return &raspberrypi_clk_pllb_arm.hw; }static int raspberrypi_clk_probe (struct platform_device *pdev)
@@ -285,7 +289,7 @@ static int raspberrypi_clk_probe(struct platform_device *pdev)struct device *dev = &pdev->dev;struct rpi_firmware *firmware;struct raspberrypi_clk *rpi; -int ret; +struct clk_hw *hw; firmware_node =of_parse_phandle (dev->of_node,"raspberrypi,firmware" ,0 );if (!firmware_node) {
@@ -305,15 +309,15 @@ static int raspberrypi_clk_probe(struct platform_device *pdev) rpi->firmware = firmware;platform_set_drvdata (pdev, rpi); - ret =raspberrypi_register_pllb (rpi); -if (ret) { -dev_err (dev,"Failed to initialize pllb, %d\n" , ret); -return ret; + hw =raspberrypi_register_pllb (rpi); +if (IS_ERR (hw)) { +dev_err (dev,"Failed to initialize pllb, %ld\n" ,PTR_ERR (hw)); +return PTR_ERR (hw); } - ret =raspberrypi_register_pllb_arm (rpi); -if (ret) -return ret; + hw =raspberrypi_register_pllb_arm (rpi); +if (IS_ERR (hw)) +return PTR_ERR (hw); rpi->cpufreq =platform_device_register_data (dev,"raspberrypi-cpufreq" ,-1 ,NULL ,0 );
Signature · 1 line
git-series 0.9.1
Re: [PATCH 20/89] clk: bcm: rpi: Make the PLLB registration function return a clk_hw
Quoting Maxime Ripard (2020-02-24 01:06:22)
Quoted 7 lines
The
raspberrypi_register_pllbhas been returning an integer so far to notify whether the functions has exited successfully or not.However, the OF provider functions in the clock framework require access to the
clk_hwstructure so that we can expose those clocks to device tree consumers.
Quoted 8 lines
Since we'll want that for the future clocks, let's return a
clk_hwpointer instead of the return code.Cc Michael Turquette <[email protected]>Cc Stephen Boyd <[email protected]>Signed-off-by Maxime Ripard <[email protected]>---
PATCH 21/89 clk: bcm: rpi: Add DT provider for the clocks
In reply to Maxime RipardFor the upcoming registration of the clocks provided by the firmware, make sure it's exposed to the device tree providers.
--- drivers/clk/bcm/clk-raspberrypi.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
drivers/clk/bcm/clk-raspberrypi.c +15 -0
@@ -31,6 +31,8 @@#define A2W_PLL_FRAC_BITS 20 +#define NUM_FW_CLKS 16 +struct raspberrypi_clk {struct device *dev;struct rpi_firmware *firmware;
@@ -285,6 +287,7 @@ static struct clk_hw *raspberrypi_register_pllb_arm(struct raspberrypi_clk *rpi)static int raspberrypi_clk_probe (struct platform_device *pdev) { +struct clk_hw_onecell_data *clk_data;struct device_node *firmware_node;struct device *dev = &pdev->dev;struct rpi_firmware *firmware;
@@ -309,6 +312,11 @@ static int raspberrypi_clk_probe(struct platform_device *pdev) rpi->firmware = firmware;platform_set_drvdata (pdev, rpi); + clk_data =devm_kzalloc (dev,struct_size (clk_data, hws,NUM_FW_CLKS ), +GFP_KERNEL ); +if (!clk_data) +return -ENOMEM ; + hw =raspberrypi_register_pllb (rpi);if (IS_ERR (hw)) {dev_err (dev,"Failed to initialize pllb, %ld\n" ,PTR_ERR (hw));
@@ -318,6 +326,13 @@ static int raspberrypi_clk_probe(struct platform_device *pdev) hw =raspberrypi_register_pllb_arm (rpi);if (IS_ERR (hw))return PTR_ERR (hw); + clk_data->hws[RPI_FIRMWARE_ARM_CLK_ID ] = hw; + clk_data->num =RPI_FIRMWARE_ARM_CLK_ID +1 ; + + ret =devm_of_clk_add_hw_provider (dev, of_clk_hw_onecell_get, + clk_data); +if (ret) +return ret; rpi->cpufreq =platform_device_register_data (dev,"raspberrypi-cpufreq" ,-1 ,NULL ,0 );
Signature · 1 line
git-series 0.9.1
Re: [PATCH 21/89] clk: bcm: rpi: Add DT provider for the clocks
Quoting Maxime Ripard (2020-02-24 01:06:23)
Quoted 8 lines
For the upcoming registration of the clocks provided by the firmware, make sure it's exposed to the device tree providers.
Cc Michael Turquette <[email protected]>Cc Stephen Boyd <[email protected]>Signed-off-by Maxime Ripard <[email protected]>---
PATCH 22/89 clk: bcm: rpi: Discover the firmware clocks
In reply to Maxime RipardThe firmware has an interface to discover the clocks it exposes.
Let's use it to discover, register the clocks in the clocks framework and then expose them through the device tree for consumers to use them.
--- drivers/clk/bcm/clk-raspberrypi.c | 105 +++++++++++++++++++--- include/soc/bcm2835/raspberrypi-firmware.h | 5 +- 2 files changed, 98 insertions(+), 12 deletions(-)
drivers/clk/bcm/clk-raspberrypi.c +93 -12
@@ -285,6 +285,95 @@ static struct clk_hw *raspberrypi_register_pllb_arm(struct raspberrypi_clk *rpi)return &raspberrypi_clk_pllb_arm.hw; } +static long raspberrypi_fw_dumb_round_rate (struct clk_hw *hw, +unsigned long rate, +unsigned long *parent_rate) +{ +return rate; +} + +static const struct clk_ops raspberrypi_firmware_clk_ops = { + .is_prepared = raspberrypi_fw_is_prepared, + .recalc_rate = raspberrypi_fw_get_rate, + .round_rate = raspberrypi_fw_dumb_round_rate, + .set_rate = raspberrypi_fw_set_rate, +}; + +static struct clk_hw *raspberrypi_clk_register (struct raspberrypi_clk *rpi, +unsigned int parent, +unsigned int id) +{ +struct raspberrypi_clk_data *data; +struct clk_init_data init = {}; +int ret; + +if (id ==RPI_FIRMWARE_ARM_CLK_ID ) { +struct clk_hw *hw; + + hw =raspberrypi_register_pllb (rpi); +if (IS_ERR (hw)) { +dev_err (rpi->dev,"Failed to initialize pllb, %ld\n" , +PTR_ERR (hw)); +return hw; + } + + hw =raspberrypi_register_pllb_arm (rpi); +if (IS_ERR (hw)) +return hw; + +return hw; + } + + data =devm_kzalloc (rpi->dev,sizeof (data),GFP_KERNEL ); +if (!data) +return ERR_PTR (-ENOMEM ); + data->rpi = rpi; + data->id = id; + + init.name =devm_kasprintf (rpi->dev,GFP_KERNEL ,"fw-clk-%u" , id); + init.ops = &raspberrypi_firmware_clk_ops; + init.flags =CLK_GET_RATE_NOCACHE |CLK_IGNORE_UNUSED ; + + data->hw.init = &init; + + ret =devm_clk_hw_register (rpi->dev, &data->hw); +if (ret) +return ERR_PTR (ret); + +return &data->hw; +} + +static int raspberrypi_discover_clocks (struct raspberrypi_clk *rpi, +struct clk_hw_onecell_data *data) +{ +struct rpi_firmware_get_clocks_response *clks; +size_t clks_size =NUM_FW_CLKS *sizeof (*clks); +int ret; + + clks =devm_kzalloc (rpi->dev, clks_size,GFP_KERNEL ); +if (!clks) +return -ENOMEM ; + + ret =rpi_firmware_property (rpi->firmware,RPI_FIRMWARE_GET_CLOCKS , + clks, clks_size); +if (ret) +return ret; + +while (clks->id) { +struct clk_hw *hw; + + hw =raspberrypi_clk_register (rpi, clks->parent, clks->id); +if (IS_ERR (hw)) +return PTR_ERR (hw); + + data->hws[clks->id] = hw; + data->num = clks->id +1 ; + clks++; + } + +return 0 ; +} +static int raspberrypi_clk_probe (struct platform_device *pdev) {struct clk_hw_onecell_data *clk_data;
@@ -292,7 +381,7 @@ static int raspberrypi_clk_probe(struct platform_device *pdev)struct device *dev = &pdev->dev;struct rpi_firmware *firmware;struct raspberrypi_clk *rpi; -struct clk_hw *hw; +int ret; firmware_node =of_parse_phandle (dev->of_node,"raspberrypi,firmware" ,0 );if (!firmware_node) {
@@ -317,17 +406,9 @@ static int raspberrypi_clk_probe(struct platform_device *pdev)if (!clk_data)return -ENOMEM ; - hw =raspberrypi_register_pllb (rpi); -if (IS_ERR (hw)) { -dev_err (dev,"Failed to initialize pllb, %ld\n" ,PTR_ERR (hw)); -return PTR_ERR (hw); - } - - hw =raspberrypi_register_pllb_arm (rpi); -if (IS_ERR (hw)) -return PTR_ERR (hw); - clk_data->hws[RPI_FIRMWARE_ARM_CLK_ID ] = hw; - clk_data->num =RPI_FIRMWARE_ARM_CLK_ID +1 ; + ret =raspberrypi_discover_clocks (rpi, clk_data); +if (ret) +return ret; ret =devm_of_clk_add_hw_provider (dev, of_clk_hw_onecell_get, clk_data);
include/soc/bcm2835/raspberrypi-firmware.h +5 -0
@@ -135,6 +135,11 @@ enum rpi_firmware_property_tag { RPI_FIRMWARE_GET_DMA_CHANNELS = 0x00060001, }; +struct rpi_firmware_get_clocks_response { +__le32 parent; +__le32 id; +}; +#if IS_ENABLED (CONFIG_RASPBERRYPI_FIRMWARE )int rpi_firmware_property (struct rpi_firmware *fw,u32 tag,void *data,size_t len);
Signature · 1 line
git-series 0.9.1
kbuild test robot
build botRe: [PATCH 22/89] clk: bcm: rpi: Discover the firmware clocks
I love your patch! Perhaps something to improve:
Hi Maxime,
I love your patch! Perhaps something to improve:
[auto build test WARNING on clk/clk-next]
[also build test WARNING on robh/for-next anholt/for-next v5.6-rc3 next-20200224] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Maxime-Ripard/drm-vc4-Support-BCM2711-Display-Pipeline/20200224-172730 base: https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git clk-next
If you fix the issue, kindly add following tag
coccinelle warnings: (new ones prefixed by >>)
>> drivers/clk/bcm/clk-raspberrypi.c:327:31-37: ERROR: application of sizeof to pointer
Please review and possibly fold the followup patch.
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
kbuild test robot
build bot[PATCH] clk: bcm: rpi: fix noderef.cocci warnings
In reply to Maxime Riparddrivers/clk/bcm/clk-raspberrypi.c:327:31-37: ERROR: application of sizeof to pointer
From: kbuild test robot <[email protected]>
drivers/clk/bcm/clk-raspberrypi.c:327:31-37: ERROR: application of sizeof to pointer
sizeof when applied to a pointer typed expression gives the size of the pointer
Generated by: scripts/coccinelle/misc/noderef.cocci
---
url: https://github.com/0day-ci/linux/commits/Maxime-Ripard/drm-vc4-Support-BCM2711-Display-Pipeline/20200224-172730 base: https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git clk-next
clk-raspberrypi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/bcm/clk-raspberrypi.c +1 -1
@@ -324,7 +324,7 @@ static struct clk_hw *raspberrypi_clk_rereturn hw; } - data =devm_kzalloc (rpi->dev,sizeof (data),GFP_KERNEL ); + data =devm_kzalloc (rpi->dev,sizeof (*data),GFP_KERNEL );if (!data)return ERR_PTR (-ENOMEM ); data->rpi = rpi;
Re: [PATCH 22/89] clk: bcm: rpi: Discover the firmware clocks
In reply to Maxime RipardQuoted 9 lines · Maxime Ripard
The firmware has an interface to discover the clocks it exposes.
Let's use it to discover, register the clocks in the clocks framework and then expose them through the device tree for consumers to use them.
Cc Michael Turquette <[email protected]>Cc Stephen Boyd <[email protected]>Signed-off-by Maxime Ripard <[email protected]>
That seems like a re-implementaiton of SCMI without all of its protocols, without being able to use the existing drivers, maybe a firmware update should be considered so standard drivers can be leveraged?
Signature · 1 line
Florian
Re: [PATCH 22/89] clk: bcm: rpi: Discover the firmware clocks
Hi Florian,
Quoted 6 lines · Florian Fainelli
Quoted 5 lines · Maxime Ripard
The firmware has an interface to discover the clocks it exposes.
Let's use it to discover, register the clocks in the clocks framework and then expose them through the device tree for consumers to use them.
Quoted 8 lines
Quoted 4 lines
Cc Michael Turquette <[email protected]>Cc Stephen Boyd <[email protected]>Signed-off-by Maxime Ripard <[email protected]>That seems like a re-implementaiton of SCMI without all of its protocols, without being able to use the existing drivers, maybe a firmware update should be considered so standard drivers can be leveraged?
I'm not really qualified to talk about how the firmware will evolve in the future, but you're right that it looks a lot like what SCMI can do.
Even if a firmware update was to support SCMI at some point, since the firmware is flashed in an EEPROM, we'd still have to support that interface.
Maxime
kbuild test robot
build botRe: [PATCH 22/89] clk: bcm: rpi: Discover the firmware clocks
In reply to Maxime RipardI love your patch! Perhaps something to improve:
Hi Maxime,
I love your patch! Perhaps something to improve:
[auto build test WARNING on clk/clk-next]
[also build test WARNING on robh/for-next anholt/for-next v5.6-rc3 next-20200224] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Maxime-Ripard/drm-vc4-Support-BCM2711-Display-Pipeline/20200224-172730 base: https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git clk-next reproduce: # apt-get install sparse # sparse version: v0.6.1-173-ge0787745-dirty make ARCH=x86_64 allmodconfig make C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__'
If you fix the issue, kindly add following tag
sparse warnings: (new ones prefixed by >>)
>> drivers/clk/bcm/clk-raspberrypi.c:365:56: sparse: sparse: incorrect type in argument 2 (different base types) >> drivers/clk/bcm/clk-raspberrypi.c:365:56: sparse: expected unsigned int parent >> drivers/clk/bcm/clk-raspberrypi.c:365:56: sparse: got restricted __le32 [usertype] parent drivers/clk/bcm/clk-raspberrypi.c:365:70: sparse: sparse: incorrect type in argument 3 (different base types) >> drivers/clk/bcm/clk-raspberrypi.c:365:70: sparse: expected unsigned int id >> drivers/clk/bcm/clk-raspberrypi.c:365:70: sparse: got restricted __le32 [usertype] id >> drivers/clk/bcm/clk-raspberrypi.c:369:31: sparse: sparse: restricted __le32 degrades to integer
drivers/clk/bcm/clk-raspberrypi.c:370:33: sparse: sparse: restricted __le32 degrades to integer
vim +365 drivers/clk/bcm/clk-raspberrypi.c
345
346 static int raspberrypi_discover_clocks(struct raspberrypi_clk *rpi,
347 struct clk_hw_onecell_data *data)
348 {
349 struct rpi_firmware_get_clocks_response *clks;
350 size_t clks_size = NUM_FW_CLKS * sizeof(*clks);
351 int ret;
352
353 clks = devm_kzalloc(rpi->dev, clks_size, GFP_KERNEL);
354 if (!clks)
355 return -ENOMEM;
356
357 ret = rpi_firmware_property(rpi->firmware, RPI_FIRMWARE_GET_CLOCKS,
358 clks, clks_size);
359 if (ret)
360 return ret;
361
362 while (clks->id) {
363 struct clk_hw *hw;
364
> 365 hw = raspberrypi_clk_register(rpi, clks->parent, clks->id); 366 if (IS_ERR(hw)) 367 return PTR_ERR(hw); 368 > 369 data->hws[clks->id] = hw;
370 data->num = clks->id + 1;
371 clks++;
372 }
373
374 return 0;
375 }
376
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
Stephen Boyd
maintainerRe: [PATCH 22/89] clk: bcm: rpi: Discover the firmware clocks
In reply to Maxime RipardQuoting Maxime Ripard (2020-02-24 01:06:24)
Quoted 4 lines
The firmware has an interface to discover the clocks it exposes.
Let's use it to discover, register the clocks in the clocks framework and then expose them through the device tree for consumers to use them.
Everyone's doing it! :)
drivers/clk/bcm/clk-raspberrypi.c static struct clk_hw *raspberrypi_register_pllb_arm(struct raspberrypi_clk *rpi) · line 292
Quoted 13 lines
drivers/clk/bcm/clk-raspberrypi.c +5
-0@@ -285,6 +285,95 @@ static struct clk_hw *raspberrypi_register_pllb_arm(struct raspberrypi_clk *rpi)return &raspberrypi_clk_pllb_arm.hw; } +static long raspberrypi_fw_dumb_round_rate (struct clk_hw *hw, +unsigned long rate, +unsigned long *parent_rate) +{ +return rate;
Can we get a comment here like "The firmware does the rounding but doesn't tell us so we have to assume anything goes!"
Quoted 22 lines
drivers/clk/bcm/clk-raspberrypi.c +22
-0+} + +static const struct clk_ops raspberrypi_firmware_clk_ops = { + .is_prepared = raspberrypi_fw_is_prepared, + .recalc_rate = raspberrypi_fw_get_rate, + .round_rate = raspberrypi_fw_dumb_round_rate, + .set_rate = raspberrypi_fw_set_rate, +}; + +static struct clk_hw *raspberrypi_clk_register (struct raspberrypi_clk *rpi, +unsigned int parent, +unsigned int id) +{ +struct raspberrypi_clk_data *data; +struct clk_init_data init = {}; +int ret; + +if (id ==RPI_FIRMWARE_ARM_CLK_ID ) { +struct clk_hw *hw; + + hw =raspberrypi_register_pllb (rpi); +if (IS_ERR (hw)) {
drivers/clk/bcm/clk-raspberrypi.c static struct clk_hw *raspberrypi_register_pllb_arm(struct raspberrypi_clk *rpi) · line 324
Quoted 10 lines
drivers/clk/bcm/clk-raspberrypi.c +10
-0+dev_err (rpi->dev,"Failed to initialize pllb, %ld\n" , +PTR_ERR (hw)); +return hw; + } + + hw =raspberrypi_register_pllb_arm (rpi); +if (IS_ERR (hw)) +return hw; + +return hw;
Why the double return? Not just
return raspberrypi_register_pllb_arm(rpi);
drivers/clk/bcm/clk-raspberrypi.c static struct clk_hw *raspberrypi_register_pllb_arm(struct raspberrypi_clk *rpi) · line 335
Quoted 11 lines
drivers/clk/bcm/clk-raspberrypi.c +11
-0+ } + + data =devm_kzalloc (rpi->dev,sizeof (data),GFP_KERNEL ); +if (!data) +return ERR_PTR (-ENOMEM ); + data->rpi = rpi; + data->id = id; + + init.name =devm_kasprintf (rpi->dev,GFP_KERNEL ,"fw-clk-%u" , id); + init.ops = &raspberrypi_firmware_clk_ops; + init.flags =CLK_GET_RATE_NOCACHE |CLK_IGNORE_UNUSED ;
Why ignore unused? Doesn't seem to support enable/disable anyway so not sure this flag adds any value.
Quoted 8 lines
drivers/clk/bcm/clk-raspberrypi.c +8
-0+ + data->hw.init = &init; + + ret =devm_clk_hw_register (rpi->dev, &data->hw); +if (ret) +return ERR_PTR (ret); + +return &data->hw;
drivers/clk/bcm/clk-raspberrypi.c static struct clk_hw *raspberrypi_register_pllb_arm(struct raspberrypi_clk *rpi) · line 353
Quoted 10 lines
drivers/clk/bcm/clk-raspberrypi.c +10
-0+} + +static int raspberrypi_discover_clocks (struct raspberrypi_clk *rpi, +struct clk_hw_onecell_data *data) +{ +struct rpi_firmware_get_clocks_response *clks; +size_t clks_size =NUM_FW_CLKS *sizeof (*clks); +int ret; + + clks =devm_kzalloc (rpi->dev, clks_size,GFP_KERNEL );
Use devm_kcalloc to avoid overflow and indicate it's an array.
Quoted 31 lines
drivers/clk/bcm/clk-raspberrypi.c +23
-0+if (!clks) +return -ENOMEM ; + + ret =rpi_firmware_property (rpi->firmware,RPI_FIRMWARE_GET_CLOCKS , + clks, clks_size); +if (ret) +return ret; + +while (clks->id) { +struct clk_hw *hw; + + hw =raspberrypi_clk_register (rpi, clks->parent, clks->id); +if (IS_ERR (hw)) +return PTR_ERR (hw); + + data->hws[clks->id] = hw; + data->num = clks->id +1 ; + clks++; + } + +return 0 ; +} +static int raspberrypi_clk_probe (struct platform_device *pdev) {struct clk_hw_onecell_data *clk_data;include/soc/bcm2835/raspberrypi-firmware.h +0
-0
include/soc/bcm2835/raspberrypi-firmware.h enum rpi_firmware_property_tag { · line 140
Quoted 6 lines
include/soc/bcm2835/raspberrypi-firmware.h +3
-0@@ -135,6 +135,11 @@ enum rpi_firmware_property_tag { RPI_FIRMWARE_GET_DMA_CHANNELS = 0x00060001, }; +struct rpi_firmware_get_clocks_response { +__le32 parent; +__le32 id;
Why double spaced or tabbed out?
include/soc/bcm2835/raspberrypi-firmware.h enum rpi_firmware_property_tag { · line 144
Quoted 4 lines
include/soc/bcm2835/raspberrypi-firmware.h +2
-0+}; +#if IS_ENABLED (CONFIG_RASPBERRYPI_FIRMWARE ) int rpi_firmware_property(struct rpi_firmware *fw,
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 23/89 ARM: dts: bcm2711: Add firmware clocks node
In reply to Maxime RipardNow that we have a clock driver for the clocks exposed by the firmware, let's add the device tree nodes for it.
--- arch/arm/boot/dts/bcm2711.dtsi | 6 ++++++ 1 file changed, 6 insertions(+)
arch/arm/boot/dts/bcm2711.dtsi +6 -0
@@ -12,6 +12,12 @@ interrupt-parent = <&gicv2>; + firmware_clocks: firmware-clocks { + compatible = "raspberrypi,firmware-clocks"; + raspberrypi,firmware = <&firmware>; + #clock-cells = <1>; + }; + soc { /* * Defined ranges:
Signature · 1 line
git-series 0.9.1
PATCH 24/89 reset: Move reset-simple header out of drivers/reset
In reply to Maxime RipardThe reset-simple code can be useful for drivers outside of drivers/reset that have a few reset controls as part of their features. Let's move it to include/linux/reset.
--- drivers/reset/reset-simple.c | 3 +-- drivers/reset/reset-simple.h | 41 +------------------------------ drivers/reset/reset-socfpga.c | 3 +-- drivers/reset/reset-sunxi.c | 3 +-- drivers/reset/reset-uniphier-glue.c | 3 +-- include/linux/reset/reset-simple.h | 41 ++++++++++++++++++++++++++++++- 6 files changed, 45 insertions(+), 49 deletions(-) delete mode 100644 drivers/reset/reset-simple.h create mode 100644 include/linux/reset/reset-simple.h
drivers/reset/reset-simple.c +1 -2
@@ -18,10 +18,9 @@#include <linux/of_device.h> #include <linux/platform_device.h> #include <linux/reset-controller.h> +#include <linux/reset/reset-simple.h> #include <linux/spinlock.h> -#include "reset-simple.h" -static inline struct reset_simple_data *to_reset_simple_data (struct reset_controller_dev *rcdev) {
drivers/reset/reset-simple.h deleted +0 -41
41 lines not on this page · raw message
drivers/reset/reset-socfpga.c +1 -2
@@ -11,13 +11,12 @@#include <linux/of_address.h> #include <linux/platform_device.h> #include <linux/reset-controller.h> +#include <linux/reset/reset-simple.h> #include <linux/reset/socfpga.h> #include <linux/slab.h> #include <linux/spinlock.h> #include <linux/types.h> -#include "reset-simple.h" -#define SOCFPGA_NR_BANKS 8static int a10_reset_init (struct device_node *np)
drivers/reset/reset-sunxi.c +1 -2
@@ -14,13 +14,12 @@#include <linux/of_address.h> #include <linux/platform_device.h> #include <linux/reset-controller.h> +#include <linux/reset/reset-simple.h> #include <linux/reset/sunxi.h> #include <linux/slab.h> #include <linux/spinlock.h> #include <linux/types.h> -#include "reset-simple.h" -static int sunxi_reset_init (struct device_node *np) {struct reset_simple_data *data;
drivers/reset/reset-uniphier-glue.c +1 -2
@@ -9,8 +9,7 @@#include <linux/of_device.h> #include <linux/platform_device.h> #include <linux/reset.h> - -#include "reset-simple.h" +#include <linux/reset/reset-simple.h> #define MAX_CLKS 2#define MAX_RSTS 2
include/linux/reset/reset-simple.h new file +41 -0
41 lines not on this page · raw message
Signature · 1 line
git-series 0.9.1
PATCH 25/89 reset: simple: Add reset callback
In reply to Maxime RipardThe reset-simple code lacks a reset callback that is still pretty easy to implement. The only real thing to consider is the delay needed for a device to be reset, so let's expose that as part of the reset-simple driver data.
--- drivers/reset/reset-simple.c | 21 +++++++++++++++++++++ include/linux/reset/reset-simple.h | 4 ++++ 2 files changed, 25 insertions(+)
drivers/reset/reset-simple.c +21 -0
@@ -11,6 +11,7 @@* Maxime Ripard <[email protected]> */ +#include <linux/delay.h> #include <linux/device.h> #include <linux/err.h> #include <linux/io.h>
@@ -63,6 +64,25 @@ static int reset_simple_deassert(struct reset_controller_dev *rcdev,return reset_simple_update (rcdev, id, false); } +static int reset_simple_reset (struct reset_controller_dev *rcdev, +unsigned long id) +{ +struct reset_simple_data *data =to_reset_simple_data (rcdev); +int ret; + + ret =reset_simple_assert (rcdev, id); +if (ret) +return ret; + +mdelay (data->reset_ms); + + ret =reset_simple_deassert (rcdev, id); +if (ret) +return ret; + +return 0 ; +} +static int reset_simple_status (struct reset_controller_dev *rcdev,unsigned long id) {
@@ -80,6 +100,7 @@ static int reset_simple_status(struct reset_controller_dev *rcdev,const struct reset_control_ops reset_simple_ops = { .assert = reset_simple_assert, .deassert = reset_simple_deassert, + .reset = reset_simple_reset, .status = reset_simple_status, };EXPORT_SYMBOL_GPL (reset_simple_ops);
include/linux/reset/reset-simple.h +4 -0
@@ -27,6 +27,9 @@* @status_active_low: if true, bits read back as cleared while the reset is * asserted. Otherwise, bits read back as set while the * reset is asserted. +* @reset_ms: Minimum delay in milliseconds needed that needs to be +* waited for between an assert and a deassert to reset the +* device. */ struct reset_simple_data {spinlock_t lock;
@@ -34,6 +37,7 @@ struct reset_simple_data {struct reset_controller_dev rcdev;bool active_low;bool status_active_low; +unsigned int reset_ms; };extern const struct reset_control_ops reset_simple_ops;
Signature · 1 line
git-series 0.9.1
Philipp Zabel
maintainerRe: [PATCH 25/89] reset: simple: Add reset callback
Hi Maxime,
Quoted 6 lines · Maxime Ripard
The reset-simple code lacks a reset callback that is still pretty easy to implement. The only real thing to consider is the delay needed for a device to be reset, so let's expose that as part of the reset-simple driver data.
Cc Philipp Zabel <[email protected]>Signed-off-by Maxime Ripard <[email protected]>
This shoulod be done in such a way that simple reset drivers which do not set the reset delay continue to return -ENOTSUPP from reset_control_reset().
Quoted 18 lines
--- drivers/reset/reset-simple.c | 21 +++++++++++++++++++++ include/linux/reset/reset-simple.h | 4 ++++ 2 files changed, 25 insertions(+)drivers/reset/reset-simple.c +1
-0@@ -11,6 +11,7 @@* Maxime Ripard <[email protected]> */ +#include <linux/delay.h> #include <linux/device.h> #include <linux/err.h> #include <linux/io.h>
drivers/reset/reset-simple.c static int reset_simple_deassert(struct reset_controller_dev *rcdev, · line 71
Quoted 8 lines
drivers/reset/reset-simple.c +5
-0@@ -63,6 +64,25 @@ static int reset_simple_deassert(struct reset_controller_dev *rcdev,return reset_simple_update (rcdev, id, false); } +static int reset_simple_reset (struct reset_controller_dev *rcdev, +unsigned long id) +{ +struct reset_simple_data *data =to_reset_simple_data (rcdev); +int ret;
You could just return -ENOTSUPP here if data->reset_ms == 0.
drivers/reset/reset-simple.c static int reset_simple_deassert(struct reset_controller_dev *rcdev, · line 77
Quoted 5 lines
drivers/reset/reset-simple.c +5
-0+ ret =reset_simple_assert (rcdev, id); +if (ret) +return ret; + +mdelay (data->reset_ms);
Have you considered specifying the delay in microseconds instead? That would allow to use usleep_range() for shorter delays.
Quoted 23 lines
drivers/reset/reset-simple.c +8
-0+ ret =reset_simple_deassert (rcdev, id); +if (ret) +return ret; + +return 0 ; +} +static int reset_simple_status (struct reset_controller_dev *rcdev,unsigned long id) {@@ -80,6 +100,7 @@ static int reset_simple_status(struct reset_controller_dev *rcdev,const struct reset_control_ops reset_simple_ops = { .assert = reset_simple_assert, .deassert = reset_simple_deassert, + .reset = reset_simple_reset, .status = reset_simple_status, };EXPORT_SYMBOL_GPL (reset_simple_ops);include/linux/reset/reset-simple.h +0
-0
include/linux/reset/reset-simple.h line 32
Quoted 6 lines
include/linux/reset/reset-simple.h +3
-0@@ -27,6 +27,9 @@* @status_active_low: if true, bits read back as cleared while the reset is * asserted. Otherwise, bits read back as set while the * reset is asserted. +* @reset_ms: Minimum delay in milliseconds needed that needs to be +* waited for between an assert and a deassert to reset the +* device.
If multiple consumers with different delay requirements are connected to this reset controllers, this must the largest minimum delay. Could you add mention for this in the comment?
regards
Philipp
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 26/89 dt-bindings: clock: Add BCM2711 DVP binding
In reply to Maxime RipardThe BCM2711 has a unit controlling the HDMI0 and HDMI1 clock and reset signals. Let's add a binding for it.
--- Documentation/devicetree/bindings/clock/brcm,bcm2711-dvp.yaml | 47 +++++++- 1 file changed, 47 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/brcm,bcm2711-dvp.yaml
Documentation/devicetree/bindings/clock/brcm,bcm2711-dvp.yaml new file +47 -0
@@ -0,0 +1,47 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/clock/brcm,bcm2711-dvp.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Broadcom BCM2711 HDMI DVP Device Tree Bindings + +maintainers: + - Maxime Ripard <[email protected]> + +properties: + "#clock-cells": + const: 1 + + "#reset-cells": + const: 1 + + compatible: + const: brcm,brcm2711-dvp + + reg: + maxItems: 1 + + clocks: + maxItems: 1 + +required: + - "#clock-cells" + - "#reset-cells" + - compatible + - reg + - clocks + +additionalProperties: false + +examples: + - | + dvp: clock@7ef00000 { + compatible = "brcm,brcm2711-dvp"; + reg = <0x7ef00000 0x10>; + clocks = <&clk_108MHz>; + #clock-cells = <1>; + #reset-cells = <1>; + }; + +...
Signature · 1 line
git-series 0.9.1
Re: [PATCH 26/89] dt-bindings: clock: Add BCM2711 DVP binding
Quoted 12 lines · Maxime Ripard
The BCM2711 has a unit controlling the HDMI0 and HDMI1 clock and reset signals. Let's add a binding for it.
Cc Philipp Zabel <[email protected]>Cc Rob Herring <[email protected]>Signed-off-by Maxime Ripard <[email protected]>--- Documentation/devicetree/bindings/clock/brcm,bcm2711-dvp.yaml | 47 +++++++- 1 file changed, 47 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/brcm,bcm2711-dvp.yaml
PATCH 27/89 clk: bcm: Add BCM2711 DVP driver
In reply to Maxime RipardThe HDMI block has a block that controls clocks and reset signals to the HDMI0 and HDMI1 controllers.
Let's expose that through a clock driver implementing a clock and reset provider.
--- drivers/clk/bcm/Kconfig | 1 +- drivers/clk/bcm/Makefile | 1 +- drivers/clk/bcm/clk-bcm2711-dvp.c | 113 +++++++++++++++++++++++++++++++- 3 files changed, 115 insertions(+) create mode 100644 drivers/clk/bcm/clk-bcm2711-dvp.c
drivers/clk/bcm/Kconfig +1 -0
@@ -4,6 +4,7 @@ config CLK_BCM2835 depends on ARCH_BCM2835 || ARCH_BRCMSTB || COMPILE_TEST depends on COMMON_CLK default ARCH_BCM2835 || ARCH_BRCMSTB + select RESET_SIMPLE help Enable common clock framework support for Broadcom BCM2835 SoCs.
drivers/clk/bcm/Makefile +1 -0
@@ -6,6 +6,7 @@ obj-$(CONFIG_CLK_BCM_KONA) += clk-kona-setup.o obj-$(CONFIG_CLK_BCM_KONA) += clk-bcm281xx.o obj-$(CONFIG_CLK_BCM_KONA) += clk-bcm21664.o obj-$(CONFIG_COMMON_CLK_IPROC) += clk-iproc-armpll.o clk-iproc-pll.o clk-iproc-asiu.o +obj-$(CONFIG_CLK_BCM2835) += clk-bcm2711-dvp.o obj-$(CONFIG_CLK_BCM2835) += clk-bcm2835.o obj-$(CONFIG_CLK_BCM2835) += clk-bcm2835-aux.o obj-$(CONFIG_CLK_RASPBERRYPI) += clk-raspberrypi.o
drivers/clk/bcm/clk-bcm2711-dvp.c new file +113 -0
113 lines not on this page · raw message
Signature · 1 line
git-series 0.9.1
Stephen Boyd
maintainerRe: [PATCH 27/89] clk: bcm: Add BCM2711 DVP driver
Quoting Maxime Ripard (2020-02-24 01:06:29)
Quoted 63 lines
drivers/clk/bcm/clk-bcm2711-dvp.c new file +57
-0@@ -0,0 +1,113 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +// Copyright 2020 Cerno + +#include <linux/clk-provider.h> +#include <linux/module.h> +#include <linux/platform_device.h> +#include <linux/reset-controller.h> +#include <linux/reset/reset-simple.h> + +#define DVP_HT_RPI_SW_INIT 0x04 +#define DVP_HT_RPI_MISC_CONFIG 0x08 + +#define NR_CLOCKS 2 +#define NR_RESETS 6 + +struct clk_dvp { +struct clk *clks[NR_CLOCKS ]; +struct clk_onecell_data clk_data; +struct reset_simple_data reset; +}; + +static int clk_dvp_probe (struct platform_device *pdev) +{ +struct resource *res; +struct clk_dvp *dvp; +void __iomem *base; +const char *parent; +int ret; + + dvp =devm_kzalloc (&pdev->dev,sizeof (*dvp),GFP_KERNEL ); +if (!dvp) +return -ENOMEM ; +platform_set_drvdata (pdev, dvp); + + res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); + base =devm_ioremap_resource (&pdev->dev, res); +if (IS_ERR (base)) +return PTR_ERR (base); + + dvp->reset.rcdev.owner =THIS_MODULE ; + dvp->reset.rcdev.nr_resets =NR_RESETS ; + dvp->reset.rcdev.ops = &reset_simple_ops; + dvp->reset.rcdev.of_node = pdev->dev.of_node; + dvp->reset.membase = base +DVP_HT_RPI_SW_INIT ; +spin_lock_init (&dvp->reset.lock); + + ret =reset_controller_register (&dvp->reset.rcdev); +if (ret) +return ret; + + parent =of_clk_get_parent_name (pdev->dev.of_node,0 ); +if (!parent) + goto unregister_reset; + + dvp->clks[0] = clk_register_gate(&pdev->dev, "hdmi0-108MHz", + parent, CLK_IS_CRITICAL, + base + DVP_HT_RPI_MISC_CONFIG, 3,
drivers/clk/bcm/clk-bcm2711-dvp.c line 67
Quoted 10 lines
drivers/clk/bcm/clk-bcm2711-dvp.c new file +10
-0+ CLK_GATE_SET_TO_DISABLE, &dvp->reset.lock); +if (IS_ERR (dvp->clks[0 ])) { + ret =PTR_ERR (dvp->clks[0 ]); + goto unregister_reset; + } + + dvp->clks[1 ] =clk_register_gate (&pdev->dev,"hdmi1-108MHz" , + parent,CLK_IS_CRITICAL , + base +DVP_HT_RPI_MISC_CONFIG ,4 , +CLK_GATE_SET_TO_DISABLE , &dvp->reset.lock);
Can we use clk_hw APIs, document why CLK_IS_CRITICAL, and use something like clk_hw_register_gate_parent_data() so that we don't have to use of_clk_get_parent_name() above?
drivers/clk/bcm/clk-bcm2711-dvp.c line 76
Quoted 9 lines
drivers/clk/bcm/clk-bcm2711-dvp.c new file +9
-0+if (IS_ERR (dvp->clks[1 ])) { + ret =PTR_ERR (dvp->clks[1 ]); + goto unregister_clk0; + } + + dvp->clk_data.clks = dvp->clks; + dvp->clk_data.clk_num =NR_CLOCKS ; +of_clk_add_provider (pdev->dev.of_node, of_clk_src_onecell_get, + &dvp->clk_data);
This can fail. Please recover. Also, please use clk_hw based APIs.
Quoted 16 lines
drivers/clk/bcm/clk-bcm2711-dvp.c new file +16
-0+ +return 0 ; + + +unregister_clk0: +clk_unregister_gate (dvp->clks[0 ]); + +unregister_reset: +reset_controller_unregister (&dvp->reset.rcdev); +return ret; +}; + +static int clk_dvp_remove (struct platform_device *pdev) +{ +struct clk_dvp *dvp =platform_get_drvdata (pdev); +
drivers/clk/bcm/clk-bcm2711-dvp.c line 102
Quoted 10 lines
drivers/clk/bcm/clk-bcm2711-dvp.c new file +10
-0+clk_unregister_gate (dvp->clks[1 ]); +clk_unregister_gate (dvp->clks[0 ]); +reset_controller_unregister (&dvp->reset.rcdev); + +return 0 ; +} + +static const struct of_device_id clk_dvp_dt_ids[] = { + { .compatible ="brcm,brcm2711-dvp" , }, + {/* sentinel */ },
Please drop comma after this so we can't put anything after lest it cause a compiler error.
Quoted 13 lines
drivers/clk/bcm/clk-bcm2711-dvp.c new file +11
-0+}; + +static struct platform_driver clk_dvp_driver = { + .probe = clk_dvp_probe, + .remove = clk_dvp_remove, + .driver = { + .name ="brcm2711-dvp" , + .of_match_table = clk_dvp_dt_ids, + }, +}; +module_platform_driver (clk_dvp_driver);Signature · 1 line
git-series 0.9.1
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 27/89] clk: bcm: Add BCM2711 DVP driver
Hi Stephen,
Quoted 8 lines · Stephen Boyd
drivers/clk/bcm/clk-bcm2711-dvp.c line 67
Quoted 4 lines
drivers/clk/bcm/clk-bcm2711-dvp.c new file +4
-0+ dvp->clks[1 ] =clk_register_gate (&pdev->dev,"hdmi1-108MHz" , + parent,CLK_IS_CRITICAL , + base +DVP_HT_RPI_MISC_CONFIG ,4 , +CLK_GATE_SET_TO_DISABLE , &dvp->reset.lock);Can we use
clk_hwAPIs, document whyCLK_IS_CRITICAL, and use something likeclk_hw_register_gate_parent_data()so that we don't have to useof_clk_get_parent_name()above?
That function is new to me, and I'm not sure how I'm supposed to use it?
It looks like clk_hw_register_gate, clk_hw_register_gate_parent_hw and clk_hw_register_gate_parent_data all call __clk_hw_register_gate with the same arguments, each expecting the parent_name, so they look equivalent?
It looks like the original intent was to have the parent name, clk_hw or clk_parent_data as argument, but the macro itself was copy pasted without changing the arguments it's calling __clk_hw_register_gate with?
Maxime
Stephen Boyd
maintainerRe: [PATCH 27/89] clk: bcm: Add BCM2711 DVP driver
Quoting Maxime Ripard (2020-03-23 03:56:16)
Quoted 19 lines
Hi Stephen,
Quoted 8 lines · Stephen Boyd
drivers/clk/bcm/clk-bcm2711-dvp.c line 67
Quoted 4 lines
drivers/clk/bcm/clk-bcm2711-dvp.c new file +4
-0+ dvp->clks[1 ] =clk_register_gate (&pdev->dev,"hdmi1-108MHz" , + parent,CLK_IS_CRITICAL , + base +DVP_HT_RPI_MISC_CONFIG ,4 , +CLK_GATE_SET_TO_DISABLE , &dvp->reset.lock);Can we use
clk_hwAPIs, document whyCLK_IS_CRITICAL, and use something likeclk_hw_register_gate_parent_data()so that we don't have to useof_clk_get_parent_name()above?That function is new to me, and I'm not sure how I'm supposed to use it?
It looks like
clk_hw_register_gate,clk_hw_register_gate_parent_hwandclk_hw_register_gate_parent_dataall call__clk_hw_register_gatewith the same arguments, each expecting theparent_name, so they look equivalent?
Quoted 5 lines
It looks like the original intent was to have the parent name,
clk_hworclk_parent_dataas argument, but the macro itself was copy pasted without changing the arguments it's calling__clk_hw_register_gatewith?
Yeah! It looks like nobody has tried to use it yet so you've come across that problem where nobody reviews things and I just merge it anyway. I'll send a fix shortly.
PATCH 28/89 ARM: dts: bcm2711: Add HDMI DVP
In reply to Maxime RipardNow that we have a driver for the DVP, let's add its DT node.
--- arch/arm/boot/dts/bcm2711.dtsi | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
arch/arm/boot/dts/bcm2711.dtsi +16 -0
@@ -12,6 +12,14 @@ interrupt-parent = <&gicv2>; + + clk_108MHz: clk-108M { + #clock-cells = <0>; + compatible = "fixed-clock"; + clock-frequency = <108000000>; + clock-output-names = "108MHz-clock"; + }; + firmware_clocks: firmware-clocks { compatible = "raspberrypi,firmware-clocks"; raspberrypi,firmware = <&firmware>;
@@ -258,6 +266,14 @@ hvs@7e400000 { interrupts = <GIC_SPI 97 IRQ_TYPE_LEVEL_HIGH>; }; + + dvp: clock@7ef00000 { + compatible = "brcm,brcm2711-dvp"; + reg = <0x7ef00000 0x10>; + clocks = <&clk_108MHz>; + #clock-cells = <1>; + #reset-cells = <1>; + }; }; arm-pmu {
Signature · 1 line
git-series 0.9.1
PATCH 29/89 dt-bindings: display: Convert VC4 bindings to schemas
In reply to Maxime RipardThe BCM283x SoCs have a display pipeline composed of several controllers with device tree bindings that are supported by Linux.
Now that we have the DT validation in place, let's split into separate files and convert the device tree bindings for those controllers to schemas.
--- Documentation/devicetree/bindings/display/brcm,bcm-vc4.txt | 174 +------------------------------------------------------------------------ Documentation/devicetree/bindings/display/brcm,bcm2835-dpi.yaml | 66 +++++++++++++++++++++++++++- Documentation/devicetree/bindings/display/brcm,bcm2835-dsi0.yaml | 73 ++++++++++++++++++++++++++++++- Documentation/devicetree/bindings/display/brcm,bcm2835-hdmi.yaml | 75 +++++++++++++++++++++++++++++++- Documentation/devicetree/bindings/display/brcm,bcm2835-hvs.yaml | 37 +++++++++++++++- Documentation/devicetree/bindings/display/brcm,bcm2835-pixelvalve0.yaml | 40 +++++++++++++++++- Documentation/devicetree/bindings/display/brcm,bcm2835-txp.yaml | 37 +++++++++++++++- Documentation/devicetree/bindings/display/brcm,bcm2835-v3d.yaml | 42 +++++++++++++++++- Documentation/devicetree/bindings/display/brcm,bcm2835-vc4.yaml | 34 ++++++++++++++- Documentation/devicetree/bindings/display/brcm,bcm2835-vec.yaml | 44 ++++++++++++++++++- MAINTAINERS | 2 +- 11 files changed, 449 insertions(+), 175 deletions(-) delete mode 100644 Documentation/devicetree/bindings/display/brcm,bcm-vc4.txt create mode 100644 Documentation/devicetree/bindings/display/brcm,bcm2835-dpi.yaml create mode 100644 Documentation/devicetree/bindings/display/brcm,bcm2835-dsi0.yaml create mode 100644 Documentation/devicetree/bindings/display/brcm,bcm2835-hdmi.yaml create mode 100644 Documentation/devicetree/bindings/display/brcm,bcm2835-hvs.yaml create mode 100644 Documentation/devicetree/bindings/display/brcm,bcm2835-pixelvalve0.yaml create mode 100644 Documentation/devicetree/bindings/display/brcm,bcm2835-txp.yaml create mode 100644 Documentation/devicetree/bindings/display/brcm,bcm2835-v3d.yaml create mode 100644 Documentation/devicetree/bindings/display/brcm,bcm2835-vc4.yaml create mode 100644 Documentation/devicetree/bindings/display/brcm,bcm2835-vec.yaml
Documentation/devicetree/bindings/display/brcm,bcm-vc4.txt deleted +0 -174
@@ -1,174 +0,0 @@ -Broadcom VC4 (VideoCore4) GPU - -The VC4 device present on the Raspberry Pi includes a display system -with HDMI output and the HVS (Hardware Video Scaler) for compositing -display planes. - -Required properties for VC4: -- compatible: Should be "brcm,bcm2835-vc4" or "brcm,cygnus-vc4" - -Required properties for Pixel Valve: -- compatible: Should be one of "brcm,bcm2835-pixelvalve0", - "brcm,bcm2835-pixelvalve1", or "brcm,bcm2835-pixelvalve2" -- reg: Physical base address and length of the PV's registers -- interrupts: The interrupt number - See bindings/interrupt-controller/brcm,bcm2835-armctrl-ic.txt - -Required properties for HVS: -- compatible: Should be "brcm,bcm2835-hvs" -- reg: Physical base address and length of the HVS's registers -- interrupts: The interrupt number - See bindings/interrupt-controller/brcm,bcm2835-armctrl-ic.txt - -Required properties for HDMI -- compatible: Should be "brcm,bcm2835-hdmi" -- reg: Physical base address and length of the two register ranges - ("HDMI" and "HD", in that order) -- interrupts: The interrupt numbers - See bindings/interrupt-controller/brcm,bcm2835-armctrl-ic.txt -- ddc: phandle of the I2C controller used for DDC EDID probing -- clocks: a) hdmi: The HDMI state machine clock - b) pixel: The pixel clock. - -Optional properties for HDMI: -- hpd-gpios: The GPIO pin for HDMI hotplug detect (if it doesn't appear - as an interrupt/status bit in the HDMI controller - itself). See bindings/pinctrl/brcm,bcm2835-gpio.txt -- dmas: Should contain one entry pointing to the DMA channel used to - transfer audio data -- dma-names: Should contain "audio-rx" - -Required properties for DPI: -- compatible: Should be "brcm,bcm2835-dpi" -- reg: Physical base address and length of the registers -- clocks: a) core: The core clock the unit runs on - b) pixel: The pixel clock that feeds the pixelvalve -- port: Port node with a single endpoint connecting to the panel - device, as defined in [1] - -Required properties for VEC: -- compatible: Should be "brcm,bcm2835-vec" -- reg: Physical base address and length of the registers -- clocks: The core clock the unit runs on -- interrupts: The interrupt number - See bindings/interrupt-controller/brcm,bcm2835-armctrl-ic.txt - -Required properties for V3D: -- compatible: Should be "brcm,bcm2835-v3d" or "brcm,cygnus-v3d" -- reg: Physical base address and length of the V3D's registers -- interrupts: The interrupt number - See bindings/interrupt-controller/brcm,bcm2835-armctrl-ic.txt - -Optional properties for V3D: -- clocks: The clock the unit runs on - -Required properties for DSI: -- compatible: Should be "brcm,bcm2835-dsi0" or "brcm,bcm2835-dsi1" -- reg: Physical base address and length of the DSI block's registers -- interrupts: The interrupt number - See bindings/interrupt-controller/brcm,bcm2835-armctrl-ic.txt -- clocks: a) phy: The DSI PLL clock feeding the DSI analog PHY - b) escape: The DSI ESC clock from CPRMAN - c) pixel: The DSI pixel clock from CPRMAN -- clock-output-names: - The 3 clocks output from the DSI analog PHY: dsi[01]_byte, - dsi[01]_ddr2, and dsi[01]_ddr - -Required properties for the TXP (writeback) block: -- compatible: Should be "brcm,bcm2835-txp" -- reg: Physical base address and length of the TXP block's registers -- interrupts: The interrupt number - See bindings/interrupt-controller/brcm,bcm2835-armctrl-ic.txt - -[1] Documentation/devicetree/bindings/media/video-interfaces.txt - -Example: -pixelvalve@7e807000 { - compatible = "brcm,bcm2835-pixelvalve2"; - reg = <0x7e807000 0x100>; - interrupts = <2 10>; /* pixelvalve */ -}; - -hvs@7e400000 { - compatible = "brcm,bcm2835-hvs"; - reg = <0x7e400000 0x6000>; - interrupts = <2 1>; -}; - -hdmi: hdmi@7e902000 { - compatible = "brcm,bcm2835-hdmi"; - reg = <0x7e902000 0x600>, - <0x7e808000 0x100>; - interrupts = <2 8>, <2 9>; - ddc = <&i2c2>; - hpd-gpios = <&gpio 46 GPIO_ACTIVE_HIGH>; - clocks = <&clocks BCM2835_PLLH_PIX>, - <&clocks BCM2835_CLOCK_HSM>; - clock-names = "pixel", "hdmi"; -}; - -dpi: dpi@7e208000 { - compatible = "brcm,bcm2835-dpi"; - reg = <0x7e208000 0x8c>; - clocks = <&clocks BCM2835_CLOCK_VPU>, - <&clocks BCM2835_CLOCK_DPI>; - clock-names = "core", "pixel"; - #address-cells = <1>; - #size-cells = <0>; - - port { - dpi_out: endpoint@0 { - remote-endpoint = <&panel_in>; - }; - }; -}; - -dsi1: dsi@7e700000 { - compatible = "brcm,bcm2835-dsi1"; - reg = <0x7e700000 0x8c>; - interrupts = <2 12>; - #address-cells = <1>; - #size-cells = <0>; - #clock-cells = <1>; - - clocks = <&clocks BCM2835_PLLD_DSI1>, - <&clocks BCM2835_CLOCK_DSI1E>, - <&clocks BCM2835_CLOCK_DSI1P>; - clock-names = "phy", "escape", "pixel"; - - clock-output-names = "dsi1_byte", "dsi1_ddr2", "dsi1_ddr"; - - pitouchscreen: panel@0 { - compatible = "raspberrypi,touchscreen"; - reg = <0>; - - <...> - }; -}; - -vec: vec@7e806000 { - compatible = "brcm,bcm2835-vec"; - reg = <0x7e806000 0x1000>; - clocks = <&clocks BCM2835_CLOCK_VEC>; - interrupts = <2 27>; -}; - -v3d: v3d@7ec00000 { - compatible = "brcm,bcm2835-v3d"; - reg = <0x7ec00000 0x1000>; - interrupts = <1 10>; -}; - -vc4: gpu { - compatible = "brcm,bcm2835-vc4"; -}; - -panel: panel { - compatible = "ontat,yx700wv03", "simple-panel"; - - port { - panel_in: endpoint { - remote-endpoint = <&dpi_out>; - }; - }; -};
Documentation/devicetree/bindings/display/brcm,bcm2835-dpi.yaml new file +66 -0
66 lines not on this page · raw message
Documentation/devicetree/bindings/display/brcm,bcm2835-dsi0.yaml new file +73 -0
73 lines not on this page · raw message
Documentation/devicetree/bindings/display/brcm,bcm2835-hdmi.yaml new file +75 -0
75 lines not on this page · raw message
Documentation/devicetree/bindings/display/brcm,bcm2835-hvs.yaml new file +37 -0
@@ -0,0 +1,37 @@ +# SPDX-License-Identifier: GPL-2.0 +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/display/brcm,bcm2835-hvs.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Broadcom VC4 (VideoCore4) Hardware Video Scaler + +maintainers: + - Eric Anholt <[email protected]> + +properties: + compatible: + const: brcm,bcm2835-hvs + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + +required: + - compatible + - reg + - interrupts + +additionalProperties: false + +examples: + - | + hvs@7e400000 { + compatible = "brcm,bcm2835-hvs"; + reg = <0x7e400000 0x6000>; + interrupts = <2 1>; + }; + +...
Documentation/devicetree/bindings/display/brcm,bcm2835-pixelvalve0.yaml new file +40 -0
@@ -0,0 +1,40 @@ +# SPDX-License-Identifier: GPL-2.0 +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/display/brcm,bcm2835-pixelvalve0.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Broadcom VC4 (VideoCore4) PixelValve + +maintainers: + - Eric Anholt <[email protected]> + +properties: + compatible: + enum: + - brcm,bcm2835-pixelvalve0 + - brcm,bcm2835-pixelvalve1 + - brcm,bcm2835-pixelvalve2 + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + +required: + - compatible + - reg + - interrupts + +additionalProperties: false + +examples: + - | + pixelvalve@7e807000 { + compatible = "brcm,bcm2835-pixelvalve2"; + reg = <0x7e807000 0x100>; + interrupts = <2 10>; /* pixelvalve */ + }; + +...
Documentation/devicetree/bindings/display/brcm,bcm2835-txp.yaml new file +37 -0
@@ -0,0 +1,37 @@ +# SPDX-License-Identifier: GPL-2.0 +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/display/brcm,bcm2835-txp.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Broadcom VC4 (VideoCore4) TXP (writeback) Controller + +maintainers: + - Eric Anholt <[email protected]> + +properties: + compatible: + const: brcm,bcm2835-txp + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + +required: + - compatible + - reg + - interrupts + +additionalProperties: false + +examples: + - | + txp: txp@7e004000 { + compatible = "brcm,bcm2835-txp"; + reg = <0x7e004000 0x20>; + interrupts = <1 11>; + }; + +...
Documentation/devicetree/bindings/display/brcm,bcm2835-v3d.yaml new file +42 -0
42 lines not on this page · raw message
Documentation/devicetree/bindings/display/brcm,bcm2835-vc4.yaml new file +34 -0
@@ -0,0 +1,34 @@ +# SPDX-License-Identifier: GPL-2.0 +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/display/brcm,bcm2835-vc4.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Broadcom VC4 (VideoCore4) GPU + +maintainers: + - Eric Anholt <[email protected]> + +description: > + The VC4 device present on the Raspberry Pi includes a display system + with HDMI output and the HVS (Hardware Video Scaler) for compositing + display planes. + +properties: + compatible: + enum: + - brcm,bcm2835-vc4 + - brcm,cygnus-vc4 + +required: + - compatible + +additionalProperties: false + +examples: + - | + vc4: gpu { + compatible = "brcm,bcm2835-vc4"; + }; + +...
Documentation/devicetree/bindings/display/brcm,bcm2835-vec.yaml new file +44 -0
44 lines not on this page · raw message
MAINTAINERS +1 -1
@@ -5698,7 +5698,7 @@ T: git git://github.com/anholt/linux S: Supported F: drivers/gpu/drm/vc4/ F: include/uapi/drm/vc4_drm.h -F: Documentation/devicetree/bindings/display/brcm,bcm-vc4.txt +F: Documentation/devicetree/bindings/display/brcm,bcm2835-*.yaml T: git git://anongit.freedesktop.org/drm/drm-misc DRM DRIVERS FOR VIVANTE GPU IP
Signature · 1 line
git-series 0.9.1
Rob Herring
maintainerRe: [PATCH 29/89] dt-bindings: display: Convert VC4 bindings to schemas
Quoted 25 lines · Maxime Ripard
The BCM283x SoCs have a display pipeline composed of several controllers with device tree bindings that are supported by Linux.
Now that we have the DT validation in place, let's split into separate files and convert the device tree bindings for those controllers to schemas.
Cc Rob Herring <[email protected]>Signed-off-by Maxime Ripard <[email protected]>--- Documentation/devicetree/bindings/display/brcm,bcm-vc4.txt | 174 +------------------------------------------------------------------------ Documentation/devicetree/bindings/display/brcm,bcm2835-dpi.yaml | 66 +++++++++++++++++++++++++++- Documentation/devicetree/bindings/display/brcm,bcm2835-dsi0.yaml | 73 ++++++++++++++++++++++++++++++- Documentation/devicetree/bindings/display/brcm,bcm2835-hdmi.yaml | 75 +++++++++++++++++++++++++++++++- Documentation/devicetree/bindings/display/brcm,bcm2835-hvs.yaml | 37 +++++++++++++++- Documentation/devicetree/bindings/display/brcm,bcm2835-pixelvalve0.yaml | 40 +++++++++++++++++- Documentation/devicetree/bindings/display/brcm,bcm2835-txp.yaml | 37 +++++++++++++++- Documentation/devicetree/bindings/display/brcm,bcm2835-v3d.yaml | 42 +++++++++++++++++- Documentation/devicetree/bindings/display/brcm,bcm2835-vc4.yaml | 34 ++++++++++++++- Documentation/devicetree/bindings/display/brcm,bcm2835-vec.yaml | 44 ++++++++++++++++++- MAINTAINERS | 2 +- 11 files changed, 449 insertions(+), 175 deletions(-) delete mode 100644 Documentation/devicetree/bindings/display/brcm,bcm-vc4.txt create mode 100644 Documentation/devicetree/bindings/display/brcm,bcm2835-dpi.yaml
Quoted 9 lines
create mode 100644 Documentation/devicetree/bindings/display/brcm,bcm2835-dsi0.yaml create mode 100644 Documentation/devicetree/bindings/display/brcm,bcm2835-hdmi.yaml create mode 100644 Documentation/devicetree/bindings/display/brcm,bcm2835-hvs.yaml create mode 100644 Documentation/devicetree/bindings/display/brcm,bcm2835-pixelvalve0.yaml create mode 100644 Documentation/devicetree/bindings/display/brcm,bcm2835-txp.yaml create mode 100644 Documentation/devicetree/bindings/display/brcm,bcm2835-v3d.yaml create mode 100644 Documentation/devicetree/bindings/display/brcm,bcm2835-vc4.yaml create mode 100644 Documentation/devicetree/bindings/display/brcm,bcm2835-vec.yaml
My bot found errors running 'make dt_binding_check' on your patch:
warning: no schema found in file: Documentation/devicetree/bindings/display/brcm,bcm2835-dsi0.yaml /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/display/brcm,bcm2835-dsi0.yaml: ignoring, error in schema: properties Documentation/devicetree/bindings/display/simple-framebuffer.example.dts:21.16-37.11: Warning (chosen_node_is_root): /example-0/chosen: chosen node must be at root node /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/display/brcm,bcm2835-dsi0.yaml: properties: '#clock-cells' is a dependency of 'clock-output-names' Documentation/devicetree/bindings/Makefile:12: recipe for target 'Documentation/devicetree/bindings/display/brcm,bcm2835-dsi0.example.dts' failed make[1]: *** [Documentation/devicetree/bindings/display/brcm,bcm2835-dsi0.example.dts] Error 1
Makefile:1263: recipe for target 'dt_binding_check' failed
make: *** [dt_binding_check] Error 2
See https://patchwork.ozlabs.org/patch/1242907
Please check and re-submit.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 29/89] dt-bindings: display: Convert VC4 bindings to schemas
Hi Rob,
Quoted 47 lines · Rob Herring
Quoted 25 lines · Maxime Ripard
The BCM283x SoCs have a display pipeline composed of several controllers with device tree bindings that are supported by Linux.
Now that we have the DT validation in place, let's split into separate files and convert the device tree bindings for those controllers to schemas.
Cc Rob Herring <[email protected]>Signed-off-by Maxime Ripard <[email protected]>--- Documentation/devicetree/bindings/display/brcm,bcm-vc4.txt | 174 +------------------------------------------------------------------------ Documentation/devicetree/bindings/display/brcm,bcm2835-dpi.yaml | 66 +++++++++++++++++++++++++++- Documentation/devicetree/bindings/display/brcm,bcm2835-dsi0.yaml | 73 ++++++++++++++++++++++++++++++- Documentation/devicetree/bindings/display/brcm,bcm2835-hdmi.yaml | 75 +++++++++++++++++++++++++++++++- Documentation/devicetree/bindings/display/brcm,bcm2835-hvs.yaml | 37 +++++++++++++++- Documentation/devicetree/bindings/display/brcm,bcm2835-pixelvalve0.yaml | 40 +++++++++++++++++- Documentation/devicetree/bindings/display/brcm,bcm2835-txp.yaml | 37 +++++++++++++++- Documentation/devicetree/bindings/display/brcm,bcm2835-v3d.yaml | 42 +++++++++++++++++- Documentation/devicetree/bindings/display/brcm,bcm2835-vc4.yaml | 34 ++++++++++++++- Documentation/devicetree/bindings/display/brcm,bcm2835-vec.yaml | 44 ++++++++++++++++++- MAINTAINERS | 2 +- 11 files changed, 449 insertions(+), 175 deletions(-) delete mode 100644 Documentation/devicetree/bindings/display/brcm,bcm-vc4.txt create mode 100644 Documentation/devicetree/bindings/display/brcm,bcm2835-dpi.yamlQuoted 9 lines
create mode 100644 Documentation/devicetree/bindings/display/brcm,bcm2835-dsi0.yaml create mode 100644 Documentation/devicetree/bindings/display/brcm,bcm2835-hdmi.yaml create mode 100644 Documentation/devicetree/bindings/display/brcm,bcm2835-hvs.yaml create mode 100644 Documentation/devicetree/bindings/display/brcm,bcm2835-pixelvalve0.yaml create mode 100644 Documentation/devicetree/bindings/display/brcm,bcm2835-txp.yaml create mode 100644 Documentation/devicetree/bindings/display/brcm,bcm2835-v3d.yaml create mode 100644 Documentation/devicetree/bindings/display/brcm,bcm2835-vc4.yaml create mode 100644 Documentation/devicetree/bindings/display/brcm,bcm2835-vec.yamlMy bot found errors running 'make
dt_binding_check' on your patch:warning: no schema found in file:
Documentation/devicetree/bindings/display/brcm,bcm2835-dsi0.yaml/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/display/brcm,bcm2835-dsi0.yaml: ignoring, error in schema: properties Documentation/devicetree/bindings/display/simple-framebuffer.example.dts:21.16-37.11: Warning (chosen_node_is_root): /example-0/chosen: chosen node must be at root node /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/display/brcm,bcm2835-dsi0.yaml: properties: '#clock-cells' is a dependency of 'clock-output-names'Documentation/devicetree/bindings/Makefile:12: recipe for target 'Documentation/devicetree/bindings/display/brcm,bcm2835-dsi0.example.dts' failed make[1]: *** [Documentation/devicetree/bindings/display/brcm,bcm2835-dsi0.example.dts] Error 1
Makefile:1263: recipe for target 'dt_binding_check' failed
make: *** [dt_binding_check] Error 2
Quoted 2 lines
See https://patchwork.ozlabs.org/patch/1242907
Please check and re-submit.
Yeah, that was fixed in patch 31 ("dt-bindings: display: vc4: dsi: Add missing clock properties"). I'm not quite sure what the preferred approach here would be: I did a conversion as is of the binding, and then fixed it, or do you prefer having it all in the same patch?
Maxime
Rob Herring
maintainerRe: [PATCH 29/89] dt-bindings: display: Convert VC4 bindings to schemas
Quoted 51 lines · Maxime Ripard
Hi Rob,
Quoted 47 lines · Rob Herring
Quoted 25 lines · Maxime Ripard
The BCM283x SoCs have a display pipeline composed of several controllers with device tree bindings that are supported by Linux.
Now that we have the DT validation in place, let's split into separate files and convert the device tree bindings for those controllers to schemas.
Cc Rob Herring <[email protected]>Signed-off-by Maxime Ripard <[email protected]>--- Documentation/devicetree/bindings/display/brcm,bcm-vc4.txt | 174 +------------------------------------------------------------------------ Documentation/devicetree/bindings/display/brcm,bcm2835-dpi.yaml | 66 +++++++++++++++++++++++++++- Documentation/devicetree/bindings/display/brcm,bcm2835-dsi0.yaml | 73 ++++++++++++++++++++++++++++++- Documentation/devicetree/bindings/display/brcm,bcm2835-hdmi.yaml | 75 +++++++++++++++++++++++++++++++- Documentation/devicetree/bindings/display/brcm,bcm2835-hvs.yaml | 37 +++++++++++++++- Documentation/devicetree/bindings/display/brcm,bcm2835-pixelvalve0.yaml | 40 +++++++++++++++++- Documentation/devicetree/bindings/display/brcm,bcm2835-txp.yaml | 37 +++++++++++++++- Documentation/devicetree/bindings/display/brcm,bcm2835-v3d.yaml | 42 +++++++++++++++++- Documentation/devicetree/bindings/display/brcm,bcm2835-vc4.yaml | 34 ++++++++++++++- Documentation/devicetree/bindings/display/brcm,bcm2835-vec.yaml | 44 ++++++++++++++++++- MAINTAINERS | 2 +- 11 files changed, 449 insertions(+), 175 deletions(-) delete mode 100644 Documentation/devicetree/bindings/display/brcm,bcm-vc4.txt create mode 100644 Documentation/devicetree/bindings/display/brcm,bcm2835-dpi.yamlQuoted 9 lines
create mode 100644 Documentation/devicetree/bindings/display/brcm,bcm2835-dsi0.yaml create mode 100644 Documentation/devicetree/bindings/display/brcm,bcm2835-hdmi.yaml create mode 100644 Documentation/devicetree/bindings/display/brcm,bcm2835-hvs.yaml create mode 100644 Documentation/devicetree/bindings/display/brcm,bcm2835-pixelvalve0.yaml create mode 100644 Documentation/devicetree/bindings/display/brcm,bcm2835-txp.yaml create mode 100644 Documentation/devicetree/bindings/display/brcm,bcm2835-v3d.yaml create mode 100644 Documentation/devicetree/bindings/display/brcm,bcm2835-vc4.yaml create mode 100644 Documentation/devicetree/bindings/display/brcm,bcm2835-vec.yamlMy bot found errors running 'make
dt_binding_check' on your patch:warning: no schema found in file:
Documentation/devicetree/bindings/display/brcm,bcm2835-dsi0.yaml/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/display/brcm,bcm2835-dsi0.yaml: ignoring, error in schema: properties Documentation/devicetree/bindings/display/simple-framebuffer.example.dts:21.16-37.11: Warning (chosen_node_is_root): /example-0/chosen: chosen node must be at root node /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/display/brcm,bcm2835-dsi0.yaml: properties: '#clock-cells' is a dependency of 'clock-output-names'Documentation/devicetree/bindings/Makefile:12: recipe for target 'Documentation/devicetree/bindings/display/brcm,bcm2835-dsi0.example.dts' failed make[1]: *** [Documentation/devicetree/bindings/display/brcm,bcm2835-dsi0.example.dts] Error 1
Makefile:1263: recipe for target 'dt_binding_check' failed
make: *** [dt_binding_check] Error 2
Quoted 7 lines
Quoted 2 lines
See https://patchwork.ozlabs.org/patch/1242907
Please check and re-submit.Yeah, that was fixed in patch 31 ("dt-bindings: display: vc4: dsi: Add missing clock properties"). I'm not quite sure what the preferred approach here would be: I did a conversion as is of the binding, and then fixed it, or do you prefer having it all in the same patch?
A note in this patch should be enough. I do review these before sending them. I was puzzled having one from you fail.
Rob
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 30/89 dt-bindings: display: vc4: dpi: Add missing clock-names property
In reply to Maxime RipardWhile the device tree and the driver expected a clock-names property, it wasn't explicitly documented in the previous binding. Make sure it is now.
--- Documentation/devicetree/bindings/display/brcm,bcm2835-dpi.yaml | 6 ++++++ 1 file changed, 6 insertions(+)
Documentation/devicetree/bindings/display/brcm,bcm2835-dpi.yaml +6 -0
@@ -21,6 +21,11 @@ properties: - description: The core clock the unit runs on - description: The pixel clock that feeds the pixelvalve + clock-names: + items: + - const: core + - const: pixel + port: type: object description: >
@@ -31,6 +36,7 @@ required: - compatible - reg - clocks + - clock-names - port additionalProperties: false
Signature · 1 line
git-series 0.9.1
Re: [PATCH 30/89] dt-bindings: display: vc4: dpi: Add missing clock-names property
Quoted 10 lines · Maxime Ripard
While the device tree and the driver expected a clock-names property, it wasn't explicitly documented in the previous binding. Make sure it is now.
Cc Rob Herring <[email protected]>Signed-off-by Maxime Ripard <[email protected]>--- Documentation/devicetree/bindings/display/brcm,bcm2835-dpi.yaml | 6 ++++++ 1 file changed, 6 insertions(+)
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 31/89 dt-bindings: display: vc4: dsi: Add missing clock properties
In reply to Maxime RipardWhile the device tree and the driver expected a clock-names and a clock-cells properties, it wasn't explicitly documented in the previous binding. Make sure it is now.
--- Documentation/devicetree/bindings/display/brcm,bcm2835-dsi0.yaml | 11 +++++++- 1 file changed, 11 insertions(+)
Documentation/devicetree/bindings/display/brcm,bcm2835-dsi0.yaml +11 -0
@@ -10,6 +10,9 @@ maintainers: - Eric Anholt <[email protected]> properties: + "#clock-cells": + const: 1 + compatible: enum: - brcm,bcm2835-dsi0
@@ -24,6 +27,12 @@ properties: - description: The DSI ESC clock - description: The DSI pixel clock + clock-names: + items: + - const: phy + - const: escape + - const: pixel + clock-output-names: true # FIXME: The meta-schemas don't seem to allow it for now # items:
@@ -35,9 +44,11 @@ properties: maxItems: 1 required: + - "#clock-cells" - compatible - reg - clocks + - clock-names - clock-output-names - interrupts
Signature · 1 line
git-series 0.9.1
Re: [PATCH 31/89] dt-bindings: display: vc4: dsi: Add missing clock properties
Quoted 11 lines · Maxime Ripard
While the device tree and the driver expected a clock-names and a clock-cells properties, it wasn't explicitly documented in the previous binding. Make sure it is now.
Cc Rob Herring <[email protected]>Signed-off-by Maxime Ripard <[email protected]>--- Documentation/devicetree/bindings/display/brcm,bcm2835-dsi0.yaml | 11 +++++++- 1 file changed, 11 insertions(+)
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 32/89 dt-bindings: display: vc4: hdmi: Add missing clock-names property
In reply to Maxime RipardWhile the device tree and the driver expected a clock-names property, it wasn't explicitly documented in the previous binding. The documented order was wrong too, so make sure clock-names is there and in the proper order.
--- Documentation/devicetree/bindings/display/brcm,bcm2835-hdmi.yaml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/display/brcm,bcm2835-hdmi.yaml +6 -1
@@ -23,8 +23,13 @@ properties: clocks: items: - - description: The HDMI state machine clock - description: The pixel clock + - description: The HDMI state machine clock + + clock-names: + items: + - const: pixel + - const: hdmi ddc: allOf:
Signature · 1 line
git-series 0.9.1
Re: [PATCH 32/89] dt-bindings: display: vc4: hdmi: Add missing clock-names property
Quoted 11 lines · Maxime Ripard
While the device tree and the driver expected a clock-names property, it wasn't explicitly documented in the previous binding. The documented order was wrong too, so make sure clock-names is there and in the proper order.
Cc Rob Herring <[email protected]>Signed-off-by Maxime Ripard <[email protected]>--- Documentation/devicetree/bindings/display/brcm,bcm2835-hdmi.yaml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
PATCH 33/89 dt-bindings: display: vc4: Document BCM2711 VC5
In reply to Maxime RipardThe BCM2711 comes with a new VideoCore. Add a compatible for it.
--- Documentation/devicetree/bindings/display/brcm,bcm2835-vc4.yaml | 1 + 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/display/brcm,bcm2835-vc4.yaml +1 -0
@@ -17,6 +17,7 @@ description: > properties: compatible: enum: + - brcm,bcm2711-vc5 - brcm,bcm2835-vc4 - brcm,cygnus-vc4
Signature · 1 line
git-series 0.9.1
Re: [PATCH 33/89] dt-bindings: display: vc4: Document BCM2711 VC5
Quoted 9 lines · Maxime Ripard
The BCM2711 comes with a new VideoCore. Add a compatible for it.
Cc Rob Herring <[email protected]>Signed-off-by Maxime Ripard <[email protected]>--- Documentation/devicetree/bindings/display/brcm,bcm2835-vc4.yaml | 1 + 1 file changed, 1 insertion(+)
PATCH 34/89 drm/vc4: drv: Add include guards
In reply to Maxime Ripardvc4_drv.h doesn't have any include guards which prevents it from being included twice. Let's add them.
--- drivers/gpu/drm/vc4/vc4_drv.h | 4 ++++ 1 file changed, 4 insertions(+)
drivers/gpu/drm/vc4/vc4_drv.h +4 -0
@@ -2,6 +2,8 @@/* * Copyright (C) 2015 Broadcom */ +#ifndef _VC4_DRV_H_ +#define _VC4_DRV_H_#include <linux/delay.h> #include <linux/refcount.h>
@@ -892,3 +894,5 @@ int vc4_perfmon_destroy_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv);int vc4_perfmon_get_values_ioctl (struct drm_device *dev,void *data,struct drm_file *file_priv); + +#endif /* _VC4_DRV_H_ */
Signature · 1 line
git-series 0.9.1
PATCH 35/89 drm/vc4: drv: Support BCM2711
In reply to Maxime RipardThe BCM2711 has a reworked display pipeline, and the load tracker needs some adjustement to operate properly. Let's add a compatible for BCM2711 and disable the load tracker until properly supported.
--- drivers/gpu/drm/vc4/vc4_drv.c | 1 + drivers/gpu/drm/vc4/vc4_drv.h | 3 +++ drivers/gpu/drm/vc4/vc4_kms.c | 32 +++++++++++++++++++++----------- drivers/gpu/drm/vc4/vc4_plane.c | 5 +++++ 4 files changed, 30 insertions(+), 11 deletions(-)
drivers/gpu/drm/vc4/vc4_drv.c +1 -0
@@ -367,6 +367,7 @@ static int vc4_platform_drm_remove(struct platform_device *pdev) }static const struct of_device_id vc4_of_match[] = { + { .compatible ="brcm,bcm2711-vc5" , }, { .compatible ="brcm,bcm2835-vc4" , }, { .compatible ="brcm,cygnus-vc4" , }, {},
drivers/gpu/drm/vc4/vc4_drv.h +3 -0
@@ -201,6 +201,9 @@ struct vc4_dev {int power_refcount; +/* Set to true when the load tracker is supported. */ +bool load_tracker_available; +/* Set to true when the load tracker is active. */ bool load_tracker_enabled;
drivers/gpu/drm/vc4/vc4_kms.c +21 -11
@@ -415,6 +415,9 @@ static int vc4_load_tracker_atomic_check(struct drm_atomic_state *state)struct drm_plane *plane;int i; +if (!vc4->load_tracker_available) +return 0 ; + priv_state =drm_atomic_get_private_obj_state (state, &vc4->load_tracker);if (IS_ERR (priv_state))
@@ -514,10 +517,14 @@ int vc4_kms_load(struct drm_device *dev)struct vc4_load_tracker_state *load_state;int ret; -/* Start with the load tracker enabled. Can be disabled through the -* debugfs load_tracker file. -*/ - vc4->load_tracker_enabled = true; +if (!of_device_is_compatible (dev->dev->of_node,"brcm,bcm2711-vc5" )) { + vc4->load_tracker_available = true; + +/* Start with the load tracker enabled. Can be +* disabled through the debugfs load_tracker file. +*/ + vc4->load_tracker_enabled = true; + }sema_init (&vc4->async_modeset,1 );
@@ -547,14 +554,17 @@ int vc4_kms_load(struct drm_device *dev)drm_atomic_private_obj_init (dev, &vc4->ctm_manager, &ctm_state->base, &vc4_ctm_state_funcs); - load_state =kzalloc (sizeof (*load_state),GFP_KERNEL ); -if (!load_state) { -drm_atomic_private_obj_fini (&vc4->ctm_manager); -return -ENOMEM ; - } +if (vc4->load_tracker_available) { + load_state =kzalloc (sizeof (*load_state),GFP_KERNEL ); +if (!load_state) { +drm_atomic_private_obj_fini (&vc4->ctm_manager); +return -ENOMEM ; + } -drm_atomic_private_obj_init (dev, &vc4->load_tracker, &load_state->base, - &vc4_load_tracker_state_funcs); +drm_atomic_private_obj_init (dev, &vc4->load_tracker, + &load_state->base, + &vc4_load_tracker_state_funcs); + }drm_mode_config_reset (dev);
drivers/gpu/drm/vc4/vc4_plane.c +5 -0
@@ -492,6 +492,11 @@ static void vc4_plane_calc_load(struct drm_plane_state *state)struct vc4_plane_state *vc4_state;struct drm_crtc_state *crtc_state;unsigned int vscale_factor; +struct vc4_dev *vc4; + + vc4 =to_vc4_dev (state->plane->dev); +if (!vc4->load_tracker_available) +return ; vc4_state =to_vc4_plane_state (state); crtc_state = drm_atomic_get_existing_crtc_state(state->state,
Signature · 1 line
git-series 0.9.1
PATCH 36/89 drm/vc4: drv: Add support for the BCM2711 HVS5
In reply to Maxime RipardFrom: Dave Stevenson <[email protected]>
The HVS found in the BCM2711 is slightly different from the previous generations.
Most notably, the display list layout changes a bit, the LBM doesn't have the same size and the formats ordering for some formats is swapped.
--- drivers/gpu/drm/vc4/vc4_crtc.c | 24 +++- drivers/gpu/drm/vc4/vc4_drv.h | 4 +- drivers/gpu/drm/vc4/vc4_hvs.c | 17 ++- drivers/gpu/drm/vc4/vc4_plane.c | 194 ++++++++++++++++++++++++--------- drivers/gpu/drm/vc4/vc4_regs.h | 67 +++++++++++- 5 files changed, 247 insertions(+), 59 deletions(-)
drivers/gpu/drm/vc4/vc4_crtc.c +19 -5
@@ -550,6 +550,7 @@ static void vc4_crtc_atomic_enable(struct drm_crtc *crtc,struct vc4_crtc *vc4_crtc =to_vc4_crtc (crtc);struct vc4_crtc_state *vc4_state =to_vc4_crtc_state (crtc->state);struct drm_display_mode *mode = &crtc->state->adjusted_mode; +u32 dispctrl;require_hvs_enabled (dev);
@@ -564,11 +565,24 @@ static void vc4_crtc_atomic_enable(struct drm_crtc *crtc,* When feeding the transposer, we should operate in oneshot * mode. */ -HVS_WRITE (SCALER_DISPCTRLX (vc4_crtc->channel), -VC4_SET_FIELD (mode->hdisplay,SCALER_DISPCTRLX_WIDTH ) | -VC4_SET_FIELD (mode->vdisplay,SCALER_DISPCTRLX_HEIGHT ) | -SCALER_DISPCTRLX_ENABLE | - (vc4_state->feed_txp ?SCALER_DISPCTRLX_ONESHOT :0 )); + dispctrl =SCALER_DISPCTRLX_ENABLE ; + +if (!vc4->hvs->hvs5) + dispctrl |=VC4_SET_FIELD (mode->hdisplay, +SCALER_DISPCTRLX_WIDTH ) | +VC4_SET_FIELD (mode->vdisplay, +SCALER_DISPCTRLX_HEIGHT ) | + (vc4_state->feed_txp ? +SCALER_DISPCTRLX_ONESHOT :0 ); +else + dispctrl |=VC4_SET_FIELD (mode->hdisplay, +SCALER5_DISPCTRLX_WIDTH ) | +VC4_SET_FIELD (mode->vdisplay, +SCALER5_DISPCTRLX_HEIGHT ) | + (vc4_state->feed_txp ? +SCALER5_DISPCTRLX_ONESHOT :0 ); + +HVS_WRITE (SCALER_DISPCTRLX (vc4_crtc->channel), dispctrl);/* When feeding the transposer block the pixelvalve is unneeded and * should not be enabled.
drivers/gpu/drm/vc4/vc4_drv.h +4 -0
@@ -332,7 +332,11 @@ struct vc4_hvs {spinlock_t mm_lock;struct drm_mm_node mitchell_netravali_filter; +struct debugfs_regset32 regset; + +/* HVS version 5 flag, therefore requires updated dlist structures */ +bool hvs5; };struct vc4_plane {
drivers/gpu/drm/vc4/vc4_hvs.c +15 -2
@@ -223,6 +223,7 @@ static int vc4_hvs_bind(struct device *dev, struct device *master, void *data)struct vc4_hvs *hvs =NULL ;int ret;u32 dispctrl; +unsigned int hvs_version; hvs =devm_kzalloc (&pdev->dev,sizeof (*hvs),GFP_KERNEL );if (!hvs)
@@ -238,7 +239,14 @@ static int vc4_hvs_bind(struct device *dev, struct device *master, void *data) hvs->regset.regs = hvs_regs; hvs->regset.nregs =ARRAY_SIZE (hvs_regs); - hvs->dlist = hvs->regs +SCALER_DLIST_START ; + hvs_version =readl (hvs->regs +SCALER_DISPLSTAT ) >>24 ; +if (hvs_version >=0x40 ) + hvs->hvs5 = true; + +if (!hvs->hvs5) + hvs->dlist = hvs->regs +SCALER_DLIST_START ; +else + hvs->dlist = hvs->regs +SCALER5_DLIST_START ;spin_lock_init (&hvs->mm_lock);
@@ -256,7 +264,12 @@ static int vc4_hvs_bind(struct device *dev, struct device *master, void *data)* between planes when they don't overlap on the screen, but * for now we just allocate globally. */ -drm_mm_init (&hvs->lbm_mm,0 ,96 *1024 ); +if (!hvs->hvs5) +/* 96kB */ +drm_mm_init (&hvs->lbm_mm,0 ,96 *1024 ); +else +/* 70k words */ +drm_mm_init (&hvs->lbm_mm,0 ,70 *2 *1024 );/* Upload filter kernels. We only have the one for now, so we * keep it around for the lifetime of the driver.
drivers/gpu/drm/vc4/vc4_plane.c +142 -52
248 lines not on this page · raw message
drivers/gpu/drm/vc4/vc4_regs.h +67 -0
119 lines not on this page · raw message
Signature · 1 line
git-series 0.9.1
PATCH 37/89 drm/vc4: plane: Improve LBM usage
In reply to Maxime RipardFrom: Dave Stevenson <[email protected]>
LBM allocations were always taking the worst case sizing of max(src_width, dst_width) * 16. This is significantly over the required sizing, and stops us rendering multiple 4k images to the screen.
Add some of the additional constraints to more accurately describe the LBM requirements.
--- drivers/gpu/drm/vc4/vc4_plane.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-)
drivers/gpu/drm/vc4/vc4_plane.c +20 -11
@@ -142,9 +142,10 @@ static const struct hvs_format *vc4_get_hvs_format(u32 drm_format)return NULL ; } -static enum vc4_scaling_mode vc4_get_scaling_mode (u32 src,u32 dst) +static enum vc4_scaling_mode vc4_get_scaling_mode (u32 src,u32 dst, +bool chroma_vrep) { -if (dst == src) +if (dst == src && !chroma_vrep)return VC4_SCALING_NONE ;if (3 * dst >=2 * src)return VC4_SCALING_PPF ;
@@ -369,9 +370,11 @@ static int vc4_plane_setup_clipping_and_scaling(struct drm_plane_state *state)return ret; vc4_state->x_scaling[0 ] =vc4_get_scaling_mode (vc4_state->src_w[0 ], - vc4_state->crtc_w); + vc4_state->crtc_w, + false); vc4_state->y_scaling[0 ] =vc4_get_scaling_mode (vc4_state->src_h[0 ], - vc4_state->crtc_h); + vc4_state->crtc_h, + false); vc4_state->is_unity = (vc4_state->x_scaling[0 ] ==VC4_SCALING_NONE && vc4_state->y_scaling[0 ] ==VC4_SCALING_NONE );
@@ -384,10 +387,12 @@ static int vc4_plane_setup_clipping_and_scaling(struct drm_plane_state *state) vc4_state->x_scaling[1 ] =vc4_get_scaling_mode (vc4_state->src_w[1 ], - vc4_state->crtc_w); + vc4_state->crtc_w, + v_subsample ==2 ); vc4_state->y_scaling[1 ] =vc4_get_scaling_mode (vc4_state->src_h[1 ], - vc4_state->crtc_h); + vc4_state->crtc_h, + v_subsample ==2 );/* YUV conversion requires that horizontal scaling be enabled * on the UV plane even if vc4_get_scaling_mode() returned
@@ -437,10 +442,7 @@ static void vc4_write_ppf(struct vc4_plane_state *vc4_state, u32 src, u32 dst)static u32 vc4_lbm_size (struct drm_plane_state *state) {struct vc4_plane_state *vc4_state =to_vc4_plane_state (state); -/* This is the worst case number. One of the two sizes will -* be used depending on the scaling configuration. -*/ -u32 pix_per_line =max (vc4_state->src_w[0 ], (u32 )vc4_state->crtc_w); +u32 pix_per_line;u32 lbm;/* LBM is not needed when there's no vertical scaling. */
@@ -448,6 +450,11 @@ static u32 vc4_lbm_size(struct drm_plane_state *state) vc4_state->y_scaling[1] == VC4_SCALING_NONE)return 0 ; +if (vc4_state->x_scaling[0 ] ==VC4_SCALING_TPZ ) + pix_per_line = vc4_state->crtc_w; +else + pix_per_line = vc4_state->src_w[0 ]; +if (!vc4_state->is_yuv) {if (vc4_state->y_scaling[0 ] ==VC4_SCALING_TPZ ) lbm = pix_per_line *8 ;
@@ -583,7 +590,9 @@ static int vc4_plane_allocate_lbm(struct drm_plane_state *state)spin_lock_irqsave (&vc4->hvs->mm_lock, irqflags); ret =drm_mm_insert_node_generic (&vc4->hvs->lbm_mm, &vc4_state->lbm, - lbm_size,32 ,0 ,0 ); + lbm_size, + vc4->hvs->hvs5 ?64 :32 , +0 ,0 );spin_unlock_irqrestore (&vc4->hvs->mm_lock, irqflags);if (ret)
Signature · 1 line
git-series 0.9.1
PATCH 38/89 drm/vc4: plane: Move planes creation to its own function
In reply to Maxime RipardThe planes so far were created as part of the CRTC binding code with each planes created associated only to one CRTC. However, the hardware in the vc4 doesn't really have such constraint and can be used with any CRTC.
In order to rework this, let's first move the overlay and cursor planes creation to a function of its own.
--- drivers/gpu/drm/vc4/vc4_crtc.c | 33 +++--------------------------- drivers/gpu/drm/vc4/vc4_drv.h | 2 ++- drivers/gpu/drm/vc4/vc4_plane.c | 38 ++++++++++++++++++++++++++++++++++- 3 files changed, 44 insertions(+), 29 deletions(-)
drivers/gpu/drm/vc4/vc4_crtc.c +4 -29
@@ -1141,7 +1141,7 @@ static int vc4_crtc_bind(struct device *dev, struct device *master, void *data)struct drm_device *drm =dev_get_drvdata (master);struct vc4_crtc *vc4_crtc;struct drm_crtc *crtc; -struct drm_plane *primary_plane, *cursor_plane, *destroy_plane, *temp; +struct drm_plane *primary_plane, *destroy_plane, *temp;const struct of_device_id *match;int ret, i;
@@ -1189,34 +1189,9 @@ static int vc4_crtc_bind(struct device *dev, struct device *master, void *data)*/ drm_crtc_enable_color_mgmt (crtc,0 , true, crtc->gamma_size); -/* Set up some arbitrary number of planes. We're not limited -* by a set number of physical registers, just the space in -* the HVS (16k) and how small an plane can be (28 bytes). -* However, each plane we set up takes up some memory, and -* increases the cost of looping over planes, which atomic -* modesetting does quite a bit. As a result, we pick a -* modest number of planes to expose, that should hopefully -* still cover any sane usecase. -*/ -for (i =0 ; i <8 ; i++) { -struct drm_plane *plane = -vc4_plane_init (drm,DRM_PLANE_TYPE_OVERLAY ); - -if (IS_ERR (plane)) -continue ; - - plane->possible_crtcs =drm_crtc_mask (crtc); - } - -/* Set up the legacy cursor after overlay initialization, -* since we overlay planes on the CRTC in the order they were -* initialized. -*/ - cursor_plane =vc4_plane_init (drm,DRM_PLANE_TYPE_CURSOR ); -if (!IS_ERR (cursor_plane)) { - cursor_plane->possible_crtcs =drm_crtc_mask (crtc); - crtc->cursor = cursor_plane; - } + ret =vc4_plane_create_additional_planes (drm, crtc); +if (ret) + goto err_destroy_planes;vc4_crtc_get_cob_allocation (vc4_crtc);
drivers/gpu/drm/vc4/vc4_drv.h +2 -0
@@ -848,6 +848,8 @@ int vc4_kms_load(struct drm_device *dev);/* vc4_plane.c */ struct drm_plane *vc4_plane_init (struct drm_device *dev,enum drm_plane_type type); +int vc4_plane_create_additional_planes (struct drm_device *dev, +struct drm_crtc *crtc);u32 vc4_plane_write_dlist (struct drm_plane *plane,u32 __iomem *dlist);u32 vc4_plane_dlist_size (const struct drm_plane_state *state); void vc4_plane_async_set_fb(struct drm_plane *plane,
drivers/gpu/drm/vc4/vc4_plane.c +38 -0
@@ -1371,3 +1371,41 @@ struct drm_plane *vc4_plane_init(struct drm_device *dev,return plane; } + +int vc4_plane_create_additional_planes (struct drm_device *drm, +struct drm_crtc *crtc) +{ +struct drm_plane *cursor_plane; +unsigned int i; + +/* Set up some arbitrary number of planes. We're not limited +* by a set number of physical registers, just the space in +* the HVS (16k) and how small an plane can be (28 bytes). +* However, each plane we set up takes up some memory, and +* increases the cost of looping over planes, which atomic +* modesetting does quite a bit. As a result, we pick a +* modest number of planes to expose, that should hopefully +* still cover any sane usecase. +*/ +for (i =0 ; i <8 ; i++) { +struct drm_plane *plane = +vc4_plane_init (drm,DRM_PLANE_TYPE_OVERLAY ); + +if (IS_ERR (plane)) +continue ; + + plane->possible_crtcs =drm_crtc_mask (crtc); + } + +/* Set up the legacy cursor after overlay initialization, +* since we overlay planes on the CRTC in the order they were +* initialized. +*/ + cursor_plane =vc4_plane_init (drm,DRM_PLANE_TYPE_CURSOR ); +if (!IS_ERR (cursor_plane)) { + cursor_plane->possible_crtcs =drm_crtc_mask (crtc); + crtc->cursor = cursor_plane; + } + +return 0 ; +}
Signature · 1 line
git-series 0.9.1
PATCH 39/89 drm/vc4: plane: Move additional planes creation to driver
In reply to Maxime RipardSo far the plane creation was done when each CRTC was bound, and those planes were only tied to the CRTC that was registering them.
This causes two main issues:
- The planes in the vc4 hardware are actually not tied to any CRTC, but can be used with every combination
- More importantly, so far, we allocate 10 planes per CRTC, with 3 CRTCs. However, the next generation of hardware will have 5 CRTCs, putting us well above the maximum of 32 planes currently allowed by DRM.
This patch is the first one in a series of patches that will take down both of these issues so that we can support the next generation of hardware while keeping a good amount of planes.
We start by changing the way the planes are registered to first registering the primary planes for each CRTC in the CRTC bind function as we used to, but moving the overlay and cursor creation to the main driver bind function, after all the CRTCs have been bound.
This will slightly change the ID order of the planes, since the primary planes of all CRTCs will be first, and then a pattern of 8 overlays, 1 cursor plane for each CRTC.
This shouldn't cause any trouble since the ordering between the planes is preserved though.
--- drivers/gpu/drm/vc4/vc4_crtc.c | 4 ---- drivers/gpu/drm/vc4/vc4_drv.c | 7 +++++++ 2 files changed, 7 insertions(+), 4 deletions(-)
drivers/gpu/drm/vc4/vc4_crtc.c +0 -4
@@ -1189,10 +1189,6 @@ static int vc4_crtc_bind(struct device *dev, struct device *master, void *data)*/ drm_crtc_enable_color_mgmt (crtc,0 , true, crtc->gamma_size); - ret =vc4_plane_create_additional_planes (drm, crtc); -if (ret) - goto err_destroy_planes; -vc4_crtc_get_cob_allocation (vc4_crtc);CRTC_WRITE (PV_INTEN ,0 );
drivers/gpu/drm/vc4/vc4_drv.c +7 -0
@@ -253,6 +253,7 @@ static int vc4_drm_bind(struct device *dev) {struct platform_device *pdev =to_platform_device (dev);struct drm_device *drm; +struct drm_crtc *crtc;struct vc4_dev *vc4;struct device_node *node;int ret =0 ;
@@ -291,6 +292,12 @@ static int vc4_drm_bind(struct device *dev)if (ret) goto gem_destroy; +drm_for_each_crtc (crtc, drm) { + ret =vc4_plane_create_additional_planes (drm, crtc); +if (ret) +continue ; + } +drm_fb_helper_remove_conflicting_framebuffers (NULL ,"vc4drmfb" , false); ret =vc4_kms_load (drm);
Signature · 1 line
git-series 0.9.1
PATCH 40/89 drm/vc4: plane: Register all the planes at once
In reply to Maxime RipardInstead of creating planes for each CRTC, we eventually want to create all the planes for each CRTCs.
In order to make that more convenient, let's iterate on the CRTCs in the plane creation function instead of its caller.
--- drivers/gpu/drm/vc4/vc4_drv.c | 9 ++---- drivers/gpu/drm/vc4/vc4_drv.h | 3 +-- drivers/gpu/drm/vc4/vc4_plane.c | 54 +++++++++++++++++----------------- 3 files changed, 32 insertions(+), 34 deletions(-)
drivers/gpu/drm/vc4/vc4_drv.c +3 -6
@@ -253,7 +253,6 @@ static int vc4_drm_bind(struct device *dev) {struct platform_device *pdev =to_platform_device (dev);struct drm_device *drm; -struct drm_crtc *crtc;struct vc4_dev *vc4;struct device_node *node;int ret =0 ;
@@ -292,11 +291,9 @@ static int vc4_drm_bind(struct device *dev)if (ret) goto gem_destroy; -drm_for_each_crtc (crtc, drm) { - ret =vc4_plane_create_additional_planes (drm, crtc); -if (ret) -continue ; - } + ret =vc4_plane_create_additional_planes (drm); +if (ret) + goto unbind_all;drm_fb_helper_remove_conflicting_framebuffers (NULL ,"vc4drmfb" , false);
drivers/gpu/drm/vc4/vc4_drv.h +1 -2
@@ -848,8 +848,7 @@ int vc4_kms_load(struct drm_device *dev);/* vc4_plane.c */ struct drm_plane *vc4_plane_init (struct drm_device *dev,enum drm_plane_type type); -int vc4_plane_create_additional_planes (struct drm_device *dev, -struct drm_crtc *crtc); +int vc4_plane_create_additional_planes (struct drm_device *dev);u32 vc4_plane_write_dlist (struct drm_plane *plane,u32 __iomem *dlist);u32 vc4_plane_dlist_size (const struct drm_plane_state *state); void vc4_plane_async_set_fb(struct drm_plane *plane,
drivers/gpu/drm/vc4/vc4_plane.c +28 -26
67 lines not on this page · raw message
Signature · 1 line
git-series 0.9.1
PATCH 41/89 drm/vc4: plane: Create overlays for any CRTC
In reply to Maxime RipardNow that we have everything in place, we can now register all the overlay planes that can be assigned to all the CRTCs.
This has two side effects:
- The number of overlay planes is reduced from 24 to 8. This is temporary and will be increased again in the next patch.
- The ID of the various planes is changed again, and we will now have all the primary planes, then all the overlay planes and finally the cursor planes. This shouldn't cause any issue since the ordering between primary, overlay and cursor planes is preserved.
--- drivers/gpu/drm/vc4/vc4_plane.c | 35 +++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-)
drivers/gpu/drm/vc4/vc4_plane.c +18 -17
@@ -1378,26 +1378,27 @@ int vc4_plane_create_additional_planes(struct drm_device *drm)struct drm_crtc *crtc;unsigned int i; -drm_for_each_crtc (crtc, drm) { -/* Set up some arbitrary number of planes. We're not limited -* by a set number of physical registers, just the space in -* the HVS (16k) and how small an plane can be (28 bytes). -* However, each plane we set up takes up some memory, and -* increases the cost of looping over planes, which atomic -* modesetting does quite a bit. As a result, we pick a -* modest number of planes to expose, that should hopefully -* still cover any sane usecase. -*/ -for (i =0 ; i <8 ; i++) { -struct drm_plane *plane = -vc4_plane_init (drm,DRM_PLANE_TYPE_OVERLAY ); +/* Set up some arbitrary number of planes. We're not limited +* by a set number of physical registers, just the space in +* the HVS (16k) and how small an plane can be (28 bytes). +* However, each plane we set up takes up some memory, and +* increases the cost of looping over planes, which atomic +* modesetting does quite a bit. As a result, we pick a +* modest number of planes to expose, that should hopefully +* still cover any sane usecase. +*/ +for (i =0 ; i <8 ; i++) { +struct drm_plane *plane = +vc4_plane_init (drm,DRM_PLANE_TYPE_OVERLAY ); -if (IS_ERR (plane)) -continue ; +if (IS_ERR (plane)) +continue ; - plane->possible_crtcs =drm_crtc_mask (crtc); - } + plane->possible_crtcs = +GENMASK (drm->mode_config.num_crtc -1 ,0 ); + } +drm_for_each_crtc (crtc, drm) {/* Set up the legacy cursor after overlay initialization, * since we overlay planes on the CRTC in the order they were * initialized.
Signature · 1 line
git-series 0.9.1
PATCH 42/89 drm/vc4: plane: Create more planes
In reply to Maxime RipardLet's now create more planes that can be affected to all the CRTCs.
vc4 has 3 CRTCs, 1 primary and 1 cursor each, and was having 24 (8 planes per CRTC) overlays.
However, vc5 has 5 CRTCs, so keeping the same logic would put us at 50 planes which is well above the 32 planes limit imposed by DRM.
Using 16 seems like a good tradeoff between staying under 32 and yet providing enough planes.
--- drivers/gpu/drm/vc4/vc4_plane.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/vc4/vc4_plane.c +1 -1
@@ -1387,7 +1387,7 @@ int vc4_plane_create_additional_planes(struct drm_device *drm)* modest number of planes to expose, that should hopefully * still cover any sane usecase. */ -for (i =0 ; i <8 ; i++) { +for (i =0 ; i <16 ; i++) {struct drm_plane *plane =vc4_plane_init (drm,DRM_PLANE_TYPE_OVERLAY );
Signature · 1 line
git-series 0.9.1
PATCH 43/89 drm/vc4: crtc: Rename SoC data structures
In reply to Maxime RipardSince we're going to introduce pixelvalve data structures for other SoCs than the BCM2835, let's rename the structures defined in the code to make it obvious which SoC we're targetting.
--- drivers/gpu/drm/vc4/vc4_crtc.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/gpu/drm/vc4/vc4_crtc.c +6 -6
@@ -1055,7 +1055,7 @@ static const struct drm_crtc_helper_funcs vc4_crtc_helper_funcs = { .atomic_disable = vc4_crtc_atomic_disable, }; -static const struct vc4_crtc_data pv0_data = { +static const struct vc4_crtc_data bcm2835_pv0_data = { .hvs_channel =0 , .debugfs_name ="crtc0_regs" , .encoder_types = {
@@ -1064,7 +1064,7 @@ static const struct vc4_crtc_data pv0_data = { }, }; -static const struct vc4_crtc_data pv1_data = { +static const struct vc4_crtc_data bcm2835_pv1_data = { .hvs_channel =2 , .debugfs_name ="crtc1_regs" , .encoder_types = {
@@ -1073,7 +1073,7 @@ static const struct vc4_crtc_data pv1_data = { }, }; -static const struct vc4_crtc_data pv2_data = { +static const struct vc4_crtc_data bcm2835_pv2_data = { .hvs_channel =1 , .debugfs_name ="crtc2_regs" , .encoder_types = {
@@ -1083,9 +1083,9 @@ static const struct vc4_crtc_data pv2_data = { };static const struct of_device_id vc4_crtc_dt_match[] = { - { .compatible ="brcm,bcm2835-pixelvalve0" , .data = &pv0_data }, - { .compatible ="brcm,bcm2835-pixelvalve1" , .data = &pv1_data }, - { .compatible ="brcm,bcm2835-pixelvalve2" , .data = &pv2_data }, + { .compatible ="brcm,bcm2835-pixelvalve0" , .data = &bcm2835_pv0_data }, + { .compatible ="brcm,bcm2835-pixelvalve1" , .data = &bcm2835_pv1_data }, + { .compatible ="brcm,bcm2835-pixelvalve2" , .data = &bcm2835_pv2_data }, {} };
Signature · 1 line
git-series 0.9.1
PATCH 44/89 drm/vc4: crtc: Move crtc state to common header
In reply to Maxime RipardWe'll need to access the crtc_state from outside of vc4_crtc.c, so let's move it to vc4_drv.h
--- drivers/gpu/drm/vc4/vc4_crtc.c | 21 --------------------- drivers/gpu/drm/vc4/vc4_drv.h | 21 +++++++++++++++++++++ 2 files changed, 21 insertions(+), 21 deletions(-)
drivers/gpu/drm/vc4/vc4_crtc.c +0 -21
@@ -44,27 +44,6 @@#include "vc4_drv.h" #include "vc4_regs.h" -struct vc4_crtc_state { -struct drm_crtc_state base; -/* Dlist area for this CRTC configuration. */ -struct drm_mm_node mm; -bool feed_txp; -bool txp_armed; - -struct { -unsigned int left; -unsigned int right; -unsigned int top; -unsigned int bottom; - } margins; -}; - -static inline struct vc4_crtc_state * -to_vc4_crtc_state (struct drm_crtc_state *crtc_state) -{ -return (struct vc4_crtc_state *)crtc_state; -} -#define CRTC_WRITE (offset, val) writel(val, vc4_crtc->regs + (offset))#define CRTC_READ (offset) readl(vc4_crtc->regs + (offset))
drivers/gpu/drm/vc4/vc4_drv.h +21 -0
@@ -484,6 +484,27 @@ to_vc4_crtc(struct drm_crtc *crtc)return (struct vc4_crtc *)crtc; } +struct vc4_crtc_state { +struct drm_crtc_state base; +/* Dlist area for this CRTC configuration. */ +struct drm_mm_node mm; +bool feed_txp; +bool txp_armed; + +struct { +unsigned int left; +unsigned int right; +unsigned int top; +unsigned int bottom; + } margins; +}; + +static inline struct vc4_crtc_state * +to_vc4_crtc_state (struct drm_crtc_state *crtc_state) +{ +return (struct vc4_crtc_state *)crtc_state; +} +#define V3D_READ (offset) readl(vc4->v3d->regs + offset)#define V3D_WRITE (offset, val) writel(val, vc4->v3d->regs + offset)#define HVS_READ (offset) readl(vc4->hvs->regs + offset)
Signature · 1 line
git-series 0.9.1
PATCH 45/89 drm/vc4: crtc: Deal with different number of pixel per clock
In reply to Maxime RipardSome of the HDMI pixelvalves in vc5 output two pixels per clock cycle. Let's put the number of pixel output per clock cycle in the CRTC data and update the various calculations to reflect that.
--- drivers/gpu/drm/vc4/vc4_crtc.c | 17 ++++++++++------- drivers/gpu/drm/vc4/vc4_drv.h | 3 +++ 2 files changed, 13 insertions(+), 7 deletions(-)
drivers/gpu/drm/vc4/vc4_crtc.c +10 -7
@@ -281,6 +281,7 @@ static void vc4_crtc_config_pv(struct drm_crtc *crtc)bool is_dsi = (vc4_encoder->type ==VC4_ENCODER_TYPE_DSI0 || vc4_encoder->type ==VC4_ENCODER_TYPE_DSI1 );u32 format = is_dsi ?PV_CONTROL_FORMAT_DSIV_24 :PV_CONTROL_FORMAT_24 ; +u8 ppc = vc4_crtc->data->pixels_per_clock;/* Reset the PV fifo. */ CRTC_WRITE (PV_CONTROL ,0 );
@@ -288,17 +289,16 @@ static void vc4_crtc_config_pv(struct drm_crtc *crtc)CRTC_WRITE (PV_CONTROL ,0 );CRTC_WRITE (PV_HORZA , -VC4_SET_FIELD ((mode->htotal - - mode->hsync_end) * pixel_rep, +VC4_SET_FIELD ((mode->htotal - mode->hsync_end) * pixel_rep / ppc,PV_HORZA_HBP ) | -VC4_SET_FIELD ((mode->hsync_end - - mode->hsync_start) * pixel_rep, +VC4_SET_FIELD ((mode->hsync_end - mode->hsync_start) * pixel_rep / ppc,PV_HORZA_HSYNC )); +CRTC_WRITE (PV_HORZB , -VC4_SET_FIELD ((mode->hsync_start - - mode->hdisplay) * pixel_rep, +VC4_SET_FIELD ((mode->hsync_start - mode->hdisplay) * pixel_rep / ppc,PV_HORZB_HFP ) | -VC4_SET_FIELD (mode->hdisplay * pixel_rep,PV_HORZB_HACTIVE )); +VC4_SET_FIELD (mode->hdisplay * pixel_rep / ppc, +PV_HORZB_HACTIVE )); CRTC_WRITE(PV_VERTA, VC4_SET_FIELD(mode->crtc_vtotal - mode->crtc_vsync_end,
@@ -1037,6 +1037,7 @@ static const struct drm_crtc_helper_funcs vc4_crtc_helper_funcs = {static const struct vc4_crtc_data bcm2835_pv0_data = { .hvs_channel =0 , .debugfs_name ="crtc0_regs" , + .pixels_per_clock =1 , .encoder_types = { [PV_CONTROL_CLK_SELECT_DSI ] =VC4_ENCODER_TYPE_DSI0 , [PV_CONTROL_CLK_SELECT_DPI_SMI_HDMI ] =VC4_ENCODER_TYPE_DPI ,
@@ -1046,6 +1047,7 @@ static const struct vc4_crtc_data bcm2835_pv0_data = {static const struct vc4_crtc_data bcm2835_pv1_data = { .hvs_channel =2 , .debugfs_name ="crtc1_regs" , + .pixels_per_clock =1 , .encoder_types = { [PV_CONTROL_CLK_SELECT_DSI ] =VC4_ENCODER_TYPE_DSI1 , [PV_CONTROL_CLK_SELECT_DPI_SMI_HDMI ] =VC4_ENCODER_TYPE_SMI ,
@@ -1055,6 +1057,7 @@ static const struct vc4_crtc_data bcm2835_pv1_data = {static const struct vc4_crtc_data bcm2835_pv2_data = { .hvs_channel =1 , .debugfs_name ="crtc2_regs" , + .pixels_per_clock =1 , .encoder_types = { [PV_CONTROL_CLK_SELECT_DPI_SMI_HDMI ] =VC4_ENCODER_TYPE_HDMI , [PV_CONTROL_CLK_SELECT_VEC ] =VC4_ENCODER_TYPE_VEC ,
drivers/gpu/drm/vc4/vc4_drv.h +3 -0
@@ -451,6 +451,9 @@ struct vc4_crtc_data {/* Which channel of the HVS this pixelvalve sources from. */ int hvs_channel; +/* Number of pixels output per clock period */ +u8 pixels_per_clock; +enum vc4_encoder_type encoder_types[4 ];const char *debugfs_name; };
Signature · 1 line
git-series 0.9.1
PATCH 46/89 drm/vc4: crtc: Use a shared interrupt
In reply to Maxime RipardSome pixelvalves in vc5 use the same interrupt line so let's register our interrupt handler as a shared one.
--- drivers/gpu/drm/vc4/vc4_crtc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/vc4/vc4_crtc.c +3 -1
@@ -1176,7 +1176,9 @@ static int vc4_crtc_bind(struct device *dev, struct device *master, void *data)CRTC_WRITE (PV_INTEN ,0 );CRTC_WRITE (PV_INTSTAT ,PV_INT_VFP_START ); ret =devm_request_irq (dev,platform_get_irq (pdev,0 ), - vc4_crtc_irq_handler,0 ,"vc4 crtc" , vc4_crtc); + vc4_crtc_irq_handler, +IRQF_SHARED , +"vc4 crtc" , vc4_crtc);if (ret) goto err_destroy_planes;
Signature · 1 line
git-series 0.9.1
PATCH 47/89 drm/vc4: crtc: Turn static const variable into a define
In reply to Maxime RipardThe hvs_latency_pix variable doesn't need to be a variable and can just be defined.
--- drivers/gpu/drm/vc4/vc4_crtc.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/gpu/drm/vc4/vc4_crtc.c +5 -3
@@ -44,6 +44,8 @@#include "vc4_drv.h" #include "vc4_regs.h" +#define HVS_FIFO_LATENCY_PIX 6 +#define CRTC_WRITE (offset, val) writel(val, vc4_crtc->regs + (offset))#define CRTC_READ (offset) readl(vc4_crtc->regs + (offset))
@@ -227,21 +229,21 @@ vc4_crtc_update_gamma_lut(struct drm_crtc *crtc)vc4_crtc_lut_load (crtc); } +static u32 vc4_get_fifo_full_level (u32 format) {static const u32 fifo_len_bytes =64 ; -static const u32 hvs_latency_pix =6 ;switch (format) {case PV_CONTROL_FORMAT_DSIV_16 :case PV_CONTROL_FORMAT_DSIC_16 : -return fifo_len_bytes -2 * hvs_latency_pix; +return fifo_len_bytes -2 *HVS_FIFO_LATENCY_PIX ;case PV_CONTROL_FORMAT_DSIV_18 :return fifo_len_bytes -14 ;case PV_CONTROL_FORMAT_24 :case PV_CONTROL_FORMAT_DSIV_24 :default : -return fifo_len_bytes -3 * hvs_latency_pix; +return fifo_len_bytes -3 *HVS_FIFO_LATENCY_PIX ; } }
Signature · 1 line
git-series 0.9.1
PATCH 48/89 drm/vc4: crtc: Move the cob allocation outside of bind
In reply to Maxime RipardThe COB allocation depends on the HVS channel used for a given pixelvalve.
While the channel allocation was entirely static in vc4, vc5 changes that and at bind time, a pixelvalve can be assigned to multiple HVS channels.
Let's prepare that rework by allocating the COB when it's actually needed.
--- drivers/gpu/drm/vc4/vc4_crtc.c | 39 +++++++++++++++++------------------ drivers/gpu/drm/vc4/vc4_drv.h | 2 +-- 2 files changed, 20 insertions(+), 21 deletions(-)
drivers/gpu/drm/vc4/vc4_crtc.c +20 -19
@@ -65,6 +65,23 @@ static const struct debugfs_reg32 crtc_regs[] = { VC4_REG32(PV_HACT_ACT), }; +static unsigned int +vc4_crtc_get_cob_allocation (struct vc4_crtc *vc4_crtc,unsigned int channel) +{ +struct drm_device *drm = vc4_crtc->base.dev; +struct vc4_dev *vc4 =to_vc4_dev (drm); + +u32 dispbase =HVS_READ (SCALER_DISPBASEX (channel)); +/* Top/base are supposed to be 4-pixel aligned, but the +* Raspberry Pi firmware fills the low bits (which are +* presumably ignored). +*/ +u32 top =VC4_GET_FIELD (dispbase,SCALER_DISPBASEX_TOP ) & ~3 ; +u32 base =VC4_GET_FIELD (dispbase,SCALER_DISPBASEX_BASE ) & ~3 ; + +return top - base +4 ; +} + bool vc4_crtc_get_scanoutpos(struct drm_device *dev, unsigned int crtc_id, bool in_vblank_irq, int *vpos, int *hpos, ktime_t *stime, ktime_t *etime,
@@ -73,6 +90,7 @@ bool vc4_crtc_get_scanoutpos(struct drm_device *dev, unsigned int crtc_id,struct vc4_dev *vc4 =to_vc4_dev (dev);struct drm_crtc *crtc =drm_crtc_from_index (dev, crtc_id);struct vc4_crtc *vc4_crtc =to_vc4_crtc (crtc); +unsigned int cob_size;u32 val;int fifo_lines;int vblank_lines;
@@ -108,8 +126,9 @@ bool vc4_crtc_get_scanoutpos(struct drm_device *dev, unsigned int crtc_id, *hpos += mode->crtc_htotal /2 ; } + cob_size =vc4_crtc_get_cob_allocation (vc4_crtc, vc4_crtc->channel);/* This is the offset we need for translating hvs -> pv scanout pos. */ - fifo_lines = vc4_crtc->cob_size / mode->crtc_hdisplay; + fifo_lines = cob_size / mode->crtc_hdisplay;if (fifo_lines >0 ) ret = true;
@@ -1103,22 +1122,6 @@ static void vc4_set_crtc_possible_masks(struct drm_device *drm, } } -static void -vc4_crtc_get_cob_allocation (struct vc4_crtc *vc4_crtc) -{ -struct drm_device *drm = vc4_crtc->base.dev; -struct vc4_dev *vc4 =to_vc4_dev (drm); -u32 dispbase =HVS_READ (SCALER_DISPBASEX (vc4_crtc->channel)); -/* Top/base are supposed to be 4-pixel aligned, but the -* Raspberry Pi firmware fills the low bits (which are -* presumably ignored). -*/ -u32 top =VC4_GET_FIELD (dispbase,SCALER_DISPBASEX_TOP ) & ~3 ; -u32 base =VC4_GET_FIELD (dispbase,SCALER_DISPBASEX_BASE ) & ~3 ; - - vc4_crtc->cob_size = top - base +4 ; -} -static int vc4_crtc_bind (struct device *dev,struct device *master,void *data) {struct platform_device *pdev =to_platform_device (dev);
@@ -1173,8 +1176,6 @@ static int vc4_crtc_bind(struct device *dev, struct device *master, void *data)*/ drm_crtc_enable_color_mgmt (crtc,0 , true, crtc->gamma_size); -vc4_crtc_get_cob_allocation (vc4_crtc); -CRTC_WRITE (PV_INTEN ,0 );CRTC_WRITE (PV_INTSTAT ,PV_INT_VFP_START ); ret = devm_request_irq(dev, platform_get_irq(pdev, 0),
drivers/gpu/drm/vc4/vc4_drv.h +0 -2
@@ -473,8 +473,6 @@ struct vc4_crtc {u8 lut_r[256 ];u8 lut_g[256 ];u8 lut_b[256 ]; -/* Size in pixels of the COB memory allocated to this CRTC. */ -u32 cob_size;struct drm_pending_vblank_event *event;
Signature · 1 line
git-series 0.9.1
PATCH 49/89 drm/vc4: crtc: Rename HVS channel to output
In reply to Maxime RipardIn vc5, the HVS has 6 outputs and 3 FIFOs (or channels), with pixelvalves each being assigned to a given output, but each output can then be muxed to feed from multiple FIFOs.
Since vc4 had that entirely static, both were probably equivalent, but since that changes, let's rename hvs_channel to hvs_output in the vc4_crtc_data, since a pixelvalve is really connected to an output, and not to a FIFO.
--- drivers/gpu/drm/vc4/vc4_crtc.c | 10 +++++----- drivers/gpu/drm/vc4/vc4_drv.h | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-)
drivers/gpu/drm/vc4/vc4_crtc.c +5 -5
@@ -1056,7 +1056,7 @@ static const struct drm_crtc_helper_funcs vc4_crtc_helper_funcs = { };static const struct vc4_crtc_data bcm2835_pv0_data = { - .hvs_channel =0 , + .hvs_output =0 , .debugfs_name ="crtc0_regs" , .pixels_per_clock =1 , .encoder_types = {
@@ -1066,7 +1066,7 @@ static const struct vc4_crtc_data bcm2835_pv0_data = { };static const struct vc4_crtc_data bcm2835_pv1_data = { - .hvs_channel =2 , + .hvs_output =2 , .debugfs_name ="crtc1_regs" , .pixels_per_clock =1 , .encoder_types = {
@@ -1076,7 +1076,7 @@ static const struct vc4_crtc_data bcm2835_pv1_data = { };static const struct vc4_crtc_data bcm2835_pv2_data = { - .hvs_channel =1 , + .hvs_output =1 , .debugfs_name ="crtc2_regs" , .pixels_per_clock =1 , .encoder_types = {
@@ -1105,7 +1105,7 @@ static void vc4_set_crtc_possible_masks(struct drm_device *drm,int i;/* HVS FIFO2 can feed the TXP IP. */ -if (crtc_data->hvs_channel ==2 && +if (crtc_data->hvs_output ==2 && encoder->encoder_type ==DRM_MODE_ENCODER_VIRTUAL ) { encoder->possible_crtcs |=drm_crtc_mask (crtc);continue ;
@@ -1167,7 +1167,7 @@ static int vc4_crtc_bind(struct device *dev, struct device *master, void *data)drm_crtc_init_with_planes (drm, crtc, primary_plane,NULL , &vc4_crtc_funcs,NULL );drm_crtc_helper_add (crtc, &vc4_crtc_helper_funcs); - vc4_crtc->channel = vc4_crtc->data->hvs_channel; + vc4_crtc->channel = vc4_crtc->data->hvs_output;drm_mode_crtc_set_gamma_size (crtc,ARRAY_SIZE (vc4_crtc->lut_r));drm_crtc_enable_color_mgmt (crtc,0 , false, crtc->gamma_size);
drivers/gpu/drm/vc4/vc4_drv.h +2 -2
@@ -448,8 +448,8 @@ to_vc4_encoder(struct drm_encoder *encoder) }struct vc4_crtc_data { -/* Which channel of the HVS this pixelvalve sources from. */ -int hvs_channel; +/* Which output of the HVS this pixelvalve sources from. */ +int hvs_output;/* Number of pixels output per clock period */ u8 pixels_per_clock;
Signature · 1 line
git-series 0.9.1
PATCH 50/89 drm/vc4: crtc: Use local chan variable
In reply to Maxime RipardThe vc4_crtc_handle_page_flip already has a local variable holding the value of vc4_crtc->channel, so let's use it instead.
--- drivers/gpu/drm/vc4/vc4_crtc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/vc4/vc4_crtc.c +1 -1
@@ -815,7 +815,7 @@ static void vc4_crtc_handle_page_flip(struct vc4_crtc *vc4_crtc)* the CRTC and encoder already reconfigured, leading to * underruns. This can be seen when reconfiguring the CRTC. */ -vc4_hvs_unmask_underrun (dev, vc4_crtc->channel); +vc4_hvs_unmask_underrun (dev, chan); }spin_unlock_irqrestore (&dev->event_lock, flags); }
Signature · 1 line
git-series 0.9.1
PATCH 51/89 drm/vc4: crtc: Enable and disable the PV in atomic_enable / disable
In reply to Maxime RipardThe VIDEN bit in the pixelvalve currently being used to enable or disable the pixelvalve seems to not be enough in some situations, which whill end up with the pixelvalve stalling.
In such a case, even re-enabling VIDEN doesn't bring it back and we need to clear the FIFO. This can only be done if the pixelvalve is disabled though.
In order to overcome this, we can configure the pixelvalve during mode_set_no_fb, but only enable it in atomic_enable and flush the FIFO there, and in atomic_disable disable the pixelvalve again.
--- drivers/gpu/drm/vc4/vc4_crtc.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/gpu/drm/vc4/vc4_crtc.c +7 -3
@@ -374,9 +374,7 @@ static void vc4_crtc_config_pv(struct drm_crtc *crtc)PV_CONTROL_TRIGGER_UNDERFLOW |PV_CONTROL_WAIT_HSTART |VC4_SET_FIELD (vc4_encoder->clock_select, -PV_CONTROL_CLK_SELECT ) | -PV_CONTROL_FIFO_CLR | - PV_CONTROL_EN); + PV_CONTROL_CLK_SELECT)); }static void vc4_crtc_mode_set_nofb (struct drm_crtc *crtc)
@@ -467,6 +465,8 @@ static void vc4_crtc_atomic_disable(struct drm_crtc *crtc, ret =wait_for (!(CRTC_READ (PV_V_CONTROL ) &PV_VCONTROL_VIDEN ),1 );WARN_ONCE (ret,"Timeout waiting for !PV_VCONTROL_VIDEN\n" ); +CRTC_WRITE (PV_CONTROL ,CRTC_READ (PV_CONTROL ) & ~PV_CONTROL_EN ); +if (HVS_READ (SCALER_DISPCTRLX (chan)) &SCALER_DISPCTRLX_ENABLE ) { HVS_WRITE(SCALER_DISPCTRLX(chan),
@@ -554,6 +554,10 @@ static void vc4_crtc_atomic_enable(struct drm_crtc *crtc,require_hvs_enabled (dev); +/* Reset the PV fifo. */ +CRTC_WRITE (PV_CONTROL ,CRTC_READ (PV_CONTROL ) | +PV_CONTROL_FIFO_CLR |PV_CONTROL_EN ); +/* Enable vblank irq handling before crtc is started otherwise * drm_crtc_get_vblank() fails in vc4_crtc_update_dlist(). */
Signature · 1 line
git-series 0.9.1
PATCH 52/89 drm/vc4: crtc: Assign output to channel automatically
In reply to Maxime RipardThe HVS found in the BCM2711 has 6 outputs and 3 FIFOs, with each output being connected to a pixelvalve, and some muxing between the FIFOs and outputs.
Any output cannot feed from any FIFO though, and they all have a bunch of constraints.
In order to support this, let's store the possible FIFOs each output can be assigned to in the vc4_crtc_data, and use that information at atomic_check time to iterate over all the CRTCs enabled and assign them FIFOs.
The channel assigned is then set in the vc4_crtc_state so that the rest of the driver can use it.
--- drivers/gpu/drm/vc4/vc4_crtc.c | 37 +++++---- drivers/gpu/drm/vc4/vc4_drv.h | 7 +- drivers/gpu/drm/vc4/vc4_kms.c | 143 ++++++++++++++++++++++++++++++++-- drivers/gpu/drm/vc4/vc4_regs.h | 10 ++- 4 files changed, 173 insertions(+), 24 deletions(-)
drivers/gpu/drm/vc4/vc4_crtc.c +21 -16
@@ -90,6 +90,7 @@ bool vc4_crtc_get_scanoutpos(struct drm_device *dev, unsigned int crtc_id,struct vc4_dev *vc4 =to_vc4_dev (dev);struct drm_crtc *crtc =drm_crtc_from_index (dev, crtc_id);struct vc4_crtc *vc4_crtc =to_vc4_crtc (crtc); +struct vc4_crtc_state *vc4_crtc_state =to_vc4_crtc_state (crtc->state);unsigned int cob_size;u32 val;int fifo_lines;
@@ -106,7 +107,7 @@ bool vc4_crtc_get_scanoutpos(struct drm_device *dev, unsigned int crtc_id,* Read vertical scanline which is currently composed for our * pixelvalve by the HVS, and also the scaler status. */ - val =HVS_READ (SCALER_DISPSTATX (vc4_crtc->channel)); + val =HVS_READ (SCALER_DISPSTATX (vc4_crtc_state->assigned_channel));/* Get optional system timestamp after query. */ if (etime)
@@ -126,7 +127,7 @@ bool vc4_crtc_get_scanoutpos(struct drm_device *dev, unsigned int crtc_id, *hpos += mode->crtc_htotal /2 ; } - cob_size =vc4_crtc_get_cob_allocation (vc4_crtc, vc4_crtc->channel); + cob_size =vc4_crtc_get_cob_allocation (vc4_crtc, vc4_crtc_state->assigned_channel);/* This is the offset we need for translating hvs -> pv scanout pos. */ fifo_lines = cob_size / mode->crtc_hdisplay;
@@ -213,6 +214,7 @@ vc4_crtc_lut_load(struct drm_crtc *crtc)struct drm_device *dev = crtc->dev;struct vc4_dev *vc4 =to_vc4_dev (dev);struct vc4_crtc *vc4_crtc =to_vc4_crtc (crtc); +struct vc4_crtc_state *vc4_crtc_state =to_vc4_crtc_state (crtc->state);u32 i;/* The LUT memory is laid out with each HVS channel in order,
@@ -221,7 +223,7 @@ vc4_crtc_lut_load(struct drm_crtc *crtc)*/ HVS_WRITE (SCALER_GAMADDR ,SCALER_GAMADDR_AUTOINC | - (vc4_crtc->channel *3 * crtc->gamma_size)); + (vc4_crtc_state->assigned_channel *3 * crtc->gamma_size));for (i =0 ; i < crtc->gamma_size; i++)HVS_WRITE (SCALER_GAMDATA , vc4_crtc->lut_r[i]);
@@ -394,7 +396,7 @@ static void vc4_crtc_mode_set_nofb(struct drm_crtc *crtc)drm_print_regset32 (&p, &vc4_crtc->regset); } -if (vc4_crtc->channel ==2 ) { +if (vc4_crtc->data->hvs_output ==2 ) {u32 dispctrl;u32 dsp3_mux;
@@ -421,7 +423,7 @@ static void vc4_crtc_mode_set_nofb(struct drm_crtc *crtc)if (!vc4_state->feed_txp)vc4_crtc_config_pv (crtc); -HVS_WRITE (SCALER_DISPBKGNDX (vc4_crtc->channel), +HVS_WRITE (SCALER_DISPBKGNDX (vc4_state->assigned_channel),SCALER_DISPBKGND_AUTOHS |SCALER_DISPBKGND_GAMMA | (interlace ?SCALER_DISPBKGND_INTERLACE :0 ));
@@ -453,7 +455,8 @@ static void vc4_crtc_atomic_disable(struct drm_crtc *crtc,struct drm_device *dev = crtc->dev;struct vc4_dev *vc4 =to_vc4_dev (dev);struct vc4_crtc *vc4_crtc =to_vc4_crtc (crtc); -u32 chan = vc4_crtc->channel; +struct vc4_crtc_state *vc4_crtc_state =to_vc4_crtc_state (old_state); +u32 chan = vc4_crtc_state->assigned_channel;int ret;require_hvs_enabled (dev);
@@ -532,12 +535,12 @@ static void vc4_crtc_update_dlist(struct drm_crtc *crtc) crtc->state->event =NULL ; } -HVS_WRITE (SCALER_DISPLISTX (vc4_crtc->channel), +HVS_WRITE (SCALER_DISPLISTX (vc4_state->assigned_channel), vc4_state->mm.start);spin_unlock_irqrestore (&dev->event_lock, flags); }else { -HVS_WRITE (SCALER_DISPLISTX (vc4_crtc->channel), +HVS_WRITE (SCALER_DISPLISTX (vc4_state->assigned_channel), vc4_state->mm.start); } }
@@ -586,7 +589,7 @@ static void vc4_crtc_atomic_enable(struct drm_crtc *crtc, (vc4_state->feed_txp ?SCALER5_DISPCTRLX_ONESHOT :0 ); -HVS_WRITE (SCALER_DISPCTRLX (vc4_crtc->channel), dispctrl); +HVS_WRITE (SCALER_DISPCTRLX (vc4_state->assigned_channel), dispctrl);/* When feeding the transposer block the pixelvalve is unneeded and * should not be enabled.
@@ -702,7 +705,6 @@ static void vc4_crtc_atomic_flush(struct drm_crtc *crtc, {struct drm_device *dev = crtc->dev;struct vc4_dev *vc4 =to_vc4_dev (dev); -struct vc4_crtc *vc4_crtc =to_vc4_crtc (crtc);struct vc4_crtc_state *vc4_state =to_vc4_crtc_state (crtc->state);struct drm_plane *plane;struct vc4_plane_state *vc4_plane_state;
@@ -744,8 +746,8 @@ static void vc4_crtc_atomic_flush(struct drm_crtc *crtc,/* This sets a black background color fill, as is the case * with other DRM drivers. */ -HVS_WRITE (SCALER_DISPBKGNDX (vc4_crtc->channel), -HVS_READ (SCALER_DISPBKGNDX (vc4_crtc->channel)) | +HVS_WRITE (SCALER_DISPBKGNDX (vc4_state->assigned_channel), +HVS_READ (SCALER_DISPBKGNDX (vc4_state->assigned_channel)) |SCALER_DISPBKGND_FILL );/* Only update DISPLIST if the CRTC was already running and is not
@@ -759,7 +761,7 @@ static void vc4_crtc_atomic_flush(struct drm_crtc *crtc,vc4_crtc_update_dlist (crtc);if (crtc->state->color_mgmt_changed) { -u32 dispbkgndx =HVS_READ (SCALER_DISPBKGNDX (vc4_crtc->channel)); +u32 dispbkgndx =HVS_READ (SCALER_DISPBKGNDX (vc4_state->assigned_channel));if (crtc->state->gamma_lut) {vc4_crtc_update_gamma_lut (crtc);
@@ -771,7 +773,7 @@ static void vc4_crtc_atomic_flush(struct drm_crtc *crtc,*/ dispbkgndx &= ~SCALER_DISPBKGND_GAMMA ; } -HVS_WRITE (SCALER_DISPBKGNDX (vc4_crtc->channel), dispbkgndx); +HVS_WRITE (SCALER_DISPBKGNDX (vc4_state->assigned_channel), dispbkgndx); }if (debug_dump_regs) {
@@ -802,7 +804,7 @@ static void vc4_crtc_handle_page_flip(struct vc4_crtc *vc4_crtc)struct drm_device *dev = crtc->dev;struct vc4_dev *vc4 =to_vc4_dev (dev);struct vc4_crtc_state *vc4_state =to_vc4_crtc_state (crtc->state); -u32 chan = vc4_crtc->channel; +u32 chan = vc4_state->assigned_channel;unsigned long flags;spin_lock_irqsave (&dev->event_lock, flags);
@@ -1001,6 +1003,7 @@ static struct drm_crtc_state *vc4_crtc_duplicate_state(struct drm_crtc *crtc) old_vc4_state =to_vc4_crtc_state (crtc->state); vc4_state->feed_txp = old_vc4_state->feed_txp; vc4_state->margins = old_vc4_state->margins; + vc4_state->assigned_channel = old_vc4_state->assigned_channel;__drm_atomic_helper_crtc_duplicate_state (crtc, &vc4_state->base);return &vc4_state->base;
@@ -1060,6 +1063,7 @@ static const struct drm_crtc_helper_funcs vc4_crtc_helper_funcs = { };static const struct vc4_crtc_data bcm2835_pv0_data = { + .hvs_available_channels =BIT (0 ), .hvs_output =0 , .debugfs_name ="crtc0_regs" , .pixels_per_clock =1 ,
@@ -1070,6 +1074,7 @@ static const struct vc4_crtc_data bcm2835_pv0_data = { };static const struct vc4_crtc_data bcm2835_pv1_data = { + .hvs_available_channels =BIT (2 ), .hvs_output =2 , .debugfs_name ="crtc1_regs" , .pixels_per_clock =1 ,
@@ -1080,6 +1085,7 @@ static const struct vc4_crtc_data bcm2835_pv1_data = { };static const struct vc4_crtc_data bcm2835_pv2_data = { + .hvs_available_channels =BIT (1 ), .hvs_output =1 , .debugfs_name ="crtc2_regs" , .pixels_per_clock =1 ,
@@ -1171,7 +1177,6 @@ static int vc4_crtc_bind(struct device *dev, struct device *master, void *data)drm_crtc_init_with_planes (drm, crtc, primary_plane,NULL , &vc4_crtc_funcs,NULL );drm_crtc_helper_add (crtc, &vc4_crtc_helper_funcs); - vc4_crtc->channel = vc4_crtc->data->hvs_output;drm_mode_crtc_set_gamma_size (crtc,ARRAY_SIZE (vc4_crtc->lut_r));drm_crtc_enable_color_mgmt (crtc,0 , false, crtc->gamma_size);
drivers/gpu/drm/vc4/vc4_drv.h +4 -3
@@ -448,6 +448,9 @@ to_vc4_encoder(struct drm_encoder *encoder) }struct vc4_crtc_data { +/* Which channels of the HVS can the output source from */ +unsigned int hvs_available_channels; +/* Which output of the HVS this pixelvalve sources from. */ int hvs_output;
@@ -467,9 +470,6 @@ struct vc4_crtc {/* Timestamp at start of vblank irq - unaffected by lock delays. */ ktime_t t_vblank; -/* Which HVS channel we're using for our CRTC. */ -int channel; -u8 lut_r[256 ];u8 lut_g[256 ];u8 lut_b[256 ];
@@ -491,6 +491,7 @@ struct vc4_crtc_state {struct drm_mm_node mm;bool feed_txp;bool txp_armed; +unsigned int assigned_channel;struct {unsigned int left;
drivers/gpu/drm/vc4/vc4_kms.c +138 -5
185 lines not on this page · raw message
drivers/gpu/drm/vc4/vc4_regs.h +10 -0
@@ -287,9 +287,19 @@#define SCALER_DISPID 0x00000008#define SCALER_DISPECTRL 0x0000000c +# define SCALER_DISPECTRL_DSP2_MUX_SHIFT 31 +# define SCALER_DISPECTRL_DSP2_MUX_MASK VC4_MASK(31, 31) +#define SCALER_DISPPROF 0x00000010 +#define SCALER_DISPDITHER 0x00000014 +# define SCALER_DISPDITHER_DSP5_MUX_SHIFT 30 +# define SCALER_DISPDITHER_DSP5_MUX_MASK VC4_MASK(31, 30) +#define SCALER_DISPEOLN 0x00000018 +# define SCALER_DISPEOLN_DSP4_MUX_SHIFT 30 +# define SCALER_DISPEOLN_DSP4_MUX_MASK VC4_MASK(31, 30) +#define SCALER_DISPLIST0 0x00000020#define SCALER_DISPLIST1 0x00000024#define SCALER_DISPLIST2 0x00000028
Signature · 1 line
git-series 0.9.1
PATCH 53/89 drm/vc4: crtc: Add FIFO depth to vc4_crtc_data
In reply to Maxime RipardNot all pixelvalve FIFOs in vc5 have the same depth, so we need to add that to our vc4_crtc_data structure to be able to compute the fill level properly later on.
--- drivers/gpu/drm/vc4/vc4_crtc.c | 20 ++++++++++++++++---- drivers/gpu/drm/vc4/vc4_drv.h | 3 +++ 2 files changed, 19 insertions(+), 4 deletions(-)
drivers/gpu/drm/vc4/vc4_crtc.c +16 -4
@@ -250,11 +250,20 @@ vc4_crtc_update_gamma_lut(struct drm_crtc *crtc)vc4_crtc_lut_load (crtc); } - -static u32 vc4_get_fifo_full_level (u32 format) +static u32 vc4_get_fifo_full_level (struct vc4_crtc *vc4_crtc,u32 format) { -static const u32 fifo_len_bytes =64 ; +u32 fifo_len_bytes = vc4_crtc->data->fifo_depth; +/* +* Pixels are pulled from the HVS if the number of bytes is +* lower than the FIFO full level. +* +* The latency of the pixel fetch mechanism is 6 pixels, so we +* need to convert those 6 pixels in bytes, depending on the +* format, and then substract that from the length of the FIFO +* to make sure we never end up in a situation where the FIFO +* is full. +*/ switch (format) {case PV_CONTROL_FORMAT_DSIV_16 :case PV_CONTROL_FORMAT_DSIC_16 :
@@ -369,7 +378,7 @@ static void vc4_crtc_config_pv(struct drm_crtc *crtc) CRTC_WRITE(PV_CONTROL, VC4_SET_FIELD(format, PV_CONTROL_FORMAT) | - VC4_SET_FIELD(vc4_get_fifo_full_level(format), + VC4_SET_FIELD(vc4_get_fifo_full_level(vc4_crtc, format), PV_CONTROL_FIFO_LEVEL) | VC4_SET_FIELD(pixel_rep - 1, PV_CONTROL_PIXEL_REP) | PV_CONTROL_CLR_AT_START |
@@ -1066,6 +1075,7 @@ static const struct vc4_crtc_data bcm2835_pv0_data = { .hvs_available_channels = BIT(0), .hvs_output = 0, .debugfs_name = "crtc0_regs", + .fifo_depth = 64, .pixels_per_clock = 1, .encoder_types = { [PV_CONTROL_CLK_SELECT_DSI] = VC4_ENCODER_TYPE_DSI0,
@@ -1077,6 +1087,7 @@ static const struct vc4_crtc_data bcm2835_pv1_data = { .hvs_available_channels = BIT(2), .hvs_output = 2, .debugfs_name = "crtc1_regs", + .fifo_depth = 64, .pixels_per_clock = 1, .encoder_types = { [PV_CONTROL_CLK_SELECT_DSI] = VC4_ENCODER_TYPE_DSI1,
@@ -1088,6 +1099,7 @@ static const struct vc4_crtc_data bcm2835_pv2_data = { .hvs_available_channels = BIT(1), .hvs_output = 1, .debugfs_name = "crtc2_regs", + .fifo_depth = 64, .pixels_per_clock = 1, .encoder_types = { [PV_CONTROL_CLK_SELECT_DPI_SMI_HDMI] = VC4_ENCODER_TYPE_HDMI,
drivers/gpu/drm/vc4/vc4_drv.h +3 -0
@@ -448,6 +448,9 @@ to_vc4_encoder(struct drm_encoder *encoder) }struct vc4_crtc_data { +/* Depth of the PixelValve FIFO in bytes */ +unsigned int fifo_depth; +/* Which channels of the HVS can the output source from */ unsigned int hvs_available_channels;
Signature · 1 line
git-series 0.9.1
PATCH 54/89 drm/vc4: crtc: Add function to compute FIFO level bits
In reply to Maxime RipardThe longer FIFOs in vc5 pixelvalves means that the FIFO full level doesn't fit in the original register field and that we also have a secondary field. In order to prepare for this, let's move the registers fill part to a helper function.
--- drivers/gpu/drm/vc4/vc4_crtc.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/gpu/drm/vc4/vc4_crtc.c +9 -2
@@ -277,6 +277,14 @@ static u32 vc4_get_fifo_full_level(struct vc4_crtc *vc4_crtc, u32 format) } } +static u32 vc4_crtc_get_fifo_full_level_bits (struct vc4_crtc *vc4_crtc, +u32 format) +{ +u32 level =vc4_get_fifo_full_level (vc4_crtc, format); +return VC4_SET_FIELD (level &0x3f , +PV_CONTROL_FIFO_LEVEL ); +} +/* * Returns the encoder attached to the CRTC. *
@@ -377,9 +385,8 @@ static void vc4_crtc_config_pv(struct drm_crtc *crtc)CRTC_WRITE (PV_HACT_ACT , mode->hdisplay * pixel_rep); CRTC_WRITE(PV_CONTROL, + vc4_crtc_get_fifo_full_level_bits(vc4_crtc, format) | VC4_SET_FIELD(format, PV_CONTROL_FORMAT) | - VC4_SET_FIELD(vc4_get_fifo_full_level(vc4_crtc, format), - PV_CONTROL_FIFO_LEVEL) | VC4_SET_FIELD(pixel_rep - 1, PV_CONTROL_PIXEL_REP) | PV_CONTROL_CLR_AT_START | PV_CONTROL_TRIGGER_UNDERFLOW |
Signature · 1 line
git-series 0.9.1
PATCH 55/89 drm/vc4: crtc: Rename HDMI encoder type to HDMI0
In reply to Maxime RipardThe previous generations were only supporting a single HDMI controller, but that's about to change, so put an index as well to differentiate between the two controllers.
--- drivers/gpu/drm/vc4/vc4_crtc.c | 2 +- drivers/gpu/drm/vc4/vc4_drv.h | 2 +- drivers/gpu/drm/vc4/vc4_hdmi.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/vc4/vc4_crtc.c +1 -1
@@ -1109,7 +1109,7 @@ static const struct vc4_crtc_data bcm2835_pv2_data = { .fifo_depth = 64, .pixels_per_clock = 1, .encoder_types = { - [PV_CONTROL_CLK_SELECT_DPI_SMI_HDMI] = VC4_ENCODER_TYPE_HDMI, + [PV_CONTROL_CLK_SELECT_DPI_SMI_HDMI] = VC4_ENCODER_TYPE_HDMI0, [PV_CONTROL_CLK_SELECT_VEC] = VC4_ENCODER_TYPE_VEC, }, };
drivers/gpu/drm/vc4/vc4_drv.h +1 -1
@@ -427,7 +427,7 @@ to_vc4_plane_state(struct drm_plane_state *state)enum vc4_encoder_type {VC4_ENCODER_TYPE_NONE , -VC4_ENCODER_TYPE_HDMI , +VC4_ENCODER_TYPE_HDMI0 ,VC4_ENCODER_TYPE_VEC ,VC4_ENCODER_TYPE_DSI0 ,VC4_ENCODER_TYPE_DSI1 ,
drivers/gpu/drm/vc4/vc4_hdmi.c +1 -1
@@ -1305,7 +1305,7 @@ static int vc4_hdmi_bind(struct device *dev, struct device *master, void *data) GFP_KERNEL);if (!vc4_hdmi_encoder)return -ENOMEM ; - vc4_hdmi_encoder->base.type =VC4_ENCODER_TYPE_HDMI ; + vc4_hdmi_encoder->base.type =VC4_ENCODER_TYPE_HDMI0 ; hdmi->encoder = &vc4_hdmi_encoder->base.base; hdmi->pdev = pdev;
Signature · 1 line
git-series 0.9.1
PATCH 56/89 drm/vc4: crtc: Add HDMI1 encoder type
In reply to Maxime RipardThe BCM2711 sports a second HDMI controller, so let's add that second HDMI encoder type.
--- drivers/gpu/drm/vc4/vc4_drv.h | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/vc4/vc4_drv.h +1 -0
@@ -428,6 +428,7 @@ to_vc4_plane_state(struct drm_plane_state *state)enum vc4_encoder_type {VC4_ENCODER_TYPE_NONE ,VC4_ENCODER_TYPE_HDMI0 , +VC4_ENCODER_TYPE_HDMI1 ,VC4_ENCODER_TYPE_VEC ,VC4_ENCODER_TYPE_DSI0 ,VC4_ENCODER_TYPE_DSI1 ,
Signature · 1 line
git-series 0.9.1
PATCH 57/89 drm/vc4: crtc: Remove redundant call to drm_crtc_enable_color_mgmt
In reply to Maxime RipardThe driver calls the helper to add the color management properties twice, which is redundant. Remove the first one.
--- drivers/gpu/drm/vc4/vc4_crtc.c | 1 - 1 file changed, 1 deletion(-)
drivers/gpu/drm/vc4/vc4_crtc.c +0 -1
@@ -1197,7 +1197,6 @@ static int vc4_crtc_bind(struct device *dev, struct device *master, void *data) &vc4_crtc_funcs, NULL);drm_crtc_helper_add (crtc, &vc4_crtc_helper_funcs);drm_mode_crtc_set_gamma_size (crtc,ARRAY_SIZE (vc4_crtc->lut_r)); -drm_crtc_enable_color_mgmt (crtc,0 , false, crtc->gamma_size);/* We support CTM, but only for one CRTC at a time. It's therefore * implemented as private driver state in vc4_kms, not here.
Signature · 1 line
git-series 0.9.1
PATCH 58/89 drm/vc4: crtc: Disable color management for HVS5
In reply to Maxime RipardThe HVS5 uses different color matrices. Disable color management support for now.
--- drivers/gpu/drm/vc4/vc4_crtc.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-)
drivers/gpu/drm/vc4/vc4_crtc.c +11 -6
@@ -441,7 +441,7 @@ static void vc4_crtc_mode_set_nofb(struct drm_crtc *crtc)HVS_WRITE (SCALER_DISPBKGNDX (vc4_state->assigned_channel),SCALER_DISPBKGND_AUTOHS | -SCALER_DISPBKGND_GAMMA | + ((!vc4->hvs->hvs5) ?SCALER_DISPBKGND_GAMMA :0 ) | (interlace ?SCALER_DISPBKGND_INTERLACE :0 ));/* Reload the LUT, since the SRAMs would have been disabled if
@@ -1155,6 +1155,7 @@ static int vc4_crtc_bind(struct device *dev, struct device *master, void *data) {struct platform_device *pdev =to_platform_device (dev);struct drm_device *drm =dev_get_drvdata (master); +struct vc4_dev *vc4 =to_vc4_dev (drm);struct vc4_crtc *vc4_crtc;struct drm_crtc *crtc;struct drm_plane *primary_plane, *destroy_plane, *temp;
@@ -1196,12 +1197,16 @@ static int vc4_crtc_bind(struct device *dev, struct device *master, void *data)drm_crtc_init_with_planes (drm, crtc, primary_plane,NULL , &vc4_crtc_funcs,NULL );drm_crtc_helper_add (crtc, &vc4_crtc_helper_funcs); -drm_mode_crtc_set_gamma_size (crtc,ARRAY_SIZE (vc4_crtc->lut_r)); -/* We support CTM, but only for one CRTC at a time. It's therefore -* implemented as private driver state in vc4_kms, not here. -*/ -drm_crtc_enable_color_mgmt (crtc,0 , true, crtc->gamma_size); +if (!vc4->hvs->hvs5) { +drm_mode_crtc_set_gamma_size (crtc,ARRAY_SIZE (vc4_crtc->lut_r)); + +/* We support CTM, but only for one CRTC at a +* time. It's therefore implemented as private driver +* state in vc4_kms, not here. +*/ +drm_crtc_enable_color_mgmt (crtc,0 , true, crtc->gamma_size); + }CRTC_WRITE (PV_INTEN ,0 );CRTC_WRITE (PV_INTSTAT ,PV_INT_VFP_START );
Signature · 1 line
git-series 0.9.1
PATCH 59/89 dt-bindings: display: vc4: pv: Add BCM2711 pixel valves
In reply to Maxime RipardThe BCM2711 comes with other pixelvalves that have different requirements and capabilities. Let's document their compatible.
--- Documentation/devicetree/bindings/display/brcm,bcm2835-pixelvalve0.yaml | 5 +++++ 1 file changed, 5 insertions(+)
Documentation/devicetree/bindings/display/brcm,bcm2835-pixelvalve0.yaml +5 -0
@@ -15,6 +15,11 @@ properties: - brcm,bcm2835-pixelvalve0 - brcm,bcm2835-pixelvalve1 - brcm,bcm2835-pixelvalve2 + - brcm,bcm2711-pixelvalve0 + - brcm,bcm2711-pixelvalve1 + - brcm,bcm2711-pixelvalve2 + - brcm,bcm2711-pixelvalve3 + - brcm,bcm2711-pixelvalve4 reg: maxItems: 1
Signature · 1 line
git-series 0.9.1
Re: [PATCH 59/89] dt-bindings: display: vc4: pv: Add BCM2711 pixel valves
Quoted 10 lines · Maxime Ripard
The BCM2711 comes with other pixelvalves that have different requirements and capabilities. Let's document their compatible.
Cc Rob Herring <[email protected]>Signed-off-by Maxime Ripard <[email protected]>--- Documentation/devicetree/bindings/display/brcm,bcm2835-pixelvalve0.yaml | 5 +++++ 1 file changed, 5 insertions(+)
PATCH 60/89 drm/vc4: crtc: Add BCM2711 pixelvalves
In reply to Maxime RipardThe BCM2711 has 5 pixelvalves, so now that our driver is ready, let's add support for them.
--- drivers/gpu/drm/vc4/vc4_crtc.c | 82 ++++++++++++++++++++++++++++++++++- drivers/gpu/drm/vc4/vc4_regs.h | 6 +++- 2 files changed, 86 insertions(+), 2 deletions(-)
drivers/gpu/drm/vc4/vc4_crtc.c +80 -2
@@ -273,6 +273,13 @@ static u32 vc4_get_fifo_full_level(struct vc4_crtc *vc4_crtc, u32 format)case PV_CONTROL_FORMAT_24 :case PV_CONTROL_FORMAT_DSIV_24 :default : +/* +* For some reason, the pixelvalve4 doesn't work with +* the usual formula and will only work with 32. +*/ +if (vc4_crtc->data->hvs_output ==5 ) +return 32 ; +return fifo_len_bytes -3 *HVS_FIFO_LATENCY_PIX ; } }
@@ -281,8 +288,14 @@ static u32 vc4_crtc_get_fifo_full_level_bits(struct vc4_crtc *vc4_crtc, u32 format) {u32 level =vc4_get_fifo_full_level (vc4_crtc, format); -return VC4_SET_FIELD (level &0x3f , -PV_CONTROL_FIFO_LEVEL ); +u32 ret =0 ; + +if (level >0x3f ) + ret |=VC4_SET_FIELD ((level >>6 ) &0x3 , +PV5_CONTROL_FIFO_LEVEL_HIGH ); + +return ret |VC4_SET_FIELD (level &0x3f , +PV_CONTROL_FIFO_LEVEL ); }/*
@@ -328,6 +341,9 @@ static void vc4_crtc_config_pv(struct drm_crtc *crtc)CRTC_WRITE (PV_CONTROL ,PV_CONTROL_FIFO_CLR |PV_CONTROL_EN );CRTC_WRITE (PV_CONTROL ,0 ); +CRTC_WRITE (PV_MUX_CFG , +VC4_SET_FIELD (8 ,PV_MUX_CFG_RGB_PIXEL_MUX_MODE )); + CRTC_WRITE(PV_HORZA, VC4_SET_FIELD((mode->htotal - mode->hsync_end) * pixel_rep / ppc, PV_HORZA_HBP) |
@@ -1114,10 +1130,72 @@ static const struct vc4_crtc_data bcm2835_pv2_data = { }, }; +static const struct vc4_crtc_data bcm2711_pv0_data = { + .debugfs_name ="crtc0_regs" , + .hvs_available_channels =BIT (0 ), + .hvs_output =0 , + .fifo_depth =64 , + .pixels_per_clock =1 , + .encoder_types = { + [0 ] =VC4_ENCODER_TYPE_DSI0 , + [1 ] =VC4_ENCODER_TYPE_DPI , + }, +}; + +static const struct vc4_crtc_data bcm2711_pv1_data = { + .debugfs_name ="crtc1_regs" , + .hvs_available_channels =BIT (0 ) |BIT (1 ) |BIT (2 ), + .hvs_output =3 , + .fifo_depth =64 , + .pixels_per_clock =1 , + .encoder_types = { + [0 ] =VC4_ENCODER_TYPE_DSI1 , + [1 ] =VC4_ENCODER_TYPE_SMI , + }, +}; + +static const struct vc4_crtc_data bcm2711_pv2_data = { + .debugfs_name ="crtc2_regs" , + .hvs_available_channels =BIT (0 ) |BIT (1 ) |BIT (2 ), + .hvs_output =4 , + .fifo_depth =256 , + .pixels_per_clock =2 , + .encoder_types = { + [0 ] =VC4_ENCODER_TYPE_HDMI0 , + }, +}; + +static const struct vc4_crtc_data bcm2711_pv3_data = { + .debugfs_name ="crtc3_regs" , + .hvs_available_channels =BIT (1 ), + .hvs_output =1 , + .fifo_depth =64 , + .pixels_per_clock =1 , + .encoder_types = { + [0 ] =VC4_ENCODER_TYPE_VEC , + }, +}; + +static const struct vc4_crtc_data bcm2711_pv4_data = { + .debugfs_name ="crtc4_regs" , + .hvs_available_channels =BIT (0 ) |BIT (1 ) |BIT (2 ), + .hvs_output =5 , + .fifo_depth =64 , + .pixels_per_clock =2 , + .encoder_types = { + [0 ] =VC4_ENCODER_TYPE_HDMI1 , + }, +}; +static const struct of_device_id vc4_crtc_dt_match[] = { { .compatible ="brcm,bcm2835-pixelvalve0" , .data = &bcm2835_pv0_data }, { .compatible ="brcm,bcm2835-pixelvalve1" , .data = &bcm2835_pv1_data }, { .compatible ="brcm,bcm2835-pixelvalve2" , .data = &bcm2835_pv2_data }, + { .compatible ="brcm,bcm2711-pixelvalve0" , .data = &bcm2711_pv0_data }, + { .compatible ="brcm,bcm2711-pixelvalve1" , .data = &bcm2711_pv1_data }, + { .compatible ="brcm,bcm2711-pixelvalve2" , .data = &bcm2711_pv2_data }, + { .compatible ="brcm,bcm2711-pixelvalve3" , .data = &bcm2711_pv3_data }, + { .compatible ="brcm,bcm2711-pixelvalve4" , .data = &bcm2711_pv4_data }, {} };
drivers/gpu/drm/vc4/vc4_regs.h +6 -0
@@ -130,6 +130,8 @@#define V3D_ERRSTAT 0x00f20#define PV_CONTROL 0x00 +# define PV5_CONTROL_FIFO_LEVEL_HIGH_MASK VC4_MASK(26, 25) +# define PV5_CONTROL_FIFO_LEVEL_HIGH_SHIFT 25# define PV_CONTROL_FORMAT_MASK VC4_MASK(23, 21)# define PV_CONTROL_FORMAT_SHIFT 21# define PV_CONTROL_FORMAT_24 0
@@ -209,6 +211,10 @@#define PV_HACT_ACT 0x30 +#define PV_MUX_CFG 0x34 +# define PV_MUX_CFG_RGB_PIXEL_MUX_MODE_MASK VC4_MASK(5, 2) +# define PV_MUX_CFG_RGB_PIXEL_MUX_MODE_SHIFT 2 +#define SCALER_CHANNELS_COUNT 3#define SCALER_DISPCTRL 0x00000000
Signature · 1 line
git-series 0.9.1
PATCH 61/89 drm/vc4: hdmi: Use debugfs private field
In reply to Maxime RipardWe're calling vc4_debugfs_add_file with our struct vc4_hdmi pointer set in the private field, but we don't use that field and go through the main struct vc4_dev to get it.
Let's use the private field directly, that will save us some trouble later on.
--- drivers/gpu/drm/vc4/vc4_hdmi.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/vc4/vc4_hdmi.c +1 -3
@@ -182,9 +182,7 @@ static const struct debugfs_reg32 hd_regs[] = {static int vc4_hdmi_debugfs_regs (struct seq_file *m,void *unused) {struct drm_info_node *node = (struct drm_info_node *)m->private; -struct drm_device *dev = node->minor->dev; -struct vc4_dev *vc4 =to_vc4_dev (dev); -struct vc4_hdmi *hdmi = vc4->hdmi; +struct vc4_hdmi *hdmi = node->info_ent->data;struct drm_printer p =drm_seq_file_printer (m);drm_print_regset32 (&p, &hdmi->hdmi_regset);
Signature · 1 line
git-series 0.9.1
PATCH 62/89 drm/vc4: hdmi: Move structure to header
In reply to Maxime RipardWe will need to share the vc4_hdmi and related structures with multiple files, so let's create a header for it.
--- drivers/gpu/drm/vc4/vc4_hdmi.c | 76 +------------------------------- drivers/gpu/drm/vc4/vc4_hdmi.h | 86 +++++++++++++++++++++++++++++++++++- 2 files changed, 87 insertions(+), 75 deletions(-) create mode 100644 drivers/gpu/drm/vc4/vc4_hdmi.h
drivers/gpu/drm/vc4/vc4_hdmi.c +1 -75
@@ -48,87 +48,13 @@#include <sound/soc.h> #include "media/cec.h" #include "vc4_drv.h" +#include "vc4_hdmi.h" #include "vc4_regs.h" #define HSM_CLOCK_FREQ 163682864#define CEC_CLOCK_FREQ 40000#define CEC_CLOCK_DIV (HSM_CLOCK_FREQ / CEC_CLOCK_FREQ) -/* HDMI audio information */ -struct vc4_hdmi_audio { -struct snd_soc_card card; -struct snd_soc_dai_link link; -struct snd_soc_dai_link_component cpu; -struct snd_soc_dai_link_component codec; -struct snd_soc_dai_link_component platform; -int samplerate; -int channels; -struct snd_dmaengine_dai_dma_data dma_data; -struct snd_pcm_substream *substream; -}; - -/* General HDMI hardware state. */ -struct vc4_hdmi { -struct platform_device *pdev; - -struct drm_encoder *encoder; -struct drm_connector *connector; - -struct vc4_hdmi_audio audio; - -struct i2c_adapter *ddc; -void __iomem *hdmicore_regs; -void __iomem *hd_regs; -int hpd_gpio; -bool hpd_active_low; - -struct cec_adapter *cec_adap; -struct cec_msg cec_rx_msg; -bool cec_tx_ok; -bool cec_irq_was_rx; - -struct clk *pixel_clock; -struct clk *hsm_clock; - -struct debugfs_regset32 hdmi_regset; -struct debugfs_regset32 hd_regset; -}; - -#define HDMI_READ (offset) readl(vc4->hdmi->hdmicore_regs + offset) -#define HDMI_WRITE (offset, val) writel(val, vc4->hdmi->hdmicore_regs + offset) -#define HD_READ (offset) readl(vc4->hdmi->hd_regs + offset) -#define HD_WRITE (offset, val) writel(val, vc4->hdmi->hd_regs + offset) - -/* VC4 HDMI encoder KMS struct */ -struct vc4_hdmi_encoder { -struct vc4_encoder base; -bool hdmi_monitor; -bool limited_rgb_range; -}; - -static inline struct vc4_hdmi_encoder * -to_vc4_hdmi_encoder (struct drm_encoder *encoder) -{ - return container_of(encoder, struct vc4_hdmi_encoder, base.base); -} - -/* VC4 HDMI connector KMS struct */ -struct vc4_hdmi_connector { -struct drm_connector base; - -/* Since the connector is attached to just the one encoder, -* this is the reference to it so we can do the best_encoder() -* hook. -*/ -struct drm_encoder *encoder; -}; - -static inline struct vc4_hdmi_connector * -to_vc4_hdmi_connector (struct drm_connector *connector) -{ - return container_of(connector, struct vc4_hdmi_connector, base); -} -static const struct debugfs_reg32 hdmi_regs[] = {VC4_REG32 (VC4_HDMI_CORE_REV ),VC4_REG32 (VC4_HDMI_SW_RESET_CONTROL ),
drivers/gpu/drm/vc4/vc4_hdmi.h new file +86 -0
86 lines not on this page · raw message
Signature · 1 line
git-series 0.9.1
PATCH 63/89 drm/vc4: hdmi: rework connectors and encoders
In reply to Maxime Ripardthe vc4_hdmi driver has some custom structures to hold the data it needs to associate with the drm_encoder and drm_connector structures.
However, it allocates them separately from the vc4_hdmi structure which makes it more complicated than it needs to be.
Move those structures to be contained by vc4_hdmi and update the code accordingly.
--- drivers/gpu/drm/vc4/vc4_hdmi.c | 85 ++++++++++++++++------------------- drivers/gpu/drm/vc4/vc4_hdmi.h | 64 +++++++++++++------------- 2 files changed, 71 insertions(+), 78 deletions(-)
drivers/gpu/drm/vc4/vc4_hdmi.c +39 -46
@@ -190,20 +190,15 @@ static const struct drm_connector_helper_funcs vc4_hdmi_connector_helper_funcs = .get_modes = vc4_hdmi_connector_get_modes, }; -static struct drm_connector *vc4_hdmi_connector_init (struct drm_device *dev, -struct drm_encoder *encoder, -struct i2c_adapter *ddc) +static int vc4_hdmi_connector_init (struct drm_device *dev, +struct vc4_hdmi *vc4_hdmi, +struct i2c_adapter *ddc) { -struct drm_connector *connector; -struct vc4_hdmi_connector *hdmi_connector; +struct vc4_hdmi_connector *hdmi_connector = &vc4_hdmi->connector; +struct drm_connector *connector = &hdmi_connector->base; +struct drm_encoder *encoder = &vc4_hdmi->encoder.base.base;int ret; - hdmi_connector =devm_kzalloc (dev->dev,sizeof (*hdmi_connector), -GFP_KERNEL ); -if (!hdmi_connector) -return ERR_PTR (-ENOMEM ); - connector = &hdmi_connector->base; - hdmi_connector->encoder = encoder; drm_connector_init_with_ddc(dev, connector,
@@ -215,7 +210,7 @@ static struct drm_connector *vc4_hdmi_connector_init(struct drm_device *dev,/* Create and attach TV margin props to this connector. */ ret =drm_mode_create_tv_margin_properties (dev);if (ret) -return ERR_PTR (ret); +return ret;drm_connector_attach_tv_margin_properties (connector);
@@ -227,7 +222,7 @@ static struct drm_connector *vc4_hdmi_connector_init(struct drm_device *dev,drm_connector_attach_encoder (connector, encoder); -return connector; +return 0 ; }static void vc4_hdmi_encoder_destroy (struct drm_encoder *encoder)
@@ -306,21 +301,22 @@ static void vc4_hdmi_set_avi_infoframe(struct drm_encoder *encoder)struct vc4_hdmi_encoder *vc4_encoder =to_vc4_hdmi_encoder (encoder);struct vc4_dev *vc4 = encoder->dev->dev_private;struct vc4_hdmi *hdmi = vc4->hdmi; -struct drm_connector_state *cstate = hdmi->connector->state; +struct drm_connector *connector = &hdmi->connector.base; +struct drm_connector_state *cstate = connector->state;struct drm_crtc *crtc = encoder->crtc;const struct drm_display_mode *mode = &crtc->state->adjusted_mode;union hdmi_infoframe frame;int ret; ret =drm_hdmi_avi_infoframe_from_display_mode (&frame.avi, - hdmi->connector, mode); + connector, mode);if (ret <0 ) {DRM_ERROR ("couldn't fill AVI infoframe\n" );return ; }drm_hdmi_avi_infoframe_quant_range (&frame.avi, - hdmi->connector, mode, + connector, mode, vc4_encoder->limited_rgb_range ?HDMI_QUANTIZATION_RANGE_LIMITED :HDMI_QUANTIZATION_RANGE_FULL );
@@ -624,7 +620,8 @@ static const struct drm_encoder_helper_funcs vc4_hdmi_encoder_helper_funcs = {/* HDMI audio codec callbacks */ static void vc4_hdmi_audio_set_mai_clock (struct vc4_hdmi *hdmi) { -struct drm_device *drm = hdmi->encoder->dev; +struct drm_encoder *encoder = &hdmi->encoder.base.base; +struct drm_device *drm = encoder->dev;struct vc4_dev *vc4 =to_vc4_dev (drm);u32 hsm_clock =clk_get_rate (hdmi->hsm_clock);unsigned long n, m;
@@ -643,7 +640,7 @@ static void vc4_hdmi_audio_set_mai_clock(struct vc4_hdmi *hdmi)static void vc4_hdmi_set_n_cts (struct vc4_hdmi *hdmi) { -struct drm_encoder *encoder = hdmi->encoder; +struct drm_encoder *encoder = &hdmi->encoder.base.base;struct drm_crtc *crtc = encoder->crtc;struct drm_device *drm = encoder->dev;struct vc4_dev *vc4 =to_vc4_dev (drm);
@@ -681,7 +678,8 @@ static int vc4_hdmi_audio_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) {struct vc4_hdmi *hdmi =dai_to_hdmi (dai); -struct drm_encoder *encoder = hdmi->encoder; +struct drm_encoder *encoder = &hdmi->encoder.base.base; +struct drm_connector *connector = &hdmi->connector.base;struct vc4_dev *vc4 =to_vc4_dev (encoder->dev);int ret;
@@ -698,8 +696,7 @@ static int vc4_hdmi_audio_startup(struct snd_pcm_substream *substream, VC4_HDMI_RAM_PACKET_ENABLE))return -ENODEV ; - ret =snd_pcm_hw_constraint_eld (substream->runtime, - hdmi->connector->eld); + ret =snd_pcm_hw_constraint_eld (substream->runtime, connector->eld);if (ret)return ret;
@@ -713,7 +710,7 @@ static int vc4_hdmi_audio_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)static void vc4_hdmi_audio_reset (struct vc4_hdmi *hdmi) { -struct drm_encoder *encoder = hdmi->encoder; +struct drm_encoder *encoder = &hdmi->encoder.base.base;struct drm_device *drm = encoder->dev;struct device *dev = &hdmi->pdev->dev;struct vc4_dev *vc4 =to_vc4_dev (drm);
@@ -747,7 +744,7 @@ static int vc4_hdmi_audio_hw_params(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) {struct vc4_hdmi *hdmi =dai_to_hdmi (dai); -struct drm_encoder *encoder = hdmi->encoder; +struct drm_encoder *encoder = &hdmi->encoder.base.base;struct drm_device *drm = encoder->dev;struct device *dev = &hdmi->pdev->dev;struct vc4_dev *vc4 =to_vc4_dev (drm);
@@ -820,7 +817,7 @@ static int vc4_hdmi_audio_trigger(struct snd_pcm_substream *substream, int cmd, struct snd_soc_dai *dai) {struct vc4_hdmi *hdmi =dai_to_hdmi (dai); -struct drm_encoder *encoder = hdmi->encoder; +struct drm_encoder *encoder = &hdmi->encoder.base.base;struct drm_device *drm = encoder->dev;struct vc4_dev *vc4 =to_vc4_dev (drm);
@@ -864,9 +861,10 @@ static int vc4_hdmi_audio_eld_ctl_info(struct snd_kcontrol *kcontrol, {struct snd_soc_component *component =snd_kcontrol_chip (kcontrol);struct vc4_hdmi *hdmi =snd_component_to_hdmi (component); +struct drm_connector *connector = &hdmi->connector.base; uinfo->type =SNDRV_CTL_ELEM_TYPE_BYTES ; - uinfo->count =sizeof (hdmi->connector->eld); + uinfo->count =sizeof (connector->eld);return 0 ; }
@@ -876,9 +874,10 @@ static int vc4_hdmi_audio_eld_ctl_get(struct snd_kcontrol *kcontrol, {struct snd_soc_component *component =snd_kcontrol_chip (kcontrol);struct vc4_hdmi *hdmi =snd_component_to_hdmi (component); +struct drm_connector *connector = &hdmi->connector.base; -memcpy (ucontrol->value.bytes.data, hdmi->connector->eld, -sizeof (hdmi->connector->eld)); +memcpy (ucontrol->value.bytes.data, connector->eld, +sizeof (connector->eld));return 0 ; }
@@ -1216,7 +1215,7 @@ static int vc4_hdmi_bind(struct device *dev, struct device *master, void *data)struct drm_device *drm =dev_get_drvdata (master);struct vc4_dev *vc4 = drm->dev_private;struct vc4_hdmi *hdmi; -struct vc4_hdmi_encoder *vc4_hdmi_encoder; +struct drm_encoder *encoder;struct device_node *ddc_node;u32 value;int ret;
@@ -1225,14 +1224,10 @@ static int vc4_hdmi_bind(struct device *dev, struct device *master, void *data)if (!hdmi)return -ENOMEM ; - vc4_hdmi_encoder =devm_kzalloc (dev,sizeof (*vc4_hdmi_encoder), -GFP_KERNEL ); -if (!vc4_hdmi_encoder) -return -ENOMEM ; - vc4_hdmi_encoder->base.type =VC4_ENCODER_TYPE_HDMI0 ; - hdmi->encoder = &vc4_hdmi_encoder->base.base; - hdmi->pdev = pdev; + encoder = &hdmi->encoder.base.base; + encoder->base.type =VC4_ENCODER_TYPE_HDMI0 ; + hdmi->hdmicore_regs =vc4_ioremap_regs (pdev,0 );if (IS_ERR (hdmi->hdmicore_regs))return PTR_ERR (hdmi->hdmicore_regs);
@@ -1318,16 +1313,14 @@ static int vc4_hdmi_bind(struct device *dev, struct device *master, void *data) }pm_runtime_enable (dev); -drm_encoder_init (drm, hdmi->encoder, &vc4_hdmi_encoder_funcs, +drm_encoder_init (drm, encoder, &vc4_hdmi_encoder_funcs,DRM_MODE_ENCODER_TMDS ,NULL ); -drm_encoder_helper_add (hdmi->encoder, &vc4_hdmi_encoder_helper_funcs); +drm_encoder_helper_add (encoder, &vc4_hdmi_encoder_helper_funcs); - hdmi->connector = -vc4_hdmi_connector_init (drm, hdmi->encoder, hdmi->ddc); -if (IS_ERR (hdmi->connector)) { - ret =PTR_ERR (hdmi->connector); + ret =vc4_hdmi_connector_init (drm, vc4_hdmi, vc4_hdmi->ddc); +if (ret) goto err_destroy_encoder; - } +#ifdef CONFIG_DRM_VC4_HDMI_CEC hdmi->cec_adap = cec_allocate_adapter(&vc4_hdmi_cec_adap_ops, vc4, "vc4",
@@ -1374,10 +1367,10 @@ static int vc4_hdmi_bind(struct device *dev, struct device *master, void *data) err_delete_cec_adap:cec_delete_adapter (hdmi->cec_adap); err_destroy_conn: -vc4_hdmi_connector_destroy (hdmi->connector); +vc4_hdmi_connector_destroy (&hdmi->connector.base);#endif err_destroy_encoder: -vc4_hdmi_encoder_destroy (hdmi->encoder); +vc4_hdmi_encoder_destroy (encoder); err_unprepare_hsm:clk_disable_unprepare (hdmi->hsm_clock);pm_runtime_disable (dev);
@@ -1395,8 +1388,8 @@ static void vc4_hdmi_unbind(struct device *dev, struct device *master,struct vc4_hdmi *hdmi = vc4->hdmi;cec_unregister_adapter (hdmi->cec_adap); -vc4_hdmi_connector_destroy (hdmi->connector); -vc4_hdmi_encoder_destroy (hdmi->encoder); +vc4_hdmi_connector_destroy (&hdmi->connector.base); +vc4_hdmi_encoder_destroy (&hdmi->encoder.base.base);clk_disable_unprepare (hdmi->hsm_clock);pm_runtime_disable (dev);
drivers/gpu/drm/vc4/vc4_hdmi.h +32 -32
80 lines not on this page · raw message
Signature · 1 line
git-series 0.9.1
PATCH 64/89 drm/vc4: hdmi: Remove DDC argument to connector_init
In reply to Maxime RipardNow that we are passing the vc4_hdmi structure to the connector init function, we can simply use the pointer in that structure instead of having the pointer as an argument.
--- drivers/gpu/drm/vc4/vc4_hdmi.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/gpu/drm/vc4/vc4_hdmi.c +3 -4
@@ -191,8 +191,7 @@ static const struct drm_connector_helper_funcs vc4_hdmi_connector_helper_funcs = };static int vc4_hdmi_connector_init (struct drm_device *dev, -struct vc4_hdmi *vc4_hdmi, -struct i2c_adapter *ddc) +struct vc4_hdmi *vc4_hdmi) {struct vc4_hdmi_connector *hdmi_connector = &vc4_hdmi->connector;struct drm_connector *connector = &hdmi_connector->base;
@@ -204,7 +203,7 @@ static int vc4_hdmi_connector_init(struct drm_device *dev,drm_connector_init_with_ddc (dev, connector, &vc4_hdmi_connector_funcs,DRM_MODE_CONNECTOR_HDMIA , - ddc); + vc4_hdmi->ddc);drm_connector_helper_add (connector, &vc4_hdmi_connector_helper_funcs);/* Create and attach TV margin props to this connector. */
@@ -1317,7 +1316,7 @@ static int vc4_hdmi_bind(struct device *dev, struct device *master, void *data) DRM_MODE_ENCODER_TMDS, NULL);drm_encoder_helper_add (encoder, &vc4_hdmi_encoder_helper_funcs); - ret =vc4_hdmi_connector_init (drm, vc4_hdmi, vc4_hdmi->ddc); + ret =vc4_hdmi_connector_init (drm, vc4_hdmi);if (ret) goto err_destroy_encoder;
Signature · 1 line
git-series 0.9.1
PATCH 65/89 drm/vc4: hdmi: Rename hdmi to vc4_hdmi
In reply to Maxime RipardThe driver isn't consistent with the name given to the vc4_hdmi structure pointer in its functions. Make sure to use a consistent name.
--- drivers/gpu/drm/vc4/vc4_hdmi.c | 265 +++++++++++++++++----------------- 1 file changed, 133 insertions(+), 132 deletions(-)
drivers/gpu/drm/vc4/vc4_hdmi.c +133 -132
@@ -108,11 +108,11 @@ static const struct debugfs_reg32 hd_regs[] = {static int vc4_hdmi_debugfs_regs (struct seq_file *m,void *unused) {struct drm_info_node *node = (struct drm_info_node *)m->private; -struct vc4_hdmi *hdmi = node->info_ent->data; +struct vc4_hdmi *vc4_hdmi = node->info_ent->data;struct drm_printer p =drm_seq_file_printer (m); -drm_print_regset32 (&p, &hdmi->hdmi_regset); -drm_print_regset32 (&p, &hdmi->hd_regset); +drm_print_regset32 (&p, &vc4_hdmi->hdmi_regset); +drm_print_regset32 (&p, &vc4_hdmi->hd_regset);return 0 ; }
@@ -299,8 +299,8 @@ static void vc4_hdmi_set_avi_infoframe(struct drm_encoder *encoder) {struct vc4_hdmi_encoder *vc4_encoder =to_vc4_hdmi_encoder (encoder);struct vc4_dev *vc4 = encoder->dev->dev_private; -struct vc4_hdmi *hdmi = vc4->hdmi; -struct drm_connector *connector = &hdmi->connector.base; +struct vc4_hdmi *vc4_hdmi = vc4->hdmi; +struct drm_connector *connector = &vc4_hdmi->connector.base;struct drm_connector_state *cstate = connector->state;struct drm_crtc *crtc = encoder->crtc;const struct drm_display_mode *mode = &crtc->state->adjusted_mode;
@@ -345,7 +345,7 @@ static void vc4_hdmi_set_audio_infoframe(struct drm_encoder *encoder) {struct drm_device *drm = encoder->dev;struct vc4_dev *vc4 = drm->dev_private; -struct vc4_hdmi *hdmi = vc4->hdmi; +struct vc4_hdmi *vc4_hdmi = vc4->hdmi;union hdmi_infoframe frame;int ret;
@@ -354,7 +354,7 @@ static void vc4_hdmi_set_audio_infoframe(struct drm_encoder *encoder) frame.audio.coding_type =HDMI_AUDIO_CODING_TYPE_STREAM ; frame.audio.sample_frequency =HDMI_AUDIO_SAMPLE_FREQUENCY_STREAM ; frame.audio.sample_size =HDMI_AUDIO_SAMPLE_SIZE_STREAM ; - frame.audio.channels = hdmi->audio.channels; + frame.audio.channels = vc4_hdmi->audio.channels;vc4_hdmi_write_infoframe (encoder, &frame); }
@@ -369,7 +369,7 @@ static void vc4_hdmi_encoder_disable(struct drm_encoder *encoder) {struct drm_device *dev = encoder->dev;struct vc4_dev *vc4 =to_vc4_dev (dev); -struct vc4_hdmi *hdmi = vc4->hdmi; +struct vc4_hdmi *vc4_hdmi = vc4->hdmi;int ret;HDMI_WRITE (VC4_HDMI_RAM_PACKET_CONFIG ,0 );
@@ -378,9 +378,9 @@ static void vc4_hdmi_encoder_disable(struct drm_encoder *encoder)HD_WRITE (VC4_HD_VID_CTL ,HD_READ (VC4_HD_VID_CTL ) & ~VC4_HD_VID_CTL_ENABLE ); -clk_disable_unprepare (hdmi->pixel_clock); +clk_disable_unprepare (vc4_hdmi->pixel_clock); - ret =pm_runtime_put (&hdmi->pdev->dev); + ret =pm_runtime_put (&vc4_hdmi->pdev->dev);if (ret <0 )DRM_ERROR ("Failed to release power domain: %d\n" , ret); }
@@ -391,7 +391,7 @@ static void vc4_hdmi_encoder_enable(struct drm_encoder *encoder)struct vc4_hdmi_encoder *vc4_encoder =to_vc4_hdmi_encoder (encoder);struct drm_device *dev = encoder->dev;struct vc4_dev *vc4 =to_vc4_dev (dev); -struct vc4_hdmi *hdmi = vc4->hdmi; +struct vc4_hdmi *vc4_hdmi = vc4->hdmi;bool debug_dump_regs = false;bool hsync_pos = mode->flags &DRM_MODE_FLAG_PHSYNC ;bool vsync_pos = mode->flags &DRM_MODE_FLAG_PVSYNC ;
@@ -413,13 +413,13 @@ static void vc4_hdmi_encoder_enable(struct drm_encoder *encoder)u32 csc_ctl;int ret; - ret =pm_runtime_get_sync (&hdmi->pdev->dev); + ret =pm_runtime_get_sync (&vc4_hdmi->pdev->dev);if (ret <0 ) {DRM_ERROR ("Failed to retain power domain: %d\n" , ret);return ; } - ret =clk_set_rate (hdmi->pixel_clock, + ret =clk_set_rate (vc4_hdmi->pixel_clock, mode->clock *1000 * ((mode->flags &DRM_MODE_FLAG_DBLCLK ) ?2 :1 ));if (ret) {
@@ -427,7 +427,7 @@ static void vc4_hdmi_encoder_enable(struct drm_encoder *encoder)return ; } - ret =clk_prepare_enable (hdmi->pixel_clock); + ret =clk_prepare_enable (vc4_hdmi->pixel_clock);if (ret) {DRM_ERROR ("Failed to turn on pixel clock: %d\n" , ret);return ;
@@ -447,11 +447,11 @@ static void vc4_hdmi_encoder_enable(struct drm_encoder *encoder)HDMI_WRITE (VC4_HDMI_TX_PHY_RESET_CTL ,0 );if (debug_dump_regs) { -struct drm_printer p =drm_info_printer (&hdmi->pdev->dev); +struct drm_printer p =drm_info_printer (&vc4_hdmi->pdev->dev); -dev_info (&hdmi->pdev->dev,"HDMI regs before:\n" ); -drm_print_regset32 (&p, &hdmi->hdmi_regset); -drm_print_regset32 (&p, &hdmi->hd_regset); +dev_info (&vc4_hdmi->pdev->dev,"HDMI regs before:\n" ); +drm_print_regset32 (&p, &vc4_hdmi->hdmi_regset); +drm_print_regset32 (&p, &vc4_hdmi->hd_regset); }HD_WRITE (VC4_HD_VID_CTL ,0 );
@@ -526,11 +526,11 @@ static void vc4_hdmi_encoder_enable(struct drm_encoder *encoder)HDMI_WRITE (VC4_HDMI_FIFO_CTL ,VC4_HDMI_FIFO_CTL_MASTER_SLAVE_N );if (debug_dump_regs) { -struct drm_printer p =drm_info_printer (&hdmi->pdev->dev); +struct drm_printer p =drm_info_printer (&vc4_hdmi->pdev->dev); -dev_info (&hdmi->pdev->dev,"HDMI regs after:\n" ); -drm_print_regset32 (&p, &hdmi->hdmi_regset); -drm_print_regset32 (&p, &hdmi->hd_regset); +dev_info (&vc4_hdmi->pdev->dev,"HDMI regs after:\n" ); +drm_print_regset32 (&p, &vc4_hdmi->hdmi_regset); +drm_print_regset32 (&p, &vc4_hdmi->hd_regset); } HD_WRITE(VC4_HD_VID_CTL,
@@ -617,15 +617,15 @@ static const struct drm_encoder_helper_funcs vc4_hdmi_encoder_helper_funcs = { };/* HDMI audio codec callbacks */ -static void vc4_hdmi_audio_set_mai_clock (struct vc4_hdmi *hdmi) +static void vc4_hdmi_audio_set_mai_clock (struct vc4_hdmi *vc4_hdmi) { -struct drm_encoder *encoder = &hdmi->encoder.base.base; +struct drm_encoder *encoder = &vc4_hdmi->encoder.base.base;struct drm_device *drm = encoder->dev;struct vc4_dev *vc4 =to_vc4_dev (drm); -u32 hsm_clock =clk_get_rate (hdmi->hsm_clock); +u32 hsm_clock =clk_get_rate (vc4_hdmi->hsm_clock);unsigned long n, m; - rational_best_approximation(hsm_clock, hdmi->audio.samplerate, + rational_best_approximation(hsm_clock, vc4_hdmi->audio.samplerate, VC4_HD_MAI_SMP_N_MASK >> VC4_HD_MAI_SMP_N_SHIFT, (VC4_HD_MAI_SMP_M_MASK >>
@@ -637,14 +637,14 @@ static void vc4_hdmi_audio_set_mai_clock(struct vc4_hdmi *hdmi) VC4_SET_FIELD(m - 1, VC4_HD_MAI_SMP_M)); } -static void vc4_hdmi_set_n_cts (struct vc4_hdmi *hdmi) +static void vc4_hdmi_set_n_cts (struct vc4_hdmi *vc4_hdmi) { -struct drm_encoder *encoder = &hdmi->encoder.base.base; +struct drm_encoder *encoder = &vc4_hdmi->encoder.base.base;struct drm_crtc *crtc = encoder->crtc;struct drm_device *drm = encoder->dev;struct vc4_dev *vc4 =to_vc4_dev (drm);const struct drm_display_mode *mode = &crtc->state->adjusted_mode; -u32 samplerate = hdmi->audio.samplerate; +u32 samplerate = vc4_hdmi->audio.samplerate;u32 n, cts;u64 tmp;
@@ -676,16 +676,16 @@ static inline struct vc4_hdmi *dai_to_hdmi(struct snd_soc_dai *dai)static int vc4_hdmi_audio_startup (struct snd_pcm_substream *substream,struct snd_soc_dai *dai) { -struct vc4_hdmi *hdmi =dai_to_hdmi (dai); -struct drm_encoder *encoder = &hdmi->encoder.base.base; -struct drm_connector *connector = &hdmi->connector.base; +struct vc4_hdmi *vc4_hdmi =dai_to_hdmi (dai); +struct drm_encoder *encoder = &vc4_hdmi->encoder.base.base; +struct drm_connector *connector = &vc4_hdmi->connector.base;struct vc4_dev *vc4 =to_vc4_dev (encoder->dev);int ret; -if (hdmi->audio.substream && hdmi->audio.substream != substream) +if (vc4_hdmi->audio.substream && vc4_hdmi->audio.substream != substream)return -EINVAL ; - hdmi->audio.substream = substream; + vc4_hdmi->audio.substream = substream;/* * If the HDMI encoder hasn't probed, or the encoder is
@@ -707,11 +707,11 @@ static int vc4_hdmi_audio_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)return 0 ; } -static void vc4_hdmi_audio_reset (struct vc4_hdmi *hdmi) +static void vc4_hdmi_audio_reset (struct vc4_hdmi *vc4_hdmi) { -struct drm_encoder *encoder = &hdmi->encoder.base.base; +struct drm_encoder *encoder = &vc4_hdmi->encoder.base.base;struct drm_device *drm = encoder->dev; -struct device *dev = &hdmi->pdev->dev; +struct device *dev = &vc4_hdmi->pdev->dev;struct vc4_dev *vc4 =to_vc4_dev (drm);int ret;
@@ -727,14 +727,14 @@ static void vc4_hdmi_audio_reset(struct vc4_hdmi *hdmi)static void vc4_hdmi_audio_shutdown (struct snd_pcm_substream *substream,struct snd_soc_dai *dai) { -struct vc4_hdmi *hdmi =dai_to_hdmi (dai); +struct vc4_hdmi *vc4_hdmi =dai_to_hdmi (dai); -if (substream != hdmi->audio.substream) +if (substream != vc4_hdmi->audio.substream)return ; -vc4_hdmi_audio_reset (hdmi); +vc4_hdmi_audio_reset (vc4_hdmi); - hdmi->audio.substream =NULL ; + vc4_hdmi->audio.substream =NULL ; }/* HDMI audio codec callbacks */
@@ -742,23 +742,23 @@ static int vc4_hdmi_audio_hw_params(struct snd_pcm_substream *substream,struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct vc4_hdmi *hdmi = dai_to_hdmi(dai); -struct drm_encoder *encoder = &hdmi->encoder.base.base; + struct vc4_hdmi *vc4_hdmi = dai_to_hdmi(dai); +struct drm_encoder *encoder = &vc4_hdmi->encoder.base.base;struct drm_device *drm = encoder->dev; -struct device *dev = &hdmi->pdev->dev; +struct device *dev = &vc4_hdmi->pdev->dev;struct vc4_dev *vc4 =to_vc4_dev (drm);u32 audio_packet_config, channel_mask;u32 channel_map, i; -if (substream != hdmi->audio.substream) +if (substream != vc4_hdmi->audio.substream)return -EINVAL ;dev_dbg (dev,"%s: %u Hz, %d bit, %d channels\n" , __func__,params_rate (params),params_width (params),params_channels (params)); - hdmi->audio.channels =params_channels (params); - hdmi->audio.samplerate =params_rate (params); + vc4_hdmi->audio.channels =params_channels (params); + vc4_hdmi->audio.samplerate =params_rate (params); HD_WRITE(VC4_HD_MAI_CTL, VC4_HD_MAI_CTL_RESET |
@@ -767,23 +767,23 @@ static int vc4_hdmi_audio_hw_params(struct snd_pcm_substream *substream,VC4_HD_MAI_CTL_ERRORE | VC4_HD_MAI_CTL_ERRORF); -vc4_hdmi_audio_set_mai_clock (hdmi); +vc4_hdmi_audio_set_mai_clock (vc4_hdmi); audio_packet_config =VC4_HDMI_AUDIO_PACKET_ZERO_DATA_ON_SAMPLE_FLAT |VC4_HDMI_AUDIO_PACKET_ZERO_DATA_ON_INACTIVE_CHANNELS |VC4_SET_FIELD (0xf ,VC4_HDMI_AUDIO_PACKET_B_FRAME_IDENTIFIER ); - channel_mask =GENMASK (hdmi->audio.channels -1 ,0 ); + channel_mask =GENMASK (vc4_hdmi->audio.channels -1 ,0 ); audio_packet_config |=VC4_SET_FIELD (channel_mask,VC4_HDMI_AUDIO_PACKET_CEA_MASK );/* Set the MAI threshold. This logic mimics the firmware's. */ -if (hdmi->audio.samplerate >96000 ) { +if (vc4_hdmi->audio.samplerate >96000 ) {HD_WRITE (VC4_HD_MAI_THR ,VC4_SET_FIELD (0x12 ,VC4_HD_MAI_THR_DREQHIGH ) |VC4_SET_FIELD (0x12 ,VC4_HD_MAI_THR_DREQLOW )); - }else if (hdmi->audio.samplerate >48000 ) { + }else if (vc4_hdmi->audio.samplerate >48000 ) {HD_WRITE (VC4_HD_MAI_THR ,VC4_SET_FIELD (0x14 ,VC4_HD_MAI_THR_DREQHIGH ) |VC4_SET_FIELD (0x12 ,VC4_HD_MAI_THR_DREQLOW ));
@@ -807,7 +807,7 @@ static int vc4_hdmi_audio_hw_params(struct snd_pcm_substream *substream,HDMI_WRITE (VC4_HDMI_MAI_CHANNEL_MAP , channel_map);HDMI_WRITE (VC4_HDMI_AUDIO_PACKET_CONFIG , audio_packet_config); -vc4_hdmi_set_n_cts (hdmi); +vc4_hdmi_set_n_cts (vc4_hdmi);return 0 ; }
@@ -815,8 +815,8 @@ static int vc4_hdmi_audio_hw_params(struct snd_pcm_substream *substream,static int vc4_hdmi_audio_trigger (struct snd_pcm_substream *substream,int cmd,struct snd_soc_dai *dai) { -struct vc4_hdmi *hdmi =dai_to_hdmi (dai); -struct drm_encoder *encoder = &hdmi->encoder.base.base; +struct vc4_hdmi *vc4_hdmi =dai_to_hdmi (dai); +struct drm_encoder *encoder = &vc4_hdmi->encoder.base.base;struct drm_device *drm = encoder->dev;struct vc4_dev *vc4 =to_vc4_dev (drm);
@@ -827,7 +827,7 @@ static int vc4_hdmi_audio_trigger(struct snd_pcm_substream *substream, int cmd,HDMI_READ (VC4_HDMI_TX_PHY_CTL0 ) & ~VC4_HDMI_TX_PHY_RNG_PWRDN);HD_WRITE (VC4_HD_MAI_CTL , -VC4_SET_FIELD (hdmi->audio.channels, +VC4_SET_FIELD (vc4_hdmi->audio.channels,VC4_HD_MAI_CTL_CHNUM ) |VC4_HD_MAI_CTL_ENABLE );break ;
@@ -859,8 +859,8 @@ static int vc4_hdmi_audio_eld_ctl_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) {struct snd_soc_component *component =snd_kcontrol_chip (kcontrol); -struct vc4_hdmi *hdmi =snd_component_to_hdmi (component); -struct drm_connector *connector = &hdmi->connector.base; +struct vc4_hdmi *vc4_hdmi =snd_component_to_hdmi (component); +struct drm_connector *connector = &vc4_hdmi->connector.base; uinfo->type =SNDRV_CTL_ELEM_TYPE_BYTES ; uinfo->count =sizeof (connector->eld);
@@ -872,8 +872,8 @@ static int vc4_hdmi_audio_eld_ctl_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) {struct snd_soc_component *component =snd_kcontrol_chip (kcontrol); -struct vc4_hdmi *hdmi =snd_component_to_hdmi (component); -struct drm_connector *connector = &hdmi->connector.base; +struct vc4_hdmi *vc4_hdmi =snd_component_to_hdmi (component); +struct drm_connector *connector = &vc4_hdmi->connector.base;memcpy (ucontrol->value.bytes.data, connector->eld,sizeof (connector->eld));
@@ -941,9 +941,9 @@ static const struct snd_soc_component_driver vc4_hdmi_audio_cpu_dai_comp = {static int vc4_hdmi_audio_cpu_dai_probe (struct snd_soc_dai *dai) { -struct vc4_hdmi *hdmi =dai_to_hdmi (dai); +struct vc4_hdmi *vc4_hdmi =dai_to_hdmi (dai); -snd_soc_dai_init_dma_data (dai, &hdmi->audio.dma_data,NULL ); +snd_soc_dai_init_dma_data (dai, &vc4_hdmi->audio.dma_data,NULL );return 0 ; }
@@ -969,11 +969,11 @@ static const struct snd_dmaengine_pcm_config pcm_conf = { .prepare_slave_config = snd_dmaengine_pcm_prepare_slave_config, }; -static int vc4_hdmi_audio_init (struct vc4_hdmi *hdmi) +static int vc4_hdmi_audio_init (struct vc4_hdmi *vc4_hdmi) { -struct snd_soc_dai_link *dai_link = &hdmi->audio.link; -struct snd_soc_card *card = &hdmi->audio.card; -struct device *dev = &hdmi->pdev->dev; +struct snd_soc_dai_link *dai_link = &vc4_hdmi->audio.link; +struct snd_soc_card *card = &vc4_hdmi->audio.card; +struct device *dev = &vc4_hdmi->pdev->dev;const __be32 *addr;int ret;
@@ -991,9 +991,9 @@ static int vc4_hdmi_audio_init(struct vc4_hdmi *hdmi)* This VC/MMU should probably be exposed to avoid this kind of hacks. */ addr =of_get_address (dev->of_node,1 ,NULL ,NULL ); - hdmi->audio.dma_data.addr =be32_to_cpup (addr) +VC4_HD_MAI_DATA ; - hdmi->audio.dma_data.addr_width =DMA_SLAVE_BUSWIDTH_4_BYTES ; - hdmi->audio.dma_data.maxburst =2 ; + vc4_hdmi->audio.dma_data.addr =be32_to_cpup (addr) +VC4_HD_MAI_DATA ; + vc4_hdmi->audio.dma_data.addr_width =DMA_SLAVE_BUSWIDTH_4_BYTES ; + vc4_hdmi->audio.dma_data.maxburst =2 ; ret =devm_snd_dmaengine_pcm_register (dev, &pcm_conf,0 );if (ret) {
@@ -1016,9 +1016,9 @@ static int vc4_hdmi_audio_init(struct vc4_hdmi *hdmi)return ret; } - dai_link->cpus = &hdmi->audio.cpu; - dai_link->codecs = &hdmi->audio.codec; - dai_link->platforms = &hdmi->audio.platform; + dai_link->cpus = &vc4_hdmi->audio.cpu; + dai_link->codecs = &vc4_hdmi->audio.codec; + dai_link->platforms = &vc4_hdmi->audio.platform; dai_link->num_cpus =1 ; dai_link->num_codecs =1 ;
@@ -1043,7 +1043,7 @@ static int vc4_hdmi_audio_init(struct vc4_hdmi *hdmi)* now stored in card->drvdata and should be retrieved with * snd_soc_card_get_drvdata() if needed. */ -snd_soc_card_set_drvdata (card, hdmi); +snd_soc_card_set_drvdata (card, vc4_hdmi); ret =devm_snd_soc_register_card (dev, card);if (ret)dev_err (dev,"Could not register sound card: %d\n" , ret);
@@ -1056,20 +1056,21 @@ static int vc4_hdmi_audio_init(struct vc4_hdmi *hdmi)static irqreturn_t vc4_cec_irq_handler_thread (int irq,void *priv) {struct vc4_dev *vc4 = priv; -struct vc4_hdmi *hdmi = vc4->hdmi; - -if (hdmi->cec_irq_was_rx) { -if (hdmi->cec_rx_msg.len) -cec_received_msg (hdmi->cec_adap, &hdmi->cec_rx_msg); - }else if (hdmi->cec_tx_ok) { -cec_transmit_done (hdmi->cec_adap,CEC_TX_STATUS_OK , +struct vc4_hdmi *vc4_hdmi = vc4->hdmi; + +if (vc4_hdmi->cec_irq_was_rx) { +if (vc4_hdmi->cec_rx_msg.len) +cec_received_msg (vc4_hdmi->cec_adap, + &vc4_hdmi->cec_rx_msg); + }else if (vc4_hdmi->cec_tx_ok) { +cec_transmit_done (vc4_hdmi->cec_adap,CEC_TX_STATUS_OK ,0 ,0 ,0 ,0 ); }else {/* * This CEC implementation makes 1 retry, so if we * get a NACK, then that means it made 2 attempts. */ -cec_transmit_done (hdmi->cec_adap,CEC_TX_STATUS_NACK , +cec_transmit_done (vc4_hdmi->cec_adap,CEC_TX_STATUS_NACK ,0 ,2 ,0 ,0 ); }return IRQ_HANDLED ;
@@ -1095,23 +1096,23 @@ static void vc4_cec_read_msg(struct vc4_dev *vc4, u32 cntrl1)static irqreturn_t vc4_cec_irq_handler (int irq,void *priv) {struct vc4_dev *vc4 = priv; -struct vc4_hdmi *hdmi = vc4->hdmi; +struct vc4_hdmi *vc4_hdmi = vc4->hdmi;u32 stat =HDMI_READ (VC4_HDMI_CPU_STATUS );u32 cntrl1, cntrl5;if (!(stat &VC4_HDMI_CPU_CEC ))return IRQ_NONE ; - hdmi->cec_rx_msg.len =0 ; + vc4_hdmi->cec_rx_msg.len =0 ; cntrl1 =HDMI_READ (VC4_HDMI_CEC_CNTRL_1 ); cntrl5 =HDMI_READ (VC4_HDMI_CEC_CNTRL_5 ); - hdmi->cec_irq_was_rx = cntrl5 &VC4_HDMI_CEC_RX_CEC_INT ; -if (hdmi->cec_irq_was_rx) { + vc4_hdmi->cec_irq_was_rx = cntrl5 &VC4_HDMI_CEC_RX_CEC_INT ; +if (vc4_hdmi->cec_irq_was_rx) {vc4_cec_read_msg (vc4, cntrl1); cntrl1 |=VC4_HDMI_CEC_CLEAR_RECEIVE_OFF ;HDMI_WRITE (VC4_HDMI_CEC_CNTRL_1 , cntrl1); cntrl1 &= ~VC4_HDMI_CEC_CLEAR_RECEIVE_OFF ; }else { - hdmi->cec_tx_ok = cntrl1 &VC4_HDMI_CEC_TX_STATUS_GOOD ; + vc4_hdmi->cec_tx_ok = cntrl1 &VC4_HDMI_CEC_TX_STATUS_GOOD ; cntrl1 &= ~VC4_HDMI_CEC_START_XMIT_BEGIN ; }HDMI_WRITE (VC4_HDMI_CEC_CNTRL_1 , cntrl1);
@@ -1213,44 +1214,44 @@ static int vc4_hdmi_bind(struct device *dev, struct device *master, void *data)struct platform_device *pdev =to_platform_device (dev);struct drm_device *drm =dev_get_drvdata (master);struct vc4_dev *vc4 = drm->dev_private; -struct vc4_hdmi *hdmi; +struct vc4_hdmi *vc4_hdmi;struct drm_encoder *encoder;struct device_node *ddc_node;u32 value;int ret; - hdmi =devm_kzalloc (dev,sizeof (*hdmi),GFP_KERNEL ); -if (!hdmi) + vc4_hdmi =devm_kzalloc (dev,sizeof (*vc4_hdmi),GFP_KERNEL ); +if (!vc4_hdmi)return -ENOMEM ; - hdmi->pdev = pdev; - encoder = &hdmi->encoder.base.base; + vc4_hdmi->pdev = pdev; + encoder = &vc4_hdmi->encoder.base.base; encoder->base.type =VC4_ENCODER_TYPE_HDMI0 ; - hdmi->hdmicore_regs =vc4_ioremap_regs (pdev,0 ); -if (IS_ERR (hdmi->hdmicore_regs)) -return PTR_ERR (hdmi->hdmicore_regs); + vc4_hdmi->hdmicore_regs =vc4_ioremap_regs (pdev,0 ); +if (IS_ERR (vc4_hdmi->hdmicore_regs)) +return PTR_ERR (vc4_hdmi->hdmicore_regs); - hdmi->hd_regs =vc4_ioremap_regs (pdev,1 ); -if (IS_ERR (hdmi->hd_regs)) -return PTR_ERR (hdmi->hd_regs); + vc4_hdmi->hd_regs =vc4_ioremap_regs (pdev,1 ); +if (IS_ERR (vc4_hdmi->hd_regs)) +return PTR_ERR (vc4_hdmi->hd_regs); - hdmi->hdmi_regset.base = hdmi->hdmicore_regs; - hdmi->hdmi_regset.regs = hdmi_regs; - hdmi->hdmi_regset.nregs =ARRAY_SIZE (hdmi_regs); - hdmi->hd_regset.base = hdmi->hd_regs; - hdmi->hd_regset.regs = hd_regs; - hdmi->hd_regset.nregs =ARRAY_SIZE (hd_regs); + vc4_hdmi->hdmi_regset.base = vc4_hdmi->hdmicore_regs; + vc4_hdmi->hdmi_regset.regs = hdmi_regs; + vc4_hdmi->hdmi_regset.nregs =ARRAY_SIZE (hdmi_regs); + vc4_hdmi->hd_regset.base = vc4_hdmi->hd_regs; + vc4_hdmi->hd_regset.regs = hd_regs; + vc4_hdmi->hd_regset.nregs =ARRAY_SIZE (hd_regs); - hdmi->pixel_clock =devm_clk_get (dev,"pixel" ); -if (IS_ERR (hdmi->pixel_clock)) { + vc4_hdmi->pixel_clock =devm_clk_get (dev,"pixel" ); +if (IS_ERR (vc4_hdmi->pixel_clock)) {DRM_ERROR ("Failed to get pixel clock\n" ); -return PTR_ERR (hdmi->pixel_clock); +return PTR_ERR (vc4_hdmi->pixel_clock); } - hdmi->hsm_clock =devm_clk_get (dev,"hdmi" ); -if (IS_ERR (hdmi->hsm_clock)) { + vc4_hdmi->hsm_clock =devm_clk_get (dev,"hdmi" ); +if (IS_ERR (vc4_hdmi->hsm_clock)) {DRM_ERROR ("Failed to get HDMI state machine clock\n" ); -return PTR_ERR (hdmi->hsm_clock); +return PTR_ERR (vc4_hdmi->hsm_clock); } ddc_node =of_parse_phandle (dev->of_node,"ddc" ,0 );
@@ -1259,9 +1260,9 @@ static int vc4_hdmi_bind(struct device *dev, struct device *master, void *data)return -ENODEV ; } - hdmi->ddc =of_find_i2c_adapter_by_node (ddc_node); + vc4_hdmi->ddc =of_find_i2c_adapter_by_node (ddc_node);of_node_put (ddc_node); -if (!hdmi->ddc) { +if (!vc4_hdmi->ddc) {DRM_DEBUG ("Failed to get ddc i2c adapter by node\n" );return -EPROBE_DEFER ; }
@@ -1270,13 +1271,13 @@ static int vc4_hdmi_bind(struct device *dev, struct device *master, void *data)* needs to be a bit higher than the pixel clock rate * (generally 148.5Mhz). */ - ret =clk_set_rate (hdmi->hsm_clock,HSM_CLOCK_FREQ ); + ret =clk_set_rate (vc4_hdmi->hsm_clock,HSM_CLOCK_FREQ );if (ret) {DRM_ERROR ("Failed to set HSM clock rate: %d\n" , ret); goto err_put_i2c; } - ret =clk_prepare_enable (hdmi->hsm_clock); + ret =clk_prepare_enable (vc4_hdmi->hsm_clock);if (ret) {DRM_ERROR ("Failed to turn on HDMI state machine clock: %d\n" , ret);
@@ -1289,18 +1290,18 @@ static int vc4_hdmi_bind(struct device *dev, struct device *master, void *data)if (of_find_property (dev->of_node,"hpd-gpios" , &value)) {enum of_gpio_flags hpd_gpio_flags; - hdmi->hpd_gpio =of_get_named_gpio_flags (dev->of_node, + vc4_hdmi->hpd_gpio =of_get_named_gpio_flags (dev->of_node,"hpd-gpios" ,0 , &hpd_gpio_flags); -if (hdmi->hpd_gpio <0 ) { - ret = hdmi->hpd_gpio; +if (vc4_hdmi->hpd_gpio <0 ) { + ret = vc4_hdmi->hpd_gpio; goto err_unprepare_hsm; } - hdmi->hpd_active_low = hpd_gpio_flags &OF_GPIO_ACTIVE_LOW ; + vc4_hdmi->hpd_active_low = hpd_gpio_flags &OF_GPIO_ACTIVE_LOW ; } - vc4->hdmi = hdmi; + vc4->hdmi = vc4_hdmi;/* HDMI core must be enabled. */ if (!(HD_READ (VC4_HD_M_CTL ) &VC4_HD_M_ENABLE )) {
@@ -1321,11 +1322,11 @@ static int vc4_hdmi_bind(struct device *dev, struct device *master, void *data) goto err_destroy_encoder;#ifdef CONFIG_DRM_VC4_HDMI_CEC - hdmi->cec_adap =cec_allocate_adapter (&vc4_hdmi_cec_adap_ops, + vc4_hdmi->cec_adap =cec_allocate_adapter (&vc4_hdmi_cec_adap_ops, vc4,"vc4" ,CEC_CAP_DEFAULTS |CEC_CAP_CONNECTOR_INFO ,1 ); - ret =PTR_ERR_OR_ZERO (hdmi->cec_adap); + ret =PTR_ERR_OR_ZERO (vc4_hdmi->cec_adap);if (ret <0 ) goto err_destroy_conn;
@@ -1349,32 +1350,32 @@ static int vc4_hdmi_bind(struct device *dev, struct device *master, void *data) "vc4 hdmi cec", vc4);if (ret) goto err_delete_cec_adap; - ret =cec_register_adapter (hdmi->cec_adap, dev); + ret =cec_register_adapter (vc4_hdmi->cec_adap, dev);if (ret <0 ) goto err_delete_cec_adap;#endif - ret =vc4_hdmi_audio_init (hdmi); + ret =vc4_hdmi_audio_init (vc4_hdmi);if (ret) goto err_destroy_encoder; -vc4_debugfs_add_file (drm,"hdmi_regs" , vc4_hdmi_debugfs_regs, hdmi); +vc4_debugfs_add_file (drm,"hdmi_regs" , vc4_hdmi_debugfs_regs, vc4_hdmi);return 0 ;#ifdef CONFIG_DRM_VC4_HDMI_CEC err_delete_cec_adap: -cec_delete_adapter (hdmi->cec_adap); +cec_delete_adapter (vc4_hdmi->cec_adap); err_destroy_conn: -vc4_hdmi_connector_destroy (&hdmi->connector.base); +vc4_hdmi_connector_destroy (&vc4_hdmi->connector.base);#endif err_destroy_encoder:vc4_hdmi_encoder_destroy (encoder); err_unprepare_hsm: -clk_disable_unprepare (hdmi->hsm_clock); +clk_disable_unprepare (vc4_hdmi->hsm_clock);pm_runtime_disable (dev); err_put_i2c: -put_device (&hdmi->ddc->dev); +put_device (&vc4_hdmi->ddc->dev);return ret; }
@@ -1384,16 +1385,16 @@ static void vc4_hdmi_unbind(struct device *dev, struct device *master, {struct drm_device *drm =dev_get_drvdata (master);struct vc4_dev *vc4 = drm->dev_private; -struct vc4_hdmi *hdmi = vc4->hdmi; +struct vc4_hdmi *vc4_hdmi = vc4->hdmi; -cec_unregister_adapter (hdmi->cec_adap); -vc4_hdmi_connector_destroy (&hdmi->connector.base); -vc4_hdmi_encoder_destroy (&hdmi->encoder.base.base); +cec_unregister_adapter (vc4_hdmi->cec_adap); +vc4_hdmi_connector_destroy (&vc4_hdmi->connector.base); +vc4_hdmi_encoder_destroy (&vc4_hdmi->encoder.base.base); -clk_disable_unprepare (hdmi->hsm_clock); +clk_disable_unprepare (vc4_hdmi->hsm_clock);pm_runtime_disable (dev); -put_device (&hdmi->ddc->dev); +put_device (&vc4_hdmi->ddc->dev); vc4->hdmi =NULL ; }
Signature · 1 line
git-series 0.9.1
kbuild test robot
build botRe: [PATCH 65/89] drm/vc4: hdmi: Rename hdmi to vc4_hdmi
I love your patch! Yet something to improve:
Hi Maxime,
I love your patch! Yet something to improve:
[auto build test ERROR on clk/clk-next]
[also build test ERROR on robh/for-next v5.6-rc3]
[cannot apply to anholt/for-next]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Maxime-Ripard/drm-vc4-Support-BCM2711-Display-Pipeline/20200224-172730 base: https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git clk-next config: h8300-allyesconfig (attached as .config) compiler: h8300-linux-gcc (GCC) 7.5.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=7.5.0 make.cross ARCH=h8300
If you fix the issue, kindly add following tag
All errors (new ones prefixed by >>):
drivers/gpu/drm/vc4/vc4_hdmi.c: In function 'vc4_hdmi_bind':
>> drivers/gpu/drm/vc4/vc4_hdmi.c:1333:42: error: 'hdmi' undeclared (first use in this function)
cec_fill_conn_info_from_drm(&conn_info, hdmi->connector);
^~~~ drivers/gpu/drm/vc4/vc4_hdmi.c:1333:42: note: each undeclared identifier is reported only once for each function it appears in
vim +/hdmi +1333 drivers/gpu/drm/vc4/vc4_hdmi.c
15b4511a4af633 Hans Verkuil 2017-07-16 1208
c8b75bca92cbf0 Eric Anholt 2015-03-02 1209 static int vc4_hdmi_bind(struct device *dev, struct device *master, void *data)
c8b75bca92cbf0 Eric Anholt 2015-03-02 1210 {
66c2dee4ae10a2 Dariusz Marcinkiewicz 2019-08-23 1211 #ifdef CONFIG_DRM_VC4_HDMI_CEC
66c2dee4ae10a2 Dariusz Marcinkiewicz 2019-08-23 1212 struct cec_connector_info conn_info;
66c2dee4ae10a2 Dariusz Marcinkiewicz 2019-08-23 1213 #endif
c8b75bca92cbf0 Eric Anholt 2015-03-02 1214 struct platform_device *pdev = to_platform_device(dev);
c8b75bca92cbf0 Eric Anholt 2015-03-02 1215 struct drm_device *drm = dev_get_drvdata(master);
c8b75bca92cbf0 Eric Anholt 2015-03-02 1216 struct vc4_dev *vc4 = drm->dev_private;
1a4c2598a482bf Maxime Ripard 2020-02-24 1217 struct vc4_hdmi *vc4_hdmi;
c561991619ae31 Maxime Ripard 2020-02-24 1218 struct drm_encoder *encoder;
c8b75bca92cbf0 Eric Anholt 2015-03-02 1219 struct device_node *ddc_node;
c8b75bca92cbf0 Eric Anholt 2015-03-02 1220 u32 value;
c8b75bca92cbf0 Eric Anholt 2015-03-02 1221 int ret;
c8b75bca92cbf0 Eric Anholt 2015-03-02 1222
1a4c2598a482bf Maxime Ripard 2020-02-24 1223 vc4_hdmi = devm_kzalloc(dev, sizeof(*vc4_hdmi), GFP_KERNEL);
1a4c2598a482bf Maxime Ripard 2020-02-24 1224 if (!vc4_hdmi)
c8b75bca92cbf0 Eric Anholt 2015-03-02 1225 return -ENOMEM;
c8b75bca92cbf0 Eric Anholt 2015-03-02 1226
1a4c2598a482bf Maxime Ripard 2020-02-24 1227 vc4_hdmi->pdev = pdev;
1a4c2598a482bf Maxime Ripard 2020-02-24 1228 encoder = &vc4_hdmi->encoder.base.base;
c561991619ae31 Maxime Ripard 2020-02-24 1229 encoder->base.type = VC4_ENCODER_TYPE_HDMI0;
c561991619ae31 Maxime Ripard 2020-02-24 1230
1a4c2598a482bf Maxime Ripard 2020-02-24 1231 vc4_hdmi->hdmicore_regs = vc4_ioremap_regs(pdev, 0);
1a4c2598a482bf Maxime Ripard 2020-02-24 1232 if (IS_ERR(vc4_hdmi->hdmicore_regs))
1a4c2598a482bf Maxime Ripard 2020-02-24 1233 return PTR_ERR(vc4_hdmi->hdmicore_regs);
c8b75bca92cbf0 Eric Anholt 2015-03-02 1234
1a4c2598a482bf Maxime Ripard 2020-02-24 1235 vc4_hdmi->hd_regs = vc4_ioremap_regs(pdev, 1);
1a4c2598a482bf Maxime Ripard 2020-02-24 1236 if (IS_ERR(vc4_hdmi->hd_regs))
1a4c2598a482bf Maxime Ripard 2020-02-24 1237 return PTR_ERR(vc4_hdmi->hd_regs);
c8b75bca92cbf0 Eric Anholt 2015-03-02 1238
1a4c2598a482bf Maxime Ripard 2020-02-24 1239 vc4_hdmi->hdmi_regset.base = vc4_hdmi->hdmicore_regs;
1a4c2598a482bf Maxime Ripard 2020-02-24 1240 vc4_hdmi->hdmi_regset.regs = hdmi_regs;
1a4c2598a482bf Maxime Ripard 2020-02-24 1241 vc4_hdmi->hdmi_regset.nregs = ARRAY_SIZE(hdmi_regs);
1a4c2598a482bf Maxime Ripard 2020-02-24 1242 vc4_hdmi->hd_regset.base = vc4_hdmi->hd_regs;
1a4c2598a482bf Maxime Ripard 2020-02-24 1243 vc4_hdmi->hd_regset.regs = hd_regs;
1a4c2598a482bf Maxime Ripard 2020-02-24 1244 vc4_hdmi->hd_regset.nregs = ARRAY_SIZE(hd_regs);
3051719af11eb4 Eric Anholt 2019-02-20 1245
1a4c2598a482bf Maxime Ripard 2020-02-24 1246 vc4_hdmi->pixel_clock = devm_clk_get(dev, "pixel");
1a4c2598a482bf Maxime Ripard 2020-02-24 1247 if (IS_ERR(vc4_hdmi->pixel_clock)) {
c8b75bca92cbf0 Eric Anholt 2015-03-02 1248 DRM_ERROR("Failed to get pixel clock\n");
1a4c2598a482bf Maxime Ripard 2020-02-24 1249 return PTR_ERR(vc4_hdmi->pixel_clock);
c8b75bca92cbf0 Eric Anholt 2015-03-02 1250 }
1a4c2598a482bf Maxime Ripard 2020-02-24 1251 vc4_hdmi->hsm_clock = devm_clk_get(dev, "hdmi");
1a4c2598a482bf Maxime Ripard 2020-02-24 1252 if (IS_ERR(vc4_hdmi->hsm_clock)) {
c8b75bca92cbf0 Eric Anholt 2015-03-02 1253 DRM_ERROR("Failed to get HDMI state machine clock\n");
1a4c2598a482bf Maxime Ripard 2020-02-24 1254 return PTR_ERR(vc4_hdmi->hsm_clock);
c8b75bca92cbf0 Eric Anholt 2015-03-02 1255 }
c8b75bca92cbf0 Eric Anholt 2015-03-02 1256
027a697677b0d5 Peter Chen 2016-07-05 1257 ddc_node = of_parse_phandle(dev->of_node, "ddc", 0);
027a697677b0d5 Peter Chen 2016-07-05 1258 if (!ddc_node) {
027a697677b0d5 Peter Chen 2016-07-05 1259 DRM_ERROR("Failed to find ddc node in device tree\n");
027a697677b0d5 Peter Chen 2016-07-05 1260 return -ENODEV;
027a697677b0d5 Peter Chen 2016-07-05 1261 }
027a697677b0d5 Peter Chen 2016-07-05 1262
1a4c2598a482bf Maxime Ripard 2020-02-24 1263 vc4_hdmi->ddc = of_find_i2c_adapter_by_node(ddc_node);
027a697677b0d5 Peter Chen 2016-07-05 1264 of_node_put(ddc_node);
1a4c2598a482bf Maxime Ripard 2020-02-24 1265 if (!vc4_hdmi->ddc) {
c8b75bca92cbf0 Eric Anholt 2015-03-02 1266 DRM_DEBUG("Failed to get ddc i2c adapter by node\n");
c8b75bca92cbf0 Eric Anholt 2015-03-02 1267 return -EPROBE_DEFER;
c8b75bca92cbf0 Eric Anholt 2015-03-02 1268 }
c8b75bca92cbf0 Eric Anholt 2015-03-02 1269
10ee275cb12f88 Hans Verkuil 2017-07-16 1270 /* This is the rate that is set by the firmware. The number
10ee275cb12f88 Hans Verkuil 2017-07-16 1271 * needs to be a bit higher than the pixel clock rate
10ee275cb12f88 Hans Verkuil 2017-07-16 1272 * (generally 148.5Mhz).
10ee275cb12f88 Hans Verkuil 2017-07-16 1273 */
1a4c2598a482bf Maxime Ripard 2020-02-24 1274 ret = clk_set_rate(vc4_hdmi->hsm_clock, HSM_CLOCK_FREQ);
10ee275cb12f88 Hans Verkuil 2017-07-16 1275 if (ret) {
10ee275cb12f88 Hans Verkuil 2017-07-16 1276 DRM_ERROR("Failed to set HSM clock rate: %d\n", ret);
10ee275cb12f88 Hans Verkuil 2017-07-16 1277 goto err_put_i2c;
10ee275cb12f88 Hans Verkuil 2017-07-16 1278 }
10ee275cb12f88 Hans Verkuil 2017-07-16 1279
1a4c2598a482bf Maxime Ripard 2020-02-24 1280 ret = clk_prepare_enable(vc4_hdmi->hsm_clock);
10ee275cb12f88 Hans Verkuil 2017-07-16 1281 if (ret) {
10ee275cb12f88 Hans Verkuil 2017-07-16 1282 DRM_ERROR("Failed to turn on HDMI state machine clock: %d\n",
10ee275cb12f88 Hans Verkuil 2017-07-16 1283 ret);
10ee275cb12f88 Hans Verkuil 2017-07-16 1284 goto err_put_i2c;
10ee275cb12f88 Hans Verkuil 2017-07-16 1285 }
10ee275cb12f88 Hans Verkuil 2017-07-16 1286
c8b75bca92cbf0 Eric Anholt 2015-03-02 1287 /* Only use the GPIO HPD pin if present in the DT, otherwise
c8b75bca92cbf0 Eric Anholt 2015-03-02 1288 * we'll use the HDMI core's register.
c8b75bca92cbf0 Eric Anholt 2015-03-02 1289 */
c8b75bca92cbf0 Eric Anholt 2015-03-02 1290 if (of_find_property(dev->of_node, "hpd-gpios", &value)) {
0b06e0a7945130 Eric Anholt 2016-02-29 1291 enum of_gpio_flags hpd_gpio_flags;
0b06e0a7945130 Eric Anholt 2016-02-29 1292
1a4c2598a482bf Maxime Ripard 2020-02-24 1293 vc4_hdmi->hpd_gpio = of_get_named_gpio_flags(dev->of_node,
0b06e0a7945130 Eric Anholt 2016-02-29 1294 "hpd-gpios", 0,
0b06e0a7945130 Eric Anholt 2016-02-29 1295 &hpd_gpio_flags);
1a4c2598a482bf Maxime Ripard 2020-02-24 1296 if (vc4_hdmi->hpd_gpio < 0) {
1a4c2598a482bf Maxime Ripard 2020-02-24 1297 ret = vc4_hdmi->hpd_gpio;
10ee275cb12f88 Hans Verkuil 2017-07-16 1298 goto err_unprepare_hsm;
c8b75bca92cbf0 Eric Anholt 2015-03-02 1299 }
0b06e0a7945130 Eric Anholt 2016-02-29 1300
1a4c2598a482bf Maxime Ripard 2020-02-24 1301 vc4_hdmi->hpd_active_low = hpd_gpio_flags & OF_GPIO_ACTIVE_LOW;
c8b75bca92cbf0 Eric Anholt 2015-03-02 1302 }
c8b75bca92cbf0 Eric Anholt 2015-03-02 1303
1a4c2598a482bf Maxime Ripard 2020-02-24 1304 vc4->hdmi = vc4_hdmi;
c8b75bca92cbf0 Eric Anholt 2015-03-02 1305
10ee275cb12f88 Hans Verkuil 2017-07-16 1306 /* HDMI core must be enabled. */
10ee275cb12f88 Hans Verkuil 2017-07-16 1307 if (!(HD_READ(VC4_HD_M_CTL) & VC4_HD_M_ENABLE)) {
10ee275cb12f88 Hans Verkuil 2017-07-16 1308 HD_WRITE(VC4_HD_M_CTL, VC4_HD_M_SW_RST);
10ee275cb12f88 Hans Verkuil 2017-07-16 1309 udelay(1);
10ee275cb12f88 Hans Verkuil 2017-07-16 1310 HD_WRITE(VC4_HD_M_CTL, 0);
10ee275cb12f88 Hans Verkuil 2017-07-16 1311
10ee275cb12f88 Hans Verkuil 2017-07-16 1312 HD_WRITE(VC4_HD_M_CTL, VC4_HD_M_ENABLE);
10ee275cb12f88 Hans Verkuil 2017-07-16 1313 }
4f6e3d66ac522d Boris Brezillon 2017-04-11 1314 pm_runtime_enable(dev);
c8b75bca92cbf0 Eric Anholt 2015-03-02 1315
c561991619ae31 Maxime Ripard 2020-02-24 1316 drm_encoder_init(drm, encoder, &vc4_hdmi_encoder_funcs,
13a3d91f17a5f7 Ville Syrjälä 2015-12-09 1317 DRM_MODE_ENCODER_TMDS, NULL);
c561991619ae31 Maxime Ripard 2020-02-24 1318 drm_encoder_helper_add(encoder, &vc4_hdmi_encoder_helper_funcs);
c8b75bca92cbf0 Eric Anholt 2015-03-02 1319
3433182419afbd Maxime Ripard 2020-02-24 1320 ret = vc4_hdmi_connector_init(drm, vc4_hdmi);
c561991619ae31 Maxime Ripard 2020-02-24 1321 if (ret)
c8b75bca92cbf0 Eric Anholt 2015-03-02 1322 goto err_destroy_encoder;
c561991619ae31 Maxime Ripard 2020-02-24 1323
15b4511a4af633 Hans Verkuil 2017-07-16 1324 #ifdef CONFIG_DRM_VC4_HDMI_CEC
1a4c2598a482bf Maxime Ripard 2020-02-24 1325 vc4_hdmi->cec_adap = cec_allocate_adapter(&vc4_hdmi_cec_adap_ops,
15b4511a4af633 Hans Verkuil 2017-07-16 1326 vc4, "vc4",
66c2dee4ae10a2 Dariusz Marcinkiewicz 2019-08-23 1327 CEC_CAP_DEFAULTS |
66c2dee4ae10a2 Dariusz Marcinkiewicz 2019-08-23 1328 CEC_CAP_CONNECTOR_INFO, 1);
1a4c2598a482bf Maxime Ripard 2020-02-24 1329 ret = PTR_ERR_OR_ZERO(vc4_hdmi->cec_adap);
15b4511a4af633 Hans Verkuil 2017-07-16 1330 if (ret < 0)
15b4511a4af633 Hans Verkuil 2017-07-16 1331 goto err_destroy_conn;
66c2dee4ae10a2 Dariusz Marcinkiewicz 2019-08-23 1332
66c2dee4ae10a2 Dariusz Marcinkiewicz 2019-08-23 @1333 cec_fill_conn_info_from_drm(&conn_info, hdmi->connector);
66c2dee4ae10a2 Dariusz Marcinkiewicz 2019-08-23 1334 cec_s_conn_info(hdmi->cec_adap, &conn_info);
66c2dee4ae10a2 Dariusz Marcinkiewicz 2019-08-23 1335
15b4511a4af633 Hans Verkuil 2017-07-16 1336 HDMI_WRITE(VC4_HDMI_CPU_MASK_SET, 0xffffffff);
15b4511a4af633 Hans Verkuil 2017-07-16 1337 value = HDMI_READ(VC4_HDMI_CEC_CNTRL_1);
15b4511a4af633 Hans Verkuil 2017-07-16 1338 value &= ~VC4_HDMI_CEC_DIV_CLK_CNT_MASK;
15b4511a4af633 Hans Verkuil 2017-07-16 1339 /*
15b4511a4af633 Hans Verkuil 2017-07-16 1340 * Set the logical address to Unregistered and set the clock
15b4511a4af633 Hans Verkuil 2017-07-16 1341 * divider: the hsm_clock rate and this divider setting will
15b4511a4af633 Hans Verkuil 2017-07-16 1342 * give a 40 kHz CEC clock.
15b4511a4af633 Hans Verkuil 2017-07-16 1343 */
15b4511a4af633 Hans Verkuil 2017-07-16 1344 value |= VC4_HDMI_CEC_ADDR_MASK |
15b4511a4af633 Hans Verkuil 2017-07-16 1345 (4091 << VC4_HDMI_CEC_DIV_CLK_CNT_SHIFT);
15b4511a4af633 Hans Verkuil 2017-07-16 1346 HDMI_WRITE(VC4_HDMI_CEC_CNTRL_1, value);
15b4511a4af633 Hans Verkuil 2017-07-16 1347 ret = devm_request_threaded_irq(dev, platform_get_irq(pdev, 0),
15b4511a4af633 Hans Verkuil 2017-07-16 1348 vc4_cec_irq_handler,
15b4511a4af633 Hans Verkuil 2017-07-16 1349 vc4_cec_irq_handler_thread, 0,
15b4511a4af633 Hans Verkuil 2017-07-16 1350 "vc4 hdmi cec", vc4);
15b4511a4af633 Hans Verkuil 2017-07-16 1351 if (ret)
15b4511a4af633 Hans Verkuil 2017-07-16 1352 goto err_delete_cec_adap;
1a4c2598a482bf Maxime Ripard 2020-02-24 1353 ret = cec_register_adapter(vc4_hdmi->cec_adap, dev);
15b4511a4af633 Hans Verkuil 2017-07-16 1354 if (ret < 0)
15b4511a4af633 Hans Verkuil 2017-07-16 1355 goto err_delete_cec_adap;
15b4511a4af633 Hans Verkuil 2017-07-16 1356 #endif
c8b75bca92cbf0 Eric Anholt 2015-03-02 1357
1a4c2598a482bf Maxime Ripard 2020-02-24 1358 ret = vc4_hdmi_audio_init(vc4_hdmi);
bb7d78568814a3 Eric Anholt 2017-02-27 1359 if (ret)
bb7d78568814a3 Eric Anholt 2017-02-27 1360 goto err_destroy_encoder;
bb7d78568814a3 Eric Anholt 2017-02-27 1361
1a4c2598a482bf Maxime Ripard 2020-02-24 1362 vc4_debugfs_add_file(drm, "hdmi_regs", vc4_hdmi_debugfs_regs, vc4_hdmi);
c9be804c8c7a2d Eric Anholt 2019-04-01 1363
c8b75bca92cbf0 Eric Anholt 2015-03-02 1364 return 0;
c8b75bca92cbf0 Eric Anholt 2015-03-02 1365 :::::: The code@line 1333 was first introduced by commit
:::::: 66c2dee4ae10a2d841c40b9dd9c7141eb23eee76 drm/vc4/vc4_hdmi: fill in connector info
:::::: TO: Dariusz Marcinkiewicz <[email protected]> :::::: CC: Hans Verkuil <[email protected]>
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
PATCH 66/89 drm/vc4: hdmi: Move accessors to vc4_hdmi
In reply to Maxime RipardThe current driver only supports a single HDMI controller, and part of the issue is that the main vc4_dev structure holds a pointer to its (only) HDMI controller, and the HDMI registers accessors will use it to retrieve the mapped addresses.
Let's modify those accessors to use directly the vc4_hdmi structure so that we can eventually get rid of that single global pointer.
--- drivers/gpu/drm/vc4/vc4_hdmi.c | 16 +++------------- drivers/gpu/drm/vc4/vc4_hdmi.h | 8 ++++---- 2 files changed, 7 insertions(+), 17 deletions(-)
drivers/gpu/drm/vc4/vc4_hdmi.c +3 -13
@@ -122,6 +122,7 @@ vc4_hdmi_connector_detect(struct drm_connector *connector, bool force) {struct drm_device *dev = connector->dev;struct vc4_dev *vc4 =to_vc4_dev (dev); +struct vc4_hdmi *vc4_hdmi = vc4->hdmi;if (vc4->hdmi->hpd_gpio) { if (gpio_get_value_cansleep(vc4->hdmi->hpd_gpio) ^
@@ -238,6 +239,7 @@ static int vc4_hdmi_stop_packet(struct drm_encoder *encoder, {struct drm_device *dev = encoder->dev;struct vc4_dev *vc4 =to_vc4_dev (dev); +struct vc4_hdmi *vc4_hdmi = vc4->hdmi;u32 packet_id = type -0x80 ; HDMI_WRITE(VC4_HDMI_RAM_PACKET_CONFIG,
@@ -252,6 +254,7 @@ static void vc4_hdmi_write_infoframe(struct drm_encoder *encoder, {struct drm_device *dev = encoder->dev;struct vc4_dev *vc4 =to_vc4_dev (dev); +struct vc4_hdmi *vc4_hdmi = vc4->hdmi;u32 packet_id = frame->any.type -0x80 ;u32 packet_reg =VC4_HDMI_RAM_PACKET (packet_id);uint8_t buffer[VC4_HDMI_PACKET_STRIDE ];
@@ -619,9 +622,6 @@ static const struct drm_encoder_helper_funcs vc4_hdmi_encoder_helper_funcs = {/* HDMI audio codec callbacks */ static void vc4_hdmi_audio_set_mai_clock (struct vc4_hdmi *vc4_hdmi) { -struct drm_encoder *encoder = &vc4_hdmi->encoder.base.base; -struct drm_device *drm = encoder->dev; -struct vc4_dev *vc4 =to_vc4_dev (drm);u32 hsm_clock =clk_get_rate (vc4_hdmi->hsm_clock);unsigned long n, m;
@@ -641,8 +641,6 @@ static void vc4_hdmi_set_n_cts(struct vc4_hdmi *vc4_hdmi) {struct drm_encoder *encoder = &vc4_hdmi->encoder.base.base;struct drm_crtc *crtc = encoder->crtc; -struct drm_device *drm = encoder->dev; -struct vc4_dev *vc4 =to_vc4_dev (drm);const struct drm_display_mode *mode = &crtc->state->adjusted_mode;u32 samplerate = vc4_hdmi->audio.samplerate;u32 n, cts;
@@ -679,7 +677,6 @@ static int vc4_hdmi_audio_startup(struct snd_pcm_substream *substream,struct vc4_hdmi *vc4_hdmi =dai_to_hdmi (dai);struct drm_encoder *encoder = &vc4_hdmi->encoder.base.base;struct drm_connector *connector = &vc4_hdmi->connector.base; -struct vc4_dev *vc4 =to_vc4_dev (encoder->dev);int ret;if (vc4_hdmi->audio.substream && vc4_hdmi->audio.substream != substream)
@@ -710,9 +707,7 @@ static int vc4_hdmi_audio_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)static void vc4_hdmi_audio_reset (struct vc4_hdmi *vc4_hdmi) {struct drm_encoder *encoder = &vc4_hdmi->encoder.base.base; -struct drm_device *drm = encoder->dev;struct device *dev = &vc4_hdmi->pdev->dev; -struct vc4_dev *vc4 =to_vc4_dev (drm);int ret; ret =vc4_hdmi_stop_packet (encoder,HDMI_INFOFRAME_TYPE_AUDIO );
@@ -743,10 +738,7 @@ static int vc4_hdmi_audio_hw_params(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) {struct vc4_hdmi *vc4_hdmi =dai_to_hdmi (dai); -struct drm_encoder *encoder = &vc4_hdmi->encoder.base.base; -struct drm_device *drm = encoder->dev;struct device *dev = &vc4_hdmi->pdev->dev; -struct vc4_dev *vc4 =to_vc4_dev (drm);u32 audio_packet_config, channel_mask;u32 channel_map, i;
@@ -817,8 +809,6 @@ static int vc4_hdmi_audio_trigger(struct snd_pcm_substream *substream, int cmd, {struct vc4_hdmi *vc4_hdmi =dai_to_hdmi (dai);struct drm_encoder *encoder = &vc4_hdmi->encoder.base.base; -struct drm_device *drm = encoder->dev; -struct vc4_dev *vc4 =to_vc4_dev (drm);switch (cmd) {case SNDRV_PCM_TRIGGER_START :
drivers/gpu/drm/vc4/vc4_hdmi.h +4 -4
@@ -78,9 +78,9 @@ struct vc4_hdmi { struct debugfs_regset32 hd_regset; }; -#define HDMI_READ (offset) readl(vc4->hdmi->hdmicore_regs + offset) -#define HDMI_WRITE (offset, val) writel(val, vc4->hdmi->hdmicore_regs + offset) -#define HD_READ (offset) readl(vc4->hdmi->hd_regs + offset) -#define HD_WRITE (offset, val) writel(val, vc4->hdmi->hd_regs + offset) +#define HDMI_READ (offset) readl(vc4_hdmi->hdmicore_regs + offset) +#define HDMI_WRITE (offset, val) writel(val, vc4_hdmi->hdmicore_regs + offset) +#define HD_READ (offset) readl(vc4_hdmi->hd_regs + offset) +#define HD_WRITE (offset, val) writel(val, vc4_hdmi->hd_regs + offset)#endif /* _VC4_HDMI_H_ */
Signature · 1 line
git-series 0.9.1
kbuild test robot
build botRe: [PATCH 66/89] drm/vc4: hdmi: Move accessors to vc4_hdmi
I love your patch! Perhaps something to improve:
Hi Maxime,
I love your patch! Perhaps something to improve:
[auto build test WARNING on clk/clk-next]
[also build test WARNING on robh/for-next v5.6-rc3]
[cannot apply to anholt/for-next]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Maxime-Ripard/drm-vc4-Support-BCM2711-Display-Pipeline/20200224-172730 base: https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git clk-next config: h8300-allyesconfig (attached as .config) compiler: h8300-linux-gcc (GCC) 7.5.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=7.5.0 make.cross ARCH=h8300
If you fix the issue, kindly add following tag
All warnings (new ones prefixed by >>):
In file included from drivers/gpu/drm/vc4/vc4_hdmi.c:51:0:
drivers/gpu/drm/vc4/vc4_hdmi.c: In function 'vc4_cec_read_msg':
drivers/gpu/drm/vc4/vc4_hdmi.h:81:33: error: 'vc4_hdmi' undeclared (first use in this function)
#define HDMI_READ(offset) readl(vc4_hdmi->hdmicore_regs + offset)
^
>> drivers/gpu/drm/vc4/vc4_hdmi.c:1077:13: note: in expansion of macro 'HDMI_READ'
u32 val = HDMI_READ(VC4_HDMI_CEC_RX_DATA_1 + i);
^~~~~~~~~
drivers/gpu/drm/vc4/vc4_hdmi.h:81:33: note: each undeclared identifier is reported only once for each function it appears in
#define HDMI_READ(offset) readl(vc4_hdmi->hdmicore_regs + offset)
^
>> drivers/gpu/drm/vc4/vc4_hdmi.c:1077:13: note: in expansion of macro 'HDMI_READ'
u32 val = HDMI_READ(VC4_HDMI_CEC_RX_DATA_1 + i);
^~~~~~~~~
drivers/gpu/drm/vc4/vc4_hdmi.c: In function 'vc4_hdmi_cec_adap_enable':
drivers/gpu/drm/vc4/vc4_hdmi.h:81:33: error: 'vc4_hdmi' undeclared (first use in this function)
#define HDMI_READ(offset) readl(vc4_hdmi->hdmicore_regs + offset)
^
drivers/gpu/drm/vc4/vc4_hdmi.c:1119:12: note: in expansion of macro 'HDMI_READ'
u32 val = HDMI_READ(VC4_HDMI_CEC_CNTRL_5);
^~~~~~~~~
drivers/gpu/drm/vc4/vc4_hdmi.c:1116:18: warning: unused variable 'vc4' [-Wunused-variable]
struct vc4_dev *vc4 = cec_get_drvdata(adap);
^~~
In file included from drivers/gpu/drm/vc4/vc4_hdmi.c:51:0:
drivers/gpu/drm/vc4/vc4_hdmi.c: In function 'vc4_hdmi_cec_adap_log_addr':
drivers/gpu/drm/vc4/vc4_hdmi.h:81:33: error: 'vc4_hdmi' undeclared (first use in this function)
#define HDMI_READ(offset) readl(vc4_hdmi->hdmicore_regs + offset)
^
drivers/gpu/drm/vc4/vc4_hdmi.h:82:40: note: in definition of macro 'HDMI_WRITE'
#define HDMI_WRITE(offset, val) writel(val, vc4_hdmi->hdmicore_regs + offset)
^~~
drivers/gpu/drm/vc4/vc4_hdmi.c:1162:7: note: in expansion of macro 'HDMI_READ'
(HDMI_READ(VC4_HDMI_CEC_CNTRL_1) & ~VC4_HDMI_CEC_ADDR_MASK) |
^~~~~~~~~
drivers/gpu/drm/vc4/vc4_hdmi.c:1159:18: warning: unused variable 'vc4' [-Wunused-variable]
struct vc4_dev *vc4 = cec_get_drvdata(adap);
^~~
In file included from drivers/gpu/drm/vc4/vc4_hdmi.c:51:0:
drivers/gpu/drm/vc4/vc4_hdmi.c: In function 'vc4_hdmi_cec_adap_transmit':
drivers/gpu/drm/vc4/vc4_hdmi.h:82:45: error: 'vc4_hdmi' undeclared (first use in this function)
#define HDMI_WRITE(offset, val) writel(val, vc4_hdmi->hdmicore_regs + offset)
^
drivers/gpu/drm/vc4/vc4_hdmi.c:1175:3: note: in expansion of macro 'HDMI_WRITE'
HDMI_WRITE(VC4_HDMI_CEC_TX_DATA_1 + i,
^~~~~~~~~~
drivers/gpu/drm/vc4/vc4_hdmi.c:1170:18: warning: unused variable 'vc4' [-Wunused-variable]
struct vc4_dev *vc4 = cec_get_drvdata(adap);
^~~
drivers/gpu/drm/vc4/vc4_hdmi.c: In function 'vc4_hdmi_bind':
drivers/gpu/drm/vc4/vc4_hdmi.c:1323:42: error: 'hdmi' undeclared (first use in this function)
cec_fill_conn_info_from_drm(&conn_info, hdmi->connector);
^~~~vim +/HDMI_READ +1077 drivers/gpu/drm/vc4/vc4_hdmi.c
15b4511a4af633 Hans Verkuil 2017-07-16 1068
15b4511a4af633 Hans Verkuil 2017-07-16 1069 static void vc4_cec_read_msg(struct vc4_dev *vc4, u32 cntrl1)
15b4511a4af633 Hans Verkuil 2017-07-16 1070 {
15b4511a4af633 Hans Verkuil 2017-07-16 1071 struct cec_msg *msg = &vc4->hdmi->cec_rx_msg;
15b4511a4af633 Hans Verkuil 2017-07-16 1072 unsigned int i;
15b4511a4af633 Hans Verkuil 2017-07-16 1073
15b4511a4af633 Hans Verkuil 2017-07-16 1074 msg->len = 1 + ((cntrl1 & VC4_HDMI_CEC_REC_WRD_CNT_MASK) >>
15b4511a4af633 Hans Verkuil 2017-07-16 1075 VC4_HDMI_CEC_REC_WRD_CNT_SHIFT);
15b4511a4af633 Hans Verkuil 2017-07-16 1076 for (i = 0; i < msg->len; i += 4) {
15b4511a4af633 Hans Verkuil 2017-07-16 @1077 u32 val = HDMI_READ(VC4_HDMI_CEC_RX_DATA_1 + i);
15b4511a4af633 Hans Verkuil 2017-07-16 1078
15b4511a4af633 Hans Verkuil 2017-07-16 1079 msg->msg[i] = val & 0xff;
15b4511a4af633 Hans Verkuil 2017-07-16 1080 msg->msg[i + 1] = (val >> 8) & 0xff;
15b4511a4af633 Hans Verkuil 2017-07-16 1081 msg->msg[i + 2] = (val >> 16) & 0xff;
15b4511a4af633 Hans Verkuil 2017-07-16 1082 msg->msg[i + 3] = (val >> 24) & 0xff;
15b4511a4af633 Hans Verkuil 2017-07-16 1083 }
15b4511a4af633 Hans Verkuil 2017-07-16 1084 }
15b4511a4af633 Hans Verkuil 2017-07-16 1085 :::::: The code at line 1077 was first introduced by commit :::::: 15b4511a4af633dca0762ae5646fdf05f1dea99a drm/vc4: add HDMI CEC support
:::::: TO: Hans Verkuil <[email protected]>
:::::: CC: Eric Anholt <[email protected]>
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
PATCH 67/89 drm/vc4: hdmi: Use local vc4_hdmi directly
In reply to Maxime RipardThe function vc4_hdmi_connector_detect access its vc4_hdmi struct by dereferencing the pointer in the structure vc4_dev. This will cause some issues when we will have multiple HDMI controllers, so let's just use the local variable for now instead of dereferencing that pointer all the time, and we'll fix the local variable later.
--- drivers/gpu/drm/vc4/vc4_hdmi.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/gpu/drm/vc4/vc4_hdmi.c +6 -6
@@ -124,20 +124,20 @@ vc4_hdmi_connector_detect(struct drm_connector *connector, bool force)struct vc4_dev *vc4 =to_vc4_dev (dev);struct vc4_hdmi *vc4_hdmi = vc4->hdmi; -if (vc4->hdmi->hpd_gpio) { -if (gpio_get_value_cansleep (vc4->hdmi->hpd_gpio) ^ - vc4->hdmi->hpd_active_low) +if (vc4_hdmi->hpd_gpio) { +if (gpio_get_value_cansleep (vc4_hdmi->hpd_gpio) ^ + vc4_hdmi->hpd_active_low)return connector_status_connected; -cec_phys_addr_invalidate (vc4->hdmi->cec_adap); +cec_phys_addr_invalidate (vc4_hdmi->cec_adap);return connector_status_disconnected; } -if (drm_probe_ddc (vc4->hdmi->ddc)) +if (drm_probe_ddc (vc4_hdmi->ddc))return connector_status_connected;if (HDMI_READ (VC4_HDMI_HOTPLUG ) &VC4_HDMI_HOTPLUG_CONNECTED )return connector_status_connected; -cec_phys_addr_invalidate (vc4->hdmi->cec_adap); +cec_phys_addr_invalidate (vc4_hdmi->cec_adap);return connector_status_disconnected; }
Signature · 1 line
git-series 0.9.1
PATCH 68/89 drm/vc4: hdmi: Add container_of macros for encoders and connectors
In reply to Maxime RipardWhenever the code needs to access the vc4_hdmi structure from a DRM connector or encoder, it first accesses the drm_device associated to the connector, then retrieve the drm_dev private data which gives it a pointer to our vc4_dev, and will finally follow the vc4_hdmi pointer in that structure.
That will also give us some trouble when having multiple controllers, but now that we have our encoder and connector structures that are part of vc4_hdmi, we can simply call container_of on the DRM connector or encoder and retrieve the vc4_hdmi structure directly.
--- drivers/gpu/drm/vc4/vc4_hdmi.c | 41 ++++++++++------------------------- drivers/gpu/drm/vc4/vc4_hdmi.h | 16 ++++++++++++++- 2 files changed, 28 insertions(+), 29 deletions(-)
drivers/gpu/drm/vc4/vc4_hdmi.c +12 -29
@@ -120,9 +120,7 @@ static int vc4_hdmi_debugfs_regs(struct seq_file *m, void *unused)static enum drm_connector_status vc4_hdmi_connector_detect (struct drm_connector *connector,bool force) { -struct drm_device *dev = connector->dev; -struct vc4_dev *vc4 =to_vc4_dev (dev); -struct vc4_hdmi *vc4_hdmi = vc4->hdmi; +struct vc4_hdmi *vc4_hdmi =connector_to_vc4_hdmi (connector);if (vc4_hdmi->hpd_gpio) { if (gpio_get_value_cansleep(vc4_hdmi->hpd_gpio) ^
@@ -149,17 +147,13 @@ static void vc4_hdmi_connector_destroy(struct drm_connector *connector)static int vc4_hdmi_connector_get_modes (struct drm_connector *connector) { -struct vc4_hdmi_connector *vc4_connector = -to_vc4_hdmi_connector (connector); -struct drm_encoder *encoder = vc4_connector->encoder; -struct vc4_hdmi_encoder *vc4_encoder =to_vc4_hdmi_encoder (encoder); -struct drm_device *dev = connector->dev; -struct vc4_dev *vc4 =to_vc4_dev (dev); +struct vc4_hdmi *vc4_hdmi =connector_to_vc4_hdmi (connector); +struct vc4_hdmi_encoder *vc4_encoder = &vc4_hdmi->encoder;int ret =0 ;struct edid *edid; - edid =drm_get_edid (connector, vc4->hdmi->ddc); -cec_s_phys_addr_from_edid (vc4->hdmi->cec_adap, edid); + edid =drm_get_edid (connector, vc4_hdmi->ddc); +cec_s_phys_addr_from_edid (vc4_hdmi->cec_adap, edid);if (!edid)return -ENODEV ;
@@ -237,9 +231,7 @@ static const struct drm_encoder_funcs vc4_hdmi_encoder_funcs = {static int vc4_hdmi_stop_packet (struct drm_encoder *encoder,enum hdmi_infoframe_type type) { -struct drm_device *dev = encoder->dev; -struct vc4_dev *vc4 =to_vc4_dev (dev); -struct vc4_hdmi *vc4_hdmi = vc4->hdmi; +struct vc4_hdmi *vc4_hdmi =encoder_to_vc4_hdmi (encoder);u32 packet_id = type -0x80 ; HDMI_WRITE(VC4_HDMI_RAM_PACKET_CONFIG,
@@ -252,9 +244,7 @@ static int vc4_hdmi_stop_packet(struct drm_encoder *encoder,static void vc4_hdmi_write_infoframe (struct drm_encoder *encoder,union hdmi_infoframe *frame) { -struct drm_device *dev = encoder->dev; -struct vc4_dev *vc4 =to_vc4_dev (dev); -struct vc4_hdmi *vc4_hdmi = vc4->hdmi; +struct vc4_hdmi *vc4_hdmi =encoder_to_vc4_hdmi (encoder);u32 packet_id = frame->any.type -0x80 ;u32 packet_reg =VC4_HDMI_RAM_PACKET (packet_id);uint8_t buffer[VC4_HDMI_PACKET_STRIDE ];
@@ -300,9 +290,8 @@ static void vc4_hdmi_write_infoframe(struct drm_encoder *encoder,static void vc4_hdmi_set_avi_infoframe (struct drm_encoder *encoder) { +struct vc4_hdmi *vc4_hdmi =encoder_to_vc4_hdmi (encoder);struct vc4_hdmi_encoder *vc4_encoder =to_vc4_hdmi_encoder (encoder); -struct vc4_dev *vc4 = encoder->dev->dev_private; -struct vc4_hdmi *vc4_hdmi = vc4->hdmi;struct drm_connector *connector = &vc4_hdmi->connector.base;struct drm_connector_state *cstate = connector->state;struct drm_crtc *crtc = encoder->crtc;
@@ -346,9 +335,7 @@ static void vc4_hdmi_set_spd_infoframe(struct drm_encoder *encoder)static void vc4_hdmi_set_audio_infoframe (struct drm_encoder *encoder) { -struct drm_device *drm = encoder->dev; -struct vc4_dev *vc4 = drm->dev_private; -struct vc4_hdmi *vc4_hdmi = vc4->hdmi; +struct vc4_hdmi *vc4_hdmi =encoder_to_vc4_hdmi (encoder);union hdmi_infoframe frame;int ret;
@@ -370,9 +357,7 @@ static void vc4_hdmi_set_infoframes(struct drm_encoder *encoder)static void vc4_hdmi_encoder_disable (struct drm_encoder *encoder) { -struct drm_device *dev = encoder->dev; -struct vc4_dev *vc4 =to_vc4_dev (dev); -struct vc4_hdmi *vc4_hdmi = vc4->hdmi; +struct vc4_hdmi *vc4_hdmi =encoder_to_vc4_hdmi (encoder);int ret;HDMI_WRITE (VC4_HDMI_RAM_PACKET_CONFIG ,0 );
@@ -391,10 +376,8 @@ static void vc4_hdmi_encoder_disable(struct drm_encoder *encoder)static void vc4_hdmi_encoder_enable (struct drm_encoder *encoder) {struct drm_display_mode *mode = &encoder->crtc->state->adjusted_mode; -struct vc4_hdmi_encoder *vc4_encoder =to_vc4_hdmi_encoder (encoder); -struct drm_device *dev = encoder->dev; -struct vc4_dev *vc4 =to_vc4_dev (dev); -struct vc4_hdmi *vc4_hdmi = vc4->hdmi; +struct vc4_hdmi *vc4_hdmi =encoder_to_vc4_hdmi (encoder); +struct vc4_hdmi_encoder *vc4_encoder = &vc4_hdmi->encoder;bool debug_dump_regs = false;bool hsync_pos = mode->flags &DRM_MODE_FLAG_PHSYNC ;bool vsync_pos = mode->flags &DRM_MODE_FLAG_PVSYNC ;
drivers/gpu/drm/vc4/vc4_hdmi.h +16 -0
@@ -78,6 +78,22 @@ struct vc4_hdmi {struct debugfs_regset32 hd_regset; }; +static inline struct vc4_hdmi * +connector_to_vc4_hdmi (struct drm_connector *connector) +{ +struct vc4_hdmi_connector *_connector =to_vc4_hdmi_connector (connector); + + return container_of(_connector, struct vc4_hdmi, connector); +} + +static inline struct vc4_hdmi * +encoder_to_vc4_hdmi (struct drm_encoder *encoder) +{ +struct vc4_hdmi_encoder *_encoder =to_vc4_hdmi_encoder (encoder); + + return container_of(_encoder, struct vc4_hdmi, encoder); +} +#define HDMI_READ (offset) readl(vc4_hdmi->hdmicore_regs + offset)#define HDMI_WRITE (offset, val) writel(val, vc4_hdmi->hdmicore_regs + offset)#define HD_READ (offset) readl(vc4_hdmi->hd_regs + offset)
Signature · 1 line
git-series 0.9.1
PATCH 69/89 drm/vc4: hdmi: Pass vc4_hdmi to CEC code
In reply to Maxime RipardOur CEC code also retrieves the associated vc4_hdmi by setting the vc4_dev pointer as its private data, and then dereferences its vc4_hdmi pointer.
In order to eventually get rid of that pointer, we can simply pass the vc4_hdmi pointer directly.
--- drivers/gpu/drm/vc4/vc4_hdmi.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-)
drivers/gpu/drm/vc4/vc4_hdmi.c +7 -9
@@ -1028,8 +1028,7 @@ static int vc4_hdmi_audio_init(struct vc4_hdmi *vc4_hdmi)#ifdef CONFIG_DRM_VC4_HDMI_CEC static irqreturn_t vc4_cec_irq_handler_thread (int irq,void *priv) { -struct vc4_dev *vc4 = priv; -struct vc4_hdmi *vc4_hdmi = vc4->hdmi; +struct vc4_hdmi *vc4_hdmi = priv;if (vc4_hdmi->cec_irq_was_rx) {if (vc4_hdmi->cec_rx_msg.len)
@@ -1068,8 +1067,7 @@ static void vc4_cec_read_msg(struct vc4_dev *vc4, u32 cntrl1)static irqreturn_t vc4_cec_irq_handler (int irq,void *priv) { -struct vc4_dev *vc4 = priv; -struct vc4_hdmi *vc4_hdmi = vc4->hdmi; +struct vc4_hdmi *vc4_hdmi = priv;u32 stat =HDMI_READ (VC4_HDMI_CPU_STATUS );u32 cntrl1, cntrl5;
@@ -1096,7 +1094,7 @@ static irqreturn_t vc4_cec_irq_handler(int irq, void *priv)static int vc4_hdmi_cec_adap_enable (struct cec_adapter *adap,bool enable) { -struct vc4_dev *vc4 =cec_get_drvdata (adap); +struct vc4_hdmi *vc4_hdmi =cec_get_drvdata (adap);/* clock period in microseconds */ const u32 usecs =1000000 /CEC_CLOCK_FREQ ;u32 val =HDMI_READ (VC4_HDMI_CEC_CNTRL_5 );
@@ -1139,7 +1137,7 @@ static int vc4_hdmi_cec_adap_enable(struct cec_adapter *adap, bool enable)static int vc4_hdmi_cec_adap_log_addr (struct cec_adapter *adap,u8 log_addr) { -struct vc4_dev *vc4 =cec_get_drvdata (adap); +struct vc4_hdmi *vc4_hdmi =cec_get_drvdata (adap); HDMI_WRITE(VC4_HDMI_CEC_CNTRL_1, (HDMI_READ(VC4_HDMI_CEC_CNTRL_1) & ~VC4_HDMI_CEC_ADDR_MASK) |
@@ -1150,7 +1148,7 @@ static int vc4_hdmi_cec_adap_log_addr(struct cec_adapter *adap, u8 log_addr)static int vc4_hdmi_cec_adap_transmit (struct cec_adapter *adap,u8 attempts,u32 signal_free_time,struct cec_msg *msg) { -struct vc4_dev *vc4 =cec_get_drvdata (adap); +struct vc4_hdmi *vc4_hdmi =cec_get_drvdata (adap);u32 val;unsigned int i;
@@ -1320,10 +1318,10 @@ static int vc4_hdmi_bind(struct device *dev, struct device *master, void *data) ret =devm_request_threaded_irq (dev,platform_get_irq (pdev,0 ), vc4_cec_irq_handler, vc4_cec_irq_handler_thread,0 , -"vc4 hdmi cec" , vc4); +"vc4 hdmi cec" , vc4_hdmi);if (ret) goto err_delete_cec_adap; - ret =cec_register_adapter (vc4_hdmi->cec_adap, dev); + ret =cec_register_adapter (vc4_hdmi->cec_adap, vc4_hdmi);if (ret <0 ) goto err_delete_cec_adap;#endif
Signature · 1 line
git-series 0.9.1
kbuild test robot
build botRe: [PATCH 69/89] drm/vc4: hdmi: Pass vc4_hdmi to CEC code
I love your patch! Yet something to improve:
Hi Maxime,
I love your patch! Yet something to improve:
[auto build test ERROR on clk/clk-next]
[also build test ERROR on robh/for-next v5.6-rc3]
[cannot apply to anholt/for-next]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Maxime-Ripard/drm-vc4-Support-BCM2711-Display-Pipeline/20200224-172730 base: https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git clk-next config: h8300-allyesconfig (attached as .config) compiler: h8300-linux-gcc (GCC) 7.5.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=7.5.0 make.cross ARCH=h8300
If you fix the issue, kindly add following tag
All errors (new ones prefixed by >>):
In file included from drivers/gpu/drm/vc4/vc4_hdmi.c:51:0:
drivers/gpu/drm/vc4/vc4_hdmi.c: In function 'vc4_cec_read_msg':
drivers/gpu/drm/vc4/vc4_hdmi.h:97:33: error: 'vc4_hdmi' undeclared (first use in this function)
#define HDMI_READ(offset) readl(vc4_hdmi->hdmicore_regs + offset)
^
drivers/gpu/drm/vc4/vc4_hdmi.c:1059:13: note: in expansion of macro 'HDMI_READ'
u32 val = HDMI_READ(VC4_HDMI_CEC_RX_DATA_1 + i);
^~~~~~~~~
drivers/gpu/drm/vc4/vc4_hdmi.h:97:33: note: each undeclared identifier is reported only once for each function it appears in
#define HDMI_READ(offset) readl(vc4_hdmi->hdmicore_regs + offset)
^
drivers/gpu/drm/vc4/vc4_hdmi.c:1059:13: note: in expansion of macro 'HDMI_READ'
u32 val = HDMI_READ(VC4_HDMI_CEC_RX_DATA_1 + i);
^~~~~~~~~
drivers/gpu/drm/vc4/vc4_hdmi.c: In function 'vc4_cec_irq_handler':
>> drivers/gpu/drm/vc4/vc4_hdmi.c:1081:20: error: 'vc4' undeclared (first use in this function)
vc4_cec_read_msg(vc4, cntrl1);
^~~
drivers/gpu/drm/vc4/vc4_hdmi.c: In function 'vc4_hdmi_bind':
drivers/gpu/drm/vc4/vc4_hdmi.c:1304:42: error: 'hdmi' undeclared (first use in this function)
cec_fill_conn_info_from_drm(&conn_info, hdmi->connector);
^~~~
>> drivers/gpu/drm/vc4/vc4_hdmi.c:1324:49: error: passing argument 2 of 'cec_register_adapter' from incompatible pointer type [-Werror=incompatible-pointer-types]
ret = cec_register_adapter(vc4_hdmi->cec_adap, vc4_hdmi);
^~~~~~~~
In file included from drivers/gpu/drm/vc4/vc4_hdmi.c:49:0:
include/media/cec.h:242:5: note: expected 'struct device *' but argument is of type 'struct vc4_hdmi *'
int cec_register_adapter(struct cec_adapter *adap, struct device *parent);
^~~~~~~~~~~~~~~~~~~~cc1: some warnings being treated as errors
vim +/vc4 +1081 drivers/gpu/drm/vc4/vc4_hdmi.c
15b4511a4af633 Hans Verkuil 2017-07-16 1067
15b4511a4af633 Hans Verkuil 2017-07-16 1068 static irqreturn_t vc4_cec_irq_handler(int irq, void *priv)
15b4511a4af633 Hans Verkuil 2017-07-16 1069 {
7b162fa6ed3963 Maxime Ripard 2020-02-24 1070 struct vc4_hdmi *vc4_hdmi = priv;
15b4511a4af633 Hans Verkuil 2017-07-16 1071 u32 stat = HDMI_READ(VC4_HDMI_CPU_STATUS);
15b4511a4af633 Hans Verkuil 2017-07-16 1072 u32 cntrl1, cntrl5;
15b4511a4af633 Hans Verkuil 2017-07-16 1073
15b4511a4af633 Hans Verkuil 2017-07-16 1074 if (!(stat & VC4_HDMI_CPU_CEC))
15b4511a4af633 Hans Verkuil 2017-07-16 1075 return IRQ_NONE;
1a4c2598a482bf Maxime Ripard 2020-02-24 1076 vc4_hdmi->cec_rx_msg.len = 0;
15b4511a4af633 Hans Verkuil 2017-07-16 1077 cntrl1 = HDMI_READ(VC4_HDMI_CEC_CNTRL_1);
15b4511a4af633 Hans Verkuil 2017-07-16 1078 cntrl5 = HDMI_READ(VC4_HDMI_CEC_CNTRL_5);
1a4c2598a482bf Maxime Ripard 2020-02-24 1079 vc4_hdmi->cec_irq_was_rx = cntrl5 & VC4_HDMI_CEC_RX_CEC_INT;
1a4c2598a482bf Maxime Ripard 2020-02-24 1080 if (vc4_hdmi->cec_irq_was_rx) {
15b4511a4af633 Hans Verkuil 2017-07-16 @1081 vc4_cec_read_msg(vc4, cntrl1);
15b4511a4af633 Hans Verkuil 2017-07-16 1082 cntrl1 |= VC4_HDMI_CEC_CLEAR_RECEIVE_OFF;
15b4511a4af633 Hans Verkuil 2017-07-16 1083 HDMI_WRITE(VC4_HDMI_CEC_CNTRL_1, cntrl1);
15b4511a4af633 Hans Verkuil 2017-07-16 1084 cntrl1 &= ~VC4_HDMI_CEC_CLEAR_RECEIVE_OFF;
15b4511a4af633 Hans Verkuil 2017-07-16 1085 } else {
1a4c2598a482bf Maxime Ripard 2020-02-24 1086 vc4_hdmi->cec_tx_ok = cntrl1 & VC4_HDMI_CEC_TX_STATUS_GOOD;
15b4511a4af633 Hans Verkuil 2017-07-16 1087 cntrl1 &= ~VC4_HDMI_CEC_START_XMIT_BEGIN;
15b4511a4af633 Hans Verkuil 2017-07-16 1088 }
15b4511a4af633 Hans Verkuil 2017-07-16 1089 HDMI_WRITE(VC4_HDMI_CEC_CNTRL_1, cntrl1);
15b4511a4af633 Hans Verkuil 2017-07-16 1090 HDMI_WRITE(VC4_HDMI_CPU_CLEAR, VC4_HDMI_CPU_CEC);
15b4511a4af633 Hans Verkuil 2017-07-16 1091
15b4511a4af633 Hans Verkuil 2017-07-16 1092 return IRQ_WAKE_THREAD;
15b4511a4af633 Hans Verkuil 2017-07-16 1093 }
15b4511a4af633 Hans Verkuil 2017-07-16 1094 :::::: The code at line 1081 was first introduced by commit :::::: 15b4511a4af633dca0762ae5646fdf05f1dea99a drm/vc4: add HDMI CEC support
:::::: TO: Hans Verkuil <[email protected]>
:::::: CC: Eric Anholt <[email protected]>
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
PATCH 70/89 drm/vc4: hdmi: Remove vc4_dev hdmi pointer
In reply to Maxime RipardNow that we don't have any users anymore, we can kill that pointer.
--- drivers/gpu/drm/vc4/vc4_drv.h | 1 - drivers/gpu/drm/vc4/vc4_hdmi.c | 14 ++++++-------- 2 files changed, 6 insertions(+), 9 deletions(-)
drivers/gpu/drm/vc4/vc4_drv.h +0 -1
@@ -73,7 +73,6 @@ struct vc4_perfmon {struct vc4_dev {struct drm_device *dev; -struct vc4_hdmi *hdmi;struct vc4_hvs *hvs;struct vc4_v3d *v3d;struct vc4_dpi *dpi;
drivers/gpu/drm/vc4/vc4_hdmi.c +6 -8
@@ -1184,7 +1184,6 @@ static int vc4_hdmi_bind(struct device *dev, struct device *master, void *data)#endif struct platform_device *pdev =to_platform_device (dev);struct drm_device *drm =dev_get_drvdata (master); -struct vc4_dev *vc4 = drm->dev_private;struct vc4_hdmi *vc4_hdmi;struct drm_encoder *encoder;struct device_node *ddc_node;
@@ -1272,8 +1271,6 @@ static int vc4_hdmi_bind(struct device *dev, struct device *master, void *data) vc4_hdmi->hpd_active_low = hpd_gpio_flags &OF_GPIO_ACTIVE_LOW ; } - vc4->hdmi = vc4_hdmi; -/* HDMI core must be enabled. */ if (!(HD_READ (VC4_HD_M_CTL ) &VC4_HD_M_ENABLE )) {HD_WRITE (VC4_HD_M_CTL ,VC4_HD_M_SW_RST );
@@ -1354,9 +1351,12 @@ static int vc4_hdmi_bind(struct device *dev, struct device *master, void *data)static void vc4_hdmi_unbind (struct device *dev,struct device *master,void *data) { -struct drm_device *drm =dev_get_drvdata (master); -struct vc4_dev *vc4 = drm->dev_private; -struct vc4_hdmi *vc4_hdmi = vc4->hdmi; +/* +* snd_soc_register_card will set the device drvdata pointer +* to the card being registered. +*/ +struct snd_soc_card *card =dev_get_drvdata (dev); +struct vc4_hdmi *vc4_hdmi =snd_soc_card_get_drvdata (card);cec_unregister_adapter (vc4_hdmi->cec_adap);vc4_hdmi_connector_destroy (&vc4_hdmi->connector.base);
@@ -1366,8 +1366,6 @@ static void vc4_hdmi_unbind(struct device *dev, struct device *master,pm_runtime_disable (dev);put_device (&vc4_hdmi->ddc->dev); - - vc4->hdmi =NULL ; }static const struct component_ops vc4_hdmi_ops = {
Signature · 1 line
git-series 0.9.1
kbuild test robot
build botRe: [PATCH 70/89] drm/vc4: hdmi: Remove vc4_dev hdmi pointer
I love your patch! Yet something to improve:
Hi Maxime,
I love your patch! Yet something to improve:
[auto build test ERROR on clk/clk-next]
[also build test ERROR on robh/for-next v5.6-rc3 next-20200224] [cannot apply to anholt/for-next]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Maxime-Ripard/drm-vc4-Support-BCM2711-Display-Pipeline/20200224-172730 base: https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git clk-next config: nds32-allyesconfig (attached as .config) compiler: nds32le-linux-gcc (GCC) 9.2.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=9.2.0 make.cross ARCH=nds32
If you fix the issue, kindly add following tag
All errors (new ones prefixed by >>):
drivers/gpu/drm/vc4/vc4_hdmi.c: In function 'vc4_cec_read_msg':
>> drivers/gpu/drm/vc4/vc4_hdmi.c:1053:28: error: 'struct vc4_dev' has no member named 'hdmi'
1053 | struct cec_msg *msg = &vc4->hdmi->cec_rx_msg;
| ^~
In file included from include/linux/byteorder/little_endian.h:5,
from arch/nds32/include/uapi/asm/byteorder.h:10,
from include/asm-generic/bitops/le.h:6,
from include/asm-generic/bitops.h:35,
from ./arch/nds32/include/generated/asm/bitops.h:1,
from include/linux/bitops.h:29,
from include/linux/of.h:15,
from include/linux/irqdomain.h:35,
from include/linux/acpi.h:13,
from include/linux/i2c.h:13,
from include/drm/drm_crtc.h:28,
from include/drm/drm_atomic_helper.h:31,
from drivers/gpu/drm/vc4/vc4_hdmi.c:34:
drivers/gpu/drm/vc4/vc4_hdmi.h:97:33: error: 'vc4_hdmi' undeclared (first use in this function)
97 | #define HDMI_READ(offset) readl(vc4_hdmi->hdmicore_regs + offset)
| ^~~~~~~~
include/uapi/linux/byteorder/little_endian.h:34:51: note: in definition of macro '__le32_to_cpu'
34 | #define __le32_to_cpu(x) ((__force __u32)(__le32)(x))
| ^
arch/nds32/include/asm/io.h:76:31: note: in expansion of macro 'readl_relaxed'
76 | #define readl(c) ({ u32 __v = readl_relaxed(c); __iormb(); __v; })
| ^~~~~~~~~~~~~
drivers/gpu/drm/vc4/vc4_hdmi.h:97:27: note: in expansion of macro 'readl'
97 | #define HDMI_READ(offset) readl(vc4_hdmi->hdmicore_regs + offset)
| ^~~~~
drivers/gpu/drm/vc4/vc4_hdmi.c:1059:13: note: in expansion of macro 'HDMI_READ'
1059 | u32 val = HDMI_READ(VC4_HDMI_CEC_RX_DATA_1 + i);
| ^~~~~~~~~
drivers/gpu/drm/vc4/vc4_hdmi.h:97:33: note: each undeclared identifier is reported only once for each function it appears in
97 | #define HDMI_READ(offset) readl(vc4_hdmi->hdmicore_regs + offset)
| ^~~~~~~~
include/uapi/linux/byteorder/little_endian.h:34:51: note: in definition of macro '__le32_to_cpu'
34 | #define __le32_to_cpu(x) ((__force __u32)(__le32)(x))
| ^
arch/nds32/include/asm/io.h:76:31: note: in expansion of macro 'readl_relaxed'
76 | #define readl(c) ({ u32 __v = readl_relaxed(c); __iormb(); __v; })
| ^~~~~~~~~~~~~
drivers/gpu/drm/vc4/vc4_hdmi.h:97:27: note: in expansion of macro 'readl'
97 | #define HDMI_READ(offset) readl(vc4_hdmi->hdmicore_regs + offset)
| ^~~~~
drivers/gpu/drm/vc4/vc4_hdmi.c:1059:13: note: in expansion of macro 'HDMI_READ'
1059 | u32 val = HDMI_READ(VC4_HDMI_CEC_RX_DATA_1 + i);
| ^~~~~~~~~
drivers/gpu/drm/vc4/vc4_hdmi.c: In function 'vc4_cec_irq_handler':
drivers/gpu/drm/vc4/vc4_hdmi.c:1081:20: error: 'vc4' undeclared (first use in this function)
1081 | vc4_cec_read_msg(vc4, cntrl1);
| ^~~
drivers/gpu/drm/vc4/vc4_hdmi.c: In function 'vc4_hdmi_bind':
drivers/gpu/drm/vc4/vc4_hdmi.c:1294:12: error: 'vc4' undeclared (first use in this function)
1294 | vc4, "vc4",
| ^~~
drivers/gpu/drm/vc4/vc4_hdmi.c:1301:42: error: 'hdmi' undeclared (first use in this function)
1301 | cec_fill_conn_info_from_drm(&conn_info, hdmi->connector);
| ^~~~
drivers/gpu/drm/vc4/vc4_hdmi.c:1321:49: error: passing argument 2 of 'cec_register_adapter' from incompatible pointer type [-Werror=incompatible-pointer-types]
1321 | ret = cec_register_adapter(vc4_hdmi->cec_adap, vc4_hdmi);
| ^~~~~~~~
| |
| struct vc4_hdmi *
In file included from drivers/gpu/drm/vc4/vc4_hdmi.c:49:
include/media/cec.h:242:67: note: expected 'struct device *' but argument is of type 'struct vc4_hdmi *'
242 | int cec_register_adapter(struct cec_adapter *adap, struct device *parent);
| ~~~~~~~~~~~~~~~^~~~~~cc1: some warnings being treated as errors
vim +1053 drivers/gpu/drm/vc4/vc4_hdmi.c
15b4511a4af633 Hans Verkuil 2017-07-16 1050
15b4511a4af633 Hans Verkuil 2017-07-16 1051 static void vc4_cec_read_msg(struct vc4_dev *vc4, u32 cntrl1)
15b4511a4af633 Hans Verkuil 2017-07-16 1052 {
15b4511a4af633 Hans Verkuil 2017-07-16 @1053 struct cec_msg *msg = &vc4->hdmi->cec_rx_msg;
15b4511a4af633 Hans Verkuil 2017-07-16 1054 unsigned int i;
15b4511a4af633 Hans Verkuil 2017-07-16 1055
15b4511a4af633 Hans Verkuil 2017-07-16 1056 msg->len = 1 + ((cntrl1 & VC4_HDMI_CEC_REC_WRD_CNT_MASK) >>
15b4511a4af633 Hans Verkuil 2017-07-16 1057 VC4_HDMI_CEC_REC_WRD_CNT_SHIFT);
15b4511a4af633 Hans Verkuil 2017-07-16 1058 for (i = 0; i < msg->len; i += 4) {
15b4511a4af633 Hans Verkuil 2017-07-16 1059 u32 val = HDMI_READ(VC4_HDMI_CEC_RX_DATA_1 + i);
15b4511a4af633 Hans Verkuil 2017-07-16 1060
15b4511a4af633 Hans Verkuil 2017-07-16 1061 msg->msg[i] = val & 0xff;
15b4511a4af633 Hans Verkuil 2017-07-16 1062 msg->msg[i + 1] = (val >> 8) & 0xff;
15b4511a4af633 Hans Verkuil 2017-07-16 1063 msg->msg[i + 2] = (val >> 16) & 0xff;
15b4511a4af633 Hans Verkuil 2017-07-16 1064 msg->msg[i + 3] = (val >> 24) & 0xff;
15b4511a4af633 Hans Verkuil 2017-07-16 1065 }
15b4511a4af633 Hans Verkuil 2017-07-16 1066 }
15b4511a4af633 Hans Verkuil 2017-07-16 1067 :::::: The code at line 1053 was first introduced by commit :::::: 15b4511a4af633dca0762ae5646fdf05f1dea99a drm/vc4: add HDMI CEC support
:::::: TO: Hans Verkuil <[email protected]>
:::::: CC: Eric Anholt <[email protected]>
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
PATCH 71/89 drm/vc4: hdmi: Remove vc4_hdmi_connector
In reply to Maxime RipardThe vc4_hdmi_connector was only used to switch between drm_connector to drm_encoder. However, we can now use vc4_hdmi to do the switch, so that structure is redundant.
--- drivers/gpu/drm/vc4/vc4_hdmi.c | 17 +++++++---------- drivers/gpu/drm/vc4/vc4_hdmi.h | 23 ++--------------------- 2 files changed, 9 insertions(+), 31 deletions(-)
drivers/gpu/drm/vc4/vc4_hdmi.c +7 -10
@@ -188,13 +188,10 @@ static const struct drm_connector_helper_funcs vc4_hdmi_connector_helper_funcs =static int vc4_hdmi_connector_init (struct drm_device *dev,struct vc4_hdmi *vc4_hdmi) { -struct vc4_hdmi_connector *hdmi_connector = &vc4_hdmi->connector; -struct drm_connector *connector = &hdmi_connector->base; +struct drm_connector *connector = &vc4_hdmi->connector;struct drm_encoder *encoder = &vc4_hdmi->encoder.base.base;int ret; - hdmi_connector->encoder = encoder; - drm_connector_init_with_ddc(dev, connector, &vc4_hdmi_connector_funcs, DRM_MODE_CONNECTOR_HDMIA,
@@ -292,7 +289,7 @@ static void vc4_hdmi_set_avi_infoframe(struct drm_encoder *encoder) {struct vc4_hdmi *vc4_hdmi =encoder_to_vc4_hdmi (encoder);struct vc4_hdmi_encoder *vc4_encoder =to_vc4_hdmi_encoder (encoder); -struct drm_connector *connector = &vc4_hdmi->connector.base; +struct drm_connector *connector = &vc4_hdmi->connector;struct drm_connector_state *cstate = connector->state;struct drm_crtc *crtc = encoder->crtc;const struct drm_display_mode *mode = &crtc->state->adjusted_mode;
@@ -659,7 +656,7 @@ static int vc4_hdmi_audio_startup(struct snd_pcm_substream *substream, {struct vc4_hdmi *vc4_hdmi =dai_to_hdmi (dai);struct drm_encoder *encoder = &vc4_hdmi->encoder.base.base; -struct drm_connector *connector = &vc4_hdmi->connector.base; +struct drm_connector *connector = &vc4_hdmi->connector;int ret;if (vc4_hdmi->audio.substream && vc4_hdmi->audio.substream != substream)
@@ -833,7 +830,7 @@ static int vc4_hdmi_audio_eld_ctl_info(struct snd_kcontrol *kcontrol, {struct snd_soc_component *component =snd_kcontrol_chip (kcontrol);struct vc4_hdmi *vc4_hdmi =snd_component_to_hdmi (component); -struct drm_connector *connector = &vc4_hdmi->connector.base; +struct drm_connector *connector = &vc4_hdmi->connector; uinfo->type =SNDRV_CTL_ELEM_TYPE_BYTES ; uinfo->count =sizeof (connector->eld);
@@ -846,7 +843,7 @@ static int vc4_hdmi_audio_eld_ctl_get(struct snd_kcontrol *kcontrol, {struct snd_soc_component *component =snd_kcontrol_chip (kcontrol);struct vc4_hdmi *vc4_hdmi =snd_component_to_hdmi (component); -struct drm_connector *connector = &vc4_hdmi->connector.base; +struct drm_connector *connector = &vc4_hdmi->connector;memcpy (ucontrol->value.bytes.data, connector->eld,sizeof (connector->eld));
@@ -1335,7 +1332,7 @@ static int vc4_hdmi_bind(struct device *dev, struct device *master, void *data) err_delete_cec_adap:cec_delete_adapter (vc4_hdmi->cec_adap); err_destroy_conn: -vc4_hdmi_connector_destroy (&vc4_hdmi->connector.base); +vc4_hdmi_connector_destroy (&vc4_hdmi->connector);#endif err_destroy_encoder:vc4_hdmi_encoder_destroy (encoder);
@@ -1359,7 +1356,7 @@ static void vc4_hdmi_unbind(struct device *dev, struct device *master,struct vc4_hdmi *vc4_hdmi =snd_soc_card_get_drvdata (card);cec_unregister_adapter (vc4_hdmi->cec_adap); -vc4_hdmi_connector_destroy (&vc4_hdmi->connector.base); +vc4_hdmi_connector_destroy (&vc4_hdmi->connector);vc4_hdmi_encoder_destroy (&vc4_hdmi->encoder.base.base);clk_disable_unprepare (vc4_hdmi->hsm_clock);
drivers/gpu/drm/vc4/vc4_hdmi.h +2 -21
@@ -21,23 +21,6 @@ to_vc4_hdmi_encoder(struct drm_encoder *encoder) return container_of(encoder, struct vc4_hdmi_encoder, base.base); } -/* VC4 HDMI connector KMS struct */ -struct vc4_hdmi_connector { -struct drm_connector base; - -/* Since the connector is attached to just the one encoder, -* this is the reference to it so we can do the best_encoder() -* hook. -*/ -struct drm_encoder *encoder; -}; - -static inline struct vc4_hdmi_connector * -to_vc4_hdmi_connector (struct drm_connector *connector) -{ - return container_of(connector, struct vc4_hdmi_connector, base); -} -/* HDMI audio information */ struct vc4_hdmi_audio {struct snd_soc_card card;
@@ -56,7 +39,7 @@ struct vc4_hdmi {struct platform_device *pdev;struct vc4_hdmi_encoder encoder; -struct vc4_hdmi_connector connector; +struct drm_connector connector;struct vc4_hdmi_audio audio;
@@ -81,9 +64,7 @@ struct vc4_hdmi {static inline struct vc4_hdmi *connector_to_vc4_hdmi (struct drm_connector *connector) { -struct vc4_hdmi_connector *_connector =to_vc4_hdmi_connector (connector); - - return container_of(_connector, struct vc4_hdmi, connector); + return container_of(connector, struct vc4_hdmi, connector); } static inline struct vc4_hdmi *
Signature · 1 line
git-series 0.9.1
PATCH 72/89 drm/vc4: hdmi: Introduce resource init and variant
In reply to Maxime RipardThe HDMI controllers found in the BCM2711 has a pretty different clock and registers areas than found in the older BCM283x SoCs.
Let's create a variant structure to store the various adjustments we'll need later on, and a function to get the resources needed for one particular version.
--- drivers/gpu/drm/vc4/vc4_hdmi.c | 67 ++++++++++++++++++++++------------- drivers/gpu/drm/vc4/vc4_hdmi.h | 8 ++++- 2 files changed, 52 insertions(+), 23 deletions(-)
drivers/gpu/drm/vc4/vc4_hdmi.c +44 -23
@@ -1174,38 +1174,23 @@ static const struct cec_adap_ops vc4_hdmi_cec_adap_ops = { };#endif -static int vc4_hdmi_bind (struct device *dev,struct device *master,void *data) +static int vc4_hdmi_init_resources (struct vc4_hdmi *vc4_hdmi) { -#ifdef CONFIG_DRM_VC4_HDMI_CEC -struct cec_connector_info conn_info; -#endif -struct platform_device *pdev =to_platform_device (dev); -struct drm_device *drm =dev_get_drvdata (master); -struct vc4_hdmi *vc4_hdmi; -struct drm_encoder *encoder; -struct device_node *ddc_node; -u32 value; -int ret; - - vc4_hdmi =devm_kzalloc (dev,sizeof (*vc4_hdmi),GFP_KERNEL ); -if (!vc4_hdmi) -return -ENOMEM ; - - vc4_hdmi->pdev = pdev; - encoder = &vc4_hdmi->encoder.base.base; - encoder->base.type =VC4_ENCODER_TYPE_HDMI0 ; +struct platform_device *pdev = vc4_hdmi->pdev; +struct device *dev = &pdev->dev; vc4_hdmi->hdmicore_regs =vc4_ioremap_regs (pdev,0 );if (IS_ERR (vc4_hdmi->hdmicore_regs))return PTR_ERR (vc4_hdmi->hdmicore_regs); + vc4_hdmi->hdmi_regset.base = vc4_hdmi->hdmicore_regs; + vc4_hdmi->hdmi_regset.regs = hdmi_regs; + vc4_hdmi->hdmi_regset.nregs =ARRAY_SIZE (hdmi_regs); + vc4_hdmi->hd_regs =vc4_ioremap_regs (pdev,1 );if (IS_ERR (vc4_hdmi->hd_regs))return PTR_ERR (vc4_hdmi->hd_regs); - vc4_hdmi->hdmi_regset.base = vc4_hdmi->hdmicore_regs; - vc4_hdmi->hdmi_regset.regs = hdmi_regs; - vc4_hdmi->hdmi_regset.nregs =ARRAY_SIZE (hdmi_regs); vc4_hdmi->hd_regset.base = vc4_hdmi->hd_regs; vc4_hdmi->hd_regset.regs = hd_regs; vc4_hdmi->hd_regset.nregs =ARRAY_SIZE (hd_regs);
@@ -1215,12 +1200,44 @@ static int vc4_hdmi_bind(struct device *dev, struct device *master, void *data)DRM_ERROR ("Failed to get pixel clock\n" );return PTR_ERR (vc4_hdmi->pixel_clock); } + vc4_hdmi->hsm_clock =devm_clk_get (dev,"hdmi" );if (IS_ERR (vc4_hdmi->hsm_clock)) {DRM_ERROR ("Failed to get HDMI state machine clock\n" );return PTR_ERR (vc4_hdmi->hsm_clock); } +return 0 ; +} + +static int vc4_hdmi_bind (struct device *dev,struct device *master,void *data) +{ +#ifdef CONFIG_DRM_VC4_HDMI_CEC +struct cec_connector_info conn_info; +#endif +struct platform_device *pdev =to_platform_device (dev); +struct drm_device *drm =dev_get_drvdata (master); +const struct vc4_hdmi_variant *variant; +struct vc4_hdmi *vc4_hdmi; +struct drm_encoder *encoder; +struct device_node *ddc_node; +u32 value; +int ret; + + vc4_hdmi =devm_kzalloc (dev,sizeof (*vc4_hdmi),GFP_KERNEL ); +if (!vc4_hdmi) +return -ENOMEM ; + + vc4_hdmi->pdev = pdev; + variant =of_device_get_match_data (dev); + vc4_hdmi->variant = variant; + vc4_hdmi->encoder.base.type =VC4_ENCODER_TYPE_HDMI0 ; + encoder = &vc4_hdmi->encoder.base.base; + + ret = variant->init_resources (vc4_hdmi); +if (ret) +return ret; + ddc_node =of_parse_phandle (dev->of_node,"ddc" ,0 );if (!ddc_node) {DRM_ERROR ("Failed to find ddc node in device tree\n" );
@@ -1381,8 +1398,12 @@ static int vc4_hdmi_dev_remove(struct platform_device *pdev)return 0 ; } +struct vc4_hdmi_variant bcm2835_variant = { + .init_resources = vc4_hdmi_init_resources, +}; +static const struct of_device_id vc4_hdmi_dt_match[] = { - { .compatible ="brcm,bcm2835-hdmi" }, + { .compatible ="brcm,bcm2835-hdmi" , .data = &bcm2835_variant }, {} };
drivers/gpu/drm/vc4/vc4_hdmi.h +8 -0
@@ -21,6 +21,13 @@ to_vc4_hdmi_encoder(struct drm_encoder *encoder) return container_of(encoder, struct vc4_hdmi_encoder, base.base); } +struct vc4_hdmi_variant { +/* Callback to get the resources (memory region, interrupts, +* clocks, etc) for that variant. +*/ +int (*init_resources)(struct vc4_hdmi *vc4_hdmi); +}; +/* HDMI audio information */ struct vc4_hdmi_audio {struct snd_soc_card card;
@@ -37,6 +44,7 @@ struct vc4_hdmi_audio {/* General HDMI hardware state. */ struct vc4_hdmi {struct platform_device *pdev; +const struct vc4_hdmi_variant *variant;struct vc4_hdmi_encoder encoder;struct drm_connector connector;
Signature · 1 line
git-series 0.9.1
kbuild test robot
build bot[RFC PATCH] drm/vc4: hdmi: bcm2835_variant can be static
Fixes: 9ee5cdb1c45e ("drm/vc4: hdmi: Introduce resource init and variant")
--- vc4_hdmi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/vc4/vc4_hdmi.c +1 -1
@@ -1398,7 +1398,7 @@ static int vc4_hdmi_dev_remove(struct platform_device *pdev)return 0 ; } -struct vc4_hdmi_variant bcm2835_variant = { +static struct vc4_hdmi_variant bcm2835_variant = { .init_resources = vc4_hdmi_init_resources, };
PATCH 73/89 drm/vc4: hdmi: Implement a register layout abstraction
In reply to Maxime RipardThe HDMI controllers found in the BCM2711 have most of the registers reorganized in multiple registers areas and at different offsets than previously found.
The logic however remains pretty much the same, so it doesn't really make sense to create a whole new driver and we should share the code as much as possible.
Let's implement some indirection to wrap around a register and depending on the variant will lookup the associated register on that particular variant.
--- drivers/gpu/drm/vc4/vc4_hdmi.c | 354 ++++++++++++++--------------- drivers/gpu/drm/vc4/vc4_hdmi.h | 13 +- drivers/gpu/drm/vc4/vc4_hdmi_regs.h | 244 ++++++++++++++++++++- drivers/gpu/drm/vc4/vc4_regs.h | 92 +-------- 4 files changed, 432 insertions(+), 271 deletions(-) create mode 100644 drivers/gpu/drm/vc4/vc4_hdmi_regs.h
drivers/gpu/drm/vc4/vc4_hdmi.c +180 -174
@@ -49,62 +49,13 @@#include "media/cec.h" #include "vc4_drv.h" #include "vc4_hdmi.h" +#include "vc4_hdmi_regs.h" #include "vc4_regs.h" #define HSM_CLOCK_FREQ 163682864#define CEC_CLOCK_FREQ 40000#define CEC_CLOCK_DIV (HSM_CLOCK_FREQ / CEC_CLOCK_FREQ) -static const struct debugfs_reg32 hdmi_regs[] = { -VC4_REG32 (VC4_HDMI_CORE_REV ), -VC4_REG32 (VC4_HDMI_SW_RESET_CONTROL ), -VC4_REG32 (VC4_HDMI_HOTPLUG_INT ), -VC4_REG32 (VC4_HDMI_HOTPLUG ), -VC4_REG32 (VC4_HDMI_MAI_CHANNEL_MAP ), -VC4_REG32 (VC4_HDMI_MAI_CONFIG ), -VC4_REG32 (VC4_HDMI_MAI_FORMAT ), -VC4_REG32 (VC4_HDMI_AUDIO_PACKET_CONFIG ), -VC4_REG32 (VC4_HDMI_RAM_PACKET_CONFIG ), -VC4_REG32 (VC4_HDMI_HORZA ), -VC4_REG32 (VC4_HDMI_HORZB ), -VC4_REG32 (VC4_HDMI_FIFO_CTL ), -VC4_REG32 (VC4_HDMI_SCHEDULER_CONTROL ), -VC4_REG32 (VC4_HDMI_VERTA0 ), -VC4_REG32 (VC4_HDMI_VERTA1 ), -VC4_REG32 (VC4_HDMI_VERTB0 ), -VC4_REG32 (VC4_HDMI_VERTB1 ), -VC4_REG32 (VC4_HDMI_TX_PHY_RESET_CTL ), -VC4_REG32 (VC4_HDMI_TX_PHY_CTL0 ), - -VC4_REG32 (VC4_HDMI_CEC_CNTRL_1 ), -VC4_REG32 (VC4_HDMI_CEC_CNTRL_2 ), -VC4_REG32 (VC4_HDMI_CEC_CNTRL_3 ), -VC4_REG32 (VC4_HDMI_CEC_CNTRL_4 ), -VC4_REG32 (VC4_HDMI_CEC_CNTRL_5 ), -VC4_REG32 (VC4_HDMI_CPU_STATUS ), -VC4_REG32 (VC4_HDMI_CPU_MASK_STATUS ), - -VC4_REG32 (VC4_HDMI_CEC_RX_DATA_1 ), -VC4_REG32 (VC4_HDMI_CEC_RX_DATA_2 ), -VC4_REG32 (VC4_HDMI_CEC_RX_DATA_3 ), -VC4_REG32 (VC4_HDMI_CEC_RX_DATA_4 ), -VC4_REG32 (VC4_HDMI_CEC_TX_DATA_1 ), -VC4_REG32 (VC4_HDMI_CEC_TX_DATA_2 ), -VC4_REG32 (VC4_HDMI_CEC_TX_DATA_3 ), -VC4_REG32 (VC4_HDMI_CEC_TX_DATA_4 ), -}; - -static const struct debugfs_reg32 hd_regs[] = { -VC4_REG32 (VC4_HD_M_CTL ), -VC4_REG32 (VC4_HD_MAI_CTL ), -VC4_REG32 (VC4_HD_MAI_THR ), -VC4_REG32 (VC4_HD_MAI_FMT ), -VC4_REG32 (VC4_HD_MAI_SMP ), -VC4_REG32 (VC4_HD_VID_CTL ), -VC4_REG32 (VC4_HD_CSC_CTL ), -VC4_REG32 (VC4_HD_FRAME_COUNT ), -}; -static int vc4_hdmi_debugfs_regs (struct seq_file *m,void *unused) {struct drm_info_node *node = (struct drm_info_node *)m->private;
@@ -133,7 +84,7 @@ vc4_hdmi_connector_detect(struct drm_connector *connector, bool force)if (drm_probe_ddc (vc4_hdmi->ddc))return connector_status_connected; -if (HDMI_READ (VC4_HDMI_HOTPLUG ) &VC4_HDMI_HOTPLUG_CONNECTED ) +if (HDMI_READ (HDMI_HOTPLUG ) &VC4_HDMI_HOTPLUG_CONNECTED )return connector_status_connected;cec_phys_addr_invalidate (vc4_hdmi->cec_adap);return connector_status_disconnected;
@@ -231,10 +182,10 @@ static int vc4_hdmi_stop_packet(struct drm_encoder *encoder,struct vc4_hdmi *vc4_hdmi =encoder_to_vc4_hdmi (encoder);u32 packet_id = type -0x80 ; -HDMI_WRITE (VC4_HDMI_RAM_PACKET_CONFIG , -HDMI_READ (VC4_HDMI_RAM_PACKET_CONFIG ) & ~BIT (packet_id)); +HDMI_WRITE (HDMI_RAM_PACKET_CONFIG , +HDMI_READ (HDMI_RAM_PACKET_CONFIG ) & ~BIT (packet_id)); -return wait_for (!(HDMI_READ (VC4_HDMI_RAM_PACKET_STATUS ) & +return wait_for (!(HDMI_READ (HDMI_RAM_PACKET_STATUS ) &BIT (packet_id)),100 ); }
@@ -243,12 +194,16 @@ static void vc4_hdmi_write_infoframe(struct drm_encoder *encoder, {struct vc4_hdmi *vc4_hdmi =encoder_to_vc4_hdmi (encoder);u32 packet_id = frame->any.type -0x80 ; -u32 packet_reg =VC4_HDMI_RAM_PACKET (packet_id); +const struct vc4_hdmi_register *ram_packet_start = + &vc4_hdmi->variant->registers[HDMI_RAM_PACKET_START ]; +u32 packet_reg = ram_packet_start->offset +VC4_HDMI_PACKET_STRIDE * packet_id; +void __iomem *base =__vc4_hdmi_get_field_base (vc4_hdmi, + ram_packet_start->reg);uint8_t buffer[VC4_HDMI_PACKET_STRIDE ];ssize_t len, i;int ret; -WARN_ONCE (!(HDMI_READ (VC4_HDMI_RAM_PACKET_CONFIG ) & +WARN_ONCE (!(HDMI_READ (HDMI_RAM_PACKET_CONFIG ) &VC4_HDMI_RAM_PACKET_ENABLE ),"Packet RAM has to be on to store the packet." );
@@ -263,23 +218,23 @@ static void vc4_hdmi_write_infoframe(struct drm_encoder *encoder, }for (i =0 ; i < len; i +=7 ) { -HDMI_WRITE (packet_reg, - buffer[i +0 ] <<0 | - buffer[i +1 ] <<8 | - buffer[i +2 ] <<16 ); +writel (buffer[i +0 ] <<0 | + buffer[i +1 ] <<8 | + buffer[i +2 ] <<16 , + base + packet_reg); packet_reg +=4 ; -HDMI_WRITE (packet_reg, - buffer[i +3 ] <<0 | - buffer[i +4 ] <<8 | - buffer[i +5 ] <<16 | - buffer[i +6 ] <<24 ); +writel (buffer[i +3 ] <<0 | + buffer[i +4 ] <<8 | + buffer[i +5 ] <<16 | + buffer[i +6 ] <<24 , + base + packet_reg); packet_reg +=4 ; } -HDMI_WRITE (VC4_HDMI_RAM_PACKET_CONFIG , -HDMI_READ (VC4_HDMI_RAM_PACKET_CONFIG ) |BIT (packet_id)); - ret =wait_for ((HDMI_READ (VC4_HDMI_RAM_PACKET_STATUS ) & +HDMI_WRITE (HDMI_RAM_PACKET_CONFIG , +HDMI_READ (HDMI_RAM_PACKET_CONFIG ) |BIT (packet_id)); + ret =wait_for ((HDMI_READ (HDMI_RAM_PACKET_STATUS ) &BIT (packet_id)),100 );if (ret)DRM_ERROR ("Failed to wait for infoframe to start: %d\n" , ret);
@@ -357,11 +312,11 @@ static void vc4_hdmi_encoder_disable(struct drm_encoder *encoder)struct vc4_hdmi *vc4_hdmi =encoder_to_vc4_hdmi (encoder);int ret; -HDMI_WRITE (VC4_HDMI_RAM_PACKET_CONFIG ,0 ); +HDMI_WRITE (HDMI_RAM_PACKET_CONFIG ,0 ); -HDMI_WRITE (VC4_HDMI_TX_PHY_RESET_CTL ,0xf <<16 ); -HD_WRITE (VC4_HD_VID_CTL , -HD_READ (VC4_HD_VID_CTL ) & ~VC4_HD_VID_CTL_ENABLE ); +HDMI_WRITE (HDMI_TX_PHY_RESET_CTL ,0xf <<16 ); +HDMI_WRITE (HDMI_VID_CTL , +HDMI_READ (HDMI_VID_CTL ) & ~VC4_HD_VID_CTL_ENABLE );clk_disable_unprepare (vc4_hdmi->pixel_clock);
@@ -416,18 +371,18 @@ static void vc4_hdmi_encoder_enable(struct drm_encoder *encoder)return ; } -HDMI_WRITE (VC4_HDMI_SW_RESET_CONTROL , +HDMI_WRITE (HDMI_SW_RESET_CONTROL ,VC4_HDMI_SW_RESET_HDMI |VC4_HDMI_SW_RESET_FORMAT_DETECT ); -HDMI_WRITE (VC4_HDMI_SW_RESET_CONTROL ,0 ); +HDMI_WRITE (HDMI_SW_RESET_CONTROL ,0 );/* PHY should be in reset, like * vc4_hdmi_encoder_disable() does. */ -HDMI_WRITE (VC4_HDMI_TX_PHY_RESET_CTL ,0xf <<16 ); +HDMI_WRITE (HDMI_TX_PHY_RESET_CTL ,0xf <<16 ); -HDMI_WRITE (VC4_HDMI_TX_PHY_RESET_CTL ,0 ); +HDMI_WRITE (HDMI_TX_PHY_RESET_CTL ,0 );if (debug_dump_regs) {struct drm_printer p =drm_info_printer (&vc4_hdmi->pdev->dev);
@@ -437,20 +392,20 @@ static void vc4_hdmi_encoder_enable(struct drm_encoder *encoder)drm_print_regset32 (&p, &vc4_hdmi->hd_regset); } -HD_WRITE (VC4_HD_VID_CTL ,0 ); +HDMI_WRITE (HDMI_VID_CTL ,0 ); -HDMI_WRITE (VC4_HDMI_SCHEDULER_CONTROL , -HDMI_READ (VC4_HDMI_SCHEDULER_CONTROL ) | +HDMI_WRITE (HDMI_SCHEDULER_CONTROL , +HDMI_READ (HDMI_SCHEDULER_CONTROL ) |VC4_HDMI_SCHEDULER_CONTROL_MANUAL_FORMAT |VC4_HDMI_SCHEDULER_CONTROL_IGNORE_VSYNC_PREDICTS ); -HDMI_WRITE (VC4_HDMI_HORZA , +HDMI_WRITE (HDMI_HORZA , (vsync_pos ?VC4_HDMI_HORZA_VPOS :0 ) | (hsync_pos ?VC4_HDMI_HORZA_HPOS :0 ) |VC4_SET_FIELD (mode->hdisplay * pixel_rep,VC4_HDMI_HORZA_HAP )); - HDMI_WRITE(VC4_HDMI_HORZB, + HDMI_WRITE(HDMI_HORZB, VC4_SET_FIELD((mode->htotal - mode->hsync_end) * pixel_rep, VC4_HDMI_HORZB_HBP) |
@@ -461,13 +416,13 @@ static void vc4_hdmi_encoder_enable(struct drm_encoder *encoder) mode->hdisplay) * pixel_rep, VC4_HDMI_HORZB_HFP)); -HDMI_WRITE (VC4_HDMI_VERTA0 , verta); -HDMI_WRITE (VC4_HDMI_VERTA1 , verta); +HDMI_WRITE (HDMI_VERTA0 , verta); +HDMI_WRITE (HDMI_VERTA1 , verta); -HDMI_WRITE (VC4_HDMI_VERTB0 , vertb_even); -HDMI_WRITE (VC4_HDMI_VERTB1 , vertb); +HDMI_WRITE (HDMI_VERTB0 , vertb_even); +HDMI_WRITE (HDMI_VERTB1 , vertb); -HD_WRITE (VC4_HD_VID_CTL , +HDMI_WRITE (HDMI_VID_CTL , (vsync_pos ?0 :VC4_HD_VID_CTL_VSYNC_LOW ) | (hsync_pos ?0 :VC4_HD_VID_CTL_HSYNC_LOW ));
@@ -492,21 +447,21 @@ static void vc4_hdmi_encoder_enable(struct drm_encoder *encoder) csc_ctl |=VC4_SET_FIELD (VC4_HD_CSC_CTL_MODE_CUSTOM ,VC4_HD_CSC_CTL_MODE ); -HD_WRITE (VC4_HD_CSC_12_11 , (0x000 <<16 ) |0x000 ); -HD_WRITE (VC4_HD_CSC_14_13 , (0x100 <<16 ) |0x6e0 ); -HD_WRITE (VC4_HD_CSC_22_21 , (0x6e0 <<16 ) |0x000 ); -HD_WRITE (VC4_HD_CSC_24_23 , (0x100 <<16 ) |0x000 ); -HD_WRITE (VC4_HD_CSC_32_31 , (0x000 <<16 ) |0x6e0 ); -HD_WRITE (VC4_HD_CSC_34_33 , (0x100 <<16 ) |0x000 ); +HDMI_WRITE (HDMI_CSC_12_11 , (0x000 <<16 ) |0x000 ); +HDMI_WRITE (HDMI_CSC_14_13 , (0x100 <<16 ) |0x6e0 ); +HDMI_WRITE (HDMI_CSC_22_21 , (0x6e0 <<16 ) |0x000 ); +HDMI_WRITE (HDMI_CSC_24_23 , (0x100 <<16 ) |0x000 ); +HDMI_WRITE (HDMI_CSC_32_31 , (0x000 <<16 ) |0x6e0 ); +HDMI_WRITE (HDMI_CSC_34_33 , (0x100 <<16 ) |0x000 ); vc4_encoder->limited_rgb_range = true; }else { vc4_encoder->limited_rgb_range = false; }/* The RGB order applies even when CSC is disabled. */ -HD_WRITE (VC4_HD_CSC_CTL , csc_ctl); +HDMI_WRITE (HDMI_CSC_CTL , csc_ctl); -HDMI_WRITE (VC4_HDMI_FIFO_CTL ,VC4_HDMI_FIFO_CTL_MASTER_SLAVE_N ); +HDMI_WRITE (HDMI_FIFO_CTL ,VC4_HDMI_FIFO_CTL_MASTER_SLAVE_N );if (debug_dump_regs) {struct drm_printer p =drm_info_printer (&vc4_hdmi->pdev->dev);
@@ -516,30 +471,30 @@ static void vc4_hdmi_encoder_enable(struct drm_encoder *encoder)drm_print_regset32 (&p, &vc4_hdmi->hd_regset); } -HD_WRITE (VC4_HD_VID_CTL , -HD_READ (VC4_HD_VID_CTL ) | -VC4_HD_VID_CTL_ENABLE | -VC4_HD_VID_CTL_UNDERFLOW_ENABLE | -VC4_HD_VID_CTL_FRAME_COUNTER_RESET ); +HDMI_WRITE (HDMI_VID_CTL , +HDMI_READ (HDMI_VID_CTL ) | +VC4_HD_VID_CTL_ENABLE | +VC4_HD_VID_CTL_UNDERFLOW_ENABLE | +VC4_HD_VID_CTL_FRAME_COUNTER_RESET );if (vc4_encoder->hdmi_monitor) { -HDMI_WRITE (VC4_HDMI_SCHEDULER_CONTROL , -HDMI_READ (VC4_HDMI_SCHEDULER_CONTROL ) | +HDMI_WRITE (HDMI_SCHEDULER_CONTROL , +HDMI_READ (HDMI_SCHEDULER_CONTROL ) |VC4_HDMI_SCHEDULER_CONTROL_MODE_HDMI ); - ret =wait_for (HDMI_READ (VC4_HDMI_SCHEDULER_CONTROL ) & + ret =wait_for (HDMI_READ (HDMI_SCHEDULER_CONTROL ) &VC4_HDMI_SCHEDULER_CONTROL_HDMI_ACTIVE ,1000 );WARN_ONCE (ret,"Timeout waiting for " "VC4_HDMI_SCHEDULER_CONTROL_HDMI_ACTIVE\n" ); }else { -HDMI_WRITE (VC4_HDMI_RAM_PACKET_CONFIG , -HDMI_READ (VC4_HDMI_RAM_PACKET_CONFIG ) & +HDMI_WRITE (HDMI_RAM_PACKET_CONFIG , +HDMI_READ (HDMI_RAM_PACKET_CONFIG ) & ~(VC4_HDMI_RAM_PACKET_ENABLE )); -HDMI_WRITE (VC4_HDMI_SCHEDULER_CONTROL , -HDMI_READ (VC4_HDMI_SCHEDULER_CONTROL ) & +HDMI_WRITE (HDMI_SCHEDULER_CONTROL , +HDMI_READ (HDMI_SCHEDULER_CONTROL ) & ~VC4_HDMI_SCHEDULER_CONTROL_MODE_HDMI ); - ret =wait_for (!(HDMI_READ (VC4_HDMI_SCHEDULER_CONTROL ) & + ret =wait_for (!(HDMI_READ (HDMI_SCHEDULER_CONTROL ) &VC4_HDMI_SCHEDULER_CONTROL_HDMI_ACTIVE ),1000 );WARN_ONCE (ret,"Timeout waiting for " "!VC4_HDMI_SCHEDULER_CONTROL_HDMI_ACTIVE\n" );
@@ -548,31 +503,31 @@ static void vc4_hdmi_encoder_enable(struct drm_encoder *encoder)if (vc4_encoder->hdmi_monitor) {u32 drift; -WARN_ON (!(HDMI_READ (VC4_HDMI_SCHEDULER_CONTROL ) & +WARN_ON (!(HDMI_READ (HDMI_SCHEDULER_CONTROL ) &VC4_HDMI_SCHEDULER_CONTROL_HDMI_ACTIVE )); -HDMI_WRITE (VC4_HDMI_SCHEDULER_CONTROL , -HDMI_READ (VC4_HDMI_SCHEDULER_CONTROL ) | +HDMI_WRITE (HDMI_SCHEDULER_CONTROL , +HDMI_READ (HDMI_SCHEDULER_CONTROL ) |VC4_HDMI_SCHEDULER_CONTROL_VERT_ALWAYS_KEEPOUT ); -HDMI_WRITE (VC4_HDMI_RAM_PACKET_CONFIG , +HDMI_WRITE (HDMI_RAM_PACKET_CONFIG ,VC4_HDMI_RAM_PACKET_ENABLE );vc4_hdmi_set_infoframes (encoder); - drift =HDMI_READ (VC4_HDMI_FIFO_CTL ); + drift =HDMI_READ (HDMI_FIFO_CTL ); drift &=VC4_HDMI_FIFO_VALID_WRITE_MASK ; -HDMI_WRITE (VC4_HDMI_FIFO_CTL , +HDMI_WRITE (HDMI_FIFO_CTL , drift & ~VC4_HDMI_FIFO_CTL_RECENTER ); -HDMI_WRITE (VC4_HDMI_FIFO_CTL , +HDMI_WRITE (HDMI_FIFO_CTL , drift |VC4_HDMI_FIFO_CTL_RECENTER );usleep_range (1000 ,1100 ); -HDMI_WRITE (VC4_HDMI_FIFO_CTL , +HDMI_WRITE (HDMI_FIFO_CTL , drift & ~VC4_HDMI_FIFO_CTL_RECENTER ); -HDMI_WRITE (VC4_HDMI_FIFO_CTL , +HDMI_WRITE (HDMI_FIFO_CTL , drift |VC4_HDMI_FIFO_CTL_RECENTER ); - ret =wait_for (HDMI_READ (VC4_HDMI_FIFO_CTL ) & + ret =wait_for (HDMI_READ (HDMI_FIFO_CTL ) &VC4_HDMI_FIFO_CTL_RECENTER_DONE ,1 );WARN_ONCE (ret,"Timeout waiting for " "VC4_HDMI_FIFO_CTL_RECENTER_DONE" );
@@ -612,7 +567,7 @@ static void vc4_hdmi_audio_set_mai_clock(struct vc4_hdmi *vc4_hdmi) VC4_HD_MAI_SMP_M_SHIFT) + 1, &n, &m); -HD_WRITE (VC4_HD_MAI_SMP , +HDMI_WRITE (HDMI_MAI_SMP ,VC4_SET_FIELD (n,VC4_HD_MAI_SMP_N ) |VC4_SET_FIELD (m -1 ,VC4_HD_MAI_SMP_M )); }
@@ -631,7 +586,7 @@ static void vc4_hdmi_set_n_cts(struct vc4_hdmi *vc4_hdmi)do_div (tmp,128 * samplerate); cts = tmp; -HDMI_WRITE (VC4_HDMI_CRP_CFG , +HDMI_WRITE (HDMI_CRP_CFG ,VC4_HDMI_CRP_CFG_EXTERNAL_CTS_EN |VC4_SET_FIELD (n,VC4_HDMI_CRP_CFG_N ));
@@ -640,8 +595,8 @@ static void vc4_hdmi_set_n_cts(struct vc4_hdmi *vc4_hdmi)* providing a CTS_1 value. The two CTS values are alternated * between based on the period fields */ -HDMI_WRITE (VC4_HDMI_CTS_0 , cts); -HDMI_WRITE (VC4_HDMI_CTS_1 , cts); +HDMI_WRITE (HDMI_CTS_0 , cts); +HDMI_WRITE (HDMI_CTS_1 , cts); }static inline struct vc4_hdmi *dai_to_hdmi (struct snd_soc_dai *dai)
@@ -668,7 +623,7 @@ static int vc4_hdmi_audio_startup(struct snd_pcm_substream *substream,* If the HDMI encoder hasn't probed, or the encoder is * currently in DVI mode, treat the codec dai as missing. */ -if (!encoder->crtc || !(HDMI_READ (VC4_HDMI_RAM_PACKET_CONFIG ) & +if (!encoder->crtc || !(HDMI_READ (HDMI_RAM_PACKET_CONFIG ) &VC4_HDMI_RAM_PACKET_ENABLE ))return -ENODEV ;
@@ -694,9 +649,9 @@ static void vc4_hdmi_audio_reset(struct vc4_hdmi *vc4_hdmi)if (ret)dev_err (dev,"Failed to stop audio infoframe: %d\n" , ret); -HD_WRITE (VC4_HD_MAI_CTL ,VC4_HD_MAI_CTL_RESET ); -HD_WRITE (VC4_HD_MAI_CTL ,VC4_HD_MAI_CTL_ERRORF ); -HD_WRITE (VC4_HD_MAI_CTL ,VC4_HD_MAI_CTL_FLUSH ); +HDMI_WRITE (HDMI_MAI_CTL ,VC4_HD_MAI_CTL_RESET ); +HDMI_WRITE (HDMI_MAI_CTL ,VC4_HD_MAI_CTL_ERRORF ); +HDMI_WRITE (HDMI_MAI_CTL ,VC4_HD_MAI_CTL_FLUSH ); } static void vc4_hdmi_audio_shutdown(struct snd_pcm_substream *substream,
@@ -732,7 +687,7 @@ static int vc4_hdmi_audio_hw_params(struct snd_pcm_substream *substream, vc4_hdmi->audio.channels =params_channels (params); vc4_hdmi->audio.samplerate =params_rate (params); - HD_WRITE(VC4_HD_MAI_CTL, + HDMI_WRITE(HDMI_MAI_CTL, VC4_HD_MAI_CTL_RESET | VC4_HD_MAI_CTL_FLUSH | VC4_HD_MAI_CTL_DLATE |
@@ -752,22 +707,22 @@ static int vc4_hdmi_audio_hw_params(struct snd_pcm_substream *substream,/* Set the MAI threshold. This logic mimics the firmware's. */ if (vc4_hdmi->audio.samplerate >96000 ) { -HD_WRITE (VC4_HD_MAI_THR , +HDMI_WRITE (HDMI_MAI_THR ,VC4_SET_FIELD (0x12 ,VC4_HD_MAI_THR_DREQHIGH ) |VC4_SET_FIELD (0x12 ,VC4_HD_MAI_THR_DREQLOW )); }else if (vc4_hdmi->audio.samplerate >48000 ) { -HD_WRITE (VC4_HD_MAI_THR , +HDMI_WRITE (HDMI_MAI_THR ,VC4_SET_FIELD (0x14 ,VC4_HD_MAI_THR_DREQHIGH ) |VC4_SET_FIELD (0x12 ,VC4_HD_MAI_THR_DREQLOW )); }else { -HD_WRITE (VC4_HD_MAI_THR , +HDMI_WRITE (HDMI_MAI_THR ,VC4_SET_FIELD (0x10 ,VC4_HD_MAI_THR_PANICHIGH ) |VC4_SET_FIELD (0x10 ,VC4_HD_MAI_THR_PANICLOW ) |VC4_SET_FIELD (0x10 ,VC4_HD_MAI_THR_DREQHIGH ) |VC4_SET_FIELD (0x10 ,VC4_HD_MAI_THR_DREQLOW )); } -HDMI_WRITE (VC4_HDMI_MAI_CONFIG , +HDMI_WRITE (HDMI_MAI_CONFIG ,VC4_HDMI_MAI_CONFIG_BIT_REVERSE |VC4_SET_FIELD (channel_mask,VC4_HDMI_MAI_CHANNEL_MASK ));
@@ -777,8 +732,8 @@ static int vc4_hdmi_audio_hw_params(struct snd_pcm_substream *substream, channel_map |= i << (3 * i); } -HDMI_WRITE (VC4_HDMI_MAI_CHANNEL_MAP , channel_map); -HDMI_WRITE (VC4_HDMI_AUDIO_PACKET_CONFIG , audio_packet_config); +HDMI_WRITE (HDMI_MAI_CHANNEL_MAP , channel_map); +HDMI_WRITE (HDMI_AUDIO_PACKET_CONFIG , audio_packet_config);vc4_hdmi_set_n_cts (vc4_hdmi);return 0 ;
@@ -793,21 +748,22 @@ static int vc4_hdmi_audio_trigger(struct snd_pcm_substream *substream, int cmd,switch (cmd) {case SNDRV_PCM_TRIGGER_START :vc4_hdmi_set_audio_infoframe (encoder); -HDMI_WRITE (VC4_HDMI_TX_PHY_CTL0 , -HDMI_READ (VC4_HDMI_TX_PHY_CTL0 ) & +HDMI_WRITE (HDMI_TX_PHY_CTL_0 , +HDMI_READ (HDMI_TX_PHY_CTL_0 ) & ~VC4_HDMI_TX_PHY_RNG_PWRDN ); -HD_WRITE (VC4_HD_MAI_CTL , + +HDMI_WRITE (HDMI_MAI_CTL ,VC4_SET_FIELD (vc4_hdmi->audio.channels,VC4_HD_MAI_CTL_CHNUM ) |VC4_HD_MAI_CTL_ENABLE );break ;case SNDRV_PCM_TRIGGER_STOP : -HD_WRITE (VC4_HD_MAI_CTL , +HDMI_WRITE (HDMI_MAI_CTL ,VC4_HD_MAI_CTL_DLATE |VC4_HD_MAI_CTL_ERRORE |VC4_HD_MAI_CTL_ERRORF ); -HDMI_WRITE (VC4_HDMI_TX_PHY_CTL0 , -HDMI_READ (VC4_HDMI_TX_PHY_CTL0 ) | +HDMI_WRITE (HDMI_TX_PHY_CTL_0 , +HDMI_READ (HDMI_TX_PHY_CTL_0 ) |VC4_HDMI_TX_PHY_RNG_PWRDN );break ;default :
@@ -941,6 +897,8 @@ static const struct snd_dmaengine_pcm_config pcm_conf = {static int vc4_hdmi_audio_init (struct vc4_hdmi *vc4_hdmi) { +const struct vc4_hdmi_register *mai_data = + &vc4_hdmi->variant->registers[HDMI_MAI_DATA ];struct snd_soc_dai_link *dai_link = &vc4_hdmi->audio.link;struct snd_soc_card *card = &vc4_hdmi->audio.card;struct device *dev = &vc4_hdmi->pdev->dev;
@@ -953,6 +911,11 @@ static int vc4_hdmi_audio_init(struct vc4_hdmi *vc4_hdmi)return 0 ; } +if (mai_data->reg !=VC4_HD ) { +WARN_ONCE (true,"MAI isn't in the HD block\n" ); +return -EINVAL ; + } +/* * Get the physical address of VC4_HD_MAI_DATA. We need to retrieve * the bus address specified in the DT, because the physical address
@@ -961,7 +924,7 @@ static int vc4_hdmi_audio_init(struct vc4_hdmi *vc4_hdmi)* This VC/MMU should probably be exposed to avoid this kind of hacks. */ addr =of_get_address (dev->of_node,1 ,NULL ,NULL ); - vc4_hdmi->audio.dma_data.addr =be32_to_cpup (addr) +VC4_HD_MAI_DATA ; + vc4_hdmi->audio.dma_data.addr =be32_to_cpup (addr) + mai_data->offset; vc4_hdmi->audio.dma_data.addr_width =DMA_SLAVE_BUSWIDTH_4_BYTES ; vc4_hdmi->audio.dma_data.maxburst =2 ;
@@ -1053,7 +1016,7 @@ static void vc4_cec_read_msg(struct vc4_dev *vc4, u32 cntrl1) msg->len =1 + ((cntrl1 &VC4_HDMI_CEC_REC_WRD_CNT_MASK ) >>VC4_HDMI_CEC_REC_WRD_CNT_SHIFT );for (i =0 ; i < msg->len; i +=4 ) { -u32 val =HDMI_READ (VC4_HDMI_CEC_RX_DATA_1 + i); +u32 val =HDMI_READ (HDMI_CEC_RX_DATA_1 + i); msg->msg[i] = val &0xff ; msg->msg[i +1 ] = (val >>8 ) &0xff ;
@@ -1065,26 +1028,26 @@ static void vc4_cec_read_msg(struct vc4_dev *vc4, u32 cntrl1)static irqreturn_t vc4_cec_irq_handler (int irq,void *priv) {struct vc4_hdmi *vc4_hdmi = priv; -u32 stat =HDMI_READ (VC4_HDMI_CPU_STATUS ); +u32 stat =HDMI_READ (HDMI_CPU_STATUS );u32 cntrl1, cntrl5;if (!(stat &VC4_HDMI_CPU_CEC ))return IRQ_NONE ; vc4_hdmi->cec_rx_msg.len =0 ; - cntrl1 =HDMI_READ (VC4_HDMI_CEC_CNTRL_1 ); - cntrl5 =HDMI_READ (VC4_HDMI_CEC_CNTRL_5 ); + cntrl1 =HDMI_READ (HDMI_CEC_CNTRL_1 ); + cntrl5 =HDMI_READ (HDMI_CEC_CNTRL_5 ); vc4_hdmi->cec_irq_was_rx = cntrl5 &VC4_HDMI_CEC_RX_CEC_INT ;if (vc4_hdmi->cec_irq_was_rx) {vc4_cec_read_msg (vc4, cntrl1); cntrl1 |=VC4_HDMI_CEC_CLEAR_RECEIVE_OFF ; -HDMI_WRITE (VC4_HDMI_CEC_CNTRL_1 , cntrl1); +HDMI_WRITE (HDMI_CEC_CNTRL_1 , cntrl1); cntrl1 &= ~VC4_HDMI_CEC_CLEAR_RECEIVE_OFF ; }else { vc4_hdmi->cec_tx_ok = cntrl1 &VC4_HDMI_CEC_TX_STATUS_GOOD ; cntrl1 &= ~VC4_HDMI_CEC_START_XMIT_BEGIN ; } -HDMI_WRITE (VC4_HDMI_CEC_CNTRL_1 , cntrl1); -HDMI_WRITE (VC4_HDMI_CPU_CLEAR ,VC4_HDMI_CPU_CEC ); +HDMI_WRITE (HDMI_CEC_CNTRL_1 , cntrl1); +HDMI_WRITE (HDMI_CPU_CLEAR ,VC4_HDMI_CPU_CEC );return IRQ_WAKE_THREAD ; }
@@ -1094,7 +1057,7 @@ static int vc4_hdmi_cec_adap_enable(struct cec_adapter *adap, bool enable)struct vc4_hdmi *vc4_hdmi =cec_get_drvdata (adap);/* clock period in microseconds */ const u32 usecs =1000000 /CEC_CLOCK_FREQ ; -u32 val =HDMI_READ (VC4_HDMI_CEC_CNTRL_5 ); +u32 val =HDMI_READ (HDMI_CEC_CNTRL_5 ); val &= ~(VC4_HDMI_CEC_TX_SW_RESET | VC4_HDMI_CEC_RX_SW_RESET | VC4_HDMI_CEC_CNT_TO_4700_US_MASK |
@@ -1103,30 +1066,30 @@ static int vc4_hdmi_cec_adap_enable(struct cec_adapter *adap, bool enable) ((4500 / usecs) <<VC4_HDMI_CEC_CNT_TO_4500_US_SHIFT );if (enable) { -HDMI_WRITE (VC4_HDMI_CEC_CNTRL_5 , val | +HDMI_WRITE (HDMI_CEC_CNTRL_5 , val |VC4_HDMI_CEC_TX_SW_RESET |VC4_HDMI_CEC_RX_SW_RESET ); -HDMI_WRITE (VC4_HDMI_CEC_CNTRL_5 , val); -HDMI_WRITE (VC4_HDMI_CEC_CNTRL_2 , +HDMI_WRITE (HDMI_CEC_CNTRL_5 , val); +HDMI_WRITE (HDMI_CEC_CNTRL_2 , ((1500 / usecs) <<VC4_HDMI_CEC_CNT_TO_1500_US_SHIFT ) | ((1300 / usecs) <<VC4_HDMI_CEC_CNT_TO_1300_US_SHIFT ) | ((800 / usecs) <<VC4_HDMI_CEC_CNT_TO_800_US_SHIFT ) | ((600 / usecs) <<VC4_HDMI_CEC_CNT_TO_600_US_SHIFT ) | ((400 / usecs) <<VC4_HDMI_CEC_CNT_TO_400_US_SHIFT )); -HDMI_WRITE (VC4_HDMI_CEC_CNTRL_3 , +HDMI_WRITE (HDMI_CEC_CNTRL_3 , ((2750 / usecs) <<VC4_HDMI_CEC_CNT_TO_2750_US_SHIFT ) | ((2400 / usecs) <<VC4_HDMI_CEC_CNT_TO_2400_US_SHIFT ) | ((2050 / usecs) <<VC4_HDMI_CEC_CNT_TO_2050_US_SHIFT ) | ((1700 / usecs) <<VC4_HDMI_CEC_CNT_TO_1700_US_SHIFT )); -HDMI_WRITE (VC4_HDMI_CEC_CNTRL_4 , +HDMI_WRITE (HDMI_CEC_CNTRL_4 , ((4300 / usecs) <<VC4_HDMI_CEC_CNT_TO_4300_US_SHIFT ) | ((3900 / usecs) <<VC4_HDMI_CEC_CNT_TO_3900_US_SHIFT ) | ((3600 / usecs) <<VC4_HDMI_CEC_CNT_TO_3600_US_SHIFT ) | ((3500 / usecs) <<VC4_HDMI_CEC_CNT_TO_3500_US_SHIFT )); -HDMI_WRITE (VC4_HDMI_CPU_MASK_CLEAR ,VC4_HDMI_CPU_CEC ); +HDMI_WRITE (HDMI_CPU_MASK_CLEAR ,VC4_HDMI_CPU_CEC ); }else { -HDMI_WRITE (VC4_HDMI_CPU_MASK_SET ,VC4_HDMI_CPU_CEC ); -HDMI_WRITE (VC4_HDMI_CEC_CNTRL_5 , val | +HDMI_WRITE (HDMI_CPU_MASK_SET ,VC4_HDMI_CPU_CEC ); +HDMI_WRITE (HDMI_CEC_CNTRL_5 , val |VC4_HDMI_CEC_TX_SW_RESET |VC4_HDMI_CEC_RX_SW_RESET ); }return 0 ;
@@ -1136,8 +1099,8 @@ static int vc4_hdmi_cec_adap_log_addr(struct cec_adapter *adap, u8 log_addr) {struct vc4_hdmi *vc4_hdmi =cec_get_drvdata (adap); -HDMI_WRITE (VC4_HDMI_CEC_CNTRL_1 , - (HDMI_READ (VC4_HDMI_CEC_CNTRL_1 ) & ~VC4_HDMI_CEC_ADDR_MASK ) | +HDMI_WRITE (HDMI_CEC_CNTRL_1 , + (HDMI_READ (HDMI_CEC_CNTRL_1 ) & ~VC4_HDMI_CEC_ADDR_MASK ) | (log_addr &0xf ) <<VC4_HDMI_CEC_ADDR_SHIFT );return 0 ; }
@@ -1150,20 +1113,20 @@ static int vc4_hdmi_cec_adap_transmit(struct cec_adapter *adap, u8 attempts,unsigned int i;for (i =0 ; i < msg->len; i +=4 ) -HDMI_WRITE (VC4_HDMI_CEC_TX_DATA_1 + i, +HDMI_WRITE (HDMI_CEC_TX_DATA_1 + i, (msg->msg[i]) | (msg->msg[i +1 ] <<8 ) | (msg->msg[i +2 ] <<16 ) | (msg->msg[i +3 ] <<24 )); - val =HDMI_READ (VC4_HDMI_CEC_CNTRL_1 ); + val =HDMI_READ (HDMI_CEC_CNTRL_1 ); val &= ~VC4_HDMI_CEC_START_XMIT_BEGIN ; -HDMI_WRITE (VC4_HDMI_CEC_CNTRL_1 , val); +HDMI_WRITE (HDMI_CEC_CNTRL_1 , val); val &= ~VC4_HDMI_CEC_MESSAGE_LENGTH_MASK ; val |= (msg->len -1 ) <<VC4_HDMI_CEC_MESSAGE_LENGTH_SHIFT ; val |=VC4_HDMI_CEC_START_XMIT_BEGIN ; -HDMI_WRITE (VC4_HDMI_CEC_CNTRL_1 , val); +HDMI_WRITE (HDMI_CEC_CNTRL_1 , val);return 0 ; }
@@ -1174,26 +1137,63 @@ static const struct cec_adap_ops vc4_hdmi_cec_adap_ops = { };#endif +static int vc4_hdmi_build_regset (struct vc4_hdmi *vc4_hdmi, +struct debugfs_regset32 *regset, +enum vc4_hdmi_regs reg) +{ +const struct vc4_hdmi_variant *variant = vc4_hdmi->variant; +struct debugfs_reg32 *regs; +unsigned int count =0 ; +unsigned int i; + + regs =kzalloc (variant->num_registers *sizeof (*regs), +GFP_KERNEL ); +if (!regs) +return -ENOMEM ; + +for (i =0 ; i < variant->num_registers; i++) { +const struct vc4_hdmi_register *field = &variant->registers[i]; + +if (field->reg != reg) +continue ; + + regs[count].name = field->name; + regs[count].offset = field->offset; + count++; + } + + regs =krealloc (regs, count *sizeof (*regs),GFP_KERNEL ); +if (!regs) +return -ENOMEM ; + + regset->base =__vc4_hdmi_get_field_base (vc4_hdmi, reg); + regset->regs = regs; + regset->nregs = count; + +return 0 ; +} +static int vc4_hdmi_init_resources (struct vc4_hdmi *vc4_hdmi) {struct platform_device *pdev = vc4_hdmi->pdev;struct device *dev = &pdev->dev; +int ret; vc4_hdmi->hdmicore_regs =vc4_ioremap_regs (pdev,0 );if (IS_ERR (vc4_hdmi->hdmicore_regs))return PTR_ERR (vc4_hdmi->hdmicore_regs); - vc4_hdmi->hdmi_regset.base = vc4_hdmi->hdmicore_regs; - vc4_hdmi->hdmi_regset.regs = hdmi_regs; - vc4_hdmi->hdmi_regset.nregs =ARRAY_SIZE (hdmi_regs); + ret =vc4_hdmi_build_regset (vc4_hdmi, &vc4_hdmi->hd_regset,VC4_HD ); +if (ret) +return ret; vc4_hdmi->hd_regs =vc4_ioremap_regs (pdev,1 );if (IS_ERR (vc4_hdmi->hd_regs))return PTR_ERR (vc4_hdmi->hd_regs); - vc4_hdmi->hd_regset.base = vc4_hdmi->hd_regs; - vc4_hdmi->hd_regset.regs = hd_regs; - vc4_hdmi->hd_regset.nregs =ARRAY_SIZE (hd_regs); + ret =vc4_hdmi_build_regset (vc4_hdmi, &vc4_hdmi->hdmi_regset,VC4_HDMI ); +if (ret) +return ret; vc4_hdmi->pixel_clock =devm_clk_get (dev,"pixel" );if (IS_ERR (vc4_hdmi->pixel_clock)) {
@@ -1286,12 +1286,12 @@ static int vc4_hdmi_bind(struct device *dev, struct device *master, void *data) }/* HDMI core must be enabled. */ -if (!(HD_READ (VC4_HD_M_CTL ) &VC4_HD_M_ENABLE )) { -HD_WRITE (VC4_HD_M_CTL ,VC4_HD_M_SW_RST ); +if (!(HDMI_READ (HDMI_M_CTL ) &VC4_HD_M_ENABLE )) { +HDMI_WRITE (HDMI_M_CTL ,VC4_HD_M_SW_RST );udelay (1 ); -HD_WRITE (VC4_HD_M_CTL ,0 ); +HDMI_WRITE (HDMI_M_CTL ,0 ); -HD_WRITE (VC4_HD_M_CTL ,VC4_HD_M_ENABLE ); +HDMI_WRITE (HDMI_M_CTL ,VC4_HD_M_ENABLE ); }pm_runtime_enable (dev);
@@ -1315,8 +1315,8 @@ static int vc4_hdmi_bind(struct device *dev, struct device *master, void *data)cec_fill_conn_info_from_drm (&conn_info, hdmi->connector);cec_s_conn_info (hdmi->cec_adap, &conn_info); -HDMI_WRITE (VC4_HDMI_CPU_MASK_SET ,0xffffffff ); - value =HDMI_READ (VC4_HDMI_CEC_CNTRL_1 ); +HDMI_WRITE (HDMI_CPU_MASK_SET ,0xffffffff ); + value =HDMI_READ (HDMI_CEC_CNTRL_1 ); value &= ~VC4_HDMI_CEC_DIV_CLK_CNT_MASK ;/* * Set the logical address to Unregistered and set the clock
@@ -1325,7 +1325,7 @@ static int vc4_hdmi_bind(struct device *dev, struct device *master, void *data)*/ value |=VC4_HDMI_CEC_ADDR_MASK | (4091 <<VC4_HDMI_CEC_DIV_CLK_CNT_SHIFT ); -HDMI_WRITE (VC4_HDMI_CEC_CNTRL_1 , value); +HDMI_WRITE (HDMI_CEC_CNTRL_1 , value); ret = devm_request_threaded_irq(dev, platform_get_irq(pdev, 0), vc4_cec_irq_handler, vc4_cec_irq_handler_thread, 0,
@@ -1372,6 +1372,9 @@ static void vc4_hdmi_unbind(struct device *dev, struct device *master,struct snd_soc_card *card =dev_get_drvdata (dev);struct vc4_hdmi *vc4_hdmi =snd_soc_card_get_drvdata (card); +kfree (vc4_hdmi->hdmi_regset.regs); +kfree (vc4_hdmi->hd_regset.regs); +cec_unregister_adapter (vc4_hdmi->cec_adap);vc4_hdmi_connector_destroy (&vc4_hdmi->connector);vc4_hdmi_encoder_destroy (&vc4_hdmi->encoder.base.base);
@@ -1399,6 +1402,9 @@ static int vc4_hdmi_dev_remove(struct platform_device *pdev) }struct vc4_hdmi_variant bcm2835_variant = { + .registers = vc4_hdmi_fields, + .num_registers =ARRAY_SIZE (vc4_hdmi_fields), + .init_resources = vc4_hdmi_init_resources, };
drivers/gpu/drm/vc4/vc4_hdmi.h +8 -5
@@ -21,7 +21,15 @@ to_vc4_hdmi_encoder(struct drm_encoder *encoder) return container_of(encoder, struct vc4_hdmi_encoder, base.base); } +struct vc4_hdmi_register ; +struct vc4_hdmi_variant { +/* List of the registers available on that variant */ +const struct vc4_hdmi_register *registers; + +/* Number of registers on that variant */ +unsigned int num_registers; +/* Callback to get the resources (memory region, interrupts, * clocks, etc) for that variant. */
@@ -83,9 +91,4 @@ encoder_to_vc4_hdmi(struct drm_encoder *encoder) return container_of(_encoder, struct vc4_hdmi, encoder); } -#define HDMI_READ (offset) readl(vc4_hdmi->hdmicore_regs + offset) -#define HDMI_WRITE (offset, val) writel(val, vc4_hdmi->hdmicore_regs + offset) -#define HD_READ (offset) readl(vc4_hdmi->hd_regs + offset) -#define HD_WRITE (offset, val) writel(val, vc4_hdmi->hd_regs + offset) -#endif /* _VC4_HDMI_H_ */
drivers/gpu/drm/vc4/vc4_hdmi_regs.h new file +244 -0
244 lines not on this page · raw message
drivers/gpu/drm/vc4/vc4_regs.h +0 -92
231 lines not on this page · raw message
Signature · 1 line
git-series 0.9.1
kbuild test robot
build botRe: [PATCH 73/89] drm/vc4: hdmi: Implement a register layout abstraction
I love your patch! Yet something to improve:
Hi Maxime,
I love your patch! Yet something to improve:
[auto build test ERROR on clk/clk-next]
[also build test ERROR on robh/for-next v5.6-rc3 next-20200224] [cannot apply to anholt/for-next]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Maxime-Ripard/drm-vc4-Support-BCM2711-Display-Pipeline/20200224-172730 base: https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git clk-next config: nds32-allyesconfig (attached as .config) compiler: nds32le-linux-gcc (GCC) 9.2.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=9.2.0 make.cross ARCH=nds32
If you fix the issue, kindly add following tag
All errors (new ones prefixed by >>):
In file included from drivers/gpu/drm/vc4/vc4_hdmi.c:51:
drivers/gpu/drm/vc4/vc4_hdmi.h:36:31: warning: 'struct vc4_hdmi' declared inside parameter list will not be visible outside of this definition or declaration
36 | int (*init_resources)(struct vc4_hdmi *vc4_hdmi);
| ^~~~~~~~
drivers/gpu/drm/vc4/vc4_hdmi.c: In function 'vc4_cec_read_msg':
drivers/gpu/drm/vc4/vc4_hdmi.c:1013:28: error: 'struct vc4_dev' has no member named 'hdmi'
1013 | struct cec_msg *msg = &vc4->hdmi->cec_rx_msg;
| ^~
In file included from drivers/gpu/drm/vc4/vc4_hdmi.c:52:
drivers/gpu/drm/vc4/vc4_hdmi_regs.h:219:39: error: 'vc4_hdmi' undeclared (first use in this function)
219 | #define HDMI_READ(reg) vc4_hdmi_read(vc4_hdmi, reg)
| ^~~~~~~~
drivers/gpu/drm/vc4/vc4_hdmi.c:1019:13: note: in expansion of macro 'HDMI_READ'
1019 | u32 val = HDMI_READ(HDMI_CEC_RX_DATA_1 + i);
| ^~~~~~~~~
drivers/gpu/drm/vc4/vc4_hdmi_regs.h:219:39: note: each undeclared identifier is reported only once for each function it appears in
219 | #define HDMI_READ(reg) vc4_hdmi_read(vc4_hdmi, reg)
| ^~~~~~~~
drivers/gpu/drm/vc4/vc4_hdmi.c:1019:13: note: in expansion of macro 'HDMI_READ'
1019 | u32 val = HDMI_READ(HDMI_CEC_RX_DATA_1 + i);
| ^~~~~~~~~
drivers/gpu/drm/vc4/vc4_hdmi.c: In function 'vc4_cec_irq_handler':
drivers/gpu/drm/vc4/vc4_hdmi.c:1031:23: error: 'HDMI_CPU_STATUS' undeclared (first use in this function); did you mean 'HDMI_CEC_CPU_STATUS'?
1031 | u32 stat = HDMI_READ(HDMI_CPU_STATUS);
| ^~~~~~~~~~~~~~~
drivers/gpu/drm/vc4/vc4_hdmi_regs.h:219:49: note: in definition of macro 'HDMI_READ'
219 | #define HDMI_READ(reg) vc4_hdmi_read(vc4_hdmi, reg)
| ^~~
drivers/gpu/drm/vc4/vc4_hdmi.c:1041:20: error: 'vc4' undeclared (first use in this function)
1041 | vc4_cec_read_msg(vc4, cntrl1);
| ^~~
In file included from drivers/gpu/drm/vc4/vc4_hdmi.c:52:
>> drivers/gpu/drm/vc4/vc4_hdmi.c:1050:13: error: 'HDMI_CPU_CLEAR' undeclared (first use in this function)
1050 | HDMI_WRITE(HDMI_CPU_CLEAR, VC4_HDMI_CPU_CEC);
| ^~~~~~~~~~~~~~
drivers/gpu/drm/vc4/vc4_hdmi_regs.h:242:55: note: in definition of macro 'HDMI_WRITE'
242 | #define HDMI_WRITE(reg, val) vc4_hdmi_write(vc4_hdmi, reg, val)
| ^~~
drivers/gpu/drm/vc4/vc4_hdmi.c: In function 'vc4_hdmi_cec_adap_enable':
>> drivers/gpu/drm/vc4/vc4_hdmi.c:1089:14: error: 'HDMI_CPU_MASK_CLEAR' undeclared (first use in this function)
1089 | HDMI_WRITE(HDMI_CPU_MASK_CLEAR, VC4_HDMI_CPU_CEC);
| ^~~~~~~~~~~~~~~~~~~
drivers/gpu/drm/vc4/vc4_hdmi_regs.h:242:55: note: in definition of macro 'HDMI_WRITE'
242 | #define HDMI_WRITE(reg, val) vc4_hdmi_write(vc4_hdmi, reg, val)
| ^~~
>> drivers/gpu/drm/vc4/vc4_hdmi.c:1091:14: error: 'HDMI_CPU_MASK_SET' undeclared (first use in this function)
1091 | HDMI_WRITE(HDMI_CPU_MASK_SET, VC4_HDMI_CPU_CEC);
| ^~~~~~~~~~~~~~~~~
drivers/gpu/drm/vc4/vc4_hdmi_regs.h:242:55: note: in definition of macro 'HDMI_WRITE'
242 | #define HDMI_WRITE(reg, val) vc4_hdmi_write(vc4_hdmi, reg, val)
| ^~~
drivers/gpu/drm/vc4/vc4_hdmi.c: In function 'vc4_hdmi_bind':
drivers/gpu/drm/vc4/vc4_hdmi.c:1237:32: error: passing argument 1 of 'variant->init_resources' from incompatible pointer type [-Werror=incompatible-pointer-types]
1237 | ret = variant->init_resources(vc4_hdmi);
| ^~~~~~~~
| |
| struct vc4_hdmi *
drivers/gpu/drm/vc4/vc4_hdmi.c:1237:32: note: expected 'struct vc4_hdmi *' but argument is of type 'struct vc4_hdmi *'
drivers/gpu/drm/vc4/vc4_hdmi.c:1308:12: error: 'vc4' undeclared (first use in this function)
1308 | vc4, "vc4",
| ^~~
drivers/gpu/drm/vc4/vc4_hdmi.c:1315:42: error: 'hdmi' undeclared (first use in this function)
1315 | cec_fill_conn_info_from_drm(&conn_info, hdmi->connector);
| ^~~~
In file included from drivers/gpu/drm/vc4/vc4_hdmi.c:52:
drivers/gpu/drm/vc4/vc4_hdmi.c:1318:13: error: 'HDMI_CPU_MASK_SET' undeclared (first use in this function)
1318 | HDMI_WRITE(HDMI_CPU_MASK_SET, 0xffffffff);
| ^~~~~~~~~~~~~~~~~
drivers/gpu/drm/vc4/vc4_hdmi_regs.h:242:55: note: in definition of macro 'HDMI_WRITE'
242 | #define HDMI_WRITE(reg, val) vc4_hdmi_write(vc4_hdmi, reg, val)
| ^~~
drivers/gpu/drm/vc4/vc4_hdmi.c:1335:49: error: passing argument 2 of 'cec_register_adapter' from incompatible pointer type [-Werror=incompatible-pointer-types]
1335 | ret = cec_register_adapter(vc4_hdmi->cec_adap, vc4_hdmi);
| ^~~~~~~~
| |
| struct vc4_hdmi *
In file included from drivers/gpu/drm/vc4/vc4_hdmi.c:49:
include/media/cec.h:242:67: note: expected 'struct device *' but argument is of type 'struct vc4_hdmi *'
242 | int cec_register_adapter(struct cec_adapter *adap, struct device *parent);
| ~~~~~~~~~~~~~~~^~~~~~
drivers/gpu/drm/vc4/vc4_hdmi.c: At top level:
drivers/gpu/drm/vc4/vc4_hdmi.c:1408:21: error: initialization of 'int (*)(struct vc4_hdmi *)' from incompatible pointer type 'int (*)(struct vc4_hdmi *)' [-Werror=incompatible-pointer-types]
1408 | .init_resources = vc4_hdmi_init_resources,
| ^~~~~~~~~~~~~~~~~~~~~~~ drivers/gpu/drm/vc4/vc4_hdmi.c:1408:21: note: (near initialization for 'bcm2835_variant.init_resources')
cc1: some warnings being treated as errors
vim +/HDMI_CPU_CLEAR +1050 drivers/gpu/drm/vc4/vc4_hdmi.c
1027
1028 static irqreturn_t vc4_cec_irq_handler(int irq, void *priv)
1029 {
1030 struct vc4_hdmi *vc4_hdmi = priv;
1031 u32 stat = HDMI_READ(HDMI_CPU_STATUS);
1032 u32 cntrl1, cntrl5;
1033
1034 if (!(stat & VC4_HDMI_CPU_CEC))
1035 return IRQ_NONE;
1036 vc4_hdmi->cec_rx_msg.len = 0;
1037 cntrl1 = HDMI_READ(HDMI_CEC_CNTRL_1);
1038 cntrl5 = HDMI_READ(HDMI_CEC_CNTRL_5);
1039 vc4_hdmi->cec_irq_was_rx = cntrl5 & VC4_HDMI_CEC_RX_CEC_INT;
1040 if (vc4_hdmi->cec_irq_was_rx) {
> 1041 vc4_cec_read_msg(vc4, cntrl1);
1042 cntrl1 |= VC4_HDMI_CEC_CLEAR_RECEIVE_OFF;
1043 HDMI_WRITE(HDMI_CEC_CNTRL_1, cntrl1);
1044 cntrl1 &= ~VC4_HDMI_CEC_CLEAR_RECEIVE_OFF;
1045 } else {
1046 vc4_hdmi->cec_tx_ok = cntrl1 & VC4_HDMI_CEC_TX_STATUS_GOOD;
1047 cntrl1 &= ~VC4_HDMI_CEC_START_XMIT_BEGIN;
1048 }
1049 HDMI_WRITE(HDMI_CEC_CNTRL_1, cntrl1);
> 1050 HDMI_WRITE(HDMI_CPU_CLEAR, VC4_HDMI_CPU_CEC);
1051
1052 return IRQ_WAKE_THREAD;
1053 }
1054
1055 static int vc4_hdmi_cec_adap_enable(struct cec_adapter *adap, bool enable)
1056 {
1057 struct vc4_hdmi *vc4_hdmi = cec_get_drvdata(adap);
1058 /* clock period in microseconds */
1059 const u32 usecs = 1000000 / CEC_CLOCK_FREQ;
1060 u32 val = HDMI_READ(HDMI_CEC_CNTRL_5);
1061
1062 val &= ~(VC4_HDMI_CEC_TX_SW_RESET | VC4_HDMI_CEC_RX_SW_RESET |
1063 VC4_HDMI_CEC_CNT_TO_4700_US_MASK |
1064 VC4_HDMI_CEC_CNT_TO_4500_US_MASK);
1065 val |= ((4700 / usecs) << VC4_HDMI_CEC_CNT_TO_4700_US_SHIFT) |
1066 ((4500 / usecs) << VC4_HDMI_CEC_CNT_TO_4500_US_SHIFT);
1067
1068 if (enable) {
1069 HDMI_WRITE(HDMI_CEC_CNTRL_5, val |
1070 VC4_HDMI_CEC_TX_SW_RESET | VC4_HDMI_CEC_RX_SW_RESET);
1071 HDMI_WRITE(HDMI_CEC_CNTRL_5, val);
1072 HDMI_WRITE(HDMI_CEC_CNTRL_2,
1073 ((1500 / usecs) << VC4_HDMI_CEC_CNT_TO_1500_US_SHIFT) |
1074 ((1300 / usecs) << VC4_HDMI_CEC_CNT_TO_1300_US_SHIFT) |
1075 ((800 / usecs) << VC4_HDMI_CEC_CNT_TO_800_US_SHIFT) |
1076 ((600 / usecs) << VC4_HDMI_CEC_CNT_TO_600_US_SHIFT) |
1077 ((400 / usecs) << VC4_HDMI_CEC_CNT_TO_400_US_SHIFT));
1078 HDMI_WRITE(HDMI_CEC_CNTRL_3,
1079 ((2750 / usecs) << VC4_HDMI_CEC_CNT_TO_2750_US_SHIFT) |
1080 ((2400 / usecs) << VC4_HDMI_CEC_CNT_TO_2400_US_SHIFT) |
1081 ((2050 / usecs) << VC4_HDMI_CEC_CNT_TO_2050_US_SHIFT) |
1082 ((1700 / usecs) << VC4_HDMI_CEC_CNT_TO_1700_US_SHIFT));
1083 HDMI_WRITE(HDMI_CEC_CNTRL_4,
1084 ((4300 / usecs) << VC4_HDMI_CEC_CNT_TO_4300_US_SHIFT) |
1085 ((3900 / usecs) << VC4_HDMI_CEC_CNT_TO_3900_US_SHIFT) |
1086 ((3600 / usecs) << VC4_HDMI_CEC_CNT_TO_3600_US_SHIFT) |
1087 ((3500 / usecs) << VC4_HDMI_CEC_CNT_TO_3500_US_SHIFT));
1088
> 1089 HDMI_WRITE(HDMI_CPU_MASK_CLEAR, VC4_HDMI_CPU_CEC);
1090 } else {
> 1091 HDMI_WRITE(HDMI_CPU_MASK_SET, VC4_HDMI_CPU_CEC); 1092 HDMI_WRITE(HDMI_CEC_CNTRL_5, val |
1093 VC4_HDMI_CEC_TX_SW_RESET | VC4_HDMI_CEC_RX_SW_RESET);
1094 }
1095 return 0;
1096 }
1097
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
PATCH 74/89 drm/vc4: hdmi: Add reset callback
In reply to Maxime RipardThe BCM2711 and BCM283x HDMI controllers use a slightly different reset sequence, so let's add a callback to reset the controller.
--- drivers/gpu/drm/vc4/vc4_hdmi.c | 17 ++++++++++++----- drivers/gpu/drm/vc4/vc4_hdmi.h | 3 +++ 2 files changed, 15 insertions(+), 5 deletions(-)
drivers/gpu/drm/vc4/vc4_hdmi.c +12 -5
@@ -68,6 +68,15 @@ static int vc4_hdmi_debugfs_regs(struct seq_file *m, void *unused)return 0 ; } +static void vc4_hdmi_reset (struct vc4_hdmi *vc4_hdmi) +{ +HDMI_WRITE (HDMI_SW_RESET_CONTROL , +VC4_HDMI_SW_RESET_HDMI | +VC4_HDMI_SW_RESET_FORMAT_DETECT ); + +HDMI_WRITE (HDMI_SW_RESET_CONTROL ,0 ); +} +static enum drm_connector_status vc4_hdmi_connector_detect (struct drm_connector *connector,bool force) {
@@ -371,11 +380,8 @@ static void vc4_hdmi_encoder_enable(struct drm_encoder *encoder)return ; } -HDMI_WRITE (HDMI_SW_RESET_CONTROL , -VC4_HDMI_SW_RESET_HDMI | -VC4_HDMI_SW_RESET_FORMAT_DETECT ); - -HDMI_WRITE (HDMI_SW_RESET_CONTROL ,0 ); +if (vc4_hdmi->variant->reset) + vc4_hdmi->variant->reset (vc4_hdmi);/* PHY should be in reset, like * vc4_hdmi_encoder_disable() does.
@@ -1406,6 +1412,7 @@ struct vc4_hdmi_variant bcm2835_variant = { .num_registers = ARRAY_SIZE(vc4_hdmi_fields), .init_resources = vc4_hdmi_init_resources, + .reset = vc4_hdmi_reset, };static const struct of_device_id vc4_hdmi_dt_match[] = {
drivers/gpu/drm/vc4/vc4_hdmi.h +3 -0
@@ -34,6 +34,9 @@ struct vc4_hdmi_variant {* clocks, etc) for that variant. */ int (*init_resources)(struct vc4_hdmi *vc4_hdmi); + +/* Callback to reset the HDMI block */ +void (*reset)(struct vc4_hdmi *vc4_hdmi); };/* HDMI audio information */
Signature · 1 line
git-series 0.9.1
PATCH 75/89 drm/vc4: hdmi: Add PHY init and disable function
In reply to Maxime RipardThe HDMI PHY in the BCM2711 HDMI controller is significantly more complicated to setup than in the older BCM283x SoCs.
Let's add hooks to enable and disable the PHY.
--- drivers/gpu/drm/vc4/Makefile | 1 + drivers/gpu/drm/vc4/vc4_hdmi.c | 14 +++++++------- drivers/gpu/drm/vc4/vc4_hdmi.h | 14 ++++++++++++++ drivers/gpu/drm/vc4/vc4_hdmi_phy.c | 25 +++++++++++++++++++++++++ 4 files changed, 47 insertions(+), 7 deletions(-) create mode 100644 drivers/gpu/drm/vc4/vc4_hdmi_phy.c
drivers/gpu/drm/vc4/Makefile +1 -0
@@ -12,6 +12,7 @@ vc4-y := \ vc4_kms.o \ vc4_gem.o \ vc4_hdmi.o \ + vc4_hdmi_phy.o \ vc4_vec.o \ vc4_hvs.o \ vc4_irq.o \
drivers/gpu/drm/vc4/vc4_hdmi.c +7 -7
@@ -323,7 +323,9 @@ static void vc4_hdmi_encoder_disable(struct drm_encoder *encoder)HDMI_WRITE (HDMI_RAM_PACKET_CONFIG ,0 ); -HDMI_WRITE (HDMI_TX_PHY_RESET_CTL ,0xf <<16 ); +if (vc4_hdmi->variant->phy_disable) + vc4_hdmi->variant->phy_disable (vc4_hdmi); +HDMI_WRITE (HDMI_VID_CTL ,HDMI_READ (HDMI_VID_CTL ) & ~VC4_HD_VID_CTL_ENABLE );
@@ -383,12 +385,8 @@ static void vc4_hdmi_encoder_enable(struct drm_encoder *encoder)if (vc4_hdmi->variant->reset) vc4_hdmi->variant->reset (vc4_hdmi); -/* PHY should be in reset, like -* vc4_hdmi_encoder_disable() does. -*/ -HDMI_WRITE (HDMI_TX_PHY_RESET_CTL ,0xf <<16 ); - -HDMI_WRITE (HDMI_TX_PHY_RESET_CTL ,0 ); +if (vc4_hdmi->variant->phy_init) + vc4_hdmi->variant->phy_init (vc4_hdmi, mode);if (debug_dump_regs) {struct drm_printer p =drm_info_printer (&vc4_hdmi->pdev->dev);
@@ -1413,6 +1411,8 @@ struct vc4_hdmi_variant bcm2835_variant = { .init_resources = vc4_hdmi_init_resources, .reset = vc4_hdmi_reset, + .phy_init = vc4_hdmi_phy_init, + .phy_disable = vc4_hdmi_phy_disable, };static const struct of_device_id vc4_hdmi_dt_match[] = {
drivers/gpu/drm/vc4/vc4_hdmi.h +14 -0
@@ -21,6 +21,9 @@ to_vc4_hdmi_encoder(struct drm_encoder *encoder) return container_of(encoder, struct vc4_hdmi_encoder, base.base); } +struct drm_display_mode ; + +struct vc4_hdmi ;struct vc4_hdmi_register ;struct vc4_hdmi_variant {
@@ -37,6 +40,13 @@ struct vc4_hdmi_variant {/* Callback to reset the HDMI block */ void (*reset)(struct vc4_hdmi *vc4_hdmi); + +/* Callback to initialize the PHY according to the mode */ +void (*phy_init)(struct vc4_hdmi *vc4_hdmi, +struct drm_display_mode *mode); + +/* Callback to disable the PHY */ +void (*phy_disable)(struct vc4_hdmi *vc4_hdmi); };/* HDMI audio information */
@@ -94,4 +104,8 @@ encoder_to_vc4_hdmi(struct drm_encoder *encoder) return container_of(_encoder, struct vc4_hdmi, encoder); } +void vc4_hdmi_phy_init (struct vc4_hdmi *vc4_hdmi, +struct drm_display_mode *mode); +void vc4_hdmi_phy_disable (struct vc4_hdmi *vc4_hdmi); +#endif /* _VC4_HDMI_H_ */
drivers/gpu/drm/vc4/vc4_hdmi_phy.c new file +25 -0
@@ -0,0 +1,25 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Copyright (C) 2015 Broadcom +* Copyright (c) 2014 The Linux Foundation. All rights reserved. +* Copyright (C) 2013 Red Hat +* Author: Rob Clark <[email protected]> +*/ + +#include "vc4_hdmi.h" +#include "vc4_hdmi_regs.h" + +void vc4_hdmi_phy_init (struct vc4_hdmi *vc4_hdmi,struct drm_display_mode *mode) +{ +/* PHY should be in reset, like +* vc4_hdmi_encoder_disable() does. +*/ + +HDMI_WRITE (HDMI_TX_PHY_RESET_CTL ,0xf <<16 ); +HDMI_WRITE (HDMI_TX_PHY_RESET_CTL ,0 ); +} + +void vc4_hdmi_phy_disable (struct vc4_hdmi *vc4_hdmi) +{ +HDMI_WRITE (HDMI_TX_PHY_RESET_CTL ,0xf <<16 ); +}
Signature · 1 line
git-series 0.9.1
PATCH 76/89 drm/vc4: hdmi: Add PHY RNG enable / disable function
In reply to Maxime RipardLet's continue the implementation of hooks for the parts that change in the BCM2711 SoC with the PHY RNG setup.
--- drivers/gpu/drm/vc4/vc4_hdmi.c | 15 +++++++++------ drivers/gpu/drm/vc4/vc4_hdmi.h | 8 ++++++++ drivers/gpu/drm/vc4/vc4_hdmi_phy.c | 15 +++++++++++++++ 3 files changed, 32 insertions(+), 6 deletions(-)
drivers/gpu/drm/vc4/vc4_hdmi.c +9 -6
@@ -752,9 +752,9 @@ static int vc4_hdmi_audio_trigger(struct snd_pcm_substream *substream, int cmd,switch (cmd) {case SNDRV_PCM_TRIGGER_START :vc4_hdmi_set_audio_infoframe (encoder); -HDMI_WRITE (HDMI_TX_PHY_CTL_0 , -HDMI_READ (HDMI_TX_PHY_CTL_0 ) & - ~VC4_HDMI_TX_PHY_RNG_PWRDN ); + +if (vc4_hdmi->variant->phy_rng_enable) + vc4_hdmi->variant->phy_rng_enable (vc4_hdmi); HDMI_WRITE(HDMI_MAI_CTL, VC4_SET_FIELD(vc4_hdmi->audio.channels,
@@ -766,9 +766,10 @@ static int vc4_hdmi_audio_trigger(struct snd_pcm_substream *substream, int cmd,VC4_HD_MAI_CTL_DLATE |VC4_HD_MAI_CTL_ERRORE | VC4_HD_MAI_CTL_ERRORF); -HDMI_WRITE (HDMI_TX_PHY_CTL_0 , -HDMI_READ (HDMI_TX_PHY_CTL_0 ) | -VC4_HDMI_TX_PHY_RNG_PWRDN ); + +if (vc4_hdmi->variant->phy_rng_disable) + vc4_hdmi->variant->phy_rng_disable (vc4_hdmi); +break ;default :break ;
@@ -1413,6 +1414,8 @@ struct vc4_hdmi_variant bcm2835_variant = { .reset = vc4_hdmi_reset, .phy_init = vc4_hdmi_phy_init, .phy_disable = vc4_hdmi_phy_disable, + .phy_rng_enable = vc4_hdmi_phy_rng_enable, + .phy_rng_disable = vc4_hdmi_phy_rng_disable, };static const struct of_device_id vc4_hdmi_dt_match[] = {
drivers/gpu/drm/vc4/vc4_hdmi.h +8 -0
@@ -47,6 +47,12 @@ struct vc4_hdmi_variant {/* Callback to disable the PHY */ void (*phy_disable)(struct vc4_hdmi *vc4_hdmi); + +/* Callback to enable the RNG in the PHY */ +void (*phy_rng_enable)(struct vc4_hdmi *vc4_hdmi); + +/* Callback to disable the RNG in the PHY */ +void (*phy_rng_disable)(struct vc4_hdmi *vc4_hdmi); };/* HDMI audio information */
@@ -107,5 +113,7 @@ encoder_to_vc4_hdmi(struct drm_encoder *encoder)void vc4_hdmi_phy_init (struct vc4_hdmi *vc4_hdmi,struct drm_display_mode *mode);void vc4_hdmi_phy_disable (struct vc4_hdmi *vc4_hdmi); +void vc4_hdmi_phy_rng_enable (struct vc4_hdmi *vc4_hdmi); +void vc4_hdmi_phy_rng_disable (struct vc4_hdmi *vc4_hdmi);#endif /* _VC4_HDMI_H_ */
drivers/gpu/drm/vc4/vc4_hdmi_phy.c +15 -0
@@ -7,6 +7,7 @@*/ #include "vc4_hdmi.h" +#include "vc4_regs.h" #include "vc4_hdmi_regs.h" void vc4_hdmi_phy_init (struct vc4_hdmi *vc4_hdmi,struct drm_display_mode *mode)
@@ -23,3 +24,17 @@ void vc4_hdmi_phy_disable(struct vc4_hdmi *vc4_hdmi) {HDMI_WRITE (HDMI_TX_PHY_RESET_CTL ,0xf <<16 ); } + +void vc4_hdmi_phy_rng_enable (struct vc4_hdmi *vc4_hdmi) +{ +HDMI_WRITE (HDMI_TX_PHY_CTL_0 , +HDMI_READ (HDMI_TX_PHY_CTL_0 ) & + ~VC4_HDMI_TX_PHY_RNG_PWRDN ); +} + +void vc4_hdmi_phy_rng_disable (struct vc4_hdmi *vc4_hdmi) +{ +HDMI_WRITE (HDMI_TX_PHY_CTL_0 , +HDMI_READ (HDMI_TX_PHY_CTL_0 ) | +VC4_HDMI_TX_PHY_RNG_PWRDN ); +}
Signature · 1 line
git-series 0.9.1
PATCH 77/89 drm/vc4: hdmi: Add a CSC setup callback
In reply to Maxime RipardSimilarly to the previous patches, the CSC setup is slightly different in the BCM2711 than in the previous generations. Let's add a callback for it.
--- drivers/gpu/drm/vc4/vc4_hdmi.c | 71 ++++++++++++++++++++--------------- drivers/gpu/drm/vc4/vc4_hdmi.h | 3 +- 2 files changed, 45 insertions(+), 29 deletions(-)
drivers/gpu/drm/vc4/vc4_hdmi.c +42 -29
@@ -336,6 +336,41 @@ static void vc4_hdmi_encoder_disable(struct drm_encoder *encoder)DRM_ERROR ("Failed to release power domain: %d\n" , ret); } +static void vc4_hdmi_csc_setup (struct vc4_hdmi *vc4_hdmi,bool enable) +{ +u32 csc_ctl; + + csc_ctl =VC4_SET_FIELD (VC4_HD_CSC_CTL_ORDER_BGR , +VC4_HD_CSC_CTL_ORDER ); + +if (enable) { +/* CEA VICs other than #1 requre limited range RGB +* output unless overridden by an AVI infoframe. +* Apply a colorspace conversion to squash 0-255 down +* to 16-235. The matrix here is: +* +* [ 0 0 0.8594 16] +* [ 0 0.8594 0 16] +* [ 0.8594 0 0 16] +* [ 0 0 0 1] +*/ + csc_ctl |=VC4_HD_CSC_CTL_ENABLE ; + csc_ctl |=VC4_HD_CSC_CTL_RGB2YCC ; + csc_ctl |=VC4_SET_FIELD (VC4_HD_CSC_CTL_MODE_CUSTOM , +VC4_HD_CSC_CTL_MODE ); + +HDMI_WRITE (HDMI_CSC_12_11 , (0x000 <<16 ) |0x000 ); +HDMI_WRITE (HDMI_CSC_14_13 , (0x100 <<16 ) |0x6e0 ); +HDMI_WRITE (HDMI_CSC_22_21 , (0x6e0 <<16 ) |0x000 ); +HDMI_WRITE (HDMI_CSC_24_23 , (0x100 <<16 ) |0x000 ); +HDMI_WRITE (HDMI_CSC_32_31 , (0x000 <<16 ) |0x6e0 ); +HDMI_WRITE (HDMI_CSC_34_33 , (0x100 <<16 ) |0x000 ); + } + +/* The RGB order applies even when CSC is disabled. */ +HDMI_WRITE (HDMI_CSC_CTL , csc_ctl); +} +static void vc4_hdmi_encoder_enable (struct drm_encoder *encoder) {struct drm_display_mode *mode = &encoder->crtc->state->adjusted_mode;
@@ -359,7 +394,6 @@ static void vc4_hdmi_encoder_enable(struct drm_encoder *encoder) mode->crtc_vsync_end - interlaced, VC4_HDMI_VERTB_VBP)); -u32 csc_ctl;int ret; ret =pm_runtime_get_sync (&vc4_hdmi->pdev->dev);
@@ -430,41 +464,19 @@ static void vc4_hdmi_encoder_enable(struct drm_encoder *encoder) (vsync_pos ?0 :VC4_HD_VID_CTL_VSYNC_LOW ) | (hsync_pos ? 0 : VC4_HD_VID_CTL_HSYNC_LOW)); - csc_ctl =VC4_SET_FIELD (VC4_HD_CSC_CTL_ORDER_BGR , -VC4_HD_CSC_CTL_ORDER ); -if (vc4_encoder->hdmi_monitor && -drm_default_rgb_quant_range (mode) == -HDMI_QUANTIZATION_RANGE_LIMITED ) { -/* CEA VICs other than #1 requre limited range RGB -* output unless overridden by an AVI infoframe. -* Apply a colorspace conversion to squash 0-255 down -* to 16-235. The matrix here is: -* -* [ 0 0 0.8594 16] -* [ 0 0.8594 0 16] -* [ 0.8594 0 0 16] -* [ 0 0 0 1] -*/ - csc_ctl |=VC4_HD_CSC_CTL_ENABLE ; - csc_ctl |=VC4_HD_CSC_CTL_RGB2YCC ; - csc_ctl |=VC4_SET_FIELD (VC4_HD_CSC_CTL_MODE_CUSTOM , -VC4_HD_CSC_CTL_MODE ); +drm_default_rgb_quant_range (mode) ==HDMI_QUANTIZATION_RANGE_LIMITED ) { +if (vc4_hdmi->variant->csc_setup) + vc4_hdmi->variant->csc_setup (vc4_hdmi, true); -HDMI_WRITE (HDMI_CSC_12_11 , (0x000 <<16 ) |0x000 ); -HDMI_WRITE (HDMI_CSC_14_13 , (0x100 <<16 ) |0x6e0 ); -HDMI_WRITE (HDMI_CSC_22_21 , (0x6e0 <<16 ) |0x000 ); -HDMI_WRITE (HDMI_CSC_24_23 , (0x100 <<16 ) |0x000 ); -HDMI_WRITE (HDMI_CSC_32_31 , (0x000 <<16 ) |0x6e0 ); -HDMI_WRITE (HDMI_CSC_34_33 , (0x100 <<16 ) |0x000 ); vc4_encoder->limited_rgb_range = true; }else { +if (vc4_hdmi->variant->csc_setup) + vc4_hdmi->variant->csc_setup (vc4_hdmi, false); + vc4_encoder->limited_rgb_range = false; } -/* The RGB order applies even when CSC is disabled. */ -HDMI_WRITE (HDMI_CSC_CTL , csc_ctl); -HDMI_WRITE (HDMI_FIFO_CTL ,VC4_HDMI_FIFO_CTL_MASTER_SLAVE_N );if (debug_dump_regs) {
@@ -1411,6 +1423,7 @@ struct vc4_hdmi_variant bcm2835_variant = { .num_registers = ARRAY_SIZE(vc4_hdmi_fields), .init_resources = vc4_hdmi_init_resources, + .csc_setup = vc4_hdmi_csc_setup, .reset = vc4_hdmi_reset, .phy_init = vc4_hdmi_phy_init, .phy_disable = vc4_hdmi_phy_disable,
drivers/gpu/drm/vc4/vc4_hdmi.h +3 -0
@@ -41,6 +41,9 @@ struct vc4_hdmi_variant {/* Callback to reset the HDMI block */ void (*reset)(struct vc4_hdmi *vc4_hdmi); +/* Callback to enable / disable the CSC */ +void (*csc_setup)(struct vc4_hdmi *vc4_hdmi,bool enable); +/* Callback to initialize the PHY according to the mode */ void (*phy_init)(struct vc4_hdmi *vc4_hdmi,struct drm_display_mode *mode);
Signature · 1 line
git-series 0.9.1
PATCH 78/89 drm/vc4: hdmi: Add a set_timings callback
In reply to Maxime RipardSimilarly to the previous patches, the timings setup in the HDMI controller of the BCM2711 is slightly different, mostly because it supports higher resolutions and thus needed more spaces for the various timings, resulting in the register layout changing.
Let's add a callback for that as well.
--- drivers/gpu/drm/vc4/vc4_hdmi.c | 71 +++++++++++++++++++---------------- drivers/gpu/drm/vc4/vc4_hdmi.h | 4 ++- 2 files changed, 44 insertions(+), 31 deletions(-)
drivers/gpu/drm/vc4/vc4_hdmi.c +40 -31
@@ -371,12 +371,9 @@ static void vc4_hdmi_csc_setup(struct vc4_hdmi *vc4_hdmi, bool enable)HDMI_WRITE (HDMI_CSC_CTL , csc_ctl); } -static void vc4_hdmi_encoder_enable (struct drm_encoder *encoder) +static void vc4_hdmi_set_timings (struct vc4_hdmi *vc4_hdmi, +struct drm_display_mode *mode) { -struct drm_display_mode *mode = &encoder->crtc->state->adjusted_mode; -struct vc4_hdmi *vc4_hdmi =encoder_to_vc4_hdmi (encoder); -struct vc4_hdmi_encoder *vc4_encoder = &vc4_hdmi->encoder; -bool debug_dump_regs = false;bool hsync_pos = mode->flags &DRM_MODE_FLAG_PHSYNC ;bool vsync_pos = mode->flags &DRM_MODE_FLAG_PVSYNC ;bool interlaced = mode->flags &DRM_MODE_FLAG_INTERLACE ;
@@ -394,6 +391,41 @@ static void vc4_hdmi_encoder_enable(struct drm_encoder *encoder) mode->crtc_vsync_end - interlaced, VC4_HDMI_VERTB_VBP)); + +HDMI_WRITE (HDMI_HORZA , + (vsync_pos ?VC4_HDMI_HORZA_VPOS :0 ) | + (hsync_pos ?VC4_HDMI_HORZA_HPOS :0 ) | +VC4_SET_FIELD (mode->hdisplay * pixel_rep, +VC4_HDMI_HORZA_HAP )); + +HDMI_WRITE (HDMI_HORZB , +VC4_SET_FIELD ((mode->htotal - + mode->hsync_end) * pixel_rep, +VC4_HDMI_HORZB_HBP ) | +VC4_SET_FIELD ((mode->hsync_end - + mode->hsync_start) * pixel_rep, +VC4_HDMI_HORZB_HSP ) | +VC4_SET_FIELD ((mode->hsync_start - + mode->hdisplay) * pixel_rep, +VC4_HDMI_HORZB_HFP )); + +HDMI_WRITE (HDMI_VERTA0 , verta); +HDMI_WRITE (HDMI_VERTA1 , verta); + +HDMI_WRITE (HDMI_VERTB0 , vertb_even); +HDMI_WRITE (HDMI_VERTB1 , vertb); + +HDMI_WRITE (HDMI_VID_CTL , + (vsync_pos ?0 :VC4_HD_VID_CTL_VSYNC_LOW ) | + (hsync_pos ?0 :VC4_HD_VID_CTL_HSYNC_LOW )); +} + +static void vc4_hdmi_encoder_enable (struct drm_encoder *encoder) +{ +struct drm_display_mode *mode = &encoder->crtc->state->adjusted_mode; +struct vc4_hdmi *vc4_hdmi =encoder_to_vc4_hdmi (encoder); +struct vc4_hdmi_encoder *vc4_encoder =to_vc4_hdmi_encoder (encoder); +bool debug_dump_regs = false;int ret; ret =pm_runtime_get_sync (&vc4_hdmi->pdev->dev);
@@ -437,32 +469,8 @@ static void vc4_hdmi_encoder_enable(struct drm_encoder *encoder)VC4_HDMI_SCHEDULER_CONTROL_MANUAL_FORMAT | VC4_HDMI_SCHEDULER_CONTROL_IGNORE_VSYNC_PREDICTS); -HDMI_WRITE (HDMI_HORZA , - (vsync_pos ?VC4_HDMI_HORZA_VPOS :0 ) | - (hsync_pos ?VC4_HDMI_HORZA_HPOS :0 ) | -VC4_SET_FIELD (mode->hdisplay * pixel_rep, -VC4_HDMI_HORZA_HAP )); - -HDMI_WRITE (HDMI_HORZB , -VC4_SET_FIELD ((mode->htotal - - mode->hsync_end) * pixel_rep, -VC4_HDMI_HORZB_HBP ) | -VC4_SET_FIELD ((mode->hsync_end - - mode->hsync_start) * pixel_rep, -VC4_HDMI_HORZB_HSP ) | -VC4_SET_FIELD ((mode->hsync_start - - mode->hdisplay) * pixel_rep, -VC4_HDMI_HORZB_HFP )); - -HDMI_WRITE (HDMI_VERTA0 , verta); -HDMI_WRITE (HDMI_VERTA1 , verta); - -HDMI_WRITE (HDMI_VERTB0 , vertb_even); -HDMI_WRITE (HDMI_VERTB1 , vertb); - -HDMI_WRITE (HDMI_VID_CTL , - (vsync_pos ?0 :VC4_HD_VID_CTL_VSYNC_LOW ) | - (hsync_pos ?0 :VC4_HD_VID_CTL_HSYNC_LOW )); +if (vc4_hdmi->variant->set_timings) + vc4_hdmi->variant->set_timings (vc4_hdmi, mode);if (vc4_encoder->hdmi_monitor &&drm_default_rgb_quant_range (mode) ==HDMI_QUANTIZATION_RANGE_LIMITED ) {
@@ -1425,6 +1433,7 @@ struct vc4_hdmi_variant bcm2835_variant = { .init_resources = vc4_hdmi_init_resources, .csc_setup = vc4_hdmi_csc_setup, .reset = vc4_hdmi_reset, + .set_timings = vc4_hdmi_set_timings, .phy_init = vc4_hdmi_phy_init, .phy_disable = vc4_hdmi_phy_disable, .phy_rng_enable = vc4_hdmi_phy_rng_enable,
drivers/gpu/drm/vc4/vc4_hdmi.h +4 -0
@@ -44,6 +44,10 @@ struct vc4_hdmi_variant {/* Callback to enable / disable the CSC */ void (*csc_setup)(struct vc4_hdmi *vc4_hdmi,bool enable); +/* Callback to configure the video timings in the HDMI block */ +void (*set_timings)(struct vc4_hdmi *vc4_hdmi, +struct drm_display_mode *mode); +/* Callback to initialize the PHY according to the mode */ void (*phy_init)(struct vc4_hdmi *vc4_hdmi,struct drm_display_mode *mode);
Signature · 1 line
git-series 0.9.1
PATCH 79/89 drm/vc4: hdmi: Add HDMI ID
In reply to Maxime RipardSome operations will need us to have the raw ID of the HDMI controller in the BCM2711, such as the encoder type to register, the name of the debugfs files, etc.
Let's add it to our variant structure.
--- drivers/gpu/drm/vc4/vc4_hdmi.c | 3 +-- drivers/gpu/drm/vc4/vc4_hdmi.h | 5 +++++ 2 files changed, 6 insertions(+), 2 deletions(-)
drivers/gpu/drm/vc4/vc4_hdmi.c +1 -2
@@ -1252,11 +1252,10 @@ static int vc4_hdmi_bind(struct device *dev, struct device *master, void *data) vc4_hdmi =devm_kzalloc (dev,sizeof (*vc4_hdmi),GFP_KERNEL );if (!vc4_hdmi)return -ENOMEM ; - vc4_hdmi->pdev = pdev; variant =of_device_get_match_data (dev); vc4_hdmi->variant = variant; - vc4_hdmi->encoder.base.type =VC4_ENCODER_TYPE_HDMI0 ; + vc4_hdmi->encoder.base.type = variant->id ?VC4_ENCODER_TYPE_HDMI1 :VC4_ENCODER_TYPE_HDMI0 ; encoder = &vc4_hdmi->encoder.base.base; ret = variant->init_resources (vc4_hdmi);
drivers/gpu/drm/vc4/vc4_hdmi.h +5 -0
@@ -27,6 +27,11 @@ struct vc4_hdmi;struct vc4_hdmi_register ;struct vc4_hdmi_variant { +/* On devices that have multiple, different instances (like +* the BCM2711), which instance is that variant useful for. +*/ +unsigned int id; +/* List of the registers available on that variant */ const struct vc4_hdmi_register *registers;
Signature · 1 line
git-series 0.9.1
PATCH 80/89 drm/vc4: hdmi: Deal with multiple debugfs files
In reply to Maxime RipardThe HDMI driver was registering a single debugfs file so far with the name hdmi_regs.
Obviously, this is not going to work anymore when will have multiple HDMI controllers since we will end up trying to register two files with the same name.
Let's use the ID to avoid that name conflict.
--- drivers/gpu/drm/vc4/vc4_hdmi.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/vc4/vc4_hdmi.c +4 -1
@@ -1365,7 +1365,10 @@ static int vc4_hdmi_bind(struct device *dev, struct device *master, void *data)if (ret) goto err_destroy_encoder; -vc4_debugfs_add_file (drm,"hdmi_regs" , vc4_hdmi_debugfs_regs, vc4_hdmi); +vc4_debugfs_add_file (drm, + variant->id ?"hdmi1_regs" :"hdmi_regs" , + vc4_hdmi_debugfs_regs, + vc4_hdmi);return 0 ;
Signature · 1 line
git-series 0.9.1
PATCH 81/89 drm/vc4: hdmi: Add an audio support flag
In reply to Maxime RipardThe BCM2711 audio support doesn't work yet, so let's add a boolean to indicate whether or not it's supported, and only register a sound card if that boolean is set.
--- drivers/gpu/drm/vc4/vc4_hdmi.c | 4 ++++ drivers/gpu/drm/vc4/vc4_hdmi.h | 3 +++ 2 files changed, 7 insertions(+)
drivers/gpu/drm/vc4/vc4_hdmi.c +4 -0
@@ -930,6 +930,9 @@ static int vc4_hdmi_audio_init(struct vc4_hdmi *vc4_hdmi)const __be32 *addr;int ret; +if (!vc4_hdmi->variant->audio_available) +return 0 ; +if (!of_find_property (dev->of_node,"dmas" ,NULL )) {dev_warn (dev,"'dmas' DT property is missing, no HDMI audio\n" );
@@ -1429,6 +1432,7 @@ static int vc4_hdmi_dev_remove(struct platform_device *pdev) }struct vc4_hdmi_variant bcm2835_variant = { + .audio_available = true, .registers = vc4_hdmi_fields, .num_registers =ARRAY_SIZE (vc4_hdmi_fields),
drivers/gpu/drm/vc4/vc4_hdmi.h +3 -0
@@ -32,6 +32,9 @@ struct vc4_hdmi_variant {*/ unsigned int id; +/* Set to true when the audio support is available */ +bool audio_available; +/* List of the registers available on that variant */ const struct vc4_hdmi_register *registers;
Signature · 1 line
git-series 0.9.1
PATCH 82/89 drm/vc4: hdmi: Move CEC init to its own function
In reply to Maxime RipardThe CEC init code was put directly into the bind function, which was quite inconsistent with how the audio support was done, and would prevent us from further changes to skip that initialisation entirely.
--- drivers/gpu/drm/vc4/vc4_hdmi.c | 102 +++++++++++++++++++++------------- 1 file changed, 64 insertions(+), 38 deletions(-)
drivers/gpu/drm/vc4/vc4_hdmi.c +64 -38
@@ -1163,6 +1163,64 @@ static const struct cec_adap_ops vc4_hdmi_cec_adap_ops = { .adap_log_addr = vc4_hdmi_cec_adap_log_addr, .adap_transmit = vc4_hdmi_cec_adap_transmit, }; + +static int vc4_hdmi_cec_init (struct vc4_hdmi *vc4_hdmi) +{ +int ret; + + vc4_hdmi->cec_adap =cec_allocate_adapter (&vc4_hdmi_cec_adap_ops, + vc4,"vc4" , +CEC_CAP_DEFAULTS | +CEC_CAP_CONNECTOR_INFO ,1 ); + ret =PTR_ERR_OR_ZERO (vc4_hdmi->cec_adap); +if (ret <0 ) +return ret; + +cec_fill_conn_info_from_drm (&conn_info, hdmi->connector); +cec_s_conn_info (hdmi->cec_adap, &conn_info); + +HDMI_WRITE (HDMI_CPU_MASK_SET ,0xffffffff ); + value =HDMI_READ (HDMI_CEC_CNTRL_1 ); + value &= ~VC4_HDMI_CEC_DIV_CLK_CNT_MASK ; +/* +* Set the logical address to Unregistered and set the clock +* divider: the hsm_clock rate and this divider setting will +* give a 40 kHz CEC clock. +*/ + value |=VC4_HDMI_CEC_ADDR_MASK | + (4091 <<VC4_HDMI_CEC_DIV_CLK_CNT_SHIFT ); +HDMI_WRITE (HDMI_CEC_CNTRL_1 , value); + ret =devm_request_threaded_irq (dev,platform_get_irq (pdev,0 ), + vc4_cec_irq_handler, + vc4_cec_irq_handler_thread,0 , +"vc4 hdmi cec" , vc4_hdmi); +if (ret) + goto err_delete_cec_adap; + + ret =cec_register_adapter (vc4_hdmi->cec_adap, vc4_hdmi); +if (ret <0 ) + goto err_delete_cec_adap; + +return 0 ; + +err_delete_cec_adap: +cec_delete_adapter (vc4_hdmi->cec_adap); + +return ret; +} + +static void vc4_hdmi_cec_exit (struct vc4_hdmi *vc4_hdmi) +{ +cec_unregister_adapter (vc4_hdmi->cec_adap); +} +#else +static int vc4_hdmi_cec_init (struct vc4_hdmi *vc4_hdmi) +{ +return 0 ; +} + +static void vc4_hdmi_cec_exit (struct vc4_hdmi *vc4_hdmi) {}; +#endif static int vc4_hdmi_build_regset(struct vc4_hdmi *vc4_hdmi,
@@ -1330,43 +1388,13 @@ static int vc4_hdmi_bind(struct device *dev, struct device *master, void *data)if (ret) goto err_destroy_encoder; -#ifdef CONFIG_DRM_VC4_HDMI_CEC - vc4_hdmi->cec_adap =cec_allocate_adapter (&vc4_hdmi_cec_adap_ops, - vc4,"vc4" , -CEC_CAP_DEFAULTS | -CEC_CAP_CONNECTOR_INFO ,1 ); - ret =PTR_ERR_OR_ZERO (vc4_hdmi->cec_adap); -if (ret <0 ) - goto err_destroy_conn; - -cec_fill_conn_info_from_drm (&conn_info, hdmi->connector); -cec_s_conn_info (hdmi->cec_adap, &conn_info); - -HDMI_WRITE (HDMI_CPU_MASK_SET ,0xffffffff ); - value =HDMI_READ (HDMI_CEC_CNTRL_1 ); - value &= ~VC4_HDMI_CEC_DIV_CLK_CNT_MASK ; -/* -* Set the logical address to Unregistered and set the clock -* divider: the hsm_clock rate and this divider setting will -* give a 40 kHz CEC clock. -*/ - value |=VC4_HDMI_CEC_ADDR_MASK | - (4091 <<VC4_HDMI_CEC_DIV_CLK_CNT_SHIFT ); -HDMI_WRITE (HDMI_CEC_CNTRL_1 , value); - ret =devm_request_threaded_irq (dev,platform_get_irq (pdev,0 ), - vc4_cec_irq_handler, - vc4_cec_irq_handler_thread,0 , -"vc4 hdmi cec" , vc4_hdmi); + ret =vc4_hdmi_cec_init (vc4_hdmi);if (ret) - goto err_delete_cec_adap; - ret =cec_register_adapter (vc4_hdmi->cec_adap, vc4_hdmi); -if (ret <0 ) - goto err_delete_cec_adap; -#endif + goto err_destroy_conn; ret =vc4_hdmi_audio_init (vc4_hdmi);if (ret) - goto err_destroy_encoder; + goto err_free_cec; vc4_debugfs_add_file(drm, variant->id ? "hdmi1_regs" : "hdmi_regs",
@@ -1375,12 +1403,10 @@ static int vc4_hdmi_bind(struct device *dev, struct device *master, void *data)return 0 ; -#ifdef CONFIG_DRM_VC4_HDMI_CEC -err_delete_cec_adap: -cec_delete_adapter (vc4_hdmi->cec_adap); +err_free_cec: +vc4_hdmi_cec_exit (vc4_hdmi); err_destroy_conn:vc4_hdmi_connector_destroy (&vc4_hdmi->connector); -#endif err_destroy_encoder:vc4_hdmi_encoder_destroy (encoder); err_unprepare_hsm:
@@ -1405,7 +1431,7 @@ static void vc4_hdmi_unbind(struct device *dev, struct device *master,kfree (vc4_hdmi->hdmi_regset.regs);kfree (vc4_hdmi->hd_regset.regs); -cec_unregister_adapter (vc4_hdmi->cec_adap); +vc4_hdmi_cec_exit (vc4_hdmi);vc4_hdmi_connector_destroy (&vc4_hdmi->connector);vc4_hdmi_encoder_destroy (&vc4_hdmi->encoder.base.base);
Signature · 1 line
git-series 0.9.1
kbuild test robot
build botRe: [PATCH 82/89] drm/vc4: hdmi: Move CEC init to its own function
I love your patch! Yet something to improve:
Hi Maxime,
I love your patch! Yet something to improve:
[auto build test ERROR on clk/clk-next]
[also build test ERROR on robh/for-next v5.6-rc3 next-20200224] [cannot apply to anholt/for-next]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Maxime-Ripard/drm-vc4-Support-BCM2711-Display-Pipeline/20200224-172730 base: https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git clk-next config: i386-allyesconfig (attached as .config) compiler: gcc-7 (Debian 7.5.0-5) 7.5.0 reproduce: # save the attached .config to linux build tree make ARCH=i386
If you fix the issue, kindly add following tag
All errors (new ones prefixed by >>):
drivers/gpu/drm/vc4/vc4_hdmi.c: In function 'vc4_cec_read_msg':
drivers/gpu/drm/vc4/vc4_hdmi.c:1041:30: error: 'struct vc4_dev' has no member named 'hdmi'; did you mean 'dpi'?
struct cec_msg *msg = &vc4->hdmi->cec_rx_msg;
^~~~
dpi
In file included from drivers/gpu/drm/vc4/vc4_hdmi.c:52:0:
drivers/gpu/drm/vc4/vc4_hdmi_regs.h:219:39: error: 'vc4_hdmi' undeclared (first use in this function)
#define HDMI_READ(reg) vc4_hdmi_read(vc4_hdmi, reg)
^
drivers/gpu/drm/vc4/vc4_hdmi.c:1047:13: note: in expansion of macro 'HDMI_READ'
u32 val = HDMI_READ(HDMI_CEC_RX_DATA_1 + i);
^~~~~~~~~
drivers/gpu/drm/vc4/vc4_hdmi_regs.h:219:39: note: each undeclared identifier is reported only once for each function it appears in
#define HDMI_READ(reg) vc4_hdmi_read(vc4_hdmi, reg)
^
drivers/gpu/drm/vc4/vc4_hdmi.c:1047:13: note: in expansion of macro 'HDMI_READ'
u32 val = HDMI_READ(HDMI_CEC_RX_DATA_1 + i);
^~~~~~~~~
drivers/gpu/drm/vc4/vc4_hdmi.c: In function 'vc4_cec_irq_handler':
drivers/gpu/drm/vc4/vc4_hdmi.c:1059:23: error: 'HDMI_CPU_STATUS' undeclared (first use in this function); did you mean 'HDMI_CEC_CPU_STATUS'?
u32 stat = HDMI_READ(HDMI_CPU_STATUS);
^
drivers/gpu/drm/vc4/vc4_hdmi_regs.h:219:49: note: in definition of macro 'HDMI_READ'
#define HDMI_READ(reg) vc4_hdmi_read(vc4_hdmi, reg)
^~~
drivers/gpu/drm/vc4/vc4_hdmi.c:1069:20: error: 'vc4' undeclared (first use in this function)
vc4_cec_read_msg(vc4, cntrl1);
^~~
In file included from drivers/gpu/drm/vc4/vc4_hdmi.c:52:0:
drivers/gpu/drm/vc4/vc4_hdmi.c:1078:13: error: 'HDMI_CPU_CLEAR' undeclared (first use in this function); did you mean 'HDMI_CPU_STATUS'?
HDMI_WRITE(HDMI_CPU_CLEAR, VC4_HDMI_CPU_CEC);
^
drivers/gpu/drm/vc4/vc4_hdmi_regs.h:242:55: note: in definition of macro 'HDMI_WRITE'
#define HDMI_WRITE(reg, val) vc4_hdmi_write(vc4_hdmi, reg, val)
^~~
drivers/gpu/drm/vc4/vc4_hdmi.c: In function 'vc4_hdmi_cec_adap_enable':
drivers/gpu/drm/vc4/vc4_hdmi.c:1117:14: error: 'HDMI_CPU_MASK_CLEAR' undeclared (first use in this function); did you mean 'CPU_MASK_ALL'?
HDMI_WRITE(HDMI_CPU_MASK_CLEAR, VC4_HDMI_CPU_CEC);
^
drivers/gpu/drm/vc4/vc4_hdmi_regs.h:242:55: note: in definition of macro 'HDMI_WRITE'
#define HDMI_WRITE(reg, val) vc4_hdmi_write(vc4_hdmi, reg, val)
^~~
drivers/gpu/drm/vc4/vc4_hdmi.c:1119:14: error: 'HDMI_CPU_MASK_SET' undeclared (first use in this function); did you mean 'HDMI_CPU_MASK_CLEAR'?
HDMI_WRITE(HDMI_CPU_MASK_SET, VC4_HDMI_CPU_CEC);
^
drivers/gpu/drm/vc4/vc4_hdmi_regs.h:242:55: note: in definition of macro 'HDMI_WRITE'
#define HDMI_WRITE(reg, val) vc4_hdmi_write(vc4_hdmi, reg, val)
^~~
drivers/gpu/drm/vc4/vc4_hdmi.c: In function 'vc4_hdmi_cec_init':
drivers/gpu/drm/vc4/vc4_hdmi.c:1172:12: error: 'vc4' undeclared (first use in this function)
vc4, "vc4",
^~~
>> drivers/gpu/drm/vc4/vc4_hdmi.c:1179:31: error: 'conn_info' undeclared (first use in this function); did you mean 'cpu_info'?
cec_fill_conn_info_from_drm(&conn_info, hdmi->connector);
^~~~~~~~~
cpu_info
drivers/gpu/drm/vc4/vc4_hdmi.c:1179:42: error: 'hdmi' undeclared (first use in this function)
cec_fill_conn_info_from_drm(&conn_info, hdmi->connector);
^~~~
In file included from drivers/gpu/drm/vc4/vc4_hdmi.c:52:0:
drivers/gpu/drm/vc4/vc4_hdmi.c:1182:13: error: 'HDMI_CPU_MASK_SET' undeclared (first use in this function); did you mean 'HDMI_MAI_SMP'?
HDMI_WRITE(HDMI_CPU_MASK_SET, 0xffffffff);
^
drivers/gpu/drm/vc4/vc4_hdmi_regs.h:242:55: note: in definition of macro 'HDMI_WRITE'
#define HDMI_WRITE(reg, val) vc4_hdmi_write(vc4_hdmi, reg, val)
^~~
drivers/gpu/drm/vc4/vc4_hdmi.c:1183:2: error: 'value' undeclared (first use in this function); did you mean 'false'?
value = HDMI_READ(HDMI_CEC_CNTRL_1);
^~~~~
false
drivers/gpu/drm/vc4/vc4_hdmi.c:1193:34: error: 'dev' undeclared (first use in this function); did you mean 'cdev'?
ret = devm_request_threaded_irq(dev, platform_get_irq(pdev, 0),
^~~
cdev
drivers/gpu/drm/vc4/vc4_hdmi.c:1193:56: error: 'pdev' undeclared (first use in this function); did you mean 'dev'?
ret = devm_request_threaded_irq(dev, platform_get_irq(pdev, 0),
^~~~
dev
drivers/gpu/drm/vc4/vc4_hdmi.c:1200:49: error: passing argument 2 of 'cec_register_adapter' from incompatible pointer type [-Werror=incompatible-pointer-types]
ret = cec_register_adapter(vc4_hdmi->cec_adap, vc4_hdmi);
^~~~~~~~
In file included from drivers/gpu/drm/vc4/vc4_hdmi.c:49:0:
include/media/cec.h:242:5: note: expected 'struct device *' but argument is of type 'struct vc4_hdmi *'
int cec_register_adapter(struct cec_adapter *adap, struct device *parent);
^~~~~~~~~~~~~~~~~~~~
drivers/gpu/drm/vc4/vc4_hdmi.c: In function 'vc4_hdmi_bind':
drivers/gpu/drm/vc4/vc4_hdmi.c:1302:28: warning: unused variable 'conn_info' [-Wunused-variable]
struct cec_connector_info conn_info;
^~~~~~~~~cc1: some warnings being treated as errors
vim +1179 drivers/gpu/drm/vc4/vc4_hdmi.c
1166
1167 static int vc4_hdmi_cec_init(struct vc4_hdmi *vc4_hdmi)
1168 {
1169 int ret;
1170
1171 vc4_hdmi->cec_adap = cec_allocate_adapter(&vc4_hdmi_cec_adap_ops,
1172 vc4, "vc4", 1173 CEC_CAP_DEFAULTS | 1174 CEC_CAP_CONNECTOR_INFO, 1); 1175 ret = PTR_ERR_OR_ZERO(vc4_hdmi->cec_adap); 1176 if (ret < 0) 1177 return ret; 1178 > 1179 cec_fill_conn_info_from_drm(&conn_info, hdmi->connector);
1180 cec_s_conn_info(hdmi->cec_adap, &conn_info);
1181
1182 HDMI_WRITE(HDMI_CPU_MASK_SET, 0xffffffff);
1183 value = HDMI_READ(HDMI_CEC_CNTRL_1);
1184 value &= ~VC4_HDMI_CEC_DIV_CLK_CNT_MASK;
1185 /*
1186 * Set the logical address to Unregistered and set the clock
1187 * divider: the hsm_clock rate and this divider setting will
1188 * give a 40 kHz CEC clock.
1189 */
1190 value |= VC4_HDMI_CEC_ADDR_MASK |
1191 (4091 << VC4_HDMI_CEC_DIV_CLK_CNT_SHIFT);
1192 HDMI_WRITE(HDMI_CEC_CNTRL_1, value);
1193 ret = devm_request_threaded_irq(dev, platform_get_irq(pdev, 0),
1194 vc4_cec_irq_handler,
1195 vc4_cec_irq_handler_thread, 0,
1196 "vc4 hdmi cec", vc4_hdmi);
1197 if (ret)
1198 goto err_delete_cec_adap;
1199
1200 ret = cec_register_adapter(vc4_hdmi->cec_adap, vc4_hdmi);
1201 if (ret < 0)
1202 goto err_delete_cec_adap;
1203
1204 return 0;
1205
1206 err_delete_cec_adap:
1207 cec_delete_adapter(vc4_hdmi->cec_adap);
1208
1209 return ret;
1210 }
1211
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
PATCH 83/89 drm/vc4: hdmi: Add CEC support flag
In reply to Maxime RipardSimilarly to the audio support, CEC support is not there yet for the BCM2711, so let's skip entirely the CEC initialization through a variant flag.
--- drivers/gpu/drm/vc4/vc4_hdmi.c | 4 ++++ drivers/gpu/drm/vc4/vc4_hdmi.h | 3 +++ 2 files changed, 7 insertions(+)
drivers/gpu/drm/vc4/vc4_hdmi.c +4 -0
@@ -1168,6 +1168,9 @@ static int vc4_hdmi_cec_init(struct vc4_hdmi *vc4_hdmi) {int ret; +if (!vc4_hdmi->variant->cec_available) +return 0 ; + vc4_hdmi->cec_adap = cec_allocate_adapter(&vc4_hdmi_cec_adap_ops, vc4, "vc4", CEC_CAP_DEFAULTS |
@@ -1459,6 +1462,7 @@ static int vc4_hdmi_dev_remove(struct platform_device *pdev)struct vc4_hdmi_variant bcm2835_variant = { .audio_available = true, + .cec_available = true, .registers = vc4_hdmi_fields, .num_registers =ARRAY_SIZE (vc4_hdmi_fields),
drivers/gpu/drm/vc4/vc4_hdmi.h +3 -0
@@ -35,6 +35,9 @@ struct vc4_hdmi_variant {/* Set to true when the audio support is available */ bool audio_available; +/* Set to true when the CEC support is available */ +bool cec_available; +/* List of the registers available on that variant */ const struct vc4_hdmi_register *registers;
Signature · 1 line
git-series 0.9.1
PATCH 84/89 drm/vc4: hdmi: Remove unused CEC_CLOCK_DIV define
In reply to Maxime RipardThe CEC_CLOCK_DIV define is not used anywhere in the driver, let's remove it.
--- drivers/gpu/drm/vc4/vc4_hdmi.c | 1 - 1 file changed, 1 deletion(-)
drivers/gpu/drm/vc4/vc4_hdmi.c +0 -1
@@ -54,7 +54,6 @@#define HSM_CLOCK_FREQ 163682864#define CEC_CLOCK_FREQ 40000 -#define CEC_CLOCK_DIV (HSM_CLOCK_FREQ / CEC_CLOCK_FREQ)static int vc4_hdmi_debugfs_regs (struct seq_file *m,void *unused) {
Signature · 1 line
git-series 0.9.1
PATCH 85/89 drm/vc4: hdmi: Rename drm_encoder pointer in mode_valid
In reply to Maxime RipardThe mode_valid hook on the encoder uses a pointer to a drm_encoder called crtc, which is pretty confusing. Let's rename it to encoder to make it clear what it is.
--- drivers/gpu/drm/vc4/vc4_hdmi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/vc4/vc4_hdmi.c +1 -1
@@ -558,7 +558,7 @@ static void vc4_hdmi_encoder_enable(struct drm_encoder *encoder) }static enum drm_mode_status -vc4_hdmi_encoder_mode_valid (struct drm_encoder *crtc, +vc4_hdmi_encoder_mode_valid (struct drm_encoder *encoder,const struct drm_display_mode *mode) {/* HSM clock must be 108% of the pixel clock. Additionally,
Signature · 1 line
git-series 0.9.1
PATCH 86/89 drm/vc4: hdmi: Adjust HSM clock rate depending on pixel rate
In reply to Maxime RipardThe HSM clock needs to be setup at around 110% of the pixel rate. This was done previously by setting the clock rate to 148.5MHz * 108% at probe time and only check in mode_valid whether the mode pixel clock was under 148.5MHz or not.
However, with 4k we need to change that frequency to a higher frequency than 148.5MHz.
Let's change that logic a bit by setting the clock rate of the HSM clock to the pixel rate at encoder_enable time. This would work for the BCM2711 that support 4k resolutions and has a clock that can provide it, but we still have to take care of a 4k panel plugged on a BCM283x SoCs that wouldn't be able to use those modes, so let's define the limit in the variant.
--- drivers/gpu/drm/vc4/vc4_hdmi.c | 55 ++++++++++++++++------------------- drivers/gpu/drm/vc4/vc4_hdmi.h | 3 ++- 2 files changed, 29 insertions(+), 29 deletions(-)
drivers/gpu/drm/vc4/vc4_hdmi.c +26 -29
@@ -52,7 +52,6 @@#include "vc4_hdmi_regs.h" #include "vc4_regs.h" -#define HSM_CLOCK_FREQ 163682864#define CEC_CLOCK_FREQ 40000static int vc4_hdmi_debugfs_regs (struct seq_file *m,void *unused)
@@ -328,6 +327,7 @@ static void vc4_hdmi_encoder_disable(struct drm_encoder *encoder)HDMI_WRITE (HDMI_VID_CTL ,HDMI_READ (HDMI_VID_CTL ) & ~VC4_HD_VID_CTL_ENABLE ); +clk_disable_unprepare (vc4_hdmi->hsm_clock);clk_disable_unprepare (vc4_hdmi->pixel_clock); ret =pm_runtime_put (&vc4_hdmi->pdev->dev);
@@ -425,6 +425,7 @@ static void vc4_hdmi_encoder_enable(struct drm_encoder *encoder)struct vc4_hdmi *vc4_hdmi =encoder_to_vc4_hdmi (encoder);struct vc4_hdmi_encoder *vc4_encoder =to_vc4_hdmi_encoder (encoder);bool debug_dump_regs = false; +unsigned long pixel_rate, hsm_rate;int ret; ret =pm_runtime_get_sync (&vc4_hdmi->pdev->dev);
@@ -433,9 +434,8 @@ static void vc4_hdmi_encoder_enable(struct drm_encoder *encoder)return ; } - ret =clk_set_rate (vc4_hdmi->pixel_clock, - mode->clock *1000 * - ((mode->flags &DRM_MODE_FLAG_DBLCLK ) ?2 :1 )); + pixel_rate = mode->clock *1000 * ((mode->flags &DRM_MODE_FLAG_DBLCLK ) ?2 :1 ); + ret =clk_set_rate (vc4_hdmi->pixel_clock, pixel_rate);if (ret) {DRM_ERROR ("Failed to set pixel clock rate: %d\n" , ret);return ;
@@ -447,6 +447,24 @@ static void vc4_hdmi_encoder_enable(struct drm_encoder *encoder)return ; } +/* +* The HSM rate needs to be at 108% of the pixel clock, with a +* minimum of 108MHz. +*/ + hsm_rate = max_t(unsigned long, 108000000, (pixel_rate / 100) * 108); + ret =clk_set_rate (vc4_hdmi->hsm_clock, hsm_rate); +if (ret) { +DRM_ERROR ("Failed to set HSM clock rate: %d\n" , ret); +return ; + } + + ret =clk_prepare_enable (vc4_hdmi->hsm_clock); +if (ret) { +DRM_ERROR ("Failed to turn on HSM clock: %d\n" , ret); +clk_disable_unprepare (vc4_hdmi->pixel_clock); +return ; + } +if (vc4_hdmi->variant->reset) vc4_hdmi->variant->reset (vc4_hdmi);
@@ -561,11 +579,9 @@ static enum drm_mode_status vc4_hdmi_encoder_mode_valid(struct drm_encoder *encoder, const struct drm_display_mode *mode) { -/* HSM clock must be 108% of the pixel clock. Additionally, -* the AXI clock needs to be at least 25% of pixel clock, but -* HSM ends up being the limiting factor. -*/ -if (mode->clock >HSM_CLOCK_FREQ / (1000 *108 /100 )) + struct vc4_hdmi *vc4_hdmi = encoder_to_vc4_hdmi(encoder); + +if ((mode->clock *1000 ) > vc4_hdmi->variant->max_pixel_clock)return MODE_CLOCK_HIGH ;return MODE_OK ;
@@ -1338,23 +1354,6 @@ static int vc4_hdmi_bind(struct device *dev, struct device *master, void *data)return -EPROBE_DEFER ; } -/* This is the rate that is set by the firmware. The number -* needs to be a bit higher than the pixel clock rate -* (generally 148.5Mhz). -*/ - ret =clk_set_rate (vc4_hdmi->hsm_clock,HSM_CLOCK_FREQ ); -if (ret) { -DRM_ERROR ("Failed to set HSM clock rate: %d\n" , ret); - goto err_put_i2c; - } - - ret =clk_prepare_enable (vc4_hdmi->hsm_clock); -if (ret) { -DRM_ERROR ("Failed to turn on HDMI state machine clock: %d\n" , - ret); - goto err_put_i2c; - } -/* Only use the GPIO HPD pin if present in the DT, otherwise * we'll use the HDMI core's register. */
@@ -1412,9 +1411,7 @@ static int vc4_hdmi_bind(struct device *dev, struct device *master, void *data) err_destroy_encoder:vc4_hdmi_encoder_destroy (encoder); err_unprepare_hsm: -clk_disable_unprepare (vc4_hdmi->hsm_clock);pm_runtime_disable (dev); -err_put_i2c:put_device (&vc4_hdmi->ddc->dev);return ret;
@@ -1437,7 +1434,6 @@ static void vc4_hdmi_unbind(struct device *dev, struct device *master,vc4_hdmi_connector_destroy (&vc4_hdmi->connector);vc4_hdmi_encoder_destroy (&vc4_hdmi->encoder.base.base); -clk_disable_unprepare (vc4_hdmi->hsm_clock);pm_runtime_disable (dev);put_device (&vc4_hdmi->ddc->dev);
@@ -1460,6 +1456,7 @@ static int vc4_hdmi_dev_remove(struct platform_device *pdev) }struct vc4_hdmi_variant bcm2835_variant = { + .max_pixel_clock =148500000 , .audio_available = true, .cec_available = true, .registers = vc4_hdmi_fields,
drivers/gpu/drm/vc4/vc4_hdmi.h +3 -0
@@ -38,6 +38,9 @@ struct vc4_hdmi_variant {/* Set to true when the CEC support is available */ bool cec_available; +/* Maximum pixel clock supported by the controller (in Hz) */ +unsigned long long max_pixel_clock; +/* List of the registers available on that variant */ const struct vc4_hdmi_register *registers;
Signature · 1 line
git-series 0.9.1
Re: [PATCH 86/89] drm/vc4: hdmi: Adjust HSM clock rate depending on pixel rate
Hi Maxime,
drivers/gpu/drm/vc4/vc4_hdmi.c static int vc4_hdmi_dev_remove(struct platform_device · line 1460
Quoted 6 lines · Maxime Ripard
drivers/gpu/drm/vc4/vc4_hdmi.c +1
-0@@ -1460,6 +1456,7 @@ static int vc4_hdmi_dev_remove(struct platform_device *pdev) }struct vc4_hdmi_variant bcm2835_variant = { + .max_pixel_clock =148500000 ,
Just a reminder this might change in the close future:
https://www.spinics.net/lists/arm-kernel/msg793013.html
Regards,
Nicolas
j
Quoted 17 lines
drivers/gpu/drm/vc4/vc4_hdmi.c +0
-0.audio_available = true, .cec_available = true,drivers/gpu/drm/vc4/vc4_hdmi.c +0
-0.registers = vc4_hdmi_fields,drivers/gpu/drm/vc4/vc4_hdmi.h +3
-0@@ -38,6 +38,9 @@ struct vc4_hdmi_variant {/* Set to true when the CEC support is available */ bool cec_available; +/* Maximum pixel clock supported by the controller (in Hz) */ +unsigned long long max_pixel_clock; +/* List of the registers available on that variant */ const struct vc4_hdmi_register *registers;