zynqmp: pm: Reimplement pinctrl set/get function EEMI API
Functions are reimplemented to issue system-level pinctrl EEMI calls to the PMU-FW rather than using MMIO read/write. Macros and functions that appear to be unused after the change is made are removed. Signed-off-by: Mirela Simonovic <mirela.simonovic@aggios.com> Signed-off-by: Rajan Vaja <rajan.vaja@xilinx.com> Change-Id: I21b8fda855aa69090b85d6aaf411e19560201cb5
This commit is contained in:
parent
43a029cb97
commit
10a346d9ce
|
@ -19,9 +19,7 @@
|
||||||
#include "pm_common.h"
|
#include "pm_common.h"
|
||||||
#include "pm_ipi.h"
|
#include "pm_ipi.h"
|
||||||
|
|
||||||
#define PINCTRL_FUNCTION_MASK U(0xFE)
|
|
||||||
#define PINCTRL_VOLTAGE_STATUS_MASK U(0x01)
|
#define PINCTRL_VOLTAGE_STATUS_MASK U(0x01)
|
||||||
#define NFUNCS_PER_PIN U(13)
|
|
||||||
#define PINCTRL_NUM_MIOS U(78)
|
#define PINCTRL_NUM_MIOS U(78)
|
||||||
#define MAX_PIN_PER_REG U(26)
|
#define MAX_PIN_PER_REG U(26)
|
||||||
#define PINCTRL_BANK_ADDR_STEP U(28)
|
#define PINCTRL_BANK_ADDR_STEP U(28)
|
||||||
|
@ -46,12 +44,6 @@
|
||||||
#define PINCTRL_REGVAL_TO_PIN_CONFIG(_pin, _val) \
|
#define PINCTRL_REGVAL_TO_PIN_CONFIG(_pin, _val) \
|
||||||
(((_val) >> PINCTRL_PIN_OFFSET(_pin)) & 0x1)
|
(((_val) >> PINCTRL_PIN_OFFSET(_pin)) & 0x1)
|
||||||
|
|
||||||
static uint8_t pm_pinctrl_mux[NFUNCS_PER_PIN] = {
|
|
||||||
0x02, 0x04, 0x08, 0x10, 0x18,
|
|
||||||
0x00, 0x20, 0x40, 0x60, 0x80,
|
|
||||||
0xA0, 0xC0, 0xE0
|
|
||||||
};
|
|
||||||
|
|
||||||
struct pinctrl_function {
|
struct pinctrl_function {
|
||||||
char name[FUNCTION_NAME_LEN];
|
char name[FUNCTION_NAME_LEN];
|
||||||
uint16_t (*groups)[];
|
uint16_t (*groups)[];
|
||||||
|
@ -2709,104 +2701,6 @@ enum pm_ret_status pm_api_pinctrl_get_pin_groups(unsigned int pin,
|
||||||
return PM_RET_SUCCESS;
|
return PM_RET_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* pm_api_pinctrl_get_function() - Read function id set for the given pin
|
|
||||||
* @pin Pin number
|
|
||||||
* @nid Node ID of function currently set for given pin
|
|
||||||
*
|
|
||||||
* This function provides the function currently set for the given pin.
|
|
||||||
*
|
|
||||||
* @return Returns status, either success or error+reason
|
|
||||||
*/
|
|
||||||
enum pm_ret_status pm_api_pinctrl_get_function(unsigned int pin,
|
|
||||||
unsigned int *id)
|
|
||||||
{
|
|
||||||
unsigned int i = 0, j = 0;
|
|
||||||
enum pm_ret_status ret = PM_RET_SUCCESS;
|
|
||||||
unsigned int ctrlreg, val, gid;
|
|
||||||
uint16_t *grps;
|
|
||||||
|
|
||||||
ctrlreg = IOU_SLCR_BASEADDR + 4U * pin;
|
|
||||||
ret = pm_mmio_read(ctrlreg, &val);
|
|
||||||
if (ret != PM_RET_SUCCESS)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
val &= PINCTRL_FUNCTION_MASK;
|
|
||||||
|
|
||||||
for (i = 0; i < NFUNCS_PER_PIN; i++)
|
|
||||||
if (val == pm_pinctrl_mux[i])
|
|
||||||
break;
|
|
||||||
|
|
||||||
if (i == NFUNCS_PER_PIN)
|
|
||||||
return PM_RET_ERROR_NOTSUPPORTED;
|
|
||||||
|
|
||||||
gid = *(*zynqmp_pin_groups[pin].groups + i);
|
|
||||||
|
|
||||||
for (i = 0; i < MAX_FUNCTION; i++) {
|
|
||||||
grps = *pinctrl_functions[i].groups;
|
|
||||||
if (grps == NULL)
|
|
||||||
continue;
|
|
||||||
if (val != pinctrl_functions[i].regval)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
for (j = 0; grps[j] != (uint16_t)END_OF_GROUPS; j++) {
|
|
||||||
if (gid == grps[j]) {
|
|
||||||
*id = i;
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (i == MAX_FUNCTION)
|
|
||||||
ret = PM_RET_ERROR_ARGS;
|
|
||||||
done:
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* pm_api_pinctrl_set_function() - Set function id set for the given pin
|
|
||||||
* @pin Pin number
|
|
||||||
* @nid Node ID of function to set for given pin
|
|
||||||
*
|
|
||||||
* This function provides the function currently set for the given pin.
|
|
||||||
*
|
|
||||||
* @return Returns status, either success or error+reason
|
|
||||||
*/
|
|
||||||
enum pm_ret_status pm_api_pinctrl_set_function(unsigned int pin,
|
|
||||||
unsigned int fid)
|
|
||||||
{
|
|
||||||
int i, j;
|
|
||||||
unsigned int ctrlreg, val;
|
|
||||||
uint16_t *pgrps, *fgrps;
|
|
||||||
|
|
||||||
ctrlreg = IOU_SLCR_BASEADDR + 4U * pin;
|
|
||||||
val = pinctrl_functions[fid].regval;
|
|
||||||
|
|
||||||
for (i = 0; i < NFUNCS_PER_PIN; i++)
|
|
||||||
if (val == pm_pinctrl_mux[i])
|
|
||||||
break;
|
|
||||||
|
|
||||||
if (i == NFUNCS_PER_PIN)
|
|
||||||
return PM_RET_ERROR_NOTSUPPORTED;
|
|
||||||
|
|
||||||
pgrps = *zynqmp_pin_groups[pin].groups;
|
|
||||||
if (!pgrps)
|
|
||||||
return PM_RET_ERROR_NOTSUPPORTED;
|
|
||||||
|
|
||||||
fgrps = *pinctrl_functions[fid].groups;
|
|
||||||
if (!fgrps)
|
|
||||||
return PM_RET_ERROR_NOTSUPPORTED;
|
|
||||||
|
|
||||||
for (i = 0; fgrps[i] != (uint16_t)END_OF_GROUPS; i++)
|
|
||||||
for (j = 0; pgrps[j] != (uint16_t)END_OF_GROUPS; j++)
|
|
||||||
if (fgrps[i] == pgrps[j])
|
|
||||||
goto match;
|
|
||||||
|
|
||||||
return PM_RET_ERROR_NOTSUPPORTED;
|
|
||||||
|
|
||||||
match:
|
|
||||||
return pm_mmio_write(ctrlreg, PINCTRL_FUNCTION_MASK, val);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* pm_api_pinctrl_set_config() - Set configuration parameter for given pin
|
* pm_api_pinctrl_set_config() - Set configuration parameter for given pin
|
||||||
* @pin: Pin for which configuration is to be set
|
* @pin: Pin for which configuration is to be set
|
||||||
|
|
|
@ -709,10 +709,6 @@ enum {
|
||||||
#define PINCTRL_DRIVE_STRENGTH_8MA 2U
|
#define PINCTRL_DRIVE_STRENGTH_8MA 2U
|
||||||
#define PINCTRL_DRIVE_STRENGTH_12MA 3U
|
#define PINCTRL_DRIVE_STRENGTH_12MA 3U
|
||||||
|
|
||||||
enum pm_ret_status pm_api_pinctrl_set_function(unsigned int pin,
|
|
||||||
unsigned int fid);
|
|
||||||
enum pm_ret_status pm_api_pinctrl_get_function(unsigned int pin,
|
|
||||||
unsigned int *id);
|
|
||||||
enum pm_ret_status pm_api_pinctrl_set_config(unsigned int pin,
|
enum pm_ret_status pm_api_pinctrl_set_config(unsigned int pin,
|
||||||
unsigned int param,
|
unsigned int param,
|
||||||
unsigned int value);
|
unsigned int value);
|
||||||
|
|
|
@ -682,31 +682,34 @@ enum pm_ret_status pm_pinctrl_release(unsigned int pin)
|
||||||
/**
|
/**
|
||||||
* pm_pinctrl_get_function() - Read function id set for the given pin
|
* pm_pinctrl_get_function() - Read function id set for the given pin
|
||||||
* @pin Pin number
|
* @pin Pin number
|
||||||
* @nid Node ID of function currently set for given pin
|
* @fid ID of function currently set for given pin
|
||||||
*
|
*
|
||||||
* This function provides the function currently set for the given pin.
|
* This function provides the function currently set for the given pin.
|
||||||
*
|
*
|
||||||
* @return Returns status, either success or error+reason
|
* @return Returns status, either success or error+reason
|
||||||
*/
|
*/
|
||||||
enum pm_ret_status pm_pinctrl_get_function(unsigned int pin,
|
enum pm_ret_status pm_pinctrl_get_function(unsigned int pin, unsigned int *fid)
|
||||||
enum pm_node_id *nid)
|
|
||||||
{
|
{
|
||||||
return pm_api_pinctrl_get_function(pin, nid);
|
uint32_t payload[PAYLOAD_ARG_CNT];
|
||||||
|
|
||||||
|
PM_PACK_PAYLOAD2(payload, PM_PINCTRL_GET_FUNCTION, pin);
|
||||||
|
return pm_ipi_send_sync(primary_proc, payload, fid, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* pm_pinctrl_set_function() - Set function id set for the given pin
|
* pm_pinctrl_set_function() - Set function id set for the given pin
|
||||||
* @pin Pin number
|
* @pin Pin number
|
||||||
* @nid Node ID of function to set for given pin
|
* @fid ID of function to set for given pin
|
||||||
*
|
|
||||||
* This function provides the function currently set for the given pin.
|
|
||||||
*
|
*
|
||||||
* @return Returns status, either success or error+reason
|
* @return Returns status, either success or error+reason
|
||||||
*/
|
*/
|
||||||
enum pm_ret_status pm_pinctrl_set_function(unsigned int pin,
|
enum pm_ret_status pm_pinctrl_set_function(unsigned int pin, unsigned int fid)
|
||||||
enum pm_node_id nid)
|
|
||||||
{
|
{
|
||||||
return pm_api_pinctrl_set_function(pin, (unsigned int)nid);
|
uint32_t payload[PAYLOAD_ARG_CNT];
|
||||||
|
|
||||||
|
/* Send request to the PMU */
|
||||||
|
PM_PACK_PAYLOAD3(payload, PM_PINCTRL_SET_FUNCTION, pin, fid);
|
||||||
|
return pm_ipi_send_sync(primary_proc, payload, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue