]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
zynqmp: Define routines for mmio write and read
authorSiva Durga Prasad Paladugu <siva.durga.paladugu@xilinx.com>
Wed, 1 Feb 2017 19:40:46 +0000 (01:10 +0530)
committerMichal Simek <michal.simek@xilinx.com>
Thu, 2 Feb 2017 09:29:31 +0000 (10:29 +0100)
Define routines of mmio write and read functionalities
for zynqmp platform.

Signed-off-by: Siva Durga Prasad Paladugu <sivadur@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
arch/arm/cpu/armv8/zynqmp/cpu.c
arch/arm/include/asm/arch-zynqmp/sys_proto.h

index b0f12955a1ffac03ec37f3ccf87ac52d687fee51..54afa9e034d61b6e1777e0d9297fd2037b90452d 100644 (file)
@@ -104,3 +104,54 @@ unsigned int zynqmp_get_silicon_version(void)
 
        return ZYNQMP_CSU_VERSION_SILICON;
 }
+
+#define PAYLOAD_ARG_CNT                5
+#define ZYNQMP_MMIO_READ       0xC2000014
+#define ZYNQMP_MMIO_WRITE      0xC2000013
+
+static int invoke_smc(u32 pm_api_id, u32 arg0, u32 arg1, u32 arg2, u32 arg3,
+                       u32 *ret_payload)
+{
+       /*
+        * Added SIP service call Function Identifier
+        * Make sure to stay in x0 register
+        */
+       struct pt_regs regs;
+
+       regs.regs[0] = pm_api_id;
+       regs.regs[1] = ((u64)arg1 << 32) | arg0;
+       regs.regs[2] = ((u64)arg3 << 32) | arg2;
+
+       smc_call(&regs);
+
+       if (ret_payload != NULL) {
+               ret_payload[0] = (u32)regs.regs[0];
+               ret_payload[1] = upper_32_bits(regs.regs[0]);
+               ret_payload[2] = (u32)regs.regs[1];
+               ret_payload[3] = upper_32_bits(regs.regs[1]);
+               ret_payload[4] = (u32)regs.regs[2];
+       }
+
+       return regs.regs[0];
+}
+
+int zynqmp_mmio_write(const u32 address,
+                     const u32 mask,
+                     const u32 value)
+{
+       return invoke_smc(ZYNQMP_MMIO_WRITE, address, mask, value, 0, NULL);
+}
+
+int zynqmp_mmio_read(const u32 address, u32 *value)
+{
+       u32 ret_payload[PAYLOAD_ARG_CNT];
+       u32 ret;
+
+       if (!value)
+               return -EINVAL;
+
+       ret = invoke_smc(ZYNQMP_MMIO_READ, address, 0, 0, 0, ret_payload);
+       *value = ret_payload[1];
+
+       return ret;
+}
index 8c54fcedf40108fcc297e825c21e3ef3fbd28d80..446e89c9b34f8fdf6ec899bc5e8ba8052397283a 100644 (file)
@@ -23,4 +23,7 @@ void psu_init(void);
 
 void handoff_setup(void);
 
+int zynqmp_mmio_write(const u32 address, const u32 mask, const u32 value);
+int zynqmp_mmio_read(const u32 address, u32 *value);
+
 #endif /* _ASM_ARCH_SYS_PROTO_H */