From 10adb6c9701c533155c82e680d89324c8d875335 Mon Sep 17 00:00:00 2001 From: Gokul Sriram Palanisamy Date: Thu, 4 Aug 2016 11:55:44 +0530 Subject: [PATCH] qca: Moving env related routines to a common file Adding a common file env.c and moving env related routines to this file to keep them generic. Change-Id: I4541b30278289fa519f78e93d6ccddf22fda0f0c Signed-off-by: Gokul Sriram Palanisamy --- board/qca/common/Makefile | 1 + board/qca/common/env.c | 70 +++++++++++++++++++++++++++++++++++++ board/qca/ipq40xx/ipq40xx.c | 47 ------------------------- 3 files changed, 71 insertions(+), 47 deletions(-) create mode 100644 board/qca/common/env.c diff --git a/board/qca/common/Makefile b/board/qca/common/Makefile index f7f6de5439..c4643748d3 100644 --- a/board/qca/common/Makefile +++ b/board/qca/common/Makefile @@ -1,3 +1,4 @@ obj-y := cmd_bootqca.o obj-y += fdt_info.o obj-y += board_init.o +obj-y += env.o diff --git a/board/qca/common/env.c b/board/qca/common/env.c new file mode 100644 index 0000000000..0d9a6dca99 --- /dev/null +++ b/board/qca/common/env.c @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2016 The Linux Foundation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 and + * only version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include +#include + +extern void nand_env_relocate_spec(void); +extern int nand_env_init(void); + +#ifdef CONFIG_QCA_MMC +extern int mmc_env_init(void); +extern void mmc_env_relocate_spec(void); +#endif + +/* + * Function description: Board specific initialization. + * I/P : None + * O/P : integer, 0 - no error. + */ +int env_init(void) +{ + int ret = 0; + qca_smem_flash_info_t sfi; + + smem_get_boot_flash(&sfi.flash_type, + &sfi.flash_index, + &sfi.flash_chip_select, + &sfi.flash_block_size, + &sfi.flash_density); + + if (sfi.flash_type != SMEM_BOOT_MMC_FLASH) { + ret = nand_env_init(); +#ifdef CONFIG_QCA_MMC + } else { + ret = mmc_env_init(); +#endif + } + + return ret; +} + +void env_relocate_spec(void) +{ + qca_smem_flash_info_t sfi; + + smem_get_boot_flash(&sfi.flash_type, + &sfi.flash_index, + &sfi.flash_chip_select, + &sfi.flash_block_size, + &sfi.flash_density); + + if (sfi.flash_type != SMEM_BOOT_MMC_FLASH) { + nand_env_relocate_spec(); +#ifdef CONFIG_QCA_MMC + } else { + mmc_env_relocate_spec(); +#endif + } + +}; diff --git a/board/qca/ipq40xx/ipq40xx.c b/board/qca/ipq40xx/ipq40xx.c index b5fab5d493..f76f9079fa 100644 --- a/board/qca/ipq40xx/ipq40xx.c +++ b/board/qca/ipq40xx/ipq40xx.c @@ -35,8 +35,6 @@ extern loff_t board_env_offset; extern loff_t board_env_range; extern loff_t board_env_size; -extern int nand_env_init(void); -extern void nand_env_relocate_spec(void); extern int ipq_spi_init(u16); extern int fdt_node_set_part_info(void *blob, int parent_offset, struct mtd_device *dev); @@ -76,51 +74,6 @@ extern void mmc_env_relocate_spec(void); #define BOOT_VERSION 0 #define TZ_VERSION 1 -int env_init(void) -{ - int ret; - - ret = 0; - - qca_smem_flash_info_t sfi; - - smem_get_boot_flash(&sfi.flash_type, - &sfi.flash_index, - &sfi.flash_chip_select, - &sfi.flash_block_size, - &sfi.flash_density); - - if (sfi.flash_type != SMEM_BOOT_MMC_FLASH) { - ret = nand_env_init(); -#ifdef CONFIG_QCA_MMC - } else { - ret = mmc_env_init(); -#endif - } - - return ret; -} - -void env_relocate_spec(void) -{ - qca_smem_flash_info_t sfi; - - smem_get_boot_flash(&sfi.flash_type, - &sfi.flash_index, - &sfi.flash_chip_select, - &sfi.flash_block_size, - &sfi.flash_density); - - if (sfi.flash_type != SMEM_BOOT_MMC_FLASH) { - nand_env_relocate_spec(); -#ifdef CONFIG_QCA_MMC - } else { - mmc_env_relocate_spec(); -#endif - } - -}; - void qca_serial_init(struct ipq_serial_platdata *plat) { int node;