From 7647593d7cd352a27c301ba773f830678cf2e965 Mon Sep 17 00:00:00 2001 From: Stefan Wahren Date: Thu, 6 Dec 2018 19:28:55 +0100 Subject: [PATCH 1/4] staging: vchiq_arm: Register a platform device for audio Following Eric's commit 37b7b3087a2f ("staging/vc04_services: Register a platform device for the camera driver.") this register the audio driver as a platform device, too. Signed-off-by: Stefan Wahren Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c index 3b9103d720c8fa..23ff8b6c176454 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -139,6 +139,7 @@ static struct vchiq_state g_state; static struct class *vchiq_class; static DEFINE_SPINLOCK(msg_queue_spinlock); static struct platform_device *bcm2835_camera; +static struct platform_device *bcm2835_audio; static struct platform_device *bcm2835_codec; static struct platform_device *vcsm_cma; @@ -3281,6 +3282,7 @@ static int vchiq_probe(struct platform_device *pdev) vcsm_cma = vchiq_register_child(pdev, "vcsm-cma"); bcm2835_codec = vchiq_register_child(pdev, "bcm2835-codec"); bcm2835_camera = vchiq_register_child(pdev, "bcm2835-camera"); + bcm2835_audio = vchiq_register_child(pdev, "bcm2835_audio"); return 0; From 33e445eef72d528b2230085274163084323d3992 Mon Sep 17 00:00:00 2001 From: Phil Elwell Date: Mon, 3 Feb 2020 17:30:46 +0000 Subject: [PATCH 2/4] staging: vchiq_arm: Give vchiq children DT nodes vchiq kernel clients are now instantiated as platform drivers rather than using DT, but the children of the vchiq interface may still benefit from access to DT properties. Give them the option of a a sub-node of the vchiq parent for configuration and to allow them to be disabled. Signed-off-by: Phil Elwell --- .../staging/vc04_services/interface/vchiq_arm/vchiq_arm.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c index 23ff8b6c176454..b3c1db94e21378 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -3200,12 +3200,20 @@ vchiq_register_child(struct platform_device *pdev, const char *name) pdevinfo.id = PLATFORM_DEVID_NONE; pdevinfo.dma_mask = DMA_BIT_MASK(32); + np = of_get_child_by_name(pdev->dev.of_node, name); + + /* Skip the child if it is explicitly disabled */ + if (np && !of_device_is_available(np)) + return NULL; + child = platform_device_register_full(&pdevinfo); if (IS_ERR(child)) { dev_warn(&pdev->dev, "%s not registered\n", name); child = NULL; } + child->dev.of_node = np; + /* * We want the dma-ranges etc to be copied from a device with the * correct dma-ranges for the VPU. From 8e97090d78c16bd4b1241ac6160de467701a750d Mon Sep 17 00:00:00 2001 From: Phil Elwell Date: Mon, 3 Feb 2020 17:33:01 +0000 Subject: [PATCH 3/4] staging: vchiq_arm: Add a matching unregister call All the registered children of vchiq have a corresponding call to platform_device_unregister except bcm2835_audio. Fix that. Fixes: 25c7597af20d ("staging: vchiq_arm: Register a platform device for audio") Signed-off-by: Phil Elwell --- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c index b3c1db94e21378..00b6674994dbd7 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -3303,6 +3303,7 @@ static int vchiq_probe(struct platform_device *pdev) static int vchiq_remove(struct platform_device *pdev) { + platform_device_unregister(bcm2835_audio); platform_device_unregister(bcm2835_camera); platform_device_unregister(bcm2835_codec); platform_device_unregister(vcsm_cma); From c363ab695a4d474205c7e9dd4427c75cdd9cd355 Mon Sep 17 00:00:00 2001 From: Phil Elwell Date: Mon, 3 Feb 2020 17:03:29 +0000 Subject: [PATCH 4/4] ARM: dts: Move audio node under the vchiq parent VCHIQ kernel clients are now instantiated as platform drivers rather than using DT, but the children of the vchiq device can optionally be given a sub-node of the vchiq parent for configuration and to disable them. Move the existing audio node beneath the vchiq parent, to prevent multiple instantiation and unpleasant warnings. Signed-off-by: Phil Elwell --- arch/arm/boot/dts/bcm270x-rpi.dtsi | 16 +++++++++------- arch/arm/boot/dts/bcm2711-rpi.dtsi | 14 ++++++++++++++ 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/arch/arm/boot/dts/bcm270x-rpi.dtsi b/arch/arm/boot/dts/bcm270x-rpi.dtsi index b7bf3606162352..32cd6c7efa67f0 100644 --- a/arch/arm/boot/dts/bcm270x-rpi.dtsi +++ b/arch/arm/boot/dts/bcm270x-rpi.dtsi @@ -70,13 +70,6 @@ status = "okay"; }; - /* Onboard audio */ - audio: audio { - compatible = "brcm,bcm2835-audio"; - brcm,pwm-channels = <8>; - status = "disabled"; - }; - /* External sound card */ sound: sound { status = "disabled"; @@ -137,3 +130,12 @@ &vec { status = "disabled"; }; + +&vchiq { + /* Onboard audio */ + audio: audio { + compatible = "brcm,bcm2835-audio"; + brcm,pwm-channels = <8>; + status = "disabled"; + }; +}; diff --git a/arch/arm/boot/dts/bcm2711-rpi.dtsi b/arch/arm/boot/dts/bcm2711-rpi.dtsi index 9e28dfc4ed8bbe..8011cb6361d340 100644 --- a/arch/arm/boot/dts/bcm2711-rpi.dtsi +++ b/arch/arm/boot/dts/bcm2711-rpi.dtsi @@ -54,6 +54,8 @@ compatible = "brcm,bcm2835-vc4"; status = "disabled"; }; + + /delete-node/ audio; }; &scb { @@ -159,6 +161,18 @@ }; }; +&vchiq { + /* Onboard audio + * This node is replicated because the original from bcm270x-rpi.dtsi + * was deleted when the vchiq node was deleted above. + */ + audio: bcm2835_audio { + compatible = "brcm,bcm2835-audio"; + brcm,pwm-channels = <8>; + status = "disabled"; + }; +}; + &dma { /* The VPU firmware uses DMA channel 11 for VCHIQ */ brcm,dma-channel-mask = <0x1f5>;