From 2a12ef637f5d8040f7e4b40dbfb80072f0632f0f Mon Sep 17 00:00:00 2001 From: Gowtham Siddarth Dhandapani Date: Wed, 27 Jul 2016 14:05:09 +0530 Subject: [PATCH] qca: ipq40xx: Enabled full boot chain for eMMC Change-Id: I5e795ff87d2c7a28ef5bd6cf2bbaabdc26cd48e7 Signed-off-by: Gowtham Siddarth Dhandapani --- arch/arm/cpu/armv7/qca/common/cmd_bootqca.c | 23 ++++++++----- .../include/asm/arch-qcom-common/qca_common.h | 33 +++++++++++++++++++ board/qca/ipq40xx/ipq40xx.c | 13 ++++++-- board/qca/ipq40xx/ipq40xx.h | 2 ++ board/qca/ipq40xx/ipq40xx_board_param.h | 16 ++++----- board/qca/ipq807x/ipq807x.c | 2 +- common/env_mmc.c | 14 ++++---- include/configs/ipq40xx.h | 14 ++++++++ 8 files changed, 91 insertions(+), 26 deletions(-) create mode 100644 arch/arm/include/asm/arch-qcom-common/qca_common.h diff --git a/arch/arm/cpu/armv7/qca/common/cmd_bootqca.c b/arch/arm/cpu/armv7/qca/common/cmd_bootqca.c index 7ac89c083e..2145131631 100644 --- a/arch/arm/cpu/armv7/qca/common/cmd_bootqca.c +++ b/arch/arm/cpu/armv7/qca/common/cmd_bootqca.c @@ -21,6 +21,7 @@ #include #include #include +#include #define DLOAD_MAGIC_COOKIE0x10 #define XMK_STR(x)#x @@ -301,15 +302,18 @@ static int do_boot_signedimg(cmd_tbl_t *cmdtp, int flag, int argc, char *const a if (smem_bootconfig_info() == 0) { active_part = get_rootfs_active_partition(); if (active_part) { - ret = find_part_efi(blk_dev, "0:HLOS_1", &disk_info); + ret = get_partition_info_efi_by_name(blk_dev, + "0:HLOS_1", &disk_info); } else { - ret = find_part_efi(blk_dev, "0:HLOS", &disk_info); + ret = get_partition_info_efi_by_name(blk_dev, + "0:HLOS", &disk_info); } } else { - ret = find_part_efi(blk_dev, "0:HLOS", &disk_info); + ret = get_partition_info_efi_by_name(blk_dev, + "0:HLOS", &disk_info); } - if (ret > 0) { + if (ret == 0) { snprintf(runcmd, sizeof(runcmd), "mmc read 0x%x 0x%X 0x%X", CONFIG_SYS_LOAD_ADDR, (uint)disk_info.start, (uint)disk_info.size); @@ -484,15 +488,18 @@ static int do_boot_unsignedimg(cmd_tbl_t *cmdtp, int flag, int argc, char *const if (smem_bootconfig_info() == 0) { active_part = get_rootfs_active_partition(); if (active_part) { - ret = find_part_efi(blk_dev, "0:HLOS_1", &disk_info); + ret = get_partition_info_efi_by_name(blk_dev, + "0:HLOS_1", &disk_info); } else { - ret = find_part_efi(blk_dev, "0:HLOS", &disk_info); + ret = get_partition_info_efi_by_name(blk_dev, + "0:HLOS", &disk_info); } } else { - ret = find_part_efi(blk_dev, "0:HLOS", &disk_info); + ret = get_partition_info_efi_by_name(blk_dev, + "0:HLOS", &disk_info); } - if (ret > 0) { + if (ret == 0) { snprintf(runcmd, sizeof(runcmd), "mmc read 0x%x 0x%x 0x%x", CONFIG_SYS_LOAD_ADDR, (uint)disk_info.start, (uint)disk_info.size); diff --git a/arch/arm/include/asm/arch-qcom-common/qca_common.h b/arch/arm/include/asm/arch-qcom-common/qca_common.h new file mode 100644 index 0000000000..dd36f5a56b --- /dev/null +++ b/arch/arm/include/asm/arch-qcom-common/qca_common.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2015-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. + */ + +#ifndef ___QCA_COMMON_H_ +#define ___QCA_COMMON_H_ +#include + +typedef struct { + uint base; + uint clk_mode; + struct mmc *mmc; + int dev_num; +} qca_mmc; + +int qca_mmc_init(bd_t *, qca_mmc *); +void board_mmc_deinit(void); + +#define MSM_SDC1_BASE 0x7824000 +#define MMC_IDENTIFY_MODE 0 +#define MMC_DATA_TRANSFER_MODE 1 +#define MMC_MODE_HC 0x800 + +#endif /* __QCA_COMMON_H_ */ diff --git a/board/qca/ipq40xx/ipq40xx.c b/board/qca/ipq40xx/ipq40xx.c index 8968ffa0ae..b3f9d51a1a 100644 --- a/board/qca/ipq40xx/ipq40xx.c +++ b/board/qca/ipq40xx/ipq40xx.c @@ -29,6 +29,8 @@ DECLARE_GLOBAL_DATA_PTR; +qca_mmc mmc_host; + loff_t board_env_offset; loff_t board_env_range; loff_t board_env_size; @@ -44,6 +46,12 @@ 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); +extern int mmc_env_init(void); +extern void mmc_env_relocate_spec(void); +extern int mmc_saveenv(void); +extern env_t *mmc_env_ptr; +extern char *mmc_env_name_spec; + /* * Don't have this as a '.bss' variable. The '.bss' and '.rel.dyn' * sections seem to overlap. @@ -650,9 +658,10 @@ int board_mmc_env_init(void) } } blk_dev = mmc_get_dev(mmc_host.dev_num); - ret = find_part_efi(blk_dev, "0:APPSBLENV", &disk_info); + ret = get_partition_info_efi_by_name(blk_dev, + "0:APPSBLENV", &disk_info); - if (ret > 0) { + if (ret == 0) { board_env_offset = disk_info.start * disk_info.blksz; board_env_size = disk_info.size * disk_info.blksz; board_env_range = board_env_size; diff --git a/board/qca/ipq40xx/ipq40xx.h b/board/qca/ipq40xx/ipq40xx.h index 2de77f16b2..2f38a540a9 100644 --- a/board/qca/ipq40xx/ipq40xx.h +++ b/board/qca/ipq40xx/ipq40xx.h @@ -16,6 +16,7 @@ #include #include +#include #include #include @@ -26,6 +27,7 @@ #define MAX_CONF_NAME 5 unsigned int smem_get_board_machtype(void); +extern qca_mmc mmc_host; #define IPQ40XX_EDMA_DEV 1 typedef struct { diff --git a/board/qca/ipq40xx/ipq40xx_board_param.h b/board/qca/ipq40xx/ipq40xx_board_param.h index 28a97eb372..083273d9e7 100644 --- a/board/qca/ipq40xx/ipq40xx_board_param.h +++ b/board/qca/ipq40xx/ipq40xx_board_param.h @@ -1003,8 +1003,8 @@ board_ipq40xx_params_t board_params[] = { #ifdef CONFIG_IPQ40XX_I2C .i2c_cfg = &i2c0, #endif - //.mmc_gpio = mmc_ap_dk04, - //.mmc_gpio_count = ARRAY_SIZE(mmc_ap_dk04), + .mmc_gpio = mmc_ap_dk04, + .mmc_gpio_count = ARRAY_SIZE(mmc_ap_dk04), .spi_nand_available = 0, .nor_nand_available = 0, .nor_emmc_available = 0, @@ -1035,8 +1035,8 @@ board_ipq40xx_params_t board_params[] = { #ifdef CONFIG_IPQ40XX_I2C .i2c_cfg = &i2c0, #endif - //.mmc_gpio = mmc_ap_dk04, - //.mmc_gpio_count = ARRAY_SIZE(mmc_ap_dk04), + .mmc_gpio = mmc_ap_dk04, + .mmc_gpio_count = ARRAY_SIZE(mmc_ap_dk04), .spi_nand_available = 0, .nor_nand_available = 0, .nor_emmc_available = 0, @@ -1065,8 +1065,8 @@ board_ipq40xx_params_t board_params[] = { 0, 1, 2, 3, 4) }, #endif - //.mmc_gpio = mmc_ap_dk04, - //.mmc_gpio_count = ARRAY_SIZE(mmc_ap_dk04), + .mmc_gpio = mmc_ap_dk04, + .mmc_gpio_count = ARRAY_SIZE(mmc_ap_dk04), .spi_nand_available = 0, .nor_nand_available = 0, .nor_emmc_available = 0, @@ -1088,8 +1088,8 @@ board_ipq40xx_params_t board_params[] = { 0, 1, 2, 3, 4) }, #endif - //.mmc_gpio = mmc_ap_dk04, - //.mmc_gpio_count = ARRAY_SIZE(mmc_ap_dk04), + .mmc_gpio = mmc_ap_dk04, + .mmc_gpio_count = ARRAY_SIZE(mmc_ap_dk04), .spi_nand_available = 0, .nor_nand_available = 0, .nor_emmc_available = 1, diff --git a/board/qca/ipq807x/ipq807x.c b/board/qca/ipq807x/ipq807x.c index a476abda29..3b0bec8ee3 100644 --- a/board/qca/ipq807x/ipq807x.c +++ b/board/qca/ipq807x/ipq807x.c @@ -17,7 +17,7 @@ #include #include "ipq807x.h" -#include "../common/qca_common.h" +#include #include #include diff --git a/common/env_mmc.c b/common/env_mmc.c index 96398224cc..17f6d67715 100644 --- a/common/env_mmc.c +++ b/common/env_mmc.c @@ -22,12 +22,12 @@ #error CONFIG_ENV_SIZE_REDUND should be the same as CONFIG_ENV_SIZE #endif -char *env_name_spec = "MMC"; +char *mmc_env_name_spec = "MMC"; #ifdef ENV_IS_EMBEDDED -env_t *env_ptr = &environment; +env_t *mmc_env_ptr = &environment; #else /* ! ENV_IS_EMBEDDED */ -env_t *env_ptr; +env_t *mmc_env_ptr; #endif /* ENV_IS_EMBEDDED */ DECLARE_GLOBAL_DATA_PTR; @@ -54,7 +54,7 @@ __weak int mmc_get_env_addr(struct mmc *mmc, int copy, u32 *env_addr) return 0; } -int env_init(void) +int mmc_env_init(void) { /* use default */ gd->env_addr = (ulong)&default_environment[0]; @@ -137,7 +137,7 @@ static inline int write_env(struct mmc *mmc, unsigned long size, static unsigned char env_flags; #endif -int saveenv(void) +int mmc_saveenv(void) { ALLOC_CACHE_ALIGN_BUFFER(env_t, env_new, 1); struct mmc *mmc = find_mmc_device(CONFIG_SYS_MMC_ENV_DEV); @@ -207,7 +207,7 @@ static inline int read_env(struct mmc *mmc, unsigned long size, } #ifdef CONFIG_ENV_OFFSET_REDUND -void env_relocate_spec(void) +void mmc_env_relocate_spec(void) { #if !defined(ENV_IS_EMBEDDED) struct mmc *mmc; @@ -295,7 +295,7 @@ err: #endif } #else /* ! CONFIG_ENV_OFFSET_REDUND */ -void env_relocate_spec(void) +void mmc_env_relocate_spec(void) { #if !defined(ENV_IS_EMBEDDED) ALLOC_CACHE_ALIGN_BUFFER(char, buf, CONFIG_ENV_SIZE); diff --git a/include/configs/ipq40xx.h b/include/configs/ipq40xx.h index c3f5255807..80c5302fc0 100644 --- a/include/configs/ipq40xx.h +++ b/include/configs/ipq40xx.h @@ -213,4 +213,18 @@ typedef struct { #define CONFIG_BOOTDELAY 2 +#define CONFIG_LIB_UUID + +#define CONFIG_QCA_MMC 1 + +#ifdef CONFIG_QCA_MMC +#define CONFIG_MMC +#define CONFIG_ENV_IS_IN_MMC +#define CONFIG_CMD_MMC +#define CONFIG_SDHCI_QCOM +#define CONFIG_GENERIC_MMC +#define CONFIG_EFI_PARTITION +#define CONFIG_SYS_MMC_ENV_DEV 0 +#endif + #endif /* _IPQ40XX_H */