Message ID | 20200417221730.555954-2-plaes@plaes.org (mailing list archive) |
---|---|
State | Changes Requested, archived |
Headers | show |
Series | ARM: sun7i: Convert A20 GMAC driver to CCU | expand |
On Sat, Apr 18, 2020 at 01:17:27AM +0300, Priit Laes wrote: > In order to register regmap for sun7i CCU, there needs to be > a device structure already bound to the CCU device node. > > Convert the sun4i/sun7i CCU setup to platform driver to use > it later as platform device. > > Signed-off-by: Priit Laes <plaes@plaes.org> You can't relly do that though. We have timers that need those clocks before the device model is initialized. Maxime
On Mon, Apr 20, 2020 at 02:49:35PM +0200, Maxime Ripard wrote: > On Sat, Apr 18, 2020 at 01:17:27AM +0300, Priit Laes wrote: > > In order to register regmap for sun7i CCU, there needs to be > > a device structure already bound to the CCU device node. > > > > Convert the sun4i/sun7i CCU setup to platform driver to use > > it later as platform device. > > > > Signed-off-by: Priit Laes <plaes@plaes.org> > > You can't relly do that though. We have timers that need those clocks before the > device model is initialized. Ok, I'm somewhat lost now... are these the affected timers on sun7i following: - allwinner,sun4i-a10-timer (timer@1c20c00) - allwinner,sun7i-a20-hstimer (hstimer@1c60000) Any ideas on what approach I could actually use? Also, similar timer dependency would affect then sun6i-a31 and sun9i-a80 platforms too... > > Maxime
Hi, On Mon, Apr 20, 2020 at 08:32:28PM +0000, Priit Laes wrote: > On Mon, Apr 20, 2020 at 02:49:35PM +0200, Maxime Ripard wrote: > > On Sat, Apr 18, 2020 at 01:17:27AM +0300, Priit Laes wrote: > > > In order to register regmap for sun7i CCU, there needs to be > > > a device structure already bound to the CCU device node. > > > > > > Convert the sun4i/sun7i CCU setup to platform driver to use > > > it later as platform device. > > > > > > Signed-off-by: Priit Laes <plaes@plaes.org> > > > > You can't relly do that though. We have timers that need those clocks before the > > device model is initialized. > > Ok, I'm somewhat lost now... are these the affected timers on sun7i following: > - allwinner,sun4i-a10-timer (timer@1c20c00) > - allwinner,sun7i-a20-hstimer (hstimer@1c60000) Yep > Any ideas on what approach I could actually use? I guess you could keep the CLK_OF_DECLARE registration, and then have a platform_driver probe and register the regmap? > Also, similar timer dependency would affect then sun6i-a31 and sun9i-a80 > platforms too... Indeed. Maxime
On Wed, Apr 29, 2020 at 04:35:10PM +0200, Maxime Ripard wrote: > Hi, > > On Mon, Apr 20, 2020 at 08:32:28PM +0000, Priit Laes wrote: > > On Mon, Apr 20, 2020 at 02:49:35PM +0200, Maxime Ripard wrote: > > > On Sat, Apr 18, 2020 at 01:17:27AM +0300, Priit Laes wrote: > > > > In order to register regmap for sun7i CCU, there needs to be > > > > a device structure already bound to the CCU device node. > > > > > > > > Convert the sun4i/sun7i CCU setup to platform driver to use > > > > it later as platform device. > > > > > > > > Signed-off-by: Priit Laes <plaes@plaes.org> > > > > > > You can't relly do that though. We have timers that need those clocks before the > > > device model is initialized. > > > > Ok, I'm somewhat lost now... are these the affected timers on sun7i following: > > - allwinner,sun4i-a10-timer (timer@1c20c00) > > - allwinner,sun7i-a20-hstimer (hstimer@1c60000) > > Yep > > > Any ideas on what approach I could actually use? > > I guess you could keep the CLK_OF_DECLARE registration, and then have a > platform_driver probe and register the regmap? > Thanks this did the trick. > > Also, similar timer dependency would affect then sun6i-a31 and sun9i-a80 > > platforms too... I didn't check this before, but sun9i-a80 CCU is initialized currently via platform device. Should it be converted first to clock driver (CLK_OF_DECLARE)? I have sent out the v2 which contains sun7i/sun6i changes. > > Indeed. > > Maxime
On Thu, Apr 30, 2020 at 06:21:37AM +0000, Priit Laes wrote: > On Wed, Apr 29, 2020 at 04:35:10PM +0200, Maxime Ripard wrote: > > On Mon, Apr 20, 2020 at 08:32:28PM +0000, Priit Laes wrote: > > > On Mon, Apr 20, 2020 at 02:49:35PM +0200, Maxime Ripard wrote: > > > > On Sat, Apr 18, 2020 at 01:17:27AM +0300, Priit Laes wrote: > > > > > In order to register regmap for sun7i CCU, there needs to be > > > > > a device structure already bound to the CCU device node. > > > > > > > > > > Convert the sun4i/sun7i CCU setup to platform driver to use > > > > > it later as platform device. > > > > > > > > > > Signed-off-by: Priit Laes <plaes@plaes.org> > > > > > > > > You can't relly do that though. We have timers that need those clocks before the > > > > device model is initialized. > > > > > > Ok, I'm somewhat lost now... are these the affected timers on sun7i following: > > > - allwinner,sun4i-a10-timer (timer@1c20c00) > > > - allwinner,sun7i-a20-hstimer (hstimer@1c60000) > > > > Yep > > > > > Any ideas on what approach I could actually use? > > > > I guess you could keep the CLK_OF_DECLARE registration, and then have a > > platform_driver probe and register the regmap? > > > > Thanks this did the trick. > > > > Also, similar timer dependency would affect then sun6i-a31 and sun9i-a80 > > > platforms too... > > I didn't check this before, but sun9i-a80 CCU is initialized currently via > platform device. Should it be converted first to clock driver (CLK_OF_DECLARE)? I guess we could just remove the timer node on the A80. It has never been tested and never worked if the clock driver is probed through a platform device. Maxime
diff --git a/drivers/clk/sunxi-ng/ccu-sun4i-a10.c b/drivers/clk/sunxi-ng/ccu-sun4i-a10.c index f32366d9336e..839e9d5a1cff 100644 --- a/drivers/clk/sunxi-ng/ccu-sun4i-a10.c +++ b/drivers/clk/sunxi-ng/ccu-sun4i-a10.c @@ -7,7 +7,8 @@ #include <linux/clk-provider.h> #include <linux/io.h> -#include <linux/of_address.h> +#include <linux/platform_device.h> +#include <linux/regmap.h> #include "ccu_common.h" #include "ccu_reset.h" @@ -1425,19 +1426,10 @@ static const struct sunxi_ccu_desc sun7i_a20_ccu_desc = { .num_resets = ARRAY_SIZE(sunxi_a10_a20_ccu_resets), }; -static void __init sun4i_ccu_init(struct device_node *node, - const struct sunxi_ccu_desc *desc) +static void bootstrap_clocks(void __iomem *reg) { - void __iomem *reg; u32 val; - reg = of_io_request_and_map(node, 0, of_node_full_name(node)); - if (IS_ERR(reg)) { - pr_err("%s: Could not map the clock registers\n", - of_node_full_name(node)); - return; - } - val = readl(reg + SUN4I_PLL_AUDIO_REG); /* @@ -1463,20 +1455,63 @@ static void __init sun4i_ccu_init(struct device_node *node, val = readl(reg + SUN4I_AHB_REG); val &= ~GENMASK(7, 6); writel(val | (2 << 6), reg + SUN4I_AHB_REG); - - sunxi_ccu_probe(node, reg, desc); } -static void __init sun4i_a10_ccu_setup(struct device_node *node) +static int sun4i_a10_ccu_probe(struct platform_device *pdev) { - sun4i_ccu_init(node, &sun4i_a10_ccu_desc); + struct resource *res; + void __iomem *reg; + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + reg = devm_ioremap_resource(&pdev->dev, res); + if (IS_ERR(reg)) + return PTR_ERR(reg); + + bootstrap_clocks(reg); + + return sunxi_ccu_probe(pdev->dev.of_node, reg, &sun4i_a10_ccu_desc); } -CLK_OF_DECLARE(sun4i_a10_ccu, "allwinner,sun4i-a10-ccu", - sun4i_a10_ccu_setup); -static void __init sun7i_a20_ccu_setup(struct device_node *node) +static int sun7i_a20_ccu_probe(struct platform_device *pdev) { - sun4i_ccu_init(node, &sun7i_a20_ccu_desc); + struct resource *res; + void __iomem *reg; + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + reg = devm_ioremap_resource(&pdev->dev, res); + if (IS_ERR(reg)) + return PTR_ERR(reg); + + bootstrap_clocks(reg); + + return sunxi_ccu_probe(pdev->dev.of_node, reg, &sun7i_a20_ccu_desc); } -CLK_OF_DECLARE(sun7i_a20_ccu, "allwinner,sun7i-a20-ccu", - sun7i_a20_ccu_setup); + + +static const struct of_device_id sun4i_a10_ccu_ids[] = { + { .compatible = "allwinner,sun4i-a10-ccu"}, + { } +}; + +static struct platform_driver sun4i_a10_ccu_driver = { + .probe = sun4i_a10_ccu_probe, + .driver = { + .name = "sun4i-a10-ccu", + .of_match_table = sun4i_a10_ccu_ids, + }, +}; +builtin_platform_driver(sun4i_a10_ccu_driver); + +static const struct of_device_id sun7i_a20_ccu_ids[] = { + { .compatible = "allwinner,sun7i-a20-ccu"}, + { } +}; + +static struct platform_driver sun7i_a20_ccu_driver = { + .probe = sun7i_a20_ccu_probe, + .driver = { + .name = "sun7i-a20-ccu", + .of_match_table = sun7i_a20_ccu_ids, + }, +}; +builtin_platform_driver(sun7i_a20_ccu_driver);
In order to register regmap for sun7i CCU, there needs to be a device structure already bound to the CCU device node. Convert the sun4i/sun7i CCU setup to platform driver to use it later as platform device. Signed-off-by: Priit Laes <plaes@plaes.org> --- drivers/clk/sunxi-ng/ccu-sun4i-a10.c | 77 ++++++++++++++++++++-------- 1 file changed, 56 insertions(+), 21 deletions(-)