]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
zynqmp: Add support for IP detection via SLCR
authorMichal Simek <michal.simek@xilinx.com>
Wed, 22 Jul 2015 07:27:11 +0000 (09:27 +0200)
committerLothar Waßmann <LW@KARO-electronics.de>
Wed, 9 Sep 2015 11:50:48 +0000 (13:50 +0200)
SLCR can be used for IP configuration setting.
Add SLCR skeleton to enable run time checking.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
arch/arm/cpu/armv8/zynqmp/Makefile
arch/arm/cpu/armv8/zynqmp/slcr.c [new file with mode: 0644]
arch/arm/include/asm/arch-zynqmp/hardware.h
arch/arm/include/asm/arch-zynqmp/sys_proto.h

index efab5eabc97b07bd81c899a4dce88d66126219aa..d0ed2223ff7973b27e24cb936546bcf81bb58b85 100644 (file)
@@ -8,3 +8,4 @@
 obj-y  += clk.o
 obj-y  += cpu.o
 obj-$(CONFIG_MP)       += mp.o
+obj-y  += slcr.o
diff --git a/arch/arm/cpu/armv8/zynqmp/slcr.c b/arch/arm/cpu/armv8/zynqmp/slcr.c
new file mode 100644 (file)
index 0000000..713e9a6
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * (C) Copyright 2014 - 2015 Xilinx, Inc.
+ * Michal Simek <michal.simek@xilinx.com>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include <common.h>
+#include <asm/io.h>
+#include <malloc.h>
+#include <asm/arch/hardware.h>
+#include <asm/arch/sys_proto.h>
+#include <asm/arch/clk.h>
+
+/*
+ * zynq_slcr_mio_get_status - Get the status of MIO peripheral.
+ *
+ * @peri_name: Name of the peripheral for checking MIO status
+ * @get_pins: Pointer to array of get pin for this peripheral
+ * @num_pins: Number of pins for this peripheral
+ * @mask: Mask value
+ * @check_val: Required check value to get the status of  periph
+ */
+struct zynq_slcr_mio_get_status {
+       const char *peri_name;
+       const int *get_pins;
+       int num_pins;
+       u32 mask;
+       u32 check_val;
+};
+
+static const struct zynq_slcr_mio_get_status mio_periphs[] = {
+};
+
+/*
+ * zynq_slcr_get_mio_pin_status - Get the MIO pin status of peripheral.
+ *
+ * @periph: Name of the peripheral
+ *
+ * Returns count to indicate the number of pins configured for the
+ * given @periph.
+ */
+int zynq_slcr_get_mio_pin_status(const char *periph)
+{
+       const struct zynq_slcr_mio_get_status *mio_ptr;
+       int val, i, j;
+       int mio = 0;
+
+       for (i = 0; i < ARRAY_SIZE(mio_periphs); i++) {
+               if (strcmp(periph, mio_periphs[i].peri_name) == 0) {
+                       mio_ptr = &mio_periphs[i];
+                       for (j = 0; j < mio_ptr->num_pins; j++) {
+                               val = readl(&slcr_base->mio_pin
+                                               [mio_ptr->get_pins[j]]);
+                               if ((val & mio_ptr->mask) == mio_ptr->check_val)
+                                       mio++;
+                       }
+                       break;
+               }
+       }
+
+       return mio;
+}
index c9dc49d783173db819352c218153e4a472a93ee4..15bd519bfbe1733f269d9fa118a77894933157c1 100644 (file)
@@ -55,6 +55,15 @@ struct iou_scntr {
 #define EMMC_MODE      0x00000006
 #define JTAG_MODE      0x00000000
 
+#define ZYNQMP_IOU_SLCR_BASEADDR       0xFF180000
+
+struct iou_slcr_regs {
+       u32 mio_pin[78];
+       u32 reserved[442];
+};
+
+#define slcr_base ((struct iou_slcr_regs *)ZYNQMP_IOU_SLCR_BASEADDR)
+
 #define ZYNQMP_RPU_BASEADDR    0xFF9A0000
 
 struct rpu_regs {
index d8e0ba1588a0a9f5ab912db5d5f17115717dc5cf..3ca15cb6e58844845824f9fcfecd20ac21cfe167 100644 (file)
@@ -9,6 +9,7 @@
 #define _ASM_ARCH_SYS_PROTO_H
 
 int zynq_sdhci_init(unsigned long regbase);
+int zynq_slcr_get_mio_pin_status(const char *periph);
 
 unsigned int zynqmp_get_silicon_version(void);