@@ -17,17 +17,60 @@
#include <dt-bindings/clock/imx8-clock.h>
#include <dt-bindings/firmware/imx/rsrc.h>
+static int imx_scu_parse_clks_from_dt(struct device *dev,
+ const struct device_node *np)
+{
+ struct clk_hw *hw;
+ const char *name;
+ int clk_type;
+ int rsrc_id;
+ int ret;
+
+ ret = of_property_read_u32(np, "rsrc-id", &rsrc_id);
+ if (ret) {
+ dev_err(dev, "failed to parse rsrc-id\n");
+ return -EINVAL;
+ }
+
+ ret = of_property_read_u32(np, "clk-type", &clk_type);
+ if (ret) {
+ dev_err(dev, "failed to parse clk-type\n");
+ return -EINVAL;
+ }
+
+ ret = of_property_read_string(np, "clock-output-names", &name);
+ if (ret) {
+ dev_err(dev, "failed to parse clock-output-names\n");
+ return -EINVAL;
+ }
+
+ hw = imx_clk_scu(name, rsrc_id, clk_type);
+ if (IS_ERR(hw)) {
+ dev_err(dev, "failed to register clock\n");
+ return -EINVAL;
+ }
+
+ return devm_of_clk_add_hw_provider(dev, of_clk_hw_simple_get, hw);
+}
+
static int imx8qxp_clk_probe(struct platform_device *pdev)
{
struct device_node *ccm_node = pdev->dev.of_node;
struct clk_hw_onecell_data *clk_data;
struct clk_hw **clks;
+ u32 clock_cells;
int ret, i;
ret = imx_clk_scu_init();
if (ret)
return ret;
+ /* try new binding to parse clocks from device tree first */
+ of_property_read_u32(ccm_node, "#clock-cells", &clock_cells);
+
+ if (clock_cells == 0)
+ return imx_scu_parse_clks_from_dt(&pdev->dev, ccm_node);
+
clk_data = devm_kzalloc(&pdev->dev, struct_size(clk_data, hws,
IMX_SCU_CLK_END), GFP_KERNEL);
if (!clk_data)
add parsing clocks from device tree Cc: Stephen Boyd <sboyd@kernel.org> Cc: Shawn Guo <shawnguo@kernel.org> Cc: Sascha Hauer <kernel@pengutronix.de> Cc: Michael Turquette <mturquette@baylibre.com> Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com> --- drivers/clk/imx/clk-imx8qxp.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+)