[U-Boot] [PATCH 0/5] imx8: several fixes

Several fixes when moving to support SPL.
Peng Fan (5): clk: imx8: fix build warning misc: imx: scu: avoid write null pointer misc: imx8: scu: use platdata instead of priv data imx8: cpu: correct info tools: imx8image: set dcd_skip to true
arch/arm/mach-imx/imx8/cpu.c | 2 +- drivers/clk/imx/clk-imx8.c | 2 ++ drivers/misc/imx8/scu.c | 26 +++++++++++++------------- drivers/misc/imx8/scu_api.c | 4 ++-- tools/imx8image.c | 2 +- 5 files changed, 19 insertions(+), 17 deletions(-)

When build clk driver in spl, met the warning: " drivers/clk/imx/clk-imx8.c:21:25: warning: ‘imx8_clk_names’ defined but not used [-Wunused-variable] static struct imx8_clks imx8_clk_names[] = { ^~~~~~~~~~~~~~ "
Fix with wrapping the array with CONFIG_CMD_CLK.
Signed-off-by: Peng Fan peng.fan@nxp.com --- drivers/clk/imx/clk-imx8.c | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/drivers/clk/imx/clk-imx8.c b/drivers/clk/imx/clk-imx8.c index fcb8090d35..d03fcc2fdd 100644 --- a/drivers/clk/imx/clk-imx8.c +++ b/drivers/clk/imx/clk-imx8.c @@ -18,6 +18,7 @@ struct imx8_clks { const char *name; };
+#if CONFIG_IS_ENABLED(CMD_CLK) static struct imx8_clks imx8_clk_names[] = { { IMX8QXP_A35_DIV, "A35_DIV" }, { IMX8QXP_I2C0_CLK, "I2C0" }, @@ -39,6 +40,7 @@ static struct imx8_clks imx8_clk_names[] = { { IMX8QXP_ENET1_REF_DIV, "ENET1_REF" }, { IMX8QXP_ENET1_PTP_CLK, "ENET1_PTP" }, }; +#endif
static ulong imx8_clk_get_rate(struct clk *clk) {

When boot_dev is true, fill boot device. However the original logic is when boot_dev is false, fill boot device, this will trigger data abort.
Also fix sc_misc_get_control when using pointer val.
Signed-off-by: Peng Fan peng.fan@nxp.com --- drivers/misc/imx8/scu_api.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/misc/imx8/scu_api.c b/drivers/misc/imx8/scu_api.c index 65080d7544..d9c4d5d784 100644 --- a/drivers/misc/imx8/scu_api.c +++ b/drivers/misc/imx8/scu_api.c @@ -169,7 +169,7 @@ int sc_misc_get_control(sc_ipc_t ipc, sc_rsrc_t resource, sc_ctrl_t ctrl, printf("%s: ctrl:%d resource:%d: res:%d\n", __func__, ctrl, resource, RPC_R8(&msg));
- if (!val) + if (val) *val = RPC_U32(&msg, 0U);
return ret; @@ -194,7 +194,7 @@ void sc_misc_get_boot_dev(sc_ipc_t ipc, sc_rsrc_t *boot_dev) if (ret) printf("%s: res:%d\n", __func__, RPC_R8(&msg));
- if (!boot_dev) + if (boot_dev) *boot_dev = RPC_U16(&msg, 0U); }

priv data has not been allocated when doing bind, so it is wrong to use dev_get_priv in bind call back.
Let's switch to use platdata in the driver to fix the issue.
Signed-off-by: Peng Fan peng.fan@nxp.com --- drivers/misc/imx8/scu.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/drivers/misc/imx8/scu.c b/drivers/misc/imx8/scu.c index b824ac79e6..15101b3e5f 100644 --- a/drivers/misc/imx8/scu.c +++ b/drivers/misc/imx8/scu.c @@ -158,7 +158,7 @@ static int sc_ipc_write(struct mu_type *base, void *data) static int imx8_scu_call(struct udevice *dev, int no_resp, void *tx_msg, int tx_size, void *rx_msg, int rx_size) { - struct imx8_scu *priv = dev_get_priv(dev); + struct imx8_scu *plat = dev_get_platdata(dev); sc_err_t result; int ret;
@@ -166,11 +166,11 @@ static int imx8_scu_call(struct udevice *dev, int no_resp, void *tx_msg, if (rx_msg && tx_msg != rx_msg) printf("tx_msg %p, rx_msg %p\n", tx_msg, rx_msg);
- ret = sc_ipc_write(priv->base, tx_msg); + ret = sc_ipc_write(plat->base, tx_msg); if (ret) return ret; if (!no_resp) { - ret = sc_ipc_read(priv->base, rx_msg); + ret = sc_ipc_read(plat->base, rx_msg); if (ret) return ret; } @@ -182,24 +182,24 @@ static int imx8_scu_call(struct udevice *dev, int no_resp, void *tx_msg,
static int imx8_scu_probe(struct udevice *dev) { - struct imx8_scu *priv = dev_get_priv(dev); + struct imx8_scu *plat = dev_get_platdata(dev); fdt_addr_t addr;
- debug("%s(dev=%p) (priv=%p)\n", __func__, dev, priv); + debug("%s(dev=%p) (plat=%p)\n", __func__, dev, plat);
addr = devfdt_get_addr(dev); if (addr == FDT_ADDR_T_NONE) return -EINVAL;
- priv->base = (struct mu_type *)addr; + plat->base = (struct mu_type *)addr;
/* U-Boot not enable interrupts, so need to enable RX interrupts */ - mu_hal_init(priv->base); + mu_hal_init(plat->base);
gd->arch.scu_dev = dev;
- device_probe(priv->clk); - device_probe(priv->pinclk); + device_probe(plat->clk); + device_probe(plat->pinclk);
return 0; } @@ -211,7 +211,7 @@ static int imx8_scu_remove(struct udevice *dev)
static int imx8_scu_bind(struct udevice *dev) { - struct imx8_scu *priv = dev_get_priv(dev); + struct imx8_scu *plat = dev_get_platdata(dev); int ret; struct udevice *child; int node; @@ -227,7 +227,7 @@ static int imx8_scu_bind(struct udevice *dev) if (ret) return ret;
- priv->clk = child; + plat->clk = child;
node = fdt_node_offset_by_compatible(gd->fdt_blob, -1, "fsl,imx8qxp-iomuxc"); @@ -238,7 +238,7 @@ static int imx8_scu_bind(struct udevice *dev) if (ret) return ret;
- priv->pinclk = child; + plat->pinclk = child;
return 0; } @@ -261,6 +261,6 @@ U_BOOT_DRIVER(imx8_scu) = { .bind = imx8_scu_bind, .remove = imx8_scu_remove, .ops = &imx8_scu_ops, - .priv_auto_alloc_size = sizeof(struct imx8_scu), + .platdata_auto_alloc_size = sizeof(struct imx8_scu), .flags = DM_FLAG_PRE_RELOC, };

+Simon
-----Original Message----- From: Peng Fan Sent: 2018年12月15日 20:20 To: sbabic@denx.de Cc: Fabio Estevam fabio.estevam@nxp.com; u-boot@lists.denx.de; dl-uboot-imx uboot-imx@nxp.com; Peng Fan peng.fan@nxp.com Subject: [PATCH 3/5] misc: imx8: scu: use platdata instead of priv data
priv data has not been allocated when doing bind, so it is wrong to use dev_get_priv in bind call back.
Let's switch to use platdata in the driver to fix the issue.
Signed-off-by: Peng Fan peng.fan@nxp.com
drivers/misc/imx8/scu.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/drivers/misc/imx8/scu.c b/drivers/misc/imx8/scu.c index b824ac79e6..15101b3e5f 100644 --- a/drivers/misc/imx8/scu.c +++ b/drivers/misc/imx8/scu.c @@ -158,7 +158,7 @@ static int sc_ipc_write(struct mu_type *base, void *data) static int imx8_scu_call(struct udevice *dev, int no_resp, void *tx_msg, int tx_size, void *rx_msg, int rx_size) {
- struct imx8_scu *priv = dev_get_priv(dev);
- struct imx8_scu *plat = dev_get_platdata(dev); sc_err_t result; int ret;
@@ -166,11 +166,11 @@ static int imx8_scu_call(struct udevice *dev, int no_resp, void *tx_msg, if (rx_msg && tx_msg != rx_msg) printf("tx_msg %p, rx_msg %p\n", tx_msg, rx_msg);
- ret = sc_ipc_write(priv->base, tx_msg);
- ret = sc_ipc_write(plat->base, tx_msg); if (ret) return ret; if (!no_resp) {
ret = sc_ipc_read(priv->base, rx_msg);
if (ret) return ret; }ret = sc_ipc_read(plat->base, rx_msg);
@@ -182,24 +182,24 @@ static int imx8_scu_call(struct udevice *dev, int no_resp, void *tx_msg,
static int imx8_scu_probe(struct udevice *dev) {
- struct imx8_scu *priv = dev_get_priv(dev);
- struct imx8_scu *plat = dev_get_platdata(dev); fdt_addr_t addr;
- debug("%s(dev=%p) (priv=%p)\n", __func__, dev, priv);
debug("%s(dev=%p) (plat=%p)\n", __func__, dev, plat);
addr = devfdt_get_addr(dev); if (addr == FDT_ADDR_T_NONE) return -EINVAL;
- priv->base = (struct mu_type *)addr;
plat->base = (struct mu_type *)addr;
/* U-Boot not enable interrupts, so need to enable RX interrupts */
- mu_hal_init(priv->base);
mu_hal_init(plat->base);
gd->arch.scu_dev = dev;
- device_probe(priv->clk);
- device_probe(priv->pinclk);
device_probe(plat->clk);
device_probe(plat->pinclk);
return 0;
} @@ -211,7 +211,7 @@ static int imx8_scu_remove(struct udevice *dev)
static int imx8_scu_bind(struct udevice *dev) {
- struct imx8_scu *priv = dev_get_priv(dev);
- struct imx8_scu *plat = dev_get_platdata(dev); int ret; struct udevice *child; int node;
@@ -227,7 +227,7 @@ static int imx8_scu_bind(struct udevice *dev) if (ret) return ret;
- priv->clk = child;
plat->clk = child;
node = fdt_node_offset_by_compatible(gd->fdt_blob, -1, "fsl,imx8qxp-iomuxc");
@@ -238,7 +238,7 @@ static int imx8_scu_bind(struct udevice *dev) if (ret) return ret;
- priv->pinclk = child;
plat->pinclk = child;
return 0;
} @@ -261,6 +261,6 @@ U_BOOT_DRIVER(imx8_scu) = { .bind = imx8_scu_bind, .remove = imx8_scu_remove, .ops = &imx8_scu_ops,
- .priv_auto_alloc_size = sizeof(struct imx8_scu),
- .platdata_auto_alloc_size = sizeof(struct imx8_scu), .flags = DM_FLAG_PRE_RELOC,
};
2.14.1

On Sat, 15 Dec 2018 at 05:22, Peng Fan peng.fan@nxp.com wrote:
+Simon
-----Original Message----- From: Peng Fan Sent: 2018年12月15日 20:20 To: sbabic@denx.de Cc: Fabio Estevam fabio.estevam@nxp.com; u-boot@lists.denx.de; dl-uboot-imx uboot-imx@nxp.com; Peng Fan peng.fan@nxp.com Subject: [PATCH 3/5] misc: imx8: scu: use platdata instead of priv data
priv data has not been allocated when doing bind, so it is wrong to use dev_get_priv in bind call back.
Let's switch to use platdata in the driver to fix the issue.
Signed-off-by: Peng Fan peng.fan@nxp.com
drivers/misc/imx8/scu.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-)
Reviewed-by: Simon Glass sjg@chromium.org

The CPU banner printed is as following: CPU: CPU: Freescale i.MX8QXP RevB A35 at 147228 MHz
1. Drop the CPU: 2. Change vendor from Freescale to NXP
Signed-off-by: Peng Fan peng.fan@nxp.com --- arch/arm/mach-imx/imx8/cpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/arm/mach-imx/imx8/cpu.c b/arch/arm/mach-imx/imx8/cpu.c index f093f34ca5..7599afe720 100644 --- a/arch/arm/mach-imx/imx8/cpu.c +++ b/arch/arm/mach-imx/imx8/cpu.c @@ -573,7 +573,7 @@ int cpu_imx_get_desc(struct udevice *dev, char *buf, int size) if (size < 100) return -ENOSPC;
- snprintf(buf, size, "CPU: Freescale i.MX8%s Rev%s %s at %u MHz\n", + snprintf(buf, size, "NXP i.MX8%s Rev%s %s at %u MHz\n", plat->type, plat->rev, plat->name, plat->freq_mhz);
return 0;

To B0[+] chips, dcd_skip needs to be true. For A0 chip, it needs to be false, however A0 chip is no longer being supported anymore. Considering we are moving code from imx-mkimage to uboot mkimage, to make sure we not introduce some surprise, we still keep dcd_skip code there.
Signed-off-by: Peng Fan peng.fan@nxp.com --- tools/imx8image.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/imx8image.c b/tools/imx8image.c index 6e8ac464e7..0d856b9d94 100644 --- a/tools/imx8image.c +++ b/tools/imx8image.c @@ -968,7 +968,7 @@ int imx8image_copy_image(int outfd, struct image_tool_params *mparams) fprintf(stdout, "CONTAINER SW VERSION:\t0x%04x\n", sw_version);
build_container(soc, sector_size, emmc_fastboot, - img_sp, false, fuse_version, sw_version, outfd); + img_sp, true, fuse_version, sw_version, outfd);
return 0; }

Ping.
Thanks, Peng.
-----Original Message----- From: Peng Fan [mailto:peng.fan@nxp.com] Sent: 2018年12月15日 20:20 To: sbabic@denx.de Cc: Fabio Estevam fabio.estevam@nxp.com; u-boot@lists.denx.de; dl-uboot-imx uboot-imx@nxp.com; Peng Fan peng.fan@nxp.com Subject: [PATCH 0/5] imx8: several fixes
Several fixes when moving to support SPL.
Peng Fan (5): clk: imx8: fix build warning misc: imx: scu: avoid write null pointer misc: imx8: scu: use platdata instead of priv data imx8: cpu: correct info tools: imx8image: set dcd_skip to true
arch/arm/mach-imx/imx8/cpu.c | 2 +- drivers/clk/imx/clk-imx8.c | 2 ++ drivers/misc/imx8/scu.c | 26 +++++++++++++------------- drivers/misc/imx8/scu_api.c | 4 ++-- tools/imx8image.c | 2 +- 5 files changed, 19 insertions(+), 17 deletions(-)
-- 2.14.1

Hi Peng,
On 02/01/19 13:10, Peng Fan wrote:
Ping.
Thanks, Peng.
Sorry, I was on holidays and afterwards I have to resume some work in office ;-)
I am now looking for which patches should be merged in release and I will pick them up.
Regards, Stefano
-----Original Message----- From: Peng Fan [mailto:peng.fan@nxp.com] Sent: 2018年12月15日 20:20 To: sbabic@denx.de Cc: Fabio Estevam fabio.estevam@nxp.com; u-boot@lists.denx.de; dl-uboot-imx uboot-imx@nxp.com; Peng Fan peng.fan@nxp.com Subject: [PATCH 0/5] imx8: several fixes
Several fixes when moving to support SPL.
Peng Fan (5): clk: imx8: fix build warning misc: imx: scu: avoid write null pointer misc: imx8: scu: use platdata instead of priv data imx8: cpu: correct info tools: imx8image: set dcd_skip to true
arch/arm/mach-imx/imx8/cpu.c | 2 +- drivers/clk/imx/clk-imx8.c | 2 ++ drivers/misc/imx8/scu.c | 26 +++++++++++++------------- drivers/misc/imx8/scu_api.c | 4 ++-- tools/imx8image.c | 2 +- 5 files changed, 19 insertions(+), 17 deletions(-)
-- 2.14.1

Hi Stefano,
-----Original Message----- From: Stefano Babic [mailto:sbabic@denx.de] Sent: 2019年1月9日 21:56 To: Peng Fan peng.fan@nxp.com; sbabic@denx.de Cc: Fabio Estevam fabio.estevam@nxp.com; u-boot@lists.denx.de; dl-uboot-imx uboot-imx@nxp.com Subject: Re: [PATCH 0/5] imx8: several fixes
Hi Peng,
On 02/01/19 13:10, Peng Fan wrote:
Ping.
Thanks, Peng.
Sorry, I was on holidays and afterwards I have to resume some work in office ;-)
I am now looking for which patches should be merged in release and I will pick them up.
Thanks very much.
Thanks, Peng.
Regards, Stefano
-----Original Message----- From: Peng Fan [mailto:peng.fan@nxp.com] Sent: 2018年12月15日 20:20 To: sbabic@denx.de Cc: Fabio Estevam fabio.estevam@nxp.com; u-boot@lists.denx.de; dl-uboot-imx uboot-imx@nxp.com; Peng Fan peng.fan@nxp.com Subject: [PATCH 0/5] imx8: several fixes
Several fixes when moving to support SPL.
Peng Fan (5): clk: imx8: fix build warning misc: imx: scu: avoid write null pointer misc: imx8: scu: use platdata instead of priv data imx8: cpu: correct info tools: imx8image: set dcd_skip to true
arch/arm/mach-imx/imx8/cpu.c | 2 +- drivers/clk/imx/clk-imx8.c | 2 ++ drivers/misc/imx8/scu.c | 26 +++++++++++++------------- drivers/misc/imx8/scu_api.c | 4 ++-- tools/imx8image.c | 2 +- 5 files changed, 19 insertions(+), 17 deletions(-)
-- 2.14.1
--
======= DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic@denx.de ============================================================== =======

[CC'd the list this time..]
On Wed, 9 Jan 2019 at 13:56, Stefano Babic sbabic@denx.de wrote:
Sorry, I was on holidays and afterwards I have to resume some work in office ;-)
I am now looking for which patches should be merged in release and I will pick them up.
Hi Stefano,
If I may make my own (selfish) suggestion, these are the patches I am applying against my local tree to get things working with my i.MX8MQ-EVK:
https://patchwork.ozlabs.org/patch/1019908/ https://patchwork.ozlabs.org/patch/1016762/ https://patchwork.ozlabs.org/patch/1018985/
Would be nice if these could be squeezed into v2019.01. :)
Thanks, Chris

On 09/01/19 15:56, Chris Spencer wrote:
[CC'd the list this time..]
On Wed, 9 Jan 2019 at 13:56, Stefano Babic sbabic@denx.de wrote:
Sorry, I was on holidays and afterwards I have to resume some work in office ;-)
I am now looking for which patches should be merged in release and I will pick them up.
Hi Stefano,
If I may make my own (selfish) suggestion, these are the patches I am applying against my local tree to get things working with my i.MX8MQ-EVK:
I have seen this patch to solve "bashism", I confess I had to think about what is it. "=" instead of "==" is quite unnatural for me, but yes, first thing I do on a new installed system is to run alternative and set bash as shell.
Anyway, if this is required, it must be solved globally on the project. What about for example scripts/setlocalversion ?
if [ "`hg log -r . --template '{latesttagdistance}'`" == "1" ]; then
I guess there are some other examples in the project. Personally, I tend to reject this one, until one goal is to support the major number of shells or there will be a list of supported shell (as far as I know, we have not even a list of supported distros).
I do not disgregate this, it just under observation - I cannot reproduce even with more threads.
This is superseeded, I take V2:
https://patchwork.ozlabs.org/patch/1019326/
Would be nice if these could be squeezed into v2019.01. :)
Best regards, Stefano

Stefano,
On Wed, 9 Jan 2019 at 15:14, Stefano Babic sbabic@denx.de wrote:
I have seen this patch to solve "bashism", I confess I had to think about what is it. "=" instead of "==" is quite unnatural for me, but yes, first thing I do on a new installed system is to run alternative and set bash as shell.
Anyway, if this is required, it must be solved globally on the project. What about for example scripts/setlocalversion ?
if [ "`hg log -r . --template '{latesttagdistance}'`" == "1" ]; then
I guess there are some other examples in the project. Personally, I tend to reject this one, until one goal is to support the major number of shells or there will be a list of supported shell (as far as I know, we have not even a list of supported distros).
Personally I would tend to take the more standard syntax, but I get your point. There is another patch from Peng which just makes it run in bash instead of changing the syntax:
https://patchwork.ozlabs.org/patch/1011510/
I do not disgregate this, it just under observation - I cannot reproduce even with more threads.
Interesting. For what it's worth, Peng did give a 'Reviewed-by' which wasn't picked up by Patchwork because my message was still in the moderation queue at that point. Not sure whether he actually managed to reproduce it though.
https://lists.denx.de/pipermail/u-boot/2018-December/352637.html https://lists.denx.de/pipermail/u-boot/2018-December/352638.html
Thanks, Chris

On 09/01/19 16:42, Chris Spencer wrote:
Stefano,
On Wed, 9 Jan 2019 at 15:14, Stefano Babic sbabic@denx.de wrote:
I have seen this patch to solve "bashism", I confess I had to think about what is it. "=" instead of "==" is quite unnatural for me, but yes, first thing I do on a new installed system is to run alternative and set bash as shell.
Anyway, if this is required, it must be solved globally on the project. What about for example scripts/setlocalversion ?
if [ "`hg log -r . --template '{latesttagdistance}'`" == "1" ]; then
I guess there are some other examples in the project. Personally, I tend to reject this one, until one goal is to support the major number of shells or there will be a list of supported shell (as far as I know, we have not even a list of supported distros).
Personally I would tend to take the more standard syntax, but I get your point. There is another patch from Peng which just makes it run in bash instead of changing the syntax:
https://patchwork.ozlabs.org/patch/1011510/
I do not disgregate this, it just under observation - I cannot reproduce even with more threads.
Interesting. For what it's worth, Peng did give a 'Reviewed-by' which wasn't picked up by Patchwork because my message was still in the moderation queue at that point. Not sure whether he actually managed to reproduce it though.
At least, I do not see why this patch should create a new problem. Ok, I pick it up (as this is a fix), and I add myself Peng's 'Reviewed-by'.
https://lists.denx.de/pipermail/u-boot/2018-December/352637.html https://lists.denx.de/pipermail/u-boot/2018-December/352638.html
Regards, Stefano
participants (4)
-
Chris Spencer
-
Peng Fan
-
Simon Glass
-
Stefano Babic