From: Hans de Goede <hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
To: Maxime Ripard
<maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
Cc: Emilio Lopez <emilio-0Z03zUJReD5OxF6Tv1QG9Q@public.gmane.org>,
Mike Turquette
<mturquette-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
Linux Media Mailing List
<linux-media-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
devicetree <devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
linux-sunxi-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
Subject: Re: [PATCH 3/9] clk: sunxi: Add prcm mod0 clock driver
Date: Fri, 21 Nov 2014 10:13:10 +0100 [thread overview]
Message-ID: <546F0226.2040700@redhat.com> (raw)
In-Reply-To: <20141121084933.GL24143@lukather>
Hi,
On 11/21/2014 09:49 AM, Maxime Ripard wrote:
> Hi,
>
> On Thu, Nov 20, 2014 at 04:55:22PM +0100, Hans de Goede wrote:
>> Add a driver for mod0 clocks found in the prcm. Currently there is only
>> one mod0 clocks in the prcm, the ir clock.
>>
>> Signed-off-by: Hans de Goede <hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
>> ---
>> Documentation/devicetree/bindings/clock/sunxi.txt | 1 +
>> drivers/clk/sunxi/Makefile | 2 +-
>> drivers/clk/sunxi/clk-sun6i-prcm-mod0.c | 63 +++++++++++++++++++++++
>> drivers/mfd/sun6i-prcm.c | 14 +++++
>> 4 files changed, 79 insertions(+), 1 deletion(-)
>> create mode 100644 drivers/clk/sunxi/clk-sun6i-prcm-mod0.c
>>
>> diff --git a/Documentation/devicetree/bindings/clock/sunxi.txt b/Documentation/devicetree/bindings/clock/sunxi.txt
>> index ed116df..342c75a 100644
>> --- a/Documentation/devicetree/bindings/clock/sunxi.txt
>> +++ b/Documentation/devicetree/bindings/clock/sunxi.txt
>> @@ -56,6 +56,7 @@ Required properties:
>> "allwinner,sun4i-a10-usb-clk" - for usb gates + resets on A10 / A20
>> "allwinner,sun5i-a13-usb-clk" - for usb gates + resets on A13
>> "allwinner,sun6i-a31-usb-clk" - for usb gates + resets on A31
>> + "allwinner,sun6i-a31-ir-clk" - for the ir clock on A31
>>
>> Required properties for all clocks:
>> - reg : shall be the control register address for the clock.
>> diff --git a/drivers/clk/sunxi/Makefile b/drivers/clk/sunxi/Makefile
>> index 7ddc2b5..daf8b1c 100644
>> --- a/drivers/clk/sunxi/Makefile
>> +++ b/drivers/clk/sunxi/Makefile
>> @@ -10,4 +10,4 @@ obj-y += clk-sun8i-mbus.o
>>
>> obj-$(CONFIG_MFD_SUN6I_PRCM) += \
>> clk-sun6i-ar100.o clk-sun6i-apb0.o clk-sun6i-apb0-gates.o \
>> - clk-sun8i-apb0.o
>> + clk-sun8i-apb0.o clk-sun6i-prcm-mod0.o
>> diff --git a/drivers/clk/sunxi/clk-sun6i-prcm-mod0.c b/drivers/clk/sunxi/clk-sun6i-prcm-mod0.c
>> new file mode 100644
>> index 0000000..e80f18e
>> --- /dev/null
>> +++ b/drivers/clk/sunxi/clk-sun6i-prcm-mod0.c
>> @@ -0,0 +1,63 @@
>> +/*
>> + * Allwinner A31 PRCM mod0 clock driver
>> + *
>> + * Copyright (C) 2014 Hans de Goede <hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
>> + *
>> + * This program is free software; you can redistribute it and/or modify
>> + * it under the terms of the GNU General Public License as published by
>> + * the Free Software Foundation; either version 2 of the License, or
>> + * (at your option) any later version.
>> + *
>> + * This program is distributed in the hope that it will be useful,
>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
>> + * GNU General Public License for more details.
>> + */
>> +
>> +#include <linux/clk-provider.h>
>> +#include <linux/clkdev.h>
>> +#include <linux/module.h>
>> +#include <linux/of_address.h>
>> +#include <linux/platform_device.h>
>> +
>> +#include "clk-factors.h"
>> +#include "clk-mod0.h"
>> +
>> +static const struct of_device_id sun6i_a31_prcm_mod0_clk_dt_ids[] = {
>> + { .compatible = "allwinner,sun6i-a31-ir-clk" },
>> + { /* sentinel */ }
>> +};
>> +
>> +static DEFINE_SPINLOCK(sun6i_prcm_mod0_lock);
>> +
>> +static int sun6i_a31_prcm_mod0_clk_probe(struct platform_device *pdev)
>> +{
>> + struct device_node *np = pdev->dev.of_node;
>> + struct resource *r;
>> + void __iomem *reg;
>> +
>> + if (!np)
>> + return -ENODEV;
>> +
>> + r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>> + reg = devm_ioremap_resource(&pdev->dev, r);
>> + if (IS_ERR(reg))
>> + return PTR_ERR(reg);
>> +
>> + sunxi_factors_register(np, &sun4i_a10_mod0_data,
>> + &sun6i_prcm_mod0_lock, reg);
>> + return 0;
>> +}
>> +
>> +static struct platform_driver sun6i_a31_prcm_mod0_clk_driver = {
>> + .driver = {
>> + .name = "sun6i-a31-prcm-mod0-clk",
>> + .of_match_table = sun6i_a31_prcm_mod0_clk_dt_ids,
>> + },
>> + .probe = sun6i_a31_prcm_mod0_clk_probe,
>> +};
>> +module_platform_driver(sun6i_a31_prcm_mod0_clk_driver);
>> +
>> +MODULE_DESCRIPTION("Allwinner A31 PRCM mod0 clock driver");
>> +MODULE_AUTHOR("Hans de Goede <hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>");
>> +MODULE_LICENSE("GPL");
>
> I don't think this is the right approach, mainly for two reasons: the
> compatible shouldn't change, and you're basically duplicating code
> there.
>
> I understand that you need the new compatible in order to avoid a
> double probing: one by CLK_OF_DECLARE, and one by the usual mechanism,
> and that also implies the second reason.
Not only for that, we need a new compatible also because the mfd framework
needs a separate compatible per sub-node as that is how it finds nodes
to attach to the platform devices, so we need a new compatible anyways,
with your make the mod0 clock driver a platform driver solution we could
use:
compatible = "allwinner,sun6i-a31-ir-clk", "allwinner,sun4i-a10-mod0-clk";
To work around this, but there are other problems, your make mod0clk a
platform driver solution cannot work because the clocks node in the dtsi
is not simple-bus compatible, so no platform-devs will be instantiated for
the clocks there.
Besides the compatible (which as said we need a separate one anyways),
your other worry is code duplication, but I've avoided that as much
as possible already, the new drivers/clk/sunxi/clk-sun6i-prcm-mod0.c is
just a very thin wrapper, waying in with all of 63 lines including
16 lines GPL header.
So sorry, I disagree I believe that this is the best solution.
> However, as those are not critical clocks that need to be here early
> at boot, you can also fix this by turning the mod0 driver into a
> platform driver itself. The compatible will be kept, the driver will
> be the same.
>
> The only thing we need to pay attention to is how "client" drivers
> react when they cannot grab their clock. They should return
> -EPROBE_DEFER, but that remains to be checked.
-EPROBE_DEFER is yet another reason to not make mod0-clk a platform
driver. Yes drivers should be able to handle this, but it is a pain,
and the more we use it the more pain it is. Also it makes booting a lot
slower as any driver using a mod0 clk now, will not complete its probe
until all the other drivers are done probing and the late_initcall
which starts the deferred-probe wq runs.
Regards,
Hans
next prev parent reply other threads:[~2014-11-21 9:13 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-20 15:55 [PATCH 0/9] sun6i / A31 ir receiver support Hans de Goede
[not found] ` <1416498928-1300-1-git-send-email-hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2014-11-20 15:55 ` [PATCH 1/9] clk: sunxi: Give sunxi_factors_register a registers parameter Hans de Goede
2014-11-21 8:35 ` Maxime Ripard
2014-11-21 8:44 ` Hans de Goede
[not found] ` <546EFB83.1020806-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2014-11-21 11:15 ` Maxime Ripard
2014-11-20 15:55 ` [PATCH 2/9] clk: sunxi: Make sun4i_a10_mod0_data available outside of clk-mod0.c Hans de Goede
2014-11-20 15:55 ` [PATCH 3/9] clk: sunxi: Add prcm mod0 clock driver Hans de Goede
[not found] ` <1416498928-1300-4-git-send-email-hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2014-11-20 18:24 ` Chen-Yu Tsai
[not found] ` <CAGb2v66zoAy93mjZn+yf8zvCmkQ8AVWH92jKL-gyu90E5HLuuw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-11-20 19:32 ` Hans de Goede
2014-11-21 8:49 ` Maxime Ripard
2014-11-21 9:13 ` Hans de Goede [this message]
[not found] ` <546F0226.2040700-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2014-11-24 22:03 ` Maxime Ripard
2014-11-25 8:29 ` Hans de Goede
[not found] ` <54743DE1.7020704-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2014-11-25 8:37 ` Hans de Goede
2014-11-26 21:13 ` Maxime Ripard
2014-11-27 8:41 ` Hans de Goede
[not found] ` <5476E3A5.4000708-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2014-11-27 9:28 ` Chen-Yu Tsai
[not found] ` <CAGb2v652m0bCdPWFF4LWwjcrCJZvnLibFPw8xXJ3Q-Ge+_-p7g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-11-27 10:10 ` Hans de Goede
[not found] ` <5476F8AB.2000601-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2014-11-27 19:05 ` Maxime Ripard
2014-11-28 13:37 ` Hans de Goede
[not found] ` <54787A8A.6040209-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2014-12-02 15:45 ` Maxime Ripard
2014-12-03 9:49 ` Hans de Goede
[not found] ` <547EDCA0.4040805-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2014-12-07 18:08 ` Maxime Ripard
2014-12-08 8:19 ` Hans de Goede
[not found] ` <54855EF6.1000900-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2014-12-09 8:51 ` Maxime Ripard
2014-11-27 18:51 ` Maxime Ripard
2014-11-27 16:40 ` Boris Brezillon
2014-11-27 19:15 ` Maxime Ripard
2014-11-20 15:55 ` [PATCH 4/9] rc: sunxi-cir: Add support for an optional reset controller Hans de Goede
2014-11-20 16:28 ` Mauro Carvalho Chehab
[not found] ` <20141120142831.003fb63e-+RedX5hVuTR+urZeOPWqwQ@public.gmane.org>
2014-11-21 8:51 ` Maxime Ripard
[not found] ` <1416498928-1300-5-git-send-email-hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2014-11-20 23:05 ` Julian Calaby
2014-11-20 15:55 ` [PATCH 5/9] rc: sunxi-cir: Add support for the larger fifo found on sun5i and sun6i Hans de Goede
2014-11-20 16:28 ` Mauro Carvalho Chehab
2014-11-21 8:26 ` Maxime Ripard
2014-11-21 8:42 ` Hans de Goede
[not found] ` <546EFAE1.9050506-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2014-11-21 9:59 ` Maxime Ripard
2014-11-21 10:13 ` Hans de Goede
[not found] ` <546F103D.6050004-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2014-11-23 15:47 ` Maxime Ripard
2014-11-20 15:55 ` [PATCH 6/9] ARM: dts: sun6i: Add ir_clk node Hans de Goede
2014-11-20 15:55 ` [PATCH 7/9] ARM: dts: sun6i: Add ir node Hans de Goede
2014-11-20 15:55 ` [PATCH 8/9] ARM: dts: sun6i: Add pinmux settings for the ir pins Hans de Goede
2014-11-20 15:55 ` [PATCH 9/9] ARM: dts: sun6i: Enable ir receiver on the Mele M9 Hans de Goede
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=546F0226.2040700@redhat.com \
--to=hdegoede-h+wxahxf7alqt0dzr+alfa@public.gmane.org \
--cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=emilio-0Z03zUJReD5OxF6Tv1QG9Q@public.gmane.org \
--cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=linux-media-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-sunxi-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org \
--cc=maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org \
--cc=mturquette-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).