From f5f074b49e5b2497fecbb7fef14191d4e5ed32c3 Mon Sep 17 00:00:00 2001 From: Vandhiadevan Karunamoorthy Date: Tue, 28 Apr 2020 16:15:57 +0530 Subject: [PATCH] ipq5018: Tiny U-boot: Remove nor from MTD This code changes remove initializing nor as sudo NAND in mtd framework and add sf command support to read from ART partition Signed-off-by: Vandhiadevan Karunamoorthy Change-Id: I39a27a72d9ab966f95d58adb4274660e147df67c --- board/ipq5018/Kconfig | 7 ++++++- board/qca/arm/common/ethaddr.c | 23 +++++++++++++++++++++++ board/qca/arm/ipq5018/ipq5018.c | 4 ++++ configs/ipq5018_defconfig | 2 ++ configs/ipq5018_tiny_defconfig | 2 ++ 5 files changed, 37 insertions(+), 1 deletion(-) diff --git a/board/ipq5018/Kconfig b/board/ipq5018/Kconfig index ef6368ccb5..21b01de09a 100644 --- a/board/ipq5018/Kconfig +++ b/board/ipq5018/Kconfig @@ -36,5 +36,10 @@ config QPIC_SERIAL config IPQ_TINY bool "Enable Tiny support for ipq5018" -endif +config IPQ_MTD_NOR + bool "Register nor in MTD framework for ipq5018" +config IPQ_TINY_SPI_NOR + bool "This config helps to update spi-nor related updated in ipq5018" + +endif diff --git a/board/qca/arm/common/ethaddr.c b/board/qca/arm/common/ethaddr.c index cd7af73610..aa06357a98 100644 --- a/board/qca/arm/common/ethaddr.c +++ b/board/qca/arm/common/ethaddr.c @@ -19,6 +19,10 @@ #include #include #include +#ifdef CONFIG_IPQ_TINY_SPI_NOR +#include +#include +#endif #ifdef CONFIG_QCA_MMC #ifndef CONFIG_SDHCI_SUPPORT @@ -46,6 +50,10 @@ int get_eth_mac_address(uchar *enetaddr, uint no_of_macs) struct mmc *mmc; char mmc_blks[512]; #endif +#ifdef CONFIG_IPQ_TINY_SPI_NOR + struct spi_flash *flash = NULL; +#endif + if (sfi->flash_type != SMEM_BOOT_MMC_FLASH) { if (qca_smem_flash_info.flash_type == SMEM_BOOT_SPI_FLASH) flash_type = CONFIG_SPI_FLASH_INFO_IDX; @@ -70,8 +78,23 @@ int get_eth_mac_address(uchar *enetaddr, uint no_of_macs) art_offset = ((loff_t) qca_smem_flash_info.flash_block_size * start_blocks); +#ifdef CONFIG_IPQ_TINY_SPI_NOR + flash = spi_flash_probe(CONFIG_SF_DEFAULT_BUS, CONFIG_SF_DEFAULT_CS, + CONFIG_SF_DEFAULT_SPEED, CONFIG_SF_DEFAULT_MODE); + if (flash == NULL){ + printf("No SPI flash device found\n"); + ret = -1; + } else { + ret = spi_flash_read(flash, art_offset, length, enetaddr); + } + /* + * Avoid unused warning + */ + (void)flash_type; +#else ret = nand_read(&nand_info[flash_type], art_offset, &length, enetaddr); +#endif if (ret < 0) printf("ART partition read failed..\n"); #ifdef CONFIG_QCA_MMC diff --git a/board/qca/arm/ipq5018/ipq5018.c b/board/qca/arm/ipq5018/ipq5018.c index 75b9a02f98..9e43304bed 100644 --- a/board/qca/arm/ipq5018/ipq5018.c +++ b/board/qca/arm/ipq5018/ipq5018.c @@ -42,7 +42,9 @@ DECLARE_GLOBAL_DATA_PTR; struct sdhci_host mmc_host; #endif +#ifdef CONFIG_IPQ_MTD_NOR extern int ipq_spi_init(u16); +#endif const char *rsvd_node = "/reserved-memory"; const char *del_node[] = {"uboot", @@ -528,7 +530,9 @@ void board_nand_init(void) gpio_node = fdt_path_offset(gd->fdt_blob, "/spi/spi_gpio"); if (gpio_node >= 0) { qca_gpio_init(gpio_node); +#ifdef CONFIG_IPQ_MTD_NOR ipq_spi_init(CONFIG_IPQ_SPI_NOR_INFO_IDX); +#endif } #endif } diff --git a/configs/ipq5018_defconfig b/configs/ipq5018_defconfig index 04249e0f1c..6fcee0f7d8 100644 --- a/configs/ipq5018_defconfig +++ b/configs/ipq5018_defconfig @@ -223,6 +223,8 @@ CONFIG_QPIC_SERIAL=y # CONFIG_DM_ETH is not set # CONFIG_PHYLIB is not set # CONFIG_NETDEVICES is not set +CONFIG_IPQ_MTD_NOR=y +# CONFIG_IPQ_TINY_SPI_NOR is not set # # PCI diff --git a/configs/ipq5018_tiny_defconfig b/configs/ipq5018_tiny_defconfig index f788444024..597a2610aa 100644 --- a/configs/ipq5018_tiny_defconfig +++ b/configs/ipq5018_tiny_defconfig @@ -223,6 +223,8 @@ CONFIG_SIMPLE_BUS=y # CONFIG_DM_ETH is not set # CONFIG_PHYLIB is not set # CONFIG_NETDEVICES is not set +# CONFIG_IPQ_MTD_NOR is not set +CONFIG_IPQ_TINY_SPI_NOR=y # # PCI