diff --git a/arch/arm/dts/ipq5332-soc.dtsi b/arch/arm/dts/ipq5332-soc.dtsi index fb1f74392e..1320b71922 100644 --- a/arch/arm/dts/ipq5332-soc.dtsi +++ b/arch/arm/dts/ipq5332-soc.dtsi @@ -56,7 +56,7 @@ mmc: sdhci@7804000 { compatible = "qcom,sdhci-msm"; - status = "disabled"; + status = "okay"; }; pci0: pci@20000000 { diff --git a/arch/arm/include/asm/arch-qca-common/qca_common.h b/arch/arm/include/asm/arch-qca-common/qca_common.h index 1be3846aa0..77da3dee5b 100644 --- a/arch/arm/include/asm/arch-qca-common/qca_common.h +++ b/arch/arm/include/asm/arch-qca-common/qca_common.h @@ -95,6 +95,12 @@ int qca_mmc_init(bd_t *, qca_mmc *); int board_mmc_env_init(qca_mmc mmc_host); #endif +#ifdef CONFIG_QCA_MMC +int do_mmc_init(void); +#endif +#ifdef CONFIG_QPIC_SERIAL +void do_nand_init(void); +#endif int ipq_board_usb_init(void); int spi_nand_init(void); void board_mmc_deinit(void); diff --git a/board/qca/arm/ipq5332/ipq5332.c b/board/qca/arm/ipq5332/ipq5332.c index dba8200155..4f1a7651da 100644 --- a/board/qca/arm/ipq5332/ipq5332.c +++ b/board/qca/arm/ipq5332/ipq5332.c @@ -125,10 +125,11 @@ int dump_entries_s = ARRAY_SIZE(dumpinfo_s); void fdt_fixup_flash(void *blob) { - if (gd->bd->bi_arch_number == MACH_TYPE_IPQ5332_EMULATION) - return; + uint32_t flash_type = SMEM_BOOT_NO_FLASH; - if ((gd->bd->bi_arch_number >> FLASH_SEL_BIT) & 0x1) { + get_current_flash_type(&flash_type); + if (flash_type == SMEM_BOOT_NORPLUSEMMC || + flash_type == SMEM_BOOT_MMC_FLASH ) { parse_fdt_fixup(LINUX_NAND_DTS"%"STATUS_DISABLED, blob); parse_fdt_fixup(LINUX_MMC_DTS"%"STATUS_OK, blob); @@ -149,6 +150,10 @@ void ipq_uboot_fdt_fixup(void) /* fix peripherals required for basic board bring up * like flash etc. */ + /* This becomes obsolete as nand or emmc will be + * initialized based on the boot type. Below code + * will be removed later + */ if ((machid >> FLASH_SEL_BIT) & 0x1) { flash = "mmc"; @@ -280,11 +285,10 @@ __weak void board_mmc_deinit(void) return; } -int board_mmc_init(bd_t *bis) +int do_mmc_init(void) { int node, gpio_node; - int ret = 0; - qca_smem_flash_info_t *sfi = &qca_smem_flash_info; + node = fdt_path_offset(gd->fdt_blob, "mmc"); if (node < 0) { printf("sdhci: Node Not found, skipping initialization\n"); @@ -293,7 +297,7 @@ int board_mmc_init(bd_t *bis) if (!fdtdec_get_is_enabled(gd->fdt_blob, node)) { printf("MMC: disabled, skipping initialization\n"); - return ret; + return -1; } gpio_node = fdt_subnode_offset(gd->fdt_blob, node, "mmc_gpio"); @@ -315,6 +319,26 @@ int board_mmc_init(bd_t *bis) return -1; } + return 0; +} + +int board_mmc_init(bd_t *bis) +{ + int ret = 0; + uint32_t flash_type = SMEM_BOOT_NO_FLASH; + qca_smem_flash_info_t *sfi = &qca_smem_flash_info; + char *name = NULL; +#ifdef CONFIG_QPIC_SERIAL + name = nand_info[CONFIG_NAND_FLASH_INFO_IDX].name; +#endif + + get_current_flash_type(&flash_type); + + if (flash_type != SMEM_BOOT_NORPLUSNAND && + flash_type != SMEM_BOOT_QSPI_NAND_FLASH && + !name) + ret = do_mmc_init(); + if (!ret && sfi->flash_type == SMEM_BOOT_MMC_FLASH) { ret = board_mmc_env_init(mmc_host); } @@ -707,21 +731,34 @@ void reset_cpu(unsigned long a) while(1); } -void board_nand_init(void) -{ #ifdef CONFIG_QPIC_SERIAL +void do_nand_init(void) +{ /* check for nand node in dts * if nand node in dts is disabled then * simply return from here without * initializing */ int node; + node = fdt_path_offset(gd->fdt_blob, "/nand-controller"); if (!fdtdec_get_is_enabled(gd->fdt_blob, node)) { printf("QPIC: disabled, skipping initialization\n"); } else { qpic_nand_init(NULL); } +} +#endif + +void board_nand_init(void) +{ +#ifdef CONFIG_QPIC_SERIAL + uint32_t flash_type = SMEM_BOOT_NO_FLASH; + + get_current_flash_type(&flash_type); + if (flash_type != SMEM_BOOT_NORPLUSEMMC && + flash_type != SMEM_BOOT_MMC_FLASH) + do_nand_init(); #endif #ifdef CONFIG_QCA_SPI int gpio_node; diff --git a/common/cmd_flashwrite.c b/common/cmd_flashwrite.c index 8eddf24836..31c95aa117 100644 --- a/common/cmd_flashwrite.c +++ b/common/cmd_flashwrite.c @@ -23,6 +23,10 @@ #include #include #include +#include +#include +#include + DECLARE_GLOBAL_DATA_PTR; #ifndef CONFIG_SDHCI_SUPPORT @@ -547,6 +551,48 @@ char * const argv[]) } #endif +#ifdef CONFIG_CMD_IPQ_FLASH_INIT +static int do_flash_init(cmd_tbl_t *cmdtp, int flag, int argc, +char * const argv[]) +{ + int ret = 0; + char *name = NULL; + void *blk_dev = NULL; + + if (argc < 2) + return CMD_RET_USAGE; + +#ifdef CONFIG_QCA_MMC + blk_dev = (void *)(mmc_get_dev(mmc_host.dev_num)); + +#endif +#ifdef CONFIG_QPIC_SERIAL + int nand_dev = CONFIG_NAND_FLASH_INFO_IDX; + name = nand_info[nand_dev].name; +#endif + + if (name || blk_dev) { + printf("Either NAND or eMMC already initialized\n"); + return 0; + } + +#ifdef CONFIG_QCA_MMC + if (!strncmp(argv[1], "mmc", 3)) { + ret = do_mmc_init(); + if (!ret) + ret = run_command("mmc info", 0); + } +#endif +#ifdef CONFIG_QPIC_SERIAL + if (!strncmp(argv[1], "nand", 4)) { + do_nand_init(); + ret = (nand_info[nand_dev].name) ? 0: -1; + } +#endif + + return ret; +} +#endif U_BOOT_CMD( flash, 4, 0, do_flash, "flash part_name \n" @@ -575,3 +621,11 @@ U_BOOT_CMD( "xtract the image and flash \n" ); #endif + +#ifdef CONFIG_CMD_IPQ_FLASH_INIT +U_BOOT_CMD( + flashinit, 2, 0, do_flash_init, + "flashinit nand/mmc \n", + "Init the flash \n" +); +#endif diff --git a/include/configs/ipq5332.h b/include/configs/ipq5332.h index bc141d04dd..b84a26ece7 100644 --- a/include/configs/ipq5332.h +++ b/include/configs/ipq5332.h @@ -440,4 +440,6 @@ extern loff_t board_env_size; #undef CONFIG_BOOTM_RTEMS #undef CONFIG_BOOTM_VXWORKS +#define CONFIG_CMD_IPQ_FLASH_INIT + #endif /* _IPQ5332_H */ diff --git a/tools/pack.py b/tools/pack.py index f92dfc4547..373540efc9 100644 --- a/tools/pack.py +++ b/tools/pack.py @@ -1398,6 +1398,12 @@ class Pack(object): if flinfo.type == "emmc" and image_type == "all": first = True + if ARCH_NAME in ["ipq5332"]: + if flinfo.type == "nand" or self.flash_type == "norplusnand": + script.append("flashinit nand") + elif flinfo.type == "emmc" or self.flash_type == "norplusemmc": + script.append("flashinit mmc") + for index in range(parts_length): filename = "" diff --git a/tools/pack_v2.py b/tools/pack_v2.py index b71ea1e7a2..e9fa85d33a 100644 --- a/tools/pack_v2.py +++ b/tools/pack_v2.py @@ -865,6 +865,11 @@ class Pack(object): if flinfo.type == "emmc" and image_type == "all": first = True + if flinfo.type == "nand" or self.flash_type == "norplusnand": + script.append("flashinit nand") + elif flinfo.type == "emmc" or self.flash_type == "norplusemmc": + script.append("flashinit mmc") + section = parts[1] imgs = section.findall('img_name') pnames = section.findall('name')