2020-06-11 09:25:50

by Maxime Ripard

[permalink] [raw]
Subject: [PATCH v4 0/3] clk: bcm: Add BCM2711 DVP driver

Hi,

Here is yet another smaller patches series that got stripped out of the
huge HDMI one.

Since it depends at build time on patches already queued by Philipp in
reset/next, maybe we should merge the clock driver in the reset tree with
the Acks of Stephen and Mike?

Maxime

Changes from v3:
- Switch to devm_platform_get_and_ioremap_resource and devm_reset_controller_register
- Actually use the Kconfig symbol in the Makefile

Maxime Ripard (3):
dt-bindings: clock: Add BCM2711 DVP binding
clk: bcm: Add BCM2711 DVP driver
ARM: dts: bcm2711: Add HDMI DVP

Documentation/devicetree/bindings/clock/brcm,bcm2711-dvp.yaml | 47 +++-
arch/arm/boot/dts/bcm2711.dtsi | 15 +-
drivers/clk/bcm/Kconfig | 11 +-
drivers/clk/bcm/Makefile | 1 +-
drivers/clk/bcm/clk-bcm2711-dvp.c | 120 +++++++-
5 files changed, 194 insertions(+)
create mode 100644 Documentation/devicetree/bindings/clock/brcm,bcm2711-dvp.yaml
create mode 100644 drivers/clk/bcm/clk-bcm2711-dvp.c

base-commit: 192e08e14e37b78e83cc2f5b9eb5a15a7d71c4e2
--
git-series 0.9.1


2020-06-11 09:26:02

by Maxime Ripard

[permalink] [raw]
Subject: [PATCH v4 2/3] clk: bcm: Add BCM2711 DVP driver

The 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.

Cc: Michael Turquette <[email protected]>
Cc: Stephen Boyd <[email protected]>
Cc: Rob Herring <[email protected]>
Cc: [email protected]
Cc: [email protected]
Reviewed-by: Stephen Boyd <[email protected]>
Signed-off-by: Maxime Ripard <[email protected]>
---
drivers/clk/bcm/Kconfig | 11 +++-
drivers/clk/bcm/Makefile | 1 +-
drivers/clk/bcm/clk-bcm2711-dvp.c | 120 +++++++++++++++++++++++++++++++-
3 files changed, 132 insertions(+)
create mode 100644 drivers/clk/bcm/clk-bcm2711-dvp.c

diff --git a/drivers/clk/bcm/Kconfig b/drivers/clk/bcm/Kconfig
index 8c83977a7dc4..784f12c72365 100644
--- a/drivers/clk/bcm/Kconfig
+++ b/drivers/clk/bcm/Kconfig
@@ -1,4 +1,15 @@
# SPDX-License-Identifier: GPL-2.0-only
+
+config CLK_BCM2711_DVP
+ tristate "Broadcom BCM2711 DVP support"
+ depends on ARCH_BCM2835 ||COMPILE_TEST
+ depends on COMMON_CLK
+ default ARCH_BCM2835
+ select RESET_SIMPLE
+ help
+ Enable common clock framework support for the Broadcom BCM2711
+ DVP Controller.
+
config CLK_BCM2835
bool "Broadcom BCM2835 clock support"
depends on ARCH_BCM2835 || ARCH_BRCMSTB || COMPILE_TEST
diff --git a/drivers/clk/bcm/Makefile b/drivers/clk/bcm/Makefile
index 0070ddf6cdd2..edb66b44cb27 100644
--- a/drivers/clk/bcm/Makefile
+++ b/drivers/clk/bcm/Makefile
@@ -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_BCM2711_DVP) += 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
diff --git a/drivers/clk/bcm/clk-bcm2711-dvp.c b/drivers/clk/bcm/clk-bcm2711-dvp.c
new file mode 100644
index 000000000000..84dbc886e303
--- /dev/null
+++ b/drivers/clk/bcm/clk-bcm2711-dvp.c
@@ -0,0 +1,120 @@
+// 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_hw_onecell_data *data;
+ struct reset_simple_data reset;
+};
+
+static const struct clk_parent_data clk_dvp_parent = {
+ .index = 0,
+};
+
+static int clk_dvp_probe(struct platform_device *pdev)
+{
+ struct clk_hw_onecell_data *data;
+ struct resource *res;
+ struct clk_dvp *dvp;
+ void __iomem *base;
+ int ret;
+
+ dvp = devm_kzalloc(&pdev->dev, sizeof(*dvp), GFP_KERNEL);
+ if (!dvp)
+ return -ENOMEM;
+ platform_set_drvdata(pdev, dvp);
+
+ dvp->data = devm_kzalloc(&pdev->dev,
+ struct_size(dvp->data, hws, NR_CLOCKS),
+ GFP_KERNEL);
+ if (!dvp->data)
+ return -ENOMEM;
+ data = dvp->data;
+
+ base = devm_platform_get_and_ioremap_resource(pdev, 0, &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 = devm_reset_controller_register(&pdev->dev, &dvp->reset.rcdev);
+ if (ret)
+ return ret;
+
+ data->hws[0] = clk_hw_register_gate_parent_data(&pdev->dev,
+ "hdmi0-108MHz",
+ &clk_dvp_parent, 0,
+ base + DVP_HT_RPI_MISC_CONFIG, 3,
+ CLK_GATE_SET_TO_DISABLE,
+ &dvp->reset.lock);
+ if (IS_ERR(data->hws[0]))
+ return PTR_ERR(data->hws[0]);
+
+ data->hws[1] = clk_hw_register_gate_parent_data(&pdev->dev,
+ "hdmi1-108MHz",
+ &clk_dvp_parent, 0,
+ base + DVP_HT_RPI_MISC_CONFIG, 4,
+ CLK_GATE_SET_TO_DISABLE,
+ &dvp->reset.lock);
+ if (IS_ERR(data->hws[1])) {
+ ret = PTR_ERR(data->hws[1]);
+ goto unregister_clk0;
+ }
+
+ data->num = NR_CLOCKS;
+ ret = of_clk_add_hw_provider(pdev->dev.of_node, of_clk_hw_onecell_get,
+ data);
+ if (ret)
+ goto unregister_clk1;
+
+ return 0;
+
+unregister_clk1:
+ clk_hw_unregister_gate(data->hws[1]);
+
+unregister_clk0:
+ clk_hw_unregister_gate(data->hws[0]);
+ return ret;
+};
+
+static int clk_dvp_remove(struct platform_device *pdev)
+{
+ struct clk_dvp *dvp = platform_get_drvdata(pdev);
+ struct clk_hw_onecell_data *data = dvp->data;
+
+ clk_hw_unregister_gate(data->hws[1]);
+ clk_hw_unregister_gate(data->hws[0]);
+
+ return 0;
+}
+
+static const struct of_device_id clk_dvp_dt_ids[] = {
+ { .compatible = "brcm,brcm2711-dvp", },
+ { /* sentinel */ }
+};
+
+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);
--
git-series 0.9.1

2020-06-11 16:57:27

by Maxime Ripard

[permalink] [raw]
Subject: Re: [PATCH v4 2/3] clk: bcm: Add BCM2711 DVP driver

Hi Stefan,

On Thu, Jun 11, 2020 at 05:50:30PM +0200, Stefan Wahren wrote:
> > diff --git a/drivers/clk/bcm/clk-bcm2711-dvp.c b/drivers/clk/bcm/clk-bcm2711-dvp.c
> > new file mode 100644
> > index 000000000000..84dbc886e303
> > --- /dev/null
> > +++ b/drivers/clk/bcm/clk-bcm2711-dvp.c
> > @@ -0,0 +1,120 @@
> > +// 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
>
> sorry for not noticing this before. Are these defines specific to the
> Raspberry Pi, because of RPI?

I'm not entirely sure to be honest. It's the names that the register
have, but it's not clear to me if it's something specific to the RPi
itself, or it just means something else entirely.

Maxime

2020-06-11 17:11:59

by Florian Fainelli

[permalink] [raw]
Subject: Re: [PATCH v4 2/3] clk: bcm: Add BCM2711 DVP driver



On 6/11/2020 9:52 AM, Maxime Ripard wrote:
> Hi Stefan,
>
> On Thu, Jun 11, 2020 at 05:50:30PM +0200, Stefan Wahren wrote:
>>> diff --git a/drivers/clk/bcm/clk-bcm2711-dvp.c b/drivers/clk/bcm/clk-bcm2711-dvp.c
>>> new file mode 100644
>>> index 000000000000..84dbc886e303
>>> --- /dev/null
>>> +++ b/drivers/clk/bcm/clk-bcm2711-dvp.c
>>> @@ -0,0 +1,120 @@
>>> +// 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
>>
>> sorry for not noticing this before. Are these defines specific to the
>> Raspberry Pi, because of RPI?
>
> I'm not entirely sure to be honest. It's the names that the register
> have, but it's not clear to me if it's something specific to the RPi
> itself, or it just means something else entirely.

My understanding is that this is a wrapper that was done specifically
for the Raspberry Pi usage of that IP block, which is why it has PI in
the name, so this looks good correct, and this does match the internal
register database name.
--
Florian

2020-06-11 19:22:41

by Stefan Wahren

[permalink] [raw]
Subject: Re: [PATCH v4 2/3] clk: bcm: Add BCM2711 DVP driver

Am 11.06.20 um 19:06 schrieb Florian Fainelli:
>
> On 6/11/2020 9:52 AM, Maxime Ripard wrote:
>> Hi Stefan,
>>
>> On Thu, Jun 11, 2020 at 05:50:30PM +0200, Stefan Wahren wrote:
>>>> diff --git a/drivers/clk/bcm/clk-bcm2711-dvp.c b/drivers/clk/bcm/clk-bcm2711-dvp.c
>>>> new file mode 100644
>>>> index 000000000000..84dbc886e303
>>>> --- /dev/null
>>>> +++ b/drivers/clk/bcm/clk-bcm2711-dvp.c
>>>> @@ -0,0 +1,120 @@
>>>> +// 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
>>> sorry for not noticing this before. Are these defines specific to the
>>> Raspberry Pi, because of RPI?
>> I'm not entirely sure to be honest. It's the names that the register
>> have, but it's not clear to me if it's something specific to the RPi
>> itself, or it just means something else entirely.
> My understanding is that this is a wrapper that was done specifically
> for the Raspberry Pi usage of that IP block, which is why it has PI in
> the name, so this looks good correct, and this does match the internal
> register database name.

Okay, i'm fine with that and the whole series.

Acked-by: Stefan Wahren <[email protected]>

2020-06-11 19:33:25

by Stefan Wahren

[permalink] [raw]
Subject: Re: [PATCH v4 2/3] clk: bcm: Add BCM2711 DVP driver

Hi Maxime,

Am 11.06.20 um 11:23 schrieb Maxime Ripard:
> The 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.
>
> Cc: Michael Turquette <[email protected]>
> Cc: Stephen Boyd <[email protected]>
> Cc: Rob Herring <[email protected]>
> Cc: [email protected]
> Cc: [email protected]
> Reviewed-by: Stephen Boyd <[email protected]>
> Signed-off-by: Maxime Ripard <[email protected]>
> ---
> drivers/clk/bcm/Kconfig | 11 +++-
> drivers/clk/bcm/Makefile | 1 +-
> drivers/clk/bcm/clk-bcm2711-dvp.c | 120 +++++++++++++++++++++++++++++++-
> 3 files changed, 132 insertions(+)
> create mode 100644 drivers/clk/bcm/clk-bcm2711-dvp.c
>
> diff --git a/drivers/clk/bcm/Kconfig b/drivers/clk/bcm/Kconfig
> index 8c83977a7dc4..784f12c72365 100644
> --- a/drivers/clk/bcm/Kconfig
> +++ b/drivers/clk/bcm/Kconfig
> @@ -1,4 +1,15 @@
> # SPDX-License-Identifier: GPL-2.0-only
> +
> +config CLK_BCM2711_DVP
> + tristate "Broadcom BCM2711 DVP support"
> + depends on ARCH_BCM2835 ||COMPILE_TEST
> + depends on COMMON_CLK
> + default ARCH_BCM2835
> + select RESET_SIMPLE
> + help
> + Enable common clock framework support for the Broadcom BCM2711
> + DVP Controller.
> +
> config CLK_BCM2835
> bool "Broadcom BCM2835 clock support"
> depends on ARCH_BCM2835 || ARCH_BRCMSTB || COMPILE_TEST
> diff --git a/drivers/clk/bcm/Makefile b/drivers/clk/bcm/Makefile
> index 0070ddf6cdd2..edb66b44cb27 100644
> --- a/drivers/clk/bcm/Makefile
> +++ b/drivers/clk/bcm/Makefile
> @@ -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_BCM2711_DVP) += 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
> diff --git a/drivers/clk/bcm/clk-bcm2711-dvp.c b/drivers/clk/bcm/clk-bcm2711-dvp.c
> new file mode 100644
> index 000000000000..84dbc886e303
> --- /dev/null
> +++ b/drivers/clk/bcm/clk-bcm2711-dvp.c
> @@ -0,0 +1,120 @@
> +// 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

sorry for not noticing this before. Are these defines specific to the
Raspberry Pi, because of RPI?

Otherwise i like to see this RPI part removed.

Regards
Stefan


2020-06-15 16:23:41

by Nicolas Saenz Julienne

[permalink] [raw]
Subject: Re: [PATCH v4 2/3] clk: bcm: Add BCM2711 DVP driver

On Thu, 2020-06-11 at 11:23 +0200, Maxime Ripard wrote:
> The 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.
>
> Cc: Michael Turquette <[email protected]>
> Cc: Stephen Boyd <[email protected]>
> Cc: Rob Herring <[email protected]>
> Cc: [email protected]
> Cc: [email protected]
> Reviewed-by: Stephen Boyd <[email protected]>
> Signed-off-by: Maxime Ripard <[email protected]>
> ---

Reviewed-by: Nicolas Saenz Julienne <[email protected]>

Regards,
Nicolas


Attachments:
signature.asc (499.00 B)
This is a digitally signed message part

2020-06-20 04:59:37

by Stephen Boyd

[permalink] [raw]
Subject: Re: [PATCH v4 2/3] clk: bcm: Add BCM2711 DVP driver

Quoting Maxime Ripard (2020-06-11 02:23:16)
> The 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.
>
> Cc: Michael Turquette <[email protected]>
> Cc: Stephen Boyd <[email protected]>
> Cc: Rob Herring <[email protected]>
> Cc: [email protected]
> Cc: [email protected]
> Reviewed-by: Stephen Boyd <[email protected]>
> Signed-off-by: Maxime Ripard <[email protected]>
> ---

Applied to clk-next

2020-06-20 05:00:01

by Stephen Boyd

[permalink] [raw]
Subject: Re: [PATCH v4 2/3] clk: bcm: Add BCM2711 DVP driver

Quoting Maxime Ripard (2020-06-11 02:23:16)
> The 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.
>
> Cc: Michael Turquette <[email protected]>
> Cc: Stephen Boyd <[email protected]>
> Cc: Rob Herring <[email protected]>
> Cc: [email protected]
> Cc: [email protected]
> Reviewed-by: Stephen Boyd <[email protected]>
> Signed-off-by: Maxime Ripard <[email protected]>
> ---

Applied to clk-next