ipq5332: avoid multiple machid for nand/mmc boot

added boot type based nand or emmc flash selection.
So machid based flash selection becomes obsolete.

Change-Id: I96fa43d31d23397fa249e02f62b905d6e4e67770
Signed-off-by: Rajkumar Ayyasamy <quic_arajkuma@quicinc.com>
This commit is contained in:
Rajkumar Ayyasamy 2022-11-22 07:23:31 +05:30 committed by Gerrit - the friendly Code Review server
parent 6f9f184fd4
commit 425d52cd85
7 changed files with 120 additions and 10 deletions

View file

@ -56,7 +56,7 @@
mmc: sdhci@7804000 {
compatible = "qcom,sdhci-msm";
status = "disabled";
status = "okay";
};
pci0: pci@20000000 {

View file

@ -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);

View file

@ -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;

View file

@ -23,6 +23,10 @@
#include <mmc.h>
#include <sdhci.h>
#include <ubi_uboot.h>
#include <fdtdec.h>
#include <asm/arch-qca-common/qpic_nand.h>
#include <nand.h>
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

View file

@ -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 */

View file

@ -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 = ""

View file

@ -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')