RE: [PATCH] drivers: clk: zynqmp: remove clock name dependency

From: Stephen Boyd
Date: Thu Apr 11 2024 - 00:18:01 EST


Quoting Trivedi Manojbhai, Naman (2024-03-26 22:47:28)
> >>Quoting Naman Trivedi Manojbhai (2024-01-02 23:20:17)
> >>> Currently, from zynqmp_get_parent_list() function the clock driver
> >>> references the clock by name instead of its reference from device tree.
> >>> This causes problem when the clock name in the device tree is changed.
> >>>
> >>> Remove hard dependency of clock name and update the logic to use
> >>> clock reference from device tree instead of clock name.
> >>
> >>Please use struct clk_parent_data instead.
> >Thanks for review. As per my understanding, you suggest to replace the
> >proposed logic, and use "struct clk_parent_data" to get the clock name from
> >device tree.

No, do not get the clock name of a parent in the driver. Use struct
clk_parent_data to tell the clk framework what the parent is.

> >
> >I have gone through other drivers which use the "struct clk_parent_data"
> >structure, they have hard coded clock names in the driver. In zynqmp, the
> >driver receives clock name from firmware.

Don't use a string name. The devicetree index must be stable, so simply
use the index that the binding has as the index in struct
clk_parent_data.

struct clk_parent_data parent_map[] = {
{ .index = MY_DT_PARENT_1 }, /* parent index 0 */
{ .index = MT_DT_PARENT_2 }, /* parent index 1 */
};

> >
> >Also, the "zynqmp_get_parent_list" function is called before clocks are
> >registered. So at this point, we don't have the hw structure which has
> >clk_parent_data.

I guess that's a problem with how the code is written?

> >
> >So, I did not get how to use the struct clk_parent_data in this case. Can you
> >please provide an example which I can look at as a reference?
> >

There are many references. A new qcom one is drivers/clk/qcom/gcc-x1e80100.c