Skip to contentSkip to conversation

clk: keystone: sci-clk: Adding support for non contiguous clocks

PATCH Superseded Udit Kumar 4 participants 13 messages Feb 6, 2024 – Feb 7, 2024

Subsystems (3)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Udit Kumar

author
#0 lore raw

PATCH v2 1/1 clk: keystone: sci-clk: Adding support for non contiguous clocks

Most of clocks and their parents are defined in contiguous range, But in few cases, there is gap in clock numbers[0]. Driver assumes clocks to be in contiguous range, and add their clock ids incrementally.

New firmware started returning error while calling get_freq and is_on API for non-available clock ids.

In this fix, driver checks and adds only valid clock ids.

Fixes 3c13933c6033 ("clk: keystone: sci-clk: add support for dynamically probing clocks")

[0] https://software-dl.ti.com/tisci/esd/latest/5_soc_doc/j7200/clocks.html
Section Clocks for NAVSS0_CPTS_0 Device,
clock id 12-15 not present.

---
Changelog

Changes in v2
- Updated commit message
- Simplified logic for valid clock id
link to v1 https://lore.kernel.org/all/[email protected]/

P.S
Firmawre returns total num_parents count including non available ids. For above device id NAVSS0_CPTS_0, number of parents clocks are 16 i.e from id 2 to 17. But out of these ids few are not valid. So driver adds only valid clock ids out ot total.

Original logs
https://gist.github.com/uditkumarti/de4b36b21247fb36725ad909ce4812f6#file-original-logs
Line 2630 for error

Logs with fix v2
https://gist.github.com/uditkumarti/94e3e28d62282fd708dbfe37435ce1d9
Line 2591

 drivers/clk/keystone/sci-clk.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/clk/keystone/sci-clk.c +10 -2
index 35fe197dd303..ff249cbd54a1 100644
@@ -517,6 +517,7 @@ static int ti_sci_scan_clocks_from_dt(struct sci_clk_provider *provider)
 	int num_clks = 0;
 	int num_parents;
 	int clk_id;
+	u64 freq;
 	const char * const clk_names[] = {
 		"clocks", "assigned-clocks", "assigned-clock-parents", NULL
 	};
@@ -586,16 +587,23 @@ static int ti_sci_scan_clocks_from_dt(struct sci_clk_provider *provider)
 				clk_id = args.args[1] + 1;
 
 				while (num_parents--) {
+					/* Check if this clock id is valid */
+					ret = provider->ops->get_freq(provider->sci,
+						sci_clk->dev_id, clk_id, &freq);
+
+					clk_id++;
+					if (ret)
+						continue;
+
 					sci_clk = devm_kzalloc(dev,
 							       sizeof(*sci_clk),
 							       GFP_KERNEL);
 					if (!sci_clk)
 						return -ENOMEM;
 					sci_clk->dev_id = args.args[0];
-					sci_clk->clk_id = clk_id++;
+					sci_clk->clk_id = clk_id - 1;
 					sci_clk->provider = provider;
 					list_add_tail(&sci_clk->node, &clks);
-
 					num_clks++;
 				}
 			}
Signature · 1 line
2.34.1
maintainer
#1 lore raw
Quoted 57 lines · Udit Kumar

Most of clocks and their parents are defined in contiguous range, But in few cases, there is gap in clock numbers[0]. Driver assumes clocks to be in contiguous range, and add their clock ids incrementally.

New firmware started returning error while calling get_freq and is_on API for non-available clock ids.

In this fix, driver checks and adds only valid clock ids.

Fixes 3c13933c6033 ("clk: keystone: sci-clk: add support for dynamically probing clocks")

[0] https://software-dl.ti.com/tisci/esd/latest/5_soc_doc/j7200/clocks.html
Section Clocks for NAVSS0_CPTS_0 Device,
clock id 12-15 not present.

---
Changelog

Changes in v2
- Updated commit message
- Simplified logic for valid clock id
link to v1 https://lore.kernel.org/all/[email protected]/

P.S
Firmawre returns total num_parents count including non available ids. For above device id NAVSS0_CPTS_0, number of parents clocks are 16 i.e from id 2 to 17. But out of these ids few are not valid. So driver adds only valid clock ids out ot total.

Original logs
https://gist.github.com/uditkumarti/de4b36b21247fb36725ad909ce4812f6#file-original-logs
Line 2630 for error

Logs with fix v2
https://gist.github.com/uditkumarti/94e3e28d62282fd708dbfe37435ce1d9
Line 2591

 drivers/clk/keystone/sci-clk.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/clk/keystone/sci-clk.c +1 -0
index 35fe197dd303..ff249cbd54a1 100644
@@ -517,6 +517,7 @@ static int ti_sci_scan_clocks_from_dt(struct sci_clk_provider *provider)
 	int num_clks = 0;
 	int num_parents;
 	int clk_id;
+	u64 freq;
 	const char * const clk_names[] = {
 		"clocks", "assigned-clocks", "assigned-clock-parents", NULL
 	};

drivers/clk/keystone/sci-clk.c static int ti_sci_scan_clocks_from_dt(struct sci_clk_provider *provider) · line 592

Quoted 6 lines
drivers/clk/keystone/sci-clk.c +3 -0
@@ -586,16 +587,23 @@ static int ti_sci_scan_clocks_from_dt(struct sci_clk_provider *provider)
 				clk_id = args.args[1] + 1;
 
 				while (num_parents--) {
+					/* Check if this clock id is valid */
+					ret = provider->ops->get_freq(provider->sci,
+						sci_clk->dev_id, clk_id, &freq);

get_freq is a bit expensive as it has to walk the clock tree to find the clock frequency (at least the first time?). just wondering if there is lighter alternative here?

Quoted 6 lines
drivers/clk/keystone/sci-clk.c +5 -0
+
+					clk_id++;
+					if (ret)
+						continue;
+
 					sci_clk = devm_kzalloc(dev,

drivers/clk/keystone/sci-clk.c static int ti_sci_scan_clocks_from_dt(struct sci_clk_provider *provider) · line 598

Quoted 10 lines
drivers/clk/keystone/sci-clk.c +1 -2
 							       sizeof(*sci_clk),
 							       GFP_KERNEL);
 					if (!sci_clk)
 						return -ENOMEM;
 					sci_clk->dev_id = args.args[0];
-					sci_clk->clk_id = clk_id++;
+					sci_clk->clk_id = clk_id - 1;
 					sci_clk->provider = provider;
 					list_add_tail(&sci_clk->node, &clks);
-

Spurious change.

Quoted 6 lines
drivers/clk/keystone/sci-clk.c +0 -0
 					num_clks++;
 				}
 			}
Signature · 1 line
2.34.1
Signature · 3 lines
Regards,
Nishanth Menon
Key (0xDDB5849D1736249D) / Fingerprint: F8A2 8693 54EB 8232 17A3  1A34 DDB5 849D 1736 249D
#2 lore raw
Quoted 17 lines · Nishanth Menon
Quoted 16 lines · Udit Kumar

Most of clocks and their parents are defined in contiguous range, But in few cases, there is gap in clock numbers[0]. Driver assumes clocks to be in contiguous range, and add their clock ids incrementally.

New firmware started returning error while calling get_freq and is_on API for non-available clock ids.

In this fix, driver checks and adds only valid clock ids.

Fixes 3c13933c6033 ("clk: keystone: sci-clk: add support for dynamically probing clocks")

[0] https://software-dl.ti.com/tisci/esd/latest/5_soc_doc/j7200/clocks.html
Section Clocks for NAVSS0_CPTS_0 Device,
clock id 12-15 not present.

Quoted 10 lines

drivers/clk/keystone/sci-clk.c static int ti_sci_scan_clocks_from_dt(struct sci_clk_provider *provider) · line 592

Quoted 5 lines
drivers/clk/keystone/sci-clk.c +3 -0
 				while (num_parents--) {
+					/* Check if this clock id is valid */
+					ret = provider->ops->get_freq(provider->sci,
+						sci_clk->dev_id, clk_id, &freq);

get_freq is a bit expensive as it has to walk the clock tree to find the clock frequency (at least the first time?). just wondering if there is lighter alternative here?

How about get_clock? Doesn't read the registers at least.

Regards,
Kamlesh

#11 lore raw
In reply to Nishanth Menon
Quoted 60 lines · Nishanth Menon
Quoted 59 lines · Udit Kumar

Most of clocks and their parents are defined in contiguous range, But in few cases, there is gap in clock numbers[0]. Driver assumes clocks to be in contiguous range, and add their clock ids incrementally.

New firmware started returning error while calling get_freq and is_on API for non-available clock ids.

In this fix, driver checks and adds only valid clock ids.

Fixes 3c13933c6033 ("clk: keystone: sci-clk: add support for dynamically probing clocks")

[0] https://software-dl.ti.com/tisci/esd/latest/5_soc_doc/j7200/clocks.html
Section Clocks for NAVSS0_CPTS_0 Device,
clock id 12-15 not present.

---
Changelog

Changes in v2
- Updated commit message
- Simplified logic for valid clock id
link to v1 https://lore.kernel.org/all/[email protected]/

P.S
Firmawre returns total num_parents count including non available ids. For above device id NAVSS0_CPTS_0, number of parents clocks are 16 i.e from id 2 to 17. But out of these ids few are not valid. So driver adds only valid clock ids out ot total.

Original logs
https://gist.github.com/uditkumarti/de4b36b21247fb36725ad909ce4812f6#file-original-logs
Line 2630 for error

Logs with fix v2
https://gist.github.com/uditkumarti/94e3e28d62282fd708dbfe37435ce1d9
Line 2591

  drivers/clk/keystone/sci-clk.c | 12 ++++++++++--
  1 file changed, 10 insertions(+), 2 deletions(-)
drivers/clk/keystone/sci-clk.c +1 -0
index 35fe197dd303..ff249cbd54a1 100644
@@ -517,6 +517,7 @@ static int ti_sci_scan_clocks_from_dt(struct sci_clk_provider *provider)
  	int num_clks = 0;
  	int num_parents;
  	int clk_id;
+	u64 freq;
  	const char * const clk_names[] = {
  		"clocks", "assigned-clocks", "assigned-clock-parents", NULL
  	};
@@ -586,16 +587,23 @@ static int ti_sci_scan_clocks_from_dt(struct sci_clk_provider *provider)
  				clk_id = args.args[1] + 1;
 
Quoted 7 lines

drivers/clk/keystone/sci-clk.c static int ti_sci_scan_clocks_from_dt(struct sci_clk_provider *provider) · line 592

Quoted 4 lines
drivers/clk/keystone/sci-clk.c +3 -0
  				while (num_parents--) {
+					/* Check if this clock id is valid */
+					ret = provider->ops->get_freq(provider->sci,
+						sci_clk->dev_id, clk_id, &freq);

get_freq is a bit expensive as it has to walk the clock tree to find the clock frequency (at least the first time?). just wondering if there is lighter alternative here?

Let me check , if we have some other alternative here

Quoted 9 lines
Quoted 9 lines
drivers/clk/keystone/sci-clk.c +5 -0
+
+					clk_id++;
+					if (ret)
+						continue;
+
  					sci_clk = devm_kzalloc(dev,
  							       sizeof(*sci_clk),
  							       GFP_KERNEL);
  					if (!sci_clk)
Quoted 8 lines

drivers/clk/keystone/sci-clk.c static int ti_sci_scan_clocks_from_dt(struct sci_clk_provider *provider) · line 598

Quoted 7 lines
drivers/clk/keystone/sci-clk.c +1 -2
  						return -ENOMEM;
  					sci_clk->dev_id = args.args[0];
-					sci_clk->clk_id = clk_id++;
+					sci_clk->clk_id = clk_id - 1;
  					sci_clk->provider = provider;
  					list_add_tail(&sci_clk->node, &clks);
-

Spurious change.

I think, you meant by deleting the line ?

If yes then will address in next version

Quoted 6 lines
Quoted 6 lines
drivers/clk/keystone/sci-clk.c +0 -0
  					num_clks++;
  				}
  			}
Signature · 1 line
2.34.1
#3 lore raw
In reply to Kamlesh Gurudasani
Quoted 28 lines · Kamlesh Gurudasani
Quoted 17 lines · Nishanth Menon
Quoted 16 lines · Udit Kumar

Most of clocks and their parents are defined in contiguous range, But in few cases, there is gap in clock numbers[0]. Driver assumes clocks to be in contiguous range, and add their clock ids incrementally.

New firmware started returning error while calling get_freq and is_on API for non-available clock ids.

In this fix, driver checks and adds only valid clock ids.

Fixes 3c13933c6033 ("clk: keystone: sci-clk: add support for dynamically probing clocks")

[0] https://software-dl.ti.com/tisci/esd/latest/5_soc_doc/j7200/clocks.html
Section Clocks for NAVSS0_CPTS_0 Device,
clock id 12-15 not present.

Quoted 9 lines

drivers/clk/keystone/sci-clk.c static int ti_sci_scan_clocks_from_dt(struct sci_clk_provider *provider) · line 592

Quoted 5 lines

while (num_parents--) {

drivers/clk/keystone/sci-clk.c +3 -0
+					/* Check if this clock id is valid */
+					ret = provider->ops->get_freq(provider->sci,
+						sci_clk->dev_id, clk_id, &freq);

get_freq is a bit expensive as it has to walk the clock tree to find the clock frequency (at least the first time?). just wondering if there is lighter alternative here?

Quoted 1 line

How about get_clock? Doesn't read the registers at least.

Said API needs, some flags to be passed,

Can those flag be set to zero, Chandru ?

Quoted 2 lines

Regards,
Kamlesh

#12 lore raw
In reply to Udit Kumar
Quoted 17 lines · Udit Kumar

Most of clocks and their parents are defined in contiguous range, But in few cases, there is gap in clock numbers[0]. Driver assumes clocks to be in contiguous range, and add their clock ids incrementally.

New firmware started returning error while calling get_freq and is_on API for non-available clock ids.

In this fix, driver checks and adds only valid clock ids.

Fixes 3c13933c6033 ("clk: keystone: sci-clk: add support for dynamically probing clocks")

[0] https://software-dl.ti.com/tisci/esd/latest/5_soc_doc/j7200/clocks.html
Section Clocks for NAVSS0_CPTS_0 Device,
clock id 12-15 not present.

...

drivers/clk/keystone/sci-clk.c static int ti_sci_scan_clocks_from_dt(struct sci_clk_provider *provider) · line 596

Quoted 11 lines
drivers/clk/keystone/sci-clk.c +5 -0
@@ -586,16 +587,23 @@ static int ti_sci_scan_clocks_from_dt(struct sci_clk_provider *provider)
 				clk_id = args.args[1] + 1;
 
 				while (num_parents--) {
+					/* Check if this clock id is valid */
+					ret = provider->ops->get_freq(provider->sci,
+						sci_clk->dev_id, clk_id, &freq);
 
 
+
+					clk_id++;

Why increment it here and subtract if get_freq succeeds (sci_clk->clk_id = clk_id - 1;), rather

if(ret) {
        clk_id++;
        continue;
}

drivers/clk/keystone/sci-clk.c static int ti_sci_scan_clocks_from_dt(struct sci_clk_provider *provider) · line 604

Quoted 12 lines
drivers/clk/keystone/sci-clk.c +4 -1
+					if (ret)
+						continue;
 
+
 					sci_clk = devm_kzalloc(dev,
 							       sizeof(*sci_clk),
 							       GFP_KERNEL);
 					if (!sci_clk)
 						return -ENOMEM;
 					sci_clk->dev_id = args.args[0];
-					sci_clk->clk_id = clk_id++;
+					sci_clk->clk_id = clk_id - 1;

and keep sci_clk->clk_id = clk_id++; intact

saves one subtraction

or even better

- clk_id = args.args[1] + 1;
+ clk_id = args.args[1];
while (num_parents--) {
+ /* Check if this clock id is valid */
+ ret = provider->ops->get_freq(provider->sci,
+ sci_clk->dev_id, ++clk_id, &freq);

and then no increments after, for clk_id

Regards,
Kamlesh

#4 lore raw
In reply to Kumar, Udit
Quoted 31 lines · Udit
Quoted 29 lines · Kamlesh Gurudasani
Quoted 27 lines · Nishanth Menon
Quoted 14 lines · Udit Kumar

Most of clocks and their parents are defined in contiguous range, But in few cases, there is gap in clock numbers[0]. Driver assumes clocks to be in contiguous range, and add their clock ids incrementally.

New firmware started returning error while calling get_freq and is_on API for non-available clock ids.

In this fix, driver checks and adds only valid clock ids.

Fixes 3c13933c6033 ("clk: keystone: sci-clk: add support for dynamically probing clocks")

[0] https://software-dl.ti.com/tisci/esd/latest/5_soc_doc/j7200/clocks.html

Quoted 8 lines

Section Clocks for NAVSS0_CPTS_0 Device,
clock id 12-15 not present.

                  while (num_parents--) {
+                    /* Check if this clock id is valid */ +                    ret = provider->ops->get_freq(provider->sci, +                        sci_clk->dev_id, clk_id, &freq);

get_freq is a bit expensive as it has to walk the clock tree to find the clock frequency (at least the first time?). just wondering if there is lighter alternative here?

Quoted 5 lines
Quoted 1 line

How about get_clock? Doesn't read the registers at least.

Said API needs, some flags to be passed,

Can those flag be set to zero, Chandru ?

get_clock doesn't require any flags to be passed.

Quoted 4 lines
Quoted 4 lines

Regards,
Kamlesh

#5 lore raw
Quoted 33 lines · CHANDRU DHAVAMANI
Quoted 31 lines · Udit
Quoted 29 lines · Kamlesh Gurudasani
Quoted 27 lines · Nishanth Menon
Quoted 14 lines · Udit Kumar

Most of clocks and their parents are defined in contiguous range, But in few cases, there is gap in clock numbers[0]. Driver assumes clocks to be in contiguous range, and add their clock ids incrementally.

New firmware started returning error while calling get_freq and is_on API for non-available clock ids.

In this fix, driver checks and adds only valid clock ids.

Fixes 3c13933c6033 ("clk: keystone: sci-clk: add support for dynamically probing clocks")

[0] https://software-dl.ti.com/tisci/esd/latest/5_soc_doc/j7200/clocks.html

Quoted 8 lines

Section Clocks for NAVSS0_CPTS_0 Device,
clock id 12-15 not present.

                  while (num_parents--) {
+                    /* Check if this clock id is valid */ +                    ret = provider->ops->get_freq(provider->sci, +                        sci_clk->dev_id, clk_id, &freq);

get_freq is a bit expensive as it has to walk the clock tree to find the clock frequency (at least the first time?). just wondering if there is lighter alternative here?

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

How about get_clock? Doesn't read the registers at least.

Said API needs, some flags to be passed,

Can those flag be set to zero, Chandru ?

get_clock doesn't require any flags to be passed.

May be firmware does not need it but  I was referring to

https://elixir.bootlin.com/linux/latest/source/drivers/clk/keystone/sci-clk.c#L78

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

Regards,
Kamlesh

#6 lore raw
Quoted 11 lines · Udit
Quoted 11 lines
Quoted 9 lines
Quoted 5 lines
Quoted 4 lines

get_freq is a bit expensive as it has to walk the clock tree to find the clock frequency (at least the first time?). just wondering if there is lighter alternative here?

How about get_clock? Doesn't read the registers at least.

Said API needs, some flags to be passed,

Can those flag be set to zero, Chandru ?

Quoted 6 lines
Quoted 1 line

get_clock doesn't require any flags to be passed.

May be firmware does not need it but  I was referring to

https://elixir.bootlin.com/linux/latest/source/drivers/clk/keystone/sci-clk.c#L78

Just took a look,

I now understand the reason for confusion,

#define TI_SCI_MSG_SET_CLOCK_STATE 0x0100
#define TI_SCI_MSG_GET_CLOCK_STATE 0x0101

cops->get_clock = ti_sci_cmd_get_clock; --> refers to TI_SCI_MSG_SET_CLOCK_STATE
That's why we are passing the flag from linux for get_clock

Linux is using terminology of get/put.

As Chandru pointed, we don't have to pass flags, cause he is refering to TI_SCI_MSG_GET_CLOCK_STATE

Below functions passes TI_SCI_MSG_GET_CLOCK_STATE to DM, which is what we actually want.
cops->is_auto = ti_sci_cmd_clk_is_auto;
cops->is_on = ti_sci_cmd_clk_is_on;
cops->is_off = ti_sci_cmd_clk_is_off;

Which should be safe to call, Chandru can confirm.

Regards,
Kamlesh

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

Regards,
Kamlesh

#7 lore raw
Quoted 29 lines · Kamlesh Gurudasani
Quoted 7 lines · Udit
Quoted 7 lines
Quoted 7 lines
Quoted 5 lines
Quoted 4 lines

get_freq is a bit expensive as it has to walk the clock tree to find the clock frequency (at least the first time?). just wondering if there is lighter alternative here?

How about get_clock? Doesn't read the registers at least.

Said API needs, some flags to be passed,

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Can those flag be set to zero, Chandru ?

get_clock doesn't require any flags to be passed.

May be firmware does not need it but  I was referring to

https://elixir.bootlin.com/linux/latest/source/drivers/clk/keystone/sci-clk.c#L78

Just took a look,

I now understand the reason for confusion,

#define TI_SCI_MSG_SET_CLOCK_STATE 0x0100
#define TI_SCI_MSG_GET_CLOCK_STATE 0x0101

cops->get_clock = ti_sci_cmd_get_clock; --> refers to TI_SCI_MSG_SET_CLOCK_STATE
That's why we are passing the flag from linux for get_clock

Linux is using terminology of get/put.

Quoted 8 lines

As Chandru pointed, we don't have to pass flags, cause he is refering to TI_SCI_MSG_GET_CLOCK_STATE

Below functions passes TI_SCI_MSG_GET_CLOCK_STATE to DM, which is what we actually want.
cops->is_auto = ti_sci_cmd_clk_is_auto;
cops->is_on = ti_sci_cmd_clk_is_on;
cops->is_off = ti_sci_cmd_clk_is_off;

I think calling ti_sci_cmd_clk_is_auto should be good . other functions needs current state and requested state.

Chandru ?

Quoted 11 lines

Which should be safe to call, Chandru can confirm.

Regards,
Kamlesh

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

Regards,
Kamlesh

#8 lore raw
Quoted 42 lines · Udit
Quoted 30 lines · Kamlesh Gurudasani
Quoted 7 lines · Udit
Quoted 7 lines
Quoted 7 lines
Quoted 5 lines
Quoted 4 lines

get_freq is a bit expensive as it has to walk the clock tree to find the clock frequency (at least the first time?). just wondering if there is lighter alternative here?

How about get_clock? Doesn't read the registers at least.

Said API needs, some flags to be passed,

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

Can those flag be set to zero, Chandru ?

get_clock doesn't require any flags to be passed.

May be firmware does not need it but  I was referring to

https://elixir.bootlin.com/linux/latest/source/drivers/clk/keystone/sci-clk.c#L78

Just took a look,

I now understand the reason for confusion,

#define TI_SCI_MSG_SET_CLOCK_STATE    0x0100
#define TI_SCI_MSG_GET_CLOCK_STATE    0x0101

cops->get_clock = ti_sci_cmd_get_clock;  --> refers to TI_SCI_MSG_SET_CLOCK_STATE
That's why we are passing the flag from linux for get_clock

Linux is using terminology of get/put.

Quoted 8 lines

As Chandru pointed, we don't have to pass flags, cause he is refering to TI_SCI_MSG_GET_CLOCK_STATE

Below functions passes TI_SCI_MSG_GET_CLOCK_STATE to DM, which is what we actually want.
cops->is_auto = ti_sci_cmd_clk_is_auto;
cops->is_on = ti_sci_cmd_clk_is_on;
cops->is_off = ti_sci_cmd_clk_is_off;

Quoted 4 lines

I think calling ti_sci_cmd_clk_is_auto should be good . other functions needs current state and requested state.

Chandru ?

ti_sci_cmd_clk_is_auto is internal function to linux.
For TI_SCI_MSG_GET_CLOCK_STATE, linux only needs to pass pointers to the variables where result will be stored.

Quoted 11 lines
Quoted 11 lines

Which should be safe to call, Chandru can confirm.

Regards,
Kamlesh

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

Regards,
Kamlesh

#9 lore raw
Quoted 44 lines · CHANDRU DHAVAMANI
Quoted 42 lines · Udit
Quoted 38 lines · Kamlesh Gurudasani
Quoted 7 lines · Udit
Quoted 7 lines
Quoted 7 lines
Quoted 5 lines
Quoted 4 lines

get_freq is a bit expensive as it has to walk the clock tree to find the clock frequency (at least the first time?). just wondering if there is lighter alternative here?

How about get_clock? Doesn't read the registers at least.

Said API needs, some flags to be passed,

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

Can those flag be set to zero, Chandru ?

get_clock doesn't require any flags to be passed.

May be firmware does not need it but  I was referring to

https://elixir.bootlin.com/linux/latest/source/drivers/clk/keystone/sci-clk.c#L78

Just took a look,

I now understand the reason for confusion,

#define TI_SCI_MSG_SET_CLOCK_STATE    0x0100
#define TI_SCI_MSG_GET_CLOCK_STATE    0x0101

cops->get_clock = ti_sci_cmd_get_clock;  --> refers to TI_SCI_MSG_SET_CLOCK_STATE
That's why we are passing the flag from linux for get_clock

Linux is using terminology of get/put.

As Chandru pointed, we don't have to pass flags, cause he is refering to TI_SCI_MSG_GET_CLOCK_STATE

Below functions passes TI_SCI_MSG_GET_CLOCK_STATE to DM, which is what we actually want.
cops->is_auto = ti_sci_cmd_clk_is_auto;
cops->is_on = ti_sci_cmd_clk_is_on;
cops->is_off = ti_sci_cmd_clk_is_off;

Quoted 7 lines
Quoted 4 lines

I think calling ti_sci_cmd_clk_is_auto should be good . other functions needs current state and requested state.

Chandru ?

ti_sci_cmd_clk_is_auto is internal function to linux.
For TI_SCI_MSG_GET_CLOCK_STATE, linux only needs to pass pointers to the variables where result will be stored.

Yes this internal function calls TI_SCI_MSG_GET_CLOCK_STATE

Quoted 13 lines
Quoted 13 lines
Quoted 13 lines

Which should be safe to call, Chandru can confirm.

Regards,
Kamlesh

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

Regards,
Kamlesh

#10 lore raw
Quoted 48 lines · Udit
Quoted 46 lines · CHANDRU DHAVAMANI
Quoted 44 lines · Udit
Quoted 30 lines · Kamlesh Gurudasani
Quoted 7 lines · Udit
Quoted 7 lines
Quoted 7 lines
Quoted 5 lines
Quoted 4 lines

get_freq is a bit expensive as it has to walk the clock tree to find the clock frequency (at least the first time?). just wondering if there is lighter alternative here?

How about get_clock? Doesn't read the registers at least.

Said API needs, some flags to be passed,

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

Can those flag be set to zero, Chandru ?

get_clock doesn't require any flags to be passed.

May be firmware does not need it but  I was referring to

https://elixir.bootlin.com/linux/latest/source/drivers/clk/keystone/sci-clk.c#L78

Just took a look,

I now understand the reason for confusion,

#define TI_SCI_MSG_SET_CLOCK_STATE    0x0100
#define TI_SCI_MSG_GET_CLOCK_STATE    0x0101

cops->get_clock = ti_sci_cmd_get_clock;  --> refers to TI_SCI_MSG_SET_CLOCK_STATE
That's why we are passing the flag from linux for get_clock

Linux is using terminology of get/put.

Quoted 8 lines

As Chandru pointed, we don't have to pass flags, cause he is refering to TI_SCI_MSG_GET_CLOCK_STATE

Below functions passes TI_SCI_MSG_GET_CLOCK_STATE to DM, which is what we actually want.
cops->is_auto = ti_sci_cmd_clk_is_auto;
cops->is_on = ti_sci_cmd_clk_is_on;
cops->is_off = ti_sci_cmd_clk_is_off;

I think calling ti_sci_cmd_clk_is_auto should be good . other functions needs current state and requested state.

Quoted 9 lines
Quoted 5 lines
Quoted 2 lines

Chandru ?

ti_sci_cmd_clk_is_auto is internal function to linux.
For TI_SCI_MSG_GET_CLOCK_STATE, linux only needs to pass pointers to the variables where result will be stored.

Yes this internal function calls TI_SCI_MSG_GET_CLOCK_STATE

Okay. We can use TI_SCI_MSG_GET_CLOCK_STATE to check to if clock is valid or not.

Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines

Which should be safe to call, Chandru can confirm.

Regards,
Kamlesh

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

Regards,
Kamlesh