Re: [U-Boot] [PATCH] efi_loader: don't allocate unusable RAM

2018-08-01 Thread Heinrich Schuchardt
On 08/01/2018 06:17 PM, Stephen Warren wrote:
> On 08/01/2018 12:07 AM, Heinrich Schuchardt wrote:
>> On 07/31/2018 09:44 PM, Stephen Warren wrote:
>>> From: Stephen Warren 
>>>
>>> Some boards define a maximum usable RAM top that's more restrictive than
>>> the ranges defined by U-Boot's memory bank definitions[1]. In this case,
>>> the unusable RAM isn't mapped in the page tables, and so the EFI code
>>> must
>>> not attempt to allocate RAM from outside the usable regions. Fix
>>> efi_find_free_memory() to detect when max_addr is unconstrained or
>>> out of
>>> range, and substitue a valid value.
>>>
>>
>> In this case the board has to call efi_add_memory_map() to mark the
>> reserved region (cf. board/raspberrypi/rpi/rpi.c) or have to mark the
>> memory region as reserved in the device tree (see
>> efi_carve_out_dt_rsv()).
>>
>> Please, check if the tegra boards with which you had problems do so.
> 
> I don't think this makes sense; memory should be managed the same way
> within U-Boot no matter which part of U-Boot is consuming that memory.
> Memory regions are currently represented by the content of the memory
> bank definitions and gd->ram_top. Having different parts of the code
> define legal RAM usage in different ways is horribly inconsistent.

Memory banks and gd->top together cannot reflect unusable memory regions
in the middle of the RAM area.

To be consistent reflect all information in the device tree and
calculate gd->ram_top from the device tree information.

> 
> At this point, I think the best thing is to revert aa909462d018
> "efi_loader: efi_allocate_pages is too restrictive" since it causes a
> regression on Jetson TX1, and we can work out the correct way to fix all
> this once the system is working again.
> 

The situation before the patch was really buggy. It is sufficient if you
get the Jetson device tree right.

Best regards

Heinrcih

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


[U-Boot] [PATCH 1/2] fsl/mc: Limit the ethernet name to ETH_NAME_LEN

2018-08-01 Thread Pankaj Bansal
The ethernet name should be within the ETH_NAME_LEN, as this
is the buffer space allocated to ethernet name.

Otherwise, this causes buffer overflow.

Reported-by: Ioana Ciornei 
Signed-off-by: Pankaj Bansal 
---
 drivers/net/fsl-mc/mc.c   | 6 +++---
 drivers/net/ldpaa_eth/ldpaa_eth.c | 4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/net/fsl-mc/mc.c b/drivers/net/fsl-mc/mc.c
index e2341a2e3c..33e4bf23e9 100644
--- a/drivers/net/fsl-mc/mc.c
+++ b/drivers/net/fsl-mc/mc.c
@@ -322,7 +322,7 @@ static int mc_fixup_dpc_mac_addr(void *blob, int dpmac_id,
 static int mc_fixup_mac_addrs(void *blob, enum mc_fixup_type type)
 {
int i, err = 0, ret = 0;
-   char ethname[10];
+   char ethname[ETH_NAME_LEN];
struct eth_device *eth_dev;
 
for (i = WRIOP1_DPMAC1; i < NUM_WRIOP_PORTS; i++) {
@@ -330,8 +330,8 @@ static int mc_fixup_mac_addrs(void *blob, enum 
mc_fixup_type type)
if (wriop_is_enabled_dpmac(i) != 1)
continue;
 
-   sprintf(ethname, "DPMAC%d@%s", i,
-   phy_interface_strings[wriop_get_enet_if(i)]);
+   snprintf(ethname, ETH_NAME_LEN, "DPMAC%d@%s", i,
+phy_interface_strings[wriop_get_enet_if(i)]);
 
eth_dev = eth_get_dev_by_name(ethname);
if (eth_dev == NULL)
diff --git a/drivers/net/ldpaa_eth/ldpaa_eth.c 
b/drivers/net/ldpaa_eth/ldpaa_eth.c
index 4fc5a0626b..fe1c03e9e4 100644
--- a/drivers/net/ldpaa_eth/ldpaa_eth.c
+++ b/drivers/net/ldpaa_eth/ldpaa_eth.c
@@ -1028,8 +1028,8 @@ static int ldpaa_eth_netdev_init(struct eth_device 
*net_dev,
int err;
struct ldpaa_eth_priv *priv = (struct ldpaa_eth_priv *)net_dev->priv;
 
-   sprintf(net_dev->name, "DPMAC%d@%s", priv->dpmac_id,
-   phy_interface_strings[enet_if]);
+   snprintf(net_dev->name, ETH_NAME_LEN, "DPMAC%d@%s", priv->dpmac_id,
+phy_interface_strings[enet_if]);
 
net_dev->iobase = 0;
net_dev->init = ldpaa_eth_open;
-- 
2.17.1

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


[U-Boot] [PATCH 2/2] net: Increase ethernet name string size to 20 chars

2018-08-01 Thread Pankaj Bansal
The 16 char ethernet name size is inadequate to hold the name of ethernet
name "DPMAC17@rgmii-id", which is a valid name in LX2160AQDS/LX2160ARDB.

Therefore, increase the name string size to 20 chars.

Reported-by: Ioana Ciornei 
Suggested-by: Ioana Ciocoi Radulescu 
Signed-off-by: Pankaj Bansal 
---
 include/net.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/net.h b/include/net.h
index 62f82c4dca..2b2deb5aae 100644
--- a/include/net.h
+++ b/include/net.h
@@ -164,7 +164,7 @@ void eth_halt_state_only(void); /* Set passive state */
 
 #ifndef CONFIG_DM_ETH
 struct eth_device {
-#define ETH_NAME_LEN 16
+#define ETH_NAME_LEN 20
char name[ETH_NAME_LEN];
unsigned char enetaddr[ARP_HLEN];
phys_addr_t iobase;
-- 
2.17.1

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


[U-Boot] [PATCH 0/2] Ethernet name length changes

2018-08-01 Thread Pankaj Bansal
The ethernet name should be within the ETH_NAME_LEN, as this
is the buffer space allocated to ethernet name.

Otherwise, this causes buffer overflow.

At the same time the 16 char ethernet name size is inadequate to hold the
name of ethernet "DPMAC17@rgmii-id", which is a valid name in upcoming
LX2160AQDS/LX2160ARDB boards.

These patches try to solve the above two issues:
1. first patch honors the limit imposed by ETH_NAME_LEN on ethernet name
2. second patch increases this limit to accommodate the requirements of
   LX2160AQDS/LX2160ARDB

Cc: Varun Sethi 

Pankaj Bansal (2):
  fsl/mc: Limit the ethernet name to ETH_NAME_LEN
  net: Increase ethernet name string size to 20 chars

 drivers/net/fsl-mc/mc.c   | 6 +++---
 drivers/net/ldpaa_eth/ldpaa_eth.c | 4 ++--
 include/net.h | 2 +-
 3 files changed, 6 insertions(+), 6 deletions(-)

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


Re: [U-Boot] [PATCH] ARM: tegra: align carveout size

2018-08-01 Thread Tom Rini
On Wed, Aug 01, 2018 at 11:52:36PM +, Tom Warren wrote:

> I can add this to my PR list (but probably won't get one out until tomorrow 
> morning), or:
> 
> Acked-by: Tom Warren 
> 
> If that'll get it in sooner.

Applied, thanks!

> 
> Tom
> 
> -Original Message-
> From: Tom Rini  
> Sent: Wednesday, August 1, 2018 4:47 PM
> To: Stephen Warren 
> Cc: Tom Warren ; u-boot@lists.denx.de; Simon Glass 
> ; Stephen Warren ; Mark Kettenis 
> ; Alexander Graf 
> Subject: Re: [U-Boot] [PATCH] ARM: tegra: align carveout size
> 
> On Wed, Aug 01, 2018 at 05:26:10PM -0600, Stephen Warren wrote:
> > On 07/31/2018 12:38 PM, Stephen Warren wrote:
> > >From: Stephen Warren 
> > >
> > >Align the size of the carveout region to 2M. This ensures that the 
> > >size can be accurately represented by an LPAE page table that uses 
> > >sections.
> > >
> > >This solves a bug (hang at boot time soon after printing the DRAM 
> > >size) that only shows up when the following two commits are merged 
> > >together:
> > >d32e86bde8a3 ARM: HYP/non-sec: enable ARMV7_LPAE if HYP mode is 
> > >supported
> > >6e584e633d10 ARM: tegra: avoid using secure carveout RAM
> > >
> > >Cc: Mark Kettenis 
> > >Cc: Alexander Graf 
> > >Signed-off-by: Stephen Warren 
> > >---
> > >This should be applied quickly since it fixes a regression that 
> > >causes all boots to fail, which in turn causes test/py to reset and 
> > >"reflash" the target board for each test, which causes the test to take 
> > >eons.
> > 
> > Could we apply this please? My Jenkins system will love you because of 
> > it:-)
> 
> I'm looking for one more person to Ack this, thanks!
> 
> --
> Tom
> ---
> This email message is for the sole use of the intended recipient(s) and may 
> contain
> confidential information.  Any unauthorized review, use, disclosure or 
> distribution
> is prohibited.  If you are not the intended recipient, please contact the 
> sender by
> reply email and destroy all copies of the original message.
> ---
> ___
> U-Boot mailing list
> U-Boot@lists.denx.de
> https://lists.denx.de/listinfo/u-boot

-- 
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: tegra: align carveout size

2018-08-01 Thread Tom Warren
I can add this to my PR list (but probably won't get one out until tomorrow 
morning), or:

Acked-by: Tom Warren 

If that'll get it in sooner.

Tom

-Original Message-
From: Tom Rini  
Sent: Wednesday, August 1, 2018 4:47 PM
To: Stephen Warren 
Cc: Tom Warren ; u-boot@lists.denx.de; Simon Glass 
; Stephen Warren ; Mark Kettenis 
; Alexander Graf 
Subject: Re: [U-Boot] [PATCH] ARM: tegra: align carveout size

On Wed, Aug 01, 2018 at 05:26:10PM -0600, Stephen Warren wrote:
> On 07/31/2018 12:38 PM, Stephen Warren wrote:
> >From: Stephen Warren 
> >
> >Align the size of the carveout region to 2M. This ensures that the 
> >size can be accurately represented by an LPAE page table that uses sections.
> >
> >This solves a bug (hang at boot time soon after printing the DRAM 
> >size) that only shows up when the following two commits are merged together:
> >d32e86bde8a3 ARM: HYP/non-sec: enable ARMV7_LPAE if HYP mode is 
> >supported
> >6e584e633d10 ARM: tegra: avoid using secure carveout RAM
> >
> >Cc: Mark Kettenis 
> >Cc: Alexander Graf 
> >Signed-off-by: Stephen Warren 
> >---
> >This should be applied quickly since it fixes a regression that 
> >causes all boots to fail, which in turn causes test/py to reset and 
> >"reflash" the target board for each test, which causes the test to take eons.
> 
> Could we apply this please? My Jenkins system will love you because of 
> it:-)

I'm looking for one more person to Ack this, thanks!

--
Tom
---
This email message is for the sole use of the intended recipient(s) and may 
contain
confidential information.  Any unauthorized review, use, disclosure or 
distribution
is prohibited.  If you are not the intended recipient, please contact the 
sender by
reply email and destroy all copies of the original message.
---
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH] ARM: tegra: align carveout size

2018-08-01 Thread Tom Rini
On Wed, Aug 01, 2018 at 05:26:10PM -0600, Stephen Warren wrote:
> On 07/31/2018 12:38 PM, Stephen Warren wrote:
> >From: Stephen Warren 
> >
> >Align the size of the carveout region to 2M. This ensures that the size
> >can be accurately represented by an LPAE page table that uses sections.
> >
> >This solves a bug (hang at boot time soon after printing the DRAM size)
> >that only shows up when the following two commits are merged together:
> >d32e86bde8a3 ARM: HYP/non-sec: enable ARMV7_LPAE if HYP mode is supported
> >6e584e633d10 ARM: tegra: avoid using secure carveout RAM
> >
> >Cc: Mark Kettenis 
> >Cc: Alexander Graf 
> >Signed-off-by: Stephen Warren 
> >---
> >This should be applied quickly since it fixes a regression that causes
> >all boots to fail, which in turn causes test/py to reset and "reflash" the
> >target board for each test, which causes the test to take eons.
> 
> Could we apply this please? My Jenkins system will love you because of it:-)

I'm looking for one more person to Ack this, 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: tegra: align carveout size

2018-08-01 Thread Stephen Warren

On 07/31/2018 12:38 PM, Stephen Warren wrote:

From: Stephen Warren 

Align the size of the carveout region to 2M. This ensures that the size
can be accurately represented by an LPAE page table that uses sections.

This solves a bug (hang at boot time soon after printing the DRAM size)
that only shows up when the following two commits are merged together:
d32e86bde8a3 ARM: HYP/non-sec: enable ARMV7_LPAE if HYP mode is supported
6e584e633d10 ARM: tegra: avoid using secure carveout RAM

Cc: Mark Kettenis 
Cc: Alexander Graf 
Signed-off-by: Stephen Warren 
---
This should be applied quickly since it fixes a regression that causes
all boots to fail, which in turn causes test/py to reset and "reflash" the
target board for each test, which causes the test to take eons.


Could we apply this please? My Jenkins system will love you because of it:-)
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v3 11/13] misc: Sort Makefile entries

2018-08-01 Thread Anatolij Gustschin
On Tue, 31 Jul 2018 12:01:08 +0200
Mario Six mario@gdsys.cc wrote:

> Makefile entries should be sorted.
> 
> Signed-off-by: Mario Six 

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


Re: [U-Boot] [PATCH v3 10/13] test: regmap: Add test for regmap_{set, get}

2018-08-01 Thread Anatolij Gustschin
On Tue, 31 Jul 2018 12:01:07 +0200
Mario Six mario@gdsys.cc wrote:

> Add test for regmap_{set,get} functions.
> 
> Signed-off-by: Mario Six 

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


Re: [U-Boot] [PATCH v3 09/13] regmap: Define regmap_{get,set}

2018-08-01 Thread Anatolij Gustschin
On Tue, 31 Jul 2018 12:01:06 +0200
Mario Six mario@gdsys.cc wrote:

> It would be convenient if one could use the regmap API in conjunction
> with register maps defined as structs (i.e. structs that directly mirror
> the memory layout of the registers in question). A similar approach was
> planned with the regmap_write32/regmap_read32 macros, but was never
> used.
> 
> Hence, implement regmap_set/regmap_range_set and
> regmap_get/regmap_range_get macros, which, given a register map, a
> struct describing the layout of the register map, and a member name
> automatically produce regmap_read/regmap_write calls that access the
> specified member in the register map.
> 
> Signed-off-by: Mario Six 
> Reviewed-by: Simon Glass 

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


Re: [U-Boot] [PATCH v3 08/13] regmap: Support reading from specific range

2018-08-01 Thread Anatolij Gustschin
On Tue, 31 Jul 2018 12:01:05 +0200
Mario Six mario@gdsys.cc wrote:

> It is useful to be able to treat the different ranges of a regmap
> separately to be able to use distinct offset for them, but this is
> currently not implemented in the regmap API.
> 
> To preserve backwards compatibility, add regmap_read_range and
> regmap_write_range functions that take an additional parameter
> 'range_num' that identifies the range to operate on.
> 
> Reviewed-by: Simon Glass 
> Signed-off-by: Mario Six 

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


Re: [U-Boot] [PATCH v3 07/13] regmap: Add raw read/write functions

2018-08-01 Thread Anatolij Gustschin
Hi Mario,

On Tue, 31 Jul 2018 12:01:04 +0200
Mario Six mario@gdsys.cc wrote:

> The regmap functions currently assume that all register map accesses
> have a data width of 32 bits, but there are maps that have different
> widths.
> 
> To rectify this, implement the regmap_raw_read and regmap_raw_write
> functions from the Linux kernel API that specify the width of a desired
> read or write operation on a regmap.
> 
> Implement the regmap_read and regmap_write functions using these raw
> functions in a backwards-compatible manner.
> 
> Signed-off-by: Mario Six 

Reviewed-by: Anatolij Gustschin 

Please see some comments below.

...
> +int regmap_raw_read(struct regmap *map, uint offset, void *valp, size_t 
> val_len)
> +{
> + void *ptr;
> +
> + ptr = map_physmem(map->ranges[0] + offset, val_len, MAP_NOCACHE);

shouldn't this be

   ptr = map_physmem(map->ranges[0].start + offset, val_len, MAP_NOCACHE);
?

It works as is, but it is better to be explicit about the start address.

...
> +int regmap_raw_write(struct regmap *map, uint offset, const void *val,
> +  size_t val_len)
> +{
> + void *ptr;
> +
> + ptr = map_physmem(map->ranges[0] + offset, val_len, MAP_NOCACHE);

map->ranges[0].start + offset ?

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


Re: [U-Boot] [PATCH v3 06/13] regmap: Add error output

2018-08-01 Thread Anatolij Gustschin
On Tue, 31 Jul 2018 12:01:03 +0200
Mario Six mario@gdsys.cc wrote:

> Add some debug output in cases where the initialization of a regmap
> fails.
> 
> Signed-off-by: Mario Six 

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


Re: [U-Boot] [PATCH v3 05/13] regmap: Introduce init_range

2018-08-01 Thread Anatolij Gustschin
On Tue, 31 Jul 2018 12:01:02 +0200
Mario Six mario@gdsys.cc wrote:

> Both fdtdec_get_addr_size_fixed and of_address_to_resource can fail with
> an error, which is not currently checked during regmap initialization.
> 
> Since the indentation depth is already quite deep, extract a new
> 'init_range' method to do the initialization.
> 
> Signed-off-by: Mario Six 

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


Re: [U-Boot] [PATCH v3 04/13] regmap: Improve error handling

2018-08-01 Thread Anatolij Gustschin
On Tue, 31 Jul 2018 12:01:01 +0200
Mario Six mario@gdsys.cc wrote:

> ofnode_read_simple_addr_cells may fail and return a negative error code.
> Check for this when initializing regmaps.
> 
> Also check if both_len is zero, since this is perfectly possible, and
> would lead to a division-by-zero further down the line.
> 
> Signed-off-by: Mario Six 

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


Re: [U-Boot] [PATCH v3 02/13] regmap: Fix documentation

2018-08-01 Thread Anatolij Gustschin
On Tue, 31 Jul 2018 12:00:59 +0200
Mario Six mario@gdsys.cc wrote:

> The documentation in regmap.h is not in kernel-doc format. Correct this.
> 
> Signed-off-by: Mario Six 

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


Re: [U-Boot] [PATCH v3 01/13] test: regmap: Increase size of syscon0 memory

2018-08-01 Thread Anatolij Gustschin
On Tue, 31 Jul 2018 12:00:58 +0200
Mario Six mario@gdsys.cc wrote:

> The upcoming changes to the regmap interface will contain a proper check
> for plausibility when reading/writing from/to a register map. To still
> have the current tests pass, increase the size of the memory region for
> the syscon0 device, since one of the tests reads and writes beyond this
> range.
> 
> Signed-off-by: Mario Six 

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


Re: [U-Boot] [PATCH v3 03/13] regmap: Add documentation

2018-08-01 Thread Anatolij Gustschin
On Tue, 31 Jul 2018 12:01:00 +0200
Mario Six mario@gdsys.cc wrote:

> Document the regmap_alloc() function.
> 
> Signed-off-by: Mario Six 

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


[U-Boot] [PATCH v2 07/29] binman: Add a new 'image-pos' property

2018-08-01 Thread Simon Glass
At present each entry has an offset within its parent section. This is
useful for figuring out how entries relate to one another. However it
is sometimes necessary to locate an entry within an image, regardless
of which sections it is nested inside.

Add a new 'image-pos' property to provide this information. Also add
some documentation for the -u option binman provides, which updates the
device tree with final entry information.

Since the image position is a better symbol to use for the position of
U-Boot as obtained by SPL, update the SPL symbols to use this instead of
offset, which might be incorrect if hierarchical sections are used.

Signed-off-by: Simon Glass 
---

Changes in v2:
- Update U-Boot symbols to use image_pos instead of offset
- Update tests to include test coverage of image_pos

 common/spl/spl.c   |   4 ++--
 common/spl/spl_ram.c   |   2 +-
 include/spl.h  |   2 +-
 tools/binman/README|  22 --
 tools/binman/bsection.py   |  10 +-
 tools/binman/control.py|   1 +
 tools/binman/entry.py  |  12 +++-
 tools/binman/etype/section.py  |   4 
 tools/binman/ftest.py  |   9 -
 tools/binman/image.py  |   3 +++
 tools/binman/test/u_boot_binman_syms   | Bin 4916 -> 4924 bytes
 tools/binman/test/u_boot_binman_syms.c |   2 +-
 12 files changed, 61 insertions(+), 10 deletions(-)

diff --git a/common/spl/spl.c b/common/spl/spl.c
index b959aa02549..eda84d0c74c 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -34,7 +34,7 @@ DECLARE_GLOBAL_DATA_PTR;
 u32 *boot_params_ptr = NULL;
 
 /* See spl.h for information about this */
-binman_sym_declare(ulong, u_boot_any, offset);
+binman_sym_declare(ulong, u_boot_any, image_pos);
 
 /* Define board data structure */
 static bd_t bdata __attribute__ ((section(".data")));
@@ -129,7 +129,7 @@ __weak void spl_board_prepare_for_boot(void)
 
 void spl_set_header_raw_uboot(struct spl_image_info *spl_image)
 {
-   ulong u_boot_pos = binman_sym(ulong, u_boot_any, offset);
+   ulong u_boot_pos = binman_sym(ulong, u_boot_any, image_pos);
 
spl_image->size = CONFIG_SYS_MONITOR_LEN;
 
diff --git a/common/spl/spl_ram.c b/common/spl/spl_ram.c
index 6000f495ccd..e594beaeaa3 100644
--- a/common/spl/spl_ram.c
+++ b/common/spl/spl_ram.c
@@ -49,7 +49,7 @@ static int spl_ram_load_image(struct spl_image_info 
*spl_image,
load.read = spl_ram_load_read;
spl_load_simple_fit(spl_image, , 0, header);
} else {
-   ulong u_boot_pos = binman_sym(ulong, u_boot_any, offset);
+   ulong u_boot_pos = binman_sym(ulong, u_boot_any, image_pos);
 
debug("Legacy image\n");
/*
diff --git a/include/spl.h b/include/spl.h
index 8c5523083b2..7fad62c043e 100644
--- a/include/spl.h
+++ b/include/spl.h
@@ -60,7 +60,7 @@ struct spl_load_info {
  * image is found. For * example if u-boot.img is used we don't check that
  * spl_parse_image_header() can parse a valid header.
  */
-binman_sym_extern(ulong, u_boot_any, offset);
+binman_sym_extern(ulong, u_boot_any, image_pos);
 
 /**
  * spl_load_simple_fit() - Loads a fit image from a device.
diff --git a/tools/binman/README b/tools/binman/README
index 4b13776ffad..df88819a1c3 100644
--- a/tools/binman/README
+++ b/tools/binman/README
@@ -324,6 +324,12 @@ offset-unset:
property is present, binman will give an error if another entry does
not set the offset (with the GetOffsets() method).
 
+image-pos:
+   This cannot be set on entry (or at least it is ignored if it is), but
+   with the -u option, binman will set it to the absolute image position
+   for each entry. This makes it easy to find out exactly where the entry
+   ended up in the image, regardless of parent sections, etc.
+
 
 The attributes supported for images are described below. Several are similar
 to those for entries.
@@ -550,8 +556,8 @@ the 'warning' line in scripts/Makefile.lib to see what it 
has found:
# u_boot_dtsi_options_debug = $(u_boot_dtsi_options_raw)
 
 
-Access to binman entry offsets at run time
---
+Access to binman entry offsets at run time (symbols)
+
 
 Binman assembles images and determines where each entry is placed in the image.
 This information may be useful to U-Boot at run time. For example, in SPL it
@@ -577,6 +583,18 @@ At present this feature is only supported in SPL. In 
principle it is possible
 to fill in such symbols in U-Boot proper, as well.
 
 
+Access to binman entry offsets at run time (fdt)
+
+
+Binman can update the U-Boot FDT to include the final position and size of
+each entry in the images it processes. The option to enable this is -u and it
+causes binman to 

[U-Boot] [PATCH v2 02/29] binman: Rename 'position' to 'offset'

2018-08-01 Thread Simon Glass
After some thought, I believe there is an unfortunate naming flaw in
binman. Entries have a position and size, but now that we support
hierarchical sections it is unclear whether a position should be an
absolute position within the image, or a relative position within its
parent section.

At present 'position' actually means the relative position. This indicates
a need for an 'image position' for code that wants to find the location of
an entry without having to do calculations back through parents to
discover this image position.

A better name for the current 'position' or 'pos' is 'offset'. It is not
always an absolute position, but it is always an offset from its parent
offset.

It is unfortunate to rename this concept now, 18 months after binman was
introduced. However I believe it is the right thing to do. The impact is
mostly limited to binman itself and a few changes to in-tree users to
binman:

   tegra
   sunxi
   x86

The change makes old binman definitions (e.g. downstream or out-of-tree)
incompatible if they use the 'pos = <...>' property. Later work will
adjust binman to generate an error when it is used.

Signed-off-by: Simon Glass 
---

Changes in v2:
- Adjust symbols in the U-Boot tree also

 arch/arm/dts/sunxi-u-boot.dtsi|   2 +-
 arch/arm/dts/tegra-u-boot.dtsi|   6 +-
 arch/x86/dts/u-boot.dtsi  |  24 ++---
 common/spl/spl.c  |   4 +-
 common/spl/spl_ram.c  |   2 +-
 include/spl.h |   2 +-
 tools/binman/README   |  79 
 tools/binman/bsection.py  |  88 +-
 tools/binman/cmdline.py   |   2 +-
 tools/binman/control.py   |   4 +-
 tools/binman/elf.py   |   6 +-
 tools/binman/entry.py |  73 ---
 tools/binman/etype/_testing.py|   4 +-
 tools/binman/etype/intel_descriptor.py|   8 +-
 tools/binman/etype/section.py |  14 +--
 tools/binman/etype/u_boot_dtb_with_ucode.py   |   4 +-
 tools/binman/etype/u_boot_ucode.py|   4 +-
 tools/binman/etype/u_boot_with_ucode_ptr.py   |  35 +++
 tools/binman/ftest.py |  85 +
 tools/binman/image.py |  12 +--
 tools/binman/test/08_pack.dts |   2 +-
 tools/binman/test/12_pack_inv_align.dts   |   2 +-
 tools/binman/test/14_pack_overlap.dts |   2 +-
 tools/binman/test/21_image_pad.dts|   2 +-
 tools/binman/test/24_sorted.dts   |   6 +-
 tools/binman/test/25_pack_zero_size.dts   |   2 +-
 tools/binman/test/27_pack_4gb_no_size.dts |   6 +-
 tools/binman/test/28_pack_4gb_outside.dts |   6 +-
 tools/binman/test/29_x86-rom.dts  |   6 +-
 tools/binman/test/30_x86-rom-me-no-desc.dts   |   4 +-
 tools/binman/test/31_x86-rom-me.dts   |   4 +-
 tools/binman/test/34_x86_ucode.dts|   2 +-
 tools/binman/test/35_x86_single_ucode.dts |   2 +-
 tools/binman/test/37_x86_no_ucode.dts |   2 +-
 .../binman/test/38_x86_ucode_missing_node.dts |   2 +-
 .../test/39_x86_ucode_missing_node2.dts   |   2 +-
 .../binman/test/40_x86_ucode_not_in_image.dts |   2 +-
 tools/binman/test/44_x86_optional_ucode.dts   |   2 +-
 tools/binman/test/45_prop_test.dts|   4 +-
 tools/binman/test/49_x86_ucode_spl.dts|   2 +-
 tools/binman/test/53_symbols.dts  |   2 +-
 .../test/58_x86_ucode_spl_needs_retry.dts |   2 +-
 tools/binman/test/u_boot_binman_syms  | Bin 4921 -> 4916 bytes
 tools/binman/test/u_boot_binman_syms.c|   6 +-
 44 files changed, 267 insertions(+), 263 deletions(-)

diff --git a/arch/arm/dts/sunxi-u-boot.dtsi b/arch/arm/dts/sunxi-u-boot.dtsi
index 5adfd9bca2e..8a9f2a6417d 100644
--- a/arch/arm/dts/sunxi-u-boot.dtsi
+++ b/arch/arm/dts/sunxi-u-boot.dtsi
@@ -8,7 +8,7 @@
filename = "spl/sunxi-spl.bin";
};
u-boot-img {
-   pos = ;
+   offset = ;
};
};
 };
diff --git a/arch/arm/dts/tegra-u-boot.dtsi b/arch/arm/dts/tegra-u-boot.dtsi
index 4f692ee9757..fe19619919e 100644
--- a/arch/arm/dts/tegra-u-boot.dtsi
+++ b/arch/arm/dts/tegra-u-boot.dtsi
@@ -15,7 +15,7 @@
u-boot-spl {
};
u-boot {
-   pos = <(U_BOOT_OFFSET)>;
+   offset = <(U_BOOT_OFFSET)>;
};
};
 
@@ -26,7 +26,7 @@
u-boot-spl {
};
u-boot {
-   pos = <(U_BOOT_OFFSET)>;
+   offset = <(U_BOOT_OFFSET)>;
};
};
 
@@ 

Re: [U-Boot] Problem booting uImage with u-boot

2018-08-01 Thread Michael Nazzareno Trimarchi
Hi

On Wed, Aug 1, 2018 at 9:08 PM, Saeed Abdoli  wrote:
> Hi Michael
> Thank you for your quick response.
> Can you please tell me how to solve the problem. Where can I change the
> relocation address, in kernel config or somewhere else?
>

If you not top-post and keep it posted it's better. What is your its
file for generate fit-image?

Michael

> Regards
> Saeed
>
> On Wed, 1 Aug 2018, 11:25 p.m. Michael Nazzareno Trimarchi,
>  wrote:
>>
>> Hi
>>
>> On Wed, Aug 1, 2018 at 8:47 PM, Saeed Abdoli  wrote:
>> > Hello
>> > I am working on a project in which I need to boot a customized linux
>> > kernel
>> > on my board. The board components are stm32f429 processor, 8Mbyte SDRAM
>> > and
>> > 32Mbyte flash memory which are connected to the processer via FMC. I've
>> > booted u-boot on the internal flash of the processor and I've installed
>> > the
>> > linux image (networking.uImage) which is provided by EMCRAFT using TFTP
>> > successfully. Then I tried to build my own linux image by editing the
>> > example provided by EMCRAFT (rootfs). But when I build the image and try
>> > to
>> > boot it, the processor can not boot the image and it resets
>> > unexpectedly.
>> > This is the message u-boot shows when trying to boot the image:
>> > ## Booting kernel from Legacy Image at d0007fc0 ...
>> >Image Name:   Linux-4.2.0
>> >Image Type:   ARM Linux Multi-File Image (uncompressed)
>> >Data Size:3945195 Bytes =  3.8 MB
>> >Load Address: d0008000
>> >Entry Point:  d0008001
>> >Contents:
>> >   Image 0: 3932720 Bytes =  3.8 MB
>> >   Image 1: 12463 Bytes = 12.2 kB
>> >Verifying Checksum ... OK
>> > ## Flattened Device Tree from multi component Image at D0007FC0
>> >Booting using the fdt at 0xd03c823c
>> >Loading Multi-File Image ... OK
>> > OK
>> > WARNING: legacy format multi component image overwritten
>> >Loading Device Tree to d07f9000, end d07ff0ae ... OK
>> >
>> > Starting kernel ...
>> >
>> > After this message the processor resets.
>> > Can you please tell me what is wrong?
>> >
>>
>> > WARNING: legacy format multi component image overwritten
>> >Loading Device Tree to d07f9000, end d07ff0ae ... OK
>>
>> Problem look like relocation address of fit image
>>
>> Michael
>>
>> > Regards
>> > ___
>> > U-Boot mailing list
>> > U-Boot@lists.denx.de
>> > https://lists.denx.de/listinfo/u-boot
>>
>>
>>
>> --
>> | Michael Nazzareno Trimarchi Amarula Solutions BV |
>> | COO  -  Founder  Cruquiuskade 47 |
>> | +31(0)851119172 Amsterdam 1018 AM NL |
>> |  [`as] http://www.amarulasolutions.com   |



-- 
| Michael Nazzareno Trimarchi Amarula Solutions BV |
| COO  -  Founder  Cruquiuskade 47 |
| +31(0)851119172 Amsterdam 1018 AM NL |
|  [`as] http://www.amarulasolutions.com   |
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] Please pull u-boot-dm

2018-08-01 Thread Tom Rini
On Wed, Aug 01, 2018 at 12:50:57PM -0600, Simon Glass wrote:
> Hi Tom.
> 
> On 31 July 2018 at 06:42, Tom Rini  wrote:
> >
> > On Mon, Jul 30, 2018 at 02:10:44PM -0600, Simon Glass wrote:
> >
> > > Hi Tom,
> > >
> > > Here are the binman changes, with the rename of the 'pos' property to 
> > > 'offset'.
> > >
> > >
> > > The following changes since commit 
> > > 0e8a8a311020d317fcfcf594e8e3fb1598134593:
> > >
> > >   Merge git://git.denx.de/u-boot-fsl-qoriq (2018-07-27 13:09:30 -0400)
> > >
> > > are available in the Git repository at:
> > >
> > >   git://git.denx.de/u-boot-dm.git
> > >
> > > for you to fetch changes up to e824c2422356cc9656d714335fc9b7907c3dace7:
> > >
> > >   binman: Adjust _GetPropTree() parameters (2018-07-30 10:28:07 -0600)
> > >
> >
> > NAK, this seems to be introducing some failures:
> > binman: Section '/binman/image1': Symbol '_binman_u_boot_any_prop_pos'
> >in entry '/binman/image1/u-boot-spl': No such property 'pos'
> > /home/trini/work/u-boot/u-boot/Makefile:1240: recipe for target 
> > 'u-boot-tegra.bin' failed
> > make[1]: *** [u-boot-tegra.bin] Error 1
> > make[1]: Leaving directory '/tmp/colibri_t30'
> > Makefile:148: recipe for target 'sub-make' failed
> > make: *** [sub-make] Error 2
> 
> I'm sorry about that. I saw the failure and thought it was device tree
> stuff. Oops.
> 
> Do you know what is happening with all the device-tree warnings? Are
> they slowing going away?

They're staying about constant.  I looked before, and I guess these are
also warnings in upstream Linux.  In some cases a re-sync helps.

-- 
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] Problem booting uImage with u-boot

2018-08-01 Thread Michael Nazzareno Trimarchi
Hi

On Wed, Aug 1, 2018 at 8:47 PM, Saeed Abdoli  wrote:
> Hello
> I am working on a project in which I need to boot a customized linux kernel
> on my board. The board components are stm32f429 processor, 8Mbyte SDRAM and
> 32Mbyte flash memory which are connected to the processer via FMC. I've
> booted u-boot on the internal flash of the processor and I've installed the
> linux image (networking.uImage) which is provided by EMCRAFT using TFTP
> successfully. Then I tried to build my own linux image by editing the
> example provided by EMCRAFT (rootfs). But when I build the image and try to
> boot it, the processor can not boot the image and it resets unexpectedly.
> This is the message u-boot shows when trying to boot the image:
> ## Booting kernel from Legacy Image at d0007fc0 ...
>Image Name:   Linux-4.2.0
>Image Type:   ARM Linux Multi-File Image (uncompressed)
>Data Size:3945195 Bytes =  3.8 MB
>Load Address: d0008000
>Entry Point:  d0008001
>Contents:
>   Image 0: 3932720 Bytes =  3.8 MB
>   Image 1: 12463 Bytes = 12.2 kB
>Verifying Checksum ... OK
> ## Flattened Device Tree from multi component Image at D0007FC0
>Booting using the fdt at 0xd03c823c
>Loading Multi-File Image ... OK
> OK
> WARNING: legacy format multi component image overwritten
>Loading Device Tree to d07f9000, end d07ff0ae ... OK
>
> Starting kernel ...
>
> After this message the processor resets.
> Can you please tell me what is wrong?
>

> WARNING: legacy format multi component image overwritten
>Loading Device Tree to d07f9000, end d07ff0ae ... OK

Problem look like relocation address of fit image

Michael

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



-- 
| Michael Nazzareno Trimarchi Amarula Solutions BV |
| COO  -  Founder  Cruquiuskade 47 |
| +31(0)851119172 Amsterdam 1018 AM NL |
|  [`as] http://www.amarulasolutions.com   |
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] Please pull u-boot-dm

2018-08-01 Thread Simon Glass
Hi Tom.

On 31 July 2018 at 06:42, Tom Rini  wrote:
>
> On Mon, Jul 30, 2018 at 02:10:44PM -0600, Simon Glass wrote:
>
> > Hi Tom,
> >
> > Here are the binman changes, with the rename of the 'pos' property to 
> > 'offset'.
> >
> >
> > The following changes since commit 0e8a8a311020d317fcfcf594e8e3fb1598134593:
> >
> >   Merge git://git.denx.de/u-boot-fsl-qoriq (2018-07-27 13:09:30 -0400)
> >
> > are available in the Git repository at:
> >
> >   git://git.denx.de/u-boot-dm.git
> >
> > for you to fetch changes up to e824c2422356cc9656d714335fc9b7907c3dace7:
> >
> >   binman: Adjust _GetPropTree() parameters (2018-07-30 10:28:07 -0600)
> >
>
> NAK, this seems to be introducing some failures:
> binman: Section '/binman/image1': Symbol '_binman_u_boot_any_prop_pos'
>in entry '/binman/image1/u-boot-spl': No such property 'pos'
> /home/trini/work/u-boot/u-boot/Makefile:1240: recipe for target 
> 'u-boot-tegra.bin' failed
> make[1]: *** [u-boot-tegra.bin] Error 1
> make[1]: Leaving directory '/tmp/colibri_t30'
> Makefile:148: recipe for target 'sub-make' failed
> make: *** [sub-make] Error 2

I'm sorry about that. I saw the failure and thought it was device tree
stuff. Oops.

Do you know what is happening with all the device-tree warnings? Are
they slowing going away?

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


[U-Boot] Problem booting uImage with u-boot

2018-08-01 Thread Saeed Abdoli
Hello
I am working on a project in which I need to boot a customized linux kernel
on my board. The board components are stm32f429 processor, 8Mbyte SDRAM and
32Mbyte flash memory which are connected to the processer via FMC. I've
booted u-boot on the internal flash of the processor and I've installed the
linux image (networking.uImage) which is provided by EMCRAFT using TFTP
successfully. Then I tried to build my own linux image by editing the
example provided by EMCRAFT (rootfs). But when I build the image and try to
boot it, the processor can not boot the image and it resets unexpectedly.
This is the message u-boot shows when trying to boot the image:
## Booting kernel from Legacy Image at d0007fc0 ...
   Image Name:   Linux-4.2.0
   Image Type:   ARM Linux Multi-File Image (uncompressed)
   Data Size:3945195 Bytes =  3.8 MB
   Load Address: d0008000
   Entry Point:  d0008001
   Contents:
  Image 0: 3932720 Bytes =  3.8 MB
  Image 1: 12463 Bytes = 12.2 kB
   Verifying Checksum ... OK
## Flattened Device Tree from multi component Image at D0007FC0
   Booting using the fdt at 0xd03c823c
   Loading Multi-File Image ... OK
OK
WARNING: legacy format multi component image overwritten
   Loading Device Tree to d07f9000, end d07ff0ae ... OK

Starting kernel ...

After this message the processor resets.
Can you please tell me what is wrong?

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


Re: [U-Boot] [PATCH] ARM: socfpga: Convert to DM serial

2018-08-01 Thread Simon Goldschmidt
Marek Vasut  schrieb am Mi., 1. Aug. 2018, 09:35:

> On 08/01/2018 09:29 AM, Goldschmidt Simon wrote:
> >
> > On 30.07.2018 16:04, Marek Vasut wrote:
> >> On 07/30/2018 04:03 PM, Simon Goldschmidt wrote:
> >>>
> >>> On 12.05.2018 22:28, Marek Vasut wrote:
>  Pull the serial port configuration from DT and use DM serial instead
>  of having the serial configuration in two places, DT and board config.
> [..]
>

While debugging, a more generic question: which drivers are now remaining
non-DM for socfpga?

And am I correct with the assumption that we could get rid of the qts files
(other than sdram maybe) by implementing pinctrl and clk drivers as DM
drivers? (Not that I would have found documentation about the pin mux
hardware cyclone5...)

I'm looking for a way to control pins from a fit image that includes
kernel, dts and fpga because the pins may change depending on the fpga
config...

Simon (from my private mail)
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 3/4] gpio: xilinx: Not read output values via regs

2018-08-01 Thread Stefan Herbrechtsmeier

Am 30.07.2018 um 21:34 schrieb Stefan Herbrechtsmeier:

Am 30.07.2018 um 16:10 schrieb Michal Simek:

On 30.7.2018 15:32, Stefan Herbrechtsmeier wrote:

Am 30.07.2018 um 14:40 schrieb Michal Simek:

On 27.7.2018 10:41, Stefan Herbrechtsmeier wrote:

Am 27.07.2018 um 09:05 schrieb Michal Simek:

On 26.7.2018 21:46, Stefan Herbrechtsmeier wrote:

Am 26.07.2018 um 10:41 schrieb Michal Simek:

On 25.7.2018 20:21, Stefan Herbrechtsmeier wrote:

Am 25.07.2018 um 08:39 schrieb Michal Simek:

On 24.7.2018 21:56, Stefan Herbrechtsmeier wrote:

Am 24.07.2018 um 12:31 schrieb Michal Simek:

On 23.7.2018 20:42, Stefan Herbrechtsmeier wrote:

Am 23.07.2018 um 13:43 schrieb Michal Simek:
Reading registers for finding out output value is not 
working

because
input value is read instead in case of tristate.

Reported-by: Stefan Herbrechtsmeier

Signed-off-by: Michal Simek 
---

    drivers/gpio/xilinx_gpio.c | 38
+-
    1 file changed, 33 insertions(+), 5 deletions(-)

diff --git a/drivers/gpio/xilinx_gpio.c
b/drivers/gpio/xilinx_gpio.c
index 4da9ae114d87..9d3e9379d0e5 100644
--- a/drivers/gpio/xilinx_gpio.c
+++ b/drivers/gpio/xilinx_gpio.c

[snip]


    + priv->output_val[bank] = val;
+
    return val;
    };
    @@ -441,6 +449,7 @@ static int
xilinx_gpio_get_function(struct
udevice *dev, unsigned offset)
    static int xilinx_gpio_get_value(struct udevice 
*dev,

unsigned
offset)
    {
    struct xilinx_gpio_platdata *platdata =
dev_get_platdata(dev);
+    struct xilinx_gpio_privdata *priv = dev_get_priv(dev);
    int val, ret;
    u32 bank, pin;
    @@ -451,7 +460,14 @@ static int
xilinx_gpio_get_value(struct
udevice
*dev, unsigned offset)
    debug("%s: regs: %lx, gpio: %x, bank %x, pin 
%x\n",

__func__,
(ulong)platdata->regs, offset, bank, pin);
    -    val = readl(>regs->gpiodata + bank 
* 2);

+    if (xilinx_gpio_get_function(dev, offset) ==
GPIOF_INPUT) {
+    debug("%s: Read input value from reg\n", __func__);
+    val = readl(>regs->gpiodata + bank * 2);
+    } else {
+    debug("%s: Read saved output value\n", __func__);
+    val = priv->output_val[bank];
+    }

Why you don't always read the data register? This doesn't
work for
three
state outputs.

In three state register every bit/pin is 0 - output, 1 input.
It means else part is output and I read saved value in
priv->output_val.
If pin is setup as INPUT then I need read data reg to find out
input
value.
Maybe you are commenting something else but please let me 
know if

there
is any other bug.

What happen if I have an open drain output. Even if the gpio
output
is 1
the input could read a 0. You driver will always return the 
output

value
and not the real input value. According to the picture in
documentation
and my tests a data register write writes the output registers
and a
data register read reads the input registers.

Why should the driver return the desired state (output 
register)

and not
the real state (input register)?

First of all thanks for description.

I have another example where you have output only and you can't
read
input because there is no wire.
Does you mean the all outputs configuration? Does this removes 
the

"gpio_io_i" signal from the IP?
I am not sure what synthesis is doing with that unused IP pins 
but I
would consider as a bug if this is automatically connected 
together.
I mean does the IP generator removes the gpio_io_i signal 
because it
isn't needed? If the IP generator creates the gpio_io_i signal I 
would

expect that you can't leave it unconnected as this would lead to
undefined values.

Normally when you know that you have output only there is no no
gpio_io_i or tristate signal. The same for input only.

And in this case the device tree flags "xlnx,all-inputs" or
"xlnx,all-outputs" should be set.

yes.


 And
also wasting a logic if there is unused part.
But in Vivado you should be able to setup output pins to and input
pins
separately. There are In/Out/Tristate.
If you don't want to deal with external pin you can connect them
inside PL.
This isn't my point. I mean that if you have an gpio_io_i signal 
you

have to connected it to a signal. You could connect it to the
output of
an IO, to the gpio_io_o signal or to fixed value (0 or 1). If you
connect it to a fixed value (0 or 1) you get this value if you read
the
status of this GPIO.

Not a HW to tell you what's vivado is going to do with that. But you
can
select that ouput/input only where these signals are out.

You mean the all-inputs or all-outputs case.

yes.


Regarding open drain output.

Also this is what it is written in manual:
"AXI GPIO Data Register Description"
"For each I/O bit programmed as output:
• R: Reads to these bits always return zeros"
This must be a mistake in the documentation. I could read the 
input

value.

The old driver and the Linux driver always read the register.

In old u-boot driver I see
 179  

Re: [U-Boot] [RFC PATCH] gpio: zynq: Setup bank_name to dev->name

2018-08-01 Thread Stefan Herbrechtsmeier

Am 30.07.2018 um 10:00 schrieb Michal Simek:

On 27.7.2018 11:14, Stefan Herbrechtsmeier wrote:

Am 27.07.2018 um 08:42 schrieb Michal Simek:

On 26.7.2018 22:04, Stefan Herbrechtsmeier wrote:

Am 26.07.2018 um 10:22 schrieb Michal Simek:

On 25.7.2018 21:17, Stefan Herbrechtsmeier wrote:

Am 25.07.2018 um 08:07 schrieb Michal Simek:

On 24.7.2018 21:39, Stefan Herbrechtsmeier wrote:

Am 24.07.2018 um 10:37 schrieb Michal Simek:

On 23.7.2018 20:29, Stefan Herbrechtsmeier wrote:

Am 23.07.2018 um 11:08 schrieb Michal Simek:

On 20.7.2018 21:31, Stefan Herbrechtsmeier wrote:

Am 12.07.2018 um 16:04 schrieb Michal Simek:

There should be proper bank name setup to distiguish between
different
gpio drivers. Use dev->name for it.

Signed-off-by: Michal Simek 
---

    drivers/gpio/zynq_gpio.c | 2 ++
    1 file changed, 2 insertions(+)

diff --git a/drivers/gpio/zynq_gpio.c
b/drivers/gpio/zynq_gpio.c
index 26f69b1a713f..f793ee5754a8 100644
--- a/drivers/gpio/zynq_gpio.c
+++ b/drivers/gpio/zynq_gpio.c
@@ -337,6 +337,8 @@ static int zynq_gpio_probe(struct udevice
*dev)
    struct zynq_gpio_privdata *priv = dev_get_priv(dev);
    struct gpio_dev_priv *uc_priv =
dev_get_uclass_priv(dev);
    +    uc_priv->bank_name = dev->name;
+
    if (priv->p_data)
    uc_priv->gpio_count = priv->p_data->ngpio;


Does this not lead to ugly names because the gpio number is
append to
the bank_name? Have you check the "gpio status -a" output?

Yes I was checking it. Names are composed together but also just
numbers
works as before.

gpio@ff0a0: input: 0 [ ]
gpio@ff0a1: input: 0 [ ]
gpio@ff0a2: input: 0 [ ]
gpio@ff0a3: input: 0 [ ]
gpio@ff0a4: input: 0 [ ]
gpio@ff0a5: input: 0 [ ]
gpio@ff0a6: input: 0 [ ]
gpio@ff0a7: input: 0 [ ]
gpio@ff0a8: input: 0 [ ]
gpio@ff0a9: input: 0 [ ]

Do you think that this are meaningful names? It isn't possible to
separate the device and pin number as well as it mix hex and
decimal
numbers.


If you know better way how to setup a bank name please let me
know
but I
need to distinguish ps gpio from pl one and for pl we need to
know
the
address.

I know the use case.

A lot of drivers use the bank_name from the device tree, some
drivers
append an underscore to the bank name and others add the
req_seq of
the
device to an alphabetic character.


Other drivers use the gpio-bank-name from the device tree.

I can't see this property inside Linux kernel. If this has been
reviewed
by dt guys please let me know.

This property is only used by u-boot. I think it isn't needed
by the
Linux kernel.

I am happy to use consistent solution but what's that?

Consistent solution between what?

all drivers. Name should be composed consistently among all drivers.
It means drivers shouldn't add additional "_" in driver code for
example.


Mixing name with hex and int is not nice but adding "_" or
something
else is just a pain in driver code. If this is done in core I am
fine
with that but adding this code to all drivers don't look like
generic
solution at all.

Normally the bank name is an alphabetic character or string.
Maybe we
could add the device name to the gpio_lookup_name function and
add an
additional optional device name parameter to the gpio command.


Using additional u-boot property is not good too.

I have mentioned in "gpio: xilinx: Convert driver to DM"
(sha1:10441ec9224d0d269dc512819a32c0785a6338d3)
that uc-priv->name is completely unused. Maybe this should be
dev->name
and bank_name should be really used for banks.

Isn't the uc-priv->name used for the label of the request?

Last time when I looked at it and I didn't see this name listed
anywhere
in output.



Then in gpio status -a can be

Device gpio@a0001000:
Bank:
...

but not sure how gpio commands will work to address exact pin from
prompt. Because this is normally working
gpio toggle gpio@a00010001

With an optional device name this would be:
gpio toggle gpio@a0001000 1

Alternative the gpio command could support the requested labels:
gpio toggle second-gpio

I am open to see this solution. Feel free to invest your time support
this but I have no time for that.

What does this mean?

I understand that you don't have the time to develop a new common
solution.

But the discussion disappoints me. You misuse the bank name in a poor
way and decline alternative solutions with additional requirements
even
if they are already used in u-boot.

The name "gpio@a000100011" for pin 11 of the device gpio@a0001000
isn't
consistent between the u-boot drivers nor is the name used in Linux. A
bank-name from the device tree is used by several u-boot drivers
even if
it isn't consistent between the drivers.

I am sorry that you feel like that. It is not about declining
alternative solution. I want to know what's the right solution is.

Thanks a lot for taking the time to write a detail explanation.


Using bank-name/gpio-bank-name via DT is something what is IMHO not
correct.

Re: [U-Boot] [PATCH v3 2/6] video_osd: Add ihs_video_out driver

2018-08-01 Thread Anatolij Gustschin
On Tue, 26 Jun 2018 13:28:50 +0200
Mario Six mario@gdsys.cc wrote:
...
> ---
>  .../video/osd/gdsys,ihs_video_out.txt  |  23 ++
>  drivers/video/Kconfig  |   9 +
>  drivers/video/Makefile |   1 +
>  drivers/video/ihs_video_out.c  | 341 
> +
>  4 files changed, 374 insertions(+)
>  create mode 100644 doc/device-tree-bindings/video/osd/gdsys,ihs_video_out.txt
>  create mode 100644 drivers/video/ihs_video_out.c

Applied to u-boot-video/master, rebased Makefile changes. Thanks!

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


Re: [U-Boot] [PATCH v3 1/6] drivers: Add OSD uclass

2018-08-01 Thread Anatolij Gustschin
Hi Mario,

On Tue, 26 Jun 2018 13:28:49 +0200
Mario Six mario@gdsys.cc wrote:
...
> ---
>  drivers/video/Kconfig|   8 ++
>  drivers/video/Makefile   |   2 +-
>  drivers/video/video_osd-uclass.c |  45 +
>  include/dm/uclass-id.h   |   1 +
>  include/video_osd.h  | 192 
> +++
>  5 files changed, 247 insertions(+), 1 deletion(-)
>  create mode 100644 drivers/video/video_osd-uclass.c
>  create mode 100644 include/video_osd.h

Applied to u-boot-video/master after fixing Makefile changes.

...
> -obj-$(CONFIG_VIDEO_FSL_DCU_FB) += fsl_dcu_fb.o videomodes.o

This line shouldn't be removed. Fixed when applying.

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


[U-Boot] [PATCH v1 5/5] test: dm: Add gpio get_function_number ops test

2018-08-01 Thread Patrice Chotard
In order to test get_function_number ops, add sandbox_gpio_set_function()
and sandbox_gpio_set_function_number() to be able to configure a pin
not as a GPIO and to select the function number.

Signed-off-by: Patrice Chotard 
---

 arch/sandbox/include/asm/gpio.h | 23 +++
 drivers/gpio/sandbox.c  | 25 +
 test/dm/gpio.c  | 13 +
 3 files changed, 61 insertions(+)

diff --git a/arch/sandbox/include/asm/gpio.h b/arch/sandbox/include/asm/gpio.h
index de8ac37f4262..d1eea307efc8 100644
--- a/arch/sandbox/include/asm/gpio.h
+++ b/arch/sandbox/include/asm/gpio.h
@@ -82,4 +82,27 @@ int sandbox_gpio_get_direction(struct udevice *dev, unsigned 
int offset);
 int sandbox_gpio_set_direction(struct udevice *dev, unsigned int offset,
   int output);
 
+/**
+ * Set the simulated usage of a pin, as a GPIO or not (used only in sandbox
+ * test code)
+ *
+ * @param dev  device to use
+ * @param offset   GPIO offset within bank
+ * @param value0 to set as GPIO, 1 to set as not a GPIO
+ * @return -1 on error, 0 if ok
+ */
+int sandbox_gpio_set_function(struct udevice *dev, unsigned int offset,
+ int value);
+
+/**
+ * Set the simulated alternate function of a pin when pin is not used as a GPIO
+ * (used only in sandbox test code)
+ *
+ * @param dev  device to use
+ * @param offset   GPIO offset within bank
+ * @param valuepin alternate function number
+ * @return -1 on error, 0 if ok
+ */
+int sandbox_gpio_set_function_number(struct udevice *dev, unsigned int offset,
+int value);
 #endif
diff --git a/drivers/gpio/sandbox.c b/drivers/gpio/sandbox.c
index 50afa697d01c..cdaab8f9bf2e 100644
--- a/drivers/gpio/sandbox.c
+++ b/drivers/gpio/sandbox.c
@@ -15,6 +15,8 @@
 #define SDBX_GPIO_OUTPUT   BIT(0)  /* Currently set as an output */
 #define SDBX_GPIO_HIGH BIT(1)  /* Currently set high */
 #define SDBX_GPIO_ODR  BIT(2)  /* Currently set to open drain mode */
+#define SDBX_GPIO_FUNC BIT(3)  /* Currently set as not used as GPIO */
+#define SDBX_GPIO_FUNC_NB  BIT(4)  /* Currently set as function number 1 */
 
 struct gpio_state {
const char *label;  /* label given by requester */
@@ -90,6 +92,18 @@ int sandbox_gpio_set_direction(struct udevice *dev, unsigned 
offset, int output)
return set_gpio_flag(dev, offset, SDBX_GPIO_OUTPUT, output);
 }
 
+int sandbox_gpio_set_function(struct udevice *dev, unsigned int offset,
+ int value)
+{
+   return set_gpio_flag(dev, offset, SDBX_GPIO_FUNC, value);
+}
+
+int sandbox_gpio_set_function_number(struct udevice *dev, unsigned int offset,
+int value)
+{
+   return set_gpio_flag(dev, offset, SDBX_GPIO_FUNC_NB, value);
+}
+
 /*
  * These functions implement the public interface within U-Boot
  */
@@ -158,11 +172,21 @@ static int sb_gpio_set_open_drain(struct udevice *dev, 
unsigned offset, int valu
 
 static int sb_gpio_get_function(struct udevice *dev, unsigned offset)
 {
+   if (get_gpio_flag(dev, offset, SDBX_GPIO_FUNC))
+   return GPIOF_FUNC;
+
if (get_gpio_flag(dev, offset, SDBX_GPIO_OUTPUT))
return GPIOF_OUTPUT;
return GPIOF_INPUT;
 }
 
+static int sb_gpio_get_function_number(struct udevice *dev, unsigned int 
offset)
+{
+   debug("%s: offset:%u\n", __func__, offset);
+
+   return get_gpio_flag(dev, offset, SDBX_GPIO_FUNC_NB);
+}
+
 static int sb_gpio_xlate(struct udevice *dev, struct gpio_desc *desc,
 struct ofnode_phandle_args *args)
 {
@@ -189,6 +213,7 @@ static const struct dm_gpio_ops gpio_sandbox_ops = {
.get_open_drain = sb_gpio_get_open_drain,
.set_open_drain = sb_gpio_set_open_drain,
.get_function   = sb_gpio_get_function,
+   .get_function_number= sb_gpio_get_function_number,
.xlate  = sb_gpio_xlate,
 };
 
diff --git a/test/dm/gpio.c b/test/dm/gpio.c
index bb4b20cea938..1cca1ba007bf 100644
--- a/test/dm/gpio.c
+++ b/test/dm/gpio.c
@@ -92,6 +92,19 @@ static int dm_test_gpio(struct unit_test_state *uts)
ut_assertok(gpio_get_status(dev, offset, buf, sizeof(buf)));
ut_asserteq_str("b4: input: 0 [ ]", buf);
 
+   /*
+* Make it not used as GPIO, select function
+* (by default function number 0 is active)
+*/
+   sandbox_gpio_set_function(dev, offset, 1);
+   ut_assertok(gpio_get_status(dev, offset, buf, sizeof(buf)));
+   ut_asserteq_str("b4: func: 0", buf);
+
+   /* select function number 1 */
+   sandbox_gpio_set_function_number(dev, offset, 1);
+   ut_assertok(gpio_get_status(dev, offset, buf, sizeof(buf)));
+   ut_asserteq_str("b4: func: 1", buf);
+
/* Check the 'a' bank also */

[U-Boot] [PATCH v1 3/5] gpio: stm32f7: Add ops get_function_number

2018-08-01 Thread Patrice Chotard
From: Patrick Delaunay 

Allow to display function number using "gpio" command.
Example, display all gpio state :

gpio status -a
  GPIOD2: func: 12
  GPIOD3: func: 9
  GPIOE3: func: 9
  GPIOG6: func: 10

It's useful to control pin configuration

Signed-off-by: Patrick Delaunay 
Signed-off-by: Patrice Chotard 
---

 drivers/gpio/stm32f7_gpio.c | 16 
 1 file changed, 16 insertions(+)

diff --git a/drivers/gpio/stm32f7_gpio.c b/drivers/gpio/stm32f7_gpio.c
index 55e121699022..67c3002acd31 100644
--- a/drivers/gpio/stm32f7_gpio.c
+++ b/drivers/gpio/stm32f7_gpio.c
@@ -85,12 +85,28 @@ static int stm32_gpio_get_function(struct udevice *dev, 
unsigned int offset)
return GPIOF_FUNC;
 }
 
+static int stm32_gpio_get_function_number(struct udevice *dev,
+ unsigned int offset)
+{
+   struct stm32_gpio_priv *priv = dev_get_priv(dev);
+   struct stm32_gpio_regs *regs = priv->regs;
+   u32 af;
+   u32 alt_shift = (offset % 8) * 4;
+   u32 alt_index =  offset / 8;
+
+   af = (readl(>afr[alt_index]) &
+ GENMASK(alt_shift + 3, alt_shift)) >> alt_shift;
+
+   return af;
+}
+
 static const struct dm_gpio_ops gpio_stm32_ops = {
.direction_input= stm32_gpio_direction_input,
.direction_output   = stm32_gpio_direction_output,
.get_value  = stm32_gpio_get_value,
.set_value  = stm32_gpio_set_value,
.get_function   = stm32_gpio_get_function,
+   .get_function_number= stm32_gpio_get_function_number,
 };
 
 static int gpio_stm32_probe(struct udevice *dev)
-- 
1.9.1

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


[U-Boot] [PATCH v1 4/5] gpio: sandbox: Rename GPIOF_(OUTPUT|HIGH|ODR) to SDBX_GPIO_(OUTPUT|HIGH|ODR)

2018-08-01 Thread Patrice Chotard
To avoid confusion with enum gpio_func_t GPIOF_OUTPUT defined in
asm-generic/gpio.h, rename all sandbox flags GPIOF_(OUTPUT|HIGH|ODR)
to SDBX_GPIO_(OUTPUT|HIGH|ODR)

Signed-off-by: Patrice Chotard 
---

 drivers/gpio/sandbox.c | 22 +++---
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/gpio/sandbox.c b/drivers/gpio/sandbox.c
index 2ef5c67ad593..50afa697d01c 100644
--- a/drivers/gpio/sandbox.c
+++ b/drivers/gpio/sandbox.c
@@ -12,9 +12,9 @@
 #include 
 
 /* Flags for each GPIO */
-#define GPIOF_OUTPUT   (1 << 0)/* Currently set as an output */
-#define GPIOF_HIGH (1 << 1)/* Currently set high */
-#define GPIOF_ODR  (1 << 2)/* Currently set to open drain mode */
+#define SDBX_GPIO_OUTPUT   BIT(0)  /* Currently set as an output */
+#define SDBX_GPIO_HIGH BIT(1)  /* Currently set high */
+#define SDBX_GPIO_ODR  BIT(2)  /* Currently set to open drain mode */
 
 struct gpio_state {
const char *label;  /* label given by requester */
@@ -60,34 +60,34 @@ static int set_gpio_flag(struct udevice *dev, unsigned 
offset, int flag,
 
 int sandbox_gpio_get_value(struct udevice *dev, unsigned offset)
 {
-   if (get_gpio_flag(dev, offset, GPIOF_OUTPUT))
+   if (get_gpio_flag(dev, offset, SDBX_GPIO_OUTPUT))
debug("sandbox_gpio: get_value on output gpio %u\n", offset);
-   return get_gpio_flag(dev, offset, GPIOF_HIGH);
+   return get_gpio_flag(dev, offset, SDBX_GPIO_HIGH);
 }
 
 int sandbox_gpio_set_value(struct udevice *dev, unsigned offset, int value)
 {
-   return set_gpio_flag(dev, offset, GPIOF_HIGH, value);
+   return set_gpio_flag(dev, offset, SDBX_GPIO_HIGH, value);
 }
 
 int sandbox_gpio_get_open_drain(struct udevice *dev, unsigned offset)
 {
-   return get_gpio_flag(dev, offset, GPIOF_ODR);
+   return get_gpio_flag(dev, offset, SDBX_GPIO_ODR);
 }
 
 int sandbox_gpio_set_open_drain(struct udevice *dev, unsigned offset, int 
value)
 {
-   return set_gpio_flag(dev, offset, GPIOF_ODR, value);
+   return set_gpio_flag(dev, offset, SDBX_GPIO_ODR, value);
 }
 
 int sandbox_gpio_get_direction(struct udevice *dev, unsigned offset)
 {
-   return get_gpio_flag(dev, offset, GPIOF_OUTPUT);
+   return get_gpio_flag(dev, offset, SDBX_GPIO_OUTPUT);
 }
 
 int sandbox_gpio_set_direction(struct udevice *dev, unsigned offset, int 
output)
 {
-   return set_gpio_flag(dev, offset, GPIOF_OUTPUT, output);
+   return set_gpio_flag(dev, offset, SDBX_GPIO_OUTPUT, output);
 }
 
 /*
@@ -158,7 +158,7 @@ static int sb_gpio_set_open_drain(struct udevice *dev, 
unsigned offset, int valu
 
 static int sb_gpio_get_function(struct udevice *dev, unsigned offset)
 {
-   if (get_gpio_flag(dev, offset, GPIOF_OUTPUT))
+   if (get_gpio_flag(dev, offset, SDBX_GPIO_OUTPUT))
return GPIOF_OUTPUT;
return GPIOF_INPUT;
 }
-- 
1.9.1

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


[U-Boot] [PATCH v1 2/5] gpio: stm32f7: Add ops get_function

2018-08-01 Thread Patrice Chotard
From: Christophe Kerello 

This patch adds gpio get_function ops support.
This function reports the state of a gpio.

Signed-off-by: Christophe Kerello 
Signed-off-by: Patrice Chotard 
---

 drivers/gpio/stm32f7_gpio.c | 20 
 1 file changed, 20 insertions(+)

diff --git a/drivers/gpio/stm32f7_gpio.c b/drivers/gpio/stm32f7_gpio.c
index 5b08e7ee275c..55e121699022 100644
--- a/drivers/gpio/stm32f7_gpio.c
+++ b/drivers/gpio/stm32f7_gpio.c
@@ -66,11 +66,31 @@ static int stm32_gpio_set_value(struct udevice *dev, 
unsigned offset, int value)
return 0;
 }
 
+static int stm32_gpio_get_function(struct udevice *dev, unsigned int offset)
+{
+   struct stm32_gpio_priv *priv = dev_get_priv(dev);
+   struct stm32_gpio_regs *regs = priv->regs;
+   int bits_index = MODE_BITS(offset);
+   int mask = MODE_BITS_MASK << bits_index;
+   u32 mode;
+
+   mode = (readl(>moder) & mask) >> bits_index;
+   if (mode == STM32_GPIO_MODE_OUT)
+   return GPIOF_OUTPUT;
+   if (mode == STM32_GPIO_MODE_IN)
+   return GPIOF_INPUT;
+   if (mode == STM32_GPIO_MODE_AN)
+   return GPIOF_UNUSED;
+
+   return GPIOF_FUNC;
+}
+
 static const struct dm_gpio_ops gpio_stm32_ops = {
.direction_input= stm32_gpio_direction_input,
.direction_output   = stm32_gpio_direction_output,
.get_value  = stm32_gpio_get_value,
.set_value  = stm32_gpio_set_value,
+   .get_function   = stm32_gpio_get_function,
 };
 
 static int gpio_stm32_probe(struct udevice *dev)
-- 
1.9.1

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


[U-Boot] [PATCH v1 1/5] dm: gpio: Add get_function_number ops

2018-08-01 Thread Patrice Chotard
From: Patrick Delaunay 

When a pin is not configured as a GPIO, it could
have several alternate function.

To be able to identify the alternate function,
add ops get_function_number() to request the pin
function index from the driver when pin is not used
as gpio.

Signed-off-by: Patrick Delaunay 
Signed-off-by: Patrice Chotard 
---

 drivers/gpio/gpio-uclass.c |  6 ++
 include/asm-generic/gpio.h | 11 +++
 2 files changed, 17 insertions(+)

diff --git a/drivers/gpio/gpio-uclass.c b/drivers/gpio/gpio-uclass.c
index da5e9ba6e524..fa249f7b12d4 100644
--- a/drivers/gpio/gpio-uclass.c
+++ b/drivers/gpio/gpio-uclass.c
@@ -568,6 +568,12 @@ int gpio_get_status(struct udevice *dev, int offset, char 
*buf, int buffsize)
 label ? label : "");
}
 
+   if (func == GPIOF_FUNC && ops->get_function_number) {
+   ret = ops->get_function_number(dev, offset);
+   if (ret >= 0)
+   snprintf(str + len, buffsize - len, ": %d", ret);
+   }
+
return 0;
 }
 
diff --git a/include/asm-generic/gpio.h b/include/asm-generic/gpio.h
index d03602696f6d..f8cd6ddccbbf 100644
--- a/include/asm-generic/gpio.h
+++ b/include/asm-generic/gpio.h
@@ -266,6 +266,17 @@ struct dm_gpio_ops {
int (*get_function)(struct udevice *dev, unsigned offset);
 
/**
+* get_function_number() Get the function number
+*
+* get index for GPIOF_FUNC, when pin is not used as a GPIO
+*
+* @dev: Device to check
+* @offset:  GPIO offset within that device
+* @return current function index
+*/
+   int (*get_function_number)(struct udevice *dev, unsigned int offset);
+
+   /**
 * xlate() - Translate phandle arguments into a GPIO description
 *
 * This function should set up the fields in desc according to the
-- 
1.9.1

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


[U-Boot] [PATCH v1 0/5] Add get_function_number ops

2018-08-01 Thread Patrice Chotard

This series :
  - Add new gpio ops get_function_number
  - Add get_function and get_function_number support to stm32 gpio driver
  - Add get_function_number test


Christophe Kerello (1):
  gpio: stm32f7: Add ops get_function

Patrice Chotard (2):
  gpio: sandbox: Rename GPIOF_(OUTPUT|HIGH|ODR) to
SDBX_GPIO_(OUTPUT|HIGH|ODR)
  test: dm: Add gpio get_function_number ops test

Patrick Delaunay (2):
  dm: gpio: Add get_function_number ops
  gpio: stm32f7: Add ops get_function_number

 arch/sandbox/include/asm/gpio.h | 23 
 drivers/gpio/gpio-uclass.c  |  6 ++
 drivers/gpio/sandbox.c  | 47 +++--
 drivers/gpio/stm32f7_gpio.c | 36 +++
 include/asm-generic/gpio.h  | 11 ++
 test/dm/gpio.c  | 13 
 6 files changed, 125 insertions(+), 11 deletions(-)

-- 
1.9.1

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


Re: [U-Boot] [PATCH] ARM: socfpga: Convert to DM serial

2018-08-01 Thread Marek Vasut
On 08/01/2018 05:42 PM, Simon Goldschmidt wrote:
> 
> 
> Marek Vasut mailto:ma...@denx.de>> schrieb am Mi., 1.
> Aug. 2018, 09:35:
> 
> On 08/01/2018 09:29 AM, Goldschmidt Simon wrote:
> >
> > On 30.07.2018 16:04, Marek Vasut wrote:
> >> On 07/30/2018 04:03 PM, Simon Goldschmidt wrote:
> >>>
> >>> On 12.05.2018 22:28, Marek Vasut wrote:
>  Pull the serial port configuration from DT and use DM serial
> instead
>  of having the serial configuration in two places, DT and board
> config.
> [..]
> 
> 
> While debugging, a more generic question: which drivers are now
> remaining non-DM for socfpga?

Not much I believe, I can't think of anything right now.

> And am I correct with the assumption that we could get rid of the qts
> files (other than sdram maybe) by implementing pinctrl and clk drivers
> as DM drivers? (Not that I would have found documentation about the pin
> mux hardware cyclone5...)

Yes. The pinmux docs are probably not public, it has to do with the
iocsr ring programming and that's super-secret for whatever reason.
What Altera did on Arria10 is pure trash, they encode registers in DT
and are done with it. If you can design something saner, that'd be so nice.

I am working on a clock driver for Arria10 now, I might do Gen5 too
afterward, since the clock block is similar. The clock DT bindings on
the other hand are complete insanity, words fail me. The clock stuff in
U-Boot on SoCFPGA right now is a complete disaster too, the way stuff
gets added to mach-socfpga is really irritating.

> I'm looking for a way to control pins from a fit image that includes
> kernel, dts and fpga because the pins may change depending on the fpga
> config...

DTOs maybe ?

> Simon (from my private mail)


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


Re: [U-Boot] [PATCH] efi_loader: don't allocate unusable RAM

2018-08-01 Thread Stephen Warren

On 08/01/2018 12:07 AM, Heinrich Schuchardt wrote:

On 07/31/2018 09:44 PM, Stephen Warren wrote:

From: Stephen Warren 

Some boards define a maximum usable RAM top that's more restrictive than
the ranges defined by U-Boot's memory bank definitions[1]. In this case,
the unusable RAM isn't mapped in the page tables, and so the EFI code must
not attempt to allocate RAM from outside the usable regions. Fix
efi_find_free_memory() to detect when max_addr is unconstrained or out of
range, and substitue a valid value.



In this case the board has to call efi_add_memory_map() to mark the
reserved region (cf. board/raspberrypi/rpi/rpi.c) or have to mark the
memory region as reserved in the device tree (see efi_carve_out_dt_rsv()).

Please, check if the tegra boards with which you had problems do so.


I don't think this makes sense; memory should be managed the same way 
within U-Boot no matter which part of U-Boot is consuming that memory. 
Memory regions are currently represented by the content of the memory 
bank definitions and gd->ram_top. Having different parts of the code 
define legal RAM usage in different ways is horribly inconsistent.


At this point, I think the best thing is to revert aa909462d018 
"efi_loader: efi_allocate_pages is too restrictive" since it causes a 
regression on Jetson TX1, and we can work out the correct way to fix all 
this once the system is working again.

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


Re: [U-Boot] [ v2 01/10] dm: panel: get timings from panel

2018-08-01 Thread Anatolij Gustschin
On Fri, 13 Jul 2018 14:11:09 +0200
Yannick Fertré yannick.fer...@st.com wrote:

> Get timings from panel instead of read device tree.
> 
> Signed-off-by: Yannick Fertré 
> ---
>  drivers/video/panel-uclass.c | 11 +++
>  include/panel.h  | 18 ++
>  2 files changed, 29 insertions(+)

Applied to u-boot-video/master, thanks!

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


[U-Boot] [PATCH v2 1/3] dm: serial: Replace setparity by setconfig

2018-08-01 Thread Patrice Chotard
From: Patrick Delaunay 

Replace setparity by more generic setconfig ops
to allow uart parity, bits word length and stop bits
number change.

Adds SERIAL_GET_PARITY/BITS/STOP macros.

Signed-off-by: Patrick Delaunay 
Signed-off-by: Patrice Chotard 
---

Changes in v2:
  - Update SERIAL_BITS_MASK and SERIAL_STOP_MASK
  - Update serial_setconfig prototype

 drivers/serial/serial-uclass.c | 16 
 include/serial.h   | 42 +++---
 2 files changed, 55 insertions(+), 3 deletions(-)

diff --git a/drivers/serial/serial-uclass.c b/drivers/serial/serial-uclass.c
index 321d23ee93bf..a7556c9b7bc3 100644
--- a/drivers/serial/serial-uclass.c
+++ b/drivers/serial/serial-uclass.c
@@ -287,6 +287,20 @@ void serial_setbrg(void)
ops->setbrg(gd->cur_serial_dev, gd->baudrate);
 }
 
+int serial_setconfig(uint config)
+{
+   struct dm_serial_ops *ops;
+
+   if (!gd->cur_serial_dev)
+   return 0;
+
+   ops = serial_get_ops(gd->cur_serial_dev);
+   if (ops->setconfig)
+   return ops->setconfig(gd->cur_serial_dev, config);
+
+   return 0;
+}
+
 void serial_stdio_init(void)
 {
 }
@@ -398,6 +412,8 @@ static int serial_post_probe(struct udevice *dev)
ops->pending += gd->reloc_off;
if (ops->clear)
ops->clear += gd->reloc_off;
+   if (ops->setconfig)
+   ops->setconfig += gd->reloc_off;
 #if CONFIG_POST & CONFIG_SYS_POST_UART
if (ops->loop)
ops->loop += gd->reloc_off
diff --git a/include/serial.h b/include/serial.h
index b9ef6d91c9c5..4f104f6a7188 100644
--- a/include/serial.h
+++ b/include/serial.h
@@ -73,6 +73,39 @@ enum serial_par {
SERIAL_PAR_EVEN
 };
 
+#define SERIAL_PAR_MASK0x03
+#define SERIAL_PAR_SHIFT   0
+#define SERIAL_GET_PARITY(config) \
+   ((config & SERIAL_PAR_MASK) >> SERIAL_PAR_SHIFT)
+
+enum serial_bits {
+   SERIAL_5_BITS,
+   SERIAL_6_BITS,
+   SERIAL_7_BITS,
+   SERIAL_8_BITS
+};
+
+#define SERIAL_BITS_SHIFT  2
+#define SERIAL_BITS_MASK   (0x3 << SERIAL_BITS_SHIFT)
+#define SERIAL_GET_BITS(config) \
+   ((config & SERIAL_BITS_MASK) >> SERIAL_BITS_SHIFT)
+
+enum serial_stop {
+   SERIAL_HALF_STOP,   /* 0.5 stop bit */
+   SERIAL_ONE_STOP,/*   1 stop bit */
+   SERIAL_ONE_HALF_STOP,   /* 1.5 stop bit */
+   SERIAL_TWO_STOP /*   2 stop bit */
+};
+
+#define SERIAL_STOP_SHIFT  4
+#define SERIAL_STOP_MASK   (0x3 << SERIAL_STOP_SHIFT)
+#define SERIAL_GET_STOP(config) \
+   ((config & SERIAL_STOP_MASK) >> SERIAL_STOP_SHIFT)
+
+#define SERIAL_DEFAULT_CONFIG  SERIAL_PAR_NONE << SERIAL_PAR_SHIFT | \
+   SERIAL_8_BITS << SERIAL_BITS_SHIFT | \
+   SERIAL_ONE_STOP << SERIAL_STOP_SHIFT
+
 /**
  * struct struct dm_serial_ops - Driver model serial operations
  *
@@ -150,15 +183,18 @@ struct dm_serial_ops {
int (*loop)(struct udevice *dev, int on);
 #endif
/**
-* setparity() - Set up the parity
+* setconfig() - Set up the uart configuration
+* (parity, 5/6/7/8 bits word length, stop bits)
 *
-* Set up a new parity for this device.
+* Set up a new config for this device.
 *
 * @dev: Device pointer
 * @parity: parity to use
+* @bits: bits number to use
+* @stop: stop bits number to use
 * @return 0 if OK, -ve on error
 */
-   int (*setparity)(struct udevice *dev, enum serial_par parity);
+   int (*setconfig)(struct udevice *dev, uint serial_config);
 };
 
 /**
-- 
1.9.1

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


[U-Boot] [PATCH v2 0/3] Replace serial setparity by setconfig

2018-08-01 Thread Patrice Chotard

This series :
  - replace setparity ops by more complete setconfig in serial uclass
  - replace setparity by setconfig in STM32 serial driver

Changes in v2:
  - Update SERIAL_BITS_MASK and SERIAL_STOP_MASK
  - Update serial_setconfig prototype
  - Update stm32_serial_setconfig prototype
  - Add sandbox serial test

Patrice Chotard (2):
  serial: stm32: Replace setparity by setconfig
  sandbox: Add serial test

Patrick Delaunay (1):
  dm: serial: Replace setparity by setconfig

 drivers/serial/sandbox.c   | 14 ++
 drivers/serial/serial-uclass.c | 16 
 drivers/serial/serial_stm32.c  | 21 +++--
 include/common.h   |  1 +
 include/serial.h   | 42 +++---
 test/dm/Makefile   |  1 +
 test/dm/serial.c   | 26 ++
 7 files changed, 112 insertions(+), 9 deletions(-)
 create mode 100644 test/dm/serial.c

-- 
1.9.1

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


[U-Boot] [PATCH v2 3/3] sandbox: Add serial test

2018-08-01 Thread Patrice Chotard
Signed-off-by: Patrice Chotard 
---

Changes in v2:
  - Add sandbox serial test

 drivers/serial/sandbox.c | 14 ++
 include/common.h |  1 +
 test/dm/Makefile |  1 +
 test/dm/serial.c | 26 ++
 4 files changed, 42 insertions(+)
 create mode 100644 test/dm/serial.c

diff --git a/drivers/serial/sandbox.c b/drivers/serial/sandbox.c
index a60dabe58835..94b4fdfb1714 100644
--- a/drivers/serial/sandbox.c
+++ b/drivers/serial/sandbox.c
@@ -143,6 +143,19 @@ static int sandbox_serial_getc(struct udevice *dev)
return result;
 }
 
+static int sandbox_serial_setconfig(struct udevice *dev, uint serial_config)
+{
+   u8 parity = SERIAL_GET_PARITY(serial_config);
+   u8 bits = SERIAL_GET_BITS(serial_config);
+   u8 stop = SERIAL_GET_STOP(serial_config);
+
+   if (bits != SERIAL_8_BITS || stop != SERIAL_ONE_STOP ||
+   parity != SERIAL_PAR_NONE)
+   return -ENOTSUPP; /* not supported in driver*/
+
+   return 0;
+}
+
 static const char * const ansi_colour[] = {
"black", "red", "green", "yellow", "blue", "megenta", "cyan",
"white",
@@ -173,6 +186,7 @@ static const struct dm_serial_ops sandbox_serial_ops = {
.putc = sandbox_serial_putc,
.pending = sandbox_serial_pending,
.getc = sandbox_serial_getc,
+   .setconfig = sandbox_serial_setconfig,
 };
 
 static const struct udevice_id sandbox_serial_ids[] = {
diff --git a/include/common.h b/include/common.h
index 940161f1758b..5c952af5e319 100644
--- a/include/common.h
+++ b/include/common.h
@@ -359,6 +359,7 @@ voidserial_putc_raw(const char);
 void   serial_puts   (const char *);
 intserial_getc   (void);
 intserial_tstc   (void);
+intserial_setconfig(uint config);
 
 /* $(CPU)/speed.c */
 intget_clocks (void);
diff --git a/test/dm/Makefile b/test/dm/Makefile
index d2ed96c61533..97517c7f825e 100644
--- a/test/dm/Makefile
+++ b/test/dm/Makefile
@@ -44,4 +44,5 @@ obj-$(CONFIG_DM_VIDEO) += video.o
 obj-$(CONFIG_ADC) += adc.o
 obj-$(CONFIG_SPMI) += spmi.o
 obj-$(CONFIG_WDT) += wdt.o
+obj-$(CONFIG_DM_SERIAL) += serial.o
 endif
diff --git a/test/dm/serial.c b/test/dm/serial.c
new file mode 100644
index ..4d8422eebd34
--- /dev/null
+++ b/test/dm/serial.c
@@ -0,0 +1,26 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2018, STMicroelectronics
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static int dm_test_serial(struct unit_test_state *uts)
+{
+   struct udevice *dev_serial;
+
+   ut_assertok(uclass_get_device_by_name(UCLASS_SERIAL, "serial",
+ _serial));
+
+   ut_assertok(serial_tstc());
+
+   ut_assertok(serial_setconfig(SERIAL_DEFAULT_CONFIG));
+
+   return 0;
+}
+
+DM_TEST(dm_test_serial, DM_TESTF_SCAN_FDT);
-- 
1.9.1

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


[U-Boot] [PATCH v2 2/3] serial: stm32: Replace setparity by setconfig

2018-08-01 Thread Patrice Chotard
Replace stm32_serial_setparity by stm32_serial_setconfig
which allows to set serial bits number, parity and stop
bits number.
Only parity setting is implemented.

Signed-off-by: Patrick Delaunay 
Signed-off-by: Patrice Chotard 
---

Changes in v2:
  - Update stm32_serial_setconfig prototype

 drivers/serial/serial_stm32.c | 21 +++--
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/drivers/serial/serial_stm32.c b/drivers/serial/serial_stm32.c
index f26234549c3e..53866a23e6fc 100644
--- a/drivers/serial/serial_stm32.c
+++ b/drivers/serial/serial_stm32.c
@@ -47,20 +47,28 @@ static int stm32_serial_setbrg(struct udevice *dev, int 
baudrate)
return 0;
 }
 
-static int stm32_serial_setparity(struct udevice *dev, enum serial_par parity)
+static int stm32_serial_setconfig(struct udevice *dev, uint serial_config)
 {
struct stm32x7_serial_platdata *plat = dev_get_platdata(dev);
bool stm32f4 = plat->uart_info->stm32f4;
u8 uart_enable_bit = plat->uart_info->uart_enable_bit;
u32 cr1 = plat->base + CR1_OFFSET(stm32f4);
u32 config = 0;
-
-   if (stm32f4)
-   return -EINVAL; /* not supported in driver*/
+   u8 parity = SERIAL_GET_PARITY(serial_config);
+   u8 bits = SERIAL_GET_BITS(serial_config);
+   u8 stop = SERIAL_GET_STOP(serial_config);
+
+   /*
+* only parity config is implemented, check if other serial settings
+* are the default one.
+* (STM32F4 serial IP didn't support parity setting)
+*/
+   if (bits != SERIAL_8_BITS || stop != SERIAL_ONE_STOP || stm32f4)
+   return -ENOTSUPP; /* not supported in driver*/
 
clrbits_le32(cr1, USART_CR1_RE | USART_CR1_TE | BIT(uart_enable_bit));
/* update usart configuration (uart need to be disable)
-* PCE: parity check control
+* PCE: parity check enable
 * PS : '0' : Even / '1' : Odd
 * M[1:0] = '00' : 8 Data bits
 * M[1:0] = '01' : 9 Data bits with parity
@@ -77,6 +85,7 @@ static int stm32_serial_setparity(struct udevice *dev, enum 
serial_par parity)
config = USART_CR1_PCE | USART_CR1_M0;
break;
}
+
clrsetbits_le32(cr1,
USART_CR1_PCE | USART_CR1_PS | USART_CR1_M1 |
USART_CR1_M0,
@@ -210,7 +219,7 @@ static const struct dm_serial_ops stm32_serial_ops = {
.pending = stm32_serial_pending,
.getc = stm32_serial_getc,
.setbrg = stm32_serial_setbrg,
-   .setparity = stm32_serial_setparity
+   .setconfig = stm32_serial_setconfig
 };
 
 U_BOOT_DRIVER(serial_stm32) = {
-- 
1.9.1

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


Re: [U-Boot] Converting to SPL_OF_CONTROL

2018-08-01 Thread Alex Kiernan
Hi Johann

On Wed, Aug 1, 2018 at 2:18 PM Alex Kiernan  wrote:
>
> On Wed, Aug 1, 2018 at 12:30 PM Johann Neuhauser
>  wrote:
> >
> > Hello Alex,
> >
> > have you tried to set "u-boot,spl-boot-order" in choosen node?
> >
> > Take a look into:
> > doc/device-tree-bindings/chosen.txt
> >
>
> Thanks, I totally failed to see that.
>
> Let me have an investigate!
>

So that only seems to be implemented for rockchip, but it certainly
looks like it's solving the kind of problem I have. The big thing
you've made me realise is that board_boot_order() is a weak function
that I can override...

I'll see what I can do starting from the rockchip code.

Thanks!

> > Best regards
> >
> > Johann Neuhauser
> >
> > -Ursprüngliche Nachricht-
> > Von: U-Boot [mailto:u-boot-boun...@lists.denx.de] Im Auftrag von Alex 
> > Kiernan
> > Gesendet: Mittwoch, 1. August 2018 12:42
> > An: u-boot ; Simon Glass 
> > Betreff: [U-Boot] Converting to SPL_OF_CONTROL
> >
> > I've long been trying to convert our board (AM3352) to all DM, after 
> > knocking out lots of problems, I've run into one I can't seem to configure 
> > my way around, when I enable SPL_OF_CONTROL.
> >
> > We have MMC2 as our boot device, with no MMC1 (and hence not present in the 
> > DTB). Once we're into full U-Boot this is all okay, we get the board's MMC2 
> > appearing as mmc0 and everything's fine.
> >
> > My problem's during SPL, where the boot device is MMC2, the code tries to 
> > lookup by devnum (which is 1 because it numbers from 0 at this point), 
> > which doesn't exist. I'd expected aliases to work, but we don't seem to 
> > lookup up by alias, only index, so I don't have any way that I can see of 
> > overriding it.
> >
> > If I make this change, then everything works (with the addition of an an 
> > alias for mmc1 = ):
> >
> > diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c index 
> > 0b2f059570..b7544ba183 100644
> > --- a/common/spl/spl_mmc.c
> > +++ b/common/spl/spl_mmc.c
> > @@ -131,7 +131,7 @@ static int spl_mmc_find_device(struct mmc **mmcp,
> > u32 boot_device)
> > }
> >
> >  #if CONFIG_IS_ENABLED(DM_MMC)
> > -   err = uclass_get_device(UCLASS_MMC, mmc_dev, );
> > +   err = uclass_get_device_by_seq(UCLASS_MMC, mmc_dev, );
> > if (!err)
> > *mmcp = mmc_get_mmc_dev(dev);  #else
> >
> > But that feels like a pretty fundamental change to make across every board 
> > and I've no real idea if that would even be the right thing to do, or if I 
> > should be trying to fix this some other way.
> >
> > --
> > Alex Kiernan
> > ___
> > U-Boot mailing list
> > U-Boot@lists.denx.de
> > https://lists.denx.de/listinfo/u-boot
>
>
>
> --
> Alex Kiernan



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


Re: [U-Boot] [ v2 02/10] video: stm32: stm32_ltdc: add bridge to display controller

2018-08-01 Thread Anatolij Gustschin
On Fri, 13 Jul 2018 14:11:10 +0200
Yannick Fertré yannick.fer...@st.com wrote:

> Manage a bridge insert between the display controller & a panel.
> 
> Signed-off-by: Yannick Fertré 
> ---
>  drivers/video/stm32/stm32_ltdc.c | 154 
> +++
>  1 file changed, 92 insertions(+), 62 deletions(-)
> 
> diff --git a/drivers/video/stm32/stm32_ltdc.c 
> b/drivers/video/stm32/stm32_ltdc.c
> index dc6c889..4a1db5e 100644
> --- a/drivers/video/stm32/stm32_ltdc.c
> +++ b/drivers/video/stm32/stm32_ltdc.c
...
> @@ -330,96 +328,128 @@ static int stm32_ltdc_probe(struct udevice *dev)
>   struct video_uc_platdata *uc_plat = dev_get_uclass_platdata(dev);
>   struct video_priv *uc_priv = dev_get_uclass_priv(dev);
>   struct stm32_ltdc_priv *priv = dev_get_priv(dev);
> - struct udevice *panel;
> +#ifdef CONFIG_VIDEO_BRIDGE
> + struct udevice *bridge = NULL;
> +#endif

Please drop ifdef here. See below.

...
> - rate = clk_set_rate(, priv->timing.pixelclock.typ);
> - if (rate < 0) {
> - debug("%s: fail to set pixel clock %d hz %d hz\n",
> -   __func__, priv->timing.pixelclock.typ, rate);
> - return rate;
> +#ifdef CONFIG_VIDEO_BRIDGE
> + ret = uclass_get_device(UCLASS_VIDEO_BRIDGE, 0, );
> + if (ret)
> + debug("No video bridge, or no backlight on bridge\n");
> +
> + if (bridge) {
> + ret = video_bridge_attach(bridge);
> + if (ret) {
> + dev_err(dev, "fail to attach bridge\n");
> + return ret;
> + }
>   }
> -
> - debug("%s: Set pixel clock req %d hz get %d hz\n", __func__,
> -   priv->timing.pixelclock.typ, rate);
> -
> +#endif

Can we do without ifdefs and use IS_ENABLED() instead ?
E.g. like:

if (IS_ENABLED(CONFIG_VIDEO_BRIDGE)) {
ret = uclass_get_device(UCLASS_VIDEO_BRIDGE, 0, );
...
}

...
> +#ifdef CONFIG_VIDEO_BRIDGE
> + if (bridge) {
> + ret = video_bridge_set_backlight(bridge, 80);
> + if (ret) {
> + dev_err(dev, "fail to set backlight\n");
> + return ret;
> + }
> + } else {
> + ret = panel_enable_backlight(panel);
> + if (ret) {
> + dev_err(dev, "panel %s enable backlight error %d\n",
> + panel->name, ret);
> + return ret;
> + }
> + }
> +#else
> + ret = panel_enable_backlight(panel);
> + if (ret) {
> + dev_err(dev, "panel %s enable backlight error %d\n",
> + panel->name, ret);
> + return ret;
> + }
> +#endif

Please reduce code duplication:

if (!bridge) {
ret = panel_enable_backlight(panel);
if (ret) {
dev_err(dev, "panel %s enable backlight error %d\n",
panel->name, ret);
return ret;
}
} else if (IS_ENABLED(CONFIG_VIDEO_BRIDGE)) {
ret = video_bridge_set_backlight(bridge, 80);
if (ret) {
dev_err(dev, "fail to set backlight\n");
return ret;
}
}

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


Re: [U-Boot] Please pull ARC changes or 2018.09-rc2

2018-08-01 Thread Tom Rini
On Tue, Jul 31, 2018 at 04:59:33AM +, Alexey Brodkin wrote:

> Hi Tom,
> 
> The following changes since commit 5a0007d481c0fcd2d422dd48b2a129dd8e8a272a:
> 
>   Prepare v2017.09-rc1 (2018-07-30 21:47:29 -0400)
> 
> are available in the Git repository at:
> 
>   git://git.denx.de/u-boot-arc.git tags/arc-updates-for-2018.09-rc2
> 
> for you to fetch changes up to 8f590063ba635264303b1713c421df331743fd46:
> 
>   ARC: Enable unaligned access in hardware if compiler uses it (2018-07-31 
> 07:49:47 +0300)
> 

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] Please pull u-boot-mpc85xx master

2018-08-01 Thread Tom Rini
On Tue, Jul 31, 2018 at 05:25:52PM +, York Sun wrote:

> Tom,
> 
> The following changes since commit 2547e91dc15e5203e15d4ebde9172174743b14a7:
> 
>   tegra: Indicate that binman makes all three output files (2018-07-26
> 15:49:40 -0400)
> 
> are available in the git repository at:
> 
>   git://git.denx.de/u-boot-mpc85xx.git
> 
> for you to fetch changes up to 9dcb9d763d328da903194d0f14f97d9620a6f52d:
> 
>   Revert "powerpc/T104xRDB: Fix endian access issue on EHCI
> intinalization" (2018-07-31 10:19:42 -0700)
> 

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 v1 1/2] dm: serial: Replace setparity by setconfig

2018-08-01 Thread Simon Glass
Hi Patrice,

On 31 July 2018 at 07:53, Patrice CHOTARD  wrote:
>
> Hi Simon
>
> On 07/31/2018 01:52 PM, Simon Glass wrote:
> > Hi Patrice,
> >
> > On 30 July 2018 at 09:23, Patrice Chotard  wrote:
> >> From: Patrick Delaunay 
> >>
> >> Replace setparity by more generic setconfig ops
> >> to allow uart parity, bits word length and stop bits
> >> number change.
> >>
> >> Adds SERIAL_GET_PARITY/BITS/STOP macros.
> >>
> >> Signed-off-by: Patrick Delaunay 
> >> Signed-off-by: Patrice Chotard 
> >> ---
> >>
> >>   drivers/serial/serial-uclass.c | 14 ++
> >>   include/serial.h   | 42 
> >> +++---
> >>   2 files changed, 53 insertions(+), 3 deletions(-)
> >>
> >> diff --git a/drivers/serial/serial-uclass.c 
> >> b/drivers/serial/serial-uclass.c
> >> index 321d23ee93bf..9f523751ce17 100644
> >> --- a/drivers/serial/serial-uclass.c
> >> +++ b/drivers/serial/serial-uclass.c
> >> @@ -287,6 +287,18 @@ void serial_setbrg(void)
> >>  ops->setbrg(gd->cur_serial_dev, gd->baudrate);
> >>   }
> >>
> >> +void serial_setconfig(u8 config)
> >> +{
> >> +   struct dm_serial_ops *ops;
> >> +
> >> +   if (!gd->cur_serial_dev)
> >> +   return;
> >> +
> >> +   ops = serial_get_ops(gd->cur_serial_dev);
> >> +   if (ops->setconfig)
> >> +   ops->setconfig(gd->cur_serial_dev, config);
> >> +}
> >> +
> >>   void serial_stdio_init(void)
> >>   {
> >>   }
> >> @@ -398,6 +410,8 @@ static int serial_post_probe(struct udevice *dev)
> >>  ops->pending += gd->reloc_off;
> >>  if (ops->clear)
> >>  ops->clear += gd->reloc_off;
> >> +   if (ops->setconfig)
> >> +   ops->setconfig += gd->reloc_off;
> >>   #if CONFIG_POST & CONFIG_SYS_POST_UART
> >>  if (ops->loop)
> >>  ops->loop += gd->reloc_off
> >> diff --git a/include/serial.h b/include/serial.h
> >> index b9ef6d91c9c5..61c1362e9e32 100644
> >> --- a/include/serial.h
> >> +++ b/include/serial.h
> >> @@ -73,6 +73,39 @@ enum serial_par {
> >>  SERIAL_PAR_EVEN
> >>   };
> >>
> >> +#define SERIAL_PAR_MASK0x03
> >> +#define SERIAL_PAR_SHIFT   0
> >> +#define SERIAL_GET_PARITY(config) \
> >> +   ((config & SERIAL_PAR_MASK) >> SERIAL_PAR_SHIFT)
> >> +
> >> +enum serial_bits {
> >> +   SERIAL_5_BITS,
> >> +   SERIAL_6_BITS,
> >> +   SERIAL_7_BITS,
> >> +   SERIAL_8_BITS
> >> +};
> >> +
> >> +#define SERIAL_BITS_MASK   0x0C
> >> +#define SERIAL_BITS_SHIFT  2
> >
> > For consistency:
> >
> > #define SERIAL_BITS_SHIFT  2
> > #define SERIAL_BITS_MASK   (0x3 << SERIAL_BITS_SHIFT)
>
> Ok
>
> >
> >> +#define SERIAL_GET_BITS(config) \
> >> +   ((config & SERIAL_BITS_MASK) >> SERIAL_BITS_SHIFT)
> >> +
> >> +enum serial_stop {
> >> +   SERIAL_HALF_STOP,   /* 0.5 stop bit */
> >> +   SERIAL_ONE_STOP,/*   1 stop bit */
> >> +   SERIAL_ONE_HALF_STOP,   /* 1.5 stop bit */
> >> +   SERIAL_TWO_STOP /*   2 stop bit */
> >> +};
> >> +
> >> +#define SERIAL_STOP_MASK   0x30
> >> +#define SERIAL_STOP_SHIFT  4
> >
> > same here
>
> ok
>
> >
> >> +#define SERIAL_GET_STOP(config) \
> >> +   ((config & SERIAL_STOP_MASK) >> SERIAL_STOP_SHIFT)
> >> +
> >> +#define SERIAL_DEFAULT_CONFIG  SERIAL_PAR_NONE << SERIAL_PAR_SHIFT | \
> >> +   SERIAL_8_BITS << SERIAL_BITS_SHIFT | \
> >> +   SERIAL_ONE_STOP << SERIAL_STOP_SHIFT
> >> +
> >>   /**
> >>* struct struct dm_serial_ops - Driver model serial operations
> >>*
> >> @@ -150,15 +183,18 @@ struct dm_serial_ops {
> >>  int (*loop)(struct udevice *dev, int on);
> >>   #endif
> >>  /**
> >> -* setparity() - Set up the parity
> >> +* setconfig() - Set up the uart configuration
> >> +* (parity, 5/6/7/8 bits word length, stop bits)
> >>   *
> >> -* Set up a new parity for this device.
> >> +* Set up a new config for this device.
> >>   *
> >>   * @dev: Device pointer
> >>   * @parity: parity to use
> >> +* @bits: bits number to use
> >> +* @stop: stop bits number to use
> >>   * @return 0 if OK, -ve on error
> >>   */
> >> -   int (*setparity)(struct udevice *dev, enum serial_par parity);
> >> +   int (*setconfig)(struct udevice *dev, u8 serial_config);
> >
> > Please make this uint instead of u8. There is no point in using u8
> > since the compiler will use a register anyway. It can only make code
> > size worse, if the compile add masking, etc.
>
> ok
>
> >
> >>   };
> >>
> >>   /**
> >> --
> >> 1.9.1
> >>
> >
> > Also you need a serial_setconfig() function call in the uclass so
> > people can call it.
>
> I already add serial_setconfig() function call in serial-uclass at the
> beginning of this patch ;-)

OK good. Please change u8 there too :-)

>
> >
> > Perhaps that could have separate 

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

2018-08-01 Thread Heinrich Schuchardt


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.

Best regards

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


Re: [U-Boot] U-Boot 2018.07 Still Broken for Allwinner H3 SoCs

2018-08-01 Thread Peter Robinson
On Tue, Jul 10, 2018 at 4:04 AM, Chen-Yu Tsai  wrote:
> This is on a Libre Computer ALL-H3-CC H3 variant. Still running a
> bisect, but v2018.07-rc1 is a working version. From the EHCI error
> messages, I'm thinking it might be related to the USB changes lately.
> Not sure if any other SoCs (ex. A64) are broken or not at the moment.

I'm still seeing this issue in 2018.09 RC1, what's the status of a fix for this?

> See log:
>
> U-Boot SPL 2018.07 (Jul 10 2018 - 10:21:03 +0800)
> DRAM: 1024 MiB
> Trying to boot from MMC1
>
>
> U-Boot 2018.07 (Jul 10 2018 - 10:21:03 +0800) Allwinner Technology
>
> CPU:   Allwinner H3 (SUN8I 1680)
> Model: Libre Computer Board ALL-H3-CC H3
> DRAM:  1 GiB
> MMC:   SUNXI SD/MMC: 0
> Loading Environment from FAT... Unable to use mmc 0:1... Failed (-5)
> In:serial
> Out:   serial
> Err:   serial
> Net:   phy interface0
> eth0: ethernet@1c3
> starting USB...
> USB0:   USB EHCI 1.00
> USB1:   USB OHCI 1.0
> USB2:   USB EHCI 1.00
> USB3:   USB OHCI 1.0
> USB4:   USB EHCI 1.00
> USB5:   USB OHCI 1.0
> scanning bus 0 for devices... 1 USB Device(s) found
> scanning bus 2 for devices... 1 USB Device(s) found
> scanning bus 4 for devices... 1 USB Device(s) found
>scanning usb for storage devices... 0 Storage Device(s) found
> Hit any key to stop autoboot:  0
> switch to partitions #0, OK
> mmc0 is current device
> Scanning mmc 0:1...
> Found U-Boot script /boot/boot.scr
> 385 bytes read in 8 ms (46.9 KiB/s)
> ## Executing script at 4310
> 6343768 bytes read in 295 ms (20.5 MiB/s)
> 18710 bytes read in 10 ms (1.8 MiB/s)
> ## Flattened Device Tree blob at 4300
>Booting using the fdt blob at 0x4300
> EHCI failed to shut down host controller.
> EHCI failed to shut down host controller.
> EHCI failed to shut down host controller.
>Loading Device Tree to 49ff8000, end 49fff915 ... OK
>
> Starting kernel ...
>
> data abort
> pc : [<7dfadc6c>]  lr : [<7df82ed7>]
> reloc pc : [<4a02bc6c>]lr : [<4a000ed7>]
> sp : 79f5ce90  ip : 79f62b8a fp : 0003
> r10: 7dfc3d14  r9 : 79f61ed8 r8 : 0400
> r7 :   r6 : 4200 r5 : 49ff8000  r4 : 
> r3 : 49ff8000  r2 : 49ff8000 r1 :   r0 : 
> Flags: nZCv  IRQs off  FIQs off  Mode UK6_32
> Code: e12fff1e e52de008 fa01 e3a0 (e49df008)
> Resetting CPU ...
>
> resetting ...
> ___
> 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] Converting to SPL_OF_CONTROL

2018-08-01 Thread Alex Kiernan
On Wed, Aug 1, 2018 at 12:30 PM Johann Neuhauser
 wrote:
>
> Hello Alex,
>
> have you tried to set "u-boot,spl-boot-order" in choosen node?
>
> Take a look into:
> doc/device-tree-bindings/chosen.txt
>

Thanks, I totally failed to see that.

Let me have an investigate!

> Best regards
>
> Johann Neuhauser
>
> -Ursprüngliche Nachricht-
> Von: U-Boot [mailto:u-boot-boun...@lists.denx.de] Im Auftrag von Alex Kiernan
> Gesendet: Mittwoch, 1. August 2018 12:42
> An: u-boot ; Simon Glass 
> Betreff: [U-Boot] Converting to SPL_OF_CONTROL
>
> I've long been trying to convert our board (AM3352) to all DM, after knocking 
> out lots of problems, I've run into one I can't seem to configure my way 
> around, when I enable SPL_OF_CONTROL.
>
> We have MMC2 as our boot device, with no MMC1 (and hence not present in the 
> DTB). Once we're into full U-Boot this is all okay, we get the board's MMC2 
> appearing as mmc0 and everything's fine.
>
> My problem's during SPL, where the boot device is MMC2, the code tries to 
> lookup by devnum (which is 1 because it numbers from 0 at this point), which 
> doesn't exist. I'd expected aliases to work, but we don't seem to lookup up 
> by alias, only index, so I don't have any way that I can see of overriding it.
>
> If I make this change, then everything works (with the addition of an an 
> alias for mmc1 = ):
>
> diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c index 
> 0b2f059570..b7544ba183 100644
> --- a/common/spl/spl_mmc.c
> +++ b/common/spl/spl_mmc.c
> @@ -131,7 +131,7 @@ static int spl_mmc_find_device(struct mmc **mmcp,
> u32 boot_device)
> }
>
>  #if CONFIG_IS_ENABLED(DM_MMC)
> -   err = uclass_get_device(UCLASS_MMC, mmc_dev, );
> +   err = uclass_get_device_by_seq(UCLASS_MMC, mmc_dev, );
> if (!err)
> *mmcp = mmc_get_mmc_dev(dev);  #else
>
> But that feels like a pretty fundamental change to make across every board 
> and I've no real idea if that would even be the right thing to do, or if I 
> should be trying to fix this some other way.
>
> --
> Alex Kiernan
> ___
> U-Boot mailing list
> U-Boot@lists.denx.de
> https://lists.denx.de/listinfo/u-boot



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


[U-Boot] [PATCH] SPL: fit signature: don´t strip off signature node and sub nodes from dtb

2018-08-01 Thread Johann Neuhauser
Hello,

I have implemented verified boot in SPL and build my SPL image with "make 
EXT_DTB=/path/to/dtb/with/embedded/pub-key SPL".
In the build process all nodes except chosen and config are stripped off for 
SPL and TPL builds.

Don´t know if this is a good behavior to remove everything except the mentioned 
nodes...
Probably there is another way to embed a precompiled dtb in the SPL image?

The attached patch adds the needed signature and sub nodes for verified boot to 
cmd_fdtgrep in scripts/Makefile.lib.

Best regards

Johann Neuhauser 
DH electronics GmbH



0001-SPL-fit-signature-don-t-strip-off-signature-node-and.patch
Description: 0001-SPL-fit-signature-don-t-strip-off-signature-node-and.patch
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH] efi_loader: don't allocate unusable RAM

2018-08-01 Thread Peter Robinson
>>> On 07/31/2018 02:03 PM, Alexander Graf wrote:
>
> Am 31.07.2018 um 21:44 schrieb Stephen Warren :
>
> From: Stephen Warren 
>
> Some boards define a maximum usable RAM top that's more restrictive
> than
> the ranges defined by U-Boot's memory bank definitions[1]. In this
> case,
> the unusable RAM isn't mapped in the page tables, and so the EFI code
> must
> not attempt to allocate RAM from outside the usable regions. Fix
> efi_find_free_memory() to detect when max_addr is unconstrained or out
> of
> range, and substitue a valid value.
>
> [1] For example, when some peripherals can't access RAM above 4GiB,
> it's
> simplest to force U-Boot's ram_top to a smaller value to avoid dealing
> with this issue more explicitly. However, the RAM bank definitions
> still
> describe the unusable RAM so that the booted OS has access to it, since
> the OS can typically deal with such restrictions in a more complex
> manner.

 That's what we have the efi bounce buffers for. Can't we just enable
 those for tegra?
>>>
>>>
>>> No, because that wouldn't help all the non-EFI code, or cause the RAM to
>>> be mapped in the page tables due to the non-EFI code not needing it.
>>
>>
>> The non-efi code can still rely on ram_top just fine, no? I was more
>> thinking of enabling the bounce buffer config option as alternative to your
>> patch.
>
>
> A lot more besides enabling that option would have to be done. The issue
> here is that EFI is attempting to use RAM that's not in the page tables and
> hence crashes. Enabling bounce buffers alone isn't going to help that; we'd
> also have to rejig the U-Boot MMU code to set up page table entries for the
> entire of the RAM banks rather than just the usable RAM, and then we've have
> to develop some new way of preventing U-Boot from mapping RAM that's part of
> the RAM banks but shouldn't be mapped because e.g. it's part of the secure
> carveout that can't be mapped in the MMU in order to ensure that the CPU
> never pre-fetches that RAM to avoid taking security faults on the fetch. The
> fact that ram_top is lower than the HW-defined RAM limit exists for reasons
> other than just preventing use of RAM that some peripheral HW can't access,
> so bounce buffers will only solve one of the causes, not everything.

For reference on the TX1 this patch doesn't fix the problem I've seen
on TX series that I previously sent the patch enabling the bounce
buffer option on the TX2, if I enable bounce buffers it works as I
need with or without this patch. I didn't test TX2 but can if it's
useful (I had to power up the TX1 for other reasons this morning).

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


Re: [U-Boot] Pull request: u-boot-sunxi/master

2018-08-01 Thread Tom Rini
On Wed, Aug 01, 2018 at 08:58:10PM +0800, Chen-Yu Tsai wrote:
> On Wed, Aug 1, 2018 at 8:55 PM, Tom Rini  wrote:
> > On Wed, Aug 01, 2018 at 08:43:17PM +0800, Chen-Yu Tsai wrote:
> >> On Wed, Aug 1, 2018 at 7:47 PM, Jagan Teki  
> >> wrote:
> >> > On Wed, Aug 1, 2018 at 4:43 PM, Tom Rini  wrote:
> >> >> On Tue, Jul 31, 2018 at 11:41:50PM +0530, Jagan Teki wrote:
> >> >>
> >> >>> Hi Tom,
> >> >>>
> >> >>> Please pull this PR.
> >> >>>
> >> >>> thanks,
> >> >>> Jagan.
> >> >>>
> >> >>> The following changes since commit 
> >> >>> 5a0007d481c0fcd2d422dd48b2a129dd8e8a272a:
> >> >>>
> >> >>>   Prepare v2017.09-rc1 (2018-07-30 21:47:29 -0400)
> >> >>>
> >> >>> are available in the Git repository at:
> >> >>>
> >> >>>   git://git.denx.de/u-boot-sunxi.git master
> >> >>>
> >> >>> for you to fetch changes up to 
> >> >>> 89a897fc4d78e31332e5899e977d8bf3c82abafa:
> >> >>>
> >> >>>   board: sun50i: h6: Add OrangePi One Plus initial support (2018-07-31 
> >> >>> 20:50:01 +0530)
> >> >>>
> >> >>
> >> >> For the moment, on hold.  pine_h64 doesn't link (see
> >> >> https://travis-ci.org/trini/u-boot/jobs/410579615) but I bet Andre's
> >> >> changes to save some space on aarch64 will get it to fit in, and I need
> >> >> to see if I'm ready to apply them.
> >> >
> >> > I though of inform the same, but for h6 atf need to use it from
> >> > mainline here all a64 boards seems failing. I didn't reproduce this
> >> > manually.
> >> >
> >> > +WARNING: BL31 file bl31.bin NOT found, resulting binary is 
> >> > non-functional
> >>
> >> The cause is obvious. The ATF blob is missing from the environment.
> >> If TravisCI is only used to test building, maybe we could just put an
> >> empty bl31.bin there to make it happy.
> >
> > Please note that the above is NOT the problem.  That's the non-fatal
> > warning that your resulting binary won't work as there's no bl31.bin.
> > The problem is:
> > +aarch64-linux-ld.bfd: u-boot-spl section `.u_boot_list' will not fit in 
> > region `.sram'
> > +aarch64-linux-ld.bfd: region `.sram' overflowed by 48 bytes
> > +make[2]: *** [spl/u-boot-spl] Error 1
> > +make[1]: *** [spl/u-boot-spl] Error 2
> > +make: *** [sub-make] Error 2
> 
> Yeah I noticed. Just pointing out if we want to get rid of the ATF noise.

Ah, no.  The noise is very intentional so that it's clear to humans that
what they made won't boot.

-- 
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] Pull request: u-boot-sunxi/master

2018-08-01 Thread Chen-Yu Tsai
On Wed, Aug 1, 2018 at 8:55 PM, Tom Rini  wrote:
> On Wed, Aug 01, 2018 at 08:43:17PM +0800, Chen-Yu Tsai wrote:
>> On Wed, Aug 1, 2018 at 7:47 PM, Jagan Teki  
>> wrote:
>> > On Wed, Aug 1, 2018 at 4:43 PM, Tom Rini  wrote:
>> >> On Tue, Jul 31, 2018 at 11:41:50PM +0530, Jagan Teki wrote:
>> >>
>> >>> Hi Tom,
>> >>>
>> >>> Please pull this PR.
>> >>>
>> >>> thanks,
>> >>> Jagan.
>> >>>
>> >>> The following changes since commit 
>> >>> 5a0007d481c0fcd2d422dd48b2a129dd8e8a272a:
>> >>>
>> >>>   Prepare v2017.09-rc1 (2018-07-30 21:47:29 -0400)
>> >>>
>> >>> are available in the Git repository at:
>> >>>
>> >>>   git://git.denx.de/u-boot-sunxi.git master
>> >>>
>> >>> for you to fetch changes up to 89a897fc4d78e31332e5899e977d8bf3c82abafa:
>> >>>
>> >>>   board: sun50i: h6: Add OrangePi One Plus initial support (2018-07-31 
>> >>> 20:50:01 +0530)
>> >>>
>> >>
>> >> For the moment, on hold.  pine_h64 doesn't link (see
>> >> https://travis-ci.org/trini/u-boot/jobs/410579615) but I bet Andre's
>> >> changes to save some space on aarch64 will get it to fit in, and I need
>> >> to see if I'm ready to apply them.
>> >
>> > I though of inform the same, but for h6 atf need to use it from
>> > mainline here all a64 boards seems failing. I didn't reproduce this
>> > manually.
>> >
>> > +WARNING: BL31 file bl31.bin NOT found, resulting binary is non-functional
>>
>> The cause is obvious. The ATF blob is missing from the environment.
>> If TravisCI is only used to test building, maybe we could just put an
>> empty bl31.bin there to make it happy.
>
> Please note that the above is NOT the problem.  That's the non-fatal
> warning that your resulting binary won't work as there's no bl31.bin.
> The problem is:
> +aarch64-linux-ld.bfd: u-boot-spl section `.u_boot_list' will not fit in 
> region `.sram'
> +aarch64-linux-ld.bfd: region `.sram' overflowed by 48 bytes
> +make[2]: *** [spl/u-boot-spl] Error 1
> +make[1]: *** [spl/u-boot-spl] Error 2
> +make: *** [sub-make] Error 2

Yeah I noticed. Just pointing out if we want to get rid of the ATF noise.

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


Re: [U-Boot] [PATCH] video: kconfig: remove DM_I2C dependency of I2C_EDID

2018-08-01 Thread Anatolij Gustschin
On Mon, 30 Jul 2018 09:11:31 -0400
Luis Araneda luaran...@gmail.com wrote:

> Hi,
> 
> On Wed, Jul 4, 2018 at 2:40 AM Luis Araneda  wrote:
> >
> > Drop the DM_I2C dependency, as the library only implements
> > the parsing of EDID data and doesn't depend on any driver
> >
> > One user of this library, the i2c command, implements
> > support for legacy and DM I2C drivers
> >
> > Tested on a Zynq board, whose I2C driver is not ported
> > yet to DM
> >
> > Signed-off-by: Luis Araneda 
> > ---
> >  drivers/video/Kconfig | 1 -
> >  1 file changed, 1 deletion(-)

Applied to u-boot-video/master, thanks!

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


Re: [U-Boot] Pull request: u-boot-sunxi/master

2018-08-01 Thread Tom Rini
On Wed, Aug 01, 2018 at 08:43:17PM +0800, Chen-Yu Tsai wrote:
> On Wed, Aug 1, 2018 at 7:47 PM, Jagan Teki  wrote:
> > On Wed, Aug 1, 2018 at 4:43 PM, Tom Rini  wrote:
> >> On Tue, Jul 31, 2018 at 11:41:50PM +0530, Jagan Teki wrote:
> >>
> >>> Hi Tom,
> >>>
> >>> Please pull this PR.
> >>>
> >>> thanks,
> >>> Jagan.
> >>>
> >>> The following changes since commit 
> >>> 5a0007d481c0fcd2d422dd48b2a129dd8e8a272a:
> >>>
> >>>   Prepare v2017.09-rc1 (2018-07-30 21:47:29 -0400)
> >>>
> >>> are available in the Git repository at:
> >>>
> >>>   git://git.denx.de/u-boot-sunxi.git master
> >>>
> >>> for you to fetch changes up to 89a897fc4d78e31332e5899e977d8bf3c82abafa:
> >>>
> >>>   board: sun50i: h6: Add OrangePi One Plus initial support (2018-07-31 
> >>> 20:50:01 +0530)
> >>>
> >>
> >> For the moment, on hold.  pine_h64 doesn't link (see
> >> https://travis-ci.org/trini/u-boot/jobs/410579615) but I bet Andre's
> >> changes to save some space on aarch64 will get it to fit in, and I need
> >> to see if I'm ready to apply them.
> >
> > I though of inform the same, but for h6 atf need to use it from
> > mainline here all a64 boards seems failing. I didn't reproduce this
> > manually.
> >
> > +WARNING: BL31 file bl31.bin NOT found, resulting binary is non-functional
> 
> The cause is obvious. The ATF blob is missing from the environment.
> If TravisCI is only used to test building, maybe we could just put an
> empty bl31.bin there to make it happy.

Please note that the above is NOT the problem.  That's the non-fatal
warning that your resulting binary won't work as there's no bl31.bin.
The problem is:
+aarch64-linux-ld.bfd: u-boot-spl section `.u_boot_list' will not fit in region 
`.sram'
+aarch64-linux-ld.bfd: region `.sram' overflowed by 48 bytes
+make[2]: *** [spl/u-boot-spl] Error 1
+make[1]: *** [spl/u-boot-spl] Error 2
+make: *** [sub-make] Error 2

-- 
Tom


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


[U-Boot] [PATCH v2 7/8] ARM: Odroid XU3: Fix the dwmci_exynos *priv data assignment for DM_MMC (sdr_timing)

2018-08-01 Thread Lukasz Majewski
By convention for DM_MMC the host->priv is used to store struct udevice
*dev pointer.

Unfortunately, the legacy Exynos DW MMC code uses this field to
store pointer to dwmci_exynos_priv_data struct
Hence, we do need to get data in other way - namely by using container_of
when host pointer is present.
In this way the sdr_timing data is properly accessed.

Signed-off-by: Lukasz Majewski 
Tested-by: Anand Moon 

---

Changes in v2:
- Add tested-by
- Rebase on the newest main line

 drivers/mmc/exynos_dw_mmc.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/exynos_dw_mmc.c b/drivers/mmc/exynos_dw_mmc.c
index 49c4f7634830..cd0fa4c6341b 100644
--- a/drivers/mmc/exynos_dw_mmc.c
+++ b/drivers/mmc/exynos_dw_mmc.c
@@ -46,8 +46,12 @@ struct dwmci_exynos_priv_data {
  */
 static void exynos_dwmci_clksel(struct dwmci_host *host)
 {
+#ifdef CONFIG_DM_MMC
+   struct dwmci_exynos_priv_data *priv =
+   container_of(host, struct dwmci_exynos_priv_data, host);
+#else
struct dwmci_exynos_priv_data *priv = host->priv;
-
+#endif
dwmci_writel(host, DWMCI_CLKSEL, priv->sdr_timing);
 }
 
-- 
2.11.0

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


[U-Boot] [PATCH v2 4/8] ARM: Odroid XU3: Fix autoboot.cmd to use ${mmcbootdev} instead of hardcoded 0

2018-08-01 Thread Lukasz Majewski
This commit adjusts the autoboot.cmd file to use ${mmcbootdev} instead of
hardcoded value 0.

This is necessary to allow booting this board from the SD card.

Signed-off-by: Lukasz Majewski 
Tested-by: Anand Moon 

---

Changes in v2:
- Add tested-by
- Rebase on the newest main line

 board/samsung/common/bootscripts/autoboot.cmd | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/board/samsung/common/bootscripts/autoboot.cmd 
b/board/samsung/common/bootscripts/autoboot.cmd
index 1faed8ba0c1a..11c724c4e095 100644
--- a/board/samsung/common/bootscripts/autoboot.cmd
+++ b/board/samsung/common/bootscripts/autoboot.cmd
@@ -74,15 +74,15 @@ setenv boot_img "
 
  Routine: autoboot - choose proper boot path
 setenv autoboot "
-if test -e mmc 0:${mmcbootpart} Image.itb; then
+if test -e mmc ${mmcbootdev}:${mmcbootpart} Image.itb; then
echo Found kernel image: Image.itb;
run setboot_fit;
run boot_img;
-elif test -e mmc 0:${mmcbootpart} zImage; then
+elif test -e mmc ${mmcbootdev}:${mmcbootpart} zImage; then
echo Found kernel image: zImage;
run setboot_zimg;
run boot_img;
-elif test -e mmc 0:${mmcbootpart} uImage; then
+elif test -e mmc ${mmcbootdev}:${mmcbootpart} uImage; then
echo Found kernel image: uImage;
run setboot_uimg;
run boot_img;
-- 
2.11.0

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


[U-Boot] [PATCH v2 8/8] ARM: Odroid XU3: Modify exynos dw_mmc driver to support Odroid XU3 in DM MMC

2018-08-01 Thread Lukasz Majewski
This commit enables support for Exynos Designware MMC driver based on DM.

Signed-off-by: Lukasz Majewski 
Tested-by: Anand Moon 

---

Changes in v2:
- Add tested-by
- Rebase on the newest main line

 drivers/mmc/exynos_dw_mmc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/mmc/exynos_dw_mmc.c b/drivers/mmc/exynos_dw_mmc.c
index cd0fa4c6341b..435ccac59421 100644
--- a/drivers/mmc/exynos_dw_mmc.c
+++ b/drivers/mmc/exynos_dw_mmc.c
@@ -295,6 +295,7 @@ static int exynos_dwmmc_bind(struct udevice *dev)
 
 static const struct udevice_id exynos_dwmmc_ids[] = {
{ .compatible = "samsung,exynos4412-dw-mshc" },
+   { .compatible = "samsung,exynos-dwmmc" },
{ }
 };
 
-- 
2.11.0

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


[U-Boot] [PATCH v2 6/8] ARM: Odroid XU3: MAINTAINERS: Add a co-maintainer for OdroidXU3

2018-08-01 Thread Lukasz Majewski
Signed-off-by: Lukasz Majewski 
Tested-by: Anand Moon 

---

Changes in v2:
- Add tested-by
- Rebase on the newest main line

 board/samsung/smdk5420/MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)

diff --git a/board/samsung/smdk5420/MAINTAINERS 
b/board/samsung/smdk5420/MAINTAINERS
index 590a1140b07e..31c00360f287 100644
--- a/board/samsung/smdk5420/MAINTAINERS
+++ b/board/samsung/smdk5420/MAINTAINERS
@@ -11,6 +11,7 @@ F:configs/peach-pi_defconfig
 
 ODROID-XU3 BOARD
 M: Jaehoon Chung 
+M: Lukasz Majewski 
 S: Maintained
 F: board/samsung/smdk5420/
 F: include/configs/odroid_xu3.h
-- 
2.11.0

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


[U-Boot] [PATCH v2 3/8] ARM: Odroid XU3: Enable driver model support for MMC (DM_MMC)

2018-08-01 Thread Lukasz Majewski
This commit enables support for DW_MMC running with driver model.

Signed-off-by: Lukasz Majewski 
Tested-by: Anand Moon 

---

Changes in v2:
- Add tested-by
- Rebase on the newest main line

 configs/odroid-xu3_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configs/odroid-xu3_defconfig b/configs/odroid-xu3_defconfig
index 6398c2cd0d6a..632542d98420 100644
--- a/configs/odroid-xu3_defconfig
+++ b/configs/odroid-xu3_defconfig
@@ -29,6 +29,7 @@ CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
 CONFIG_ADC=y
 CONFIG_ADC_EXYNOS=y
 CONFIG_DFU_MMC=y
+CONFIG_DM_MMC=y
 CONFIG_MMC_DW=y
 CONFIG_NETDEVICES=y
 CONFIG_SMC911X=y
-- 
2.11.0

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


[U-Boot] [PATCH v2 5/8] ARM: Odroid XU3: Adjust BOOT_TARGET_DEVICES to allow booting from SD card (mmc2)

2018-08-01 Thread Lukasz Majewski
This change is necessary to allow booting the Odroid XU3 from SD card
after enabling the DM_MMC support.

After this change the SD card mmc IP block is correctly enumerated as mmc2
(and not as mmc1 as in the legacy code).

Signed-off-by: Lukasz Majewski 
Tested-by: Anand Moon 

---

Changes in v2:
- Add tested-by
- Rebase on the newest main line

 include/configs/exynos5-common.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/configs/exynos5-common.h b/include/configs/exynos5-common.h
index a7621fc701b2..cd2a9046afec 100644
--- a/include/configs/exynos5-common.h
+++ b/include/configs/exynos5-common.h
@@ -138,6 +138,7 @@
 #define BOOT_TARGET_DEVICES(func) \
func(MMC, mmc, 1) \
func(MMC, mmc, 0) \
+   func(MMC, mmc, 2) \
func(PXE, pxe, na) \
func(DHCP, dhcp, na)
 
-- 
2.11.0

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


[U-Boot] [PATCH v2 2/8] ARM: Odroid XU3: config: Disable SDHCI support in the Odroid XU3

2018-08-01 Thread Lukasz Majewski
The Exynos5422 is solely using DW MMC IP block to support eMMC/SD devices,
hence the SDHCI code doesn't need to be compiled it.

Signed-off-by: Lukasz Majewski 
Tested-by: Anand Moon 

---

Changes in v2:
- Add tested-by
- Rebase on the newest main line

 configs/odroid-xu3_defconfig | 2 --
 1 file changed, 2 deletions(-)

diff --git a/configs/odroid-xu3_defconfig b/configs/odroid-xu3_defconfig
index 5943c19cf9b3..6398c2cd0d6a 100644
--- a/configs/odroid-xu3_defconfig
+++ b/configs/odroid-xu3_defconfig
@@ -30,8 +30,6 @@ CONFIG_ADC=y
 CONFIG_ADC_EXYNOS=y
 CONFIG_DFU_MMC=y
 CONFIG_MMC_DW=y
-CONFIG_MMC_SDHCI=y
-CONFIG_MMC_SDHCI_S5P=y
 CONFIG_NETDEVICES=y
 CONFIG_SMC911X=y
 CONFIG_SMC911X_BASE=0x500
-- 
2.11.0

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


[U-Boot] [PATCH v2 1/8] ARM: dw_mmc: Exclude dwmci Exynos priv_data allocation from exynos_dwmci_get_config()

2018-08-01 Thread Lukasz Majewski
This commit prevents memory leak when this function is used with DM_MMC
as the struct dwmci_exynos_priv_data is already allocated by DM.

It is necessary for NON DM aware devices to allocate this struct first.

Signed-off-by: Lukasz Majewski 
Tested-by: Anand Moon 

---

Changes in v2:
- Add tested-by
- Rebase on the newest main line

 drivers/mmc/exynos_dw_mmc.c | 30 +++---
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/drivers/mmc/exynos_dw_mmc.c b/drivers/mmc/exynos_dw_mmc.c
index 865fdf4dbba0..49c4f7634830 100644
--- a/drivers/mmc/exynos_dw_mmc.c
+++ b/drivers/mmc/exynos_dw_mmc.c
@@ -146,17 +146,11 @@ static int do_dwmci_init(struct dwmci_host *host)
 }
 
 static int exynos_dwmci_get_config(const void *blob, int node,
-   struct dwmci_host *host)
+  struct dwmci_host *host,
+  struct dwmci_exynos_priv_data *priv)
 {
int err = 0;
u32 base, timing[3];
-   struct dwmci_exynos_priv_data *priv;
-
-   priv = malloc(sizeof(struct dwmci_exynos_priv_data));
-   if (!priv) {
-   pr_err("dwmci_exynos_priv_data malloc fail!\n");
-   return -ENOMEM;
-   }
 
/* Extract device id for each mmc channel */
host->dev_id = pinmux_decode_periph_id(blob, node);
@@ -167,7 +161,6 @@ static int exynos_dwmci_get_config(const void *blob, int 
node,
 
if (host->dev_index > 4) {
printf("DWMMC%d: Can't get the dev index\n", host->dev_index);
-   free(priv);
return -EINVAL;
}
 
@@ -178,7 +171,6 @@ static int exynos_dwmci_get_config(const void *blob, int 
node,
base = fdtdec_get_addr(blob, node, "reg");
if (!base) {
printf("DWMMC%d: Can't get base address\n", host->dev_index);
-   free(priv);
return -EINVAL;
}
host->ioaddr = (void *)base;
@@ -188,7 +180,6 @@ static int exynos_dwmci_get_config(const void *blob, int 
node,
if (err) {
printf("DWMMC%d: Can't get sdr-timings for devider\n",
host->dev_index);
-   free(priv);
return -EINVAL;
}
 
@@ -208,14 +199,13 @@ static int exynos_dwmci_get_config(const void *blob, int 
node,
host->bus_hz = fdtdec_get_int(blob, node, "bus_hz", 0);
host->div = fdtdec_get_int(blob, node, "div", 0);
 
-   host->priv = priv;
-
return 0;
 }
 
 static int exynos_dwmci_process_node(const void *blob,
int node_list[], int count)
 {
+   struct dwmci_exynos_priv_data *priv;
struct dwmci_host *host;
int i, node, err;
 
@@ -224,11 +214,20 @@ static int exynos_dwmci_process_node(const void *blob,
if (node <= 0)
continue;
host = _host[i];
-   err = exynos_dwmci_get_config(blob, node, host);
+
+   priv = malloc(sizeof(struct dwmci_exynos_priv_data));
+   if (!priv) {
+   pr_err("dwmci_exynos_priv_data malloc fail!\n");
+   return -ENOMEM;
+   }
+
+   err = exynos_dwmci_get_config(blob, node, host, priv);
if (err) {
printf("%s: failed to decode dev %d\n", __func__, i);
+   free(priv);
return err;
}
+   host->priv = priv;
 
do_dwmci_init(host);
}
@@ -266,7 +265,8 @@ static int exynos_dwmmc_probe(struct udevice *dev)
struct dwmci_host *host = >host;
int err;
 
-   err = exynos_dwmci_get_config(gd->fdt_blob, dev_of_offset(dev), host);
+   err = exynos_dwmci_get_config(gd->fdt_blob, dev_of_offset(dev), host,
+ priv);
if (err)
return err;
err = do_dwmci_init(host);
-- 
2.11.0

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


[U-Boot] [PATCH v2 0/8] ARM: Odroid XU3: Enable DM_MMC support which is necessary for CONFIG_BLK

2018-08-01 Thread Lukasz Majewski
This patch series provides following improvements to Odroid XU3:
- Fix sdr_timing problem with DW_MMC running with DM
- Clean up the defconfig file
- Fix potential memory leak when running under DM (DW_MMC)
- Rebase on newest ML
- Remove the patch, which add support for booting only from SD card
Travis-CI: https://travis-ci.org/lmajewski/u-boot-dfu/builds/410698980
SHA1: ae5afc37204e72ebe6e6844f70afff99db3bd910

Changes in v2:
- Add tested-by
- Rebase on the newest main line
- Add tested-by
- Rebase on the newest main line
- Add tested-by
- Rebase on the newest main line
- Add tested-by
- Rebase on the newest main line
- Add tested-by
- Rebase on the newest main line
- Add tested-by
- Rebase on the newest main line
- Add tested-by
- Rebase on the newest main line
- Add tested-by
- Rebase on the newest main line

Lukasz Majewski (8):
  ARM: dw_mmc: Exclude dwmci Exynos priv_data allocation from
exynos_dwmci_get_config()
  ARM: Odroid XU3: config: Disable SDHCI support in the Odroid XU3
  ARM: Odroid XU3: Enable driver model support for MMC (DM_MMC)
  ARM: Odroid XU3: Fix autoboot.cmd to use ${mmcbootdev} instead of
hardcoded 0
  ARM: Odroid XU3: Adjust BOOT_TARGET_DEVICES to allow booting from SD
card (mmc2)
  ARM: Odroid XU3: MAINTAINERS: Add a co-maintainer for OdroidXU3
  ARM: Odroid XU3: Fix the dwmci_exynos *priv data assignment for DM_MMC
(sdr_timing)
  ARM: Odroid XU3: Modify exynos dw_mmc driver to support Odroid XU3 in
DM MMC

 board/samsung/common/bootscripts/autoboot.cmd |  6 ++---
 board/samsung/smdk5420/MAINTAINERS|  1 +
 configs/odroid-xu3_defconfig  |  3 +--
 drivers/mmc/exynos_dw_mmc.c   | 37 +++
 include/configs/exynos5-common.h  |  1 +
 5 files changed, 27 insertions(+), 21 deletions(-)

-- 
2.11.0

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


Re: [U-Boot] Pull request: u-boot-sunxi/master

2018-08-01 Thread Chen-Yu Tsai
On Wed, Aug 1, 2018 at 7:47 PM, Jagan Teki  wrote:
> On Wed, Aug 1, 2018 at 4:43 PM, Tom Rini  wrote:
>> On Tue, Jul 31, 2018 at 11:41:50PM +0530, Jagan Teki wrote:
>>
>>> Hi Tom,
>>>
>>> Please pull this PR.
>>>
>>> thanks,
>>> Jagan.
>>>
>>> The following changes since commit 5a0007d481c0fcd2d422dd48b2a129dd8e8a272a:
>>>
>>>   Prepare v2017.09-rc1 (2018-07-30 21:47:29 -0400)
>>>
>>> are available in the Git repository at:
>>>
>>>   git://git.denx.de/u-boot-sunxi.git master
>>>
>>> for you to fetch changes up to 89a897fc4d78e31332e5899e977d8bf3c82abafa:
>>>
>>>   board: sun50i: h6: Add OrangePi One Plus initial support (2018-07-31 
>>> 20:50:01 +0530)
>>>
>>
>> For the moment, on hold.  pine_h64 doesn't link (see
>> https://travis-ci.org/trini/u-boot/jobs/410579615) but I bet Andre's
>> changes to save some space on aarch64 will get it to fit in, and I need
>> to see if I'm ready to apply them.
>
> I though of inform the same, but for h6 atf need to use it from
> mainline here all a64 boards seems failing. I didn't reproduce this
> manually.
>
> +WARNING: BL31 file bl31.bin NOT found, resulting binary is non-functional

The cause is obvious. The ATF blob is missing from the environment.
If TravisCI is only used to test building, maybe we could just put an
empty bl31.bin there to make it happy.

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


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

2018-08-01 Thread Bin Meng
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?

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


Re: [U-Boot] Pull request: u-boot-sunxi/master

2018-08-01 Thread Jagan Teki
On Wed, Aug 1, 2018 at 4:43 PM, Tom Rini  wrote:
> On Tue, Jul 31, 2018 at 11:41:50PM +0530, Jagan Teki wrote:
>
>> Hi Tom,
>>
>> Please pull this PR.
>>
>> thanks,
>> Jagan.
>>
>> The following changes since commit 5a0007d481c0fcd2d422dd48b2a129dd8e8a272a:
>>
>>   Prepare v2017.09-rc1 (2018-07-30 21:47:29 -0400)
>>
>> are available in the Git repository at:
>>
>>   git://git.denx.de/u-boot-sunxi.git master
>>
>> for you to fetch changes up to 89a897fc4d78e31332e5899e977d8bf3c82abafa:
>>
>>   board: sun50i: h6: Add OrangePi One Plus initial support (2018-07-31 
>> 20:50:01 +0530)
>>
>
> For the moment, on hold.  pine_h64 doesn't link (see
> https://travis-ci.org/trini/u-boot/jobs/410579615) but I bet Andre's
> changes to save some space on aarch64 will get it to fit in, and I need
> to see if I'm ready to apply them.

I though of inform the same, but for h6 atf need to use it from
mainline here all a64 boards seems failing. I didn't reproduce this
manually.

+WARNING: BL31 file bl31.bin NOT found, resulting binary is non-functional
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] Converting to SPL_OF_CONTROL

2018-08-01 Thread Johann Neuhauser
Hello Alex,

have you tried to set "u-boot,spl-boot-order" in choosen node?

Take a look into:
doc/device-tree-bindings/chosen.txt

Best regards

Johann Neuhauser 

-Ursprüngliche Nachricht-
Von: U-Boot [mailto:u-boot-boun...@lists.denx.de] Im Auftrag von Alex Kiernan
Gesendet: Mittwoch, 1. August 2018 12:42
An: u-boot ; Simon Glass 
Betreff: [U-Boot] Converting to SPL_OF_CONTROL

I've long been trying to convert our board (AM3352) to all DM, after knocking 
out lots of problems, I've run into one I can't seem to configure my way 
around, when I enable SPL_OF_CONTROL.

We have MMC2 as our boot device, with no MMC1 (and hence not present in the 
DTB). Once we're into full U-Boot this is all okay, we get the board's MMC2 
appearing as mmc0 and everything's fine.

My problem's during SPL, where the boot device is MMC2, the code tries to 
lookup by devnum (which is 1 because it numbers from 0 at this point), which 
doesn't exist. I'd expected aliases to work, but we don't seem to lookup up by 
alias, only index, so I don't have any way that I can see of overriding it.

If I make this change, then everything works (with the addition of an an alias 
for mmc1 = ):

diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c index 
0b2f059570..b7544ba183 100644
--- a/common/spl/spl_mmc.c
+++ b/common/spl/spl_mmc.c
@@ -131,7 +131,7 @@ static int spl_mmc_find_device(struct mmc **mmcp,
u32 boot_device)
}

 #if CONFIG_IS_ENABLED(DM_MMC)
-   err = uclass_get_device(UCLASS_MMC, mmc_dev, );
+   err = uclass_get_device_by_seq(UCLASS_MMC, mmc_dev, );
if (!err)
*mmcp = mmc_get_mmc_dev(dev);  #else

But that feels like a pretty fundamental change to make across every board and 
I've no real idea if that would even be the right thing to do, or if I should 
be trying to fix this some other way.

--
Alex Kiernan
___
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 v2 1/3] efi: Fix truncation of constant value

2018-08-01 Thread Eugeniu Rosca
Hello Tom, Simon, Alexander, Heinrich,

On Wed, Jul 25, 2018 at 03:30:16PM +0200, Eugeniu Rosca wrote:
> Hello Alexander,
> 
> Heinrich was kind to have a look at [1] and already provided his
> Reviewed-by. Could you please state your further expectations to accept
> the patches?
> 
> [1] https://patchwork.ozlabs.org/patch/944004/
> 
> Thanks,
> Eugeniu.

Any idea how to move forward with these patches?

Best regards,
Eugeniu.

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


Re: [U-Boot] [PATCH] openrd: Once again shrink binary size

2018-08-01 Thread Tom Rini
On Wed, Aug 01, 2018 at 08:40:18PM +1200, Chris Packham wrote:

> On Fri, Jul 27, 2018 at 11:59 PM Tom Rini  wrote:
> >
> > With some recent changes to relevant drivers here the openrd board
> > (openrd_client in this case) does not fit within its size constraint.
> > We can however drop the slightly extended baudrate table and then the
> > duplication of mtdparts/mtdids in the default environment.  These
> > defaults are set in the environment by the 'mtdparts' command and
> > otherwise referenced throughout the code.
> >
> > Signed-off-by: Tom Rini 
> 
> We could probably shrink things further by disabling jffs2 and only
> supporting ubifs. Similarly having support for both fat and ext4 is
> taking up much of the image although it may be less desirable to pick
> only one of these since either of those file systems could be on
> removable media.

Ah, so, did you also see my email marking the platforms as orphaned?  If
so, please feel free to pick them up and trim the config down :)
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] Pull request: u-boot-sunxi/master

2018-08-01 Thread Tom Rini
On Tue, Jul 31, 2018 at 11:41:50PM +0530, Jagan Teki wrote:

> Hi Tom,
> 
> Please pull this PR.
> 
> thanks,
> Jagan.
> 
> The following changes since commit 5a0007d481c0fcd2d422dd48b2a129dd8e8a272a:
> 
>   Prepare v2017.09-rc1 (2018-07-30 21:47:29 -0400)
> 
> are available in the Git repository at:
> 
>   git://git.denx.de/u-boot-sunxi.git master
> 
> for you to fetch changes up to 89a897fc4d78e31332e5899e977d8bf3c82abafa:
> 
>   board: sun50i: h6: Add OrangePi One Plus initial support (2018-07-31 
> 20:50:01 +0530)
> 

For the moment, on hold.  pine_h64 doesn't link (see
https://travis-ci.org/trini/u-boot/jobs/410579615) but I bet Andre's
changes to save some space on aarch64 will get it to fit in, and I need
to see if I'm ready to apply them.

-- 
Tom


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


[U-Boot] [PATCH] ram: stm32_sdram: Adds stm32f746-disco fix for HardFault at booting

2018-08-01 Thread Mark Olsson
- changes ram start address to 0xC000

Signed-off-by: Mark Olsson 
Cc: Vipin Kumar 
---
 include/configs/stm32f746-disco.h | 2 ++
 1 file changed, 2 insertions(+)
 mode change 100644 => 100755 include/configs/stm32f746-disco.h

diff --git a/include/configs/stm32f746-disco.h 
b/include/configs/stm32f746-disco.h
old mode 100644
new mode 100755
index 567e7f2a00..238d4e939f
--- a/include/configs/stm32f746-disco.h
+++ b/include/configs/stm32f746-disco.h
@@ -21,6 +21,8 @@
  * Configuration of the external SDRAM memory
  */
 #define CONFIG_NR_DRAM_BANKS   1
+#define CONFIG_SYS_RAM_BASE0xC000
+#define CONFIG_SYS_SDRAM_BASE  CONFIG_SYS_RAM_BASE
 
 #define CONFIG_SYS_MAX_FLASH_SECT  8
 #define CONFIG_SYS_MAX_FLASH_BANKS 1
-- 
2.17.1


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


[U-Boot] [PATCH] Corrected checksum failure handling of FDT within FIT image

2018-08-01 Thread Patz, Heiko
Hello,

I have observed, that if you have a corrupted FDT within a FIT image, then the 
error handling is not correct and you will fail to  'hang()'.
To allow an error handling within scripts, the return value of the calling 
function 'fit_image_load()' has to be checked for negative values.
On error (return value < 0), we have to exit the function. This error seems to 
also exists in the newest u-boot release.

Please check and fix, if not already done in current versions of u-boot.

With best regards,
Heiko Patz

Siemens Healthcare GmbH
Diagnostic Imaging
Computed Tomography
Electronics
SHS DI CT R SC EL
Siemensstr. 1
91301 Forchheim, Germany
Tel.: +49 9191 18-6444
Fax: +49 9191 18-6513
Mobile: +49 152 06340249
mailto:heiko.p...@siemens-healthineers.com
[cid:image001.gif@01D42981.A98AE880]
Siemens Healthcare GmbH: Management: Bernhard Montag, Chairman; Jochen Schmitz, 
Michael Reitermann; Chairman of the Supervisory Board: Michael Sen; Registered 
office: Munich, Germany; Commercial Registry: Munich, HRB 213821 WEEE-Reg.-No. 
DE 64872105

Important notice: This e-mail and any attachment thereof contain corporate 
proprietary information. If you have received it by mistake, please notify us 
immediately by reply e-mail and delete this e-mail and its attachments from 
your system. Thank you.


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


Re: [U-Boot] xyz-modem: Change getc timeout loop waiting

2018-08-01 Thread Alexander Sverdlin
Hi!

On Wed, 1 Aug 2018 08:44:13 +0300
Tomas Melin  wrote:

> > This commit breaks YMODEM SPL->U-Boot boot on Beagle Bone,
> > transfer is aborted (because of timeout) after 497kb
> > (u-boot.img is around 570kb).
> > Reverting the commit repairs YMODEM boot.
> 
> Is the timeout a watchdog timeout or some communication freeze?

I suppose, it reports false-positive timeout back to ymodem code.
Because all it does is terminating communication gracefully (with 'C'
and a bunch of CANs).
I need to check if timer overflow is possible on Beaglebone,
because the code is obviously not overflow-proof, but on the
other hand it happens within minutes and at least the timer variable
is 32 bit...

> In case watchdog is correctly configured, kicking should still
> happen.

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


[U-Boot] Converting to SPL_OF_CONTROL

2018-08-01 Thread Alex Kiernan
I've long been trying to convert our board (AM3352) to all DM, after
knocking out lots of problems, I've run into one I can't seem to
configure my way around, when I enable SPL_OF_CONTROL.

We have MMC2 as our boot device, with no MMC1 (and hence not present
in the DTB). Once we're into full U-Boot this is all okay, we get the
board's MMC2 appearing as mmc0 and everything's fine.

My problem's during SPL, where the boot device is MMC2, the code tries
to lookup by devnum (which is 1 because it numbers from 0 at this
point), which doesn't exist. I'd expected aliases to work, but we
don't seem to lookup up by alias, only index, so I don't have any way
that I can see of overriding it.

If I make this change, then everything works (with the addition of an
an alias for mmc1 = ):

diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c
index 0b2f059570..b7544ba183 100644
--- a/common/spl/spl_mmc.c
+++ b/common/spl/spl_mmc.c
@@ -131,7 +131,7 @@ static int spl_mmc_find_device(struct mmc **mmcp,
u32 boot_device)
}

 #if CONFIG_IS_ENABLED(DM_MMC)
-   err = uclass_get_device(UCLASS_MMC, mmc_dev, );
+   err = uclass_get_device_by_seq(UCLASS_MMC, mmc_dev, );
if (!err)
*mmcp = mmc_get_mmc_dev(dev);
 #else

But that feels like a pretty fundamental change to make across every
board and I've no real idea if that would even be the right thing to
do, or if I should be trying to fix this some other way.

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


[U-Boot] [PATCH] net: fman: Support both new and legacy FMan Compatibles

2018-08-01 Thread Zhao Qiang
Recently  the FMan Port and MAC compatibles were changed.
This patch aligns the FMan Port and MAC compatibles
to the new FMan device tree binding document.
The FMan device tree binding document can be found in the Linux
kernel:
./Documentation/devicetree/bindings/net/fsl-fman.txt

This patch doesn't affect legacy compatibles support.

Signed-off-by: Zhao Qiang 
---
 drivers/net/fm/init.c |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/net/fm/init.c b/drivers/net/fm/init.c
index 147d043..e3b1a50 100644
--- a/drivers/net/fm/init.c
+++ b/drivers/net/fm/init.c
@@ -328,7 +328,8 @@ void fdt_fixup_fman_ethernet(void *blob)
ft_fixup_port(blob, _info[i],
  "fsl,fman-1g-mac");
} else {
-   if (ft_fixup_port(blob, _info[i], "fsl,fman-tgec"))
+   if (ft_fixup_port(blob, _info[i], "fsl,fman-tgec") &&
+   ft_fixup_port(blob, _info[i], "fsl,fman-xgec"))
ft_fixup_port(blob, _info[i],
  "fsl,fman-10g-mac");
}
-- 
1.7.1

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


Re: [U-Boot] [PATCH] openrd: Once again shrink binary size

2018-08-01 Thread Chris Packham
On Fri, Jul 27, 2018 at 11:59 PM Tom Rini  wrote:
>
> With some recent changes to relevant drivers here the openrd board
> (openrd_client in this case) does not fit within its size constraint.
> We can however drop the slightly extended baudrate table and then the
> duplication of mtdparts/mtdids in the default environment.  These
> defaults are set in the environment by the 'mtdparts' command and
> otherwise referenced throughout the code.
>
> Signed-off-by: Tom Rini 

We could probably shrink things further by disabling jffs2 and only
supporting ubifs. Similarly having support for both fat and ext4 is
taking up much of the image although it may be less desirable to pick
only one of these since either of those file systems could be on
removable media.
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v6 26/27] cmd: mtd: add 'mtd' command

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

Signed-off-by: Miquel Raynal 
Acked-by: Jagan Teki 
---
 cmd/Kconfig |   7 +
 cmd/Makefile|   1 +
 cmd/mtd.c   | 392 
 drivers/mtd/Makefile|   2 +-
 include/linux/mtd/mtd.h |   1 +
 5 files changed, 402 insertions(+), 1 deletion(-)
 create mode 100644 cmd/mtd.c

diff --git a/cmd/Kconfig b/cmd/Kconfig
index 0cf530d923..45ead0ffce 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -848,6 +848,13 @@ config CMD_MMC_SWRITE
  Enable support for the "mmc swrite" command to write Android sparse
  images to eMMC.
 
+config CMD_MTD
+   bool "mtd"
+   depends on CMD_MTDPARTS
+   select MTD_PARTITIONS
+   help
+ MTD commands support.
+
 config CMD_NAND
bool "nand"
default y if NAND_SUNXI
diff --git a/cmd/Makefile b/cmd/Makefile
index 323f1fd2c7..32fd102189 100644
--- a/cmd/Makefile
+++ b/cmd/Makefile
@@ -90,6 +90,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..221b12500f
--- /dev/null
+++ b/cmd/mtd.c
@@ -0,0 +1,392 @@
+// 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 
+
+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_device(struct mtd_info *mtd)
+{
+   /* Device */
+   printf("* %s", mtd->name);
+   if (mtd->dev)
+   printf(" [device: %s] [parent: %s] [driver: %s]",
+  mtd->dev->name, mtd->dev->parent->name,
+  mtd->dev->driver->name);
+   printf("\n");
+
+   /* MTD information */
+   printf("\t> 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("\t> Size: 0x%llx bytes\n", mtd->size);
+   printf("\t> Block: 0x%x bytes\n", mtd->erasesize);
+   printf("\t> Min I/O: 0x%x bytes\n", mtd->writesize);
+
+   if (mtd->oobsize) {
+   printf("\t> OOB size: %u bytes\n", mtd->oobsize);
+   printf("\t> OOB available: %u bytes\n", mtd->oobavail);
+   }
+
+   if (mtd->ecc_strength) {
+   printf("\t> ECC strength: %u bits\n", mtd->ecc_strength);
+   printf("\t> ECC step size: %u bytes\n", mtd->ecc_step_size);
+   printf("\t> Bitflip threshold: %u bits\n",
+  mtd->bitflip_threshold);
+   }
+}
+
+int mtd_probe_devices(void)
+{
+   const char *mtdparts = env_get("mtdparts");
+   struct udevice *dev;
+   int idx = 0;
+
+   /* Probe devices with DM compliant drivers */
+   while (!uclass_find_device(UCLASS_MTD, idx, ) && dev) {
+   mtd_probe(dev);
+   idx++;
+   }
+
+   /* Create the partitions defined in mtdparts, here the fun begins */
+
+   /* Ignore the extra 'mtdparts=' prefix if any */
+   if (strstr(mtdparts, "mtdparts="))
+   mtdparts += 9;
+
+   /* For each MTD device in mtdparts */
+   while (mtdparts[0] != '\0') {
+   struct mtd_partition *parts;
+   struct mtd_info *parent;
+   char mtdname[20];
+   int mtdname_len, len, ret;
+
+   mtdname_len = strchr(mtdparts, 

[U-Boot] [PATCH v6 27/27] cmd: mtdparts: try to probe the MTD devices as a fallback

2018-08-01 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 
---
 cmd/mtdparts.c | 12 +---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/cmd/mtdparts.c b/cmd/mtdparts.c
index ef8588bd71..76f0138e4d 100644
--- a/cmd/mtdparts.c
+++ b/cmd/mtdparts.c
@@ -305,9 +305,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_CMD_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.14.1

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


[U-Boot] [PATCH v6 17/27] mtd: spinand: Add initial support for the MX35LF1GE4AB chip

2018-08-01 Thread Miquel Raynal
From: Boris Brezillon 

Add minimal support for the MX35LF1GE4AB SPI NAND chip.

Signed-off-by: Boris Brezillon 
Acked-by: Jagan Teki 
---
 drivers/mtd/nand/spi/Makefile   |   2 +-
 drivers/mtd/nand/spi/core.c |   1 +
 drivers/mtd/nand/spi/macronix.c | 138 
 include/linux/mtd/spinand.h |   1 +
 4 files changed, 141 insertions(+), 1 deletion(-)
 create mode 100644 drivers/mtd/nand/spi/macronix.c

diff --git a/drivers/mtd/nand/spi/Makefile b/drivers/mtd/nand/spi/Makefile
index 11ba5de68b..a66edd9199 100644
--- a/drivers/mtd/nand/spi/Makefile
+++ b/drivers/mtd/nand/spi/Makefile
@@ -1,4 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0
 
-spinand-objs := core.o micron.o winbond.o
+spinand-objs := core.o macronix.o micron.o winbond.o
 obj-$(CONFIG_MTD_SPI_NAND) += spinand.o
diff --git a/drivers/mtd/nand/spi/core.c b/drivers/mtd/nand/spi/core.c
index ef3e6445d8..362d104846 100644
--- a/drivers/mtd/nand/spi/core.c
+++ b/drivers/mtd/nand/spi/core.c
@@ -830,6 +830,7 @@ static const struct nand_ops spinand_ops = {
 };
 
 static const struct spinand_manufacturer *spinand_manufacturers[] = {
+   _spinand_manufacturer,
_spinand_manufacturer,
_spinand_manufacturer,
 };
diff --git a/drivers/mtd/nand/spi/macronix.c b/drivers/mtd/nand/spi/macronix.c
new file mode 100644
index 00..dd351dcb6c
--- /dev/null
+++ b/drivers/mtd/nand/spi/macronix.c
@@ -0,0 +1,138 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2018 Macronix
+ *
+ * Author: Boris Brezillon 
+ */
+
+#ifndef __UBOOT__
+#include 
+#include 
+#endif
+#include 
+
+#define SPINAND_MFR_MACRONIX   0xC2
+
+static SPINAND_OP_VARIANTS(read_cache_variants,
+   SPINAND_PAGE_READ_FROM_CACHE_X4_OP(0, 1, NULL, 0),
+   SPINAND_PAGE_READ_FROM_CACHE_X2_OP(0, 1, NULL, 0),
+   SPINAND_PAGE_READ_FROM_CACHE_OP(true, 0, 1, NULL, 0),
+   SPINAND_PAGE_READ_FROM_CACHE_OP(false, 0, 1, NULL, 0));
+
+static SPINAND_OP_VARIANTS(write_cache_variants,
+   SPINAND_PROG_LOAD_X4(true, 0, NULL, 0),
+   SPINAND_PROG_LOAD(true, 0, NULL, 0));
+
+static SPINAND_OP_VARIANTS(update_cache_variants,
+   SPINAND_PROG_LOAD_X4(false, 0, NULL, 0),
+   SPINAND_PROG_LOAD(false, 0, NULL, 0));
+
+static int mx35lf1ge4ab_ooblayout_ecc(struct mtd_info *mtd, int section,
+ struct mtd_oob_region *region)
+{
+   return -ERANGE;
+}
+
+static int mx35lf1ge4ab_ooblayout_free(struct mtd_info *mtd, int section,
+  struct mtd_oob_region *region)
+{
+   if (section)
+   return -ERANGE;
+
+   region->offset = 2;
+   region->length = mtd->oobsize - 2;
+
+   return 0;
+}
+
+static const struct mtd_ooblayout_ops mx35lf1ge4ab_ooblayout = {
+   .ecc = mx35lf1ge4ab_ooblayout_ecc,
+   .free = mx35lf1ge4ab_ooblayout_free,
+};
+
+static int mx35lf1ge4ab_get_eccsr(struct spinand_device *spinand, u8 *eccsr)
+{
+   struct spi_mem_op op = SPI_MEM_OP(SPI_MEM_OP_CMD(0x7c, 1),
+ SPI_MEM_OP_NO_ADDR,
+ SPI_MEM_OP_DUMMY(1, 1),
+ SPI_MEM_OP_DATA_IN(1, eccsr, 1));
+
+   return spi_mem_exec_op(spinand->slave, );
+}
+
+static int mx35lf1ge4ab_ecc_get_status(struct spinand_device *spinand,
+  u8 status)
+{
+   struct nand_device *nand = spinand_to_nand(spinand);
+   u8 eccsr;
+
+   switch (status & STATUS_ECC_MASK) {
+   case STATUS_ECC_NO_BITFLIPS:
+   return 0;
+
+   case STATUS_ECC_UNCOR_ERROR:
+   return -EBADMSG;
+
+   case STATUS_ECC_HAS_BITFLIPS:
+   /*
+* Let's try to retrieve the real maximum number of bitflips
+* in order to avoid forcing the wear-leveling layer to move
+* data around if it's not necessary.
+*/
+   if (mx35lf1ge4ab_get_eccsr(spinand, ))
+   return nand->eccreq.strength;
+
+   if (WARN_ON(eccsr > nand->eccreq.strength || !eccsr))
+   return nand->eccreq.strength;
+
+   return eccsr;
+
+   default:
+   break;
+   }
+
+   return -EINVAL;
+}
+
+static const struct spinand_info macronix_spinand_table[] = {
+   SPINAND_INFO("MX35LF1GE4AB", 0x12,
+NAND_MEMORG(1, 2048, 64, 64, 1024, 1, 1, 1),
+NAND_ECCREQ(4, 512),
+SPINAND_INFO_OP_VARIANTS(_cache_variants,
+ _cache_variants,
+ _cache_variants),
+SPINAND_HAS_QE_BIT,
+SPINAND_ECCINFO(_ooblayout,
+mx35lf1ge4ab_ecc_get_status)),
+};
+
+static int macronix_spinand_detect(struct 

[U-Boot] [PATCH v6 22/27] cmd: mtdparts: accept spi-nand devices

2018-08-01 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 
---
 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 0da3afd75f..f26a761c99 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)
  *
@@ -336,7 +336,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;
@@ -1027,7 +1027,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
@@ -1051,6 +1051,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;
@@ -1633,7 +1636,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, , , ) != 0)
break;
 
@@ -2109,7 +2112,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.14.1

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


[U-Boot] [PATCH v6 23/27] cmd: mtdparts: add a generic 'mtdparts' parser

2018-08-01 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. 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 command 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 
---
 cmd/mtdparts.c | 71 ++
 include/linux/mtd/partitions.h |  3 ++
 2 files changed, 74 insertions(+)

diff --git a/cmd/mtdparts.c b/cmd/mtdparts.c
index f26a761c99..27e84db0e4 100644
--- a/cmd/mtdparts.c
+++ b/cmd/mtdparts.c
@@ -78,6 +78,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #if defined(CONFIG_CMD_NAND)
 #include 
@@ -705,6 +706,76 @@ static int part_parse(const char *const partdef, const 
char **ret, struct part_i
return 0;
 }
 
+int mtdparts_parse_part(struct mtd_info *parent, const char **_mtdparts,
+   struct mtd_partition **_parts, int *_nb_parts)
+{
+   const char *mtdparts = *_mtdparts;
+   struct part_info *part_legacy;
+   struct mtd_partition *parts;
+   int cur_off = 0, cur_sz = 0;
+   int nb_parts = 0;
+   char *names;
+   int ret, idx;
+
+   *_parts = NULL;
+   *_nb_parts = 0;
+
+   /* First, iterate over the partitions until we know their number */
+   while (mtdparts[0] != '\0' && mtdparts[0] != ';') {
+   ret = part_parse(mtdparts, , _legacy);
+   if (ret)
+   return ret;
+
+   nb_parts++;
+   free(part_legacy);
+   }
+
+   /* Allocate an array of partitions to give back to the caller */
+   parts = malloc((sizeof(*parts) + 20) * nb_parts);
+   names = (char *)[nb_parts];
+   if (!parts) {
+   printf("Could not allocate enough space to save partitions 
meta-data\n");
+   return -ENOMEM;
+   }
+
+   /* Iterate again over each partition to save the data in our array */
+   for (idx = 0; idx < nb_parts; idx++) {
+   char *name;
+
+   ret = part_parse(*_mtdparts, _mtdparts, _legacy);
+   if (ret)
+   return ret;
+
+   name = [idx * 20];
+   strncpy(name, part_legacy->name, 20);
+   parts[idx].name = name;
+
+   parts[idx].size = part_legacy->size;
+   if (parts[idx].size == SIZE_REMAINING)
+   parts[idx].size = parent->size - cur_sz;
+   cur_sz += parts[idx].size;
+
+   parts[idx].offset = part_legacy->offset;
+   if (parts[idx].offset == OFFSET_NOT_SPECIFIED)
+   parts[idx].offset = cur_off;
+   cur_off += parts[idx].size;
+
+   parts[idx].mask_flags = part_legacy->mask_flags;
+   parts[idx].ecclayout = parent->ecclayout;
+
+   free(part_legacy);
+   }
+
+   /* Offset by one mtdparts to point to the next device if needed */
+   if (*_mtdparts[0] == ';')
+   _mtdparts++;
+
+   *_parts = parts;
+   *_nb_parts = nb_parts;
+
+   return 0;
+}
+
 /**
  * Check device number to be within valid range for given device type.
  *
diff --git a/include/linux/mtd/partitions.h b/include/linux/mtd/partitions.h
index ce0e8dbee4..0cf26ca945 100644
--- a/include/linux/mtd/partitions.h
+++ b/include/linux/mtd/partitions.h
@@ -87,4 +87,7 @@ int mtd_add_partition(struct mtd_info *master, const char 
*name,
 int mtd_del_partition(struct mtd_info *master, int partno);
 uint64_t mtd_get_device_size(const struct mtd_info *mtd);
 
+int mtdparts_parse_part(struct mtd_info *parent, const char **_mtdparts,
+   struct mtd_partition **_parts, int *_nb_parts);
+
 #endif
-- 
2.14.1

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


[U-Boot] [PATCH v6 18/27] mtd: spinand: Add initial support for the MX35LF2GE4AB chip

2018-08-01 Thread Miquel Raynal
Add support for the MX35LF2GE4AB chip, which is similar to its cousin
MX35LF1GE4AB, with two planes instead of one.

Signed-off-by: Miquel Raynal 
Acked-by: Jagan Teki 
---
 drivers/mtd/nand/spi/macronix.c | 20 ++--
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/drivers/mtd/nand/spi/macronix.c b/drivers/mtd/nand/spi/macronix.c
index dd351dcb6c..662c561e50 100644
--- a/drivers/mtd/nand/spi/macronix.c
+++ b/drivers/mtd/nand/spi/macronix.c
@@ -27,13 +27,13 @@ static SPINAND_OP_VARIANTS(update_cache_variants,
SPINAND_PROG_LOAD_X4(false, 0, NULL, 0),
SPINAND_PROG_LOAD(false, 0, NULL, 0));
 
-static int mx35lf1ge4ab_ooblayout_ecc(struct mtd_info *mtd, int section,
+static int mx35lfxge4ab_ooblayout_ecc(struct mtd_info *mtd, int section,
  struct mtd_oob_region *region)
 {
return -ERANGE;
 }
 
-static int mx35lf1ge4ab_ooblayout_free(struct mtd_info *mtd, int section,
+static int mx35lfxge4ab_ooblayout_free(struct mtd_info *mtd, int section,
   struct mtd_oob_region *region)
 {
if (section)
@@ -45,9 +45,9 @@ static int mx35lf1ge4ab_ooblayout_free(struct mtd_info *mtd, 
int section,
return 0;
 }
 
-static const struct mtd_ooblayout_ops mx35lf1ge4ab_ooblayout = {
-   .ecc = mx35lf1ge4ab_ooblayout_ecc,
-   .free = mx35lf1ge4ab_ooblayout_free,
+static const struct mtd_ooblayout_ops mx35lfxge4ab_ooblayout = {
+   .ecc = mx35lfxge4ab_ooblayout_ecc,
+   .free = mx35lfxge4ab_ooblayout_free,
 };
 
 static int mx35lf1ge4ab_get_eccsr(struct spinand_device *spinand, u8 *eccsr)
@@ -102,8 +102,16 @@ static const struct spinand_info macronix_spinand_table[] 
= {
  _cache_variants,
  _cache_variants),
 SPINAND_HAS_QE_BIT,
-SPINAND_ECCINFO(_ooblayout,
+SPINAND_ECCINFO(_ooblayout,
 mx35lf1ge4ab_ecc_get_status)),
+   SPINAND_INFO("MX35LF2GE4AB", 0x22,
+NAND_MEMORG(1, 2048, 64, 64, 2048, 2, 1, 1),
+NAND_ECCREQ(4, 512),
+SPINAND_INFO_OP_VARIANTS(_cache_variants,
+ _cache_variants,
+ _cache_variants),
+SPINAND_HAS_QE_BIT,
+SPINAND_ECCINFO(_ooblayout, NULL)),
 };
 
 static int macronix_spinand_detect(struct spinand_device *spinand)
-- 
2.14.1

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


[U-Boot] [PATCH v6 24/27] cmd: mtdparts: remove useless 'mtdparts=' prefix

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

This is a pure software limitation and is a complete non-sense. Remove
this limitation but keep the backward compatibility.

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

diff --git a/cmd/mtdparts.c b/cmd/mtdparts.c
index 27e84db0e4..ef8588bd71 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)
  *
  */
 
@@ -1167,9 +1167,6 @@ static int generate_mtdparts(char *buf, u32 buflen)
return 0;
}
 
-   strcpy(p, "mtdparts=");
-   p += 9;
-
list_for_each(dentry, ) {
dev = list_entry(dentry, struct mtd_device, link);
 
@@ -1640,11 +1637,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.14.1

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


[U-Boot] [PATCH v6 21/27] cmd: ubi: delete useless and misleading definitions

2018-08-01 Thread Miquel Raynal
These definitions are simply not used and are misleading because similar
definitions exist in jffs2/load_kernel.h and are used widely to define
MTD device types (which is, by the way, totally redundant with what the
MTD core does). Remove these definitions.

Signed-off-by: Miquel Raynal 
Acked-by: Jagan Teki 
---
 cmd/ubi.c | 5 -
 1 file changed, 5 deletions(-)

diff --git a/cmd/ubi.c b/cmd/ubi.c
index 913f0f71fd..0a3405a3b1 100644
--- a/cmd/ubi.c
+++ b/cmd/ubi.c
@@ -27,11 +27,6 @@
 #undef ubi_msg
 #define ubi_msg(fmt, ...) printf("UBI: " fmt "\n", ##__VA_ARGS__)
 
-#define DEV_TYPE_NONE  0
-#define DEV_TYPE_NAND  1
-#define DEV_TYPE_ONENAND   2
-#define DEV_TYPE_NOR   3
-
 /* Private own data */
 static struct ubi_device *ubi;
 static char buffer[80];
-- 
2.14.1

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


[U-Boot] [PATCH v6 19/27] dt-bindings: Add bindings for SPI NAND devices

2018-08-01 Thread Miquel Raynal
From: Boris Brezillon 

Add bindings for SPI NAND chips.

Signed-off-by: Boris Brezillon 
Signed-off-by: Miquel Raynal 
Acked-by: Jagan Teki 
---
 doc/device-tree-bindings/mtd/spi-nand.txt | 5 +
 1 file changed, 5 insertions(+)
 create mode 100644 doc/device-tree-bindings/mtd/spi-nand.txt

diff --git a/doc/device-tree-bindings/mtd/spi-nand.txt 
b/doc/device-tree-bindings/mtd/spi-nand.txt
new file mode 100644
index 00..8b51f3b6d5
--- /dev/null
+++ b/doc/device-tree-bindings/mtd/spi-nand.txt
@@ -0,0 +1,5 @@
+SPI NAND flash
+
+Required properties:
+- compatible: should be "spi-nand"
+- reg: should encode the chip-select line used to access the NAND chip
-- 
2.14.1

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


[U-Boot] [PATCH v6 15/27] mtd: spinand: Add initial support for Micron MT29F2G01ABAGD

2018-08-01 Thread Miquel Raynal
From: Peter Pan 

Add a basic driver for Micron SPI NANDs. Only one device is supported
right now, but the driver will be extended to support more devices
afterwards.

Signed-off-by: Peter Pan 
Signed-off-by: Boris Brezillon 
Signed-off-by: Miquel Raynal 
Acked-by: Jagan Teki 
---
 drivers/mtd/nand/spi/Makefile |   2 +-
 drivers/mtd/nand/spi/core.c   |  17 ++
 drivers/mtd/nand/spi/micron.c | 135 ++
 include/linux/mtd/spinand.h   |   3 +
 4 files changed, 156 insertions(+), 1 deletion(-)
 create mode 100644 drivers/mtd/nand/spi/micron.c

diff --git a/drivers/mtd/nand/spi/Makefile b/drivers/mtd/nand/spi/Makefile
index f0c6e69d2e..4eb745abd4 100644
--- a/drivers/mtd/nand/spi/Makefile
+++ b/drivers/mtd/nand/spi/Makefile
@@ -1,4 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0
 
-spinand-objs := core.o
+spinand-objs := core.o micron.o
 obj-$(CONFIG_MTD_SPI_NAND) += spinand.o
diff --git a/drivers/mtd/nand/spi/core.c b/drivers/mtd/nand/spi/core.c
index 08f853ae11..36b8b52bc2 100644
--- a/drivers/mtd/nand/spi/core.c
+++ b/drivers/mtd/nand/spi/core.c
@@ -829,8 +829,25 @@ static const struct nand_ops spinand_ops = {
.isbad = spinand_isbad,
 };
 
+static const struct spinand_manufacturer *spinand_manufacturers[] = {
+   _spinand_manufacturer,
+};
+
 static int spinand_manufacturer_detect(struct spinand_device *spinand)
 {
+   unsigned int i;
+   int ret;
+
+   for (i = 0; i < ARRAY_SIZE(spinand_manufacturers); i++) {
+   ret = spinand_manufacturers[i]->ops->detect(spinand);
+   if (ret > 0) {
+   spinand->manufacturer = spinand_manufacturers[i];
+   return 0;
+   } else if (ret < 0) {
+   return ret;
+   }
+   }
+
return -ENOTSUPP;
 }
 
diff --git a/drivers/mtd/nand/spi/micron.c b/drivers/mtd/nand/spi/micron.c
new file mode 100644
index 00..83951c5d0f
--- /dev/null
+++ b/drivers/mtd/nand/spi/micron.c
@@ -0,0 +1,135 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2016-2017 Micron Technology, Inc.
+ *
+ * Authors:
+ * Peter Pan 
+ */
+
+#ifndef __UBOOT__
+#include 
+#include 
+#endif
+#include 
+
+#define SPINAND_MFR_MICRON 0x2c
+
+#define MICRON_STATUS_ECC_MASK GENMASK(7, 4)
+#define MICRON_STATUS_ECC_NO_BITFLIPS  (0 << 4)
+#define MICRON_STATUS_ECC_1TO3_BITFLIPS(1 << 4)
+#define MICRON_STATUS_ECC_4TO6_BITFLIPS(3 << 4)
+#define MICRON_STATUS_ECC_7TO8_BITFLIPS(5 << 4)
+
+static SPINAND_OP_VARIANTS(read_cache_variants,
+   SPINAND_PAGE_READ_FROM_CACHE_QUADIO_OP(0, 2, NULL, 0),
+   SPINAND_PAGE_READ_FROM_CACHE_X4_OP(0, 1, NULL, 0),
+   SPINAND_PAGE_READ_FROM_CACHE_DUALIO_OP(0, 1, NULL, 0),
+   SPINAND_PAGE_READ_FROM_CACHE_X2_OP(0, 1, NULL, 0),
+   SPINAND_PAGE_READ_FROM_CACHE_OP(true, 0, 1, NULL, 0),
+   SPINAND_PAGE_READ_FROM_CACHE_OP(false, 0, 1, NULL, 0));
+
+static SPINAND_OP_VARIANTS(write_cache_variants,
+   SPINAND_PROG_LOAD_X4(true, 0, NULL, 0),
+   SPINAND_PROG_LOAD(true, 0, NULL, 0));
+
+static SPINAND_OP_VARIANTS(update_cache_variants,
+   SPINAND_PROG_LOAD_X4(false, 0, NULL, 0),
+   SPINAND_PROG_LOAD(false, 0, NULL, 0));
+
+static int mt29f2g01abagd_ooblayout_ecc(struct mtd_info *mtd, int section,
+   struct mtd_oob_region *region)
+{
+   if (section)
+   return -ERANGE;
+
+   region->offset = 64;
+   region->length = 64;
+
+   return 0;
+}
+
+static int mt29f2g01abagd_ooblayout_free(struct mtd_info *mtd, int section,
+struct mtd_oob_region *region)
+{
+   if (section)
+   return -ERANGE;
+
+   /* Reserve 2 bytes for the BBM. */
+   region->offset = 2;
+   region->length = 62;
+
+   return 0;
+}
+
+static const struct mtd_ooblayout_ops mt29f2g01abagd_ooblayout = {
+   .ecc = mt29f2g01abagd_ooblayout_ecc,
+   .free = mt29f2g01abagd_ooblayout_free,
+};
+
+static int mt29f2g01abagd_ecc_get_status(struct spinand_device *spinand,
+u8 status)
+{
+   switch (status & MICRON_STATUS_ECC_MASK) {
+   case STATUS_ECC_NO_BITFLIPS:
+   return 0;
+
+   case STATUS_ECC_UNCOR_ERROR:
+   return -EBADMSG;
+
+   case MICRON_STATUS_ECC_1TO3_BITFLIPS:
+   return 3;
+
+   case MICRON_STATUS_ECC_4TO6_BITFLIPS:
+   return 6;
+
+   case MICRON_STATUS_ECC_7TO8_BITFLIPS:
+   return 8;
+
+   default:
+   break;
+   }
+
+   return -EINVAL;
+}
+
+static const struct spinand_info micron_spinand_table[] = {
+   SPINAND_INFO("MT29F2G01ABAGD", 0x24,
+NAND_MEMORG(1, 2048, 128, 64, 2048, 2, 1, 1),
+NAND_ECCREQ(8, 512),
+

[U-Boot] [PATCH v6 11/27] mtd: nand: Add core infrastructure to deal with NAND devices

2018-08-01 Thread Miquel Raynal
From: Boris Brezillon 

Add an intermediate layer to abstract NAND device interface so that
some logic can be shared between SPI NANDs, parallel/raw NANDs,
OneNANDs, ...

Signed-off-by: Boris Brezillon 
Signed-off-by: Miquel Raynal 
Acked-by: Jagan Teki 
---
 drivers/mtd/nand/Kconfig  |   3 +
 drivers/mtd/nand/Makefile |   2 +
 drivers/mtd/nand/bbt.c| 132 +
 drivers/mtd/nand/core.c   | 243 +++
 include/linux/mtd/nand.h  | 731 ++
 5 files changed,  insertions(+)
 create mode 100644 drivers/mtd/nand/bbt.c
 create mode 100644 drivers/mtd/nand/core.c
 create mode 100644 include/linux/mtd/nand.h

diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig
index 6d53734718..1c1a1f487e 100644
--- a/drivers/mtd/nand/Kconfig
+++ b/drivers/mtd/nand/Kconfig
@@ -1 +1,4 @@
+config MTD_NAND_CORE
+   tristate
+
 source "drivers/mtd/nand/raw/Kconfig"
diff --git a/drivers/mtd/nand/Makefile b/drivers/mtd/nand/Makefile
index 69f40d1563..cd492dbc14 100644
--- a/drivers/mtd/nand/Makefile
+++ b/drivers/mtd/nand/Makefile
@@ -1,2 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0+
 
+nandcore-objs := core.o bbt.o
+obj-$(CONFIG_MTD_NAND_CORE) += nandcore.o
diff --git a/drivers/mtd/nand/bbt.c b/drivers/mtd/nand/bbt.c
new file mode 100644
index 00..7e0ad3190c
--- /dev/null
+++ b/drivers/mtd/nand/bbt.c
@@ -0,0 +1,132 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2017 Free Electrons
+ *
+ * Authors:
+ * Boris Brezillon 
+ * Peter Pan 
+ */
+
+#define pr_fmt(fmt)"nand-bbt: " fmt
+
+#include 
+#ifndef __UBOOT__
+#include 
+#endif
+
+/**
+ * nanddev_bbt_init() - Initialize the BBT (Bad Block Table)
+ * @nand: NAND device
+ *
+ * Initialize the in-memory BBT.
+ *
+ * Return: 0 in case of success, a negative error code otherwise.
+ */
+int nanddev_bbt_init(struct nand_device *nand)
+{
+   unsigned int bits_per_block = fls(NAND_BBT_BLOCK_NUM_STATUS);
+   unsigned int nblocks = nanddev_neraseblocks(nand);
+   unsigned int nwords = DIV_ROUND_UP(nblocks * bits_per_block,
+  BITS_PER_LONG);
+
+   nand->bbt.cache = kzalloc(nwords, GFP_KERNEL);
+   if (!nand->bbt.cache)
+   return -ENOMEM;
+
+   return 0;
+}
+EXPORT_SYMBOL_GPL(nanddev_bbt_init);
+
+/**
+ * nanddev_bbt_cleanup() - Cleanup the BBT (Bad Block Table)
+ * @nand: NAND device
+ *
+ * Undoes what has been done in nanddev_bbt_init()
+ */
+void nanddev_bbt_cleanup(struct nand_device *nand)
+{
+   kfree(nand->bbt.cache);
+}
+EXPORT_SYMBOL_GPL(nanddev_bbt_cleanup);
+
+/**
+ * nanddev_bbt_update() - Update a BBT
+ * @nand: nand device
+ *
+ * Update the BBT. Currently a NOP function since on-flash bbt is not yet
+ * supported.
+ *
+ * Return: 0 in case of success, a negative error code otherwise.
+ */
+int nanddev_bbt_update(struct nand_device *nand)
+{
+   return 0;
+}
+EXPORT_SYMBOL_GPL(nanddev_bbt_update);
+
+/**
+ * nanddev_bbt_get_block_status() - Return the status of an eraseblock
+ * @nand: nand device
+ * @entry: the BBT entry
+ *
+ * Return: a positive number nand_bbt_block_status status or -%ERANGE if @entry
+ *is bigger than the BBT size.
+ */
+int nanddev_bbt_get_block_status(const struct nand_device *nand,
+unsigned int entry)
+{
+   unsigned int bits_per_block = fls(NAND_BBT_BLOCK_NUM_STATUS);
+   unsigned long *pos = nand->bbt.cache +
+((entry * bits_per_block) / BITS_PER_LONG);
+   unsigned int offs = (entry * bits_per_block) % BITS_PER_LONG;
+   unsigned long status;
+
+   if (entry >= nanddev_neraseblocks(nand))
+   return -ERANGE;
+
+   status = pos[0] >> offs;
+   if (bits_per_block + offs > BITS_PER_LONG)
+   status |= pos[1] << (BITS_PER_LONG - offs);
+
+   return status & GENMASK(bits_per_block - 1, 0);
+}
+EXPORT_SYMBOL_GPL(nanddev_bbt_get_block_status);
+
+/**
+ * nanddev_bbt_set_block_status() - Update the status of an eraseblock in the
+ * in-memory BBT
+ * @nand: nand device
+ * @entry: the BBT entry to update
+ * @status: the new status
+ *
+ * Update an entry of the in-memory BBT. If you want to push the updated BBT
+ * the NAND you should call nanddev_bbt_update().
+ *
+ * Return: 0 in case of success or -%ERANGE if @entry is bigger than the BBT
+ *size.
+ */
+int nanddev_bbt_set_block_status(struct nand_device *nand, unsigned int entry,
+enum nand_bbt_block_status status)
+{
+   unsigned int bits_per_block = fls(NAND_BBT_BLOCK_NUM_STATUS);
+   unsigned long *pos = nand->bbt.cache +
+((entry * bits_per_block) / BITS_PER_LONG);
+   unsigned int offs = (entry * bits_per_block) % BITS_PER_LONG;
+   unsigned long val = status & GENMASK(bits_per_block - 1, 0);
+
+   if (entry >= nanddev_neraseblocks(nand))
+   return 

[U-Boot] [PATCH v6 20/27] mtd: declare MTD_PARTITIONS symbol in Kconfig

2018-08-01 Thread Miquel Raynal
UBI selects MTD_PARTITIONS which is the symbol to compile
drivers/mtd/mtdpart.c. Unfortunately, the symbol was not defined in
Kconfig and this worked only with board files defining it. Fix this by
adding a boolean in Kconfig so boards defined by defconfig files only
will work as expected.

Signed-off-by: Miquel Raynal 
Reviewed-by: Jagan Teki 
---
 drivers/mtd/Kconfig | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/mtd/Kconfig b/drivers/mtd/Kconfig
index 9341d518f3..d98457e223 100644
--- a/drivers/mtd/Kconfig
+++ b/drivers/mtd/Kconfig
@@ -1,5 +1,8 @@
 menu "MTD Support"
 
+config MTD_PARTITIONS
+   bool
+
 config MTD
bool "Enable Driver Model for MTD drivers"
depends on DM
-- 
2.14.1

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


[U-Boot] [PATCH v6 14/27] mtd: nand: Add core infrastructure to support SPI NANDs

2018-08-01 Thread Miquel Raynal
From: Peter Pan 

Add a SPI NAND framework based on the generic NAND framework and the
spi-mem infrastructure.

In its current state, this framework supports the following features:

- single/dual/quad IO modes
- on-die ECC

Signed-off-by: Peter Pan 
Signed-off-by: Boris Brezillon 
Signed-off-by: Miquel Raynal 
Acked-by: Jagan Teki 
---
 drivers/mtd/nand/Kconfig  |2 +
 drivers/mtd/nand/Makefile |1 +
 drivers/mtd/nand/spi/Kconfig  |7 +
 drivers/mtd/nand/spi/Makefile |4 +
 drivers/mtd/nand/spi/core.c   | 1235 +
 include/linux/mtd/spinand.h   |  427 ++
 6 files changed, 1676 insertions(+)
 create mode 100644 drivers/mtd/nand/spi/Kconfig
 create mode 100644 drivers/mtd/nand/spi/Makefile
 create mode 100644 drivers/mtd/nand/spi/core.c
 create mode 100644 include/linux/mtd/spinand.h

diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig
index 1c1a1f487e..78ae04bdcb 100644
--- a/drivers/mtd/nand/Kconfig
+++ b/drivers/mtd/nand/Kconfig
@@ -2,3 +2,5 @@ config MTD_NAND_CORE
tristate
 
 source "drivers/mtd/nand/raw/Kconfig"
+
+source "drivers/mtd/nand/spi/Kconfig"
diff --git a/drivers/mtd/nand/Makefile b/drivers/mtd/nand/Makefile
index cd492dbc14..a358bc680e 100644
--- a/drivers/mtd/nand/Makefile
+++ b/drivers/mtd/nand/Makefile
@@ -2,3 +2,4 @@
 
 nandcore-objs := core.o bbt.o
 obj-$(CONFIG_MTD_NAND_CORE) += nandcore.o
+obj-$(CONFIG_MTD_SPI_NAND) += spi/
diff --git a/drivers/mtd/nand/spi/Kconfig b/drivers/mtd/nand/spi/Kconfig
new file mode 100644
index 00..2197cb531f
--- /dev/null
+++ b/drivers/mtd/nand/spi/Kconfig
@@ -0,0 +1,7 @@
+menuconfig MTD_SPI_NAND
+   bool "SPI NAND device Support"
+   depends on MTD && DM_SPI
+   select MTD_NAND_CORE
+   select SPI_MEM
+   help
+ This is the framework for the SPI NAND device drivers.
diff --git a/drivers/mtd/nand/spi/Makefile b/drivers/mtd/nand/spi/Makefile
new file mode 100644
index 00..f0c6e69d2e
--- /dev/null
+++ b/drivers/mtd/nand/spi/Makefile
@@ -0,0 +1,4 @@
+# SPDX-License-Identifier: GPL-2.0
+
+spinand-objs := core.o
+obj-$(CONFIG_MTD_SPI_NAND) += spinand.o
diff --git a/drivers/mtd/nand/spi/core.c b/drivers/mtd/nand/spi/core.c
new file mode 100644
index 00..08f853ae11
--- /dev/null
+++ b/drivers/mtd/nand/spi/core.c
@@ -0,0 +1,1235 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2016-2017 Micron Technology, Inc.
+ *
+ * Authors:
+ * Peter Pan 
+ * Boris Brezillon 
+ */
+
+#define pr_fmt(fmt)"spi-nand: " fmt
+
+#ifndef __UBOOT__
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#else
+#include 
+#include 
+#include 
+#include 
+#include 
+#endif
+
+/* SPI NAND index visible in MTD names */
+static int spi_nand_idx;
+
+static void spinand_cache_op_adjust_colum(struct spinand_device *spinand,
+ const struct nand_page_io_req *req,
+ u16 *column)
+{
+   struct nand_device *nand = spinand_to_nand(spinand);
+   unsigned int shift;
+
+   if (nand->memorg.planes_per_lun < 2)
+   return;
+
+   /* The plane number is passed in MSB just above the column address */
+   shift = fls(nand->memorg.pagesize);
+   *column |= req->pos.plane << shift;
+}
+
+static int spinand_read_reg_op(struct spinand_device *spinand, u8 reg, u8 *val)
+{
+   struct spi_mem_op op = SPINAND_GET_FEATURE_OP(reg,
+ spinand->scratchbuf);
+   int ret;
+
+   ret = spi_mem_exec_op(spinand->slave, );
+   if (ret)
+   return ret;
+
+   *val = *spinand->scratchbuf;
+   return 0;
+}
+
+static int spinand_write_reg_op(struct spinand_device *spinand, u8 reg, u8 val)
+{
+   struct spi_mem_op op = SPINAND_SET_FEATURE_OP(reg,
+ spinand->scratchbuf);
+
+   *spinand->scratchbuf = val;
+   return spi_mem_exec_op(spinand->slave, );
+}
+
+static int spinand_read_status(struct spinand_device *spinand, u8 *status)
+{
+   return spinand_read_reg_op(spinand, REG_STATUS, status);
+}
+
+static int spinand_get_cfg(struct spinand_device *spinand, u8 *cfg)
+{
+   struct nand_device *nand = spinand_to_nand(spinand);
+
+   if (WARN_ON(spinand->cur_target < 0 ||
+   spinand->cur_target >= nand->memorg.ntargets))
+   return -EINVAL;
+
+   *cfg = spinand->cfg_cache[spinand->cur_target];
+   return 0;
+}
+
+static int spinand_set_cfg(struct spinand_device *spinand, u8 cfg)
+{
+   struct nand_device *nand = spinand_to_nand(spinand);
+   int ret;
+
+   if (WARN_ON(spinand->cur_target < 0 ||
+   spinand->cur_target >= nand->memorg.ntargets))
+   return -EINVAL;
+
+   if (spinand->cfg_cache[spinand->cur_target] == cfg)
+   return 0;
+
+   ret = 

[U-Boot] [PATCH v6 13/27] spi: Extend the core to ease integration of SPI memory controllers

2018-08-01 Thread Miquel Raynal
From: Boris Brezillon 

Some controllers are exposing high-level interfaces to access various
kind of SPI memories. Unfortunately they do not fit in the current
spi_controller model and usually have drivers placed in
drivers/mtd/spi-nor which are only supporting SPI NORs and not SPI
memories in general.

This is an attempt at defining a SPI memory interface which works for
all kinds of SPI memories (NORs, NANDs, SRAMs).

Signed-off-by: Boris Brezillon 
Signed-off-by: Miquel Raynal 
Acked-by: Jagan Teki 
---
 drivers/spi/Kconfig   |   7 +
 drivers/spi/Makefile  |   1 +
 drivers/spi/spi-mem.c | 500 ++
 include/spi-mem.h | 258 ++
 include/spi.h |  11 ++
 5 files changed, 777 insertions(+)
 create mode 100644 drivers/spi/spi-mem.c
 create mode 100644 include/spi-mem.h

diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig
index b85fca5628..6286b2e234 100644
--- a/drivers/spi/Kconfig
+++ b/drivers/spi/Kconfig
@@ -18,6 +18,13 @@ config DM_SPI
 
 if DM_SPI
 
+config SPI_MEM
+   bool "SPI memory extension"
+   help
+ Enable this option if you want to enable the SPI memory extension.
+ This extension is meant to simplify interaction with SPI memories
+ by providing an high-level interface to send memory-like commands.
+
 config ALTERA_SPI
bool "Altera SPI driver"
help
diff --git a/drivers/spi/Makefile b/drivers/spi/Makefile
index 95b03a29dc..7971adeb6f 100644
--- a/drivers/spi/Makefile
+++ b/drivers/spi/Makefile
@@ -8,6 +8,7 @@ ifdef CONFIG_DM_SPI
 obj-y += spi-uclass.o
 obj-$(CONFIG_SANDBOX) += spi-emul-uclass.o
 obj-$(CONFIG_SOFT_SPI) += soft_spi.o
+obj-$(CONFIG_SPI_MEM) += spi-mem.o
 else
 obj-y += spi.o
 obj-$(CONFIG_SOFT_SPI) += soft_spi_legacy.o
diff --git a/drivers/spi/spi-mem.c b/drivers/spi/spi-mem.c
new file mode 100644
index 00..07ce799170
--- /dev/null
+++ b/drivers/spi/spi-mem.c
@@ -0,0 +1,500 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2018 Exceet Electronics GmbH
+ * Copyright (C) 2018 Bootlin
+ *
+ * Author: Boris Brezillon 
+ */
+
+#ifndef __UBOOT__
+#include 
+#include 
+#include "internals.h"
+#else
+#include 
+#include 
+#endif
+
+#ifndef __UBOOT__
+/**
+ * spi_controller_dma_map_mem_op_data() - DMA-map the buffer attached to a
+ *   memory operation
+ * @ctlr: the SPI controller requesting this dma_map()
+ * @op: the memory operation containing the buffer to map
+ * @sgt: a pointer to a non-initialized sg_table that will be filled by this
+ *  function
+ *
+ * Some controllers might want to do DMA on the data buffer embedded in @op.
+ * This helper prepares everything for you and provides a ready-to-use
+ * sg_table. This function is not intended to be called from spi drivers.
+ * Only SPI controller drivers should use it.
+ * Note that the caller must ensure the memory region pointed by
+ * op->data.buf.{in,out} is DMA-able before calling this function.
+ *
+ * Return: 0 in case of success, a negative error code otherwise.
+ */
+int spi_controller_dma_map_mem_op_data(struct spi_controller *ctlr,
+  const struct spi_mem_op *op,
+  struct sg_table *sgt)
+{
+   struct device *dmadev;
+
+   if (!op->data.nbytes)
+   return -EINVAL;
+
+   if (op->data.dir == SPI_MEM_DATA_OUT && ctlr->dma_tx)
+   dmadev = ctlr->dma_tx->device->dev;
+   else if (op->data.dir == SPI_MEM_DATA_IN && ctlr->dma_rx)
+   dmadev = ctlr->dma_rx->device->dev;
+   else
+   dmadev = ctlr->dev.parent;
+
+   if (!dmadev)
+   return -EINVAL;
+
+   return spi_map_buf(ctlr, dmadev, sgt, op->data.buf.in, op->data.nbytes,
+  op->data.dir == SPI_MEM_DATA_IN ?
+  DMA_FROM_DEVICE : DMA_TO_DEVICE);
+}
+EXPORT_SYMBOL_GPL(spi_controller_dma_map_mem_op_data);
+
+/**
+ * spi_controller_dma_unmap_mem_op_data() - DMA-unmap the buffer attached to a
+ * memory operation
+ * @ctlr: the SPI controller requesting this dma_unmap()
+ * @op: the memory operation containing the buffer to unmap
+ * @sgt: a pointer to an sg_table previously initialized by
+ *  spi_controller_dma_map_mem_op_data()
+ *
+ * Some controllers might want to do DMA on the data buffer embedded in @op.
+ * This helper prepares things so that the CPU can access the
+ * op->data.buf.{in,out} buffer again.
+ *
+ * This function is not intended to be called from SPI drivers. Only SPI
+ * controller drivers should use it.
+ *
+ * This function should be called after the DMA operation has finished and is
+ * only valid if the previous spi_controller_dma_map_mem_op_data() call
+ * returned 0.
+ *
+ * Return: 0 in case of success, a negative error code otherwise.
+ */
+void spi_controller_dma_unmap_mem_op_data(struct spi_controller *ctlr,
+  

[U-Boot] [PATCH v6 25/27] mtd: uclass: add probe function

2018-08-01 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 
---
 drivers/mtd/mtd-uclass.c | 9 +
 include/linux/mtd/mtd.h  | 3 +++
 2 files changed, 12 insertions(+)

diff --git a/drivers/mtd/mtd-uclass.c b/drivers/mtd/mtd-uclass.c
index 9ca049c437..9a9470410c 100644
--- a/drivers/mtd/mtd-uclass.c
+++ b/drivers/mtd/mtd-uclass.c
@@ -5,6 +5,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -13,6 +14,14 @@
  * The uclass private is pointed to mtd_info.
  */
 
+int mtd_probe(struct udevice *dev)
+{
+   if (device_active(dev))
+   return 0;
+
+   return device_probe(dev);
+}
+
 UCLASS_DRIVER(mtd) = {
.id = UCLASS_MTD,
.name   = "mtd",
diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
index 6771ee2586..7dd45bde65 100644
--- a/include/linux/mtd/mtd.h
+++ b/include/linux/mtd/mtd.h
@@ -533,5 +533,8 @@ int mtd_arg_off_size(int argc, char *const argv[], int 
*idx, loff_t *off,
 void mtd_get_len_incl_bad(struct mtd_info *mtd, uint64_t offset,
  const uint64_t length, uint64_t *len_incl_bad,
  int *truncated);
+
+int mtd_probe(struct udevice *dev);
+
 #endif
 #endif /* __MTD_MTD_H__ */
-- 
2.14.1

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


[U-Boot] [PATCH v6 16/27] mtd: spinand: Add initial support for Winbond W25M02GV

2018-08-01 Thread Miquel Raynal
From: Frieder Schrempf 

Add support for the W25M02GV chip.

Signed-off-by: Frieder Schrempf 
Signed-off-by: Boris Brezillon 
Signed-off-by: Miquel Raynal 
Acked-by: Jagan Teki 
---
 drivers/mtd/nand/spi/Makefile  |   2 +-
 drivers/mtd/nand/spi/core.c|   1 +
 drivers/mtd/nand/spi/winbond.c | 143 +
 include/linux/mtd/spinand.h|   1 +
 4 files changed, 146 insertions(+), 1 deletion(-)
 create mode 100644 drivers/mtd/nand/spi/winbond.c

diff --git a/drivers/mtd/nand/spi/Makefile b/drivers/mtd/nand/spi/Makefile
index 4eb745abd4..11ba5de68b 100644
--- a/drivers/mtd/nand/spi/Makefile
+++ b/drivers/mtd/nand/spi/Makefile
@@ -1,4 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0
 
-spinand-objs := core.o micron.o
+spinand-objs := core.o micron.o winbond.o
 obj-$(CONFIG_MTD_SPI_NAND) += spinand.o
diff --git a/drivers/mtd/nand/spi/core.c b/drivers/mtd/nand/spi/core.c
index 36b8b52bc2..ef3e6445d8 100644
--- a/drivers/mtd/nand/spi/core.c
+++ b/drivers/mtd/nand/spi/core.c
@@ -831,6 +831,7 @@ static const struct nand_ops spinand_ops = {
 
 static const struct spinand_manufacturer *spinand_manufacturers[] = {
_spinand_manufacturer,
+   _spinand_manufacturer,
 };
 
 static int spinand_manufacturer_detect(struct spinand_device *spinand)
diff --git a/drivers/mtd/nand/spi/winbond.c b/drivers/mtd/nand/spi/winbond.c
new file mode 100644
index 00..eac811d97c
--- /dev/null
+++ b/drivers/mtd/nand/spi/winbond.c
@@ -0,0 +1,143 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2017 exceet electronics GmbH
+ *
+ * Authors:
+ * Frieder Schrempf 
+ * Boris Brezillon 
+ */
+
+#ifndef __UBOOT__
+#include 
+#include 
+#endif
+#include 
+
+#define SPINAND_MFR_WINBOND0xEF
+
+#define WINBOND_CFG_BUF_READ   BIT(3)
+
+static SPINAND_OP_VARIANTS(read_cache_variants,
+   SPINAND_PAGE_READ_FROM_CACHE_QUADIO_OP(0, 2, NULL, 0),
+   SPINAND_PAGE_READ_FROM_CACHE_X4_OP(0, 1, NULL, 0),
+   SPINAND_PAGE_READ_FROM_CACHE_DUALIO_OP(0, 1, NULL, 0),
+   SPINAND_PAGE_READ_FROM_CACHE_X2_OP(0, 1, NULL, 0),
+   SPINAND_PAGE_READ_FROM_CACHE_OP(true, 0, 1, NULL, 0),
+   SPINAND_PAGE_READ_FROM_CACHE_OP(false, 0, 1, NULL, 0));
+
+static SPINAND_OP_VARIANTS(write_cache_variants,
+   SPINAND_PROG_LOAD_X4(true, 0, NULL, 0),
+   SPINAND_PROG_LOAD(true, 0, NULL, 0));
+
+static SPINAND_OP_VARIANTS(update_cache_variants,
+   SPINAND_PROG_LOAD_X4(false, 0, NULL, 0),
+   SPINAND_PROG_LOAD(false, 0, NULL, 0));
+
+static int w25m02gv_ooblayout_ecc(struct mtd_info *mtd, int section,
+ struct mtd_oob_region *region)
+{
+   if (section > 3)
+   return -ERANGE;
+
+   region->offset = (16 * section) + 8;
+   region->length = 8;
+
+   return 0;
+}
+
+static int w25m02gv_ooblayout_free(struct mtd_info *mtd, int section,
+  struct mtd_oob_region *region)
+{
+   if (section > 3)
+   return -ERANGE;
+
+   region->offset = (16 * section) + 2;
+   region->length = 6;
+
+   return 0;
+}
+
+static const struct mtd_ooblayout_ops w25m02gv_ooblayout = {
+   .ecc = w25m02gv_ooblayout_ecc,
+   .free = w25m02gv_ooblayout_free,
+};
+
+static int w25m02gv_select_target(struct spinand_device *spinand,
+ unsigned int target)
+{
+   struct spi_mem_op op = SPI_MEM_OP(SPI_MEM_OP_CMD(0xc2, 1),
+ SPI_MEM_OP_NO_ADDR,
+ SPI_MEM_OP_NO_DUMMY,
+ SPI_MEM_OP_DATA_OUT(1,
+   spinand->scratchbuf,
+   1));
+
+   *spinand->scratchbuf = target;
+   return spi_mem_exec_op(spinand->slave, );
+}
+
+static const struct spinand_info winbond_spinand_table[] = {
+   SPINAND_INFO("W25M02GV", 0xAB,
+NAND_MEMORG(1, 2048, 64, 64, 1024, 1, 1, 2),
+NAND_ECCREQ(1, 512),
+SPINAND_INFO_OP_VARIANTS(_cache_variants,
+ _cache_variants,
+ _cache_variants),
+0,
+SPINAND_ECCINFO(_ooblayout, NULL),
+SPINAND_SELECT_TARGET(w25m02gv_select_target)),
+};
+
+/**
+ * winbond_spinand_detect - initialize device related part in spinand_device
+ * struct if it is a Winbond device.
+ * @spinand: SPI NAND device structure
+ */
+static int winbond_spinand_detect(struct spinand_device *spinand)
+{
+   u8 *id = spinand->id.data;
+   int ret;
+
+   /*
+* Winbond SPI NAND read ID need a dummy byte,
+* so the first byte in raw_id is dummy.
+*/
+   if (id[1] != SPINAND_MFR_WINBOND)
+   return 

[U-Boot] [PATCH v6 09/27] mtd: move NAND files into a raw/ subdirectory

2018-08-01 Thread Miquel Raynal
NAND flavors, like serial and parallel, have a lot in common and would
benefit to share code. Let's move raw (parallel) NAND specific code in a
raw/ subdirectory, to ease the addition of a core file in nand/ and the
introduction of a spi/ subdirectory specific to SPI NANDs.

Documentation, README*, and MAINTAINERS files are updated accordingly.

Signed-off-by: Miquel Raynal 
---
 MAINTAINERS   |   6 +-
 Makefile  |   2 +-
 README|   6 +-
 arch/arm/mach-uniphier/board_late_init.c  |   2 +-
 common/spl/Kconfig|   2 +-
 common/spl/spl_spi.c  |   2 +-
 doc/README.SPL|   4 +-
 doc/README.arm-relocation |   2 +-
 doc/README.nand   |   6 +-
 doc/README.zynq   |   2 +-
 drivers/Makefile  |   2 +-
 drivers/mtd/Makefile  |   2 +
 drivers/mtd/nand/Kconfig  | 298 +-
 drivers/mtd/nand/Makefile |  75 ---
 drivers/mtd/nand/raw/Kconfig  | 297 +
 drivers/mtd/nand/raw/Makefile |  77 +++
 drivers/mtd/nand/{ => raw}/am335x_spl_bch.c   |   0
 drivers/mtd/nand/{ => raw}/arasan_nfc.c   |   0
 drivers/mtd/nand/{ => raw}/atmel_nand.c   |   0
 drivers/mtd/nand/{ => raw}/atmel_nand_ecc.h   |   0
 drivers/mtd/nand/{ => raw}/davinci_nand.c |   2 +-
 drivers/mtd/nand/{ => raw}/denali.c   |   0
 drivers/mtd/nand/{ => raw}/denali.h   |   0
 drivers/mtd/nand/{ => raw}/denali_dt.c|   0
 drivers/mtd/nand/{ => raw}/denali_spl.c   |   0
 drivers/mtd/nand/{ => raw}/fsl_elbc_nand.c|   0
 drivers/mtd/nand/{ => raw}/fsl_elbc_spl.c |   0
 drivers/mtd/nand/{ => raw}/fsl_ifc_nand.c |   0
 drivers/mtd/nand/{ => raw}/fsl_ifc_spl.c  |   0
 drivers/mtd/nand/{ => raw}/fsl_upm.c  |   0
 drivers/mtd/nand/{ => raw}/fsmc_nand.c|   0
 drivers/mtd/nand/{ => raw}/kb9202_nand.c  |   0
 drivers/mtd/nand/{ => raw}/kirkwood_nand.c|   0
 drivers/mtd/nand/{ => raw}/kmeter1_nand.c |   0
 drivers/mtd/nand/{ => raw}/lpc32xx_nand_mlc.c |   0
 drivers/mtd/nand/{ => raw}/lpc32xx_nand_slc.c |   0
 drivers/mtd/nand/{ => raw}/mxc_nand.c |   0
 drivers/mtd/nand/{ => raw}/mxc_nand.h |   0
 drivers/mtd/nand/{ => raw}/mxc_nand_spl.c |   0
 drivers/mtd/nand/{ => raw}/mxs_nand.c |   0
 drivers/mtd/nand/{ => raw}/mxs_nand.h |   0
 drivers/mtd/nand/{ => raw}/mxs_nand_dt.c  |   0
 drivers/mtd/nand/{ => raw}/mxs_nand_spl.c |   0
 drivers/mtd/nand/{ => raw}/nand.c |   0
 drivers/mtd/nand/{ => raw}/nand_base.c|   0
 drivers/mtd/nand/{ => raw}/nand_bbt.c |   0
 drivers/mtd/nand/{ => raw}/nand_bch.c |   0
 drivers/mtd/nand/{ => raw}/nand_ecc.c |   2 +-
 drivers/mtd/nand/{ => raw}/nand_ids.c |   0
 drivers/mtd/nand/{ => raw}/nand_plat.c|   0
 drivers/mtd/nand/{ => raw}/nand_spl_load.c|   0
 drivers/mtd/nand/{ => raw}/nand_spl_loaders.c |   0
 drivers/mtd/nand/{ => raw}/nand_spl_simple.c  |   0
 drivers/mtd/nand/{ => raw}/nand_timings.c |   0
 drivers/mtd/nand/{ => raw}/nand_util.c|   2 +-
 drivers/mtd/nand/{ => raw}/omap_elm.c |   0
 drivers/mtd/nand/{ => raw}/omap_gpmc.c|   0
 drivers/mtd/nand/{ => raw}/pxa3xx_nand.c  |   2 +-
 drivers/mtd/nand/{ => raw}/pxa3xx_nand.h  |   0
 drivers/mtd/nand/{ => raw}/sunxi_nand.c   |   0
 drivers/mtd/nand/{ => raw}/sunxi_nand_spl.c   |   0
 drivers/mtd/nand/{ => raw}/tegra_nand.c   |   0
 drivers/mtd/nand/{ => raw}/tegra_nand.h   |   0
 drivers/mtd/nand/{ => raw}/vf610_nfc.c|   0
 drivers/mtd/nand/{ => raw}/zynq_nand.c|   0
 include/configs/MPC8313ERDB.h |   2 +-
 66 files changed, 400 insertions(+), 395 deletions(-)
 create mode 100644 drivers/mtd/nand/raw/Kconfig
 create mode 100644 drivers/mtd/nand/raw/Makefile
 rename drivers/mtd/nand/{ => raw}/am335x_spl_bch.c (100%)
 rename drivers/mtd/nand/{ => raw}/arasan_nfc.c (100%)
 rename drivers/mtd/nand/{ => raw}/atmel_nand.c (100%)
 rename drivers/mtd/nand/{ => raw}/atmel_nand_ecc.h (100%)
 rename drivers/mtd/nand/{ => raw}/davinci_nand.c (99%)
 rename drivers/mtd/nand/{ => raw}/denali.c (100%)
 rename drivers/mtd/nand/{ => raw}/denali.h (100%)
 rename drivers/mtd/nand/{ => raw}/denali_dt.c (100%)
 rename drivers/mtd/nand/{ => raw}/denali_spl.c (100%)
 rename drivers/mtd/nand/{ => raw}/fsl_elbc_nand.c (100%)
 rename drivers/mtd/nand/{ => raw}/fsl_elbc_spl.c (100%)
 rename drivers/mtd/nand/{ => raw}/fsl_ifc_nand.c (100%)
 rename drivers/mtd/nand/{ => raw}/fsl_ifc_spl.c (100%)
 rename drivers/mtd/nand/{ => raw}/fsl_upm.c (100%)
 rename drivers/mtd/nand/{ => raw}/fsmc_nand.c (100%)
 rename 

[U-Boot] [PATCH v6 08/27] mtd: move all flash categories inside MTD submenu

2018-08-01 Thread Miquel Raynal
There is no reason to have NAND, SPI flashes and UBI sections outside of
the MTD submenu in Kconfig.

Signed-off-by: Miquel Raynal 
Reviewed-by: Jagan Teki 
---
 drivers/mtd/Kconfig | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/Kconfig b/drivers/mtd/Kconfig
index 41f8883ec2..9341d518f3 100644
--- a/drivers/mtd/Kconfig
+++ b/drivers/mtd/Kconfig
@@ -59,10 +59,10 @@ config RENESAS_RPC_HF
  This enables access to Hyperflash memory through the Renesas
  RCar Gen3 RPC controller.
 
-endmenu
-
 source "drivers/mtd/nand/Kconfig"
 
 source "drivers/mtd/spi/Kconfig"
 
 source "drivers/mtd/ubi/Kconfig"
+
+endmenu
-- 
2.14.1

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


[U-Boot] [PATCH v6 10/27] mtd: rename nand into rawnand in Kconfig prompt

2018-08-01 Thread Miquel Raynal
Sync the Kconfig raw NAND entry title with the code architecture.

Signed-off-by: Miquel Raynal 
---
 drivers/mtd/nand/raw/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mtd/nand/raw/Kconfig b/drivers/mtd/nand/raw/Kconfig
index 1e4ea7bdd4..008f7b4b4b 100644
--- a/drivers/mtd/nand/raw/Kconfig
+++ b/drivers/mtd/nand/raw/Kconfig
@@ -1,6 +1,6 @@
 
 menuconfig NAND
-   bool "NAND Device Support"
+   bool "Raw NAND Device Support"
 if NAND
 
 config SYS_NAND_SELF_INIT
-- 
2.14.1

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


[U-Boot] [PATCH v6 05/27] mtd: add get/set of_node/flash_node helpers

2018-08-01 Thread Miquel Raynal
From: Brian Norris 

We are going to begin using the mtd->dev.of_node field for MTD device
nodes, so let's add helpers for it. Also, we'll be making some
conversions on spi_nor (and nand_chip eventually) too, so get that ready
with their own helpers.

Signed-off-by: Brian Norris 
Reviewed-by: Boris Brezillon 
Signed-off-by: Miquel Raynal 
Reviewed-by: Jagan Teki 
---
 include/linux/mtd/mtd.h | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
index eb39f38887..ea659c354b 100644
--- a/include/linux/mtd/mtd.h
+++ b/include/linux/mtd/mtd.h
@@ -306,6 +306,17 @@ struct mtd_info {
int usecount;
 };
 
+static inline void mtd_set_of_node(struct mtd_info *mtd,
+  const struct device_node *np)
+{
+   mtd->dev->node.np = np;
+}
+
+static inline const struct device_node *mtd_get_of_node(struct mtd_info *mtd)
+{
+   return mtd->dev->node.np;
+}
+
 int mtd_ooblayout_ecc(struct mtd_info *mtd, int section,
  struct mtd_oob_region *oobecc);
 int mtd_ooblayout_find_eccregion(struct mtd_info *mtd, int eccbyte,
-- 
2.14.1

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


  1   2   >