]> rtime.felk.cvut.cz Git - zynq/linux.git/commitdiff
ARM64: zynqmp: Add get_chipid FW call
authorSoren Brinkmann <soren.brinkmann@xilinx.com>
Thu, 6 Oct 2016 16:41:11 +0000 (09:41 -0700)
committerMichal Simek <michal.simek@xilinx.com>
Thu, 13 Oct 2016 12:09:06 +0000 (14:09 +0200)
The firmware provides a function to obtain silicon version information.

Signed-off-by: Soren Brinkmann <soren.brinkmann@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
drivers/soc/xilinx/zynqmp/pm.c
include/linux/soc/xilinx/zynqmp/pm.h

index 055ad62b381d90ca99810afb8c36d6dd4b26f430..112247dcc44eaa18c46acf16a8ecc2e3f19adc39 100644 (file)
@@ -68,6 +68,7 @@ enum pm_api_id {
        PM_INIT,
        FPGA_LOAD,
        FPGA_GET_STATUS,
+       GET_CHIPID,
 };
 
 /* PMU-FW return status codes */
@@ -463,6 +464,29 @@ int zynqmp_pm_get_api_version(u32 *version)
 }
 EXPORT_SYMBOL_GPL(zynqmp_pm_get_api_version);
 
+/**
+ * zynqmp_pm_get_chipid - Get silicon ID registers
+ * @idcode:    IDCODE register
+ * @version:   version register
+ *
+ * Return:     Returns the status of the operation and the idcode and version
+ *             registers in @idcode and @version.
+ */
+int zynqmp_pm_get_chipid(u32 *idcode, u32 *version)
+{
+       u32 ret_payload[PAYLOAD_ARG_CNT];
+
+       if (!idcode || !version)
+               return -EINVAL;
+
+       invoke_pm_fn(GET_CHIPID, 0, 0, 0, 0, ret_payload);
+       *idcode = ret_payload[1];
+       *version = ret_payload[2];
+
+       return zynqmp_pm_ret_code((enum pm_ret_status)ret_payload[0]);
+}
+EXPORT_SYMBOL_GPL(zynqmp_pm_get_chipid);
+
 /**
  * zynqmp_pm_set_configuration - PM call to set system configuration
  * @physical_addr:     Physical 32-bit address of data structure in memory
@@ -745,6 +769,8 @@ static ssize_t zynqmp_pm_debugfs_api_write(struct file *file,
                pm_id = MMIO_READ;
        else if (strncasecmp(pm_api_req, "MMIO_WRITE", 10) == 0)
                pm_id = MMIO_WRITE;
+       else if (strncasecmp(pm_api_req, "GET_CHIPID", 9) == 0)
+               pm_id = GET_CHIPID;
        /* If no name was entered look for PM-API ID instead */
        else if (kstrtouint(pm_api_req, 10, &pm_id))
                ret = -EINVAL;
@@ -852,6 +878,11 @@ static ssize_t zynqmp_pm_debugfs_api_write(struct file *file,
                ret = zynqmp_pm_mmio_write(pm_api_arg[0],
                                     pm_api_arg[1], pm_api_arg[2]);
                break;
+       case GET_CHIPID:
+               ret = zynqmp_pm_get_chipid(&pm_api_arg[0], &pm_api_arg[1]);
+               pr_info("%s idcode: %#x, version:%#x\n",
+                       __func__, pm_api_arg[0], pm_api_arg[1]);
+               break;
        default:
                pr_err("%s Unsupported PM-API request\n", __func__);
                ret = -EINVAL;
index 394dc8fb0a1bee5163f3afc885b77442460d99f9..7378a5efb0fbdb25bc8345795a9f5ef6b86f956b 100644 (file)
@@ -246,5 +246,6 @@ int zynqmp_pm_mmio_write(const u32 address,
 int zynqmp_pm_mmio_read(const u32 address, u32 *value);
 int zynqmp_pm_fpga_load(const u64 address, const u32 size, const u32 flags);
 int zynqmp_pm_fpga_get_status(u32 *value);
+int zynqmp_pm_get_chipid(u32 *idcode, u32 *version);
 
 #endif /* __SOC_ZYNQMP_PM_H__ */