Skip to content

drivers: firmware: Clock control TISCI driver support #90216

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Kronosblaster
Copy link
Contributor

@Kronosblaster Kronosblaster commented May 20, 2025

Support added for clock control using TISCI added for devices using the binding ti,k2g-sci-clk. This PR waits on #90053

Testing

Refer: ClockControllerTest

Output:

DMSC Firmware Version 11.0.7--v11.00.07 (Fancy Rat)                                                 
DMSC Firmware revision 0xb                                                                          
DMSC ABI revision 4.0                                                                               
                                                                                                    
INFO: Bootloader_runCpu:205: CPU r5f1-0  is initialized to 800000000 Hz !!!                         
INFO: Bootloader_runCpu:205: CPU r5f1-1 is initialized to 800000000 Hz !!!                          
INFO: Bootloader_runCpu:205: CPU m4f0-0 is initialized to 400000000 Hz !!!                          
INFO: Bootloader_runCpu:205: CPU a530-0 is initialized to 800000000 Hz !!!                          
INFO: Bootloader_runCpu:205: CPU a530-1 is initialized to 800000000 Hz !!!                          
INFO: Bootloader_loadSelfCpu:257: CPU r5f0-0 is initialized to 800000000 Hz !!!                     
INFO: Bootloader_loadSelfCpu:257: CPU r5f0-1 is initialized to 800000000 Hz !!!                     
INFO: Bootloader_runSelfCpu:267: All done, reseting self ...                                        
                                                                                                    
*** Booting Zephyr OS build v4.1.0-5562-g50269a5c5de1 ***                                           
Current clock rate: 48000000                                                                        
Clock rate set to 96000000                                                                          
Clock rate set to 48000000                                                                          
Current clock rate after set: 48000000                                                              
All clock controller tests passed! 

@Kronosblaster Kronosblaster force-pushed the clockControl branch 6 times, most recently from 7cf310e to 2dc18ee Compare May 27, 2025 11:17
@Kronosblaster Kronosblaster force-pushed the clockControl branch 2 times, most recently from 8b10b9f to 9ee64d7 Compare June 9, 2025 08:08
@Kronosblaster Kronosblaster force-pushed the clockControl branch 7 times, most recently from 9a47dbf to 20b38b7 Compare June 10, 2025 13:18
@Kronosblaster Kronosblaster marked this pull request as ready for review June 10, 2025 13:19
@github-actions github-actions bot added platform: TI SimpleLink Texas Instruments SimpleLink MCU area: Clock Control labels Jun 10, 2025
@Kronosblaster Kronosblaster force-pushed the clockControl branch 4 times, most recently from 6bd0da6 to 7f1f9bf Compare June 11, 2025 10:38
@vaishnavachath vaishnavachath added the DNM This PR should not be merged (Do Not Merge) label Jun 17, 2025
@Kronosblaster Kronosblaster force-pushed the clockControl branch 3 times, most recently from 2154640 to 20a6a86 Compare June 23, 2025 05:47
Support added for clock control using TISCI for devices using the binding
ti,k2g-sci-clk. This driver relies on the TISCI layer to make calls to the
DMSC core to set and get the clock rate and retrieve clock status.

Signed-off-by: Dave Joseph <d-joseph@ti.com>
Copy link

Comment on lines +31 to +34
#define TISCI_GET_CLOCK_DETAILS(_dev) \
{.dev_id = DT_CLOCKS_CELL(DT_NODELABEL(_dev), devid), \
.clk_id = DT_CLOCKS_CELL(DT_NODELABEL(_dev), clkid)}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#define TISCI_GET_CLOCK_DETAILS(_dev) \
{.dev_id = DT_CLOCKS_CELL(DT_NODELABEL(_dev), devid), \
.clk_id = DT_CLOCKS_CELL(DT_NODELABEL(_dev), clkid)}
#define TISCI_GET_CLOCK_DETAILS(node_id) \
{ \
.dev_id = DT_CLOCKS_CELL(node_id, devid), \
.clk_id = DT_CLOCKS_CELL(node_id, clkid), \
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

#define TISCI_GET_CLOCK_BY_INST(inst) DEVICE_DT_INST_GET(inst)

#define TISCI_GET_CLOCK_DETAILS_BY_INST(inst) \
{.dev_id = DT_INST_CLOCKS_CELL(inst, devid), .clk_id = DT_INST_CLOCKS_CELL(inst, clkid)}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{.dev_id = DT_INST_CLOCKS_CELL(inst, devid), .clk_id = DT_INST_CLOCKS_CELL(inst, clkid)}
TISCI_GET_CLOCK_DETAILS(DT_DRV_INST(inst))

uint32_t clk_id;
};

#define TISCI_GET_CLOCK(_dev) DEVICE_DT_GET(DT_PHANDLE(DT_NODELABEL(_dev), clocks))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#define TISCI_GET_CLOCK(_dev) DEVICE_DT_GET(DT_PHANDLE(DT_NODELABEL(_dev), clocks))
#define TISCI_GET_CLOCK(node_id) DEVICE_DT_GET(DT_PHANDLE(node_id, clocks))

I feel we should follow the devicetree.h convention and use node_id instead of manually using DT_NODELABEL here

{.dev_id = DT_CLOCKS_CELL(DT_NODELABEL(_dev), devid), \
.clk_id = DT_CLOCKS_CELL(DT_NODELABEL(_dev), clkid)}

#define TISCI_GET_CLOCK_BY_INST(inst) DEVICE_DT_INST_GET(inst)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#define TISCI_GET_CLOCK_BY_INST(inst) DEVICE_DT_INST_GET(inst)
#define TISCI_GET_CLOCK_BY_INST(inst) TISCI_GET_CLOCK(DT_DRV_INST(inst))

@vaishnavachath vaishnavachath requested a review from glneo June 27, 2025 05:07
zephyr_library_sources_ifdef(CONFIG_CLOCK_CONTROL_NRF54H_HFXO clock_control_nrf54h_hfxo.c)
zephyr_library_sources_ifdef(CONFIG_CLOCK_CONTROL_NRF_HSFLL_LOCAL clock_control_nrf_hsfll_local.c)
zephyr_library_sources_ifdef(CONFIG_CLOCK_CONTROL_NRF_LFCLK clock_control_nrf_lfclk.c)
zephyr_library_sources_ifdef(CONFIG_CLOCK_CONTROL_BOUFFALOLAB_BL60X clock_control_bl60x.c)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The above look unrelated, seems like you had some rebase issue going on here.

{
struct tisci_clock_config *req = (struct tisci_clock_config *)sys;
uint64_t temp_rate;
int ret = tisci_cmd_clk_get_freq(dmsc, req->dev_id, req->clk_id, &temp_rate);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Declare ret, then a newline, then assign to it, then no newline after between the assignment and the checking of ret. Same for tisci_set_rate(), make them look like you did in tisci_get_status().

if (curr_state) {
return CLOCK_CONTROL_STATUS_OFF;
}
return state;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return CLOCK_CONTROL_STATUS_UNKNOWN; here, then just drop the state variable.

return ret;
}

static inline enum clock_control_status tisci_get_status(const struct device *dev,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inline?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Clock Control DNM This PR should not be merged (Do Not Merge) platform: TI SimpleLink Texas Instruments SimpleLink MCU
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants