Tegra: fix clock init
Subsystems (3)
v3 cover Tegra: fix clock init
This should fix https://lore.kernel.org/all/20241201164810.GT3600562@bill-the-cat/T/#m2b62b471fd37e4c9725c98547e2a919cf11db5e5
---
Changes from v2
- adjusted periph clk id check
- restored unconditional debug messages on car functions calls
Changes from v1
- added partially support PLL clocks commit
---
Svyatoslav Ryhel (2):
driver: clk: tegra: partially support PLL clocks
driver: clk: tegra: init basic clocks on probe
drivers/clk/tegra/tegra-car-clk.c | 50 +++++++++++++++++++++++++------ 1 file changed, 41 insertions(+), 9 deletions(-)
Signature · 1 line
2.43.0
PATCH v3 1/2 driver: clk: tegra: partially support PLL clocks
Return PLL id into struct clk if PLL is parsed from device tree instead of throwing an error. Allow requesting PLL clock rate via get_rate op.
--- drivers/clk/tegra/tegra-car-clk.c | 47 +++++++++++++++++++++++++------ 1 file changed, 38 insertions(+), 9 deletions(-)
drivers/clk/tegra/tegra-car-clk.c +38 -9
@@ -10,6 +10,9 @@#include <asm/arch/clock.h> #include <asm/arch-tegra/clk_rst.h> +#define TEGRA_CAR_CLK_PLL BIT(0) +#define TEGRA_CAR_CLK_PERIPH BIT(1) +static int tegra_car_clk_request (struct clk *clk) { debug("%s(clk=%p) (dev=%p, id=%lu)\n", __func__, clk, clk->dev,
@@ -20,24 +23,41 @@ static int tegra_car_clk_request(struct clk *clk)* varies per SoC) are the peripheral clocks, which use a numbering * scheme that matches HW registers 1:1. There are other clock IDs * beyond this that are assigned arbitrarily by the Tegra CAR DT -* binding. Due to the implementation of this driver, it currently -* only supports the peripheral IDs. +* binding. */ -if (clk->id >=PERIPH_ID_COUNT ) -return -EINVAL ; +if (clk->id <PERIPH_ID_COUNT ) { + clk->data |=TEGRA_CAR_CLK_PERIPH ; +return 0 ; + } -return 0 ; +/* If check for periph failed, then check for PLL clock id */ +int id =clk_id_to_pll_id (clk->id); + +if (clock_id_is_pll (id)) { + clk->id = id; + clk->data |=TEGRA_CAR_CLK_PLL ; +return 0 ; + } + +return -EINVAL ; }static ulong tegra_car_clk_get_rate (struct clk *clk) { -enum clock_id parent; -debug ("%s(clk=%p) (dev=%p, id=%lu)\n" , __func__, clk, clk->dev, clk->id); - parent =clock_get_periph_parent (clk->id); -return clock_get_periph_rate (clk->id, parent); +if (clk->data &TEGRA_CAR_CLK_PLL ) +return clock_get_rate (clk->id); + +if (clk->data &TEGRA_CAR_CLK_PERIPH ) { +enum clock_id parent; + + parent =clock_get_periph_parent (clk->id); +return clock_get_periph_rate (clk->id, parent); + } + +return -1U ; }static ulong tegra_car_clk_set_rate (struct clk *clk,ulong rate)
@@ -47,6 +67,9 @@ static ulong tegra_car_clk_set_rate(struct clk *clk, ulong rate)debug ("%s(clk=%p, rate=%lu) (dev=%p, id=%lu)\n" , __func__, clk, rate, clk->dev, clk->id); +if (clk->data &TEGRA_CAR_CLK_PLL ) +return 0 ; + parent =clock_get_periph_parent (clk->id);return clock_adjust_periph_pll_div (clk->id, parent, rate,NULL ); }
@@ -56,6 +79,9 @@ static int tegra_car_clk_enable(struct clk *clk)debug ("%s(clk=%p) (dev=%p, id=%lu)\n" , __func__, clk, clk->dev, clk->id); +if (clk->data &TEGRA_CAR_CLK_PLL ) +return 0 ; +clock_enable (clk->id);return 0 ;
@@ -66,6 +92,9 @@ static int tegra_car_clk_disable(struct clk *clk)debug ("%s(clk=%p) (dev=%p, id=%lu)\n" , __func__, clk, clk->dev, clk->id); +if (clk->data &TEGRA_CAR_CLK_PLL ) +return 0 ; +clock_disable (clk->id);return 0 ;
Signature · 1 line
2.43.0
PATCH v3 2/2 driver: clk: tegra: init basic clocks on probe
In reply to Svyatoslav RyhelIn case DM drivers probe earlier than board clock setup is done init of basic clocks should be done in CAR driver probe as well. Add it to avoid possible clock related problems.
--- drivers/clk/tegra/tegra-car-clk.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/clk/tegra/tegra-car-clk.c +3 -0
@@ -112,6 +112,9 @@ static int tegra_car_clk_probe(struct udevice *dev) {debug ("%s(dev=%p)\n" , __func__, dev); +clock_init (); +clock_verify (); +return 0 ; }
Signature · 1 line
2.43.0
Quoted 2 lines · Svyatoslav Ryhel
This should fix https://lore.kernel.org/all/20241201164810.GT3600562@bill-the-cat/T/#m2b62b471fd37e4c9725c98547e2a919cf11db5e5
Applied to u-boot/master, thanks!
Signature · 1 line
Tom