summaryrefslogtreecommitdiff
path: root/plat/xilinx
diff options
context:
space:
mode:
authorJolly Shah <jollys@xilinx.com>2019-01-02 12:40:17 -0800
committerJolly Shah <jollys@xilinx.com>2019-01-04 11:38:57 -0800
commit1e3fb352b7415ed53bdb6e439970870e3828bc64 (patch)
tree3f25201a3bccc48fb58624e6733e520344ef50e2 /plat/xilinx
parent202797934dcf4bf44b2ec4800ec1a7e1fcb9968b (diff)
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: Mirela Simonovic <mirela.simonovic@aggios.com> Acked-by: Will Wong <WILLW@xilinx.com> Signed-off-by: Jolly Shah <jollys@xilinx.com>
Diffstat (limited to 'plat/xilinx')
-rw-r--r--plat/xilinx/zynqmp/pm_service/pm_api_clock.c100
-rw-r--r--plat/xilinx/zynqmp/pm_service/pm_api_clock.h8
-rw-r--r--plat/xilinx/zynqmp/pm_service/pm_api_ioctl.c12
3 files changed, 83 insertions, 37 deletions
diff --git a/plat/xilinx/zynqmp/pm_service/pm_api_clock.c b/plat/xilinx/zynqmp/pm_service/pm_api_clock.c
index b175b78b..723ad401 100644
--- a/plat/xilinx/zynqmp/pm_service/pm_api_clock.c
+++ b/plat/xilinx/zynqmp/pm_service/pm_api_clock.c
@@ -2489,6 +2489,74 @@ enum pm_ret_status pm_api_clock_get_attributes(unsigned int clock_id,
}
/**
+ * 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_id: Id of the pll
*
@@ -3170,35 +3238,3 @@ enum pm_ret_status pm_api_clk_set_pll_frac_data(unsigned int pll,
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;
-}
diff --git a/plat/xilinx/zynqmp/pm_service/pm_api_clock.h b/plat/xilinx/zynqmp/pm_service/pm_api_clock.h
index f7cbdbaf..ebada774 100644
--- a/plat/xilinx/zynqmp/pm_service/pm_api_clock.h
+++ b/plat/xilinx/zynqmp/pm_service/pm_api_clock.h
@@ -55,7 +55,7 @@
#define END_OF_CLK "END_OF_CLK"
//CLock Ids
-enum {
+enum clock_id {
CLK_IOPLL,
CLK_RPLL,
CLK_APLL,
@@ -288,6 +288,10 @@ enum pm_ret_status pm_api_clock_get_parents(unsigned int clock_id,
uint32_t *parents);
enum pm_ret_status pm_api_clock_get_attributes(unsigned int clock_id,
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_disable(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,
unsigned int *mode);
enum pm_ret_status pm_api_clk_set_pll_frac_data(unsigned int pll,
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 */
diff --git a/plat/xilinx/zynqmp/pm_service/pm_api_ioctl.c b/plat/xilinx/zynqmp/pm_service/pm_api_ioctl.c
index 16c08ae6..87c3f7de 100644
--- a/plat/xilinx/zynqmp/pm_service/pm_api_ioctl.c
+++ b/plat/xilinx/zynqmp/pm_service/pm_api_ioctl.c
@@ -381,7 +381,7 @@ static enum pm_ret_status pm_ioctl_set_pll_frac_data
/**
* pm_ioctl_get_pll_frac_data() - Ioctl function for
* getting pll fraction data
- * @pll PLL id
+ * @pll PLL clock id
* @data fraction data
*
* This function returns fraction data value.
@@ -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
(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);
}
/**