Merge tag 'u-boot-atmel-fixes-2020.07-a' of https://gitlab.denx.de/u-boot/custodians...
[oweals/u-boot.git] / arch / arm / cpu / arm926ejs / spear / cpu.c
index 3037084b29bce7cdae69b31a65f25eb79bb7dba0..21065410746b4622590f1011f5eda841a29bbf64 100644 (file)
@@ -1,11 +1,12 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * (C) Copyright 2010
  * Vipin Kumar, ST Micoelectronics, vipin.kumar@st.com.
- *
- * SPDX-License-Identifier:    GPL-2.0+
  */
 
 #include <common.h>
+#include <command.h>
+#include <init.h>
 #include <asm/io.h>
 #include <asm/arch/hardware.h>
 #include <asm/arch/spr_misc.h>
@@ -50,6 +51,12 @@ int arch_cpu_init(void)
 #if defined(CONFIG_USB_EHCI_SPEAR)
        periph1_clken |= PERIPH_USBH1 | PERIPH_USBH2;
 #endif
+#if defined(CONFIG_SPEAR_GPIO)
+       periph1_clken |= MISC_GPIO3ENB | MISC_GPIO4ENB;
+#endif
+#if defined(CONFIG_PL022_SPI)
+       periph1_clken |= MISC_SSP1ENB | MISC_SSP2ENB | MISC_SSP3ENB;
+#endif
 
        writel(periph1_clken, &misc_p->periph1_clken);
 
@@ -73,3 +80,37 @@ int print_cpuinfo(void)
        return 0;
 }
 #endif
+
+#if !defined(CONFIG_SPL_BUILD) && defined(CONFIG_NAND_ECC_BCH) && defined(CONFIG_NAND_FSMC)
+static int do_switch_ecc(struct cmd_tbl *cmdtp, int flag, int argc,
+                        char *const argv[])
+{
+       if (argc != 2)
+               goto usage;
+
+       if (strncmp(argv[1], "hw", 2) == 0) {
+               /* 1-bit HW ECC */
+               printf("Switching to 1-bit HW ECC\n");
+               fsmc_nand_switch_ecc(1);
+       } else if (strncmp(argv[1], "bch4", 2) == 0) {
+               /* 4-bit SW ECC BCH4 */
+               printf("Switching to 4-bit SW ECC (BCH4)\n");
+               fsmc_nand_switch_ecc(4);
+       } else {
+               goto usage;
+       }
+
+       return 0;
+
+usage:
+       printf("Usage: nandecc %s\n", cmdtp->usage);
+       return 1;
+}
+
+U_BOOT_CMD(
+       nandecc, 2, 0,  do_switch_ecc,
+       "switch NAND ECC calculation algorithm",
+       "hw|bch4 - Switch between NAND hardware 1-bit HW and"
+       " 4-bit SW BCH\n"
+);
+#endif