Message ID | 20191028215919.83697-6-john.stultz@linaro.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Prereqs for HiKey960 USB support | expand |
Hi, John Stultz <john.stultz@linaro.org> writes: > The dwc3 core binding specifies three clocks: > ref, bus_early, and suspend > > which are all controlled in the driver together. > > However some variants of the hardware my not have all three clks ^^ may In fact *all* platforms have all three clocks. It's just that in some cases clock pins are shorted together (or take input from same clock). > So this patch reworks the reading of the clks from the dts to > use devm_clk_bulk_get_all() will will fetch all the clocks ^^^^ which? > specified in the dts together. > > This patch was reccomended by Rob Herring <robh@kernel.org> > as an alternative to creating multiple bindings for each variant > of hardware when the only unique bits were clocks and resets. > > Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> > Cc: Rob Herring <robh+dt@kernel.org> > Cc: Mark Rutland <mark.rutland@arm.com> > CC: ShuFan Lee <shufan_lee@richtek.com> > Cc: Heikki Krogerus <heikki.krogerus@linux.intel.com> > Cc: Suzuki K Poulose <suzuki.poulose@arm.com> > Cc: Chunfeng Yun <chunfeng.yun@mediatek.com> > Cc: Yu Chen <chenyu56@huawei.com> > Cc: Felipe Balbi <balbi@kernel.org> > Cc: Hans de Goede <hdegoede@redhat.com> > Cc: Andy Shevchenko <andy.shevchenko@gmail.com> > Cc: Jun Li <lijun.kernel@gmail.com> > Cc: Valentin Schneider <valentin.schneider@arm.com> > Cc: Jack Pham <jackp@codeaurora.org> > Cc: linux-usb@vger.kernel.org > Cc: devicetree@vger.kernel.org > Suggested-by: Rob Herring <robh@kernel.org> > Signed-off-by: John Stultz <john.stultz@linaro.org> > --- > v3: Rework dwc3 core rather then adding another dwc-of-simple > binding. > --- > drivers/usb/dwc3/core.c | 20 +++++--------------- > 1 file changed, 5 insertions(+), 15 deletions(-) > > diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c > index a039e35ec7ad..4d4f1836b62c 100644 > --- a/drivers/usb/dwc3/core.c > +++ b/drivers/usb/dwc3/core.c > @@ -305,12 +305,6 @@ static int dwc3_core_soft_reset(struct dwc3 *dwc) > return 0; > } > > -static const struct clk_bulk_data dwc3_core_clks[] = { > - { .id = "ref" }, > - { .id = "bus_early" }, > - { .id = "suspend" }, > -}; another option would be to pass three clocks with the same phandle. That would even make sure that clock usage counts are correct, no?
On Tue, Oct 29, 2019 at 2:14 AM Felipe Balbi <balbi@kernel.org> wrote: > John Stultz <john.stultz@linaro.org> writes: > > > The dwc3 core binding specifies three clocks: > > ref, bus_early, and suspend > > > > which are all controlled in the driver together. > > > > However some variants of the hardware my not have all three clks > ^^ > may > > In fact *all* platforms have all three clocks. It's just that in some > cases clock pins are shorted together (or take input from same clock). > ... > another option would be to pass three clocks with the same phandle. That > would even make sure that clock usage counts are correct, no? Hey Felipe! So I actually had done that initially (and it seemed to work), but Rob suggested this way instead. I'm fine with either, as long as having multiple references to the same clk in the enable/disable paths doesn't cause trouble. Thanks so much for the review here! -john
Hi, John Stultz <john.stultz@linaro.org> writes: > On Tue, Oct 29, 2019 at 2:14 AM Felipe Balbi <balbi@kernel.org> wrote: >> John Stultz <john.stultz@linaro.org> writes: >> >> > The dwc3 core binding specifies three clocks: >> > ref, bus_early, and suspend >> > >> > which are all controlled in the driver together. >> > >> > However some variants of the hardware my not have all three clks >> ^^ >> may >> >> In fact *all* platforms have all three clocks. It's just that in some >> cases clock pins are shorted together (or take input from same clock). >> > ... >> another option would be to pass three clocks with the same phandle. That >> would even make sure that clock usage counts are correct, no? > > Hey Felipe! > > So I actually had done that initially (and it seemed to work), but Rob > suggested this way instead. > I'm fine with either, as long as having multiple references to the > same clk in the enable/disable paths doesn't cause trouble. > > Thanks so much for the review here! same as the other patch, if we're supposed to describe the HW, then we should describe what's actually happening.
On Tue, Oct 29, 2019 at 4:14 AM Felipe Balbi <balbi@kernel.org> wrote: > > > Hi, > > John Stultz <john.stultz@linaro.org> writes: > > > The dwc3 core binding specifies three clocks: > > ref, bus_early, and suspend > > > > which are all controlled in the driver together. > > > > However some variants of the hardware my not have all three clks > ^^ > may > > In fact *all* platforms have all three clocks. It's just that in some > cases clock pins are shorted together (or take input from same clock). > > > So this patch reworks the reading of the clks from the dts to > > use devm_clk_bulk_get_all() will will fetch all the clocks > ^^^^ > which? > > > specified in the dts together. > > > > This patch was reccomended by Rob Herring <robh@kernel.org> > > as an alternative to creating multiple bindings for each variant > > of hardware when the only unique bits were clocks and resets. > > > > Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> > > Cc: Rob Herring <robh+dt@kernel.org> > > Cc: Mark Rutland <mark.rutland@arm.com> > > CC: ShuFan Lee <shufan_lee@richtek.com> > > Cc: Heikki Krogerus <heikki.krogerus@linux.intel.com> > > Cc: Suzuki K Poulose <suzuki.poulose@arm.com> > > Cc: Chunfeng Yun <chunfeng.yun@mediatek.com> > > Cc: Yu Chen <chenyu56@huawei.com> > > Cc: Felipe Balbi <balbi@kernel.org> > > Cc: Hans de Goede <hdegoede@redhat.com> > > Cc: Andy Shevchenko <andy.shevchenko@gmail.com> > > Cc: Jun Li <lijun.kernel@gmail.com> > > Cc: Valentin Schneider <valentin.schneider@arm.com> > > Cc: Jack Pham <jackp@codeaurora.org> > > Cc: linux-usb@vger.kernel.org > > Cc: devicetree@vger.kernel.org > > Suggested-by: Rob Herring <robh@kernel.org> > > Signed-off-by: John Stultz <john.stultz@linaro.org> > > --- > > v3: Rework dwc3 core rather then adding another dwc-of-simple > > binding. > > --- > > drivers/usb/dwc3/core.c | 20 +++++--------------- > > 1 file changed, 5 insertions(+), 15 deletions(-) > > > > diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c > > index a039e35ec7ad..4d4f1836b62c 100644 > > --- a/drivers/usb/dwc3/core.c > > +++ b/drivers/usb/dwc3/core.c > > @@ -305,12 +305,6 @@ static int dwc3_core_soft_reset(struct dwc3 *dwc) > > return 0; > > } > > > > -static const struct clk_bulk_data dwc3_core_clks[] = { > > - { .id = "ref" }, > > - { .id = "bus_early" }, > > - { .id = "suspend" }, > > -}; > > another option would be to pass three clocks with the same phandle. That > would even make sure that clock usage counts are correct, no? If you have the datasheet for the block, then perhaps some suggestion of which clocks code be the same. My guess would be ref and suspend. Maybe suspend is a fixed clock which is unmanaged on HiSilicon platforms. If we allow for no clocks on some platforms, then why does it have to be all or none? Rob
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index a039e35ec7ad..4d4f1836b62c 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -305,12 +305,6 @@ static int dwc3_core_soft_reset(struct dwc3 *dwc) return 0; } -static const struct clk_bulk_data dwc3_core_clks[] = { - { .id = "ref" }, - { .id = "bus_early" }, - { .id = "suspend" }, -}; - /* * dwc3_frame_length_adjustment - Adjusts frame length if required * @dwc3: Pointer to our controller context structure @@ -1418,11 +1412,6 @@ static int dwc3_probe(struct platform_device *pdev) if (!dwc) return -ENOMEM; - dwc->clks = devm_kmemdup(dev, dwc3_core_clks, sizeof(dwc3_core_clks), - GFP_KERNEL); - if (!dwc->clks) - return -ENOMEM; - dwc->dev = dev; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); @@ -1458,17 +1447,18 @@ static int dwc3_probe(struct platform_device *pdev) return PTR_ERR(dwc->reset); if (dev->of_node) { - dwc->num_clks = ARRAY_SIZE(dwc3_core_clks); - - ret = devm_clk_bulk_get(dev, dwc->num_clks, dwc->clks); + ret = devm_clk_bulk_get_all(dev, &dwc->clks); if (ret == -EPROBE_DEFER) return ret; /* * Clocks are optional, but new DT platforms should support all * clocks as required by the DT-binding. */ - if (ret) + if (ret < 0) dwc->num_clks = 0; + else + dwc->num_clks = ret; + } ret = reset_control_deassert(dwc->reset);
The dwc3 core binding specifies three clocks: ref, bus_early, and suspend which are all controlled in the driver together. However some variants of the hardware my not have all three clks So this patch reworks the reading of the clks from the dts to use devm_clk_bulk_get_all() will will fetch all the clocks specified in the dts together. This patch was reccomended by Rob Herring <robh@kernel.org> as an alternative to creating multiple bindings for each variant of hardware when the only unique bits were clocks and resets. Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Rob Herring <robh+dt@kernel.org> Cc: Mark Rutland <mark.rutland@arm.com> CC: ShuFan Lee <shufan_lee@richtek.com> Cc: Heikki Krogerus <heikki.krogerus@linux.intel.com> Cc: Suzuki K Poulose <suzuki.poulose@arm.com> Cc: Chunfeng Yun <chunfeng.yun@mediatek.com> Cc: Yu Chen <chenyu56@huawei.com> Cc: Felipe Balbi <balbi@kernel.org> Cc: Hans de Goede <hdegoede@redhat.com> Cc: Andy Shevchenko <andy.shevchenko@gmail.com> Cc: Jun Li <lijun.kernel@gmail.com> Cc: Valentin Schneider <valentin.schneider@arm.com> Cc: Jack Pham <jackp@codeaurora.org> Cc: linux-usb@vger.kernel.org Cc: devicetree@vger.kernel.org Suggested-by: Rob Herring <robh@kernel.org> Signed-off-by: John Stultz <john.stultz@linaro.org> --- v3: Rework dwc3 core rather then adding another dwc-of-simple binding. --- drivers/usb/dwc3/core.c | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-)