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

2019-10-27 Thread Jagan Teki
Hi Tom,

On Fri, Oct 25, 2019 at 11:19 PM Tom Rini  wrote:
>
> On Fri, Oct 25, 2019 at 02:08:12PM +0530, Jagan Teki wrote:
>
> > Hi Tom,
> >
> > Please pull this PR.
> >
> > Summary:
> > - SPL_SPI_FLASH_MTD (Frieder)
> > - SPI NOR IDs' fixes, additions (Vignesh)
> > - cs_info change (Bin)
> > - Enable sunxi spi (Jagan)
> >
> > Travis-CI:
> > https://travis-ci.org/openedev/u-boot-amarula/builds/602483415
> >
> > Thanks,
> > Jagan.
> >
> > The following changes since commit 17fd9915a4c639381804ed28274fa136ae3b0bee:
> >
> >   Merge branch '2019-10-24-UFS-support' (2019-10-24 09:51:48 -0400)
> >
> > are available in the Git repository at:
> >
> >   https://gitlab.denx.de/u-boot/custodians/u-boot-spi master
> >
> > for you to fetch changes up to 395ec7418695e5ce23f8b48c01a1dbffd2e52d3f:
> >
> >   spi-nor-ids: Add support for Adesto AT25SL321 (2019-10-25 00:48:32 +0530)
> >
>
> So, looking over the build output, I see the expected size increase in
> sunxi due to new support. But I also see a lot of size increases in
> rockchip and layerscape platforms (and possibly more, I stopped after
> spotting two different SoCs), for example:
> evb-px5: all +12139 data +176 rodata +2275 
> spl/u-boot-spl:all +3529 spl/u-boot-spl:data +120 spl/u-boot-spl:rodata +309 
> spl/u-boot-spl:text +3100 text +9688
>u-boot: add: 49/0, grow: 0/0 bytes: 9512/0 (9512)
>  function   old new   
> delta
>  spi_nor_scan -2032   
> +2032
>  do_spi_flash -2008   
> +2008
>  spi_get_bus_and_cs   - 436
> +436
>  spi_mem_exec_op  - 420
> +420
>  static.spi_nor_wait_till_ready_with_timeout   - 300  
>   +300
>  spi_nor_write- 300
> +300
>  mtd_arg_off_size - 276
> +276
>  spi_nor_erase- 232
> +232
>  device_unbind- 232
> +232
>  spi_nor_read_data- 220
> +220
>  spi_nor_write_data   - 212
> +212
>  dm_spi_claim_bus - 196
> +196
>  spi_mem_adjust_op_size   - 160
> +160
>  spi_mem_default_supports_op  - 156
> +156
>  spi_nor_read - 152
> +152
>  spi_flash_probe_bus_cs   - 152
> +152
>  spi_set_speed_mode   - 148
> +148
>  spi_flash_std_erase  - 136
> +136
>  spi_flash_std_probe  - 132
> +132
>  mtd_arg_off  - 124
> +124
>  device_chld_unbind   - 120
> +120
>  _u_boot_list_2_driver_2_spi_flash_std- 120
> +120
>  spi_nor_write_reg- 104
> +104
>  spi_find_bus_and_cs  - 104
> +104
>  spi_nor_read_reg - 100
> +100
>  spi_find_chip_select -  96 
> +96
>  static.spi_check_buswidth_req-  88 
> +88
>  str2off  -  80 
> +80
>  bytes_per_second -  76 
> +76
>  spi_flash_std_write  -  72 
> +72
>  spi_flash_std_read   -  72 
> +72
>  spi_mem_supports_op  -  56 
> +56
>  _u_boot_list_2_cmd_2_sf  -  56 
> +56
>  dm_spi_xfer  -  48 
> +48
>  read_sr  -  44 
> +44
>  device_find_next_child   -  40 
> +40
>  spi_flash_cmd_get_sw_write_prot  -  36 
> +36
>  dm_spi_release_bus   -  28 
> +28
>  write_enable -  20 
> +20
>  write_disable-  20 
> +20
>  spi_flash_std_get_sw_write_prot  -  20 
> +20
>  spi_flash_

Re: [U-Boot] [PATCH v6 0/3] End of the MTD makefile cleanup

2019-10-27 Thread Jagan Teki
On Sun, Oct 27, 2019 at 3:33 AM Miquel Raynal  wrote:
>
> Hi Jagan,
>
> Jagan Teki  wrote on Sat, 26 Oct 2019
> 15:50:06 +0530:
>
> > On Fri, Oct 25, 2019 at 11:09 PM Miquel Raynal
> >  wrote:
> > >
> > > As rightfully pointed by Jagan, I should have dropped the dependency
> > > of cmd/sf.c and cmd/nand.c on mtd_uboot.c in patch 24/26 of the "MTD
> > > defconfigs/Kconfigs/Makefiles heavy cleanup" v5 series.
> > >
> > > Instead of sending the 40 patches again, here are only the last three
> > > patches with:
> > > * patch 1 (24/26) being corrected as per Jagan's comment
> > > * patch 2 (25/26) is untouched
> > > * patch 3 (26/26) is almost untouched but I had to resolve a conflict
> > >   due to patch 1.
> > >
> > > Thanks,
> > > Miquèl
> > >
> > > Miquel Raynal (3):
> > >   cmd: nand/sf: isolate legacy code
> > >   cmd: make MTD commands depend on MTD
> > >   mtd: Makefile: deep cleanup
> >
> > Reviewed-by: Jagan Teki 
>
> Thanks!
>
> Who is supposed to take the two series?

Looks like there are several defconfig changes in master, please
rebase on master and send your branch (some where from github or so).
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3 0/9] tools: Support building U-Boot host tools for Windows via MSYS2

2019-10-27 Thread Bin Meng
Per current U-Boot README, building Windows versions of the utilities
in the tools directory is done via the MinGW toolchain. But testing
shows that it is broken and actually it must have been broken for
quite a long time.

Fixing MinGW build seems quite amount of work as developers of
U-Boot normally work on Linux boxes hence codes written are mainly
for Linux or POSIX OSes. We must investigate another way of building
host tools for Windows, and now we have MSYS2, a software distro and
building platform for Windows, to build POSIX compliant software on
Windows using an emulation layer.

This small series fixes several issues in current U-Boot tools codes,
that only assume a Linux host is used. Cases are using standard C
typedefs whenever possbile, or using compiler builtin functions to
improve portability, etc.

A reST document for how to build U-Boot host tools for both platforms
is added.

A new CI pipeline configuration for Microsoft Azure Pipelines is added
for U-Boot. We rely on it to ensure future host tools for Windows build
does not break.

I've also investigated putting what we have for now on GitLab-CI and
Travis-CI to Azure Pipelines, and it turns out there are several issues
that should be fixed. I will post a follow-up patch series for enabling
full CI testing on Azure Pipelines.

Changes in v3:
- new patch: tools: ifwitool: Define __packed when it is not defined
- rename to .azure-pipelines.yml
- correct typo in the commit summary

Changes in v2:
- new patch: Add .gitattributes for line endings
- new patch: tools: Avoid creating symbolic links for tools/version.h
- new patch: Add Microsoft Azure pipelines configuration

Bin Meng (9):
  tools: image.h: Use portable uint32_t instead of linux-specific __be32
  tools: mtk_image.h: Use portable uintXX_t instead of linux-specific
__leXX
  tools: zynqmpbif: Use compiler builtin instead of linux-specific
__swab32
  linux/types.h: Surround 'struct ustat' with __linux__
  tools: ifwitool: Define __packed when it is not defined
  doc: Add documentation for how to build U-Boot host tools
  Add .gitattributes for line endings
  tools: Avoid creating symbolic links for tools/version.h
  Add Microsoft Azure Pipelines configuration

 .azure-pipelines.yml  | 38 +++
 .gitattributes|  2 ++
 Makefile  |  9 --
 doc/build/index.rst   |  9 ++
 doc/build/tools.rst   | 47 
 doc/index.rst | 11 +++
 include/image.h   | 14 -
 include/linux/types.h |  2 ++
 tools/.gitignore  |  1 +
 tools/ifwitool.c  |  2 ++
 tools/mtk_image.h | 86 +--
 tools/version.h   |  1 -
 tools/zynqmpbif.c |  2 +-
 13 files changed, 169 insertions(+), 55 deletions(-)
 create mode 100644 .azure-pipelines.yml
 create mode 100644 .gitattributes
 create mode 100644 doc/build/index.rst
 create mode 100644 doc/build/tools.rst
 delete mode 12 tools/version.h

-- 
2.7.4

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


[U-Boot] [PATCH v3 2/9] tools: mtk_image.h: Use portable uintXX_t instead of linux-specific __leXX

2019-10-27 Thread Bin Meng
__leXX has Linux kernel specific __attribute__((bitwise)) which is
not portable. Use corresponding uintXX_t instead.

Signed-off-by: Bin Meng 
---

Changes in v3: None
Changes in v2: None

 tools/mtk_image.h | 86 +++
 1 file changed, 43 insertions(+), 43 deletions(-)

diff --git a/tools/mtk_image.h b/tools/mtk_image.h
index 0a9eab3..4e78b3d 100644
--- a/tools/mtk_image.h
+++ b/tools/mtk_image.h
@@ -9,14 +9,14 @@
 #ifndef _MTK_IMAGE_H
 #define _MTK_IMAGE_H
 
-/* Device header definitions */
+/* Device header definitions, all fields are little-endian */
 
 /* Header for NOR/SD/eMMC */
 union gen_boot_header {
struct {
char name[12];
-   __le32 version;
-   __le32 size;
+   uint32_t version;
+   uint32_t size;
};
 
uint8_t pad[0x200];
@@ -32,14 +32,14 @@ union nand_boot_header {
char name[12];
char version[4];
char id[8];
-   __le16 ioif;
-   __le16 pagesize;
-   __le16 addrcycles;
-   __le16 oobsize;
-   __le16 pages_of_block;
-   __le16 numblocks;
-   __le16 writesize_shift;
-   __le16 erasesize_shift;
+   uint16_t ioif;
+   uint16_t pagesize;
+   uint16_t addrcycles;
+   uint16_t oobsize;
+   uint16_t pages_of_block;
+   uint16_t numblocks;
+   uint16_t writesize_shift;
+   uint16_t erasesize_shift;
uint8_t dummy[60];
uint8_t ecc_parity[28];
};
@@ -54,14 +54,14 @@ union nand_boot_header {
 /* BootROM layout header */
 struct brom_layout_header {
char name[8];
-   __le32 version;
-   __le32 header_size;
-   __le32 total_size;
-   __le32 magic;
-   __le32 type;
-   __le32 header_size_2;
-   __le32 total_size_2;
-   __le32 unused;
+   uint32_t version;
+   uint32_t header_size;
+   uint32_t total_size;
+   uint32_t magic;
+   uint32_t type;
+   uint32_t header_size_2;
+   uint32_t total_size_2;
+   uint32_t unused;
 };
 
 #define BRLYT_NAME "BRLYT"
@@ -90,8 +90,8 @@ struct gen_device_header {
 struct gfh_common_header {
uint8_t magic[3];
uint8_t version;
-   __le16 size;
-   __le16 type;
+   uint16_t size;
+   uint16_t type;
 };
 
 #define GFH_HEADER_MAGIC   "MMM"
@@ -106,17 +106,17 @@ struct gfh_common_header {
 struct gfh_file_info {
struct gfh_common_header gfh;
char name[12];
-   __le32 unused;
-   __le16 file_type;
+   uint32_t unused;
+   uint16_t file_type;
uint8_t flash_type;
uint8_t sig_type;
-   __le32 load_addr;
-   __le32 total_size;
-   __le32 max_size;
-   __le32 hdr_size;
-   __le32 sig_size;
-   __le32 jump_offset;
-   __le32 processed;
+   uint32_t load_addr;
+   uint32_t total_size;
+   uint32_t max_size;
+   uint32_t hdr_size;
+   uint32_t sig_size;
+   uint32_t jump_offset;
+   uint32_t processed;
 };
 
 #define GFH_FILE_INFO_NAME "FILE_INFO"
@@ -129,16 +129,16 @@ struct gfh_file_info {
 
 struct gfh_bl_info {
struct gfh_common_header gfh;
-   __le32 attr;
+   uint32_t attr;
 };
 
 struct gfh_brom_cfg {
struct gfh_common_header gfh;
-   __le32 cfg_bits;
-   __le32 usbdl_by_auto_detect_timeout_ms;
+   uint32_t cfg_bits;
+   uint32_t usbdl_by_auto_detect_timeout_ms;
uint8_t unused[0x48];
-   __le32 usbdl_by_kcol0_timeout_ms;
-   __le32 usbdl_by_flag_timeout_ms;
+   uint32_t usbdl_by_kcol0_timeout_ms;
+   uint32_t usbdl_by_flag_timeout_ms;
uint32_t pad;
 };
 
@@ -157,15 +157,15 @@ struct gfh_anti_clone {
uint8_t ac_b2k;
uint8_t ac_b2c;
uint16_t pad;
-   __le32 ac_offset;
-   __le32 ac_len;
+   uint32_t ac_offset;
+   uint32_t ac_len;
 };
 
 struct gfh_brom_sec_cfg {
struct gfh_common_header gfh;
-   __le32 cfg_bits;
+   uint32_t cfg_bits;
char customer_name[0x20];
-   __le32 pad;
+   uint32_t pad;
 };
 
 #define BROM_SEC_CFG_JTAG_EN   1
@@ -184,11 +184,11 @@ struct gfh_header {
 
 union lk_hdr {
struct {
-   __le32 magic;
-   __le32 size;
+   uint32_t magic;
+   uint32_t size;
char name[32];
-   __le32 loadaddr;
-   __le32 mode;
+   uint32_t loadaddr;
+   uint32_t mode;
};
 
uint8_t data[512];
-- 
2.7.4

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


[U-Boot] [PATCH v3 1/9] tools: image.h: Use portable uint32_t instead of linux-specific __be32

2019-10-27 Thread Bin Meng
__be32 has Linux kernel specific __attribute__((bitwise)) which is
not portable. Use uint32_t instead.

Signed-off-by: Bin Meng 
---

Changes in v3: None
Changes in v2: None

 include/image.h | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/include/image.h b/include/image.h
index c1065c0..f4d2aaf 100644
--- a/include/image.h
+++ b/include/image.h
@@ -319,13 +319,13 @@ enum {
  * all data in network byte order (aka natural aka bigendian).
  */
 typedef struct image_header {
-   __be32  ih_magic;   /* Image Header Magic Number*/
-   __be32  ih_hcrc;/* Image Header CRC Checksum*/
-   __be32  ih_time;/* Image Creation Timestamp */
-   __be32  ih_size;/* Image Data Size  */
-   __be32  ih_load;/* Data  Load  Address  */
-   __be32  ih_ep;  /* Entry Point Address  */
-   __be32  ih_dcrc;/* Image Data CRC Checksum  */
+   uint32_tih_magic;   /* Image Header Magic Number*/
+   uint32_tih_hcrc;/* Image Header CRC Checksum*/
+   uint32_tih_time;/* Image Creation Timestamp */
+   uint32_tih_size;/* Image Data Size  */
+   uint32_tih_load;/* Data  Load  Address  */
+   uint32_tih_ep;  /* Entry Point Address  */
+   uint32_tih_dcrc;/* Image Data CRC Checksum  */
uint8_t ih_os;  /* Operating System */
uint8_t ih_arch;/* CPU architecture */
uint8_t ih_type;/* Image Type   */
-- 
2.7.4

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


[U-Boot] [PATCH v3 8/9] tools: Avoid creating symbolic links for tools/version.h

2019-10-27 Thread Bin Meng
When building U-Boot host tools for Windows from Microsoft Azure
Pipelines, the following errors were seen:

  HOSTCC  tools/mkenvimage.o
  In file included from tools/mkenvimage.c:25:
  ./tools/version.h:1:1: error: expected identifier or ‘(’ before ‘.’ token
 1 | ../include/version.h
   | ^
  tools/mkenvimage.c: In function ‘main’:
  tools/mkenvimage.c:117:4: warning: implicit declaration of function ‘usage’ 
[-Wimplicit-function-declaration]
   117 |usage(prg);
   |^
  tools/mkenvimage.c:120:35: error: ‘PLAIN_VERSION’ undeclared (first use in 
this function)
   120 |printf("%s version %s\n", prg, PLAIN_VERSION);
   |   ^
  tools/mkenvimage.c:120:35: note: each undeclared identifier is reported only 
once for each function it appears in
  make[2]: *** [scripts/Makefile.host:114: tools/mkenvimage.o] Error 1

It turns out tools/version.h is a symbolic link and with Windows
default settings it is unsupported hence the actual content of
tools/version.h is not what file include/version.h has, but the
the linked file path, which breaks the build.

To fix this, remove the symbolic links for tools/version.h. Instead
we perform a copy from include/version.h during the build.

Signed-off-by: Bin Meng 

---

Changes in v3: None
Changes in v2:
- new patch: tools: Avoid creating symbolic links for tools/version.h

 Makefile | 9 ++---
 tools/.gitignore | 1 +
 tools/version.h  | 1 -
 3 files changed, 7 insertions(+), 4 deletions(-)
 delete mode 12 tools/version.h

diff --git a/Makefile b/Makefile
index cbacf1c..e78b317 100644
--- a/Makefile
+++ b/Makefile
@@ -1837,11 +1837,14 @@ checkarmreloc: u-boot
false; \
fi
 
-envtools: scripts_basic $(version_h) $(timestamp_h)
+tools/version.h: include/version.h
+   $(call if_changed,copy)
+
+envtools: scripts_basic $(version_h) $(timestamp_h) tools/version.h
$(Q)$(MAKE) $(build)=tools/env
 
 tools-only: export TOOLS_ONLY=y
-tools-only: scripts_basic $(version_h) $(timestamp_h)
+tools-only: scripts_basic $(version_h) $(timestamp_h) tools/version.h
$(Q)$(MAKE) $(build)=tools
 
 tools-all: export HOST_TOOLS_ALL=y
@@ -1869,7 +1872,7 @@ CLEAN_DIRS  += $(MODVERDIR) \
   $(foreach d, spl tpl, $(patsubst %,$d/%, \
$(filter-out include, $(shell ls -1 $d 2>/dev/null
 
-CLEAN_FILES += include/bmp_logo.h include/bmp_logo_data.h \
+CLEAN_FILES += include/bmp_logo.h include/bmp_logo_data.h tools/version.h \
   boot* u-boot* MLO* SPL System.map fit-dtb.blob*
 
 # Directories & files removed with 'make mrproper'
diff --git a/tools/.gitignore b/tools/.gitignore
index bd03d32..d0176a7 100644
--- a/tools/.gitignore
+++ b/tools/.gitignore
@@ -31,4 +31,5 @@
 /spl_size_limit
 /sunxi-spl-image-builder
 /ubsha1
+/version.h
 /xway-swap-bytes
diff --git a/tools/version.h b/tools/version.h
deleted file mode 12
index bb57607..000
--- a/tools/version.h
+++ /dev/null
@@ -1 +0,0 @@
-../include/version.h
\ No newline at end of file
-- 
2.7.4

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


[U-Boot] [PATCH v3 3/9] tools: zynqmpbif: Use compiler builtin instead of linux-specific __swab32

2019-10-27 Thread Bin Meng
__swab32() is a Linux specific macro defined in linux/swab.h. Let's
use the compiler equivalent builtin function __builtin_bswap32() for
better portability.

Signed-off-by: Bin Meng 
---

Changes in v3: None
Changes in v2: None

 tools/zynqmpbif.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/zynqmpbif.c b/tools/zynqmpbif.c
index 8c47107..82ce0ac 100644
--- a/tools/zynqmpbif.c
+++ b/tools/zynqmpbif.c
@@ -517,7 +517,7 @@ static int bif_add_bit(struct bif_entry *bf)
debug("Bitstream Length: 0x%x\n", bitlen);
for (i = 0; i < bitlen; i += sizeof(uint32_t)) {
uint32_t *bitbin32 = (uint32_t *)&bitbin[i];
-   *bitbin32 = __swab32(*bitbin32);
+   *bitbin32 = __builtin_bswap32(*bitbin32);
}
 
if (!bf->dest_dev)
-- 
2.7.4

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


[U-Boot] [PATCH v3 9/9] Add Microsoft Azure Pipelines configuration

2019-10-27 Thread Bin Meng
Microsoft Azure Pipelines [1] provides unlimited CI/CD minutes and
10 parallel jobs to every open source project for free.

This adds a configuration file for Azure Pipelines to utilize the
free Windows VM hosted by Microsoft to ensure no build broken in
building U-Boot host tools for Windows.

[1] 
https://azure.microsoft.com/en-us/blog/announcing-azure-pipelines-with-unlimited-ci-cd-minutes-for-open-source/

Signed-off-by: Bin Meng 

---
See the build result at:
https://dev.azure.com/bmeng/GitHub/_build/results?buildId=53

Changes in v3:
- rename to .azure-pipelines.yml
- correct typo in the commit summary

Changes in v2:
- new patch: Add Microsoft Azure pipelines configuration

 .azure-pipelines.yml | 38 ++
 1 file changed, 38 insertions(+)
 create mode 100644 .azure-pipelines.yml

diff --git a/.azure-pipelines.yml b/.azure-pipelines.yml
new file mode 100644
index 000..6c6b24e
--- /dev/null
+++ b/.azure-pipelines.yml
@@ -0,0 +1,38 @@
+variables:
+  windows_vm: vs2015-win2012r2
+
+jobs:
+  - job: tools_only_windows
+displayName: 'Ensure host tools build for Windows'
+pool:
+  vmImage: $(windows_vm)
+strategy:
+  matrix:
+i686:
+  MSYS_DIR: msys32
+  BASE_REPO: msys2-ci-base-i686
+x86_64:
+  MSYS_DIR: msys64
+  BASE_REPO: msys2-ci-base
+steps:
+  - script: |
+  git clone https://github.com/msys2/$(BASE_REPO).git 
%CD:~0,2%\$(MSYS_DIR)
+displayName: 'Install MSYS2'
+  - script: |
+  set 
PATH=%CD:~0,2%\$(MSYS_DIR)\usr\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem
+  %CD:~0,2%\$(MSYS_DIR)\usr\bin\pacman --noconfirm -Syyuu
+displayName: 'Update MSYS2'
+  - script: |
+  set 
PATH=%CD:~0,2%\$(MSYS_DIR)\usr\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem
+  %CD:~0,2%\$(MSYS_DIR)\usr\bin\pacman --noconfirm --needed -S make 
gcc bison diffutils openssl-devel
+displayName: 'Install Toolchain'
+  - script: |
+  set PATH=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem
+  echo make tools-only_defconfig tools-only NO_SDL=1 > build-tools.sh
+  %CD:~0,2%\$(MSYS_DIR)\usr\bin\bash -lc "bash build-tools.sh"
+displayName: 'Build Host Tools'
+env:
+  # Tell MSYS2 we need a POSIX emulation layer
+  MSYSTEM: MSYS
+  # Tell MSYS2 not to ‘cd’ our startup directory to HOME
+  CHERE_INVOKING: yes
-- 
2.7.4

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


[U-Boot] [PATCH v3 5/9] tools: ifwitool: Define __packed when it is not defined

2019-10-27 Thread Bin Meng
Some compilers may provide __packed define for us.

Signed-off-by: Bin Meng 

---

Changes in v3:
- new patch: tools: ifwitool: Define __packed when it is not defined

Changes in v2: None

 tools/ifwitool.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/ifwitool.c b/tools/ifwitool.c
index 2e020a8..543e9d4 100644
--- a/tools/ifwitool.c
+++ b/tools/ifwitool.c
@@ -10,7 +10,9 @@
 #include 
 #include "os_support.h"
 
+#ifndef __packed
 #define __packed   __attribute__((packed))
+#endif
 #define KiB1024
 #define ALIGN(x, a)__ALIGN_MASK((x), (typeof(x))(a) - 1)
 #define __ALIGN_MASK(x, mask)  (((x) + (mask)) & ~(mask))
-- 
2.7.4

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


[U-Boot] [PATCH v3 7/9] Add .gitattributes for line endings

2019-10-27 Thread Bin Meng
When building U-Boot host tools for Windows from Microsoft Azure
Pipelines, we see tons of weird warnings and errors emitted from
every Kconfig files:

  Kconfig:6:warning: ignoring unsupported character ''
  Kconfig:6:warning: ignoring unsupported character ''
  Kconfig:8:warning: ignoring unsupported character ''
  Kconfig:9:warning: ignoring unsupported character ''
  Kconfig:10:warning: ignoring unsupported character ''
  Kconfig:10:warning: ignoring unsupported character ''
  Kconfig:13:warning: ignoring unsupported character ''
  arch/Kconfig:1:warning: ignoring unsupported character ''
  arch/Kconfig:2:warning: ignoring unsupported character ''
  arch/Kconfig:2:warning: ignoring unsupported character ''
  arch/Kconfig:4:warning: ignoring unsupported character ''
  ...

After several rounds of experiments, it turns out this is caused
by line endings. Historically, Linux and macOS used linefeed (LF)
characters while Windows used a carriage return plus a linefeed
(CRLF). When Azure Pipelines checks out the U-Boot repo, Git tries
to compensate for the difference by automatically making lines end
in CRLF in the working directory on Windows, which confuses the
Kconfig file parsing logic.

Fortunately Git provides a way for repos to tell Git not to do such
automatical line endings conversion via .gitattributes file below:

* text eol=lf

Signed-off-by: Bin Meng 

---

Changes in v3: None
Changes in v2:
- new patch: Add .gitattributes for line endings

 .gitattributes | 2 ++
 1 file changed, 2 insertions(+)
 create mode 100644 .gitattributes

diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 000..8560b79
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1,2 @@
+# Declare files that always have LF line endings on checkout
+* text eol=lf
-- 
2.7.4

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


[U-Boot] [PATCH v3 6/9] doc: Add documentation for how to build U-Boot host tools

2019-10-27 Thread Bin Meng
This adds a reST document for how to build U-Boot host tools,
including information for both Linux and Windows.

Signed-off-by: Bin Meng 

---

Changes in v3: None
Changes in v2: None

 doc/build/index.rst |  9 +
 doc/build/tools.rst | 47 +++
 doc/index.rst   | 11 +++
 3 files changed, 67 insertions(+)
 create mode 100644 doc/build/index.rst
 create mode 100644 doc/build/tools.rst

diff --git a/doc/build/index.rst b/doc/build/index.rst
new file mode 100644
index 000..e4e3411
--- /dev/null
+++ b/doc/build/index.rst
@@ -0,0 +1,9 @@
+.. SPDX-License-Identifier: GPL-2.0+
+
+Build U-Boot
+
+
+.. toctree::
+   :maxdepth: 2
+
+   tools
diff --git a/doc/build/tools.rst b/doc/build/tools.rst
new file mode 100644
index 000..c06f915
--- /dev/null
+++ b/doc/build/tools.rst
@@ -0,0 +1,47 @@
+.. SPDX-License-Identifier: GPL-2.0+
+.. sectionauthor:: Bin Meng 
+
+Host tools
+==
+
+Building tools for Linux
+
+
+To allow distributions to distribute all possible tools in a generic way,
+avoiding the need of specific tools building for each machine, a tools only
+defconfig file is provided.
+
+Using this, we can build the tools by doing::
+
+   $ make tools-only_defconfig
+   $ make tools-only
+
+Building tools for Windows
+--
+If you wish to generate Windows versions of the utilities in the tools 
directory
+you can use MSYS2, a software distro and building platform for Windows.
+
+Download the MSYS2 installer from https://www.msys2.org. Make sure you have
+installed all required packages below in order to build these host tools::
+
+   * gcc (9.1.0)
+   * make (4.2.1)
+   * bison (3.4.2)
+   * diffutils (3.7)
+   * openssl-devel (1.1.1.d)
+
+Note the version numbers in these parentheses above are the package versions
+at the time being when writing this document. The MSYS2 installer tested is
+http://repo.msys2.org/distrib/x86_64/msys2-x86_64-20190524.exe.
+
+There are 3 MSYS subsystems installed: MSYS2, MinGW32 and MinGW64. Each
+subsystem provides an environment to build Windows applications. The MSYS2
+environment is for building POSIX compliant software on Windows using an
+emulation layer. The MinGW32/64 subsystems are for building native Windows
+applications using a linux toolchain (gcc, bash, etc), targeting respectively
+32 and 64 bit Windows.
+
+Launch the MSYS2 shell of the MSYS2 environment, and do the following::
+
+   $ make tools-only_defconfig
+   $ make tools-only NO_SDL=1
diff --git a/doc/index.rst b/doc/index.rst
index 458f0d2..206a045 100644
--- a/doc/index.rst
+++ b/doc/index.rst
@@ -15,6 +15,17 @@ if you want to help out.
 .. toctree::
:maxdepth: 2
 
+User-oriented documentation
+---
+
+The following manuals are written for *users* of the U-Boot - those who are
+trying to get it to work optimally on a given system.
+
+.. toctree::
+   :maxdepth: 2
+
+   build/index
+
 Unified Extensible Firmware (UEFI)
 --
 
-- 
2.7.4

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


[U-Boot] [PATCH v3 4/9] linux/types.h: Surround 'struct ustat' with __linux__

2019-10-27 Thread Bin Meng
'struct ustat' uses linux-specific typedefs to declare its memebers:
__kernel_daddr_t and __kernel_ino_t. It is currently not used by any
U-Boot codes, but when we build U-Boot tools for other platform like
Windows, this becomes a problem.

Let's surround it with __linux__.

Signed-off-by: Bin Meng 
---

Changes in v3: None
Changes in v2: None

 include/linux/types.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/linux/types.h b/include/linux/types.h
index cc6f7cb..51cb284 100644
--- a/include/linux/types.h
+++ b/include/linux/types.h
@@ -151,12 +151,14 @@ typedef __u32 __bitwise __wsum;
 
 typedef unsigned __bitwise__   gfp_t;
 
+#ifdef __linux__
 struct ustat {
__kernel_daddr_tf_tfree;
__kernel_ino_t  f_tinode;
charf_fname[6];
charf_fpack[6];
 };
+#endif
 
 #define DECLARE_BITMAP(name, bits) \
unsigned long name[BITS_TO_LONGS(bits)]
-- 
2.7.4

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


[U-Boot] [PATCH 0/5] Bring all testings in gitlab and travis CI to Azure Pipelines

2019-10-27 Thread Bin Meng
At present we have set up a Microsoft Azure Pipelines to build
U-Boot host tools for Windows. We can expand it to cover all the
CI testing in gitlab and travis CI.

There are issues if we use the 'container' keyword in the pipeline,
that buildman seems to not able to exit correctly and hangs forever.
So we manually call docker to run the image to perform the CI tasks.
Unfortunately with above configuration, the uboot user inside the
container does not have the write permission to the U-Boot git repo,
and this exposes several issues in the U-Boot build process.

With all such issues fixed, a complete run on Azure Pipelines takes
about 2 hours and 10 minutes. It seems to be a good backup for the
free travis CI service.

This series depends on
http://patchwork.ozlabs.org/project/uboot/list/?series=138998

and is avaiable at u-boot-x86/azure for testing.


Bin Meng (5):
  tools: buildman: Honor output directory when generating boards.cfg
  tools: buildman: Remove useless mkdir() in Make() in test.py
  arm: mvebu: Avoid generating kwbimage.cfg in the source tree
  .travis.yml: Remove the unneeded '&' for ls20xx buildman
  Bring all testings in gitlab and travis CI to Azure Pipelines

 .azure-pipelines.yml | 382 +++
 .travis.yml  |   2 +-
 Makefile |  15 +-
 arch/arm/mach-mvebu/Makefile |   4 +-
 board/Marvell/db-88f6281-bp/Makefile |   4 +-
 board/Marvell/db-xc3-24g4xg/Makefile |   4 +-
 board/mikrotik/crs305-1g-4s/Makefile |   4 +-
 tools/buildman/control.py|  10 +-
 tools/buildman/test.py   |   9 +-
 9 files changed, 410 insertions(+), 24 deletions(-)

-- 
2.7.4

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


[U-Boot] [PATCH 3/5] arm: mvebu: Avoid generating kwbimage.cfg in the source tree

2019-10-27 Thread Bin Meng
At present some boards generate kwbimage.cfg in the source tree
during the build. This breaks buildman testing on some systems
where the source tree is read-only. Update makefile rules to
generate it in the build tree instead.

Note some other boards have the kwbimage.cfg file written in
advance, hence we need check if the file exists in the build
tree first, otherwise we fall back to one in the source tree.

Signed-off-by: Bin Meng 
---

 Makefile | 15 +--
 arch/arm/mach-mvebu/Makefile |  4 ++--
 board/Marvell/db-88f6281-bp/Makefile |  4 ++--
 board/Marvell/db-xc3-24g4xg/Makefile |  4 ++--
 board/mikrotik/crs305-1g-4s/Makefile |  4 ++--
 5 files changed, 21 insertions(+), 10 deletions(-)

diff --git a/Makefile b/Makefile
index e78b317..61b94c5 100644
--- a/Makefile
+++ b/Makefile
@@ -1276,10 +1276,21 @@ endif
 
 MKIMAGEFLAGS_u-boot-dtb.img = $(MKIMAGEFLAGS_u-boot.img)
 
-MKIMAGEFLAGS_u-boot.kwb = -n $(srctree)/$(CONFIG_SYS_KWD_CONFIG:"%"=%) \
+# Some boards have the kwbimage.cfg file written in advance, while some
+# other boards generate it on the fly during the build in the build tree.
+# Let's check if the file exists in the build tree first, otherwise we
+# fall back to use the one in the source tree.
+KWD_CONFIG_FILE = $(shell \
+   if [ -f $(objtree)/$(CONFIG_SYS_KWD_CONFIG:"%"=%) ]; then \
+   echo -n $(objtree)/$(CONFIG_SYS_KWD_CONFIG:"%"=%); \
+   else \
+   echo -n $(srctree)/$(CONFIG_SYS_KWD_CONFIG:"%"=%); \
+   fi)
+
+MKIMAGEFLAGS_u-boot.kwb = -n $(KWD_CONFIG_FILE) \
-T kwbimage -a $(CONFIG_SYS_TEXT_BASE) -e $(CONFIG_SYS_TEXT_BASE)
 
-MKIMAGEFLAGS_u-boot-spl.kwb = -n $(srctree)/$(CONFIG_SYS_KWD_CONFIG:"%"=%) \
+MKIMAGEFLAGS_u-boot-spl.kwb = -n $(KWD_CONFIG_FILE) \
-T kwbimage -a $(CONFIG_SYS_TEXT_BASE) -e $(CONFIG_SYS_TEXT_BASE) \
$(if $(KEYDIR),-k $(KEYDIR))
 
diff --git a/arch/arm/mach-mvebu/Makefile b/arch/arm/mach-mvebu/Makefile
index 8228a17..b739520 100644
--- a/arch/arm/mach-mvebu/Makefile
+++ b/arch/arm/mach-mvebu/Makefile
@@ -58,10 +58,10 @@ KWB_REPLACE += SEC_FUSE_DUMP
 KWB_CFG_SEC_FUSE_DUMP = a38x
 endif
 
-$(src)/kwbimage.cfg: $(src)/kwbimage.cfg.in include/autoconf.mk \
+$(obj)/kwbimage.cfg: $(src)/kwbimage.cfg.in include/autoconf.mk \
include/config/auto.conf
$(Q)sed -ne '$(foreach V,$(KWB_REPLACE),s/^#@$(V)/$(V) 
$(KWB_CFG_$(V))/;)p' \
-   <$< >$(dir $<)$(@F)
+   <$< >$(dir $@)$(@F)
 
 endif # CONFIG_SPL_BUILD
 obj-y  += gpio.o
diff --git a/board/Marvell/db-88f6281-bp/Makefile 
b/board/Marvell/db-88f6281-bp/Makefile
index e6aa7e3..003e9f6 100644
--- a/board/Marvell/db-88f6281-bp/Makefile
+++ b/board/Marvell/db-88f6281-bp/Makefile
@@ -4,9 +4,9 @@ obj-y   := db-88f6281-bp.o
 extra-y := kwbimage.cfg
 
 quiet_cmd_sed = SED $@
-  cmd_sed = sed $(SEDFLAGS_$(@F)) $< >$(dir $<)$(@F)
+  cmd_sed = sed $(SEDFLAGS_$(@F)) $< >$(dir $@)$(@F)
 
 SEDFLAGS_kwbimage.cfg = -e "s/^\#@BOOT_FROM.*/BOOT_FROM$(if 
$(CONFIG_CMD_NAND),nand,spi)/"
-$(src)/kwbimage.cfg: $(src)/kwbimage.cfg.in include/autoconf.mk \
+$(obj)/kwbimage.cfg: $(src)/kwbimage.cfg.in include/autoconf.mk \
include/config/auto.conf
$(call if_changed,sed)
diff --git a/board/Marvell/db-xc3-24g4xg/Makefile 
b/board/Marvell/db-xc3-24g4xg/Makefile
index 4dd5790..24e8200 100644
--- a/board/Marvell/db-xc3-24g4xg/Makefile
+++ b/board/Marvell/db-xc3-24g4xg/Makefile
@@ -6,9 +6,9 @@ obj-y   := db-xc3-24g4xg.o
 extra-y:= kwbimage.cfg
 
 quiet_cmd_sed = SED $@
-  cmd_sed = sed $(SEDFLAGS_$(@F)) $< >$(dir $<)$(@F)
+  cmd_sed = sed $(SEDFLAGS_$(@F)) $< >$(dir $@)$(@F)
 
 SEDFLAGS_kwbimage.cfg =-e "s|^BINARY.*|BINARY $(srctree)/$(@D)/binary.0 
005b 0068|"
-$(src)/kwbimage.cfg: $(src)/kwbimage.cfg.in include/autoconf.mk \
+$(obj)/kwbimage.cfg: $(src)/kwbimage.cfg.in include/autoconf.mk \
include/config/auto.conf
  $(call if_changed,sed)
diff --git a/board/mikrotik/crs305-1g-4s/Makefile 
b/board/mikrotik/crs305-1g-4s/Makefile
index 895331b..c03f534 100644
--- a/board/mikrotik/crs305-1g-4s/Makefile
+++ b/board/mikrotik/crs305-1g-4s/Makefile
@@ -6,9 +6,9 @@ obj-y   := crs305-1g-4s.o
 extra-y:= kwbimage.cfg
 
 quiet_cmd_sed = SED $@
-  cmd_sed = sed $(SEDFLAGS_$(@F)) $< >$(dir $<)$(@F)
+  cmd_sed = sed $(SEDFLAGS_$(@F)) $< >$(dir $@)$(@F)
 
 SEDFLAGS_kwbimage.cfg =-e "s|^BINARY.*|BINARY $(srctree)/$(@D)/binary.0 
005b 0068|"
-$(src)/kwbimage.cfg: $(src)/kwbimage.cfg.in include/autoconf.mk \
+$(obj)/kwbimage.cfg: $(src)/kwbimage.cfg.in include/autoconf.mk \
include/config/auto.conf
  $(call if_changed,sed)
-- 
2.7.4

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


[U-Boot] [PATCH 2/5] tools: buildman: Remove useless mkdir() in Make() in test.py

2019-10-27 Thread Bin Meng
In the 'Make' function, the codes tries to create a directory
if current stage is 'build'. But the directory isn't used at
all anywhere.

Signed-off-by: Bin Meng 
---

 tools/buildman/test.py | 9 +
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/tools/buildman/test.py b/tools/buildman/test.py
index de02f61..0dd8516 100644
--- a/tools/buildman/test.py
+++ b/tools/buildman/test.py
@@ -22,6 +22,7 @@ import commit
 import terminal
 import test_util
 import toolchain
+from terminal import Print
 
 use_network = True
 
@@ -156,14 +157,6 @@ class TestBuild(unittest.TestCase):
 result.return_code = commit.return_code
 result.stderr = (''.join(commit.error_list)
 % {'basedir' : base_dir + '/.bm-work/00/'})
-if stage == 'build':
-target_dir = None
-for arg in args:
-if arg.startswith('O='):
-target_dir = arg[2:]
-
-if not os.path.isdir(target_dir):
-os.mkdir(target_dir)
 
 result.combined = result.stdout + result.stderr
 return result
-- 
2.7.4

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


[U-Boot] [PATCH 1/5] tools: buildman: Honor output directory when generating boards.cfg

2019-10-27 Thread Bin Meng
buildman always generates boards.cfg in the U-Boot source tree.
When '-o' is given, we should generate boards.cfg to the given
output directory.

Signed-off-by: Bin Meng 
---

 tools/buildman/control.py | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/tools/buildman/control.py b/tools/buildman/control.py
index fcf531c..9787b86 100644
--- a/tools/buildman/control.py
+++ b/tools/buildman/control.py
@@ -201,14 +201,14 @@ def DoBuildman(options, args, toolchains=None, 
make_func=None, boards=None,
 
 # Work out what subset of the boards we are building
 if not boards:
-board_file = os.path.join(options.git, 'boards.cfg')
-status = subprocess.call([os.path.join(options.git,
-'tools/genboardscfg.py')])
+board_file = os.path.join(options.output_dir, 'boards.cfg')
+genboardscfg = os.path.join(options.git, 'tools/genboardscfg.py')
+status = subprocess.call([genboardscfg, '-o', board_file])
 if status != 0:
-sys.exit("Failed to generate boards.cfg")
+sys.exit("Failed to generate boards.cfg")
 
 boards = board.Boards()
-boards.ReadBoards(os.path.join(options.git, 'boards.cfg'))
+boards.ReadBoards(board_file)
 
 exclude = []
 if options.exclude:
-- 
2.7.4

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


[U-Boot] [PATCH 5/5] Bring all testings in gitlab and travis CI to Azure Pipelines

2019-10-27 Thread Bin Meng
This expands current Azure Pipelines Windows host tools build
testing to cover all the CI testing in gitlab and travis CI.

Note for some unknown reason, the 'container' cannot be used for
any jobs that have buildman, for buildman does not exit properly
and hangs the job forever. As a workaround, we manually call
docker to run the image to perform the CI tasks.

A complete run on Azure Pipelines takes about 2 hours and 10
minutes.

Signed-off-by: Bin Meng 

---
See the build result at:
https://dev.azure.com/bmeng/GitHub/_build/results?buildId=109

 .azure-pipelines.yml | 382 +++
 1 file changed, 382 insertions(+)

diff --git a/.azure-pipelines.yml b/.azure-pipelines.yml
index 6c6b24e..d476d8d 100644
--- a/.azure-pipelines.yml
+++ b/.azure-pipelines.yml
@@ -1,5 +1,12 @@
 variables:
   windows_vm: vs2015-win2012r2
+  ubuntu_vm: ubuntu-18.04
+  ci_runner_image: trini/u-boot-gitlab-ci-runner:bionic-20190912.1-03Oct2019
+  # Add '-u 0' options for Azure pipelines, otherwise we get "permission
+  # denied" error when it tries to "useradd -m -u 1001 vsts_azpcontainer",
+  # since our $(ci_runner_image) user is not root.
+  container_option: -u 0
+  work_dir: /u
 
 jobs:
   - job: tools_only_windows
@@ -36,3 +43,378 @@ jobs:
   MSYSTEM: MSYS
   # Tell MSYS2 not to ‘cd’ our startup directory to HOME
   CHERE_INVOKING: yes
+
+  - job: cppcheck
+displayName: 'Static code analysis with cppcheck'
+pool:
+  vmImage: $(ubuntu_vm)
+container:
+  image: $(ci_runner_image)
+  options: $(container_option)
+steps:
+  - script: cppcheck --force --quiet --inline-suppr .
+
+  - job: todo
+displayName: 'Search for TODO within source tree'
+pool:
+  vmImage: $(ubuntu_vm)
+container:
+  image: $(ci_runner_image)
+  options: $(container_option)
+steps:
+  - script: grep -r TODO .
+  - script: grep -r FIXME .
+  - script: grep -r HACK . | grep -v HACKKIT
+
+  - job: sloccount
+displayName: 'Some statistics about the code base'
+pool:
+  vmImage: $(ubuntu_vm)
+container:
+  image: $(ci_runner_image)
+  options: $(container_option)
+steps:
+  - script: sloccount .
+
+  - job: maintainers
+displayName: 'Ensure all configs have MAINTAINERS entries'
+pool:
+  vmImage: $(ubuntu_vm)
+container:
+  image: $(ci_runner_image)
+  options: $(container_option)
+steps:
+  - script: |
+  if [ `./tools/genboardscfg.py -f 2>&1 | wc -l` -ne 0 ]; then exit 1; 
fi
+
+  - job: tools_only
+displayName: 'Ensure host tools build'
+pool:
+  vmImage: $(ubuntu_vm)
+container:
+  image: $(ci_runner_image)
+  options: $(container_option)
+steps:
+  - script: |
+  make tools-only_config tools-only -j$(nproc)
+
+  - job: envtools
+displayName: 'Ensure env tools build'
+pool:
+  vmImage: $(ubuntu_vm)
+container:
+  image: $(ci_runner_image)
+  options: $(container_option)
+steps:
+  - script: |
+  make tools-only_config envtools -j$(nproc)
+
+  - job: utils
+displayName: 'Run binman, buildman, dtoc and patman testsuites'
+pool:
+  vmImage: $(ubuntu_vm)
+steps:
+  - script: |
+  cat << EOF > build.sh
+  set -ex
+  cd ${WORK_DIR}
+  EOF
+  cat << "EOF" >> build.sh
+  git config --global user.name "Azure Pipelines"
+  git config --global user.email bmeng...@gmail.com
+  export USER=azure
+  virtualenv /tmp/venv
+  . /tmp/venv/bin/activate
+  pip install pyelftools
+  export UBOOT_TRAVIS_BUILD_DIR=/tmp/.bm-work/sandbox_spl
+  export PYTHONPATH=${UBOOT_TRAVIS_BUILD_DIR}/scripts/dtc/pylibfdt
+  export PATH=${UBOOT_TRAVIS_BUILD_DIR}/scripts/dtc:${PATH}
+  ./tools/buildman/buildman -o /tmp -P sandbox_spl
+  ./tools/binman/binman --toolpath ${UBOOT_TRAVIS_BUILD_DIR}/tools test
+  ./tools/buildman/buildman -t
+  ./tools/dtoc/dtoc -t
+  ./tools/patman/patman --test
+  EOF
+  cat build.sh
+  # We cannot use "container" like other jobs above, as buildman
+  # seems to hang forever with pre-configured "container" environment
+  docker run -v $PWD:$(work_dir) $(ci_runner_image) /bin/bash 
$(work_dir)/build.sh
+
+  - job: test_py
+displayName: 'test.py'
+pool:
+  vmImage: $(ubuntu_vm)
+strategy:
+  matrix:
+sandbox:
+  TEST_PY_BD: "sandbox"
+  BUILDMAN: "^sandbox$"
+sandbox_spl:
+  TEST_PY_BD: "sandbox_spl"
+  TEST_PY_TEST_SPEC: "test_ofplatdata"
+  BUILDMAN: "^sandbox_spl$"
+sandbox_flattree:
+  TEST_PY_BD: "sandbox_flattree"
+  BUILDMAN: "^sandbox_flattree$"
+evb_ast2500:
+  TEST_PY_BD: "evb-ast2500"
+  TEST_PY_ID: "--id qemu"
+  BUILDMAN: "^evb-a

[U-Boot] [PATCH 4/5] .travis.yml: Remove the unneeded '&' for ls20xx buildman

2019-10-27 Thread Bin Meng
Signed-off-by: Bin Meng 
---

 .travis.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.travis.yml b/.travis.yml
index a3e7451..3aaed93 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -200,7 +200,7 @@ matrix:
 - BUILDMAN="freescale&aarch64&ls108"
 - name: "buildman NXP AArch64 LS20xx"
   env:
-- BUILDMAN="freescale&aarch64&&ls20"
+- BUILDMAN="freescale&aarch64&ls20"
 - name: "buildman NXP AArch64 LX216x"
   env:
 - BUILDMAN="freescale&aarch64&lx216"
-- 
2.7.4

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


Re: [U-Boot] [PATCH 2/5] tools: buildman: Remove useless mkdir() in Make() in test.py

2019-10-27 Thread Bin Meng
On Sun, Oct 27, 2019 at 8:28 PM Bin Meng  wrote:
>
> In the 'Make' function, the codes tries to create a directory
> if current stage is 'build'. But the directory isn't used at
> all anywhere.
>
> Signed-off-by: Bin Meng 
> ---
>
>  tools/buildman/test.py | 9 +
>  1 file changed, 1 insertion(+), 8 deletions(-)
>
> diff --git a/tools/buildman/test.py b/tools/buildman/test.py
> index de02f61..0dd8516 100644
> --- a/tools/buildman/test.py
> +++ b/tools/buildman/test.py
> @@ -22,6 +22,7 @@ import commit
>  import terminal
>  import test_util
>  import toolchain
> +from terminal import Print

Oops, this was added for debugging and should be removed ...

Will remove in v2.

>
>  use_network = True
>
> @@ -156,14 +157,6 @@ class TestBuild(unittest.TestCase):
>  result.return_code = commit.return_code
>  result.stderr = (''.join(commit.error_list)
>  % {'basedir' : base_dir + '/.bm-work/00/'})
> -if stage == 'build':
> -target_dir = None
> -for arg in args:
> -if arg.startswith('O='):
> -target_dir = arg[2:]
> -
> -if not os.path.isdir(target_dir):
> -os.mkdir(target_dir)
>
>  result.combined = result.stdout + result.stderr
>  return result
> --

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


Re: [U-Boot] [PATCH v6 0/3] End of the MTD makefile cleanup

2019-10-27 Thread Tom Rini
On Sun, Oct 27, 2019 at 05:23:14PM +0530, Jagan Teki wrote:
> On Sun, Oct 27, 2019 at 3:33 AM Miquel Raynal  
> wrote:
> >
> > Hi Jagan,
> >
> > Jagan Teki  wrote on Sat, 26 Oct 2019
> > 15:50:06 +0530:
> >
> > > On Fri, Oct 25, 2019 at 11:09 PM Miquel Raynal
> > >  wrote:
> > > >
> > > > As rightfully pointed by Jagan, I should have dropped the dependency
> > > > of cmd/sf.c and cmd/nand.c on mtd_uboot.c in patch 24/26 of the "MTD
> > > > defconfigs/Kconfigs/Makefiles heavy cleanup" v5 series.
> > > >
> > > > Instead of sending the 40 patches again, here are only the last three
> > > > patches with:
> > > > * patch 1 (24/26) being corrected as per Jagan's comment
> > > > * patch 2 (25/26) is untouched
> > > > * patch 3 (26/26) is almost untouched but I had to resolve a conflict
> > > >   due to patch 1.
> > > >
> > > > Thanks,
> > > > Miquèl
> > > >
> > > > Miquel Raynal (3):
> > > >   cmd: nand/sf: isolate legacy code
> > > >   cmd: make MTD commands depend on MTD
> > > >   mtd: Makefile: deep cleanup
> > >
> > > Reviewed-by: Jagan Teki 
> >
> > Thanks!
> >
> > Who is supposed to take the two series?
> 
> Looks like there are several defconfig changes in master, please
> rebase on master and send your branch (some where from github or so).

If it's just defconfigs, I'll grab it so I can have the series also be
the only thing in the tree when I do the before/after size check.
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 v6 0/3] End of the MTD makefile cleanup

2019-10-27 Thread Jagan Teki
On Sun, 27 Oct, 2019, 15:06 Tom Rini,  wrote:

> On Sun, Oct 27, 2019 at 05:23:14PM +0530, Jagan Teki wrote:
> > On Sun, Oct 27, 2019 at 3:33 AM Miquel Raynal 
> wrote:
> > >
> > > Hi Jagan,
> > >
> > > Jagan Teki  wrote on Sat, 26 Oct 2019
> > > 15:50:06 +0530:
> > >
> > > > On Fri, Oct 25, 2019 at 11:09 PM Miquel Raynal
> > > >  wrote:
> > > > >
> > > > > As rightfully pointed by Jagan, I should have dropped the
> dependency
> > > > > of cmd/sf.c and cmd/nand.c on mtd_uboot.c in patch 24/26 of the
> "MTD
> > > > > defconfigs/Kconfigs/Makefiles heavy cleanup" v5 series.
> > > > >
> > > > > Instead of sending the 40 patches again, here are only the last
> three
> > > > > patches with:
> > > > > * patch 1 (24/26) being corrected as per Jagan's comment
> > > > > * patch 2 (25/26) is untouched
> > > > > * patch 3 (26/26) is almost untouched but I had to resolve a
> conflict
> > > > >   due to patch 1.
> > > > >
> > > > > Thanks,
> > > > > Miquèl
> > > > >
> > > > > Miquel Raynal (3):
> > > > >   cmd: nand/sf: isolate legacy code
> > > > >   cmd: make MTD commands depend on MTD
> > > > >   mtd: Makefile: deep cleanup
> > > >
> > > > Reviewed-by: Jagan Teki 
> > >
> > > Thanks!
> > >
> > > Who is supposed to take the two series?
> >
> > Looks like there are several defconfig changes in master, please
> > rebase on master and send your branch (some where from github or so).
>
> If it's just defconfigs, I'll grab it so I can have the series also be
> the only thing in the tree when I do the before/after size check.
> Thanks!
>

Thanks Tom.

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


Re: [U-Boot] [PATCH v6 0/3] End of the MTD makefile cleanup

2019-10-27 Thread Miquel Raynal
Hello,

Jagan Teki  wrote on Sun, 27 Oct 2019
15:24:40 +0100:

> On Sun, 27 Oct, 2019, 15:06 Tom Rini,  wrote:
> 
> > On Sun, Oct 27, 2019 at 05:23:14PM +0530, Jagan Teki wrote:  
> > > On Sun, Oct 27, 2019 at 3:33 AM Miquel Raynal  
> > >  
> > wrote:  
> > > >
> > > > Hi Jagan,
> > > >
> > > > Jagan Teki  wrote on Sat, 26 Oct 2019
> > > > 15:50:06 +0530:
> > > >  
> > > > > On Fri, Oct 25, 2019 at 11:09 PM Miquel Raynal
> > > > >  wrote:  
> > > > > >
> > > > > > As rightfully pointed by Jagan, I should have dropped the  
> > dependency  
> > > > > > of cmd/sf.c and cmd/nand.c on mtd_uboot.c in patch 24/26 of the  
> > "MTD  
> > > > > > defconfigs/Kconfigs/Makefiles heavy cleanup" v5 series.
> > > > > >
> > > > > > Instead of sending the 40 patches again, here are only the last  
> > three  
> > > > > > patches with:
> > > > > > * patch 1 (24/26) being corrected as per Jagan's comment
> > > > > > * patch 2 (25/26) is untouched
> > > > > > * patch 3 (26/26) is almost untouched but I had to resolve a  
> > conflict  
> > > > > >   due to patch 1.
> > > > > >
> > > > > > Thanks,
> > > > > > Miquèl
> > > > > >
> > > > > > Miquel Raynal (3):
> > > > > >   cmd: nand/sf: isolate legacy code
> > > > > >   cmd: make MTD commands depend on MTD
> > > > > >   mtd: Makefile: deep cleanup  
> > > > >
> > > > > Reviewed-by: Jagan Teki   
> > > >
> > > > Thanks!
> > > >
> > > > Who is supposed to take the two series?  
> > >
> > > Looks like there are several defconfig changes in master, please
> > > rebase on master and send your branch (some where from github or so).  
> >
> > If it's just defconfigs, I'll grab it so I can have the series also be
> > the only thing in the tree when I do the before/after size check.
> > Thanks!
> >  
> 
> Thanks Tom.
> 
> >  

Great! Thanks Tom.

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


[U-Boot] [PATCH] stm32mp1: configs: fix checking the presence of an environment

2019-10-27 Thread Bartosz Bilas
Execute env check command within extra env settings section instead of
bootcmd whereby we are able to mount rootfs partition from sd card properly.

Signed-off-by: Bartosz Bilas 
---
 include/configs/stm32mp1.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/configs/stm32mp1.h b/include/configs/stm32mp1.h
index 988992b336..cadc0358fd 100644
--- a/include/configs/stm32mp1.h
+++ b/include/configs/stm32mp1.h
@@ -115,7 +115,6 @@
"if test ${boot_device} = serial || test ${boot_device} = usb;" \
"then stm32prog ${boot_device} ${boot_instance}; " \
"else " \
-   "run env_check;" \
"if test ${boot_device} = mmc;" \
"then env set boot_targets \"mmc${boot_instance}\"; fi;" \
"if test ${boot_device} = nand;" \
@@ -160,6 +159,7 @@
"initrd_high=0x\0" \
"altbootcmd=run bootcmd\0" \
"env_default=1\0" \
+   "run env_check;" \
"env_check=if test $env_default -eq 1;"\
" then env set env_default 0;env save;fi\0" \
STM32MP_BOOTCMD \
-- 
2.23.0

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


[U-Boot] [PATCH 1/4] fdt: Add INT32_MAX to kernel.h for libfdt

2019-10-27 Thread Simon Glass
Unfortunately libfdt needs this value now, which is present in the
stdint.h header. That file is just a placeholder in U-Boot and these sorts
of constants appear in the linux/kernel.h header instead.

To keep libfdt happy, add INT32_MAX too.

Signed-off-by: Simon Glass 
---

 include/linux/kernel.h | 2 ++
 include/linux/libfdt_env.h | 1 +
 2 files changed, 3 insertions(+)

diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index a85c15d8dc..5c7e5f635b 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -37,6 +37,8 @@
 #define UINT32_MAX U32_MAX
 #define UINT64_MAX U64_MAX
 
+#define INT32_MAX  S32_MAX
+
 #define STACK_MAGIC0xdeadbeef
 
 #define REPEAT_BYTE(x) ((~0ul / 0xff) * (x))
diff --git a/include/linux/libfdt_env.h b/include/linux/libfdt_env.h
index e2bf79c7ee..cca7792acd 100644
--- a/include/linux/libfdt_env.h
+++ b/include/linux/libfdt_env.h
@@ -10,6 +10,7 @@
 #define LIBFDT_ENV_H
 
 #include 
+#include 
 
 #include 
 
-- 
2.24.0.rc0.303.g954a862665-goog

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


[U-Boot] [PATCH 2/4] fdt: Add Kconfig options to control code size

2019-10-27 Thread Simon Glass
For better or worse libfdt recent grew a lot of code that checks the
validity of the device tree in great detail. When using unsigned or
unverified data this makes things safer, but it does add to code size.

Add some controls to select the trade-off between safety and code size.

Signed-off-by: Simon Glass 
---

 lib/Kconfig | 33 +
 lib/libfdt/Makefile |  3 ++-
 2 files changed, 35 insertions(+), 1 deletion(-)

diff --git a/lib/Kconfig b/lib/Kconfig
index 135f0b372b..b8a8509d72 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -464,6 +464,17 @@ config OF_LIBFDT
  particular compatible nodes. The library operates on a flattened
  version of the device tree.
 
+config OF_LIBFDT_ASSUME_MASK
+   hex "Mask of conditions to assume for libfdt"
+   depends on OF_LIBFDT || FIT
+   default 0
+   help
+ Use this to change the assumptions made by libfdt about the
+ device tree it is working with. A value of 0 means that no assumptions
+ are made, and libfdt is able to deal with malicious data. A value of
+ 0xff means all assumptions are made and any invalid data may cause
+ unsafe execution. See FDT_ASSUME_PERFECT, etc. in libfdt_internal.h
+
 config OF_LIBFDT_OVERLAY
bool "Enable the FDT library overlay support"
depends on OF_LIBFDT
@@ -481,6 +492,17 @@ config SPL_OF_LIBFDT
  particular compatible nodes. The library operates on a flattened
  version of the device tree.
 
+config SPL_OF_LIBFDT_ASSUME_MASK
+   hex "Mask of conditions to assume for libfdt"
+   depends on SPL_OF_LIBFDT || FIT
+   default 0xff
+   help
+ Use this to change the assumptions made by libfdt in SPL about the
+ device tree it is working with. A value of 0 means that no assumptions
+ are made, and libfdt is able to deal with malicious data. A value of
+ 0xff means all assumptions are made and any invalid data may cause
+ unsafe execution. See FDT_ASSUME_PERFECT, etc. in libfdt_internal.h
+
 config TPL_OF_LIBFDT
bool "Enable the FDT library for TPL"
default y if TPL_OF_CONTROL
@@ -491,6 +513,17 @@ config TPL_OF_LIBFDT
  particular compatible nodes. The library operates on a flattened
  version of the device tree.
 
+config TPL_OF_LIBFDT_ASSUME_MASK
+   hex "Mask of conditions to assume for libfdt"
+   depends on TPL_OF_LIBFDT || FIT
+   default 0xff
+   help
+ Use this to change the assumptions made by libfdt in TPL about the
+ device tree it is working with. A value of 0 means that no assumptions
+ are made, and libfdt is able to deal with malicious data. A value of
+ 0xff means all assumptions are made and any invalid data may cause
+ unsafe execution. See FDT_ASSUME_PERFECT, etc. in libfdt_internal.h
+
 config FDT_FIXUP_PARTITIONS
bool "overwrite MTD partitions in DTS through defined in 'mtdparts'"
depends on OF_LIBFDT
diff --git a/lib/libfdt/Makefile b/lib/libfdt/Makefile
index ef5b6e29d4..5d3ae4e2f1 100644
--- a/lib/libfdt/Makefile
+++ b/lib/libfdt/Makefile
@@ -22,4 +22,5 @@ obj-y += fdt_ro.o
 # U-Boot own file
 obj-y += fdt_region.o
 
-ccflags-y := -I$(srctree)/scripts/dtc/libfdt
+ccflags-y := -I$(srctree)/scripts/dtc/libfdt \
+   -DFDT_ASSUME_MASK=$(CONFIG_$(SPL_TPL_)OF_LIBFDT_ASSUME_MASK)
-- 
2.24.0.rc0.303.g954a862665-goog

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


[U-Boot] [PATCH 0/4] fdt: Switch to the latest libfdt, sort-of

2019-10-27 Thread Simon Glass
This series brings over the latest libfdt with some changes to deal with
the recent code-size bloat.

With this change U-Boot size increases about 2.5KB on 'rock' and SPL
reduces by about 128 bytes. This should be acceptable.

The 'assumptions' series is still under review, so we can sync that up
later when complete.


Simon Glass (4):
  fdt: Add INT32_MAX to kernel.h for libfdt
  fdt: Add Kconfig options to control code size
  mx6: tbs2910: Minimise libfdt code size
  fdt: Sync up to the latest libfdt

 configs/tbs2910_defconfig|   1 +
 include/linux/kernel.h   |   2 +
 include/linux/libfdt_env.h   |   1 +
 lib/Kconfig  |  33 +++
 lib/libfdt/Makefile  |   3 +-
 lib/libfdt/fdt_ro.c  | 420 ---
 scripts/dtc/libfdt/Makefile.libfdt   |   7 +
 scripts/dtc/libfdt/fdt.c | 182 
 scripts/dtc/libfdt/fdt.h |  47 +--
 scripts/dtc/libfdt/fdt_addresses.c   |  94 +++---
 scripts/dtc/libfdt/fdt_empty_tree.c  |  47 +--
 scripts/dtc/libfdt/fdt_overlay.c |  91 ++
 scripts/dtc/libfdt/fdt_ro.c  | 341 +++---
 scripts/dtc/libfdt/fdt_rw.c  | 119 
 scripts/dtc/libfdt/fdt_strerror.c|  47 +--
 scripts/dtc/libfdt/fdt_sw.c  | 241 ++-
 scripts/dtc/libfdt/fdt_wip.c |  47 +--
 scripts/dtc/libfdt/libfdt.h  | 268 +
 scripts/dtc/libfdt/libfdt_env.h  |  48 +--
 scripts/dtc/libfdt/libfdt_internal.h | 144 +
 tools/libfdt/fdt_rw.c|   3 +-
 21 files changed, 1314 insertions(+), 872 deletions(-)

-- 
2.24.0.rc0.303.g954a862665-goog

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


[U-Boot] [PATCH 3/4] mx6: tbs2910: Minimise libfdt code size

2019-10-27 Thread Simon Glass
This board appears to be very near its size limit and cannot accept the
new checking code in libfdt. Disable this code so this the board can
continue to build.

Signed-off-by: Simon Glass 
---

 configs/tbs2910_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configs/tbs2910_defconfig b/configs/tbs2910_defconfig
index 42e6f58eee..6d4d4c8f9f 100644
--- a/configs/tbs2910_defconfig
+++ b/configs/tbs2910_defconfig
@@ -78,4 +78,5 @@ CONFIG_USB_GADGET_DOWNLOAD=y
 CONFIG_I2C_EDID=y
 CONFIG_VIDEO_IPUV3=y
 CONFIG_VIDEO=y
+CONFIG_OF_LIBFDT_ASSUME_MASK=0xff
 # CONFIG_EFI_LOADER is not set
-- 
2.24.0.rc0.303.g954a862665-goog

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


[U-Boot] [PATCH 4/4] fdt: Sync up to the latest libfdt

2019-10-27 Thread Simon Glass
Bring over the fdt from this commit:

430419c (origin/master) tests: fix some python warnings

adding in the 'assumptions' series designed to reduce code size.

Signed-off-by: Simon Glass 
---

 lib/libfdt/fdt_ro.c  | 420 ---
 scripts/dtc/libfdt/Makefile.libfdt   |   7 +
 scripts/dtc/libfdt/fdt.c | 182 
 scripts/dtc/libfdt/fdt.h |  47 +--
 scripts/dtc/libfdt/fdt_addresses.c   |  94 +++---
 scripts/dtc/libfdt/fdt_empty_tree.c  |  47 +--
 scripts/dtc/libfdt/fdt_overlay.c |  91 ++
 scripts/dtc/libfdt/fdt_ro.c  | 341 +++---
 scripts/dtc/libfdt/fdt_rw.c  | 119 
 scripts/dtc/libfdt/fdt_strerror.c|  47 +--
 scripts/dtc/libfdt/fdt_sw.c  | 241 ++-
 scripts/dtc/libfdt/fdt_wip.c |  47 +--
 scripts/dtc/libfdt/libfdt.h  | 268 +
 scripts/dtc/libfdt/libfdt_env.h  |  48 +--
 scripts/dtc/libfdt/libfdt_internal.h | 144 +
 tools/libfdt/fdt_rw.c|   3 +-
 16 files changed, 1275 insertions(+), 871 deletions(-)

diff --git a/lib/libfdt/fdt_ro.c b/lib/libfdt/fdt_ro.c
index 693de9aa5a..560041b603 100644
--- a/lib/libfdt/fdt_ro.c
+++ b/lib/libfdt/fdt_ro.c
@@ -14,12 +14,13 @@
 
 #include "libfdt_internal.h"
 
-static int _fdt_nodename_eq(const void *fdt, int offset,
+static int fdt_nodename_eq_(const void *fdt, int offset,
const char *s, int len)
 {
-   const char *p = fdt_offset_ptr(fdt, offset + FDT_TAGSIZE, len+1);
+   int olen;
+   const char *p = fdt_get_name(fdt, offset, &olen);
 
-   if (!p)
+   if (!p || (fdt_chk_extra() && olen < len))
/* short match */
return 0;
 
@@ -34,46 +35,85 @@ static int _fdt_nodename_eq(const void *fdt, int offset,
return 0;
 }
 
-const char *fdt_string(const void *fdt, int stroffset)
-{
-   return (const char *)fdt + fdt_off_dt_strings(fdt) + stroffset;
-}
-
-static int _fdt_string_eq(const void *fdt, int stroffset,
- const char *s, int len)
+const char *fdt_get_string(const void *fdt, int stroffset, int *lenp)
 {
-   const char *p = fdt_string(fdt, stroffset);
+   int32_t totalsize;
+   uint32_t absoffset;
+   size_t len;
+   int err;
+   const char *s, *n;
 
-   return (strnlen(p, len + 1) == len) && (memcmp(p, s, len) == 0);
-}
+   if (!fdt_chk_extra()) {
+   s = (const char *)fdt + fdt_off_dt_strings(fdt) + stroffset;
 
-uint32_t fdt_get_max_phandle(const void *fdt)
-{
-   uint32_t max_phandle = 0;
-   int offset;
+   if (lenp)
+   *lenp = strlen(s);
+   return s;
+   }
+   totalsize = fdt_ro_probe_(fdt);
+   err = totalsize;
+   if (totalsize < 0)
+   goto fail;
+
+   err = -FDT_ERR_BADOFFSET;
+   absoffset = stroffset + fdt_off_dt_strings(fdt);
+   if (absoffset >= totalsize)
+   goto fail;
+   len = totalsize - absoffset;
+
+   if (fdt_magic(fdt) == FDT_MAGIC) {
+   if (stroffset < 0)
+   goto fail;
+   if (!fdt_chk_version() || fdt_version(fdt) >= 17) {
+   if (stroffset >= fdt_size_dt_strings(fdt))
+   goto fail;
+   if ((fdt_size_dt_strings(fdt) - stroffset) < len)
+   len = fdt_size_dt_strings(fdt) - stroffset;
+   }
+   } else if (fdt_magic(fdt) == FDT_SW_MAGIC) {
+   if ((stroffset >= 0)
+   || (stroffset < -fdt_size_dt_strings(fdt)))
+   goto fail;
+   if ((-stroffset) < len)
+   len = -stroffset;
+   } else {
+   err = -FDT_ERR_INTERNAL;
+   goto fail;
+   }
 
-   for (offset = fdt_next_node(fdt, -1, NULL);;
-offset = fdt_next_node(fdt, offset, NULL)) {
-   uint32_t phandle;
+   s = (const char *)fdt + absoffset;
+   n = memchr(s, '\0', len);
+   if (!n) {
+   /* missing terminating NULL */
+   err = -FDT_ERR_TRUNCATED;
+   goto fail;
+   }
 
-   if (offset == -FDT_ERR_NOTFOUND)
-   return max_phandle;
+   if (lenp)
+   *lenp = n - s;
+   return s;
 
-   if (offset < 0)
-   return (uint32_t)-1;
+fail:
+   if (lenp)
+   *lenp = err;
+   return NULL;
+}
 
-   phandle = fdt_get_phandle(fdt, offset);
-   if (phandle == (uint32_t)-1)
-   continue;
+const char *fdt_string(const void *fdt, int stroffset)
+{
+   return fdt_get_string(fdt, stroffset, NULL);
+}
 
-   if (phandle > max_phandle)
-   max_phandle = phandle;
-   }
+static int fdt_string_eq_(const void *fdt, int stroffset,
+   

[U-Boot] [PATCH 01/30] lib: Allow crc32 to be disabled.

2019-10-27 Thread Simon Glass
Unfortunately this table seems to appear in TPL with gcc 7.3 even if it
is not used. Fix it by creating a Kconfig that can be used to disable this
routine.

It is enabled by default, since most boards use it.

Signed-off-by: Simon Glass 
---

 lib/Kconfig  | 29 +
 lib/Makefile |  2 +-
 2 files changed, 30 insertions(+), 1 deletion(-)

diff --git a/lib/Kconfig b/lib/Kconfig
index 135f0b372b..be5f9d343a 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -353,6 +353,35 @@ config SHA_PROG_HW_ACCEL
 config MD5
bool
 
+config CRC32
+   bool "Enable crc32 routine"
+   default y
+   help
+ This enables a 32-bit CRC (cyclic-redundancy check) routine. It is
+ typically used to check for changes in a group of bytes. Even a
+ small change typically produces a very different CRC value. This
+ algorithm is simple and quite fast.
+
+config SPL_CRC32
+   bool "Enable crc32 routine in SPL"
+   depends on SPL
+   default y
+   help
+ This enables a 32-bit CRC (cyclic-redundancy check) routine in SPL. It
+ is typically used to check for changes in a group of bytes. Even a
+ small change typically produces a very different CRC value. This
+ algorithm is simple and quite fast.
+
+config TPL_CRC32
+   bool "Enable crc32 routine in SPL"
+   depends on TPL
+   default y
+   help
+ This enables a 32-bit CRC (cyclic-redundancy check) routine in SPL. It
+ is typically used to check for changes in a group of bytes. Even a
+ small change typically produces a very different CRC value. This
+ algorithm is simple and quite fast.
+
 config CRC32C
bool
 
diff --git a/lib/Makefile b/lib/Makefile
index d248d8626c..8adc08fd73 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -84,7 +84,7 @@ obj-y += errno.o
 obj-y += display_options.o
 CFLAGS_display_options.o := $(if $(BUILD_TAG),-DBUILD_TAG='"$(BUILD_TAG)"')
 obj-$(CONFIG_BCH) += bch.o
-obj-y += crc32.o
+obj-$(CONFIG_$(SPL_TPL_)CRC32) += crc32.o
 obj-$(CONFIG_CRC32C) += crc32c.o
 obj-y += ctype.o
 obj-y += div64.o
-- 
2.24.0.rc0.303.g954a862665-goog

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


[U-Boot] [PATCH 02/30] spi: Allow separate control of SPI_FLASH_TINY for SPL/TPL

2019-10-27 Thread Simon Glass
In some cases SPL needs to be able to erase but TPL just needs to read.
Allow these to have separate settings for SPI_FLASH_TINY.

Signed-off-by: Simon Glass 
---

 common/spl/Kconfig   | 10 ++
 drivers/mtd/spi/Makefile |  2 +-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/common/spl/Kconfig b/common/spl/Kconfig
index 86d7edfee1..604bb69d69 100644
--- a/common/spl/Kconfig
+++ b/common/spl/Kconfig
@@ -1423,6 +1423,16 @@ config TPL_SPI_FLASH_SUPPORT
  Enable support for using SPI flash in TPL. See SPL_SPI_FLASH_SUPPORT
  for details.
 
+config TPL_SPI_FLASH_TINY
+   bool "Enable low footprint TPL SPI Flash support"
+   depends on TPL_SPI_FLASH_SUPPORT && !SPI_FLASH_BAR
+   default y if SPI_FLASH
+   help
+Enable lightweight TPL SPI Flash support that supports just reading
+data/images from flash. No support to write/erase flash. Enable
+this if you have TPL size limitations and don't need full-fledged
+SPI flash support.
+
 config TPL_SPI_LOAD
bool "Support loading from SPI flash"
depends on TPL_SPI_FLASH_SUPPORT
diff --git a/drivers/mtd/spi/Makefile b/drivers/mtd/spi/Makefile
index 20db1015d9..df04297671 100644
--- a/drivers/mtd/spi/Makefile
+++ b/drivers/mtd/spi/Makefile
@@ -8,7 +8,7 @@ spi-nor-y := sf_probe.o spi-nor-ids.o
 
 ifdef CONFIG_SPL_BUILD
 obj-$(CONFIG_SPL_SPI_BOOT) += fsl_espi_spl.o
-ifeq ($(CONFIG_SPL_SPI_FLASH_TINY),y)
+ifeq ($(CONFIG_$(SPL_TPL_)SPI_FLASH_TINY),y)
 spi-nor-y += spi-nor-tiny.o
 else
 spi-nor-y += spi-nor-core.o
-- 
2.24.0.rc0.303.g954a862665-goog

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


[U-Boot] [PATCH 03/30] mtd: spi-nor: Tidy up error handling / debug code

2019-10-27 Thread Simon Glass
The -ENODEV error value in spi_nor_read_id() is incorrect since there
clearly is a device - it just cannot be supported. Use -ENOMEDIUM instead
which has the virtue of being less common.

Fix the return value in spi_nor_scan().

Also there are a few printf() statements which should be debug() since
they bloat the code with unused strings at present. Fix those while here.

Signed-off-by: Simon Glass 
---

 drivers/mtd/spi/sf_probe.c | 2 +-
 drivers/mtd/spi/spi-nor-core.c | 2 +-
 drivers/mtd/spi/spi-nor-tiny.c | 4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/mtd/spi/sf_probe.c b/drivers/mtd/spi/sf_probe.c
index 73297e1a0a..277241d6f6 100644
--- a/drivers/mtd/spi/sf_probe.c
+++ b/drivers/mtd/spi/sf_probe.c
@@ -119,7 +119,7 @@ static int spi_flash_std_erase(struct udevice *dev, u32 
offset, size_t len)
struct erase_info instr;
 
if (offset % mtd->erasesize || len % mtd->erasesize) {
-   printf("SF: Erase offset/length not multiple of erase size\n");
+   debug("SF: Erase offset/length not multiple of erase size\n");
return -EINVAL;
}
 
diff --git a/drivers/mtd/spi/spi-nor-core.c b/drivers/mtd/spi/spi-nor-core.c
index 990e39d7c2..98405d421d 100644
--- a/drivers/mtd/spi/spi-nor-core.c
+++ b/drivers/mtd/spi/spi-nor-core.c
@@ -2399,7 +2399,7 @@ static int spi_nor_init(struct spi_nor *nor)
 * designer) that this is bad.
 */
if (nor->flags & SNOR_F_BROKEN_RESET)
-   printf("enabling reset hack; may not recover from 
unexpected reboots\n");
+   debug("enabling reset hack; may not recover from 
unexpected reboots\n");
set_4byte(nor, nor->info, 1);
}
 
diff --git a/drivers/mtd/spi/spi-nor-tiny.c b/drivers/mtd/spi/spi-nor-tiny.c
index c19d468d62..d8fcd6db24 100644
--- a/drivers/mtd/spi/spi-nor-tiny.c
+++ b/drivers/mtd/spi/spi-nor-tiny.c
@@ -375,7 +375,7 @@ static const struct flash_info *spi_nor_read_id(struct 
spi_nor *nor)
}
dev_dbg(nor->dev, "unrecognized JEDEC id bytes: %02x, %02x, %02x\n",
id[0], id[1], id[2]);
-   return ERR_PTR(-ENODEV);
+   return ERR_PTR(-EMEDIUMTYPE);
 }
 
 static int spi_nor_read(struct mtd_info *mtd, loff_t from, size_t len,
@@ -731,7 +731,7 @@ int spi_nor_scan(struct spi_nor *nor)
 
info = spi_nor_read_id(nor);
if (IS_ERR_OR_NULL(info))
-   return -ENOENT;
+   return PTR_ERR(info);
/* Parse the Serial Flash Discoverable Parameters table. */
ret = spi_nor_init_params(nor, info, ¶ms);
if (ret)
-- 
2.24.0.rc0.303.g954a862665-goog

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


[U-Boot] [PATCH 07/30] mtd: spi-mem: Drop dm.h header file

2019-10-27 Thread Simon Glass
This header file should not be included in other header files. Remove it
and use a forward declaration instead.

Signed-off-by: Simon Glass 
---

 drivers/spi/spi-mem-nodm.c | 1 +
 drivers/spi/spi-mem.c  | 5 +
 drivers/spi/stm32_qspi.c   | 2 ++
 include/spi-mem.h  | 5 +
 4 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/spi/spi-mem-nodm.c b/drivers/spi/spi-mem-nodm.c
index 4447d44991..83dde4806e 100644
--- a/drivers/spi/spi-mem-nodm.c
+++ b/drivers/spi/spi-mem-nodm.c
@@ -3,6 +3,7 @@
  * Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com/
  */
 
+#include 
 #include 
 #include 
 
diff --git a/drivers/spi/spi-mem.c b/drivers/spi/spi-mem.c
index 7788ab9953..e5a8109058 100644
--- a/drivers/spi/spi-mem.c
+++ b/drivers/spi/spi-mem.c
@@ -11,6 +11,11 @@
 #include 
 #include "internals.h"
 #else
+#include 
+#include 
+#include 
+#include 
+#include 
 #include 
 #include 
 #endif
diff --git a/drivers/spi/stm32_qspi.c b/drivers/spi/stm32_qspi.c
index 958c394a1a..c8c81396c5 100644
--- a/drivers/spi/stm32_qspi.c
+++ b/drivers/spi/stm32_qspi.c
@@ -9,7 +9,9 @@
 
 #include 
 #include 
+#include 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/include/spi-mem.h b/include/spi-mem.h
index 36814efa86..2f3f0156d0 100644
--- a/include/spi-mem.h
+++ b/include/spi-mem.h
@@ -11,10 +11,7 @@
 #ifndef __UBOOT_SPI_MEM_H
 #define __UBOOT_SPI_MEM_H
 
-#include 
-#include 
-#include 
-#include 
+struct udevice;
 
 #define SPI_MEM_OP_CMD(__opcode, __buswidth)   \
{   \
-- 
2.24.0.rc0.303.g954a862665-goog

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


[U-Boot] [PATCH 08/30] mtd: spi: Drop SPI_XFER_MMAP*

2019-10-27 Thread Simon Glass
These two defines are no-longer supported. Drop them.

Signed-off-by: Simon Glass 
---

 include/spi.h | 2 --
 1 file changed, 2 deletions(-)

diff --git a/include/spi.h b/include/spi.h
index 5eec0c4775..f5001a2cb2 100644
--- a/include/spi.h
+++ b/include/spi.h
@@ -113,8 +113,6 @@ struct spi_slave {
 #define SPI_XFER_BEGIN BIT(0)  /* Assert CS before transfer */
 #define SPI_XFER_END   BIT(1)  /* Deassert CS after transfer */
 #define SPI_XFER_ONCE  (SPI_XFER_BEGIN | SPI_XFER_END)
-#define SPI_XFER_MMAP  BIT(2)  /* Memory Mapped start */
-#define SPI_XFER_MMAP_END  BIT(3)  /* Memory Mapped End */
 };
 
 /**
-- 
2.24.0.rc0.303.g954a862665-goog

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


[U-Boot] [PATCH 24/30] mediatek: Drop dm.h header file

2019-10-27 Thread Simon Glass
This header file should not be included in other header files. Remove it
and use a forward declaration instead.

Signed-off-by: Simon Glass 
---

 arch/arm/include/asm/arch-mediatek/reset.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/include/asm/arch-mediatek/reset.h 
b/arch/arm/include/asm/arch-mediatek/reset.h
index 9704666d24..4ba0bad94e 100644
--- a/arch/arm/include/asm/arch-mediatek/reset.h
+++ b/arch/arm/include/asm/arch-mediatek/reset.h
@@ -6,7 +6,7 @@
 #ifndef __MEDIATEK_RESET_H
 #define __MEDIATEK_RESET_H
 
-#include 
+struct udevice;
 
 int mediatek_reset_bind(struct udevice *pdev, u32 regofs, u32 num_regs);
 
-- 
2.24.0.rc0.303.g954a862665-goog

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


[U-Boot] [PATCH 13/30] sf: Drop dm.h header file from spi_flash.h

2019-10-27 Thread Simon Glass
This header file should not be included in other header files. Remove it
and use a forward declaration instead.

Signed-off-by: Simon Glass 
---

 arch/x86/cpu/ivybridge/sdram.c | 1 +
 include/spi_flash.h| 3 ++-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/x86/cpu/ivybridge/sdram.c b/arch/x86/cpu/ivybridge/sdram.c
index 8a58d0383d..d2d51ebca1 100644
--- a/arch/x86/cpu/ivybridge/sdram.c
+++ b/arch/x86/cpu/ivybridge/sdram.c
@@ -10,6 +10,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/include/spi_flash.h b/include/spi_flash.h
index 0b23f57a71..0d302a7938 100644
--- a/include/spi_flash.h
+++ b/include/spi_flash.h
@@ -9,10 +9,11 @@
 #ifndef _SPI_FLASH_H_
 #define _SPI_FLASH_H_
 
-#include /* Because we dereference struct udevice here */
 #include 
 #include 
 
+struct udevice;
+
 /* by default ENV use the same parameters than SF command */
 #ifndef CONFIG_ENV_SPI_BUS
 # define CONFIG_ENV_SPI_BUSCONFIG_SF_DEFAULT_BUS
-- 
2.24.0.rc0.303.g954a862665-goog

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


[U-Boot] [PATCH 18/30] mmc: Drop duplicate dm.h inclusion

2019-10-27 Thread Simon Glass
We only need to include this header once. Drop the duplicate.

Signed-off-by: Simon Glass 
---

 drivers/mmc/sdhci.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/mmc/sdhci.c b/drivers/mmc/sdhci.c
index fbc576fd72..c081bfde5f 100644
--- a/drivers/mmc/sdhci.c
+++ b/drivers/mmc/sdhci.c
@@ -13,7 +13,6 @@
 #include 
 #include 
 #include 
-#include 
 
 #if defined(CONFIG_FIXED_SDHCI_ALIGNED_BUFFER)
 void *aligned_buffer = (void *)CONFIG_FIXED_SDHCI_ALIGNED_BUFFER;
-- 
2.24.0.rc0.303.g954a862665-goog

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


[U-Boot] [PATCH 05/30] wdt: Move code out of the header

2019-10-27 Thread Simon Glass
We should not have C code in a header file. Move it into a shared C file
so it can be used by U-Boot and SPL.

Signed-off-by: Simon Glass 
---

 common/init/Makefile |  1 +
 common/init/wdt.c| 46 
 include/init.h   |  7 +++
 include/wdt.h| 38 
 4 files changed, 54 insertions(+), 38 deletions(-)
 create mode 100644 common/init/wdt.c

diff --git a/common/init/Makefile b/common/init/Makefile
index 853b56d1e5..a76dedf350 100644
--- a/common/init/Makefile
+++ b/common/init/Makefile
@@ -6,3 +6,4 @@
 
 obj-y += board_init.o
 obj-$(CONFIG_$(SPL_TPL_)HANDOFF) += handoff.o
+obj-$(CONFIG_$(SPL_TPL_)WDT) += wdt.o
diff --git a/common/init/wdt.c b/common/init/wdt.c
new file mode 100644
index 00..79146fb293
--- /dev/null
+++ b/common/init/wdt.c
@@ -0,0 +1,46 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2017 Google, Inc
+ */
+
+#include 
+#include 
+#include 
+
+DECLARE_GLOBAL_DATA_PTR;
+
+#ifndef CONFIG_WATCHDOG_TIMEOUT_MSECS
+#define CONFIG_WATCHDOG_TIMEOUT_MSECS  (60 * 1000)
+#endif
+#define WATCHDOG_TIMEOUT_SECS  (CONFIG_WATCHDOG_TIMEOUT_MSECS / 1000)
+
+int initr_watchdog(void)
+{
+   u32 timeout = WATCHDOG_TIMEOUT_SECS;
+
+   /*
+* Init watchdog: This will call the probe function of the
+* watchdog driver, enabling the use of the device
+*/
+   if (uclass_get_device_by_seq(UCLASS_WDT, 0,
+(struct udevice **)&gd->watchdog_dev)) {
+   debug("WDT:   Not found by seq!\n");
+   if (uclass_get_device(UCLASS_WDT, 0,
+ (struct udevice **)&gd->watchdog_dev)) {
+   printf("WDT:   Not found!\n");
+   return 0;
+   }
+   }
+
+   if (CONFIG_IS_ENABLED(OF_CONTROL)) {
+   timeout = dev_read_u32_default(gd->watchdog_dev, "timeout-sec",
+  WATCHDOG_TIMEOUT_SECS);
+   }
+
+   wdt_start(gd->watchdog_dev, timeout * 1000, 0);
+   gd->flags |= GD_FLG_WDT_READY;
+   printf("WDT:   Started with%s servicing (%ds timeout)\n",
+  IS_ENABLED(CONFIG_WATCHDOG) ? "" : "out", timeout);
+
+   return 0;
+}
diff --git a/include/init.h b/include/init.h
index afc953d51e..3e5857f07f 100644
--- a/include/init.h
+++ b/include/init.h
@@ -181,6 +181,13 @@ int init_func_vid(void);
 int checkboard(void);
 int show_board_info(void);
 
+/**
+ * initr_watchdog() - Init the watchdog
+ *
+ * @return 0 if OK, -ve on error
+ */
+int initr_watchdog(void);
+
 #endif /* __ASSEMBLY__ */
 /* Put only stuff here that the assembler can digest */
 
diff --git a/include/wdt.h b/include/wdt.h
index 5bcff24ab3..5698605c02 100644
--- a/include/wdt.h
+++ b/include/wdt.h
@@ -106,42 +106,4 @@ struct wdt_ops {
int (*expire_now)(struct udevice *dev, ulong flags);
 };
 
-#if CONFIG_IS_ENABLED(WDT)
-#ifndef CONFIG_WATCHDOG_TIMEOUT_MSECS
-#define CONFIG_WATCHDOG_TIMEOUT_MSECS  (60 * 1000)
-#endif
-#define WATCHDOG_TIMEOUT_SECS  (CONFIG_WATCHDOG_TIMEOUT_MSECS / 1000)
-
-static inline int initr_watchdog(void)
-{
-   u32 timeout = WATCHDOG_TIMEOUT_SECS;
-
-   /*
-* Init watchdog: This will call the probe function of the
-* watchdog driver, enabling the use of the device
-*/
-   if (uclass_get_device_by_seq(UCLASS_WDT, 0,
-(struct udevice **)&gd->watchdog_dev)) {
-   debug("WDT:   Not found by seq!\n");
-   if (uclass_get_device(UCLASS_WDT, 0,
- (struct udevice **)&gd->watchdog_dev)) {
-   printf("WDT:   Not found!\n");
-   return 0;
-   }
-   }
-
-   if (CONFIG_IS_ENABLED(OF_CONTROL)) {
-   timeout = dev_read_u32_default(gd->watchdog_dev, "timeout-sec",
-  WATCHDOG_TIMEOUT_SECS);
-   }
-
-   wdt_start(gd->watchdog_dev, timeout * 1000, 0);
-   gd->flags |= GD_FLG_WDT_READY;
-   printf("WDT:   Started with%s servicing (%ds timeout)\n",
-  IS_ENABLED(CONFIG_WATCHDOG) ? "" : "out", timeout);
-
-   return 0;
-}
-#endif
-
 #endif  /* _WDT_H_ */
-- 
2.24.0.rc0.303.g954a862665-goog

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


[U-Boot] [PATCH 22/30] pci: Drop dm.h inclusion from header file

2019-10-27 Thread Simon Glass
The layerscape header should not include dm.h so remove it.

Signed-off-by: Simon Glass 
---

 drivers/pci/pcie_layerscape.h| 1 -
 drivers/pci/pcie_layerscape_fixup.c  | 1 +
 drivers/pci/pcie_layerscape_gen4.h   | 1 -
 drivers/pci/pcie_layerscape_gen4_fixup.c | 1 +
 4 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/pci/pcie_layerscape.h b/drivers/pci/pcie_layerscape.h
index ddfbba6538..9423d963b1 100644
--- a/drivers/pci/pcie_layerscape.h
+++ b/drivers/pci/pcie_layerscape.h
@@ -8,7 +8,6 @@
 #ifndef _PCIE_LAYERSCAPE_H_
 #define _PCIE_LAYERSCAPE_H_
 #include 
-#include 
 
 #ifndef CONFIG_SYS_PCI_MEMORY_BUS
 #define CONFIG_SYS_PCI_MEMORY_BUS CONFIG_SYS_SDRAM_BASE
diff --git a/drivers/pci/pcie_layerscape_fixup.c 
b/drivers/pci/pcie_layerscape_fixup.c
index 089e031724..bd7c01d296 100644
--- a/drivers/pci/pcie_layerscape_fixup.c
+++ b/drivers/pci/pcie_layerscape_fixup.c
@@ -6,6 +6,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/drivers/pci/pcie_layerscape_gen4.h 
b/drivers/pci/pcie_layerscape_gen4.h
index 27c2d09332..f681e63b30 100644
--- a/drivers/pci/pcie_layerscape_gen4.h
+++ b/drivers/pci/pcie_layerscape_gen4.h
@@ -9,7 +9,6 @@
 #ifndef _PCIE_LAYERSCAPE_GEN4_H_
 #define _PCIE_LAYERSCAPE_GEN4_H_
 #include 
-#include 
 
 #ifndef CONFIG_SYS_PCI_MEMORY_SIZE
 #define CONFIG_SYS_PCI_MEMORY_SIZE (4 * 1024 * 1024 * 1024ULL)
diff --git a/drivers/pci/pcie_layerscape_gen4_fixup.c 
b/drivers/pci/pcie_layerscape_gen4_fixup.c
index 1c9e5750bd..e42a31da82 100644
--- a/drivers/pci/pcie_layerscape_gen4_fixup.c
+++ b/drivers/pci/pcie_layerscape_gen4_fixup.c
@@ -8,6 +8,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
-- 
2.24.0.rc0.303.g954a862665-goog

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


[U-Boot] [PATCH 26/30] adc: Drop dm.h header file

2019-10-27 Thread Simon Glass
This header file should not be included in other header files. Remove it
and use a forward declaration instead.

Drop the common.h inclusion also.

Signed-off-by: Simon Glass 
---

 drivers/adc/stm32-adc-core.c | 1 +
 drivers/adc/stm32-adc-core.h | 4 ++--
 drivers/adc/stm32-adc.c  | 1 +
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/adc/stm32-adc-core.c b/drivers/adc/stm32-adc-core.c
index 04b6a8a2f5..d61c23b91a 100644
--- a/drivers/adc/stm32-adc-core.c
+++ b/drivers/adc/stm32-adc-core.c
@@ -7,6 +7,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include "stm32-adc-core.h"
diff --git a/drivers/adc/stm32-adc-core.h b/drivers/adc/stm32-adc-core.h
index ba0e10e6cc..05968dbcc8 100644
--- a/drivers/adc/stm32-adc-core.h
+++ b/drivers/adc/stm32-adc-core.h
@@ -26,9 +26,9 @@
 #define STM32_ADC_MAX_ADCS 3
 #define STM32_ADCX_COMN_OFFSET 0x300
 
-#include 
 #include 
-#include 
+
+struct udevice;
 
 /**
  * struct stm32_adc_common - stm32 ADC driver common data (for all instances)
diff --git a/drivers/adc/stm32-adc.c b/drivers/adc/stm32-adc.c
index 029338e4af..c928980e1d 100644
--- a/drivers/adc/stm32-adc.c
+++ b/drivers/adc/stm32-adc.c
@@ -8,6 +8,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include "stm32-adc-core.h"
-- 
2.24.0.rc0.303.g954a862665-goog

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


[U-Boot] [PATCH 23/30] video: meson: Drop unnecessary header includes

2019-10-27 Thread Simon Glass
These files should not be included in meson header files. Drop them and
tidy up the affected C files.

Signed-off-by: Simon Glass 
---

 drivers/video/meson/meson_canvas.c   |  4 
 drivers/video/meson/meson_plane.c|  5 +
 drivers/video/meson/meson_vclk.c |  2 ++
 drivers/video/meson/meson_venc.c |  4 
 drivers/video/meson/meson_vpu.c  | 18 +++---
 drivers/video/meson/meson_vpu.h  | 17 +
 drivers/video/meson/meson_vpu_init.c |  4 
 include/video.h  |  2 ++
 8 files changed, 41 insertions(+), 15 deletions(-)

diff --git a/drivers/video/meson/meson_canvas.c 
b/drivers/video/meson/meson_canvas.c
index b71cbfcc0b..eccac2f8f2 100644
--- a/drivers/video/meson/meson_canvas.c
+++ b/drivers/video/meson/meson_canvas.c
@@ -6,6 +6,10 @@
  * Author: Neil Armstrong 
  */
 
+#include 
+#include 
+#include 
+
 #include "meson_vpu.h"
 
 /* DMC Registers */
diff --git a/drivers/video/meson/meson_plane.c 
b/drivers/video/meson/meson_plane.c
index 2bc9327e1e..8edf451f13 100644
--- a/drivers/video/meson/meson_plane.c
+++ b/drivers/video/meson/meson_plane.c
@@ -6,6 +6,11 @@
  * Author: Neil Armstrong 
  */
 
+#include 
+#include 
+#include 
+#include 
+
 #include "meson_vpu.h"
 
 /* OSDx_BLKx_CFG */
diff --git a/drivers/video/meson/meson_vclk.c b/drivers/video/meson/meson_vclk.c
index 0f628e920b..01bfa4bcb8 100644
--- a/drivers/video/meson/meson_vclk.c
+++ b/drivers/video/meson/meson_vclk.c
@@ -6,6 +6,8 @@
  * Author: Neil Armstrong 
  */
 
+#include 
+#include 
 #include 
 #include "meson_vpu.h"
 #include 
diff --git a/drivers/video/meson/meson_venc.c b/drivers/video/meson/meson_venc.c
index 5da4b3f096..89e859b02a 100644
--- a/drivers/video/meson/meson_venc.c
+++ b/drivers/video/meson/meson_venc.c
@@ -6,7 +6,11 @@
  * Author: Neil Armstrong 
  */
 
+#include 
+#include 
 #include 
+#include 
+#include 
 #include "meson_vpu.h"
 
 enum {
diff --git a/drivers/video/meson/meson_vpu.c b/drivers/video/meson/meson_vpu.c
index c3af9b013c..4eb66398d0 100644
--- a/drivers/video/meson/meson_vpu.c
+++ b/drivers/video/meson/meson_vpu.c
@@ -6,13 +6,17 @@
  * Author: Neil Armstrong 
  */
 
-#include "meson_vpu.h"
+#include 
+#include 
+#include 
 #include 
-#include 
-#include 
 #include 
 #include 
 #include 
+#include 
+#include 
+
+#include "meson_vpu.h"
 #include "meson_registers.h"
 #include "simplefb_common.h"
 
@@ -27,6 +31,14 @@ static struct meson_framebuffer {
bool is_cvbs;
 } meson_fb = { 0 };
 
+bool meson_vpu_is_compatible(struct meson_vpu_priv *priv,
+enum vpu_compatible family)
+{
+   enum vpu_compatible compat = dev_get_driver_data(priv->dev);
+
+   return compat == family;
+}
+
 static int meson_vpu_setup_mode(struct udevice *dev, struct udevice *disp)
 {
struct video_uc_platdata *uc_plat = dev_get_uclass_platdata(dev);
diff --git a/drivers/video/meson/meson_vpu.h b/drivers/video/meson/meson_vpu.h
index 0d9fddad2e..d9588c3775 100644
--- a/drivers/video/meson/meson_vpu.h
+++ b/drivers/video/meson/meson_vpu.h
@@ -9,14 +9,12 @@
 #ifndef __MESON_VPU_H__
 #define __MESON_VPU_H__
 
-#include 
-#include 
 #include 
-#include 
-#include 
-#include 
 #include "meson_registers.h"
 
+struct display_timing;
+struct udevice;
+
 enum {
/* Maximum size we support */
VPU_MAX_WIDTH   = 3840,
@@ -38,13 +36,8 @@ struct meson_vpu_priv {
void __iomem *dmc_base;
 };
 
-static inline bool meson_vpu_is_compatible(struct meson_vpu_priv *priv,
-  enum vpu_compatible family)
-{
-   enum vpu_compatible compat = dev_get_driver_data(priv->dev);
-
-   return compat == family;
-}
+bool meson_vpu_is_compatible(struct meson_vpu_priv *priv,
+enum vpu_compatible family);
 
 #define hhi_update_bits(offset, mask, value) \
writel_bits(mask, value, priv->hhi_base + offset)
diff --git a/drivers/video/meson/meson_vpu_init.c 
b/drivers/video/meson/meson_vpu_init.c
index 12f8c4194a..8408c59eaa 100644
--- a/drivers/video/meson/meson_vpu_init.c
+++ b/drivers/video/meson/meson_vpu_init.c
@@ -8,6 +8,10 @@
 
 #define DEBUG
 
+#include 
+#include 
+#include 
+
 #include "meson_vpu.h"
 
 /* HHI Registers */
diff --git a/include/video.h b/include/video.h
index 485071d072..e7c58e86cb 100644
--- a/include/video.h
+++ b/include/video.h
@@ -17,6 +17,8 @@
 
 #include 
 
+struct udevice;
+
 struct video_uc_platdata {
uint align;
uint size;
-- 
2.24.0.rc0.303.g954a862665-goog

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


[U-Boot] [PATCH 19/30] spi: Drop duplicate dm.h inclusion

2019-10-27 Thread Simon Glass
We only need to include this header once. Drop the duplicate.

Signed-off-by: Simon Glass 
---

 drivers/spi/mscc_bb_spi.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/spi/mscc_bb_spi.c b/drivers/spi/mscc_bb_spi.c
index c3c7b80426..22fa2efd34 100644
--- a/drivers/spi/mscc_bb_spi.c
+++ b/drivers/spi/mscc_bb_spi.c
@@ -10,7 +10,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
-- 
2.24.0.rc0.303.g954a862665-goog

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


[U-Boot] [PATCH 25/30] mscc: Drop dm.h header file

2019-10-27 Thread Simon Glass
This header file should not be included in other header files. Remove it
from each one and use a forward declaration instead.

Signed-off-by: Simon Glass 
---

 arch/mips/mach-mscc/include/mach/jr2/jr2.h | 3 ---
 arch/mips/mach-mscc/include/mach/luton/luton.h | 3 ---
 arch/mips/mach-mscc/include/mach/ocelot/ocelot.h   | 3 ---
 arch/mips/mach-mscc/include/mach/serval/serval.h   | 3 ---
 arch/mips/mach-mscc/include/mach/servalt/servalt.h | 3 ---
 board/mscc/servalt/servalt.c   | 2 ++
 6 files changed, 2 insertions(+), 15 deletions(-)

diff --git a/arch/mips/mach-mscc/include/mach/jr2/jr2.h 
b/arch/mips/mach-mscc/include/mach/jr2/jr2.h
index 67244f63fa..3a779e7035 100644
--- a/arch/mips/mach-mscc/include/mach/jr2/jr2.h
+++ b/arch/mips/mach-mscc/include/mach/jr2/jr2.h
@@ -8,9 +8,6 @@
 #ifndef _MSCC_JR2_H_
 #define _MSCC_JR2_H_
 
-#include 
-#include 
-
 /*
  * Target offset base(s)
  */
diff --git a/arch/mips/mach-mscc/include/mach/luton/luton.h 
b/arch/mips/mach-mscc/include/mach/luton/luton.h
index 19f02ede66..dda665fc15 100644
--- a/arch/mips/mach-mscc/include/mach/luton/luton.h
+++ b/arch/mips/mach-mscc/include/mach/luton/luton.h
@@ -8,9 +8,6 @@
 #ifndef _MSCC_OCELOT_H_
 #define _MSCC_OCELOT_H_
 
-#include 
-#include 
-
 /*
  * Target offset base(s)
  */
diff --git a/arch/mips/mach-mscc/include/mach/ocelot/ocelot.h 
b/arch/mips/mach-mscc/include/mach/ocelot/ocelot.h
index 2cb2135d37..72b07c33cd 100644
--- a/arch/mips/mach-mscc/include/mach/ocelot/ocelot.h
+++ b/arch/mips/mach-mscc/include/mach/ocelot/ocelot.h
@@ -8,9 +8,6 @@
 #ifndef _MSCC_OCELOT_H_
 #define _MSCC_OCELOT_H_
 
-#include 
-#include 
-
 /*
  * Target offset base(s)
  */
diff --git a/arch/mips/mach-mscc/include/mach/serval/serval.h 
b/arch/mips/mach-mscc/include/mach/serval/serval.h
index 763d18fe62..a78c6e59bb 100644
--- a/arch/mips/mach-mscc/include/mach/serval/serval.h
+++ b/arch/mips/mach-mscc/include/mach/serval/serval.h
@@ -8,9 +8,6 @@
 #ifndef _MSCC_SERVAL_H_
 #define _MSCC_SERVAL_H_
 
-#include 
-#include 
-
 /*
  * Target offset base(s)
  */
diff --git a/arch/mips/mach-mscc/include/mach/servalt/servalt.h 
b/arch/mips/mach-mscc/include/mach/servalt/servalt.h
index 9015bc7dad..4d7d0886dd 100644
--- a/arch/mips/mach-mscc/include/mach/servalt/servalt.h
+++ b/arch/mips/mach-mscc/include/mach/servalt/servalt.h
@@ -8,9 +8,6 @@
 #ifndef _MSCC_SERVALT_H_
 #define _MSCC_SERVALT_H_
 
-#include 
-#include 
-
 /*
  * Target offset base(s)
  */
diff --git a/board/mscc/servalt/servalt.c b/board/mscc/servalt/servalt.c
index 566f9765c2..541a84c9cf 100644
--- a/board/mscc/servalt/servalt.c
+++ b/board/mscc/servalt/servalt.c
@@ -7,6 +7,8 @@
 #include 
 #include 
 
+DECLARE_GLOBAL_DATA_PTR;
+
 enum {
BOARD_TYPE_PCB116 = 0xAABBCE00,
 };
-- 
2.24.0.rc0.303.g954a862665-goog

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


[U-Boot] [PATCH 14/30] thermal: Drop dm.h header file

2019-10-27 Thread Simon Glass
This header file should not be included in other header files. Remove it
and use a forward declaration instead.

Signed-off-by: Simon Glass 
---

 arch/arm/mach-imx/cpu.c | 1 +
 include/thermal.h   | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-imx/cpu.c b/arch/arm/mach-imx/cpu.c
index d39f607e3f..68268bd515 100644
--- a/arch/arm/mach-imx/cpu.c
+++ b/arch/arm/mach-imx/cpu.c
@@ -8,6 +8,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/include/thermal.h b/include/thermal.h
index 11d75256e0..52a3317fd5 100644
--- a/include/thermal.h
+++ b/include/thermal.h
@@ -7,7 +7,7 @@
 #ifndef _THERMAL_H_
 #define _THERMAL_H_
 
-#include 
+struct udevice;
 
 int thermal_get_temp(struct udevice *dev, int *temp);
 
-- 
2.24.0.rc0.303.g954a862665-goog

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


[U-Boot] [PATCH 06/30] wdt: Drop dm.h header file

2019-10-27 Thread Simon Glass
This header file should not be included in other header files. Remove it
and use a forward declaration instead.

Signed-off-by: Simon Glass 
---

 include/wdt.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/include/wdt.h b/include/wdt.h
index 5698605c02..62f4b34c30 100644
--- a/include/wdt.h
+++ b/include/wdt.h
@@ -6,8 +6,7 @@
 #ifndef _WDT_H_
 #define _WDT_H_
 
-#include 
-#include 
+struct udevice;
 
 /*
  * Implement a simple watchdog uclass. Watchdog is basically a timer that
-- 
2.24.0.rc0.303.g954a862665-goog

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


[U-Boot] [PATCH 04/30] mtd: spi: Export spi_flash_std_probe()

2019-10-27 Thread Simon Glass
With of-platdata we need to create drivers for particular chips, or at
least drivers that are separate from the standard code, since C structures
are created by dtoc which are private to that driver.

To avoid duplicating the probing code, export this probe function for use
by these drivers.

Signed-off-by: Simon Glass 
---

 drivers/mtd/spi/sf_probe.c |  2 +-
 include/spi_flash.h| 12 
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/spi/sf_probe.c b/drivers/mtd/spi/sf_probe.c
index 277241d6f6..7ab8b69c2b 100644
--- a/drivers/mtd/spi/sf_probe.c
+++ b/drivers/mtd/spi/sf_probe.c
@@ -137,7 +137,7 @@ static int spi_flash_std_get_sw_write_prot(struct udevice 
*dev)
return spi_flash_cmd_get_sw_write_prot(flash);
 }
 
-static int spi_flash_std_probe(struct udevice *dev)
+int spi_flash_std_probe(struct udevice *dev)
 {
struct spi_slave *slave = dev_get_parent_priv(dev);
struct dm_spi_slave_platdata *plat = dev_get_parent_platdata(dev);
diff --git a/include/spi_flash.h b/include/spi_flash.h
index 55b4721813..0b23f57a71 100644
--- a/include/spi_flash.h
+++ b/include/spi_flash.h
@@ -102,6 +102,18 @@ int spi_flash_erase_dm(struct udevice *dev, u32 offset, 
size_t len);
  */
 int spl_flash_get_sw_write_prot(struct udevice *dev);
 
+/**
+ * spi_flash_std_probe() - Probe a SPI flash device
+ *
+ * This is the standard internal method for probing a SPI flash device to
+ * determine its type. It can be used in chip-specific drivers which need to
+ * do this, typically with of-platdata
+ *
+ * @dev: SPI-flash device to probe
+ * @return 0 if OK, -ve on error
+ */
+int spi_flash_std_probe(struct udevice *dev);
+
 int spi_flash_probe_bus_cs(unsigned int busnum, unsigned int cs,
   unsigned int max_hz, unsigned int spi_mode,
   struct udevice **devp);
-- 
2.24.0.rc0.303.g954a862665-goog

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


[U-Boot] [PATCH 12/30] net: Drop dm.h header file from phy.h

2019-10-27 Thread Simon Glass
This header file should not be included in other header files. Remove it
and use other headers and C inclusions instead.

Signed-off-by: Simon Glass 
---

 cmd/mdio.c| 1 +
 cmd/mii.c | 1 +
 include/dm/read.h | 1 +
 include/phy.h | 5 -
 net/eth_legacy.c  | 1 +
 5 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/cmd/mdio.c b/cmd/mdio.c
index 22c8fbe856..4e985302a4 100644
--- a/cmd/mdio.c
+++ b/cmd/mdio.c
@@ -10,6 +10,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 
diff --git a/cmd/mii.c b/cmd/mii.c
index 23ee1e6cfa..fb2769c138 100644
--- a/cmd/mii.c
+++ b/cmd/mii.c
@@ -10,6 +10,7 @@
 
 #include 
 #include 
+#include 
 #include 
 
 typedef struct _MII_field_desc_t {
diff --git a/include/dm/read.h b/include/dm/read.h
index d37fcb504d..75970619f1 100644
--- a/include/dm/read.h
+++ b/include/dm/read.h
@@ -9,6 +9,7 @@
 #ifndef _DM_READ_H
 #define _DM_READ_H
 
+#include 
 #include 
 #include 
 #include 
diff --git a/include/phy.h b/include/phy.h
index e50f56b6eb..4518ddad50 100644
--- a/include/phy.h
+++ b/include/phy.h
@@ -9,13 +9,16 @@
 #ifndef _PHY_H
 #define _PHY_H
 
-#include 
+#include 
+#include 
 #include 
 #include 
 #include 
 #include 
 #include 
 
+struct udevice;
+
 #define PHY_FIXED_ID   0xa5a55a5a
 /*
  * There is no actual id for this.
diff --git a/net/eth_legacy.c b/net/eth_legacy.c
index 41f5263526..8cdef5b827 100644
--- a/net/eth_legacy.c
+++ b/net/eth_legacy.c
@@ -7,6 +7,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
-- 
2.24.0.rc0.303.g954a862665-goog

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


[U-Boot] [PATCH 21/30] liebherr: Drop duplicate dm.h inclusion

2019-10-27 Thread Simon Glass
We only need to include this header once. Drop the duplicate.

Signed-off-by: Simon Glass 
---

 board/liebherr/display5/display5.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/board/liebherr/display5/display5.c 
b/board/liebherr/display5/display5.c
index 85ca777c1d..14bae67886 100644
--- a/board/liebherr/display5/display5.c
+++ b/board/liebherr/display5/display5.c
@@ -23,7 +23,6 @@
 #include 
 #include 
 
-#include 
 #include 
 #include 
 
-- 
2.24.0.rc0.303.g954a862665-goog

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


[U-Boot] [PATCH 10/30] dm: core: Drop header files from dm/test.h

2019-10-27 Thread Simon Glass
These header file should not be included in other header files. Remove
them and add to each individual file.

Signed-off-by: Simon Glass 
---

 include/dm/test.h  | 3 ---
 test/dm/adc.c  | 1 +
 test/dm/audio.c| 1 +
 test/dm/axi.c  | 3 ++-
 test/dm/blk.c  | 1 +
 test/dm/board.c| 1 +
 test/dm/bootcount.c| 1 +
 test/dm/bus.c  | 1 +
 test/dm/clk.c  | 1 +
 test/dm/clk_ccf.c  | 1 +
 test/dm/core.c | 1 +
 test/dm/cpu.c  | 1 +
 test/dm/dma.c  | 1 +
 test/dm/dsi_host.c | 1 +
 test/dm/eth.c  | 3 ++-
 test/dm/firmware.c | 1 +
 test/dm/gpio.c | 3 ++-
 test/dm/hwspinlock.c   | 1 +
 test/dm/i2c.c  | 1 +
 test/dm/i2s.c  | 3 ++-
 test/dm/led.c  | 1 +
 test/dm/mailbox.c  | 1 +
 test/dm/mdio.c | 5 +++--
 test/dm/mdio_mux.c | 5 +++--
 test/dm/misc.c | 1 +
 test/dm/mmc.c  | 1 +
 test/dm/nop.c  | 1 +
 test/dm/ofnode.c   | 1 +
 test/dm/osd.c  | 5 +++--
 test/dm/panel.c| 3 ++-
 test/dm/pch.c  | 1 +
 test/dm/pci.c  | 1 +
 test/dm/pci_ep.c   | 5 +++--
 test/dm/phy.c  | 1 +
 test/dm/pmic.c | 5 +++--
 test/dm/power-domain.c | 1 +
 test/dm/pwm.c  | 1 +
 test/dm/ram.c  | 1 +
 test/dm/regmap.c   | 1 +
 test/dm/regulator.c| 1 +
 test/dm/remoteproc.c   | 2 ++
 test/dm/reset.c| 1 +
 test/dm/rtc.c  | 1 +
 test/dm/serial.c   | 1 +
 test/dm/sf.c   | 1 +
 test/dm/smem.c | 1 +
 test/dm/sound.c| 1 +
 test/dm/spi.c  | 1 +
 test/dm/spmi.c | 1 +
 test/dm/syscon.c   | 1 +
 test/dm/sysreset.c | 1 +
 test/dm/tee.c  | 1 +
 test/dm/test-driver.c  | 3 ++-
 test/dm/test-fdt.c | 1 +
 test/dm/test-main.c| 2 ++
 test/dm/test-uclass.c  | 1 +
 test/dm/timer.c| 1 +
 test/dm/usb.c  | 1 +
 test/dm/video.c| 1 +
 test/dm/virtio.c   | 3 ++-
 test/dm/wdt.c  | 1 +
 test/lib/lmb.c | 2 ++
 62 files changed, 81 insertions(+), 20 deletions(-)

diff --git a/include/dm/test.h b/include/dm/test.h
index 07385cd531..b528b35617 100644
--- a/include/dm/test.h
+++ b/include/dm/test.h
@@ -6,9 +6,6 @@
 #ifndef __DM_TEST_H
 #define __DM_TEST_H
 
-#include 
-#include 
-
 /**
  * struct dm_test_cdata - configuration data for test instance
  *
diff --git a/test/dm/adc.c b/test/dm/adc.c
index da7bd4bf1f..7fa1d48dd9 100644
--- a/test/dm/adc.c
+++ b/test/dm/adc.c
@@ -17,6 +17,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 static int dm_test_adc_bind(struct unit_test_state *uts)
diff --git a/test/dm/audio.c b/test/dm/audio.c
index 77c3a3625b..4bb86e3214 100644
--- a/test/dm/audio.c
+++ b/test/dm/audio.c
@@ -8,6 +8,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
diff --git a/test/dm/axi.c b/test/dm/axi.c
index e234ab82e6..d84dfdeb4b 100644
--- a/test/dm/axi.c
+++ b/test/dm/axi.c
@@ -7,9 +7,10 @@
 #include 
 #include 
 #include 
+#include 
 #include 
+#include 
 #include 
-#include 
 
 /* Test that sandbox AXI works correctly */
 static int dm_test_axi_base(struct unit_test_state *uts)
diff --git a/test/dm/blk.c b/test/dm/blk.c
index 9c71adc69d..e1a40a31d4 100644
--- a/test/dm/blk.c
+++ b/test/dm/blk.c
@@ -8,6 +8,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 DECLARE_GLOBAL_DATA_PTR;
diff --git a/test/dm/board.c b/test/dm/board.c
index 0f267a1926..f3fd51cac8 100644
--- a/test/dm/board.c
+++ b/test/dm/board.c
@@ -8,6 +8,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include "../../drivers/board/sandbox.h"
diff --git a/test/dm/bootcount.c b/test/dm/bootcount.c
index 0817b7d3ec..2d2aac6674 100644
--- a/test/dm/bootcount.c
+++ b/test/dm/bootcount.c
@@ -8,6 +8,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 static int dm_test_bootcount(struct unit_test_state *uts)
diff --git a/test/dm/bus.c b/test/dm/bus.c
index 1ad45adb60..f0e1cae7fc 100644
--- a/test/dm/bus.c
+++ b/test/dm/bus.c
@@ -13,6 +13,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 DECLARE_GLOBAL_DATA_PTR;
diff --git a/test/dm/clk.c b/test/dm/clk.c
index 676ef217f0..abb6531b50 100644
--- a/test/dm/clk.c
+++ b/test/dm/clk.c
@@ -9,6 +9,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 /* Base test of the clk uclass */
diff --git a/test/dm/clk_ccf.c b/test/dm/clk_ccf.c
index ae3a4d8a76..da2292a51a 100644
--- a/test/dm/clk_ccf.c
+++ b/test/dm/clk_ccf.c
@@ -11,6 +11,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
diff --git a/test/dm/core.c b/test/dm/core.c
index f74c430843..9690dcb6d7 100644
--- a/test/dm/core.c
+++ b/test/dm/core.c
@@ -15,6 +15,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 DECLARE_GLOBAL_DATA_PTR;
diff --git a/test/dm/cpu.c b/test/dm/cpu.c
index f5f1caef71..36bd14c14e 100644
--- a/test/dm/cpu.c
+++ b/test/dm/cpu.c
@@ -9,6 +9,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 

[U-Boot] [PATCH 30/30] dm: core: Guard against including dm.h in header files

2019-10-27 Thread Simon Glass
Header files generally should not include header files just for a struct,
since forward declarations work just as well and reduce overhead.

Add a warning for dm.h being included, since this has crept into U-Boot.

Signed-off-by: Simon Glass 
dm: Avoid including dm.h in header files
At present a small number of header files include the dm.h header file.
The intent with driver model is for C files that use it to define dm.h
themselves. This helps indicate that driver model is supported and also
reduces the amount of code pointlessly included and relying on header
guards. Ultimately (combined with the reduction in size of common.h)
this should speed up U-Boot compilation.

This series removes all uses of dm.h in header files and adds a warning
to avert more such activity.
END

---

 include/dm.h | 4 
 1 file changed, 4 insertions(+)

diff --git a/include/dm.h b/include/dm.h
index 2e1afda440..a1b84169e6 100644
--- a/include/dm.h
+++ b/include/dm.h
@@ -3,6 +3,10 @@
  * Copyright (c) 2013 Google, Inc
  */
 
+#ifdef _DM_H_
+#warning "Suspect dm.h is included from a header file - please fix"
+#endif
+
 #ifndef _DM_H_
 #define _DM_H_
 
-- 
2.24.0.rc0.303.g954a862665-goog

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


[U-Boot] [PATCH 11/30] fs: fs-loader: Drop dm.h header file

2019-10-27 Thread Simon Glass
This header file should not be included in other header files. Remove it
and use a forward declaration instead.

Signed-off-by: Simon Glass 
---

 drivers/fpga/socfpga_arria10.c | 1 +
 include/fs_loader.h| 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/fpga/socfpga_arria10.c b/drivers/fpga/socfpga_arria10.c
index 5fb9d6a191..d94366a39a 100644
--- a/drivers/fpga/socfpga_arria10.c
+++ b/drivers/fpga/socfpga_arria10.c
@@ -11,6 +11,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/include/fs_loader.h b/include/fs_loader.h
index b728c06fcf..1b3c58086f 100644
--- a/include/fs_loader.h
+++ b/include/fs_loader.h
@@ -6,7 +6,7 @@
 #ifndef _FS_LOADER_H_
 #define _FS_LOADER_H_
 
-#include 
+struct udevice;
 
 /**
  * struct phandle_part - A place for storing phandle of node and its partition
-- 
2.24.0.rc0.303.g954a862665-goog

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


[U-Boot] [PATCH 09/30] dm: core: Drop dm.h header file from dm-demo.h

2019-10-27 Thread Simon Glass
This header file should not be included in other header files. Remove it
and add it to the cmd file instead.

Signed-off-by: Simon Glass 
---

 cmd/demo.c| 1 +
 include/dm-demo.h | 2 --
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/cmd/demo.c b/cmd/demo.c
index 52c6e7ec15..2c81bf2822 100644
--- a/cmd/demo.c
+++ b/cmd/demo.c
@@ -7,6 +7,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/include/dm-demo.h b/include/dm-demo.h
index c9a82c7e52..7b6d0d80ff 100644
--- a/include/dm-demo.h
+++ b/include/dm-demo.h
@@ -6,8 +6,6 @@
 #ifndef __DM_DEMO_H
 #define __DM_DEMO_H
 
-#include 
-
 /**
  * struct dm_demo_pdata - configuration data for demo instance
  *
-- 
2.24.0.rc0.303.g954a862665-goog

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


[U-Boot] [PATCH 15/30] w1: Drop dm.h header file

2019-10-27 Thread Simon Glass
This header file should not be included in other header files. Remove it
and use a forward declaration instead.

Signed-off-by: Simon Glass 
---

 board/atmel/common/board.c | 1 +
 cmd/w1.c   | 1 +
 include/w1.h   | 2 +-
 3 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/board/atmel/common/board.c b/board/atmel/common/board.c
index c41706c400..eee5c357bd 100644
--- a/board/atmel/common/board.c
+++ b/board/atmel/common/board.c
@@ -5,6 +5,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/cmd/w1.c b/cmd/w1.c
index 9c95fcf9cd..c7e2b62bfa 100644
--- a/cmd/w1.c
+++ b/cmd/w1.c
@@ -6,6 +6,7 @@
  */
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/include/w1.h b/include/w1.h
index b958b1c92c..77f439e587 100644
--- a/include/w1.h
+++ b/include/w1.h
@@ -8,7 +8,7 @@
 #ifndef __W1_H
 #define __W1_H
 
-#include 
+struct udevice;
 
 #define W1_FAMILY_DS24B33  0x23
 #define W1_FAMILY_DS2431   0x2d
-- 
2.24.0.rc0.303.g954a862665-goog

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


[U-Boot] [PATCH 27/30] nand: Drop dm.h header file

2019-10-27 Thread Simon Glass
This header file should not be included in other header files. Remove it
and use a forward declaration instead.

Signed-off-by: Simon Glass 
---

 drivers/mtd/nand/raw/brcmnand/brcmnand_compat.c | 4 
 drivers/mtd/nand/raw/brcmnand/brcmnand_compat.h | 4 ++--
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/nand/raw/brcmnand/brcmnand_compat.c 
b/drivers/mtd/nand/raw/brcmnand/brcmnand_compat.c
index 96b27e6e5a..01c2b922c8 100644
--- a/drivers/mtd/nand/raw/brcmnand/brcmnand_compat.c
+++ b/drivers/mtd/nand/raw/brcmnand/brcmnand_compat.c
@@ -1,6 +1,10 @@
 // SPDX-License-Identifier: GPL-2.0+
 
 #include 
+#include 
+#include 
+#include 
+
 #include "brcmnand_compat.h"
 
 struct clk *devm_clk_get(struct udevice *dev, const char *id)
diff --git a/drivers/mtd/nand/raw/brcmnand/brcmnand_compat.h 
b/drivers/mtd/nand/raw/brcmnand/brcmnand_compat.h
index 02cab0f828..408b2d809a 100644
--- a/drivers/mtd/nand/raw/brcmnand/brcmnand_compat.h
+++ b/drivers/mtd/nand/raw/brcmnand/brcmnand_compat.h
@@ -3,8 +3,8 @@
 #ifndef __BRCMNAND_COMPAT_H
 #define __BRCMNAND_COMPAT_H
 
-#include 
-#include 
+struct clk;
+struct udevice;
 
 struct clk *devm_clk_get(struct udevice *dev, const char *id);
 int clk_prepare_enable(struct clk *clk);
-- 
2.24.0.rc0.303.g954a862665-goog

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


[U-Boot] [PATCH 28/30] ufs: Drop dm.h header file

2019-10-27 Thread Simon Glass
This header file should not be included in other header files. Remove it
and use a forward declaration instead.

Also drop asm.io

Signed-off-by: Simon Glass 
---

 drivers/ufs/cdns-platform.c | 1 +
 drivers/ufs/ufs.c   | 2 +-
 drivers/ufs/ufs.h   | 5 ++---
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/ufs/cdns-platform.c b/drivers/ufs/cdns-platform.c
index c80f4253e4..341fd217c7 100644
--- a/drivers/ufs/cdns-platform.c
+++ b/drivers/ufs/cdns-platform.c
@@ -9,6 +9,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "ufs.h"
 
diff --git a/drivers/ufs/ufs.c b/drivers/ufs/ufs.c
index 23306863d5..89a32d38cd 100644
--- a/drivers/ufs/ufs.c
+++ b/drivers/ufs/ufs.c
@@ -16,7 +16,7 @@
 #include 
 #include 
 #include 
-
+#include 
 #include 
 
 #include "ufs.h"
diff --git a/drivers/ufs/ufs.h b/drivers/ufs/ufs.h
index e0bde93776..069888fdd9 100644
--- a/drivers/ufs/ufs.h
+++ b/drivers/ufs/ufs.h
@@ -2,11 +2,10 @@
 #ifndef __UFS_H
 #define __UFS_H
 
-#include 
-#include 
-
 #include "unipro.h"
 
+struct udevice;
+
 #define UFS_CDB_SIZE   16
 #define UPIU_TRANSACTION_UIC_CMD 0x1F
 #define UIC_CMD_SIZE (sizeof(u32) * 4)
-- 
2.24.0.rc0.303.g954a862665-goog

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


[U-Boot] [PATCH 16/30] efi: Tidy up header includes

2019-10-27 Thread Simon Glass
Two files relay on efi_driver.h to include common.h and dm.h which is
incorrect. The former should always be included in a non-host C file and
the latter should be included if driver model is used.

Signed-off-by: Simon Glass 
---

 include/efi_driver.h  | 2 --
 lib/efi_driver/efi_block_device.c | 2 ++
 lib/efi_driver/efi_uclass.c   | 2 ++
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/include/efi_driver.h b/include/efi_driver.h
index 840483a416..2b62219c5b 100644
--- a/include/efi_driver.h
+++ b/include/efi_driver.h
@@ -8,8 +8,6 @@
 #ifndef _EFI_DRIVER_H
 #define _EFI_DRIVER_H 1
 
-#include 
-#include 
 #include 
 
 /*
diff --git a/lib/efi_driver/efi_block_device.c 
b/lib/efi_driver/efi_block_device.c
index cf02341931..c7e7946cdd 100644
--- a/lib/efi_driver/efi_block_device.c
+++ b/lib/efi_driver/efi_block_device.c
@@ -28,6 +28,8 @@
  * iPXE uses the simple file protocol to load Grub or the Linux Kernel.
  */
 
+#include 
+#include 
 #include 
 #include 
 #include 
diff --git a/lib/efi_driver/efi_uclass.c b/lib/efi_driver/efi_uclass.c
index b14746e6b1..c837db165c 100644
--- a/lib/efi_driver/efi_uclass.c
+++ b/lib/efi_driver/efi_uclass.c
@@ -17,6 +17,8 @@
  * controllers.
  */
 
+#include 
+#include 
 #include 
 
 /**
-- 
2.24.0.rc0.303.g954a862665-goog

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


[U-Boot] [PATCH 29/30] usb: Drop dm.h header file

2019-10-27 Thread Simon Glass
This header file should not be included in other header files. Remove it
and use a forward declaration instead.

Also move the inline function out into a C file. We should not include C
code in headers.

Signed-off-by: Simon Glass 
---

 drivers/usb/musb-new/musb_uboot.c | 37 +
 drivers/usb/musb-new/pic32.c  |  1 +
 drivers/usb/musb-new/usb-compat.h | 45 +++
 3 files changed, 47 insertions(+), 36 deletions(-)

diff --git a/drivers/usb/musb-new/musb_uboot.c 
b/drivers/usb/musb-new/musb_uboot.c
index 9eb593402e..98df080e50 100644
--- a/drivers/usb/musb-new/musb_uboot.c
+++ b/drivers/usb/musb-new/musb_uboot.c
@@ -1,5 +1,6 @@
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -449,3 +450,39 @@ struct musb *musb_register(struct musb_hdrc_platform_data 
*plat, void *bdata,
 
return *musbp;
 }
+
+#if CONFIG_IS_ENABLED(DM_USB)
+struct usb_device *usb_dev_get_parent(struct usb_device *udev)
+{
+   struct udevice *parent = udev->dev->parent;
+
+   /*
+* When called from usb-uclass.c: usb_scan_device() udev->dev points
+* to the parent udevice, not the actual udevice belonging to the
+* udev as the device is not instantiated yet.
+*
+* If dev is an usb-bus, then we are called from usb_scan_device() for
+* an usb-device plugged directly into the root port, return NULL.
+*/
+   if (device_get_uclass_id(udev->dev) == UCLASS_USB)
+   return NULL;
+
+   /*
+* If these 2 are not the same we are being called from
+* usb_scan_device() and udev itself is the parent.
+*/
+   if (dev_get_parent_priv(udev->dev) != udev)
+   return udev;
+
+   /* We are being called normally, use the parent pointer */
+   if (device_get_uclass_id(parent) == UCLASS_USB_HUB)
+   return dev_get_parent_priv(parent);
+
+   return NULL;
+}
+#else
+struct usb_device *usb_dev_get_parent(struct usb_device *udev)
+{
+   return udev->parent;
+}
+#endif
diff --git a/drivers/usb/musb-new/pic32.c b/drivers/usb/musb-new/pic32.c
index 3a19900e21..b41b7ee154 100644
--- a/drivers/usb/musb-new/pic32.c
+++ b/drivers/usb/musb-new/pic32.c
@@ -10,6 +10,7 @@
  */
 
 #include 
+#include 
 #include 
 #include "linux-compat.h"
 #include "musb_core.h"
diff --git a/drivers/usb/musb-new/usb-compat.h 
b/drivers/usb/musb-new/usb-compat.h
index f2c18ad3a2..1c66c4fe36 100644
--- a/drivers/usb/musb-new/usb-compat.h
+++ b/drivers/usb/musb-new/usb-compat.h
@@ -1,9 +1,10 @@
 #ifndef __USB_COMPAT_H__
 #define __USB_COMPAT_H__
 
-#include 
 #include "usb.h"
 
+struct udevice;
+
 struct usb_hcd {
void *hcd_priv;
 };
@@ -67,40 +68,12 @@ static inline int usb_hcd_unmap_urb_for_dma(struct usb_hcd 
*hcd,
return 0;
 }
 
-#if CONFIG_IS_ENABLED(DM_USB)
-static inline struct usb_device *usb_dev_get_parent(struct usb_device *udev)
-{
-   struct udevice *parent = udev->dev->parent;
-
-   /*
-* When called from usb-uclass.c: usb_scan_device() udev->dev points
-* to the parent udevice, not the actual udevice belonging to the
-* udev as the device is not instantiated yet.
-*
-* If dev is an usb-bus, then we are called from usb_scan_device() for
-* an usb-device plugged directly into the root port, return NULL.
-*/
-   if (device_get_uclass_id(udev->dev) == UCLASS_USB)
-   return NULL;
-
-   /*
-* If these 2 are not the same we are being called from
-* usb_scan_device() and udev itself is the parent.
-*/
-   if (dev_get_parent_priv(udev->dev) != udev)
-   return udev;
-
-   /* We are being called normally, use the parent pointer */
-   if (device_get_uclass_id(parent) == UCLASS_USB_HUB)
-   return dev_get_parent_priv(parent);
-
-   return NULL;
-}
-#else
-static inline struct usb_device *usb_dev_get_parent(struct usb_device *dev)
-{
-   return dev->parent;
-}
-#endif
+/**
+ * usb_dev_get_parent() - Get the parent of a USB device
+ *
+ * @udev: USB struct containing information about the device
+ * @return associated device for which udev == dev_get_parent_priv(dev)
+ */
+struct usb_device *usb_dev_get_parent(struct usb_device *udev);
 
 #endif /* __USB_COMPAT_H__ */
-- 
2.24.0.rc0.303.g954a862665-goog

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


[U-Boot] [PATCH 17/30] power: Tidy up inclusion of regulator_common.h

2019-10-27 Thread Simon Glass
This file should not include common.h and dm.h so remove them. Also move
the inclusion of this file to after the normal includes.

Signed-off-by: Simon Glass 
---

 drivers/power/regulator/fixed.c| 3 ++-
 drivers/power/regulator/gpio-regulator.c   | 3 ++-
 drivers/power/regulator/regulator_common.c | 4 +++-
 drivers/power/regulator/regulator_common.h | 2 --
 4 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/power/regulator/fixed.c b/drivers/power/regulator/fixed.c
index 763e671d54..5c93e6523b 100644
--- a/drivers/power/regulator/fixed.c
+++ b/drivers/power/regulator/fixed.c
@@ -5,13 +5,14 @@
  *  Przemyslaw Marczak 
  */
 
-#include "regulator_common.h"
 #include 
 #include 
 #include 
 #include 
 #include 
 
+#include "regulator_common.h"
+
 static int fixed_regulator_ofdata_to_platdata(struct udevice *dev)
 {
struct dm_regulator_uclass_platdata *uc_pdata;
diff --git a/drivers/power/regulator/gpio-regulator.c 
b/drivers/power/regulator/gpio-regulator.c
index ec1dcb64b3..730aea833f 100644
--- a/drivers/power/regulator/gpio-regulator.c
+++ b/drivers/power/regulator/gpio-regulator.c
@@ -4,7 +4,6 @@
  * Keerthy 
  */
 
-#include "regulator_common.h"
 #include 
 #include 
 #include 
@@ -14,6 +13,8 @@
 #include 
 #include 
 
+#include "regulator_common.h"
+
 #define GPIO_REGULATOR_MAX_STATES  2
 
 DECLARE_GLOBAL_DATA_PTR;
diff --git a/drivers/power/regulator/regulator_common.c 
b/drivers/power/regulator/regulator_common.c
index 2041086567..242668a55b 100644
--- a/drivers/power/regulator/regulator_common.c
+++ b/drivers/power/regulator/regulator_common.c
@@ -4,10 +4,12 @@
  * Sven Schwermer 
  */
 
-#include "regulator_common.h"
 #include 
+#include 
 #include 
 
+#include "regulator_common.h"
+
 int regulator_common_ofdata_to_platdata(struct udevice *dev,
struct regulator_common_platdata *dev_pdata, const char 
*enable_gpio_name)
 {
diff --git a/drivers/power/regulator/regulator_common.h 
b/drivers/power/regulator/regulator_common.h
index 18a525880a..bf80439c78 100644
--- a/drivers/power/regulator/regulator_common.h
+++ b/drivers/power/regulator/regulator_common.h
@@ -7,9 +7,7 @@
 #ifndef _REGULATOR_COMMON_H
 #define _REGULATOR_COMMON_H
 
-#include 
 #include 
-#include 
 
 struct regulator_common_platdata {
struct gpio_desc gpio; /* GPIO for regulator enable control */
-- 
2.24.0.rc0.303.g954a862665-goog

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


[U-Boot] [PATCH 20/30] ti: am654: Drop duplicate dm.h inclusion

2019-10-27 Thread Simon Glass
We only need to include this header once. Drop the duplicate.

Signed-off-by: Simon Glass 
---

 drivers/ram/k3-am654-ddrss.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/ram/k3-am654-ddrss.c b/drivers/ram/k3-am654-ddrss.c
index 7015d8cfe7..00673e80a9 100644
--- a/drivers/ram/k3-am654-ddrss.c
+++ b/drivers/ram/k3-am654-ddrss.c
@@ -12,7 +12,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include "k3-am654-ddrss.h"
-- 
2.24.0.rc0.303.g954a862665-goog

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


Re: [U-Boot] [RFC 3/3] lib: rsa: add rsa_verify_with_pkey()

2019-10-27 Thread Simon Glass
Hi Takahiro,

On Tue, 22 Oct 2019 at 23:43, AKASHI Takahiro
 wrote:
>
> On Tue, Oct 22, 2019 at 07:50:20AM -0600, Simon Glass wrote:
> > Hi Takahiro,
> >
> > On Tue, 17 Sep 2019 at 20:59, AKASHI Takahiro
> >  wrote:
> > >
> > > Simon,
> > >
> > > Overall, do you agree to my approach here?
> > >
> > > On Mon, Sep 16, 2019 at 10:48:07PM -0700, Simon Glass wrote:
> > > > Hi AKASHI,
> > > >
> > > > On Fri, 6 Sep 2019 at 00:06, AKASHI Takahiro 
> > > >  wrote:
> > > > >
> > > > > This function, and hence rsa_verify(), will perform RSA verification
> > > > > with two essential parameters for a RSA public key in contract of
> > > > > rsa_verify_with_keynode(), which requires additional three parameters
> > > > > stored in FIT image.
> > > > >
> > > > > It will be used in implementing UEFI secure boot, i.e. image 
> > > > > authentication
> > > > > and variable authentication.
> > > > >
> > > > > Signed-off-by: AKASHI Takahiro 
> > > > > ---
> > > > >  lib/rsa/Kconfig  |  7 +
> > > > >  lib/rsa/Makefile |  3 ++-
> > > > >  lib/rsa/rsa-verify.c | 63 
> > > > > ++--
> > > > >  3 files changed, 64 insertions(+), 9 deletions(-)
> > > > >
> > > > > diff --git a/lib/rsa/Kconfig b/lib/rsa/Kconfig
> > > > > index 338c8124da59..3c1986a26f8c 100644
> > > > > --- a/lib/rsa/Kconfig
> > > > > +++ b/lib/rsa/Kconfig
> > > > > @@ -25,6 +25,13 @@ config RSA_VERIFY
> > > > > help
> > > > >   Add RSA signature verification support.
> > > > >
> > > > > +config RSA_VERIFY_WITH_PKEY
> > > > > +   bool "Execute RSA verification without key parameters from 
> > > > > FDT"
> > > > > +   depends on RSA
> > > > > +   help
> > > > > + This options enables RSA signature verification without
> > > > > + using public key parameters which is embedded control FDT.
> > > >
> > > > Please expand this, a lot. It is too brief.
> > >
> > > Will add more description.
> > >
> > > > > +
> > > > >  config RSA_SOFTWARE_EXP
> > > > > bool "Enable driver for RSA Modular Exponentiation in 
> > > > > software"
> > > > > depends on DM
> > > > > diff --git a/lib/rsa/Makefile b/lib/rsa/Makefile
> > > > > index d66eef74c514..fd4592fd6a8a 100644
> > > > > --- a/lib/rsa/Makefile
> > > > > +++ b/lib/rsa/Makefile
> > > > > @@ -5,5 +5,6 @@
> > > > >  # (C) Copyright 2000-2007
> > > > >  # Wolfgang Denk, DENX Software Engineering, w...@denx.de.
> > > > >
> > > > > -obj-$(CONFIG_RSA_VERIFY) += rsa-verify.o rsa-checksum.o rsa-keyprop.o
> > > > > +obj-$(CONFIG_RSA_VERIFY) += rsa-verify.o rsa-checksum.o
> > > > > +obj-$(CONFIG_RSA_VERIFY_WITH_PKEY) += rsa-keyprop.o
> > > > >  obj-$(CONFIG_RSA_SOFTWARE_EXP) += rsa-mod-exp.o
> > > > > diff --git a/lib/rsa/rsa-verify.c b/lib/rsa/rsa-verify.c
> > > > > index 287fcc4d234d..80eabff3e940 100644
> > > > > --- a/lib/rsa/rsa-verify.c
> > > > > +++ b/lib/rsa/rsa-verify.c
> > > > > @@ -17,9 +17,14 @@
> > > > >  #include "mkimage.h"
> > > > >  #include 
> > > > >  #endif
> > > > > +#include 
> > > > >  #include 
> > > > >  #include 
> > > > >
> > > > > +#ifndef __UBOOT__ /* for host tools */
> > > > > +#undef CONFIG_RSA_VERIFY_WITH_PKEY
> > > > > +#endif
> > > > > +
> > > > >  /* Default public exponent for backward compatibility */
> > > > >  #define RSA_DEFAULT_PUBEXP 65537
> > > > >
> > > > > @@ -342,6 +347,34 @@ static int rsa_verify_key(struct image_sign_info 
> > > > > *info,
> > > > > return 0;
> > > > >  }
> > > > >
> > > > > +#ifdef CONFIG_RSA_VERIFY_WITH_PKEY
> > > > > +/**
> > > > > + * rsa_verify_with_pkey()
> > > > > + *
> > > > > + */
> > > > > +static int rsa_verify_with_pkey(struct image_sign_info *info,
> > > > > +   const void *hash, uint8_t *sig, uint 
> > > > > sig_len)
> > > > > +{
> > > > > +   struct key_prop *prop;
> > > > > +   int ret;
> > > > > +
> > > > > +   /* Public key is self-described to fill key_prop */
> > > > > +   prop = rsa_gen_key_prop(info->key, info->keylen);
> > > > > +   if (!prop) {
> > > > > +   debug("Generating necessary parameter for decoding 
> > > > > failed\n");
> > > > > +   return -EACCES;
> > > > > +   }
> > > > > +
> > > > > +   ret = rsa_verify_key(info, prop, sig, sig_len, hash,
> > > > > +info->crypto->key_len);
> > > > > +
> > > > > +   rsa_free_key_prop(prop);
> > > > > +
> > > > > +   return ret;
> > > > > +}
> > > > > +#endif
> > > > > +
> > > > > +#if CONFIG_IS_ENABLED(FIT_SIGNATURE)
> > > > >  /**
> > > > >   * rsa_verify_with_keynode() - Verify a signature against some data 
> > > > > using
> > > > >   * information in node with prperties of RSA Key like modulus, 
> > > > > exponent etc.
> > > > > @@ -395,18 +428,21 @@ static int rsa_verify_with_keynode(struct 
> > > > > image_sign_info *info,
> > > > >
> > > > > return ret;
> > > > >  }
> > > > > +#endif
> > > > >
> > > > >  int rsa_verify(struct image_sign_info *info,
> > > > 

Re: [U-Boot] [PATCH v2] dm: core: Update log method for uclass_find_device_by_seq

2019-10-27 Thread Simon Glass
On Tue, 22 Oct 2019 at 01:40, Kever Yang  wrote:
>
> Use log() insted of debug() for uclass_find_device_by_seq function,
> since this print is very much and we can filter it out with log()
> interface.
>
> Signed-off-by: Kever Yang 
> ---
>
> Changes in v2:
> - use log_debug() instead of log()
>
>  drivers/core/uclass.c | 11 +++
>  1 file changed, 7 insertions(+), 4 deletions(-)

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


Re: [U-Boot] [PATCH v2] patman: separate emails in CC list with NULs

2019-10-27 Thread Simon Glass
On Mon, 21 Oct 2019 at 21:10, Dmitry Torokhov  wrote:
>
> There is a contributor in Linux kernel with a comma in their name, which
> confuses patman and results in invalid to- or cc- addresses on some
> patches. To avoid this, let's use \0 as a separator when generating cc
> file.
>
> Signed-off-by: Dmitry Torokhov 
> ---
>
> Changes in v2:
> - updated test cases so that 'patman --test' passes
>
>  tools/patman/func_test.py | 4 ++--
>  tools/patman/patman.py| 2 +-
>  tools/patman/series.py| 4 ++--
>  3 files changed, 5 insertions(+), 5 deletions(-)

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


Re: [U-Boot] [PATCH v2] fdt: Fix alignment issue when reading 64-bits properties from fdt

2019-10-27 Thread Simon Glass
On Tue, 22 Oct 2019 at 02:05, Jean-Jacques Hiblot  wrote:
>
> The FDT specification [0] gives a requirement of aligning properties on
> 32-bits. Make sure that the compiler is aware of this constraint when
> accessing 64-bits properties.
>
> [0]: 
> https://github.com/devicetree-org/devicetree-specification/blob/master/source/flattened-format.rst
>
> Signed-off-by: Jean-Jacques Hiblot 
> ---
>
> Here is a portion of the disassembly of ofnode_read_u64(). It show the effect
> of the patch on ARM64.
>
> with the classic fdt64_t type. GCC emits LDR (load register)
>   34:   54000109b.ls54   // b.plast
>   38:   f940ldr x0, [x0]
>   3c:   dac00c00rev x0, x0
>
> with the unaligned_fdt64_t type. GCC emits LDP (Load Pair of registers)
>   34:   54000129b.ls58   // b.plast
>   38:   2941ldp w1, w0, [x0]
>   3c:   aa008020orr x0, x1, x0, lsl #32
>   40:   dac00c00rev x0, x0
>
>
>  common/fdt_support.c   | 2 +-
>  drivers/core/ofnode.c  | 2 +-
>  include/linux/libfdt_env.h | 1 +
>  lib/fdtdec.c   | 2 +-
>  4 files changed, 4 insertions(+), 3 deletions(-)

Reviewed-by: Simon Glass 

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


Re: [U-Boot] [PATCH 01/30] lib: Allow crc32 to be disabled.

2019-10-27 Thread Heinrich Schuchardt

On 10/27/19 4:53 PM, Simon Glass wrote:

Unfortunately this table seems to appear in TPL with gcc 7.3 even if it
is not used. Fix it by creating a Kconfig that can be used to disable this
routine.

It is enabled by default, since most boards use it.

Signed-off-by: Simon Glass 
---

  lib/Kconfig  | 29 +
  lib/Makefile |  2 +-
  2 files changed, 30 insertions(+), 1 deletion(-)

diff --git a/lib/Kconfig b/lib/Kconfig
index 135f0b372b..be5f9d343a 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -353,6 +353,35 @@ config SHA_PROG_HW_ACCEL
  config MD5
bool

+config CRC32
+   bool "Enable crc32 routine"


env/common.c uses crc32(). I could not find how to disable building it.
So this configuration option seems to be superfluous. Otherwise please,
add all reverse dependencies like EFI_LOADER, CMD_UBIFS, ...


+   default y
+   help
+ This enables a 32-bit CRC (cyclic-redundancy check) routine. It is
+ typically used to check for changes in a group of bytes. Even a
+ small change typically produces a very different CRC value. This
+ algorithm is simple and quite fast.
+
+config SPL_CRC32
+   bool "Enable crc32 routine in SPL"
+   depends on SPL


Reverse dependencies are missing here, e.g.

selected by SPL_EFI_PARTITION

Best regards

Heinrich


+   default y
+   help
+ This enables a 32-bit CRC (cyclic-redundancy check) routine in SPL. It
+ is typically used to check for changes in a group of bytes. Even a
+ small change typically produces a very different CRC value. This
+ algorithm is simple and quite fast.
+
+config TPL_CRC32
+   bool "Enable crc32 routine in SPL"
+   depends on TPL
+   default y
+   help
+ This enables a 32-bit CRC (cyclic-redundancy check) routine in SPL. It
+ is typically used to check for changes in a group of bytes. Even a
+ small change typically produces a very different CRC value. This
+ algorithm is simple and quite fast.
+
  config CRC32C
bool

diff --git a/lib/Makefile b/lib/Makefile
index d248d8626c..8adc08fd73 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -84,7 +84,7 @@ obj-y += errno.o
  obj-y += display_options.o
  CFLAGS_display_options.o := $(if $(BUILD_TAG),-DBUILD_TAG='"$(BUILD_TAG)"')
  obj-$(CONFIG_BCH) += bch.o
-obj-y += crc32.o
+obj-$(CONFIG_$(SPL_TPL_)CRC32) += crc32.o
  obj-$(CONFIG_CRC32C) += crc32c.o
  obj-y += ctype.o
  obj-y += div64.o



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


[U-Boot] [PATCH] patman: fix some typos in comments

2019-10-27 Thread Anatolij Gustschin
s/Subprocress/Subprocess/
s/easiler/easier/
s/repositiory/repository/
s/rangem/range/
s/Retruns/Returns/

Signed-off-by: Anatolij Gustschin 
---
 tools/patman/cros_subprocess.py | 4 ++--
 tools/patman/gitutil.py | 4 ++--
 tools/patman/terminal.py| 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/tools/patman/cros_subprocess.py b/tools/patman/cros_subprocess.py
index 0f0d60dfb7..efd0a5aaf7 100644
--- a/tools/patman/cros_subprocess.py
+++ b/tools/patman/cros_subprocess.py
@@ -6,11 +6,11 @@
 # Licensed to PSF under a Contributor Agreement.
 # See http://www.python.org/2.4/license for licensing details.
 
-"""Subprocress execution
+"""Subprocess execution
 
 This module holds a subclass of subprocess.Popen with our own required
 features, mainly that we get access to the subprocess output while it
-is running rather than just at the end. This makes it easiler to show
+is running rather than just at the end. This makes it easier to show
 progress information and filter output in real time.
 """
 
diff --git a/tools/patman/gitutil.py b/tools/patman/gitutil.py
index dce7fa25b6..a2a225c6b9 100644
--- a/tools/patman/gitutil.py
+++ b/tools/patman/gitutil.py
@@ -23,7 +23,7 @@ def LogCmd(commit_range, git_dir=None, oneline=False, 
reverse=False,
 
 Args:
 commit_range: Range expression to use for log, None for none
-git_dir: Path to git repositiory (None to use default)
+git_dir: Path to git repository (None to use default)
 oneline: True to use --oneline, else False
 reverse: True to reverse the log (--reverse)
 count: Number of commits to list, or None for no limit
@@ -166,7 +166,7 @@ def CountCommitsInRange(git_dir, range_expr):
 git_dir: Directory containing git repo
 range_expr: Range to check
 Return:
-Number of patches that exist in the supplied rangem or None if none
+Number of patches that exist in the supplied range or None if none
 were found
 """
 pipe = [LogCmd(range_expr, git_dir=git_dir, oneline=True)]
diff --git a/tools/patman/terminal.py b/tools/patman/terminal.py
index 4ceab189bf..7a3b658b00 100644
--- a/tools/patman/terminal.py
+++ b/tools/patman/terminal.py
@@ -128,7 +128,7 @@ class Color(object):
 return ''
 
 def Stop(self):
-"""Retruns a stop color code.
+"""Returns a stop color code.
 
 Returns:
   If color is enabled, returns an ANSI color reset sequence,
-- 
2.17.1

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


Re: [U-Boot] [PATCH 23/30] video: meson: Drop unnecessary header includes

2019-10-27 Thread Anatolij Gustschin
On Sun, 27 Oct 2019 09:54:03 -0600
Simon Glass s...@chromium.org wrote:

> These files should not be included in meson header files. Drop them and
> tidy up the affected C files.
> 
> Signed-off-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 16/30] efi: Tidy up header includes

2019-10-27 Thread Heinrich Schuchardt

On 10/27/19 4:53 PM, Simon Glass wrote:> Two files relay on efi_driver.h
to include common.h and dm.h which is
%s/relay/rely/


incorrect. The former should always be included in a non-host C file and
the latter should be included if driver model is used.


https://www.denx.de/wiki/U-Boot/CodingStyle does no mention these
requirements. Does the wiki need an update?

Non-host C files not including common.h at all or not as the first
include call for trouble, cf.

https://lists.denx.de/pipermail/u-boot/2019-October/388406.html
https://lists.denx.de/pipermail/u-boot/2019-October/388408.html

As your patch makes it obvious that common.h is included first:

Reviewed-by: Heinrich Schuchardt 



Signed-off-by: Simon Glass 
---

  include/efi_driver.h  | 2 --
  lib/efi_driver/efi_block_device.c | 2 ++
  lib/efi_driver/efi_uclass.c   | 2 ++
  3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/include/efi_driver.h b/include/efi_driver.h
index 840483a416..2b62219c5b 100644
--- a/include/efi_driver.h
+++ b/include/efi_driver.h
@@ -8,8 +8,6 @@
  #ifndef _EFI_DRIVER_H
  #define _EFI_DRIVER_H 1

-#include 
-#include 
  #include 

  /*
diff --git a/lib/efi_driver/efi_block_device.c 
b/lib/efi_driver/efi_block_device.c
index cf02341931..c7e7946cdd 100644
--- a/lib/efi_driver/efi_block_device.c
+++ b/lib/efi_driver/efi_block_device.c
@@ -28,6 +28,8 @@
   * iPXE uses the simple file protocol to load Grub or the Linux Kernel.
   */

+#include 
+#include 
  #include 
  #include 
  #include 
diff --git a/lib/efi_driver/efi_uclass.c b/lib/efi_driver/efi_uclass.c
index b14746e6b1..c837db165c 100644
--- a/lib/efi_driver/efi_uclass.c
+++ b/lib/efi_driver/efi_uclass.c
@@ -17,6 +17,8 @@
   * controllers.
   */

+#include 
+#include 
  #include 

  /**



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


Re: [U-Boot] [PATCH 23/30] video: meson: Drop unnecessary header includes

2019-10-27 Thread Neil Armstrong
On 27/10/2019 16:54, Simon Glass wrote:
> These files should not be included in meson header files. Drop them and
> tidy up the affected C files.
> 
> Signed-off-by: Simon Glass 
> ---
> 
>  drivers/video/meson/meson_canvas.c   |  4 
>  drivers/video/meson/meson_plane.c|  5 +
>  drivers/video/meson/meson_vclk.c |  2 ++
>  drivers/video/meson/meson_venc.c |  4 
>  drivers/video/meson/meson_vpu.c  | 18 +++---
>  drivers/video/meson/meson_vpu.h  | 17 +
>  drivers/video/meson/meson_vpu_init.c |  4 
>  include/video.h  |  2 ++
>  8 files changed, 41 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/video/meson/meson_canvas.c 
> b/drivers/video/meson/meson_canvas.c
> index b71cbfcc0b..eccac2f8f2 100644
> --- a/drivers/video/meson/meson_canvas.c
> +++ b/drivers/video/meson/meson_canvas.c
> @@ -6,6 +6,10 @@
>   * Author: Neil Armstrong 
>   */
>  
> +#include 
> +#include 
> +#include 
> +
>  #include "meson_vpu.h"
>  
>  /* DMC Registers */
> diff --git a/drivers/video/meson/meson_plane.c 
> b/drivers/video/meson/meson_plane.c
> index 2bc9327e1e..8edf451f13 100644
> --- a/drivers/video/meson/meson_plane.c
> +++ b/drivers/video/meson/meson_plane.c
> @@ -6,6 +6,11 @@
>   * Author: Neil Armstrong 
>   */
>  
> +#include 
> +#include 
> +#include 
> +#include 
> +
>  #include "meson_vpu.h"
>  
>  /* OSDx_BLKx_CFG */
> diff --git a/drivers/video/meson/meson_vclk.c 
> b/drivers/video/meson/meson_vclk.c
> index 0f628e920b..01bfa4bcb8 100644
> --- a/drivers/video/meson/meson_vclk.c
> +++ b/drivers/video/meson/meson_vclk.c
> @@ -6,6 +6,8 @@
>   * Author: Neil Armstrong 
>   */
>  
> +#include 
> +#include 
>  #include 
>  #include "meson_vpu.h"
>  #include 
> diff --git a/drivers/video/meson/meson_venc.c 
> b/drivers/video/meson/meson_venc.c
> index 5da4b3f096..89e859b02a 100644
> --- a/drivers/video/meson/meson_venc.c
> +++ b/drivers/video/meson/meson_venc.c
> @@ -6,7 +6,11 @@
>   * Author: Neil Armstrong 
>   */
>  
> +#include 
> +#include 
>  #include 
> +#include 
> +#include 
>  #include "meson_vpu.h"
>  
>  enum {
> diff --git a/drivers/video/meson/meson_vpu.c b/drivers/video/meson/meson_vpu.c
> index c3af9b013c..4eb66398d0 100644
> --- a/drivers/video/meson/meson_vpu.c
> +++ b/drivers/video/meson/meson_vpu.c
> @@ -6,13 +6,17 @@
>   * Author: Neil Armstrong 
>   */
>  
> -#include "meson_vpu.h"
> +#include 
> +#include 
> +#include 
>  #include 
> -#include 
> -#include 
>  #include 
>  #include 
>  #include 
> +#include 
> +#include 
> +
> +#include "meson_vpu.h"
>  #include "meson_registers.h"
>  #include "simplefb_common.h"
>  
> @@ -27,6 +31,14 @@ static struct meson_framebuffer {
>   bool is_cvbs;
>  } meson_fb = { 0 };
>  
> +bool meson_vpu_is_compatible(struct meson_vpu_priv *priv,
> +  enum vpu_compatible family)
> +{
> + enum vpu_compatible compat = dev_get_driver_data(priv->dev);
> +
> + return compat == family;
> +}
> +
>  static int meson_vpu_setup_mode(struct udevice *dev, struct udevice *disp)
>  {
>   struct video_uc_platdata *uc_plat = dev_get_uclass_platdata(dev);
> diff --git a/drivers/video/meson/meson_vpu.h b/drivers/video/meson/meson_vpu.h
> index 0d9fddad2e..d9588c3775 100644
> --- a/drivers/video/meson/meson_vpu.h
> +++ b/drivers/video/meson/meson_vpu.h
> @@ -9,14 +9,12 @@
>  #ifndef __MESON_VPU_H__
>  #define __MESON_VPU_H__
>  
> -#include 
> -#include 
>  #include 
> -#include 
> -#include 
> -#include 
>  #include "meson_registers.h"
>  
> +struct display_timing;
> +struct udevice;
> +
>  enum {
>   /* Maximum size we support */
>   VPU_MAX_WIDTH   = 3840,
> @@ -38,13 +36,8 @@ struct meson_vpu_priv {
>   void __iomem *dmc_base;
>  };
>  
> -static inline bool meson_vpu_is_compatible(struct meson_vpu_priv *priv,
> -enum vpu_compatible family)
> -{
> - enum vpu_compatible compat = dev_get_driver_data(priv->dev);
> -
> - return compat == family;
> -}
> +bool meson_vpu_is_compatible(struct meson_vpu_priv *priv,
> +  enum vpu_compatible family);
>  
>  #define hhi_update_bits(offset, mask, value) \
>   writel_bits(mask, value, priv->hhi_base + offset)
> diff --git a/drivers/video/meson/meson_vpu_init.c 
> b/drivers/video/meson/meson_vpu_init.c
> index 12f8c4194a..8408c59eaa 100644
> --- a/drivers/video/meson/meson_vpu_init.c
> +++ b/drivers/video/meson/meson_vpu_init.c
> @@ -8,6 +8,10 @@
>  
>  #define DEBUG
>  
> +#include 
> +#include 
> +#include 
> +
>  #include "meson_vpu.h"
>  
>  /* HHI Registers */
> diff --git a/include/video.h b/include/video.h
> index 485071d072..e7c58e86cb 100644
> --- a/include/video.h
> +++ b/include/video.h
> @@ -17,6 +17,8 @@
>  
>  #include 
>  
> +struct udevice;
> +
>  struct video_uc_platdata {
>   uint align;
>   uint size;
> 

Acked-by: Neil Armstrong 
___
U-Boot mailing list
U-Boo

Re: [U-Boot] [PATCH 2/4] fdt: Add Kconfig options to control code size

2019-10-27 Thread Heinrich Schuchardt

On 10/27/19 4:47 PM, Simon Glass wrote:

For better or worse libfdt recent grew a lot of code that checks the
validity of the device tree in great detail. When using unsigned or
unverified data this makes things safer, but it does add to code size.

Add some controls to select the trade-off between safety and code size.

Signed-off-by: Simon Glass 
---

  lib/Kconfig | 33 +
  lib/libfdt/Makefile |  3 ++-
  2 files changed, 35 insertions(+), 1 deletion(-)

diff --git a/lib/Kconfig b/lib/Kconfig
index 135f0b372b..b8a8509d72 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -464,6 +464,17 @@ config OF_LIBFDT
  particular compatible nodes. The library operates on a flattened
  version of the device tree.

+config OF_LIBFDT_ASSUME_MASK
+   hex "Mask of conditions to assume for libfdt"
+   depends on OF_LIBFDT || FIT
+   default 0
+   help
+ Use this to change the assumptions made by libfdt about the
+ device tree it is working with. A value of 0 means that no assumptions
+ are made, and libfdt is able to deal with malicious data. A value of


What do you mean by malicious here?

The checks in libfdt are about inconsistent FDT files. But they would
not discover malicious settings like a destructive voltage or frequency.

Would FDT_ASSUME_SANE match what we have been checking up to now? Why
not use 1 as the default here to reduce the code size of U-Boot?


+ 0xff means all assumptions are made and any invalid data may cause
+ unsafe execution. See FDT_ASSUME_PERFECT, etc. in libfdt_internal.h
+
  config OF_LIBFDT_OVERLAY
bool "Enable the FDT library overlay support"
depends on OF_LIBFDT
@@ -481,6 +492,17 @@ config SPL_OF_LIBFDT
  particular compatible nodes. The library operates on a flattened
  version of the device tree.

+config SPL_OF_LIBFDT_ASSUME_MASK
+   hex "Mask of conditions to assume for libfdt"
+   depends on SPL_OF_LIBFDT || FIT
+   default 0xff


On some devices the device tree is provided by the device (e.g. QEMU).
Is it wise to set FDT_ASSUME_LATEST in this case?

Best regards

Heinrich


+   help
+ Use this to change the assumptions made by libfdt in SPL about the
+ device tree it is working with. A value of 0 means that no assumptions
+ are made, and libfdt is able to deal with malicious data. A value of
+ 0xff means all assumptions are made and any invalid data may cause
+ unsafe execution. See FDT_ASSUME_PERFECT, etc. in libfdt_internal.h
+
  config TPL_OF_LIBFDT
bool "Enable the FDT library for TPL"
default y if TPL_OF_CONTROL
@@ -491,6 +513,17 @@ config TPL_OF_LIBFDT
  particular compatible nodes. The library operates on a flattened
  version of the device tree.

+config TPL_OF_LIBFDT_ASSUME_MASK
+   hex "Mask of conditions to assume for libfdt"
+   depends on TPL_OF_LIBFDT || FIT
+   default 0xff
+   help
+ Use this to change the assumptions made by libfdt in TPL about the
+ device tree it is working with. A value of 0 means that no assumptions
+ are made, and libfdt is able to deal with malicious data. A value of
+ 0xff means all assumptions are made and any invalid data may cause
+ unsafe execution. See FDT_ASSUME_PERFECT, etc. in libfdt_internal.h
+
  config FDT_FIXUP_PARTITIONS
bool "overwrite MTD partitions in DTS through defined in 'mtdparts'"
depends on OF_LIBFDT
diff --git a/lib/libfdt/Makefile b/lib/libfdt/Makefile
index ef5b6e29d4..5d3ae4e2f1 100644
--- a/lib/libfdt/Makefile
+++ b/lib/libfdt/Makefile
@@ -22,4 +22,5 @@ obj-y += fdt_ro.o
  # U-Boot own file
  obj-y += fdt_region.o

-ccflags-y := -I$(srctree)/scripts/dtc/libfdt
+ccflags-y := -I$(srctree)/scripts/dtc/libfdt \
+   -DFDT_ASSUME_MASK=$(CONFIG_$(SPL_TPL_)OF_LIBFDT_ASSUME_MASK)



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


Re: [U-Boot] [PATCH 2/4] fdt: Add Kconfig options to control code size

2019-10-27 Thread Simon Glass
Hi Heinrich,

On Sun, 27 Oct 2019 at 12:06, Heinrich Schuchardt  wrote:
>
> On 10/27/19 4:47 PM, Simon Glass wrote:
> > For better or worse libfdt recent grew a lot of code that checks the
> > validity of the device tree in great detail. When using unsigned or
> > unverified data this makes things safer, but it does add to code size.
> >
> > Add some controls to select the trade-off between safety and code size.
> >
> > Signed-off-by: Simon Glass 
> > ---
> >
> >   lib/Kconfig | 33 +
> >   lib/libfdt/Makefile |  3 ++-
> >   2 files changed, 35 insertions(+), 1 deletion(-)
> >
> > diff --git a/lib/Kconfig b/lib/Kconfig
> > index 135f0b372b..b8a8509d72 100644
> > --- a/lib/Kconfig
> > +++ b/lib/Kconfig
> > @@ -464,6 +464,17 @@ config OF_LIBFDT
> > particular compatible nodes. The library operates on a flattened
> > version of the device tree.
> >
> > +config OF_LIBFDT_ASSUME_MASK
> > + hex "Mask of conditions to assume for libfdt"
> > + depends on OF_LIBFDT || FIT
> > + default 0
> > + help
> > +   Use this to change the assumptions made by libfdt about the
> > +   device tree it is working with. A value of 0 means that no 
> > assumptions
> > +   are made, and libfdt is able to deal with malicious data. A value of
>
> What do you mean by malicious here?

Someone trying to compromise the system with a carefully crafted DT.

>
> The checks in libfdt are about inconsistent FDT files. But they would
> not discover malicious settings like a destructive voltage or frequency.

That's right. To cover that people should probably use verified boot.

>
> Would FDT_ASSUME_SANE match what we have been checking up to now? Why
> not use 1 as the default here to reduce the code size of U-Boot?

Possibly. I'm open to changing this as the code size increase is a paind.

But most of the new checking code could be dropped by enabling
FDT_ASSUME_FRIENDLY. Take a look at that and see what you think.

>
> > +   0xff means all assumptions are made and any invalid data may cause
> > +   unsafe execution. See FDT_ASSUME_PERFECT, etc. in libfdt_internal.h
> > +
> >   config OF_LIBFDT_OVERLAY
> >   bool "Enable the FDT library overlay support"
> >   depends on OF_LIBFDT
> > @@ -481,6 +492,17 @@ config SPL_OF_LIBFDT
> > particular compatible nodes. The library operates on a flattened
> > version of the device tree.
> >
> > +config SPL_OF_LIBFDT_ASSUME_MASK
> > + hex "Mask of conditions to assume for libfdt"
> > + depends on SPL_OF_LIBFDT || FIT
> > + default 0xff
>
> On some devices the device tree is provided by the device (e.g. QEMU).
> Is it wise to set FDT_ASSUME_LATEST in this case?

Well I think we have been on the current version for about 13 years,
so probably.

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


Re: [U-Boot] [PATCH 16/30] efi: Tidy up header includes

2019-10-27 Thread Simon Glass
Hi Heinrich,

On Sun, 27 Oct 2019 at 11:42, Heinrich Schuchardt  wrote:
>
> On 10/27/19 4:53 PM, Simon Glass wrote:> Two files relay on efi_driver.h
> to include common.h and dm.h which is
> %s/relay/rely/
>
> > incorrect. The former should always be included in a non-host C file and
> > the latter should be included if driver model is used.
>
> https://www.denx.de/wiki/U-Boot/CodingStyle does no mention these
> requirements. Does the wiki need an update?

OK I added a bit of an update. Feel free to improve it.

>
> Non-host C files not including common.h at all or not as the first
> include call for trouble, cf.
>
> https://lists.denx.de/pipermail/u-boot/2019-October/388406.html
> https://lists.denx.de/pipermail/u-boot/2019-October/388408.html
>
> As your patch makes it obvious that common.h is included first:
>
> Reviewed-by: Heinrich Schuchardt 
>

Thanks...at some point we might consider running a tool over the code
base to sort the includes.

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


Re: [U-Boot] [PATCH 3/5] arm: mvebu: Avoid generating kwbimage.cfg in the source tree

2019-10-27 Thread Chris Packham
Hi Bin,

On Mon, 28 Oct 2019, 1:28 AM Bin Meng,  wrote:

> At present some boards generate kwbimage.cfg in the source tree
> during the build. This breaks buildman testing on some systems
> where the source tree is read-only. Update makefile rules to
> generate it in the build tree instead.
>
> Note some other boards have the kwbimage.cfg file written in
> advance, hence we need check if the file exists in the build
> tree first, otherwise we fall back to one in the source tree.
>
> Signed-off-by: Bin Meng 
>

Reviewed-by: Chris Packham 

---
>
>  Makefile | 15 +--
>  arch/arm/mach-mvebu/Makefile |  4 ++--
>  board/Marvell/db-88f6281-bp/Makefile |  4 ++--
>  board/Marvell/db-xc3-24g4xg/Makefile |  4 ++--
>  board/mikrotik/crs305-1g-4s/Makefile |  4 ++--
>  5 files changed, 21 insertions(+), 10 deletions(-)
>
> diff --git a/Makefile b/Makefile
> index e78b317..61b94c5 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -1276,10 +1276,21 @@ endif
>
>  MKIMAGEFLAGS_u-boot-dtb.img = $(MKIMAGEFLAGS_u-boot.img)
>
> -MKIMAGEFLAGS_u-boot.kwb = -n $(srctree)/$(CONFIG_SYS_KWD_CONFIG:"%"=%) \
> +# Some boards have the kwbimage.cfg file written in advance, while some
> +# other boards generate it on the fly during the build in the build tree.
> +# Let's check if the file exists in the build tree first, otherwise we
> +# fall back to use the one in the source tree.
> +KWD_CONFIG_FILE = $(shell \
> +   if [ -f $(objtree)/$(CONFIG_SYS_KWD_CONFIG:"%"=%) ]; then \
> +   echo -n $(objtree)/$(CONFIG_SYS_KWD_CONFIG:"%"=%); \
> +   else \
> +   echo -n $(srctree)/$(CONFIG_SYS_KWD_CONFIG:"%"=%); \
> +   fi)
> +
> +MKIMAGEFLAGS_u-boot.kwb = -n $(KWD_CONFIG_FILE) \
> -T kwbimage -a $(CONFIG_SYS_TEXT_BASE) -e $(CONFIG_SYS_TEXT_BASE)
>
> -MKIMAGEFLAGS_u-boot-spl.kwb = -n
> $(srctree)/$(CONFIG_SYS_KWD_CONFIG:"%"=%) \
> +MKIMAGEFLAGS_u-boot-spl.kwb = -n $(KWD_CONFIG_FILE) \
> -T kwbimage -a $(CONFIG_SYS_TEXT_BASE) -e $(CONFIG_SYS_TEXT_BASE) \
> $(if $(KEYDIR),-k $(KEYDIR))
>
> diff --git a/arch/arm/mach-mvebu/Makefile b/arch/arm/mach-mvebu/Makefile
> index 8228a17..b739520 100644
> --- a/arch/arm/mach-mvebu/Makefile
> +++ b/arch/arm/mach-mvebu/Makefile
> @@ -58,10 +58,10 @@ KWB_REPLACE += SEC_FUSE_DUMP
>  KWB_CFG_SEC_FUSE_DUMP = a38x
>  endif
>
> -$(src)/kwbimage.cfg: $(src)/kwbimage.cfg.in include/autoconf.mk \
> +$(obj)/kwbimage.cfg: $(src)/kwbimage.cfg.in include/autoconf.mk \
> include/config/auto.conf
> $(Q)sed -ne '$(foreach V,$(KWB_REPLACE),s/^#@$(V)/$(V)
> $(KWB_CFG_$(V))/;)p' \
> -   <$< >$(dir $<)$(@F)
> +   <$< >$(dir $@)$(@F)
>
>  endif # CONFIG_SPL_BUILD
>  obj-y  += gpio.o
> diff --git a/board/Marvell/db-88f6281-bp/Makefile
> b/board/Marvell/db-88f6281-bp/Makefile
> index e6aa7e3..003e9f6 100644
> --- a/board/Marvell/db-88f6281-bp/Makefile
> +++ b/board/Marvell/db-88f6281-bp/Makefile
> @@ -4,9 +4,9 @@ obj-y   := db-88f6281-bp.o
>  extra-y := kwbimage.cfg
>
>  quiet_cmd_sed = SED $@
> -  cmd_sed = sed $(SEDFLAGS_$(@F)) $< >$(dir $<)$(@F)
> +  cmd_sed = sed $(SEDFLAGS_$(@F)) $< >$(dir $@)$(@F)
>
>  SEDFLAGS_kwbimage.cfg = -e "s/^\#@BOOT_FROM.*/BOOT_FROM$(if
> $(CONFIG_CMD_NAND),nand,spi)/"
> -$(src)/kwbimage.cfg: $(src)/kwbimage.cfg.in include/autoconf.mk \
> +$(obj)/kwbimage.cfg: $(src)/kwbimage.cfg.in include/autoconf.mk \
> include/config/auto.conf
> $(call if_changed,sed)
> diff --git a/board/Marvell/db-xc3-24g4xg/Makefile
> b/board/Marvell/db-xc3-24g4xg/Makefile
> index 4dd5790..24e8200 100644
> --- a/board/Marvell/db-xc3-24g4xg/Makefile
> +++ b/board/Marvell/db-xc3-24g4xg/Makefile
> @@ -6,9 +6,9 @@ obj-y   := db-xc3-24g4xg.o
>  extra-y:= kwbimage.cfg
>
>  quiet_cmd_sed = SED $@
> -  cmd_sed = sed $(SEDFLAGS_$(@F)) $< >$(dir $<)$(@F)
> +  cmd_sed = sed $(SEDFLAGS_$(@F)) $< >$(dir $@)$(@F)
>
>  SEDFLAGS_kwbimage.cfg =-e "s|^BINARY.*|BINARY $(srctree)/$(@D)/binary.0
> 005b 0068|"
> -$(src)/kwbimage.cfg: $(src)/kwbimage.cfg.in include/autoconf.mk \
> +$(obj)/kwbimage.cfg: $(src)/kwbimage.cfg.in include/autoconf.mk \
> include/config/auto.conf
>   $(call if_changed,sed)
> diff --git a/board/mikrotik/crs305-1g-4s/Makefile
> b/board/mikrotik/crs305-1g-4s/Makefile
> index 895331b..c03f534 100644
> --- a/board/mikrotik/crs305-1g-4s/Makefile
> +++ b/board/mikrotik/crs305-1g-4s/Makefile
> @@ -6,9 +6,9 @@ obj-y   := crs305-1g-4s.o
>  extra-y:= kwbimage.cfg
>
>  quiet_cmd_sed = SED $@
> -  cmd_sed = sed $(SEDFLAGS_$(@F)) $< >$(dir $<)$(@F)
> +  cmd_sed = sed $(SEDFLAGS_$(@F)) $< >$(dir $@)$(@F)
>
>  SEDFLAGS_kwbimage.cfg =-e "s|^BINARY.*|BINARY $(srctree)/$(@D)/binary.0
> 005b 0068|"
> -$(src)/kwbimage.cfg: $(src)/kwbimage.cfg.in include/autoconf.mk \
> +$(obj)/kwbimage.cfg: $(src)/kwbimage.cfg.in include/autoconf.mk \
> include/config/auto.conf
>   $(

[U-Boot] [PATCH] phy: atheros: add some debug output

2019-10-27 Thread Michael Walle
The network driver has to set the PHY node correctly. If that is not the
case, ar803x_of_init() will fail. Add some debugging output.

If the device tree binding is not working for you have a look at the
  ar803x_of_init: found PHY node: phy@0
output. In the case above "phy@0" is the phy node in the device tree. If
instead the node of your network device is displayed, you have to set
the phydev->node property in your network device driver. For example,
the following patch adds it to the fsl_enetc driver:
  https://patchwork.ozlabs.org/patch/1184523/

Signed-off-by: Michael Walle 
---
 drivers/net/phy/atheros.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/net/phy/atheros.c b/drivers/net/phy/atheros.c
index 922dc91835..f68e5f2cab 100644
--- a/drivers/net/phy/atheros.c
+++ b/drivers/net/phy/atheros.c
@@ -191,6 +191,8 @@ static int ar803x_of_init(struct phy_device *phydev)
if (!ofnode_valid(node))
return -EINVAL;
 
+   debug("%s: found PHY node: %s\n", __func__, ofnode_get_name(node));
+
if (ofnode_read_bool(node, "atheros,keep-pll-enabled"))
priv->flags |= AR803x_FLAG_KEEP_PLL_ENABLED;
if (ofnode_read_bool(node, "atheros,rgmii-io-1v8"))
@@ -236,6 +238,9 @@ static int ar803x_of_init(struct phy_device *phydev)
return -EINVAL;
}
}
+
+   debug("%s: flags=%x clk_25m_reg=%04x\n", __func__, priv->flags,
+   priv->clk_25m_reg);
 #endif
 
return 0;
-- 
2.20.1

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


Re: [U-Boot] [PATCH v2 16/17] test: add lib specific Kconfig

2019-10-27 Thread AKASHI Takahiro
Tom,

On Fri, Oct 25, 2019 at 12:07:30PM -0400, Tom Rini wrote:
> On Fri, Oct 25, 2019 at 07:07:48PM +0900, AKASHI Takahiro wrote:
> > Adding new unit tests for library routines will make test/Kconfig
> > messy. So just create a Kconfig file under lib.
> > 
> > Signed-off-by: AKASHI Takahiro 
> > ---
> >  test/Kconfig | 8 +---
> >  test/lib/Kconfig | 7 +++
> >  2 files changed, 8 insertions(+), 7 deletions(-)
> >  create mode 100644 test/lib/Kconfig
> > 
> > diff --git a/test/Kconfig b/test/Kconfig
> > index 48a0e501f88f..3a5aabedd0ef 100644
> > --- a/test/Kconfig
> > +++ b/test/Kconfig
> > @@ -6,13 +6,7 @@ menuconfig UNIT_TEST
> >   This does not require sandbox to be included, but it is most
> >   often used there.
> >  
> > -config UT_LIB
> > -   bool "Unit tests for library functions"
> > -   depends on UNIT_TEST
> > -   default y
> > -   help
> > - Enables the 'ut lib' command which tests library functions like
> > - memcat(), memcyp(), memmove().
> > +source "test/lib/Kconfig"
> >  
> >  config UT_TIME
> > bool "Unit tests for time functions"
> > diff --git a/test/lib/Kconfig b/test/lib/Kconfig
> > new file mode 100644
> > index ..a983bdcaa3f1
> > --- /dev/null
> > +++ b/test/lib/Kconfig
> > @@ -0,0 +1,7 @@
> > +config UT_LIB
> > +   bool "Unit tests for library functions"
> > +   depends on UNIT_TEST
> > +   default y
> > +   help
> > + Enables the 'ut lib' command which tests library functions like
> > + memcat(), memcyp(), memmove().
> 
> But we then only add one more entry in the next patch.  How many library
> tests do you see adding when everything is done?

Only this one.

> If it's less than 5,
> we should just keep things in the test/Kconfig file I think.  The rest
> of the series seems fine, thanks!

As you know, there are bunch of library functions which are NOT
tested by "ut". I would expect that more and more tests should come
as someone modify any of libraries functions.

But I don't have a strong opinion here and will follow your suggestion.

-Takahiro Akashi


> -- 
> Tom


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


Re: [U-Boot] [PATCH v1 2/3] lib: rsa: generate additional parameters for public key

2019-10-27 Thread AKASHI Takahiro
Simon, Tom,

On Fri, Oct 25, 2019 at 12:29:08PM -0600, Simon Glass wrote:
> Hi,
> 
> On Fri, 25 Oct 2019 at 12:27, Tom Rini  wrote:
> >
> > On Thu, Oct 24, 2019 at 03:36:07PM -0600, Simon Glass wrote:
> > > Hi,
> > >
> > > On Tue, 22 Oct 2019 at 23:23, AKASHI Takahiro
> > >  wrote:
> > > >
> > > > On Mon, Oct 21, 2019 at 06:17:03PM -0600, Simon Glass wrote:
> > > > > Hi Takahiro,
> > > > >
> > > > > On Tue, 8 Oct 2019 at 23:27, AKASHI Takahiro 
> > > > >  wrote:
> > > > > >
> > > > > > In the current implementation of FIT_SIGNATURE, five parameters for
> > > > > > a RSA public key are required while only two of them are essential.
> > > > > > (See rsa-mod-exp.h and uImage.FIT/signature.txt)
> > > > > > This is a result of considering relatively limited computer power
> > > > > > and resources on embedded systems, while such a assumption may not
> > > > > > be quite practical for other use cases.
> > > > > >
> > > > > > In this patch, added is a function, rsa_gen_key_prop(), which will
> > > > > > generate additional parameters for other uses, in particular
> > > > > > UEFI secure boot, on the fly.
> > > > > >
> > > > > > Note: the current code uses some "big number" routines from BearSSL
> > > > > > for the calculation.
> > > > > >
> > > > > > Signed-off-by: AKASHI Takahiro 
> > > > > > ---
> > > > > >  include/u-boot/rsa-mod-exp.h |   3 +
> > > > > >  lib/rsa/Kconfig  |   7 +
> > > > > >  lib/rsa/Makefile |   1 +
> > > > > >  lib/rsa/rsa-keyprop.c| 585 
> > > > > > +++
> > > > > >  4 files changed, 596 insertions(+)
> > > > > >  create mode 100644 lib/rsa/rsa-keyprop.c
> > > > > >
> > > > > > diff --git a/include/u-boot/rsa-mod-exp.h 
> > > > > > b/include/u-boot/rsa-mod-exp.h
> > > > > > index 8a428c4b6a1a..ca189292d869 100644
> > > > > > --- a/include/u-boot/rsa-mod-exp.h
> > > > > > +++ b/include/u-boot/rsa-mod-exp.h
> > > > > > @@ -26,6 +26,9 @@ struct key_prop {
> > > > > > uint32_t exp_len;   /* Exponent length in number of 
> > > > > > uint8_t */
> > > > > >  };
> > > > > >
> > > > > > +struct key_prop *rsa_gen_key_prop(const void *key, uint32_t 
> > > > > > keylen);
> > > > > > +void rsa_free_key_prop(struct key_prop *prop);
> > > > >
> > > > > Please add full function comments.
> > > >
> > > > Sure.
> > > >
> > > > > > +
> > > > > >  /**
> > > > > >   * rsa_mod_exp_sw() - Perform RSA Modular Exponentiation in sw
> > > > > >   *
> > > > > > diff --git a/lib/rsa/Kconfig b/lib/rsa/Kconfig
> > > > > > index 62b7ab9c5e5c..d1743d7a4c47 100644
> > > > > > --- a/lib/rsa/Kconfig
> > > > > > +++ b/lib/rsa/Kconfig
> > > > > > @@ -30,6 +30,13 @@ config RSA_VERIFY
> > > > > > help
> > > > > >   Add RSA signature verification support.
> > > > > >
> > > > > > +config RSA_VERIFY_WITH_PKEY
> > > > > > +   bool "Execute RSA verification without key parameters from 
> > > > > > FDT"
> > > > > > +   depends on RSA
> > > > > > +   help
> > > > > > + This options enables RSA signature verification without
> > > > > > + using public key parameters which is embedded control FDT.
> > > > >
> > > > > How about something like...
> > > > >
> > > > > The standard RSA-signature verification code uses 
> > > > >
> > > > > This does not suit the use case where ...
> > > > >
> > > > > This option enables ...
> > > >
> > > > I will try to improve ...
> > > >
> > > > > > +
> > > > > >  config RSA_SOFTWARE_EXP
> > > > > > bool "Enable driver for RSA Modular Exponentiation in 
> > > > > > software"
> > > > > > depends on DM
> > > > > > diff --git a/lib/rsa/Makefile b/lib/rsa/Makefile
> > > > > > index c07305188e0c..14ed3cb4012b 100644
> > > > > > --- a/lib/rsa/Makefile
> > > > > > +++ b/lib/rsa/Makefile
> > > > > > @@ -6,4 +6,5 @@
> > > > > >  # Wolfgang Denk, DENX Software Engineering, w...@denx.de.
> > > > > >
> > > > > >  obj-$(CONFIG_$(SPL_)RSA_VERIFY) += rsa-verify.o rsa-checksum.o
> > > > > > +obj-$(CONFIG_RSA_VERIFY_WITH_PKEY) += rsa-keyprop.o
> > > > > >  obj-$(CONFIG_RSA_SOFTWARE_EXP) += rsa-mod-exp.o
> > > > > > diff --git a/lib/rsa/rsa-keyprop.c b/lib/rsa/rsa-keyprop.c
> > > > > > new file mode 100644
> > > > > > index ..d7d222e9bed9
> > > > > > --- /dev/null
> > > > > > +++ b/lib/rsa/rsa-keyprop.c
> > > > > > @@ -0,0 +1,585 @@
> > > > > > +// SPDX-License-Identifier: GPL-2.0+ and MIT
> > > > > > +/*
> > > > > > + * RSA library - generate parameters for a public key
> > > > > > + *
> > > > > > + * Copyright (c) 2019 Linaro Limited
> > > > > > + * Author: AKASHI Takahiro
> > > > > > + *
> > > > > > + * Big number routines in this file come from BearSSL:
> > > > > > + * Copyright (c) 2016 Thomas Pornin 
> > > > > > + */
> > > > > > +
> > > > > > +#include 
> > > > > > +#include 
> > > > > > +#include 
> > > > > > +#include 
> > > > > > +#include 
> > > > > > +#include 
> > > > > > +
> > > > > > +static inline unsigned
> > > > >
> > > > > Please drop the inlines unless needed

Re: [U-Boot] [PATCH v2 01/17] linux_compat: move kmemdup() from ubifs.c to linux_compat.c

2019-10-27 Thread AKASHI Takahiro
On Fri, Oct 25, 2019 at 07:38:45PM +0200, Heinrich Schuchardt wrote:
> On 10/25/19 12:07 PM, AKASHI Takahiro wrote:
> > linux_compat.c is the best place for kmemdup(), which is currenly used
> > only in ubifs.c, but will also be used when other kernel files
> > (in my case, lib/crypto/x509_cert_parser.c and pkcs7_parser.c) will be
> > imported. So just move it.
> >
> > Signed-off-by: AKASHI Takahiro 
> > ---
> >  fs/ubifs/ubifs.c   | 19 +--
> >  lib/linux_compat.c | 17 +
> >  2 files changed, 18 insertions(+), 18 deletions(-)
> >
> > diff --git a/fs/ubifs/ubifs.c b/fs/ubifs/ubifs.c
> > index 67a0e8caae70..1ffdfe0d9089 100644
> > --- a/fs/ubifs/ubifs.c
> > +++ b/fs/ubifs/ubifs.c
> > @@ -18,6 +18,7 @@
> >  #include "ubifs.h"
> >  #include 
> >
> > +#include 
> >  #include 
> >  #include 
> >
> > @@ -70,24 +71,6 @@ struct ubifs_compressor 
> > *ubifs_compressors[UBIFS_COMPR_TYPES_CNT];
> >
> >
> >  #ifdef __UBOOT__
> > -/* from mm/util.c */
> > -
> > -/**
> > - * kmemdup - duplicate region of memory
> > - *
> > - * @src: memory region to duplicate
> > - * @len: memory region length
> > - * @gfp: GFP mask to use
> > - */
> > -void *kmemdup(const void *src, size_t len, gfp_t gfp)
> > -{
> > -   void *p;
> > -
> > -   p = kmalloc(len, gfp);
> > -   if (p)
> > -   memcpy(p, src, len);
> > -   return p;
> > -}
> >
> >  struct crypto_comp {
> > int compressor;
> > diff --git a/lib/linux_compat.c b/lib/linux_compat.c
> > index 6373b4451eb3..1f8ef4266613 100644
> > --- a/lib/linux_compat.c
> > +++ b/lib/linux_compat.c
> > @@ -40,3 +40,20 @@ void *kmem_cache_alloc(struct kmem_cache *obj, int flag)
> >  {
> > return malloc_cache_aligned(obj->sz);
> >  }
> > +
> > +/**
> > + * kmemdup - duplicate region of memory
> > + *
> > + * @src: memory region to duplicate
> > + * @len: memory region length
> > + * @gfp: GFP mask to use
> 
> Please add a 'Return:' line here. Linux has:

Okay.

-Takahiro Akashi

>  * Return: newly allocated copy of @src or %NULL in case of error
> 
> Otherwise
> 
> Reviewed-by: Heinrich Schuchardt 
> 
> > + */
> > +void *kmemdup(const void *src, size_t len, gfp_t gfp)
> > +{
> > +   void *p;
> > +
> > +   p = kmalloc(len, gfp);
> > +   if (p)
> > +   memcpy(p, src, len);
> > +   return p;
> > +}
> >
> 
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v6 1/1] cmd: env: extend "env [set|print] -e" to manage UEFI variables

2019-10-27 Thread AKASHI Takahiro
On Fri, Oct 25, 2019 at 08:17:03PM +0200, Heinrich Schuchardt wrote:
> On 10/24/19 8:17 AM, AKASHI Takahiro wrote:
> > With this patch, when setting UEFI variable with "env set -e" command,
> > we will be able to
> > - specify vendor guid with "-guid guid",
> > - specify variable attributes,  BOOTSERVICE_ACCESS, RUNTIME_ACCESS,
> >   respectively with "-bs" and "-rt",
> > - append a value instead of overwriting with "-a",
> > - use memory as variable's value instead of explicit values given
> >   at the command line with "-i address,size"
> >
> > If guid is not explicitly given, default value will be used.
> >
> > Meanwhile, "env print -e," will be modified so that it will NOT dump
> > a variable's value if '-n' is specified.
> >
> > Signed-off-by: AKASHI Takahiro 
> 
> Looks fine to me. The only strange behavior is:
> 
> => printenv -e
> OsIndicationsSupported:
> EFI_GLOBAL_VARIABLE_GUID: BS|RT, DataSize = 0x8
> : 00 00 00 00 00 00 00 00  
> PlatformLang:
> EFI_GLOBAL_VARIABLE_GUID: NV|BS|RT, DataSize = 0x6
> : 65 6e 2d 55 53 00en-US.
> PlatformLangCodes:
> EFI_GLOBAL_VARIABLE_GUID: BS|RT, DataSize = 0x6
> : 65 6e 2d 55 53 00en-US.
> RuntimeServicesSupported:
> EFI_GLOBAL_VARIABLE_GUID: BS|RT, DataSize = 0x2
> : 80 05..
> => env set -e -guid 0001-0002-0003-0004-010203040506 a b
> EFI: Entry efi_set_variable("a" 0001-0002-0003-0004-010203040506 0 1
> 7eef7610)
> EFI: Exit: efi_set_variable: 14
> ## Failed to set EFI variable (not found)
> 
> I would have expected
> ## Failed to set EFI variable (invalid parameter)
> 
> The UEFI spec has:
> If a preexisting variable is rewritten with no access attributes
> specified, the variable will be deleted.
> 
> But "a" is not a preexisting variable. Instead the attributes are invalid.

This might justify all arbitrary attribute/option checks being removed
at command level, at least for test purpose.

Thank you for your review.
-Takahiro Akashi


> But as this is a bug in a code that you did not touch:
> 
> Reviewed-by: Heinrich Schuchardt 
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [RFC 3/3] lib: rsa: add rsa_verify_with_pkey()

2019-10-27 Thread AKASHI Takahiro
Simon,

On Sun, Oct 27, 2019 at 10:31:59AM -0600, Simon Glass wrote:
> Hi Takahiro,
> 
> On Tue, 22 Oct 2019 at 23:43, AKASHI Takahiro
>  wrote:
> >
> > On Tue, Oct 22, 2019 at 07:50:20AM -0600, Simon Glass wrote:
> > > Hi Takahiro,
> > >
> > > On Tue, 17 Sep 2019 at 20:59, AKASHI Takahiro
> > >  wrote:
> > > >
> > > > Simon,
> > > >
> > > > Overall, do you agree to my approach here?
> > > >
> > > > On Mon, Sep 16, 2019 at 10:48:07PM -0700, Simon Glass wrote:
> > > > > Hi AKASHI,
> > > > >
> > > > > On Fri, 6 Sep 2019 at 00:06, AKASHI Takahiro 
> > > > >  wrote:
> > > > > >
> > > > > > This function, and hence rsa_verify(), will perform RSA verification
> > > > > > with two essential parameters for a RSA public key in contract of
> > > > > > rsa_verify_with_keynode(), which requires additional three 
> > > > > > parameters
> > > > > > stored in FIT image.
> > > > > >
> > > > > > It will be used in implementing UEFI secure boot, i.e. image 
> > > > > > authentication
> > > > > > and variable authentication.
> > > > > >
> > > > > > Signed-off-by: AKASHI Takahiro 
> > > > > > ---
> > > > > >  lib/rsa/Kconfig  |  7 +
> > > > > >  lib/rsa/Makefile |  3 ++-
> > > > > >  lib/rsa/rsa-verify.c | 63 
> > > > > > ++--
> > > > > >  3 files changed, 64 insertions(+), 9 deletions(-)
> > > > > >
> > > > > > diff --git a/lib/rsa/Kconfig b/lib/rsa/Kconfig
> > > > > > index 338c8124da59..3c1986a26f8c 100644
> > > > > > --- a/lib/rsa/Kconfig
> > > > > > +++ b/lib/rsa/Kconfig
> > > > > > @@ -25,6 +25,13 @@ config RSA_VERIFY
> > > > > > help
> > > > > >   Add RSA signature verification support.
> > > > > >
> > > > > > +config RSA_VERIFY_WITH_PKEY
> > > > > > +   bool "Execute RSA verification without key parameters from 
> > > > > > FDT"
> > > > > > +   depends on RSA
> > > > > > +   help
> > > > > > + This options enables RSA signature verification without
> > > > > > + using public key parameters which is embedded control FDT.
> > > > >
> > > > > Please expand this, a lot. It is too brief.
> > > >
> > > > Will add more description.
> > > >
> > > > > > +
> > > > > >  config RSA_SOFTWARE_EXP
> > > > > > bool "Enable driver for RSA Modular Exponentiation in 
> > > > > > software"
> > > > > > depends on DM
> > > > > > diff --git a/lib/rsa/Makefile b/lib/rsa/Makefile
> > > > > > index d66eef74c514..fd4592fd6a8a 100644
> > > > > > --- a/lib/rsa/Makefile
> > > > > > +++ b/lib/rsa/Makefile
> > > > > > @@ -5,5 +5,6 @@
> > > > > >  # (C) Copyright 2000-2007
> > > > > >  # Wolfgang Denk, DENX Software Engineering, w...@denx.de.
> > > > > >
> > > > > > -obj-$(CONFIG_RSA_VERIFY) += rsa-verify.o rsa-checksum.o 
> > > > > > rsa-keyprop.o
> > > > > > +obj-$(CONFIG_RSA_VERIFY) += rsa-verify.o rsa-checksum.o
> > > > > > +obj-$(CONFIG_RSA_VERIFY_WITH_PKEY) += rsa-keyprop.o
> > > > > >  obj-$(CONFIG_RSA_SOFTWARE_EXP) += rsa-mod-exp.o
> > > > > > diff --git a/lib/rsa/rsa-verify.c b/lib/rsa/rsa-verify.c
> > > > > > index 287fcc4d234d..80eabff3e940 100644
> > > > > > --- a/lib/rsa/rsa-verify.c
> > > > > > +++ b/lib/rsa/rsa-verify.c
> > > > > > @@ -17,9 +17,14 @@
> > > > > >  #include "mkimage.h"
> > > > > >  #include 
> > > > > >  #endif
> > > > > > +#include 
> > > > > >  #include 
> > > > > >  #include 
> > > > > >
> > > > > > +#ifndef __UBOOT__ /* for host tools */
> > > > > > +#undef CONFIG_RSA_VERIFY_WITH_PKEY
> > > > > > +#endif
> > > > > > +
> > > > > >  /* Default public exponent for backward compatibility */
> > > > > >  #define RSA_DEFAULT_PUBEXP 65537
> > > > > >
> > > > > > @@ -342,6 +347,34 @@ static int rsa_verify_key(struct 
> > > > > > image_sign_info *info,
> > > > > > return 0;
> > > > > >  }
> > > > > >
> > > > > > +#ifdef CONFIG_RSA_VERIFY_WITH_PKEY
> > > > > > +/**
> > > > > > + * rsa_verify_with_pkey()
> > > > > > + *
> > > > > > + */
> > > > > > +static int rsa_verify_with_pkey(struct image_sign_info *info,
> > > > > > +   const void *hash, uint8_t *sig, 
> > > > > > uint sig_len)
> > > > > > +{
> > > > > > +   struct key_prop *prop;
> > > > > > +   int ret;
> > > > > > +
> > > > > > +   /* Public key is self-described to fill key_prop */
> > > > > > +   prop = rsa_gen_key_prop(info->key, info->keylen);
> > > > > > +   if (!prop) {
> > > > > > +   debug("Generating necessary parameter for decoding 
> > > > > > failed\n");
> > > > > > +   return -EACCES;
> > > > > > +   }
> > > > > > +
> > > > > > +   ret = rsa_verify_key(info, prop, sig, sig_len, hash,
> > > > > > +info->crypto->key_len);
> > > > > > +
> > > > > > +   rsa_free_key_prop(prop);
> > > > > > +
> > > > > > +   return ret;
> > > > > > +}
> > > > > > +#endif
> > > > > > +
> > > > > > +#if CONFIG_IS_ENABLED(FIT_SIGNATURE)
> > > > > >  /**
> > > > > >   * rsa_verify_with_keynode() - Verify a signature against some 
> > > > > > data

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

2019-10-27 Thread Tom Rini
On Sun, Oct 27, 2019 at 05:20:22PM +0530, Jagan Teki wrote:
> Hi Tom,
> 
> On Fri, Oct 25, 2019 at 11:19 PM Tom Rini  wrote:
> >
> > On Fri, Oct 25, 2019 at 02:08:12PM +0530, Jagan Teki wrote:
> >
> > > Hi Tom,
> > >
> > > Please pull this PR.
> > >
> > > Summary:
> > > - SPL_SPI_FLASH_MTD (Frieder)
> > > - SPI NOR IDs' fixes, additions (Vignesh)
> > > - cs_info change (Bin)
> > > - Enable sunxi spi (Jagan)
> > >
> > > Travis-CI:
> > > https://travis-ci.org/openedev/u-boot-amarula/builds/602483415
> > >
> > > Thanks,
> > > Jagan.
> > >
> > > The following changes since commit 
> > > 17fd9915a4c639381804ed28274fa136ae3b0bee:
> > >
> > >   Merge branch '2019-10-24-UFS-support' (2019-10-24 09:51:48 -0400)
> > >
> > > are available in the Git repository at:
> > >
> > >   https://gitlab.denx.de/u-boot/custodians/u-boot-spi master
> > >
> > > for you to fetch changes up to 395ec7418695e5ce23f8b48c01a1dbffd2e52d3f:
> > >
> > >   spi-nor-ids: Add support for Adesto AT25SL321 (2019-10-25 00:48:32 
> > > +0530)
> > >
> >
> > So, looking over the build output, I see the expected size increase in
> > sunxi due to new support. But I also see a lot of size increases in
> > rockchip and layerscape platforms (and possibly more, I stopped after
> > spotting two different SoCs), for example:
> > evb-px5: all +12139 data +176 rodata +2275 
> > spl/u-boot-spl:all +3529 spl/u-boot-spl:data +120 spl/u-boot-spl:rodata 
> > +309 spl/u-boot-spl:text +3100 text +9688
> >u-boot: add: 49/0, grow: 0/0 bytes: 9512/0 (9512)
> >  function   old new   
> > delta
> >  spi_nor_scan -2032   
> > +2032
> >  do_spi_flash -2008   
> > +2008
> >  spi_get_bus_and_cs   - 436
> > +436
> >  spi_mem_exec_op  - 420
> > +420
> >  static.spi_nor_wait_till_ready_with_timeout   - 
> > 300+300
> >  spi_nor_write- 300
> > +300
> >  mtd_arg_off_size - 276
> > +276
> >  spi_nor_erase- 232
> > +232
> >  device_unbind- 232
> > +232
> >  spi_nor_read_data- 220
> > +220
> >  spi_nor_write_data   - 212
> > +212
> >  dm_spi_claim_bus - 196
> > +196
> >  spi_mem_adjust_op_size   - 160
> > +160
> >  spi_mem_default_supports_op  - 156
> > +156
> >  spi_nor_read - 152
> > +152
> >  spi_flash_probe_bus_cs   - 152
> > +152
> >  spi_set_speed_mode   - 148
> > +148
> >  spi_flash_std_erase  - 136
> > +136
> >  spi_flash_std_probe  - 132
> > +132
> >  mtd_arg_off  - 124
> > +124
> >  device_chld_unbind   - 120
> > +120
> >  _u_boot_list_2_driver_2_spi_flash_std- 120
> > +120
> >  spi_nor_write_reg- 104
> > +104
> >  spi_find_bus_and_cs  - 104
> > +104
> >  spi_nor_read_reg - 100
> > +100
> >  spi_find_chip_select -  96 
> > +96
> >  static.spi_check_buswidth_req-  88 
> > +88
> >  str2off  -  80 
> > +80
> >  bytes_per_second -  76 
> > +76
> >  spi_flash_std_write  -  72 
> > +72
> >  spi_flash_std_read   -  72 
> > +72
> >  spi_mem_supports_op  -  56 
> > +56
> >  _u_boot_list_2_cmd_2_sf  -  56 
> > +56
> >  dm_spi_xfer  -  48 
> > +48
> >  read_sr  -  44 
> > +44
> >  device_find_next_child   -  40 
> > +40
> >  spi_flash_cmd_get_sw_write_prot  -  36 
> > +36
> >  dm_spi_release_bus  

Re: [U-Boot] [PATCH v2 00/17] import x509/pkcs7 parsers from linux

2019-10-27 Thread AKASHI Takahiro
On Fri, Oct 25, 2019 at 07:07:32PM +0900, AKASHI Takahiro wrote:
> # This patch set should be merged first prior to my rsa extension patch
> # due to some dependency. I plan to send out a new version of rsa
> # extension next week.
> 
> Asn1 parsers of x509 certificates and pkcs7 messages are required
> to implement image authentication and variable authentication as
> part of UEFI secure boot feature.
> 
> As we discussed before in the thread[1], most people insisted that
> we should re-use corresponding source code from Linux repository
> for this purpose.
> 
> Here is my attempt to import all the necessary files from Linux; Those
> will eventually be part of UEFI secure boot implementation, but I'd like
> to get early feedback from other peoples before submitting the whole
> patchset so that they will be better formatted for merging.
> 
> My approach here is
> * files from the latest Linux
> * modify files as little as possible
> * mark/protect unavoidable changes with "#if(n)def __UBOOT__"
> so that future fixes/differences in Linux repository will easily
> be applied to U-Boot.
> 
> Known issues:
> * checkpatch.pl
>   Checkpatch.pl will complain with a bunch of warnings/errors but
>   I intentionally left them unchanged for the sake of better
>   maintainability I said above.
> 
> * unit test
>   I'm still waiting for a feedback from Tom[2] regarding how we should
>   enable "unit test" for ASN1 compiler/decoder on sandbox and others
>   in Travis CI.
> 
> * Travis CI
>   It is still running against this very version, but I'm sure I have
>   fixed all the issues (as long as Heinrich's [3] is applied);
>   I will let you know the result on Monday.

All Travis CI tests have passed.

-Takahiro Akashi


> Any comments will be appreciated.
> -Takahiro Akashi
> 
> [1] https://lists.denx.de/pipermail/u-boot/2019-April/366423.html
> [2] https://lists.denx.de/pipermail/u-boot/2019-October/387734.html
> [3] https://lists.denx.de/pipermail/u-boot/2019-October/385643.html
> 
> Changes in v2 (Oct 25, 2019)
> * revise commit messages, describing what files are modified or not.
> * move kmemdump() in ubifs.c to linux_compat.c for general use (patch#1)
> * add patch#2
> * move date.c to lib/ for general use (patch#3)
> * implement mktime64() with rtc_mktime() (patch#4)
> * move asn1_compiler.c to tools/ (patch#7)
> * change CONFIG_BUILD_ASN1 to CONFIG_ASN1_COMPILER (patch#7)
> * add clean rule to asn1_compiler-generated files to clean targets (patch#8)
> * change CONFIG_ASN1 to CONFIG_ASN1_DECODER (patch#9)
> * add README for asn1 compiler/decoder (patch#10)
> * move build_oid_registory to scripts/ (patch#11)
> * shuffle an order of patches (patch#13,#14,#15)
> * add a new config CONFIG_RSA_PUBLIC_KEY_PARSER so that it can be
> * modify Kconfig dependency (patch#13,#14,#15)
>   compiled in independently (patch#13)
> * add unit test (patch#16,#17)
> 
> Changes in v1 (Oct 11, 2019) from RFC
> * change the kernel code base from v5.0 to v5.3
> * add preparatory patches (#1, #2 and #3)
> * comment off x509_check_for_self_signed() which is not useful
>   for UEFI secure boot (patch#9)
> * improve usages of "#if(n)def __UBOOT__* to minimize differences
>   between U-Boot and linux kernel
> 
> AKASHI Takahiro (17):
>   linux_compat: move kmemdup() from ubifs.c to linux_compat.c
>   rtc.h: add struct udevice declaration
>   rtc: move date.c from drivers/rtc/ to lib/
>   lib: add mktime64() for linux compatibility
>   include: kernel.h: include printk.h
>   linux/time.h: include vsprintf.h
>   cmd: add asn1_compiler
>   Makefile: add build script for asn1 parsers
>   lib: add asn1 decoder
>   doc: add README for asn1 compiler and decoder
>   lib: add oid registry utility
>   lib: crypto: add public key utility
>   lib: crypto: add rsa public key parser
>   lib: crypto: add x509 parser
>   lib: crypto: add pkcs7 message parser
>   test: add lib specific Kconfig
>   test: add asn1 unit test
> 
>  Makefile  |1 +
>  cmd/Kconfig   |1 +
>  doc/README.asn1   |   40 +
>  drivers/rtc/Kconfig   |1 +
>  drivers/rtc/Makefile  |1 -
>  fs/ubifs/ubifs.c  |   19 +-
>  include/crypto/internal/rsa.h |   57 +
>  include/crypto/pkcs7.h|   47 +
>  include/crypto/public_key.h   |   90 ++
>  include/keys/asymmetric-type.h|   88 ++
>  include/linux/asn1.h  |   65 ++
>  include/linux/asn1_ber_bytecode.h |   89 ++
>  include/linux/asn1_decoder.h  |   20 +
>  include/linux/kernel.h|2 +-
>  include/linux/oid_registry.h  |  117 +++
>  include/linux/time.h  |   11 +
>  include/rtc.h |2 +
>  lib/Kconfig   |   17 +
>  lib/Makefile  |   20 +
>  lib/asn1_decoder.c|  527 ++
>  lib/crypto/Kconfig|   52 +
>  lib/crypto/Makefile   |   49 +
>  lib/crypto/asymmetric_t

Re: [U-Boot] [PATCH v3 001/108] binman: Correct symbol calculation with non-zero image base

2019-10-27 Thread Bin Meng
On Mon, Oct 21, 2019 at 11:33 AM Simon Glass  wrote:
>
> At present binman adds the image base address to the symbol value before
> it writes it to the binary. This is not correct since the symbol value
> itself (e.g. image position) has no relationship to the image base.
>
> Fix this and update the tests to cover this case.
>
> Signed-off-by: Simon Glass 
> ---
>
> Changes in v3: None
> Changes in v2: None
>
>  tools/binman/elf.py  | 4 +---
>  tools/binman/test/u_boot_binman_syms.lds | 2 +-
>  2 files changed, 2 insertions(+), 4 deletions(-)
>

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


Re: [U-Boot] [PATCH v3 003/108] binman: Add support for Intel FSP-T

2019-10-27 Thread Bin Meng
On Mon, Oct 21, 2019 at 11:33 AM Simon Glass  wrote:
>
> This entry is used to hold an Intel FSP-T (Firmware Support Package
> Temp-RAM init) binary. Add support for this in binman.
>
> Signed-off-by: Simon Glass 
> ---
>
> Changes in v3: None
> Changes in v2: None
>
>  tools/binman/README.entries   | 16 
>  tools/binman/etype/intel_fsp_t.py | 26 ++
>  tools/binman/ftest.py |  7 +++
>  tools/binman/test/154_intel_fsp_t.dts | 14 ++
>  4 files changed, 63 insertions(+)
>  create mode 100644 tools/binman/etype/intel_fsp_t.py
>  create mode 100644 tools/binman/test/154_intel_fsp_t.dts
>

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


Re: [U-Boot] [PATCH v3 005/108] binman: Add a library to access binman entries

2019-10-27 Thread Bin Meng
Hi Simon,

On Mon, Oct 21, 2019 at 11:33 AM Simon Glass  wrote:
>
> SPL and TPL can access information about binman entries using link-time
> symbols but this is not available in U-Boot proper. Of course it could be
> made available, but the intention is to just read the device tree.
>
> Add support for this, so that U-Boot can locate entries.
>
> Signed-off-by: Simon Glass 
> ---
>
> Changes in v3: None
> Changes in v2: None
>
>  common/board_r.c | 10 ++
>  include/binman.h | 27 +++
>  lib/Kconfig  | 10 ++
>  lib/Makefile |  1 +
>  lib/binman.c | 48 
>  5 files changed, 96 insertions(+)
>  create mode 100644 include/binman.h
>  create mode 100644 lib/binman.c
>
> diff --git a/common/board_r.c b/common/board_r.c
> index d6fb5047a26..e0f3eb325aa 100644
> --- a/common/board_r.c
> +++ b/common/board_r.c
> @@ -15,6 +15,7 @@
>  #if defined(CONFIG_CMD_BEDBUG)
>  #include 
>  #endif
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -342,6 +343,14 @@ static int initr_manual_reloc_cmdtable(void)
>  }
>  #endif
>
> +static int initr_binman(void)
> +{
> +   if (!CONFIG_IS_ENABLED(BINMAN_FDT))
> +   return 0;
> +
> +   return binman_init();
> +}
> +
>  #if defined(CONFIG_MTD_NOR_FLASH)
>  static int initr_flash(void)
>  {
> @@ -693,6 +702,7 @@ static init_fnc_t init_sequence_r[] = {
>  #ifdef CONFIG_EFI_LOADER
> efi_memory_init,
>  #endif
> +   initr_binman,
> stdio_init_tables,
> initr_serial,
> initr_announce,
> diff --git a/include/binman.h b/include/binman.h
> new file mode 100644
> index 000..cc9ec77797f
> --- /dev/null
> +++ b/include/binman.h
> @@ -0,0 +1,27 @@
> +/* SPDX-License-Identifier: Intel */
> +/*
> + * Access to binman information at runtime
> + *
> + * Copyright 2019 Google LLC
> + * Written by Simon Glass 
> + */
> +
> +#ifndef _BINMAN_H_
> +#define _BINMAN_H_
> +
> +/**
> + *struct binman_entry - information about a binman entry
> + *
> + * @image_pos: Position of entry in the image
> + * @size: Size of entry
> + */
> +struct binman_entry {
> +   u32 image_pos;
> +   u32 size;
> +};
> +
> +int binman_entry_find(const char *name, struct binman_entry *entry);
> +
> +int binman_init(void);

Please add the comment block with parameters/return value for the
above 2 functions.

> +
> +#endif
> diff --git a/lib/Kconfig b/lib/Kconfig
> index 135f0b372b0..291d42324d1 100644
> --- a/lib/Kconfig
> +++ b/lib/Kconfig
> @@ -7,6 +7,16 @@ config BCH
>   This is used by SoC platforms which do not have built-in ELM
>   hardware engine required for BCH ECC correction.
>
> +config BINMAN_FDT
> +   bool "Allow access to binman information in the device tree"
> +   depends on BINMAN
> +   default y
> +   help
> + This enables U-Boot to access information about binman entries,
> + stored in the device tree in a binman node. Typical uses are to
> + locate entries in the firmware image. See binman.h for the available
> + functionality.
> +
>  config CC_OPTIMIZE_LIBS_FOR_SPEED
> bool "Optimize libraries for speed"
> help
> diff --git a/lib/Makefile b/lib/Makefile
> index d248d8626ce..0c89b4896fe 100644
> --- a/lib/Makefile
> +++ b/lib/Makefile
> @@ -19,6 +19,7 @@ obj-$(CONFIG_ARCH_AT91) += at91/
>  obj-$(CONFIG_OPTEE) += optee/
>
>  obj-$(CONFIG_AES) += aes.o
> +obj-$(CONFIG_$(SPL_TPL_)BINMAN_FDT) += binman.o
>
>  ifndef API_BUILD
>  ifneq ($(CONFIG_UT_UNICODE)$(CONFIG_EFI_LOADER),)
> diff --git a/lib/binman.c b/lib/binman.c
> new file mode 100644
> index 000..1774bdf2e5c
> --- /dev/null
> +++ b/lib/binman.c
> @@ -0,0 +1,48 @@
> +// SPDX-License-Identifier: Intel
> +/*
> + * Access to binman information at runtime
> + *
> + * Copyright 2019 Google LLC
> + * Written by Simon Glass 
> + */
> +
> +#include 
> +#include 
> +#include 
> +
> +struct binman_info {
> +   ofnode image;
> +};
> +
> +static struct binman_info *binman;
> +
> +int binman_entry_find(const char *name, struct binman_entry *entry)
> +{
> +   ofnode node;
> +   int ret;
> +
> +   node = ofnode_find_subnode(binman->image, name);
> +   if (!ofnode_valid(node))
> +   return log_msg_ret("no binman node", -ENOENT);
> +
> +   ret = ofnode_read_u32(node, "image-pos", &entry->image_pos);
> +   if (ret)
> +   return log_msg_ret("bad binman node1", ret);
> +   ret = ofnode_read_u32(node, "size", &entry->size);
> +   if (ret)
> +   return log_msg_ret("bad binman node2", ret);
> +
> +   return 0;
> +}
> +
> +int binman_init(void)
> +{
> +   binman = malloc(sizeof(struct binman_info));
> +   if (!binman)
> +   return log_msg_ret("space for binman", -ENOMEM);
> +   binman->image = ofnode_path("/binman");
> +   if (!ofnode_valid(binman->image))
> +   return log_msg_ret("binman node", -EINVAL);
> +

Re: [U-Boot] [PATCH v3 011/108] i2c: Tidy up designware PCI support

2019-10-27 Thread Heiko Schocher

Hello Simon,

Am 21.10.2019 um 05:31 schrieb Simon Glass:

This is hacked into the driver at present. It seems better to have it as
a separate driver that uses the base driver. Create a new file and put
the X86 code into it.

Actually the Baytrail settings should really come from the device tree.

Signed-off-by: Simon Glass 
---

Changes in v3: None
Changes in v2: None

  drivers/i2c/Makefile |   3 +
  drivers/i2c/designware_i2c.c | 104 ++-
  drivers/i2c/designware_i2c.h |  35 
  drivers/i2c/dw_i2c_pci.c |  78 ++
  4 files changed, 132 insertions(+), 88 deletions(-)
  create mode 100644 drivers/i2c/dw_i2c_pci.c


Reviewed-by: Heiko Schocher 

Thanks!

bye,
Heiko
--
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: h...@denx.de
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v3 006/108] dm: gpio: Allow control of GPIO uclass in SPL

2019-10-27 Thread Bin Meng
On Mon, Oct 21, 2019 at 11:33 AM Simon Glass  wrote:
>
> At present if CONFIG_SPL_GPIO_SUPPORT is enabled then the GPIO uclass
> is included in SPL/TPL without any control for boards. Some boards may
> want to disable this to reduce code size where GPIOs are not needed in
> SPL or TPL.
>
> Add a new Kconfig option to permit this. Default it to 'y' so that
> existing boards work correctly.
>
> Change existing uses of CONFIG_DM_GPIO to CONFIG_IS_ENABLED(DM_GPIO) to
> preserve the current behaviour. Also update the 74x164 GPIO driver since
> it cannot build with SPL.
>
> This allows us to remove the hacks in config_uncmd_spl.h and
> Makefile.uncmd_spl (eventually those files should be removed).
>
> Signed-off-by: Simon Glass 
> ---
>
> Changes in v3: None
> Changes in v2:
> - Fix the Kconfig condition to avoid build errors on snow
>
>  arch/arm/include/asm/omap_gpio.h  |  2 +-
>  arch/arm/mach-at91/include/mach/at91sam9260.h |  2 +-
>  arch/arm/mach-davinci/include/mach/gpio.h |  2 +-
>  arch/arm/mach-omap2/am33xx/board.c|  4 ++--
>  arch/arm/mach-omap2/omap3/board.c |  2 +-
>  arch/arm/mach-omap2/omap5/hwinit.c|  2 +-
>  board/freescale/imx8qm_mek/imx8qm_mek.c   |  2 +-
>  board/freescale/imx8qxp_mek/imx8qxp_mek.c |  2 +-
>  board/gateworks/gw_ventana/Kconfig|  3 +++
>  board/toradex/apalis-imx8/apalis-imx8.c   |  2 +-
>  drivers/gpio/Kconfig  | 22 +++
>  drivers/gpio/Makefile |  4 +++-
>  drivers/gpio/at91_gpio.c  |  6 ++---
>  drivers/gpio/atmel_pio4.c |  2 +-
>  drivers/gpio/da8xx_gpio.c |  6 ++---
>  drivers/gpio/da8xx_gpio.h |  2 +-
>  drivers/gpio/mxc_gpio.c   |  4 ++--
>  drivers/gpio/mxs_gpio.c   |  4 ++--
>  drivers/gpio/omap_gpio.c  |  6 ++---
>  drivers/gpio/sunxi_gpio.c |  8 +++
>  drivers/i2c/i2c-uclass.c  |  6 ++---
>  drivers/i2c/muxes/pca954x.c   |  4 ++--
>  drivers/mmc/fsl_esdhc_imx.c   | 13 ++-
>  drivers/mmc/omap_hsmmc.c  |  2 +-
>  drivers/net/designware.c  | 10 -
>  drivers/net/designware.h  |  4 ++--
>  drivers/net/fec_mxc.c |  6 ++---
>  drivers/net/fec_mxc.h |  2 +-
>  drivers/net/mvneta.c  |  4 ++--
>  drivers/net/mvpp2.c   |  8 +++
>  drivers/net/sun8i_emac.c  | 12 +-
>  drivers/pci/pci-aardvark.c|  4 ++--
>  drivers/pci/pcie_dw_mvebu.c   |  4 ++--
>  drivers/spi/atmel_spi.c   | 10 -
>  drivers/spi/designware_spi.c  |  4 ++--
>  drivers/tpm/tpm2_tis_spi.c|  2 +-
>  include/config_uncmd_spl.h|  1 -
>  include/configs/at91-sama5_common.h   |  5 +++--
>  include/configs/gw_ventana.h  |  1 -
>  include/configs/mx6ul_14x14_evk.h |  1 +
>  scripts/Makefile.uncmd_spl|  1 -
>  41 files changed, 109 insertions(+), 82 deletions(-)
>

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


Re: [U-Boot] [PATCH v3 007/108] dm: core: Fix offset_to_ofnode() with invalid offset

2019-10-27 Thread Bin Meng
Hi Simon,

On Mon, Oct 21, 2019 at 11:33 AM Simon Glass  wrote:
>
> If the offset is -1 this function correct sets up a null ofnode. But if

correctly?

> the offset is any other negative number (e.g. an FDT_ERR) then it does the

FDT_ERR is -1. So probably another error number?

> wrong thing.

>
> Fix it.
>
> Signed-off-by: Simon Glass 
> ---
>
> Changes in v3: None
> Changes in v2: None
>
>  include/dm/ofnode.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h
> index 5c4cbf09986..4282169706c 100644
> --- a/include/dm/ofnode.h
> +++ b/include/dm/ofnode.h
> @@ -118,7 +118,7 @@ static inline ofnode offset_to_ofnode(int of_offset)
> if (of_live_active())
> node.np = NULL;
> else
> -   node.of_offset = of_offset;
> +   node.of_offset = of_offset >= 0 ? of_offset : -1;
>
> return node;
>  }
> --

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


Re: [U-Boot] [PATCH v3 008/108] dm: pci: Delay auto-config until after relocation

2019-10-27 Thread Bin Meng
Hi Simon,

On Mon, Oct 21, 2019 at 11:33 AM Simon Glass  wrote:
>
> At present PCI auto-configuration happens in U-Boot both before and after
> relocation. This is a waste of time and may mess up static addresses used
> in board_init_f(). Adjust the code to do auto-configuration once, after
> relocation.
>
> Signed-off-by: Simon Glass 
> ---
>
> Changes in v3: None
> Changes in v2: None
>
>  drivers/pci/pci-uclass.c | 10 +-
>  1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/pci/pci-uclass.c b/drivers/pci/pci-uclass.c
> index 896cb6b23a1..e77445cea33 100644
> --- a/drivers/pci/pci-uclass.c
> +++ b/drivers/pci/pci-uclass.c
> @@ -983,11 +983,11 @@ static int pci_uclass_post_probe(struct udevice *bus)
> if (ret)
> return ret;
>
> -#if CONFIG_IS_ENABLED(PCI_PNP)
> -   ret = pci_auto_config_devices(bus);
> -   if (ret < 0)
> -   return ret;
> -#endif
> +   if (CONFIG_IS_ENABLED(PCI_PNP) && (gd->flags & GD_FLG_RELOC)) {

This breaks boards that use PCI before relocation, eg: PCI UART.

> +   ret = pci_auto_config_devices(bus);
> +   if (ret < 0)
> +   return log_msg_ret("pci auto-config", ret);
> +   }
>
>  #if defined(CONFIG_X86) && defined(CONFIG_HAVE_FSP)
> /*
> --

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


Re: [U-Boot] [PATCH v3 010/108] net: Move the checksum functions to lib/

2019-10-27 Thread Bin Meng
Hi Simon,

On Mon, Oct 21, 2019 at 11:33 AM Simon Glass  wrote:
>
> These functions are used by code outside the network support, so move them
> to lib/ to be more accessible.
>
> Fix up a few code-style nits while we are here.
>
> Signed-off-by: Simon Glass 
> ---
>
> Changes in v3: None
> Changes in v2: None
>
>  lib/Makefile|  2 +-
>  lib/net_utils.c | 48 
>  net/Makefile|  1 -
>  net/checksum.c  | 59 -
>  4 files changed, 49 insertions(+), 61 deletions(-)
>  delete mode 100644 net/checksum.c
>
> diff --git a/lib/Makefile b/lib/Makefile
> index 0c89b4896fe..505527d58aa 100644
> --- a/lib/Makefile
> +++ b/lib/Makefile
> @@ -76,7 +76,7 @@ endif
>  ifdef CONFIG_SPL_BUILD
>  obj-$(CONFIG_SPL_YMODEM_SUPPORT) += crc16.o
>  obj-$(CONFIG_$(SPL_TPL_)HASH_SUPPORT) += crc16.o
> -obj-$(CONFIG_SPL_NET_SUPPORT) += net_utils.o
> +obj-y += net_utils.o
>  endif
>  obj-$(CONFIG_ADDR_MAP) += addr_map.o
>  obj-y += qsort.o
> diff --git a/lib/net_utils.c b/lib/net_utils.c
> index 9fb9d4a4b05..252290210f1 100644
> --- a/lib/net_utils.c
> +++ b/lib/net_utils.c
> @@ -41,3 +41,51 @@ struct in_addr string_to_ip(const char *s)
> addr.s_addr = htonl(addr.s_addr);
> return addr;
>  }
> +
> +uint compute_ip_checksum(const void *vptr, uint nbytes)
> +{
> +   int sum, oddbyte;
> +   const unsigned short *ptr = vptr;
> +
> +   sum = 0;
> +   while (nbytes > 1) {
> +   sum += *ptr++;
> +   nbytes -= 2;
> +   }
> +   if (nbytes == 1) {
> +   oddbyte = 0;
> +   ((u8 *)&oddbyte)[0] = *(u8 *)ptr;
> +   ((u8 *)&oddbyte)[1] = 0;
> +   sum += oddbyte;
> +   }
> +   sum = (sum >> 16) + (sum & 0x);
> +   sum += (sum >> 16);
> +   sum = ~sum & 0x;
> +
> +   return sum;
> +}
> +
> +uint add_ip_checksums(uint offset, uint sum, uint new)
> +{
> +   ulong checksum;
> +
> +   sum = ~sum & 0x;
> +   new = ~new & 0x;
> +   if (offset & 1) {
> +   /*
> +* byte-swap the sum if it came from an odd offset; since the
> +* computation is endian-independent this works.
> +*/
> +   new = ((new >> 8) & 0xff) | ((new << 8) & 0xff00);
> +   }
> +   checksum = sum + new;
> +   if (checksum > 0x)
> +   checksum -= 0x;
> +
> +   return (~checksum) & 0x;
> +}
> +
> +int ip_checksum_ok(const void *addr, uint nbytes)
> +{
> +   return !(compute_ip_checksum(addr, nbytes) & 0xfffe);
> +}
> diff --git a/net/Makefile b/net/Makefile
> index 2a700c8401c..fef71b940a0 100644
> --- a/net/Makefile
> +++ b/net/Makefile
> @@ -5,7 +5,6 @@
>
>  #ccflags-y += -DDEBUG
>
> -obj-y += checksum.o

So I don't get it. checksum.o is built unconditionally here, why do we
move it to another file?

>  obj-$(CONFIG_NET)  += arp.o
>  obj-$(CONFIG_CMD_BOOTP) += bootp.o
>  obj-$(CONFIG_CMD_CDP)  += cdp.o
> diff --git a/net/checksum.c b/net/checksum.c
> deleted file mode 100644
> index 16ef4163567..000
> --- a/net/checksum.c
> +++ /dev/null
> @@ -1,59 +0,0 @@
> -// SPDX-License-Identifier: BSD-2-Clause
> -/*
> - * This file was originally taken from the FreeBSD project.
> - *
> - * Copyright (c) 2001 Charles Mott 
> - * Copyright (c) 2008 coresystems GmbH
> - * All rights reserved.
> - */
> -
> -#include 
> -#include 
> -
> -unsigned compute_ip_checksum(const void *vptr, unsigned nbytes)
> -{
> -   int sum, oddbyte;
> -   const unsigned short *ptr = vptr;
> -
> -   sum = 0;
> -   while (nbytes > 1) {
> -   sum += *ptr++;
> -   nbytes -= 2;
> -   }
> -   if (nbytes == 1) {
> -   oddbyte = 0;
> -   ((u8 *)&oddbyte)[0] = *(u8 *)ptr;
> -   ((u8 *)&oddbyte)[1] = 0;
> -   sum += oddbyte;
> -   }
> -   sum = (sum >> 16) + (sum & 0x);
> -   sum += (sum >> 16);
> -   sum = ~sum & 0x;
> -
> -   return sum;
> -}
> -
> -unsigned add_ip_checksums(unsigned offset, unsigned sum, unsigned new)
> -{
> -   unsigned long checksum;
> -
> -   sum = ~sum & 0x;
> -   new = ~new & 0x;
> -   if (offset & 1) {
> -   /*
> -* byte-swap the sum if it came from an odd offset; since the
> -* computation is endian independant this works.
> -*/
> -   new = ((new >> 8) & 0xff) | ((new << 8) & 0xff00);
> -   }
> -   checksum = sum + new;
> -   if (checksum > 0x)
> -   checksum -= 0x;
> -
> -   return (~checksum) & 0x;
> -}
> -
> -int ip_checksum_ok(const void *addr, unsigned nbytes)
> -{
> -   return !(compute_ip_checksum(addr, nbytes) & 0xfffe);
> -}
> --

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

Re: [U-Boot] [PATCH v3 009/108] dm: pci: Move pci_get_devfn() into a common file

2019-10-27 Thread Bin Meng
Hi Simon,

On Mon, Oct 21, 2019 at 11:33 AM Simon Glass  wrote:
>
> Early in boot it is necessary to decode the PCI device/function values for
> particular peripherals in the device tree or of-platdata. This is needed
> in TPL where CONFIG_PCI is not defined.
>
> To handle this, move pci_get_devfn() into a file that is built even when
> CONFIG_PCI is not defined.
>
> Signed-off-by: Simon Glass 
> ---
>
> Changes in v3:
> - Move the function to a common file instead of duplicating it
> - Update device type to pci_dev_t
>
> Changes in v2: None
>
>  arch/x86/include/asm/pci.h | 11 +++
>  drivers/core/util.c| 20 
>  drivers/pci/pci-uclass.c   | 16 
>  include/dm/pci.h   | 21 +
>  include/pci.h  | 12 ++--
>  5 files changed, 54 insertions(+), 26 deletions(-)
>  create mode 100644 include/dm/pci.h
>
> diff --git a/arch/x86/include/asm/pci.h b/arch/x86/include/asm/pci.h
> index 2a720735728..66f1515cefa 100644
> --- a/arch/x86/include/asm/pci.h
> +++ b/arch/x86/include/asm/pci.h
> @@ -60,6 +60,17 @@ int pci_x86_write_config(pci_dev_t bdf, uint offset, ulong 
> value,
>  int pci_x86_clrset_config(pci_dev_t bdf, uint offset, ulong clr, ulong set,
>   enum pci_size_t size);
>
> +/**
> + * pci_x86_ofplat_get_devfn() - Get the PCI dev/fn from ofplat reg data
> + *
> + * @reg: reg value from dt-platdata.c array (first member)
> + * @return device/function for that device
> + */
> +static inline pci_dev_t pci_x86_ofplat_get_devfn(u32 reg)
> +{
> +   return reg & 0xff00;
> +}

What is this function for?

> +
>  /**
>   * Assign IRQ number to a PCI device
>   *
> diff --git a/drivers/core/util.c b/drivers/core/util.c
> index 7dc1a2af028..69f83755f05 100644
> --- a/drivers/core/util.c
> +++ b/drivers/core/util.c
> @@ -4,7 +4,9 @@
>   */
>
>  #include 
> +#include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -58,3 +60,21 @@ bool dm_ofnode_pre_reloc(ofnode node)
>  #endif
>  }
>  #endif
> +
> +#if !CONFIG_IS_ENABLED(OF_PLATDATA)
> +int pci_get_devfn(struct udevice *dev)
> +{
> +   struct fdt_pci_addr addr;
> +   int ret;
> +
> +   /* Extract the devfn from fdt_pci_addr */
> +   ret = ofnode_read_pci_addr(dev_ofnode(dev), FDT_PCI_SPACE_CONFIG,
> +  "reg", &addr);
> +   if (ret) {
> +   if (ret != -ENOENT)
> +   return -EINVAL;
> +   }
> +
> +   return addr.phys_hi & 0xff00;
> +}
> +#endif
> diff --git a/drivers/pci/pci-uclass.c b/drivers/pci/pci-uclass.c
> index e77445cea33..95d36d91564 100644
> --- a/drivers/pci/pci-uclass.c
> +++ b/drivers/pci/pci-uclass.c
> @@ -1013,22 +1013,6 @@ static int pci_uclass_post_probe(struct udevice *bus)
> return 0;
>  }
>
> -int pci_get_devfn(struct udevice *dev)
> -{
> -   struct fdt_pci_addr addr;
> -   int ret;
> -
> -   /* Extract the devfn from fdt_pci_addr */
> -   ret = ofnode_read_pci_addr(dev_ofnode(dev), FDT_PCI_SPACE_CONFIG,
> -  "reg", &addr);
> -   if (ret) {
> -   if (ret != -ENOENT)
> -   return -EINVAL;
> -   }
> -
> -   return addr.phys_hi & 0xff00;
> -}
> -
>  static int pci_uclass_child_post_bind(struct udevice *dev)
>  {
> struct pci_child_platdata *pplat;
> diff --git a/include/dm/pci.h b/include/dm/pci.h
> new file mode 100644
> index 000..6147696d825
> --- /dev/null
> +++ b/include/dm/pci.h
> @@ -0,0 +1,21 @@
> +/* SPDX-License-Identifier: GPL-2.0+ */
> +/*
> + * Copyright (c) 2019 Google, Inc
> + */
> +
> +#ifndef __DM_PCI_H
> +#define __DM_PCI_H
> +
> +struct udevice;
> +
> +/**
> + * pci_get_devfn() - Extract the devfn from fdt_pci_addr of the device
> + *
> + * Get devfn from fdt_pci_addr of the specified device
> + *
> + * @dev:   PCI device
> + * @return devfn in bits 15...8 if found, -ENODEV if not found
> + */
> +int pci_get_devfn(struct udevice *dev);
> +
> +#endif
> diff --git a/include/pci.h b/include/pci.h
> index ff59ac0e695..083f4ee2e90 100644
> --- a/include/pci.h
> +++ b/include/pci.h
> @@ -482,6 +482,8 @@
>
>  #ifndef __ASSEMBLY__
>
> +#include 
> +
>  #ifdef CONFIG_SYS_PCI_64BIT
>  typedef u64 pci_addr_t;
>  typedef u64 pci_size_t;
> @@ -1612,16 +1614,6 @@ int sandbox_pci_get_emul(struct udevice *bus, 
> pci_dev_t find_devfn,
>   */
>  int sandbox_pci_get_client(struct udevice *emul, struct udevice **devp);
>
> -/**
> - * pci_get_devfn() - Extract the devfn from fdt_pci_addr of the device
> - *
> - * Get devfn from fdt_pci_addr of the specified device
> - *
> - * @dev:   PCI device
> - * @return devfn in bits 15...8 if found, -ENODEV if not found
> - */
> -int pci_get_devfn(struct udevice *dev);
> -
>  #endif /* CONFIG_DM_PCI */
>
>  /**
> --

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


Re: [U-Boot] [PATCH v3 094/108] i2c: designware: Add apollolake support

2019-10-27 Thread Heiko Schocher

Hello Simon,

Am 21.10.2019 um 05:38 schrieb Simon Glass:

For apollolake we need to take the I2C bus controller out of reset before
using this. Add this functionality to the driver.

Signed-off-by: Simon Glass 
---

Changes in v3:
- Add a weak function to avoid errors on other platforms

Changes in v2: None

  drivers/i2c/dw_i2c_pci.c | 20 +++-
  1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/drivers/i2c/dw_i2c_pci.c b/drivers/i2c/dw_i2c_pci.c
index 065c0aa5994..d6d93f08a56 100644
--- a/drivers/i2c/dw_i2c_pci.c
+++ b/drivers/i2c/dw_i2c_pci.c
@@ -6,8 +6,14 @@
   */
  
  #include 

+#include 
  #include "designware_i2c.h"
  
+enum {

+   VANILLA = 0,
+   INTEL_APL,
+};
+
  /* BayTrail HCNT/LCNT/SDA hold time */
  static struct dw_scl_sda_cfg byt_config = {
.ss_hcnt = 0x200,
@@ -17,6 +23,9 @@ static struct dw_scl_sda_cfg byt_config = {
.sda_hold = 0x6,
  };
  
+/* Have a weak function for now - possibly should be a new uclass */

+void lpss_reset_release(void *regs);
+
  static int designware_i2c_pci_probe(struct udevice *dev)
  {
struct dw_i2c *priv = dev_get_priv(dev);
@@ -25,9 +34,12 @@ static int designware_i2c_pci_probe(struct udevice *dev)
priv->regs = (struct i2c_regs *)
dm_pci_map_bar(dev, PCI_BASE_ADDRESS_0, PCI_REGION_MEM);
if (IS_ENABLED(CONFIG_INTEL_BAYTRAIL))
-   /* Use BayTrail specific timing values */
+   /* Use BayTrail-specific timing values */


Nitpick only: unrelated change.

Reviewed-by: Heiko Schocher 

[...]

bye,
Heiko
--
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: h...@denx.de
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v2 4/9] mpc85xx, socrates: add DM support

2019-10-27 Thread Heiko Schocher

Hello Priyanka Jain,

Am 23.10.2019 um 13:18 schrieb Priyanka Jain:




-Original Message-
From: U-Boot  On Behalf Of Heiko Schocher
Sent: Wednesday, October 16, 2019 9:26 AM
To: U-Boot Mailing List 
Subject: [U-Boot] [PATCH v2 4/9] mpc85xx, socrates: add DM support

enable CONFIG_DM for the socrates board.

Signed-off-by: Heiko Schocher 
---

Changes in v2: None

board/socrates/socrates.c  | 15 +++  configs/socrates_defconfig
|  6 +-  include/configs/socrates.h | 13 +++--
3 files changed, 27 insertions(+), 7 deletions(-)

diff --git a/board/socrates/socrates.c b/board/socrates/socrates.c index
da9ae5bebb..8f9583360b 100644
--- a/board/socrates/socrates.c
+++ b/board/socrates/socrates.c
@@ -432,3 +432,18 @@ void video_get_info_str (int line_number, char *info)
}
}
#endif
+
+#if defined(CONFIG_OF_SEPARATE)
+void *board_fdt_blob_setup(void)
+{
+   void *fw_dtb;
+
+   fw_dtb = (void *)(CONFIG_SYS_TEXT_BASE - CONFIG_ENV_SECT_SIZE);
+   if (fdt_magic(fw_dtb) != FDT_MAGIC) {
+   printf("DTB is not passed via %x\n", (u32)fw_dtb);
+   return NULL;
+   }
+
+   return fw_dtb;
+}
+#endif
diff --git a/configs/socrates_defconfig b/configs/socrates_defconfig index
58d135b907..1730d5793b 100644
--- a/configs/socrates_defconfig
+++ b/configs/socrates_defconfig
@@ -3,6 +3,7 @@ CONFIG_SYS_TEXT_BASE=0xfff8  CONFIG_MPC85xx=y
# CONFIG_CMD_ERRATA is not set  CONFIG_TARGET_SOCRATES=y
+# CONFIG_SYS_MALLOC_F is not set
CONFIG_FIT=y
CONFIG_FIT_VERBOSE=y
CONFIG_OF_BOARD_SETUP=y
@@ -15,6 +16,7 @@ CONFIG_BOARD_EARLY_INIT_R=y
CONFIG_HUSH_PARSER=y  CONFIG_CMD_REGINFO=y  CONFIG_CMD_IMLS=y
+CONFIG_CMD_DM=y
CONFIG_CMD_I2C=y
CONFIG_CMD_NAND=y
CONFIG_CMD_PCI=y
@@ -31,7 +33,10 @@ CONFIG_CMD_DATE=y
# CONFIG_CMD_HASH is not set
CONFIG_CMD_EXT2=y
# CONFIG_CMD_IRQ is not set
+CONFIG_OF_CONTROL=y
+CONFIG_DEFAULT_DEVICE_TREE="socrates"
CONFIG_ENV_IS_IN_FLASH=y
+CONFIG_DM=y
# CONFIG_MMC is not set
CONFIG_MTD_NOR_FLASH=y
CONFIG_FLASH_CFI_DRIVER=y
@@ -46,4 +51,3 @@ CONFIG_USB=y
CONFIG_USB_STORAGE=y
CONFIG_VIDEO=y
CONFIG_CONSOLE_EXTRA_INFO=y
-CONFIG_OF_LIBFDT=y
diff --git a/include/configs/socrates.h b/include/configs/socrates.h index
4192148b52..4e10786ed8 100644
--- a/include/configs/socrates.h
+++ b/include/configs/socrates.h
@@ -238,9 +238,10 @@
  * Environment
  */
#define CONFIG_ENV_SECT_SIZE0x2 /* 128K(one sector) for env
*/
-#define CONFIG_ENV_ADDR(CONFIG_SYS_MONITOR_BASE -
CONFIG_ENV_SECT_SIZE)
+#define CONFIG_ENV_ADDR(CONFIG_SYS_MONITOR_BASE - \
+   CONFIG_ENV_SECT_SIZE -
CONFIG_ENV_SECT_SIZE)
#define CONFIG_ENV_SIZE 0x4000
-#define CONFIG_ENV_ADDR_REDUND (CONFIG_ENV_ADDR-
CONFIG_ENV_SECT_SIZE)
+#define CONFIG_ENV_ADDR_REDUND (CONFIG_ENV_ADDR -
CONFIG_ENV_SECT_SIZE)
#define CONFIG_ENV_SIZE_REDUND  (CONFIG_ENV_SIZE)

#define CONFIG_LOADS_ECHO   1   /* echo on for serial download  */
@@ -280,7 +281,7 @@
"bootfile=/home/tftp/syscon3/uImage\0"
\
"fdt_file=/home/tftp/syscon3/socrates.dtb\0"  \
"initrd_file=/home/tftp/syscon3/uinitrd.gz\0" \
-   "uboot_addr=FFFA\0"
\
+   "uboot_addr=FFF6\0"
\
"kernel_addr=FE00\0"  \
"fdt_addr=FE1E\0" \
"ramdisk_addr=FE20\0" \
@@ -303,9 +304,9 @@
"run nfsargs addip addcons;"  \
"bootm ${kernel_addr_r} - ${fdt_addr_r}\0"\
"update_uboot=tftp 10 ${uboot_file};" \
-   "protect off fffa ;"  \
-   "era fffa ;"  \
-   "cp.b 10 fffa ${filesize};"   \
+   "protect off fff6 ;"  \
+   "era fff6 ;"  \
+   "cp.b 10 fff6 ${filesize};"   \
"setenv filesize;saveenv\0"   \
"update_kernel=tftp 10 ${bootfile};"  \
"era fe00 fe1d;"  \
--
2.21.0

__

Travis build error. Please check
https://travis-ci.org/p-priyanka-jain/u-boot-fsl-qoriq/jobs/601663817


I could not open this webpage, I get in my brwoser the error:

We couldn't find the repository
p-priyanka-jain/u-boot-fsl-qoriq



+This board does use CONFIG_LIBATA but has CONFIG_AHCI not
1481
+enabled. Please update the storage controller driver to use
1482
+CONFIG_AHCI before the v2019.07 release.
1483
+Error: arch/powerpc/dts/.socrates.dtb.pre.tmp:235.9-21 syntax error
1484
+FATAL ERROR: Unable to parse input tree
1485
+make[3]: *** [arch/powerpc/dts/socrates.dtb] Error 1
1486
+make[

Re: [U-Boot] [PATCH 3/5] arm: mvebu: Avoid generating kwbimage.cfg in the source tree

2019-10-27 Thread Stefan Roese

On 27.10.19 13:28, Bin Meng wrote:

At present some boards generate kwbimage.cfg in the source tree
during the build. This breaks buildman testing on some systems
where the source tree is read-only. Update makefile rules to
generate it in the build tree instead.

Note some other boards have the kwbimage.cfg file written in
advance, hence we need check if the file exists in the build
tree first, otherwise we fall back to one in the source tree.

Signed-off-by: Bin Meng 


Reviewed-by: Stefan Roese 

Thanks,
Stefan


---

  Makefile | 15 +--
  arch/arm/mach-mvebu/Makefile |  4 ++--
  board/Marvell/db-88f6281-bp/Makefile |  4 ++--
  board/Marvell/db-xc3-24g4xg/Makefile |  4 ++--
  board/mikrotik/crs305-1g-4s/Makefile |  4 ++--
  5 files changed, 21 insertions(+), 10 deletions(-)

diff --git a/Makefile b/Makefile
index e78b317..61b94c5 100644
--- a/Makefile
+++ b/Makefile
@@ -1276,10 +1276,21 @@ endif
  
  MKIMAGEFLAGS_u-boot-dtb.img = $(MKIMAGEFLAGS_u-boot.img)
  
-MKIMAGEFLAGS_u-boot.kwb = -n $(srctree)/$(CONFIG_SYS_KWD_CONFIG:"%"=%) \

+# Some boards have the kwbimage.cfg file written in advance, while some
+# other boards generate it on the fly during the build in the build tree.
+# Let's check if the file exists in the build tree first, otherwise we
+# fall back to use the one in the source tree.
+KWD_CONFIG_FILE = $(shell \
+   if [ -f $(objtree)/$(CONFIG_SYS_KWD_CONFIG:"%"=%) ]; then \
+   echo -n $(objtree)/$(CONFIG_SYS_KWD_CONFIG:"%"=%); \
+   else \
+   echo -n $(srctree)/$(CONFIG_SYS_KWD_CONFIG:"%"=%); \
+   fi)
+
+MKIMAGEFLAGS_u-boot.kwb = -n $(KWD_CONFIG_FILE) \
-T kwbimage -a $(CONFIG_SYS_TEXT_BASE) -e $(CONFIG_SYS_TEXT_BASE)
  
-MKIMAGEFLAGS_u-boot-spl.kwb = -n $(srctree)/$(CONFIG_SYS_KWD_CONFIG:"%"=%) \

+MKIMAGEFLAGS_u-boot-spl.kwb = -n $(KWD_CONFIG_FILE) \
-T kwbimage -a $(CONFIG_SYS_TEXT_BASE) -e $(CONFIG_SYS_TEXT_BASE) \
$(if $(KEYDIR),-k $(KEYDIR))
  
diff --git a/arch/arm/mach-mvebu/Makefile b/arch/arm/mach-mvebu/Makefile

index 8228a17..b739520 100644
--- a/arch/arm/mach-mvebu/Makefile
+++ b/arch/arm/mach-mvebu/Makefile
@@ -58,10 +58,10 @@ KWB_REPLACE += SEC_FUSE_DUMP
  KWB_CFG_SEC_FUSE_DUMP = a38x
  endif
  
-$(src)/kwbimage.cfg: $(src)/kwbimage.cfg.in include/autoconf.mk \

+$(obj)/kwbimage.cfg: $(src)/kwbimage.cfg.in include/autoconf.mk \
include/config/auto.conf
$(Q)sed -ne '$(foreach V,$(KWB_REPLACE),s/^#@$(V)/$(V) 
$(KWB_CFG_$(V))/;)p' \
-   <$< >$(dir $<)$(@F)
+   <$< >$(dir $@)$(@F)
  
  endif # CONFIG_SPL_BUILD

  obj-y += gpio.o
diff --git a/board/Marvell/db-88f6281-bp/Makefile 
b/board/Marvell/db-88f6281-bp/Makefile
index e6aa7e3..003e9f6 100644
--- a/board/Marvell/db-88f6281-bp/Makefile
+++ b/board/Marvell/db-88f6281-bp/Makefile
@@ -4,9 +4,9 @@ obj-y   := db-88f6281-bp.o
  extra-y := kwbimage.cfg
  
  quiet_cmd_sed = SED $@

-  cmd_sed = sed $(SEDFLAGS_$(@F)) $< >$(dir $<)$(@F)
+  cmd_sed = sed $(SEDFLAGS_$(@F)) $< >$(dir $@)$(@F)
  
  SEDFLAGS_kwbimage.cfg = -e "s/^\#@BOOT_FROM.*/BOOT_FROM	$(if $(CONFIG_CMD_NAND),nand,spi)/"

-$(src)/kwbimage.cfg: $(src)/kwbimage.cfg.in include/autoconf.mk \
+$(obj)/kwbimage.cfg: $(src)/kwbimage.cfg.in include/autoconf.mk \
include/config/auto.conf
$(call if_changed,sed)
diff --git a/board/Marvell/db-xc3-24g4xg/Makefile 
b/board/Marvell/db-xc3-24g4xg/Makefile
index 4dd5790..24e8200 100644
--- a/board/Marvell/db-xc3-24g4xg/Makefile
+++ b/board/Marvell/db-xc3-24g4xg/Makefile
@@ -6,9 +6,9 @@ obj-y   := db-xc3-24g4xg.o
  extra-y   := kwbimage.cfg
  
  quiet_cmd_sed = SED $@

-  cmd_sed = sed $(SEDFLAGS_$(@F)) $< >$(dir $<)$(@F)
+  cmd_sed = sed $(SEDFLAGS_$(@F)) $< >$(dir $@)$(@F)
  
  SEDFLAGS_kwbimage.cfg =-e "s|^BINARY.*|BINARY $(srctree)/$(@D)/binary.0 005b 0068|"

-$(src)/kwbimage.cfg: $(src)/kwbimage.cfg.in include/autoconf.mk \
+$(obj)/kwbimage.cfg: $(src)/kwbimage.cfg.in include/autoconf.mk \
include/config/auto.conf
  $(call if_changed,sed)
diff --git a/board/mikrotik/crs305-1g-4s/Makefile 
b/board/mikrotik/crs305-1g-4s/Makefile
index 895331b..c03f534 100644
--- a/board/mikrotik/crs305-1g-4s/Makefile
+++ b/board/mikrotik/crs305-1g-4s/Makefile
@@ -6,9 +6,9 @@ obj-y   := crs305-1g-4s.o
  extra-y   := kwbimage.cfg
  
  quiet_cmd_sed = SED $@

-  cmd_sed = sed $(SEDFLAGS_$(@F)) $< >$(dir $<)$(@F)
+  cmd_sed = sed $(SEDFLAGS_$(@F)) $< >$(dir $@)$(@F)
  
  SEDFLAGS_kwbimage.cfg =-e "s|^BINARY.*|BINARY $(srctree)/$(@D)/binary.0 005b 0068|"

-$(src)/kwbimage.cfg: $(src)/kwbimage.cfg.in include/autoconf.mk \
+$(obj)/kwbimage.cfg: $(src)/kwbimage.cfg.in include/autoconf.mk \
include/config/auto.conf
  $(call if_changed,sed)



Viele Grüße,
Stefan

--
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell

Re: [U-Boot] [PATCH 05/30] wdt: Move code out of the header

2019-10-27 Thread Stefan Roese

On 27.10.19 16:53, Simon Glass wrote:

We should not have C code in a header file. Move it into a shared C file
so it can be used by U-Boot and SPL.

Signed-off-by: Simon Glass 


Reviewed-by: Stefan Roese 

Thanks,
Stefan


---

  common/init/Makefile |  1 +
  common/init/wdt.c| 46 
  include/init.h   |  7 +++
  include/wdt.h| 38 
  4 files changed, 54 insertions(+), 38 deletions(-)
  create mode 100644 common/init/wdt.c

diff --git a/common/init/Makefile b/common/init/Makefile
index 853b56d1e5..a76dedf350 100644
--- a/common/init/Makefile
+++ b/common/init/Makefile
@@ -6,3 +6,4 @@
  
  obj-y += board_init.o

  obj-$(CONFIG_$(SPL_TPL_)HANDOFF) += handoff.o
+obj-$(CONFIG_$(SPL_TPL_)WDT) += wdt.o
diff --git a/common/init/wdt.c b/common/init/wdt.c
new file mode 100644
index 00..79146fb293
--- /dev/null
+++ b/common/init/wdt.c
@@ -0,0 +1,46 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2017 Google, Inc
+ */
+
+#include 
+#include 
+#include 
+
+DECLARE_GLOBAL_DATA_PTR;
+
+#ifndef CONFIG_WATCHDOG_TIMEOUT_MSECS
+#define CONFIG_WATCHDOG_TIMEOUT_MSECS  (60 * 1000)
+#endif
+#define WATCHDOG_TIMEOUT_SECS  (CONFIG_WATCHDOG_TIMEOUT_MSECS / 1000)
+
+int initr_watchdog(void)
+{
+   u32 timeout = WATCHDOG_TIMEOUT_SECS;
+
+   /*
+* Init watchdog: This will call the probe function of the
+* watchdog driver, enabling the use of the device
+*/
+   if (uclass_get_device_by_seq(UCLASS_WDT, 0,
+(struct udevice **)&gd->watchdog_dev)) {
+   debug("WDT:   Not found by seq!\n");
+   if (uclass_get_device(UCLASS_WDT, 0,
+ (struct udevice **)&gd->watchdog_dev)) {
+   printf("WDT:   Not found!\n");
+   return 0;
+   }
+   }
+
+   if (CONFIG_IS_ENABLED(OF_CONTROL)) {
+   timeout = dev_read_u32_default(gd->watchdog_dev, "timeout-sec",
+  WATCHDOG_TIMEOUT_SECS);
+   }
+
+   wdt_start(gd->watchdog_dev, timeout * 1000, 0);
+   gd->flags |= GD_FLG_WDT_READY;
+   printf("WDT:   Started with%s servicing (%ds timeout)\n",
+  IS_ENABLED(CONFIG_WATCHDOG) ? "" : "out", timeout);
+
+   return 0;
+}
diff --git a/include/init.h b/include/init.h
index afc953d51e..3e5857f07f 100644
--- a/include/init.h
+++ b/include/init.h
@@ -181,6 +181,13 @@ int init_func_vid(void);
  int checkboard(void);
  int show_board_info(void);
  
+/**

+ * initr_watchdog() - Init the watchdog
+ *
+ * @return 0 if OK, -ve on error
+ */
+int initr_watchdog(void);
+
  #endif/* __ASSEMBLY__ */
  /* Put only stuff here that the assembler can digest */
  
diff --git a/include/wdt.h b/include/wdt.h

index 5bcff24ab3..5698605c02 100644
--- a/include/wdt.h
+++ b/include/wdt.h
@@ -106,42 +106,4 @@ struct wdt_ops {
int (*expire_now)(struct udevice *dev, ulong flags);
  };
  
-#if CONFIG_IS_ENABLED(WDT)

-#ifndef CONFIG_WATCHDOG_TIMEOUT_MSECS
-#define CONFIG_WATCHDOG_TIMEOUT_MSECS  (60 * 1000)
-#endif
-#define WATCHDOG_TIMEOUT_SECS  (CONFIG_WATCHDOG_TIMEOUT_MSECS / 1000)
-
-static inline int initr_watchdog(void)
-{
-   u32 timeout = WATCHDOG_TIMEOUT_SECS;
-
-   /*
-* Init watchdog: This will call the probe function of the
-* watchdog driver, enabling the use of the device
-*/
-   if (uclass_get_device_by_seq(UCLASS_WDT, 0,
-(struct udevice **)&gd->watchdog_dev)) {
-   debug("WDT:   Not found by seq!\n");
-   if (uclass_get_device(UCLASS_WDT, 0,
- (struct udevice **)&gd->watchdog_dev)) {
-   printf("WDT:   Not found!\n");
-   return 0;
-   }
-   }
-
-   if (CONFIG_IS_ENABLED(OF_CONTROL)) {
-   timeout = dev_read_u32_default(gd->watchdog_dev, "timeout-sec",
-  WATCHDOG_TIMEOUT_SECS);
-   }
-
-   wdt_start(gd->watchdog_dev, timeout * 1000, 0);
-   gd->flags |= GD_FLG_WDT_READY;
-   printf("WDT:   Started with%s servicing (%ds timeout)\n",
-  IS_ENABLED(CONFIG_WATCHDOG) ? "" : "out", timeout);
-
-   return 0;
-}
-#endif
-
  #endif  /* _WDT_H_ */



Viele Grüße,
Stefan

--
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: s...@denx.de
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 06/30] wdt: Drop dm.h header file

2019-10-27 Thread Stefan Roese

On 27.10.19 16:53, Simon Glass wrote:

This header file should not be included in other header files. Remove it
and use a forward declaration instead.

Signed-off-by: Simon Glass 
---

  include/wdt.h | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/include/wdt.h b/include/wdt.h
index 5698605c02..62f4b34c30 100644
--- a/include/wdt.h
+++ b/include/wdt.h
@@ -6,8 +6,7 @@
  #ifndef _WDT_H_
  #define _WDT_H_
  
-#include 

-#include 
+struct udevice;


I'm not a big fan of forward declarations. But if this helps with
overall cleanup and compile speed:

Reviewed-by: Stefan Roese 

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


Re: [U-Boot] [PATCH v2 4/9] mpc85xx, socrates: add DM support

2019-10-27 Thread Heiko Schocher



Am 28.10.2019 um 06:02 schrieb Heiko Schocher:

Hello Priyanka Jain,

Am 23.10.2019 um 13:18 schrieb Priyanka Jain:




-Original Message-
From: U-Boot  On Behalf Of Heiko Schocher
Sent: Wednesday, October 16, 2019 9:26 AM
To: U-Boot Mailing List 
Subject: [U-Boot] [PATCH v2 4/9] mpc85xx, socrates: add DM support

enable CONFIG_DM for the socrates board.

Signed-off-by: Heiko Schocher 
---

Changes in v2: None

board/socrates/socrates.c  | 15 +++  configs/socrates_defconfig
|  6 +-  include/configs/socrates.h | 13 +++--
3 files changed, 27 insertions(+), 7 deletions(-)

diff --git a/board/socrates/socrates.c b/board/socrates/socrates.c index
da9ae5bebb..8f9583360b 100644
--- a/board/socrates/socrates.c
+++ b/board/socrates/socrates.c
@@ -432,3 +432,18 @@ void video_get_info_str (int line_number, char *info)
}
}
#endif
+
+#if defined(CONFIG_OF_SEPARATE)
+void *board_fdt_blob_setup(void)
+{
+    void *fw_dtb;
+
+    fw_dtb = (void *)(CONFIG_SYS_TEXT_BASE - CONFIG_ENV_SECT_SIZE);
+    if (fdt_magic(fw_dtb) != FDT_MAGIC) {
+    printf("DTB is not passed via %x\n", (u32)fw_dtb);
+    return NULL;
+    }
+
+    return fw_dtb;
+}
+#endif
diff --git a/configs/socrates_defconfig b/configs/socrates_defconfig index
58d135b907..1730d5793b 100644
--- a/configs/socrates_defconfig
+++ b/configs/socrates_defconfig
@@ -3,6 +3,7 @@ CONFIG_SYS_TEXT_BASE=0xfff8  CONFIG_MPC85xx=y
# CONFIG_CMD_ERRATA is not set  CONFIG_TARGET_SOCRATES=y
+# CONFIG_SYS_MALLOC_F is not set
CONFIG_FIT=y
CONFIG_FIT_VERBOSE=y
CONFIG_OF_BOARD_SETUP=y
@@ -15,6 +16,7 @@ CONFIG_BOARD_EARLY_INIT_R=y
CONFIG_HUSH_PARSER=y  CONFIG_CMD_REGINFO=y  CONFIG_CMD_IMLS=y
+CONFIG_CMD_DM=y
CONFIG_CMD_I2C=y
CONFIG_CMD_NAND=y
CONFIG_CMD_PCI=y
@@ -31,7 +33,10 @@ CONFIG_CMD_DATE=y
# CONFIG_CMD_HASH is not set
CONFIG_CMD_EXT2=y
# CONFIG_CMD_IRQ is not set
+CONFIG_OF_CONTROL=y
+CONFIG_DEFAULT_DEVICE_TREE="socrates"
CONFIG_ENV_IS_IN_FLASH=y
+CONFIG_DM=y
# CONFIG_MMC is not set
CONFIG_MTD_NOR_FLASH=y
CONFIG_FLASH_CFI_DRIVER=y
@@ -46,4 +51,3 @@ CONFIG_USB=y
CONFIG_USB_STORAGE=y
CONFIG_VIDEO=y
CONFIG_CONSOLE_EXTRA_INFO=y
-CONFIG_OF_LIBFDT=y
diff --git a/include/configs/socrates.h b/include/configs/socrates.h index
4192148b52..4e10786ed8 100644
--- a/include/configs/socrates.h
+++ b/include/configs/socrates.h
@@ -238,9 +238,10 @@
  * Environment
  */
#define CONFIG_ENV_SECT_SIZE    0x2 /* 128K(one sector) for env
*/
-#define CONFIG_ENV_ADDR    (CONFIG_SYS_MONITOR_BASE -
CONFIG_ENV_SECT_SIZE)
+#define CONFIG_ENV_ADDR    (CONFIG_SYS_MONITOR_BASE - \
+    CONFIG_ENV_SECT_SIZE -
CONFIG_ENV_SECT_SIZE)
#define CONFIG_ENV_SIZE    0x4000
-#define CONFIG_ENV_ADDR_REDUND    (CONFIG_ENV_ADDR-
CONFIG_ENV_SECT_SIZE)
+#define CONFIG_ENV_ADDR_REDUND    (CONFIG_ENV_ADDR -
CONFIG_ENV_SECT_SIZE)
#define CONFIG_ENV_SIZE_REDUND    (CONFIG_ENV_SIZE)

#define CONFIG_LOADS_ECHO    1    /* echo on for serial download    */
@@ -280,7 +281,7 @@
"bootfile=/home/tftp/syscon3/uImage\0"
\
"fdt_file=/home/tftp/syscon3/socrates.dtb\0"    \
"initrd_file=/home/tftp/syscon3/uinitrd.gz\0"    \
-    "uboot_addr=FFFA\0"
\
+    "uboot_addr=FFF6\0"
\
"kernel_addr=FE00\0"    \
"fdt_addr=FE1E\0"    \
"ramdisk_addr=FE20\0"    \
@@ -303,9 +304,9 @@
    "run nfsargs addip addcons;"    \
    "bootm ${kernel_addr_r} - ${fdt_addr_r}\0"    \
"update_uboot=tftp 10 ${uboot_file};"    \
-    "protect off fffa ;"    \
-    "era fffa ;"    \
-    "cp.b 10 fffa ${filesize};"    \
+    "protect off fff6 ;"    \
+    "era fff6 ;"    \
+    "cp.b 10 fff6 ${filesize};"    \
    "setenv filesize;saveenv\0"    \
"update_kernel=tftp 10 ${bootfile};"    \
    "era fe00 fe1d;"    \
--
2.21.0

__

Travis build error. Please check
https://travis-ci.org/p-priyanka-jain/u-boot-fsl-qoriq/jobs/601663817


I could not open this webpage, I get in my brwoser the error:

We couldn't find the repository
p-priyanka-jain/u-boot-fsl-qoriq



+This board does use CONFIG_LIBATA but has CONFIG_AHCI not
1481
+enabled. Please update the storage controller driver to use
1482
+CONFIG_AHCI before the v2019.07 release.
1483
+Error: arch/powerpc/dts/.socrates.dtb.pre.tmp:235.9-21 syntax error
1484
+FATAL ERROR: Unable to parse input tree
1485
+make[3]: *** [arch/powerpc/dts/socrates.dtb] Error 1
1486
+make[2]: *** [arch-dtbs] Error 2
1487
+make[1]: *** [dts/dt.dtb] Error 2
1488
+make: *** [sub-make] Error 2
1489

--priyankajain


Hmm, I did a travis buld before posting, see:
https://travis-ci.org/hsdenx/u-boot-test/builds/597488733

Based on which tree, had you applied the patches?


rebased tree on current mainline master

Re: [U-Boot] [EXT] Re: [RFC/RESEND 01/22] arm: introduce ARCH_THUNDERX

2019-10-27 Thread Suneel Garapati
Hi Matthias,

Thanks for your patience. Sorry for the delay.

I will post the patch-set tomorrow.

Regards,
Suneel

On Fri, Sep 27, 2019 at 01:59 Matthias Brugger  wrote:

> Hi Suneel,
>
> On 04/09/2019 08:03, Suneel Garapati wrote:
> > Hi Matthias,
> >
> > Thank you for your concern. I picked up things last week. So will post
> > by this weekend.
> > Apologies for the delay.
>
> Any update on this? It's a long time since you said you want to provide the
> patches, is there anything I can help you with?
> I have access to the HW, if you want me to test code etc.
>
> Regards,
> Matthias
>
> >
> > Regards,
> > Suneel
> >
> > On Mon, Sep 2, 2019 at 7:19 AM Matthias Brugger 
> wrote:
> >>
> >> Hi Suneel,
> >>
> >> On 27/08/2019 02:59, Chandrakala Chavva wrote:
> >>> Tim,
> >>>
> >>> It was scheduled to post the patches on August 15th, it got delayed as
> Suneel got sick, he will post in 2 weeks.
> >>>
> >>
> >> Hope you are fine again. Do you have an update about the patches?
> >>
> >> Best regards,
> >> Matthias
> >>
> >>> Chandra
> >>> 
> >>> From: Tim Harvey 
> >>> Sent: Monday, August 26, 2019 10:54:34 AM
> >>> To: Suneel Garapati 
> >>> Cc: Matthias Brugger ; Chandrakala Chavva <
> ccha...@marvell.com>; prasun.kap...@cavium.com ;
> Sergey Temerkhanov ; u-boot ;
> chandrakala.cha...@cavium.com ; Zi Shen
> Lim ; Maen Suleiman ; Aaron Williams
> ; Chris Packham 
> >>> Subject: [EXT] Re: [U-Boot] [RFC/RESEND 01/22] arm: introduce
> ARCH_THUNDERX
> >>>
> >>> External Email
> >>>
> >>> --
> >>> On Wed, Jul 31, 2019 at 5:32 PM Suneel Garapati <
> suneelgli...@gmail.com> wrote:
> 
>  Hi Matthias,
> 
>  Hard deadline is Aug 15th, so you should see first series before that.
> 
> >>>
> >>> Suneel,
> >>>
> >>> Update? I'm really wishing my patches posted last March were
> >>> considered instead of all of this waiting.
> >>>
> >>> Regards,
> >>>
> >>> Tim
> >>> ___
> >>> 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
> >
>
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v3 012/108] spl: Correct priority selection for image loaders

2019-10-27 Thread Bin Meng
On Mon, Oct 21, 2019 at 11:33 AM Simon Glass  wrote:
>
> At present the name of the image comes first in the linker-list symbol
> used. This means that the name of the function sets the sort order, which
> is not the intention.
>
> Update it to put the boot-device type first, then the priority. This
> produces the expected behaviour.
>
> Signed-off-by: Simon Glass 
> ---
>
> Changes in v3: None
> Changes in v2:
> - s/board device/boot device/
>
>  include/spl.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>

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


Re: [U-Boot] [PATCH v3 011/108] i2c: Tidy up designware PCI support

2019-10-27 Thread Bin Meng
+Stefan

Hi Simon,

On Mon, Oct 21, 2019 at 11:33 AM Simon Glass  wrote:
>
> This is hacked into the driver at present. It seems better to have it as
> a separate driver that uses the base driver. Create a new file and put
> the X86 code into it.
>
> Actually the Baytrail settings should really come from the device tree.
>
> Signed-off-by: Simon Glass 
> ---
>
> Changes in v3: None
> Changes in v2: None
>
>  drivers/i2c/Makefile |   3 +
>  drivers/i2c/designware_i2c.c | 104 ++-
>  drivers/i2c/designware_i2c.h |  35 
>  drivers/i2c/dw_i2c_pci.c |  78 ++
>  4 files changed, 132 insertions(+), 88 deletions(-)
>  create mode 100644 drivers/i2c/dw_i2c_pci.c
>
> diff --git a/drivers/i2c/Makefile b/drivers/i2c/Makefile
> index c2f75d87559..a7fa38b8dcf 100644
> --- a/drivers/i2c/Makefile
> +++ b/drivers/i2c/Makefile
> @@ -14,6 +14,9 @@ obj-$(CONFIG_SYS_I2C_AT91) += at91_i2c.o
>  obj-$(CONFIG_SYS_I2C_CADENCE) += i2c-cdns.o
>  obj-$(CONFIG_SYS_I2C_DAVINCI) += davinci_i2c.o
>  obj-$(CONFIG_SYS_I2C_DW) += designware_i2c.o
> +ifdef CONFIG_DM_PCI
> +obj-$(CONFIG_SYS_I2C_DW) += dw_i2c_pci.o

nits: designware_i2c_pci.o for consistency?

> +endif
>  obj-$(CONFIG_SYS_I2C_FSL) += fsl_i2c.o
>  obj-$(CONFIG_SYS_I2C_IHS) += ihs_i2c.o
>  obj-$(CONFIG_SYS_I2C_INTEL) += intel_i2c.o
> diff --git a/drivers/i2c/designware_i2c.c b/drivers/i2c/designware_i2c.c
> index 6daa90e7442..54e4a70c74c 100644
> --- a/drivers/i2c/designware_i2c.c
> +++ b/drivers/i2c/designware_i2c.c
> @@ -13,34 +13,6 @@
>  #include 
>  #include "designware_i2c.h"
>
> -struct dw_scl_sda_cfg {
> -   u32 ss_hcnt;
> -   u32 fs_hcnt;
> -   u32 ss_lcnt;
> -   u32 fs_lcnt;
> -   u32 sda_hold;
> -};
> -
> -#ifdef CONFIG_X86
> -/* BayTrail HCNT/LCNT/SDA hold time */
> -static struct dw_scl_sda_cfg byt_config = {
> -   .ss_hcnt = 0x200,
> -   .fs_hcnt = 0x55,
> -   .ss_lcnt = 0x200,
> -   .fs_lcnt = 0x99,
> -   .sda_hold = 0x6,
> -};
> -#endif
> -
> -struct dw_i2c {
> -   struct i2c_regs *regs;
> -   struct dw_scl_sda_cfg *scl_sda_cfg;
> -   struct reset_ctl_bulk resets;
> -#if CONFIG_IS_ENABLED(CLK)
> -   struct clk clk;
> -#endif
> -};
> -
>  #ifdef CONFIG_SYS_I2C_DW_ENABLE_STATUS_UNSUPPORTED
>  static int  dw_i2c_enable(struct i2c_regs *i2c_base, bool enable)
>  {
> @@ -90,7 +62,8 @@ static unsigned int __dw_i2c_set_bus_speed(struct i2c_regs 
> *i2c_base,
> unsigned int ena;
> int i2c_spd;
>
> -   if (speed >= I2C_MAX_SPEED)
> +   if (speed >= I2C_MAX_SPEED &&
> +   (!scl_sda_cfg || scl_sda_cfg->has_max_speed))

I think the logic should be && not ||

And I don't see scl_sda_cfg->has_max_speed in the original driver. Is
this new functionality?

> i2c_spd = IC_SPEED_MODE_MAX;
> else if (speed >= I2C_FAST_SPEED)
> i2c_spd = IC_SPEED_MODE_FAST;
> @@ -106,7 +79,6 @@ static unsigned int __dw_i2c_set_bus_speed(struct i2c_regs 
> *i2c_base,
> cntl = (readl(&i2c_base->ic_con) & (~IC_CON_SPD_MSK));
>
> switch (i2c_spd) {
> -#ifndef CONFIG_X86 /* No High-speed for BayTrail yet */
> case IC_SPEED_MODE_MAX:
> cntl |= IC_CON_SPD_SS;
> if (scl_sda_cfg) {
> @@ -119,7 +91,6 @@ static unsigned int __dw_i2c_set_bus_speed(struct i2c_regs 
> *i2c_base,
> writel(hcnt, &i2c_base->ic_hs_scl_hcnt);
> writel(lcnt, &i2c_base->ic_hs_scl_lcnt);
> break;
> -#endif
>
> case IC_SPEED_MODE_STANDARD:
> cntl |= IC_CON_SPD_SS;
> @@ -565,24 +536,20 @@ static int designware_i2c_probe_chip(struct udevice 
> *bus, uint chip_addr,
> return ret;
>  }
>
> -static int designware_i2c_probe(struct udevice *bus)
> +static int designware_i2c_ofdata_to_platdata(struct udevice *bus)
>  {
> struct dw_i2c *priv = dev_get_priv(bus);
> -   int ret;
>
> -   if (device_is_on_pci_bus(bus)) {
> -#ifdef CONFIG_DM_PCI
> -   /* Save base address from PCI BAR */
> -   priv->regs = (struct i2c_regs *)
> -   dm_pci_map_bar(bus, PCI_BASE_ADDRESS_0, 
> PCI_REGION_MEM);
> -#ifdef CONFIG_X86
> -   /* Use BayTrail specific timing values */
> -   priv->scl_sda_cfg = &byt_config;
> -#endif
> -#endif
> -   } else {
> -   priv->regs = (struct i2c_regs *)devfdt_get_addr_ptr(bus);
> -   }
> +   printf("bad\n");

What's this?

> +   priv->regs = (struct i2c_regs *)devfdt_get_addr_ptr(bus);
> +
> +   return 0;
> +}
> +
> +int designware_i2c_probe(struct udevice *bus)
> +{
> +   struct dw_i2c *priv = dev_get_priv(bus);
> +   int ret;
>
> ret = reset_get_bulk(bus, &priv->resets);
> if (ret)
> @@ -606,7 +573,7 @@ static int designware_i2c_probe(struct udevice *bus)
> return __dw_i2c_init(priv->regs, 0, 0);
>  }
>
> -static int designware_i2c_remove(struct udevice *d

Re: [U-Boot] [PATCH v3 015/108] dm: doc: Correct of-platdata driver name

2019-10-27 Thread Bin Meng
On Mon, Oct 21, 2019 at 11:33 AM Simon Glass  wrote:
>
> Add a note about the driver name in the of-platdata documentation since
> the naming must follow the compatible string.
>
> Signed-off-by: Simon Glass 
> ---
>
> Changes in v3:
> - Rework patch now that the original CONFIG_IS_ENABLED() problems is fixed
>
> Changes in v2: None
>
>  doc/driver-model/of-plat.rst | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>

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


Re: [U-Boot] [PATCH v3 018/108] Revert "RFC: sandbox: net: Suppress the MAC-address warnings"

2019-10-27 Thread Bin Meng
Hi Simon,

On Mon, Oct 21, 2019 at 11:33 AM Simon Glass  wrote:
>
> This reverts commit 96ac4def8b6686de8566b91419ce98cd5765079b.
>
> Signed-off-by: Simon Glass 
> ---
>
> Changes in v3: None
> Changes in v2: None
>
>  arch/sandbox/cpu/state.c | 12 ++--
>  arch/sandbox/include/asm/state.h |  5 +
>  cmd/nvedit.c |  8 
>  include/configs/sandbox.h|  7 +--
>  include/env.h| 12 
>  net/eth-uclass.c | 11 ++-
>  test/dm/test-main.c  |  2 +-
>  7 files changed, 11 insertions(+), 46 deletions(-)
>

I don't understand the revert. Is this because the previous patch will
break the following patches in this series?

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


Re: [U-Boot] [PATCH v3 019/108] spl: Add a size check for TPL

2019-10-27 Thread Bin Meng
On Mon, Oct 21, 2019 at 11:33 AM Simon Glass  wrote:
>
> We have the ability to enforce a maximum size for SPL but not yet for TPL.
> Add a new option for this.
>
> Document the size check macro while we are here.
>
> Signed-off-by: Simon Glass 
> ---
>
> Changes in v3: None
> Changes in v2: None
>
>  Makefile   | 7 +++
>  common/spl/Kconfig | 8 
>  2 files changed, 15 insertions(+)
>

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


  1   2   >