Commit 1e3fb352 authored by Jolly Shah's avatar Jolly Shah
Browse files

zynqmp: pm: Get PLL fractional data using PLL get parameter EEMI API



Fractional data should be get using PLL get parameter EEMI API. This
stands for system-level communication (APU to PMU). Since linux
already uses a specific IOCTL function to do this and we need to
keep it that way, the pll clock ID given by linux has to be mapped
to the pll node ID that is communicated at the system-level (argument
of PLL get parameter API).
With this modification the function pm_api_clk_get_pll_frac_data is
removed from pm_api_clock.c/h because it became unused.
The clock enum is defined as 'enum clock_id'.
Signed-off-by: default avatarMirela Simonovic <mirela.simonovic@aggios.com>
Acked-by: default avatarWill Wong <WILLW@xilinx.com>
Signed-off-by: default avatarJolly Shah <jollys@xilinx.com>
parent 20279793
...@@ -2488,6 +2488,74 @@ enum pm_ret_status pm_api_clock_get_attributes(unsigned int clock_id, ...@@ -2488,6 +2488,74 @@ enum pm_ret_status pm_api_clock_get_attributes(unsigned int clock_id,
return PM_RET_SUCCESS; return PM_RET_SUCCESS;
} }
/**
* struct pm_pll - PLL related data required to map IOCTL-based PLL control
* implemented by linux to system-level EEMI APIs
* @nid: PLL node ID
* @cid: PLL clock ID
*/
struct pm_pll {
const enum pm_node_id nid;
const enum clock_id cid;
};
static struct pm_pll pm_plls[] = {
{
.nid = NODE_IOPLL,
.cid = CLK_IOPLL_INT,
}, {
.nid = NODE_RPLL,
.cid = CLK_RPLL_INT,
}, {
.nid = NODE_APLL,
.cid = CLK_APLL_INT,
}, {
.nid = NODE_VPLL,
.cid = CLK_VPLL_INT,
}, {
.nid = NODE_DPLL,
.cid = CLK_DPLL_INT,
},
};
/**
* pm_clock_get_pll() - Get PLL structure by PLL clock ID
* @clock_id Clock ID of the target PLL
*
* @return Pointer to PLL structure if found, NULL otherwise
*/
static struct pm_pll *pm_clock_get_pll(enum clock_id clock_id)
{
uint32_t i;
for (i = 0; i < ARRAY_SIZE(pm_plls); i++) {
if (pm_plls[i].cid == clock_id)
return &pm_plls[i];
}
return NULL;
}
/**
* pm_clock_get_pll_node_id() - Get PLL node ID by PLL clock ID
* @clock_id Clock ID of the target PLL
* @node_id Location to store node ID of the target PLL
*
* @return PM_RET_SUCCESS if node ID is found, PM_RET_ERROR_ARGS otherwise
*/
enum pm_ret_status pm_clock_get_pll_node_id(enum clock_id clock_id,
enum pm_node_id *node_id)
{
struct pm_pll *pll = pm_clock_get_pll(clock_id);
if (pll) {
*node_id = pll->nid;
return PM_RET_SUCCESS;
}
return PM_RET_ERROR_ARGS;
}
/** /**
* pll_get_lockbit() - Returns lockbit index for pll id * pll_get_lockbit() - Returns lockbit index for pll id
* @pll_id: Id of the pll * @pll_id: Id of the pll
...@@ -3170,35 +3238,3 @@ enum pm_ret_status pm_api_clk_set_pll_frac_data(unsigned int pll, ...@@ -3170,35 +3238,3 @@ enum pm_ret_status pm_api_clk_set_pll_frac_data(unsigned int pll,
return ret; return ret;
} }
/**
* pm_api_clk_get_pll_frac_data() - Get PLL fraction data
* @pll PLL id
* @data fraction data
*
* This function returns fraction data value.
*
* @return Returns status, either success or error+reason
*/
enum pm_ret_status pm_api_clk_get_pll_frac_data(unsigned int pll,
unsigned int *data)
{
enum pm_ret_status ret = PM_RET_SUCCESS;
unsigned int val, reg;
if (!pm_clock_valid(pll))
return PM_RET_ERROR_ARGS;
if (pm_clock_type(pll) != CLK_TYPE_OUTPUT)
return PM_RET_ERROR_NOTSUPPORTED;
if (!ISPLL(pll))
return PM_RET_ERROR_NOTSUPPORTED;
reg = clocks[pll].control_reg + PLL_FRAC_OFFSET;
ret = pm_mmio_read(reg, &val);
*data = (val & PLL_FRAC_DATA_MASK);
return ret;
}
...@@ -55,7 +55,7 @@ ...@@ -55,7 +55,7 @@
#define END_OF_CLK "END_OF_CLK" #define END_OF_CLK "END_OF_CLK"
//CLock Ids //CLock Ids
enum { enum clock_id {
CLK_IOPLL, CLK_IOPLL,
CLK_RPLL, CLK_RPLL,
CLK_APLL, CLK_APLL,
...@@ -288,6 +288,10 @@ enum pm_ret_status pm_api_clock_get_parents(unsigned int clock_id, ...@@ -288,6 +288,10 @@ enum pm_ret_status pm_api_clock_get_parents(unsigned int clock_id,
uint32_t *parents); uint32_t *parents);
enum pm_ret_status pm_api_clock_get_attributes(unsigned int clock_id, enum pm_ret_status pm_api_clock_get_attributes(unsigned int clock_id,
uint32_t *attr); uint32_t *attr);
enum pm_ret_status pm_clock_get_pll_node_id(enum clock_id clock_id,
enum pm_node_id *node_id);
enum pm_ret_status pm_api_clock_enable(unsigned int clock_id); enum pm_ret_status pm_api_clock_enable(unsigned int clock_id);
enum pm_ret_status pm_api_clock_disable(unsigned int clock_id); enum pm_ret_status pm_api_clock_disable(unsigned int clock_id);
enum pm_ret_status pm_api_clock_getstate(unsigned int clock_id, enum pm_ret_status pm_api_clock_getstate(unsigned int clock_id,
...@@ -310,7 +314,5 @@ enum pm_ret_status pm_api_clk_get_pll_mode(unsigned int pll, ...@@ -310,7 +314,5 @@ enum pm_ret_status pm_api_clk_get_pll_mode(unsigned int pll,
unsigned int *mode); unsigned int *mode);
enum pm_ret_status pm_api_clk_set_pll_frac_data(unsigned int pll, enum pm_ret_status pm_api_clk_set_pll_frac_data(unsigned int pll,
unsigned int data); unsigned int data);
enum pm_ret_status pm_api_clk_get_pll_frac_data(unsigned int pll,
unsigned int *data);
#endif /* PM_API_CLOCK_H */ #endif /* PM_API_CLOCK_H */
...@@ -381,7 +381,7 @@ static enum pm_ret_status pm_ioctl_set_pll_frac_data ...@@ -381,7 +381,7 @@ static enum pm_ret_status pm_ioctl_set_pll_frac_data
/** /**
* pm_ioctl_get_pll_frac_data() - Ioctl function for * pm_ioctl_get_pll_frac_data() - Ioctl function for
* getting pll fraction data * getting pll fraction data
* @pll PLL id * @pll PLL clock id
* @data fraction data * @data fraction data
* *
* This function returns fraction data value. * This function returns fraction data value.
...@@ -391,7 +391,15 @@ static enum pm_ret_status pm_ioctl_set_pll_frac_data ...@@ -391,7 +391,15 @@ static enum pm_ret_status pm_ioctl_set_pll_frac_data
static enum pm_ret_status pm_ioctl_get_pll_frac_data static enum pm_ret_status pm_ioctl_get_pll_frac_data
(unsigned int pll, unsigned int *data) (unsigned int pll, unsigned int *data)
{ {
return pm_api_clk_get_pll_frac_data(pll, data); enum pm_node_id pll_nid;
enum pm_ret_status status;
/* Get PLL node ID using PLL clock ID */
status = pm_clock_get_pll_node_id(pll, &pll_nid);
if (status != PM_RET_SUCCESS)
return status;
return pm_pll_get_parameter(pll_nid, PM_PLL_PARAM_DATA, data);
} }
/** /**
......
Markdown is supported
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