arm: stm32mp: migrate cmd_stm32prog to log macro
Change debug and pr_ macro to log macro. Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com> Reviewed-by: Patrice Chotard <patrice.chotard@st.com>
This commit is contained in:

committed by
Patrick Delaunay

parent
eb653acd63
commit
711b5bc0a2
@@ -97,28 +97,28 @@ u8 stm32prog_header_check(struct raw_header_s *raw_header,
|
||||
header->image_length = 0x0;
|
||||
|
||||
if (!raw_header || !header) {
|
||||
pr_debug("%s:no header data\n", __func__);
|
||||
log_debug("%s:no header data\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
if (raw_header->magic_number !=
|
||||
(('S' << 0) | ('T' << 8) | ('M' << 16) | (0x32 << 24))) {
|
||||
pr_debug("%s:invalid magic number : 0x%x\n",
|
||||
__func__, raw_header->magic_number);
|
||||
log_debug("%s:invalid magic number : 0x%x\n",
|
||||
__func__, raw_header->magic_number);
|
||||
return -2;
|
||||
}
|
||||
/* only header v1.0 supported */
|
||||
if (raw_header->header_version != 0x00010000) {
|
||||
pr_debug("%s:invalid header version : 0x%x\n",
|
||||
__func__, raw_header->header_version);
|
||||
log_debug("%s:invalid header version : 0x%x\n",
|
||||
__func__, raw_header->header_version);
|
||||
return -3;
|
||||
}
|
||||
if (raw_header->reserved1 != 0x0 || raw_header->reserved2) {
|
||||
pr_debug("%s:invalid reserved field\n", __func__);
|
||||
log_debug("%s:invalid reserved field\n", __func__);
|
||||
return -4;
|
||||
}
|
||||
for (i = 0; i < (sizeof(raw_header->padding) / 4); i++) {
|
||||
if (raw_header->padding[i] != 0) {
|
||||
pr_debug("%s:invalid padding field\n", __func__);
|
||||
log_debug("%s:invalid padding field\n", __func__);
|
||||
return -5;
|
||||
}
|
||||
}
|
||||
@@ -376,7 +376,7 @@ static int parse_flash_layout(struct stm32prog_data *data,
|
||||
last = start + size;
|
||||
|
||||
*last = 0x0; /* force null terminated string */
|
||||
pr_debug("flash layout =\n%s\n", start);
|
||||
log_debug("flash layout =\n%s\n", start);
|
||||
|
||||
/* calculate expected number of partitions */
|
||||
part_list_size = 1;
|
||||
@@ -584,11 +584,11 @@ static int init_device(struct stm32prog_data *data,
|
||||
last_addr = (u64)(block_dev->lba - GPT_HEADER_SZ - 1) *
|
||||
block_dev->blksz;
|
||||
}
|
||||
pr_debug("MMC %d: lba=%ld blksz=%ld\n", dev->dev_id,
|
||||
block_dev->lba, block_dev->blksz);
|
||||
pr_debug(" available address = 0x%llx..0x%llx\n",
|
||||
first_addr, last_addr);
|
||||
pr_debug(" full_update = %d\n", dev->full_update);
|
||||
log_debug("MMC %d: lba=%ld blksz=%ld\n", dev->dev_id,
|
||||
block_dev->lba, block_dev->blksz);
|
||||
log_debug(" available address = 0x%llx..0x%llx\n",
|
||||
first_addr, last_addr);
|
||||
log_debug(" full_update = %d\n", dev->full_update);
|
||||
break;
|
||||
case STM32PROG_NOR:
|
||||
case STM32PROG_NAND:
|
||||
@@ -598,7 +598,7 @@ static int init_device(struct stm32prog_data *data,
|
||||
return -ENODEV;
|
||||
}
|
||||
get_mtd_by_target(mtd_id, dev->target, dev->dev_id);
|
||||
pr_debug("%s\n", mtd_id);
|
||||
log_debug("%s\n", mtd_id);
|
||||
|
||||
mtdparts_init();
|
||||
mtd = get_mtd_device_nm(mtd_id);
|
||||
@@ -609,10 +609,10 @@ static int init_device(struct stm32prog_data *data,
|
||||
first_addr = 0;
|
||||
last_addr = mtd->size;
|
||||
dev->erase_size = mtd->erasesize;
|
||||
pr_debug("MTD device %s: size=%lld erasesize=%d\n",
|
||||
mtd_id, mtd->size, mtd->erasesize);
|
||||
pr_debug(" available address = 0x%llx..0x%llx\n",
|
||||
first_addr, last_addr);
|
||||
log_debug("MTD device %s: size=%lld erasesize=%d\n",
|
||||
mtd_id, mtd->size, mtd->erasesize);
|
||||
log_debug(" available address = 0x%llx..0x%llx\n",
|
||||
first_addr, last_addr);
|
||||
dev->mtd = mtd;
|
||||
break;
|
||||
case STM32PROG_RAM:
|
||||
@@ -624,13 +624,13 @@ static int init_device(struct stm32prog_data *data,
|
||||
stm32prog_err("unknown device type = %d", dev->target);
|
||||
return -ENODEV;
|
||||
}
|
||||
pr_debug(" erase size = 0x%x\n", dev->erase_size);
|
||||
pr_debug(" full_update = %d\n", dev->full_update);
|
||||
log_debug(" erase size = 0x%x\n", dev->erase_size);
|
||||
log_debug(" full_update = %d\n", dev->full_update);
|
||||
|
||||
/* order partition list in offset order */
|
||||
list_sort(NULL, &dev->part_list, &part_cmp);
|
||||
part_id = 1;
|
||||
pr_debug("id : Opt Phase Name target.n dev.n addr size part_off part_size\n");
|
||||
log_debug("id : Opt Phase Name target.n dev.n addr size part_off part_size\n");
|
||||
list_for_each_entry(part, &dev->part_list, list) {
|
||||
if (part->bin_nb > 1) {
|
||||
if ((dev->target != STM32PROG_NAND &&
|
||||
@@ -650,10 +650,10 @@ static int init_device(struct stm32prog_data *data,
|
||||
part->size = block_dev->lba * block_dev->blksz;
|
||||
else
|
||||
part->size = last_addr;
|
||||
pr_debug("-- : %1d %02x %14s %02d.%d %02d.%02d %08llx %08llx\n",
|
||||
part->option, part->id, part->name,
|
||||
part->part_type, part->bin_nb, part->target,
|
||||
part->dev_id, part->addr, part->size);
|
||||
log_debug("-- : %1d %02x %14s %02d.%d %02d.%02d %08llx %08llx\n",
|
||||
part->option, part->id, part->name,
|
||||
part->part_type, part->bin_nb, part->target,
|
||||
part->dev_id, part->addr, part->size);
|
||||
continue;
|
||||
}
|
||||
if (part->part_id < 0) { /* boot hw partition for eMMC */
|
||||
@@ -709,10 +709,10 @@ static int init_device(struct stm32prog_data *data,
|
||||
part->dev->erase_size);
|
||||
return -EINVAL;
|
||||
}
|
||||
pr_debug("%02d : %1d %02x %14s %02d.%d %02d.%02d %08llx %08llx",
|
||||
part->part_id, part->option, part->id, part->name,
|
||||
part->part_type, part->bin_nb, part->target,
|
||||
part->dev_id, part->addr, part->size);
|
||||
log_debug("%02d : %1d %02x %14s %02d.%d %02d.%02d %08llx %08llx",
|
||||
part->part_id, part->option, part->id, part->name,
|
||||
part->part_type, part->bin_nb, part->target,
|
||||
part->dev_id, part->addr, part->size);
|
||||
|
||||
part_addr = 0;
|
||||
part_size = 0;
|
||||
@@ -726,7 +726,7 @@ static int init_device(struct stm32prog_data *data,
|
||||
* created for full update
|
||||
*/
|
||||
if (dev->full_update || part->part_id < 0) {
|
||||
pr_debug("\n");
|
||||
log_debug("\n");
|
||||
continue;
|
||||
}
|
||||
struct disk_partition partinfo;
|
||||
@@ -770,11 +770,11 @@ static int init_device(struct stm32prog_data *data,
|
||||
|
||||
/* no partition for this device */
|
||||
if (!part_found) {
|
||||
pr_debug("\n");
|
||||
log_debug("\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
pr_debug(" %08llx %08llx\n", part_addr, part_size);
|
||||
log_debug(" %08llx %08llx\n", part_addr, part_size);
|
||||
|
||||
if (part->addr != part_addr) {
|
||||
stm32prog_err("%s (0x%x): Bad address for partition %d (%s) = 0x%llx <> 0x%llx expected",
|
||||
@@ -910,8 +910,8 @@ static int create_gpt_partitions(struct stm32prog_data *data)
|
||||
continue;
|
||||
|
||||
if (offset + 100 > buflen) {
|
||||
pr_debug("\n%s: buffer too small, %s skippped",
|
||||
__func__, part->name);
|
||||
log_debug("\n%s: buffer too small, %s skippped",
|
||||
__func__, part->name);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -959,7 +959,7 @@ static int create_gpt_partitions(struct stm32prog_data *data)
|
||||
|
||||
if (offset) {
|
||||
offset += snprintf(buf + offset, buflen - offset, "\"");
|
||||
pr_debug("\ncmd: %s\n", buf);
|
||||
log_debug("\ncmd: %s\n", buf);
|
||||
if (run_command(buf, 0)) {
|
||||
stm32prog_err("GPT partitionning fail: %s",
|
||||
buf);
|
||||
@@ -974,7 +974,7 @@ static int create_gpt_partitions(struct stm32prog_data *data)
|
||||
|
||||
#ifdef DEBUG
|
||||
sprintf(buf, "gpt verify mmc %d", data->dev[i].dev_id);
|
||||
pr_debug("\ncmd: %s", buf);
|
||||
log_debug("\ncmd: %s", buf);
|
||||
if (run_command(buf, 0))
|
||||
printf("fail !\n");
|
||||
else
|
||||
@@ -1098,10 +1098,10 @@ static int stm32prog_alt_add(struct stm32prog_data *data,
|
||||
stm32prog_err("invalid target: %d", part->target);
|
||||
return ret;
|
||||
}
|
||||
pr_debug("dfu_alt_add(%s,%s,%s)\n", dfustr, devstr, buf);
|
||||
log_debug("dfu_alt_add(%s,%s,%s)\n", dfustr, devstr, buf);
|
||||
ret = dfu_alt_add(dfu, dfustr, devstr, buf);
|
||||
pr_debug("dfu_alt_add(%s,%s,%s) result %d\n",
|
||||
dfustr, devstr, buf, ret);
|
||||
log_debug("dfu_alt_add(%s,%s,%s) result %d\n",
|
||||
dfustr, devstr, buf, ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -1116,7 +1116,7 @@ static int stm32prog_alt_add_virt(struct dfu_entity *dfu,
|
||||
sprintf(devstr, "%d", phase);
|
||||
sprintf(buf, "@%s/0x%02x/1*%dBe", name, phase, size);
|
||||
ret = dfu_alt_add(dfu, "virt", devstr, buf);
|
||||
pr_debug("dfu_alt_add(virt,%s,%s) result %d\n", devstr, buf, ret);
|
||||
log_debug("dfu_alt_add(virt,%s,%s) result %d\n", devstr, buf, ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -1171,7 +1171,7 @@ static int dfu_init_entities(struct stm32prog_data *data)
|
||||
sprintf(buf, "@FlashLayout/0x%02x/1*256Ke ram %x 40000",
|
||||
PHASE_FLASHLAYOUT, STM32_DDR_BASE);
|
||||
ret = dfu_alt_add(dfu, "ram", NULL, buf);
|
||||
pr_debug("dfu_alt_add(ram, NULL,%s) result %d\n", buf, ret);
|
||||
log_debug("dfu_alt_add(ram, NULL,%s) result %d\n", buf, ret);
|
||||
}
|
||||
|
||||
if (!ret)
|
||||
@@ -1196,7 +1196,7 @@ static int dfu_init_entities(struct stm32prog_data *data)
|
||||
int stm32prog_otp_write(struct stm32prog_data *data, u32 offset, u8 *buffer,
|
||||
long *size)
|
||||
{
|
||||
pr_debug("%s: %x %lx\n", __func__, offset, *size);
|
||||
log_debug("%s: %x %lx\n", __func__, offset, *size);
|
||||
|
||||
if (!data->otp_part) {
|
||||
data->otp_part = memalign(CONFIG_SYS_CACHELINE_SIZE, OTP_SIZE);
|
||||
@@ -1226,7 +1226,7 @@ int stm32prog_otp_read(struct stm32prog_data *data, u32 offset, u8 *buffer,
|
||||
return -1;
|
||||
}
|
||||
|
||||
pr_debug("%s: %x %lx\n", __func__, offset, *size);
|
||||
log_debug("%s: %x %lx\n", __func__, offset, *size);
|
||||
/* alway read for first packet */
|
||||
if (!offset) {
|
||||
if (!data->otp_part)
|
||||
@@ -1258,7 +1258,7 @@ int stm32prog_otp_read(struct stm32prog_data *data, u32 offset, u8 *buffer,
|
||||
memcpy(buffer, (void *)((u32)data->otp_part + offset), *size);
|
||||
|
||||
end_otp_read:
|
||||
pr_debug("%s: result %i\n", __func__, result);
|
||||
log_debug("%s: result %i\n", __func__, result);
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -1292,20 +1292,20 @@ int stm32prog_otp_start(struct stm32prog_data *data)
|
||||
result = 0;
|
||||
break;
|
||||
default:
|
||||
pr_err("%s: OTP incorrect value (err = %ld)\n",
|
||||
__func__, res.a1);
|
||||
log_err("%s: OTP incorrect value (err = %ld)\n",
|
||||
__func__, res.a1);
|
||||
result = -EINVAL;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
pr_err("%s: Failed to exec svc=%x op=%x in secure mode (err = %ld)\n",
|
||||
__func__, STM32_SMC_BSEC, STM32_SMC_WRITE_ALL, res.a0);
|
||||
log_err("%s: Failed to exec svc=%x op=%x in secure mode (err = %ld)\n",
|
||||
__func__, STM32_SMC_BSEC, STM32_SMC_WRITE_ALL, res.a0);
|
||||
result = -EINVAL;
|
||||
}
|
||||
|
||||
free(data->otp_part);
|
||||
data->otp_part = NULL;
|
||||
pr_debug("%s: result %i\n", __func__, result);
|
||||
log_debug("%s: result %i\n", __func__, result);
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -1313,7 +1313,7 @@ int stm32prog_otp_start(struct stm32prog_data *data)
|
||||
int stm32prog_pmic_write(struct stm32prog_data *data, u32 offset, u8 *buffer,
|
||||
long *size)
|
||||
{
|
||||
pr_debug("%s: %x %lx\n", __func__, offset, *size);
|
||||
log_debug("%s: %x %lx\n", __func__, offset, *size);
|
||||
|
||||
if (!offset)
|
||||
memset(data->pmic_part, 0, PMIC_SIZE);
|
||||
@@ -1338,7 +1338,7 @@ int stm32prog_pmic_read(struct stm32prog_data *data, u32 offset, u8 *buffer,
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
pr_debug("%s: %x %lx\n", __func__, offset, *size);
|
||||
log_debug("%s: %x %lx\n", __func__, offset, *size);
|
||||
ret = uclass_get_device_by_driver(UCLASS_MISC,
|
||||
DM_DRIVER_GET(stpmic1_nvm),
|
||||
&dev);
|
||||
@@ -1373,7 +1373,7 @@ int stm32prog_pmic_read(struct stm32prog_data *data, u32 offset, u8 *buffer,
|
||||
memcpy(buffer, &data->pmic_part[offset], *size);
|
||||
|
||||
end_pmic_read:
|
||||
pr_debug("%s: result %i\n", __func__, result);
|
||||
log_debug("%s: result %i\n", __func__, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1429,7 +1429,7 @@ static int stm32prog_copy_fsbl(struct stm32prog_part_t *part)
|
||||
if (!fsbl)
|
||||
return -ENOMEM;
|
||||
ret = dfu->read_medium(dfu, 0, fsbl, &size);
|
||||
pr_debug("%s read size=%lx ret=%d\n", __func__, size, ret);
|
||||
log_debug("%s read size=%lx ret=%d\n", __func__, size, ret);
|
||||
if (ret)
|
||||
goto error;
|
||||
|
||||
@@ -1439,8 +1439,8 @@ static int stm32prog_copy_fsbl(struct stm32prog_part_t *part)
|
||||
offset += size;
|
||||
/* write to the next erase block */
|
||||
ret = dfu->write_medium(dfu, offset, fsbl, &size);
|
||||
pr_debug("%s copy at ofset=%lx size=%lx ret=%d",
|
||||
__func__, offset, size, ret);
|
||||
log_debug("%s copy at ofset=%lx size=%lx ret=%d",
|
||||
__func__, offset, size, ret);
|
||||
if (ret)
|
||||
goto error;
|
||||
}
|
||||
@@ -1751,6 +1751,6 @@ void dfu_initiated_callback(struct dfu_entity *dfu)
|
||||
if (dfu->alt == stm32prog_data->cur_part->alt_id) {
|
||||
dfu->offset = stm32prog_data->offset;
|
||||
stm32prog_data->dfu_seq = 0;
|
||||
pr_debug("dfu offset = 0x%llx\n", dfu->offset);
|
||||
log_debug("dfu offset = 0x%llx\n", dfu->offset);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user