[PATCH v2] doc: board: bcm7xxx: Convert to reStructuredText format

2023-02-13 Thread Thomas Fitzsimmons
ple, it can be dumped from within
-* U-Boot (at ${fdtcontroladdr}), after BOLT
-* has loaded U-Boot.  The result can be added
-* to the Linux source tree as a .dts file.
-*
-* To support modifications to the device tree
-* in-place in U-Boot, add to Linux's
-* arch/arm/boot/dts/Makefile:
-*
-* DTC_FLAGS ?= -p 4096
-*
-* This will leave some padding in the DTB and
-* thus reserve room for node additions.
-*
-* Also, set the environment variable fdt_high
-* to 0x to keep the DTB in-place and
-* to accommodate stblinux bmem/CMA
-* reservations.
-*/
-   data = /incbin/(".dtb");
-   type = "flat_dt";
-   arch = "arm";
-   compression = "none";
-   hash@1 {
-   algo = "sha256";
-   };
-   };
-   };
-   configurations {
-   default = "conf@bcm7445";
-   conf@bcm7445 {
-   description = "BCM7445 configuration";
-   kernel = "kernel@1";
-   ramdisk = "ramdisk@1";
-       fdt = "fdt@1";
-   };
-   };
-};
diff --git a/doc/board/broadcom/bcm7xxx.rst b/doc/board/broadcom/bcm7xxx.rst
new file mode 100644
index 00..f1994d9f97
--- /dev/null
+++ b/doc/board/broadcom/bcm7xxx.rst
@@ -0,0 +1,183 @@
+.. SPDX-License-Identifier: GPL-2.0+
+.. Copyright (C) 2018, 2023 Thomas Fitzsimmons 
+
+BCM7445 and BCM7260
+===
+
+This document describes how to use U-Boot on the Broadcom 7445 and
+Broadcom 7260 SoC, as a third stage bootloader loaded by Broadcom's
+BOLT bootloader.
+
+BOLT loads U-Boot as a generic ELF binary.  Some U-Boot features such
+as networking are not implemented but other important features are,
+including:
+
+* ext4 file system traversal
+* support for loading FIT images
+* advanced scripting
+* support for FIT-provided DTBs instead of relying on the BOLT-provided DTB
+
+A customized version of this port has been used in production.  The
+same approach may work on other BCM7xxx boards, with some
+configuration adjustments and memory layout experimentation.
+
+Configure
+-
+
+BCM7445
+^^^
+
+.. code-block:: console
+
+   $ make bcm7445_defconfig
+
+BCM7260
+^^^
+
+.. code-block:: console
+
+   $ make bcm7260_defconfig
+
+Build
+-
+
+.. code-block:: console
+
+   $ make
+   $ ${CROSS_COMPILE}strip u-boot
+
+Run
+---
+
+To tell U-Boot which serial port to use for its console, set the
+``stdout-path`` property in the ``/chosen`` node of the BOLT-generated
+device tree.  For example:
+
+::
+
+   BOLT> dt add prop chosen stdout-path s serial0:115200n8
+
+Flash the ``u-boot`` binary into board storage, then invoke it from
+BOLT.  For example:
+
+::
+
+   BOLT> boot -bsu -elf flash0.u-boot1
+
+This port assumes that I-cache and D-cache are already enabled when
+U-Boot is entered.
+
+Flattened Image Tree Support
+
+
+What follows is an example FIT image source file.  Build it with:
+
+.. code-block:: console
+
+   $ mkimage -f image.its image.itb
+
+Booting the resulting ``image.itb`` was tested on BOLT v1.20, with the
+following kernels:
+
+* https://github.com/Broadcom/stblinux-3.14
+* https://github.com/Broadcom/stblinux-4.1
+* https://github.com/Broadcom/stblinux-4.9
+
+and with a generic ARMv7 root file system.
+
+**image.its**
+
+::
+
+   /dts-v1/;
+   / {
+   description = "BCM7445 FIT";
+   images {
+   kernel@1 {
+   description = "Linux kernel";
+   /*
+* This kernel image output format can be
+* generated with:
+*
+* make vmlinux
+* ${CROSS_COMPILE}objcopy -O binary -S vmlinux 
vmlinux.bin
+* gzip -9 vmlinux.bin
+*
+* For stblinux-3.14, the specific Broadcom
+* board type should be configured in the
+* kernel, for example CONFIG_BCM7445D0=y.
+*/
+   data = /incbin/("");
+

[PATCH] doc: board: bcm7xxx: Convert to reStructuredText format

2023-02-11 Thread Thomas Fitzsimmons
, after BOLT
-* has loaded U-Boot.  The result can be added
-* to the Linux source tree as a .dts file.
-*
-* To support modifications to the device tree
-* in-place in U-Boot, add to Linux's
-* arch/arm/boot/dts/Makefile:
-*
-* DTC_FLAGS ?= -p 4096
-*
-* This will leave some padding in the DTB and
-* thus reserve room for node additions.
-*
-* Also, set the environment variable fdt_high
-* to 0x to keep the DTB in-place and
-* to accommodate stblinux bmem/CMA
-* reservations.
-*/
-   data = /incbin/(".dtb");
-   type = "flat_dt";
-   arch = "arm";
-   compression = "none";
-   hash@1 {
-   algo = "sha256";
-   };
-   };
-   };
-   configurations {
-   default = "conf@bcm7445";
-   conf@bcm7445 {
-   description = "BCM7445 configuration";
-   kernel = "kernel@1";
-   ramdisk = "ramdisk@1";
-       fdt = "fdt@1";
-   };
-   };
-};
diff --git a/doc/board/broadcom/bcm7xxx.rst b/doc/board/broadcom/bcm7xxx.rst
new file mode 100644
index 00..6231431a67
--- /dev/null
+++ b/doc/board/broadcom/bcm7xxx.rst
@@ -0,0 +1,186 @@
+.. SPDX-License-Identifier: GPL-2.0+
+.. Copyright (C) 2018, 2023 Thomas Fitzsimmons 
+
+BCM7445 and BCM7260
+===
+
+About this
+--
+
+This document describes how to use U-Boot on the Broadcom 7445 and
+Broadcom 7260 SoC, as a third stage bootloader loaded by Broadcom's
+BOLT bootloader.
+
+BOLT loads U-Boot as a generic ELF binary.  Some U-Boot features such
+as networking are not implemented but other important features are,
+including:
+
+* ext4 file system traversal
+* support for loading FIT images
+* advanced scripting
+* support for FIT-provided DTBs instead of relying on the BOLT-provided DTB
+
+A customized version of this port has been used in production.  The
+same approach may work on other BCM7xxx boards, with some
+configuration adjustments and memory layout experimentation.
+
+Configure
+-
+
+BCM7445
+^^^
+
+.. code-block:: console
+
+   $ make bcm7445_defconfig
+
+BCM7260
+^^^
+
+.. code-block:: console
+
+   $ make bcm7260_defconfig
+
+Build
+-
+
+.. code-block:: console
+
+   $ make
+   $ ${CROSS_COMPILE}strip u-boot
+
+Run
+---
+
+To tell U-Boot which serial port to use for its console, set the
+``stdout-path`` property in the ``/chosen`` node of the BOLT-generated
+device tree.  For example:
+
+::
+
+   BOLT> dt add prop chosen stdout-path s serial0:115200n8
+
+Flash the ``u-boot`` binary into board storage, then invoke it from
+BOLT.  For example:
+
+::
+
+   BOLT> boot -bsu -elf flash0.u-boot1
+
+This port assumes that I-cache and D-cache are already enabled when
+U-Boot is entered.
+
+Flattened Image Tree Support
+
+
+What follows is an example FIT image source file.  Build it with:
+
+.. code-block:: console
+
+   $ mkimage -f image.its image.itb
+
+Booting the resulting ``image.itb`` was tested on BOLT v1.20, with the
+following kernels:
+
+* https://github.com/Broadcom/stblinux-3.14
+* https://github.com/Broadcom/stblinux-4.1
+* https://github.com/Broadcom/stblinux-4.9
+
+and with a generic ARMv7 root file system.
+
+**image.its**
+
+::
+
+   /dts-v1/;
+   / {
+   description = "BCM7445 FIT";
+   images {
+   kernel@1 {
+   description = "Linux kernel";
+   /*
+* This kernel image output format can be
+* generated with:
+*
+* make vmlinux
+* ${CROSS_COMPILE}objcopy -O binary -S vmlinux 
vmlinux.bin
+* gzip -9 vmlinux.bin
+*
+* For stblinux-3.14, the specific Broadcom
+* board type should be configured in the
+* kernel, for example CONFIG_BCM7445D0=y.
+*/
+   data = /incbin/("");
+  

[PATCH] arm: bcm7xxx: Convert to DM_SERIAL

2023-02-05 Thread Thomas Fitzsimmons
Remove ns16550 configuration from header files.  Document
DM_SERIAL-required prior stage device tree configuration.
---
 configs/bcm7260_defconfig |  4 ++--
 configs/bcm7445_defconfig |  4 ++--
 doc/README.bcm7xxx|  6 ++
 include/configs/bcm7260.h |  2 --
 include/configs/bcm7445.h |  2 --
 include/configs/bcmstb.h  | 13 -
 6 files changed, 10 insertions(+), 21 deletions(-)

diff --git a/configs/bcm7260_defconfig b/configs/bcm7260_defconfig
index f8e0327d8f..51e0a5ddd7 100644
--- a/configs/bcm7260_defconfig
+++ b/configs/bcm7260_defconfig
@@ -40,6 +40,6 @@ CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_MMC_SDHCI=y
 CONFIG_MMC_SDHCI_BCMSTB=y
 CONFIG_MTD=y
-CONFIG_SYS_NS16550_SERIAL=y
-CONFIG_SYS_NS16550_REG_SIZE=-4
+CONFIG_DM_SERIAL=y
+CONFIG_SYS_NS16550=y
 # CONFIG_EFI_LOADER is not set
diff --git a/configs/bcm7445_defconfig b/configs/bcm7445_defconfig
index 81433b02cb..f5f1e8d397 100644
--- a/configs/bcm7445_defconfig
+++ b/configs/bcm7445_defconfig
@@ -44,8 +44,8 @@ CONFIG_MTD=y
 CONFIG_DM_SPI_FLASH=y
 CONFIG_SPI_FLASH_MACRONIX=y
 CONFIG_SPI_FLASH_STMICRO=y
-CONFIG_SYS_NS16550_SERIAL=y
-CONFIG_SYS_NS16550_REG_SIZE=-4
+CONFIG_DM_SERIAL=y
+CONFIG_SYS_NS16550=y
 CONFIG_SPI=y
 CONFIG_DM_SPI=y
 CONFIG_BCMSTB_SPI=y
diff --git a/doc/README.bcm7xxx b/doc/README.bcm7xxx
index 9b5eae4741..6839da5f97 100644
--- a/doc/README.bcm7xxx
+++ b/doc/README.bcm7xxx
@@ -31,6 +31,12 @@ ${CROSS_COMPILE}strip u-boot
 Run
 ===
 
+To tell U-Boot which serial port to use for its console, set the
+"stdout-path" property in the "/chosen" node of the BOLT-generated
+device tree.  For example:
+
+BOLT> dt add prop chosen stdout-path s serial0:115200n8
+
 Flash the u-boot binary into board storage, then invoke it from BOLT.
 For example:
 
diff --git a/include/configs/bcm7260.h b/include/configs/bcm7260.h
index 43edc91b10..dbe545c175 100644
--- a/include/configs/bcm7260.h
+++ b/include/configs/bcm7260.h
@@ -10,8 +10,6 @@
 #ifndef __CONFIG_H
 #define __CONFIG_H
 
-#define CFG_SYS_NS16550_COM1   0xf040c000
-
 #define CFG_SYS_INIT_RAM_ADDR  0x1020
 
 #include "bcmstb.h"
diff --git a/include/configs/bcm7445.h b/include/configs/bcm7445.h
index 114337294e..b59048d175 100644
--- a/include/configs/bcm7445.h
+++ b/include/configs/bcm7445.h
@@ -10,8 +10,6 @@
 #ifndef __CONFIG_H
 #define __CONFIG_H
 
-#define CFG_SYS_NS16550_COM1   0xf040ab00
-
 #define CFG_SYS_INIT_RAM_ADDR  0x8020
 
 #include "bcmstb.h"
diff --git a/include/configs/bcmstb.h b/include/configs/bcmstb.h
index d1de3561af..c9280927b3 100644
--- a/include/configs/bcmstb.h
+++ b/include/configs/bcmstb.h
@@ -92,19 +92,6 @@ extern phys_addr_t prior_stage_fdt_address;
  * Large kernel image bootm configuration.
  */
 
-/*
- * NS16550 configuration.
- */
-#define V_NS16550_CLK  8100
-
-#define CFG_SYS_NS16550_CLKV_NS16550_CLK
-
-/*
- * Serial console configuration.
- */
-#define CFG_SYS_BAUDRATE_TABLE {4800, 9600, 19200, 38400, 57600, \
-115200}
-
 /*
  * Informational display configuration.
  */
-- 
2.33.1



Re: [PATCH 1/1 RFC] treewide: Deprecate OF_PRIOR_STAGE

2021-10-15 Thread Thomas Fitzsimmons
Hi Tom,

Tom Rini  writes:

> On Wed, Oct 13, 2021 at 01:36:00PM -0400, Thomas Fitzsimmons wrote:
>> Simon Glass  writes:
>> 
>> [...]
>> 
>> > On Wed, 13 Oct 2021 at 10:26, Thomas Fitzsimmons  
>> > wrote:
>> >>
>> >> Simon Glass  writes:
>> >>
>> >> [...]
>> >>
>> >> >> > I think one option is better than two. I have a slight preference for
>> >> >> > OF_PRIOR_STAGE because it is board-agnostic, but I'm not sure it
>> >> >> > matters, since some of these boards are doing strange things anyway
>> >> >> > and cannot use OF_PRIOR_STAGE. So let's go with this.
>> >> >>
>> >> >> For now it's easier getting rid of OF_PRIOR_STAGE than OF_BOARD.
>> >> >> Once we unify OF_PRIOR_STAGE/OF_BOARD and OF_HOSTFILE, then
>> >> >> I can send a patch on top of that, which removes the 
>> >> >> board_fdt_blob_setup()
>> >> >> and just stores the address in a similar fashion to the removed
>> >> >> 'prior_stage_fdt_address'.  That way we can get rid of architecture
>> >> >> specific constructs wrt to DT in gd.  The callback is a bit more of a 
>> >> >> pain to
>> >> >> maintain for multiple boards but is more flexible than an address in a
>> >> >> register.  In any case we can do something along the lines of:
>> >> >>
>> >> >> Check register (or blob list or whatever)
>> >> >> if (valid dtb)
>> >> >> fixup/amend/use (depending on what we decide)
>> >> >> else
>> >> >>arch specific callback
>> >> >>
>> >> >> That should give us enough flexibility to deal with future boards 
>> >> >> (famous
>> >> >> last words).
>> >> >
>> >> > SGTM
>> >>
>> >> This sounds like a good generalization that would still work for the
>> >> bcm7445 and bcm7260 boards.  I'll test this approach on the evaluation
>> >> boards I have.
>> >>
>> >> For the BCM7445 I may be able to import the evaluation board device tree
>> >> that Broadcom publishes as part of stblinux.  At runtime I may need to
>> >> merge some of the in-memory items generated by BOLT, but I'll try to
>> >> make this work.
>> >
>> > That would be good.
>> >
>> >> The BCM7260 DTS is not publicly available though, as far as I know.
>> >
>> > Presumably it can be dumped from U-Boot?
>> 
>> Technically, yes, but I wouldn't want to publish the result for various
>> reasons; e.g., it would be specific to the evaluation boards I have, and
>> it may contain vendor-specific fields.  I'd much rather this one remain
>> a stub, until/unless Broadcom publishes a generic BCM7260 DTS under a
>> free license.
>
> Also note that the notion that the U-Boot source tree _must_ contain a
> dts for a given board is something we're very much debating still, in
> another thread, if you're inclined to read and chime in there as well
> with more details about the broadcom use case and technical/legal
> limitations.  Thanks!

Sure.  I read through [1]; here are my thoughts from the BCM7445/BCM7260
perspective.

First of all, for background, BCM7445 and BCM7260 are partial ports of
U-Boot.  They're meant to allow using nice U-Boot features like hush and
FIT image loading on these platforms.  But they do not handle low-level
initialization -- that's done by BOLT, the proprietary
first-and-second-stage bootloader -- and they don't support configuring
all of the hardware on these boards.  Instead these ports include a
small set of drivers (e.g., SPI, eMMC, serial) and configuration that is
needed to make use of the higher level features.

At the time I contributed the BCM7445 support, README called OF_CONTROL
an experimental feature, and device driver configuration was
alternatively allowed to live in board-specific header files.  My
initial local implementation did that, but then I switched to OF_CONTROL
before submitting the patches, since then I could get some of U-Boot's
driver configuration from the prior stage (BOLT) dynamically, instead of
hard-coding addresses in U-Boot source code.  The proposed new policy
would require me to (re-)add these hard-coded values, albeit in a DTS,
not a header file.  IMO that's probably a good/fair requirement for the
non-technical reasons in [1].

The second section of [1] says: "Every board in U-Boot must include a
devicetree sufficient to build and boot tha

Re: [PATCH 1/1 RFC] treewide: Deprecate OF_PRIOR_STAGE

2021-10-13 Thread Thomas Fitzsimmons
Simon Glass  writes:

[...]

> On Wed, 13 Oct 2021 at 10:26, Thomas Fitzsimmons  wrote:
>>
>> Simon Glass  writes:
>>
>> [...]
>>
>> >> > I think one option is better than two. I have a slight preference for
>> >> > OF_PRIOR_STAGE because it is board-agnostic, but I'm not sure it
>> >> > matters, since some of these boards are doing strange things anyway
>> >> > and cannot use OF_PRIOR_STAGE. So let's go with this.
>> >>
>> >> For now it's easier getting rid of OF_PRIOR_STAGE than OF_BOARD.
>> >> Once we unify OF_PRIOR_STAGE/OF_BOARD and OF_HOSTFILE, then
>> >> I can send a patch on top of that, which removes the 
>> >> board_fdt_blob_setup()
>> >> and just stores the address in a similar fashion to the removed
>> >> 'prior_stage_fdt_address'.  That way we can get rid of architecture
>> >> specific constructs wrt to DT in gd.  The callback is a bit more of a 
>> >> pain to
>> >> maintain for multiple boards but is more flexible than an address in a
>> >> register.  In any case we can do something along the lines of:
>> >>
>> >> Check register (or blob list or whatever)
>> >> if (valid dtb)
>> >> fixup/amend/use (depending on what we decide)
>> >> else
>> >>arch specific callback
>> >>
>> >> That should give us enough flexibility to deal with future boards (famous
>> >> last words).
>> >
>> > SGTM
>>
>> This sounds like a good generalization that would still work for the
>> bcm7445 and bcm7260 boards.  I'll test this approach on the evaluation
>> boards I have.
>>
>> For the BCM7445 I may be able to import the evaluation board device tree
>> that Broadcom publishes as part of stblinux.  At runtime I may need to
>> merge some of the in-memory items generated by BOLT, but I'll try to
>> make this work.
>
> That would be good.
>
>> The BCM7260 DTS is not publicly available though, as far as I know.
>
> Presumably it can be dumped from U-Boot?

Technically, yes, but I wouldn't want to publish the result for various
reasons; e.g., it would be specific to the evaluation boards I have, and
it may contain vendor-specific fields.  I'd much rather this one remain
a stub, until/unless Broadcom publishes a generic BCM7260 DTS under a
free license.

Thomas


Re: [PATCH 1/1 RFC] treewide: Deprecate OF_PRIOR_STAGE

2021-10-13 Thread Thomas Fitzsimmons
Simon Glass  writes:

[...]

>> > I think one option is better than two. I have a slight preference for
>> > OF_PRIOR_STAGE because it is board-agnostic, but I'm not sure it
>> > matters, since some of these boards are doing strange things anyway
>> > and cannot use OF_PRIOR_STAGE. So let's go with this.
>>
>> For now it's easier getting rid of OF_PRIOR_STAGE than OF_BOARD.
>> Once we unify OF_PRIOR_STAGE/OF_BOARD and OF_HOSTFILE, then
>> I can send a patch on top of that, which removes the board_fdt_blob_setup()
>> and just stores the address in a similar fashion to the removed
>> 'prior_stage_fdt_address'.  That way we can get rid of architecture
>> specific constructs wrt to DT in gd.  The callback is a bit more of a pain to
>> maintain for multiple boards but is more flexible than an address in a
>> register.  In any case we can do something along the lines of:
>>
>> Check register (or blob list or whatever)
>> if (valid dtb)
>> fixup/amend/use (depending on what we decide)
>> else
>>arch specific callback
>>
>> That should give us enough flexibility to deal with future boards (famous
>> last words).
>
> SGTM

This sounds like a good generalization that would still work for the
bcm7445 and bcm7260 boards.  I'll test this approach on the evaluation
boards I have.

For the BCM7445 I may be able to import the evaluation board device tree
that Broadcom publishes as part of stblinux.  At runtime I may need to
merge some of the in-memory items generated by BOLT, but I'll try to
make this work.

The BCM7260 DTS is not publicly available though, as far as I know.

Thomas


Re: [PATCH 1/1 RFC] treewide: Deprecate OF_PRIOR_STAGE

2021-10-13 Thread Thomas Fitzsimmons
Hi Simon,

Simon Glass  writes:

> Hi Mark,
>
> On Sat, 25 Sept 2021 at 11:27, Mark Kettenis  wrote:
>>
>> > From: Simon Glass 
>> > Date: Fri, 24 Sep 2021 07:57:00 -0600
>> >
>> > Hi Ilias,
>> >
>> > On Fri, 24 Sept 2021 at 07:10, Ilias Apalodimas
>> >  wrote:
>> > >
>> > > At some point back in 2018 prior_stage_fdt_address and OF_PRIOR_STAGE got
>> > > introduced,  in order to support a DTB handed over by an earlier stage 
>> > > boot
>> > > loader.  However we have another option in the Kconfig (OF_BOARD) which 
>> > > has
>> > > identical semantics.
>> > >
>> > > A good example of this is RISC-V boards which during their startup,
>> > > pick up the DTB from a1 and copy it in their private gd_t.  Apart from 
>> > > that
>> > > they also copy it to prior_stage_fdt_address,  if the Kconfig option is
>> > > selected,  which seems unnecessary(??).
>> > >
>> > > This is mostly an RFC,  trying to figure out if I am missing some subtle
>> > > functionality,  which would justify having 2 Kconfig options doing 
>> > > similar
>> > > things present.
>> > >
>> > > - Should we do this?
>> >
>> > I think one option is better than two. I have a slight preference for
>> > OF_PRIOR_STAGE because it is board-agnostic, but I'm not sure it
>> > matters, since some of these boards are doing strange things anyway
>> > and cannot use OF_PRIOR_STAGE. So let's go with this.
>> >
>> > > - Doesn't OF_BOARD and OF_PRIOR_STAGE practically mean "Someone else is
>> > >   going to pass me my DTB".  Why should we care if that someone is a 
>> > > prior
>> > >   bootloader or runtime memory generated on the fly by U-Boot?  It all
>> > >   boils down to having a *board* specific callback for that.
>> >
>> > More generally, I think OF_BOARD is basically 'opt out of the normal
>> > flow and do something special'.
>> >
>> > So at some point I would like to define what 'normal' is. At present,
>> > normal is OF_SEPARATE which means that the devicetree is packed with
>> > U-Boot.
>> >
>> > Really we want to add a second 'normal', to permit a devicetree (and
>> > perhaps other stuff) to be passed in. I think this should be that a
>> > bloblist is passed in, which can contain a devicetree. If it does,
>> > then the one in U-Boot is ignored.
>> >
>> > There should be a standard way to do this with U-Boot. Apart from the
>> > arch-specific selection of machine registers, the standard way should
>> > work for all boards, at some indeterminate point in the future.
>>
>> There are well-established ABIs here that you can't really change.
>> One of those ABIs is how the Linux kernel expects to be called.  On
>> both riscv and arm64 Linux expects to find a pointer to the DTB in a
>> register.
>>
>> Several U-Boot platforms take advantage of this by pretending to be a
>> Linux kernel.  This way they can be loaded by prior stage firmware
>> that was designed to directly load a Linux kernel.  This is what I do
>> for the Apple M1, but this is also how chainloading works on some
>> chromebooks, and there are a few platforms where a proprietary closed
>> source first stage bootloader is used.
>>
>> So once again, U-Boot should be flexible here.  We can certainly
>> recommend a certain approach to folks that are building a firmware
>> stack for new platforms, but we can't really enforce it.
>
> Indeed.
>
> We can nudge people along by providing useful features. Private
> firmware does not seem to be going away.

The situation Mark described is the same as the one I was addressing by
introducing CONFIG_OF_PRIOR_STAGE for these BOLT-using Broadcom boards.
BOLT is a Broadcom proprietary first- and second-stage bootloader.  On
these boards, the DTB that BOLT generates in-memory and provides to the
Linux kernel is meant to be authoritative.

I would much prefer if Broadcom provided native U-Boot support as an
alternative to BOLT, including maintaining free software device trees.
But in the absence of that, given that I wanted U-Boot features on these
boards, I made U-Boot an intermediate (third) stage and used the
BOLT-provided DTB.  One reason I had for contributing the changes is
that I was faintly hoping to nudge Broadcom to support these and future
boards in U-Boot.

My understanding is that the DTB design intent does allow things like
loading a DTB from ROM, so I'm sort of treating the BOLT-provided DTB
that way.  But I also understand that not having U-Boot and Linux in
full control of device trees for boards they support is annoying.  That
said, I'm glad the consensus here seems to be that it's preferable to
have U-Boot accommodate/still be usable on no-DTS boards.

Thomas


[PATCH v2] configs: bcmstb: Disable networking support

2020-09-11 Thread Thomas Fitzsimmons
Silence the "Driver Model for Ethernet drivers" migration warning for
the bcm7445 and bcm7260 ports, neither of which supports networking yet.

Signed-off-by: Thomas Fitzsimmons 
---
 configs/bcm7260_defconfig | 1 +
 configs/bcm7445_defconfig | 1 +
 2 files changed, 2 insertions(+)

diff --git a/configs/bcm7260_defconfig b/configs/bcm7260_defconfig
index f25659db48..d1b05309e1 100644
--- a/configs/bcm7260_defconfig
+++ b/configs/bcm7260_defconfig
@@ -27,6 +27,7 @@ CONFIG_ENV_OVERWRITE=y
 CONFIG_ENV_IS_IN_MMC=y
 CONFIG_SYS_REDUNDAND_ENVIRONMENT=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
+# CONFIG_NET is not set
 CONFIG_DM_MMC=y
 CONFIG_MMC_SDHCI=y
 CONFIG_MMC_SDHCI_BCMSTB=y
diff --git a/configs/bcm7445_defconfig b/configs/bcm7445_defconfig
index 18d31048ff..1f9ab482a2 100644
--- a/configs/bcm7445_defconfig
+++ b/configs/bcm7445_defconfig
@@ -28,6 +28,7 @@ CONFIG_ENV_OVERWRITE=y
 CONFIG_ENV_IS_IN_SPI_FLASH=y
 CONFIG_SYS_REDUNDAND_ENVIRONMENT=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
+# CONFIG_NET is not set
 CONFIG_DM_MMC=y
 CONFIG_MMC_SDHCI=y
 CONFIG_MMC_SDHCI_BCMSTB=y
-- 
2.26.0.rc2



[PATCH] dm: arm: bcmstb: Enable driver model for Ethernet drivers

2020-09-11 Thread Thomas Fitzsimmons
Eliminate the Driver Model migration warning for the bcm7260 and bcm7445
ports (though neither port has Ethernet support yet).

Signed-off-by: Thomas Fitzsimmons 
---
 configs/bcm7260_defconfig | 1 +
 configs/bcm7445_defconfig | 1 +
 2 files changed, 2 insertions(+)

diff --git a/configs/bcm7260_defconfig b/configs/bcm7260_defconfig
index f25659db48..47157f04eb 100644
--- a/configs/bcm7260_defconfig
+++ b/configs/bcm7260_defconfig
@@ -31,4 +31,5 @@ CONFIG_DM_MMC=y
 CONFIG_MMC_SDHCI=y
 CONFIG_MMC_SDHCI_BCMSTB=y
 CONFIG_MTD=y
+CONFIG_DM_ETH=y
 # CONFIG_EFI_LOADER is not set
diff --git a/configs/bcm7445_defconfig b/configs/bcm7445_defconfig
index 18d31048ff..0f80e309ab 100644
--- a/configs/bcm7445_defconfig
+++ b/configs/bcm7445_defconfig
@@ -33,6 +33,7 @@ CONFIG_MMC_SDHCI=y
 CONFIG_MMC_SDHCI_BCMSTB=y
 CONFIG_MTD=y
 CONFIG_DM_SPI_FLASH=y
+CONFIG_DM_ETH=y
 CONFIG_SPI=y
 CONFIG_DM_SPI=y
 CONFIG_BCMSTB_SPI=y
-- 
2.26.0.rc2



Re: [PATCH v1 1/3] board: ns3: add optee based bnxt fw load driver

2020-05-19 Thread Thomas Fitzsimmons
Hi Rayagonda and Vikas,

Rayagonda Kokatanur  writes:

> From: Vikas Gupta 
>
> Add optee based bnxt fw load driver.

What is "bnxt"?  Maybe you could add a comment explaining what it is, or
at least expanding it if it's an acronym?

Thanks,
Thomas


Re: [PATCH v1 00/15] add basic driver support for broadcom NS3 soc

2020-05-19 Thread Thomas Fitzsimmons
Rayagonda Kokatanur  writes:

> On Tue, May 19, 2020 at 11:01 PM Tom Rini  wrote:
>>
>> On Tue, May 19, 2020 at 10:39:49PM +0530, Rayagonda Kokatanur wrote:
>> > Hi Tom,
>> >
>> >
>> > On Tue, May 19, 2020 at 12:46 AM Tom Rini  wrote:
>> > >
>> > > On Sun, May 17, 2020 at 01:49:30PM +0530, Rayagonda Kokatanur wrote:
>> > >
>> > > > This is the second patch set series prepared on top of the
>> > > > first patch set ("add initial support for broadcom NS3 soc").
>> > > >
>> > > > This patch set will add following,
>> > > > -dt nodes and defconfig options for basic device like pinctrl,
>> > > >  gpio, mmc, qspi, wdt, i2c and pcie.
>> > > > -start wdt service
>> > > > -Enable GPT commands
>> > > > -Enable EXT4 and FAT fs support
>> > >
>> > > All of the dts changes not in a -u-boot.dtsi file either come from
>> > > mainline Linux or at least linux-next and have had some level upstream
>> > > review, right?  Thanks!
>> >
>> > Yes. All the DTS changes are merged in the Linux and are available at
>> > arch/arm64/boot/dts/broadcom/stingray/
>>
>> Great.  Please reference the release you're taking these from as that
>> will make future resyncs easier.  Thanks!
>
> It's Linux v5.6.

What's the relationship between e.g., bcm958742t.dts and ns3.dts?  I
looked at the mainline Linux device trees and I couldn't easily see the
correspondence.  Will the renaming complicate synchronization?

Thomas


Re: [PATCH v1 2/3] board: ns3: add FIT image its file

2020-05-19 Thread Thomas Fitzsimmons
Hi Rayagonda and Pramod,

Rayagonda Kokatanur  writes:

> From: Pramod Kumar 
>
> Add FIT image its file.

The .its file and dev keys seem generic.  Are you intending to add to
the .its file subsequently, e.g., to demonstrate FIT usage unique to the
NS3?

Thomas


Re: [U-Boot] [PATCH 1/2] dm: device: Request next sequence number

2019-09-14 Thread Thomas Fitzsimmons
Hi Bin,

Bin Meng  writes:

[...]

> On Fri, Sep 6, 2019 at 7:52 PM Thomas Fitzsimmons  wrote:
>>
>> For CONFIG_OF_PRIOR_STAGE, in the absence of a device tree alias for a
>> given device, use the next request number for that type of device.
>> This allows aliases to be used when they're available, while still
>> allowing unaliased devices to be probed.
>>
>> Signed-off-by: Thomas Fitzsimmons 
>> Cc: Bin Meng 
>> Cc: Simon Glass 
>> ---
>>  drivers/core/device.c | 5 +
>>  drivers/core/uclass.c | 4 +++-
>>  2 files changed, 8 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/core/device.c b/drivers/core/device.c
>> index 474c1642ee..ca8be208a9 100644
>> --- a/drivers/core/device.c
>> +++ b/drivers/core/device.c
>> @@ -82,6 +82,11 @@ static int device_bind_common(struct udevice *parent, 
>> const struct driver *drv,
>> if (CONFIG_IS_ENABLED(OF_CONTROL) && 
>> !CONFIG_IS_ENABLED(OF_PLATDATA)) {
>> if (uc->uc_drv->name && ofnode_valid(node))
>> dev_read_alias_seq(dev, >req_seq);
>> +#if CONFIG_IS_ENABLED(OF_PRIOR_STAGE)
>
> I was wondering whether we should limit such only for OF_PRIOR_STATE,
> instead change the behaviors for all DM devices.

Maybe, though I wouldn't want to break assumptions made in this area by
non-OF_PRIOR_STAGE boards.

> Because as I pointed out in
> https://lists.denx.de/pipermail/u-boot/2019-August/382368.html, it
> seems there are quite some codes in the existing code base that tried
> to workaround such limitation in their own way.

I could create a separate config option to control this behavior, and
document what it does in Kconfig.  Then other ports could adopt it
gradually, and eventually we could make it unconditional.  I think
OF_PRIOR_STAGE should select the new option, since I can confirm this is
an improvement for my OF_PRIOR_STAGE-using board.

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


[U-Boot] [PATCH 2/2] dm: spi: Do not assume first SPI bus

2019-09-06 Thread Thomas Fitzsimmons
When CONFIG_OF_PRIOR_STAGE is enabled, this workaround was needed
before device_bind_common assigned request numbers sequentially in the
absence of aliases.

Signed-off-by: Thomas Fitzsimmons 
Cc: Bin Meng 
Cc: Simon Glass 
---
 drivers/spi/spi-uclass.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/spi/spi-uclass.c b/drivers/spi/spi-uclass.c
index 88cb2a1262..5e1f2232e5 100644
--- a/drivers/spi/spi-uclass.c
+++ b/drivers/spi/spi-uclass.c
@@ -275,7 +275,7 @@ int spi_get_bus_and_cs(int busnum, int cs, int speed, int 
mode,
bool created = false;
int ret;
 
-#if CONFIG_IS_ENABLED(OF_PLATDATA) || CONFIG_IS_ENABLED(OF_PRIOR_STAGE)
+#if CONFIG_IS_ENABLED(OF_PLATDATA)
ret = uclass_first_device_err(UCLASS_SPI, );
 #else
ret = uclass_get_device_by_seq(UCLASS_SPI, busnum, );
-- 
2.23.0

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


[U-Boot] [PATCH 1/2] dm: device: Request next sequence number

2019-09-06 Thread Thomas Fitzsimmons
For CONFIG_OF_PRIOR_STAGE, in the absence of a device tree alias for a
given device, use the next request number for that type of device.
This allows aliases to be used when they're available, while still
allowing unaliased devices to be probed.

Signed-off-by: Thomas Fitzsimmons 
Cc: Bin Meng 
Cc: Simon Glass 
---
 drivers/core/device.c | 5 +
 drivers/core/uclass.c | 4 +++-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/core/device.c b/drivers/core/device.c
index 474c1642ee..ca8be208a9 100644
--- a/drivers/core/device.c
+++ b/drivers/core/device.c
@@ -82,6 +82,11 @@ static int device_bind_common(struct udevice *parent, const 
struct driver *drv,
if (CONFIG_IS_ENABLED(OF_CONTROL) && 
!CONFIG_IS_ENABLED(OF_PLATDATA)) {
if (uc->uc_drv->name && ofnode_valid(node))
dev_read_alias_seq(dev, >req_seq);
+#if CONFIG_IS_ENABLED(OF_PRIOR_STAGE)
+   if (dev->req_seq == -1)
+   dev->req_seq =
+   uclass_find_next_free_req_seq(drv->id);
+#endif
} else {
dev->req_seq = uclass_find_next_free_req_seq(drv->id);
}
diff --git a/drivers/core/uclass.c b/drivers/core/uclass.c
index b33296542f..d7aedac351 100644
--- a/drivers/core/uclass.c
+++ b/drivers/core/uclass.c
@@ -269,7 +269,9 @@ int uclass_find_device_by_name(enum uclass_id id, const 
char *name,
return -ENODEV;
 }
 
-#if !CONFIG_IS_ENABLED(OF_CONTROL) || CONFIG_IS_ENABLED(OF_PLATDATA)
+#if !CONFIG_IS_ENABLED(OF_CONTROL) || \
+CONFIG_IS_ENABLED(OF_PLATDATA) || \
+CONFIG_IS_ENABLED(OF_PRIOR_STAGE)
 int uclass_find_next_free_req_seq(enum uclass_id id)
 {
struct uclass *uc;
-- 
2.23.0

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


[U-Boot] [PATCH 0/2] dm: CONFIG_OF_PRIOR_STAGE request number fixes

2019-09-06 Thread Thomas Fitzsimmons
These patches remove a workaround that was needed for ports that use
CONFIG_OF_PRIOR_STAGE, that need to probe a SPI bus, and whose prior
stage device tree does not provide SPI bus aliases.

Thomas Fitzsimmons (2):
  dm: device: Request next sequence number
  dm: spi: Do not assume first SPI bus

 drivers/core/device.c| 5 +
 drivers/core/uclass.c| 4 +++-
 drivers/spi/spi-uclass.c | 2 +-
 3 files changed, 9 insertions(+), 2 deletions(-)

-- 
2.23.0

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


Re: [U-Boot] [PATCH v4 1/1] board: arm: Add support for Broadcom BCM7445

2019-08-28 Thread Thomas Fitzsimmons
Hi Bin,

Bin Meng  writes:

> Hi Thomas,
>
> On Wed, Aug 28, 2019 at 6:31 AM Thomas Fitzsimmons  
> wrote:
>>
>> Hi Bin,
>>
>> Bin Meng  writes:
>>
>> > Hi Thomas,
>> >
>> > On Sat, Jun 9, 2018 at 6:06 AM Thomas Fitzsimmons  
>> > wrote:
>> >>
>> >> Add support for loading U-Boot on the Broadcom 7445 SoC.  This port
>> >> assumes Broadcom's BOLT bootloader is acting as the second stage
>> >> bootloader, and U-Boot is acting as the third stage bootloader, loaded
>> >> as an ELF program by BOLT.
>> >>
>> >> Signed-off-by: Thomas Fitzsimmons 
>> >> Cc: Stefan Roese 
>> >> Cc: Tom Rini 
>> >> Cc: Florian Fainelli 
>> >> ---
>> >> Changes for v4:
>> >>- Use high timer register for get_ticks
>> >>- Move hard-coded register addresses from Kconfig to header
>> >>- Document I-cache/D-cache expectation
>> >>
>> >>  MAINTAINERS |  10 +
>> >>  arch/arm/Kconfig|  12 +
>> >>  arch/arm/Makefile   |   1 +
>> >>  arch/arm/mach-bcmstb/Kconfig|  36 ++
>> >>  arch/arm/mach-bcmstb/Makefile   |   8 +
>> >>  arch/arm/mach-bcmstb/include/mach/gpio.h|  11 +
>> >>  arch/arm/mach-bcmstb/include/mach/hardware.h|  11 +
>> >>  arch/arm/mach-bcmstb/include/mach/prior_stage.h |  30 ++
>> >>  arch/arm/mach-bcmstb/include/mach/sdhci.h   |  15 +
>> >>  arch/arm/mach-bcmstb/include/mach/timer.h   |  13 +
>> >>  arch/arm/mach-bcmstb/lowlevel_init.S|  21 ++
>> >>  board/broadcom/bcmstb/MAINTAINERS   |   7 +
>> >>  board/broadcom/bcmstb/Makefile  |   8 +
>> >>  board/broadcom/bcmstb/bcmstb.c  | 194 +++
>> >>  configs/bcm7445_defconfig   |  27 ++
>> >>  doc/README.bcm7xxx  | 150 
>> >>  drivers/mmc/Kconfig |  11 +
>> >>  drivers/mmc/Makefile|   1 +
>> >>  drivers/mmc/bcmstb_sdhci.c  |  67 
>> >>  drivers/spi/Kconfig |   7 +
>> >>  drivers/spi/Makefile|   1 +
>> >>  drivers/spi/bcmstb_spi.c| 439 
>> >> 
>> >>  drivers/spi/spi-uclass.c|   2 +-
>> >>  dts/Kconfig |   7 +
>> >>  include/configs/bcm7445.h   |  26 ++
>> >>  include/configs/bcmstb.h| 183 ++
>> >>  include/fdtdec.h|   4 +
>> >>  lib/fdtdec.c|   4 +
>> >>  28 files changed, 1305 insertions(+), 1 deletion(-)
>> >>  create mode 100644 arch/arm/mach-bcmstb/Kconfig
>> >>  create mode 100644 arch/arm/mach-bcmstb/Makefile
>> >>  create mode 100644 arch/arm/mach-bcmstb/include/mach/gpio.h
>> >>  create mode 100644 arch/arm/mach-bcmstb/include/mach/hardware.h
>> >>  create mode 100644 arch/arm/mach-bcmstb/include/mach/prior_stage.h
>> >>  create mode 100644 arch/arm/mach-bcmstb/include/mach/sdhci.h
>> >>  create mode 100644 arch/arm/mach-bcmstb/include/mach/timer.h
>> >>  create mode 100644 arch/arm/mach-bcmstb/lowlevel_init.S
>> >>  create mode 100644 board/broadcom/bcmstb/MAINTAINERS
>> >>  create mode 100644 board/broadcom/bcmstb/Makefile
>> >>  create mode 100644 board/broadcom/bcmstb/bcmstb.c
>> >>  create mode 100644 configs/bcm7445_defconfig
>> >>  create mode 100644 doc/README.bcm7xxx
>> >>  create mode 100644 drivers/mmc/bcmstb_sdhci.c
>> >>  create mode 100644 drivers/spi/bcmstb_spi.c
>> >>  create mode 100644 include/configs/bcm7445.h
>> >>  create mode 100644 include/configs/bcmstb.h
>> >>
>> >
>> > [snip]
>> >
>> >> diff --git a/drivers/spi/spi-uclass.c b/drivers/spi/spi-uclass.c
>> >> index d2d091f..c517d06 100644
>> >> --- a/drivers/spi/spi-uclass.c
>> >> +++ b/drivers/spi/spi-uclass.c
>> >> @@ -273,7 +273,7 @@ int spi_get_bus_and_cs(int busnum, int cs, int speed, 
>> >> int mode,
>> >>

Re: [U-Boot] [PATCH v4 1/1] board: arm: Add support for Broadcom BCM7445

2019-08-27 Thread Thomas Fitzsimmons
Hi Bin,

Bin Meng  writes:

> Hi Thomas,
>
> On Sat, Jun 9, 2018 at 6:06 AM Thomas Fitzsimmons  wrote:
>>
>> Add support for loading U-Boot on the Broadcom 7445 SoC.  This port
>> assumes Broadcom's BOLT bootloader is acting as the second stage
>> bootloader, and U-Boot is acting as the third stage bootloader, loaded
>> as an ELF program by BOLT.
>>
>> Signed-off-by: Thomas Fitzsimmons 
>> Cc: Stefan Roese 
>> Cc: Tom Rini 
>> Cc: Florian Fainelli 
>> ---
>> Changes for v4:
>>- Use high timer register for get_ticks
>>- Move hard-coded register addresses from Kconfig to header
>>- Document I-cache/D-cache expectation
>>
>>  MAINTAINERS |  10 +
>>  arch/arm/Kconfig|  12 +
>>  arch/arm/Makefile   |   1 +
>>  arch/arm/mach-bcmstb/Kconfig|  36 ++
>>  arch/arm/mach-bcmstb/Makefile   |   8 +
>>  arch/arm/mach-bcmstb/include/mach/gpio.h|  11 +
>>  arch/arm/mach-bcmstb/include/mach/hardware.h|  11 +
>>  arch/arm/mach-bcmstb/include/mach/prior_stage.h |  30 ++
>>  arch/arm/mach-bcmstb/include/mach/sdhci.h   |  15 +
>>  arch/arm/mach-bcmstb/include/mach/timer.h   |  13 +
>>  arch/arm/mach-bcmstb/lowlevel_init.S|  21 ++
>>  board/broadcom/bcmstb/MAINTAINERS   |   7 +
>>  board/broadcom/bcmstb/Makefile  |   8 +
>>  board/broadcom/bcmstb/bcmstb.c  | 194 +++
>>  configs/bcm7445_defconfig   |  27 ++
>>  doc/README.bcm7xxx  | 150 
>>  drivers/mmc/Kconfig |  11 +
>>  drivers/mmc/Makefile|   1 +
>>  drivers/mmc/bcmstb_sdhci.c  |  67 
>>  drivers/spi/Kconfig |   7 +
>>  drivers/spi/Makefile|   1 +
>>  drivers/spi/bcmstb_spi.c| 439 
>> 
>>  drivers/spi/spi-uclass.c|   2 +-
>>  dts/Kconfig |   7 +
>>  include/configs/bcm7445.h   |  26 ++
>>  include/configs/bcmstb.h| 183 ++
>>  include/fdtdec.h|   4 +
>>  lib/fdtdec.c|   4 +
>>  28 files changed, 1305 insertions(+), 1 deletion(-)
>>  create mode 100644 arch/arm/mach-bcmstb/Kconfig
>>  create mode 100644 arch/arm/mach-bcmstb/Makefile
>>  create mode 100644 arch/arm/mach-bcmstb/include/mach/gpio.h
>>  create mode 100644 arch/arm/mach-bcmstb/include/mach/hardware.h
>>  create mode 100644 arch/arm/mach-bcmstb/include/mach/prior_stage.h
>>  create mode 100644 arch/arm/mach-bcmstb/include/mach/sdhci.h
>>  create mode 100644 arch/arm/mach-bcmstb/include/mach/timer.h
>>  create mode 100644 arch/arm/mach-bcmstb/lowlevel_init.S
>>  create mode 100644 board/broadcom/bcmstb/MAINTAINERS
>>  create mode 100644 board/broadcom/bcmstb/Makefile
>>  create mode 100644 board/broadcom/bcmstb/bcmstb.c
>>  create mode 100644 configs/bcm7445_defconfig
>>  create mode 100644 doc/README.bcm7xxx
>>  create mode 100644 drivers/mmc/bcmstb_sdhci.c
>>  create mode 100644 drivers/spi/bcmstb_spi.c
>>  create mode 100644 include/configs/bcm7445.h
>>  create mode 100644 include/configs/bcmstb.h
>>
>
> [snip]
>
>> diff --git a/drivers/spi/spi-uclass.c b/drivers/spi/spi-uclass.c
>> index d2d091f..c517d06 100644
>> --- a/drivers/spi/spi-uclass.c
>> +++ b/drivers/spi/spi-uclass.c
>> @@ -273,7 +273,7 @@ int spi_get_bus_and_cs(int busnum, int cs, int speed, 
>> int mode,
>> bool created = false;
>> int ret;
>>
>> -#if CONFIG_IS_ENABLED(OF_PLATDATA)
>> +#if CONFIG_IS_ENABLED(OF_PLATDATA) || CONFIG_IS_ENABLED(OF_PRIOR_STAGE)
>
> Could you please explain this change a little bit? Why should we call
> uclass_first_device_err() for OF_PRIOR_STAGE?
>
>> ret = uclass_first_device_err(UCLASS_SPI, );
>>  #else
>> ret = uclass_get_device_by_seq(UCLASS_SPI, busnum, );

On the BCM7445 eval board, the prior-stage-provided device tree does not
have an alias for spi0, though it has aliases for other device types; I
don't know why this is the case, but I don't have control over what the
prior stage bootloader (Broadcom's BOLT) provides.  Without that alias,
uclass_get_device_by_seq fails to find the SPI bus (and so U-Boot can't
find the SPI flash device that stores its 

[U-Boot] [PATCH] dm: arm: bcmstb: Enable driver model MMC support

2019-05-17 Thread Thomas Fitzsimmons
For bcm7445 and bcm7260, this patch enables CONFIG_DM_MMC and updates
the bcmstb SDHCI driver to use the new driver model.  This allows
removal of SDHCI configuration handling from bcmstb.c, and eliminates
a board removal compile warning.

Signed-off-by: Thomas Fitzsimmons 
---
 board/broadcom/bcmstb/bcmstb.c | 65 +-
 configs/bcm7260_defconfig  |  1 +
 configs/bcm7445_defconfig  |  1 +
 drivers/mmc/bcmstb_sdhci.c | 73 +-
 include/configs/bcm7260.h  |  1 -
 include/configs/bcm7445.h  |  1 -
 6 files changed, 58 insertions(+), 84 deletions(-)

diff --git a/board/broadcom/bcmstb/bcmstb.c b/board/broadcom/bcmstb/bcmstb.c
index 56328463ae..7f8e0f951d 100644
--- a/board/broadcom/bcmstb/bcmstb.c
+++ b/board/broadcom/bcmstb/bcmstb.c
@@ -1,6 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0+
 /*
  * (C) Copyright 2018  Cisco Systems, Inc.
+ * (C) Copyright 2019  Synamedia
  *
  * Author: Thomas Fitzsimmons 
  */
@@ -9,7 +10,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -80,69 +80,6 @@ void enable_caches(void)
 */
 }
 
-static const phys_addr_t bcmstb_sdhci_address(u32 alias_index)
-{
-   int node = 0;
-   int ret = 0;
-   char sdhci[16] = { 0 };
-   const void *fdt = gd->fdt_blob;
-   const char *path = NULL;
-   struct fdt_resource resource = { 0 };
-
-   if (!fdt) {
-   printf("%s: Invalid gd->fdt_blob\n", __func__);
-   return 0;
-   }
-
-   node = fdt_path_offset(fdt, "/aliases");
-   if (node < 0) {
-   printf("%s: Failed to find /aliases node\n", __func__);
-   return 0;
-   }
-
-   sprintf(sdhci, "sdhci%d", alias_index);
-   path = fdt_getprop(fdt, node, sdhci, NULL);
-   if (!path) {
-   printf("%s: Failed to find alias for %s\n", __func__, sdhci);
-   return 0;
-   }
-
-   node = fdt_path_offset(fdt, path);
-   if (node < 0) {
-   printf("%s: Failed to resolve BCMSTB SDHCI alias\n", __func__);
-   return 0;
-   }
-
-   ret = fdt_get_named_resource(fdt, node, "reg", "reg-names",
-"host", );
-   if (ret) {
-   printf("%s: Failed to read BCMSTB SDHCI host resource\n",
-  __func__);
-   return 0;
-   }
-
-   return resource.start;
-}
-
-int board_mmc_init(bd_t *bis)
-{
-   phys_addr_t sdhci_base_address = 0;
-
-   sdhci_base_address = bcmstb_sdhci_address(CONFIG_BCMSTB_SDHCI_INDEX);
-
-   if (!sdhci_base_address) {
-   sdhci_base_address = BCMSTB_SDHCI_BASE;
-   printf("%s: Assuming BCMSTB SDHCI address: 0x%p\n",
-  __func__, (void *)sdhci_base_address);
-   }
-
-   debug("BCMSTB SDHCI base address: 0x%p\n", (void *)sdhci_base_address);
-
-   bcmstb_sdhci_init(sdhci_base_address);
-
-   return 0;
-}
-
 int timer_init(void)
 {
gd->arch.timer_rate_hz = readl(BCMSTB_TIMER_FREQUENCY);
diff --git a/configs/bcm7260_defconfig b/configs/bcm7260_defconfig
index 263694c58f..6e0266be45 100644
--- a/configs/bcm7260_defconfig
+++ b/configs/bcm7260_defconfig
@@ -11,6 +11,7 @@ CONFIG_SYS_PROMPT="U-Boot>"
 CONFIG_EFI_PARTITION=y
 CONFIG_OF_PRIOR_STAGE=y
 CONFIG_ENV_IS_IN_MMC=y
+CONFIG_DM_MMC=y
 CONFIG_MMC_SDHCI=y
 CONFIG_MMC_SDHCI_BCMSTB=y
 # CONFIG_EFI_LOADER is not set
diff --git a/configs/bcm7445_defconfig b/configs/bcm7445_defconfig
index 97098bf7e2..f22b06e9ce 100644
--- a/configs/bcm7445_defconfig
+++ b/configs/bcm7445_defconfig
@@ -13,6 +13,7 @@ CONFIG_CMD_SF_TEST=y
 CONFIG_CMD_SPI=y
 CONFIG_OF_PRIOR_STAGE=y
 CONFIG_ENV_IS_IN_SPI_FLASH=y
+CONFIG_DM_MMC=y
 CONFIG_MMC_SDHCI=y
 CONFIG_MMC_SDHCI_BCMSTB=y
 CONFIG_DM_SPI_FLASH=y
diff --git a/drivers/mmc/bcmstb_sdhci.c b/drivers/mmc/bcmstb_sdhci.c
index 443ae8d481..eef46f3af1 100644
--- a/drivers/mmc/bcmstb_sdhci.c
+++ b/drivers/mmc/bcmstb_sdhci.c
@@ -1,11 +1,13 @@
 // SPDX-License-Identifier: GPL-2.0+
 /*
  * (C) Copyright 2018  Cisco Systems, Inc.
+ * (C) Copyright 2019  Synamedia
  *
  * Author: Thomas Fitzsimmons 
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -36,32 +38,67 @@
  */
 #define BCMSTB_SDHCI_MINIMUM_CLOCK_FREQUENCY   40
 
-static char *BCMSTB_SDHCI_NAME = "bcmstb-sdhci";
-
 /*
  * This driver has only been tested with eMMC devices; SD devices may
  * not work.
  */
-int bcmstb_sdhci_init(phys_addr_t regbase)
+struct sdhci_bcmstb_plat {
+   struct mmc_config cfg;
+   struct mmc mmc;
+};
+
+static int sdhci_bcmstb_bind(struct udevice *dev)
+{
+   struct sdhci_bcmstb_plat *plat = dev_get_platdata(dev);
+
+   return sdhci_bind(dev, >mmc, >cfg);
+}
+
+static int sdhci_bcmstb_probe(struct udevice *dev)
 {
-  

Re: [U-Boot] [PATCH] board: arm: Add support for Broadcom BCM7260

2018-08-22 Thread Thomas Fitzsimmons
Hi Florian,

Florian Fainelli  writes:

[...]

>> +#define CONFIG_SYS_NS16550_COM3 0xf040c000
>
> This is the physical address of UARTA, there are typically 3 UARTs on
> those SoCs, is there a reason to name this COM3 and not COM1? If this is
> an established u-boot convention, pardon my ignore here.

There wasn't a good reason not to make this COM1, so I changed it and
BCM7445 to use CONFIG_CONS_INDEX=1 in the latest patch set I posted.

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


[U-Boot] [PATCH v2 2/2] board: arm: Add support for Broadcom BCM7260

2018-08-22 Thread Thomas Fitzsimmons
Add support for loading U-Boot on the Broadcom 7260 SoC.  This port
assumes Broadcom's BOLT bootloader is acting as the second stage
bootloader, and U-Boot is acting as the third stage bootloader, loaded
as an ELF program by BOLT.

Signed-off-by: Thomas Fitzsimmons 
Reviewed-by: Florian Fainelli 
Cc: Florian Fainelli 
---
Changes for v2:
   - Rebase to master tip
   - Change serial console index
   - Simplify and reorder defconfig
   - Move some environment configuration to bcm7260.h
   - Update MAINTAINERS files

 MAINTAINERS   |  2 +-
 arch/arm/mach-bcmstb/Kconfig  | 13 ++---
 board/broadcom/bcmstb/MAINTAINERS |  8 
 configs/bcm7260_defconfig | 17 +
 include/configs/bcm7260.h | 40 +++
 5 files changed, 76 insertions(+), 4 deletions(-)
 create mode 100644 configs/bcm7260_defconfig
 create mode 100644 include/configs/bcm7260.h

diff --git a/MAINTAINERS b/MAINTAINERS
index 8f23712..a1c31e2 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -113,7 +113,7 @@ M:  Thomas Fitzsimmons 
 S: Maintained
 F: arch/arm/mach-bcmstb/
 F: board/broadcom/bcmstb/
-F: configs/bcm7445_defconfig
+F: configs/bcm7*_defconfig
 F: doc/README.bcm7xxx
 F: drivers/mmc/bcmstb_sdhci.c
 F: drivers/spi/bcmstb_spi.c
diff --git a/arch/arm/mach-bcmstb/Kconfig b/arch/arm/mach-bcmstb/Kconfig
index 6c7952f..0a56c3c 100644
--- a/arch/arm/mach-bcmstb/Kconfig
+++ b/arch/arm/mach-bcmstb/Kconfig
@@ -7,8 +7,14 @@ config TARGET_BCM7445
  Support for the Broadcom 7445 SoC.  This port assumes BOLT
  is acting as the second stage bootloader, and U-Boot is
  acting as the third stage bootloader (TSBL), loaded by BOLT.
- This port may work on other BCM7xxx boards with
- configuration changes.
+
+config TARGET_BCM7260
+   bool "Broadcom 7260 TSBL"
+   depends on ARCH_BCMSTB
+   help
+ Support for the Broadcom 7260 SoC.  This port assumes BOLT
+ is acting as the second stage bootloader, and U-Boot is
+ acting as the third stage bootloader (TSBL), loaded by BOLT.
 
 config SYS_CPU
default "armv7"
@@ -23,7 +29,8 @@ config SYS_SOC
default "bcmstb"
 
 config SYS_CONFIG_NAME
-   default "bcm7445"
+   default "bcm7445" if TARGET_BCM7445
+   default "bcm7260" if TARGET_BCM7260
 
 config SYS_FDT_SAVE_ADDRESS
hex "Address to which the prior stage provided DTB will be copied"
diff --git a/board/broadcom/bcmstb/MAINTAINERS 
b/board/broadcom/bcmstb/MAINTAINERS
index 5851cb9..eda29b9 100644
--- a/board/broadcom/bcmstb/MAINTAINERS
+++ b/board/broadcom/bcmstb/MAINTAINERS
@@ -5,3 +5,11 @@ F: board/broadcom/bcmstb/
 F: include/configs/bcmstb.h
 F: include/configs/bcm7445.h
 F: configs/bcm7445_defconfig
+
+BCM7260 BOARD
+M: Thomas Fitzsimmons 
+S: Maintained
+F: board/broadcom/bcmstb/
+F: include/configs/bcmstb.h
+F: include/configs/bcm7260.h
+F: configs/bcm7260_defconfig
diff --git a/configs/bcm7260_defconfig b/configs/bcm7260_defconfig
new file mode 100644
index 000..e3b6ed4
--- /dev/null
+++ b/configs/bcm7260_defconfig
@@ -0,0 +1,17 @@
+CONFIG_ARM=y
+CONFIG_ARCH_BCMSTB=y
+CONFIG_SYS_TEXT_BASE=0x1010
+CONFIG_TARGET_BCM7260=y
+CONFIG_NR_DRAM_BANKS=1
+CONFIG_FIT=y
+CONFIG_FIT_SIGNATURE=y
+CONFIG_BOOTDELAY=1
+CONFIG_HUSH_PARSER=y
+CONFIG_SYS_PROMPT="U-Boot>"
+CONFIG_OF_PRIOR_STAGE=y
+CONFIG_ENV_IS_IN_MMC=y
+CONFIG_MMC_SDHCI=y
+CONFIG_MMC_SDHCI_BCMSTB=y
+CONFIG_CONS_INDEX=1
+CONFIG_EFI_LOADER=n
+CONFIG_EFI_PARTITION=y
diff --git a/include/configs/bcm7260.h b/include/configs/bcm7260.h
new file mode 100644
index 000..a2d7f61
--- /dev/null
+++ b/include/configs/bcm7260.h
@@ -0,0 +1,40 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * (C) Copyright 2018  Cisco Systems, Inc.
+ *
+ * Author: Thomas Fitzsimmons 
+ *
+ * Configuration settings for the Broadcom BCM7260 SoC family.
+ */
+
+#ifndef __CONFIG_H
+#define __CONFIG_H
+
+#define CONFIG_SYS_NS16550_COM10xf040c000
+
+#define CONFIG_SYS_TEXT_BASE   0x1010
+#define CONFIG_SYS_INIT_RAM_ADDR   0x1020
+
+#define CONFIG_SYS_MALLOC_LEN  ((40 * 1024) << 10) /* 40 MiB */
+
+#include "bcmstb.h"
+
+#define BCMSTB_SDHCI_BASE  0xf0200300
+#define BCMSTB_TIMER_LOW   0xf0412008
+#define BCMSTB_TIMER_HIGH  0xf041200c
+#define BCMSTB_TIMER_FREQUENCY 0xf0412020
+#define BCMSTB_HIF_MSPI_BASE   0xf0203c00
+#define BCMSTB_BSPI_BASE   0xf0203a00
+#define BCMSTB_HIF_SPI_INTR2   0xf0201a00
+#define BCMSTB_CS_REG  0xf0200920
+
+/*
+ * Environment configuration for eMMC.
+ */
+#define CONFIG_ENV_OFFSET  (0x40a4 * 512)
+#define CONFIG_SYS_MMC_ENV_DEV 0
+#define CONFIG_SYS_MMC_ENV_PART0
+
+#define CONFIG_CMD_GPT
+
+#endif /* __CONFIG_H */
-- 
1.8.3.1

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


[U-Boot] [PATCH v2 1/2] arm: bcm7445: Change serial console index

2018-08-22 Thread Thomas Fitzsimmons
Change the configured serial console index to reflect that it is the
first physical UART, reorder some defconfig lines and move some
environment configuration from bcmstb.h to bcm7445.h.

Signed-off-by: Thomas Fitzsimmons 
Cc: Florian Fainelli 
---
Changes for v2:
   - Rebase to master tip
   - Change serial console index
   - Reorder defconfig lines
   - Move some environment configuration to bcm7445.h

 configs/bcm7445_defconfig | 8 
 include/configs/bcm7445.h | 9 +++--
 include/configs/bcmstb.h  | 4 
 3 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/configs/bcm7445_defconfig b/configs/bcm7445_defconfig
index 59c745f..cb15226 100644
--- a/configs/bcm7445_defconfig
+++ b/configs/bcm7445_defconfig
@@ -12,10 +12,10 @@ CONFIG_OF_PRIOR_STAGE=y
 CONFIG_ENV_IS_IN_SPI_FLASH=y
 CONFIG_MMC_SDHCI=y
 CONFIG_MMC_SDHCI_BCMSTB=y
-CONFIG_DM_SPI_FLASH=y
-CONFIG_SPI_FLASH=y
-CONFIG_CONS_INDEX=3
+CONFIG_CONS_INDEX=1
+CONFIG_EFI_LOADER=n
 CONFIG_SPI=y
+CONFIG_SPI_FLASH=y
 CONFIG_DM_SPI=y
+CONFIG_DM_SPI_FLASH=y
 CONFIG_BCMSTB_SPI=y
-# CONFIG_EFI_LOADER is not set
diff --git a/include/configs/bcm7445.h b/include/configs/bcm7445.h
index f34cf2d..8c675f7 100644
--- a/include/configs/bcm7445.h
+++ b/include/configs/bcm7445.h
@@ -10,7 +10,7 @@
 #ifndef __CONFIG_H
 #define __CONFIG_H
 
-#define CONFIG_SYS_NS16550_COM30xf040ab00
+#define CONFIG_SYS_NS16550_COM10xf040ab00
 
 #define CONFIG_SYS_TEXT_BASE   0x8010
 #define CONFIG_SYS_INIT_RAM_ADDR   0x8020
@@ -28,7 +28,12 @@
 #define BCMSTB_HIF_SPI_INTR2   0xf03e1a00
 #define BCMSTB_CS_REG  0xf03e0920
 
-#define CONFIG_ENV_IS_IN_SPI_FLASH 1
+/*
+ * Environment configuration for SPI flash.
+ */
+#define CONFIG_ENV_OFFSET  0x1e
+#define CONFIG_ENV_SECT_SIZE   CONFIG_ENV_SIZE
+
 #define CONFIG_DM_SPI  1
 #define CONFIG_SYS_MAX_FLASH_BANKS 1
 #define CONFIG_CMD_SF
diff --git a/include/configs/bcmstb.h b/include/configs/bcmstb.h
index e755383..cc28924 100644
--- a/include/configs/bcmstb.h
+++ b/include/configs/bcmstb.h
@@ -114,7 +114,6 @@ extern phys_addr_t prior_stage_fdt_address;
 /*
  * Serial console configuration.
  */
-
 #define CONFIG_BAUDRATE115200
 #define CONFIG_SYS_BAUDRATE_TABLE  {4800, 9600, 19200, 38400, 57600, \
 115200}
@@ -151,10 +150,7 @@ extern phys_addr_t prior_stage_fdt_address;
  * Environment configuration.
  */
 #define CONFIG_SYS_REDUNDAND_ENVIRONMENT
-
-#define CONFIG_ENV_OFFSET  0x1e
 #define CONFIG_ENV_SIZE(64 << 10) /* 64 KiB */
-#define CONFIG_ENV_SECT_SIZE   CONFIG_ENV_SIZE
 #define CONFIG_ENV_OFFSET_REDUND   (CONFIG_ENV_OFFSET + CONFIG_ENV_SIZE)
 #define CONFIG_ENV_OVERWRITE
 
-- 
1.8.3.1

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


[U-Boot] [PATCH v2 0/2] board: arm: Add support for Broadcom BCM7260

2018-08-22 Thread Thomas Fitzsimmons
Add support for loading U-Boot on the Broadcom 7260 SoC.  The first
patch in this series reorganizes the BCM7445 configury to make way for
BCM7260.

Thomas Fitzsimmons (2):
  arm: bcm7445: Change serial console index
  board: arm: Add support for Broadcom BCM7260

 MAINTAINERS   |  2 +-
 arch/arm/mach-bcmstb/Kconfig  | 13 ++---
 board/broadcom/bcmstb/MAINTAINERS |  8 
 configs/bcm7260_defconfig | 17 +
 configs/bcm7445_defconfig |  8 
 include/configs/bcm7260.h | 40 +++
 include/configs/bcm7445.h |  9 +++--
 include/configs/bcmstb.h  |  4 
 8 files changed, 87 insertions(+), 14 deletions(-)
 create mode 100644 configs/bcm7260_defconfig
 create mode 100644 include/configs/bcm7260.h

-- 
1.8.3.1

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


[U-Boot] [PATCH] board: arm: Add support for Broadcom BCM7260

2018-08-16 Thread Thomas Fitzsimmons
Add support for loading U-Boot on the Broadcom 7260 SoC.  This port
assumes Broadcom's BOLT bootloader is acting as the second stage
bootloader, and U-Boot is acting as the third stage bootloader, loaded
as an ELF program by BOLT.

Signed-off-by: Thomas Fitzsimmons 
---
 arch/arm/mach-bcmstb/Kconfig | 13 ++---
 configs/bcm7260_defconfig| 23 +++
 include/configs/bcm7260.h| 35 +++
 include/configs/bcmstb.h | 10 --
 4 files changed, 76 insertions(+), 5 deletions(-)
 create mode 100644 configs/bcm7260_defconfig
 create mode 100644 include/configs/bcm7260.h

diff --git a/arch/arm/mach-bcmstb/Kconfig b/arch/arm/mach-bcmstb/Kconfig
index 6c7952f..0a56c3c 100644
--- a/arch/arm/mach-bcmstb/Kconfig
+++ b/arch/arm/mach-bcmstb/Kconfig
@@ -7,8 +7,14 @@ config TARGET_BCM7445
  Support for the Broadcom 7445 SoC.  This port assumes BOLT
  is acting as the second stage bootloader, and U-Boot is
  acting as the third stage bootloader (TSBL), loaded by BOLT.
- This port may work on other BCM7xxx boards with
- configuration changes.
+
+config TARGET_BCM7260
+   bool "Broadcom 7260 TSBL"
+   depends on ARCH_BCMSTB
+   help
+ Support for the Broadcom 7260 SoC.  This port assumes BOLT
+ is acting as the second stage bootloader, and U-Boot is
+ acting as the third stage bootloader (TSBL), loaded by BOLT.
 
 config SYS_CPU
default "armv7"
@@ -23,7 +29,8 @@ config SYS_SOC
default "bcmstb"
 
 config SYS_CONFIG_NAME
-   default "bcm7445"
+   default "bcm7445" if TARGET_BCM7445
+   default "bcm7260" if TARGET_BCM7260
 
 config SYS_FDT_SAVE_ADDRESS
hex "Address to which the prior stage provided DTB will be copied"
diff --git a/configs/bcm7260_defconfig b/configs/bcm7260_defconfig
new file mode 100644
index 000..a04f700
--- /dev/null
+++ b/configs/bcm7260_defconfig
@@ -0,0 +1,23 @@
+CONFIG_ARM=y
+CONFIG_ARCH_BCMSTB=y
+CONFIG_TARGET_BCM7260=y
+CONFIG_USE_PRIVATE_LIBGCC=y
+CONFIG_OF_CONTROL=y
+CONFIG_OF_PRIOR_STAGE=y
+CONFIG_DM=y
+CONFIG_ENV_IS_IN_MMC=y
+CONFIG_FIT=y
+CONFIG_FIT_SIGNATURE=y
+CONFIG_RSA=y
+CONFIG_BLK=n
+CONFIG_SDHCI=y
+CONFIG_MMC_SDHCI=y
+CONFIG_MMC_SDHCI_BCMSTB=y
+CONFIG_CONS_INDEX=3
+CONFIG_BOOTDELAY=1
+CONFIG_SYS_PROMPT="U-Boot>"
+CONFIG_HUSH_PARSER=y
+CONFIG_SYS_TEXT_BASE=0x1010
+CONFIG_SYS_NS16550_COM3=0xf040c000
+CONFIG_EFI_LOADER=n
+CONFIG_EFI_PARTITION=y
diff --git a/include/configs/bcm7260.h b/include/configs/bcm7260.h
new file mode 100644
index 000..1a5eab1
--- /dev/null
+++ b/include/configs/bcm7260.h
@@ -0,0 +1,35 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * (C) Copyright 2018  Cisco Systems, Inc.
+ *
+ * Author: Thomas Fitzsimmons 
+ *
+ * Configuration settings for the Broadcom BCM7260 SoC family.
+ */
+
+#ifndef __CONFIG_H
+#define __CONFIG_H
+
+#define CONFIG_SYS_NS16550_COM30xf040c000
+
+#define CONFIG_NR_DRAM_BANKS   1
+
+#define CONFIG_SYS_TEXT_BASE   0x1010
+#define CONFIG_SYS_INIT_RAM_ADDR   0x1020
+
+#define CONFIG_SYS_MALLOC_LEN  ((40 * 1024) << 10) /* 40 MiB */
+
+#include "bcmstb.h"
+
+#define BCMSTB_SDHCI_BASE  0xf0200300
+#define BCMSTB_TIMER_LOW   0xf0412008
+#define BCMSTB_TIMER_HIGH  0xf041200c
+#define BCMSTB_TIMER_FREQUENCY 0xf0412020
+#define BCMSTB_HIF_MSPI_BASE   0xf0203c00
+#define BCMSTB_BSPI_BASE   0xf0203a00
+#define BCMSTB_HIF_SPI_INTR2   0xf0201a00
+#define BCMSTB_CS_REG  0xf0200920
+
+#define CONFIG_CMD_GPT
+
+#endif /* __CONFIG_H */
diff --git a/include/configs/bcmstb.h b/include/configs/bcmstb.h
index c74fe40..2dcefb8 100644
--- a/include/configs/bcmstb.h
+++ b/include/configs/bcmstb.h
@@ -158,9 +158,15 @@ extern phys_addr_t prior_stage_fdt_address;
  */
 #define CONFIG_SYS_REDUNDAND_ENVIRONMENT
 
-#define CONFIG_ENV_OFFSET  0x1e
 #define CONFIG_ENV_SIZE(64 << 10) /* 64 KiB */
-#define CONFIG_ENV_SECT_SIZE   CONFIG_ENV_SIZE
+#if defined(CONFIG_ENV_IS_IN_MMC)
+# define CONFIG_SYS_MMC_ENV_DEV0
+# define CONFIG_SYS_MMC_ENV_PART   0
+# define CONFIG_ENV_OFFSET (0x40a4 * 512)
+#elif defined(CONFIG_ENV_IS_IN_SPI_FLASH)
+# define CONFIG_ENV_OFFSET 0x1e
+# define CONFIG_ENV_SECT_SIZE  CONFIG_ENV_SIZE
+#endif
 #define CONFIG_ENV_OFFSET_REDUND   (CONFIG_ENV_OFFSET + CONFIG_ENV_SIZE)
 #define CONFIG_ENV_OVERWRITE
 
-- 
1.8.3.1

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


[U-Boot] [PATCH] board: arm: bcmstb: Declare get_ticks in timer.h

2018-08-15 Thread Thomas Fitzsimmons
In an earlier proposed patch, bcmstb.c implemented timer_read_counter,
but it was updated to implement get_ticks instead.  This patch updates
the declaration in timer.h accordingly.

Signed-off-by: Thomas Fitzsimmons 
---
 arch/arm/mach-bcmstb/include/mach/timer.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/mach-bcmstb/include/mach/timer.h 
b/arch/arm/mach-bcmstb/include/mach/timer.h
index d05b4d6..039dd66 100644
--- a/arch/arm/mach-bcmstb/include/mach/timer.h
+++ b/arch/arm/mach-bcmstb/include/mach/timer.h
@@ -8,6 +8,6 @@
 #ifndef _BCMSTB_TIMER_H
 #define _BCMSTB_TIMER_H
 
-unsigned long timer_read_counter(void);
+uint64_t get_ticks(void);
 
 #endif /* _BCMSTB_TIMER_H */
-- 
1.8.3.1

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


[U-Boot] [PATCH] arm: bcm7445: Move config defines to bcm7445.h

2018-07-26 Thread Thomas Fitzsimmons
Move some configuration #defines that do not apply to other bcmstb
boards from bcmstb.h to bcm7445.h.

Signed-off-by: Thomas Fitzsimmons 
---
 include/configs/bcm7445.h | 18 --
 include/configs/bcmstb.h  | 13 -
 2 files changed, 16 insertions(+), 15 deletions(-)

diff --git a/include/configs/bcm7445.h b/include/configs/bcm7445.h
index f720035..4601adf 100644
--- a/include/configs/bcm7445.h
+++ b/include/configs/bcm7445.h
@@ -10,10 +10,17 @@
 #ifndef __CONFIG_H
 #define __CONFIG_H
 
-#include "bcmstb.h"
-
 #define CONFIG_SYS_NS16550_COM30xf040ab00
 
+#define CONFIG_NR_DRAM_BANKS   3
+
+#define CONFIG_SYS_TEXT_BASE   0x8010
+#define CONFIG_SYS_INIT_RAM_ADDR   0x8020
+
+#define CONFIG_SYS_MALLOC_LEN  ((10 * 1024) << 10) /* 10 MiB */
+
+#include "bcmstb.h"
+
 #define BCMSTB_SDHCI_BASE  0xf03e0200
 #define BCMSTB_TIMER_LOW   0xf0412008
 #define BCMSTB_TIMER_HIGH  0xf041200c
@@ -23,4 +30,11 @@
 #define BCMSTB_HIF_SPI_INTR2   0xf03e1a00
 #define BCMSTB_CS_REG  0xf03e0920
 
+#define CONFIG_ENV_IS_IN_SPI_FLASH 1
+#define CONFIG_DM_SPI  1
+#define CONFIG_SYS_MAX_FLASH_BANKS 1
+#define CONFIG_CMD_SF
+#define CONFIG_CMD_SPI
+#define CONFIG_CMD_SF_TEST
+
 #endif /* __CONFIG_H */
diff --git a/include/configs/bcmstb.h b/include/configs/bcmstb.h
index 262ef54..c74fe40 100644
--- a/include/configs/bcmstb.h
+++ b/include/configs/bcmstb.h
@@ -87,16 +87,11 @@ extern phys_addr_t prior_stage_fdt_address;
  * MiB.  However, BOLT can be configured to allow loading larger
  * initramfs images, in which case this limitation is eliminated.
  */
-#define CONFIG_NR_DRAM_BANKS   3
-
 #define CONFIG_SYS_SDRAM_BASE  0x
-#define CONFIG_SYS_TEXT_BASE   0x8010
-#define CONFIG_SYS_INIT_RAM_ADDR   0x8020
 #define CONFIG_SYS_INIT_RAM_SIZE   0x10
 #define CONFIG_SYS_INIT_SP_ADDR(CONFIG_SYS_INIT_RAM_ADDR + 
\
 CONFIG_SYS_INIT_RAM_SIZE - \
 GENERATED_GBL_DATA_SIZE)
-#define CONFIG_SYS_MALLOC_LEN  ((10 * 1024) << 10) /* 10 MiB */
 #define CONFIG_SYS_LOAD_ADDR   0x200
 
 /*
@@ -141,9 +136,6 @@ extern phys_addr_t prior_stage_fdt_address;
 #define CONFIG_CMD_ASKENV
 #define CONFIG_CMD_CACHE
 #define CONFIG_CMD_EXT2
-#define CONFIG_CMD_SF
-#define CONFIG_CMD_SPI
-#define CONFIG_CMD_SF_TEST
 #define CONFIG_CMD_MMC
 
 /*
@@ -166,7 +158,6 @@ extern phys_addr_t prior_stage_fdt_address;
  */
 #define CONFIG_SYS_REDUNDAND_ENVIRONMENT
 
-#define CONFIG_ENV_IS_IN_SPI_FLASH  1
 #define CONFIG_ENV_OFFSET  0x1e
 #define CONFIG_ENV_SIZE(64 << 10) /* 64 KiB */
 #define CONFIG_ENV_SECT_SIZE   CONFIG_ENV_SIZE
@@ -194,8 +185,4 @@ extern phys_addr_t prior_stage_fdt_address;
  */
 #define CONFIG_BOARD_LATE_INIT
 
-#define CONFIG_SYS_MAX_FLASH_BANKS 1
-
-#define CONFIG_DM_SPI 1
-
 #endif /* __BCMSTB_H */
-- 
1.8.3.1

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


[U-Boot] [PATCH] arm: bcm7445: Fix parallel make race condition

2018-07-26 Thread Thomas Fitzsimmons
Move the contents of prior_stage.h into bcmstb.h to prevent a build
failure when bcmstb.h is #include'ed before the asm/arch symbolic link
is present.

Signed-off-by: Thomas Fitzsimmons 
---
 arch/arm/mach-bcmstb/include/mach/prior_stage.h | 30 -
 include/configs/bcmstb.h| 20 -
 2 files changed, 19 insertions(+), 31 deletions(-)
 delete mode 100644 arch/arm/mach-bcmstb/include/mach/prior_stage.h

diff --git a/arch/arm/mach-bcmstb/include/mach/prior_stage.h 
b/arch/arm/mach-bcmstb/include/mach/prior_stage.h
deleted file mode 100644
index 6c36c68..000
--- a/arch/arm/mach-bcmstb/include/mach/prior_stage.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0+ */
-/*
- * (C) Copyright 2018  Cisco Systems, Inc.
- *
- * Author: Thomas Fitzsimmons 
- */
-
-#ifndef _BCMSTB_PRIOR_STAGE_H
-#define _BCMSTB_PRIOR_STAGE_H
-
-#ifndef __ASSEMBLY__
-
-#include 
-
-struct bcmstb_boot_parameters {
-   u32 r0;
-   u32 r1;
-   u32 r2;
-   u32 r3;
-   u32 sp;
-   u32 lr;
-};
-
-extern struct bcmstb_boot_parameters bcmstb_boot_parameters;
-
-extern phys_addr_t prior_stage_fdt_address;
-
-#endif /* __ASSEMBLY__ */
-
-#endif /* _BCMSTB_PRIOR_STAGE_H */
diff --git a/include/configs/bcmstb.h b/include/configs/bcmstb.h
index 8c61780..262ef54 100644
--- a/include/configs/bcmstb.h
+++ b/include/configs/bcmstb.h
@@ -12,7 +12,25 @@
 
 #include "version.h"
 #include 
-#include 
+
+#ifndef __ASSEMBLY__
+
+#include 
+
+struct bcmstb_boot_parameters {
+   u32 r0;
+   u32 r1;
+   u32 r2;
+   u32 r3;
+   u32 sp;
+   u32 lr;
+};
+
+extern struct bcmstb_boot_parameters bcmstb_boot_parameters;
+
+extern phys_addr_t prior_stage_fdt_address;
+
+#endif /* __ASSEMBLY__ */
 
 /*
  * Generic board configuration.
-- 
1.8.3.1

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


Re: [U-Boot] [PATCH v3 1/1] board: arm: Add support for Broadcom BCM7445

2018-06-08 Thread Thomas Fitzsimmons
Florian Fainelli  writes:

> On 06/06/2018 11:35 AM, Thomas Fitzsimmons wrote:
>> Add support for loading U-Boot on the Broadcom 7445 SoC.  This port
>> assumes Broadcom's BOLT bootloader is acting as the second stage
>> bootloader, and U-Boot is acting as the third stage bootloader, loaded
>> as an ELF program by BOLT.
>> 
>> Signed-off-by: Thomas Fitzsimmons 
>> Cc: Stefan Roese 
>> Cc: Tom Rini 
>> Cc: Florian Fainelli 
>> ---
>
> Looks good, still some minor comments about the choice of representation
> for physical addresses of peripherals, see below.
>
>> +config BCMSTB_TIMER_LOW
>> +hex "Address of BCMSTB timer low register"
>> +default 0xf0412008
>
> This looks very simplistic here since the CPU system control timer is a
> 64-bit timer.

This worked via the default get_ticks implementation in lib/time.c,
which tracks rollovers and converts to a 64-bit value.  But I agree it's
better to use the high timer register, so that (among other reasons)
get_ticks reflects total uptime including time spent in BOLT.  I
overrode get_ticks in v4 of the patch to use the high and low timer
registers.

> I am really not a big fan of all of those configurable addresses which
> are a) fixed given a specific SoC family (7445, 7439 etc.) and b) are
> error prone because we let an user change those without necessarily
> knowing what is the implication. I really think sticking those constants
> into a header file would be much more appropriate.

Makes sense, moved to a 7445-specific header in v4.

>> +void enable_caches(void)
>> +{
>> +/*
>> + * Nothing required here, since the prior stage bootloader has
>> + * enabled I-cache and D-cache already.  Implementing this
>> + * function silences the warning in the default function.
>> + */
>
> This heavily depends on how you load your binary from BOLT, so you must
> be careful about this statement here.

In v4 I adjusted the comment and added an entry to the README to
document the expectation.

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


[U-Boot] [PATCH v4 1/1] board: arm: Add support for Broadcom BCM7445

2018-06-08 Thread Thomas Fitzsimmons
Add support for loading U-Boot on the Broadcom 7445 SoC.  This port
assumes Broadcom's BOLT bootloader is acting as the second stage
bootloader, and U-Boot is acting as the third stage bootloader, loaded
as an ELF program by BOLT.

Signed-off-by: Thomas Fitzsimmons 
Cc: Stefan Roese 
Cc: Tom Rini 
Cc: Florian Fainelli 
---
Changes for v4:
   - Use high timer register for get_ticks
   - Move hard-coded register addresses from Kconfig to header
   - Document I-cache/D-cache expectation

 MAINTAINERS |  10 +
 arch/arm/Kconfig|  12 +
 arch/arm/Makefile   |   1 +
 arch/arm/mach-bcmstb/Kconfig|  36 ++
 arch/arm/mach-bcmstb/Makefile   |   8 +
 arch/arm/mach-bcmstb/include/mach/gpio.h|  11 +
 arch/arm/mach-bcmstb/include/mach/hardware.h|  11 +
 arch/arm/mach-bcmstb/include/mach/prior_stage.h |  30 ++
 arch/arm/mach-bcmstb/include/mach/sdhci.h   |  15 +
 arch/arm/mach-bcmstb/include/mach/timer.h   |  13 +
 arch/arm/mach-bcmstb/lowlevel_init.S|  21 ++
 board/broadcom/bcmstb/MAINTAINERS   |   7 +
 board/broadcom/bcmstb/Makefile  |   8 +
 board/broadcom/bcmstb/bcmstb.c  | 194 +++
 configs/bcm7445_defconfig   |  27 ++
 doc/README.bcm7xxx  | 150 
 drivers/mmc/Kconfig |  11 +
 drivers/mmc/Makefile|   1 +
 drivers/mmc/bcmstb_sdhci.c  |  67 
 drivers/spi/Kconfig |   7 +
 drivers/spi/Makefile|   1 +
 drivers/spi/bcmstb_spi.c| 439 
 drivers/spi/spi-uclass.c|   2 +-
 dts/Kconfig |   7 +
 include/configs/bcm7445.h   |  26 ++
 include/configs/bcmstb.h| 183 ++
 include/fdtdec.h|   4 +
 lib/fdtdec.c|   4 +
 28 files changed, 1305 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/mach-bcmstb/Kconfig
 create mode 100644 arch/arm/mach-bcmstb/Makefile
 create mode 100644 arch/arm/mach-bcmstb/include/mach/gpio.h
 create mode 100644 arch/arm/mach-bcmstb/include/mach/hardware.h
 create mode 100644 arch/arm/mach-bcmstb/include/mach/prior_stage.h
 create mode 100644 arch/arm/mach-bcmstb/include/mach/sdhci.h
 create mode 100644 arch/arm/mach-bcmstb/include/mach/timer.h
 create mode 100644 arch/arm/mach-bcmstb/lowlevel_init.S
 create mode 100644 board/broadcom/bcmstb/MAINTAINERS
 create mode 100644 board/broadcom/bcmstb/Makefile
 create mode 100644 board/broadcom/bcmstb/bcmstb.c
 create mode 100644 configs/bcm7445_defconfig
 create mode 100644 doc/README.bcm7xxx
 create mode 100644 drivers/mmc/bcmstb_sdhci.c
 create mode 100644 drivers/spi/bcmstb_spi.c
 create mode 100644 include/configs/bcm7445.h
 create mode 100644 include/configs/bcmstb.h

diff --git a/MAINTAINERS b/MAINTAINERS
index 642c448..58634fc 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -107,6 +107,16 @@ F: drivers/video/bcm2835.c
 F: include/dm/platform_data/serial_bcm283x_mu.h
 F: drivers/pinctrl/broadcom/
 
+ARM BROADCOM BCMSTB
+M: Thomas Fitzsimmons 
+S: Maintained
+F: arch/arm/mach-bcmstb/
+F: board/broadcom/bcmstb/
+F: configs/bcm7445_defconfig
+F: doc/README.bcm7xxx
+F: drivers/mmc/bcmstb_sdhci.c
+F: drivers/spi/bcmstb_spi.c
+
 ARM FREESCALE IMX
 M: Stefano Babic 
 M: Fabio Estevam 
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index dde422b..fa2001b 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -533,6 +533,16 @@ config TARGET_VEXPRESS_CA15_TC2
select CPU_V7_HAS_VIRT
select PL011_SERIAL
 
+config ARCH_BCMSTB
+   bool "Broadcom BCM7XXX family"
+   select CPU_V7A
+   select DM
+   select OF_CONTROL
+   select OF_PRIOR_STAGE
+   help
+ This enables support for Broadcom ARM-based set-top box
+ chipsets, including the 7445 family of chips.
+
 config TARGET_VEXPRESS_CA5X2
bool "Support vexpress_ca5x2"
select CPU_V7A
@@ -1297,6 +1307,8 @@ source "arch/arm/mach-at91/Kconfig"
 
 source "arch/arm/mach-bcm283x/Kconfig"
 
+source "arch/arm/mach-bcmstb/Kconfig"
+
 source "arch/arm/mach-davinci/Kconfig"
 
 source "arch/arm/mach-exynos/Kconfig"
diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index 680c6e8..03252fe 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -54,6 +54,7 @@ PLATFORM_CPPFLAGS += $(arch-y) $(tune-y)
 machine-$(CONFIG_ARCH_ASPEED)  += aspeed
 machine-$(CONFIG_ARCH_AT91)+= at91
 machine-$(CONFIG_ARCH_BCM283X) += bcm283x
+machine-$(CONFIG_ARCH_BCMSTB)  += bcmstb
 machine-$(CONFIG_ARCH_DAVINCI

[U-Boot] [PATCH v4 0/1] board: arm: Add support for Broadcom BCM7445

2018-06-08 Thread Thomas Fitzsimmons
Add support for Broadcom BCM7445

Changes for v4:
   - Use high timer register for get_ticks
   - Move hard-coded register addresses from Kconfig to header
   - Document I-cache/D-cache expectation

Thomas Fitzsimmons (1):
  board: arm: Add support for Broadcom BCM7445

 MAINTAINERS |  10 +
 arch/arm/Kconfig|  12 +
 arch/arm/Makefile   |   1 +
 arch/arm/mach-bcmstb/Kconfig|  36 ++
 arch/arm/mach-bcmstb/Makefile   |   8 +
 arch/arm/mach-bcmstb/include/mach/gpio.h|  11 +
 arch/arm/mach-bcmstb/include/mach/hardware.h|  11 +
 arch/arm/mach-bcmstb/include/mach/prior_stage.h |  30 ++
 arch/arm/mach-bcmstb/include/mach/sdhci.h   |  15 +
 arch/arm/mach-bcmstb/include/mach/timer.h   |  13 +
 arch/arm/mach-bcmstb/lowlevel_init.S|  21 ++
 board/broadcom/bcmstb/MAINTAINERS   |   7 +
 board/broadcom/bcmstb/Makefile  |   8 +
 board/broadcom/bcmstb/bcmstb.c  | 194 +++
 configs/bcm7445_defconfig   |  27 ++
 doc/README.bcm7xxx  | 150 
 drivers/mmc/Kconfig |  11 +
 drivers/mmc/Makefile|   1 +
 drivers/mmc/bcmstb_sdhci.c  |  67 
 drivers/spi/Kconfig |   7 +
 drivers/spi/Makefile|   1 +
 drivers/spi/bcmstb_spi.c| 439 
 drivers/spi/spi-uclass.c|   2 +-
 dts/Kconfig |   7 +
 include/configs/bcm7445.h   |  26 ++
 include/configs/bcmstb.h| 183 ++
 include/fdtdec.h|   4 +
 lib/fdtdec.c|   4 +
 28 files changed, 1305 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/mach-bcmstb/Kconfig
 create mode 100644 arch/arm/mach-bcmstb/Makefile
 create mode 100644 arch/arm/mach-bcmstb/include/mach/gpio.h
 create mode 100644 arch/arm/mach-bcmstb/include/mach/hardware.h
 create mode 100644 arch/arm/mach-bcmstb/include/mach/prior_stage.h
 create mode 100644 arch/arm/mach-bcmstb/include/mach/sdhci.h
 create mode 100644 arch/arm/mach-bcmstb/include/mach/timer.h
 create mode 100644 arch/arm/mach-bcmstb/lowlevel_init.S
 create mode 100644 board/broadcom/bcmstb/MAINTAINERS
 create mode 100644 board/broadcom/bcmstb/Makefile
 create mode 100644 board/broadcom/bcmstb/bcmstb.c
 create mode 100644 configs/bcm7445_defconfig
 create mode 100644 doc/README.bcm7xxx
 create mode 100644 drivers/mmc/bcmstb_sdhci.c
 create mode 100644 drivers/spi/bcmstb_spi.c
 create mode 100644 include/configs/bcm7445.h
 create mode 100644 include/configs/bcmstb.h

-- 
1.8.3.1

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


Re: [U-Boot] [PATCH 1/1] board: arm: Add support for Broadcom BCM7445D0

2018-06-06 Thread Thomas Fitzsimmons
Florian Fainelli  writes:

> On 05/10/2018 06:04 AM, Thomas Fitzsimmons wrote:
>> Florian Fainelli  writes:
>> 
>>> On 05/06/2018 04:09 AM, Thomas Fitzsimmons wrote:

[...]

>>>> +
>>>> +config BCMSTB_ACCOMMODATE_STBLINUX
>>>> +  bool ""
>>>> +  default y
>>>> +  help
>>>> +This prevents U-Boot from adding memory reservations for the
>>>> +  lengths of initramfs and DTB.  Without skipping these,
>>>> +  stblinux's "contiguous memory allocator" (CMA) Linux driver
>>>> +  (cma_driver) will allocate memory ranges smaller than what
>>>> +  are actually available, because it only checks reservation
>>>> +  sizes.  It doesn't check if the reserved range overlaps the
>>>> +  range it allocates.  stblinux also tries to move the DTB to
>>>> +  a lower memory location early in the Linux boot.  If the FIT
>>>> +  image specifies a load address for the initramfs then
>>>> +  sometimes the DTB is moved into the range where the
>>>> +  initramfs image is loaded.  Defining this will mean that
>>>> +  FIT-provided initramfs load addresses are ignored.
>>>
>>> What STB Linux kernel did you observe this with? I am afraid this is
>>> still true about the ranges vs. allocation even in newer kernels, but
>>> that is kind of intented to keep the logic KISS (because it's already
>>> too complicated IMHO).
>> 
>> I investigated the allocation discrepancy and wrote the workaround while
>> we were still using stblinux-3.14.  Since then we've updated to
>> stblinux-4.1 and I've left the workaround enabled, but I haven't
>> investigated its interactions with the newer bmem mechanism.  I should
>> probably revisit this though, with stblinux-4.1 and stblinux-4.9, just
>> to make sure this macro is still useful.
>
> Sounds good, let me know if there is something that does not seem quite
> right, we could fix it.

[...]

In the v3 patch, I keep the FIT's RFS and DTB in-place.  This approach
eliminates the bmem/cma allocation discrepancies.  I compared bmem/cma
dmesg output for stblinux 3.14, 4.1 and 4.9, zImage and ITB builds, on
my eval board, and they're all the same for the same kernel version.
The only thing I noticed is that in 3.14 and 4.1 (zImage and ITB), the
first bmem region is:

   768 MiB at 0x1000

whereas in 4.9 (zImage and ITB), it is:

   760 MiB at 0x1080

This is booting with no kernel command line arguments, so I guess some
default may have changed between stblinux 4.1 and 4.9?

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


Re: [U-Boot] [U-Boot, v2, 1/1] board: arm: Add support for Broadcom BCM7445

2018-06-06 Thread Thomas Fitzsimmons
Tom Rini  writes:

> On Wed, May 23, 2018 at 09:24:03PM -0400, Thomas Fitzsimmons wrote:
>
>> Add support for loading U-Boot on the Broadcom 7445 SoC.  This port
>> assumes Broadcom's BOLT bootloader is acting as the second stage
>> bootloader, and U-Boot is acting as the third stage bootloader, loaded
>> as an ELF program by BOLT.
>> 
>> Signed-off-by: Thomas Fitzsimmons 
>> Cc: Stefan Roese 
>> Cc: Tom Rini 
>> Cc: Florian Fainelli 
>
> Please rebase this to master.  While I can fixup the SPDX tags (and some
> formatting issues from checkpatch.pl)

I think I fixed all of these in v3 (just posted), by adding an entry to
top-level MAINTAINERS and using the new SPDX formatting rules.

> I also run in to: +(bcm7445) In file included from
> ../arch/arm/include/asm/system.h:6:0, +(bcm7445) from
> ../arch/arm/include/asm/cache.h:11, +(bcm7445) from
> ../include/net.h:15, +(bcm7445) from ../include/common.h:519,
> +(bcm7445) from ../lib/asm-offsets.c:14: +(bcm7445)
> ../arch/arm/include/asm/barriers.h:32:24: error: operator '>=' has no
> left operand +(bcm7445) #if __LINUX_ARM_ARCH__ >= 7 +(bcm7445) ^~
> +(bcm7445) ../arch/arm/include/asm/barriers.h:36:26: error: operator
> '==' has no left operand +(bcm7445) #elif __LINUX_ARM_ARCH__ == 6
> +(bcm7445) ^~ +(bcm7445) make[2]: *** [.././Kbuild:44:
> lib/asm-offsets.s] Error 1 +(bcm7445) make[1]: *** [Makefile:1433:
> prepare0] Error 2
>
> Please look into, thanks!

This was caused by a Kconfig option being renamed on master (CPU_V7 to
CPU_V7A).  Fixed in v3.

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


[U-Boot] [PATCH v3 1/1] board: arm: Add support for Broadcom BCM7445

2018-06-06 Thread Thomas Fitzsimmons
Add support for loading U-Boot on the Broadcom 7445 SoC.  This port
assumes Broadcom's BOLT bootloader is acting as the second stage
bootloader, and U-Boot is acting as the third stage bootloader, loaded
as an ELF program by BOLT.

Signed-off-by: Thomas Fitzsimmons 
Cc: Stefan Roese 
Cc: Tom Rini 
Cc: Florian Fainelli 
---
Changes for v3:
   - Rebase to master
   - Add "ARM BROADCOM BCMSTB" entry to top-level MAINTAINERS
   - Fix SPDX formatting
   - In Kconfig use CPU_V7A, not CPU_V7, per acf15001...

 MAINTAINERS |  10 +
 arch/arm/Kconfig|  12 +
 arch/arm/Makefile   |   1 +
 arch/arm/mach-bcmstb/Kconfig|  64 
 arch/arm/mach-bcmstb/Makefile   |   8 +
 arch/arm/mach-bcmstb/include/mach/gpio.h|  11 +
 arch/arm/mach-bcmstb/include/mach/hardware.h|  11 +
 arch/arm/mach-bcmstb/include/mach/prior_stage.h |  30 ++
 arch/arm/mach-bcmstb/include/mach/sdhci.h   |  15 +
 arch/arm/mach-bcmstb/include/mach/timer.h   |  13 +
 arch/arm/mach-bcmstb/lowlevel_init.S|  21 ++
 board/broadcom/bcmstb/MAINTAINERS   |   6 +
 board/broadcom/bcmstb/Makefile  |   8 +
 board/broadcom/bcmstb/bcmstb.c  | 191 +++
 configs/bcm7445_defconfig   |  27 ++
 doc/README.bcm7xxx  | 147 
 drivers/mmc/Kconfig |  11 +
 drivers/mmc/Makefile|   1 +
 drivers/mmc/bcmstb_sdhci.c  |  67 
 drivers/spi/Kconfig |   7 +
 drivers/spi/Makefile|   1 +
 drivers/spi/bcmstb_spi.c| 439 
 drivers/spi/spi-uclass.c|   2 +-
 dts/Kconfig |   7 +
 include/configs/bcmstb.h| 188 ++
 include/fdtdec.h|   4 +
 lib/fdtdec.c|   4 +
 27 files changed, 1305 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/mach-bcmstb/Kconfig
 create mode 100644 arch/arm/mach-bcmstb/Makefile
 create mode 100644 arch/arm/mach-bcmstb/include/mach/gpio.h
 create mode 100644 arch/arm/mach-bcmstb/include/mach/hardware.h
 create mode 100644 arch/arm/mach-bcmstb/include/mach/prior_stage.h
 create mode 100644 arch/arm/mach-bcmstb/include/mach/sdhci.h
 create mode 100644 arch/arm/mach-bcmstb/include/mach/timer.h
 create mode 100644 arch/arm/mach-bcmstb/lowlevel_init.S
 create mode 100644 board/broadcom/bcmstb/MAINTAINERS
 create mode 100644 board/broadcom/bcmstb/Makefile
 create mode 100644 board/broadcom/bcmstb/bcmstb.c
 create mode 100644 configs/bcm7445_defconfig
 create mode 100644 doc/README.bcm7xxx
 create mode 100644 drivers/mmc/bcmstb_sdhci.c
 create mode 100644 drivers/spi/bcmstb_spi.c
 create mode 100644 include/configs/bcmstb.h

diff --git a/MAINTAINERS b/MAINTAINERS
index 642c448..58634fc 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -107,6 +107,16 @@ F: drivers/video/bcm2835.c
 F: include/dm/platform_data/serial_bcm283x_mu.h
 F: drivers/pinctrl/broadcom/
 
+ARM BROADCOM BCMSTB
+M:     Thomas Fitzsimmons 
+S: Maintained
+F: arch/arm/mach-bcmstb/
+F: board/broadcom/bcmstb/
+F: configs/bcm7445_defconfig
+F: doc/README.bcm7xxx
+F: drivers/mmc/bcmstb_sdhci.c
+F: drivers/spi/bcmstb_spi.c
+
 ARM FREESCALE IMX
 M: Stefano Babic 
 M: Fabio Estevam 
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index dde422b..fa2001b 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -533,6 +533,16 @@ config TARGET_VEXPRESS_CA15_TC2
select CPU_V7_HAS_VIRT
select PL011_SERIAL
 
+config ARCH_BCMSTB
+   bool "Broadcom BCM7XXX family"
+   select CPU_V7A
+   select DM
+   select OF_CONTROL
+   select OF_PRIOR_STAGE
+   help
+ This enables support for Broadcom ARM-based set-top box
+ chipsets, including the 7445 family of chips.
+
 config TARGET_VEXPRESS_CA5X2
bool "Support vexpress_ca5x2"
select CPU_V7A
@@ -1297,6 +1307,8 @@ source "arch/arm/mach-at91/Kconfig"
 
 source "arch/arm/mach-bcm283x/Kconfig"
 
+source "arch/arm/mach-bcmstb/Kconfig"
+
 source "arch/arm/mach-davinci/Kconfig"
 
 source "arch/arm/mach-exynos/Kconfig"
diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index 680c6e8..03252fe 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -54,6 +54,7 @@ PLATFORM_CPPFLAGS += $(arch-y) $(tune-y)
 machine-$(CONFIG_ARCH_ASPEED)  += aspeed
 machine-$(CONFIG_ARCH_AT91)+= at91
 machine-$(CONFIG_ARCH_BCM283X) += bcm283x
+machine-$(CONFIG_ARCH_BCMSTB)  += bcmstb
 machine-$(CONFIG_ARCH_DAVINCI) += davinci
 machine-$(CONFIG_ARCH_EXYNOS)  += exynos
 

[U-Boot] [PATCH v3 0/1] board: arm: Add support for Broadcom BCM7445

2018-06-06 Thread Thomas Fitzsimmons
Add support for Broadcom BCM7445

Changes for v3:
   - Rebase to master
   - Add "ARM BROADCOM BCMSTB" entry to top-level MAINTAINERS
   - Fix SPDX formatting
   - In Kconfig use CPU_V7A, not CPU_V7, per acf15001...

Thomas Fitzsimmons (1):
  board: arm: Add support for Broadcom BCM7445

 MAINTAINERS |  10 +
 arch/arm/Kconfig|  12 +
 arch/arm/Makefile   |   1 +
 arch/arm/mach-bcmstb/Kconfig|  64 
 arch/arm/mach-bcmstb/Makefile   |   8 +
 arch/arm/mach-bcmstb/include/mach/gpio.h|  11 +
 arch/arm/mach-bcmstb/include/mach/hardware.h|  11 +
 arch/arm/mach-bcmstb/include/mach/prior_stage.h |  30 ++
 arch/arm/mach-bcmstb/include/mach/sdhci.h   |  15 +
 arch/arm/mach-bcmstb/include/mach/timer.h   |  13 +
 arch/arm/mach-bcmstb/lowlevel_init.S|  21 ++
 board/broadcom/bcmstb/MAINTAINERS   |   6 +
 board/broadcom/bcmstb/Makefile  |   8 +
 board/broadcom/bcmstb/bcmstb.c  | 191 +++
 configs/bcm7445_defconfig   |  27 ++
 doc/README.bcm7xxx  | 147 
 drivers/mmc/Kconfig |  11 +
 drivers/mmc/Makefile|   1 +
 drivers/mmc/bcmstb_sdhci.c  |  67 
 drivers/spi/Kconfig |   7 +
 drivers/spi/Makefile|   1 +
 drivers/spi/bcmstb_spi.c| 439 
 drivers/spi/spi-uclass.c|   2 +-
 dts/Kconfig |   7 +
 include/configs/bcmstb.h| 188 ++
 include/fdtdec.h|   4 +
 lib/fdtdec.c|   4 +
 27 files changed, 1305 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/mach-bcmstb/Kconfig
 create mode 100644 arch/arm/mach-bcmstb/Makefile
 create mode 100644 arch/arm/mach-bcmstb/include/mach/gpio.h
 create mode 100644 arch/arm/mach-bcmstb/include/mach/hardware.h
 create mode 100644 arch/arm/mach-bcmstb/include/mach/prior_stage.h
 create mode 100644 arch/arm/mach-bcmstb/include/mach/sdhci.h
 create mode 100644 arch/arm/mach-bcmstb/include/mach/timer.h
 create mode 100644 arch/arm/mach-bcmstb/lowlevel_init.S
 create mode 100644 board/broadcom/bcmstb/MAINTAINERS
 create mode 100644 board/broadcom/bcmstb/Makefile
 create mode 100644 board/broadcom/bcmstb/bcmstb.c
 create mode 100644 configs/bcm7445_defconfig
 create mode 100644 doc/README.bcm7xxx
 create mode 100644 drivers/mmc/bcmstb_sdhci.c
 create mode 100644 drivers/spi/bcmstb_spi.c
 create mode 100644 include/configs/bcmstb.h

-- 
1.8.3.1

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


[U-Boot] [PATCH v2 1/1] board: arm: Add support for Broadcom BCM7445

2018-05-23 Thread Thomas Fitzsimmons
Add support for loading U-Boot on the Broadcom 7445 SoC.  This port
assumes Broadcom's BOLT bootloader is acting as the second stage
bootloader, and U-Boot is acting as the third stage bootloader, loaded
as an ELF program by BOLT.

Signed-off-by: Thomas Fitzsimmons <fitz...@fitzsim.org>
Cc: Stefan Roese <s...@denx.de>
Cc: Tom Rini <tr...@konsulko.com>
Cc: Florian Fainelli <f.faine...@gmail.com>
---
Changes for v2:
   - Reorganize Kconfig to create ARCH_BCMSTB
   - Use generic bcmstb SoC name wherever possible
   - Eliminate crt0.S changes by moving relocation logic to bcmstb.c
   - Use debug() macro where appropriate
   - Read bcmstb_spi register base addresses from prior stage device
 tree, where possible
   - Read bcmstb_sdhci register base address from prior stage DT
   - Make timer register addresses configurable
   - Fix BOLT typos
   - Eliminate CONFIG_BCMSTB_ACCOMMODATE_STBLINUX by keeping FIT
 initramfs and device tree binary in-place
   - Add README.bcm7xxx
   - Read memory configuration from prior stage device tree
   - Add CONFIG_OF_PRIOR_STAGE support in spi-uclass.c
   - Fix issues reported by checkpatch.pl
   - Fix issues reported by sparse
   - Update some comments and formatting
   - Add a MAINTAINERS file

 arch/arm/Kconfig|  12 +
 arch/arm/Makefile   |   1 +
 arch/arm/mach-bcmstb/Kconfig|  64 
 arch/arm/mach-bcmstb/Makefile   |   9 +
 arch/arm/mach-bcmstb/include/mach/gpio.h|  12 +
 arch/arm/mach-bcmstb/include/mach/hardware.h|  12 +
 arch/arm/mach-bcmstb/include/mach/prior_stage.h |  31 ++
 arch/arm/mach-bcmstb/include/mach/sdhci.h   |  16 +
 arch/arm/mach-bcmstb/include/mach/timer.h   |  14 +
 arch/arm/mach-bcmstb/lowlevel_init.S|  22 ++
 board/broadcom/bcmstb/MAINTAINERS   |   6 +
 board/broadcom/bcmstb/Makefile  |   9 +
 board/broadcom/bcmstb/bcmstb.c  | 192 +++
 configs/bcm7445_defconfig   |  27 ++
 doc/README.bcm7xxx  | 147 
 drivers/mmc/Kconfig |  11 +
 drivers/mmc/Makefile|   1 +
 drivers/mmc/bcmstb_sdhci.c  |  68 
 drivers/spi/Kconfig |   7 +
 drivers/spi/Makefile|   1 +
 drivers/spi/bcmstb_spi.c| 440 
 drivers/spi/spi-uclass.c|   2 +-
 dts/Kconfig |   7 +
 include/configs/bcmstb.h| 189 ++
 include/fdtdec.h|   4 +
 lib/fdtdec.c|   4 +
 26 files changed, 1307 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/mach-bcmstb/Kconfig
 create mode 100644 arch/arm/mach-bcmstb/Makefile
 create mode 100644 arch/arm/mach-bcmstb/include/mach/gpio.h
 create mode 100644 arch/arm/mach-bcmstb/include/mach/hardware.h
 create mode 100644 arch/arm/mach-bcmstb/include/mach/prior_stage.h
 create mode 100644 arch/arm/mach-bcmstb/include/mach/sdhci.h
 create mode 100644 arch/arm/mach-bcmstb/include/mach/timer.h
 create mode 100644 arch/arm/mach-bcmstb/lowlevel_init.S
 create mode 100644 board/broadcom/bcmstb/MAINTAINERS
 create mode 100644 board/broadcom/bcmstb/Makefile
 create mode 100644 board/broadcom/bcmstb/bcmstb.c
 create mode 100644 configs/bcm7445_defconfig
 create mode 100644 doc/README.bcm7xxx
 create mode 100644 drivers/mmc/bcmstb_sdhci.c
 create mode 100644 drivers/spi/bcmstb_spi.c
 create mode 100644 include/configs/bcmstb.h

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 9bd70f4..fa3089f 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -498,6 +498,16 @@ config TARGET_VEXPRESS_CA15_TC2
select CPU_V7_HAS_VIRT
select PL011_SERIAL
 
+config ARCH_BCMSTB
+   bool "Broadcom BCM7XXX family"
+   select CPU_V7
+   select DM
+   select OF_CONTROL
+   select OF_PRIOR_STAGE
+   help
+ This enables support for Broadcom ARM-based set-top box
+ chipsets, including the 7445 family of chips.
+
 config TARGET_VEXPRESS_CA5X2
bool "Support vexpress_ca5x2"
select CPU_V7
@@ -1237,6 +1247,8 @@ source "arch/arm/mach-at91/Kconfig"
 
 source "arch/arm/mach-bcm283x/Kconfig"
 
+source "arch/arm/mach-bcmstb/Kconfig"
+
 source "arch/arm/mach-davinci/Kconfig"
 
 source "arch/arm/mach-exynos/Kconfig"
diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index 4fa8b38..b0cd152 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -53,6 +53,7 @@ PLATFORM_CPPFLAGS += $(arch-y) $(tune-y)
 machine-$(CONFIG_ARCH_ASPEED)  += aspeed
 machine-$(CONFIG_ARCH_AT91)+= at91
 machine-$(CONFIG_ARCH_BCM283X) += bcm283x
+machine-$(CONF

[U-Boot] [PATCH v2 0/1] board: arm: Add support for Broadcom BCM7445

2018-05-23 Thread Thomas Fitzsimmons
Add support for Broadcom BCM7445

Changes for v2:
   - Reorganize Kconfig to create ARCH_BCMSTB
   - Use generic bcmstb SoC name wherever possible
   - Eliminate crt0.S changes by moving relocation logic to bcmstb.c
   - Use debug() macro where appropriate
   - Read bcmstb_spi register base addresses from prior stage device
 tree, where possible
   - Read bcmstb_sdhci register base address from prior stage DT
   - Make timer register addresses configurable
   - Fix BOLT typos
   - Eliminate CONFIG_BCMSTB_ACCOMMODATE_STBLINUX by keeping FIT
 initramfs and device tree binary in-place
   - Add README.bcm7xxx
   - Read memory configuration from prior stage device tree
   - Add CONFIG_OF_PRIOR_STAGE support in spi-uclass.c
   - Fix issues reported by checkpatch.pl
   - Fix issues reported by sparse
   - Update some comments and formatting
   - Add a MAINTAINERS file

Thomas Fitzsimmons (1):
  board: arm: Add support for Broadcom BCM7445

 arch/arm/Kconfig|  12 +
 arch/arm/Makefile   |   1 +
 arch/arm/mach-bcmstb/Kconfig|  64 
 arch/arm/mach-bcmstb/Makefile   |   9 +
 arch/arm/mach-bcmstb/include/mach/gpio.h|  12 +
 arch/arm/mach-bcmstb/include/mach/hardware.h|  12 +
 arch/arm/mach-bcmstb/include/mach/prior_stage.h |  31 ++
 arch/arm/mach-bcmstb/include/mach/sdhci.h   |  16 +
 arch/arm/mach-bcmstb/include/mach/timer.h   |  14 +
 arch/arm/mach-bcmstb/lowlevel_init.S|  22 ++
 board/broadcom/bcmstb/MAINTAINERS   |   6 +
 board/broadcom/bcmstb/Makefile  |   9 +
 board/broadcom/bcmstb/bcmstb.c  | 192 +++
 configs/bcm7445_defconfig   |  27 ++
 doc/README.bcm7xxx  | 147 
 drivers/mmc/Kconfig |  11 +
 drivers/mmc/Makefile|   1 +
 drivers/mmc/bcmstb_sdhci.c  |  68 
 drivers/spi/Kconfig |   7 +
 drivers/spi/Makefile|   1 +
 drivers/spi/bcmstb_spi.c| 440 
 drivers/spi/spi-uclass.c|   2 +-
 dts/Kconfig |   7 +
 include/configs/bcmstb.h| 189 ++
 include/fdtdec.h|   4 +
 lib/fdtdec.c|   4 +
 26 files changed, 1307 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/mach-bcmstb/Kconfig
 create mode 100644 arch/arm/mach-bcmstb/Makefile
 create mode 100644 arch/arm/mach-bcmstb/include/mach/gpio.h
 create mode 100644 arch/arm/mach-bcmstb/include/mach/hardware.h
 create mode 100644 arch/arm/mach-bcmstb/include/mach/prior_stage.h
 create mode 100644 arch/arm/mach-bcmstb/include/mach/sdhci.h
 create mode 100644 arch/arm/mach-bcmstb/include/mach/timer.h
 create mode 100644 arch/arm/mach-bcmstb/lowlevel_init.S
 create mode 100644 board/broadcom/bcmstb/MAINTAINERS
 create mode 100644 board/broadcom/bcmstb/Makefile
 create mode 100644 board/broadcom/bcmstb/bcmstb.c
 create mode 100644 configs/bcm7445_defconfig
 create mode 100644 doc/README.bcm7xxx
 create mode 100644 drivers/mmc/bcmstb_sdhci.c
 create mode 100644 drivers/spi/bcmstb_spi.c
 create mode 100644 include/configs/bcmstb.h

-- 
1.8.3.1

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


Re: [U-Boot] [PATCH 1/1] board: arm: Add support for Broadcom BCM7445D0

2018-05-23 Thread Thomas Fitzsimmons
Tom Rini <tr...@konsulko.com> writes:

> On Sun, May 06, 2018 at 07:09:22AM -0400, Thomas Fitzsimmons wrote:
>
>> Add support for loading U-Boot on the Broadcom 7445D0 SoC.  This port
>> assumes Broadcom's BOLT bootloader is acting as the second stage
>> bootloader, and U-Boot is acting as the third stage bootloader, loaded
>> as an ELF program by BOLT.
>> 
>> Signed-off-by: Thomas Fitzsimmons <fitz...@fitzsim.org>
>> Cc: Stefan Roese <s...@denx.de>
> [snip]
>> diff --git a/arch/arm/lib/crt0.S b/arch/arm/lib/crt0.S
>> index fa81317..f1a6f35 100644
>> --- a/arch/arm/lib/crt0.S
>> +++ b/arch/arm/lib/crt0.S
>> @@ -94,6 +94,7 @@ ENTRY(_main)
>>   * 'here' but relocated.
>>   */
>>  
>> +#if !defined(CONFIG_OF_PRIOR_STAGE)
>>  ldr r0, [r9, #GD_START_ADDR_SP] /* sp = gd->start_addr_sp */
>>  bic r0, r0, #7  /* 8-byte alignment for ABI compliance */
>>  mov sp, r0
>> @@ -108,6 +109,7 @@ ENTRY(_main)
>>  #endif
>>  ldr r0, [r9, #GD_RELOCADDR] /* r0 = gd->relocaddr */
>>  b   relocate_code
>> +#endif
>>  here:
>>  /*
>>   * now relocate vectors
>
> Can you explain this bit a good bit more?

When BOLT loads U-Boot as an ELF program, this relocation code hangs --
I haven't found out why yet -- but if I skip the relocation, U-Boot runs
successfully.  I figured out a different approach to preventing the
relocation, one that only requires logic in an SoC-specific file, so v2
of the patch will not have any crt0.S changes.

>> +config BCHP_BSPI_MAST_N_BOOT_CTRL
>> +hex ""
>> +default 0x003e3208
>
> Doing hex "" seems wrong.  What are you doing here exactly?

I've reorganized all these into more appropriate locations, and
documented all the remaining Kconfig items, which you'll see in the v2
patch I'll post shortly.

>> diff --git a/common/fdt_support.c b/common/fdt_support.c
>> index 66a313e..f07dfe3 100644
>> --- a/common/fdt_support.c
>> +++ b/common/fdt_support.c
>> @@ -242,11 +242,13 @@ int fdt_initrd(void *fdt, ulong initrd_start, ulong 
>> initrd_end)
>>  }
>>  }
>>  
>> +#if !defined(CONFIG_BCMSTB_ACCOMMODATE_STBLINUX)
>>  err = fdt_add_mem_rsv(fdt, initrd_start, initrd_end - initrd_start);
>>  if (err < 0) {
>>  printf("fdt_initrd: %s\n", fdt_strerror(err));
>>  return err;
>>  }
>> +#endif
>
> Why do we need this?

The background is that stblinux is designed to use some physical memory
for Linux itself, and leave the rest of physical memory for direct use
by video decode blocks in the SoC.

Basically, without making accommodations for it in U-Boot, stblinux will
allocate less memory for use by the video decode blocks than is actually
available, even if it could safely allocate more.

In v2 of the patch, I've documented a different approach to loading FIT
images (one that keeps the RFS and DTB in-place), which eliminates the
need for this configuration macro.

>> +#ifdef DEBUG
>> +static int debug_tx_rx;
>> +#define D(fmt, args...) debug_cond(debug_tx_rx, fmt, ##args)
>> +#else
>> +#define D(fmt, args...)
>> +#endif
>
> We have dbg() etc, please use.  Thanks!

OK, done in v2 of the patch.

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


Re: [U-Boot] [PATCH 1/1] board: arm: Add support for Broadcom BCM7445D0

2018-05-10 Thread Thomas Fitzsimmons
Florian Fainelli <f.faine...@gmail.com> writes:

> On 05/06/2018 04:09 AM, Thomas Fitzsimmons wrote:
>> Add support for loading U-Boot on the Broadcom 7445D0 SoC.  This port
>> assumes Broadcom's BOLT bootloader is acting as the second stage
>> bootloader, and U-Boot is acting as the third stage bootloader, loaded
>> as an ELF program by BOLT.
>> 
>> Signed-off-by: Thomas Fitzsimmons <fitz...@fitzsim.org>
>> Cc: Stefan Roese <s...@denx.de>
>
>> 
>> diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
>> index 9bd70f4..b2df30a 100644
>> --- a/arch/arm/Kconfig
>> +++ b/arch/arm/Kconfig
>> @@ -498,6 +498,17 @@ config TARGET_VEXPRESS_CA15_TC2
>>  select CPU_V7_HAS_VIRT
>>  select PL011_SERIAL
>>  
>> +config TARGET_BCM7445D0
>> +bool "Broadcom 7445D0 TSBL"
>> +select CPU_V7
>> +select SUPPORT_SPL
>> +help
>> +  Support for the Broadcom 7445D0 SoC.  This port assumes Bolt
>
> BOLT
>
>> +  is acting as the second stage bootloader, and U-Boot is
>> +  acting as the third stage bootloader (TSBL), loaded by Bolt.
>
> again BOLT

Oops, will fix in a v2 patch.

>> +  This port may work on other BCM7xxx boards with
>> +  configuration changes.
>
> There are other revisions than D0, so I would just name this
> TARGET_BCM7445. You would likely want to create a TARGET_BRCMSTB general
> menu which would encompass all ARMv7-A based SoCs from the Broadcom
> STB/CM division, and then have per-chip Kconfig options (similar to what
> the older <= 3.14 STB Linux kernels did).

OK, will try this in v2.

>> +
>> +config BCMSTB_ACCOMMODATE_STBLINUX
>> +bool ""
>> +default y
>> +help
>> +  This prevents U-Boot from adding memory reservations for the
>> +  lengths of initramfs and DTB.  Without skipping these,
>> +  stblinux's "contiguous memory allocator" (CMA) Linux driver
>> +  (cma_driver) will allocate memory ranges smaller than what
>> +  are actually available, because it only checks reservation
>> +  sizes.  It doesn't check if the reserved range overlaps the
>> +  range it allocates.  stblinux also tries to move the DTB to
>> +  a lower memory location early in the Linux boot.  If the FIT
>> +  image specifies a load address for the initramfs then
>> +  sometimes the DTB is moved into the range where the
>> +  initramfs image is loaded.  Defining this will mean that
>> +  FIT-provided initramfs load addresses are ignored.
>
> What STB Linux kernel did you observe this with? I am afraid this is
> still true about the ranges vs. allocation even in newer kernels, but
> that is kind of intented to keep the logic KISS (because it's already
> too complicated IMHO).

I investigated the allocation discrepancy and wrote the workaround while
we were still using stblinux-3.14.  Since then we've updated to
stblinux-4.1 and I've left the workaround enabled, but I haven't
investigated its interactions with the newer bmem mechanism.  I should
probably revisit this though, with stblinux-4.1 and stblinux-4.9, just
to make sure this macro is still useful.

>> +
>> +config BCMSTB_SDHCI
>> +bool ""
>> +default y
>> +
>> +config BCMSTB_SDHCI_BASE
>> +hex ""
>> +default 0xf03e0200
>> +
>> +config BCMSTB_SPI_BASE
>> +hex ""
>> +default 0xf03e3400
>
> Why don't you get those from the Device Tree blob that BOLT passes?

During development I did implement that for SDHCI_BASE, so it is
possible.  But I ended up #ifdef'ing it out and hard-coding the address
in production, to keep the runtime logic simpler.  Doing DTB traversal
in code adds complexity but it may achieve portability to different
BCM7xxx SoCs without further code changes, which would be nice.

>> +
>> +config CMD_FDT_MAX_DUMP
>> +int ""
>> +default 256
>> +
>> +config GENERIC_MMC
>> +bool ""
>> +default y
>> +
>> +config MMC_SDMA
>> +bool ""
>> +default y
>> +
>> +config SDHCI
>> +bool ""
>> +default y
>> +
>> +config SYS_BCMSTB_SPI_WAIT
>> +int ""
>> +default 10
>> +
>> +config SYS_FDT_SAVE_ADDRESS
>> +hex ""
>> +default 0x1f0
>> +
>> +config SYS_NO_FLASH
>> +bool ""
>> +default y
>> +
>> +config TIMER_FREQUENCY_REGISTER_ADDRESS
>> +hex "&

[U-Boot] [PATCH 1/1] board: arm: Add support for Broadcom BCM7445D0

2018-05-06 Thread Thomas Fitzsimmons
Add support for loading U-Boot on the Broadcom 7445D0 SoC.  This port
assumes Broadcom's BOLT bootloader is acting as the second stage
bootloader, and U-Boot is acting as the third stage bootloader, loaded
as an ELF program by BOLT.

Signed-off-by: Thomas Fitzsimmons <fitz...@fitzsim.org>
Cc: Stefan Roese <s...@denx.de>
---
 arch/arm/Kconfig|  12 +
 arch/arm/cpu/armv7/Makefile |   1 +
 arch/arm/cpu/armv7/bcm7445d0/Makefile   |  11 +
 arch/arm/cpu/armv7/bcm7445d0/lowlevel_init.S|  24 ++
 arch/arm/lib/crt0.S |   2 +
 arch/arm/mach-bcm7445d0/include/mach/gpio.h |  12 +
 arch/arm/mach-bcm7445d0/include/mach/hardware.h |  12 +
 arch/arm/mach-bcm7445d0/include/mach/sdhci.h|  15 +
 board/broadcom/bcm7445d0/Kconfig| 132 
 board/broadcom/bcm7445d0/Makefile   |  11 +
 board/broadcom/bcm7445d0/bcm7445d0.c| 147 
 common/fdt_support.c|   9 +-
 common/image-fit.c  |   2 +
 configs/bcm7445d0_defconfig |  21 ++
 drivers/mmc/Makefile|   1 +
 drivers/mmc/bcmstb_sdhci.c  |  59 
 drivers/spi/Kconfig |   7 +
 drivers/spi/Makefile|   1 +
 drivers/spi/bcmstb_spi.c| 428 
 dts/Kconfig |   6 +
 include/configs/bcm7445d0.h | 227 +
 include/configs/bcmstb.h|  57 
 lib/fdtdec.c|   8 +
 23 files changed, 1204 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/cpu/armv7/bcm7445d0/Makefile
 create mode 100644 arch/arm/cpu/armv7/bcm7445d0/lowlevel_init.S
 create mode 100644 arch/arm/mach-bcm7445d0/include/mach/gpio.h
 create mode 100644 arch/arm/mach-bcm7445d0/include/mach/hardware.h
 create mode 100644 arch/arm/mach-bcm7445d0/include/mach/sdhci.h
 create mode 100644 board/broadcom/bcm7445d0/Kconfig
 create mode 100644 board/broadcom/bcm7445d0/Makefile
 create mode 100644 board/broadcom/bcm7445d0/bcm7445d0.c
 create mode 100644 configs/bcm7445d0_defconfig
 create mode 100644 drivers/mmc/bcmstb_sdhci.c
 create mode 100644 drivers/spi/bcmstb_spi.c
 create mode 100644 include/configs/bcm7445d0.h
 create mode 100644 include/configs/bcmstb.h

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 9bd70f4..b2df30a 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -498,6 +498,17 @@ config TARGET_VEXPRESS_CA15_TC2
select CPU_V7_HAS_VIRT
select PL011_SERIAL
 
+config TARGET_BCM7445D0
+   bool "Broadcom 7445D0 TSBL"
+   select CPU_V7
+   select SUPPORT_SPL
+   help
+ Support for the Broadcom 7445D0 SoC.  This port assumes Bolt
+ is acting as the second stage bootloader, and U-Boot is
+ acting as the third stage bootloader (TSBL), loaded by Bolt.
+ This port may work on other BCM7xxx boards with
+ configuration changes.
+
 config TARGET_VEXPRESS_CA5X2
bool "Support vexpress_ca5x2"
select CPU_V7
@@ -1320,6 +1331,7 @@ source "board/armltd/vexpress/Kconfig"
 source "board/armltd/vexpress64/Kconfig"
 source "board/broadcom/bcm23550_w1d/Kconfig"
 source "board/broadcom/bcm28155_ap/Kconfig"
+source "board/broadcom/bcm7445d0/Kconfig"
 source "board/broadcom/bcmcygnus/Kconfig"
 source "board/broadcom/bcmnsp/Kconfig"
 source "board/broadcom/bcmns2/Kconfig"
diff --git a/arch/arm/cpu/armv7/Makefile b/arch/arm/cpu/armv7/Makefile
index b14ee54..7183d4d 100644
--- a/arch/arm/cpu/armv7/Makefile
+++ b/arch/arm/cpu/armv7/Makefile
@@ -30,6 +30,7 @@ endif
 
 obj-$(if $(filter bcm235xx,$(SOC)),y) += bcm235xx/
 obj-$(if $(filter bcm281xx,$(SOC)),y) += bcm281xx/
+obj-$(if $(filter bcm7445d0,$(SOC)),y) += bcm7445d0/
 obj-$(if $(filter bcmcygnus,$(SOC)),y) += bcmcygnus/
 obj-$(if $(filter bcmnsp,$(SOC)),y) += bcmnsp/
 obj-$(if $(filter ls102xa,$(SOC)),y) += ls102xa/
diff --git a/arch/arm/cpu/armv7/bcm7445d0/Makefile 
b/arch/arm/cpu/armv7/bcm7445d0/Makefile
new file mode 100644
index 000..796f482
--- /dev/null
+++ b/arch/arm/cpu/armv7/bcm7445d0/Makefile
@@ -0,0 +1,11 @@
+#
+# (C) Copyright 2018
+# Cisco Systems, Inc. 
+#
+# Author :
+#  Thomas Fitzsimmons <fitz...@fitzsim.org>
+#
+# SPDX-License-Identifier: GPL-2.0+
+#
+
+obj-y  := lowlevel_init.o
diff --git a/arch/arm/cpu/armv7/bcm7445d0/lowlevel_init.S 
b/arch/arm/cpu/armv7/bcm7445d0/lowlevel_init.S
new file mode 100644
index 000..1eb67a0
--- /dev/null
+++ b/arch/arm/cpu/armv7/bcm7445d0/lowlevel_init.S
@@ -0,0 +1,24 @@
+/*
+ * (C) Copyright 2018
+ * Cisco Systems, Inc. 
+ *
+ * Author :
+ * Thomas Fitzsimmons <fitz...@fitzsim.org>
+ *
+ * SPDX-License-Identifier:GPL-

[U-Boot] [PATCH 0/1] board: arm: Add support for Broadcom BCM7445D0

2018-05-06 Thread Thomas Fitzsimmons
Hi,

This patch adds support for loading U-Boot on the Broadcom 7445D0 SoC,
as a third stage bootloader loaded by Broadcom's BOLT bootloader.

While this is only a partial port, it does enable some of U-Boot's
flexibility on this SoC, functionality beyond what BOLT provides.
Specifically, it brings:

   - ext4 file system traversal

   - support for loading FIT images

   - advanced scripting

   - support for FIT-provided DTBs instead of relying on the
 BOLT-provided DTB

My team at Cisco is using a customized version of this port in
production.  The same approach may work on other BCM7xxx boards, with
some configuration adjustments and memory layout experimentation.

Stefan Roese reviewed (off-list) some early revisions of these
changes.  This patch is my attempt to rebase on the current U-Boot
master branch.  I'm submitting it in case there is interest in
including this port in upstream U-Boot.

Thomas

Thomas Fitzsimmons (1):
  board: arm: Add support for Broadcom BCM7445D0

 arch/arm/Kconfig|  12 +
 arch/arm/cpu/armv7/Makefile |   1 +
 arch/arm/cpu/armv7/bcm7445d0/Makefile   |  11 +
 arch/arm/cpu/armv7/bcm7445d0/lowlevel_init.S|  24 ++
 arch/arm/lib/crt0.S |   2 +
 arch/arm/mach-bcm7445d0/include/mach/gpio.h |  12 +
 arch/arm/mach-bcm7445d0/include/mach/hardware.h |  12 +
 arch/arm/mach-bcm7445d0/include/mach/sdhci.h|  15 +
 board/broadcom/bcm7445d0/Kconfig| 132 
 board/broadcom/bcm7445d0/Makefile   |  11 +
 board/broadcom/bcm7445d0/bcm7445d0.c| 147 
 common/fdt_support.c|   9 +-
 common/image-fit.c  |   2 +
 configs/bcm7445d0_defconfig |  21 ++
 drivers/mmc/Makefile|   1 +
 drivers/mmc/bcmstb_sdhci.c  |  59 
 drivers/spi/Kconfig |   7 +
 drivers/spi/Makefile|   1 +
 drivers/spi/bcmstb_spi.c| 428 
 dts/Kconfig |   6 +
 include/configs/bcm7445d0.h | 227 +
 include/configs/bcmstb.h|  57 
 lib/fdtdec.c|   8 +
 23 files changed, 1204 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/cpu/armv7/bcm7445d0/Makefile
 create mode 100644 arch/arm/cpu/armv7/bcm7445d0/lowlevel_init.S
 create mode 100644 arch/arm/mach-bcm7445d0/include/mach/gpio.h
 create mode 100644 arch/arm/mach-bcm7445d0/include/mach/hardware.h
 create mode 100644 arch/arm/mach-bcm7445d0/include/mach/sdhci.h
 create mode 100644 board/broadcom/bcm7445d0/Kconfig
 create mode 100644 board/broadcom/bcm7445d0/Makefile
 create mode 100644 board/broadcom/bcm7445d0/bcm7445d0.c
 create mode 100644 configs/bcm7445d0_defconfig
 create mode 100644 drivers/mmc/bcmstb_sdhci.c
 create mode 100644 drivers/spi/bcmstb_spi.c
 create mode 100644 include/configs/bcm7445d0.h
 create mode 100644 include/configs/bcmstb.h

-- 
1.8.3.1

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


[U-Boot] [PATCH] fs: ext4: Prevent infinite loop in ext4fs_iterate_dir

2015-11-18 Thread Thomas Fitzsimmons
If the ext3 journal gets out of sync with what is written on disk, for
example because of an unexpected power cut, ext4fs_read_file can
return an all-zero directory entry.  In that case, ext4fs_iterate_dir
would infinite loop.

This patch detects when a directory entry's direntlen member is 0 and
returns a failure status, which breaks out of the infinite loop.  As a
result, U-Boot will not find files that may subsequently be recovered
when the journal is replayed.

This is better behaviour than hanging in an infinite loop, but as a
further improvement maybe U-Boot could interpret the ext3 journal and
actually find the unsynced entries.

Signed-off-by: Thomas Fitzsimmons <fitz...@cisco.com>
---
 fs/ext4/ext4_common.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/fs/ext4/ext4_common.c b/fs/ext4/ext4_common.c
index 727a2f7..e73223a 100644
--- a/fs/ext4/ext4_common.c
+++ b/fs/ext4/ext4_common.c
@@ -1920,6 +1920,11 @@ int ext4fs_iterate_dir(struct ext2fs_node *dir, char 
*name,
if (status < 0)
return 0;
 
+   if (dirent.direntlen == 0) {
+   printf("Failed to iterate over directory %s\n", name);
+   return 0;
+   }
+
if (dirent.namelen != 0) {
char filename[dirent.namelen + 1];
struct ext2fs_node *fdiro;
-- 
1.8.3.1

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