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 <gpalan@codeaurora.org>
This commit is contained in:
Gokul Sriram Palanisamy 2016-08-04 11:55:44 +05:30 committed by Gerrit - the friendly Code Review server
parent 35ee65208c
commit 10adb6c970
3 changed files with 71 additions and 47 deletions

View file

@ -1,3 +1,4 @@
obj-y := cmd_bootqca.o
obj-y += fdt_info.o
obj-y += board_init.o
obj-y += env.o

70
board/qca/common/env.c Normal file
View file

@ -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 <common.h>
#include <asm/arch-qcom-common/smem.h>
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
}
};

View file

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