diff --git a/arch/arm/cpu/armv7/qca/common/smem.c b/arch/arm/cpu/armv7/qca/common/smem.c index 0888795b1a..4fdf542e73 100644 --- a/arch/arm/cpu/armv7/qca/common/smem.c +++ b/arch/arm/cpu/armv7/qca/common/smem.c @@ -47,7 +47,7 @@ typedef struct smem_pmic_type unsigned pmic_die_revision; }pmic_type; -struct qca_platfrom { +struct qca_platform { unsigned format; unsigned id; unsigned version; @@ -199,7 +199,7 @@ int smem_ptable_init(void) return -ENOMSG; if (smem_ptable.magic[0] != _SMEM_PTABLE_MAGIC_1 || - smem_ptable.magic[1] != _SMEM_PTABLE_MAGIC_2) + smem_ptable.magic[1] != _SMEM_PTABLE_MAGIC_2) return -ENOMSG; debug("smem ptable found: ver: %d len: %d\n", @@ -216,9 +216,10 @@ int smem_bootconfig_info(void) unsigned ret; ret = smem_read_alloc_entry(SMEM_BOOT_DUALPARTINFO, - &qca_smem_bootconfig_info, sizeof(qca_smem_bootconfig_info_t)); - if ((ret != 0) || (qca_smem_bootconfig_info.magic - != _SMEM_DUAL_BOOTINFO_MAGIC)) + &qca_smem_bootconfig_info, sizeof(qca_smem_bootconfig_info_t)); + if ((ret != 0) || + (qca_smem_bootconfig_info.magic_start != _SMEM_DUAL_BOOTINFO_MAGIC_START) || + (qca_smem_bootconfig_info.magic_end != _SMEM_DUAL_BOOTINFO_MAGIC_END)) return -ENOMSG; return 0; @@ -263,6 +264,7 @@ unsigned int get_partition_table_offset(void) int smem_getpart(char *part_name, uint32_t *start, uint32_t *size) { unsigned i; + qca_smem_flash_info_t *sfi = &qca_smem_flash_info; struct smem_ptn *p; for (i = 0; i < smem_ptable.len; i++) { @@ -276,7 +278,17 @@ int smem_getpart(char *part_name, uint32_t *start, uint32_t *size) p = &smem_ptable.parts[i]; *start = p->start; - *size = p->size; + + if (p->size == (~0u)) { + /* + * Partition size is 'till end of device', calculate + * appropriately + */ + *size = (nand_info[nand_env_device].size / + sfi->flash_block_size) - p->start; + } else { + *size = p->size; + } return 0; } @@ -355,19 +367,65 @@ int smem_get_build_version(char *version_name, int buf_size, int index) unsigned int smem_get_board_platform_type() { - struct qca_platfrom platform_type; + struct qca_platform platform_type; + struct smem_machid_info machid_info; + unsigned smem_status; unsigned int machid = 0; + + smem_status = smem_read_alloc_entry(SMEM_MACHID_INFO_LOCATION, + &machid_info, sizeof(machid_info)); + if (!smem_status) { + machid = machid_info.machid; + return machid; + } + smem_read_alloc_entry(SMEM_HW_SW_BUILD_ID, &platform_type, - sizeof(struct qca_platfrom)); + sizeof(struct qca_platform)); machid = ((platform_type.hw_platform << 24) | - ((SOCINFO_VERSION_MAJOR(platform_type.platform_version)) << 16) | - ((SOCINFO_VERSION_MINOR(platform_type.platform_version)) << 8) | - (platform_type.hw_platform_subtype)); + ((SOCINFO_VERSION_MAJOR(platform_type.platform_version)) << 16) | + ((SOCINFO_VERSION_MINOR(platform_type.platform_version)) << 8) | + (platform_type.hw_platform_subtype)); return machid; } +int ipq_smem_get_socinfo_cpu_type(uint32_t *cpu_type) +{ + int smem_status; + struct qca_platform platform_type; + + smem_status = smem_read_alloc_entry(SMEM_HW_SW_BUILD_ID, + &platform_type, sizeof(struct qca_platform)); + + if (!smem_status) { + *cpu_type = platform_type.id; + debug("smem: socinfo - cpu type = %d\n",*cpu_type); + } else { + printf("smem: Get socinfo failed\n"); + } + + return smem_status; +} + +int ipq_smem_get_socinfo_version(uint32_t *version) +{ + int smem_status; + struct qca_platform platform_type; + + smem_status = smem_read_alloc_entry(SMEM_HW_SW_BUILD_ID, + &platform_type, sizeof(struct qca_platform)); + + if (!smem_status) { + *version = platform_type.version; + debug("smem: socinfo - version = 0x%x\n",*version); + } else { + printf("smem: Get socinfo failed\n"); + } + + return smem_status; +} + /* * smem_ptable_init - initializes RAM partition table from SMEM * @@ -517,16 +575,28 @@ int do_smeminfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { qca_smem_flash_info_t *sfi = &qca_smem_flash_info; int i; + uint32_t bsize; - printf( "flash_type: 0x%x\n" - "flash_index: 0x%x\n" - "flash_chip_select: 0x%x\n" - "flash_block_size: 0x%x\n" - "flash_density: 0x%x\n" - "partition table offset 0x%x\n", - sfi->flash_type, sfi->flash_index, - sfi->flash_chip_select, sfi->flash_block_size, - sfi->flash_density, get_partition_table_offset()); + if(sfi->flash_density != 0) { + printf( "flash_type: 0x%x\n" + "flash_index: 0x%x\n" + "flash_chip_select: 0x%x\n" + "flash_block_size: 0x%x\n" + "flash_density: 0x%x\n" + "partition table offset 0x%x\n", + sfi->flash_type, sfi->flash_index, + sfi->flash_chip_select, sfi->flash_block_size, + sfi->flash_density, get_partition_table_offset()); + } else { + printf( "flash_type: 0x%x\n" + "flash_index: 0x%x\n" + "flash_chip_select: 0x%x\n" + "flash_block_size: 0x%x\n" + "partition table offset 0x%x\n", + sfi->flash_type, sfi->flash_index, + sfi->flash_chip_select, sfi->flash_block_size, + get_partition_table_offset()); + } if (smem_ptable.len > 0) { printf("%-3s: " smem_ptn_name_fmt " %10s %16s %16s\n", @@ -538,12 +608,21 @@ int do_smeminfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) for (i = 0; i < smem_ptable.len; i++) { struct smem_ptn *p = &smem_ptable.parts[i]; loff_t psize; + bsize = get_part_block_size(p, sfi); - psize = ((loff_t)p->size) * sfi->flash_block_size; + if (p->size == (~0u)) { + /* + * Partition size is 'till end of device', calculate + * appropriately + */ + psize = nand_info[nand_env_device].size + - (((loff_t)p->start) * bsize); + } else { + psize = ((loff_t)p->size) * bsize; + } printf("%3d: " smem_ptn_name_fmt " 0x%08x %#16llx %#16llx\n", - i, p->name, p->attr, ((loff_t)p->start) * - sfi->flash_block_size, psize); + i, p->name, p->attr, ((loff_t)p->start) * bsize, psize); } return 0; } diff --git a/arch/arm/include/asm/arch-qcom-common/smem.h b/arch/arm/include/asm/arch-qcom-common/smem.h index 3d6a7f9d32..d8e9783653 100644 --- a/arch/arm/include/asm/arch-qcom-common/smem.h +++ b/arch/arm/include/asm/arch-qcom-common/smem.h @@ -123,18 +123,23 @@ struct per_part_info uint32_t upgraded; }; -#define NUM_ALT_PARTITION 3 +#define NUM_ALT_PARTITION 8 typedef struct { -#define _SMEM_DUAL_BOOTINFO_MAGIC 0xA5A3A1A0 +#define _SMEM_DUAL_BOOTINFO_MAGIC_START 0xA3A2A1A0 +#define _SMEM_DUAL_BOOTINFO_MAGIC_END 0xB3B2B1B0 + /* Magic number for identification when reading from flash */ - uint32_t magic; + uint32_t magic_start; /* upgradeinprogress indicates to attempting the upgrade */ - uint32_t upgradeinprogress; + uint32_t age; /* numaltpart indicate number of alt partitions */ uint32_t numaltpart; struct per_part_info per_part_entry[NUM_ALT_PARTITION]; + + uint32_t magic_end; + } qca_smem_bootconfig_info_t; extern qca_smem_bootconfig_info_t qca_smem_bootconfig_info; @@ -143,5 +148,6 @@ int smem_bootconfig_info(void); unsigned int get_rootfs_active_partition(void); unsigned int get_mibib_active_partition(void); void qca_smem_part_to_mtdparts(char *mtdid); - +int ipq_smem_get_socinfo_cpu_type(uint32_t *cpu_type); +int ipq_smem_get_socinfo_version(uint32_t *version); #endif diff --git a/board/qca/ipq40xx/ipq40xx.h b/board/qca/ipq40xx/ipq40xx.h index 5570b3940b..698ec8339b 100644 --- a/board/qca/ipq40xx/ipq40xx.h +++ b/board/qca/ipq40xx/ipq40xx.h @@ -98,22 +98,23 @@ typedef struct { } __attribute__ ((__packed__)) board_ipq40xx_params_t; typedef enum { - SMEM_SPINLOCK_ARRAY = 7, - SMEM_AARM_PARTITION_TABLE = 9, - SMEM_HW_SW_BUILD_ID = 137, - SMEM_USABLE_RAM_PARTITION_TABLE = 402, - SMEM_POWER_ON_STATUS_INFO = 403, - SMEM_IMAGE_VERSION_TABLE = 469, - SMEM_BOOT_FLASH_TYPE = 478, - SMEM_BOOT_FLASH_INDEX = 479, - SMEM_BOOT_FLASH_CHIP_SELECT = 480, - SMEM_BOOT_FLASH_BLOCK_SIZE = 481, - SMEM_BOOT_FLASH_DENSITY = 482, - SMEM_PARTITION_TABLE_OFFSET = 483, - SMEM_BOOT_DUALPARTINFO = 484, - SMEM_FIRST_VALID_TYPE = SMEM_SPINLOCK_ARRAY, - SMEM_LAST_VALID_TYPE = SMEM_PARTITION_TABLE_OFFSET, - SMEM_MAX_SIZE = SMEM_PARTITION_TABLE_OFFSET + 1, + SMEM_SPINLOCK_ARRAY = 7, + SMEM_AARM_PARTITION_TABLE = 9, + SMEM_HW_SW_BUILD_ID = 137, + SMEM_USABLE_RAM_PARTITION_TABLE = 402, + SMEM_POWER_ON_STATUS_INFO = 403, + SMEM_MACHID_INFO_LOCATION = 425, + SMEM_IMAGE_VERSION_TABLE = 469, + SMEM_BOOT_FLASH_TYPE = 478, + SMEM_BOOT_FLASH_INDEX = 479, + SMEM_BOOT_FLASH_CHIP_SELECT = 480, + SMEM_BOOT_FLASH_BLOCK_SIZE = 481, + SMEM_BOOT_FLASH_DENSITY = 482, + SMEM_PARTITION_TABLE_OFFSET = 483, + SMEM_BOOT_DUALPARTINFO = 484, + SMEM_FIRST_VALID_TYPE = SMEM_SPINLOCK_ARRAY, + SMEM_LAST_VALID_TYPE = SMEM_BOOT_DUALPARTINFO, + SMEM_MAX_SIZE = SMEM_PARTITION_TABLE_OFFSET + 1, } smem_mem_type_t; /* Reserved-memory node names*/ diff --git a/board/qca/ipq806x/ipq806x.h b/board/qca/ipq806x/ipq806x.h index 48ee5112dd..a2c8ba7b0a 100644 --- a/board/qca/ipq806x/ipq806x.h +++ b/board/qca/ipq806x/ipq806x.h @@ -18,4 +18,28 @@ #include #define GSBI4_BASE 0x16300000 + +typedef enum { + SMEM_SPINLOCK_ARRAY = 7, + SMEM_AARM_PARTITION_TABLE = 9, + SMEM_APPS_BOOT_MODE = 106, + SMEM_HW_SW_BUILD_ID = 137, + SMEM_USABLE_RAM_PARTITION_TABLE = 402, + SMEM_POWER_ON_STATUS_INFO = 403, + SMEM_RLOCK_AREA = 404, + SMEM_BOOT_INFO_FOR_APPS = 418, + SMEM_BOOT_FLASH_TYPE = 421, + SMEM_BOOT_FLASH_INDEX = 422, + SMEM_BOOT_FLASH_CHIP_SELECT = 423, + SMEM_BOOT_FLASH_BLOCK_SIZE = 424, + SMEM_MACHID_INFO_LOCATION = 425, + SMEM_BOOT_DUALPARTINFO = 427, + SMEM_PARTITION_TABLE_OFFSET = 428, + SMEM_IMAGE_VERSION_TABLE = 469, + SMEM_BOOT_FLASH_DENSITY = 482, + SMEM_FIRST_VALID_TYPE = SMEM_SPINLOCK_ARRAY, + SMEM_LAST_VALID_TYPE = SMEM_BOOT_FLASH_DENSITY, + SMEM_MAX_SIZE = SMEM_PARTITION_TABLE_OFFSET + 1, +} smem_mem_type_t; + #endif /* _IPQ806X_H_ */ diff --git a/board/qca/ipq807x/ipq807x.h b/board/qca/ipq807x/ipq807x.h index f36fb8d215..4ed38548bf 100644 --- a/board/qca/ipq807x/ipq807x.h +++ b/board/qca/ipq807x/ipq807x.h @@ -31,22 +31,23 @@ #define GCC_BLSP1_UART1_APPS_CBCR 0x0180203c typedef enum { - SMEM_SPINLOCK_ARRAY = 7, - SMEM_AARM_PARTITION_TABLE = 9, - SMEM_HW_SW_BUILD_ID = 137, - SMEM_USABLE_RAM_PARTITION_TABLE = 402, - SMEM_POWER_ON_STATUS_INFO = 403, - SMEM_IMAGE_VERSION_TABLE = 469, - SMEM_BOOT_FLASH_TYPE = 478, - SMEM_BOOT_FLASH_INDEX = 479, - SMEM_BOOT_FLASH_CHIP_SELECT = 480, - SMEM_BOOT_FLASH_BLOCK_SIZE = 481, - SMEM_BOOT_FLASH_DENSITY = 482, - SMEM_PARTITION_TABLE_OFFSET = 483, - SMEM_BOOT_DUALPARTINFO = 484, - SMEM_FIRST_VALID_TYPE = SMEM_SPINLOCK_ARRAY, - SMEM_LAST_VALID_TYPE = SMEM_PARTITION_TABLE_OFFSET, - SMEM_MAX_SIZE = SMEM_PARTITION_TABLE_OFFSET + 1, + SMEM_SPINLOCK_ARRAY = 7, + SMEM_AARM_PARTITION_TABLE = 9, + SMEM_HW_SW_BUILD_ID = 137, + SMEM_USABLE_RAM_PARTITION_TABLE = 402, + SMEM_POWER_ON_STATUS_INFO = 403, + SMEM_MACHID_INFO_LOCATION = 425, + SMEM_IMAGE_VERSION_TABLE = 469, + SMEM_BOOT_FLASH_TYPE = 478, + SMEM_BOOT_FLASH_INDEX = 479, + SMEM_BOOT_FLASH_CHIP_SELECT = 480, + SMEM_BOOT_FLASH_BLOCK_SIZE = 481, + SMEM_BOOT_FLASH_DENSITY = 482, + SMEM_PARTITION_TABLE_OFFSET = 483, + SMEM_BOOT_DUALPARTINFO = 484, + SMEM_FIRST_VALID_TYPE = SMEM_SPINLOCK_ARRAY, + SMEM_LAST_VALID_TYPE = SMEM_BOOT_DUALPARTINFO, + SMEM_MAX_SIZE = SMEM_PARTITION_TABLE_OFFSET + 1, } smem_mem_type_t; /* Reserved-memory node names*/