[U-Boot] [PATCH v2] spi: designware_spi: Add reset ctrl to driver

2018-09-06 Thread Ley Foon Tan
Add code to reset all reset signals as in SPI DT node. A reset property
is an optional feature, so only print out a warning and do not fail if a
reset property is not present.

If a reset property is discovered, then use it to deassert, thus
bringing the IP out of reset.

Release reset when _remove().

Signed-off-by: Ley Foon Tan 
Acked-by: Marek Vasut 
Reviewed-by: Jagan Teki 

---
v2:
- Fix multi-lines comment style
---
 drivers/spi/designware_spi.c | 43 +++
 1 file changed, 43 insertions(+)

diff --git a/drivers/spi/designware_spi.c b/drivers/spi/designware_spi.c
index d8b73ea..5cca414 100644
--- a/drivers/spi/designware_spi.c
+++ b/drivers/spi/designware_spi.c
@@ -17,6 +17,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -111,6 +112,8 @@ struct dw_spi_priv {
void *tx_end;
void *rx;
void *rx_end;
+
+   struct reset_ctl_bulk   resets;
 };
 
 static inline u32 dw_read(struct dw_spi_priv *priv, u32 offset)
@@ -231,6 +234,34 @@ err_rate:
return -EINVAL;
 }
 
+static int dw_spi_reset(struct udevice *bus)
+{
+   int ret;
+   struct dw_spi_priv *priv = dev_get_priv(bus);
+
+   ret = reset_get_bulk(bus, &priv->resets);
+   if (ret) {
+   /*
+* Return 0 if error due to !CONFIG_DM_RESET and reset
+* DT property is not present.
+*/
+   if (ret == -ENOENT || ret == -ENOTSUPP)
+   return 0;
+
+   dev_warn(bus, "Can't get reset: %d\n", ret);
+   return ret;
+   }
+
+   ret = reset_deassert_bulk(&priv->resets);
+   if (ret) {
+   reset_release_bulk(&priv->resets);
+   dev_err(bus, "Failed to reset: %d\n", ret);
+   return ret;
+   }
+
+   return 0;
+}
+
 static int dw_spi_probe(struct udevice *bus)
 {
struct dw_spi_platdata *plat = dev_get_platdata(bus);
@@ -244,6 +275,10 @@ static int dw_spi_probe(struct udevice *bus)
if (ret)
return ret;
 
+   ret = dw_spi_reset(bus);
+   if (ret)
+   return ret;
+
/* Currently only bits_per_word == 8 supported */
priv->bits_per_word = 8;
 
@@ -478,6 +513,13 @@ static int dw_spi_set_mode(struct udevice *bus, uint mode)
return 0;
 }
 
+static int dw_spi_remove(struct udevice *bus)
+{
+   struct dw_spi_priv *priv = dev_get_priv(bus);
+
+   return reset_release_bulk(&priv->resets);
+}
+
 static const struct dm_spi_ops dw_spi_ops = {
.xfer   = dw_spi_xfer,
.set_speed  = dw_spi_set_speed,
@@ -502,4 +544,5 @@ U_BOOT_DRIVER(dw_spi) = {
.platdata_auto_alloc_size = sizeof(struct dw_spi_platdata),
.priv_auto_alloc_size = sizeof(struct dw_spi_priv),
.probe = dw_spi_probe,
+   .remove = dw_spi_remove,
 };
-- 
2.2.2

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v2] gpio: dwapb_gpio: Change to use devm_kcalloc()

2018-09-06 Thread Ley Foon Tan
Change to use managed resource function devm_kcalloc(),
so it will auto free memory when driver is removed.

Signed-off-by: Ley Foon Tan 

---
v2:
- Remove free() function.
---
 drivers/gpio/dwapb_gpio.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/gpio/dwapb_gpio.c b/drivers/gpio/dwapb_gpio.c
index 0f6574d..6f9d17d 100644
--- a/drivers/gpio/dwapb_gpio.c
+++ b/drivers/gpio/dwapb_gpio.c
@@ -171,8 +171,7 @@ static int gpio_dwapb_bind(struct udevice *dev)
if (!fdtdec_get_bool(blob, node, "gpio-controller"))
continue;
 
-   plat = NULL;
-   plat = calloc(1, sizeof(*plat));
+   plat = devm_kcalloc(dev, 1, sizeof(*plat), GFP_KERNEL);
if (!plat)
return -ENOMEM;
 
@@ -196,7 +195,6 @@ static int gpio_dwapb_bind(struct udevice *dev)
return 0;
 
 err:
-   free(plat);
return ret;
 }
 
-- 
2.2.2

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH V5 00/31] imx: add i.MX8M support and i.MX8MQ EVK

2018-09-06 Thread Peng Fan
Hi Jon,

> -Original Message-
> From: Jon Nettleton [mailto:j...@solid-run.com]
> Sent: 2018年9月7日 14:03
> To: Fabio Estevam 
> Cc: Peng Fan ; Diego Dorta ;
> Fabio Estevam ; U-Boot Mailing List
> 
> Subject: Re: [U-Boot] [PATCH V5 00/31] imx: add i.MX8M support and i.MX8MQ
> EVK
> 
> On Thu, Sep 6, 2018 at 3:37 PM Fabio Estevam  wrote:
> >
> > Hi Peng,
> >
> > On Fri, Aug 31, 2018 at 3:27 AM, Jon Nettleton  wrote:
> >
> > > Peng,
> > >
> > > Will you be releasing the script you are using to convert that code
> > > generated by the ddr training tool into this format?  I would like
> > > to test your patchset on our new SOMs and that would be very useful.
> >
> > Any comments about the DDR init script? Looks like we are stuck in
> > this issue for a long time.
> >
> 
> I have been chewing on this over the past week, and I am starting to think 
> that
> u-boot is not necessarily the right place for the DDR initialization for this
> platform.  We require ATF in order to load the
> lpddr4 firmware regardless, so why not do the DDR training and configuration
> there?  This would also abstract out the proprietary memory bits so the code
> doesn't need to be re-duplicated in the various bootloaders.  In theory it 
> should
> also simplify the MX8 image scripts since SPL would not be a requirement.

On i.MX8M, SPL is used to initialize DDR and load ATF/TEE/U-Boot to memory and 
kick ATF.

Two option:
1. Move DDR code out of SPL and make it a standalone image, then pad it the 
SPL. The drawback is
 need a new repo holding ddr code.
2. Restructure the DDR code the make it generic enough.
  One engineer in NXP is looking into restructure code, but priority is low.

Regards,
Peng.

> 
> Thoughts?
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH V5 00/31] imx: add i.MX8M support and i.MX8MQ EVK

2018-09-06 Thread Jon Nettleton
On Thu, Sep 6, 2018 at 3:37 PM Fabio Estevam  wrote:
>
> Hi Peng,
>
> On Fri, Aug 31, 2018 at 3:27 AM, Jon Nettleton  wrote:
>
> > Peng,
> >
> > Will you be releasing the script you are using to convert that code
> > generated by the ddr training tool into this format?  I would like to
> > test your patchset on our new SOMs and that would be very useful.
>
> Any comments about the DDR init script? Looks like we are stuck in
> this issue for a long time.
>

I have been chewing on this over the past week, and I am starting to
think that u-boot is not necessarily the right place for the DDR
initialization for this platform.  We require ATF in order to load the
lpddr4 firmware regardless, so why not do the DDR training and
configuration there?  This would also abstract out the proprietary
memory bits so the code doesn't need to be re-duplicated in the
various bootloaders.  In theory it should also simplify the MX8 image
scripts since SPL would not be a requirement.

Thoughts?
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH] i2c: xiic: Record xilinx i2c with Zynq fragment

2018-09-06 Thread Michal Simek
Include xilinx soft i2c controller to Zynq fragment to make clear who is
responsible for it.

Signed-off-by: Michal Simek 
---

Normally we are handling all these drivers via one fragment to make sure
that there is only one central contact. Another reason is that people are
changing and their responsibility is moving time to time.

---
 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 9ad052aeac39..d870cb57c887 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -2311,6 +2311,7 @@ F:drivers/clocksource/cadence_ttc_timer.c
 F: drivers/i2c/busses/i2c-cadence.c
 F: drivers/mmc/host/sdhci-of-arasan.c
 F: drivers/edac/synopsys_edac.c
+F: drivers/i2c/busses/i2c-xiic.c
 
 ARM64 PORT (AARCH64 ARCHITECTURE)
 M: Catalin Marinas 
-- 
1.9.1

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v2] usb: dwc3: convert to livetree

2018-09-06 Thread Siva Durga Prasad Paladugu
Hi,

> -Original Message-
> From: Michal Simek [mailto:michal.si...@xilinx.com]
> Sent: Thursday, September 06, 2018 7:36 PM
> To: Siva Durga Prasad Paladugu ; u-
> b...@lists.denx.de
> Cc: Michal Simek ; ma...@denx.de;
> bmeng...@gmail.com; s...@chromium.org;
> yamada.masah...@socionext.com; Vipul Kumar 
> Subject: Re: [PATCH v2] usb: dwc3: convert to livetree
> 
> On 6.9.2018 12:39, Siva Durga Prasad Paladugu wrote:
> > From: Vipul Kumar 
> >
> > Update the DWC3 USB driver to support a live tree.
> >
> > Signed-off-by: Siva Durga Prasad Paladugu
> > 
> > Signed-off-by: Vipul Kumar 
> > Tested-by: Michal Simek 
> > ---
> > Changes in v2:
> > - Fixed travis build issues with some platforms.
> > ---
> >  drivers/usb/common/common.c  | 11 +--
> >  drivers/usb/dwc3/dwc3-generic.c  | 17 +++--
> > drivers/usb/host/dwc3-sti-glue.c |  7 +++
> >  drivers/usb/host/xhci-dwc3.c |  3 ++-
> >  drivers/usb/host/xhci-zynqmp.c   |  3 +--
> >  drivers/usb/musb-new/ti-musb.c   | 11 ---
> >  include/linux/usb/otg.h  |  6 --
> >  7 files changed, 26 insertions(+), 32 deletions(-)
> >
> > diff --git a/drivers/usb/common/common.c
> b/drivers/usb/common/common.c
> > index a55def5..3dea79b 100644
> > --- a/drivers/usb/common/common.c
> > +++ b/drivers/usb/common/common.c
> > @@ -10,6 +10,7 @@
> >  #include 
> >  #include 
> >  #include 
> > +#include 
> >
> >  DECLARE_GLOBAL_DATA_PTR;
> >
> > @@ -20,13 +21,12 @@ static const char *const usb_dr_modes[] = {
> > [USB_DR_MODE_OTG]   = "otg",
> >  };
> >
> > -enum usb_dr_mode usb_get_dr_mode(int node)
> > +enum usb_dr_mode usb_get_dr_mode(ofnode node)
> >  {
> > -   const void *fdt = gd->fdt_blob;
> > const char *dr_mode;
> > int i;
> >
> > -   dr_mode = fdt_getprop(fdt, node, "dr_mode", NULL);
> > +   dr_mode = ofnode_get_property(node, "dr_mode", NULL);
> > if (!dr_mode) {
> > pr_err("usb dr_mode not found\n");
> > return USB_DR_MODE_UNKNOWN;
> > @@ -48,13 +48,12 @@ static const char *const speed_names[] = {
> > [USB_SPEED_SUPER] = "super-speed",
> >  };
> >
> > -enum usb_device_speed usb_get_maximum_speed(int node)
> > +enum usb_device_speed usb_get_maximum_speed(ofnode node)
> >  {
> > -   const void *fdt = gd->fdt_blob;
> > const char *max_speed;
> > int i;
> >
> > -   max_speed = fdt_getprop(fdt, node, "maximum-speed", NULL);
> > +   max_speed = ofnode_get_property(node, "maximum-speed",
> NULL);
> > if (!max_speed) {
> > pr_err("usb maximum-speed not found\n");
> > return USB_SPEED_UNKNOWN;
> > diff --git a/drivers/usb/dwc3/dwc3-generic.c
> > b/drivers/usb/dwc3/dwc3-generic.c index ca63eac..ef72c8c 100644
> > --- a/drivers/usb/dwc3/dwc3-generic.c
> > +++ b/drivers/usb/dwc3/dwc3-generic.c
> > @@ -61,18 +61,17 @@ static int
> dwc3_generic_peripheral_remove(struct
> > udevice *dev)  static int
> > dwc3_generic_peripheral_ofdata_to_platdata(struct udevice *dev)  {
> > struct dwc3 *priv = dev_get_priv(dev);
> > -   int node = dev_of_offset(dev);
> >
> > -   priv->regs = (void *)devfdt_get_addr(dev);
> > +   priv->regs = (void *)dev_read_addr(dev);
> > priv->regs += DWC3_GLOBALS_REGS_START;
> >
> > -   priv->maximum_speed = usb_get_maximum_speed(node);
> > +   priv->maximum_speed = usb_get_maximum_speed(dev->node);
> > if (priv->maximum_speed == USB_SPEED_UNKNOWN) {
> > pr_err("Invalid usb maximum speed\n");
> > return -ENODEV;
> > }
> >
> > -   priv->dr_mode = usb_get_dr_mode(node);
> > +   priv->dr_mode = usb_get_dr_mode(dev->node);
> > if (priv->dr_mode == USB_DR_MODE_UNKNOWN) {
> > pr_err("Invalid usb mode setup\n");
> > return -ENODEV;
> > @@ -100,13 +99,11 @@ U_BOOT_DRIVER(dwc3_generic_peripheral) = {
> >
> >  static int dwc3_generic_bind(struct udevice *parent)  {
> > -   const void *fdt = gd->fdt_blob;
> > -   int node;
> > +   ofnode node;
> > int ret;
> >
> > -   for (node = fdt_first_subnode(fdt, dev_of_offset(parent)); node > 0;
> > -node = fdt_next_subnode(fdt, node)) {
> > -   const char *name = fdt_get_name(fdt, node, NULL);
> > +   dev_for_each_subnode(node, parent) {
> > +   const char *name = (char *)ofnode_get_name(node);
> > enum usb_dr_mode dr_mode;
> > struct udevice *dev;
> > const char *driver;
> > @@ -133,7 +130,7 @@ static int dwc3_generic_bind(struct udevice
> *parent)
> > };
> >
> > ret = device_bind_driver_to_node(parent, driver, name,
> > -offset_to_ofnode(node),
> &dev);
> > +node, &dev);
> > if (ret) {
> > debug("%s: not able to bind usb device mode\n",
> >   __func__);
> > diff --git a/drivers/usb/host/dwc3-sti-glue.c
> > b/drivers/usb/host/dwc3-sti-glue.c
> > index ad7cf6e..de423ee 100644
> > --- a/drivers/

Re: [U-Boot] [PATCH] mtd: nand: denali_dt: Add reset support

2018-09-06 Thread Masahiro Yamada
Hi Marek,


2018-09-06 17:02 GMT+09:00 Marek Vasut :
> On 09/06/2018 03:46 AM, Masahiro Yamada wrote:
>> 2018-09-05 17:31 GMT+09:00 Marek Vasut :
>>> On 08/24/2018 03:10 PM, Marek Vasut wrote:
 On 08/24/2018 03:05 PM, Masahiro Yamada wrote:
> Hi Marek,

 Hi,

> 2018-08-21 22:57 GMT+09:00 Marek Vasut :
>> Add optional reset support into the Denali NAND driver. In case there is
>> a valid reset entry in the DT, the reset gets deasserted before the NAND
>> controller gets used.
>>
>> Signed-off-by: Marek Vasut 
>> Cc: Masahiro Yamada 
>> ---
>>  drivers/mtd/nand/denali_dt.c | 9 +
>>  1 file changed, 9 insertions(+)
>>
>> diff --git a/drivers/mtd/nand/denali_dt.c b/drivers/mtd/nand/denali_dt.c
>> index 65a7797f0f..6fcd7d3843 100644
>> --- a/drivers/mtd/nand/denali_dt.c
>> +++ b/drivers/mtd/nand/denali_dt.c
>> @@ -9,6 +9,7 @@
>>  #include 
>>  #include 
>>  #include 
>> +#include 
>>
>>  #include "denali.h"
>>
>> @@ -64,6 +65,7 @@ static int denali_dt_probe(struct udevice *dev)
>> const struct denali_dt_data *data;
>> struct clk clk;
>> struct resource res;
>> +   struct reset_ctl reset_ctl;
>> int ret;
>>
>> data = (void *)dev_get_driver_data(dev);
>> @@ -97,6 +99,13 @@ static int denali_dt_probe(struct udevice *dev)
>>
>> denali->clk_x_rate = clk_get_rate(&clk);
>>
>> +   ret = reset_get_by_index(dev, 0, &reset_ctl);
>> +   if (!ret) {
>> +   reset_assert(&reset_ctl);
>> +   udelay(2);
>> +   reset_deassert(&reset_ctl);
>> +   }
>> +
>> return denali_init(denali);
>>  }
>>
>
>
> I was testing this patch today
> because my SoC also has a reset line for NAND.
>
>
> This patch looks trivial enough,
> but if the NAND is reset here,
> my board fails to boot with
> "nand_base: timeout while waiting for chip to become ready"
>
>
> I do not know why.
> Please give me more time to figure out what is going on in my SoC.

 Sure. Maybe you need to un-reset more stuff or the reset polarity is wrong 
 ?
>>
>>
>> I do not think so.
>>
>> The reset sequence of Denali is not so simple as you may think
>> because the HW sequencer runs after the reset de-assertion.
>> It includes some SoC-dependent parts.
>>
>>
>>
>>>
>>> Did you figure something out ?
>>>
>>
>>
>> Just testing one of my boards.
>>
>> It booted by adding mdelay() after reset_deassert().
>>
>>
>>
>> reset_assert(&reset_ctl);
>> udelay(2);
>> reset_deassert(&reset_ctl);
>> mdelay(1);   /* Why is this long delay required? */
>
> It works right away after ungating the reset on my board.



With my further tests, it typically takes 200 usec
for the chip identification sequence after the reset de-assertion.

The number is for my UniPhier SoC family.

This part is SoC-dependent,
so the situation is probably different for SOCFPGA.


I'd like to suggest the following sequence.

 reset_assert(&reset_ctl);
 udelay(1);
 reset_deassert(&reset_ctl);
 udelay(200);



Is this OK with you?


The IP datasheet says that the reset lines should be
kept 10 clock cycles.  I think udelay(1) is good enough for reset assertion.



BTW, are you applying this patch to your tree?

Or, do you want me to pick this up?



>> I will read HW docs more,
>> and talk to HW engineers
>> to figure out the right solution.
>
> OK


-- 
Best Regards
Masahiro Yamada
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH] ARM: Specify aligned address for secure section instead of using attributes

2018-09-06 Thread Jagan Teki
On Thu, Sep 6, 2018 at 7:15 PM, Tom Rini  wrote:
> On Thu, Sep 06, 2018 at 11:56:28AM +0800, Chen-Yu Tsai wrote:
>
>> In commit a1274cc94a20 ("ARM: Page align secure section only when it is
>> executed in situ"), we used output section attributes (the "ALIGN"
>> keyword after the colon) to specify the alignment requirements. Using
>> the constant "COMMONPAGE" there was recently broken in binutils 2.31 [1].
>>
>> Binutils maintainer Alan Modra suggested the former method would still
>> work. Since both methods achieve the same result, this patch does just
>> that. This fixes the "reboot after bootm" issue we've been seeing on
>> sunxi when booting non-secure.
>>
>>   [1] https://sourceware.org/bugzilla/show_bug.cgi?id=23571
>>
>> Suggested-by: Alan Modra 
>> Signed-off-by: Chen-Yu Tsai 
>
> Reviewed-by: Tom Rini 

Acked-by: Jagan Teki 

>
> After a little more time for review, should I take this directly or a PR
> from the sunxi team?  Thanks!

As of now, I don't have any patches for the release please take it directly.
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 1/2] watchdog: Fix SPL builds when watchdog is enabled

2018-09-06 Thread Jagan Teki
On Tue, Sep 4, 2018 at 6:36 AM, Chris Blake  wrote:
> Without this fix, u-boot fails to comple as it tries to load watchdog.h
> during an SPL build. This breaks support for things such as the sunxi
> arch.

I'm not quite clear about the issue, was it a build break or
functionality? better to paste the log or elaborate more can helpful.
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH] driver/spi: fsl_qspi: Remove non-DM stuff

2018-09-06 Thread Ashish Kumar
Convert fsl_qspi.c to complete DM mode.

Signed-off-by: Ashish Kumar 
Tested-by: Rajat Srivastava 
Tested-by: Ye Li 
---

Tested on LS1088ARDB(arm64).
Tested on LS1021ATWR(arm32) by Rajat
Tested on i.mx6 and i.mx7 by Ye Li

Depends on patch series:
http://patchwork.ozlabs.org/patch/935858/
http://patchwork.ozlabs.org/patch/935860/

 drivers/spi/fsl_qspi.c | 138 -
 1 file changed, 138 deletions(-)

diff --git a/drivers/spi/fsl_qspi.c b/drivers/spi/fsl_qspi.c
index 197f41f9db..1598c4f698 100644
--- a/drivers/spi/fsl_qspi.c
+++ b/drivers/spi/fsl_qspi.c
@@ -84,7 +84,6 @@ DECLARE_GLOBAL_DATA_PTR;
 /* QSPI max chipselect signals number */
 #define FSL_QSPI_MAX_CHIPSELECT_NUM 4
 
-#ifdef CONFIG_DM_SPI
 /**
  * struct fsl_qspi_platdata - platform data for Freescale QSPI
  *
@@ -105,7 +104,6 @@ struct fsl_qspi_platdata {
u32 flash_num;
u32 num_chipselect;
 };
-#endif
 
 /**
  * struct fsl_qspi_priv - private data for Freescale QSPI
@@ -136,12 +134,6 @@ struct fsl_qspi_priv {
struct fsl_qspi_regs *regs;
 };
 
-#ifndef CONFIG_DM_SPI
-struct fsl_qspi {
-   struct spi_slave slave;
-   struct fsl_qspi_priv priv;
-};
-#endif
 
 static u32 qspi_read32(u32 flags, u32 *addr)
 {
@@ -869,136 +861,7 @@ void qspi_cfg_smpr(struct fsl_qspi_priv *priv, u32 
clear_bits, u32 set_bits)
smpr_val |= set_bits;
qspi_write32(priv->flags, &priv->regs->smpr, smpr_val);
 }
-#ifndef CONFIG_DM_SPI
-static unsigned long spi_bases[] = {
-   QSPI0_BASE_ADDR,
-#ifdef CONFIG_MX6SX
-   QSPI1_BASE_ADDR,
-#endif
-};
-
-static unsigned long amba_bases[] = {
-   QSPI0_AMBA_BASE,
-#ifdef CONFIG_MX6SX
-   QSPI1_AMBA_BASE,
-#endif
-};
-
-static inline struct fsl_qspi *to_qspi_spi(struct spi_slave *slave)
-{
-   return container_of(slave, struct fsl_qspi, slave);
-}
-
-struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
-   unsigned int max_hz, unsigned int mode)
-{
-   u32 mcr_val;
-   struct fsl_qspi *qspi;
-   struct fsl_qspi_regs *regs;
-   u32 total_size;
-
-   if (bus >= ARRAY_SIZE(spi_bases))
-   return NULL;
-
-   if (cs >= FSL_QSPI_FLASH_NUM)
-   return NULL;
-
-   qspi = spi_alloc_slave(struct fsl_qspi, bus, cs);
-   if (!qspi)
-   return NULL;
-
-#ifdef CONFIG_SYS_FSL_QSPI_BE
-   qspi->priv.flags |= QSPI_FLAG_REGMAP_ENDIAN_BIG;
-#endif
-
-   regs = (struct fsl_qspi_regs *)spi_bases[bus];
-   qspi->priv.regs = regs;
-   /*
-* According cs, use different amba_base to choose the
-* corresponding flash devices.
-*
-* If not, only one flash device is used even if passing
-* different cs using `sf probe`
-*/
-   qspi->priv.cur_amba_base = amba_bases[bus] + cs * FSL_QSPI_FLASH_SIZE;
-
-   qspi->slave.max_write_size = TX_BUFFER_SIZE;
-
-   mcr_val = qspi_read32(qspi->priv.flags, ®s->mcr);
-
-   /* Set endianness to LE for i.mx */
-   if (IS_ENABLED(CONFIG_MX6) || IS_ENABLED(CONFIG_MX7))
-   mcr_val = QSPI_MCR_END_CFD_LE;
-
-   qspi_write32(qspi->priv.flags, ®s->mcr,
-QSPI_MCR_RESERVED_MASK | QSPI_MCR_MDIS_MASK |
-(mcr_val & QSPI_MCR_END_CFD_MASK));
-
-   qspi_cfg_smpr(&qspi->priv,
- ~(QSPI_SMPR_FSDLY_MASK | QSPI_SMPR_DDRSMP_MASK |
- QSPI_SMPR_FSPHS_MASK | QSPI_SMPR_HSENA_MASK), 0);
-
-   total_size = FSL_QSPI_FLASH_SIZE * FSL_QSPI_FLASH_NUM;
-   /*
-* Any read access to non-implemented addresses will provide
-* undefined results.
-*
-* In case single die flash devices, TOP_ADDR_MEMA2 and
-* TOP_ADDR_MEMB2 should be initialized/programmed to
-* TOP_ADDR_MEMA1 and TOP_ADDR_MEMB1 respectively - in effect,
-* setting the size of these devices to 0.  This would ensure
-* that the complete memory map is assigned to only one flash device.
-*/
-   qspi_write32(qspi->priv.flags, ®s->sfa1ad,
-FSL_QSPI_FLASH_SIZE | amba_bases[bus]);
-   qspi_write32(qspi->priv.flags, ®s->sfa2ad,
-FSL_QSPI_FLASH_SIZE | amba_bases[bus]);
-   qspi_write32(qspi->priv.flags, ®s->sfb1ad,
-total_size | amba_bases[bus]);
-   qspi_write32(qspi->priv.flags, ®s->sfb2ad,
-total_size | amba_bases[bus]);
-
-   qspi_set_lut(&qspi->priv);
-
-#ifdef CONFIG_SYS_FSL_QSPI_AHB
-   qspi_init_ahb_read(&qspi->priv);
-#endif
-
-   qspi_module_disable(&qspi->priv, 0);
-
-   return &qspi->slave;
-}
-
-void spi_free_slave(struct spi_slave *slave)
-{
-   struct fsl_qspi *qspi = to_qspi_spi(slave);
-
-   free(qspi);
-}
 
-int spi_claim_bus(struct spi_slave *slave)
-{
-   return 0;
-}
-
-void spi_release_bus(struct spi_slave *slave)
-{
-   /* Nothing to do */
-}
-
-int spi_xfer(struct spi_slave *slave, unsigned int bitlen,

Re: [U-Boot] [PATCH 12/12] riscv: Add QEMU virt board support

2018-09-06 Thread Bin Meng
Hi Tuomas,

On Fri, Sep 7, 2018 at 5:03 AM Tuomas Tynkkynen  wrote:
>
> Hi Bin,
>
> On 09/04/2018 12:31 PM, Bin Meng wrote:
> > Hi Lukas,
> >
> > On Tue, Sep 4, 2018 at 5:39 AM Auer, Lukas
> >  wrote:
> >>
> >> On Thu, 2018-08-30 at 00:54 -0700, Bin Meng wrote:
> >>> This adds QEMU RISC-V 'virt' board target support, with the hope of
> >>> helping people easily test U-Boot on RISC-V.
> >>>
> >>> The QEMU virt machine models a generic RISC-V virtual machine with
> >>> support for the VirtIO standard networking and block storage devices.
> >>> It has CLINT, PLIC, 16550A UART devices in addition to VirtIO and
> >>> it also uses device-tree to pass configuration information to guest
> >>> software. It implements RISC-V privileged architecture spec v1.10.
> >>>
> >>> Both 32-bit and 64-bit builds are supported. Support is pretty much
> >>> preliminary, only booting to U-Boot shell with the UART driver on
> >>> a single core. Booting Linux is not supported yet.
> >>>
> >>
> >> For your information and to avoid duplicate work, I am working on a
> >> patch set that improves RISC-V support in u-boot. I am currently able
> >> to boot Linux on a multi-core setup in QEMU, but they are not quite
> >> ready to submit yet.
> >>
> >
> > This is great! My next step is to work on virtio driver support in
> > U-Boot as qemu-riscv virt machine has these devices but we don't have
> > corresponding drivers in U-Boot.
> At some point I was working on porting the virtio stack from Linux to
> U-Boot and IIRC got virtio-blk and virtio-net working on ARM. But other
> things consumed my time and I never quite finished that work. Let me
> know if you want to take a look.

This is great. I just finished reading the virtio 1.0 spec and was
about to start the work. My interest was to add virtio-blk and
virtio-net driver to U-Boot too since they are most common devices
(others are not used too much I believe). If you already have the
drivers working, I can help to bring them upstream.

Regards,
Bin
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 08/12] riscv: Add a helper routine to print CPU information

2018-09-06 Thread Bin Meng
Hi Lucas,

On Fri, Sep 7, 2018 at 5:29 AM Auer, Lukas
 wrote:
>
> Hi Bin,
>
> On Thu, 2018-09-06 at 11:03 +0800, Bin Meng wrote:
> > Hi Lukas,
> >
> > On Tue, Sep 4, 2018 at 5:42 AM Auer, Lukas
> >  wrote:
> > >
> > > On Thu, 2018-08-30 at 00:54 -0700, Bin Meng wrote:
> > > > This adds a helper routine to print CPU information. Currently
> > > > it prints all the instruction set extensions that the processor
> > > > core supports.
> > > >
> > > > Signed-off-by: Bin Meng 
> > > > ---
> > > >
> > > >  arch/riscv/Makefile  |   1 +
> > > >  arch/riscv/cpu/Makefile  |   5 ++
> > > >  arch/riscv/cpu/cpu.c |  49 +
> > > >  arch/riscv/include/asm/csr.h | 124
> > > > +++
> > > >  4 files changed, 179 insertions(+)
> > > >  create mode 100644 arch/riscv/cpu/Makefile
> > > >  create mode 100644 arch/riscv/cpu/cpu.c
> > > >  create mode 100644 arch/riscv/include/asm/csr.h
> > > >
> > > > diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile
> > > > index 084888a..af432e1 100644
> > > > --- a/arch/riscv/Makefile
> > > > +++ b/arch/riscv/Makefile
> > > > @@ -5,5 +5,6 @@
> > > >
> > > >  head-y := arch/riscv/cpu/$(CPU)/start.o
> > > >
> > > > +libs-y += arch/riscv/cpu/
> > > >  libs-y += arch/riscv/cpu/$(CPU)/
> > > >  libs-y += arch/riscv/lib/
> > > > diff --git a/arch/riscv/cpu/Makefile b/arch/riscv/cpu/Makefile
> > > > new file mode 100644
> > > > index 000..63de163
> > > > --- /dev/null
> > > > +++ b/arch/riscv/cpu/Makefile
> > > > @@ -0,0 +1,5 @@
> > > > +# SPDX-License-Identifier: GPL-2.0+
> > > > +#
> > > > +# Copyright (C) 2018, Bin Meng 
> > > > +
> > > > +obj-y += cpu.o
> > > > diff --git a/arch/riscv/cpu/cpu.c b/arch/riscv/cpu/cpu.c
> > > > new file mode 100644
> > > > index 000..ae57fb8
> > > > --- /dev/null
> > > > +++ b/arch/riscv/cpu/cpu.c
> > > > @@ -0,0 +1,49 @@
> > > > +// SPDX-License-Identifier: GPL-2.0+
> > > > +/*
> > > > + * Copyright (C) 2018, Bin Meng 
> > > > + */
> > > > +
> > > > +#include 
> > > > +#include 
> > > > +
> > > > +enum {
> > > > + ISA_INVALID = 0,
> > > > + ISA_32BIT,
> > > > + ISA_64BIT,
> > > > + ISA_128BIT
> > > > +};
> > > > +
> > > > +static const char * const isa_bits[] = {
> > > > + [ISA_INVALID] = NULL,
> > > > + [ISA_32BIT]   = "32",
> > > > + [ISA_64BIT]   = "64",
> > > > + [ISA_128BIT]  = "128"
> > > > +};
> > > > +
> > > > +static inline bool supports_extension(char ext)
> > > > +{
> > > > + return csr_read(misa) & (1 << (ext - 'a'));
> > > > +}
> > > > +
> > > > +int print_cpuinfo(void)
> > > > +{
> > > > + char name[32];
> > > > + char *s = name;
> > > > + int bit;
> > > > +
> > > > + s += sprintf(name, "rv");
> > > > + bit = csr_read(misa) >> (sizeof(long) * 8 - 2);
> > > > + s += sprintf(s, isa_bits[bit]);
> > > > +
> > > > + supports_extension('i') ? *s++ = 'i' : 'r';
> > > > + supports_extension('m') ? *s++ = 'm' : 'i';
> > > > + supports_extension('a') ? *s++ = 'a' : 's';
> > > > + supports_extension('f') ? *s++ = 'f' : 'c';
> > > > + supports_extension('d') ? *s++ = 'd' : '-';
> > > > + supports_extension('c') ? *s++ = 'c' : 'v';
> > > > + *s++ = '\0';
> > > > +
> > > > + printf("CPU:   %s\n", name);
> > > > +
> > > > + return 0;
> > > > +}
> > > > diff --git a/arch/riscv/include/asm/csr.h
> > > > b/arch/riscv/include/asm/csr.h
> > > > new file mode 100644
> > > > index 000..50fccea
> > > > --- /dev/null
> > > > +++ b/arch/riscv/include/asm/csr.h
> > > > @@ -0,0 +1,124 @@
> > > > +/* SPDX-License-Identifier: GPL-2.0 */
> > > > +/*
> > > > + * Copyright (C) 2015 Regents of the University of California
> > > > + *
> > > > + * Taken from Linux arch/riscv/include/asm/csr.h
> > > > + */
> > > > +
> > > > +#ifndef _ASM_RISCV_CSR_H
> > > > +#define _ASM_RISCV_CSR_H
> > > > +
> > > > +/* Status register flags */
> > > > +#define SR_SIE   _AC(0x0002, UL) /* Supervisor
> > > > Interrupt Enable */
> > > > +#define SR_SPIE  _AC(0x0020, UL) /* Previous
> > > > Supervisor IE */
> > > > +#define SR_SPP   _AC(0x0100, UL) /* Previously
> > > > Supervisor */
> > > > +#define SR_SUM   _AC(0x0004, UL) /* Supervisor
> > > > access User Memory */
> > > > +
> > > > +#define SR_FS_AC(0x6000, UL) /* Floating-
> > > > point
> > > > Status */
> > > > +#define SR_FS_OFF_AC(0x, UL)
> > > > +#define SR_FS_INITIAL_AC(0x2000, UL)
> > > > +#define SR_FS_CLEAN  _AC(0x4000, UL)
> > > > +#define SR_FS_DIRTY  _AC(0x6000, UL)
> > > > +
> > > > +#define SR_XS_AC(0x00018000, UL) /* Extension
> > > > Status
> > > > */
> > > > +#define SR_XS_OFF_AC(0x, UL)
> > > > +#define SR_XS_INITIAL_AC(0x8000, UL)
> > > > +#define SR_XS_CLEAN  _AC(0x0001, UL)
> > > > +#define SR_XS_DIRTY  _AC(0x00018000, UL)
> > > > +
> > > > +#ifndef CONFIG_64BIT
> > > > +#define SR_SD  

Re: [U-Boot] [PATCH] gpio: dwapb_gpio: Change to use devm_kcalloc()

2018-09-06 Thread Ley Foon Tan
On Thu, Sep 6, 2018 at 7:14 PM Marek Vasut  wrote:
>
> On 09/06/2018 04:48 PM, Ley Foon Tan wrote:
> > Change to use managed resource function devm_kcalloc(),
> > so it will auto free memory when driver is removed.
> >
> > Signed-off-by: Ley Foon Tan 
> > ---
> >  drivers/gpio/dwapb_gpio.c | 3 +--
> >  1 file changed, 1 insertion(+), 2 deletions(-)
> >
> > diff --git a/drivers/gpio/dwapb_gpio.c b/drivers/gpio/dwapb_gpio.c
> > index 0f6574d..1594434 100644
> > --- a/drivers/gpio/dwapb_gpio.c
> > +++ b/drivers/gpio/dwapb_gpio.c
> > @@ -171,8 +171,7 @@ static int gpio_dwapb_bind(struct udevice *dev)
> >   if (!fdtdec_get_bool(blob, node, "gpio-controller"))
> >   continue;
> >
> > - plat = NULL;
> > - plat = calloc(1, sizeof(*plat));
> > + plat = devm_kcalloc(dev, 1, sizeof(*plat), GFP_KERNEL);
> >   if (!plat)
> >   return -ENOMEM;
>
> You also need to drop the matching free()
Yes, you are right. Will fix that.

Thanks.

Regards
Ley Foon
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 1/4] ARM: bootscript: Remove hard-coded rootpath from K+P's tpcboot.cmd

2018-09-06 Thread Lukasz Majewski
Dear Tom, Stefano,

> The 'rootpath' can be provided by DHCP server. Removing this line
> prevents from overwriting it.
> 
> To do that on the DHCP server side (isc-dhcp-server) modify dhcpd.conf
> and add 'option root-path "192.168.X.Y:/srv/tftp/rootfs";'
> 
> Signed-off-by: Lukasz Majewski 
> ---
> 
>  board/k+p/bootscripts/tpcboot.cmd | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/board/k+p/bootscripts/tpcboot.cmd
> b/board/k+p/bootscripts/tpcboot.cmd index 16b93ebe3f..9290317730
> 100644 --- a/board/k+p/bootscripts/tpcboot.cmd
> +++ b/board/k+p/bootscripts/tpcboot.cmd
> @@ -65,7 +65,6 @@ fi"
>  #
>  # Provide 'boot_nfs' command
>  #
> -setenv rootpath "/srv/tftp/KP/rootfs"
>  setenv nfsargs "setenv bootargs root=/dev/nfs rw \
> nfsroot=${serverip}:${rootpath},nolock,nfsvers=3"
>  setenv addip "setenv bootargs ${bootargs} \

Is there any chance that this series would be applied before v2018.09
release? 

Those are fixes related to a particular board(s), which I do maintain.

Thanks in advance.


Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de


pgpuPZUVmK6hC.pgp
Description: OpenPGP digital signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 12/12] riscv: Add QEMU virt board support

2018-09-06 Thread Auer, Lukas
Hi Bin,

On Thu, 2018-09-06 at 11:15 +0800, Bin Meng wrote:
> Hi Lukas,
> 
> On Wed, Sep 5, 2018 at 5:37 PM Auer, Lukas
>  wrote:
> > 
> > On Wed, 2018-09-05 at 10:34 +0800, Bin Meng wrote:
> > > Hi Rick,
> > > 
> > > On Wed, Sep 5, 2018 at 9:27 AM Rick Chen 
> > > wrote:
> > > > 
> > > >  > > From: Auer, Lukas [mailto:lukas.a...@aisec.fraunhofer.de]
> > > >  > > Sent: Wednesday, September 05, 2018 5:53 AM
> > > >  > > To: bmeng...@gmail.com
> > > >  > > Cc: Rick Jian-Zhi Chen(陳建志); u-boot@lists.denx.de
> > > >  > > Subject: Re: [U-Boot] [PATCH 12/12] riscv: Add QEMU virt
> > > > board
> > > > support
> > > >  > >
> > > >  > > On Tue, 2018-09-04 at 17:31 +0800, Bin Meng wrote:
> > > >  > > > Hi Lukas,
> > > >  > > >
> > > >  > > > On Tue, Sep 4, 2018 at 5:39 AM Auer, Lukas
> > > >  > > >  wrote:
> > > >  > > > >
> > > >  > > > > On Thu, 2018-08-30 at 00:54 -0700, Bin Meng wrote:
> > > >  > > > > > This adds QEMU RISC-V 'virt' board target support,
> > > > with
> > > > the hope
> > > >  > > > > > of helping people easily test U-Boot on RISC-V.
> > > >  > > > > >
> > > >  > > > > > The QEMU virt machine models a generic RISC-V
> > > > virtual
> > > > machine
> > > >  > > > > > with support for the VirtIO standard networking and
> > > > block
> > > >  > > > > > storage devices.
> > > >  > > > > > It has CLINT, PLIC, 16550A UART devices in addition
> > > > to
> > > > VirtIO
> > > >  > > > > > and it also uses device-tree to pass configuration
> > > > information
> > > >  > > > > > to guest software. It implements RISC-V privileged
> > > > architecture
> > > >  > > > > > spec v1.10.
> > > >  > > > > >
> > > >  > > > > > Both 32-bit and 64-bit builds are supported. Support
> > > > is
> > > > pretty
> > > >  > > > > > much preliminary, only booting to U-Boot shell with
> > > > the
> > > > UART
> > > >  > > > > > driver on a single core. Booting Linux is not
> > > > supported
> > > > yet.
> > > >  > > > > >
> > > >  > > > >
> > > >  > > > > For your information and to avoid duplicate work, I am
> > > > working on
> > > >  > > > > a patch set that improves RISC-V support in u-boot. I
> > > > am
> > > > currently
> > > >  > > > > able to boot Linux on a multi-core setup in QEMU, but
> > > > they
> > > > are not
> > > >  > > > > quite ready to submit yet.
> > > >  > > > >
> > > >  > > >
> > > >  > > > This is great! My next step is to work on virtio driver
> > > > support in
> > > >  > > > U-Boot as qemu-riscv virt machine has these devices but
> > > > we
> > > > don't
> > > >  > > > have corresponding drivers in U-Boot. Then I will try to
> > > > boot Linux
> > > >  > > > after that. Good to hear you already boot Linux with
> > > > qemu-
> > > > riscv!
> > > >  > > > Have you already supported virtio drivers in your port?
> > > > If
> > > > yes, I
> > > >  > > > will just hold on and wait for your patch series :-)
> > > >  > > >
> > > >  > >
> > > >  > > Hi Bin,
> > > >  > >
> > > >  > > Support for the virtio devices would be great! I don't
> > > > support
> > > > them in
> > > >  > > my port, I can only boot a kernel image from RAM.
> > > >  > > I only have a driver for the clint0 (core local interrupt
> > > > controller),
> > > >  > > which I need for software interrupts to other cores and as
> > > > a
> > > > timer.
> > > >  > > Software interrupts also work over the supervisor binary
> > > > interface
> > > >  > > (SBI), which allows u-boot to run in supervisor mode with
> > > > bbl
> > > > running
> > > >  > > in machine mode to handle the SBI calls.
> > > >  > >
> > > > 
> > > > Hi Bin and Auer
> > > > 
> > > > I have already boot bbl run in S-mode and riscv-linux in M-mode 
> > > > via
> > > > u-boot from SD card or FLASH.
> > > > It mean after booting riscv-linux, u-boot will be dead. And no
> > > > matter
> > > > about kernel.
> > > > Please refer to doc/README.ae350
> > > > 
> > > 
> > > Thanks for pointing out the doc for ae350. I just read it, and
> > > have
> > > one question. There is a chapter in that doc "Boot bbl and riscv-
> > > linux
> > > via U-Boot on QEMU", yet I don't see what QEMU command is
> > > invoked.
> > > Can
> > > you please clarify? AFAIK mainline QEMU does not have support to
> > > ae350
> > > board. Also there is no instructions on how bbl was built. Is
> > > that
> > > the
> > > mainline bbl that can work on every riscv board? I doubt that.
> > > 
> > > > May I figure out more clearly what are you going to do ?
> > > > What are you going to do is let u-boot run in S-mode and boot
> > > > bbl
> > > > and
> > > > riscv-linux in M-mode, right ?
> > > 
> > > I want to use U-Boot to directly boot Linux, but seems Lukas is
> > > using
> > > bbl for SBI implementation.
> > > 
> > 
> > Hi Bin,
> > 
> > I don't really need bbl to run u-boot. I use it for Linux, which
> > expects the SBI to be present.
> > 
> > > > It mean after booting bbl and riscv-linux, u-boot will still
> > > > alive
> > > > and
> > > > handle SBI calls and somethings in S-mode.
> > > > 
> > > > Or u-boot is going to 

Re: [U-Boot] [PATCH 12/12] riscv: Add QEMU virt board support

2018-09-06 Thread Auer, Lukas
Hi Bin,

On Thu, 2018-09-06 at 11:14 +0800, Bin Meng wrote:
> Hi Lukas,
> 
> On Wed, Sep 5, 2018 at 5:35 PM Auer, Lukas
>  wrote:
> > 
> > On Wed, 2018-09-05 at 09:28 +0800, Rick Chen wrote:
> > >  > > From: Auer, Lukas [mailto:lukas.a...@aisec.fraunhofer.de]
> > >  > > Sent: Wednesday, September 05, 2018 5:53 AM
> > >  > > To: bmeng...@gmail.com
> > >  > > Cc: Rick Jian-Zhi Chen(陳建志); u-boot@lists.denx.de
> > >  > > Subject: Re: [U-Boot] [PATCH 12/12] riscv: Add QEMU virt
> > > board
> > > support
> > >  > >
> > >  > > On Tue, 2018-09-04 at 17:31 +0800, Bin Meng wrote:
> > >  > > > Hi Lukas,
> > >  > > >
> > >  > > > On Tue, Sep 4, 2018 at 5:39 AM Auer, Lukas
> > >  > > >  wrote:
> > >  > > > >
> > >  > > > > On Thu, 2018-08-30 at 00:54 -0700, Bin Meng wrote:
> > >  > > > > > This adds QEMU RISC-V 'virt' board target support,
> > > with
> > > the hope
> > >  > > > > > of helping people easily test U-Boot on RISC-V.
> > >  > > > > >
> > >  > > > > > The QEMU virt machine models a generic RISC-V virtual
> > > machine
> > >  > > > > > with support for the VirtIO standard networking and
> > > block
> > >  > > > > > storage devices.
> > >  > > > > > It has CLINT, PLIC, 16550A UART devices in addition to
> > > VirtIO
> > >  > > > > > and it also uses device-tree to pass configuration
> > > information
> > >  > > > > > to guest software. It implements RISC-V privileged
> > > architecture
> > >  > > > > > spec v1.10.
> > >  > > > > >
> > >  > > > > > Both 32-bit and 64-bit builds are supported. Support
> > > is
> > > pretty
> > >  > > > > > much preliminary, only booting to U-Boot shell with
> > > the
> > > UART
> > >  > > > > > driver on a single core. Booting Linux is not
> > > supported
> > > yet.
> > >  > > > > >
> > >  > > > >
> > >  > > > > For your information and to avoid duplicate work, I am
> > > working on
> > >  > > > > a patch set that improves RISC-V support in u-boot. I am
> > > currently
> > >  > > > > able to boot Linux on a multi-core setup in QEMU, but
> > > they
> > > are not
> > >  > > > > quite ready to submit yet.
> > >  > > > >
> > >  > > >
> > >  > > > This is great! My next step is to work on virtio driver
> > > support in
> > >  > > > U-Boot as qemu-riscv virt machine has these devices but we
> > > don't
> > >  > > > have corresponding drivers in U-Boot. Then I will try to
> > > boot
> > > Linux
> > >  > > > after that. Good to hear you already boot Linux with qemu-
> > > riscv!
> > >  > > > Have you already supported virtio drivers in your port? If
> > > yes, I
> > >  > > > will just hold on and wait for your patch series :-)
> > >  > > >
> > >  > >
> > >  > > Hi Bin,
> > >  > >
> > >  > > Support for the virtio devices would be great! I don't
> > > support
> > > them in
> > >  > > my port, I can only boot a kernel image from RAM.
> > >  > > I only have a driver for the clint0 (core local interrupt
> > > controller),
> > >  > > which I need for software interrupts to other cores and as a
> > > timer.
> > >  > > Software interrupts also work over the supervisor binary
> > > interface
> > >  > > (SBI), which allows u-boot to run in supervisor mode with
> > > bbl
> > > running
> > >  > > in machine mode to handle the SBI calls.
> > >  > >
> > > 
> > > Hi Bin and Auer
> > > 
> > > I have already boot bbl run in S-mode and riscv-linux in M-mode
> > > via
> > > u-boot from SD card or FLASH.
> > > It mean after booting riscv-linux, u-boot will be dead. And no
> > > matter
> > > about kernel.
> > > Please refer to doc/README.ae350
> > > 
> > > May I figure out more clearly what are you going to do ?
> > > What are you going to do is let u-boot run in S-mode and boot bbl
> > > and
> > > riscv-linux in M-mode, right ?
> > > It mean after booting bbl and riscv-linux, u-boot will still
> > > alive
> > > and
> > > handle SBI calls and somethings in S-mode.
> > > 
> > > Or u-boot is going to replace the role of bbl ?
> > > 
> > > Rick
> > > 
> > 
> > Hi Rick,
> > 
> > Not exactly, my current boot flow is as follows.
> > 
> > 1. u-boot SPL starts in machine mode and jumps to bbl
> > 2. bbl starts u-boot proper in supervisor mode
> > 3. u-boot boots the kernel
> > 
> 
> If this is QEMU virt target, there is no need to boot from SPL then
> U-Boot proper.
> 

That's true. My goal was to load bbl without having to embed either  
u-boot or Linux in it. That boot flow is similar to armv8, where ARM
trusted firmware can be loaded by SPL.
With an SBI implementation in u-boot this is not required of course. I
think I'll simplify my boot flow for now and remove SPL. Either u-boot
or Linux must then be embedded into bbl until we have our own SBI
implementation.

Thanks,
Lukas

> > bbl is still active once Linux has booted and is used there for its
> > SBI
> > implementation. Hope this helps.
> 
> Yes, I am not quite convinced why Linux kernel was designed this way.
> This is something like x86's SMM or EFI runtime services...
> 
> Regards,
> Bin
___
U-Boot mailing lis

Re: [U-Boot] [PATCH v2 2/2] spl: socfpga: stratix10: add hex file output for spl image

2018-09-06 Thread Marek Vasut
On 09/06/2018 11:26 PM, Dalon L Westergreen wrote:
> On Thu, 2018-09-06 at 15:41 +0200, Marek Vasut wrote:
>> On 09/06/2018 03:39 PM, Dalon L Westergreen wrote:
>> On Thu, 2018-09-06 at 12:09 +0200, Marek Vasut wrote:
>> On 09/06/2018 05:02 AM, Dalon Westergreen wrote:
>> Stratix10 requires a hex image of the spl for boot.  The hex
>> image is added to the FPGA configuration image and loaded to
>> the processor memory by the configuration engine.
>>
>> v2:
>>   -> add CONFIG_OF_EMBED to include dtb in elf
>>   -> generate hex from elf source
>>
>> Signed-off-by: Dalon Westergreen >  > >>
>> ---
>>  configs/socfpga_stratix10_defconfig | 1 +
>>  scripts/Makefile.spl| 6 ++
>>  2 files changed, 7 insertions(+)
>>
>> diff --git a/configs/socfpga_stratix10_defconfig 
>> b/configs/socfpga_stratix10_defconfig
>> index dceadff439..17cc732cbe 100644
>> --- a/configs/socfpga_stratix10_defconfig
>> +++ b/configs/socfpga_stratix10_defconfig
>> @@ -56,3 +56,4 @@ CONFIG_DM_USB=y
>>  CONFIG_USB_DWC2=y
>>  CONFIG_USB_STORAGE=y
>>  CONFIG_USE_TINY_PRINTF=y
>> +CONFIG_OF_EMBED=y
>>
>> Why is this needed ? And where did the objcopy hack go ? What is the
>> explanation here ?
>>
>> You suggested the use of CONFIG_OF_EMBED as an alternative to using the
>> u-boot-spl-dtb.bin for objcopy.
>> The intent is to ensure that the spl elf has the dtb included, and then
>> a simple objcopy to elf to hex is fine.
>> You no longer need the --change-address as the elf indicates the correct
>> start address, unlike the binary.
>>
>> And that's fine with your usecase ? Fine be me then ...
>>
>> diff --git a/scripts/Makefile.spl b/scripts/Makefile.spl
>> index 76d08fd92b..b09bd40b2a 100644
>> --- a/scripts/Makefile.spl
>> +++ b/scripts/Makefile.spl
>> @@ -190,6 +190,7 @@ endif
>>  ifdef CONFIG_ARCH_SOCFPGA
>>  ALL-$(CONFIG_TARGET_SOCFPGA_GEN5)   += $(obj)/$(SPL_BIN).sfp
>>  ALL-$(CONFIG_TARGET_SOCFPGA_ARRIA10)+= $(obj)/$(SPL_BIN).sfp
>> +ALL-$(CONFIG_TARGET_SOCFPGA_STRATIX10)  += $(obj)/$(SPL_BIN).hex
>>
>> CONFIG_SPL_TARGET "u-boot-spl.hex" can replace this addition I think ?
> 
> This doesnt actually work as CONFIG_SPL_TARGET doesnt appear to be an
> SPL target, but rather a
> target for creating combined u-boot + spl images at the top level. Adding
> 
> ALL-$(CONFIG_SPL_TARGET) += $(obj)/$(SPL_BIN).hex
> 
> in Makefile.spl and
> CONFIG_SPL_TARGET="u-boot-spl.hex"
> in the socfpga_stratix10_config
> 
> results in a build failure with no target for u-boot-spl.hex

I mean, just define CONFIG_SPL_TARGET and it should generate the
matching file automatically. See the README, it explains this macro.

-- 
Best regards,
Marek Vasut
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 03/12] riscv: bootm: Correct the 1st kernel argument to hart id

2018-09-06 Thread Auer, Lukas
Hi Bin,

On Thu, 2018-09-06 at 10:57 +0800, Bin Meng wrote:
> Hi Lukas,
> 
> On Tue, Sep 4, 2018 at 5:41 AM Auer, Lukas
>  wrote:
> > 
> > On Thu, 2018-08-30 at 00:54 -0700, Bin Meng wrote:
> > > The first argument of Linux kernel is the risc-v core hart id,
> > > from which the kernel is booted from. It is not the mach_id,
> > > which seems to be copied from arm.
> > > 
> > > Signed-off-by: Bin Meng 
> > > ---
> > > 
> > >  arch/riscv/lib/bootm.c | 18 +-
> > >  1 file changed, 5 insertions(+), 13 deletions(-)
> > > 
> > > diff --git a/arch/riscv/lib/bootm.c b/arch/riscv/lib/bootm.c
> > > index 6662aff..754bbff 100644
> > > --- a/arch/riscv/lib/bootm.c
> > > +++ b/arch/riscv/lib/bootm.c
> > > @@ -25,10 +25,7 @@ int arch_fixup_fdt(void *blob)
> > > 
> > >  int do_bootm_linux(int flag, int argc, char *argv[],
> > > bootm_headers_t
> > > *images)
> > >  {
> > > - bd_t*bd = gd->bd;
> > > - char*s;
> > > - int machid = bd->bi_arch_number;
> > > - void(*theKernel)(int arch, uint params);
> > > + void(*kernel)(int hart, uint dtb);
> > 
> > This probably does not cause any issues in u-boot, but the second
> > parameter should be 32 bit or 64 bit depending on the architecture.
> > Since you are already changing the kernel arguments it would make
> > sense
> > to also change dtb from uint to ulong or void *.
> > 
> 
> Yes. Will address this in v2.
> 
> > > 
> > >   /*
> > >* allow the PREP bootm subcommand, it is required for
> > > bootm to
> > > work
> > > @@ -39,18 +36,12 @@ int do_bootm_linux(int flag, int argc, char
> > > *argv[], bootm_headers_t *images)
> > >   if ((flag != 0) && (flag != BOOTM_STATE_OS_GO))
> > >   return 1;
> > > 
> > > - theKernel = (void (*)(int, uint))images->ep;
> > > -
> > > - s = env_get("machid");
> > > - if (s) {
> > > - machid = simple_strtoul(s, NULL, 16);
> > > - printf("Using machid 0x%x from environment\n",
> > > machid);
> > > - }
> > > + kernel = (void (*)(int, uint))images->ep;
> > > 
> > >   bootstage_mark(BOOTSTAGE_ID_RUN_OS);
> > > 
> > >   debug("## Transferring control to Linux (at address %08lx)
> > > ...\n",
> > > -(ulong)theKernel);
> > > +(ulong)kernel);
> > > 
> > >   if (IMAGE_ENABLE_OF_LIBFDT && images->ft_len) {
> > >  #ifdef CONFIG_OF_LIBFDT
> > > @@ -66,8 +57,9 @@ int do_bootm_linux(int flag, int argc, char
> > > *argv[], bootm_headers_t *images)
> > >   printf("\nStarting kernel ...\n\n");
> > > 
> > >   cleanup_before_linux();
> > > + /* TODO: hardcode the hart id to zero for now */
> > >   if (IMAGE_ENABLE_OF_LIBFDT && images->ft_len)
> > > - theKernel(machid, (unsigned long)images->ft_addr);
> > > + kernel(0, (unsigned long)images->ft_addr);
> > > 
> > 
> > You can use the mhartid CSR to get the hart id. This will limit u-
> > boot
> > to running in machine mode however. Alternatively you can also use
> > the
> > hart id, which is passed in a0 by the bootloader.
> > 
> 
> If the goal is to use U-Boot to directly boot Linux, I think we need
> more changes. I believe we should allow only one hart to execute this
> function. For other harts, they should be waked up and jump to kernel
> directly.
> 

Yes, that's true. We should be able to pick which hart executes it
though. This is useful for chips like SiFive's U54, where hart 0 is a
smaller hart for monitoring tasks. Here it would make sense to run   
u-boot on one of the other harts.

Thanks,
Lukas
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 08/12] riscv: Add a helper routine to print CPU information

2018-09-06 Thread Auer, Lukas
Hi Bin,

On Thu, 2018-09-06 at 11:03 +0800, Bin Meng wrote:
> Hi Lukas,
> 
> On Tue, Sep 4, 2018 at 5:42 AM Auer, Lukas
>  wrote:
> > 
> > On Thu, 2018-08-30 at 00:54 -0700, Bin Meng wrote:
> > > This adds a helper routine to print CPU information. Currently
> > > it prints all the instruction set extensions that the processor
> > > core supports.
> > > 
> > > Signed-off-by: Bin Meng 
> > > ---
> > > 
> > >  arch/riscv/Makefile  |   1 +
> > >  arch/riscv/cpu/Makefile  |   5 ++
> > >  arch/riscv/cpu/cpu.c |  49 +
> > >  arch/riscv/include/asm/csr.h | 124
> > > +++
> > >  4 files changed, 179 insertions(+)
> > >  create mode 100644 arch/riscv/cpu/Makefile
> > >  create mode 100644 arch/riscv/cpu/cpu.c
> > >  create mode 100644 arch/riscv/include/asm/csr.h
> > > 
> > > diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile
> > > index 084888a..af432e1 100644
> > > --- a/arch/riscv/Makefile
> > > +++ b/arch/riscv/Makefile
> > > @@ -5,5 +5,6 @@
> > > 
> > >  head-y := arch/riscv/cpu/$(CPU)/start.o
> > > 
> > > +libs-y += arch/riscv/cpu/
> > >  libs-y += arch/riscv/cpu/$(CPU)/
> > >  libs-y += arch/riscv/lib/
> > > diff --git a/arch/riscv/cpu/Makefile b/arch/riscv/cpu/Makefile
> > > new file mode 100644
> > > index 000..63de163
> > > --- /dev/null
> > > +++ b/arch/riscv/cpu/Makefile
> > > @@ -0,0 +1,5 @@
> > > +# SPDX-License-Identifier: GPL-2.0+
> > > +#
> > > +# Copyright (C) 2018, Bin Meng 
> > > +
> > > +obj-y += cpu.o
> > > diff --git a/arch/riscv/cpu/cpu.c b/arch/riscv/cpu/cpu.c
> > > new file mode 100644
> > > index 000..ae57fb8
> > > --- /dev/null
> > > +++ b/arch/riscv/cpu/cpu.c
> > > @@ -0,0 +1,49 @@
> > > +// SPDX-License-Identifier: GPL-2.0+
> > > +/*
> > > + * Copyright (C) 2018, Bin Meng 
> > > + */
> > > +
> > > +#include 
> > > +#include 
> > > +
> > > +enum {
> > > + ISA_INVALID = 0,
> > > + ISA_32BIT,
> > > + ISA_64BIT,
> > > + ISA_128BIT
> > > +};
> > > +
> > > +static const char * const isa_bits[] = {
> > > + [ISA_INVALID] = NULL,
> > > + [ISA_32BIT]   = "32",
> > > + [ISA_64BIT]   = "64",
> > > + [ISA_128BIT]  = "128"
> > > +};
> > > +
> > > +static inline bool supports_extension(char ext)
> > > +{
> > > + return csr_read(misa) & (1 << (ext - 'a'));
> > > +}
> > > +
> > > +int print_cpuinfo(void)
> > > +{
> > > + char name[32];
> > > + char *s = name;
> > > + int bit;
> > > +
> > > + s += sprintf(name, "rv");
> > > + bit = csr_read(misa) >> (sizeof(long) * 8 - 2);
> > > + s += sprintf(s, isa_bits[bit]);
> > > +
> > > + supports_extension('i') ? *s++ = 'i' : 'r';
> > > + supports_extension('m') ? *s++ = 'm' : 'i';
> > > + supports_extension('a') ? *s++ = 'a' : 's';
> > > + supports_extension('f') ? *s++ = 'f' : 'c';
> > > + supports_extension('d') ? *s++ = 'd' : '-';
> > > + supports_extension('c') ? *s++ = 'c' : 'v';
> > > + *s++ = '\0';
> > > +
> > > + printf("CPU:   %s\n", name);
> > > +
> > > + return 0;
> > > +}
> > > diff --git a/arch/riscv/include/asm/csr.h
> > > b/arch/riscv/include/asm/csr.h
> > > new file mode 100644
> > > index 000..50fccea
> > > --- /dev/null
> > > +++ b/arch/riscv/include/asm/csr.h
> > > @@ -0,0 +1,124 @@
> > > +/* SPDX-License-Identifier: GPL-2.0 */
> > > +/*
> > > + * Copyright (C) 2015 Regents of the University of California
> > > + *
> > > + * Taken from Linux arch/riscv/include/asm/csr.h
> > > + */
> > > +
> > > +#ifndef _ASM_RISCV_CSR_H
> > > +#define _ASM_RISCV_CSR_H
> > > +
> > > +/* Status register flags */
> > > +#define SR_SIE   _AC(0x0002, UL) /* Supervisor
> > > Interrupt Enable */
> > > +#define SR_SPIE  _AC(0x0020, UL) /* Previous
> > > Supervisor IE */
> > > +#define SR_SPP   _AC(0x0100, UL) /* Previously
> > > Supervisor */
> > > +#define SR_SUM   _AC(0x0004, UL) /* Supervisor
> > > access User Memory */
> > > +
> > > +#define SR_FS_AC(0x6000, UL) /* Floating-
> > > point
> > > Status */
> > > +#define SR_FS_OFF_AC(0x, UL)
> > > +#define SR_FS_INITIAL_AC(0x2000, UL)
> > > +#define SR_FS_CLEAN  _AC(0x4000, UL)
> > > +#define SR_FS_DIRTY  _AC(0x6000, UL)
> > > +
> > > +#define SR_XS_AC(0x00018000, UL) /* Extension
> > > Status
> > > */
> > > +#define SR_XS_OFF_AC(0x, UL)
> > > +#define SR_XS_INITIAL_AC(0x8000, UL)
> > > +#define SR_XS_CLEAN  _AC(0x0001, UL)
> > > +#define SR_XS_DIRTY  _AC(0x00018000, UL)
> > > +
> > > +#ifndef CONFIG_64BIT
> > > +#define SR_SD_AC(0x8000, UL) /* FS/XS dirty
> > > */
> > > +#else
> > > +#define SR_SD_AC(0x8000, UL) /*
> > > FS/XS
> > > dirty */
> > > +#endif
> > > +
> > > +/* SATP flags */
> > > +#if __riscv_xlen == 32
> > > +#define SATP_PPN _AC(0x003F, UL)
> > > +#define SATP_MODE_32 _AC(0x8000, UL)
> > > +#define SATP

Re: [U-Boot] [PATCH v2 2/2] spl: socfpga: stratix10: add hex file output for spl image

2018-09-06 Thread Dalon L Westergreen
On Thu, 2018-09-06 at 15:41 +0200, Marek Vasut wrote:
> On 09/06/2018 03:39 PM, Dalon L Westergreen wrote:
> 
> On Thu, 2018-09-06 at 12:09 +0200, Marek Vasut wrote:
> 
> On 09/06/2018 05:02 AM, Dalon Westergreen wrote:
> Stratix10 requires a hex image of the spl for boot.  The hex
> image is added to the FPGA configuration image and loaded to
> the processor memory by the configuration engine.
> 
> v2:
>   -> add CONFIG_OF_EMBED to include dtb in elf
>   -> generate hex from elf source
> 
> Signed-off-by: Dalon Westergreen  >
> ---
>  configs/socfpga_stratix10_defconfig | 1 +
>  scripts/Makefile.spl| 6 ++
>  2 files changed, 7 insertions(+)
> 
> diff --git a/configs/socfpga_stratix10_defconfig 
> b/configs/socfpga_stratix10_defconfig
> index dceadff439..17cc732cbe 100644
> --- a/configs/socfpga_stratix10_defconfig
> +++ b/configs/socfpga_stratix10_defconfig
> @@ -56,3 +56,4 @@ CONFIG_DM_USB=y
>  CONFIG_USB_DWC2=y
>  CONFIG_USB_STORAGE=y
>  CONFIG_USE_TINY_PRINTF=y
> +CONFIG_OF_EMBED=y
> 
> Why is this needed ? And where did the objcopy hack go ? What is the
> explanation here ?
> 
> You suggested the use of CONFIG_OF_EMBED as an alternative to using the
> u-boot-spl-dtb.bin for objcopy.
> The intent is to ensure that the spl elf has the dtb included, and then
> a simple objcopy to elf to hex is fine.
> You no longer need the --change-address as the elf indicates the correct
> start address, unlike the binary.
> 
> And that's fine with your usecase ? Fine be me then ...
> 
> 
> 
> diff --git a/scripts/Makefile.spl b/scripts/Makefile.spl
> index 76d08fd92b..b09bd40b2a 100644
> --- a/scripts/Makefile.spl
> +++ b/scripts/Makefile.spl
> @@ -190,6 +190,7 @@ endif
>  ifdef CONFIG_ARCH_SOCFPGA
>  ALL-$(CONFIG_TARGET_SOCFPGA_GEN5)+= $(obj)/$(SPL_BIN).sfp
>  ALL-$(CONFIG_TARGET_SOCFPGA_ARRIA10) += $(obj)/$(SPL_BIN).sfp
> +ALL-$(CONFIG_TARGET_SOCFPGA_STRATIX10)   += $(obj)/$(SPL_BIN).hex
> 
> CONFIG_SPL_TARGET "u-boot-spl.hex" can replace this addition I think ?

This doesnt actually work as CONFIG_SPL_TARGET doesnt appear to be an SPL
target, but rather a
target for creating combined u-boot + spl images at the top level.  Adding

ALL-$(CONFIG_SPL_TARGET) += $(obj)/$(SPL_BIN).hex 

in Makefile.spl and 
CONFIG_SPL_TARGET="u-boot-spl.hex" 
in the socfpga_stratix10_config

results in a build failure with no target for u-boot-spl.hex

> 
>  endif
>  
>  ifdef CONFIG_ARCH_SUNXI
> @@ -299,6 +300,11 @@ OBJCOPYFLAGS_u-boot-x86-16bit-spl.bin := -O binary -j 
> .start16 -j .resetvec
>  $(obj)/u-boot-x86-16bit-spl.bin: $(obj)/u-boot-spl FORCE
>   $(call if_changed,objcopy)
>  
> +OBJCOPYFLAGS_$(SPL_BIN).hex = -O ihex
> +
> +$(obj)/$(SPL_BIN).hex: $(obj)/$(SPL_BIN) FORCE
> + $(call if_changed,objcopy)
> +
> 
> This is generic, separate patch please.
> 
>  LDFLAGS_$(SPL_BIN) += -T u-boot-spl.lds $(LDFLAGS_FINAL)
>  
> 
> Will do
> 
> Thanks
> 
> 
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 12/12] riscv: Add QEMU virt board support

2018-09-06 Thread Tuomas Tynkkynen

Hi Bin,

On 09/04/2018 12:31 PM, Bin Meng wrote:

Hi Lukas,

On Tue, Sep 4, 2018 at 5:39 AM Auer, Lukas
 wrote:


On Thu, 2018-08-30 at 00:54 -0700, Bin Meng wrote:

This adds QEMU RISC-V 'virt' board target support, with the hope of
helping people easily test U-Boot on RISC-V.

The QEMU virt machine models a generic RISC-V virtual machine with
support for the VirtIO standard networking and block storage devices.
It has CLINT, PLIC, 16550A UART devices in addition to VirtIO and
it also uses device-tree to pass configuration information to guest
software. It implements RISC-V privileged architecture spec v1.10.

Both 32-bit and 64-bit builds are supported. Support is pretty much
preliminary, only booting to U-Boot shell with the UART driver on
a single core. Booting Linux is not supported yet.



For your information and to avoid duplicate work, I am working on a
patch set that improves RISC-V support in u-boot. I am currently able
to boot Linux on a multi-core setup in QEMU, but they are not quite
ready to submit yet.



This is great! My next step is to work on virtio driver support in
U-Boot as qemu-riscv virt machine has these devices but we don't have
corresponding drivers in U-Boot. 

At some point I was working on porting the virtio stack from Linux to
U-Boot and IIRC got virtio-blk and virtio-net working on ARM. But other
things consumed my time and I never quite finished that work. Let me
know if you want to take a look.

- Tuomas
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v2 1/1] test/py: typo occured

2018-09-06 Thread Heinrich Schuchardt
%s/occured/occurred/

Signed-off-by: Heinrich Schuchardt 
---
v2:
remove an obsolete correction
---
 test/py/tests/test_efi_selftest.py | 2 +-
 1 file changed, 1 insertions(+), 1 deletions(-)

diff --git a/test/py/tests/test_efi_selftest.py 
b/test/py/tests/test_efi_selftest.py
index de3272402e..994d2e2241 100644
--- a/test/py/tests/test_efi_selftest.py
+++ b/test/py/tests/test_efi_selftest.py
@@ -16,7 +16,7 @@ def test_efi_selftest(u_boot_console):
u_boot_console.run_command(cmd='bootefi selftest', 
wait_for_prompt=False)
m = u_boot_console.p.expect(['Summary: 0 failures', 'Press any key'])
if m != 0:
-   raise Exception('Failures occured during the EFI selftest')
+   raise Exception('Failures occurred during the EFI selftest')
u_boot_console.run_command(cmd='', wait_for_echo=False, 
wait_for_prompt=False);
m = u_boot_console.p.expect(['resetting', 'U-Boot'])
if m != 0:
-- 
2.18.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 1/1] test/py: typo occured

2018-09-06 Thread Heinrich Schuchardt
%s/occured/occurred/

Signed-off-by: Heinrich Schuchardt 
---
 test/py/tests/test_efi_selftest.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/test/py/tests/test_efi_selftest.py 
b/test/py/tests/test_efi_selftest.py
index de3272402e..994d2e2241 100644
--- a/test/py/tests/test_efi_selftest.py
+++ b/test/py/tests/test_efi_selftest.py
@@ -16,7 +16,7 @@ def test_efi_selftest(u_boot_console):
u_boot_console.run_command(cmd='bootefi selftest', 
wait_for_prompt=False)
m = u_boot_console.p.expect(['Summary: 0 failures', 'Press any key'])
if m != 0:
-   raise Exception('Failures occured during the EFI selftest')
+   raise Exception('Failures occurred during the EFI selftest')
u_boot_console.run_command(cmd='', wait_for_echo=False, 
wait_for_prompt=False);
m = u_boot_console.p.expect(['resetting', 'U-Boot'])
if m != 0:
@@ -104,5 +104,5 @@ def test_efi_selftest_text_input(u_boot_console):
   wait_for_prompt=False)
m = u_boot_console.p.expect(['Summary: 0 failures', 'Press any key'])
if m != 0:
-   raise Exception('Failures occured during the EFI selftest')
+   raise Exception('Failures occurred during the EFI selftest')
u_boot_console.restart_uboot();
-- 
2.18.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 1/1] test/py: test EFI_SIMPLE_TEXT_INPUT_PROTOCOL

2018-09-06 Thread Heinrich Schuchardt
Execute the EFI selftest for the EFI_SIMPLE_TEXT_INPUT_PROTOCOL.

Signed-off-by: Heinrich Schuchardt 
---
 test/py/tests/test_efi_selftest.py | 58 ++
 1 file changed, 58 insertions(+)

diff --git a/test/py/tests/test_efi_selftest.py 
b/test/py/tests/test_efi_selftest.py
index 747d52d935..de3272402e 100644
--- a/test/py/tests/test_efi_selftest.py
+++ b/test/py/tests/test_efi_selftest.py
@@ -48,3 +48,61 @@ def test_efi_selftest_watchdog_reboot(u_boot_console):
if m != 0:
raise Exception('Reset failed in \'watchdog reboot\' test')
u_boot_console.restart_uboot();
+
+@pytest.mark.buildconfigspec('cmd_bootefi_selftest')
+def test_efi_selftest_text_input(u_boot_console):
+   """Test the EFI_SIMPLE_TEXT_INPUT_PROTOCOL
+
+   :param u_boot_console: U-Boot console
+
+   This function calls the text input EFI selftest.
+   """
+   u_boot_console.run_command(cmd='setenv efi_selftest text input')
+   output = u_boot_console.run_command(cmd='bootefi selftest',
+   wait_for_prompt=False)
+   m = u_boot_console.p.expect(['To terminate type \'x\''])
+   if m != 0:
+   raise Exception('No prompt for \'text input\' test')
+   u_boot_console.drain_console()
+   u_boot_console.p.timeout = 500
+   # EOT
+   u_boot_console.run_command(cmd=chr(4), wait_for_echo=False,
+  send_nl=False, wait_for_prompt=False)
+   m = u_boot_console.p.expect(['Unicode char 4'])
+   if m != 0:
+   raise Exception('EOT failed in \'text input\' test')
+   u_boot_console.drain_console()
+   # BS
+   u_boot_console.run_command(cmd=chr(8), wait_for_echo=False,
+  send_nl=False, wait_for_prompt=False)
+   m = u_boot_console.p.expect(['(BS)'])
+   if m != 0:
+   raise Exception('BS failed in \'text input\' test')
+   u_boot_console.drain_console()
+   # TAB
+   u_boot_console.run_command(cmd=chr(9), wait_for_echo=False,
+  send_nl=False, wait_for_prompt=False)
+   m = u_boot_console.p.expect(['(TAB)'])
+   if m != 0:
+   raise Exception('BS failed in \'text input\' test')
+   u_boot_console.drain_console()
+   # a
+   u_boot_console.run_command(cmd='a', wait_for_echo=False, send_nl=False,
+  wait_for_prompt=False)
+   m = u_boot_console.p.expect(['(\'a\')'])
+   if m != 0:
+   raise Exception('\'a\' failed in \'text input\' test')
+   u_boot_console.drain_console()
+   # UP escape sequence
+   u_boot_console.run_command(cmd=chr(27) + '[A', wait_for_echo=False,
+  send_nl=False, wait_for_prompt=False)
+   m = u_boot_console.p.expect(['(Up)'])
+   if m != 0:
+   raise Exception('UP failed in \'text input\' test')
+   u_boot_console.drain_console()
+   u_boot_console.run_command(cmd='x', wait_for_echo=False, send_nl=False,
+  wait_for_prompt=False)
+   m = u_boot_console.p.expect(['Summary: 0 failures', 'Press any key'])
+   if m != 0:
+   raise Exception('Failures occurred during the EFI selftest')
+   u_boot_console.restart_uboot();
-- 
2.18.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v2 2/2] spl: socfpga: stratix10: add hex file output for spl image

2018-09-06 Thread Marek Vasut
On 09/06/2018 07:40 PM, Dalon L Westergreen wrote:
> On Thu, 2018-09-06 at 15:41 +0200, Marek Vasut wrote:
>> On 09/06/2018 03:39 PM, Dalon L Westergreen wrote:
>> On Thu, 2018-09-06 at 12:09 +0200, Marek Vasut wrote:
>> On 09/06/2018 05:02 AM, Dalon Westergreen wrote:
>> Stratix10 requires a hex image of the spl for boot.  The hex
>> image is added to the FPGA configuration image and loaded to
>> the processor memory by the configuration engine.
>>
>> v2:
>>   -> add CONFIG_OF_EMBED to include dtb in elf
>>   -> generate hex from elf source
>>
>> Signed-off-by: Dalon Westergreen >  > >>
>> ---
>>  configs/socfpga_stratix10_defconfig | 1 +
>>  scripts/Makefile.spl| 6 ++
>>  2 files changed, 7 insertions(+)
>>
>> diff --git a/configs/socfpga_stratix10_defconfig 
>> b/configs/socfpga_stratix10_defconfig
>> index dceadff439..17cc732cbe 100644
>> --- a/configs/socfpga_stratix10_defconfig
>> +++ b/configs/socfpga_stratix10_defconfig
>> @@ -56,3 +56,4 @@ CONFIG_DM_USB=y
>>  CONFIG_USB_DWC2=y
>>  CONFIG_USB_STORAGE=y
>>  CONFIG_USE_TINY_PRINTF=y
>> +CONFIG_OF_EMBED=y
>>
>> Why is this needed ? And where did the objcopy hack go ? What is the
>> explanation here ?
>>
>> You suggested the use of CONFIG_OF_EMBED as an alternative to using the
>> u-boot-spl-dtb.bin for objcopy.
>> The intent is to ensure that the spl elf has the dtb included, and then
>> a simple objcopy to elf to hex is fine.
>> You no longer need the --change-address as the elf indicates the correct
>> start address, unlike the binary.
>>
>> And that's fine with your usecase ? Fine be me then ...
> 
> Is it possible to apply CONFIG_OF_EMBED=y only to the SPL build?

I think so, and if not, create CONFIG_SPL_OF_EMBED

-- 
Best regards,
Marek Vasut
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v2 2/2] spl: socfpga: stratix10: add hex file output for spl image

2018-09-06 Thread Dalon L Westergreen
On Thu, 2018-09-06 at 15:41 +0200, Marek Vasut wrote:
> On 09/06/2018 03:39 PM, Dalon L Westergreen wrote:
> On Thu, 2018-09-06 at 12:09 +0200, Marek Vasut wrote:
> On 09/06/2018 05:02 AM, Dalon Westergreen wrote:Stratix10 requires a hex image
> of the spl for boot.  The heximage is added to the FPGA configuration image
> and loaded tothe processor memory by the configuration engine.
> v2:  -> add CONFIG_OF_EMBED to include dtb in elf  -> generate hex from elf
> source
> Signed-off-by: Dalon Westergreen  dwest...@gmail.com>>--- configs/socfpga_stratix10_defconfig | 1 +
> scripts/Makefile.spl| 6 ++ 2 files changed, 7
> insertions(+)
> diff --git a/configs/socfpga_stratix10_defconfig
> b/configs/socfpga_stratix10_defconfigindex dceadff439..17cc732cbe 100644---
> a/configs/socfpga_stratix10_defconfig+++
> b/configs/socfpga_stratix10_defconfig@@ -56,3 +56,4 @@ CONFIG_DM_USB=y
> CONFIG_USB_DWC2=y CONFIG_USB_STORAGE=y
> CONFIG_USE_TINY_PRINTF=y+CONFIG_OF_EMBED=y
> Why is this needed ? And where did the objcopy hack go ? What is
> theexplanation here ?
> You suggested the use of CONFIG_OF_EMBED as an alternative to using theu-boot-
> spl-dtb.bin for objcopy.The intent is to ensure that the spl elf has the dtb
> included, and thena simple objcopy to elf to hex is fine.You no longer need
> the --change-address as the elf indicates the correctstart address, unlike the
> binary.
> And that's fine with your usecase ? Fine be me then ...

Is it possible to apply CONFIG_OF_EMBED=y only to the SPL build?
> diff --git a/scripts/Makefile.spl b/scripts/Makefile.splindex
> 76d08fd92b..b09bd40b2a 100644--- a/scripts/Makefile.spl+++
> b/scripts/Makefile.spl@@ -190,6 +190,7 @@ endif ifdef CONFIG_ARCH_SOCFPGA ALL-
> $(CONFIG_TARGET_SOCFPGA_GEN5) += $(obj)/$(SPL_BIN).sfp ALL-
> $(CONFIG_TARGET_SOCFPGA_ARRIA10)  += $(obj)/$(SPL_BIN).sfp+ALL-
> $(CONFIG_TARGET_SOCFPGA_STRATIX10)+= $(obj)/$(SPL_BIN).hex
> CONFIG_SPL_TARGET "u-boot-spl.hex" can replace this addition I think ?
>  endif  ifdef CONFIG_ARCH_SUNXI@@ -299,6 +300,11 @@ OBJCOPYFLAGS_u-boot-x86-
> 16bit-spl.bin := -O binary -j .start16 -j .resetvec $(obj)/u-boot-x86-16bit-
> spl.bin: $(obj)/u-boot-spl FORCE  $(call if_changed,objcopy)
> +OBJCOPYFLAGS_$(SPL_BIN).hex = -O ihex++$(obj)/$(SPL_BIN).hex:
> $(obj)/$(SPL_BIN) FORCE+  $(call if_changed,objcopy)+
> This is generic, separate patch please.
>  LDFLAGS_$(SPL_BIN) += -T u-boot-spl.lds $(LDFLAGS_FINAL) 
> Will do
> Thanks
> 
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PULL] Please pull u-boot-imx

2018-09-06 Thread Peter Robinson
> > I tested current master successfully on Hummingboard2 with i.MX6 Solo
> > (SOM rev 1.5):
>
> Thanks for testing.
>
> It seems we need more information from Peter about the regression he reported.
>
> It would be helpful if Peter could run a bisect so that we could
> understand where the regression is coming from.

We're using gcc 8.2 and binutils 2.31 and there have been a few
interesting bits there on some other platforms, I wonder if something
like that is coming along here with the latest toolchains. I'll try
building with Fedora 27 (gcc 7.3.1 / binutils 2.29) to rule them out
first.

P
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PULL] Please pull u-boot-imx

2018-09-06 Thread Fabio Estevam
Hi Baruch,

On Thu, Sep 6, 2018 at 12:42 PM, Baruch Siach  wrote:

> I tested current master successfully on Hummingboard2 with i.MX6 Solo
> (SOM rev 1.5):

Thanks for testing.

It seems we need more information from Peter about the regression he reported.

It would be helpful if Peter could run a bisect so that we could
understand where the regression is coming from.

Thanks
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PULL] Please pull u-boot-imx

2018-09-06 Thread Baruch Siach
Hi Fabio,

Fabio Estevam writes:
> Hi Peter,
>
> [Adding Jon and Baruch]
>
> On Thu, Sep 6, 2018 at 9:37 AM, Peter Robinson  wrote:
>
>> It seems like the Wandboard Quad revB I have also works fine so It
>> might just be a regression in the mx6cuboxi target.
>
> I don't have access to a hummingboard2 to investigate it.
>
> Does this issue also happen on a mx6q cuboxi?
>
> Are you able to run a bisect?

I tested current master successfully on Hummingboard2 with i.MX6 Solo
(SOM rev 1.5):

U-Boot SPL 2018.09-rc3-00026-g4cdeda511f80 (Sep 06 2018 - 18:30:30 +0300)
Trying to boot from MMC1


U-Boot 2018.09-rc3-00026-g4cdeda511f80 (Sep 06 2018 - 18:30:30 +0300)

CPU:   Freescale i.MX6SOLO rev1.3 996 MHz (running at 792 MHz)
CPU:   Commercial temperature grade (0C to 95C) at 38C
Reset cause: POR
Board: MX6 HummingBoard2 (som rev 1.5)
DRAM:  512 MiB
MMC:   FSL_SDHC: 0, FSL_SDHC: 1
Loading Environment from MMC... *** Warning - bad CRC, using default environment

No panel detected: default to HDMI
Display: HDMI (1024x768)
In:serial
Out:   serial
Err:   serial
Net:   FEC
Error: FEC address not set.

Hit any key to stop autoboot:  0
=>

... and with i.MX6Q (SOM rev 1.3):

U-Boot SPL 2018.09-rc3-00026-g4cdeda511f80 (Sep 06 2018 - 18:30:30 +0300)
Trying to boot from MMC1


U-Boot 2018.09-rc3-00026-g4cdeda511f80 (Sep 06 2018 - 18:30:30 +0300)

CPU:   Freescale i.MX6Q rev1.5 996 MHz (running at 792 MHz)
CPU:   Extended Commercial temperature grade (-20C to 105C) at 27C
Reset cause: POR
Board: MX6 HummingBoard2
DRAM:  2 GiB
MMC:   FSL_SDHC: 0, FSL_SDHC: 1
Loading Environment from MMC... *** Warning - bad CRC, using default environment

No panel detected: default to HDMI
Display: HDMI (1024x768)
In:serial
Out:   serial
Err:   serial
Card did not respond to voltage select!
Net:   FEC
Hit any key to stop autoboot:  0
=>

I don't have handy at the moment the exact same combination of HB2 with
i.MX6Q SOM rev 1.5.

I built mx6cuboxi_defconfig with no changes using Linaro GCC 7.3-2018.05.

baruch

--
 http://baruch.siach.name/blog/  ~. .~   Tk Open Systems
=}ooO--U--Ooo{=
   - bar...@tkos.co.il - tel: +972.52.368.4656, http://www.tkos.co.il -
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH] mtd: spi: Add DM support to SH QSPI driver

2018-09-06 Thread Jagan Teki
On Mon, Sep 3, 2018 at 12:46 AM, Marek Vasut  wrote:
> On 09/02/2018 08:41 PM, Jagan Teki wrote:
>> On Sun, Sep 2, 2018 at 11:56 PM, Marek Vasut  wrote:
>>> On 09/02/2018 08:00 PM, Jagan Teki wrote:
 On Sun, Aug 26, 2018 at 4:07 PM, Marek Vasut  wrote:
> On 08/26/2018 08:45 AM, Jagan Teki wrote:
>> On Sat, Aug 25, 2018 at 11:04 PM, Marek Vasut  
>> wrote:
>>> Add DM support to the SH QSPI driver while retaining non-DM support.
>>> The later is required as this driver is used in SPL which has a size
>>> limitation of 16 kiB.
>>>
>>> Signed-off-by: Marek Vasut 
>>> Cc: Nobuhiro Iwamatsu 
>>> ---
>>>  drivers/spi/sh_qspi.c | 215 
>>> +++---
>>>  1 file changed, 150 insertions(+), 65 deletions(-)
>>>
>>> diff --git a/drivers/spi/sh_qspi.c b/drivers/spi/sh_qspi.c
>>> index e9123e2c39..64dfd748d6 100644
>>> --- a/drivers/spi/sh_qspi.c
>>> +++ b/drivers/spi/sh_qspi.c
>>> @@ -67,15 +67,12 @@ struct sh_qspi_regs {
>>>  };
>>>
>>>  struct sh_qspi_slave {
>>> +#ifndef CONFIG_DM_SPI
>>
>> We are trying to drop non-dm code as much as possible (with
>> MIGRATION.txt policy), how about adding PLTADATA or spi read glue code
>> or any other?
>
> The SPL on that board (silk) has 16 kiB limit, right now I am at 15500 B
> with gcc 7.x already, adding any more overhead will make it overflow. So
> while I'd like to have it all fancy DM and stuff, it's not possible.

 How about having simple glue code for SPL, since it anyway used for
 read in real?
>>>
>>> I'd prefer to use the same driver for both SPL and U-Boot instead of
>>> hacking stuff up. Not sure what exactly you mean by "glue" though.
>>
>> Something that bypass spi stack and read the flash with local code,
>> this usually suited for low SRAM size like silk example
>> spl_spi_sunxi.c
>
> But I am not _that_ cripplingly low, so I'd prefer to stick to a
> standard solution instead of some hack.

OK, is this a fix or shall I take it for next?
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 2/2] watchdog: Add sunxi watchdog driver

2018-09-06 Thread Jagan Teki
On Tue, Sep 4, 2018 at 6:36 AM, Chris Blake  wrote:
> Based on the linux mainline driver, this adds support for the hardware
> watchdog timer found on some sunxi boards.

This has to do it via UCLASS_WDT and there is enough sunxi code using
watchdog so update the same accordingly.
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH] spi: designware_spi: Add reset ctrl to driver

2018-09-06 Thread Jagan Teki
On Thu, Sep 6, 2018 at 7:52 PM, Ley Foon Tan  wrote:
> Add code to reset all reset signals as in SPI DT node. A reset property
> is an optional feature, so only print out a warning and do not fail if a
> reset property is not present.
>
> If a reset property is discovered, then use it to deassert, thus
> bringing the IP out of reset.
>
> Release reset when _remove().
>
> Signed-off-by: Ley Foon Tan 

Reviewed-by: Jagan Teki 
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v2] usb: dwc3: convert to livetree

2018-09-06 Thread Michal Simek
On 6.9.2018 12:39, Siva Durga Prasad Paladugu wrote:
> From: Vipul Kumar 
> 
> Update the DWC3 USB driver to support a live tree.
> 
> Signed-off-by: Siva Durga Prasad Paladugu 
> Signed-off-by: Vipul Kumar 
> Tested-by: Michal Simek 
> ---
> Changes in v2:
> - Fixed travis build issues with some platforms.
> ---
>  drivers/usb/common/common.c  | 11 +--
>  drivers/usb/dwc3/dwc3-generic.c  | 17 +++--
>  drivers/usb/host/dwc3-sti-glue.c |  7 +++
>  drivers/usb/host/xhci-dwc3.c |  3 ++-
>  drivers/usb/host/xhci-zynqmp.c   |  3 +--
>  drivers/usb/musb-new/ti-musb.c   | 11 ---
>  include/linux/usb/otg.h  |  6 --
>  7 files changed, 26 insertions(+), 32 deletions(-)
> 
> diff --git a/drivers/usb/common/common.c b/drivers/usb/common/common.c
> index a55def5..3dea79b 100644
> --- a/drivers/usb/common/common.c
> +++ b/drivers/usb/common/common.c
> @@ -10,6 +10,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  
>  DECLARE_GLOBAL_DATA_PTR;
>  
> @@ -20,13 +21,12 @@ static const char *const usb_dr_modes[] = {
>   [USB_DR_MODE_OTG]   = "otg",
>  };
>  
> -enum usb_dr_mode usb_get_dr_mode(int node)
> +enum usb_dr_mode usb_get_dr_mode(ofnode node)
>  {
> - const void *fdt = gd->fdt_blob;
>   const char *dr_mode;
>   int i;
>  
> - dr_mode = fdt_getprop(fdt, node, "dr_mode", NULL);
> + dr_mode = ofnode_get_property(node, "dr_mode", NULL);
>   if (!dr_mode) {
>   pr_err("usb dr_mode not found\n");
>   return USB_DR_MODE_UNKNOWN;
> @@ -48,13 +48,12 @@ static const char *const speed_names[] = {
>   [USB_SPEED_SUPER] = "super-speed",
>  };
>  
> -enum usb_device_speed usb_get_maximum_speed(int node)
> +enum usb_device_speed usb_get_maximum_speed(ofnode node)
>  {
> - const void *fdt = gd->fdt_blob;
>   const char *max_speed;
>   int i;
>  
> - max_speed = fdt_getprop(fdt, node, "maximum-speed", NULL);
> + max_speed = ofnode_get_property(node, "maximum-speed", NULL);
>   if (!max_speed) {
>   pr_err("usb maximum-speed not found\n");
>   return USB_SPEED_UNKNOWN;
> diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c
> index ca63eac..ef72c8c 100644
> --- a/drivers/usb/dwc3/dwc3-generic.c
> +++ b/drivers/usb/dwc3/dwc3-generic.c
> @@ -61,18 +61,17 @@ static int dwc3_generic_peripheral_remove(struct udevice 
> *dev)
>  static int dwc3_generic_peripheral_ofdata_to_platdata(struct udevice *dev)
>  {
>   struct dwc3 *priv = dev_get_priv(dev);
> - int node = dev_of_offset(dev);
>  
> - priv->regs = (void *)devfdt_get_addr(dev);
> + priv->regs = (void *)dev_read_addr(dev);
>   priv->regs += DWC3_GLOBALS_REGS_START;
>  
> - priv->maximum_speed = usb_get_maximum_speed(node);
> + priv->maximum_speed = usb_get_maximum_speed(dev->node);
>   if (priv->maximum_speed == USB_SPEED_UNKNOWN) {
>   pr_err("Invalid usb maximum speed\n");
>   return -ENODEV;
>   }
>  
> - priv->dr_mode = usb_get_dr_mode(node);
> + priv->dr_mode = usb_get_dr_mode(dev->node);
>   if (priv->dr_mode == USB_DR_MODE_UNKNOWN) {
>   pr_err("Invalid usb mode setup\n");
>   return -ENODEV;
> @@ -100,13 +99,11 @@ U_BOOT_DRIVER(dwc3_generic_peripheral) = {
>  
>  static int dwc3_generic_bind(struct udevice *parent)
>  {
> - const void *fdt = gd->fdt_blob;
> - int node;
> + ofnode node;
>   int ret;
>  
> - for (node = fdt_first_subnode(fdt, dev_of_offset(parent)); node > 0;
> -  node = fdt_next_subnode(fdt, node)) {
> - const char *name = fdt_get_name(fdt, node, NULL);
> + dev_for_each_subnode(node, parent) {
> + const char *name = (char *)ofnode_get_name(node);
>   enum usb_dr_mode dr_mode;
>   struct udevice *dev;
>   const char *driver;
> @@ -133,7 +130,7 @@ static int dwc3_generic_bind(struct udevice *parent)
>   };
>  
>   ret = device_bind_driver_to_node(parent, driver, name,
> -  offset_to_ofnode(node), &dev);
> +  node, &dev);
>   if (ret) {
>   debug("%s: not able to bind usb device mode\n",
> __func__);
> diff --git a/drivers/usb/host/dwc3-sti-glue.c 
> b/drivers/usb/host/dwc3-sti-glue.c
> index ad7cf6e..de423ee 100644
> --- a/drivers/usb/host/dwc3-sti-glue.c
> +++ b/drivers/usb/host/dwc3-sti-glue.c
> @@ -153,18 +153,17 @@ static int sti_dwc3_glue_ofdata_to_platdata(struct 
> udevice *dev)
>  static int sti_dwc3_glue_bind(struct udevice *dev)
>  {
>   struct sti_dwc3_glue_platdata *plat = dev_get_platdata(dev);
> - int dwc3_node;
> + ofnode dwc3_node;
>  
>   /* check if one subnode is present */
> - dwc3_node = fdt_first_subnode(gd->fdt_blob, dev_of_offset(dev));
> + dwc3_node = dev_read_fi

Re: [U-Boot] [PATCH v3 1/1] ARM: opos6ul: make the board boot again

2018-09-06 Thread Stefano Babic
On 06/09/2018 09:51, Sébastien Szymanski wrote:
> Commit 9faa43c4b5e5 ("ARM: dts: i.MX6UL: U-Boot specific dts for u-boot,
> dm-spl") removes the u-boot,dm-spl properties from the imx6ul.dtsi file
> and breaks the OPOS6UL board.
> Add the u-boot,dm-spl properties into *-u-boot.dts files to make the
> board boot again.
> 
> Fixes: commit 9faa43c4b5e5 ("ARM: dts: i.MX6UL: U-Boot specific dts for 
> u-boot, dm-spl")
> Signed-off-by: Sébastien Szymanski 
> ---
> 
> Changes for v3:
>  - use the automatic inclusion of -u-boot.dtsi mechanism of U-Boot.
> 
> Changes for v2:
>  - put u-boot,dm-spl properties into -u-boot.dts files
> 
>  arch/arm/dts/imx6ul-opos6ul-u-boot.dtsi| 28 
>  arch/arm/dts/imx6ul-opos6ul.dtsi   |  2 --
>  arch/arm/dts/imx6ul-opos6uldev-u-boot.dtsi | 24 
>  arch/arm/dts/imx6ul-opos6uldev.dts |  2 --
>  4 files changed, 52 insertions(+), 4 deletions(-)
>  create mode 100644 arch/arm/dts/imx6ul-opos6ul-u-boot.dtsi
>  create mode 100644 arch/arm/dts/imx6ul-opos6uldev-u-boot.dtsi
> 
> diff --git a/arch/arm/dts/imx6ul-opos6ul-u-boot.dtsi 
> b/arch/arm/dts/imx6ul-opos6ul-u-boot.dtsi
> new file mode 100644
> index 00..4918de388e
> --- /dev/null
> +++ b/arch/arm/dts/imx6ul-opos6ul-u-boot.dtsi
> @@ -0,0 +1,28 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Device Tree Source extras for U-Boot for the OPOS6UL SoM
> + *
> + * Copyright (C) 2018 Armadeus Systems 
> + */
> +
> +/ {
> + soc {
> + u-boot,dm-spl;
> + };
> +};
> +
> +&aips2 {
> + u-boot,dm-spl;
> +};
> +
> +&iomuxc {
> + u-boot,dm-spl;
> +};
> +
> +&pinctrl_usdhc1 {
> + u-boot,dm-spl;
> +};
> +
> +&usdhc1 {
> + u-boot,dm-spl;
> +};
> diff --git a/arch/arm/dts/imx6ul-opos6ul.dtsi 
> b/arch/arm/dts/imx6ul-opos6ul.dtsi
> index d51ad4de20..8f16a0a81c 100644
> --- a/arch/arm/dts/imx6ul-opos6ul.dtsi
> +++ b/arch/arm/dts/imx6ul-opos6ul.dtsi
> @@ -99,7 +99,6 @@
>  
>  /* eMMC */
>  &usdhc1 {
> - u-boot,dm-spl;
>   pinctrl-names = "default";
>   pinctrl-0 = <&pinctrl_usdhc1>;
>   bus-width = <8>;
> @@ -162,7 +161,6 @@
>   };
>  
>   pinctrl_usdhc1: usdhc1grp {
> - u-boot,dm-spl;
>   fsl,pins = <
>   MX6UL_PAD_SD1_CMD__USDHC1_CMD   0x17059
>   MX6UL_PAD_SD1_CLK__USDHC1_CLK   0x10059
> diff --git a/arch/arm/dts/imx6ul-opos6uldev-u-boot.dtsi 
> b/arch/arm/dts/imx6ul-opos6uldev-u-boot.dtsi
> new file mode 100644
> index 00..da8b0392ef
> --- /dev/null
> +++ b/arch/arm/dts/imx6ul-opos6uldev-u-boot.dtsi
> @@ -0,0 +1,24 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Device Tree Source extras for U-Boot for the OPOS6ULDev board
> + *
> + * Copyright (C) 2018 Armadeus Systems 
> + */
> +
> +#include "imx6ul-opos6ul-u-boot.dtsi"
> +
> +&aips1 {
> + u-boot,dm-spl;
> +
> + spba-bus@0200 {
> + u-boot,dm-spl;
> + };
> +};
> +
> +&pinctrl_uart1 {
> + u-boot,dm-spl;
> +};
> +
> +&uart1 {
> + u-boot,dm-spl;
> +};
> diff --git a/arch/arm/dts/imx6ul-opos6uldev.dts 
> b/arch/arm/dts/imx6ul-opos6uldev.dts
> index 9a51d1e54f..0e59ee57fd 100644
> --- a/arch/arm/dts/imx6ul-opos6uldev.dts
> +++ b/arch/arm/dts/imx6ul-opos6uldev.dts
> @@ -228,7 +228,6 @@
>  };
>  
>  &uart1 {
> - u-boot,dm-spl;
>   pinctrl-names = "default";
>   pinctrl-0 = <&pinctrl_uart1>;
>   status = "okay";
> @@ -374,7 +373,6 @@
>   };
>  
>   pinctrl_uart1: uart1grp {
> - u-boot,dm-spl;
>   fsl,pins = <
>   MX6UL_PAD_UART1_TX_DATA__UART1_DCE_TX   0x1b0b1
>   MX6UL_PAD_UART1_RX_DATA__UART1_DCE_RX   0x1b0b1
> 

Reviewed-by: Stefano Babic 

Best regards,
Stefano Babic

-- 
=
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: sba...@denx.de
=
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v2 2/2] spl: socfpga: stratix10: add hex file output for spl image

2018-09-06 Thread Dalon L Westergreen
On Thu, 2018-09-06 at 07:51 +0200, Simon Goldschmidt wrote:
> On Thu, Sep 6, 2018 at 5:04 AM Dalon Westergreen  wrote:
> 
> Stratix10 requires a hex image of the spl for boot.  The heximage is added to
> the FPGA configuration image and loaded tothe processor memory by the
> configuration engine.
> Although not running a Stratix10, I also need a hex image for spl toboot
> unconfigured CycloneV devices.However, for this, it is enough to objcopy u-
> boot.spl.sfp to hex andadd the resulting file to the FPGA configuration image.
> Quartus does complain about the format a bit, but it does work. Isthis
> different for Stratix10?

The difference is that in stratix10 the SDM loads the spl image into the HPS
onchip ram.  The SPL image is actually a part of the fpga configuration
image.  The tool that adds the image to the fpga configuration image validates
its address span, so using objcopy on the binary requires a --change-
address.  Since the file is always needed for stratix10, it seems prudent to
generate it as part of the build.
> Simon
> 
> v2:  -> add CONFIG_OF_EMBED to include dtb in elf  -> generate hex from elf
> source
> Signed-off-by: Dalon Westergreen ---
> configs/socfpga_stratix10_defconfig | 1 +
> scripts/Makefile.spl| 6 ++ 2 files changed, 7
> insertions(+)
> diff --git a/configs/socfpga_stratix10_defconfig
> b/configs/socfpga_stratix10_defconfigindex dceadff439..17cc732cbe 100644---
> a/configs/socfpga_stratix10_defconfig+++
> b/configs/socfpga_stratix10_defconfig@@ -56,3 +56,4 @@ CONFIG_DM_USB=y
> CONFIG_USB_DWC2=y CONFIG_USB_STORAGE=y
> CONFIG_USE_TINY_PRINTF=y+CONFIG_OF_EMBED=ydiff --git a/scripts/Makefile.spl
> b/scripts/Makefile.splindex 76d08fd92b..b09bd40b2a 100644---
> a/scripts/Makefile.spl+++ b/scripts/Makefile.spl@@ -190,6 +190,7 @@ endif
> ifdef CONFIG_ARCH_SOCFPGA ALL-$(CONFIG_TARGET_SOCFPGA_GEN5)  +=
> $(obj)/$(SPL_BIN).sfp ALL-$(CONFIG_TARGET_SOCFPGA_ARRIA10)   +=
> $(obj)/$(SPL_BIN).sfp+ALL-$(CONFIG_TARGET_SOCFPGA_STRATIX10) +=
> $(obj)/$(SPL_BIN).hex endif
>  ifdef CONFIG_ARCH_SUNXI@@ -299,6 +300,11 @@ OBJCOPYFLAGS_u-boot-x86-16bit-
> spl.bin := -O binary -j .start16 -j .resetvec 
> $(obj)/u-boot-x86-16bit-spl.bin: 
> $(obj)/u-boot-spl FORCE$(call if_changed,objcopy)
> +OBJCOPYFLAGS_$(SPL_BIN).hex = -O ihex++$(obj)/$(SPL_BIN).hex:
> $(obj)/$(SPL_BIN) FORCE+   $(call if_changed,objcopy)+ LDFLAGS_$(SPL_BIN)
> += -T u-boot-spl.lds $(LDFLAGS_FINAL)
>  # Avoid 'Not enough room for program headers' error on binutils 2.28
> onwards.--2.17.1
> ___U-Boot mailing listU-
> b...@lists.denx.de
> https://lists.denx.de/listinfo/u-boot___U-Boot
>  mailing listu-b...@lists.denx.dehttps://lists.denx.de/listinfo/u-boot
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] travis: Use kernel.org pre-built toolchain for riscv

2018-09-06 Thread Tom Rini
On Thu, Aug 30, 2018 at 06:17:06AM -0700, Bin Meng wrote:

> This updates travis configuration to use kernel.org pre-built
> toolchain for riscv.
> 
> Signed-off-by: Bin Meng 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v2 2/2] spl: socfpga: stratix10: add hex file output for spl image

2018-09-06 Thread Marek Vasut
On 09/06/2018 03:39 PM, Dalon L Westergreen wrote:
> On Thu, 2018-09-06 at 12:09 +0200, Marek Vasut wrote:
>> On 09/06/2018 05:02 AM, Dalon Westergreen wrote:
>> Stratix10 requires a hex image of the spl for boot.  The hex
>> image is added to the FPGA configuration image and loaded to
>> the processor memory by the configuration engine.
>>
>> v2:
>>   -> add CONFIG_OF_EMBED to include dtb in elf
>>   -> generate hex from elf source
>>
>> Signed-off-by: Dalon Westergreen > >
>> ---
>>  configs/socfpga_stratix10_defconfig | 1 +
>>  scripts/Makefile.spl| 6 ++
>>  2 files changed, 7 insertions(+)
>>
>> diff --git a/configs/socfpga_stratix10_defconfig 
>> b/configs/socfpga_stratix10_defconfig
>> index dceadff439..17cc732cbe 100644
>> --- a/configs/socfpga_stratix10_defconfig
>> +++ b/configs/socfpga_stratix10_defconfig
>> @@ -56,3 +56,4 @@ CONFIG_DM_USB=y
>>  CONFIG_USB_DWC2=y
>>  CONFIG_USB_STORAGE=y
>>  CONFIG_USE_TINY_PRINTF=y
>> +CONFIG_OF_EMBED=y
>>
>> Why is this needed ? And where did the objcopy hack go ? What is the
>> explanation here ?
> 
> You suggested the use of CONFIG_OF_EMBED as an alternative to using the
> u-boot-spl-dtb.bin for objcopy.
> The intent is to ensure that the spl elf has the dtb included, and then
> a simple objcopy to elf to hex is fine.
> You no longer need the --change-address as the elf indicates the correct
> start address, unlike the binary.

And that's fine with your usecase ? Fine be me then ...

>> diff --git a/scripts/Makefile.spl b/scripts/Makefile.spl
>> index 76d08fd92b..b09bd40b2a 100644
>> --- a/scripts/Makefile.spl
>> +++ b/scripts/Makefile.spl
>> @@ -190,6 +190,7 @@ endif
>>  ifdef CONFIG_ARCH_SOCFPGA
>>  ALL-$(CONFIG_TARGET_SOCFPGA_GEN5)   += $(obj)/$(SPL_BIN).sfp
>>  ALL-$(CONFIG_TARGET_SOCFPGA_ARRIA10)+= $(obj)/$(SPL_BIN).sfp
>> +ALL-$(CONFIG_TARGET_SOCFPGA_STRATIX10)  += $(obj)/$(SPL_BIN).hex
>>
>> CONFIG_SPL_TARGET "u-boot-spl.hex" can replace this addition I think ?
>>
>>  endif
>>  
>>  ifdef CONFIG_ARCH_SUNXI
>> @@ -299,6 +300,11 @@ OBJCOPYFLAGS_u-boot-x86-16bit-spl.bin := -O binary -j 
>> .start16 -j .resetvec
>>  $(obj)/u-boot-x86-16bit-spl.bin: $(obj)/u-boot-spl FORCE
>>  $(call if_changed,objcopy)
>>  
>> +OBJCOPYFLAGS_$(SPL_BIN).hex = -O ihex
>> +
>> +$(obj)/$(SPL_BIN).hex: $(obj)/$(SPL_BIN) FORCE
>> +$(call if_changed,objcopy)
>> +
>>
>> This is generic, separate patch please.
>>
>>  LDFLAGS_$(SPL_BIN) += -T u-boot-spl.lds $(LDFLAGS_FINAL)
>>  
> 
> Will do

Thanks

-- 
Best regards,
Marek Vasut
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [U-Boot,v2,06/13] pico-imx7d: Update the README file

2018-09-06 Thread Tom Rini
On Tue, Sep 04, 2018 at 10:23:12AM -0300, Otavio Salvador wrote:

> From: Fabio Estevam 
> 
> Update the README file to take into accound the switch to SPL.
> 
> Signed-off-by: Fabio Estevam 
> Signed-off-by: Fabio Berton 
> Signed-off-by: Otavio Salvador 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH] ARM: Specify aligned address for secure section instead of using attributes

2018-09-06 Thread Tom Rini
On Thu, Sep 06, 2018 at 11:56:28AM +0800, Chen-Yu Tsai wrote:

> In commit a1274cc94a20 ("ARM: Page align secure section only when it is
> executed in situ"), we used output section attributes (the "ALIGN"
> keyword after the colon) to specify the alignment requirements. Using
> the constant "COMMONPAGE" there was recently broken in binutils 2.31 [1].
> 
> Binutils maintainer Alan Modra suggested the former method would still
> work. Since both methods achieve the same result, this patch does just
> that. This fixes the "reboot after bootm" issue we've been seeing on
> sunxi when booting non-secure.
> 
>   [1] https://sourceware.org/bugzilla/show_bug.cgi?id=23571
> 
> Suggested-by: Alan Modra 
> Signed-off-by: Chen-Yu Tsai 

Reviewed-by: Tom Rini 

After a little more time for review, should I take this directly or a PR
from the sunxi team?  Thanks!

-- 
Tom


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v3 1/1] ARM: opos6ul: make the board boot again

2018-09-06 Thread Tom Rini
On Thu, Sep 06, 2018 at 09:51:53AM +0200, Sébastien Szymanski wrote:

> Commit 9faa43c4b5e5 ("ARM: dts: i.MX6UL: U-Boot specific dts for u-boot,
> dm-spl") removes the u-boot,dm-spl properties from the imx6ul.dtsi file
> and breaks the OPOS6UL board.
> Add the u-boot,dm-spl properties into *-u-boot.dts files to make the
> board boot again.
> 
> Fixes: commit 9faa43c4b5e5 ("ARM: dts: i.MX6UL: U-Boot specific dts for 
> u-boot, dm-spl")
> Signed-off-by: Sébastien Szymanski 

Reviewed-by: Tom Rini 

-- 
Tom


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] ARM: qemu-arm: Fix qemu_arm64_defconfig for QEMU 3.0

2018-09-06 Thread Tom Rini
On Tue, Sep 04, 2018 at 06:16:52PM +0300, Tuomas Tynkkynen wrote:

> QEMU 3.0 introduced additional memory-mapped regions for PCI-E ECAM and
> MMIO. Thus we need to add them to our MMU map or U-Boot will crash with
> a Synchronous Abort during PCI-E probing when it tries to access the
> unmapped ECAM memory area.
> 
> Reported-by: Jonathan Gray 
> Signed-off-by: Tuomas Tynkkynen 
> Tested-by: Jonathan Gray 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] qemu-arm: Enable DHCP distro target

2018-09-06 Thread Tom Rini
On Tue, Sep 04, 2018 at 01:49:29PM +0200, Alexander Graf wrote:

> When booting the QEMU virt machine with -net nic,model=e1000 we can already
> support network boot just fine today.
> 
> So let's enable the default bootcmd to also evaluate DHCP responses properly.
> That way we can enable network boot seamlessly with the virt target.
> 
> Signed-off-by: Alexander Graf 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] amlogic: board p212: Fix Ethernet PHY init

2018-09-06 Thread Tom Rini
On Mon, Sep 03, 2018 at 10:14:53PM +0200, Jasper kcoding wrote:

> Without this patch the Ethernet PHY on the p212 board does not get
> fully configured.
> When this happens Ethernet does not function.
> 
> The similar libretech-cc and khadas-vim boards have this code already.
> That's why the Ethernet on these boards do work.
> 
> Signed-off-by: Jasper Kcoding 
> Acked-by: Neil Armstrong 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] ARM: dts: logicpd-torpedo-37xx-devkit-u-boot: Fix MMC Card Detect

2018-09-06 Thread Tom Rini
On Mon, Sep 03, 2018 at 09:08:04AM -0500, Adam Ford wrote:

> When re-syncing the DTS files from the kernel, something caused
> the MMC driver to no longer detect the MMC card. Undoing the
> CD-invert appears to fix the issue.
> 
> Fixes: e6ea2390cde3 ("ARM: DTS: Resync LogicPD-Torpedo-37xx-devkit
> with Linux 4.18-RC4")
> 
> Signed-off-by: Adam Ford 
> 
> diff --git a/arch/arm/dts/logicpd-torpedo-37xx-devkit-u-boot.dtsi 
> b/arch/arm/dts/logicpd-torpedo-37xx-devkit-u-boot.dtsi
> index 4028fe7642..d584b4a9ab 100644

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [U-Boot,1/1] lib/slre: remove superfluous assignment

2018-09-06 Thread Tom Rini
On Mon, Sep 03, 2018 at 05:17:20AM +0200, Heinrich Schuchardt wrote:

> It makes no sense to assign a value to 'res' if the next use of the
> variable is an assignment.
> 
> Signed-off-by: Heinrich Schuchardt 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v2 2/2] spl: socfpga: stratix10: add hex file output for spl image

2018-09-06 Thread Dalon L Westergreen
On Thu, 2018-09-06 at 12:09 +0200, Marek Vasut wrote:
> On 09/06/2018 05:02 AM, Dalon Westergreen wrote:
> Stratix10 requires a hex image of the spl for boot.  The heximage is added to
> the FPGA configuration image and loaded tothe processor memory by the
> configuration engine.
> v2:  -> add CONFIG_OF_EMBED to include dtb in elf  -> generate hex from elf
> source
> Signed-off-by: Dalon Westergreen ---
> configs/socfpga_stratix10_defconfig | 1 +
> scripts/Makefile.spl| 6 ++ 2 files changed, 7
> insertions(+)
> diff --git a/configs/socfpga_stratix10_defconfig
> b/configs/socfpga_stratix10_defconfigindex dceadff439..17cc732cbe 100644---
> a/configs/socfpga_stratix10_defconfig+++
> b/configs/socfpga_stratix10_defconfig@@ -56,3 +56,4 @@ CONFIG_DM_USB=y
> CONFIG_USB_DWC2=y CONFIG_USB_STORAGE=y
> CONFIG_USE_TINY_PRINTF=y+CONFIG_OF_EMBED=y
> Why is this needed ? And where did the objcopy hack go ? What is
> theexplanation here ?

You suggested the use of CONFIG_OF_EMBED as an alternative to using the u-boot-
spl-dtb.bin for objcopy.  The intent is to ensure that the spl elf has the dtb
included, and then a simple objcopy to elf to hex is fine.You no longer need the
--change-address as the elf indicates the correct start address, unlike the
binary.
> diff --git a/scripts/Makefile.spl b/scripts/Makefile.splindex
> 76d08fd92b..b09bd40b2a 100644--- a/scripts/Makefile.spl+++
> b/scripts/Makefile.spl@@ -190,6 +190,7 @@ endif ifdef CONFIG_ARCH_SOCFPGA ALL-
> $(CONFIG_TARGET_SOCFPGA_GEN5) += $(obj)/$(SPL_BIN).sfp ALL-
> $(CONFIG_TARGET_SOCFPGA_ARRIA10)  += $(obj)/$(SPL_BIN).sfp+ALL-
> $(CONFIG_TARGET_SOCFPGA_STRATIX10)+= $(obj)/$(SPL_BIN).hex
> CONFIG_SPL_TARGET "u-boot-spl.hex" can replace this addition I think ?
>  endif  ifdef CONFIG_ARCH_SUNXI@@ -299,6 +300,11 @@ OBJCOPYFLAGS_u-boot-x86-
> 16bit-spl.bin := -O binary -j .start16 -j .resetvec $(obj)/u-boot-x86-16bit-
> spl.bin: $(obj)/u-boot-spl FORCE  $(call if_changed,objcopy)
> +OBJCOPYFLAGS_$(SPL_BIN).hex = -O ihex++$(obj)/$(SPL_BIN).hex:
> $(obj)/$(SPL_BIN) FORCE+  $(call if_changed,objcopy)+
> This is generic, separate patch please.
>  LDFLAGS_$(SPL_BIN) += -T u-boot-spl.lds $(LDFLAGS_FINAL) 

Will do
>  # Avoid 'Not enough room for program headers' error on binutils 2.28 onwards.
> 
> 
> 
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH V5 00/31] imx: add i.MX8M support and i.MX8MQ EVK

2018-09-06 Thread Fabio Estevam
Hi Peng,

On Fri, Aug 31, 2018 at 3:27 AM, Jon Nettleton  wrote:

> Peng,
>
> Will you be releasing the script you are using to convert that code
> generated by the ddr training tool into this format?  I would like to
> test your patchset on our new SOMs and that would be very useful.

Any comments about the DDR init script? Looks like we are stuck in
this issue for a long time.

Any progress?

Thanks
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v2 1/2] spl: socfpga: only gen5 devices and arria10 require sfp image

2018-09-06 Thread Dalon L Westergreen
On Thu, 2018-09-06 at 12:08 +0200, Marek Vasut wrote:
> On 09/06/2018 05:02 AM, Dalon Westergreen wrote:
> 
> Only the Cyclone5/Arria5 and Arria10 devices require the sfp
> formated image for booting. This path ensures that the file is
> only generated for those devices.
> 
> Signed-off-by: Dalon Westergreen 
> ---
>  scripts/Makefile.spl | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/scripts/Makefile.spl b/scripts/Makefile.spl
> index 252f13826d..76d08fd92b 100644
> --- a/scripts/Makefile.spl
> +++ b/scripts/Makefile.spl
> @@ -188,7 +188,8 @@ ALL-y += $(obj)/$(BOARD)-spl.bin
>  endif
>  
>  ifdef CONFIG_ARCH_SOCFPGA
> -ALL-y+= $(obj)/$(SPL_BIN).sfp
> +ALL-$(CONFIG_TARGET_SOCFPGA_GEN5)+= $(obj)/$(SPL_BIN).sfp
> +ALL-$(CONFIG_TARGET_SOCFPGA_ARRIA10) += $(obj)/$(SPL_BIN).sfp
>  endif
>  
>  ifdef CONFIG_ARCH_SUNXI
> 
> What about adding Kconfig option , something like
> CONFIG_TARGET_SOCFPGA_SFP , using it above and enabling it on Gen5 and
> A10 ? That way ,we won't have two entries with the same content.
> 
Good idea.
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PULL] Please pull u-boot-imx

2018-09-06 Thread Fabio Estevam
Hi Peter,

[Adding Jon and Baruch]

On Thu, Sep 6, 2018 at 9:37 AM, Peter Robinson  wrote:

> It seems like the Wandboard Quad revB I have also works fine so It
> might just be a regression in the mx6cuboxi target.

I don't have access to a hummingboard2 to investigate it.

Does this issue also happen on a mx6q cuboxi?

Are you able to run a bisect?

Thanks
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v2 06/13] pico-imx7d: Update the README file

2018-09-06 Thread Stefano Babic
On 06/09/2018 14:17, Otavio Salvador wrote:
> 
> 
> On Thu, Sep 6, 2018 at 6:54 AM Stefano Babic  > wrote:
> 
> On 05/09/2018 21:13, Otavio Salvador wrote:
> > Hello Tom and Stefano,
> >
> > This should be applied for release as it puts the README aligned with
> > current use. Please consider it.
> >
> 
> You patches look good and I can confirm they are just related to the
> pico board. I have no comments at all, and I do not see any reason you
> need to change them.  I have set them to go into my (local) next branch.
> 
> 
> This README update is trivial and Tom can apply it directly.


Sorry, I thought the whole patchset - of course, README can be applied
directly.

Regards,
Stefano


-- 
=
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: sba...@denx.de
=
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PULL] Please pull u-boot-imx

2018-09-06 Thread Peter Robinson
Hi Stefano,
> >> a new PR. I dropped the patches causing breakages on PowerPC boards, as
> >> well as the issue on GE boards. It ran on travis successfully.
> >>
> >>
> >> The following changes since commit 
> >> 11ed312896c5f5814064c5d45dcb2f53dc121437:
> >>
> >>   configs: am57xx: change default board name to beagle_x15 (2018-08-26
> >> 12:26:16 -0400)
> >>
> >> are available in the Git repository at:
> >>
> >>   git://www.denx.de/git/u-boot-imx.git master
> >>
> >> for you to fetch changes up to c1d1543ebc6e1fb026d0d7ac96d865faa7567555:
> >>
> >>   mx7dsabresd: Add the qspi target to the list of supported defconfigs
> >> (2018-09-04 08:47:23 +0200)
> >>
> >> 
> >> Alex Kiernan (1):
> >>   Cleanup CONFIG_BOOTDELAY on cl-som-imx7
> >>
> >> Anson Huang (3):
> >>   imx: mx7: psci: improve cpu hotplug flow
> >>   imx: mx7: add gpc initialization for low power mode
> >>   imx: mx7: add system suspend/resume support
> >>
> >> Fabio Estevam (1):
> >>   mx7dsabresd: Add the qspi target to the list of supported defconfigs
> >>
> >> Martin Kaiser (1):
> >>   watchdog: mx25: use the imx_watchdog driver for mx25
> >>
> >> Stefan Agner (2):
> >>   board: toradex: common: fail gracefully on missing NAND chip
> >>   colibri_imx7_emmc: add Colibri iMX7D 1GB (eMMC) module support
> >>
> >> Stefano Babic (1):
> >>   imx: missing CONFIG_MII in mx7dsabresd_qspi_defconfig
> >>
> >> Ye Li (6):
> >>   imx: imx6sx-sdb: Enable DM QSPI driver
> >>   imx: imx6sx-sabreauto: convert to use DM QSPI driver
> >>   imx: imx7d-sdb: Add DM QSPI support
> >>   dts: imx6ul: Update alias to support DM
> >>   dts: imx6ul_evk: Add DTS files for 14x14 EVK and 9x9 EVK boards
> >>   imx: imx6ul_evk: Enable DM driver for iMX6UL EVK u-boot
> >
> > Are you aware of any issues on some imx6 devices in 2018.09?
>
> No.
>
> > The
> > hummingboard2 (imx6q) hangs for me just after the output below, even
> > with the above PR, it works fine with a imx6sx device (udoo neo). I'm
> > sure I've seen something on the list that might be related but I can't
> > find it.
>
> :-(
>
> >
> > Sorry for picking this up so late in the cycle.
>
> I can just try to test on another mx6q boar if I get enough time, but of
> course this is not a great test.

It seems like the Wandboard Quad revB I have also works fine so It
might just be a regression in the mx6cuboxi target.

P
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v2 06/13] pico-imx7d: Update the README file

2018-09-06 Thread Otavio Salvador
On Thu, Sep 6, 2018 at 6:54 AM Stefano Babic  wrote:

> On 05/09/2018 21:13, Otavio Salvador wrote:
> > Hello Tom and Stefano,
> >
> > This should be applied for release as it puts the README aligned with
> > current use. Please consider it.
> >
>
> You patches look good and I can confirm they are just related to the
> pico board. I have no comments at all, and I do not see any reason you
> need to change them.  I have set them to go into my (local) next branch.
>

This README update is trivial and Tom can apply it directly.

-- 
Otavio Salvador O.S. Systems
http://www.ossystems.com.brhttp://code.ossystems.com.br
Mobile: +55 (53) 9 9981-7854  Mobile: +1 (347) 903-9750
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v2] usb: dwc3: convert to livetree

2018-09-06 Thread Marek Vasut
On 09/06/2018 01:19 PM, Siva Durga Prasad Paladugu wrote:
> Hi,
> 
>> -Original Message-
>> From: Marek Vasut [mailto:ma...@denx.de]
>> Sent: Thursday, September 06, 2018 4:28 PM
>> To: Siva Durga Prasad Paladugu ; u-
>> b...@lists.denx.de
>> Cc: Michal Simek ; bmeng...@gmail.com;
>> s...@chromium.org; yamada.masah...@socionext.com; Vipul Kumar
>> 
>> Subject: Re: [PATCH v2] usb: dwc3: convert to livetree
>>
>> On 09/06/2018 12:39 PM, Siva Durga Prasad Paladugu wrote:
>>> From: Vipul Kumar 
>>>
>>> Update the DWC3 USB driver to support a live tree.
>>>
>>> Signed-off-by: Siva Durga Prasad Paladugu
>>> 
>>> Signed-off-by: Vipul Kumar 
>>> Tested-by: Michal Simek 
>>> ---
>>> Changes in v2:
>>> - Fixed travis build issues with some platforms.
>>
>> Cool, what exactly changed ?
> 
> Earlier we got compilation failures for am335x_hs_evm_uart platform during 
> travis ci
> as we didn’t made corresponding changes to drivers/usb/musb-new/ti-musb.c  as 
> per
> live tree conversion. Now it is fixed by moving this driver to support live 
> tree.
> Also fixed dwc3-sti-glue.c to support live tree.

That is what should be in the V2 description. Not that random "fixed
some stuff" blurb.

-- 
Best regards,
Marek Vasut
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v2] usb: dwc3: convert to livetree

2018-09-06 Thread Siva Durga Prasad Paladugu
Hi,

> -Original Message-
> From: Marek Vasut [mailto:ma...@denx.de]
> Sent: Thursday, September 06, 2018 4:28 PM
> To: Siva Durga Prasad Paladugu ; u-
> b...@lists.denx.de
> Cc: Michal Simek ; bmeng...@gmail.com;
> s...@chromium.org; yamada.masah...@socionext.com; Vipul Kumar
> 
> Subject: Re: [PATCH v2] usb: dwc3: convert to livetree
> 
> On 09/06/2018 12:39 PM, Siva Durga Prasad Paladugu wrote:
> > From: Vipul Kumar 
> >
> > Update the DWC3 USB driver to support a live tree.
> >
> > Signed-off-by: Siva Durga Prasad Paladugu
> > 
> > Signed-off-by: Vipul Kumar 
> > Tested-by: Michal Simek 
> > ---
> > Changes in v2:
> > - Fixed travis build issues with some platforms.
> 
> Cool, what exactly changed ?

Earlier we got compilation failures for am335x_hs_evm_uart platform during 
travis ci
as we didn’t made corresponding changes to drivers/usb/musb-new/ti-musb.c  as 
per
live tree conversion. Now it is fixed by moving this driver to support live 
tree.
Also fixed dwc3-sti-glue.c to support live tree.

Thanks,
Siva

> 
> > ---
> >  drivers/usb/common/common.c  | 11 +--
> >  drivers/usb/dwc3/dwc3-generic.c  | 17 +++--
> > drivers/usb/host/dwc3-sti-glue.c |  7 +++
> >  drivers/usb/host/xhci-dwc3.c |  3 ++-
> >  drivers/usb/host/xhci-zynqmp.c   |  3 +--
> >  drivers/usb/musb-new/ti-musb.c   | 11 ---
> >  include/linux/usb/otg.h  |  6 --
> >  7 files changed, 26 insertions(+), 32 deletions(-)
> >
> > diff --git a/drivers/usb/common/common.c
> b/drivers/usb/common/common.c
> > index a55def5..3dea79b 100644
> > --- a/drivers/usb/common/common.c
> > +++ b/drivers/usb/common/common.c
> > @@ -10,6 +10,7 @@
> >  #include 
> >  #include 
> >  #include 
> > +#include 
> >
> >  DECLARE_GLOBAL_DATA_PTR;
> >
> > @@ -20,13 +21,12 @@ static const char *const usb_dr_modes[] = {
> > [USB_DR_MODE_OTG]   = "otg",
> >  };
> >
> > -enum usb_dr_mode usb_get_dr_mode(int node)
> > +enum usb_dr_mode usb_get_dr_mode(ofnode node)
> >  {
> > -   const void *fdt = gd->fdt_blob;
> > const char *dr_mode;
> > int i;
> >
> > -   dr_mode = fdt_getprop(fdt, node, "dr_mode", NULL);
> > +   dr_mode = ofnode_get_property(node, "dr_mode", NULL);
> > if (!dr_mode) {
> > pr_err("usb dr_mode not found\n");
> > return USB_DR_MODE_UNKNOWN;
> > @@ -48,13 +48,12 @@ static const char *const speed_names[] = {
> > [USB_SPEED_SUPER] = "super-speed",
> >  };
> >
> > -enum usb_device_speed usb_get_maximum_speed(int node)
> > +enum usb_device_speed usb_get_maximum_speed(ofnode node)
> >  {
> > -   const void *fdt = gd->fdt_blob;
> > const char *max_speed;
> > int i;
> >
> > -   max_speed = fdt_getprop(fdt, node, "maximum-speed", NULL);
> > +   max_speed = ofnode_get_property(node, "maximum-speed",
> NULL);
> > if (!max_speed) {
> > pr_err("usb maximum-speed not found\n");
> > return USB_SPEED_UNKNOWN;
> > diff --git a/drivers/usb/dwc3/dwc3-generic.c
> > b/drivers/usb/dwc3/dwc3-generic.c index ca63eac..ef72c8c 100644
> > --- a/drivers/usb/dwc3/dwc3-generic.c
> > +++ b/drivers/usb/dwc3/dwc3-generic.c
> > @@ -61,18 +61,17 @@ static int
> dwc3_generic_peripheral_remove(struct
> > udevice *dev)  static int
> > dwc3_generic_peripheral_ofdata_to_platdata(struct udevice *dev)  {
> > struct dwc3 *priv = dev_get_priv(dev);
> > -   int node = dev_of_offset(dev);
> >
> > -   priv->regs = (void *)devfdt_get_addr(dev);
> > +   priv->regs = (void *)dev_read_addr(dev);
> > priv->regs += DWC3_GLOBALS_REGS_START;
> >
> > -   priv->maximum_speed = usb_get_maximum_speed(node);
> > +   priv->maximum_speed = usb_get_maximum_speed(dev->node);
> > if (priv->maximum_speed == USB_SPEED_UNKNOWN) {
> > pr_err("Invalid usb maximum speed\n");
> > return -ENODEV;
> > }
> >
> > -   priv->dr_mode = usb_get_dr_mode(node);
> > +   priv->dr_mode = usb_get_dr_mode(dev->node);
> > if (priv->dr_mode == USB_DR_MODE_UNKNOWN) {
> > pr_err("Invalid usb mode setup\n");
> > return -ENODEV;
> > @@ -100,13 +99,11 @@ U_BOOT_DRIVER(dwc3_generic_peripheral) = {
> >
> >  static int dwc3_generic_bind(struct udevice *parent)  {
> > -   const void *fdt = gd->fdt_blob;
> > -   int node;
> > +   ofnode node;
> > int ret;
> >
> > -   for (node = fdt_first_subnode(fdt, dev_of_offset(parent)); node > 0;
> > -node = fdt_next_subnode(fdt, node)) {
> > -   const char *name = fdt_get_name(fdt, node, NULL);
> > +   dev_for_each_subnode(node, parent) {
> > +   const char *name = (char *)ofnode_get_name(node);
> > enum usb_dr_mode dr_mode;
> > struct udevice *dev;
> > const char *driver;
> > @@ -133,7 +130,7 @@ static int dwc3_generic_bind(struct udevice
> *parent)
> > };
> >
> > ret = device_bind_driver_to_node(parent, driver, name,
> > -offset_to_ofnode(node),
> &dev);
> > + 

Re: [U-Boot] [PATCH v2 1/2] spl: socfpga: only gen5 devices and arria10 require sfp image

2018-09-06 Thread Marek Vasut
On 09/06/2018 05:02 AM, Dalon Westergreen wrote:
> Only the Cyclone5/Arria5 and Arria10 devices require the sfp
> formated image for booting. This path ensures that the file is
> only generated for those devices.
> 
> Signed-off-by: Dalon Westergreen 
> ---
>  scripts/Makefile.spl | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/scripts/Makefile.spl b/scripts/Makefile.spl
> index 252f13826d..76d08fd92b 100644
> --- a/scripts/Makefile.spl
> +++ b/scripts/Makefile.spl
> @@ -188,7 +188,8 @@ ALL-y += $(obj)/$(BOARD)-spl.bin
>  endif
>  
>  ifdef CONFIG_ARCH_SOCFPGA
> -ALL-y+= $(obj)/$(SPL_BIN).sfp
> +ALL-$(CONFIG_TARGET_SOCFPGA_GEN5)+= $(obj)/$(SPL_BIN).sfp
> +ALL-$(CONFIG_TARGET_SOCFPGA_ARRIA10) += $(obj)/$(SPL_BIN).sfp
>  endif
>  
>  ifdef CONFIG_ARCH_SUNXI
> 
What about adding Kconfig option , something like
CONFIG_TARGET_SOCFPGA_SFP , using it above and enabling it on Gen5 and
A10 ? That way ,we won't have two entries with the same content.

-- 
Best regards,
Marek Vasut
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH] gpio: dwapb_gpio: Change to use devm_kcalloc()

2018-09-06 Thread Marek Vasut
On 09/06/2018 04:48 PM, Ley Foon Tan wrote:
> Change to use managed resource function devm_kcalloc(),
> so it will auto free memory when driver is removed.
> 
> Signed-off-by: Ley Foon Tan 
> ---
>  drivers/gpio/dwapb_gpio.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/gpio/dwapb_gpio.c b/drivers/gpio/dwapb_gpio.c
> index 0f6574d..1594434 100644
> --- a/drivers/gpio/dwapb_gpio.c
> +++ b/drivers/gpio/dwapb_gpio.c
> @@ -171,8 +171,7 @@ static int gpio_dwapb_bind(struct udevice *dev)
>   if (!fdtdec_get_bool(blob, node, "gpio-controller"))
>   continue;
>  
> - plat = NULL;
> - plat = calloc(1, sizeof(*plat));
> + plat = devm_kcalloc(dev, 1, sizeof(*plat), GFP_KERNEL);
>   if (!plat)
>   return -ENOMEM;

You also need to drop the matching free()

-- 
Best regards,
Marek Vasut
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH] spi: designware_spi: Add reset ctrl to driver

2018-09-06 Thread Marek Vasut
On 09/06/2018 04:22 PM, Ley Foon Tan wrote:
> Add code to reset all reset signals as in SPI DT node. A reset property
> is an optional feature, so only print out a warning and do not fail if a
> reset property is not present.
> 
> If a reset property is discovered, then use it to deassert, thus
> bringing the IP out of reset.
> 
> Release reset when _remove().
> 
> Signed-off-by: Ley Foon Tan 
> ---
>  drivers/spi/designware_spi.c | 42 ++
>  1 file changed, 42 insertions(+)
> 
> diff --git a/drivers/spi/designware_spi.c b/drivers/spi/designware_spi.c
> index d8b73ea..b73ec38 100644
> --- a/drivers/spi/designware_spi.c
> +++ b/drivers/spi/designware_spi.c
> @@ -17,6 +17,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -111,6 +112,8 @@ struct dw_spi_priv {
>   void *tx_end;
>   void *rx;
>   void *rx_end;
> +
> + struct reset_ctl_bulk   resets;
>  };
>  
>  static inline u32 dw_read(struct dw_spi_priv *priv, u32 offset)
> @@ -231,6 +234,33 @@ err_rate:
>   return -EINVAL;
>  }
>  
> +static int dw_spi_reset(struct udevice *bus)
> +{
> + int ret;
> + struct dw_spi_priv *priv = dev_get_priv(bus);
> +
> + ret = reset_get_bulk(bus, &priv->resets);
> + if (ret) {
> + /* Return 0 if error due to !CONFIG_DM_RESET and reset
> +  * DT property is not present.

Multiline comment style.

Otherwise
Acked-by: Marek Vasut 

I'll let Jagan pick it for next.

-- 
Best regards,
Marek Vasut
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v2 2/2] spl: socfpga: stratix10: add hex file output for spl image

2018-09-06 Thread Marek Vasut
On 09/06/2018 05:02 AM, Dalon Westergreen wrote:
> Stratix10 requires a hex image of the spl for boot.  The hex
> image is added to the FPGA configuration image and loaded to
> the processor memory by the configuration engine.
> 
> v2:
>   -> add CONFIG_OF_EMBED to include dtb in elf
>   -> generate hex from elf source
> 
> Signed-off-by: Dalon Westergreen 
> ---
>  configs/socfpga_stratix10_defconfig | 1 +
>  scripts/Makefile.spl| 6 ++
>  2 files changed, 7 insertions(+)
> 
> diff --git a/configs/socfpga_stratix10_defconfig 
> b/configs/socfpga_stratix10_defconfig
> index dceadff439..17cc732cbe 100644
> --- a/configs/socfpga_stratix10_defconfig
> +++ b/configs/socfpga_stratix10_defconfig
> @@ -56,3 +56,4 @@ CONFIG_DM_USB=y
>  CONFIG_USB_DWC2=y
>  CONFIG_USB_STORAGE=y
>  CONFIG_USE_TINY_PRINTF=y
> +CONFIG_OF_EMBED=y

Why is this needed ? And where did the objcopy hack go ? What is the
explanation here ?

> diff --git a/scripts/Makefile.spl b/scripts/Makefile.spl
> index 76d08fd92b..b09bd40b2a 100644
> --- a/scripts/Makefile.spl
> +++ b/scripts/Makefile.spl
> @@ -190,6 +190,7 @@ endif
>  ifdef CONFIG_ARCH_SOCFPGA
>  ALL-$(CONFIG_TARGET_SOCFPGA_GEN5)+= $(obj)/$(SPL_BIN).sfp
>  ALL-$(CONFIG_TARGET_SOCFPGA_ARRIA10) += $(obj)/$(SPL_BIN).sfp
> +ALL-$(CONFIG_TARGET_SOCFPGA_STRATIX10)   += $(obj)/$(SPL_BIN).hex

CONFIG_SPL_TARGET "u-boot-spl.hex" can replace this addition I think ?

>  endif
>  
>  ifdef CONFIG_ARCH_SUNXI
> @@ -299,6 +300,11 @@ OBJCOPYFLAGS_u-boot-x86-16bit-spl.bin := -O binary -j 
> .start16 -j .resetvec
>  $(obj)/u-boot-x86-16bit-spl.bin: $(obj)/u-boot-spl FORCE
>   $(call if_changed,objcopy)
>  
> +OBJCOPYFLAGS_$(SPL_BIN).hex = -O ihex
> +
> +$(obj)/$(SPL_BIN).hex: $(obj)/$(SPL_BIN) FORCE
> + $(call if_changed,objcopy)
> +

This is generic, separate patch please.

>  LDFLAGS_$(SPL_BIN) += -T u-boot-spl.lds $(LDFLAGS_FINAL)
>  
>  # Avoid 'Not enough room for program headers' error on binutils 2.28 onwards.
> 


-- 
Best regards,
Marek Vasut
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH] mtd: nand: denali_dt: Add reset support

2018-09-06 Thread Marek Vasut
On 09/06/2018 03:46 AM, Masahiro Yamada wrote:
> 2018-09-05 17:31 GMT+09:00 Marek Vasut :
>> On 08/24/2018 03:10 PM, Marek Vasut wrote:
>>> On 08/24/2018 03:05 PM, Masahiro Yamada wrote:
 Hi Marek,
>>>
>>> Hi,
>>>
 2018-08-21 22:57 GMT+09:00 Marek Vasut :
> Add optional reset support into the Denali NAND driver. In case there is
> a valid reset entry in the DT, the reset gets deasserted before the NAND
> controller gets used.
>
> Signed-off-by: Marek Vasut 
> Cc: Masahiro Yamada 
> ---
>  drivers/mtd/nand/denali_dt.c | 9 +
>  1 file changed, 9 insertions(+)
>
> diff --git a/drivers/mtd/nand/denali_dt.c b/drivers/mtd/nand/denali_dt.c
> index 65a7797f0f..6fcd7d3843 100644
> --- a/drivers/mtd/nand/denali_dt.c
> +++ b/drivers/mtd/nand/denali_dt.c
> @@ -9,6 +9,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>
>  #include "denali.h"
>
> @@ -64,6 +65,7 @@ static int denali_dt_probe(struct udevice *dev)
> const struct denali_dt_data *data;
> struct clk clk;
> struct resource res;
> +   struct reset_ctl reset_ctl;
> int ret;
>
> data = (void *)dev_get_driver_data(dev);
> @@ -97,6 +99,13 @@ static int denali_dt_probe(struct udevice *dev)
>
> denali->clk_x_rate = clk_get_rate(&clk);
>
> +   ret = reset_get_by_index(dev, 0, &reset_ctl);
> +   if (!ret) {
> +   reset_assert(&reset_ctl);
> +   udelay(2);
> +   reset_deassert(&reset_ctl);
> +   }
> +
> return denali_init(denali);
>  }
>


 I was testing this patch today
 because my SoC also has a reset line for NAND.


 This patch looks trivial enough,
 but if the NAND is reset here,
 my board fails to boot with
 "nand_base: timeout while waiting for chip to become ready"


 I do not know why.
 Please give me more time to figure out what is going on in my SoC.
>>>
>>> Sure. Maybe you need to un-reset more stuff or the reset polarity is wrong ?
> 
> 
> I do not think so.
> 
> The reset sequence of Denali is not so simple as you may think
> because the HW sequencer runs after the reset de-assertion.
> It includes some SoC-dependent parts.
> 
> 
> 
>>
>> Did you figure something out ?
>>
> 
> 
> Just testing one of my boards.
> 
> It booted by adding mdelay() after reset_deassert().
> 
> 
> 
> reset_assert(&reset_ctl);
> udelay(2);
> reset_deassert(&reset_ctl);
> mdelay(1);   /* Why is this long delay required? */

It works right away after ungating the reset on my board.

> I will read HW docs more,
> and talk to HW engineers
> to figure out the right solution.

OK

-- 
Best regards,
Marek Vasut
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v2] usb: dwc3: convert to livetree

2018-09-06 Thread Marek Vasut
On 09/06/2018 12:39 PM, Siva Durga Prasad Paladugu wrote:
> From: Vipul Kumar 
> 
> Update the DWC3 USB driver to support a live tree.
> 
> Signed-off-by: Siva Durga Prasad Paladugu 
> Signed-off-by: Vipul Kumar 
> Tested-by: Michal Simek 
> ---
> Changes in v2:
> - Fixed travis build issues with some platforms.

Cool, what exactly changed ?

> ---
>  drivers/usb/common/common.c  | 11 +--
>  drivers/usb/dwc3/dwc3-generic.c  | 17 +++--
>  drivers/usb/host/dwc3-sti-glue.c |  7 +++
>  drivers/usb/host/xhci-dwc3.c |  3 ++-
>  drivers/usb/host/xhci-zynqmp.c   |  3 +--
>  drivers/usb/musb-new/ti-musb.c   | 11 ---
>  include/linux/usb/otg.h  |  6 --
>  7 files changed, 26 insertions(+), 32 deletions(-)
> 
> diff --git a/drivers/usb/common/common.c b/drivers/usb/common/common.c
> index a55def5..3dea79b 100644
> --- a/drivers/usb/common/common.c
> +++ b/drivers/usb/common/common.c
> @@ -10,6 +10,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  
>  DECLARE_GLOBAL_DATA_PTR;
>  
> @@ -20,13 +21,12 @@ static const char *const usb_dr_modes[] = {
>   [USB_DR_MODE_OTG]   = "otg",
>  };
>  
> -enum usb_dr_mode usb_get_dr_mode(int node)
> +enum usb_dr_mode usb_get_dr_mode(ofnode node)
>  {
> - const void *fdt = gd->fdt_blob;
>   const char *dr_mode;
>   int i;
>  
> - dr_mode = fdt_getprop(fdt, node, "dr_mode", NULL);
> + dr_mode = ofnode_get_property(node, "dr_mode", NULL);
>   if (!dr_mode) {
>   pr_err("usb dr_mode not found\n");
>   return USB_DR_MODE_UNKNOWN;
> @@ -48,13 +48,12 @@ static const char *const speed_names[] = {
>   [USB_SPEED_SUPER] = "super-speed",
>  };
>  
> -enum usb_device_speed usb_get_maximum_speed(int node)
> +enum usb_device_speed usb_get_maximum_speed(ofnode node)
>  {
> - const void *fdt = gd->fdt_blob;
>   const char *max_speed;
>   int i;
>  
> - max_speed = fdt_getprop(fdt, node, "maximum-speed", NULL);
> + max_speed = ofnode_get_property(node, "maximum-speed", NULL);
>   if (!max_speed) {
>   pr_err("usb maximum-speed not found\n");
>   return USB_SPEED_UNKNOWN;
> diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c
> index ca63eac..ef72c8c 100644
> --- a/drivers/usb/dwc3/dwc3-generic.c
> +++ b/drivers/usb/dwc3/dwc3-generic.c
> @@ -61,18 +61,17 @@ static int dwc3_generic_peripheral_remove(struct udevice 
> *dev)
>  static int dwc3_generic_peripheral_ofdata_to_platdata(struct udevice *dev)
>  {
>   struct dwc3 *priv = dev_get_priv(dev);
> - int node = dev_of_offset(dev);
>  
> - priv->regs = (void *)devfdt_get_addr(dev);
> + priv->regs = (void *)dev_read_addr(dev);
>   priv->regs += DWC3_GLOBALS_REGS_START;
>  
> - priv->maximum_speed = usb_get_maximum_speed(node);
> + priv->maximum_speed = usb_get_maximum_speed(dev->node);
>   if (priv->maximum_speed == USB_SPEED_UNKNOWN) {
>   pr_err("Invalid usb maximum speed\n");
>   return -ENODEV;
>   }
>  
> - priv->dr_mode = usb_get_dr_mode(node);
> + priv->dr_mode = usb_get_dr_mode(dev->node);
>   if (priv->dr_mode == USB_DR_MODE_UNKNOWN) {
>   pr_err("Invalid usb mode setup\n");
>   return -ENODEV;
> @@ -100,13 +99,11 @@ U_BOOT_DRIVER(dwc3_generic_peripheral) = {
>  
>  static int dwc3_generic_bind(struct udevice *parent)
>  {
> - const void *fdt = gd->fdt_blob;
> - int node;
> + ofnode node;
>   int ret;
>  
> - for (node = fdt_first_subnode(fdt, dev_of_offset(parent)); node > 0;
> -  node = fdt_next_subnode(fdt, node)) {
> - const char *name = fdt_get_name(fdt, node, NULL);
> + dev_for_each_subnode(node, parent) {
> + const char *name = (char *)ofnode_get_name(node);
>   enum usb_dr_mode dr_mode;
>   struct udevice *dev;
>   const char *driver;
> @@ -133,7 +130,7 @@ static int dwc3_generic_bind(struct udevice *parent)
>   };
>  
>   ret = device_bind_driver_to_node(parent, driver, name,
> -  offset_to_ofnode(node), &dev);
> +  node, &dev);
>   if (ret) {
>   debug("%s: not able to bind usb device mode\n",
> __func__);
> diff --git a/drivers/usb/host/dwc3-sti-glue.c 
> b/drivers/usb/host/dwc3-sti-glue.c
> index ad7cf6e..de423ee 100644
> --- a/drivers/usb/host/dwc3-sti-glue.c
> +++ b/drivers/usb/host/dwc3-sti-glue.c
> @@ -153,18 +153,17 @@ static int sti_dwc3_glue_ofdata_to_platdata(struct 
> udevice *dev)
>  static int sti_dwc3_glue_bind(struct udevice *dev)
>  {
>   struct sti_dwc3_glue_platdata *plat = dev_get_platdata(dev);
> - int dwc3_node;
> + ofnode dwc3_node;
>  
>   /* check if one subnode is present */
> - dwc3_node = fdt_first_subnode(gd->fdt_blob, dev_of_offset(de

Re: [U-Boot] [PATCH 1/2] config_fallback: update CONFIG_SYS_BAUDRATE_TABLE

2018-09-06 Thread Christian Gmeiner
Am Do., 6. Sep. 2018 um 09:58 Uhr schrieb Bin Meng :
>
> Hi Christian,
>
> On Thu, Sep 6, 2018 at 3:41 PM Christian Gmeiner
>  wrote:
> >
> > Take the values from x86-common.h as inspiration.
> >
> > Signed-off-by: Christian Gmeiner 
> > ---
> >  include/config_fallbacks.h | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/include/config_fallbacks.h b/include/config_fallbacks.h
> > index c18f19a550..4c1bdf5ee5 100644
> > --- a/include/config_fallbacks.h
> > +++ b/include/config_fallbacks.h
> > @@ -26,7 +26,8 @@
> >  #endif
> >
> >  #ifndef CONFIG_SYS_BAUDRATE_TABLE
> > -#define CONFIG_SYS_BAUDRATE_TABLE  { 9600, 19200, 38400, 57600, 115200 
> > }
> > +#define CONFIG_SYS_BAUDRATE_TABLE  { 300, 600, 1200, 2400, 4800, \
>
> I don't see a value to bring in 300/600/1200 etc .
>

I just copied the table from x86 - I am fine with dropping these baud
rates them.

> > +   9600, 19200, 38400, 57600, 115200 }
> >  #endif
> >
> >  /* Console I/O Buffer Size */
> > --
>

-- 
greets
--
Christian Gmeiner, MSc

https://christian-gmeiner.info
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v2] usb: dwc3: convert to livetree

2018-09-06 Thread Siva Durga Prasad Paladugu
From: Vipul Kumar 

Update the DWC3 USB driver to support a live tree.

Signed-off-by: Siva Durga Prasad Paladugu 
Signed-off-by: Vipul Kumar 
Tested-by: Michal Simek 
---
Changes in v2:
- Fixed travis build issues with some platforms.
---
 drivers/usb/common/common.c  | 11 +--
 drivers/usb/dwc3/dwc3-generic.c  | 17 +++--
 drivers/usb/host/dwc3-sti-glue.c |  7 +++
 drivers/usb/host/xhci-dwc3.c |  3 ++-
 drivers/usb/host/xhci-zynqmp.c   |  3 +--
 drivers/usb/musb-new/ti-musb.c   | 11 ---
 include/linux/usb/otg.h  |  6 --
 7 files changed, 26 insertions(+), 32 deletions(-)

diff --git a/drivers/usb/common/common.c b/drivers/usb/common/common.c
index a55def5..3dea79b 100644
--- a/drivers/usb/common/common.c
+++ b/drivers/usb/common/common.c
@@ -10,6 +10,7 @@
 #include 
 #include 
 #include 
+#include 
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -20,13 +21,12 @@ static const char *const usb_dr_modes[] = {
[USB_DR_MODE_OTG]   = "otg",
 };
 
-enum usb_dr_mode usb_get_dr_mode(int node)
+enum usb_dr_mode usb_get_dr_mode(ofnode node)
 {
-   const void *fdt = gd->fdt_blob;
const char *dr_mode;
int i;
 
-   dr_mode = fdt_getprop(fdt, node, "dr_mode", NULL);
+   dr_mode = ofnode_get_property(node, "dr_mode", NULL);
if (!dr_mode) {
pr_err("usb dr_mode not found\n");
return USB_DR_MODE_UNKNOWN;
@@ -48,13 +48,12 @@ static const char *const speed_names[] = {
[USB_SPEED_SUPER] = "super-speed",
 };
 
-enum usb_device_speed usb_get_maximum_speed(int node)
+enum usb_device_speed usb_get_maximum_speed(ofnode node)
 {
-   const void *fdt = gd->fdt_blob;
const char *max_speed;
int i;
 
-   max_speed = fdt_getprop(fdt, node, "maximum-speed", NULL);
+   max_speed = ofnode_get_property(node, "maximum-speed", NULL);
if (!max_speed) {
pr_err("usb maximum-speed not found\n");
return USB_SPEED_UNKNOWN;
diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c
index ca63eac..ef72c8c 100644
--- a/drivers/usb/dwc3/dwc3-generic.c
+++ b/drivers/usb/dwc3/dwc3-generic.c
@@ -61,18 +61,17 @@ static int dwc3_generic_peripheral_remove(struct udevice 
*dev)
 static int dwc3_generic_peripheral_ofdata_to_platdata(struct udevice *dev)
 {
struct dwc3 *priv = dev_get_priv(dev);
-   int node = dev_of_offset(dev);
 
-   priv->regs = (void *)devfdt_get_addr(dev);
+   priv->regs = (void *)dev_read_addr(dev);
priv->regs += DWC3_GLOBALS_REGS_START;
 
-   priv->maximum_speed = usb_get_maximum_speed(node);
+   priv->maximum_speed = usb_get_maximum_speed(dev->node);
if (priv->maximum_speed == USB_SPEED_UNKNOWN) {
pr_err("Invalid usb maximum speed\n");
return -ENODEV;
}
 
-   priv->dr_mode = usb_get_dr_mode(node);
+   priv->dr_mode = usb_get_dr_mode(dev->node);
if (priv->dr_mode == USB_DR_MODE_UNKNOWN) {
pr_err("Invalid usb mode setup\n");
return -ENODEV;
@@ -100,13 +99,11 @@ U_BOOT_DRIVER(dwc3_generic_peripheral) = {
 
 static int dwc3_generic_bind(struct udevice *parent)
 {
-   const void *fdt = gd->fdt_blob;
-   int node;
+   ofnode node;
int ret;
 
-   for (node = fdt_first_subnode(fdt, dev_of_offset(parent)); node > 0;
-node = fdt_next_subnode(fdt, node)) {
-   const char *name = fdt_get_name(fdt, node, NULL);
+   dev_for_each_subnode(node, parent) {
+   const char *name = (char *)ofnode_get_name(node);
enum usb_dr_mode dr_mode;
struct udevice *dev;
const char *driver;
@@ -133,7 +130,7 @@ static int dwc3_generic_bind(struct udevice *parent)
};
 
ret = device_bind_driver_to_node(parent, driver, name,
-offset_to_ofnode(node), &dev);
+node, &dev);
if (ret) {
debug("%s: not able to bind usb device mode\n",
  __func__);
diff --git a/drivers/usb/host/dwc3-sti-glue.c b/drivers/usb/host/dwc3-sti-glue.c
index ad7cf6e..de423ee 100644
--- a/drivers/usb/host/dwc3-sti-glue.c
+++ b/drivers/usb/host/dwc3-sti-glue.c
@@ -153,18 +153,17 @@ static int sti_dwc3_glue_ofdata_to_platdata(struct 
udevice *dev)
 static int sti_dwc3_glue_bind(struct udevice *dev)
 {
struct sti_dwc3_glue_platdata *plat = dev_get_platdata(dev);
-   int dwc3_node;
+   ofnode dwc3_node;
 
/* check if one subnode is present */
-   dwc3_node = fdt_first_subnode(gd->fdt_blob, dev_of_offset(dev));
+   dwc3_node = dev_read_first_subnode(dev);
if (dwc3_node <= 0) {
pr_err("Can't find subnode for %s\n", dev->name);
return -ENODEV;
}
 
/* check if the subnode compatible s

[U-Boot] [PATCH 4/11] Add board specific reset support to ppc4xx CPU

2018-09-06 Thread ashley
Spam detection software, running on the system "lists.denx.de",
has identified this incoming email as possible spam.  The original
message has been attached to this so you can view it or label
similar future email.  If you have any questions, see
@@CONTACT_ADDRESS@@ for details.

Content preview:  [PATCH 4/11] Add board specific reset support to ppc4xx CPU
   u-boot@lists.denx.de Good day! [...] 

Content analysis details:   (8.4 points, 5.0 required)

 pts rule name  description
 -- --
 3.6 RCVD_IN_PBLRBL: Received via a relay in Spamhaus PBL
[113.77.85.192 listed in zen.spamhaus.org]
 1.1 MIME_HTML_ONLY BODY: Message only has text/html MIME parts
 0.7 HTML_IMAGE_ONLY_20 BODY: HTML: images with 1600-2000 bytes of words
 0.0 HTML_MESSAGE   BODY: HTML included in message
 1.6 RCVD_IN_BRBL_LASTEXT   RBL: No description available.
[113.77.85.192 listed in bb.barracudacentral.org]
 0.1 MISSING_MIDMissing Message-Id: header
 0.0 UNPARSEABLE_RELAY  Informational: message has unparseable relay lines
 1.3 RDNS_NONE  Delivered to internal network by a host with no rDNS

The original message was not completely plain text, and may be unsafe to
open with some email clients; in particular, it may contain a virus,
or confirm that your address can receive spam.  If you wish to view
it, it may be safer to save it to a file and open it with an editor.

--- Begin Message ---
<<< image/jpeg: EXCLUDED >>>
--- End Message ---
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [EDK2] Implementing EFI_SIMPLE_TEXT_INPUT_PROTOCOL

2018-09-06 Thread Ni, Ruiyu

On 9/6/2018 11:27 AM, Heinrich Schuchardt wrote:

Hello Ruiyu,

currently I am struggling a bit with interpreting the UEFI spec
concerning the EFI_SIMPLE_TEXT_INPUT_PROTOCOL.

In UEFI spec 2.7. chapter 12.1.2 ConsoleIn Definition there is this
sentence:

"Only the control characters defined in Table 100 have meaning in the
Unicode input or output streams."

Table 100:

U+ Null character ignored when received.
U+0008 Backspace. Moves cursor left one column.
U+0009 Tab.
U+000A Linefeed. Moves cursor  to the next line.
U+000D Carriage Return. Moves cursor to left margin of the current line.

Rob interpreted this in a patch for U-Boot such that he simply
suppressed all other Unicode characters in the 0x00-01F range except for
special treatment of 0x001b as ESC.

When I look at EDK2 function USBKeyboardReadKeyStroke()
(MdeModulePkg/Bus/Usb/UsbKbDxe/EfiKey.c:700) it seems that EDK2 would
pass CTRL+C as Unicode character U+0003 (cf. your patch 608817ad7114
"Change the SimpleTextInEx implementation to return CTRL+C").

The same seems to be the case in function KeyboardReadKeyStroke()
(MdeModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KbdTextIn.c:265).

So do I get it right that for CTRL+A to CTRL+Z we should return a value
U+0001 - U+001a in Key->UnicodeChar and table 100 is about meaning of
control characters only and does *not* prescribe a filter?
The reason to return U+0003 for CTRL+C because SimpleTextIn cannot 
return the CTRL state so it uses U+0003 to tell caller that CTRL+C is 
pressed. I think your interpretation to the spec is right.




But what about CTRL+[ - CTRL+_ ? Why are they suppressed in the EDK2
keyboard drivers? How do we enter U+001c - U+001f?

Good question. I didn't think about how to translate CTRL+[ and etc.
The patch I made 7 years ago was to meet the purpose how to tell caller 
the CTRL+[ALPHA] is pressed. There was no requirement to tell caller 
whether CTRL+[ (etc.) is pressed at that moment.
I think since SimpleTextInEx is introduced in UEFI Spec, which can 
return more precise key state/toggle information, caller should use the 
Ex version.
I think it's ok for your driver to translate CTRL+[. I doubt any 
consumer code cares about that.




Best regards

Heinrich




--
Thanks,
Ray
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v7 12/12] cmd: mtdparts: describe as legacy

2018-09-06 Thread Boris Brezillon
On Thu,  6 Sep 2018 09:08:54 +0200
Miquel Raynal  wrote:

> The 'mtdparts' command is not needed anymore. While the environment
> variable is still valid (and useful, along with the 'mtdids' one), the
> command has been replaced by 'mtd' which is much more close to the MTD
> stack and do not add its own specific glue.
> 
> Signed-off-by: Miquel Raynal 
> Reviewed-by: Stefan Roese 
> ---
>  cmd/Kconfig | 6 +-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/cmd/Kconfig b/cmd/Kconfig
> index f82addca0a..51dd058128 100644
> --- a/cmd/Kconfig
> +++ b/cmd/Kconfig
> @@ -1680,7 +1680,11 @@ config CMD_MTDPARTS
>   bool "MTD partition support"
>   select MTD_DEVICE if (CMD_NAND || NAND)
>   help
> -   MTD partition support
> +   MTD partitioning tool support.
> +   It is strongly encouraged to avoid using this command
> +   anymore. One can still declare the partitions in the
> +   mtdparts environment variable but better use the MTD stack
> +   and the mtd command instead than this one.

Well, that's only working if people stop using nand,onenand,sf,...
commands in favor the mtd ones, otherwise they still need mtdparts,
unfortunately :-(.

I guess a long term goal could be to define aliases between flash
specific commands and the generic mtd ones so that we can get rid of
cmd/.c drivers.

Regards,

Boris
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v2 06/13] pico-imx7d: Update the README file

2018-09-06 Thread Stefano Babic
Hi Otavio,

On 05/09/2018 21:13, Otavio Salvador wrote:
> Hello Tom and Stefano,
> 
> This should be applied for release as it puts the README aligned with
> current use. Please consider it.
> 

You patches look good and I can confirm they are just related to the
pico board. I have no comments at all, and I do not see any reason you
need to change them.  I have set them to go into my (local) next branch.

But patches (V1) were sent after Window was closed (last week) and we
are a quite more restrictive as in the past, so I have not considered to
get them in before release. My last PR was already too late and raises
some new issues and I guess Tom is "quite" releasing. I want to avoid to
push him other stuff just some days before release if they are not
strict important fixes.

Best regards,
Stefano


> On Tue, Sep 4, 2018 at 4:13 PM Otavio Salvador  > wrote:
> 
> On Tue, Sep 4, 2018 at 11:06 AM Michael Nazzareno Trimarchi
> mailto:mich...@amarulasolutions.com>>
> wrote:
> ...
> > Those change are about imx6ul and you update the readme of imx7d
> 
> Those put them on sync and it is part of our work. I see no reason for
> another PR just for a single commit.
> --
> Otavio Salvador                             O.S. Systems
> http://www.ossystems.com.br        http://code.ossystems.com.br
> Mobile: +55 (53) 9 9981-7854          Mobile: +1 (347) 903-9750
> 
> 
> 
> -- 
> Otavio Salvador                             O.S. Systems
> http://www.ossystems.com.br        http://code.ossystems.com.br
> Mobile: +55 (53) 9 9981-7854          Mobile: +1 (347) 903-9750


-- 
=
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: sba...@denx.de
=
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v7 11/12] cmd: ubi: clean the partition handling

2018-09-06 Thread Boris Brezillon
Hi Miquel,

On Thu,  6 Sep 2018 09:08:53 +0200
Miquel Raynal  wrote:

>  int ubi_part(char *part_name, const char *vid_header_offset)
>  {
> + struct mtd_info *mtd;
>   int err = 0;
> - char mtd_dev[16];
> - struct mtd_device *dev;
> - struct part_info *part;
> - u8 pnum;
>  
>   ubi_detach();
> - /*
> -  * Search the mtd device number where this partition
> -  * is located
> -  */
> - if (find_dev_and_part(part_name, &dev, &pnum, &part)) {
> +
> +#ifdef CONFIG_MTD
> + mtd_probe_devices();
> +#endif

Okay, so just like for the mtdparts patch, the #ifdef is incorrect, but
more importantly, with you're rework, you're breaking all non-DM
platforms, because the UBI layer no longer creates an MTD device on the
fly, and the mtd partition creation won't take place if CONFIG_MTD is
not activated.

My suggestion would be to make mtd_probe_devices() available to everyone
(not only those who have CONFIG_MTD selected, which in turn depends on
CONFIG_DM) so that the mtd part creation is done unconditionally, and
you can safely get rid of the "dummy MTD device creation" done in UBI.

> + mtd = get_mtd_device_nm(part_name);
> + if (IS_ERR(mtd)) {

Regards,

Boris
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v7 10/12] cmd: mtdparts: try to probe the MTD devices as a fallback

2018-09-06 Thread Boris Brezillon
On Thu,  6 Sep 2018 09:08:52 +0200
Miquel Raynal  wrote:

> Current implementation of mtdparts command errors out if the desired MTD
> device is not found. Fallback to the new probe function in this case
> before erroring out.
> 
> This will the save the user the need to call something like 'mtd list'
> before mtdparts.
> 
> Signed-off-by: Miquel Raynal 
> Acked-by: Jagan Teki 
> Reviewed-by: Stefan Roese 
> ---
>  cmd/mtdparts.c | 16 +---
>  1 file changed, 13 insertions(+), 3 deletions(-)
> 
> diff --git a/cmd/mtdparts.c b/cmd/mtdparts.c
> index f7ed1a0779..a1102c3fc5 100644
> --- a/cmd/mtdparts.c
> +++ b/cmd/mtdparts.c
> @@ -79,6 +79,10 @@
>  #include 
>  #include 
>  
> +#if defined(CONFIG_MTD)
> +#include 
> +#endif
> +
>  #if defined(CONFIG_CMD_NAND)
>  #include 
>  #include 
> @@ -307,9 +311,15 @@ static int get_mtd_info(u8 type, u8 num, struct mtd_info 
> **mtd)
>  
>   sprintf(mtd_dev, "%s%d", MTD_DEV_TYPE(type), num);
>   *mtd = get_mtd_device_nm(mtd_dev);
> - if (IS_ERR(*mtd)) {
> - printf("Device %s not found!\n", mtd_dev);
> - return 1;
> + if (IS_ERR_OR_NULL(*mtd)) {
> +#ifdef CONFIG_MTD

In its current state, it should #ifdef CONFIG_CMD_MTD, since
mtd_probe_devices() is implemented in cmd/mtd.c. Anyway, as I
suggested, I think it's better to just move that in mtd_uboot.c and
drop the #ifdef.

> + mtd_probe_devices();
> + *mtd = get_mtd_device_nm(mtd_dev);
> +#endif

BTW, I'm not sure why we need to call mtd_probe_devices() here. If we
really want to deprecate this command, then I'd recommend not adding new
features to it.

> + if (IS_ERR_OR_NULL(*mtd)) {
> + printf("Device %s not found!\n", mtd_dev);
> + return 1;
> + }
>   }
>   put_mtd_device(*mtd);
>  

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v7 09/12] cmd: mtd: add 'mtd' command

2018-09-06 Thread Boris Brezillon
On Thu,  6 Sep 2018 09:08:51 +0200
Miquel Raynal  wrote:

> +
> +int mtd_probe_devices(void)
> +{
> + const char *mtdparts = env_get("mtdparts");
> + const char *mtdids = env_get("mtdids");
> + bool remaining_partitions = true;
> + struct mtd_info *mtd;
> + int i;
> +
> + mtd_probe_uclass_mtd_devs();
> +
> + /* Check if mtdparts/mtdids changed since last call, otherwise: exit */
> + if (!strcmp(mtdparts, old_mtdparts) && !strcmp(mtdids, old_mtdids))
> + return CMD_RET_SUCCESS;
> +
> + /* Update the local copy of mtdparts */
> + free(old_mtdparts);
> + free(old_mtdids);
> + old_mtdparts = strdup(mtdparts);
> + old_mtdids = strdup(mtdids);
> +
> + /* If at least one partition is still in use, do not delete anything */
> + mtd_for_each_device(mtd) {
> + if (mtd->usecount) {
> + printf("Partition \"%s\" already in use, aborting\n",
> +mtd->name);
> + return CMD_RET_FAILURE;
> + }
> + }
> +
> + /*
> +  * Everything looks clear, remove all partitions. It is not safe to
> +  * remove entries from the mtd_for_each_device loop as it uses idr
> +  * indexes and the partitions removal is done in bulk (all partitions of
> +  * one device at the same time), so break and iterate from start each
> +  * time a new partition is found and deleted.
> +  */
> + while (remaining_partitions) {
> + remaining_partitions = false;
> + mtd_for_each_device(mtd) {
> + if (!mtd_is_partition(mtd) && mtd_has_partitions(mtd)) {
> + del_mtd_partitions(mtd);
> + remaining_partitions = true;
> + break;
> + }
> + }
> + }

Just a detail, but I think this logic could be moved in moved in
the core (mtd_uboot.c).

> +
> + /* Start the parsing by ignoring the extra 'mtdparts=' prefix, if any */
> + if (strstr(mtdparts, "mtdparts="))
> + mtdparts += 9;
> +
> + /* For each MTD device in mtdparts */
> + while (mtdparts[0] != '\0') {
> + char mtd_name[MTD_NAME_MAX_LEN], *colon;
> + struct mtd_partition *parts;
> + int mtd_name_len, len;
> + int ret;
> +
> + colon = strchr(mtdparts, ':');
> + if (!colon) {
> + printf("Wrong mtdparts: %s\n", mtdparts);
> + return CMD_RET_FAILURE;
> + }
> +
> + mtd_name_len = colon - mtdparts;
> + strncpy(mtd_name, mtdparts, mtd_name_len);
> + mtd_name[mtd_name_len] = '\0';
> + /* Move the pointer forward (including the ':') */
> + mtdparts += mtd_name_len + 1;
> + mtd = get_mtd_device_nm(mtd_name);
> + if (IS_ERR_OR_NULL(mtd)) {
> + char linux_name[MTD_NAME_MAX_LEN];
> +
> + /*
> +  * The MTD device named "mtd_name" does not exist. Try
> +  * to find a correspondance with an MTD device having
> +  * the same type and number as defined in the mtdids.
> +  */
> + debug("No device named %s\n", mtd_name);
> + ret = mtd_search_alternate_name(mtd_name, linux_name,
> + MTD_NAME_MAX_LEN);
> + if (!ret)
> + mtd = get_mtd_device_nm(linux_name);
> +
> + /*
> +  * If no device could be found, move the mtdparts
> +  * pointer forward until the next set of partitions.
> +  */
> + if (ret || IS_ERR_OR_NULL(mtd)) {
> + printf("Could not find a valid device for %s\n",
> +mtd_name);
> + mtdparts = strchr(mtdparts, ';');
> + if (mtdparts)
> + mtdparts++;
> +
> + continue;
> + }
> + }
> + put_mtd_device(mtd);

Don't know if the refcounting is a nop or not, but shouldn't we keep
a reference to mtd until we're done manipulating it (after the call to
add_mtd_partitions())?

> +
> + /*
> +  * Parse the MTD device partitions. It will update the mtdparts
> +  * pointer, create an array of parts (that must be freed), and
> +  * return the number of partition structures in the array.
> +  */
> + ret = mtd_parse_partitions(mtd, &mtdparts, &parts, &len);
> + if (ret) {
> + printf("Could not parse device %s\n", mtd->name);
> + return CMD_RET_FAILURE;
> +  

[U-Boot] [PATCH] phy: marvell: add SATA comphy RX/TX polarity invert support

2018-09-06 Thread Baruch Siach
From: Rabeeh Khoury 

This patch adds support to Armada 7k/8k comphy RX/TX lane swap. The
'phy-invert' DT property defines the inverted signals.

Signed-off-by: Rabeeh Khoury 
Signed-off-by: Baruch Siach 
---
 drivers/phy/marvell/comphy_cp110.c | 19 +--
 drivers/phy/marvell/comphy_hpipe.h |  6 ++
 2 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/drivers/phy/marvell/comphy_cp110.c 
b/drivers/phy/marvell/comphy_cp110.c
index b0d5d5ca26b9..7dd968f00d79 100644
--- a/drivers/phy/marvell/comphy_cp110.c
+++ b/drivers/phy/marvell/comphy_cp110.c
@@ -641,7 +641,8 @@ static int comphy_usb3_power_up(u32 lane, void __iomem 
*hpipe_base,
 }
 
 static int comphy_sata_power_up(u32 lane, void __iomem *hpipe_base,
-   void __iomem *comphy_base, int cp_index)
+   void __iomem *comphy_base, int cp_index,
+   u32 invert)
 {
u32 mask, data, i, ret = 1;
void __iomem *hpipe_addr = HPIPE_ADDR(hpipe_base, lane);
@@ -927,6 +928,19 @@ static int comphy_sata_power_up(u32 lane, void __iomem 
*hpipe_base,
reg_set(hpipe_addr + HPIPE_PWR_CTR_REG,
0x0 << HPIPE_PWR_CTR_RST_DFE_OFFSET,
HPIPE_PWR_CTR_RST_DFE_MASK);
+
+   /* Set RX / TX swaps */
+   data = mask = 0;
+   if (invert & PHY_POLARITY_TXD_INVERT) {
+   data |= (1 << HPIPE_SYNC_PATTERN_TXD_SWAP_OFFSET);
+   mask |= HPIPE_SYNC_PATTERN_TXD_SWAP_MASK;
+   }
+   if (invert & PHY_POLARITY_RXD_INVERT) {
+   data |= (1 << HPIPE_SYNC_PATTERN_RXD_SWAP_OFFSET);
+   mask |= HPIPE_SYNC_PATTERN_RXD_SWAP_MASK;
+   }
+   reg_set(hpipe_addr + HPIPE_SYNC_PATTERN_REG, data, mask);
+
/* SW reset for interupt logic */
reg_set(hpipe_addr + HPIPE_PWR_CTR_REG,
0x1 << HPIPE_PWR_CTR_SFT_RST_OFFSET,
@@ -2006,7 +2020,8 @@ int comphy_cp110_init(struct chip_serdes_phy_config 
*ptr_chip_cfg,
case PHY_TYPE_SATA3:
ret = comphy_sata_power_up(
lane, hpipe_base_addr, comphy_base_addr,
-   ptr_chip_cfg->cp_index);
+   ptr_chip_cfg->cp_index,
+   serdes_map[lane].invert);
break;
case PHY_TYPE_USB3_HOST0:
case PHY_TYPE_USB3_HOST1:
diff --git a/drivers/phy/marvell/comphy_hpipe.h 
b/drivers/phy/marvell/comphy_hpipe.h
index d99da7b9ffcd..a692035c9417 100644
--- a/drivers/phy/marvell/comphy_hpipe.h
+++ b/drivers/phy/marvell/comphy_hpipe.h
@@ -221,6 +221,12 @@
(0x7 << HPIPE_LOOPBACK_SEL_OFFSET)
 
 #define HPIPE_SYNC_PATTERN_REG  0x090
+#define HPIPE_SYNC_PATTERN_TXD_SWAP_OFFSET 10
+#define HPIPE_SYNC_PATTERN_TXD_SWAP_MASK   \
+   (0x1 << HPIPE_SYNC_PATTERN_TXD_SWAP_OFFSET)
+#define HPIPE_SYNC_PATTERN_RXD_SWAP_OFFSET 11
+#define HPIPE_SYNC_PATTERN_RXD_SWAP_MASK   \
+   (0x1 << HPIPE_SYNC_PATTERN_RXD_SWAP_OFFSET)
 
 #define HPIPE_INTERFACE_REG0x94
 #define HPIPE_INTERFACE_GEN_MAX_OFFSET 10
-- 
2.18.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PULL] Please pull u-boot-imx

2018-09-06 Thread Stefano Babic
Hi Peter,

On 06/09/2018 11:23, Peter Robinson wrote:
> Hi Stefano,
> 
>> a new PR. I dropped the patches causing breakages on PowerPC boards, as
>> well as the issue on GE boards. It ran on travis successfully.
>>
>>
>> The following changes since commit 11ed312896c5f5814064c5d45dcb2f53dc121437:
>>
>>   configs: am57xx: change default board name to beagle_x15 (2018-08-26
>> 12:26:16 -0400)
>>
>> are available in the Git repository at:
>>
>>   git://www.denx.de/git/u-boot-imx.git master
>>
>> for you to fetch changes up to c1d1543ebc6e1fb026d0d7ac96d865faa7567555:
>>
>>   mx7dsabresd: Add the qspi target to the list of supported defconfigs
>> (2018-09-04 08:47:23 +0200)
>>
>> 
>> Alex Kiernan (1):
>>   Cleanup CONFIG_BOOTDELAY on cl-som-imx7
>>
>> Anson Huang (3):
>>   imx: mx7: psci: improve cpu hotplug flow
>>   imx: mx7: add gpc initialization for low power mode
>>   imx: mx7: add system suspend/resume support
>>
>> Fabio Estevam (1):
>>   mx7dsabresd: Add the qspi target to the list of supported defconfigs
>>
>> Martin Kaiser (1):
>>   watchdog: mx25: use the imx_watchdog driver for mx25
>>
>> Stefan Agner (2):
>>   board: toradex: common: fail gracefully on missing NAND chip
>>   colibri_imx7_emmc: add Colibri iMX7D 1GB (eMMC) module support
>>
>> Stefano Babic (1):
>>   imx: missing CONFIG_MII in mx7dsabresd_qspi_defconfig
>>
>> Ye Li (6):
>>   imx: imx6sx-sdb: Enable DM QSPI driver
>>   imx: imx6sx-sabreauto: convert to use DM QSPI driver
>>   imx: imx7d-sdb: Add DM QSPI support
>>   dts: imx6ul: Update alias to support DM
>>   dts: imx6ul_evk: Add DTS files for 14x14 EVK and 9x9 EVK boards
>>   imx: imx6ul_evk: Enable DM driver for iMX6UL EVK u-boot
> 
> Are you aware of any issues on some imx6 devices in 2018.09?

No.

> The
> hummingboard2 (imx6q) hangs for me just after the output below, even
> with the above PR, it works fine with a imx6sx device (udoo neo). I'm
> sure I've seen something on the list that might be related but I can't
> find it.

:-(

> 
> Sorry for picking this up so late in the cycle.

I can just try to test on another mx6q boar if I get enough time, but of
course this is not a great test.

Regards,
Stefano

> 
> Peter
> 
> U-Boot SPL 2018.09-rc3 (Sep 05 2018 - 20:28:15 +)
> Trying to boot from MMC1
> 
> 
> U-Boot 2018.09-rc3 (Sep 05 2018 - 20:28:15 +)
> 
> CPU:   Freescale i.MX6Q rev1.5 996 MHz (running at 792 MHz)
> CPU:   Extended Commercial temperature grade (-20C to 105C) at 25C
> Reset cause: POR
> Board: MX6 HummingBoard2 (som rev 1.5)
> DRAM:  2 GiB
> MMC:   FSL_SDHC: 0, FSL_SDHC: 1
> Loading Environment from MMC... *** Warning - bad CRC, using default 
> environment
> 
> No panel detected: default to HDMI
> Display: HDMI (1024x768)
> In:serial
> Out:   serial
> Err:   serial
> 


-- 
=
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: sba...@denx.de
=
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PULL] Please pull u-boot-imx

2018-09-06 Thread Peter Robinson
Hi Stefano,

> a new PR. I dropped the patches causing breakages on PowerPC boards, as
> well as the issue on GE boards. It ran on travis successfully.
>
>
> The following changes since commit 11ed312896c5f5814064c5d45dcb2f53dc121437:
>
>   configs: am57xx: change default board name to beagle_x15 (2018-08-26
> 12:26:16 -0400)
>
> are available in the Git repository at:
>
>   git://www.denx.de/git/u-boot-imx.git master
>
> for you to fetch changes up to c1d1543ebc6e1fb026d0d7ac96d865faa7567555:
>
>   mx7dsabresd: Add the qspi target to the list of supported defconfigs
> (2018-09-04 08:47:23 +0200)
>
> 
> Alex Kiernan (1):
>   Cleanup CONFIG_BOOTDELAY on cl-som-imx7
>
> Anson Huang (3):
>   imx: mx7: psci: improve cpu hotplug flow
>   imx: mx7: add gpc initialization for low power mode
>   imx: mx7: add system suspend/resume support
>
> Fabio Estevam (1):
>   mx7dsabresd: Add the qspi target to the list of supported defconfigs
>
> Martin Kaiser (1):
>   watchdog: mx25: use the imx_watchdog driver for mx25
>
> Stefan Agner (2):
>   board: toradex: common: fail gracefully on missing NAND chip
>   colibri_imx7_emmc: add Colibri iMX7D 1GB (eMMC) module support
>
> Stefano Babic (1):
>   imx: missing CONFIG_MII in mx7dsabresd_qspi_defconfig
>
> Ye Li (6):
>   imx: imx6sx-sdb: Enable DM QSPI driver
>   imx: imx6sx-sabreauto: convert to use DM QSPI driver
>   imx: imx7d-sdb: Add DM QSPI support
>   dts: imx6ul: Update alias to support DM
>   dts: imx6ul_evk: Add DTS files for 14x14 EVK and 9x9 EVK boards
>   imx: imx6ul_evk: Enable DM driver for iMX6UL EVK u-boot

Are you aware of any issues on some imx6 devices in 2018.09? The
hummingboard2 (imx6q) hangs for me just after the output below, even
with the above PR, it works fine with a imx6sx device (udoo neo). I'm
sure I've seen something on the list that might be related but I can't
find it.

Sorry for picking this up so late in the cycle.

Peter

U-Boot SPL 2018.09-rc3 (Sep 05 2018 - 20:28:15 +)
Trying to boot from MMC1


U-Boot 2018.09-rc3 (Sep 05 2018 - 20:28:15 +)

CPU:   Freescale i.MX6Q rev1.5 996 MHz (running at 792 MHz)
CPU:   Extended Commercial temperature grade (-20C to 105C) at 25C
Reset cause: POR
Board: MX6 HummingBoard2 (som rev 1.5)
DRAM:  2 GiB
MMC:   FSL_SDHC: 0, FSL_SDHC: 1
Loading Environment from MMC... *** Warning - bad CRC, using default environment

No panel detected: default to HDMI
Display: HDMI (1024x768)
In:serial
Out:   serial
Err:   serial
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 1/1] x86: qemu-x86 requires CONFIG_SYS_HZ=2000

2018-09-06 Thread Bin Meng
Hi Heinrich,

On Thu, Sep 6, 2018 at 3:30 PM Heinrich Schuchardt  wrote:
>
>
>
> On 09/06/2018 08:55 AM, Bin Meng wrote:
> > On Thu, Sep 6, 2018 at 2:49 PM Bin Meng  wrote:
> >>
> >> Hi Heinrich,
> >>
> >> On Thu, Sep 6, 2018 at 2:06 PM Heinrich Schuchardt  
> >> wrote:
> >>>
> >>> The sleep command only provides correct timings for
> >>> CONFIG_SYS_HZ=2000 on qemu-x86_defconfig.
> >>>
> >>> This can be tested with
> >>>
> >>> date && sleep 4 && date
> >>
> >> With current u-boot/master, with the same test command you provided, I got:
> >>
> >> => date && sleep 4 && date
> >> Date: 2018-09-06 (Thursday)Time:  6:47:28
> >> Date: 2018-09-06 (Thursday)Time:  6:47:32
> >> => date && sleep 4 && date
> >> Date: 2018-09-06 (Thursday)Time:  6:47:41
> >> Date: 2018-09-06 (Thursday)Time:  6:47:45
> >> => date && sleep 4 && date
> >> Date: 2018-09-06 (Thursday)Time:  6:47:47
> >> Date: 2018-09-06 (Thursday)Time:  6:47:51
> >>
> >> It seems there is no issue.
> >>
> >> QEMU was invoked like this: qemu-system-i386 -nographic -bios u-boot.rom
> >
> > with '-smp 4', the issue still cannot be reproduced.
> >
> > I am using QEMU 2.5.0, shipped by Ubuntu 16.04.
> >
> > Regards,
> > Bin
> >
> Hello Bin,
>
> thanks for testing.
>
> I reran my tests with the same Debian Buster release and QEMU 2.12.0 on
> two machines, one with Intel CPU one with AMD Ryzen and I get different
> results.
>
> So my suggestion would be that I reduce the patch to only change
> lib/Kconfig to make CONFIG_SYS_HZ editable and keep the 1000 Hz default
> value. That way corrections become possible in .config. And we keep the
> defconfig as it is.
>

Sound good to me.

Regards,
Bin
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 2/4] serial: protect access to serial rx buffer

2018-09-06 Thread Patrick DELAUNAY
Hi Stefan,

> From: Stefan 
> Sent: mardi 4 septembre 2018 14:08
> 
> Hi Patrick,
> 
> On 04.09.2018 09:56, Patrick DELAUNAY wrote:
> > Hi Stefan
> >
> >> From: Stefan 
> >> Sent: lundi 3 septembre 2018 16:03
> >>
> >> Hi Patrick,
> >>
> >> On 03.09.2018 15:35, Patrick DELAUNAY wrote:
> >>> Hi Simon and Stefan,
> >>>
> >>> Sorry for my late answer (I just come back from my summer holiday)
> >>>
>  From: s...@google.com  On Behalf Of Simon Glass
>  Sent: mercredi 8 août 2018 11:56
> 
>  On 3 August 2018 at 05:38, Patrick Delaunay
>  
> >> wrote:
> > Add test to avoid access to rx buffer when this buffer is empty.
> > In this case directly call getc() function to avoid issue when
> > tstc() is not called.
> >
> > Signed-off-by: Patrick Delaunay 
> > ---
> >
> >drivers/serial/serial-uclass.c | 3 +++
> >1 file changed, 3 insertions(+)
> >
> > diff --git a/drivers/serial/serial-uclass.c
> > b/drivers/serial/serial-uclass.c index 321d23e..4121a37 100644
> > --- a/drivers/serial/serial-uclass.c
> > +++ b/drivers/serial/serial-uclass.c
> > @@ -228,6 +228,9 @@ static int _serial_getc(struct udevice *dev)
> >   struct serial_dev_priv *upriv = dev_get_uclass_priv(dev);
> >   char val;
> >
> > +   if (upriv->rd_ptr == upriv->wr_ptr)
> > +   return __serial_getc(dev);
> > +
> >   val = upriv->buf[upriv->rd_ptr++];
> >   upriv->rd_ptr %= CONFIG_SERIAL_RX_BUFFER_SIZE;
> >
> > --
> > 2.7.4
> >
> 
>  Reviewed-by: Simon Glass 
> 
>  BTW I think the code in _serial_tstc() is wrong, or at least sub-optimal:
> 
>  /* Read all available chars into the RX buffer */ while 
>  (__serial_tstc(dev)) {
>   upriv->buf[upriv->wr_ptr++] = __serial_getc(dev);
>   upriv->wr_ptr %= CONFIG_SERIAL_RX_BUFFER_SIZE; }
> 
>  It should call serial_getc() until it returns -EAGAIN. There should
>  be no need to call __serial_tstc() first,
> >>>
> >>> This part had be added by Stefan Roese in
> >>> SHA1 3ca7a06afb7cbc867b7861a8b9aada74e5bbb559
> >>>
> >>> But I check again the code, and I think the code is correct
> >>
> >> I really hope so. I did test this implementation quite heavily at that 
> >> time.
> >>
> >>> but I agree it is not optimal.
> >>>
> >>> we can directly ops->getc(dev) and no more __serial_getc() or
> >>> __serial_tstc() :
> >>> the behavior don't change but the access to serial driver is reduced.
> >>> When no char is available, ops->getc witll return -EAGAIN
> >>>
> >>> static int _serial_tstc(struct udevice *dev) {
> >>>   struct dm_serial_ops *ops = serial_get_ops(dev);
> >>>   struct serial_dev_priv *upriv = dev_get_uclass_priv(dev);
> >>>   int err;
> >>>
> >>>   /* Read all available chars into the RX buffer */
> >>>   while(1) {
> >>>   err = ops->getc(dev);
> >>>   if (err < 0)
> >>>   break;
> >>>   upriv->buf[upriv->wr_ptr++] = err;
> >>>   upriv->wr_ptr %= CONFIG_SERIAL_RX_BUFFER_SIZE;
> >>>   }
> >>>
> >>>   return upriv->rd_ptr != upriv->wr_ptr ? 1 : 0; }
> >>>
> >>> If you are OK I will push a other patchset for these otpimisation.
> >>
> >> I'm not 100% sure, if this new implementation is "better". Lets
> >> compare the
> >> code:
> >>
> >> Current version:
> >> static int _serial_tstc(struct udevice *dev) {
> >>struct serial_dev_priv *upriv = dev_get_uclass_priv(dev);
> >>
> >>/* Read all available chars into the RX buffer */
> >>while (__serial_tstc(dev)) {
> >>upriv->buf[upriv->wr_ptr++] = __serial_getc(dev);
> >>upriv->wr_ptr %= CONFIG_SERIAL_RX_BUFFER_SIZE;
> >>}
> >>
> >>return upriv->rd_ptr != upriv->wr_ptr ? 1 : 0; }
> >>
> >> New version:
> >> static int _serial_tstc(struct udevice *dev) {
> >>struct dm_serial_ops *ops = serial_get_ops(dev);
> >>struct serial_dev_priv *upriv = dev_get_uclass_priv(dev);
> >>int err;
> >>
> >>/* Read all available chars into the RX buffer */
> >>while(1) {
> >>err = ops->getc(dev);
> >>if (err < 0)
> >>break;
> >>upriv->buf[upriv->wr_ptr++] = err;
> >>upriv->wr_ptr %= CONFIG_SERIAL_RX_BUFFER_SIZE;
> >>}
> >>
> >>return upriv->rd_ptr != upriv->wr_ptr ? 1 : 0; }
> >>
> >> The new version has more code and will most likely produce a larger
> >> binary. You are removing the calls to the __foo() functions - making
> >> the call chain a bit smaller. But this will only affect the
> >> performance which is most likely negligible in this case.
> >
> > Yes, perhaps a larger code but no more  "pending"  ops call of serial 
> > driver.
> > I only  directly use getc ops => that avoid one access to HW register I 
> > think.
> >
> > Than can improve the execution time, but I agree that seems marginal in most
> the case.
> >
> >> I any case, I don't object against a

Re: [U-Boot] [RESENT PATCH] rockchip: make_fit_atf: fix warning unit_address_vs_reg

2018-09-06 Thread Peter Robinson
On Thu, Aug 23, 2018 at 4:01 AM Kever Yang  wrote:
>
> Patch fix warning:
> /builddir/BUILD/u-boot-2018.05-rc2/"arch/arm/mach-rockchip/make_fit_atf.py" \
> arch/arm/dts/rk3399-firefly.dtb > u-boot.its
>   ./tools/mkimage  -f u-boot.its -E u-boot.itb >/dev/null  && cat
> /dev/null
> u-boot.itb.tmp: Warning (unit_address_vs_reg): Node /images/uboot@1
> has a unit name, but no reg property
> u-boot.itb.tmp: Warning (unit_address_vs_reg): Node /images/atf@1 has
> a unit name, but no reg property
> u-boot.itb.tmp: Warning (unit_address_vs_reg): Node /images/atf@2 has
> a unit name, but no reg property
> u-boot.itb.tmp: Warning (unit_address_vs_reg): Node /images/atf@3 has
> a unit name, but no reg property
> u-boot.itb.tmp: Warning (unit_address_vs_reg): Node /images/fdt@1 has
> a unit name, but no reg property
> u-boot.itb.tmp: Warning (unit_address_vs_reg): Node
> /configurations/config@1 has a unit name, but no reg property
> make[1]: Leaving directory
> '/builddir/BUILD/u-boot-2018.05-rc2/builds/firefly-rk3399'
>
> Reported-by: Peter Robinson 
> Signed-off-by: Kever Yang 
Tested-by: Peter Robinson 

Apologies, I thought I had tested and provided by tested by for this.
LGTM on the newer dtc

Peter

> ---
>
>  arch/arm/mach-rockchip/make_fit_atf.py | 18 +-
>  1 file changed, 9 insertions(+), 9 deletions(-)
>
> diff --git a/arch/arm/mach-rockchip/make_fit_atf.py 
> b/arch/arm/mach-rockchip/make_fit_atf.py
> index 6b3d9201c9..62b9caee34 100755
> --- a/arch/arm/mach-rockchip/make_fit_atf.py
> +++ b/arch/arm/mach-rockchip/make_fit_atf.py
> @@ -34,7 +34,7 @@ DT_HEADER="""// SPDX-License-Identifier: GPL-2.0+ OR X11
> #address-cells = <1>;
>
> images {
> -   uboot@1 {
> +   uboot {
> description = "U-Boot (64-bit)";
> data = /incbin/("u-boot-nodtb.bin");
> type = "standalone";
> @@ -58,7 +58,7 @@ def append_atf_node(file, atf_index, phy_addr):
>  Append ATF DT node to input FIT dts file.
>  """
>  data = 'bl31_0x%08x.bin' % phy_addr
> -print >> file, '\t\tatf@%d {' % atf_index
> +print >> file, '\t\tatf_%d {' % atf_index
>  print >> file, '\t\t\tdescription = \"ARM Trusted Firmware\";'
>  print >> file, '\t\t\tdata = /incbin/("%s");' % data
>  print >> file, '\t\t\ttype = "firmware";'
> @@ -78,7 +78,7 @@ def append_fdt_node(file, dtbs):
>  cnt = 1
>  for dtb in dtbs:
>  dtname = os.path.basename(dtb)
> -print >> file, '\t\tfdt@%d {' % cnt
> +print >> file, '\t\tfdt_%d {' % cnt
>  print >> file, '\t\t\tdescription = "%s";' % dtname
>  print >> file, '\t\t\tdata = /incbin/("%s");' % dtb
>  print >> file, '\t\t\ttype = "flat_dt";'
> @@ -88,17 +88,17 @@ def append_fdt_node(file, dtbs):
>  cnt = cnt + 1
>
>  def append_conf_section(file, cnt, dtname, atf_cnt):
> -print >> file, '\t\tconfig@%d {' % cnt
> +print >> file, '\t\tconfig_%d {' % cnt
>  print >> file, '\t\t\tdescription = "%s";' % dtname
> -print >> file, '\t\t\tfirmware = "atf@1";'
> -print >> file, '\t\t\tloadables = "uboot@1",',
> +print >> file, '\t\t\tfirmware = "atf_1";'
> +print >> file, '\t\t\tloadables = "uboot",',
>  for i in range(1, atf_cnt):
> -print >> file, '"atf@%d"' % (i+1),
> +print >> file, '"atf_%d"' % (i+1),
>  if i != (atf_cnt - 1):
>  print >> file, ',',
>  else:
>  print >> file, ';'
> -print >> file, '\t\t\tfdt = "fdt@1";'
> +print >> file, '\t\t\tfdt = "fdt_1";'
>  print >> file, '\t\t};'
>  print >> file, ''
>
> @@ -108,7 +108,7 @@ def append_conf_node(file, dtbs, atf_cnt):
>  """
>  cnt = 1
>  print >> file, '\tconfigurations {'
> -print >> file, '\t\tdefault = "config@1";'
> +print >> file, '\t\tdefault = "config_1";'
>  for dtb in dtbs:
>  dtname = os.path.basename(dtb)
>  append_conf_section(file, cnt, dtname, atf_cnt)
> --
> 2.18.0
>
> ___
> U-Boot mailing list
> U-Boot@lists.denx.de
> https://lists.denx.de/listinfo/u-boot
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 2/2] x86_common: drop custom CONFIG_SYS_BAUDRATE_TABLE

2018-09-06 Thread Bin Meng
On Thu, Sep 6, 2018 at 3:41 PM Christian Gmeiner
 wrote:
>

I would use "x86" instead of "x86_common" in the commit title.

> Signed-off-by: Christian Gmeiner 
> ---
>  include/configs/x86-common.h | 2 --
>  1 file changed, 2 deletions(-)
>

Regards,
Bin
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 1/2] config_fallback: update CONFIG_SYS_BAUDRATE_TABLE

2018-09-06 Thread Bin Meng
Hi Christian,

On Thu, Sep 6, 2018 at 3:41 PM Christian Gmeiner
 wrote:
>
> Take the values from x86-common.h as inspiration.
>
> Signed-off-by: Christian Gmeiner 
> ---
>  include/config_fallbacks.h | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/include/config_fallbacks.h b/include/config_fallbacks.h
> index c18f19a550..4c1bdf5ee5 100644
> --- a/include/config_fallbacks.h
> +++ b/include/config_fallbacks.h
> @@ -26,7 +26,8 @@
>  #endif
>
>  #ifndef CONFIG_SYS_BAUDRATE_TABLE
> -#define CONFIG_SYS_BAUDRATE_TABLE  { 9600, 19200, 38400, 57600, 115200 }
> +#define CONFIG_SYS_BAUDRATE_TABLE  { 300, 600, 1200, 2400, 4800, \

I don't see a value to bring in 300/600/1200 etc .

> +   9600, 19200, 38400, 57600, 115200 }
>  #endif
>
>  /* Console I/O Buffer Size */
> --

Regards,
Bin
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH] x86: extend baudrate table with 57600

2018-09-06 Thread Christian Gmeiner
Am Mi., 5. Sep. 2018 um 17:10 Uhr schrieb Tom Rini :
>
> On Wed, Sep 05, 2018 at 12:57:39PM +0800, Bin Meng wrote:
> > Hi Christian,
> >
> > On Tue, Sep 4, 2018 at 6:07 PM Christian Gmeiner
> >  wrote:
> > >
> > > Hi all,
> > >
> > > I totally forgot to answer that mail - but as I need this change my
> > > motivation is back.
> > >
> > > Am Do., 22. Juni 2017 um 08:50 Uhr schrieb Bin Meng :
> > > >
> > > > Hi Christian,
> > > >
> > > > On Fri, Jun 9, 2017 at 8:58 AM, Tom Rini  wrote:
> > > > > On Thu, Jun 08, 2017 at 09:38:49AM +0200, Christian Gmeiner wrote:
> > > > >> Hi Tom
> > > > >>
> > > > >> 2017-06-06 22:04 GMT+02:00 Tom Rini :
> > > > >> > On Tue, Jun 06, 2017 at 01:51:38PM +0200, Christian Gmeiner wrote:
> > > > >> >
> > > > >> >> Signed-off-by: Christian Gmeiner 
> > > > >> >> ---
> > > > >> >>  include/configs/x86-common.h | 2 +-
> > > > >> >>  1 file changed, 1 insertion(+), 1 deletion(-)
> > > > >> >>
> > > > >> >> diff --git a/include/configs/x86-common.h 
> > > > >> >> b/include/configs/x86-common.h
> > > > >> >> index b5ef8b5..9a97714 100644
> > > > >> >> --- a/include/configs/x86-common.h
> > > > >> >> +++ b/include/configs/x86-common.h
> > > > >> >> @@ -56,7 +56,7 @@
> > > > >> >>   * Serial Configuration
> > > > >> >>   */
> > > > >> >>  #define CONFIG_SYS_BAUDRATE_TABLE{300, 600, 1200, 2400, 
> > > > >> >> 4800, \
> > > > >> >> -  9600, 19200, 38400, 115200}
> > > > >> >> +  9600, 19200, 38400, 57600, 
> > > > >> >> 115200}
> > > > >> >>  #define CONFIG_SYS_NS16550_PORT_MAPPED
> > > > >> >>
> > > > >> >>  #define CONFIG_CMDLINE_EDITING
> > > > >> >
> > > > >> > Can we just use the fall back table instead?  Thanks!
> > > > >>
> > > > >> Can you point me to the "fall back table"?
> > > > >
> > > > > If one isn't defined the one in  is used.
> > > >
> > >
> > > The fallback table looks okay and has 57600 as baud rate in it. The 
> > > problematic
> > > part is the xf86-common.h which defines CONFIG_SYS_BAUDRATE_TABLE and
> > > as a result the fallback table plays no role here.
> > >
> > > > Can you respin the patch per Tom's suggestion? Thanks!
> > >
> > > I think that the current patch is okay as Tom's suggestion does not fly.
> > >
> >
> > I believe what Tom asked was to update config_fallbacks.h directly,
> > and then no need to keep x86-specific one.
>
> To be extra clear, drop the table from the x86 file and then the default
> will be used.
>

Got it - thanks...

-- 
greets
--
Christian Gmeiner, MSc

https://christian-gmeiner.info
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 2/2] x86_common: drop custom CONFIG_SYS_BAUDRATE_TABLE

2018-09-06 Thread Christian Gmeiner
Signed-off-by: Christian Gmeiner 
---
 include/configs/x86-common.h | 2 --
 1 file changed, 2 deletions(-)

diff --git a/include/configs/x86-common.h b/include/configs/x86-common.h
index f0b027e69c..78c382de0c 100644
--- a/include/configs/x86-common.h
+++ b/include/configs/x86-common.h
@@ -47,8 +47,6 @@
 /*---
  * Serial Configuration
  */
-#define CONFIG_SYS_BAUDRATE_TABLE  {300, 600, 1200, 2400, 4800, \
-9600, 19200, 38400, 115200}
 #define CONFIG_SYS_NS16550_PORT_MAPPED
 
 /*---
-- 
2.17.1

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 1/2] config_fallback: update CONFIG_SYS_BAUDRATE_TABLE

2018-09-06 Thread Christian Gmeiner
Take the values from x86-common.h as inspiration.

Signed-off-by: Christian Gmeiner 
---
 include/config_fallbacks.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/config_fallbacks.h b/include/config_fallbacks.h
index c18f19a550..4c1bdf5ee5 100644
--- a/include/config_fallbacks.h
+++ b/include/config_fallbacks.h
@@ -26,7 +26,8 @@
 #endif
 
 #ifndef CONFIG_SYS_BAUDRATE_TABLE
-#define CONFIG_SYS_BAUDRATE_TABLE  { 9600, 19200, 38400, 57600, 115200 }
+#define CONFIG_SYS_BAUDRATE_TABLE  { 300, 600, 1200, 2400, 4800, \
+   9600, 19200, 38400, 57600, 115200 }
 #endif
 
 /* Console I/O Buffer Size */
-- 
2.17.1

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3 1/1] ARM: opos6ul: make the board boot again

2018-09-06 Thread Sébastien Szymanski
Commit 9faa43c4b5e5 ("ARM: dts: i.MX6UL: U-Boot specific dts for u-boot,
dm-spl") removes the u-boot,dm-spl properties from the imx6ul.dtsi file
and breaks the OPOS6UL board.
Add the u-boot,dm-spl properties into *-u-boot.dts files to make the
board boot again.

Fixes: commit 9faa43c4b5e5 ("ARM: dts: i.MX6UL: U-Boot specific dts for u-boot, 
dm-spl")
Signed-off-by: Sébastien Szymanski 
---

Changes for v3:
 - use the automatic inclusion of -u-boot.dtsi mechanism of U-Boot.

Changes for v2:
 - put u-boot,dm-spl properties into -u-boot.dts files

 arch/arm/dts/imx6ul-opos6ul-u-boot.dtsi| 28 
 arch/arm/dts/imx6ul-opos6ul.dtsi   |  2 --
 arch/arm/dts/imx6ul-opos6uldev-u-boot.dtsi | 24 
 arch/arm/dts/imx6ul-opos6uldev.dts |  2 --
 4 files changed, 52 insertions(+), 4 deletions(-)
 create mode 100644 arch/arm/dts/imx6ul-opos6ul-u-boot.dtsi
 create mode 100644 arch/arm/dts/imx6ul-opos6uldev-u-boot.dtsi

diff --git a/arch/arm/dts/imx6ul-opos6ul-u-boot.dtsi 
b/arch/arm/dts/imx6ul-opos6ul-u-boot.dtsi
new file mode 100644
index 00..4918de388e
--- /dev/null
+++ b/arch/arm/dts/imx6ul-opos6ul-u-boot.dtsi
@@ -0,0 +1,28 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Device Tree Source extras for U-Boot for the OPOS6UL SoM
+ *
+ * Copyright (C) 2018 Armadeus Systems 
+ */
+
+/ {
+   soc {
+   u-boot,dm-spl;
+   };
+};
+
+&aips2 {
+   u-boot,dm-spl;
+};
+
+&iomuxc {
+   u-boot,dm-spl;
+};
+
+&pinctrl_usdhc1 {
+   u-boot,dm-spl;
+};
+
+&usdhc1 {
+   u-boot,dm-spl;
+};
diff --git a/arch/arm/dts/imx6ul-opos6ul.dtsi b/arch/arm/dts/imx6ul-opos6ul.dtsi
index d51ad4de20..8f16a0a81c 100644
--- a/arch/arm/dts/imx6ul-opos6ul.dtsi
+++ b/arch/arm/dts/imx6ul-opos6ul.dtsi
@@ -99,7 +99,6 @@
 
 /* eMMC */
 &usdhc1 {
-   u-boot,dm-spl;
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_usdhc1>;
bus-width = <8>;
@@ -162,7 +161,6 @@
};
 
pinctrl_usdhc1: usdhc1grp {
-   u-boot,dm-spl;
fsl,pins = <
MX6UL_PAD_SD1_CMD__USDHC1_CMD   0x17059
MX6UL_PAD_SD1_CLK__USDHC1_CLK   0x10059
diff --git a/arch/arm/dts/imx6ul-opos6uldev-u-boot.dtsi 
b/arch/arm/dts/imx6ul-opos6uldev-u-boot.dtsi
new file mode 100644
index 00..da8b0392ef
--- /dev/null
+++ b/arch/arm/dts/imx6ul-opos6uldev-u-boot.dtsi
@@ -0,0 +1,24 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Device Tree Source extras for U-Boot for the OPOS6ULDev board
+ *
+ * Copyright (C) 2018 Armadeus Systems 
+ */
+
+#include "imx6ul-opos6ul-u-boot.dtsi"
+
+&aips1 {
+   u-boot,dm-spl;
+
+   spba-bus@0200 {
+   u-boot,dm-spl;
+   };
+};
+
+&pinctrl_uart1 {
+   u-boot,dm-spl;
+};
+
+&uart1 {
+   u-boot,dm-spl;
+};
diff --git a/arch/arm/dts/imx6ul-opos6uldev.dts 
b/arch/arm/dts/imx6ul-opos6uldev.dts
index 9a51d1e54f..0e59ee57fd 100644
--- a/arch/arm/dts/imx6ul-opos6uldev.dts
+++ b/arch/arm/dts/imx6ul-opos6uldev.dts
@@ -228,7 +228,6 @@
 };
 
 &uart1 {
-   u-boot,dm-spl;
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_uart1>;
status = "okay";
@@ -374,7 +373,6 @@
};
 
pinctrl_uart1: uart1grp {
-   u-boot,dm-spl;
fsl,pins = <
MX6UL_PAD_UART1_TX_DATA__UART1_DCE_TX   0x1b0b1
MX6UL_PAD_UART1_RX_DATA__UART1_DCE_RX   0x1b0b1
-- 
2.16.4

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 1/1] x86: qemu-x86 requires CONFIG_SYS_HZ=2000

2018-09-06 Thread Heinrich Schuchardt


On 09/06/2018 08:55 AM, Bin Meng wrote:
> On Thu, Sep 6, 2018 at 2:49 PM Bin Meng  wrote:
>>
>> Hi Heinrich,
>>
>> On Thu, Sep 6, 2018 at 2:06 PM Heinrich Schuchardt  
>> wrote:
>>>
>>> The sleep command only provides correct timings for
>>> CONFIG_SYS_HZ=2000 on qemu-x86_defconfig.
>>>
>>> This can be tested with
>>>
>>> date && sleep 4 && date
>>
>> With current u-boot/master, with the same test command you provided, I got:
>>
>> => date && sleep 4 && date
>> Date: 2018-09-06 (Thursday)Time:  6:47:28
>> Date: 2018-09-06 (Thursday)Time:  6:47:32
>> => date && sleep 4 && date
>> Date: 2018-09-06 (Thursday)Time:  6:47:41
>> Date: 2018-09-06 (Thursday)Time:  6:47:45
>> => date && sleep 4 && date
>> Date: 2018-09-06 (Thursday)Time:  6:47:47
>> Date: 2018-09-06 (Thursday)Time:  6:47:51
>>
>> It seems there is no issue.
>>
>> QEMU was invoked like this: qemu-system-i386 -nographic -bios u-boot.rom
> 
> with '-smp 4', the issue still cannot be reproduced.
> 
> I am using QEMU 2.5.0, shipped by Ubuntu 16.04.
> 
> Regards,
> Bin
> 
Hello Bin,

thanks for testing.

I reran my tests with the same Debian Buster release and QEMU 2.12.0 on
two machines, one with Intel CPU one with AMD Ryzen and I get different
results.

So my suggestion would be that I reduce the patch to only change
lib/Kconfig to make CONFIG_SYS_HZ editable and keep the 1000 Hz default
value. That way corrections become possible in .config. And we keep the
defconfig as it is.

Best regards

Heinrich
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] Two CRC32 implementation in U-Boot, why?

2018-09-06 Thread Bin Meng
Hi Kyungmin,

On Thu, Aug 9, 2018 at 4:02 PM Bin Meng  wrote:
>
> Hi Kyungmin,
>
> On Mon, Aug 6, 2018 at 1:56 PM, Bin Meng  wrote:
> > On Wed, Aug 1, 2018 at 9:50 PM, Heinrich Schuchardt  
> > wrote:
> >>
> >>
> >> On 08/01/2018 02:13 PM, Bin Meng wrote:
> >>> Hi,
> >>>
> >>> Currently it seems that we have two CRC32 implementation in U-Boot.
> >>> Two headers files are provided.
> >>>
> >>> 1. include/linux/crc32.h
> >>> The implementation is drivers/mtd/ubi/crc32.c.
> >>> Codes that use this implementation include:
> >>>
> >>> drivers/mtd/ubi/*
> >>> drivers/mtd/ubispl/*
> >>> fs/ubifs/*
> >>>
> >>> 2. include/u-boot/crc.h
> >>> The implementation is lib/crc32.c
> >>> Codes that use this implementation include:
> >>>
> >>> fs/btrfs/hash.c
> >>> tools/*
> >>> common/hash.c
> >>> common/image.c
> >>> common/image-fit.c
> >>> lib/efi_loader/efi_boottime.c
> >>>
> >>> It looks that include/linux/crc32.h was originally imported from Linux
> >>> kernel's include/linux/crc32.h, but the implementation in Linux
> >>> kernel's lib/crc32.c was not imported to U-Boot's lib/crc32.c but to
> >>> drivers/mtd/ubi/crc32.c. Why?
> >>>
> >>> Somehow U-Boot lib/crc32.c uses another different implementation from 
> >>> zlib.
> >>>
> >>> This is a mess. For example if I include both headers in one C file,
> >>> it won't compile.
> >>>
> >>> Can we clean this up?
> >>
> >> Thanks for pointing this out.
> >>
> >> The drivers/mtd/ubi/crc32.c is based on an elder version of Linux.
> >>
> >> When looking at the function signatures I am not happy with
> >> include/u-boot/crc.h
> >>  uint32_t crc32 (uint32_t, const unsigned char *, uint)
> >> The last parameter should be size_t. Otherwise the CRC may be wrong on
> >> 64bit systems.
> >>
> >> The two crc32 implementations do not have the same result on a
> >> low-endian system:
> >>
> >> crc32_le(0, 'U-Boot', 6) = a289ac17
> >> crc32(0, 'U-Boot', 6) = 134b0db4.
> >>
> >> According to the comments in in include/linux/crc32.h the result of
> >> crc32_le is in bit reversed order.
> >>
> >> Conflicting definitions could be avoided by removing #define crc32() in
> >> include/linux/crc32.h and adjusting the ubi code accordingly.
> >>
> >
> > I would like to see one CRC32 implementation to support all use cases
> > in U-Boot. Allowing two different implementation just confuses people.
>
> Since UBI seems to be the only user of the Linux CRC32 implementation
> but the header files are a mess, I would expect some comments or plan
> from you.

Any comments?

Regards,
Bin
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v7 00/12] SPI-NAND support

2018-09-06 Thread Miquel Raynal
Hello,

I failed the numbering, this is actually the v8. The below changelog is
still right though. I don't plan to resend unless I am explicitly told
to do so.

Sorry for the mistake.

Thanks,
Miquèl


Miquel Raynal  wrote on Thu,  6 Sep 2018
09:08:42 +0200:

> During the last months, Boris Brezillon shared his work to support
> serial flashes within Linux. First, he delivered (and merged) a new
> layer called spi-mem. He also initiated in Linux MTD subsystem the move
> of all 'raw' NAND related code to a raw/ subdirectory, adding at the
> same time a NAND core that would be shared with all NAND devices. Then,
> he contributed a generic SPI-NAND driver, making use of this NAND core,
> as well as some vendor code to drive a few chips.
> 
> On top of this work, I made some cleanups in the MTD layer and added an
> 'mtd' U-Boot command to handle all sort of MTD devices. This should
> become the default command instead of having one per flash flavor
> ('sf', 'nand', 'spi-nand' ?).
> 
> The series has been tested on an Ocelot board PCB123 (VSC7514),
> featuring a Macronix SPI NAND chip.
> 
> TL;DR: the series contains (stripped version since 23 patches have
> already been taken):
> - Various fixes
> - Support for spi-nand devices in mtdparts.
> - Generics mtdparts/mtdids parsers.
> - A new 'mtd' command.
> - A note to set mtdparts command legacy.
> 
> To test your SPI-NAND device with U-Boot, you can test someting like:
> 
> > setenv mtdparts 'spi-nand0:1m(foo),-(bar)'
> > setenv mtdids 'spi-nand0=spi0.0' # spi0.0 is Linux MTD name for this device
> > ubi part bar # create a static UBI volume in the bar partition
> > mtd list # show the current MTD devices/partitions  
> 
> Thanks,
> Miquèl
> 
> Changes since v7:
> -
> * Added Stefan R-b tags.
> * Used tolower() as suggested by Stefan in lib/strto.c.
> * Added a mention saying that we continue to abuse the kB suffix in
>   lib/strto.c by not making a difference between kB and kiB which both
>   mean "* 1024" for us. This has been added in the commit log.
> * Fixed various bugs in the mtd command and in the parsers, they should
>   be pretty stable now (tested with two MTD devices probed and several
>   different partition configurations).
> * mtdids is not deprecated at all as opposed at what I wrote in
>   v6. U-Boot still uses its own MTD names (being  like nor0
>   or spi-nand1) and mtdids is still needed to do the glue.
> * Removed a useless patch removing a Kconfig entry I added myself since
>   during a rebase someone else also added this symbol.
> 
> Changes since v6:
> -
> * Squashed Boris' fixes about build issues in Travis.
> * Merged Stefan Roese's contributions.
> * cmd: mtdparts:
>   * added fallthrough comments in switch blocks deriving sizes.
>   * balanced debug messages to compare freed and allocated partitions.
>   * move mtdparts_init() declaration in mtd/partitions.h to be used in
> mtd command as well.
>   * introduced a "compatibility" function to return what the MTD device
> name could be thanks to the mtdids environment variable (which is
> useless with the new partitioning logic).
> * mtd: mtdpart:
>   * reworked the way partitions are created/handled.
> * cmd: mtd:
>   * implement a partitioning logic that takes the best out of the MTD
> layer without re-inventing the wheel. Partitions are all freed
> correctly when the value of mtdparts changes.
>   * balance get_mtd_device() by put_mtd_device() calls.
>   * prevent memory leak by reorganizing the code a bit in do_mtd.
>   * do not reconstruct partition list when a partition is already in use
> (complain about that instead).
>   * add support for the legacy mtdids (not needed anymore if mtdparts
> directly uses the MTD device names as in Linux.
> * cmd: ubi:
>   * clean and simplify the partition handling a bit to make use the best
> use of the MTD layer as well and keep the code simple.
> 
> Changes since v5:
> -
> * Included Boris fixup about the build issues.
> * Added Rb/Ab tags from Jagan on patchs 20/21.
> 
> Changes since v4:
> -
> * Added Jagan's Acked-by tags to every patch related to the
>   SPI-mem/SPI-NAND addition.
> * Rebased on top of master.
> 
> Changes since v3:
> -
> * Fixed the debug messages in spi-mem to print either Rx or Tx data.
> * Fixed a Kconfig error that prevented to build mtdparts with plain
>   defconfig.
> * Fixed a compilation error due to the above error that prevented one
>   file to be compiled.
> * Adapted the mtd command to probe MTD partitions also.
> * Declared mtd_probe_devices() in a header so mtdparts or UBI could
>   use it too (to probe all devices and MTD partitions in a clean way).
> * As I worked on mtdparts, I found annoying and completely useless the
>   fact that we need to prefix the environment variable with
>   "mtdparts=". Canceled this obligation.
> * Added one patch to allow spi-nand devices to be 

[U-Boot] [PATCH v7 11/12] cmd: ubi: clean the partition handling

2018-09-06 Thread Miquel Raynal
UBI should not mess with MTD partitions, now that the partitions are
handled in a clean way, clean the ubi command and avoid using this
uneeded extra-glue to reference the devices.

Signed-off-by: Miquel Raynal 
Reviewed-by: Stefan Roese 
---
 cmd/Kconfig |   2 ++
 cmd/ubi.c   | 100 +++-
 2 files changed, 31 insertions(+), 71 deletions(-)

diff --git a/cmd/Kconfig b/cmd/Kconfig
index b5bd978f6d..f82addca0a 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -1822,6 +1822,8 @@ config CMD_UBI
  capabilities. Please, consult the MTD web site for more details
  (www.linux-mtd.infradead.org). Activate this option if you want
  to use U-Boot UBI commands.
+ It is also strongly encouraged to also enable CONFIG_MTD to get full
+ partition support.
 
 config CMD_UBIFS
tristate "Enable UBIFS - Unsorted block images filesystem commands"
diff --git a/cmd/ubi.c b/cmd/ubi.c
index 0a3405a3b1..af0cea2ca5 100644
--- a/cmd/ubi.c
+++ b/cmd/ubi.c
@@ -15,6 +15,9 @@
 #include 
 #include 
 #include 
+#if defined(CONFIG_MTD)
+#include 
+#endif
 #include 
 #include 
 #include 
@@ -29,17 +32,6 @@
 
 /* Private own data */
 static struct ubi_device *ubi;
-static char buffer[80];
-static int ubi_initialized;
-
-struct selected_dev {
-   char part_name[80];
-   int selected;
-   int nr;
-   struct mtd_info *mtd_info;
-};
-
-static struct selected_dev ubi_dev;
 
 #ifdef CONFIG_CMD_UBIFS
 int ubifs_is_mounted(void);
@@ -404,43 +396,24 @@ int ubi_volume_read(char *volume, char *buf, size_t size)
return err;
 }
 
-static int ubi_dev_scan(struct mtd_info *info, char *ubidev,
-   const char *vid_header_offset)
+static int ubi_dev_scan(struct mtd_info *info, const char *vid_header_offset)
 {
-   struct mtd_device *dev;
-   struct part_info *part;
-   struct mtd_partition mtd_part;
char ubi_mtd_param_buffer[80];
-   u8 pnum;
int err;
 
-   if (find_dev_and_part(ubidev, &dev, &pnum, &part) != 0)
-   return 1;
+   if (!vid_header_offset)
+   sprintf(ubi_mtd_param_buffer, "%s", info->name);
+   else
+   sprintf(ubi_mtd_param_buffer, "%s,%s", info->name,
+   vid_header_offset);
 
-   sprintf(buffer, "mtd=%d", pnum);
-   memset(&mtd_part, 0, sizeof(mtd_part));
-   mtd_part.name = buffer;
-   mtd_part.size = part->size;
-   mtd_part.offset = part->offset;
-   add_mtd_partitions(info, &mtd_part, 1);
-
-   strcpy(ubi_mtd_param_buffer, buffer);
-   if (vid_header_offset)
-   sprintf(ubi_mtd_param_buffer, "mtd=%d,%s", pnum,
-   vid_header_offset);
err = ubi_mtd_param_parse(ubi_mtd_param_buffer, NULL);
-   if (err) {
-   del_mtd_partitions(info);
+   if (err)
return -err;
-   }
 
err = ubi_init();
-   if (err) {
-   del_mtd_partitions(info);
+   if (err)
return -err;
-   }
-
-   ubi_initialized = 1;
 
return 0;
 }
@@ -465,50 +438,35 @@ int ubi_detach(void)
/*
 * Call ubi_exit() before re-initializing the UBI subsystem
 */
-   if (ubi_initialized) {
+   if (ubi)
ubi_exit();
-   del_mtd_partitions(ubi_dev.mtd_info);
-   ubi_initialized = 0;
-   }
 
-   ubi_dev.selected = 0;
+   ubi = NULL;
+
return 0;
 }
 
 int ubi_part(char *part_name, const char *vid_header_offset)
 {
+   struct mtd_info *mtd;
int err = 0;
-   char mtd_dev[16];
-   struct mtd_device *dev;
-   struct part_info *part;
-   u8 pnum;
 
ubi_detach();
-   /*
-* Search the mtd device number where this partition
-* is located
-*/
-   if (find_dev_and_part(part_name, &dev, &pnum, &part)) {
+
+#ifdef CONFIG_MTD
+   mtd_probe_devices();
+#endif
+   mtd = get_mtd_device_nm(part_name);
+   if (IS_ERR(mtd)) {
printf("Partition %s not found!\n", part_name);
return 1;
}
-   sprintf(mtd_dev, "%s%d", MTD_DEV_TYPE(dev->id->type), dev->id->num);
-   ubi_dev.mtd_info = get_mtd_device_nm(mtd_dev);
-   if (IS_ERR(ubi_dev.mtd_info)) {
-   printf("Partition %s not found on device %s!\n", part_name,
-  mtd_dev);
-   return 1;
-   }
+   put_mtd_device(mtd);
 
-   ubi_dev.selected = 1;
-
-   strcpy(ubi_dev.part_name, part_name);
-   err = ubi_dev_scan(ubi_dev.mtd_info, ubi_dev.part_name,
-   vid_header_offset);
+   err = ubi_dev_scan(mtd, vid_header_offset);
if (err) {
printf("UBI init error %d\n", err);
printf("Please check, if the correct MTD partition is used 
(size big enough?)\n");
-   ubi_dev.selected = 0;
return err;
}
 
@@ -539,

[U-Boot] [PATCH v7 07/12] mtd: uclass: search for an equivalent MTD name with the mtdids

2018-09-06 Thread Miquel Raynal
Using an MTD device (resp. partition) name in mtdparts is simple and
straightforward. However, for a long time already, another name was
given in mtdparts to indicate a device (resp. partition) so the
"mtdids" environment variable was created to do the match.

Let's create a function that, from an MTD device (resp. partition)
name, search for the equivalent name in the "mtdparts" environment
variable thanks to the "mtdids" string.

Signed-off-by: Miquel Raynal 
Reviewed-by: Stefan Roese 
---
 drivers/mtd/mtdpart.c  | 61 ++
 include/linux/mtd/partitions.h |  2 ++
 2 files changed, 63 insertions(+)

diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c
index eecdb650ad..09427b7b87 100644
--- a/drivers/mtd/mtdpart.c
+++ b/drivers/mtd/mtdpart.c
@@ -263,6 +263,67 @@ int mtd_parse_partitions(struct mtd_info *parent, const 
char **_mtdparts,
return 0;
 }
 
+/**
+ * mtd_search_alternate_name - Search an alternate name for @mtdname thanks to
+ * the mtdids legacy environment variable.
+ *
+ * The mtdids string is a list of comma-separated 'dev_id=mtd_id' tupples.
+ * Check if one of the mtd_id matches mtdname, in this case save dev_id in
+ * altname.
+ *
+ * @mtdname: Current MTD device name
+ * @altname: Alternate name to return
+ * @max_len: Length of the alternate name buffer
+ *
+ * @return 0 on success, an error otherwise.
+ */
+int mtd_search_alternate_name(const char *mtdname, char *altname,
+ unsigned int max_len)
+{
+   const char *mtdids, *equal, *comma, *dev_id, *mtd_id;
+   int dev_id_len, mtd_id_len;
+
+   mtdids = env_get("mtdids");
+   if (!mtdids)
+   return -EINVAL;
+
+   do {
+   /* Find the '=' sign */
+   dev_id = mtdids;
+   equal = strchr(dev_id, '=');
+   if (!equal)
+   break;
+   dev_id_len = equal - mtdids;
+   mtd_id = equal + 1;
+
+   /* Find the end of the tupple */
+   comma = strchr(mtdids, ',');
+   if (comma)
+   mtd_id_len = comma - mtd_id;
+   else
+   mtd_id_len = &mtdids[strlen(mtdids)] - mtd_id + 1;
+
+   if (!dev_id_len || !mtd_id_len)
+   return -EINVAL;
+
+   if (dev_id_len + 1 > max_len)
+   continue;
+
+   /* Compare the name we search with the current mtd_id */
+   if (!strncmp(mtdname, mtd_id, mtd_id_len)) {
+   strncpy(altname, dev_id, dev_id_len);
+   altname[dev_id_len] = 0;
+
+   return 0;
+   }
+
+   /* Go to the next tupple */
+   mtdids = comma + 1;
+   } while (comma);
+
+   return -EINVAL;
+}
+
 /*
  * MTD methods which simply translate the effective address and pass through
  * to the _real_ device.
diff --git a/include/linux/mtd/partitions.h b/include/linux/mtd/partitions.h
index ed4ece5e13..082a4966ea 100644
--- a/include/linux/mtd/partitions.h
+++ b/include/linux/mtd/partitions.h
@@ -88,5 +88,7 @@ int mtd_del_partition(struct mtd_info *master, int partno);
 uint64_t mtd_get_device_size(const struct mtd_info *mtd);
 int mtd_parse_partitions(struct mtd_info *parent, const char **_mtdparts,
 struct mtd_partition **_parts, int *_nb_parts);
+int mtd_search_alternate_name(const char *mtdname, char *altname,
+ unsigned int max_len);
 
 #endif
-- 
2.17.1

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v7 09/12] cmd: mtd: add 'mtd' command

2018-09-06 Thread Miquel Raynal
There should not be a 'nand' command, a 'sf' command and certainly not
a new 'spi-nand' command. Write a 'mtd' command instead to manage all
MTD devices/partitions at once. This should be the preferred way to
access any MTD device.

Signed-off-by: Miquel Raynal 
Acked-by: Jagan Teki 
Reviewed-by: Stefan Roese 
---
 cmd/Kconfig  |  10 +-
 cmd/Makefile |   1 +
 cmd/mtd.c| 521 +++
 drivers/mtd/Makefile |   2 +-
 include/mtd.h|   1 +
 5 files changed, 532 insertions(+), 3 deletions(-)
 create mode 100644 cmd/mtd.c

diff --git a/cmd/Kconfig b/cmd/Kconfig
index f97d3df328..b5bd978f6d 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -854,6 +854,12 @@ config CMD_MMC_SWRITE
  Enable support for the "mmc swrite" command to write Android sparse
  images to eMMC.
 
+config CMD_MTD
+   bool "mtd"
+   select MTD_PARTITIONS
+   help
+ MTD commands support.
+
 config CMD_NAND
bool "nand"
default y if NAND_SUNXI
@@ -1678,14 +1684,14 @@ config CMD_MTDPARTS
 
 config MTDIDS_DEFAULT
string "Default MTD IDs"
-   depends on CMD_MTDPARTS || CMD_NAND || CMD_FLASH
+   depends on CMD_MTD || CMD_MTDPARTS || CMD_NAND || CMD_FLASH
help
  Defines a default MTD IDs list for use with MTD partitions in the
  Linux MTD command line partitions format.
 
 config MTDPARTS_DEFAULT
string "Default MTD partition scheme"
-   depends on CMD_MTDPARTS || CMD_NAND || CMD_FLASH
+   depends on CMD_MTD || CMD_MTDPARTS || CMD_NAND || CMD_FLASH
help
  Defines a default MTD partitioning scheme in the Linux MTD command
  line partitions format
diff --git a/cmd/Makefile b/cmd/Makefile
index 414187f073..8107cb0aa8 100644
--- a/cmd/Makefile
+++ b/cmd/Makefile
@@ -91,6 +91,7 @@ obj-$(CONFIG_CMD_MISC) += misc.o
 obj-$(CONFIG_CMD_MMC) += mmc.o
 obj-$(CONFIG_CMD_MMC_SPI) += mmc_spi.o
 obj-$(CONFIG_MP) += mp.o
+obj-$(CONFIG_CMD_MTD) += mtd.o
 obj-$(CONFIG_CMD_MTDPARTS) += mtdparts.o
 obj-$(CONFIG_CMD_NAND) += nand.o
 obj-$(CONFIG_CMD_NET) += net.o
diff --git a/cmd/mtd.c b/cmd/mtd.c
new file mode 100644
index 00..d771c5d223
--- /dev/null
+++ b/cmd/mtd.c
@@ -0,0 +1,521 @@
+// SPDX-License-Identifier:  GPL-2.0+
+/*
+ * mtd.c
+ *
+ * Generic command to handle basic operations on any memory device.
+ *
+ * Copyright: Bootlin, 2018
+ * Author: Miquèl Raynal 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define MTD_NAME_MAX_LEN 20
+
+static char *old_mtdparts;
+static char *old_mtdids;
+
+static void mtd_dump_buf(u8 *buf, uint len, uint offset)
+{
+   int i, j;
+
+   for (i = 0; i < len; ) {
+   printf("0x%08x:\t", offset + i);
+   for (j = 0; j < 8; j++)
+   printf("%02x ", buf[i + j]);
+   printf(" ");
+   i += 8;
+   for (j = 0; j < 8; j++)
+   printf("%02x ", buf[i + j]);
+   printf("\n");
+   i += 8;
+   }
+}
+
+static void mtd_show_parts(struct mtd_info *mtd, int level)
+{
+   struct mtd_info *part;
+   int i;
+
+   list_for_each_entry(part, &mtd->partitions, node) {
+   for (i = 0; i < level; i++)
+   printf("\t");
+   printf("  - 0x%012llx-0x%012llx : \"%s\"\n",
+  part->offset, part->offset + part->size, part->name);
+
+   mtd_show_parts(part, level + 1);
+   }
+}
+
+static void mtd_show_device(struct mtd_info *mtd)
+{
+   /* Device */
+   printf("* %s\n", mtd->name);
+   if (mtd->dev) {
+   printf("  - device: %s\n", mtd->dev->name);
+   printf("  - parent: %s\n", mtd->dev->parent->name);
+   printf("  - driver: %s\n", mtd->dev->driver->name);
+   }
+
+   /* MTD device information */
+   printf("  - type: ");
+   switch (mtd->type) {
+   case MTD_RAM:
+   printf("RAM\n");
+   break;
+   case MTD_ROM:
+   printf("ROM\n");
+   break;
+   case MTD_NORFLASH:
+   printf("NOR flash\n");
+   break;
+   case MTD_NANDFLASH:
+   printf("NAND flash\n");
+   break;
+   case MTD_DATAFLASH:
+   printf("Data flash\n");
+   break;
+   case MTD_UBIVOLUME:
+   printf("UBI volume\n");
+   break;
+   case MTD_MLCNANDFLASH:
+   printf("MLC NAND flash\n");
+   break;
+   case MTD_ABSENT:
+   default:
+   printf("Unknown\n");
+   break;
+   }
+
+   printf("  - block size: 0x%x bytes\n", mtd->erasesize);
+   printf("  - min I/O: 0x%x bytes\n", mtd->writesize);
+
+   if (mtd->oobsize) {
+   printf("  - OOB size: %u bytes\n", mtd->oobsize);
+   printf("  -

[U-Boot] [PATCH v7 12/12] cmd: mtdparts: describe as legacy

2018-09-06 Thread Miquel Raynal
The 'mtdparts' command is not needed anymore. While the environment
variable is still valid (and useful, along with the 'mtdids' one), the
command has been replaced by 'mtd' which is much more close to the MTD
stack and do not add its own specific glue.

Signed-off-by: Miquel Raynal 
Reviewed-by: Stefan Roese 
---
 cmd/Kconfig | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/cmd/Kconfig b/cmd/Kconfig
index f82addca0a..51dd058128 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -1680,7 +1680,11 @@ config CMD_MTDPARTS
bool "MTD partition support"
select MTD_DEVICE if (CMD_NAND || NAND)
help
- MTD partition support
+ MTD partitioning tool support.
+ It is strongly encouraged to avoid using this command
+ anymore. One can still declare the partitions in the
+ mtdparts environment variable but better use the MTD stack
+ and the mtd command instead than this one.
 
 config MTDIDS_DEFAULT
string "Default MTD IDs"
-- 
2.17.1

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v7 06/12] mtd: uclass: add a generic 'mtdparts' parser

2018-09-06 Thread Miquel Raynal
The current parser is very specific to U-Boot mtdparts implementation.
It does not use MTD structures like mtd_info and mtd_partition. Copy
and adapt the current parser in drivers/mtd/mtd-uclass.c (to not break
the current use of mtdparts.c itself) and write some kind of a wrapper
around the current implementation to allow other commands to benefit
from this parsing in a user-friendly way.

This new function will allocate an mtd_partition array for each
successful call. This array must be freed after use by the caller.
The given 'mtdparts' buffer pointer will be moved forward to the next
MTD device (if any, it will point towards a '\0' character otherwise).

Signed-off-by: Miquel Raynal 
Acked-by: Jagan Teki 
Reviewed-by: Stefan Roese 
---
 drivers/mtd/mtdpart.c  | 187 +
 include/linux/mtd/partitions.h |   2 +
 2 files changed, 189 insertions(+)

diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c
index 9ccb1b3361..eecdb650ad 100644
--- a/drivers/mtd/mtdpart.c
+++ b/drivers/mtd/mtdpart.c
@@ -76,6 +76,193 @@ char *kstrdup(const char *s, gfp_t gfp)
 }
 #endif
 
+#define MTD_SIZE_REMAINING (~0LLU)
+#define MTD_OFFSET_NOT_SPECIFIED   (~0LLU)
+
+/**
+ * mtd_parse_partition - Parse @mtdparts partition definition, fill @partition
+ *   with it and update the @mtdparts string pointer.
+ *
+ * The partition name is allocated and must be freed by the caller.
+ *
+ * This function is widely inspired from part_parse (mtdparts.c).
+ *
+ * @mtdparts: String describing the partition with mtdparts command syntax
+ * @partition: MTD partition structure to fill
+ *
+ * @return 0 on success, an error otherwise.
+ */
+static int mtd_parse_partition(const char **_mtdparts,
+  struct mtd_partition *partition)
+{
+   const char *mtdparts = *_mtdparts;
+   const char *name = NULL;
+   int name_len;
+   char *buf;
+
+   /* Ensure the partition structure is empty */
+   memset(partition, 0, sizeof(struct mtd_partition));
+
+   /* Fetch the partition size */
+   if (*mtdparts == '-') {
+   /* Assign all remaining space to this partition */
+   partition->size = MTD_SIZE_REMAINING;
+   mtdparts++;
+   } else {
+   partition->size = ustrtoull(mtdparts, (char **)&mtdparts, 0);
+   if (partition->size < SZ_4K) {
+   printf("Minimum partition size 4kiB, %lldB requested\n",
+  partition->size);
+   return -EINVAL;
+   }
+   }
+
+   /* Check for the offset */
+   partition->offset = MTD_OFFSET_NOT_SPECIFIED;
+   if (*mtdparts == '@') {
+   mtdparts++;
+   partition->offset = ustrtoull(mtdparts, (char **)&mtdparts, 0);
+   }
+
+   /* Now look for the name */
+   if (*mtdparts == '(') {
+   name = ++mtdparts;
+   mtdparts = strchr(name, ')');
+   if (!mtdparts) {
+   printf("No closing ')' found in partition name\n");
+   return -EINVAL;
+   }
+   name_len = mtdparts - name + 1;
+   if ((name_len - 1) == 0) {
+   printf("Empty partition name\n");
+   return -EINVAL;
+   }
+   mtdparts++;
+   } else {
+   /* Name will be of the form size@offset */
+   name_len = 22;
+   }
+
+   /* Check if the partition is read-only */
+   if (strncmp(mtdparts, "ro", 2) == 0) {
+   partition->mask_flags |= MTD_WRITEABLE;
+   mtdparts += 2;
+   }
+
+   /* Check for a potential next partition definition */
+   if (*mtdparts == ',') {
+   if (partition->size == MTD_SIZE_REMAINING) {
+   printf("No partitions allowed after a fill-up\n");
+   return -EINVAL;
+   }
+   ++mtdparts;
+   } else if ((*mtdparts == ';') || (*mtdparts == '\0')) {
+   /* NOP */
+   } else {
+   printf("Unexpected character '%c' in mtdparts\n", *mtdparts);
+   return -EINVAL;
+   }
+
+   /*
+* Allocate a buffer for the name and either copy the provided name or
+* auto-generate it with the form 'size@offset'.
+*/
+   buf = malloc(name_len);
+   if (!buf)
+   return -ENOMEM;
+
+   if (name)
+   strncpy(buf, name, name_len - 1);
+   else
+   snprintf(buf, name_len, "0x%08llx@0x%08llx",
+partition->size, partition->offset);
+
+   buf[name_len - 1] = '\0';
+   partition->name = buf;
+
+   *_mtdparts = mtdparts;
+
+   return 0;
+}
+
+/**
+ * mtdparts_parse_part - Create a partition array from an mtdparts definition
+ *
+ * Stateless function that takes a @parent MTD device, a s

[U-Boot] [PATCH v7 04/12] cmd: mtdparts: remove mandatory 'mtdparts=' prefix

2018-09-06 Thread Miquel Raynal
All U-Boot users must define the mtdparts environment variable with:
setenv mtdparts mtdparts=...

While this may ease the partition declaration job to be passed to
Linux, this is a pure software limitation and forcing this prefix is a
complete non-sense. Let the user to declare manually the mtdparts
variable without the prefix.

Signed-off-by: Miquel Raynal 
Acked-by: Jagan Teki 
Reviewed-by: Stefan Roese 
---
 cmd/mtdparts.c | 17 ++---
 1 file changed, 6 insertions(+), 11 deletions(-)

diff --git a/cmd/mtdparts.c b/cmd/mtdparts.c
index 2e547894c6..f7ed1a0779 100644
--- a/cmd/mtdparts.c
+++ b/cmd/mtdparts.c
@@ -44,7 +44,7 @@
  *
  * 'mtdparts' - partition list
  *
- * mtdparts=mtdparts=[;...]
+ * mtdparts=[mtdparts=][;...]
  *
  *   := :[,...]
  *:= unique device tag used by linux kernel to find mtd device 
(mtd->name)
@@ -62,11 +62,11 @@
  *
  * 1 NOR Flash, with 1 single writable partition:
  * mtdids=nor0=edb7312-nor
- * mtdparts=mtdparts=edb7312-nor:-
+ * mtdparts=[mtdparts=]edb7312-nor:-
  *
  * 1 NOR Flash with 2 partitions, 1 NAND with one
  * mtdids=nor0=edb7312-nor,nand0=edb7312-nand
- * mtdparts=mtdparts=edb7312-nor:256k(ARMboot)ro,-(root);edb7312-nand:-(home)
+ * mtdparts=[mtdparts=]edb7312-nor:256k(ARMboot)ro,-(root);edb7312-nand:-(home)
  *
  */
 
@@ -1099,9 +1099,6 @@ static int generate_mtdparts(char *buf, u32 buflen)
return 0;
}
 
-   strcpy(p, "mtdparts=");
-   p += 9;
-
list_for_each(dentry, &devices) {
dev = list_entry(dentry, struct mtd_device, link);
 
@@ -1572,11 +1569,9 @@ static int parse_mtdparts(const char *const mtdparts)
if (!p)
p = mtdparts;
 
-   if (strncmp(p, "mtdparts=", 9) != 0) {
-   printf("mtdparts variable doesn't start with 'mtdparts='\n");
-   return err;
-   }
-   p += 9;
+   /* Skip the useless prefix, if any */
+   if (strncmp(p, "mtdparts=", 9) == 0)
+   p += 9;
 
while (*p != '\0') {
err = 1;
-- 
2.17.1

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v7 10/12] cmd: mtdparts: try to probe the MTD devices as a fallback

2018-09-06 Thread Miquel Raynal
Current implementation of mtdparts command errors out if the desired MTD
device is not found. Fallback to the new probe function in this case
before erroring out.

This will the save the user the need to call something like 'mtd list'
before mtdparts.

Signed-off-by: Miquel Raynal 
Acked-by: Jagan Teki 
Reviewed-by: Stefan Roese 
---
 cmd/mtdparts.c | 16 +---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/cmd/mtdparts.c b/cmd/mtdparts.c
index f7ed1a0779..a1102c3fc5 100644
--- a/cmd/mtdparts.c
+++ b/cmd/mtdparts.c
@@ -79,6 +79,10 @@
 #include 
 #include 
 
+#if defined(CONFIG_MTD)
+#include 
+#endif
+
 #if defined(CONFIG_CMD_NAND)
 #include 
 #include 
@@ -307,9 +311,15 @@ static int get_mtd_info(u8 type, u8 num, struct mtd_info 
**mtd)
 
sprintf(mtd_dev, "%s%d", MTD_DEV_TYPE(type), num);
*mtd = get_mtd_device_nm(mtd_dev);
-   if (IS_ERR(*mtd)) {
-   printf("Device %s not found!\n", mtd_dev);
-   return 1;
+   if (IS_ERR_OR_NULL(*mtd)) {
+#ifdef CONFIG_MTD
+   mtd_probe_devices();
+   *mtd = get_mtd_device_nm(mtd_dev);
+#endif
+   if (IS_ERR_OR_NULL(*mtd)) {
+   printf("Device %s not found!\n", mtd_dev);
+   return 1;
+   }
}
put_mtd_device(*mtd);
 
-- 
2.17.1

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v7 05/12] mtd: uclass: add probe function

2018-09-06 Thread Miquel Raynal
The user might want to trigger the probe of any MTD device, export these
functions so they can be called from a command source file.

Signed-off-by: Miquel Raynal 
Acked-by: Jagan Teki 
Reviewed-by: Stefan Roese 
---
 drivers/mtd/mtd-uclass.c | 16 
 include/mtd.h|  2 ++
 2 files changed, 18 insertions(+)

diff --git a/drivers/mtd/mtd-uclass.c b/drivers/mtd/mtd-uclass.c
index 9ca049c437..5418217431 100644
--- a/drivers/mtd/mtd-uclass.c
+++ b/drivers/mtd/mtd-uclass.c
@@ -5,9 +5,25 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 
+/**
+ * mtd_probe - Probe the device @dev if not already done
+ *
+ * @dev: U-Boot device to probe
+ *
+ * @return 0 on success, an error otherwise.
+ */
+int mtd_probe(struct udevice *dev)
+{
+   if (device_active(dev))
+   return 0;
+
+   return device_probe(dev);
+}
+
 /*
  * Implement a MTD uclass which should include most flash drivers.
  * The uclass private is pointed to mtd_info.
diff --git a/include/mtd.h b/include/mtd.h
index 548e7f191b..6e6da3002f 100644
--- a/include/mtd.h
+++ b/include/mtd.h
@@ -19,4 +19,6 @@ static inline struct mtd_info *mtd_get_info(struct udevice 
*dev)
return dev_get_uclass_priv(dev);
 }
 
+int mtd_probe(struct udevice *dev);
+
 #endif /* _MTD_H_ */
-- 
2.17.1

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v7 08/12] mtd: mtdpart: implement proper partition handling

2018-09-06 Thread Miquel Raynal
Instead of collecting partitions in a flat list, create a hierarchy
within the mtd_info structure: use a partitions list to keep track of
the partitions of an MTD device (which might be itself a partition of
another MTD device), a pointer to the parent device (NULL when the MTD
device is the root one, not a partition).

By also saving directly in mtd_info the offset of the partition, we
can get rid of the mtd_part structure.

Signed-off-by: Miquel Raynal 
Reviewed-by: Stefan Roese 
---
 drivers/mtd/mtdcore.c  |   2 +
 drivers/mtd/mtdpart.c  | 412 ++---
 include/linux/mtd/mtd.h|  31 +++
 include/linux/mtd/partitions.h |   1 -
 4 files changed, 208 insertions(+), 238 deletions(-)

diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index fb1d68d5e2..fb6c779abb 100644
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -426,6 +426,8 @@ int add_mtd_device(struct mtd_info *mtd)
mtd->index = i;
mtd->usecount = 0;
 
+   INIT_LIST_HEAD(&mtd->partitions);
+
/* default value if not set by driver */
if (mtd->bitflip_threshold == 0)
mtd->bitflip_threshold = mtd->ecc_strength;
diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c
index 09427b7b87..fae780855d 100644
--- a/drivers/mtd/mtdpart.c
+++ b/drivers/mtd/mtdpart.c
@@ -29,29 +29,12 @@
 
 #include "mtdcore.h"
 
-/* Our partition linked list */
-static LIST_HEAD(mtd_partitions);
 #ifndef __UBOOT__
 static DEFINE_MUTEX(mtd_partitions_mutex);
 #else
 DEFINE_MUTEX(mtd_partitions_mutex);
 #endif
 
-/* Our partition node structure */
-struct mtd_part {
-   struct mtd_info mtd;
-   struct mtd_info *master;
-   uint64_t offset;
-   struct list_head list;
-};
-
-/*
- * Given a pointer to the MTD object in the mtd_part structure, we can retrieve
- * the pointer to that structure with this macro.
- */
-#define PART(x)  ((struct mtd_part *)(x))
-
-
 #ifdef __UBOOT__
 /* from mm/util.c */
 
@@ -332,19 +315,18 @@ int mtd_search_alternate_name(const char *mtdname, char 
*altname,
 static int part_read(struct mtd_info *mtd, loff_t from, size_t len,
size_t *retlen, u_char *buf)
 {
-   struct mtd_part *part = PART(mtd);
struct mtd_ecc_stats stats;
int res;
 
-   stats = part->master->ecc_stats;
-   res = part->master->_read(part->master, from + part->offset, len,
- retlen, buf);
+   stats = mtd->parent->ecc_stats;
+   res = mtd->parent->_read(mtd->parent, from + mtd->offset, len,
+retlen, buf);
if (unlikely(mtd_is_eccerr(res)))
mtd->ecc_stats.failed +=
-   part->master->ecc_stats.failed - stats.failed;
+   mtd->parent->ecc_stats.failed - stats.failed;
else
mtd->ecc_stats.corrected +=
-   part->master->ecc_stats.corrected - stats.corrected;
+   mtd->parent->ecc_stats.corrected - stats.corrected;
return res;
 }
 
@@ -352,17 +334,13 @@ static int part_read(struct mtd_info *mtd, loff_t from, 
size_t len,
 static int part_point(struct mtd_info *mtd, loff_t from, size_t len,
size_t *retlen, void **virt, resource_size_t *phys)
 {
-   struct mtd_part *part = PART(mtd);
-
-   return part->master->_point(part->master, from + part->offset, len,
-   retlen, virt, phys);
+   return mtd->parent->_point(mtd->parent, from + mtd->offset, len,
+  retlen, virt, phys);
 }
 
 static int part_unpoint(struct mtd_info *mtd, loff_t from, size_t len)
 {
-   struct mtd_part *part = PART(mtd);
-
-   return part->master->_unpoint(part->master, from + part->offset, len);
+   return mtd->parent->_unpoint(mtd->parent, from + mtd->offset, len);
 }
 #endif
 
@@ -371,17 +349,13 @@ static unsigned long part_get_unmapped_area(struct 
mtd_info *mtd,
unsigned long offset,
unsigned long flags)
 {
-   struct mtd_part *part = PART(mtd);
-
-   offset += part->offset;
-   return part->master->_get_unmapped_area(part->master, len, offset,
-   flags);
+   offset += mtd->offset;
+   return mtd->parent->_get_unmapped_area(mtd->parent, len, offset, flags);
 }
 
 static int part_read_oob(struct mtd_info *mtd, loff_t from,
struct mtd_oob_ops *ops)
 {
-   struct mtd_part *part = PART(mtd);
int res;
 
if (from >= mtd->size)
@@ -406,7 +380,7 @@ static int part_read_oob(struct mtd_info *mtd, loff_t from,
return -EINVAL;
}
 
-   res = part->master->_read_oob(part->master, from + part->offset, ops);
+   res = mtd->parent->_read_oob(mtd->parent, from + mtd->offset, ops);
if (unlikely(res)) {
if (mtd_is_bitf

[U-Boot] [PATCH v7 03/12] cmd: mtdparts: accept spi-nand devices

2018-09-06 Thread Miquel Raynal
Let spi-nand devices be recognized by mtdparts. This is superfluous
but a full mtdparts rework would be very time-consuming.

Signed-off-by: Miquel Raynal 
Acked-by: Jagan Teki 
Reviewed-by: Boris Brezillon 
Reviewed-by: Stefan Roese 
---
 cmd/mtdparts.c  | 13 -
 include/jffs2/load_kernel.h |  7 +--
 2 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/cmd/mtdparts.c b/cmd/mtdparts.c
index 756fc6018f..2e547894c6 100644
--- a/cmd/mtdparts.c
+++ b/cmd/mtdparts.c
@@ -37,7 +37,7 @@
  * mtdids=[,,...]
  *
  * := =
- *:= 'nand'|'nor'|'onenand'
+ *:= 'nand'|'nor'|'onenand'|'spi-nand'
  *   := mtd device number, 0...
  *:= unique device tag used by linux kernel to find mtd device 
(mtd->name)
  *
@@ -339,7 +339,7 @@ static int part_validate_eraseblock(struct mtdids *id, 
struct part_info *part)
 
if (!mtd->numeraseregions) {
/*
-* Only one eraseregion (NAND, OneNAND or uniform NOR),
+* Only one eraseregion (NAND, SPI-NAND, OneNAND or uniform 
NOR),
 * checking for alignment is easy here
 */
offset = part->offset;
@@ -1030,7 +1030,7 @@ static struct mtdids* id_find_by_mtd_id(const char 
*mtd_id, unsigned int mtd_id_
 }
 
 /**
- * Parse device id string  := 'nand'|'nor'|'onenand',
+ * Parse device id string  := 
'nand'|'nor'|'onenand'|'spi-nand',
  * return device type and number.
  *
  * @param id string describing device id
@@ -1054,6 +1054,9 @@ int mtd_id_parse(const char *id, const char **ret_id, u8 
*dev_type,
} else if (strncmp(p, "onenand", 7) == 0) {
*dev_type = MTD_DEV_TYPE_ONENAND;
p += 7;
+   } else if (strncmp(p, "spi-nand", 8) == 0) {
+   *dev_type = MTD_DEV_TYPE_SPINAND;
+   p += 8;
} else {
printf("incorrect device type in %s\n", id);
return 1;
@@ -1636,7 +1639,7 @@ static int parse_mtdids(const char *const ids)
while(p && (*p != '\0')) {
 
ret = 1;
-   /* parse 'nor'|'nand'|'onenand' */
+   /* parse 'nor'|'nand'|'onenand'|'spi-nand' */
if (mtd_id_parse(p, &p, &type, &num) != 0)
break;
 
@@ -2112,7 +2115,7 @@ static char mtdparts_help_text[] =
"'mtdids' - linux kernel mtd device id <-> u-boot device id mapping\n\n"
"mtdids=[,,...]\n\n"
":= =\n"
-   "   := 'nand'|'nor'|'onenand'\n"
+   "   := 'nand'|'nor'|'onenand'|'spi-nand'\n"
"  := mtd device number, 0...\n"
"   := unique device tag used by linux kernel to find mtd 
device (mtd->name)\n\n"
"'mtdparts' - partition list\n\n"
diff --git a/include/jffs2/load_kernel.h b/include/jffs2/load_kernel.h
index 1ddff062ad..9346d7ee9f 100644
--- a/include/jffs2/load_kernel.h
+++ b/include/jffs2/load_kernel.h
@@ -15,9 +15,12 @@
 #define MTD_DEV_TYPE_NOR   0x0001
 #define MTD_DEV_TYPE_NAND  0x0002
 #define MTD_DEV_TYPE_ONENAND   0x0004
+#define MTD_DEV_TYPE_SPINAND   0x0008
 
-#define MTD_DEV_TYPE(type) ((type == MTD_DEV_TYPE_NAND) ? "nand" : \
-   (type == MTD_DEV_TYPE_ONENAND) ? "onenand" : "nor")
+#define MTD_DEV_TYPE(type) (type == MTD_DEV_TYPE_NAND ? "nand" :   \
+   (type == MTD_DEV_TYPE_NOR ? "nor" : \
+(type == MTD_DEV_TYPE_ONENAND ? "onenand" : \
+ "spi-nand"))) \
 
 struct mtd_device {
struct list_head link;
-- 
2.17.1

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v7 02/12] lib: strto: fix metric suffix parsing in strtoul[l]

2018-09-06 Thread Miquel Raynal
While 1kB or 1kiB will be parsed correctly, 1k will return the right
amount, but the metric suffix will not be escaped once the char
pointer updated. Fix this situation by simplifying the move of the
endp pointer.

Signed-off-by: Miquel Raynal 
Reviewed-by: Stefan Roese 
---
 lib/strto.c | 22 ++
 1 file changed, 10 insertions(+), 12 deletions(-)

diff --git a/lib/strto.c b/lib/strto.c
index b7fc31d6e5..55ff9f7437 100644
--- a/lib/strto.c
+++ b/lib/strto.c
@@ -94,12 +94,11 @@ unsigned long ustrtoul(const char *cp, char **endp, 
unsigned int base)
/* fall through */
case 'k':
result *= 1024;
-   if ((*endp)[1] == 'i') {
-   if ((*endp)[2] == 'B')
-   (*endp) += 3;
-   else
-   (*endp) += 2;
-   }
+   (*endp)++;
+   if (**endp == 'i')
+   (*endp)++;
+   if (**endp == 'B')
+   (*endp)++;
}
return result;
 }
@@ -116,12 +115,11 @@ unsigned long long ustrtoull(const char *cp, char **endp, 
unsigned int base)
/* fall through */
case 'k':
result *= 1024;
-   if ((*endp)[1] == 'i') {
-   if ((*endp)[2] == 'B')
-   (*endp) += 3;
-   else
-   (*endp) += 2;
-   }
+   (*endp)++;
+   if (**endp == 'i')
+   (*endp)++;
+   if (**endp == 'B')
+   (*endp)++;
}
return result;
 }
-- 
2.17.1

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v7 00/12] SPI-NAND support

2018-09-06 Thread Miquel Raynal
During the last months, Boris Brezillon shared his work to support
serial flashes within Linux. First, he delivered (and merged) a new
layer called spi-mem. He also initiated in Linux MTD subsystem the move
of all 'raw' NAND related code to a raw/ subdirectory, adding at the
same time a NAND core that would be shared with all NAND devices. Then,
he contributed a generic SPI-NAND driver, making use of this NAND core,
as well as some vendor code to drive a few chips.

On top of this work, I made some cleanups in the MTD layer and added an
'mtd' U-Boot command to handle all sort of MTD devices. This should
become the default command instead of having one per flash flavor
('sf', 'nand', 'spi-nand' ?).

The series has been tested on an Ocelot board PCB123 (VSC7514),
featuring a Macronix SPI NAND chip.

TL;DR: the series contains (stripped version since 23 patches have
already been taken):
- Various fixes
- Support for spi-nand devices in mtdparts.
- Generics mtdparts/mtdids parsers.
- A new 'mtd' command.
- A note to set mtdparts command legacy.

To test your SPI-NAND device with U-Boot, you can test someting like:

> setenv mtdparts 'spi-nand0:1m(foo),-(bar)'
> setenv mtdids 'spi-nand0=spi0.0' # spi0.0 is Linux MTD name for this device
> ubi part bar # create a static UBI volume in the bar partition
> mtd list # show the current MTD devices/partitions

Thanks,
Miquèl

Changes since v7:
-
* Added Stefan R-b tags.
* Used tolower() as suggested by Stefan in lib/strto.c.
* Added a mention saying that we continue to abuse the kB suffix in
  lib/strto.c by not making a difference between kB and kiB which both
  mean "* 1024" for us. This has been added in the commit log.
* Fixed various bugs in the mtd command and in the parsers, they should
  be pretty stable now (tested with two MTD devices probed and several
  different partition configurations).
* mtdids is not deprecated at all as opposed at what I wrote in
  v6. U-Boot still uses its own MTD names (being  like nor0
  or spi-nand1) and mtdids is still needed to do the glue.
* Removed a useless patch removing a Kconfig entry I added myself since
  during a rebase someone else also added this symbol.

Changes since v6:
-
* Squashed Boris' fixes about build issues in Travis.
* Merged Stefan Roese's contributions.
* cmd: mtdparts:
  * added fallthrough comments in switch blocks deriving sizes.
  * balanced debug messages to compare freed and allocated partitions.
  * move mtdparts_init() declaration in mtd/partitions.h to be used in
mtd command as well.
  * introduced a "compatibility" function to return what the MTD device
name could be thanks to the mtdids environment variable (which is
useless with the new partitioning logic).
* mtd: mtdpart:
  * reworked the way partitions are created/handled.
* cmd: mtd:
  * implement a partitioning logic that takes the best out of the MTD
layer without re-inventing the wheel. Partitions are all freed
correctly when the value of mtdparts changes.
  * balance get_mtd_device() by put_mtd_device() calls.
  * prevent memory leak by reorganizing the code a bit in do_mtd.
  * do not reconstruct partition list when a partition is already in use
(complain about that instead).
  * add support for the legacy mtdids (not needed anymore if mtdparts
directly uses the MTD device names as in Linux.
* cmd: ubi:
  * clean and simplify the partition handling a bit to make use the best
use of the MTD layer as well and keep the code simple.

Changes since v5:
-
* Included Boris fixup about the build issues.
* Added Rb/Ab tags from Jagan on patchs 20/21.

Changes since v4:
-
* Added Jagan's Acked-by tags to every patch related to the
  SPI-mem/SPI-NAND addition.
* Rebased on top of master.

Changes since v3:
-
* Fixed the debug messages in spi-mem to print either Rx or Tx data.
* Fixed a Kconfig error that prevented to build mtdparts with plain
  defconfig.
* Fixed a compilation error due to the above error that prevented one
  file to be compiled.
* Adapted the mtd command to probe MTD partitions also.
* Declared mtd_probe_devices() in a header so mtdparts or UBI could
  use it too (to probe all devices and MTD partitions in a clean way).
* As I worked on mtdparts, I found annoying and completely useless the
  fact that we need to prefix the environment variable with
  "mtdparts=". Canceled this obligation.
* Added one patch to allow spi-nand devices to be recognized by mtdparts
  (this is purely useless but needed to be done in order to use this
  command).
* Removed useless definitions of MTD device types in UBI code.
* Wrote a generic mtdparts environment variable parser, used by the mtd
  command.
* Used the mtd_probe_devices() function from get_mtd_info() in
  cmd/mtdparts.c to be sure the desired partition really does not exist
  (otherwise it will be probed and then found).

Changes since v2:
-

[U-Boot] [PATCH v7 01/12] lib: strto: parse all lowercase metric prefixes in ustrtoul[l]

2018-09-06 Thread Miquel Raynal
Both ustrtoul and ustrtoull interpret 1k but not 1m or 1g. Even if the
SI symbols for Mega and Giga are 'M' and 'G', certain entries of
eg. mtdparts also use (wrongly) the metric prefix 'm' and 'g'.

I do not see how parsing lowercase prefixes could break anything, so
parse them like their uppercase counterpart.

Also, even though kiB is not equal to kB in general, lets not change
U-Boot behavior and always use kiB and kB (same applies for MiB vs. MB
and GiB vs. GB) as a representation for 1024 instead of 1000.

Signed-off-by: Miquel Raynal 
Reviewed-by: Stefan Roese 
---
 lib/strto.c | 14 ++
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/lib/strto.c b/lib/strto.c
index 7f6076909a..b7fc31d6e5 100644
--- a/lib/strto.c
+++ b/lib/strto.c
@@ -85,14 +85,13 @@ long simple_strtol(const char *cp, char **endp, unsigned 
int base)
 unsigned long ustrtoul(const char *cp, char **endp, unsigned int base)
 {
unsigned long result = simple_strtoul(cp, endp, base);
-   switch (**endp) {
-   case 'G':
+   switch (tolower(**endp)) {
+   case 'g':
result *= 1024;
/* fall through */
-   case 'M':
+   case 'm':
result *= 1024;
/* fall through */
-   case 'K':
case 'k':
result *= 1024;
if ((*endp)[1] == 'i') {
@@ -108,14 +107,13 @@ unsigned long ustrtoul(const char *cp, char **endp, 
unsigned int base)
 unsigned long long ustrtoull(const char *cp, char **endp, unsigned int base)
 {
unsigned long long result = simple_strtoull(cp, endp, base);
-   switch (**endp) {
-   case 'G':
+   switch (tolower(**endp)) {
+   case 'g':
result *= 1024;
/* fall through */
-   case 'M':
+   case 'm':
result *= 1024;
/* fall through */
-   case 'K':
case 'k':
result *= 1024;
if ((*endp)[1] == 'i') {
-- 
2.17.1

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot