diff options
author | Peng Fan <Peng.Fan@freescale.com> | 2015-01-30 17:07:56 +0800 |
---|---|---|
committer | Max Krummenacher <max.krummenacher@toradex.com> | 2016-03-09 14:42:10 +0100 |
commit | ffeb5e2feee004393a87fd96a12f85bfec26f468 (patch) | |
tree | 1a4ca9cf312e04f6b38b8a4bcfe4e889577076a0 /tools | |
parent | 83429ea6af4094a05e87d3f00661db6918bafcb2 (diff) |
MLK-10186-2 imximage: support new command
Since rom code supports clear bit and check data command, and new ddrc
needs such commands, add clear bit and check data command in imximage.c.
CHECK_DATA 4 xxxx bit
This command is dead loop until bit set at address xxxx.
CLR_BIT 4 xxxx bit
This command is to clear bit at address xxxx.
Signed-off-by: Peng Fan <Peng.Fan@freescale.com>
(cherry picked from commit 257600d197bf9a58a2b8d08419296aaf901d850d)
Conflicts:
tools/imximage.c
Diffstat (limited to 'tools')
-rw-r--r-- | tools/imximage.c | 85 | ||||
-rw-r--r-- | tools/imximage.h | 21 |
2 files changed, 88 insertions, 18 deletions
diff --git a/tools/imximage.c b/tools/imximage.c index 7952210ebf5..a3af2c83e5b 100644 --- a/tools/imximage.c +++ b/tools/imximage.c @@ -6,6 +6,8 @@ * Marvell Semiconductor <www.marvell.com> * Written-by: Prafulla Wadaskar <prafulla@marvell.com> * + * Copyright (C) 2014-2015 Freescale Semiconductor, Inc. + * * SPDX-License-Identifier: GPL-2.0+ */ @@ -22,6 +24,8 @@ static table_entry_t imximage_cmds[] = { {CMD_BOOT_FROM, "BOOT_FROM", "boot command", }, {CMD_BOOT_OFFSET, "BOOT_OFFSET", "Boot offset", }, {CMD_DATA, "DATA", "Reg Write Data", }, + {CMD_CLR_BIT, "CLR_BIT", "Reg clear bit", }, + {CMD_CHECK_DATA, "CHECK_DATA", "Reg Check Data", }, {CMD_CSF, "CSF", "Command Sequence File", }, {CMD_IMAGE_VERSION, "IMAGE_VERSION", "image version", }, #ifdef CONFIG_USE_PLUGIN @@ -89,6 +93,7 @@ static set_imx_hdr_t set_imx_hdr; static uint32_t max_dcd_entries; static uint32_t *header_size_ptr; static uint32_t *csf_ptr; +static uint32_t dataindex; static uint32_t get_cfg_value(char *token, char *name, int linenr) { @@ -138,7 +143,7 @@ static void err_imximage_version(int version) } static void set_dcd_val_v1(struct imx_header *imxhdr, char *name, int lineno, - int fld, uint32_t value, uint32_t off) + int fld, int cmd, uint32_t value, uint32_t off) { dcd_v1_t *dcd_v1 = &imxhdr->header.hdr_v1.dcd_table; @@ -166,16 +171,39 @@ static void set_dcd_val_v1(struct imx_header *imxhdr, char *name, int lineno, } static void set_dcd_val_v2(struct imx_header *imxhdr, char *name, int lineno, - int fld, uint32_t value, uint32_t off) + int fld, int cmd, uint32_t value, uint32_t off) { dcd_v2_t *dcd_v2 = &imxhdr->header.hdr_v2.data.dcd_table; + dcd_command_t *dcd_command_block = (dcd_command_t *)& + dcd_v2->dcd_data[dataindex]; switch (fld) { + case CFG_COMMAND: + /* update header */ + if (cmd == CMD_DATA) { + dcd_command_block->tag = DCD_WRITE_DATA_COMMAND_TAG; + dcd_command_block->length = cpu_to_be16(off * + sizeof(dcd_addr_data_t) + 4); + dcd_command_block->param = DCD_WRITE_DATA_PARAM; + } else if (cmd == CMD_CLR_BIT) { + dcd_command_block->tag = DCD_WRITE_DATA_COMMAND_TAG; + dcd_command_block->length = cpu_to_be16(off * + sizeof(dcd_addr_data_t) + 4); + dcd_command_block->param = DCD_CLR_BIT_PARAM; + } else if (CMD_CHECK_DATA) { + dcd_command_block->tag = DCD_CHECK_DATA_COMMAND_TAG; + /* + * check data command only supports one entry, + * so use 0xC = size(address + value + command). + */ + dcd_command_block->length = cpu_to_be16(0xC); + dcd_command_block->param = DCD_CHECK_DATA_PARAM; + } case CFG_REG_ADDRESS: - dcd_v2->addr_data[off].addr = cpu_to_be32(value); + dcd_command_block->addr_data[off].addr = cpu_to_be32(value); break; case CFG_REG_VALUE: - dcd_v2->addr_data[off].value = cpu_to_be32(value); + dcd_command_block->addr_data[off].value = cpu_to_be32(value); break; default: break; @@ -207,13 +235,14 @@ static void set_dcd_rst_v2(struct imx_header *imxhdr, uint32_t dcd_len, dcd_v2_t *dcd_v2 = &imxhdr->header.hdr_v2.data.dcd_table; dcd_v2->header.tag = DCD_HEADER_TAG; + /* + * dataindex does not contain the last dcd block, + * see how dataindex is updated. + */ dcd_v2->header.length = cpu_to_be16( - dcd_len * sizeof(dcd_addr_data_t) + 8); + (dataindex + 1) * 4 + dcd_len * + sizeof(dcd_addr_data_t) + 4); dcd_v2->header.version = DCD_VERSION; - dcd_v2->write_dcd_command.tag = DCD_COMMAND_TAG; - dcd_v2->write_dcd_command.length = cpu_to_be16( - dcd_len * sizeof(dcd_addr_data_t) + 4); - dcd_v2->write_dcd_command.param = DCD_COMMAND_PARAM; } } @@ -543,7 +572,7 @@ static void parse_cfg_cmd(struct imx_header *imxhdr, int32_t cmd, char *token, break; case CMD_DATA: value = get_cfg_value(token, name, lineno); - (*set_dcd_val)(imxhdr, name, lineno, fld, value, dcd_len); + (*set_dcd_val)(imxhdr, name, lineno, fld, cmd, value, dcd_len); if (unlikely(cmd_ver_first != 1)) cmd_ver_first = 0; break; @@ -567,7 +596,8 @@ static void parse_cfg_cmd(struct imx_header *imxhdr, int32_t cmd, char *token, } static void parse_cfg_fld(struct imx_header *imxhdr, int32_t *cmd, - char *token, char *name, int lineno, int fld, int *dcd_len) + int32_t *precmd, char *token, char *name, + int lineno, int fld, int *dcd_len) { int value; @@ -580,6 +610,28 @@ static void parse_cfg_fld(struct imx_header *imxhdr, int32_t *cmd, "(%s)\n", name, lineno, token); exit(EXIT_FAILURE); } + + if ((*precmd == CMD_DATA) || (*precmd == CMD_CLR_BIT) || + (*precmd == CMD_CHECK_DATA)) { + if (*cmd != *precmd) { + dataindex += ((*dcd_len) * + sizeof(dcd_addr_data_t) + 4) >> 2; + *dcd_len = 0; + } + } + + if ((*cmd == CMD_DATA) || (*cmd == CMD_CLR_BIT) || + (*cmd == CMD_CHECK_DATA)) { + /* + * Reserve the first entry for command header, + * So use *dcd_len + 1 as the off. + */ + (*set_dcd_val)(imxhdr, name, lineno, fld, + *cmd, 0, *dcd_len + 1); + } + + *precmd = *cmd; + break; case CFG_REG_SIZE: parse_cfg_cmd(imxhdr, *cmd, token, name, lineno, fld, *dcd_len); @@ -587,9 +639,11 @@ static void parse_cfg_fld(struct imx_header *imxhdr, int32_t *cmd, case CFG_REG_ADDRESS: case CFG_REG_VALUE: switch (*cmd) { + case CMD_CHECK_DATA: case CMD_DATA: + case CMD_CLR_BIT: value = get_cfg_value(token, name, lineno); - (*set_dcd_val)(imxhdr, name, lineno, fld, value, + (*set_dcd_val)(imxhdr, name, lineno, fld, *cmd, value, *dcd_len); if (fld == CFG_REG_VALUE) { @@ -626,7 +680,7 @@ static uint32_t parse_cfg_file(struct imx_header *imxhdr, char *name) int fld; size_t len; int dcd_len = 0; - int32_t cmd; + int32_t cmd, precmd = CMD_INVALID; fd = fopen(name, "r"); if (fd == 0) { @@ -634,6 +688,7 @@ static uint32_t parse_cfg_file(struct imx_header *imxhdr, char *name) exit(EXIT_FAILURE); } + dataindex = 0; /* * Very simple parsing, line starting with # are comments * and are dropped @@ -656,8 +711,8 @@ static uint32_t parse_cfg_file(struct imx_header *imxhdr, char *name) if (token[0] == '#') break; - parse_cfg_fld(imxhdr, &cmd, token, name, - lineno, fld, &dcd_len); + parse_cfg_fld(imxhdr, &cmd, &precmd, token, name, + lineno, fld, &dcd_len); } } diff --git a/tools/imximage.h b/tools/imximage.h index c05426035ae..2d33f8f5e1d 100644 --- a/tools/imximage.h +++ b/tools/imximage.h @@ -11,6 +11,7 @@ #define _IMXIMAGE_H_ #include <config.h> +#include <linux/sizes.h> #define MAX_HW_CFG_SIZE_V2 220 /* Max number of registers imx can set for v2 */ #define MAX_PLUGIN_CODE_SIZE (16*1024) #define MAX_HW_CFG_SIZE_V1 60 /* Max number of registers imx can set for v1 */ @@ -61,12 +62,20 @@ #define DCD_VERSION 0x40 #define DCD_COMMAND_PARAM 0x4 +#define DCD_WRITE_DATA_COMMAND_TAG 0xCC +#define DCD_WRITE_DATA_PARAM 0x4 +#define DCD_CLR_BIT_PARAM 0xC +#define DCD_CHECK_DATA_COMMAND_TAG 0xCF +#define DCD_CHECK_DATA_PARAM 0x14 + enum imximage_cmd { CMD_INVALID, CMD_IMAGE_VERSION, CMD_BOOT_FROM, CMD_BOOT_OFFSET, CMD_DATA, + CMD_CLR_BIT, + CMD_CHECK_DATA, CMD_CSF, CMD_PLUGIN, }; @@ -139,9 +148,15 @@ typedef struct { } __attribute__((packed)) write_dcd_command_t; typedef struct { + uint8_t tag; + uint16_t length; + uint8_t param; + dcd_addr_data_t addr_data[0]; +} __attribute__((packed)) dcd_command_t; + +typedef struct { ivt_header_t header; - write_dcd_command_t write_dcd_command; - dcd_addr_data_t addr_data[MAX_HW_CFG_SIZE_V2]; + uint32_t dcd_data[SZ_512]; } dcd_v2_t; typedef struct { @@ -183,7 +198,7 @@ struct imx_header { typedef void (*set_dcd_val_t)(struct imx_header *imxhdr, char *name, int lineno, - int fld, uint32_t value, + int fld, int cmd, uint32_t value, uint32_t off); typedef void (*set_dcd_rst_t)(struct imx_header *imxhdr, |