--- /dev/null
+/*
+ * Copyright (c) 2013 Xilinx Inc.
+ *
+ * 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>
+
+#define SLCR_QSPI_ENABLE 0x02
+#define SLCR_QSPI_ENABLE_MASK 0x03
+
+/*
+ * 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 int qspi0_pins[] = {
+ 0, 1, 2, 3, 4, 5
+};
+
+static const int qspi1_cs_pin[] = {
+ 7
+};
+
+static const int qspi1_pins[] = {
+ 8, 9, 10, 11, 12
+};
+
+static const struct zynq_slcr_mio_get_status mio_periphs[] = {
+ {
+ "qspi0",
+ qspi0_pins,
+ ARRAY_SIZE(qspi0_pins),
+ SLCR_QSPI_ENABLE_MASK,
+ SLCR_QSPI_ENABLE,
+ },
+ {
+ "qspi1_cs",
+ qspi1_cs_pin,
+ ARRAY_SIZE(qspi1_cs_pin),
+ SLCR_QSPI_ENABLE_MASK,
+ SLCR_QSPI_ENABLE,
+ },
+ {
+ "qspi1",
+ qspi1_pins,
+ ARRAY_SIZE(qspi1_pins),
+ SLCR_QSPI_ENABLE_MASK,
+ SLCR_QSPI_ENABLE,
+ },
+};
+
+/*
+ * 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;
+}
int is_dual = -1;
int lower_mio = 0, upper_mio = 0, upper_mio_cs1 = 0;
-#ifndef XILINX_ZYNQMP
lower_mio = zynq_slcr_get_mio_pin_status("qspi0");
if (lower_mio == ZYNQ_QSPI_MIO_NUM_QSPI0)
is_dual = SF_SINGLE_FLASH;
(upper_mio_cs1 == ZYNQ_QSPI_MIO_NUM_QSPI1_CS) &&
(upper_mio == ZYNQ_QSPI_MIO_NUM_QSPI1))
is_dual = SF_DUAL_PARALLEL_FLASH;
-#else
- is_dual = SF_SINGLE_FLASH;
-#endif
return is_dual;
}