xilinx: Move bootmode detection to separate function
authorMichal Simek <michal.simek@xilinx.com>
Wed, 8 Apr 2020 09:04:41 +0000 (11:04 +0200)
committerMichal Simek <michal.simek@xilinx.com>
Mon, 27 Apr 2020 11:57:18 +0000 (13:57 +0200)
Create special function for reading bootmode on Versal and ZynqMP.
Zynq is using specific function (without mask) already.
Future patches will be calling this function from different location too.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
board/xilinx/versal/board.c
board/xilinx/zynqmp/zynqmp.c

index 2900dfb44e931b2f3599c9295a7c74df8e5f8f53..483e3ce2f79a29dee74d9eabcda08be27863b854 100644 (file)
@@ -82,9 +82,23 @@ int board_early_init_r(void)
        return 0;
 }
 
-int board_late_init(void)
+static u8 versal_get_bootmode(void)
 {
+       u8 bootmode;
        u32 reg = 0;
+
+       reg = readl(&crp_base->boot_mode_usr);
+
+       if (reg >> BOOT_MODE_ALT_SHIFT)
+               reg >>= BOOT_MODE_ALT_SHIFT;
+
+       bootmode = reg & BOOT_MODES_MASK;
+
+       return bootmode;
+}
+
+int board_late_init(void)
+{
        u8 bootmode;
        struct udevice *dev;
        int bootseq = -1;
@@ -99,12 +113,7 @@ int board_late_init(void)
                return 0;
        }
 
-       reg = readl(&crp_base->boot_mode_usr);
-
-       if (reg >> BOOT_MODE_ALT_SHIFT)
-               reg >>= BOOT_MODE_ALT_SHIFT;
-
-       bootmode = reg & BOOT_MODES_MASK;
+       bootmode = versal_get_bootmode();
 
        puts("Bootmode: ");
        switch (bootmode) {
index 66a43974e68d00abb9d2bf91e49d1c6fd68fb950..a2a0d563318ee7bbf783c737b56f353bcada657c 100644 (file)
@@ -552,9 +552,26 @@ static int set_fdtfile(void)
        return 0;
 }
 
-int board_late_init(void)
+static u8 zynqmp_get_bootmode(void)
 {
+       u8 bootmode;
        u32 reg = 0;
+       int ret;
+
+       ret = zynqmp_mmio_read((ulong)&crlapb_base->boot_mode, &reg);
+       if (ret)
+               return -EINVAL;
+
+       if (reg >> BOOT_MODE_ALT_SHIFT)
+               reg >>= BOOT_MODE_ALT_SHIFT;
+
+       bootmode = reg & BOOT_MODES_MASK;
+
+       return bootmode;
+}
+
+int board_late_init(void)
+{
        u8 bootmode;
        struct udevice *dev;
        int bootseq = -1;
@@ -578,14 +595,7 @@ int board_late_init(void)
        if (ret)
                return ret;
 
-       ret = zynqmp_mmio_read((ulong)&crlapb_base->boot_mode, &reg);
-       if (ret)
-               return -EINVAL;
-
-       if (reg >> BOOT_MODE_ALT_SHIFT)
-               reg >>= BOOT_MODE_ALT_SHIFT;
-
-       bootmode = reg & BOOT_MODES_MASK;
+       bootmode = zynqmp_get_bootmode();
 
        puts("Bootmode: ");
        switch (bootmode) {