From: Simon Glass Date: Mon, 30 Dec 2019 04:19:15 +0000 (-0700) Subject: aspeed: ast2500: Read clock ofdata in the correct method X-Git-Tag: v2020.04-rc1~29^2~17 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=b2b1100a3bef7881ffeb1250a087e40d9672db26;p=oweals%2Fu-boot.git aspeed: ast2500: Read clock ofdata in the correct method At present the clock driver reads its ofdata in the probe() method. This is not correct although it is often harmless. However in this case it causes a problem, something like this: - ast_get_scu() is called (from somewhere) to get the SCI address - this probes the clock - first sets up ofdata (which does nothing at present) - DM marks clock device as active - DM calls pinctrl - pinctrl probes and calls ast_get_scu() in ast2500_pinctrl_probe() - ast_get_scu() probes the clock, but sees it already marked as probed - ast_get_scu() accesses the clock's private data, with scu as NULL - DM calls clock probe function ast2500_clk_probe() which reads scu By putting the read of scu into the correct method, scu is read as part of ofdata setup, and everything is OK. Note: This problem did not matter until now since DM always probed all parents before reading a child's ofdata. The fact that pinctrl is a child of clock seems to trigger this strange bug. Signed-off-by: Simon Glass Reviewed-by: Cédric Le Goater --- diff --git a/drivers/clk/aspeed/clk_ast2500.c b/drivers/clk/aspeed/clk_ast2500.c index 9249cf9cdf..b3a3f3d4dd 100644 --- a/drivers/clk/aspeed/clk_ast2500.c +++ b/drivers/clk/aspeed/clk_ast2500.c @@ -490,7 +490,7 @@ struct clk_ops ast2500_clk_ops = { .enable = ast2500_clk_enable, }; -static int ast2500_clk_probe(struct udevice *dev) +static int ast2500_clk_ofdata_to_platdata(struct udevice *dev) { struct ast2500_clk_priv *priv = dev_get_priv(dev); @@ -525,5 +525,5 @@ U_BOOT_DRIVER(aspeed_ast2500_scu) = { .priv_auto_alloc_size = sizeof(struct ast2500_clk_priv), .ops = &ast2500_clk_ops, .bind = ast2500_clk_bind, - .probe = ast2500_clk_probe, + .ofdata_to_platdata = ast2500_clk_ofdata_to_platdata, };