Skip to content

Commit 23c64d7

Browse files
Piyush Mehtabrgl
authored andcommitted
firmware: zynqmp: Add MMIO read and write support for PS_MODE pin
Add Xilinx ZynqMP firmware MMIO APIs support to set and get PS_MODE pins value and status. These APIs create an interface path between mode pin controller driver and low-level API to access GPIO pins. Signed-off-by: Piyush Mehta <[email protected]> Acked-by: Michal Simek <[email protected]> Acked-by: Linus Walleij <[email protected]> Signed-off-by: Bartosz Golaszewski <[email protected]>
1 parent 03e2080 commit 23c64d7

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-0
lines changed

drivers/firmware/xilinx/zynqmp.c

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@
2828
/* Max HashMap Order for PM API feature check (1<<7 = 128) */
2929
#define PM_API_FEATURE_CHECK_MAX_ORDER 7
3030

31+
/* CRL registers and bitfields */
32+
#define CRL_APB_BASE 0xFF5E0000U
33+
/* BOOT_PIN_CTRL- Used to control the mode pins after boot */
34+
#define CRL_APB_BOOT_PIN_CTRL (CRL_APB_BASE + (0x250U))
35+
/* BOOT_PIN_CTRL_MASK- out_val[11:8], out_en[3:0] */
36+
#define CRL_APB_BOOTPIN_CTRL_MASK 0xF0FU
37+
3138
static bool feature_check_enabled;
3239
static DEFINE_HASHTABLE(pm_api_features_map, PM_API_FEATURE_CHECK_MAX_ORDER);
3340

@@ -925,6 +932,45 @@ int zynqmp_pm_pinctrl_set_config(const u32 pin, const u32 param,
925932
}
926933
EXPORT_SYMBOL_GPL(zynqmp_pm_pinctrl_set_config);
927934

935+
/**
936+
* zynqmp_pm_bootmode_read() - PM Config API for read bootpin status
937+
* @ps_mode: Returned output value of ps_mode
938+
*
939+
* This API function is to be used for notify the power management controller
940+
* to read bootpin status.
941+
*
942+
* Return: status, either success or error+reason
943+
*/
944+
unsigned int zynqmp_pm_bootmode_read(u32 *ps_mode)
945+
{
946+
unsigned int ret;
947+
u32 ret_payload[PAYLOAD_ARG_CNT];
948+
949+
ret = zynqmp_pm_invoke_fn(PM_MMIO_READ, CRL_APB_BOOT_PIN_CTRL, 0,
950+
0, 0, ret_payload);
951+
952+
*ps_mode = ret_payload[1];
953+
954+
return ret;
955+
}
956+
EXPORT_SYMBOL_GPL(zynqmp_pm_bootmode_read);
957+
958+
/**
959+
* zynqmp_pm_bootmode_write() - PM Config API for Configure bootpin
960+
* @ps_mode: Value to be written to the bootpin ctrl register
961+
*
962+
* This API function is to be used for notify the power management controller
963+
* to configure bootpin.
964+
*
965+
* Return: Returns status, either success or error+reason
966+
*/
967+
int zynqmp_pm_bootmode_write(u32 ps_mode)
968+
{
969+
return zynqmp_pm_invoke_fn(PM_MMIO_WRITE, CRL_APB_BOOT_PIN_CTRL,
970+
CRL_APB_BOOTPIN_CTRL_MASK, ps_mode, 0, NULL);
971+
}
972+
EXPORT_SYMBOL_GPL(zynqmp_pm_bootmode_write);
973+
928974
/**
929975
* zynqmp_pm_init_finalize() - PM call to inform firmware that the caller
930976
* master has initialized its own power management

include/linux/firmware/xlnx-zynqmp.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ enum pm_api_id {
7272
PM_SET_REQUIREMENT = 15,
7373
PM_RESET_ASSERT = 17,
7474
PM_RESET_GET_STATUS = 18,
75+
PM_MMIO_WRITE = 19,
76+
PM_MMIO_READ = 20,
7577
PM_PM_INIT_FINALIZE = 21,
7678
PM_FPGA_LOAD = 22,
7779
PM_FPGA_GET_STATUS = 23,
@@ -390,6 +392,8 @@ int zynqmp_pm_sd_dll_reset(u32 node_id, u32 type);
390392
int zynqmp_pm_reset_assert(const enum zynqmp_pm_reset reset,
391393
const enum zynqmp_pm_reset_action assert_flag);
392394
int zynqmp_pm_reset_get_status(const enum zynqmp_pm_reset reset, u32 *status);
395+
unsigned int zynqmp_pm_bootmode_read(u32 *ps_mode);
396+
int zynqmp_pm_bootmode_write(u32 ps_mode);
393397
int zynqmp_pm_init_finalize(void);
394398
int zynqmp_pm_set_suspend_mode(u32 mode);
395399
int zynqmp_pm_request_node(const u32 node, const u32 capabilities,
@@ -520,6 +524,16 @@ static inline int zynqmp_pm_reset_get_status(const enum zynqmp_pm_reset reset,
520524
return -ENODEV;
521525
}
522526

527+
static inline unsigned int zynqmp_pm_bootmode_read(u32 *ps_mode)
528+
{
529+
return -ENODEV;
530+
}
531+
532+
static inline int zynqmp_pm_bootmode_write(u32 ps_mode)
533+
{
534+
return -ENODEV;
535+
}
536+
523537
static inline int zynqmp_pm_init_finalize(void)
524538
{
525539
return -ENODEV;

0 commit comments

Comments
 (0)