Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp1527846ybg; Thu, 4 Jun 2020 11:59:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzEsu7UlopPRmG6Rm/7wKY5iMYPudHgbB+hARDrDNT808511yu6qz++xu40vTUsMHrVZpIZ X-Received: by 2002:a17:906:264a:: with SMTP id i10mr5183735ejc.210.1591297187011; Thu, 04 Jun 2020 11:59:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591297187; cv=none; d=google.com; s=arc-20160816; b=UDLKbrNsx5nyoV0+39k5dS2KkKtY+Ez3xXn9/2EUmPu8bPWf9wSVjy443KdqMVr1IL +5jtQqeORGyT/VoBttfQkmnRbJpsoBD4Wu1gbN7Q+dkWXj4L0WoNwFJZhpMW0KiM8uYw i1zykx3SRqk3KhwM8Daw/hFSz0bpjZM7GCuoMEbGramjwfO1k+NupTiORJwLP70qRWON me1wD8dndNDhzKqCbIxo9qCliyLwuXj6xeO1sXe9seMZrH+sCQgq5Bq8yFwjmCV9OvDn jvTzGO3cTm2FVv2vim8oCWTnt/qkLEiPZMa+9WfznzfOtyd68Hnth8ITLrEP5Oh3JsiA gNfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:date:cc:to:from:subject:message-id; bh=AEe621Vz5jV9OYf4r321XBX4MHkdg1VwdUCcRn8lYp0=; b=rOR9ee1DBJkkkhW8n8qw4zLg+hIvIZ31AbFAR2YEgZNbfXiFEoXsQvY6RLqx3zgje9 nuQGMaeVrTvq6U+nW2VCdNlLmYdhmMMo+9Ru+gAbXi+lVUml34Ic+9nCixfT34me9nHc C/mJDf67S5XczVlwvoP6CLENPJuJ2txQx6+/IUsBRMpkGJX1SmaKRDlafO41hb8lw4Io TJUNFEE9LyeBs+1vuBnxau+iIV0vdlnjVvI0jPe9HIsGMPs2454Ov/FXBkW8Y+0vp+Gt 9RTpdDqW0s4gDW0wwYQMbxPybuWDo/vbUV2SYy/KdoEhWxKe8zsf1dLAePGcZx24DnZG jG2A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u18si2104988edf.273.2020.06.04.11.59.23; Thu, 04 Jun 2020 11:59:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730139AbgFDR0N (ORCPT + 99 others); Thu, 4 Jun 2020 13:26:13 -0400 Received: from mx2.suse.de ([195.135.220.15]:39414 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730014AbgFDR0N (ORCPT ); Thu, 4 Jun 2020 13:26:13 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id D195FAFBB; Thu, 4 Jun 2020 17:26:13 +0000 (UTC) Message-ID: Subject: Re: [PATCH v3 004/105] clk: bcm: Add BCM2711 DVP driver From: Nicolas Saenz Julienne To: Maxime Ripard , Eric Anholt Cc: dri-devel@lists.freedesktop.org, linux-rpi-kernel@lists.infradead.org, bcm-kernel-feedback-list@broadcom.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Dave Stevenson , Tim Gover , Phil Elwell , Michael Turquette , Stephen Boyd , Rob Herring , linux-clk@vger.kernel.org, devicetree@vger.kernel.org Date: Thu, 04 Jun 2020 19:26:07 +0200 In-Reply-To: <6615a61b8af240e3d10f8890e4b2462ccdaac9b9.1590594512.git-series.maxime@cerno.tech> References: <6615a61b8af240e3d10f8890e4b2462ccdaac9b9.1590594512.git-series.maxime@cerno.tech> Content-Type: multipart/signed; micalg="pgp-sha256"; protocol="application/pgp-signature"; boundary="=-lPBuLBa/wxwh1MLkx6OO" User-Agent: Evolution 3.36.2 MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --=-lPBuLBa/wxwh1MLkx6OO Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Maxime, On Wed, 2020-05-27 at 17:47 +0200, Maxime Ripard wrote: > The HDMI block has a block that controls clocks and reset signals to the > HDMI0 and HDMI1 controllers. Why not having two separate drivers? > Let's expose that through a clock driver implementing a clock and reset > provider. >=20 > Cc: Michael Turquette > Cc: Stephen Boyd > Cc: Rob Herring > Cc: linux-clk@vger.kernel.org > Cc: devicetree@vger.kernel.org > Reviewed-by: Stephen Boyd > Signed-off-by: Maxime Ripard > --- > drivers/clk/bcm/Kconfig | 11 +++- > drivers/clk/bcm/Makefile | 1 +- > drivers/clk/bcm/clk-bcm2711-dvp.c | 127 +++++++++++++++++++++++++++++++- > 3 files changed, 139 insertions(+) > create mode 100644 drivers/clk/bcm/clk-bcm2711-dvp.c >=20 > 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..2c1349062147 100644 > --- a/drivers/clk/bcm/Makefile > +++ b/drivers/clk/bcm/Makefile > @@ -6,6 +6,7 @@ obj-$(CONFIG_CLK_BCM_KONA) +=3D clk-kona-setup.o > obj-$(CONFIG_CLK_BCM_KONA) +=3D clk-bcm281xx.o > obj-$(CONFIG_CLK_BCM_KONA) +=3D clk-bcm21664.o > obj-$(CONFIG_COMMON_CLK_IPROC) +=3D clk-iproc-armpll.o clk-iproc-pll.o > clk-iproc-asiu.o > +obj-$(CONFIG_CLK_BCM2835) +=3D clk-bcm2711-dvp.o > obj-$(CONFIG_CLK_BCM2835) +=3D clk-bcm2835.o > obj-$(CONFIG_CLK_BCM2835) +=3D clk-bcm2835-aux.o > obj-$(CONFIG_CLK_RASPBERRYPI) +=3D clk-raspberrypi.o > diff --git a/drivers/clk/bcm/clk-bcm2711-dvp.c b/drivers/clk/bcm/clk-bcm2= 711- > dvp.c > new file mode 100644 > index 000000000000..c1c4b5857d32 > --- /dev/null > +++ b/drivers/clk/bcm/clk-bcm2711-dvp.c > @@ -0,0 +1,127 @@ > +// SPDX-License-Identifier: GPL-2.0-or-later > +// Copyright 2020 Cerno > + > +#include > +#include > +#include > +#include > +#include > + > +#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 =3D { > + .index =3D 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 =3D devm_kzalloc(&pdev->dev, sizeof(*dvp), GFP_KERNEL); > + if (!dvp) > + return -ENOMEM; > + platform_set_drvdata(pdev, dvp); > + > + dvp->data =3D devm_kzalloc(&pdev->dev, > + struct_size(dvp->data, hws, NR_CLOCKS), > + GFP_KERNEL); > + if (!dvp->data) > + return -ENOMEM; > + data =3D dvp->data; > + > + res =3D platform_get_resource(pdev, IORESOURCE_MEM, 0); > + base =3D devm_ioremap_resource(&pdev->dev, res); I think the cool function to use these days is devm_platform_get_and_ioremap_resource(). Regards, Nicolas > + if (IS_ERR(base)) > + return PTR_ERR(base); > + > + dvp->reset.rcdev.owner =3D THIS_MODULE; > + dvp->reset.rcdev.nr_resets =3D NR_RESETS; > + dvp->reset.rcdev.ops =3D &reset_simple_ops; > + dvp->reset.rcdev.of_node =3D pdev->dev.of_node; > + dvp->reset.membase =3D base + DVP_HT_RPI_SW_INIT; > + spin_lock_init(&dvp->reset.lock); > + > + ret =3D reset_controller_register(&dvp->reset.rcdev); > + if (ret) > + return ret; > + > + data->hws[0] =3D 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])) { > + ret =3D PTR_ERR(data->hws[0]); > + goto unregister_reset; > + } > + > + data->hws[1] =3D 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 =3D PTR_ERR(data->hws[1]); > + goto unregister_clk0; > + } > + > + data->num =3D NR_CLOCKS; > + ret =3D 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]); > + > +unregister_reset: > + reset_controller_unregister(&dvp->reset.rcdev); > + return ret; > +}; > + > +static int clk_dvp_remove(struct platform_device *pdev) > +{ > + struct clk_dvp *dvp =3D platform_get_drvdata(pdev); > + struct clk_hw_onecell_data *data =3D dvp->data; > + > + clk_hw_unregister_gate(data->hws[1]); > + clk_hw_unregister_gate(data->hws[0]); > + reset_controller_unregister(&dvp->reset.rcdev); > + > + return 0; > +} > + > +static const struct of_device_id clk_dvp_dt_ids[] =3D { > + { .compatible =3D "brcm,brcm2711-dvp", }, > + { /* sentinel */ } > +}; > + > +static struct platform_driver clk_dvp_driver =3D { > + .probe =3D clk_dvp_probe, > + .remove =3D clk_dvp_remove, > + .driver =3D { > + .name =3D "brcm2711-dvp", > + .of_match_table =3D clk_dvp_dt_ids, > + }, > +}; > +module_platform_driver(clk_dvp_driver); --=-lPBuLBa/wxwh1MLkx6OO Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- iQEzBAABCAAdFiEErOkkGDHCg2EbPcGjlfZmHno8x/4FAl7ZLq8ACgkQlfZmHno8 x/6woAf9He9cZYeL4fiweKGtSwB5ZNhTx7awC6UNWL/E+YIzVoDuIb+gqe31BkE0 ooZ7fIEybz0SXP6sqWm7V813jg7Mgsn93NXZlK5aHQ3avRB4uLse4NcASz7b5gTu ZtXxL7ULQdBpGlACncdzzq+JlvrkiNy54a3AvZdCjy4u6RewoPrLU5+yWYNC15LF LQn1NOv4Hq3llEIgpO9cDva7YESfGnsJRHLvGceayptvAjMaLagzsc43C0rltyJ6 2QYjBT7duCsYtA20CZ9WCBwL10hgU7Uenwb9bo2XA7+7ZTP4R/fAx6NAe+nVnQSX l916sTFCkkBnPd5rMvnk+TeZ3DPUqg== =ShOF -----END PGP SIGNATURE----- --=-lPBuLBa/wxwh1MLkx6OO--