Commit 2394b94b authored by Tejas Patel's avatar Tejas Patel Committed by Jolly Shah
Browse files

xilinx: versal: Implement clock related PM APIs



Implement below clock related APIs:
  - Clock enable
  - Clock disable
  - Clock get status
  - Clock set divider
  - Clock get divider
  - Clock set parent
  - Clock get parent

Signed-off-by: default avatarTejas Patel <tejas.patel@xilinx.com>
Signed-off-by: default avatarJolly Shah <jolly.shah@xilinx.com>
Change-Id: Ibb3606e88ac6796d9d759226908b2c2997c5fea0
parent 0ed83c62
......@@ -378,3 +378,122 @@ enum pm_ret_status pm_pinctrl_get_pin_param(uint32_t pin, uint32_t param,
return pm_ipi_send_sync(primary_proc, payload, value, 1);
}
/**
* pm_clock_enable() - Enable the clock
* @clk_id Clock ID
*
* @return Returns status, either success or error+reason
*/
enum pm_ret_status pm_clock_enable(uint32_t clk_id)
{
uint32_t payload[PAYLOAD_ARG_CNT];
/* Send request to the PMC */
PM_PACK_PAYLOAD2(payload, LIBPM_MODULE_ID, PM_CLOCK_ENABLE, clk_id);
return pm_ipi_send_sync(primary_proc, payload, NULL, 0);
}
/**
* pm_clock_disable() - Disable the clock
* @clk_id Clock ID
*
* @return Returns status, either success or error+reason
*/
enum pm_ret_status pm_clock_disable(uint32_t clk_id)
{
uint32_t payload[PAYLOAD_ARG_CNT];
/* Send request to the PMC */
PM_PACK_PAYLOAD2(payload, LIBPM_MODULE_ID, PM_CLOCK_DISABLE, clk_id);
return pm_ipi_send_sync(primary_proc, payload, NULL, 0);
}
/**
* pm_clock_get_state() - Get clock status
* @clk_id Clock ID
* @state: Buffer to store clock status (1: Enabled, 0:Disabled)
*
* @return Returns status, either success or error+reason
*/
enum pm_ret_status pm_clock_get_state(uint32_t clk_id, uint32_t *state)
{
uint32_t payload[PAYLOAD_ARG_CNT];
/* Send request to the PMC */
PM_PACK_PAYLOAD2(payload, LIBPM_MODULE_ID, PM_CLOCK_GETSTATE, clk_id);
return pm_ipi_send_sync(primary_proc, payload, state, 1);
}
/**
* pm_clock_set_divider() - Set divider for the clock
* @clk_id Clock ID
* @divider Divider value
*
* @return Returns status, either success or error+reason
*/
enum pm_ret_status pm_clock_set_divider(uint32_t clk_id, uint32_t divider)
{
uint32_t payload[PAYLOAD_ARG_CNT];
/* Send request to the PMC */
PM_PACK_PAYLOAD3(payload, LIBPM_MODULE_ID, PM_CLOCK_SETDIVIDER, clk_id,
divider);
return pm_ipi_send_sync(primary_proc, payload, NULL, 0);
}
/**
* pm_clock_get_divider() - Get divider value for the clock
* @clk_id Clock ID
* @divider: Buffer to store clock divider value
*
* @return Returns status, either success or error+reason
*/
enum pm_ret_status pm_clock_get_divider(uint32_t clk_id, uint32_t *divider)
{
uint32_t payload[PAYLOAD_ARG_CNT];
/* Send request to the PMC */
PM_PACK_PAYLOAD2(payload, LIBPM_MODULE_ID, PM_CLOCK_GETDIVIDER, clk_id);
return pm_ipi_send_sync(primary_proc, payload, divider, 1);
}
/**
* pm_clock_set_parent() - Set parent for the clock
* @clk_id Clock ID
* @parent Parent ID
*
* @return Returns status, either success or error+reason
*/
enum pm_ret_status pm_clock_set_parent(uint32_t clk_id, uint32_t parent)
{
uint32_t payload[PAYLOAD_ARG_CNT];
/* Send request to the PMC */
PM_PACK_PAYLOAD3(payload, LIBPM_MODULE_ID, PM_CLOCK_SETPARENT, clk_id,
parent);
return pm_ipi_send_sync(primary_proc, payload, NULL, 0);
}
/**
* pm_clock_get_parent() - Get parent value for the clock
* @clk_id Clock ID
* @parent: Buffer to store clock parent value
*
* @return Returns status, either success or error+reason
*/
enum pm_ret_status pm_clock_get_parent(uint32_t clk_id, uint32_t *parent)
{
uint32_t payload[PAYLOAD_ARG_CNT];
/* Send request to the PMC */
PM_PACK_PAYLOAD2(payload, LIBPM_MODULE_ID, PM_CLOCK_GETPARENT, clk_id);
return pm_ipi_send_sync(primary_proc, payload, parent, 1);
}
......@@ -40,5 +40,12 @@ enum pm_ret_status pm_pinctrl_set_pin_param(uint32_t pin, uint32_t param,
uint32_t value);
enum pm_ret_status pm_pinctrl_get_pin_param(uint32_t pin, uint32_t param,
uint32_t *value);
enum pm_ret_status pm_clock_enable(uint32_t clk_id);
enum pm_ret_status pm_clock_disable(uint32_t clk_id);
enum pm_ret_status pm_clock_get_state(uint32_t clk_id, uint32_t *state);
enum pm_ret_status pm_clock_set_divider(uint32_t clk_id, uint32_t divider);
enum pm_ret_status pm_clock_get_divider(uint32_t clk_id, uint32_t *divider);
enum pm_ret_status pm_clock_set_parent(uint32_t clk_id, uint32_t parent);
enum pm_ret_status pm_clock_get_parent(uint32_t clk_id, uint32_t *parent);
#endif /* PM_API_SYS_H */
......@@ -39,6 +39,15 @@
#define PM_PINCTRL_SET_FUNCTION 31U
#define PM_PINCTRL_CONFIG_PARAM_GET 32U
#define PM_PINCTRL_CONFIG_PARAM_SET 33U
#define PM_CLOCK_ENABLE 36U
#define PM_CLOCK_DISABLE 37U
#define PM_CLOCK_GETSTATE 38U
#define PM_CLOCK_SETDIVIDER 39U
#define PM_CLOCK_GETDIVIDER 40U
#define PM_CLOCK_SETRATE 41U
#define PM_CLOCK_GETRATE 42U
#define PM_CLOCK_SETPARENT 43U
#define PM_CLOCK_GETPARENT 44U
/*********************************************************************
* Enum definitions
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment