Re: [PATCH v4 4/7] arm: dts: k3-am625-sk: Enable usb port in u-boot

2024-01-16 Thread Sjoerd Simons
On Tue, 2024-01-16 at 12:17 +0100, Mattijs Korpershoek wrote:
> Hi Sjoerd
> 
> Thank you for the patch.
> 
> On ven., janv. 12, 2024 at 09:52, Sjoerd Simons
>  wrote:
> 
> > Enable usb0 in all boot phases for use with DFU
> > 
> > Signed-off-by: Sjoerd Simons 
> > 
> > ---
> > 
> > Changes in v4:
> > - Don't force usb0 into peripheral mode
> 
> I know that dr_mode = "peripheral" has been removed as requested by
> Roger here:
> 
> https://lore.kernel.org/all/054aa15f-05b9-4645-ab00-fac1be46d...@kernel.org/
> 
> However, the reason for this was the following series:
> https://lore.kernel.org/all/20230706-handle-otg-as-periph-v3-0-27e24fa17...@baylibre.com/
> 
> I've spoken to Julien (off-list) about the above series and he
> confirmed
> that there are no plans to keep working this.
> 
> Therefore, I'd prefer to re-instate dr_mode = "peripheral" here to
> make
> this series simpler and focus on enabling DFU.
> 
> Would that be possible ?

If others agree sure; I really don't care either way (I wouldn't use
the port as host in any case), I only addressed it because i got a
complaint about it :)

Roger?

> 
> > 
> > Changes in v3:
> > - Enable usb nodes in all boot phases
> > 
> > Changes in v2:
> > - Only enable usb port 0 DFU in SPL
> > 
> >  arch/arm/dts/k3-am625-sk-u-boot.dtsi | 8 
> >  1 file changed, 8 insertions(+)
> > 
> > diff --git a/arch/arm/dts/k3-am625-sk-u-boot.dtsi
> > b/arch/arm/dts/k3-am625-sk-u-boot.dtsi
> > index fa778b0ff4c..67c9fa2bbc3 100644
> > --- a/arch/arm/dts/k3-am625-sk-u-boot.dtsi
> > +++ b/arch/arm/dts/k3-am625-sk-u-boot.dtsi
> > @@ -46,3 +46,11 @@
> >  _port2 {
> >     status = "disabled";
> >  };
> > +
> > + {
> > +   bootph-all;
> > +};
> > +
> > + {
> > +   bootph-all;
> > +};
> > -- 
> > 2.43.0

-- 
Sjoerd Simons
Collabora Ltd.


Re: [PATCH v4 5/7] configs: am62x_evm_*: Enable USB and DFU support

2024-01-12 Thread Sjoerd Simons
On Fri, 2024-01-12 at 09:40 -0600, Nishanth Menon wrote:
> On 16:06-20240112, Sjoerd Simons wrote:
> [...]
> > > 
> > > I am starting to wonder if
> > > https://lore.kernel.org/u-boot/20231101170519.39627-1-...@ti.com/
> > > will help us here.
> > 
> > Yes absolutely that would be perfect. Can i suggest we land it as
> > is
> > for now ("fat monolithic config") and once those patches land i'm
> > happy
> > to split things up? 
> > 
> 
> https://libera.irclog.whitequark.org/u-boot/2024-01-12#35590530 I
> think
> Tom agrees in principle (and Simon already acked), so we could go
> down
> this road and refactor - I am always a bit squeamish about redoing
> work
> if the baseline changes or has a reasonable chance of change.. Just
> doing it once and cleanly is my preference.

Well lets see if this will land soonish then, that would be 
amazing :) 

And yes, no doubt, doing it right the first time makes sense. On the
other hand I'm wary about adding more and more blockers for this set. 

-- 
Sjoerd Simons
Collabora Ltd.


Re: [PATCH v4 5/7] configs: am62x_evm_*: Enable USB and DFU support

2024-01-12 Thread Sjoerd Simons
On Fri, 2024-01-12 at 07:19 -0600, Nishanth Menon wrote:
> On 14:09-20240112, Sjoerd Simons wrote:
> [...]
> 
> > > > diff --git a/configs/am62x_evm_a53_defconfig
> > > > b/configs/am62x_evm_a53_defconfig
> > > > index aa96c1b3125..f335eb11e63 100644
> > > > --- a/configs/am62x_evm_a53_defconfig
> > > > +++ b/configs/am62x_evm_a53_defconfig
> > > 
> > > Should we make the a53 also a defconfig fragment allowing reuse
> > > across
> > > multiple boards?
> > 
> > Pros and cons. having all the various options (USB boot, ETH boot,
> > misc
> > other) as fragments would allow easier re-use but make it more
> > complicated for the end-user to get a "full-featured" u-boot. 
> > 
> > My personal preference, as i'm coming with a distribution
> > background,
> > is to always enable as much as possible in a default build to allow
> > maximum flexibility for end-users; Those that need
> > space/performance/whatever optimisation can always do custom
> > builds.
> > 
> > It would be great if we could have a level of indirection here
> > where by
> > default a set of fragments get included such that it's invisible to
> > the
> > end-user that the underlying config is actually quite modular. But
> > I
> > don't think that's currently possible, hence preferring a fat
> > defconfig
> > such that the user/distro can just do `make
> > am62x_evm_a53_defconfig`
> > (and similar for beagleplay)
> > 
> 
> I understand, but I am looking to reduce duplication between boards
> and making it easier for new board devs to be able to pick the
> feature
> group they need - almost all am62x users who desire dfu on a53 will
> need the same options enabled. This also keeps the default u-boot
> foot
> print lower to allow for emmc boot0 partition limitations if any (I
> removed that dependency on beagle by using uda, but other platforms
> still keep u-boot in emmc boot0 and depending on the part and TEE
> binary size, the available space can be constraining)

Fwiw just testing; for the SK board the difference in size for
tispl.bin and u-boot.img is about 200 kilobytes with this extra config.
 
The SK board i have has about 32 megabytes for the hardware boot
partition so unlikely an issue there; For the beagleplay it seems to be
only 4M, but that's currently already on UDA indeed so shouldn't matter
there.

Mind i agree with you in general; and i was looking at moving the full
u-boot into the hw boot partition on beagleplay already so the OS i
flash doesn't have to be device specific.

> 
> I am starting to wonder if
> https://lore.kernel.org/u-boot/20231101170519.39627-1-...@ti.com/
> will help us here.

Yes absolutely that would be perfect. Can i suggest we land it as is
for now ("fat monolithic config") and once those patches land i'm happy
to split things up? 


-- 
Sjoerd Simons
Collabora Ltd.


Re: [PATCH v4 2/7] usb: dwc3: Switch to device mode on gadget start

2024-01-12 Thread Sjoerd Simons
On Fri, 2024-01-12 at 14:56 +0200, Roger Quadros wrote:
> 
> 
> On 12/01/2024 13:06, Sjoerd Simons wrote:
> > On Fri, 2024-01-12 at 12:39 +0200, Roger Quadros wrote:
> > > 
> > > 
> > > On 12/01/2024 10:52, Sjoerd Simons wrote:
> > > > When dr_mode is "otg" the dwc3 is initially configured in _OTG
> > > > mode;
> > > > However in this mode the gadget functionality doesn't work
> > > > without
> > > > further configuration. To resolve that on gadget start switch
> > > > to
> > > > _DEVICE
> > > > mode globally and go back to _OTG on stop again.
> > > > 
> > > > For this the dwc3_set_mode is renamed to dwc3_core_set_mode to
> > > > avoid a
> > > > conflict with the same function exposed by xhci-dwc3
> > > 
> > > Aren't they both doing the same thing? I'd rather define them at
> > > one
> > > place
> > > i.e. dwc3/core.c.
> > 
> > They twiddle the same registers afaict indeed; but the way to get
> > there
> > is rather different. So having just one for both really needs a
> > bigger
> > amount of rework.
> > 
> > > The driver model design for dwc3 looks really broken in u-boot.
> > > 
> > > "snps,dwc3" is claimed by xhci-dwc3.c instead of being claimed by
> > > dwc3/core.c.
> > > This is probably because at the time USB host was the more needed
> > > use
> > > case at u-boot.
> > > 
> > > Ideally dwc3/core.c should claim "snps,dwc3" device and
> > > instantiate
> > > the respective Host/Device/OTG device based on the provided otg
> > > mode.
> > > 
> > > For Host/Device mode it is straight forwa
> > > dwc3/core.c does dwc3_set_mode() depending on the mode and:
> > > for host mode -> register xhci-usb driver.
> > > for device mode -> register UDC device driver.
> > > 
> > > For dual-role mode, the solution is not very clear as I don't
> > > think
> > > there is a role switch framework present
> > > 
> > > To begin with, we could probably restrict it to just device mode
> > > as most platforms were forcing it to device mode in any case as
> > > they
> > > usually have a 2nd USB port that is host only.
> > 
> > Right we don't have role switching; And if we had we'd have to add
> > support of the Type-C controller on the SK boards which determines
> > the
> > roles for this.
> > 
> > This one more minimal patch was modelled after the discussion last
> > year
> > around otg mode[0]. And similar to how the cdns3 driver handles it.
> > Essentially letting host/gadget mode be determined by the usage
> > rather
> > then the cables plugged, which is not pretty but works.
> > 
> > While I agree with you this could all be a lot nicer of u-boot did
> > "proper" OTG/role-switching; I unfortunately don't have the
> > bandwidth
> > to introduce all of that and it seems a shame to block DFU support
> > on
> > it. For reference my previous series just set the peripheral role
> > in
> > the dts which reflects your suggestion of forcing device mode. I'd
> > be
> > wary to do so in the driver because i would hope the OTG handling
> > in
> > dwc3 is there for a reason :) 
> > 
> > 
> > 0: https://lists.denx.de/pipermail/u-boot/2023-August/527709.html
> > 
> > 
> 
> In your current series, how does it work?
> What happens if user starts both host and device controllers?

Testing host functionality on the same port as used for DFU (the only
one that's otg) doesn't seem to work at all, not sure why that is. host
on usb1 (usb-a port, host only) works fine ofcourse.

practically however once the user has used a gadget it's likely they'd
have to reset the host side (or at least do a rescan) though as likely
they'll have also switched around the cable :).

> 
> e.g.
> > usb start
> > dfu 0

That seems to work fine, modulo usb0 not seeing attached devices, but
that's not a regression introduced by this patch.



-- 
Sjoerd Simons
Collabora Ltd.


Re: [PATCH v4 5/7] configs: am62x_evm_*: Enable USB and DFU support

2024-01-12 Thread Sjoerd Simons
On Fri, 2024-01-12 at 06:37 -0600, Nishanth Menon wrote:
> On 09:52-20240112, Sjoerd Simons wrote:
> > Enable USB host as well as USB gadget and DFU support for a53; For
> > the
> > r5 due to the smaller available size create a config fragment for
> > DFU
> > supports which disables support for persistent storage to free up
> > space
> > for USB support
> > 
> > Signed-off-by: Sjoerd Simons 
> > 
> > ---
> > 
> > Changes in v4:
> > - Move R5 dfu config to a config fragment rather then a full
> > defconfig
> > - Don't enable XHCI for the R5 SPL, unneeded
> > 
> > Changes in v3:
> > - Run savedefconfig to adjust to more recent u-boot
> > 
> > Changes in v2:
> > - Create a seperate defconfig for R5
> > 
> >  configs/am62x_evm_a53_defconfig | 30
> > ++
> >  configs/am62x_r5_usbdfu.config  | 28 
> >  2 files changed, 58 insertions(+)
> >  create mode 100644 configs/am62x_r5_usbdfu.config
> > 
> > diff --git a/configs/am62x_evm_a53_defconfig
> > b/configs/am62x_evm_a53_defconfig
> > index aa96c1b3125..f335eb11e63 100644
> > --- a/configs/am62x_evm_a53_defconfig
> > +++ b/configs/am62x_evm_a53_defconfig
> 
> Should we make the a53 also a defconfig fragment allowing reuse
> across
> multiple boards?

Pros and cons. having all the various options (USB boot, ETH boot, misc
other) as fragments would allow easier re-use but make it more
complicated for the end-user to get a "full-featured" u-boot. 

My personal preference, as i'm coming with a distribution background,
is to always enable as much as possible in a default build to allow
maximum flexibility for end-users; Those that need
space/performance/whatever optimisation can always do custom builds.

It would be great if we could have a level of indirection here where by
default a set of fragments get included such that it's invisible to the
end-user that the underlying config is actually quite modular. But I
don't think that's currently possible, hence preferring a fat defconfig
such that the user/distro can just do `make am62x_evm_a53_defconfig`
(and similar for beagleplay)

Regards,
  Sjoerd

> > @@ -1,5 +1,6 @@
> >  CONFIG_ARM=y
> >  CONFIG_ARCH_K3=y
> > +CONFIG_SYS_MALLOC_LEN=0x200
> >  CONFIG_SYS_MALLOC_F_LEN=0x8000
> >  CONFIG_SPL_LIBCOMMON_SUPPORT=y
> >  CONFIG_SPL_LIBGENERIC_SUPPORT=y
> > @@ -41,16 +42,23 @@ CONFIG_SPL_SYS_MALLOC_SIMPLE=y
> >  CONFIG_SPL_STACK_R=y
> >  CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR=y
> >  CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0x1400
> > +CONFIG_SPL_ENV_SUPPORT=y
> >  CONFIG_SPL_FS_LOAD_PAYLOAD_NAME="u-boot.img"
> >  CONFIG_SPL_DM_MAILBOX=y
> >  CONFIG_SPL_DM_SPI_FLASH=y
> >  CONFIG_SPL_POWER_DOMAIN=y
> > +CONFIG_SPL_RAM_SUPPORT=y
> > +CONFIG_SPL_RAM_DEVICE=y
> >  # CONFIG_SPL_SPI_FLASH_TINY is not set
> >  CONFIG_SPL_SPI_FLASH_SFDP_SUPPORT=y
> >  CONFIG_SPL_SPI_LOAD=y
> >  CONFIG_SYS_SPI_U_BOOT_OFFS=0x28
> > +CONFIG_SPL_USB_GADGET=y
> > +CONFIG_SPL_DFU=y
> >  CONFIG_SPL_YMODEM_SUPPORT=y
> > +CONFIG_CMD_DFU=y
> >  CONFIG_CMD_MMC=y
> > +CONFIG_CMD_USB=y
> >  CONFIG_OF_CONTROL=y
> >  CONFIG_SPL_OF_CONTROL=y
> >  CONFIG_MULTI_DTB_FIT=y
> > @@ -61,10 +69,17 @@ CONFIG_SPL_DM=y
> >  CONFIG_SPL_DM_SEQ_ALIAS=y
> >  CONFIG_REGMAP=y
> >  CONFIG_SPL_REGMAP=y
> > +CONFIG_SYSCON=y
> > +CONFIG_SPL_SYSCON=y
> >  CONFIG_SPL_OF_TRANSLATE=y
> >  CONFIG_CLK=y
> >  CONFIG_SPL_CLK=y
> >  CONFIG_CLK_TI_SCI=y
> > +CONFIG_DFU_MMC=y
> > +CONFIG_DFU_RAM=y
> > +CONFIG_DFU_SF=y
> > +CONFIG_SYS_DFU_DATA_BUF_SIZE=0x5000
> > +CONFIG_SYS_DFU_MAX_FILE_SIZE=0x80
> >  CONFIG_DMA_CHANNELS=y
> >  CONFIG_TI_K3_NAVSS_UDMA=y
> >  CONFIG_TI_SCI_PROTOCOL=y
> > @@ -103,4 +118,19 @@ CONFIG_CADENCE_QSPI=y
> >  CONFIG_SYSRESET=y
> >  CONFIG_SPL_SYSRESET=y
> >  CONFIG_SYSRESET_TI_SCI=y
> > +CONFIG_USB=y
> > +CONFIG_DM_USB_GADGET=y
> > +CONFIG_SPL_DM_USB_GADGET=y
> > +CONFIG_USB_XHCI_HCD=y
> > +CONFIG_USB_XHCI_DWC3=y
> > +CONFIG_USB_DWC3=y
> > +CONFIG_USB_DWC3_GENERIC=y
> > +CONFIG_SPL_USB_DWC3_GENERIC=y
> > +CONFIG_SPL_USB_DWC3_AM62=y
> > +CONFIG_USB_DWC3_AM62=y
> > +CONFIG_USB_GADGET=y
> > +CONFIG_USB_GADGET_MANUFACTURER="Texas Instruments"
> > +CONFIG_USB_GADGET_VENDOR_NUM=0x0451
> > +CONFIG_USB_GADGET_PRODUCT_NUM=0x6165
> > +CONFIG_USB_GADGET_DOWNLOAD=y
> >  CONFIG_FS_FAT_MAX_CLUSTSIZE=16384
> > diff --git a/configs/am62x_r5_usbdfu.

Re: [PATCH v4 7/7] doc: board: Add document for DFU boot on am62x SoCs

2024-01-12 Thread Sjoerd Simons
On Fri, 2024-01-12 at 06:36 -0600, Nishanth Menon wrote:
> On 09:52-20240112, Sjoerd Simons wrote:
> > 
> > +DFU based boot
> > +--
> > +
> > +To boot the board over DFU, ensure there is no SD card inserted
> > with a
> > +bootloader. Hold the USR switch while plugging into the Type C to
> > boot into DFU
> > +mode. After power-on the build artifacts needs to be uploaded one
> > by one with a
> > +tool like dfu-util.
> 
> Don't we also need a wiped out emmc unfortunately?

Nope just not having an SD card without boot artifacts is enough (or to
keep things simple no SD card). the USR switch changes the bootmode to
have SD as primary, DFU as fallback, so what's on the eMMC is luckily
not relevant.

So i've been happily testing with the factory eMMC image untouched to
allow me to compare against the factory u-boot behaviour 

> 
> > +
> > +.. include::  ../ti/am62x_sk.rst
> > +    :start-after: .. am62x_evm_rst_include_start_dfu_boot
> > +    :end-before: .. am62x_evm_rst_include_end_dfu_boot
> > +
> >  Debugging U-Boot
> >  
> >  
> > diff --git a/doc/board/ti/am62x_sk.rst b/doc/board/ti/am62x_sk.rst
> > index b12dc85f06b..904a54cd5ff 100644
> > --- a/doc/board/ti/am62x_sk.rst
> > +++ b/doc/board/ti/am62x_sk.rst
> > @@ -105,6 +105,20 @@ Set the variables corresponding to this
> > platform:
> >  
> >  * 3.1 R5:
> >  
> > +.. include::  ../ti/k3.rst
> > +    :start-after: .. k3_rst_include_start_build_steps_spl_r5
> > +    :end-before: .. k3_rst_include_end_build_steps_spl_r5
> > +
> > +* 3.1.1 Alternatively build R5 for DFU boot:
> > +
> > +As the SPL size can get to big when building with support for
> > booting both from
> > +local storage *and* DFU an extra config fragment should be used to
> > enable DFU
> > +support (and disable storage support)
> > +
> > +.. prompt:: bash $
> > +
> > +  export UBOOT_CFG_CORTEXR=${UBOOT_CFG_CORTEXR}
> > am62x_r5_usbdfu.config
> > +
> >  .. include::  ../ti/k3.rst
> >  :start-after: .. k3_rst_include_start_build_steps_spl_r5
> >  :end-before: .. k3_rst_include_end_build_steps_spl_r5
> > @@ -251,6 +265,29 @@ https://www.ti.com/lit/pdf/spruiv7 under the
> > `Boot Mode Pins` section.
> >  
> >  For SW2 and SW1, the switch state in the "ON" position = 1.
> >  
> > +DFU based boot
> > +--
> > +
> > +To boot the board over DFU, set the switches to DFU mode and
> > connect to the
> > +USB Type C DRD Port on the board. After power-on the build
> > artifacts needs to be
> > +uploaded one by one with a tool like dfu-util.
> > +
> > +.. am62x_evm_rst_include_start_dfu_boot
> > +
> > +The initial ROM will have a DFU alt named `bootloader` for the
> > initial R5 spl
> > +upload. The next stages as exposed by u-boot have target alts
> > matching the name
> > +of the artifacts, for these a USB reset has to be done after each
> > upload.
> > +
> > +When using dfu-util the following commands can be used to boot to
> > a u-boot shell:
> > +
> > +.. prompt:: bash $
> > +
> > +  dfu-util -a bootloader -D tiboot3.bin
> > +  dfu-util -R -a tispl -D tispl.bin
> > +  dfu-util -R -a u-boot.img -D u-boot.img
> > +
> > +.. am62x_evm_rst_include_end_dfu_boot
> > +
> >  Debugging U-Boot
> >  
> >  
> > -- 
> > 2.43.0
> > 
> 

-- 
Sjoerd Simons
Collabora Ltd.


Re: [PATCH v4 2/7] usb: dwc3: Switch to device mode on gadget start

2024-01-12 Thread Sjoerd Simons
On Fri, 2024-01-12 at 12:39 +0200, Roger Quadros wrote:
> 
> 
> On 12/01/2024 10:52, Sjoerd Simons wrote:
> > When dr_mode is "otg" the dwc3 is initially configured in _OTG
> > mode;
> > However in this mode the gadget functionality doesn't work without
> > further configuration. To resolve that on gadget start switch to
> > _DEVICE
> > mode globally and go back to _OTG on stop again.
> > 
> > For this the dwc3_set_mode is renamed to dwc3_core_set_mode to
> > avoid a
> > conflict with the same function exposed by xhci-dwc3
> 
> Aren't they both doing the same thing? I'd rather define them at one
> place
> i.e. dwc3/core.c.

They twiddle the same registers afaict indeed; but the way to get there
is rather different. So having just one for both really needs a bigger
amount of rework.

> The driver model design for dwc3 looks really broken in u-boot.
> 
> "snps,dwc3" is claimed by xhci-dwc3.c instead of being claimed by
> dwc3/core.c.
> This is probably because at the time USB host was the more needed use
> case at u-boot.
> 
> Ideally dwc3/core.c should claim "snps,dwc3" device and instantiate
> the respective Host/Device/OTG device based on the provided otg mode.
> 
> For Host/Device mode it is straight forwa
> dwc3/core.c does dwc3_set_mode() depending on the mode and:
> for host mode -> register xhci-usb driver.
> for device mode -> register UDC device driver.
> 
> For dual-role mode, the solution is not very clear as I don't think
> there is a role switch framework present
> 
> To begin with, we could probably restrict it to just device mode
> as most platforms were forcing it to device mode in any case as they
> usually have a 2nd USB port that is host only.

Right we don't have role switching; And if we had we'd have to add
support of the Type-C controller on the SK boards which determines the
roles for this.

This one more minimal patch was modelled after the discussion last year
around otg mode[0]. And similar to how the cdns3 driver handles it.
Essentially letting host/gadget mode be determined by the usage rather
then the cables plugged, which is not pretty but works.

While I agree with you this could all be a lot nicer of u-boot did
"proper" OTG/role-switching; I unfortunately don't have the bandwidth
to introduce all of that and it seems a shame to block DFU support on
it. For reference my previous series just set the peripheral role in
the dts which reflects your suggestion of forcing device mode. I'd be
wary to do so in the driver because i would hope the OTG handling in
dwc3 is there for a reason :) 


0: https://lists.denx.de/pipermail/u-boot/2023-August/527709.html


-- 
Sjoerd Simons
Collabora Ltd.


Re: [PATCH v4 6/7] beagleplay: Add DFU support

2024-01-12 Thread Sjoerd Simons
On Fri, 2024-01-12 at 12:41 +0200, Roger Quadros wrote:
> 
> 
> On 12/01/2024 10:52, Sjoerd Simons wrote:
> > DFU mode on a beagleplay can be used via the Type-C connector by
> > holding
> > the USR switch while powering on.
> > 
> > Configuration is only added for the A53 u-boot parts, for R5 the
> > am62x_r5_usbdfu.config fragment should be used.
> > 
> > Signed-off-by: Sjoerd Simons 
> > 
> > ---
> > 
> > Changes in v4:
> > - New patch
> > 
> >  arch/arm/dts/k3-am625-beagleplay-u-boot.dtsi |  8 ++
> >  board/beagle/beagleplay/beagleplay.env   |  1 +
> >  configs/am62x_beagleplay_a53_defconfig   | 30
> > 
> >  3 files changed, 39 insertions(+)
> > 
> > diff --git a/arch/arm/dts/k3-am625-beagleplay-u-boot.dtsi
> > b/arch/arm/dts/k3-am625-beagleplay-u-boot.dtsi
> > index a723caa5805..0b1e5e70fe2 100644
> > --- a/arch/arm/dts/k3-am625-beagleplay-u-boot.dtsi
> > +++ b/arch/arm/dts/k3-am625-beagleplay-u-boot.dtsi
> > @@ -61,6 +61,14 @@
> >     >;
> >  };
> >  
> > + {
> > +   bootph-all;
> > +};
> > +
> > + {
> > +   bootph-all;
> > +};
> > +
> >  #ifdef CONFIG_TARGET_AM625_A53_BEAGLEPLAY
> >  
> >  #define SPL_NODTB "spl/u-boot-spl-nodtb.bin"
> > diff --git a/board/beagle/beagleplay/beagleplay.env
> > b/board/beagle/beagleplay/beagleplay.env
> > index 4f0a94a8113..85c94856017 100644
> > --- a/board/beagle/beagleplay/beagleplay.env
> > +++ b/board/beagle/beagleplay/beagleplay.env
> > @@ -1,6 +1,7 @@
> >  #include 
> >  #include 
> >  #include 
> > +#include 
> >  
> >  name_kern=Image
> >  console=ttyS2,115200n8
> > diff --git a/configs/am62x_beagleplay_a53_defconfig
> > b/configs/am62x_beagleplay_a53_defconfig
> > index 0be20045a97..dfe04b71810 100644
> > --- a/configs/am62x_beagleplay_a53_defconfig
> > +++ b/configs/am62x_beagleplay_a53_defconfig
> > @@ -1,5 +1,6 @@
> >  CONFIG_ARM=y
> >  CONFIG_ARCH_K3=y
> > +CONFIG_SYS_MALLOC_LEN=0x200
> >  CONFIG_SYS_MALLOC_F_LEN=0x8000
> >  CONFIG_SPL_GPIO=y
> >  CONFIG_SPL_LIBCOMMON_SUPPORT=y
> > @@ -43,15 +44,20 @@ CONFIG_SPL_SYS_MALLOC_SIMPLE=y
> >  CONFIG_SPL_STACK_R=y
> >  CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR=y
> >  CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0x1400
> > +CONFIG_SPL_ENV_SUPPORT=y
> >  CONFIG_SPL_FS_LOAD_PAYLOAD_NAME="u-boot.img"
> >  CONFIG_SPL_I2C=y
> >  CONFIG_SPL_DM_MAILBOX=y
> >  CONFIG_SPL_POWER_DOMAIN=y
> > +CONFIG_SPL_RAM_SUPPORT=y
> > +CONFIG_SPL_RAM_DEVICE=y
> >  CONFIG_SPL_YMODEM_SUPPORT=y
> > +CONFIG_CMD_DFU=y
> >  CONFIG_CMD_GPIO=y
> >  CONFIG_CMD_GPIO_READ=y
> >  CONFIG_CMD_I2C=y
> >  CONFIG_CMD_MMC=y
> > +CONFIG_CMD_USB=y
> >  CONFIG_CMD_PMIC=y
> >  CONFIG_CMD_REGULATOR=y
> >  CONFIG_OF_CONTROL=y
> > @@ -68,6 +74,10 @@ CONFIG_SPL_OF_TRANSLATE=y
> >  CONFIG_CLK=y
> >  CONFIG_SPL_CLK=y
> >  CONFIG_CLK_TI_SCI=y
> > +CONFIG_DFU_MMC=y
> > +CONFIG_DFU_RAM=y
> > +CONFIG_SYS_DFU_DATA_BUF_SIZE=0x5000
> > +CONFIG_SYS_DFU_MAX_FILE_SIZE=0x80
> >  CONFIG_DMA_CHANNELS=y
> >  CONFIG_TI_K3_NAVSS_UDMA=y
> >  CONFIG_TI_SCI_PROTOCOL=y
> > @@ -113,6 +123,26 @@ CONFIG_SOC_TI=y
> >  CONFIG_SYSRESET=y
> >  CONFIG_SPL_SYSRESET=y
> >  CONFIG_SYSRESET_TI_SCI=y
> > +CONFIG_USB=y
> > +CONFIG_DM_USB_GADGET=y
> > +CONFIG_SPL_DM_USB_GADGET=y
> > +CONFIG_USB_XHCI_HCD=y
> > +CONFIG_USB_XHCI_DWC3=y
> 
> XHCI features are really not required for DFU
> but now I see that we depend on XHCI driver to get
> probed even for device mode. lol.

Right yeah i should have made it more clear in the commit message; This
also adds USB host support in the full u-boot in principle (i admit i
didn't actually test that on beagleplay). Which we can do now as the
usb glue is there.

Fwiw in the R5 SPL i've disable XHCI support now based on your comments
last time as USB host support there is not needed ofcourse



-- 
Sjoerd Simons
Collabora Ltd.


Re: [PATCH v4 5/7] configs: am62x_evm_*: Enable USB and DFU support

2024-01-12 Thread Sjoerd Simons
On Fri, 2024-01-12 at 11:58 +0200, Roger Quadros wrote:
> Hi Sjoerd,
> 
> On 12/01/2024 10:52, Sjoerd Simons wrote:
> > Enable USB host as well as USB gadget and DFU support for a53; For
> > the
> > r5 due to the smaller available size create a config fragment for
> > DFU
> > supports which disables support for persistent storage to free up
> > space
> > for USB support
> > 
> > Signed-off-by: Sjoerd Simons 
> > 
> > ---
> > 
> > Changes in v4:
> > - Move R5 dfu config to a config fragment rather then a full
> > defconfig
> > - Don't enable XHCI for the R5 SPL, unneeded
> > 
> > Changes in v3:
> > - Run savedefconfig to adjust to more recent u-boot
> > 
> > Changes in v2:
> > - Create a seperate defconfig for R5
> > 
> >  configs/am62x_evm_a53_defconfig | 30
> > ++
> >  configs/am62x_r5_usbdfu.config  | 28 
> >  2 files changed, 58 insertions(+)
> >  create mode 100644 configs/am62x_r5_usbdfu.config
> > 
> > diff --git a/configs/am62x_evm_a53_defconfig
> > b/configs/am62x_evm_a53_defconfig
> > index aa96c1b3125..f335eb11e63 100644
> > --- a/configs/am62x_evm_a53_defconfig
> > +++ b/configs/am62x_evm_a53_defconfig
> > @@ -1,5 +1,6 @@
> >  CONFIG_ARM=y
> >  CONFIG_ARCH_K3=y
> > +CONFIG_SYS_MALLOC_LEN=0x200
> >  CONFIG_SYS_MALLOC_F_LEN=0x8000
> >  CONFIG_SPL_LIBCOMMON_SUPPORT=y
> >  CONFIG_SPL_LIBGENERIC_SUPPORT=y
> > @@ -41,16 +42,23 @@ CONFIG_SPL_SYS_MALLOC_SIMPLE=y
> >  CONFIG_SPL_STACK_R=y
> >  CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR=y
> >  CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0x1400
> > +CONFIG_SPL_ENV_SUPPORT=y
> >  CONFIG_SPL_FS_LOAD_PAYLOAD_NAME="u-boot.img"
> >  CONFIG_SPL_DM_MAILBOX=y
> >  CONFIG_SPL_DM_SPI_FLASH=y
> >  CONFIG_SPL_POWER_DOMAIN=y
> > +CONFIG_SPL_RAM_SUPPORT=y
> > +CONFIG_SPL_RAM_DEVICE=y
> >  # CONFIG_SPL_SPI_FLASH_TINY is not set
> >  CONFIG_SPL_SPI_FLASH_SFDP_SUPPORT=y
> >  CONFIG_SPL_SPI_LOAD=y
> >  CONFIG_SYS_SPI_U_BOOT_OFFS=0x28
> > +CONFIG_SPL_USB_GADGET=y
> > +CONFIG_SPL_DFU=y
> >  CONFIG_SPL_YMODEM_SUPPORT=y
> > +CONFIG_CMD_DFU=y
> >  CONFIG_CMD_MMC=y
> > +CONFIG_CMD_USB=y
> >  CONFIG_OF_CONTROL=y
> >  CONFIG_SPL_OF_CONTROL=y
> >  CONFIG_MULTI_DTB_FIT=y
> > @@ -61,10 +69,17 @@ CONFIG_SPL_DM=y
> >  CONFIG_SPL_DM_SEQ_ALIAS=y
> >  CONFIG_REGMAP=y
> >  CONFIG_SPL_REGMAP=y
> > +CONFIG_SYSCON=y
> > +CONFIG_SPL_SYSCON=y
> >  CONFIG_SPL_OF_TRANSLATE=y
> >  CONFIG_CLK=y
> >  CONFIG_SPL_CLK=y
> >  CONFIG_CLK_TI_SCI=y
> > +CONFIG_DFU_MMC=y
> > +CONFIG_DFU_RAM=y
> > +CONFIG_DFU_SF=y
> > +CONFIG_SYS_DFU_DATA_BUF_SIZE=0x5000
> > +CONFIG_SYS_DFU_MAX_FILE_SIZE=0x80
> >  CONFIG_DMA_CHANNELS=y
> >  CONFIG_TI_K3_NAVSS_UDMA=y
> >  CONFIG_TI_SCI_PROTOCOL=y
> > @@ -103,4 +118,19 @@ CONFIG_CADENCE_QSPI=y
> >  CONFIG_SYSRESET=y
> >  CONFIG_SPL_SYSRESET=y
> >  CONFIG_SYSRESET_TI_SCI=y
> > +CONFIG_USB=y
> > +CONFIG_DM_USB_GADGET=y
> > +CONFIG_SPL_DM_USB_GADGET=y
> > +CONFIG_USB_XHCI_HCD=y
> > +CONFIG_USB_XHCI_DWC3=y
> > +CONFIG_USB_DWC3=y
> > +CONFIG_USB_DWC3_GENERIC=y
> > +CONFIG_SPL_USB_DWC3_GENERIC=y
> > +CONFIG_SPL_USB_DWC3_AM62=y
> > +CONFIG_USB_DWC3_AM62=y
> > +CONFIG_USB_GADGET=y
> > +CONFIG_USB_GADGET_MANUFACTURER="Texas Instruments"
> > +CONFIG_USB_GADGET_VENDOR_NUM=0x0451
> > +CONFIG_USB_GADGET_PRODUCT_NUM=0x6165
> > +CONFIG_USB_GADGET_DOWNLOAD=y
> >  CONFIG_FS_FAT_MAX_CLUSTSIZE=16384
> > diff --git a/configs/am62x_r5_usbdfu.config
> > b/configs/am62x_r5_usbdfu.config
> > new file mode 100644
> > index 000..772bb2ab935
> > --- /dev/null
> > +++ b/configs/am62x_r5_usbdfu.config
> > @@ -0,0 +1,28 @@
> > +CONFIG_SPL_ENV_SUPPORT=y
> > +CONFIG_SYSCON=y
> > +CONFIG_SPL_SYSCON=y
> > +CONFIG_SYS_DFU_DATA_BUF_SIZE=0x5000
> > +CONFIG_MISC=y
> > +CONFIG_USB=y
> > +CONFIG_DM_USB_GADGET=y
> > +CONFIG_SPL_DM_USB_GADGET=y
> > +CONFIG_USB_DWC3=y
> > +CONFIG_USB_DWC3_GENERIC=y
> > +CONFIG_SPL_USB_DWC3_GENERIC=y
> > +CONFIG_SPL_USB_DWC3_AM62=y
> > +CONFIG_USB_GADGET=y
> > +CONFIG_SPL_USB_GADGET=y
> > +CONFIG_USB_GADGET_MANUFACTURER="Texas Instruments"
> > +CONFIG_USB_GADGET_VENDOR_NUM=0x0451
> > +CONFIG_USB_GADGET_PRODUCT_NUM=0x6165
> > +CONFIG_USB_GADGET_DOWNLOAD=y
> > +CONFIG_SPL_DFU=y
> 
> Why do we need USB DFU support at R5 SPL stage?
> What is the use case?

So we can load the A53 SPL over DFU ? There is no way to get a full DFU
bootchain without the R5 also taking part 


-- 
Sjoerd Simons
Collabora Ltd.


[PATCH v4 7/7] doc: board: Add document for DFU boot on am62x SoCs

2024-01-12 Thread Sjoerd Simons
Both AM62 SK and beagleplay support DFU boot in a similar way now;
Document how to actually run DFU boot for both boards

Signed-off-by: Sjoerd Simons 

---

Changes in v4:
- New patch

 doc/board/beagle/am62x_beagleplay.rst | 12 +
 doc/board/ti/am62x_sk.rst | 37 +++
 2 files changed, 49 insertions(+)

diff --git a/doc/board/beagle/am62x_beagleplay.rst 
b/doc/board/beagle/am62x_beagleplay.rst
index 7784e62b0b7..4c8b0845845 100644
--- a/doc/board/beagle/am62x_beagleplay.rst
+++ b/doc/board/beagle/am62x_beagleplay.rst
@@ -270,6 +270,18 @@ for details.
 To switch to SD card boot mode, hold the USR button while powering on
 with Type-C power supply, then release when power LED lights up.
 
+DFU based boot
+--
+
+To boot the board over DFU, ensure there is no SD card inserted with a
+bootloader. Hold the USR switch while plugging into the Type C to boot into DFU
+mode. After power-on the build artifacts needs to be uploaded one by one with a
+tool like dfu-util.
+
+.. include::  ../ti/am62x_sk.rst
+:start-after: .. am62x_evm_rst_include_start_dfu_boot
+:end-before: .. am62x_evm_rst_include_end_dfu_boot
+
 Debugging U-Boot
 
 
diff --git a/doc/board/ti/am62x_sk.rst b/doc/board/ti/am62x_sk.rst
index b12dc85f06b..904a54cd5ff 100644
--- a/doc/board/ti/am62x_sk.rst
+++ b/doc/board/ti/am62x_sk.rst
@@ -105,6 +105,20 @@ Set the variables corresponding to this platform:
 
 * 3.1 R5:
 
+.. include::  ../ti/k3.rst
+:start-after: .. k3_rst_include_start_build_steps_spl_r5
+:end-before: .. k3_rst_include_end_build_steps_spl_r5
+
+* 3.1.1 Alternatively build R5 for DFU boot:
+
+As the SPL size can get to big when building with support for booting both from
+local storage *and* DFU an extra config fragment should be used to enable DFU
+support (and disable storage support)
+
+.. prompt:: bash $
+
+  export UBOOT_CFG_CORTEXR=${UBOOT_CFG_CORTEXR} am62x_r5_usbdfu.config
+
 .. include::  ../ti/k3.rst
 :start-after: .. k3_rst_include_start_build_steps_spl_r5
 :end-before: .. k3_rst_include_end_build_steps_spl_r5
@@ -251,6 +265,29 @@ https://www.ti.com/lit/pdf/spruiv7 under the `Boot Mode 
Pins` section.
 
 For SW2 and SW1, the switch state in the "ON" position = 1.
 
+DFU based boot
+--
+
+To boot the board over DFU, set the switches to DFU mode and connect to the
+USB Type C DRD Port on the board. After power-on the build artifacts needs to 
be
+uploaded one by one with a tool like dfu-util.
+
+.. am62x_evm_rst_include_start_dfu_boot
+
+The initial ROM will have a DFU alt named `bootloader` for the initial R5 spl
+upload. The next stages as exposed by u-boot have target alts matching the name
+of the artifacts, for these a USB reset has to be done after each upload.
+
+When using dfu-util the following commands can be used to boot to a u-boot 
shell:
+
+.. prompt:: bash $
+
+  dfu-util -a bootloader -D tiboot3.bin
+  dfu-util -R -a tispl -D tispl.bin
+  dfu-util -R -a u-boot.img -D u-boot.img
+
+.. am62x_evm_rst_include_end_dfu_boot
+
 Debugging U-Boot
 
 
-- 
2.43.0



[PATCH v4 6/7] beagleplay: Add DFU support

2024-01-12 Thread Sjoerd Simons
DFU mode on a beagleplay can be used via the Type-C connector by holding
the USR switch while powering on.

Configuration is only added for the A53 u-boot parts, for R5 the
am62x_r5_usbdfu.config fragment should be used.

Signed-off-by: Sjoerd Simons 

---

Changes in v4:
- New patch

 arch/arm/dts/k3-am625-beagleplay-u-boot.dtsi |  8 ++
 board/beagle/beagleplay/beagleplay.env   |  1 +
 configs/am62x_beagleplay_a53_defconfig   | 30 
 3 files changed, 39 insertions(+)

diff --git a/arch/arm/dts/k3-am625-beagleplay-u-boot.dtsi 
b/arch/arm/dts/k3-am625-beagleplay-u-boot.dtsi
index a723caa5805..0b1e5e70fe2 100644
--- a/arch/arm/dts/k3-am625-beagleplay-u-boot.dtsi
+++ b/arch/arm/dts/k3-am625-beagleplay-u-boot.dtsi
@@ -61,6 +61,14 @@
>;
 };
 
+ {
+   bootph-all;
+};
+
+ {
+   bootph-all;
+};
+
 #ifdef CONFIG_TARGET_AM625_A53_BEAGLEPLAY
 
 #define SPL_NODTB "spl/u-boot-spl-nodtb.bin"
diff --git a/board/beagle/beagleplay/beagleplay.env 
b/board/beagle/beagleplay/beagleplay.env
index 4f0a94a8113..85c94856017 100644
--- a/board/beagle/beagleplay/beagleplay.env
+++ b/board/beagle/beagleplay/beagleplay.env
@@ -1,6 +1,7 @@
 #include 
 #include 
 #include 
+#include 
 
 name_kern=Image
 console=ttyS2,115200n8
diff --git a/configs/am62x_beagleplay_a53_defconfig 
b/configs/am62x_beagleplay_a53_defconfig
index 0be20045a97..dfe04b71810 100644
--- a/configs/am62x_beagleplay_a53_defconfig
+++ b/configs/am62x_beagleplay_a53_defconfig
@@ -1,5 +1,6 @@
 CONFIG_ARM=y
 CONFIG_ARCH_K3=y
+CONFIG_SYS_MALLOC_LEN=0x200
 CONFIG_SYS_MALLOC_F_LEN=0x8000
 CONFIG_SPL_GPIO=y
 CONFIG_SPL_LIBCOMMON_SUPPORT=y
@@ -43,15 +44,20 @@ CONFIG_SPL_SYS_MALLOC_SIMPLE=y
 CONFIG_SPL_STACK_R=y
 CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR=y
 CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0x1400
+CONFIG_SPL_ENV_SUPPORT=y
 CONFIG_SPL_FS_LOAD_PAYLOAD_NAME="u-boot.img"
 CONFIG_SPL_I2C=y
 CONFIG_SPL_DM_MAILBOX=y
 CONFIG_SPL_POWER_DOMAIN=y
+CONFIG_SPL_RAM_SUPPORT=y
+CONFIG_SPL_RAM_DEVICE=y
 CONFIG_SPL_YMODEM_SUPPORT=y
+CONFIG_CMD_DFU=y
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_GPIO_READ=y
 CONFIG_CMD_I2C=y
 CONFIG_CMD_MMC=y
+CONFIG_CMD_USB=y
 CONFIG_CMD_PMIC=y
 CONFIG_CMD_REGULATOR=y
 CONFIG_OF_CONTROL=y
@@ -68,6 +74,10 @@ CONFIG_SPL_OF_TRANSLATE=y
 CONFIG_CLK=y
 CONFIG_SPL_CLK=y
 CONFIG_CLK_TI_SCI=y
+CONFIG_DFU_MMC=y
+CONFIG_DFU_RAM=y
+CONFIG_SYS_DFU_DATA_BUF_SIZE=0x5000
+CONFIG_SYS_DFU_MAX_FILE_SIZE=0x80
 CONFIG_DMA_CHANNELS=y
 CONFIG_TI_K3_NAVSS_UDMA=y
 CONFIG_TI_SCI_PROTOCOL=y
@@ -113,6 +123,26 @@ CONFIG_SOC_TI=y
 CONFIG_SYSRESET=y
 CONFIG_SPL_SYSRESET=y
 CONFIG_SYSRESET_TI_SCI=y
+CONFIG_USB=y
+CONFIG_DM_USB_GADGET=y
+CONFIG_SPL_DM_USB_GADGET=y
+CONFIG_USB_XHCI_HCD=y
+CONFIG_USB_XHCI_DWC3=y
+CONFIG_USB_DWC3=y
+CONFIG_USB_DWC3_GENERIC=y
+CONFIG_SPL_USB_DWC3_GENERIC=y
+CONFIG_SPL_USB_DWC3_AM62=y
+CONFIG_USB_DWC3_AM62=y
+CONFIG_USB_GADGET=y
+CONFIG_SPL_USB_GADGET=y
+CONFIG_USB_GADGET_MANUFACTURER="Texas Instruments"
+CONFIG_USB_GADGET_VENDOR_NUM=0x0451
+CONFIG_USB_GADGET_PRODUCT_NUM=0x6165
+CONFIG_USB_GADGET_DOWNLOAD=y
+CONFIG_SPL_DFU=y
 CONFIG_EXT4_WRITE=y
 CONFIG_FS_FAT_MAX_CLUSTSIZE=16384
 CONFIG_LZO=y
+CONFIG_SYSCON=y
+CONFIG_SPL_SYSCON=y
+
-- 
2.43.0



[PATCH v4 5/7] configs: am62x_evm_*: Enable USB and DFU support

2024-01-12 Thread Sjoerd Simons
Enable USB host as well as USB gadget and DFU support for a53; For the
r5 due to the smaller available size create a config fragment for DFU
supports which disables support for persistent storage to free up space
for USB support

Signed-off-by: Sjoerd Simons 

---

Changes in v4:
- Move R5 dfu config to a config fragment rather then a full defconfig
- Don't enable XHCI for the R5 SPL, unneeded

Changes in v3:
- Run savedefconfig to adjust to more recent u-boot

Changes in v2:
- Create a seperate defconfig for R5

 configs/am62x_evm_a53_defconfig | 30 ++
 configs/am62x_r5_usbdfu.config  | 28 
 2 files changed, 58 insertions(+)
 create mode 100644 configs/am62x_r5_usbdfu.config

diff --git a/configs/am62x_evm_a53_defconfig b/configs/am62x_evm_a53_defconfig
index aa96c1b3125..f335eb11e63 100644
--- a/configs/am62x_evm_a53_defconfig
+++ b/configs/am62x_evm_a53_defconfig
@@ -1,5 +1,6 @@
 CONFIG_ARM=y
 CONFIG_ARCH_K3=y
+CONFIG_SYS_MALLOC_LEN=0x200
 CONFIG_SYS_MALLOC_F_LEN=0x8000
 CONFIG_SPL_LIBCOMMON_SUPPORT=y
 CONFIG_SPL_LIBGENERIC_SUPPORT=y
@@ -41,16 +42,23 @@ CONFIG_SPL_SYS_MALLOC_SIMPLE=y
 CONFIG_SPL_STACK_R=y
 CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR=y
 CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0x1400
+CONFIG_SPL_ENV_SUPPORT=y
 CONFIG_SPL_FS_LOAD_PAYLOAD_NAME="u-boot.img"
 CONFIG_SPL_DM_MAILBOX=y
 CONFIG_SPL_DM_SPI_FLASH=y
 CONFIG_SPL_POWER_DOMAIN=y
+CONFIG_SPL_RAM_SUPPORT=y
+CONFIG_SPL_RAM_DEVICE=y
 # CONFIG_SPL_SPI_FLASH_TINY is not set
 CONFIG_SPL_SPI_FLASH_SFDP_SUPPORT=y
 CONFIG_SPL_SPI_LOAD=y
 CONFIG_SYS_SPI_U_BOOT_OFFS=0x28
+CONFIG_SPL_USB_GADGET=y
+CONFIG_SPL_DFU=y
 CONFIG_SPL_YMODEM_SUPPORT=y
+CONFIG_CMD_DFU=y
 CONFIG_CMD_MMC=y
+CONFIG_CMD_USB=y
 CONFIG_OF_CONTROL=y
 CONFIG_SPL_OF_CONTROL=y
 CONFIG_MULTI_DTB_FIT=y
@@ -61,10 +69,17 @@ CONFIG_SPL_DM=y
 CONFIG_SPL_DM_SEQ_ALIAS=y
 CONFIG_REGMAP=y
 CONFIG_SPL_REGMAP=y
+CONFIG_SYSCON=y
+CONFIG_SPL_SYSCON=y
 CONFIG_SPL_OF_TRANSLATE=y
 CONFIG_CLK=y
 CONFIG_SPL_CLK=y
 CONFIG_CLK_TI_SCI=y
+CONFIG_DFU_MMC=y
+CONFIG_DFU_RAM=y
+CONFIG_DFU_SF=y
+CONFIG_SYS_DFU_DATA_BUF_SIZE=0x5000
+CONFIG_SYS_DFU_MAX_FILE_SIZE=0x80
 CONFIG_DMA_CHANNELS=y
 CONFIG_TI_K3_NAVSS_UDMA=y
 CONFIG_TI_SCI_PROTOCOL=y
@@ -103,4 +118,19 @@ CONFIG_CADENCE_QSPI=y
 CONFIG_SYSRESET=y
 CONFIG_SPL_SYSRESET=y
 CONFIG_SYSRESET_TI_SCI=y
+CONFIG_USB=y
+CONFIG_DM_USB_GADGET=y
+CONFIG_SPL_DM_USB_GADGET=y
+CONFIG_USB_XHCI_HCD=y
+CONFIG_USB_XHCI_DWC3=y
+CONFIG_USB_DWC3=y
+CONFIG_USB_DWC3_GENERIC=y
+CONFIG_SPL_USB_DWC3_GENERIC=y
+CONFIG_SPL_USB_DWC3_AM62=y
+CONFIG_USB_DWC3_AM62=y
+CONFIG_USB_GADGET=y
+CONFIG_USB_GADGET_MANUFACTURER="Texas Instruments"
+CONFIG_USB_GADGET_VENDOR_NUM=0x0451
+CONFIG_USB_GADGET_PRODUCT_NUM=0x6165
+CONFIG_USB_GADGET_DOWNLOAD=y
 CONFIG_FS_FAT_MAX_CLUSTSIZE=16384
diff --git a/configs/am62x_r5_usbdfu.config b/configs/am62x_r5_usbdfu.config
new file mode 100644
index 000..772bb2ab935
--- /dev/null
+++ b/configs/am62x_r5_usbdfu.config
@@ -0,0 +1,28 @@
+CONFIG_SPL_ENV_SUPPORT=y
+CONFIG_SYSCON=y
+CONFIG_SPL_SYSCON=y
+CONFIG_SYS_DFU_DATA_BUF_SIZE=0x5000
+CONFIG_MISC=y
+CONFIG_USB=y
+CONFIG_DM_USB_GADGET=y
+CONFIG_SPL_DM_USB_GADGET=y
+CONFIG_USB_DWC3=y
+CONFIG_USB_DWC3_GENERIC=y
+CONFIG_SPL_USB_DWC3_GENERIC=y
+CONFIG_SPL_USB_DWC3_AM62=y
+CONFIG_USB_GADGET=y
+CONFIG_SPL_USB_GADGET=y
+CONFIG_USB_GADGET_MANUFACTURER="Texas Instruments"
+CONFIG_USB_GADGET_VENDOR_NUM=0x0451
+CONFIG_USB_GADGET_PRODUCT_NUM=0x6165
+CONFIG_USB_GADGET_DOWNLOAD=y
+CONFIG_SPL_DFU=y
+# CONFIG_SPL_MMC is not set
+# CONFIG_SPL_FS_FAT is not set
+# CONFIG_SPL_LIBDISK_SUPPORT is not set
+# CONFIG_SPL_SPI is not set
+# CONFIG_SPL_SYS_MALLOC is not set
+# CONFIG_CMD_GPT is not set
+# CONFIG_CMD_MMC is not set
+# CONFIG_CMD_FAT is not set
+# CONFIG_MMC_SDHCI is not set
-- 
2.43.0



[PATCH v4 4/7] arm: dts: k3-am625-sk: Enable usb port in u-boot

2024-01-12 Thread Sjoerd Simons
Enable usb0 in all boot phases for use with DFU

Signed-off-by: Sjoerd Simons 

---

Changes in v4:
- Don't force usb0 into peripheral mode

Changes in v3:
- Enable usb nodes in all boot phases

Changes in v2:
- Only enable usb port 0 DFU in SPL

 arch/arm/dts/k3-am625-sk-u-boot.dtsi | 8 
 1 file changed, 8 insertions(+)

diff --git a/arch/arm/dts/k3-am625-sk-u-boot.dtsi 
b/arch/arm/dts/k3-am625-sk-u-boot.dtsi
index fa778b0ff4c..67c9fa2bbc3 100644
--- a/arch/arm/dts/k3-am625-sk-u-boot.dtsi
+++ b/arch/arm/dts/k3-am625-sk-u-boot.dtsi
@@ -46,3 +46,11 @@
 _port2 {
status = "disabled";
 };
+
+ {
+   bootph-all;
+};
+
+ {
+   bootph-all;
+};
-- 
2.43.0



[PATCH v4 3/7] board: ti: am62x: am62x: include env for DFU

2024-01-12 Thread Sjoerd Simons
Include standard TI K3 dfu environment

Signed-off-by: Sjoerd Simons 

---

(no changes since v3)

Changes in v3:
- Add dfu via environment rather then config headers

Changes in v2:
- Minimize config changes to just DFU configuration

 board/ti/am62x/am62x.env | 1 +
 1 file changed, 1 insertion(+)

diff --git a/board/ti/am62x/am62x.env b/board/ti/am62x/am62x.env
index e53a55c38fb..0651b9cd7cb 100644
--- a/board/ti/am62x/am62x.env
+++ b/board/ti/am62x/am62x.env
@@ -1,6 +1,7 @@
 #include 
 #include 
 #include 
+#include 
 
 name_kern=Image
 console=ttyS2,115200n8
-- 
2.43.0



[PATCH v4 2/7] usb: dwc3: Switch to device mode on gadget start

2024-01-12 Thread Sjoerd Simons
When dr_mode is "otg" the dwc3 is initially configured in _OTG mode;
However in this mode the gadget functionality doesn't work without
further configuration. To resolve that on gadget start switch to _DEVICE
mode globally and go back to _OTG on stop again.

For this the dwc3_set_mode is renamed to dwc3_core_set_mode to avoid a
conflict with the same function exposed by xhci-dwc3

Signed-off-by: Sjoerd Simons 

---

Changes in v4:
- New patch

 drivers/usb/dwc3/core.c   | 10 +-
 drivers/usb/dwc3/core.h   |  1 +
 drivers/usb/dwc3/gadget.c |  6 ++
 3 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 4b4fcd8a22e..d22d4c4bb6a 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -42,7 +42,7 @@
 static LIST_HEAD(dwc3_list);
 /* -- 
*/
 
-static void dwc3_set_mode(struct dwc3 *dwc, u32 mode)
+void dwc3_core_set_mode(struct dwc3 *dwc, u32 mode)
 {
u32 reg;
 
@@ -736,7 +736,7 @@ static int dwc3_core_init_mode(struct dwc3 *dwc)
 
switch (dwc->dr_mode) {
case USB_DR_MODE_PERIPHERAL:
-   dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_DEVICE);
+   dwc3_core_set_mode(dwc, DWC3_GCTL_PRTCAP_DEVICE);
ret = dwc3_gadget_init(dwc);
if (ret) {
dev_err(dwc->dev, "failed to initialize gadget\n");
@@ -744,7 +744,7 @@ static int dwc3_core_init_mode(struct dwc3 *dwc)
}
break;
case USB_DR_MODE_HOST:
-   dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_HOST);
+   dwc3_core_set_mode(dwc, DWC3_GCTL_PRTCAP_HOST);
ret = dwc3_host_init(dwc);
if (ret) {
dev_err(dwc->dev, "failed to initialize host\n");
@@ -752,7 +752,7 @@ static int dwc3_core_init_mode(struct dwc3 *dwc)
}
break;
case USB_DR_MODE_OTG:
-   dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_OTG);
+   dwc3_core_set_mode(dwc, DWC3_GCTL_PRTCAP_OTG);
ret = dwc3_host_init(dwc);
if (ret) {
dev_err(dwc->dev, "failed to initialize host\n");
@@ -810,7 +810,7 @@ static void dwc3_core_exit_mode(struct dwc3 *dwc)
 * switch back to peripheral mode
 * This enables the phy to enter idle and then, if enabled, suspend.
 */
-   dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_DEVICE);
+   dwc3_core_set_mode(dwc, DWC3_GCTL_PRTCAP_DEVICE);
dwc3_gadget_run(dwc);
 }
 
diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
index 4162a682298..1e7eda89a34 100644
--- a/drivers/usb/dwc3/core.h
+++ b/drivers/usb/dwc3/core.h
@@ -1057,6 +1057,7 @@ int dwc3_gadget_resize_tx_fifos(struct dwc3 *dwc);
 void dwc3_of_parse(struct dwc3 *dwc);
 int dwc3_init(struct dwc3 *dwc);
 void dwc3_remove(struct dwc3 *dwc);
+void dwc3_core_set_mode(struct dwc3 *dwc, u32 mode);
 
 static inline int dwc3_host_init(struct dwc3 *dwc)
 { return 0; }
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 406d36ceafe..69d9fe40e2f 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -1468,6 +1468,9 @@ static int dwc3_gadget_start(struct usb_gadget *g,
 
dwc->gadget_driver  = driver;
 
+   if (dwc->dr_mode == DWC3_GCTL_PRTCAP_OTG)
+   dwc3_core_set_mode(dwc, DWC3_GCTL_PRTCAP_DEVICE);
+
reg = dwc3_readl(dwc->regs, DWC3_DCFG);
reg &= ~(DWC3_DCFG_SPEED_MASK);
 
@@ -1559,6 +1562,9 @@ static int dwc3_gadget_stop(struct usb_gadget *g)
__dwc3_gadget_ep_disable(dwc->eps[0]);
__dwc3_gadget_ep_disable(dwc->eps[1]);
 
+   if (dwc->dr_mode == DWC3_GCTL_PRTCAP_OTG)
+   dwc3_core_set_mode(dwc, DWC3_GCTL_PRTCAP_OTG);
+
dwc->gadget_driver  = NULL;
 
spin_unlock_irqrestore(>lock, flags);
-- 
2.43.0



[PATCH v4 1/7] usb: dwc3: Add dwc3 glue driver for am62

2024-01-12 Thread Sjoerd Simons
Add glue code for TI AM62 to the dwc3 driver; Most code adopted from
TI vendor u-boot code.

Signed-off-by: Sjoerd Simons 

---

Changes in v4:
- Add config dependency on SYSCON
- Move defines and constants outside out of function scope

Changes in v2:
- Switch dwc3 glue to a seperate driver rather then in dwc-generic

 drivers/usb/dwc3/Kconfig |  14 
 drivers/usb/dwc3/Makefile|   1 +
 drivers/usb/dwc3/dwc3-am62.c | 125 +++
 3 files changed, 140 insertions(+)
 create mode 100644 drivers/usb/dwc3/dwc3-am62.c

diff --git a/drivers/usb/dwc3/Kconfig b/drivers/usb/dwc3/Kconfig
index c0c8c16fd9c..0100723a68b 100644
--- a/drivers/usb/dwc3/Kconfig
+++ b/drivers/usb/dwc3/Kconfig
@@ -37,6 +37,20 @@ config SPL_USB_DWC3_GENERIC
  Select this for Xilinx ZynqMP and similar Platforms.
  This wrapper supports Host and Peripheral operation modes.
 
+config SPL_USB_DWC3_AM62
+   bool "TI AM62 USB wrapper"
+   depends on SPL_DM_USB && SPL_USB_DWC3_GENERIC && SPL_SYSCON
+   help
+ Select this for TI AM62 Platforms.
+ This wrapper supports Host and Peripheral operation modes.
+
+config USB_DWC3_AM62
+   bool "TI AM62 USB wrapper"
+   depends on DM_USB && USB_DWC3_GENERIC && SYSCON
+   help
+ Select this for TI AM62 Platforms.
+ This wrapper supports Host and Peripheral operation modes.
+
 config USB_DWC3_MESON_G12A
bool "Amlogic Meson G12A USB wrapper"
depends on DM_USB && USB_DWC3 && ARCH_MESON
diff --git a/drivers/usb/dwc3/Makefile b/drivers/usb/dwc3/Makefile
index 97b4f7191ca..a46b6824ab7 100644
--- a/drivers/usb/dwc3/Makefile
+++ b/drivers/usb/dwc3/Makefile
@@ -6,6 +6,7 @@ dwc3-y  := core.o
 
 obj-$(CONFIG_USB_DWC3_GADGET)  += gadget.o ep0.o
 
+obj-$(CONFIG_$(SPL_)USB_DWC3_AM62) += dwc3-am62.o
 obj-$(CONFIG_USB_DWC3_OMAP)+= dwc3-omap.o
 obj-$(CONFIG_USB_DWC3_MESON_G12A)  += dwc3-meson-g12a.o
 obj-$(CONFIG_USB_DWC3_MESON_GXL)   += dwc3-meson-gxl.o
diff --git a/drivers/usb/dwc3/dwc3-am62.c b/drivers/usb/dwc3/dwc3-am62.c
new file mode 100644
index 000..99519602eb2
--- /dev/null
+++ b/drivers/usb/dwc3/dwc3-am62.c
@@ -0,0 +1,125 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * TI AM62 specific glue layer for DWC3
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "dwc3-generic.h"
+
+#define USBSS_MODE_CONTROL 0x1c
+#define USBSS_PHY_CONFIG   0x8
+#define USBSS_PHY_VBUS_SEL_MASKGENMASK(2, 1)
+#define USBSS_PHY_VBUS_SEL_SHIFT   1
+#define USBSS_MODE_VALID   BIT(0)
+#define PHY_PLL_REFCLK_MASKGENMASK(3, 0)
+static const int dwc3_ti_am62_rate_table[] = { /* in KHZ */
+   9600,
+   1,
+   12000,
+   19200,
+   2,
+   24000,
+   25000,
+   26000,
+   38400,
+   4,
+   58000,
+   5,
+   52000,
+};
+
+static void dwc3_ti_am62_glue_configure(struct udevice *dev, int index,
+   enum usb_dr_mode mode)
+{
+   struct clk usb2_refclk;
+   int rate_code, i, ret;
+   unsigned long rate;
+   u32 reg;
+   void *usbss;
+   bool vbus_divider;
+   struct regmap *syscon;
+   struct ofnode_phandle_args args;
+
+   usbss = dev_remap_addr_index(dev, 0);
+   if (IS_ERR(usbss)) {
+   dev_err(dev, "can't map IOMEM resource\n");
+   return;
+   }
+
+   ret = clk_get_by_name(dev, "ref", _refclk);
+   if (ret) {
+   dev_err(dev, "can't get usb2_refclk\n");
+   return;
+   }
+
+   /* Calculate the rate code */
+   rate = clk_get_rate(_refclk);
+   rate /= 1000;   /* To KHz */
+   for (i = 0; i < ARRAY_SIZE(dwc3_ti_am62_rate_table); i++) {
+   if (dwc3_ti_am62_rate_table[i] == rate)
+   break;
+   }
+
+   if (i == ARRAY_SIZE(dwc3_ti_am62_rate_table)) {
+   dev_err(dev, "unsupported usb2_refclk rate: %lu KHz\n", rate);
+   return;
+   }
+
+   rate_code = i;
+
+   /* Read the syscon property */
+   syscon = syscon_regmap_lookup_by_phandle(dev, 
"ti,syscon-phy-pll-refclk");
+   if (IS_ERR(syscon)) {
+   dev_err(dev, "unable to get ti,syscon-phy-pll-refclk regmap\n");
+   return;
+   }
+
+   ret = ofnode_parse_phandle_with_args(dev_ofnode(dev), 
"ti,syscon-phy-pll-refclk", NULL, 1,
+0, );
+   if (ret)
+   return;
+
+   /* Program PHY PLL refclk by reading syscon property */
+   ret = regmap_update_bits(syscon, args.args[0], PHY_PLL_REFCLK_MASK, 
rate_code);
+   if (ret) {
+   dev_err(dev, "failed to set phy p

[PATCH v4 0/7] Add DFU and usb boot for TI am62x SK and beagleplay

2024-01-12 Thread Sjoerd Simons


This series adds DFU support for TI AM62 SK board and new since this
version also for beagleplay.

Since the last revision, apart from beagleplay support the main changes
are:
* Documentation was added on how to use this functionality on both boards
* the R5 configuration is now done via a config fragment rather
  then a full configuraiton
* A new patch was added for dwc3 to work in device mode even if dr_mode is
  configured as otg. Avoiding the need for an explicit switch to
  periphal in the u-boot dts

I will also submit the dts changes to linux so that those can be dropped
again in the near future (hopefully)

Changes in v4:
- Add config dependency on SYSCON
- Move defines and constants outside out of function scope
- Don't force usb0 into peripheral mode
- Move R5 dfu config to a config fragment rather then a full defconfig
- Don't enable XHCI for the R5 SPL, unneeded

Change in v3:
- Add dfu via environment rather then config headers
- Enable usb nodes in all boot phases
- Run savedefconfig to adjust to more recent u-boot

Changes in v2:
- Switch dwc3 glue to a seperate driver rather then in dwc-generic
- Minimize config changes to just DFU configuration
- Only enable usb port 0 DFU in SPL
- Create a seperate defconfig for R5

Sjoerd Simons (7):
  usb: dwc3: Add dwc3 glue driver for am62
  usb: dwc3: Switch to device mode on gadget start
  board: ti: am62x: am62x: include env for DFU
  arm: dts: k3-am625-sk: Enable usb port in u-boot
  configs: am62x_evm_*: Enable USB and DFU support
  beagleplay: Add DFU support
  doc: board: Add document for DFU boot on am62x SoCs

 arch/arm/dts/k3-am625-beagleplay-u-boot.dtsi |   8 ++
 arch/arm/dts/k3-am625-sk-u-boot.dtsi |   8 ++
 board/beagle/beagleplay/beagleplay.env   |   1 +
 board/ti/am62x/am62x.env |   1 +
 configs/am62x_beagleplay_a53_defconfig   |  30 +
 configs/am62x_evm_a53_defconfig  |  30 +
 configs/am62x_r5_usbdfu.config   |  28 +
 doc/board/beagle/am62x_beagleplay.rst|  12 ++
 doc/board/ti/am62x_sk.rst|  37 ++
 drivers/usb/dwc3/Kconfig |  14 +++
 drivers/usb/dwc3/Makefile|   1 +
 drivers/usb/dwc3/core.c  |  10 +-
 drivers/usb/dwc3/core.h  |   1 +
 drivers/usb/dwc3/dwc3-am62.c | 125 +++
 drivers/usb/dwc3/gadget.c|   6 +
 15 files changed, 307 insertions(+), 5 deletions(-)
 create mode 100644 configs/am62x_r5_usbdfu.config
 create mode 100644 drivers/usb/dwc3/dwc3-am62.c

-- 
2.43.0



Re: [PATCH v3 4/4] configs: am62x_evm_*: Enable USB and DFU support

2023-12-13 Thread Sjoerd Simons
Hey Brian,

On Tue, 2023-12-12 at 21:58 -0600, Bryan Brattlof wrote:
[...]
> > 
> >  configs/am62x_evm_a53_defconfig   |  31 ++-
> >  configs/am62x_evm_r5_usbdfu_defconfig | 111
> > ++
> 
> One of the newer developments was the addition of config fragments[0]
> to 
> try to minimize all the duplicate defconfigs for all the different 
> evaluation boards for the same SoC we have in the pipeline. I'm 
> wondering what people would think if we did this for the different 
> boot-mode defconfigs for the 62xx extended family like this usbdfu
> and 
> cpsw? 
> 
> idk how messy it would get trying to disable one of the primary boot 
> modes like MMC and enable USB though... So this may be a idea for 
> another day.

Nishanth mentioned the same and it's something i'd like to play with
(a beagleplay is on the way, but stuck in customs atm for some 
practical tests).

However I think it would make sense to get this landed first and then
try refactoring with config fragments for a second step?


> 
> [0]
> https://lore.kernel.org/u-boot/20231130115552.3580995-16-a-nan...@ti.com/
>  
> 
> ~Bryan

-- 
Sjoerd Simons
Collabora Ltd.


[PATCH v3 2/4] board: ti: am62x: am62x: include env for DFU

2023-12-12 Thread Sjoerd Simons
Include standard TI K3 dfu environment

Signed-off-by: Sjoerd Simons 

---

Changes in v3:
- Add dfu via environment rather then config headers

Changes in v2:
- Minimize config changes to just DFU configuration

 board/ti/am62x/am62x.env | 1 +
 1 file changed, 1 insertion(+)

diff --git a/board/ti/am62x/am62x.env b/board/ti/am62x/am62x.env
index e53a55c38fb..0651b9cd7cb 100644
--- a/board/ti/am62x/am62x.env
+++ b/board/ti/am62x/am62x.env
@@ -1,6 +1,7 @@
 #include 
 #include 
 #include 
+#include 
 
 name_kern=Image
 console=ttyS2,115200n8
-- 
2.43.0



[PATCH v3 4/4] configs: am62x_evm_*: Enable USB and DFU support

2023-12-12 Thread Sjoerd Simons
Enable USB host as well as USB gadget and DFU support for a53; For the
r5 due to the smaller available size create a new config just for
DFU support

Signed-off-by: Sjoerd Simons 

---

Changes in v3:
- Run savedefconfig to adjust to more recent u-boot

Changes in v2:
- Create a seperate defconfig for R5

 configs/am62x_evm_a53_defconfig   |  31 ++-
 configs/am62x_evm_r5_usbdfu_defconfig | 111 ++
 2 files changed, 141 insertions(+), 1 deletion(-)
 create mode 100644 configs/am62x_evm_r5_usbdfu_defconfig

diff --git a/configs/am62x_evm_a53_defconfig b/configs/am62x_evm_a53_defconfig
index df2511546ea..1bd8f0fd9ec 100644
--- a/configs/am62x_evm_a53_defconfig
+++ b/configs/am62x_evm_a53_defconfig
@@ -1,5 +1,6 @@
 CONFIG_ARM=y
 CONFIG_ARCH_K3=y
+CONFIG_SYS_MALLOC_LEN=0x200
 CONFIG_SYS_MALLOC_F_LEN=0x8000
 CONFIG_SPL_LIBCOMMON_SUPPORT=y
 CONFIG_SPL_LIBGENERIC_SUPPORT=y
@@ -40,17 +41,23 @@ CONFIG_SPL_SYS_MALLOC_SIMPLE=y
 CONFIG_SPL_STACK_R=y
 CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR=y
 CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0x1400
+CONFIG_SPL_ENV_SUPPORT=y
 CONFIG_SPL_FS_LOAD_PAYLOAD_NAME="u-boot.img"
 CONFIG_SPL_DM_MAILBOX=y
 CONFIG_SPL_DM_SPI_FLASH=y
 CONFIG_SPL_POWER_DOMAIN=y
+CONFIG_SPL_RAM_SUPPORT=y
+CONFIG_SPL_RAM_DEVICE=y
 # CONFIG_SPL_SPI_FLASH_TINY is not set
 CONFIG_SPL_SPI_FLASH_SFDP_SUPPORT=y
 CONFIG_SPL_SPI_LOAD=y
 CONFIG_SYS_SPI_U_BOOT_OFFS=0x28
+CONFIG_SPL_USB_GADGET=y
+CONFIG_SPL_DFU=y
 CONFIG_SPL_YMODEM_SUPPORT=y
-CONFIG_SYS_BOOTM_LEN=0x80
+CONFIG_CMD_DFU=y
 CONFIG_CMD_MMC=y
+CONFIG_CMD_USB=y
 CONFIG_OF_CONTROL=y
 CONFIG_SPL_OF_CONTROL=y
 CONFIG_MULTI_DTB_FIT=y
@@ -61,10 +68,17 @@ CONFIG_SPL_DM=y
 CONFIG_SPL_DM_SEQ_ALIAS=y
 CONFIG_REGMAP=y
 CONFIG_SPL_REGMAP=y
+CONFIG_SYSCON=y
+CONFIG_SPL_SYSCON=y
 CONFIG_SPL_OF_TRANSLATE=y
 CONFIG_CLK=y
 CONFIG_SPL_CLK=y
 CONFIG_CLK_TI_SCI=y
+CONFIG_DFU_MMC=y
+CONFIG_DFU_RAM=y
+CONFIG_DFU_SF=y
+CONFIG_SYS_DFU_DATA_BUF_SIZE=0x5000
+CONFIG_SYS_DFU_MAX_FILE_SIZE=0x80
 CONFIG_DMA_CHANNELS=y
 CONFIG_TI_K3_NAVSS_UDMA=y
 CONFIG_TI_SCI_PROTOCOL=y
@@ -103,4 +117,19 @@ CONFIG_CADENCE_QSPI=y
 CONFIG_SYSRESET=y
 CONFIG_SPL_SYSRESET=y
 CONFIG_SYSRESET_TI_SCI=y
+CONFIG_USB=y
+CONFIG_DM_USB_GADGET=y
+CONFIG_SPL_DM_USB_GADGET=y
+CONFIG_USB_XHCI_HCD=y
+CONFIG_USB_XHCI_DWC3=y
+CONFIG_USB_DWC3=y
+CONFIG_USB_DWC3_GENERIC=y
+CONFIG_SPL_USB_DWC3_GENERIC=y
+CONFIG_SPL_USB_DWC3_AM62=y
+CONFIG_USB_DWC3_AM62=y
+CONFIG_USB_GADGET=y
+CONFIG_USB_GADGET_MANUFACTURER="Texas Instruments"
+CONFIG_USB_GADGET_VENDOR_NUM=0x0451
+CONFIG_USB_GADGET_PRODUCT_NUM=0x6165
+CONFIG_USB_GADGET_DOWNLOAD=y
 CONFIG_FS_FAT_MAX_CLUSTSIZE=16384
diff --git a/configs/am62x_evm_r5_usbdfu_defconfig 
b/configs/am62x_evm_r5_usbdfu_defconfig
new file mode 100644
index 000..14bc08f60a4
--- /dev/null
+++ b/configs/am62x_evm_r5_usbdfu_defconfig
@@ -0,0 +1,111 @@
+CONFIG_ARM=y
+CONFIG_ARCH_K3=y
+CONFIG_SYS_MALLOC_LEN=0x0800
+CONFIG_SYS_MALLOC_F_LEN=0x9000
+CONFIG_SPL_LIBCOMMON_SUPPORT=y
+CONFIG_SPL_LIBGENERIC_SUPPORT=y
+CONFIG_NR_DRAM_BANKS=2
+CONFIG_SOC_K3_AM625=y
+CONFIG_TARGET_AM625_R5_EVM=y
+CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
+CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x43c3a7f0
+CONFIG_ENV_SIZE=0x2
+CONFIG_DM_GPIO=y
+CONFIG_DEFAULT_DEVICE_TREE="k3-am625-r5-sk"
+CONFIG_SPL_TEXT_BASE=0x43c0
+CONFIG_DM_RESET=y
+CONFIG_SPL_SERIAL=y
+CONFIG_SPL_DRIVERS_MISC=y
+CONFIG_SPL_STACK_R_ADDR=0x8200
+CONFIG_SPL_SYS_MALLOC_F_LEN=0x7000
+CONFIG_SPL_SIZE_LIMIT=0x3A7F0
+CONFIG_SPL_SIZE_LIMIT_PROVIDE_STACK=0x3500
+CONFIG_SPL_LOAD_FIT=y
+CONFIG_SPL_LOAD_FIT_ADDRESS=0x8008
+# CONFIG_DISPLAY_CPUINFO is not set
+CONFIG_SPL_SIZE_LIMIT_SUBTRACT_GD=y
+CONFIG_SPL_SIZE_LIMIT_SUBTRACT_MALLOC=y
+CONFIG_SPL_MAX_SIZE=0x3B000
+CONFIG_SPL_PAD_TO=0x0
+CONFIG_SPL_HAS_BSS_LINKER_SECTION=y
+CONFIG_SPL_BSS_START_ADDR=0x43c3b000
+CONFIG_SPL_BSS_MAX_SIZE=0x3000
+CONFIG_SPL_SYS_REPORT_STACK_F_USAGE=y
+CONFIG_SPL_SYS_MALLOC_SIMPLE=y
+CONFIG_SPL_STACK_R=y
+CONFIG_SPL_SEPARATE_BSS=y
+CONFIG_SPL_EARLY_BSS=y
+CONFIG_SPL_ENV_SUPPORT=y
+CONFIG_SPL_DM_MAILBOX=y
+CONFIG_SPL_DM_RESET=y
+CONFIG_SPL_POWER_DOMAIN=y
+CONFIG_SPL_RAM_SUPPORT=y
+CONFIG_SPL_RAM_DEVICE=y
+CONFIG_SPL_REMOTEPROC=y
+CONFIG_SPL_YMODEM_SUPPORT=y
+CONFIG_HUSH_PARSER=y
+CONFIG_CMD_ASKENV=y
+CONFIG_CMD_DFU=y
+CONFIG_CMD_REMOTEPROC=y
+# CONFIG_CMD_SETEXPR is not set
+CONFIG_CMD_TIME=y
+CONFIG_OF_CONTROL=y
+CONFIG_SPL_OF_CONTROL=y
+CONFIG_SPL_MULTI_DTB_FIT=y
+CONFIG_SPL_MULTI_DTB_FIT_NO_COMPRESSION=y
+CONFIG_SYS_RELOC_GD_ENV_ADDR=y
+CONFIG_SPL_DM=y
+CONFIG_SPL_DM_SEQ_ALIAS=y
+CONFIG_REGMAP=y
+CONFIG_SPL_REGMAP=y
+CONFIG_SYSCON=y
+CONFIG_SPL_SYSCON=y
+CONFIG_SPL_OF_TRANSLATE=y
+CONFIG_CLK=y
+CONFIG_SPL_CLK=y
+CONFIG_SPL_CLK_CCF=y
+CONFIG_SPL_CLK_K3_PLL=y
+CONFIG_SPL_CLK_K3=y
+CONFIG_SYS_DFU_DATA_BUF_SIZE=0x5000
+CONFIG_TI_SCI_PROTOCOL=y
+CONFIG_DA8XX_GPIO=y
+CONFIG_DM_MAILBOX=y
+CONFIG_K3_SEC_PROXY=y
+CONFIG_MISC=y
+CONFIG_ESM_K3=y
+CONFIG_PINCTRL=y
+# CONFIG_PINCTRL_GENERIC is

[PATCH v3 3/4] arm: dts: k3-am625-sk: Enable usb ports in u-boot

2023-12-12 Thread Sjoerd Simons
Enable both usb0 as a peripheral for use with DFU and

Signed-off-by: Sjoerd Simons 

---

Changes in v3:
- Enable usb nodes in all boot phases

Changes in v2:
- Only enable usb port 0 DFU in SPL

 arch/arm/dts/k3-am625-sk-u-boot.dtsi | 9 +
 1 file changed, 9 insertions(+)

diff --git a/arch/arm/dts/k3-am625-sk-u-boot.dtsi 
b/arch/arm/dts/k3-am625-sk-u-boot.dtsi
index fa778b0ff4c..1fc0d407cbf 100644
--- a/arch/arm/dts/k3-am625-sk-u-boot.dtsi
+++ b/arch/arm/dts/k3-am625-sk-u-boot.dtsi
@@ -46,3 +46,12 @@
 _port2 {
status = "disabled";
 };
+
+ {
+   bootph-all;
+};
+
+ {
+   dr_mode = "peripheral";
+   bootph-all;
+};
-- 
2.43.0



[PATCH v3 0/4] Add DFU and usb boot for TI am62x

2023-12-12 Thread Sjoerd Simons


Previous version of this patchset went out back in April and got delayed
for various reasons. As some parts were merge this is a somewhat smaller
set then before.

Patches against u-boot/next to take advantage of the latest dts sync
from linux v6.7-rc1

0: https://lists.denx.de/pipermail/u-boot/2023-April/514642.html

Changes in v3:
- Add dfu via environment rather then config headers
- Enable usb nodes in all boot phases
- Run savedefconfig to adjust to more recent u-boot

Changes in v2:
- Switch dwc3 glue to a seperate driver rather then in dwc-generic
- Minimize config changes to just DFU configuration
- Only enable usb port 0 DFU in SPL
- Create a seperate defconfig for R5

Sjoerd Simons (4):
  usb: dwc3: Add dwc3 glue driver for am62
  board: ti: am62x: am62x: include env for DFU
  arm: dts: k3-am625-sk: Enable usb ports in u-boot
  configs: am62x_evm_*: Enable USB and DFU support

 arch/arm/dts/k3-am625-sk-u-boot.dtsi  |   9 ++
 board/ti/am62x/am62x.env  |   1 +
 configs/am62x_evm_a53_defconfig   |  31 ++-
 configs/am62x_evm_r5_usbdfu_defconfig | 111 +++
 drivers/usb/dwc3/Kconfig  |  14 +++
 drivers/usb/dwc3/Makefile |   1 +
 drivers/usb/dwc3/dwc3-am62.c  | 125 ++
 7 files changed, 291 insertions(+), 1 deletion(-)
 create mode 100644 configs/am62x_evm_r5_usbdfu_defconfig
 create mode 100644 drivers/usb/dwc3/dwc3-am62.c

-- 
2.43.0



[PATCH v3 1/4] usb: dwc3: Add dwc3 glue driver for am62

2023-12-12 Thread Sjoerd Simons
Add glue code for TI AM62 to the dwc3 driver; Most code adopted from
TI vendor u-boot code.

Signed-off-by: Sjoerd Simons 
Reviewed-by: Mattijs Korpershoek 

---

(no changes since v2)

Changes in v2:
- Switch dwc3 glue to a seperate driver rather then in dwc-generic

 drivers/usb/dwc3/Kconfig |  14 
 drivers/usb/dwc3/Makefile|   1 +
 drivers/usb/dwc3/dwc3-am62.c | 125 +++
 3 files changed, 140 insertions(+)
 create mode 100644 drivers/usb/dwc3/dwc3-am62.c

diff --git a/drivers/usb/dwc3/Kconfig b/drivers/usb/dwc3/Kconfig
index c0c8c16fd9c..26a1e1770c5 100644
--- a/drivers/usb/dwc3/Kconfig
+++ b/drivers/usb/dwc3/Kconfig
@@ -37,6 +37,20 @@ config SPL_USB_DWC3_GENERIC
  Select this for Xilinx ZynqMP and similar Platforms.
  This wrapper supports Host and Peripheral operation modes.
 
+config SPL_USB_DWC3_AM62
+   bool "TI AM62 USB wrapper"
+   depends on SPL_DM_USB && SPL_USB_DWC3_GENERIC
+   help
+ Select this for TI AM62 Platforms.
+ This wrapper supports Host and Peripheral operation modes.
+
+config USB_DWC3_AM62
+   bool "TI AM62 USB wrapper"
+   depends on DM_USB && USB_DWC3_GENERIC
+   help
+ Select this for TI AM62 Platforms.
+ This wrapper supports Host and Peripheral operation modes.
+
 config USB_DWC3_MESON_G12A
bool "Amlogic Meson G12A USB wrapper"
depends on DM_USB && USB_DWC3 && ARCH_MESON
diff --git a/drivers/usb/dwc3/Makefile b/drivers/usb/dwc3/Makefile
index 97b4f7191ca..a46b6824ab7 100644
--- a/drivers/usb/dwc3/Makefile
+++ b/drivers/usb/dwc3/Makefile
@@ -6,6 +6,7 @@ dwc3-y  := core.o
 
 obj-$(CONFIG_USB_DWC3_GADGET)  += gadget.o ep0.o
 
+obj-$(CONFIG_$(SPL_)USB_DWC3_AM62) += dwc3-am62.o
 obj-$(CONFIG_USB_DWC3_OMAP)+= dwc3-omap.o
 obj-$(CONFIG_USB_DWC3_MESON_G12A)  += dwc3-meson-g12a.o
 obj-$(CONFIG_USB_DWC3_MESON_GXL)   += dwc3-meson-gxl.o
diff --git a/drivers/usb/dwc3/dwc3-am62.c b/drivers/usb/dwc3/dwc3-am62.c
new file mode 100644
index 000..56c3b26a531
--- /dev/null
+++ b/drivers/usb/dwc3/dwc3-am62.c
@@ -0,0 +1,125 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * TI AM62 specific glue layer for DWC3
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "dwc3-generic.h"
+
+static void dwc3_ti_am62_glue_configure(struct udevice *dev, int index,
+   enum usb_dr_mode mode)
+{
+#define USBSS_MODE_CONTROL 0x1c
+#define USBSS_PHY_CONFIG   0x8
+#define USBSS_PHY_VBUS_SEL_MASKGENMASK(2, 1)
+#define USBSS_PHY_VBUS_SEL_SHIFT   1
+#define USBSS_MODE_VALID   BIT(0)
+#define PHY_PLL_REFCLK_MASKGENMASK(3, 0)
+static const int dwc3_ti_am62_rate_table[] = { /* in KHZ */
+   9600,
+   1,
+   12000,
+   19200,
+   2,
+   24000,
+   25000,
+   26000,
+   38400,
+   4,
+   58000,
+   5,
+   52000,
+};
+
+   struct clk usb2_refclk;
+   int rate_code, i, ret;
+   unsigned long rate;
+   u32 reg;
+   void *usbss;
+   bool vbus_divider;
+   struct regmap *syscon;
+   struct ofnode_phandle_args args;
+
+   usbss = dev_remap_addr_index(dev, 0);
+   if (IS_ERR(usbss)) {
+   dev_err(dev, "can't map IOMEM resource\n");
+   return;
+   }
+
+   ret = clk_get_by_name(dev, "ref", _refclk);
+   if (ret) {
+   dev_err(dev, "can't get usb2_refclk\n");
+   return;
+   }
+
+   /* Calculate the rate code */
+   rate = clk_get_rate(_refclk);
+   rate /= 1000;   /* To KHz */
+   for (i = 0; i < ARRAY_SIZE(dwc3_ti_am62_rate_table); i++) {
+   if (dwc3_ti_am62_rate_table[i] == rate)
+   break;
+   }
+
+   if (i == ARRAY_SIZE(dwc3_ti_am62_rate_table)) {
+   dev_err(dev, "unsupported usb2_refclk rate: %lu KHz\n", rate);
+   return;
+   }
+
+   rate_code = i;
+
+   /* Read the syscon property */
+   syscon = syscon_regmap_lookup_by_phandle(dev, 
"ti,syscon-phy-pll-refclk");
+   if (IS_ERR(syscon)) {
+   dev_err(dev, "unable to get ti,syscon-phy-pll-refclk regmap\n");
+   return;
+   }
+
+   ret = ofnode_parse_phandle_with_args(dev_ofnode(dev), 
"ti,syscon-phy-pll-refclk", NULL, 1,
+0, );
+   if (ret)
+   return;
+
+   /* Program PHY PLL refclk by reading syscon property */
+   ret = regmap_update_bits(syscon, args.args[0], PHY_PLL_REFCLK_MASK, 
rate_code);
+   if (ret) {
+   dev_err(dev, "failed to set phy pll reference clock rate\n");
+   return;
+   }
+
+   /* V

Re: [PATCH v2 0/8] Add DFU, emmc and usb boot for TI am62x

2023-06-01 Thread Sjoerd Simons
On Wed, 2023-05-31 at 17:14 -0400, Tom Rini wrote:
> On Thu, Apr 06, 2023 at 08:55:34PM +0200, Sjoerd Simons wrote:
> 
> > This series adds more boot sources for the TI am62x. For that the
> > dts'
> > are synced from the upstream ti-next git tree (to add usb nodes),
> > some
> > dwc3 glue is and finally the default configuration is tuned to add
> > support for DFU and USB (host and gadget)
> 
> This seems, conceptually, fine.  But as we're getting the TI dts
> files
> in sync with the kernel, I'm deferring this version and you'll want
> to
> rebase and re-post once everything has settled.

Thanks for the update/hint ;) I also got a few review comments so the
plan is to include those and repost.. Just my may has been stupidly
busy causing me to not get around it in the first place, so maybe that
turned into good timing in the end.

-- 
Sjoerd Simons
Collabora Ltd.


[PATCH v2 8/8] configs: am62x_evm_*: Enable USB and DFU support

2023-04-06 Thread Sjoerd Simons
Enable USB host as well as USB gadget and DFU support for a53; For the
r5 due to the smaller available size create a new config just for
DFU support

Signed-off-by: Sjoerd Simons 

---

Changes in v2:
- Create a seperate defconfig for R5

 configs/am62x_evm_a53_defconfig   |  35 +++-
 configs/am62x_evm_r5_usbdfu_defconfig | 116 ++
 2 files changed, 148 insertions(+), 3 deletions(-)
 create mode 100644 configs/am62x_evm_r5_usbdfu_defconfig

diff --git a/configs/am62x_evm_a53_defconfig b/configs/am62x_evm_a53_defconfig
index cc9c8eab3e3..7dbf2f54050 100644
--- a/configs/am62x_evm_a53_defconfig
+++ b/configs/am62x_evm_a53_defconfig
@@ -1,5 +1,6 @@
 CONFIG_ARM=y
 CONFIG_ARCH_K3=y
+CONFIG_SYS_MALLOC_LEN=0x200
 CONFIG_SYS_MALLOC_F_LEN=0x8000
 CONFIG_SPL_LIBCOMMON_SUPPORT=y
 CONFIG_SPL_LIBGENERIC_SUPPORT=y
@@ -9,9 +10,11 @@ CONFIG_K3_ATF_LOAD_ADDR=0x9e78
 CONFIG_TARGET_AM625_A53_EVM=y
 CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
 CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x8048
+CONFIG_SF_DEFAULT_SPEED=2500
 CONFIG_SPL_DM_SPI=y
 CONFIG_DEFAULT_DEVICE_TREE="k3-am625-sk"
 CONFIG_SPL_TEXT_BASE=0x8008
+CONFIG_OF_LIBFDT_OVERLAY=y
 CONFIG_DM_RESET=y
 CONFIG_SPL_MMC=y
 CONFIG_SPL_SERIAL=y
@@ -33,17 +36,23 @@ CONFIG_SPL_SYS_MALLOC_SIMPLE=y
 CONFIG_SPL_STACK_R=y
 CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR=y
 CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0x1400
+CONFIG_SPL_ENV_SUPPORT=y
 CONFIG_SPL_FS_LOAD_PAYLOAD_NAME="u-boot.img"
 CONFIG_SPL_DM_MAILBOX=y
 CONFIG_SPL_DM_SPI_FLASH=y
 CONFIG_SPL_POWER_DOMAIN=y
+CONFIG_SPL_RAM_SUPPORT=y
+CONFIG_SPL_RAM_DEVICE=y
 # CONFIG_SPL_SPI_FLASH_TINY is not set
 CONFIG_SPL_SPI_FLASH_SFDP_SUPPORT=y
 CONFIG_SPL_SPI_LOAD=y
 CONFIG_SYS_SPI_U_BOOT_OFFS=0x28
+CONFIG_SPL_USB_GADGET=y
+CONFIG_SPL_DFU=y
 CONFIG_SPL_YMODEM_SUPPORT=y
-CONFIG_SYS_BOOTM_LEN=0x80
+CONFIG_CMD_DFU=y
 CONFIG_CMD_MMC=y
+CONFIG_CMD_USB=y
 CONFIG_OF_CONTROL=y
 CONFIG_SPL_OF_CONTROL=y
 CONFIG_MULTI_DTB_FIT=y
@@ -54,10 +63,17 @@ CONFIG_SPL_DM=y
 CONFIG_SPL_DM_SEQ_ALIAS=y
 CONFIG_REGMAP=y
 CONFIG_SPL_REGMAP=y
+CONFIG_SYSCON=y
+CONFIG_SPL_SYSCON=y
 CONFIG_SPL_OF_TRANSLATE=y
 CONFIG_CLK=y
 CONFIG_SPL_CLK=y
 CONFIG_CLK_TI_SCI=y
+CONFIG_DFU_MMC=y
+CONFIG_DFU_RAM=y
+CONFIG_DFU_SF=y
+CONFIG_SYS_DFU_DATA_BUF_SIZE=0x5000
+CONFIG_SYS_DFU_MAX_FILE_SIZE=0x80
 CONFIG_DMA_CHANNELS=y
 CONFIG_TI_K3_NAVSS_UDMA=y
 CONFIG_TI_SCI_PROTOCOL=y
@@ -68,7 +84,6 @@ CONFIG_MMC_SDHCI_ADMA=y
 CONFIG_SPL_MMC_SDHCI_ADMA=y
 CONFIG_MMC_SDHCI_AM654=y
 CONFIG_DM_SPI_FLASH=y
-CONFIG_SF_DEFAULT_SPEED=2500
 CONFIG_SPI_FLASH_SFDP_SUPPORT=y
 CONFIG_SPI_FLASH_SOFT_RESET=y
 CONFIG_SPI_FLASH_SOFT_RESET_ON_BOOT=y
@@ -96,5 +111,19 @@ CONFIG_CADENCE_QSPI=y
 CONFIG_SYSRESET=y
 CONFIG_SPL_SYSRESET=y
 CONFIG_SYSRESET_TI_SCI=y
+CONFIG_USB=y
+CONFIG_DM_USB_GADGET=y
+CONFIG_SPL_DM_USB_GADGET=y
+CONFIG_USB_XHCI_HCD=y
+CONFIG_USB_XHCI_DWC3=y
+CONFIG_USB_DWC3=y
+CONFIG_USB_DWC3_GENERIC=y
+CONFIG_SPL_USB_DWC3_GENERIC=y
+CONFIG_SPL_USB_DWC3_AM62=y
+CONFIG_USB_DWC3_AM62=y
+CONFIG_USB_GADGET=y
+CONFIG_USB_GADGET_MANUFACTURER="Texas Instruments"
+CONFIG_USB_GADGET_VENDOR_NUM=0x0451
+CONFIG_USB_GADGET_PRODUCT_NUM=0x6165
+CONFIG_USB_GADGET_DOWNLOAD=y
 CONFIG_FS_FAT_MAX_CLUSTSIZE=16384
-CONFIG_OF_LIBFDT_OVERLAY=y
diff --git a/configs/am62x_evm_r5_usbdfu_defconfig 
b/configs/am62x_evm_r5_usbdfu_defconfig
new file mode 100644
index 000..00a0821b6df
--- /dev/null
+++ b/configs/am62x_evm_r5_usbdfu_defconfig
@@ -0,0 +1,116 @@
+CONFIG_ARM=y
+CONFIG_ARCH_K3=y
+CONFIG_SYS_MALLOC_LEN=0x0800
+CONFIG_SYS_MALLOC_F_LEN=0x9000
+CONFIG_SPL_LIBCOMMON_SUPPORT=y
+CONFIG_SPL_LIBGENERIC_SUPPORT=y
+CONFIG_NR_DRAM_BANKS=2
+CONFIG_SOC_K3_AM625=y
+CONFIG_TARGET_AM625_R5_EVM=y
+CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
+CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x43c3a7f0
+CONFIG_ENV_SIZE=0x2
+CONFIG_DM_GPIO=y
+CONFIG_DEFAULT_DEVICE_TREE="k3-am625-r5-sk"
+CONFIG_SPL_TEXT_BASE=0x43c0
+CONFIG_DM_RESET=y
+CONFIG_SPL_SERIAL=y
+CONFIG_SPL_DRIVERS_MISC=y
+CONFIG_SPL_STACK_R_ADDR=0x8200
+CONFIG_SPL_SYS_MALLOC_F_LEN=0x7000
+CONFIG_SPL_SIZE_LIMIT=0x3A7F0
+CONFIG_SPL_SIZE_LIMIT_PROVIDE_STACK=0x3500
+CONFIG_SPL_LOAD_FIT=y
+CONFIG_SPL_LOAD_FIT_ADDRESS=0x8008
+CONFIG_SPL_FIT_IMAGE_POST_PROCESS=y
+# CONFIG_DISPLAY_CPUINFO is not set
+CONFIG_SPL_SIZE_LIMIT_SUBTRACT_GD=y
+CONFIG_SPL_SIZE_LIMIT_SUBTRACT_MALLOC=y
+CONFIG_SPL_MAX_SIZE=0x3B000
+CONFIG_SPL_PAD_TO=0x0
+CONFIG_SPL_HAS_BSS_LINKER_SECTION=y
+CONFIG_SPL_BSS_START_ADDR=0x43c3b000
+CONFIG_SPL_BSS_MAX_SIZE=0x3000
+CONFIG_SPL_SYS_REPORT_STACK_F_USAGE=y
+CONFIG_SPL_SYS_MALLOC_SIMPLE=y
+CONFIG_SPL_STACK_R=y
+CONFIG_SPL_SEPARATE_BSS=y
+CONFIG_SYS_SPL_MALLOC=y
+CONFIG_HAS_CUSTOM_SPL_MALLOC_START=y
+CONFIG_CUSTOM_SYS_SPL_MALLOC_ADDR=0x8400
+CONFIG_SYS_SPL_MALLOC_SIZE=0x100
+CONFIG_SPL_EARLY_BSS=y
+CONFIG_SPL_ENV_SUPPORT=y
+CONFIG_SPL_DM_MAILBOX=y
+CONFIG_SPL_DM_RESET=y
+CONFIG_SPL_POWER_DOMAIN=y
+CONFIG_SPL_RAM_SUPPORT=y
+CONFIG_SPL_RAM_DEVICE=y
+CONFIG_SPL_REMOTEPROC=y
+C

[PATCH v2 7/8] arm: dts: k3-am625-sk: Enable usb ports in u-boot

2023-04-06 Thread Sjoerd Simons
Enable both usb0 as a peripheral for use with DFU and

Signed-off-by: Sjoerd Simons 

---

Changes in v2:
- Only enable usb port 0 DFU in SPL

 arch/arm/dts/k3-am625-sk-u-boot.dtsi | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/arch/arm/dts/k3-am625-sk-u-boot.dtsi 
b/arch/arm/dts/k3-am625-sk-u-boot.dtsi
index 5f90a4b56f1..2746451572d 100644
--- a/arch/arm/dts/k3-am625-sk-u-boot.dtsi
+++ b/arch/arm/dts/k3-am625-sk-u-boot.dtsi
@@ -154,3 +154,14 @@
 _port2 {
status = "disabled";
 };
+
+ {
+   bootph-pre-ram;
+};
+
+ {
+   dr_mode = "peripheral";
+   /* Since role switching is not supported in U-Boot */
+   /delete-property/ extcon;
+   bootph-pre-ram;
+};
-- 
2.40.0



[PATCH v2 5/8] usb: dwc3: Add dwc3 glue driver for am62

2023-04-06 Thread Sjoerd Simons
Add glue code for TI AM62 to the dwc3 driver; Most code adopted from
TI vendor u-boot code.

Signed-off-by: Sjoerd Simons 

---

Changes in v2:
- Switch dwc3 glue to a seperate driver rather then in dwc-generic

 drivers/usb/dwc3/Kconfig |  14 
 drivers/usb/dwc3/Makefile|   1 +
 drivers/usb/dwc3/dwc3-am62.c | 127 +++
 3 files changed, 142 insertions(+)
 create mode 100644 drivers/usb/dwc3/dwc3-am62.c

diff --git a/drivers/usb/dwc3/Kconfig b/drivers/usb/dwc3/Kconfig
index c0c8c16fd9c..26a1e1770c5 100644
--- a/drivers/usb/dwc3/Kconfig
+++ b/drivers/usb/dwc3/Kconfig
@@ -37,6 +37,20 @@ config SPL_USB_DWC3_GENERIC
  Select this for Xilinx ZynqMP and similar Platforms.
  This wrapper supports Host and Peripheral operation modes.
 
+config SPL_USB_DWC3_AM62
+   bool "TI AM62 USB wrapper"
+   depends on SPL_DM_USB && SPL_USB_DWC3_GENERIC
+   help
+ Select this for TI AM62 Platforms.
+ This wrapper supports Host and Peripheral operation modes.
+
+config USB_DWC3_AM62
+   bool "TI AM62 USB wrapper"
+   depends on DM_USB && USB_DWC3_GENERIC
+   help
+ Select this for TI AM62 Platforms.
+ This wrapper supports Host and Peripheral operation modes.
+
 config USB_DWC3_MESON_G12A
bool "Amlogic Meson G12A USB wrapper"
depends on DM_USB && USB_DWC3 && ARCH_MESON
diff --git a/drivers/usb/dwc3/Makefile b/drivers/usb/dwc3/Makefile
index 97b4f7191ca..a46b6824ab7 100644
--- a/drivers/usb/dwc3/Makefile
+++ b/drivers/usb/dwc3/Makefile
@@ -6,6 +6,7 @@ dwc3-y  := core.o
 
 obj-$(CONFIG_USB_DWC3_GADGET)  += gadget.o ep0.o
 
+obj-$(CONFIG_$(SPL_)USB_DWC3_AM62) += dwc3-am62.o
 obj-$(CONFIG_USB_DWC3_OMAP)+= dwc3-omap.o
 obj-$(CONFIG_USB_DWC3_MESON_G12A)  += dwc3-meson-g12a.o
 obj-$(CONFIG_USB_DWC3_MESON_GXL)   += dwc3-meson-gxl.o
diff --git a/drivers/usb/dwc3/dwc3-am62.c b/drivers/usb/dwc3/dwc3-am62.c
new file mode 100644
index 000..20d99758b4f
--- /dev/null
+++ b/drivers/usb/dwc3/dwc3-am62.c
@@ -0,0 +1,127 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * TI AM62 specific glue layer for DWC3
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "dwc3-generic.h"
+
+void dwc3_ti_am62_glue_configure(struct udevice *dev, int index,
+enum usb_dr_mode mode)
+{
+#define USBSS_MODE_CONTROL 0x1c
+#define USBSS_PHY_CONFIG   0x8
+#define USBSS_PHY_VBUS_SEL_MASKGENMASK(2, 1)
+#define USBSS_PHY_VBUS_SEL_SHIFT   1
+#define USBSS_MODE_VALID   BIT(0)
+#define PHY_PLL_REFCLK_MASKGENMASK(3, 0)
+static const int dwc3_ti_am62_rate_table[] = { /* in KHZ */
+   9600,
+   1,
+   12000,
+   19200,
+   2,
+   24000,
+   25000,
+   26000,
+   38400,
+   4,
+   58000,
+   5,
+   52000,
+};
+
+   struct clk usb2_refclk;
+   int rate_code, i, ret;
+   unsigned long rate;
+   u32 reg;
+   void *usbss;
+   bool vbus_divider;
+   struct regmap *syscon;
+   struct ofnode_phandle_args args;
+
+   usbss = dev_remap_addr_index(dev, 0);
+   if (IS_ERR(usbss)) {
+   dev_err(dev, "can't map IOMEM resource\n");
+   return;
+   }
+
+   ret = clk_get_by_name(dev, "ref", _refclk);
+   if (ret) {
+   dev_err(dev, "can't get usb2_refclk\n");
+   return;
+   }
+
+   /* Calcuate the rate code */
+   rate = clk_get_rate(_refclk);
+   rate /= 1000;   /* To KHz */
+   for (i = 0; i < ARRAY_SIZE(dwc3_ti_am62_rate_table); i++) {
+   if (dwc3_ti_am62_rate_table[i] == rate)
+   break;
+   }
+
+   if (i == ARRAY_SIZE(dwc3_ti_am62_rate_table)) {
+   dev_err(dev, "unsupported usb2_refclk rate: %lu KHz\n", rate);
+   return;
+   }
+
+   rate_code = i;
+
+   /* Read the syscon property */
+   syscon = syscon_regmap_lookup_by_phandle(dev, 
"ti,syscon-phy-pll-refclk");
+   if (IS_ERR(syscon)) {
+   dev_err(dev, "unable to get ti,syscon-phy-pll-refclk regmap\n");
+   return;
+   }
+
+   ret = ofnode_parse_phandle_with_args(dev_ofnode(dev), 
"ti,syscon-phy-pll-refclk", NULL, 1,
+0, );
+   if (ret)
+   return;
+
+   /* Program PHY PLL refclk by reading syscon property */
+   ret = regmap_update_bits(syscon, args.args[0], PHY_PLL_REFCLK_MASK, 
rate_code);
+   if (ret) {
+   dev_err(dev, "failed to set phy pll reference clock rate\n");
+   return;
+   }
+
+   /* VBUS divider select */
+   reg = readl(usbss + USBSS_PHY_CONFIG);
+  

[PATCH v2 6/8] configs: am62: Add configs for enabling USB in U-Boot

2023-04-06 Thread Sjoerd Simons
Add configs for enabling USB DFU in U-Boot.

Signed-off-by: Sjoerd Simons 

---

Changes in v2:
- Minimize config changes to just DFU configuration

 include/configs/am62x_evm.h | 10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/include/configs/am62x_evm.h b/include/configs/am62x_evm.h
index 7bf07809b05..d07da4ebae4 100644
--- a/include/configs/am62x_evm.h
+++ b/include/configs/am62x_evm.h
@@ -11,6 +11,7 @@
 
 #include 
 #include 
+#include 
 
 /* DDR Configuration */
 #define CFG_SYS_SDRAM_BASE10x88000
@@ -38,9 +39,16 @@
DISTRO_BOOT_DEV_PXE(func) \
DISTRO_BOOT_DEV_DHCP(func)
 
+#define EXTRA_ENV_DFUARGS \
+   DFU_ALT_INFO_MMC \
+   DFU_ALT_INFO_EMMC \
+   DFU_ALT_INFO_RAM \
+   DFU_ALT_INFO_OSPI
+
 /* Incorporate settings into the U-Boot environment */
 #define CFG_EXTRA_ENV_SETTINGS \
-   BOOTENV
+   BOOTENV \
+   EXTRA_ENV_DFUARGS
 
 /* Now for the remaining common defines */
 #include 
-- 
2.40.0



[PATCH v2 4/8] arm: dts: k3-am625-sk: Enable emmc in SPL

2023-04-06 Thread Sjoerd Simons
sdhci0 on the k3-am625-sk is the emmc, enable this in SPL as well to
allow booting from that media.

Signed-off-by: Sjoerd Simons 
Reviewed-by: Tom Rini 
---

(no changes since v1)

 arch/arm/dts/k3-am625-sk-u-boot.dtsi | 8 
 1 file changed, 8 insertions(+)

diff --git a/arch/arm/dts/k3-am625-sk-u-boot.dtsi 
b/arch/arm/dts/k3-am625-sk-u-boot.dtsi
index 0def84b4cf0..5f90a4b56f1 100644
--- a/arch/arm/dts/k3-am625-sk-u-boot.dtsi
+++ b/arch/arm/dts/k3-am625-sk-u-boot.dtsi
@@ -92,6 +92,14 @@
bootph-pre-ram;
 };
 
+ {
+   bootph-pre-ram;
+};
+
+_mmc0_pins_default {
+   bootph-pre-ram;
+};
+
  {
bootph-pre-ram;
 };
-- 
2.40.0



[PATCH v2 3/8] arm: dts: k3-am62: Bump dtsi from linux

2023-04-06 Thread Sjoerd Simons
Update the am62 and am625 device-trees from linux v6.3-rc5 This needed the 
following
tweaks to the u-boot specific dtsi as well:
- Switch tick-timer to the main_timer as it's now defined in the main dtsi
- Add mdio pins to the cpsw3g pinctrl. It moved to a subnode in the
  linux dtsi that u-boot doesn't use/support

Signed-off-by: Sjoerd Simons 

---

Changes in v2:
- Update dts sync to v6.3-rc5

 arch/arm/dts/k3-am62-main.dtsi   | 259 ---
 arch/arm/dts/k3-am62-mcu.dtsi|  49 +
 arch/arm/dts/k3-am62-wakeup.dtsi |   4 +-
 arch/arm/dts/k3-am625-r5-sk.dts  |   2 +-
 arch/arm/dts/k3-am625-sk-u-boot.dtsi |   8 +-
 arch/arm/dts/k3-am625-sk.dts |  95 +-
 arch/arm/dts/k3-am625.dtsi   |  52 ++
 7 files changed, 381 insertions(+), 88 deletions(-)

diff --git a/arch/arm/dts/k3-am62-main.dtsi b/arch/arm/dts/k3-am62-main.dtsi
index 4a42f1b2e31..ea683fd77d6 100644
--- a/arch/arm/dts/k3-am62-main.dtsi
+++ b/arch/arm/dts/k3-am62-main.dtsi
@@ -54,6 +54,12 @@
reg = <0x4044 0x8>;
#phy-cells = <1>;
};
+
+   epwm_tbclk: clock@4130 {
+   compatible = "ti,am62-epwm-tbclk", "syscon";
+   reg = <0x4130 0x4>;
+   #clock-cells = <1>;
+   };
};
 
dmss: bus@4800 {
@@ -144,8 +150,8 @@
compatible = "ti,k2g-sci";
ti,host-id = <12>;
mbox-names = "rx", "tx";
-   mboxes= <_proxy_main 12>,
-   <_proxy_main 13>;
+   mboxes = <_proxy_main 12>,
+<_proxy_main 13>;
reg-names = "debug_messages";
reg = <0x00 0x44043000 0x00 0xfe0>;
 
@@ -186,6 +192,102 @@
pinctrl-single,function-mask = <0x>;
};
 
+   main_timer0: timer@240 {
+   compatible = "ti,am654-timer";
+   reg = <0x00 0x240 0x00 0x400>;
+   interrupts = ;
+   clocks = <_clks 36 2>;
+   clock-names = "fck";
+   assigned-clocks = <_clks 36 2>;
+   assigned-clock-parents = <_clks 36 3>;
+   power-domains = <_pds 36 TI_SCI_PD_EXCLUSIVE>;
+   ti,timer-pwm;
+   };
+
+   main_timer1: timer@241 {
+   compatible = "ti,am654-timer";
+   reg = <0x00 0x241 0x00 0x400>;
+   interrupts = ;
+   clocks = <_clks 37 2>;
+   clock-names = "fck";
+   assigned-clocks = <_clks 37 2>;
+   assigned-clock-parents = <_clks 37 3>;
+   power-domains = <_pds 37 TI_SCI_PD_EXCLUSIVE>;
+   ti,timer-pwm;
+   };
+
+   main_timer2: timer@242 {
+   compatible = "ti,am654-timer";
+   reg = <0x00 0x242 0x00 0x400>;
+   interrupts = ;
+   clocks = <_clks 38 2>;
+   clock-names = "fck";
+   assigned-clocks = <_clks 38 2>;
+   assigned-clock-parents = <_clks 38 3>;
+   power-domains = <_pds 38 TI_SCI_PD_EXCLUSIVE>;
+   ti,timer-pwm;
+   };
+
+   main_timer3: timer@243 {
+   compatible = "ti,am654-timer";
+   reg = <0x00 0x243 0x00 0x400>;
+   interrupts = ;
+   clocks = <_clks 39 2>;
+   clock-names = "fck";
+   assigned-clocks = <_clks 39 2>;
+   assigned-clock-parents = <_clks 39 3>;
+   power-domains = <_pds 39 TI_SCI_PD_EXCLUSIVE>;
+   ti,timer-pwm;
+   };
+
+   main_timer4: timer@244 {
+   compatible = "ti,am654-timer";
+   reg = <0x00 0x244 0x00 0x400>;
+   interrupts = ;
+   clocks = <_clks 40 2>;
+   clock-names = "fck";
+   assigned-clocks = <_clks 40 2>;
+   assigned-clock-parents = <_clks 40 3>;
+   power-domains = <_pds 40 TI_SCI_PD_EXCLUSIVE>;
+   ti,timer-pwm;
+   };
+
+   main_timer5: timer@245 {
+   compatible = "ti,am654-timer";
+   reg = <0x00 0x245 0x00 0x400>;
+   interrupts = ;
+   clocks = <_clks 41 2>;
+   clock-names = "fck";
+   assigned-clocks = <_clks 41 2>;
+   assigned-clock-parents = <_clks 41 3>;
+   power-domains = <_pds 41 TI_SCI_PD_EXCLUSIVE>;
+ 

[PATCH v2 2/8] arm: mach-k3: am62: Add timer0 id to the dev list

2023-04-06 Thread Sjoerd Simons
Timer0 is used by u-boot as the tick timer; Add it to the soc devices
list so it can be enabled via the k3 power controller.

Signed-off-by: Sjoerd Simons 
Reviewed-by: Tom Rini 
---

(no changes since v1)

 arch/arm/mach-k3/am62x/dev-data.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/mach-k3/am62x/dev-data.c 
b/arch/arm/mach-k3/am62x/dev-data.c
index 616d0650b9c..140dca4bd1d 100644
--- a/arch/arm/mach-k3/am62x/dev-data.c
+++ b/arch/arm/mach-k3/am62x/dev-data.c
@@ -58,6 +58,7 @@ static struct ti_dev soc_dev_list[] = {
PSC_DEV(161, _lpsc_list[8]),
PSC_DEV(162, _lpsc_list[9]),
PSC_DEV(75, _lpsc_list[10]),
+   PSC_DEV(36, _lpsc_list[11]),
PSC_DEV(102, _lpsc_list[11]),
PSC_DEV(146, _lpsc_list[11]),
PSC_DEV(13, _lpsc_list[12]),
-- 
2.40.0



[PATCH v2 1/8] omap: timer: add ti,am654-timer compatibility

2023-04-06 Thread Sjoerd Simons
THe TI AM654 timer is compatible with the omap-timer implementation, so
add it to the id list

Signed-off-by: Sjoerd Simons 
Reviewed-by: Tom Rini 
---

(no changes since v1)

 drivers/timer/omap-timer.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/timer/omap-timer.c b/drivers/timer/omap-timer.c
index aa2e4360c1b..9b6d97dae67 100644
--- a/drivers/timer/omap-timer.c
+++ b/drivers/timer/omap-timer.c
@@ -114,6 +114,7 @@ static const struct udevice_id omap_timer_ids[] = {
{ .compatible = "ti,am335x-timer" },
{ .compatible = "ti,am4372-timer" },
{ .compatible = "ti,omap5430-timer" },
+   { .compatible = "ti,am654-timer" },
{}
 };
 
-- 
2.40.0



[PATCH v2 0/8] Add DFU, emmc and usb boot for TI am62x

2023-04-06 Thread Sjoerd Simons


This series adds more boot sources for the TI am62x. For that the dts'
are synced from the upstream ti-next git tree (to add usb nodes), some
dwc3 glue is and finally the default configuration is tuned to add
support for DFU and USB (host and gadget)


Changes in v2:
- Update dts sync to v6.3-rc5
- Switch dwc3 glue to a seperate driver rather then in dwc-generic
- Minimize config changes to just DFU configuration
- Only enable usb port 0 DFU in SPL
- Create a seperate defconfig for R5

Sjoerd Simons (8):
  omap: timer: add ti,am654-timer compatibility
  arm: mach-k3: am62: Add timer0 id to the dev list
  arm: dts: k3-am62: Bump dtsi from linux
  arm: dts: k3-am625-sk: Enable emmc in SPL
  usb: dwc3: Add dwc3 glue driver for am62
  configs: am62: Add configs for enabling USB in U-Boot
  arm: dts: k3-am625-sk: Enable usb ports in u-boot
  configs: am62x_evm_*: Enable USB and DFU support

 arch/arm/dts/k3-am62-main.dtsi| 259 +++---
 arch/arm/dts/k3-am62-mcu.dtsi |  49 +
 arch/arm/dts/k3-am62-wakeup.dtsi  |   4 +-
 arch/arm/dts/k3-am625-r5-sk.dts   |   2 +-
 arch/arm/dts/k3-am625-sk-u-boot.dtsi  |  27 ++-
 arch/arm/dts/k3-am625-sk.dts  |  95 +-
 arch/arm/dts/k3-am625.dtsi|  52 ++
 arch/arm/mach-k3/am62x/dev-data.c |   1 +
 configs/am62x_evm_a53_defconfig   |  35 +++-
 configs/am62x_evm_r5_usbdfu_defconfig | 116 
 drivers/timer/omap-timer.c|   1 +
 drivers/usb/dwc3/Kconfig  |  14 ++
 drivers/usb/dwc3/Makefile |   1 +
 drivers/usb/dwc3/dwc3-am62.c  | 127 +
 include/configs/am62x_evm.h   |  10 +-
 15 files changed, 701 insertions(+), 92 deletions(-)
 create mode 100644 configs/am62x_evm_r5_usbdfu_defconfig
 create mode 100644 drivers/usb/dwc3/dwc3-am62.c

-- 
2.40.0



Re: [PATCH v2 1/1] lmb: Treat a region which is a subset as equal

2023-02-14 Thread Sjoerd Simons
Hey,

On Tue, 2023-02-14 at 07:57 +, Soma, Ashok Reddy wrote:
> Hi Sjoerd Simons,
> 
> Thanks for you patches.
> 
> However even after your patches, I still see below error.
> 
> ERROR: reserving fdt memory region failed (addr=8
> size=18000 flags=4)
> ERROR: reserving fdt memory region failed (addr=500
> size=2 flags=4)

Annoyingly it's hard to tell why the reservation has failed; It could
for example be a difference in mapping flags (making them
incompatible); looking at bdinfo could help a bit here but otherwise
it'll need slightly more debugging

> My DT has extra reserved memory nodes which are reserved as below.
> Any idea what may be wrong ?
> 
> Reserved memory nodes in DT:
> 
>     memory@0 {
>     device_type = "memory";
>     reg = <0x00 0x00 0x00 0x8000 0x08 0x00 0x01
> 0x8000>;
>     };
> 
>     memory@500 {
>     device_type = "memory";
>     reg = <0x500 0x00 0x02 0x00>;
>     };
> 
>     reserved-memory {
>     #address-cells = <0x02>;
>     #size-cells = <0x02>;
>     ranges;
> 
>     buffer@0 {
>     no-map;
>     reg = <0x08 0x00 0x01 0x8000>;
>     };
> 
>     buffer@1 {
>     no-map;
>     reg = <0x500 0x00 0x02 0x00>;
>     };
>     };
> 
> Boot log:
> 
> ## Loading init Ramdisk from Legacy Image at 0400 ...
>    Image Name:   petalinux-image-minimal-xlnx-zyn
>    Created:  2011-04-05  23:00:00 UTC
>    Image Type:   AArch64 Linux RAMDisk Image (uncompressed)
>    Data Size:    59194022 Bytes = 56.5 MiB
>    Load Address: 
>    Entry Point:  
>    Verifying Checksum ... OK
> ## Flattened Device Tree blob at 0010
>    Booting using the fdt blob at 0x10
> Working FDT set to 10
> Host not halted after 16000 microseconds.
>    Loading Ramdisk to 74575000, end 77de8aa6 ... OK
> ERROR: reserving fdt memory region failed (addr=8
> size=18000 flags=4)
> ERROR: reserving fdt memory region failed (addr=5000000
> size=2 flags=4)
>    Loading Device Tree to 74564000, end 74574603 ...
> OK
> Working FDT set to 74564000
> 
> Starting kernel ...
> 
> 
> Thanks,
> Ashok
> 
> 
> > -Original Message-
> > From: Sjoerd Simons 
> > Sent: Sunday, February 12, 2023 8:37 PM
> > To: Tom Rini 
> > Cc: Ashok Reddy Soma ; Heinrich
> > Schuchardt ; Simek, Michal
> > ; Patrice Chotard
> > ;
> > u-boot@lists.denx.de
> > Subject: [PATCH v2 1/1] lmb: Treat a region which is a subset as
> > equal
> > 
> > CAUTION: This message has originated from an External Source.
> > Please use
> > proper judgment and caution when opening attachments, clicking
> > links, or
> > responding to this email.
> > 
> > 
> > In various cases logical memory blocks are coalesced; As a result
> > doing a
> > strict check whether memory blocks are the same doesn't necessarily
> > work as
> > a previous addition of a given block might have been merged into a
> > bigger
> > block.
> > 
> > Fix this by considering a block is already registered if it's a
> > pure subset of one
> > of the existing blocks.
> > 
> > Signed-off-by: Sjoerd Simons 
> > 
> > ---
> > 
> > Changes in v2:
> > - Adjust calculation to prevent integer overview (fixes lmb tests)
> > 
> >  lib/lmb.c | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> > 
> > diff --git a/lib/lmb.c b/lib/lmb.c
> > index f447c639a60..2444b2a6212 100644
> > --- a/lib/lmb.c
> > +++ b/lib/lmb.c
> > @@ -247,8 +247,10 @@ static long lmb_add_region_flags(struct
> > lmb_region
> > *rgn, phys_addr_t base,
> >     phys_addr_t rgnbase = rgn->region[i].base;
> >     phys_size_t rgnsize = rgn->region[i].size;
> >     phys_size_t rgnflags = rgn->region[i].flags;
> > +   phys_addr_t end = base + size - 1;
> > +   phys_addr_t rgnend = rgnbase + rgnsize - 1;
> > 
> > -   if (rgnbase == base && rgnsize == size) {
> > +   if (rgnbase <= base && end <= rgnend) {
> >     if (flags == rgnflags)
> >     /* Already have this region, so
> > we're done */
> >     return 0;
> > --
> > 2.39.1
> 

-- 
Sjoerd Simons
Collabora Ltd.


[PATCH v2 0/1] Fix boot regressions on at least TI am62x

2023-02-12 Thread Sjoerd Simons


When booting a recent u-boot master on TI am62x with the distro boot
sequence it fails loading the FDT:

   Booting using the fdt blob at 0x8800
Working FDT set to 8800
   Loading Ramdisk to 8d711000, end 8d95 ... OK
ERROR: reserving fdt memory region failed (addr=9e78 size=8 flags=4)
ERROR: reserving fdt memory region failed (addr=9e80 size=180 flags=4)
ERROR: reserving fdt memory region failed (addr=9db0 size=c0 flags=4)
ERROR: Failed to allocate 0x8f58 bytes below 0x9000.
device tree - allocation error
FDT creation failed!
resetting ...

It turns out that this is caused by commit 06d514d77c37 ("lmb: consider EFI
memory map") due to injecting both extra and some similar memory regions
via a different path into the lmb. The following series fixes the
apparent fallout from that ;)

Changes in v2:
- Adjust calculation to prevent integer overview (fixes lmb tests)
- Drop first 2 patches as they were applied already

Sjoerd Simons (1):
  lmb: Treat a region which is a subset as equal

 lib/lmb.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

-- 
2.39.1



[PATCH v2 1/1] lmb: Treat a region which is a subset as equal

2023-02-12 Thread Sjoerd Simons
In various cases logical memory blocks are coalesced; As a result doing
a strict check whether memory blocks are the same doesn't necessarily
work as a previous addition of a given block might have been merged into
a bigger block.

Fix this by considering a block is already registered if it's a pure
subset of one of the existing blocks.

Signed-off-by: Sjoerd Simons 

---

Changes in v2:
- Adjust calculation to prevent integer overview (fixes lmb tests)

 lib/lmb.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lib/lmb.c b/lib/lmb.c
index f447c639a60..2444b2a6212 100644
--- a/lib/lmb.c
+++ b/lib/lmb.c
@@ -247,8 +247,10 @@ static long lmb_add_region_flags(struct lmb_region *rgn, 
phys_addr_t base,
phys_addr_t rgnbase = rgn->region[i].base;
phys_size_t rgnsize = rgn->region[i].size;
phys_size_t rgnflags = rgn->region[i].flags;
+   phys_addr_t end = base + size - 1;
+   phys_addr_t rgnend = rgnbase + rgnsize - 1;
 
-   if (rgnbase == base && rgnsize == size) {
+   if (rgnbase <= base && end <= rgnend) {
if (flags == rgnflags)
/* Already have this region, so we're done */
return 0;
-- 
2.39.1



Re: [PATCH 3/3] lmb: Treat a region which is a subset as equal

2023-02-07 Thread Sjoerd Simons
On Mon, 2023-02-06 at 13:04 -0500, Tom Rini wrote:
> On Thu, Jan 19, 2023 at 09:38:19AM +0100, Sjoerd Simons wrote:
> 
> > In various cases logical memory blocks are coalesced; As a result
> > doing
> > a strict check whether memory blocks are the same doesn't
> > necessarily
> > work as a previous addition of a given block might have been merged
> > into
> > a bigger block.
> > 
> > Fix this by considering a block is already registered if it's a
> > pure
> > subset of one of the existing blocks.
> > 
> > Signed-off-by: Sjoerd Simons 
> > ---
> > 
> >  lib/lmb.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/lib/lmb.c b/lib/lmb.c
> > index f447c639a60..b09a043f4c2 100644
> > --- a/lib/lmb.c
> > +++ b/lib/lmb.c
> > @@ -248,7 +248,7 @@ static long lmb_add_region_flags(struct
> > lmb_region *rgn, phys_addr_t base,
> > phys_size_t rgnsize = rgn->region[i].size;
> > phys_size_t rgnflags = rgn->region[i].flags;
> >  
> > -   if (rgnbase == base && rgnsize == size) {
> > +   if (rgnbase <= base && rgnbase + rgnsize >= base +
> > size) {
> > if (flags == rgnflags)
> > /* Already have this region, so
> > we're done */
> >         return 0;
> 
> This breaks lib_test_lmb_simple, lib_test_lmb_simple_x2 and
> lib_test_lmb_alloc_addr.

Oh sorry for missing that; I'll get those fixed. Does the direction at
least seem sensible to you ?


-- 
Sjoerd Simons
Collabora Ltd.


Re: [PATCH 1/3] Bump LMB_MAX_REGIONS default to 16

2023-01-26 Thread Sjoerd Simons
On Thu, 2023-01-26 at 13:28 -0500, Tom Rini wrote:
> On Thu, Jan 19, 2023 at 09:38:17AM +0100, Sjoerd Simons wrote:
> > 
> > As this is likely to impact more devices bump the default max
> > regions to 16 so there is a bit more slack.
> > 
> > Signed-off-by: Sjoerd Simons 
> 
> I prefer to use:
> https://patchwork.ozlabs.org/project/uboot/patch/20230125230823.1567778-1-tr...@konsulko.com/
> in this case due to it being overall a smaller size increase.

That's fine by me, achieves the same goal i was after for sure; The
other 2 patches in this series are still required to fix the boot
regressions i'm seeing ofcourse :)

-- 
Sjoerd Simons
Collabora Ltd.


Re: [PATCH 3/8] arm: dts: k3-am62: Bump dtsi from ti-next

2023-01-24 Thread Sjoerd Simons
On Tue, 2023-01-24 at 15:47 -0500, Tom Rini wrote:
> On Sat, Jan 21, 2023 at 04:54:29PM +0100, Sjoerd Simons wrote:
> 
> > Update the am62 and am625 device-trees from current ti-k3-next 

...

> These need to come from linux-next or similar, not a TI tree. What's
> the
> status on upstreaming those changes?

With ti-k3-next i was referring to: 

https://git.kernel.org/pub/scm/linux/kernel/git/ti/linux.git/log/?h=ti-k3-next

Which is a maintainer branch that flows into the ti tree that gets
pulled into linux next.. Just checked this morning and the relevant
commit is now available in linux-next as well (it wasn't just yet when
i sent this out).


Would you like me to resend this series with the body of this patch
updated to reflect that ?

-- 
Sjoerd Simons
Collabora Ltd.


[PATCH 6/8] configs: am62: Add configs for enabling USB in U-Boot

2023-01-21 Thread Sjoerd Simons
From: Aswath Govindraju 

Add configs for enabling USB host MSC and USB DFU in U-Boot.

Signed-off-by: Aswath Govindraju 
[ rebase from vendor u-boot to upstream ]
Signed-off-by: Sjoerd Simons 
---

 include/configs/am62x_evm.h | 10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/include/configs/am62x_evm.h b/include/configs/am62x_evm.h
index 7fbefdece40..580ff390f6e 100644
--- a/include/configs/am62x_evm.h
+++ b/include/configs/am62x_evm.h
@@ -11,6 +11,7 @@
 
 #include 
 #include 
+#include 
 
 /* DDR Configuration */
 #define CFG_SYS_SDRAM_BASE10x88000
@@ -77,13 +78,20 @@
"${bootdir}/${name_fit}\0"  \
"partitions=" PARTS_DEFAULT
 
+#define EXTRA_ENV_DFUARGS \
+   DFU_ALT_INFO_MMC \
+   DFU_ALT_INFO_EMMC \
+   DFU_ALT_INFO_RAM \
+   DFU_ALT_INFO_OSPI
+
 /* Incorporate settings into the U-Boot environment */
 #define CFG_EXTRA_ENV_SETTINGS \
DEFAULT_LINUX_BOOT_ENV  \
DEFAULT_MMC_TI_ARGS \
EXTRA_ENV_AM625_BOARD_SETTINGS  \
EXTRA_ENV_AM625_BOARD_SETTINGS_MMC  \
-   BOOTENV
+   BOOTENV \
+   EXTRA_ENV_DFUARGS
 
 /* Now for the remaining common defines */
 #include 
-- 
2.39.0



[PATCH 3/8] arm: dts: k3-am62: Bump dtsi from ti-next

2023-01-21 Thread Sjoerd Simons
Update the am62 and am625 device-trees from current ti-k3-next (commit
880932e657f). This needed the following tweaks to the u-boot specific$
dtsi as well:
- Switch tick-timer to the main_timer as it's now defined in the main dtsi
- Add mdio pins to the cpsw3g pinctrl. It moved to a subnode in the
  linux dtsi that u-boot doesn't use/support

Signed-off-by: Sjoerd Simons 
---

 arch/arm/dts/k3-am62-main.dtsi   | 259 ---
 arch/arm/dts/k3-am62-mcu.dtsi|  49 +
 arch/arm/dts/k3-am62-wakeup.dtsi |   4 +-
 arch/arm/dts/k3-am625-r5-sk.dts  |   2 +-
 arch/arm/dts/k3-am625-sk-u-boot.dtsi |   8 +-
 arch/arm/dts/k3-am625-sk.dts |  95 +-
 arch/arm/dts/k3-am625.dtsi   |  52 ++
 7 files changed, 381 insertions(+), 88 deletions(-)

diff --git a/arch/arm/dts/k3-am62-main.dtsi b/arch/arm/dts/k3-am62-main.dtsi
index 4a42f1b2e31..ea683fd77d6 100644
--- a/arch/arm/dts/k3-am62-main.dtsi
+++ b/arch/arm/dts/k3-am62-main.dtsi
@@ -54,6 +54,12 @@
reg = <0x4044 0x8>;
#phy-cells = <1>;
};
+
+   epwm_tbclk: clock@4130 {
+   compatible = "ti,am62-epwm-tbclk", "syscon";
+   reg = <0x4130 0x4>;
+   #clock-cells = <1>;
+   };
};
 
dmss: bus@4800 {
@@ -144,8 +150,8 @@
compatible = "ti,k2g-sci";
ti,host-id = <12>;
mbox-names = "rx", "tx";
-   mboxes= <_proxy_main 12>,
-   <_proxy_main 13>;
+   mboxes = <_proxy_main 12>,
+<_proxy_main 13>;
reg-names = "debug_messages";
reg = <0x00 0x44043000 0x00 0xfe0>;
 
@@ -186,6 +192,102 @@
pinctrl-single,function-mask = <0x>;
};
 
+   main_timer0: timer@240 {
+   compatible = "ti,am654-timer";
+   reg = <0x00 0x240 0x00 0x400>;
+   interrupts = ;
+   clocks = <_clks 36 2>;
+   clock-names = "fck";
+   assigned-clocks = <_clks 36 2>;
+   assigned-clock-parents = <_clks 36 3>;
+   power-domains = <_pds 36 TI_SCI_PD_EXCLUSIVE>;
+   ti,timer-pwm;
+   };
+
+   main_timer1: timer@241 {
+   compatible = "ti,am654-timer";
+   reg = <0x00 0x241 0x00 0x400>;
+   interrupts = ;
+   clocks = <_clks 37 2>;
+   clock-names = "fck";
+   assigned-clocks = <_clks 37 2>;
+   assigned-clock-parents = <_clks 37 3>;
+   power-domains = <_pds 37 TI_SCI_PD_EXCLUSIVE>;
+   ti,timer-pwm;
+   };
+
+   main_timer2: timer@242 {
+   compatible = "ti,am654-timer";
+   reg = <0x00 0x242 0x00 0x400>;
+   interrupts = ;
+   clocks = <_clks 38 2>;
+   clock-names = "fck";
+   assigned-clocks = <_clks 38 2>;
+   assigned-clock-parents = <_clks 38 3>;
+   power-domains = <_pds 38 TI_SCI_PD_EXCLUSIVE>;
+   ti,timer-pwm;
+   };
+
+   main_timer3: timer@243 {
+   compatible = "ti,am654-timer";
+   reg = <0x00 0x243 0x00 0x400>;
+   interrupts = ;
+   clocks = <_clks 39 2>;
+   clock-names = "fck";
+   assigned-clocks = <_clks 39 2>;
+   assigned-clock-parents = <_clks 39 3>;
+   power-domains = <_pds 39 TI_SCI_PD_EXCLUSIVE>;
+   ti,timer-pwm;
+   };
+
+   main_timer4: timer@244 {
+   compatible = "ti,am654-timer";
+   reg = <0x00 0x244 0x00 0x400>;
+   interrupts = ;
+   clocks = <_clks 40 2>;
+   clock-names = "fck";
+   assigned-clocks = <_clks 40 2>;
+   assigned-clock-parents = <_clks 40 3>;
+   power-domains = <_pds 40 TI_SCI_PD_EXCLUSIVE>;
+   ti,timer-pwm;
+   };
+
+   main_timer5: timer@245 {
+   compatible = "ti,am654-timer";
+   reg = <0x00 0x245 0x00 0x400>;
+   interrupts = ;
+   clocks = <_clks 41 2>;
+   clock-names = "fck";
+   assigned-clocks = <_clks 41 2>;
+   assigned-clock-parents = <_clks 41 3>;
+   power-domains = <_pds 41 TI_SCI_PD_EXCLUSIVE>;
+   ti,tim

[PATCH 8/8] configs: am62x_evm_*: Enable USB and DFU support

2023-01-21 Thread Sjoerd Simons
Enable USB host as well as USB gadget and DFU support; This allows using
a single set binaries to load both the u-boot chain and linux from USB DFU,
SD card and emmc.

Signed-off-by: Sjoerd Simons 

---

 configs/am62x_evm_a53_defconfig | 33 ++---
 configs/am62x_evm_r5_defconfig  | 26 +++---
 2 files changed, 53 insertions(+), 6 deletions(-)

diff --git a/configs/am62x_evm_a53_defconfig b/configs/am62x_evm_a53_defconfig
index 273db2edbfb..5a650d21f32 100644
--- a/configs/am62x_evm_a53_defconfig
+++ b/configs/am62x_evm_a53_defconfig
@@ -1,5 +1,6 @@
 CONFIG_ARM=y
 CONFIG_ARCH_K3=y
+CONFIG_SYS_MALLOC_LEN=0x200
 CONFIG_SYS_MALLOC_F_LEN=0x8000
 CONFIG_SPL_LIBCOMMON_SUPPORT=y
 CONFIG_SPL_LIBGENERIC_SUPPORT=y
@@ -7,6 +8,8 @@ CONFIG_NR_DRAM_BANKS=2
 CONFIG_SOC_K3_AM625=y
 CONFIG_K3_ATF_LOAD_ADDR=0x9e78
 CONFIG_TARGET_AM625_A53_EVM=y
+CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
+CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x8048
 CONFIG_SPL_DM_SPI=y
 CONFIG_DEFAULT_DEVICE_TREE="k3-am625-sk"
 CONFIG_SPL_TEXT_BASE=0x8008
@@ -18,8 +21,6 @@ CONFIG_SPL_LIBDISK_SUPPORT=y
 CONFIG_SPL_SPI_FLASH_SUPPORT=y
 CONFIG_SPL_SPI=y
 CONFIG_DISTRO_DEFAULTS=y
-CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
-CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x8048
 # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
 CONFIG_SPL_LOAD_FIT=y
 CONFIG_SPL_LOAD_FIT_ADDRESS=0x8100
@@ -32,17 +33,23 @@ CONFIG_SPL_SYS_MALLOC_SIMPLE=y
 CONFIG_SPL_STACK_R=y
 CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR=y
 CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0x1400
+CONFIG_SPL_ENV_SUPPORT=y
 CONFIG_SPL_FS_LOAD_PAYLOAD_NAME="u-boot.img"
 CONFIG_SPL_DM_MAILBOX=y
 CONFIG_SPL_DM_SPI_FLASH=y
 CONFIG_SPL_POWER_DOMAIN=y
+CONFIG_SPL_RAM_SUPPORT=y
+CONFIG_SPL_RAM_DEVICE=y
 # CONFIG_SPL_SPI_FLASH_TINY is not set
 CONFIG_SPL_SPI_FLASH_SFDP_SUPPORT=y
 CONFIG_SPL_SPI_LOAD=y
 CONFIG_SYS_SPI_U_BOOT_OFFS=0x28
+CONFIG_SPL_USB_GADGET=y
+CONFIG_SPL_DFU=y
 CONFIG_SPL_YMODEM_SUPPORT=y
-CONFIG_SYS_BOOTM_LEN=0x80
+CONFIG_CMD_DFU=y
 CONFIG_CMD_MMC=y
+CONFIG_CMD_USB=y
 CONFIG_OF_CONTROL=y
 CONFIG_SPL_OF_CONTROL=y
 CONFIG_MULTI_DTB_FIT=y
@@ -53,10 +60,17 @@ CONFIG_SPL_DM=y
 CONFIG_SPL_DM_SEQ_ALIAS=y
 CONFIG_REGMAP=y
 CONFIG_SPL_REGMAP=y
+CONFIG_SYSCON=y
+CONFIG_SPL_SYSCON=y
 CONFIG_SPL_OF_TRANSLATE=y
 CONFIG_CLK=y
 CONFIG_SPL_CLK=y
 CONFIG_CLK_TI_SCI=y
+CONFIG_DFU_MMC=y
+CONFIG_DFU_RAM=y
+CONFIG_DFU_SF=y
+CONFIG_SYS_DFU_DATA_BUF_SIZE=0x5000
+CONFIG_SYS_DFU_MAX_FILE_SIZE=0x80
 CONFIG_DMA_CHANNELS=y
 CONFIG_TI_K3_NAVSS_UDMA=y
 CONFIG_TI_SCI_PROTOCOL=y
@@ -97,5 +111,18 @@ CONFIG_CADENCE_QSPI=y
 CONFIG_SYSRESET=y
 CONFIG_SPL_SYSRESET=y
 CONFIG_SYSRESET_TI_SCI=y
+CONFIG_USB=y
+CONFIG_DM_USB_GADGET=y
+CONFIG_SPL_DM_USB_GADGET=y
+CONFIG_USB_XHCI_HCD=y
+CONFIG_USB_XHCI_DWC3=y
+CONFIG_USB_DWC3=y
+CONFIG_USB_DWC3_GENERIC=y
+CONFIG_SPL_USB_DWC3_GENERIC=y
+CONFIG_USB_GADGET=y
+CONFIG_USB_GADGET_MANUFACTURER="Texas Instruments"
+CONFIG_USB_GADGET_VENDOR_NUM=0x0451
+CONFIG_USB_GADGET_PRODUCT_NUM=0x6165
+CONFIG_USB_GADGET_DOWNLOAD=y
 CONFIG_FS_FAT_MAX_CLUSTSIZE=16384
 CONFIG_OF_LIBFDT_OVERLAY=y
diff --git a/configs/am62x_evm_r5_defconfig b/configs/am62x_evm_r5_defconfig
index 7350882a36f..3ac54e50472 100644
--- a/configs/am62x_evm_r5_defconfig
+++ b/configs/am62x_evm_r5_defconfig
@@ -7,6 +7,8 @@ CONFIG_SPL_LIBGENERIC_SUPPORT=y
 CONFIG_NR_DRAM_BANKS=2
 CONFIG_SOC_K3_AM625=y
 CONFIG_TARGET_AM625_R5_EVM=y
+CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
+CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x7000
 CONFIG_ENV_SIZE=0x2
 CONFIG_DM_GPIO=y
 CONFIG_SPL_DM_SPI=y
@@ -21,8 +23,6 @@ CONFIG_SPL_FS_FAT=y
 CONFIG_SPL_LIBDISK_SUPPORT=y
 CONFIG_SPL_SPI_FLASH_SUPPORT=y
 CONFIG_SPL_SPI=y
-CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
-CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x7000
 CONFIG_SPL_LOAD_FIT=y
 CONFIG_SPL_LOAD_FIT_ADDRESS=0x8008
 CONFIG_SPL_FIT_IMAGE_POST_PROCESS=y
@@ -41,6 +41,7 @@ CONFIG_SYS_SPL_MALLOC_SIZE=0x100
 CONFIG_SPL_EARLY_BSS=y
 CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR=y
 CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0x400
+CONFIG_SPL_ENV_SUPPORT=y
 CONFIG_SPL_DM_MAILBOX=y
 CONFIG_SPL_DM_SPI_FLASH=y
 CONFIG_SPL_DM_RESET=y
@@ -52,6 +53,8 @@ CONFIG_SPL_REMOTEPROC=y
 CONFIG_SPL_SPI_FLASH_SFDP_SUPPORT=y
 CONFIG_SPL_SPI_LOAD=y
 CONFIG_SYS_SPI_U_BOOT_OFFS=0x8
+CONFIG_SPL_USB_GADGET=y
+CONFIG_SPL_DFU=y
 CONFIG_SPL_YMODEM_SUPPORT=y
 CONFIG_HUSH_PARSER=y
 CONFIG_CMD_ASKENV=y
@@ -71,17 +74,20 @@ CONFIG_SPL_DM=y
 CONFIG_SPL_DM_SEQ_ALIAS=y
 CONFIG_REGMAP=y
 CONFIG_SPL_REGMAP=y
+CONFIG_SYSCON=y
+CONFIG_SPL_SYSCON=y
 CONFIG_SPL_OF_TRANSLATE=y
 CONFIG_CLK=y
 CONFIG_SPL_CLK=y
 CONFIG_SPL_CLK_CCF=y
 CONFIG_SPL_CLK_K3_PLL=y
 CONFIG_SPL_CLK_K3=y
+CONFIG_SYS_DFU_DATA_BUF_SIZE=0x5000
 CONFIG_TI_SCI_PROTOCOL=y
 CONFIG_DA8XX_GPIO=y
 CONFIG_DM_MAILBOX=y
 CONFIG_K3_SEC_PROXY=y
-CONFIG_SPL_MISC=y
+CONFIG_MISC=y
 CONFIG_ESM_K3=y
 CONFIG_MMC_SDHCI=y
 CONFIG_MMC_SDHCI_ADMA=y
@@ -117,5 +123,19 @@ CONFIG_CADENCE_QSPI=y
 CONFIG_TIMER=y
 CONFIG_SPL_TIMER=y
 CONFIG_OMAP_TIMER=y
+CONFIG

[PATCH 4/8] arm: dts: k3-am625-sk: Enable emmc in SPL

2023-01-21 Thread Sjoerd Simons
sdhci0 on the k3-am625-sk is the emmc, enable this in SPL as well to
allow booting from that media.

Signed-off-by: Sjoerd Simons 
---

 arch/arm/dts/k3-am625-sk-u-boot.dtsi | 8 
 1 file changed, 8 insertions(+)

diff --git a/arch/arm/dts/k3-am625-sk-u-boot.dtsi 
b/arch/arm/dts/k3-am625-sk-u-boot.dtsi
index 37458737d76..32163e5373a 100644
--- a/arch/arm/dts/k3-am625-sk-u-boot.dtsi
+++ b/arch/arm/dts/k3-am625-sk-u-boot.dtsi
@@ -92,6 +92,14 @@
u-boot,dm-spl;
 };
 
+ {
+   u-boot,dm-spl;
+};
+
+_mmc0_pins_default {
+   u-boot,dm-spl;
+};
+
  {
u-boot,dm-spl;
 };
-- 
2.39.0



[PATCH 7/8] arm: dts: k3-am625-sk: Enable usb ports in u-boot

2023-01-21 Thread Sjoerd Simons
Enable both usb0 as a peripheral for use with DFU and usb1 as a host
port for usage with e.g. usb storage.

Signed-off-by: Sjoerd Simons 
---

 arch/arm/dts/k3-am625-sk-u-boot.dtsi | 23 +++
 1 file changed, 23 insertions(+)

diff --git a/arch/arm/dts/k3-am625-sk-u-boot.dtsi 
b/arch/arm/dts/k3-am625-sk-u-boot.dtsi
index 32163e5373a..5a5b539f97a 100644
--- a/arch/arm/dts/k3-am625-sk-u-boot.dtsi
+++ b/arch/arm/dts/k3-am625-sk-u-boot.dtsi
@@ -154,3 +154,26 @@
 _port2 {
status = "disabled";
 };
+
+ {
+   u-boot,dm-spl;
+};
+
+ {
+   dr_mode = "peripheral";
+   /* Since role switching is not supported in U-Boot */
+   /delete-property/ extcon;
+   u-boot,dm-spl;
+};
+
+ {
+   u-boot,dm-spl;
+};
+
+ {
+   u-boot,dm-spl;
+};
+
+_usb1_pins_default {
+   u-boot,dm-spl;
+};
-- 
2.39.0



[PATCH 5/8] usb: dwc3: Add dwc3 glue for am62

2023-01-21 Thread Sjoerd Simons
Add glue code for TI AM62 to the dwc3 driver; Most code adopted from
TI vendor u-boot code.

Signed-off-by: Sjoerd Simons 
---

 drivers/usb/dwc3/dwc3-generic.c | 102 
 1 file changed, 102 insertions(+)

diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c
index 78966718d01..cab7b2e928d 100644
--- a/drivers/usb/dwc3/dwc3-generic.c
+++ b/drivers/usb/dwc3/dwc3-generic.c
@@ -11,6 +11,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -23,7 +24,9 @@
 #include 
 #include "core.h"
 #include "gadget.h"
+#include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -398,6 +401,104 @@ struct dwc3_glue_ops ti_ops = {
.glue_configure = dwc3_ti_glue_configure,
 };
 
+void dwc3_ti_am62_glue_configure(struct udevice *dev, int index,
+enum usb_dr_mode mode)
+{
+#define USBSS_MODE_CONTROL 0x1c
+#define USBSS_PHY_CONFIG   0x8
+#define USBSS_PHY_VBUS_SEL_MASKGENMASK(2, 1)
+#define USBSS_PHY_VBUS_SEL_SHIFT   1
+#define USBSS_MODE_VALID   BIT(0)
+#define PHY_PLL_REFCLK_MASKGENMASK(3, 0)
+static const int dwc3_ti_am62_rate_table[] = { /* in KHZ */
+   9600,
+   1,
+   12000,
+   19200,
+   2,
+   24000,
+   25000,
+   26000,
+   38400,
+   4,
+   58000,
+   5,
+   52000,
+};
+
+   struct clk usb2_refclk;
+   int rate_code, i, ret;
+   unsigned long rate;
+   u32 reg;
+   void *usbss;
+   bool vbus_divider;
+   struct regmap *syscon;
+   struct ofnode_phandle_args args;
+
+   usbss = dev_remap_addr_index(dev, 0);
+   if (IS_ERR(usbss)) {
+   dev_err(dev, "can't map IOMEM resource\n");
+   return;
+   }
+
+   ret = clk_get_by_name(dev, "ref", _refclk);
+   if (ret) {
+   dev_err(dev, "can't get usb2_refclk\n");
+   return;
+   }
+
+   /* Calcuate the rate code */
+   rate = clk_get_rate(_refclk);
+   rate /= 1000;   /* To KHz */
+   for (i = 0; i < ARRAY_SIZE(dwc3_ti_am62_rate_table); i++) {
+   if (dwc3_ti_am62_rate_table[i] == rate)
+   break;
+   }
+
+   if (i == ARRAY_SIZE(dwc3_ti_am62_rate_table)) {
+   dev_err(dev, "unsupported usb2_refclk rate: %lu KHz\n", rate);
+   return;
+   }
+
+   rate_code = i;
+
+   /* Read the syscon property */
+   syscon = syscon_regmap_lookup_by_phandle(dev, 
"ti,syscon-phy-pll-refclk");
+   if (IS_ERR(syscon)) {
+   dev_err(dev, "unable to get ti,syscon-phy-pll-refclk regmap\n");
+   return;
+   }
+
+   ret = ofnode_parse_phandle_with_args(dev_ofnode(dev), 
"ti,syscon-phy-pll-refclk", NULL, 1,
+0, );
+   if (ret)
+   return;
+
+   /* Program PHY PLL refclk by reading syscon property */
+   ret = regmap_update_bits(syscon, args.args[0], PHY_PLL_REFCLK_MASK, 
rate_code);
+   if (ret) {
+   dev_err(dev, "failed to set phy pll reference clock rate\n");
+   return;
+   }
+
+   /* VBUS divider select */
+   reg = readl(usbss + USBSS_PHY_CONFIG);
+   vbus_divider = dev_read_bool(dev, "ti,vbus-divider");
+   if (vbus_divider)
+   reg |= 1 << USBSS_PHY_VBUS_SEL_SHIFT;
+
+   writel(reg, usbss + USBSS_PHY_CONFIG);
+
+   /* Set mode valid */
+   reg = readl(usbss + USBSS_MODE_CONTROL);
+   reg |= USBSS_MODE_VALID;
+   writel(reg, usbss + USBSS_MODE_CONTROL);
+}
+
+struct dwc3_glue_ops ti_am62_ops = {
+   .glue_configure = dwc3_ti_am62_glue_configure,
+};
+
 static int dwc3_glue_bind(struct udevice *parent)
 {
ofnode node;
@@ -570,6 +671,7 @@ static const struct udevice_id dwc3_glue_ids[] = {
{ .compatible = "ti,keystone-dwc3"},
{ .compatible = "ti,dwc3", .data = (ulong)_ops },
{ .compatible = "ti,am437x-dwc3", .data = (ulong)_ops },
+   { .compatible = "ti,am62-usb", .data = (ulong)_am62_ops },
{ .compatible = "ti,am654-dwc3" },
{ .compatible = "rockchip,rk3328-dwc3" },
{ .compatible = "rockchip,rk3399-dwc3" },
-- 
2.39.0



[PATCH 2/8] arm: mach-k3: am62: Add timer0 id to the dev list

2023-01-21 Thread Sjoerd Simons
Timer0 is used by u-boot as the tick timer; Add it to the soc devices
list so it can be enabled via the k3 power controller.

Signed-off-by: Sjoerd Simons 
---

 arch/arm/mach-k3/am62x/dev-data.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/mach-k3/am62x/dev-data.c 
b/arch/arm/mach-k3/am62x/dev-data.c
index 616d0650b9c..140dca4bd1d 100644
--- a/arch/arm/mach-k3/am62x/dev-data.c
+++ b/arch/arm/mach-k3/am62x/dev-data.c
@@ -58,6 +58,7 @@ static struct ti_dev soc_dev_list[] = {
PSC_DEV(161, _lpsc_list[8]),
PSC_DEV(162, _lpsc_list[9]),
PSC_DEV(75, _lpsc_list[10]),
+   PSC_DEV(36, _lpsc_list[11]),
PSC_DEV(102, _lpsc_list[11]),
PSC_DEV(146, _lpsc_list[11]),
PSC_DEV(13, _lpsc_list[12]),
-- 
2.39.0



[PATCH 1/8] omap: timer: add ti,am654-timer compatibility

2023-01-21 Thread Sjoerd Simons
THe TI AM654 timer is compatible with the omap-timer implementation, so
add it to the id list

Signed-off-by: Sjoerd Simons 
---

 drivers/timer/omap-timer.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/timer/omap-timer.c b/drivers/timer/omap-timer.c
index aa2e4360c1b..9b6d97dae67 100644
--- a/drivers/timer/omap-timer.c
+++ b/drivers/timer/omap-timer.c
@@ -114,6 +114,7 @@ static const struct udevice_id omap_timer_ids[] = {
{ .compatible = "ti,am335x-timer" },
{ .compatible = "ti,am4372-timer" },
{ .compatible = "ti,omap5430-timer" },
+   { .compatible = "ti,am654-timer" },
{}
 };
 
-- 
2.39.0



[PATCH 0/8] Add DFU, emmc and usb boot for TI am62x

2023-01-21 Thread Sjoerd Simons


This series adds more boot sources for the TI am62x. For that the dts'
are synced from the upstream ti-next git tree (to add usb nodes), some
dwc3 glue is and finally the default configuration is tuned to add
support for DFU and USB (host and gadget)



Aswath Govindraju (1):
  configs: am62: Add configs for enabling USB in U-Boot

Sjoerd Simons (7):
  omap: timer: add ti,am654-timer compatibility
  arm: mach-k3: am62: Add timer0 id to the dev list
  arm: dts: k3-am62: Bump dtsi from ti-next
  arm: dts: k3-am625-sk: Enable emmc in SPL
  usb: dwc3: Add dwc3 glue for am62
  arm: dts: k3-am625-sk: Enable usb ports in u-boot
  configs: am62x_evm_*: Enable USB and DFU support

 arch/arm/dts/k3-am62-main.dtsi   | 259 ---
 arch/arm/dts/k3-am62-mcu.dtsi|  49 +
 arch/arm/dts/k3-am62-wakeup.dtsi |   4 +-
 arch/arm/dts/k3-am625-r5-sk.dts  |   2 +-
 arch/arm/dts/k3-am625-sk-u-boot.dtsi |  39 +++-
 arch/arm/dts/k3-am625-sk.dts |  95 +-
 arch/arm/dts/k3-am625.dtsi   |  52 ++
 arch/arm/mach-k3/am62x/dev-data.c|   1 +
 configs/am62x_evm_a53_defconfig  |  33 +++-
 configs/am62x_evm_r5_defconfig   |  26 ++-
 drivers/timer/omap-timer.c   |   1 +
 drivers/usb/dwc3/dwc3-generic.c  | 102 +++
 include/configs/am62x_evm.h  |  10 +-
 13 files changed, 578 insertions(+), 95 deletions(-)

-- 
2.39.0



[PATCH 3/3] lmb: Treat a region which is a subset as equal

2023-01-19 Thread Sjoerd Simons
In various cases logical memory blocks are coalesced; As a result doing
a strict check whether memory blocks are the same doesn't necessarily
work as a previous addition of a given block might have been merged into
a bigger block.

Fix this by considering a block is already registered if it's a pure
subset of one of the existing blocks.

Signed-off-by: Sjoerd Simons 

---

 lib/lmb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/lmb.c b/lib/lmb.c
index f447c639a60..b09a043f4c2 100644
--- a/lib/lmb.c
+++ b/lib/lmb.c
@@ -248,7 +248,7 @@ static long lmb_add_region_flags(struct lmb_region *rgn, 
phys_addr_t base,
phys_size_t rgnsize = rgn->region[i].size;
phys_size_t rgnflags = rgn->region[i].flags;
 
-   if (rgnbase == base && rgnsize == size) {
+   if (rgnbase <= base && rgnbase + rgnsize >= base + size) {
if (flags == rgnflags)
/* Already have this region, so we're done */
return 0;
-- 
2.39.0



[PATCH 2/3] lmb: Set correct lmb flags for EFI memory map entries

2023-01-19 Thread Sjoerd Simons
When adding reserved memory areas from the EFI memory map set the NOMAP
flag when applicable. When this isn't done adding "no-map" flagged entries
from the fdt after receiving the same from the EFI memory map fails due
to non-matching flags.

Signed-off-by: Sjoerd Simons 
---

 lib/lmb.c | 13 -
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/lib/lmb.c b/lib/lmb.c
index ec790760db6..f447c639a60 100644
--- a/lib/lmb.c
+++ b/lib/lmb.c
@@ -175,11 +175,14 @@ static __maybe_unused int efi_lmb_reserve(struct lmb *lmb)
return 1;
 
for (i = 0, map = memmap; i < map_size / sizeof(*map); ++map, ++i) {
-   if (map->type != EFI_CONVENTIONAL_MEMORY)
-   lmb_reserve(lmb,
-   map_to_sysmem((void *)(uintptr_t)
- map->physical_start),
-   map->num_pages * EFI_PAGE_SIZE);
+   if (map->type != EFI_CONVENTIONAL_MEMORY) {
+   lmb_reserve_flags(lmb,
+ map_to_sysmem((void *)(uintptr_t)
+   map->physical_start),
+ map->num_pages * EFI_PAGE_SIZE,
+ map->type == EFI_RESERVED_MEMORY_TYPE
+ ? LMB_NOMAP : LMB_NONE);
+   }
}
efi_free_pool(memmap);
 
-- 
2.39.0



[PATCH 1/3] Bump LMB_MAX_REGIONS default to 16

2023-01-19 Thread Sjoerd Simons
Since commit 06d514d77c37 ("lmb: consider EFI memory map") the EFI regions
are also pushed into the lmb if EFI_LOADER is enabled (which is by
default on most system). Which can cause the number of entries to go
over the maximum as it's default is only 8.

Specifically i ran into this case on an TI am62 which has an fdt with
4 reserved regions (in practice 3 lmb entries due to adjecent ranges).

As this is likely to impact more devices bump the default max
regions to 16 so there is a bit more slack.

Signed-off-by: Sjoerd Simons 
---

 lib/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/Kconfig b/lib/Kconfig
index def36f275ce..7eb0e7addc7 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -1005,7 +1005,7 @@ config LMB_USE_MAX_REGIONS
 config LMB_MAX_REGIONS
int "Number of memory and reserved regions in lmb lib"
depends on LMB && LMB_USE_MAX_REGIONS
-   default 8
+   default 16
help
  Define the number of supported regions, memory and reserved, in the
  library logical memory blocks.
-- 
2.39.0



[PATCH 0/3] Fix boot regressions on at least TI am62x

2023-01-19 Thread Sjoerd Simons


When booting a recent u-boot master on TI am62x with the distro boot
sequence it fails loading the FDT:

   Booting using the fdt blob at 0x8800
Working FDT set to 8800
   Loading Ramdisk to 8d711000, end 8d95 ... OK
ERROR: reserving fdt memory region failed (addr=9e78 size=8 flags=4)
ERROR: reserving fdt memory region failed (addr=9e80 size=180 flags=4)
ERROR: reserving fdt memory region failed (addr=9db0 size=c0 flags=4)
ERROR: Failed to allocate 0x8f58 bytes below 0x9000.
device tree - allocation error
FDT creation failed!
resetting ...

It turns out that this is caused by commit 06d514d77c37 ("lmb: consider EFI
memory map") due to injecting both extra and some similar memory regions
via a different path into the lmb. The following series fixes the
apparent fallout from that ;)


Sjoerd Simons (3):
  Bump LMB_MAX_REGIONS default to 16
  lmb: Set correct lmb flags for EFI memory map entries
  lmb: Treat a region which is a subset as equal

 lib/Kconfig |  2 +-
 lib/lmb.c   | 15 +--
 2 files changed, 10 insertions(+), 7 deletions(-)

-- 
2.39.0



Re: [PATCH 1/2] Revert "patman: invoke the checkpatch.pl script with '--u-boot' and '--strict'"

2023-01-16 Thread Sjoerd Simons
On Fri, 2023-01-13 at 08:50 -0500, Maxim Cournoyer wrote:
> This reverts commit 648d8186dd7f9c444fb07f355090d275dcdd4de4, because
> it broke usage of patman on Linux, whose check script doesn't know
> about '--strict' or '--u-boot'.

I can confirm that this reverts fixes the reported issue:

Tested-by: Sjoerd Simons 

> 
> Reported-by: Sjoerd Simons 
> Signed-off-by: Maxim Cournoyer 
> ---
> 
>  tools/patman/checkpatch.py | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/patman/checkpatch.py b/tools/patman/checkpatch.py
> index 012c0d895c..d1b902dd96 100644
> --- a/tools/patman/checkpatch.py
> +++ b/tools/patman/checkpatch.py
> @@ -211,7 +211,7 @@ def check_patch(fname, verbose=False,
> show_types=False, use_tree=False):
>  stdout: Full output of checkpatch
>  """
>  chk = find_check_patch()
> -    args = [chk, '--u-boot', '--strict']
> +    args = [chk]
>  if not use_tree:
>  args.append('--no-tree')
>      if show_types:
> 
> base-commit: 87c9e117bf57d6bb42c5521a3f6ec9ca7d97e5fa

-- 
Sjoerd Simons
Collabora Ltd.


Re: [PATCH v3 3/8] patman: invoke the checkpatch.pl script with '--u-boot' and '--strict'

2023-01-13 Thread Sjoerd Simons
Hey,

This breaks using patman for linux as it's check-patch has no clue
about `--u-boot` :).  I'm not sure if people using patman for linux
patches is meant to be a supported use-case though (the documentation
seems to indicate it is)


On Wed, 2022-12-21 at 00:28 +, Simon Glass wrote:
> This resolves 10 out of 11 test failures seen when running './patman
> test' from the 'tools/patman' subdirectory. This was caused by the
> .checkpatch.conf configuration file at the root of the project not
> being picked up. Make the test suite of patman independent from it by
> always invoking the checkpatch.pl script with the minimally required
> arguments for the test suite to pass.
> 
> Reviewed-by: Simon Glass 
> Signed-off-by: Maxim Cournoyer 
> ---
> 
> Changes in v3:
> - Fix typo in commit message
> 
> Changes in v2:
> - Reword the commit message with a better explanation of the problem
> - Add the '--strict' argument to script invocation
> 
>  tools/patman/checkpatch.py | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> Applied to u-boot-dm/next, thanks!

-- 
Sjoerd Simons
Collabora Ltd.


[PATCH v2 3/4] arm: dts: k3-am625-sk: Enable first ethernet port

2022-12-20 Thread Sjoerd Simons
The K3 am625 sk EVM has two ethernet ports; Enable the first one for
usage in u-boot.

Signed-off-by: Sjoerd Simons 
---

(no changes since v1)

 arch/arm/dts/k3-am625-sk-u-boot.dtsi | 22 ++
 1 file changed, 22 insertions(+)

diff --git a/arch/arm/dts/k3-am625-sk-u-boot.dtsi 
b/arch/arm/dts/k3-am625-sk-u-boot.dtsi
index 92788bae3e0..f275e3b46ca 100644
--- a/arch/arm/dts/k3-am625-sk-u-boot.dtsi
+++ b/arch/arm/dts/k3-am625-sk-u-boot.dtsi
@@ -126,3 +126,25 @@
};
};
 };
+
+ {
+   reg = <0x0 0x800 0x0 0x20>,
+ <0x0 0x43000200 0x0 0x8>;
+   reg-names = "cpsw_nuss", "mac_efuse";
+   /delete-property/ ranges;
+   u-boot,dm-spl;
+
+   cpsw-phy-sel@04044 {
+   compatible = "ti,am64-phy-gmii-sel";
+   reg = <0x0 0x00104044 0x0 0x8>;
+   u-boot,dm-spl;
+   };
+};
+
+_port1 {
+   u-boot,dm-spl;
+};
+
+_port2 {
+   status = "disabled";
+};
-- 
2.39.0



[PATCH v2 2/4] configs: am62x_evm_*: Run savedefconfig

2022-12-20 Thread Sjoerd Simons
Clean configuration for am62x_evm using savedefconfig

Signed-off-by: Sjoerd Simons 
---

(no changes since v1)

 configs/am62x_evm_a53_defconfig |  4 ++--
 configs/am62x_evm_r5_defconfig  | 32 +++-
 2 files changed, 17 insertions(+), 19 deletions(-)

diff --git a/configs/am62x_evm_a53_defconfig b/configs/am62x_evm_a53_defconfig
index 94de1ea4586..cd06e362f09 100644
--- a/configs/am62x_evm_a53_defconfig
+++ b/configs/am62x_evm_a53_defconfig
@@ -7,6 +7,7 @@ CONFIG_NR_DRAM_BANKS=2
 CONFIG_SOC_K3_AM625=y
 CONFIG_K3_ATF_LOAD_ADDR=0x9e78
 CONFIG_TARGET_AM625_A53_EVM=y
+CONFIG_SPL_DM_SPI=y
 CONFIG_DEFAULT_DEVICE_TREE="k3-am625-sk"
 CONFIG_SPL_TEXT_BASE=0x8008
 CONFIG_SPL_MMC=y
@@ -14,6 +15,7 @@ CONFIG_SPL_SERIAL=y
 CONFIG_SPL_STACK_R_ADDR=0x8200
 CONFIG_SPL_FS_FAT=y
 CONFIG_SPL_LIBDISK_SUPPORT=y
+CONFIG_SPL_SPI_FLASH_SUPPORT=y
 CONFIG_SPL_SPI=y
 CONFIG_DISTRO_DEFAULTS=y
 CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
@@ -32,12 +34,10 @@ CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR=y
 CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0x1400
 CONFIG_SPL_FS_LOAD_PAYLOAD_NAME="u-boot.img"
 CONFIG_SPL_DM_MAILBOX=y
-CONFIG_SPL_DM_SPI=y
 CONFIG_SPL_DM_SPI_FLASH=y
 CONFIG_SPL_POWER_DOMAIN=y
 # CONFIG_SPL_SPI_FLASH_TINY is not set
 CONFIG_SPL_SPI_FLASH_SFDP_SUPPORT=y
-CONFIG_SPL_SPI_FLASH_SUPPORT=y
 CONFIG_SPL_SPI_LOAD=y
 CONFIG_SYS_SPI_U_BOOT_OFFS=0x28
 CONFIG_SPL_YMODEM_SUPPORT=y
diff --git a/configs/am62x_evm_r5_defconfig b/configs/am62x_evm_r5_defconfig
index 40f933ca749..7350882a36f 100644
--- a/configs/am62x_evm_r5_defconfig
+++ b/configs/am62x_evm_r5_defconfig
@@ -7,6 +7,7 @@ CONFIG_SPL_LIBGENERIC_SUPPORT=y
 CONFIG_NR_DRAM_BANKS=2
 CONFIG_SOC_K3_AM625=y
 CONFIG_TARGET_AM625_R5_EVM=y
+CONFIG_ENV_SIZE=0x2
 CONFIG_DM_GPIO=y
 CONFIG_SPL_DM_SPI=y
 CONFIG_DEFAULT_DEVICE_TREE="k3-am625-r5-sk"
@@ -18,10 +19,8 @@ CONFIG_SPL_STACK_R_ADDR=0x8200
 CONFIG_SPL_SIZE_LIMIT=0x4
 CONFIG_SPL_FS_FAT=y
 CONFIG_SPL_LIBDISK_SUPPORT=y
-CONFIG_SPL_SPI=y
 CONFIG_SPL_SPI_FLASH_SUPPORT=y
-CONFIG_SPL_SPI_SUPPORT=y
-CONFIG_SF_DEFAULT_SPEED=2500
+CONFIG_SPL_SPI=y
 CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
 CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x7000
 CONFIG_SPL_LOAD_FIT=y
@@ -42,10 +41,9 @@ CONFIG_SYS_SPL_MALLOC_SIZE=0x100
 CONFIG_SPL_EARLY_BSS=y
 CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR=y
 CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0x400
-CONFIG_SYS_SPI_U_BOOT_OFFS=0x8
 CONFIG_SPL_DM_MAILBOX=y
-CONFIG_SPL_DM_RESET=y
 CONFIG_SPL_DM_SPI_FLASH=y
+CONFIG_SPL_DM_RESET=y
 CONFIG_SPL_POWER_DOMAIN=y
 CONFIG_SPL_RAM_SUPPORT=y
 CONFIG_SPL_RAM_DEVICE=y
@@ -53,6 +51,7 @@ CONFIG_SPL_REMOTEPROC=y
 # CONFIG_SPL_SPI_FLASH_TINY is not set
 CONFIG_SPL_SPI_FLASH_SFDP_SUPPORT=y
 CONFIG_SPL_SPI_LOAD=y
+CONFIG_SYS_SPI_U_BOOT_OFFS=0x8
 CONFIG_SPL_YMODEM_SUPPORT=y
 CONFIG_HUSH_PARSER=y
 CONFIG_CMD_ASKENV=y
@@ -88,6 +87,14 @@ CONFIG_MMC_SDHCI=y
 CONFIG_MMC_SDHCI_ADMA=y
 CONFIG_SPL_MMC_SDHCI_ADMA=y
 CONFIG_MMC_SDHCI_AM654=y
+CONFIG_DM_SPI_FLASH=y
+CONFIG_SF_DEFAULT_MODE=0
+CONFIG_SF_DEFAULT_SPEED=2500
+CONFIG_SPI_FLASH_SFDP_SUPPORT=y
+CONFIG_SPI_FLASH_SOFT_RESET=y
+CONFIG_SPI_FLASH_SOFT_RESET_ON_BOOT=y
+CONFIG_SPI_FLASH_SPANSION=y
+CONFIG_SPI_FLASH_S28HX_T=y
 CONFIG_PINCTRL=y
 # CONFIG_PINCTRL_GENERIC is not set
 CONFIG_SPL_PINCTRL=y
@@ -101,23 +108,14 @@ CONFIG_DM_RESET=y
 CONFIG_RESET_TI_SCI=y
 CONFIG_SPECIFY_CONSOLE_INDEX=y
 CONFIG_DM_SERIAL=y
-CONFIG_DM_SPI=y
-CONFIG_CADENCE_QSPI=y
-CONFIG_DM_SPI_FLASH=y
-CONFIG_SF_DEFAULT_MODE=0
-CONFIG_SPI=y
-CONFIG_SPI_FLASH_SFDP_SUPPORT=y
-CONFIG_SPI_FLASH_SOFT_RESET=y
-CONFIG_SPI_FLASH_SOFT_RESET_ON_BOOT=y
-CONFIG_SPI_FLASH_SPANSION=y
-CONFIG_SPI_FLASH_S28HX_T=y
 CONFIG_SOC_DEVICE=y
 CONFIG_SOC_DEVICE_TI_K3=y
 CONFIG_SOC_TI=y
+CONFIG_SPI=y
+CONFIG_DM_SPI=y
+CONFIG_CADENCE_QSPI=y
 CONFIG_TIMER=y
 CONFIG_SPL_TIMER=y
 CONFIG_OMAP_TIMER=y
 CONFIG_LIB_RATIONAL=y
 CONFIG_SPL_LIB_RATIONAL=y
-CONFIG_ENV_SIZE=0x2
-CONFIG_ENV_OFFSET=0x68
-- 
2.39.0



[PATCH v2 4/4] configs: am62x_evm_a53: Enable ethernet

2022-12-20 Thread Sjoerd Simons
Enable ethernet support for u-boot on am62x evm

Signed-off-by: Sjoerd Simons 

---

Changes in v2:
  - Split out config cleanup from ethernet changes

 configs/am62x_evm_a53_defconfig | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/configs/am62x_evm_a53_defconfig b/configs/am62x_evm_a53_defconfig
index cd06e362f09..ab77135e257 100644
--- a/configs/am62x_evm_a53_defconfig
+++ b/configs/am62x_evm_a53_defconfig
@@ -57,6 +57,8 @@ CONFIG_SPL_OF_TRANSLATE=y
 CONFIG_CLK=y
 CONFIG_SPL_CLK=y
 CONFIG_CLK_TI_SCI=y
+CONFIG_DMA_CHANNELS=y
+CONFIG_TI_K3_NAVSS_UDMA=y
 CONFIG_TI_SCI_PROTOCOL=y
 CONFIG_DM_MAILBOX=y
 CONFIG_K3_SEC_PROXY=y
@@ -72,6 +74,10 @@ CONFIG_SPI_FLASH_SOFT_RESET=y
 CONFIG_SPI_FLASH_SOFT_RESET_ON_BOOT=y
 CONFIG_SPI_FLASH_SPANSION=y
 CONFIG_SPI_FLASH_S28HX_T=y
+CONFIG_PHY_TI_DP83867=y
+CONFIG_PHY_FIXED=y
+CONFIG_TI_AM65_CPSW_NUSS=y
+CONFIG_PHY=y
 CONFIG_PINCTRL=y
 CONFIG_SPL_PINCTRL=y
 CONFIG_PINCTRL_SINGLE=y
-- 
2.39.0



[PATCH v2 1/4] configs: am62x_evm_*: Correct SPI configuration option

2022-12-20 Thread Sjoerd Simons
In f422c4bec the configuration option to support s28hs512t SPI flashes
was changed from CONFIG_SPI_FLASH_S28HS512T to CONFIG_SPI_FLASH_S28HX_T
to support the wider family. Follow this change in the AM62x EVM
configurations.

Signed-off-by: Sjoerd Simons 
---

(no changes since v1)

 configs/am62x_evm_a53_defconfig | 2 +-
 configs/am62x_evm_r5_defconfig  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/configs/am62x_evm_a53_defconfig b/configs/am62x_evm_a53_defconfig
index e6ffd166927..94de1ea4586 100644
--- a/configs/am62x_evm_a53_defconfig
+++ b/configs/am62x_evm_a53_defconfig
@@ -71,7 +71,7 @@ CONFIG_SPI_FLASH_SFDP_SUPPORT=y
 CONFIG_SPI_FLASH_SOFT_RESET=y
 CONFIG_SPI_FLASH_SOFT_RESET_ON_BOOT=y
 CONFIG_SPI_FLASH_SPANSION=y
-CONFIG_SPI_FLASH_S28HS512T=y
+CONFIG_SPI_FLASH_S28HX_T=y
 CONFIG_PINCTRL=y
 CONFIG_SPL_PINCTRL=y
 CONFIG_PINCTRL_SINGLE=y
diff --git a/configs/am62x_evm_r5_defconfig b/configs/am62x_evm_r5_defconfig
index f95bc5f2221..40f933ca749 100644
--- a/configs/am62x_evm_r5_defconfig
+++ b/configs/am62x_evm_r5_defconfig
@@ -110,7 +110,7 @@ CONFIG_SPI_FLASH_SFDP_SUPPORT=y
 CONFIG_SPI_FLASH_SOFT_RESET=y
 CONFIG_SPI_FLASH_SOFT_RESET_ON_BOOT=y
 CONFIG_SPI_FLASH_SPANSION=y
-CONFIG_SPI_FLASH_S28HS512T=y
+CONFIG_SPI_FLASH_S28HX_T=y
 CONFIG_SOC_DEVICE=y
 CONFIG_SOC_DEVICE_TI_K3=y
 CONFIG_SOC_TI=y
-- 
2.39.0



[PATCH v2 0/4] Enable ethernet for ti am62x

2022-12-20 Thread Sjoerd Simons


These patches enable ethernet from u-boot on the ti am62x EVM. They are
based on the u-boot next branch (33f4d3c3) to take advantage of recent dts sync
of these boards with linux

The first two patches clean up the configurations little bit (fixing
incorrect config variable, running savedefconfig), the last two actually
enable ethernet support


Changes in v2:
  - Split out config cleanup from ethernet changes

Sjoerd Simons (4):
  configs: am62x_evm_*: Correct SPI configuration option
  configs: am62x_evm_*: Run savedefconfig
  arm: dts: k3-am625-sk: Enable first ethernet port
  configs: am62x_evm_a53: Enable ethernet

 arch/arm/dts/k3-am625-sk-u-boot.dtsi | 22 +++
 configs/am62x_evm_a53_defconfig  | 12 ---
 configs/am62x_evm_r5_defconfig   | 32 +---
 3 files changed, 46 insertions(+), 20 deletions(-)

-- 
2.39.0



Re: [PATCH 2/2] configs: am62x_evm_a53: Enable ethernet

2022-12-19 Thread Sjoerd Simons
On Tue, 2022-12-20 at 10:17 +0530, Dhruva Gole wrote:
> 
> 
> On 19/12/22 21:45, Sjoerd Simons wrote:
> > Enable configuration ethernet for u-boot on am62x; Some unrelated
> > things
> > also got moved around due to running through savedefconfig.
> > 
> > Signed-off-by: Sjoerd Simons 
> > 
> > ---
> > 
> >   configs/am62x_evm_a53_defconfig | 11 ---
> >   1 file changed, 8 insertions(+), 3 deletions(-)
> > 
> > diff --git a/configs/am62x_evm_a53_defconfig
> > b/configs/am62x_evm_a53_defconfig
> > index e6ffd166927..30b19428e9e 100644
> > --- a/configs/am62x_evm_a53_defconfig
> > +++ b/configs/am62x_evm_a53_defconfig
> > @@ -7,6 +7,7 @@ CONFIG_NR_DRAM_BANKS=2
> [...]
> >   CONFIG_K3_SEC_PROXY=y
> > @@ -71,7 +73,10 @@ CONFIG_SPI_FLASH_SFDP_SUPPORT=y
> >   CONFIG_SPI_FLASH_SOFT_RESET=y
> >   CONFIG_SPI_FLASH_SOFT_RESET_ON_BOOT=y
> >   CONFIG_SPI_FLASH_SPANSION=y
> > -CONFIG_SPI_FLASH_S28HS512T=y
> 
> Removing this might break  S28HS512T Octal SPI NOR Flash. Please let
> this stay if it isn't related to the eth configs.

This got removed by savedefconfig ; CONFIG_SPI_FLASH_S28HS512T doesn't
exist in u-boot anymore[0], it's been replaced by
CONFIG_SPI_FLASH_S28HX_T.   

I can do quick respin to seperate out cleaning the defconfig,
correcting that option and then add ethernet on top to make things more
clear.


0:https://source.denx.de/u-boot/u-boot/-/commit/f422c4bec7c654d185abb9bb29f79738e3115323

-- 
Sjoerd Simons
Collabora Ltd.


[PATCH 1/2] arm: dts: k3-am625-sk: Enable first ethernet port

2022-12-19 Thread Sjoerd Simons
The K3 am625 sk EVM has two ethernet ports; Enable the first one for
usage in u-boot.

Signed-off-by: Sjoerd Simons 
---

 arch/arm/dts/k3-am625-sk-u-boot.dtsi | 22 ++
 1 file changed, 22 insertions(+)

diff --git a/arch/arm/dts/k3-am625-sk-u-boot.dtsi 
b/arch/arm/dts/k3-am625-sk-u-boot.dtsi
index 92788bae3e0..f275e3b46ca 100644
--- a/arch/arm/dts/k3-am625-sk-u-boot.dtsi
+++ b/arch/arm/dts/k3-am625-sk-u-boot.dtsi
@@ -126,3 +126,25 @@
};
};
 };
+
+ {
+   reg = <0x0 0x800 0x0 0x20>,
+ <0x0 0x43000200 0x0 0x8>;
+   reg-names = "cpsw_nuss", "mac_efuse";
+   /delete-property/ ranges;
+   u-boot,dm-spl;
+
+   cpsw-phy-sel@04044 {
+   compatible = "ti,am64-phy-gmii-sel";
+   reg = <0x0 0x00104044 0x0 0x8>;
+   u-boot,dm-spl;
+   };
+};
+
+_port1 {
+   u-boot,dm-spl;
+};
+
+_port2 {
+   status = "disabled";
+};
-- 
2.39.0



[PATCH 2/2] configs: am62x_evm_a53: Enable ethernet

2022-12-19 Thread Sjoerd Simons
Enable configuration ethernet for u-boot on am62x; Some unrelated things
also got moved around due to running through savedefconfig.

Signed-off-by: Sjoerd Simons 

---

 configs/am62x_evm_a53_defconfig | 11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/configs/am62x_evm_a53_defconfig b/configs/am62x_evm_a53_defconfig
index e6ffd166927..30b19428e9e 100644
--- a/configs/am62x_evm_a53_defconfig
+++ b/configs/am62x_evm_a53_defconfig
@@ -7,6 +7,7 @@ CONFIG_NR_DRAM_BANKS=2
 CONFIG_SOC_K3_AM625=y
 CONFIG_K3_ATF_LOAD_ADDR=0x9e78
 CONFIG_TARGET_AM625_A53_EVM=y
+CONFIG_SPL_DM_SPI=y
 CONFIG_DEFAULT_DEVICE_TREE="k3-am625-sk"
 CONFIG_SPL_TEXT_BASE=0x8008
 CONFIG_SPL_MMC=y
@@ -14,6 +15,7 @@ CONFIG_SPL_SERIAL=y
 CONFIG_SPL_STACK_R_ADDR=0x8200
 CONFIG_SPL_FS_FAT=y
 CONFIG_SPL_LIBDISK_SUPPORT=y
+CONFIG_SPL_SPI_FLASH_SUPPORT=y
 CONFIG_SPL_SPI=y
 CONFIG_DISTRO_DEFAULTS=y
 CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
@@ -32,12 +34,10 @@ CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR=y
 CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0x1400
 CONFIG_SPL_FS_LOAD_PAYLOAD_NAME="u-boot.img"
 CONFIG_SPL_DM_MAILBOX=y
-CONFIG_SPL_DM_SPI=y
 CONFIG_SPL_DM_SPI_FLASH=y
 CONFIG_SPL_POWER_DOMAIN=y
 # CONFIG_SPL_SPI_FLASH_TINY is not set
 CONFIG_SPL_SPI_FLASH_SFDP_SUPPORT=y
-CONFIG_SPL_SPI_FLASH_SUPPORT=y
 CONFIG_SPL_SPI_LOAD=y
 CONFIG_SYS_SPI_U_BOOT_OFFS=0x28
 CONFIG_SPL_YMODEM_SUPPORT=y
@@ -57,6 +57,8 @@ CONFIG_SPL_OF_TRANSLATE=y
 CONFIG_CLK=y
 CONFIG_SPL_CLK=y
 CONFIG_CLK_TI_SCI=y
+CONFIG_DMA_CHANNELS=y
+CONFIG_TI_K3_NAVSS_UDMA=y
 CONFIG_TI_SCI_PROTOCOL=y
 CONFIG_DM_MAILBOX=y
 CONFIG_K3_SEC_PROXY=y
@@ -71,7 +73,10 @@ CONFIG_SPI_FLASH_SFDP_SUPPORT=y
 CONFIG_SPI_FLASH_SOFT_RESET=y
 CONFIG_SPI_FLASH_SOFT_RESET_ON_BOOT=y
 CONFIG_SPI_FLASH_SPANSION=y
-CONFIG_SPI_FLASH_S28HS512T=y
+CONFIG_PHY_TI_DP83867=y
+CONFIG_PHY_FIXED=y
+CONFIG_TI_AM65_CPSW_NUSS=y
+CONFIG_PHY=y
 CONFIG_PINCTRL=y
 CONFIG_SPL_PINCTRL=y
 CONFIG_PINCTRL_SINGLE=y
-- 
2.39.0



[PATCH 0/2] Enable ethernet for ti am62x

2022-12-19 Thread Sjoerd Simons


These patches enable ethernet from u-boot on the ti am62x EVM. They are
based on the u-boot next branch (9c955393) to take advantage of recent dts sync
of these boards with linux


Sjoerd Simons (2):
  arm: dts: k3-am625-sk: Enable first ethernet port
  configs: am62x_evm_a53: Enable ethernet

 arch/arm/dts/k3-am625-sk-u-boot.dtsi | 22 ++
 configs/am62x_evm_a53_defconfig  | 11 ---
 2 files changed, 30 insertions(+), 3 deletions(-)

-- 
2.39.0



Re: [PATCH 1/2] rpi: Copy properties from firmware dtb to the loaded dtb

2022-09-06 Thread Sjoerd Simons
On Mon, 2022-09-05 at 21:11 +0200, Antoine Mazeas wrote:
> Sorry following up on your last comment, what specific issues are you
> referring to on the rev 1.3+ pi 4s ? It may be worth hunting them
> down, 
> although I may lack access to such boards.
> 
> Le 05/09/2022 à 15:41, Peter Robinson a écrit :
> > Tested on RPi400 and it solves the issues with the kernel DT I've
> > seen
> > plus some RPi4s although no the rev 1.3+ devices that also have the
> > newer SoC rev that's the same in the rpi400

For reference the newer RPI4 boards is why i wrote the patch in the
first place as some folks in our team were hitting issues with them :)
So i can confirm my patch solves the issue there as well;

Unfortunately i don't have newer revisions RPI4's myself, but behaviour
wise they seem the same as the RPI 400 as they share the same SoC
revision
-- 
Sjoerd Simons
Collabora Ltd.


[PATCH] configs: rock-pi-4: Enable rockchip efuse support

2021-11-25 Thread Sjoerd Simons
Enable efuse support for reading the cpuid#, serial# and generate a
board unique mac address

Signed-off-by: Sjoerd Simons 

---

 configs/rock-pi-4-rk3399_defconfig  | 1 +
 configs/rock-pi-4c-rk3399_defconfig | 1 +
 2 files changed, 2 insertions(+)

diff --git a/configs/rock-pi-4-rk3399_defconfig 
b/configs/rock-pi-4-rk3399_defconfig
index 9366eba8f15..032b9086699 100644
--- a/configs/rock-pi-4-rk3399_defconfig
+++ b/configs/rock-pi-4-rk3399_defconfig
@@ -31,6 +31,7 @@ CONFIG_OF_SPL_REMOVE_PROPS="pinctrl-0 pinctrl-names 
clock-names interrupt-parent
 CONFIG_ENV_IS_IN_MMC=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_ROCKCHIP_GPIO=y
+CONFIG_ROCKCHIP_EFUSE=y
 CONFIG_SYS_I2C_ROCKCHIP=y
 CONFIG_MISC=y
 CONFIG_MMC_DW=y
diff --git a/configs/rock-pi-4c-rk3399_defconfig 
b/configs/rock-pi-4c-rk3399_defconfig
index ac045d1492f..6f5e8666b0d 100644
--- a/configs/rock-pi-4c-rk3399_defconfig
+++ b/configs/rock-pi-4c-rk3399_defconfig
@@ -31,6 +31,7 @@ CONFIG_OF_SPL_REMOVE_PROPS="pinctrl-0 pinctrl-names 
clock-names interrupt-parent
 CONFIG_ENV_IS_IN_MMC=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_ROCKCHIP_GPIO=y
+CONFIG_ROCKCHIP_EFUSE=y
 CONFIG_SYS_I2C_ROCKCHIP=y
 CONFIG_MISC=y
 CONFIG_MMC_DW=y
-- 
2.34.0



[RESEND PATCH] rpi: Copy properties from firmware dtb to the loaded dtb

2021-11-25 Thread Sjoerd Simons
The RPI firmware adjusts several property values in the dtb it passes
to u-boot depending on the board/SoC revision. Inherit some of these
when u-boot loads a dtb itself. Specificaly copy:

* /model: The firmware provides a more specific string
* /memreserve: The firmware defines a reserved range, better keep it
* emmc2bus and pcie0 dma-ranges: The C0T revision of the bcm2711 Soc (as
  present on rpi 400 and some rpi 4B boards) has different values for
  these then the B0T revision. So these need to be adjusted to boot on
  these boards
* blconfig: The firmware defines the memory area where the blconfig
  stored. Copy those over so it can be enabled.
* /chosen/kaslr-seed: The firmware generates a kaslr seed, take advantage
  of that.

Signed-off-by: Sjoerd Simons 
---

 board/raspberrypi/rpi/rpi.c | 48 +
 1 file changed, 48 insertions(+)

diff --git a/board/raspberrypi/rpi/rpi.c b/board/raspberrypi/rpi/rpi.c
index 55afaa54d9f..cdde32c8143 100644
--- a/board/raspberrypi/rpi/rpi.c
+++ b/board/raspberrypi/rpi/rpi.c
@@ -499,10 +499,58 @@ void *board_fdt_blob_setup(int *err)
return (void *)fw_dtb_pointer;
 }
 
+int copy_property(void *dst, void *src, char *path, char *property)
+{
+   int dst_offset, src_offset;
+   const fdt32_t *prop;
+   int len;
+
+   src_offset = fdt_path_offset(src, path);
+   dst_offset = fdt_path_offset(dst, path);
+
+   if (src_offset < 0 || dst_offset < 0)
+   return -1;
+
+   prop = fdt_getprop(src, src_offset, property, );
+   if (!prop)
+   return -1;
+
+   return fdt_setprop(dst, dst_offset, property, prop, len);
+}
+
+/* Copy tweaks from the firmware dtb to the loaded dtb */
+void  update_fdt_from_fw(void *fdt, void *fw_fdt)
+{
+   /* Using dtb from firmware directly; leave it alone */
+   if (fdt == fw_fdt)
+   return;
+
+   /* The firmware provides a more precie model; so copy that */
+   copy_property(fdt, fw_fdt, "/", "model");
+
+   /* memory reserve as suggested by the firmware */
+   copy_property(fdt, fw_fdt, "/", "memreserve");
+
+   /* Adjust dma-ranges for the SD card and PCI bus as they can depend on
+* the SoC revision
+*/
+   copy_property(fdt, fw_fdt, "emmc2bus", "dma-ranges");
+   copy_property(fdt, fw_fdt, "pcie0", "dma-ranges");
+
+   /* Bootloader configuration template exposes as nvmem */
+   if (copy_property(fdt, fw_fdt, "blconfig", "reg") == 0)
+   copy_property(fdt, fw_fdt, "blconfig", "status");
+
+   /* kernel address randomisation seed as provided by the firmware */
+   copy_property(fdt, fw_fdt, "/chosen", "kaslr-seed");
+}
+
 int ft_board_setup(void *blob, struct bd_info *bd)
 {
int node;
 
+   update_fdt_from_fw(blob, (void *)fw_dtb_pointer);
+
node = fdt_node_offset_by_compatible(blob, -1, "simple-framebuffer");
if (node < 0)
lcd_dt_simplefb_add_node(blob);
-- 
2.34.0



[PATCH] rpi: Copy properties from firmware dtb to the loaded dtb

2021-08-22 Thread Sjoerd Simons
The RPI firmware adjusts several property values in the dtb it passes
to u-boot depending on the board/SoC revision. Inherit some of these
when u-boot loads a dtb itself. Specificaly copy:

* /model: The firmware provides a more specific string
* /memreserve: The firmware defines a reserved range, better keep it
* emmc2bus and pcie0 dma-ranges: The C0T revision of the bcm2711 Soc (as
  present on rpi 400 and some rpi 4B boards) has different values for
  these then the B0T revision. So these need to be adjusted to boot on
  these boards
* blconfig: The firmware defines the memory area where the blconfig
  stored. Copy those over so it can be enabled.
* /chosen/kaslr-seed: The firmware generates a kaslr seed, take advantage
  of that.

Signed-off-by: Sjoerd Simons 
---

 board/raspberrypi/rpi/rpi.c | 47 +
 1 file changed, 47 insertions(+)

diff --git a/board/raspberrypi/rpi/rpi.c b/board/raspberrypi/rpi/rpi.c
index df52a4689f..d9467f4bda 100644
--- a/board/raspberrypi/rpi/rpi.c
+++ b/board/raspberrypi/rpi/rpi.c
@@ -495,8 +495,55 @@ void *board_fdt_blob_setup(void)
return (void *)fw_dtb_pointer;
 }
 
+int copy_property(void *dst, void *src, char *path, char *property)
+{
+   int dst_offset, src_offset;
+   const fdt32_t *prop;
+   int len;
+
+   src_offset = fdt_path_offset(src, path);
+   dst_offset = fdt_path_offset(dst, path);
+
+   if (src_offset < 0 || dst_offset < 0)
+   return -1;
+
+   prop = fdt_getprop(src, src_offset, property, );
+   if (!prop)
+   return -1;
+
+   return fdt_setprop(dst, dst_offset, property, prop, len);
+}
+
+/* Copy tweaks from the firmware dtb to the loaded dtb */
+void  update_fdt_from_fw(void *fdt, void *fw_fdt)
+{
+   /* Using dtb from firmware directly; leave it alone */
+   if (fdt == fw_fdt)
+   return;
+
+   /* The firmware provides a more precie model; so copy that */
+   copy_property(fdt, fw_fdt, "/", "model");
+
+   /* memory reserve as suggested by the firmware */
+   copy_property(fdt, fw_fdt, "/", "memreserve");
+
+   /* Adjust dma-ranges for the SD card and PCI bus as they can depend on
+* the SoC revision
+*/
+   copy_property(fdt, fw_fdt, "emmc2bus", "dma-ranges");
+   copy_property(fdt, fw_fdt, "pcie0", "dma-ranges");
+
+   /* Bootloader configuration template exposes as nvmem */
+   if (copy_property(fdt, fw_fdt, "blconfig", "reg") == 0)
+   copy_property(fdt, fw_fdt, "blconfig", "status");
+
+   /* kernel address randomisation seed as provided by the firmware */
+   copy_property(fdt, fw_fdt, "/chosen", "kaslr-seed");
+}
+
 int ft_board_setup(void *blob, struct bd_info *bd)
 {
+   update_fdt_from_fw(blob, (void *)fw_dtb_pointer);
/*
 * For now, we simply always add the simplefb DT node. Later, we
 * should be more intelligent, and e.g. only do this if no enabled DT
-- 
2.33.0



Re: [U-Boot] [PATCH 2/2] mx6: mx6sabre common: Add distro boot config

2019-07-18 Thread Sjoerd Simons
On Fri, 2019-07-12 at 10:51 -0300, Fabio Estevam wrote:
> Hi Sjoerd,
> 
> Subject says 2/2, but I don't see a 1/2.

1/2 is https://patchwork.ozlabs.org/patch/1119776/ guess patman didn't
cc you.

> On Thu, Jun 20, 2019 at 5:35 PM Sjoerd Simons
>  wrote:
> > Allow mx6 sabreauto and sabresd to boot via the default distro boot
> > commands to make it easier to support general distributions. The
> > previous boot setup is still supported via legacy boot targets.
> > 
> > Signed-off-by: Sjoerd Simons 
> > ---
> > 
> >  configs/mx6sabreauto_defconfig|  2 ++
> 
> It seems you missed to touch mx6sabresd_defconfig.

Indeed; Thanks! Will get that fixed

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


[U-Boot] [PATCH 2/2] mx6: mx6sabre common: Add distro boot config

2019-06-20 Thread Sjoerd Simons
Allow mx6 sabreauto and sabresd to boot via the default distro boot
commands to make it easier to support general distributions. The
previous boot setup is still supported via legacy boot targets.

Signed-off-by: Sjoerd Simons 
---

 configs/mx6sabreauto_defconfig|  2 ++
 include/configs/mx6sabre_common.h | 52 +++
 2 files changed, 41 insertions(+), 13 deletions(-)

diff --git a/configs/mx6sabreauto_defconfig b/configs/mx6sabreauto_defconfig
index 558b1cd996..e3430fd131 100644
--- a/configs/mx6sabreauto_defconfig
+++ b/configs/mx6sabreauto_defconfig
@@ -1,6 +1,8 @@
 CONFIG_ARM=y
 CONFIG_ARCH_MX6=y
 CONFIG_SYS_TEXT_BASE=0x1780
+CONFIG_DISTRO_DEFAULTS=y
+CONFIG_BOOTCOMMAND="run findfdt; run distro_bootcmd"
 CONFIG_SPL_GPIO_SUPPORT=y
 CONFIG_SPL_LIBCOMMON_SUPPORT=y
 CONFIG_SPL_LIBGENERIC_SUPPORT=y
diff --git a/include/configs/mx6sabre_common.h 
b/include/configs/mx6sabre_common.h
index 270cd2bae2..bc700b 100644
--- a/include/configs/mx6sabre_common.h
+++ b/include/configs/mx6sabre_common.h
@@ -48,7 +48,45 @@
 #define EMMC_ENV ""
 #endif
 
+#define BOOTENV_DEV_LEGACY_MMC(devtypeu, devtypel, instance) \
+   "bootcmd_" #devtypel #instance "=" \
+   "setenv mmcdev " #instance "; "\
+   "mmc dev ${mmcdev};" \
+   "if mmc rescan; then " \
+   "if run loadbootscript; then " \
+   "run bootscript; " \
+   "else " \
+   "if run loadimage; then " \
+   "run mmcboot; " \
+   "fi; " \
+   "fi; " \
+   "fi;\0"
+
+#define BOOTENV_DEV_NAME_LEGACY_MMC(devtypeu, devtypel, instance) \
+   #devtypel #instance " "
+
+#define BOOTENV_DEV_LEGACY_NET(devtypeu, devtypel, instance) \
+   "bootcmd_" #devtypel "=" \
+   "run netboot\0"
+
+#define BOOTENV_DEV_NAME_LEGACY_NET(devtypeu, devtypel, instance) \
+   #devtypel " "
+
+#define BOOT_TARGET_DEVICES(func) \
+   func(MMC, mmc, CONFIG_SYS_MMC_ENV_DEV) \
+   func(LEGACY_MMC, legacy_mmc, CONFIG_SYS_MMC_ENV_DEV) \
+   func(PXE, pxe, na) \
+   func(DHCP, dhcp, na) \
+   func(LEGACY_NET, legacy_net, na)
+
+#include 
+
 #define CONFIG_EXTRA_ENV_SETTINGS \
+   "kernel_addr_r=" __stringify(CONFIG_LOADADDR) "\0"  \
+   "pxefile_addr_r=" __stringify(CONFIG_LOADADDR) "\0" \
+   "scriptaddr=" __stringify(CONFIG_LOADADDR) "\0" \
+   "ramdisk_addr_r=0x1400\0" \
+   "fdt_addr_r=0x1800\0" \
"script=boot.scr\0" \
"image=zImage\0" \
"fdtfile=undefined\0" \
@@ -144,20 +182,8 @@
"if test $fdtfile = undefined; then " \
"echo WARNING: Could not determine dtb 
to use; fi; " \
"fi;\0" \
+   BOOTENV
 
-#define CONFIG_BOOTCOMMAND \
-   "run findfdt;" \
-   "mmc dev ${mmcdev};" \
-   "if mmc rescan; then " \
-   "if run loadbootscript; then " \
-   "run bootscript; " \
-   "else " \
-   "if run loadimage; then " \
-   "run mmcboot; " \
-   "else run netboot; " \
-   "fi; " \
-   "fi; " \
-   "else run netboot; fi"
 
 #define CONFIG_ARP_TIMEOUT 200UL
 
-- 
2.20.1

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


[U-Boot] [PATCH 1/2] mx6: mx6sabre common: Use more conventional spelling of fdtfile

2019-06-20 Thread Sjoerd Simons
Both the distro boot configuration as well as the general pxe support
standardized on fdtfile as the variable to hold the dtb filename.
Adjust to follow that such that e.g. "pxe boot" will just work.

Signed-off-by: Sjoerd Simons 
---

 include/configs/mx6sabre_common.h | 22 +++---
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/include/configs/mx6sabre_common.h 
b/include/configs/mx6sabre_common.h
index c137612b01..270cd2bae2 100644
--- a/include/configs/mx6sabre_common.h
+++ b/include/configs/mx6sabre_common.h
@@ -51,7 +51,7 @@
 #define CONFIG_EXTRA_ENV_SETTINGS \
"script=boot.scr\0" \
"image=zImage\0" \
-   "fdt_file=undefined\0" \
+   "fdtfile=undefined\0" \
"fdt_addr=0x1800\0" \
"boot_fdt=try\0" \
"ip_dyn=yes\0" \
@@ -86,7 +86,7 @@
"bootscript=echo Running bootscript from mmc ...; " \
"source\0" \
"loadimage=fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${image}\0" \
-   "loadfdt=fatload mmc ${mmcdev}:${mmcpart} ${fdt_addr} ${fdt_file}\0" \
+   "loadfdt=fatload mmc ${mmcdev}:${mmcpart} ${fdt_addr} ${fdtfile}\0" \
"mmcboot=echo Booting from mmc ...; " \
"run finduuid; " \
"run mmcargs; " \
@@ -115,7 +115,7 @@
"fi; " \
"${get_cmd} ${image}; " \
"if test ${boot_fdt} = yes || test ${boot_fdt} = try; then " \
-   "if ${get_cmd} ${fdt_addr} ${fdt_file}; then " \
+   "if ${get_cmd} ${fdt_addr} ${fdtfile}; then " \
"bootz ${loadaddr} - ${fdt_addr}; " \
"else " \
"if test ${boot_fdt} = try; then " \
@@ -128,20 +128,20 @@
"bootz; " \
"fi;\0" \
"findfdt="\
-   "if test $fdt_file = undefined; then " \
+   "if test $fdtfile = undefined; then " \
"if test $board_name = SABREAUTO && test 
$board_rev = MX6QP; then " \
-   "setenv fdt_file imx6qp-sabreauto.dtb; 
fi; " \
+   "setenv fdtfile imx6qp-sabreauto.dtb; 
fi; " \
"if test $board_name = SABREAUTO && test 
$board_rev = MX6Q; then " \
-   "setenv fdt_file imx6q-sabreauto.dtb; 
fi; " \
+   "setenv fdtfile imx6q-sabreauto.dtb; 
fi; " \
"if test $board_name = SABREAUTO && test 
$board_rev = MX6DL; then " \
-   "setenv fdt_file imx6dl-sabreauto.dtb; 
fi; " \
+   "setenv fdtfile imx6dl-sabreauto.dtb; 
fi; " \
"if test $board_name = SABRESD && test 
$board_rev = MX6QP; then " \
-   "setenv fdt_file imx6qp-sabresd.dtb; 
fi; " \
+   "setenv fdtfile imx6qp-sabresd.dtb; fi; 
" \
"if test $board_name = SABRESD && test 
$board_rev = MX6Q; then " \
-   "setenv fdt_file imx6q-sabresd.dtb; fi; 
" \
+   "setenv fdtfile imx6q-sabresd.dtb; fi; 
" \
"if test $board_name = SABRESD && test 
$board_rev = MX6DL; then " \
-   "setenv fdt_file imx6dl-sabresd.dtb; 
fi; " \
-   "if test $fdt_file = undefined; then " \
+   "setenv fdtfile imx6dl-sabresd.dtb; fi; 
" \
+   "if test $fdtfile = undefined; then " \
"echo WARNING: Could not determine dtb 
to use; fi; " \
"fi;\0" \
 
-- 
2.20.1

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


Re: [U-Boot] [PATCH v2 3/3] usb: gadget: f_sdp: Allow SPL to load and boot FIT via SDP

2019-06-19 Thread Sjoerd Simons
Hey,

On Tue, 2019-06-18 at 23:00 -0300, Breno Matheus Lima wrote:
> > Seems a bit ugly that the start offset of the external data can't
> > be
> > introspected from the fdt blob, but oh well.
> > 
> > The way this seems to work for i.mx8 is that the SECOND_LOADER
> > command
> > sticks in a IVT header into the fit image. I assume some other
> > tooling
> > can then stick the CSF data in the appropriate place (anyone have a
> > pointer?).
> > 
> 
> Thanks for looking at this issue.
> 
> We are using similar structure in NXP U-Boot for i.MX8M devices, you
> can use dd tool as explained in document below:
> https://source.codeaurora.org/external/imx/uboot-imx/tree/doc/imx/habv4/guides/mx8m_mx8mm_secure_boot.txt?h=imx_v2018.03_4.14.98_2.0.0_ga#n301

THat's a quite useful document indeed to explain the mx8m setup a bit
more; Would be lovely to get that in upstream u-boot!

Though from what i can tell mx8m secure boot isn't there yet upstream,
at least judging by the fact there is no correct definition of the RVT
base address for those upstream yet ;) 

> > Now i guess the first question becomes whether the i.mx6 should
> > follow
> > the same layout. And if so how to integrate it properly (teach
> > mkimage
> > about handling firmware_ivt for fit images?).
> > 
> 
> IMHO we should follow the same layout as in i.MX8M, as far as I know
> in NXP BSP this is handled by imx-mkimage tool:
> https://source.codeaurora.org/external/imx/imx-mkimage/?h=imx_4.14.98_2.0.0_ga
> 
> Perhaps we can try similar with mkimage tool included in upstream U-
> Boot?

Right i'd hope the i.mx8m specific bits in u-boot already do that as
well; but for i.MX6 those are overkill since there isn't one big
flash.bin but two seperate bits of data (Though from the documentation
it feels like that might be the case for i.mx8 as well? As there
doesn't seem to be a reason apart from flashing convenience to put the
SPL and the u-boot images in one big file)


> > Relatedly i was looking for a good description of using HAB for
> > loading
> > the OS in FIT images, but failed to find a good document. pointers
> > welcome.
> > 
> 
> For HAB API usage you can take a look in HABv4 RVT Guidelines and
> Recommendations application note:
> https://www.nxp.com/docs/en/application-note/AN12263.pdf
> 
> The U-Boot docs in NXP BSP U-Boot also provides an overview:
> https://source.codeaurora.org/external/imx/uboot-imx/tree/doc/imx/habv4?h=imx_v2018.03_4.14.98_2.0.0_ga

Right all those assume you're using a (z)Image with the IVT/CSF
appended; None of those describe a conventional layout for a FIT image.


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


[U-Boot] [PATCH] imx :hab: Add hab version command

2019-06-18 Thread Sjoerd Simons
THe RVT data includes a major and minor version in its header
parameter. Add a new command to print this out.

Signed-off-by: Sjoerd Simons 

---
Unfortunately there doesn't seem to be a way to get the minor version of
the hab ROM. While there is a get_version function pointer in the vector
table it's documented to only be valid during the ROM phase and a quick
hack to try and call it on my board always returned 1 :/.

 arch/arm/include/asm/mach-imx/hab.h |  1 +
 arch/arm/mach-imx/hab.c | 21 +
 2 files changed, 22 insertions(+)

diff --git a/arch/arm/include/asm/mach-imx/hab.h 
b/arch/arm/include/asm/mach-imx/hab.h
index 95df88423c..5c82a148b4 100644
--- a/arch/arm/include/asm/mach-imx/hab.h
+++ b/arch/arm/include/asm/mach-imx/hab.h
@@ -189,6 +189,7 @@ typedef void hapi_clock_init_t(void);
 #define HAB_CID_ROM 0 /**< ROM Caller ID */
 #define HAB_CID_UBOOT 1 /**< UBOOT Caller ID*/
 
+#define HAB_TAG_RVT  0xDD  /* ROM Vector Table */
 #define HAB_CMD_HDR  0xD4  /* CSF Header */
 #define HAB_CMD_WRT_DAT  0xCC  /* Write Data command tag */
 #define HAB_CMD_CHK_DAT  0xCF  /* Check Data command tag */
diff --git a/arch/arm/mach-imx/hab.c b/arch/arm/mach-imx/hab.c
index d42a15e877..e8487932c0 100644
--- a/arch/arm/mach-imx/hab.c
+++ b/arch/arm/mach-imx/hab.c
@@ -365,6 +365,21 @@ static int do_hab_failsafe(cmd_tbl_t *cmdtp, int flag, int 
argc,
return 0;
 }
 
+static int do_hab_version(cmd_tbl_t *cmdtp, int flag, int argc,
+ char * const argv[])
+{
+   struct hab_hdr *hdr = (struct hab_hdr *)HAB_RVT_BASE;
+
+   if (hdr->tag != HAB_TAG_RVT) {
+   printf("Unexpected header tag: %x\n", hdr->tag);
+   return CMD_RET_FAILURE;
+   }
+
+   printf("HAB version: %d.%d\n", hdr->par >> 4, hdr->par & 0xf);
+
+   return 0;
+}
+
 static int do_authenticate_image_or_failover(cmd_tbl_t *cmdtp, int flag,
 int argc, char * const argv[])
 {
@@ -421,6 +436,12 @@ U_BOOT_CMD(
"ivt_offset - hex offset of IVT in the image"
  );
 
+U_BOOT_CMD(
+   hab_version, 1, 0, do_hab_version,
+   "print HAB major/minor version",
+   ""
+ );
+
 #endif /* !defined(CONFIG_SPL_BUILD) */
 
 /* Get CSF Header length */
-- 
2.20.1

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


Re: [U-Boot] [PATCH] spl, Makefile: Take external offset into account for fit images

2019-06-18 Thread Sjoerd Simons
On Tue, 2019-06-18 at 22:20 +0200, Marek Vasut wrote:
> On 6/18/19 10:13 PM, Sjoerd Simons wrote:
> > When building a FIT image for SPL to load also take into account
> > the
> > configured external offset. This allows the SPL to load the u-boot
> > FIT
> > image correctly when configuring SECURE_BOOT on i.mx6 is enabled
> > (with CONFIG_FIT_EXTERNAL_OFFSET=0x3000).
> > 
> > Note this doesn't allow secure booting; but it does allow an
> > unsigned
> > SPL/u-boot with secure boot support eanbled to boot on open device.
> 
> Does this change behavior on systems which don't use
> CONFIG_FIT_EXTERNAL_OFFSET ?

Nope; in that case the default CONFIG_FIT_EXTERNAL_OFFSET is 0x0, which
gets essentially ignored if passed as a argument to -p 

> 
> > Signed-off-by: Sjoerd Simons 
> > 
> > ---
> > 
> >  Makefile | 1 +
> >  1 file changed, 1 insertion(+)
> > 
> > diff --git a/Makefile b/Makefile
> > index c55ffa265f..a8808aeefd 100644
> > --- a/Makefile
> > +++ b/Makefile
> > @@ -1240,6 +1240,7 @@ endif
> >  ifdef CONFIG_SPL_LOAD_FIT
> >  MKIMAGEFLAGS_u-boot.img = -f auto -A $(ARCH) -T firmware -C none
> > -O u-boot \
> > -a $(CONFIG_SYS_TEXT_BASE) -e $(CONFIG_SYS_UBOOT_START) \
> > +   -p $(CONFIG_FIT_EXTERNAL_OFFSET) \
> > -n "U-Boot $(UBOOTRELEASE) for $(BOARD) board" -E \
> > $(patsubst %,-b arch/$(ARCH)/dts/%.dtb,$(subst
> > ",,$(CONFIG_OF_LIST)))
> >  else
> > 
> 
> 

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


[U-Boot] [PATCH] spl, Makefile: Take external offset into account for fit images

2019-06-18 Thread Sjoerd Simons
When building a FIT image for SPL to load also take into account the
configured external offset. This allows the SPL to load the u-boot FIT
image correctly when configuring SECURE_BOOT on i.mx6 is enabled
(with CONFIG_FIT_EXTERNAL_OFFSET=0x3000).

Note this doesn't allow secure booting; but it does allow an unsigned
SPL/u-boot with secure boot support eanbled to boot on open device.

Signed-off-by: Sjoerd Simons 

---

 Makefile | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Makefile b/Makefile
index c55ffa265f..a8808aeefd 100644
--- a/Makefile
+++ b/Makefile
@@ -1240,6 +1240,7 @@ endif
 ifdef CONFIG_SPL_LOAD_FIT
 MKIMAGEFLAGS_u-boot.img = -f auto -A $(ARCH) -T firmware -C none -O u-boot \
-a $(CONFIG_SYS_TEXT_BASE) -e $(CONFIG_SYS_UBOOT_START) \
+   -p $(CONFIG_FIT_EXTERNAL_OFFSET) \
-n "U-Boot $(UBOOTRELEASE) for $(BOARD) board" -E \
$(patsubst %,-b arch/$(ARCH)/dts/%.dtb,$(subst ",,$(CONFIG_OF_LIST)))
 else
-- 
2.20.1

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


Re: [U-Boot] [PATCH] am335x, guardian: update the maintainer list

2019-06-18 Thread Sjoerd Simons
On Tue, 2019-06-18 at 13:54 +,
bollavarapumoses.christop...@in.bosch.com wrote:
> From: Moses Christopher 
> 
> Signed-off-by: Moses Christopher <
> bollavarapumoses.christop...@in.bosch.com>

Acked-by: Sjoerd Simons 

> ---
>  board/bosch/guardian/MAINTAINERS | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/board/bosch/guardian/MAINTAINERS
> b/board/bosch/guardian/MAINTAINERS
> index 8d16ec0..2f674d7 100644
> --- a/board/bosch/guardian/MAINTAINERS
> +++ b/board/bosch/guardian/MAINTAINERS
> @@ -1,5 +1,7 @@
>  Guardian BOARD
>  M:   Sjoerd Simons 
> +M:   Govindaraji Sivanantham 
> +M:   Moses Christopher Bollavarapu <
> bollavarapumoses.christop...@in.bosch.com>
>  S:   Maintained
>  F:   board/bosch/guardian/
>  F:   include/configs/am335x_guardian.h
-- 
Sjoerd Simons
Collabora Ltd.
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v2 3/3] usb: gadget: f_sdp: Allow SPL to load and boot FIT via SDP

2019-06-17 Thread Sjoerd Simons
On Tue, 2019-06-04 at 18:56 -0300, Fabio Estevam wrote:
> On Tue, Jun 4, 2019 at 5:41 PM Sjoerd Simons
>  wrote:

> We have been using imx_usb_loader for a long time. After DM / fit
> comvesion the IVT piece is not added into the final .img.
> 
> From the main Makefile:
> 
> ifdef CONFIG_SPL_LOAD_FIT
> MKIMAGEFLAGS_u-boot.img = -f auto -A $(ARCH) -T firmware -C none -O
> u-boot \
> -a $(CONFIG_SYS_TEXT_BASE) -e $(CONFIG_SYS_UBOOT_START) \
> -n "U-Boot $(UBOOTRELEASE) for $(BOARD) board" -E \
> $(patsubst %,-b arch/$(ARCH)/dts/%.dtb,$(subst ",,$(CONFIG_OF_LIST)))
> else
> MKIMAGEFLAGS_u-boot.img = -A $(ARCH) -T firmware -C none -O u-boot \
> -a $(CONFIG_SYS_TEXT_BASE) -e $(CONFIG_SYS_UBOOT_START) \
> -n "U-Boot $(UBOOTRELEASE) for $(BOARD) board"
> MKIMAGEFLAGS_u-boot-ivt.img = -A $(ARCH) -T firmware_ivt -C none -O
> u-boot \
> -a $(CONFIG_SYS_TEXT_BASE) -e $(CONFIG_SYS_UBOOT_START) \
> -n "U-Boot $(UBOOTRELEASE) for $(BOARD) board"
> u-boot-ivt.img: MKIMAGEOUTPUT = u-boot-ivt.img.log
> CLEAN_FILES += u-boot-ivt.img.log u-boot-dtb.imx.log SPL.log u-
> boot.imx.log
> endif
> 
> we  can see that the ivt is not added for the CONFIG_SPL_LOAD_FIT
> case.
> 
> I tried to change this logic, but so far was not able to make it
> work.

So when looking through how secure boot can work from the SPL i can
accross e246bfcfe. Which explains the u-boot SPL expect a signed fit
image with roughly the following layout:

--
| | | |   |   | ||
| FIT | FIT | FIT |   | U-BOOT| ATF | U-BOOT |
| FDT | IVT | CSF |   | nodtb.bin | |   DTB  |
| | | |   |   | ||
--

The code aligns the IVT at 0x1000 and the standard CSF size is
0x2000. So one has to set CONFIG_FIT_EXTERNAL_OFFSET=0x3000 (assuming the FIT 
FDT <= 0x1000 bytes) to make CONFIG_SECURE_BOOT work in this setup (even if HAB 
is off and the image isn't signed). Otherwise the SPL won't pick up the correct 
location for all the external data.

Seems a bit ugly that the start offset of the external data can't be
introspected from the fdt blob, but oh well. 

The way this seems to work for i.mx8 is that the SECOND_LOADER command
sticks in a IVT header into the fit image. I assume some other tooling
can then stick the CSF data in the appropriate place (anyone have a
pointer?).

Now i guess the first question becomes whether the i.mx6 should follow
the same layout. And if so how to integrate it properly (teach mkimage
about handling firmware_ivt for fit images?). 

Relatedly i was looking for a good description of using HAB for loading
the OS in FIT images, but failed to find a good document. pointers
welcome.


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


Re: [U-Boot] [PATCH v2 3/3] usb: gadget: f_sdp: Allow SPL to load and boot FIT via SDP

2019-06-05 Thread Sjoerd Simons
On Wed, 2019-06-05 at 11:40 +0200, Lukasz Majewski wrote:
> Hi Fabio, Sjoerd
> 
> > On Tue, Jun 4, 2019 at 5:41 PM Sjoerd Simons
> >  wrote:
> > 
> > > Small steps right; Ooi what imx_usb_loader configuration/commands
> > > are you using to test this? (I find its config rather tricky to
> > > grasp).  
> > 
> > I simply run:
> > 
> > sudo ./imx_usb SPL
> > 
> > and then
> > 
> > sudo ./imx_usb u-boot-dtb.img
> > 
> > I suggest you to try U-Boot 2019.01 on a mx6sabreauto first.
> > 
> 
> Tested-by: Lukasz Majewski 
> 
> Test HW: i.MX6Q Display5 factory setup.
> 
> 
> 
> However, one thing puzzles me - the VID / PID used.When I run uuu
> (mfgtools: SHA1: 13d187304f4faa473d2141409419c5b6f052addb):
> 
> I see that "Build in config" has following VID/PID:
> SDPU:SPL 0x0525  0xb4a4  [0x..0x04ff] [1]
> SDPV:SPL10x0525  0xb4a4  [0x0500..0x9998]
> SDPU:SPL 0x0525  0xb4a4  [0x..0x]
> 
> But to make the SDPU command working I had to adjust it to be similar
> to sabreauto (CONFIG_USB_GADGET_VENDOR_NUM=0x0525
> CONFIG_USB_GADGET_PRODUCT_NUM=0xa4a5). Those match to "FB"
> (fastboot?).
> 
> Is this a bug or just the "Build in config" information is outdated?
> With VID/PID set as for [1] (and as we use SDPU command, not FB), the
> uuu doesn't connect to loaded SPL.

So u-boot for the spl does (arch/arm/mach-imx/spl.c):
```
int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name)
{
  put_unaligned(CONFIG_USB_GADGET_PRODUCT_NUM + 0xfff, >idProduct);
``

Iotw with CONFIG_USB_GADGET_PRODUCT_NUM=0xa4a5 in the config when in
the SPL the product will be 0xb4a4, which uuu recognizes.

Once in the main u-boot image in principle you shoudl be able to use
`FB:`, however it doesn't seem `FB: ucmd` is supported for mainline u-
boot so...

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


Re: [U-Boot] [PATCH v2 3/3] usb: gadget: f_sdp: Allow SPL to load and boot FIT via SDP

2019-06-05 Thread Sjoerd Simons
On Tue, 2019-06-04 at 18:56 -0300, Fabio Estevam wrote:
> On Tue, Jun 4, 2019 at 5:41 PM Sjoerd Simons
>  wrote:
> 
> > Small steps right; Ooi what imx_usb_loader configuration/commands
> > are
> > you using to test this? (I find its config rather tricky to grasp).
> 
> I simply run:
> 
> sudo ./imx_usb SPL
> 
> and then
> 
> sudo ./imx_usb u-boot-dtb.img
> 
> I suggest you to try U-Boot 2019.01 on a mx6sabreauto first.

> U-Boot 2019.01 is prior to the DM / fit conversion and loading SPL +
> u-boot.img with the method above works fine.

Right; I've used that method on a fair few boards but none of those use
FIT.

For loading the SPL mx6_usb_sdp_spl.conf of imx_usb_loader has:
`hid,uboot_header,1024,0x1000,1G,0x00907000,0x31000`

So my guess was that it was simply failing as a fit image doesn't have
a uboot header ;). I did have a quick look at seeing how to convince
imx_usb_loader to upload a FIT image, but failed to do so (hence my
question). uuu turned to be simpler to get to comply :)

> > One of the next things I will need to look at is actually secure
> > boot..
> > That said why does imx_usb_loader if the board isn't locked?
> 
> Not sure what you mean by locked.

Sorry closing the device would be the right jargon for i.mx. My point
really is, isn't it something to be fixed in imx_usb_loader if it can't
upload unsigned FIT images rather then in u-boot?

> We have been using imx_usb_loader for a long time. After DM / fit
> comvesion the IVT piece is not added into the final .img.
> 
> From the main Makefile:
> 
> ifdef CONFIG_SPL_LOAD_FIT
> MKIMAGEFLAGS_u-boot.img = -f auto -A $(ARCH) -T firmware -C none -O
> u-boot \
> -a $(CONFIG_SYS_TEXT_BASE) -e $(CONFIG_SYS_UBOOT_START) \
> -n "U-Boot $(UBOOTRELEASE) for $(BOARD) board" -E \
> $(patsubst %,-b arch/$(ARCH)/dts/%.dtb,$(subst ",,$(CONFIG_OF_LIST)))
> else
> MKIMAGEFLAGS_u-boot.img = -A $(ARCH) -T firmware -C none -O u-boot \
> -a $(CONFIG_SYS_TEXT_BASE) -e $(CONFIG_SYS_UBOOT_START) \
> -n "U-Boot $(UBOOTRELEASE) for $(BOARD) board"
> MKIMAGEFLAGS_u-boot-ivt.img = -A $(ARCH) -T firmware_ivt -C none -O
> u-boot \
> -a $(CONFIG_SYS_TEXT_BASE) -e $(CONFIG_SYS_UBOOT_START) \
> -n "U-Boot $(UBOOTRELEASE) for $(BOARD) board"
> u-boot-ivt.img: MKIMAGEOUTPUT = u-boot-ivt.img.log
> CLEAN_FILES += u-boot-ivt.img.log u-boot-dtb.imx.log SPL.log u-
> boot.imx.log
> endif
> 
> we  can see that the ivt is not added for the CONFIG_SPL_LOAD_FIT
> case.
> 
> I tried to change this logic, but so far was not able to make it
> work.

Right; Thanks for the pointer

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


Re: [U-Boot] [PATCH v2 3/3] usb: gadget: f_sdp: Allow SPL to load and boot FIT via SDP

2019-06-04 Thread Sjoerd Simons
On Tue, 2019-06-04 at 17:19 -0300, Fabio Estevam wrote:
> Hi Sjoerd,
> 
> On Tue, Jun 4, 2019 at 4:58 PM Sjoerd Simons
>  wrote:
> > From: Frieder Schrempf 
> > 
> > Add support for loading u-boot FIT images over the USB SDP protocol
> > in
> > the SPL
> > 
> > Signed-off-by: Frieder Schrempf 
> > [Various build fixes]
> > Signed-off-by: Sjoerd Simons 
> 
> Unfortunately, it still fails with imx_usb_loader due to the lack of
> IVT.
> 
> Secure boot also needs IVT, so we need to find a way to insert IVT in
> the FIT image.
> 
> Tested with UUU and it worked, so this is progress :-)

Small steps right; Ooi what imx_usb_loader configuration/commands are
you using to test this? (I find its config rather tricky to grasp).

One of the next things I will need to look at is actually secure boot..
That said why does imx_usb_loader if the board isn't locked?

> Tested-by: Fabio Estevam 
> 
> Thanks

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


Re: [U-Boot] [PATCH 2/5] mx6sabreauto: Select pinctrl driver

2019-06-04 Thread Sjoerd Simons
On Tue, 2019-06-04 at 11:15 -0300, Fabio Estevam wrote:
> Hi Sjoerd,
> 
> On Mon, Jun 3, 2019 at 4:01 PM Sjoerd Simons
>  wrote:
> > With the conversion to DM we should select the pinctrl driver.
> > 
> > Signed-off-by: Sjoerd Simons 
> 
> I did the same for mx6sabresd initially, but then later I realized
> that it would be better to fix this globally like this:
> https://lists.denx.de/pipermail/u-boot/2019-May/370740.html
> 
> Hopefully Stefano can apply this version and then we can fix all i.MX
> boards that were converted to DM automatically.

Agreed that is a better solution

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


Re: [U-Boot] [PATCH] imx: Select the pinctrl drivers when DM is used

2019-06-04 Thread Sjoerd Simons
On Fri, 2019-05-24 at 09:50 -0300, Fabio Estevam wrote:
> When using device model it is required to select the pinctrl
> drivers so that the pins can be properly configured via
> devicetree.
> 
> mx6sabreauto board is an example of a target that uses DM and does
> not select the pinctrl drivers.
> 
> Instead of doing the pinctrl driver selection in each individual
> defconfig file, select it at SoC level when DM is used. 
> 
> Signed-off-by: Fabio Estevam 


Reviewed-by: Sjoerd Simons 
> ---
>  arch/arm/Kconfig | 8 
>  1 file changed, 8 insertions(+)
> 
> diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
> index efb9aab390..4c361c9a1d 100644
> --- a/arch/arm/Kconfig
> +++ b/arch/arm/Kconfig
> @@ -787,6 +787,8 @@ config ARCH_MX31
>  config ARCH_MX7ULP
>   bool "NXP MX7ULP"
>   select CPU_V7A
> + select PINCTRL if DM
> + select PINCTRL_IMX7ULP if DM
>   select ROM_UNIFIED_SECTIONS
>   imply MXC_GPIO
>  
> @@ -795,6 +797,8 @@ config ARCH_MX7
>   select ARCH_MISC_INIT
>   select BOARD_EARLY_INIT_F
>   select CPU_V7A
> + select PINCTRL if DM
> + select PINCTRL_IMX7 if DM
>   select SYS_FSL_HAS_SEC if SECURE_BOOT
>   select SYS_FSL_SEC_COMPAT_4
>   select SYS_FSL_SEC_LE
> @@ -803,6 +807,8 @@ config ARCH_MX7
>  config ARCH_MX6
>   bool "Freescale MX6"
>   select CPU_V7A
> + select PINCTRL if DM
> + select PINCTRL_IMX6 if DM
>   select SYS_FSL_HAS_SEC if SECURE_BOOT
>   select SYS_FSL_SEC_COMPAT_4
>   select SYS_FSL_SEC_LE
> @@ -818,6 +824,8 @@ config ARCH_MX5
>   bool "Freescale MX5"
>   select BOARD_EARLY_INIT_F
>   select CPU_V7A
> + select PINCTRL if DM
> + select PINCTRL_IMX5 if DM
>   imply MXC_GPIO
>  
>  config ARCH_OWL

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


[U-Boot] [PATCH v2 3/3] usb: gadget: f_sdp: Allow SPL to load and boot FIT via SDP

2019-06-04 Thread Sjoerd Simons
From: Frieder Schrempf 

Add support for loading u-boot FIT images over the USB SDP protocol in
the SPL

Signed-off-by: Frieder Schrempf 
[Various build fixes]
Signed-off-by: Sjoerd Simons 

---

Changes in v2:
- Fix build with CMD_USB_SDP
- Add SoB from Frieder Schrempf

 common/spl/spl_sdp.c   | 12 ++---
 drivers/usb/gadget/f_sdp.c | 53 +-
 include/sdp.h  |  9 ++-
 3 files changed, 63 insertions(+), 11 deletions(-)

diff --git a/common/spl/spl_sdp.c b/common/spl/spl_sdp.c
index 807256e908..51b245b886 100644
--- a/common/spl/spl_sdp.c
+++ b/common/spl/spl_sdp.c
@@ -25,10 +25,14 @@ static int spl_sdp_load_image(struct spl_image_info 
*spl_image,
return -ENODEV;
}
 
-   /* This command typically does not return but jumps to an image */
-   sdp_handle(controller_index);
-   pr_err("SDP ended\n");
+   /*
+* This command either loads a legacy image, jumps and never returns,
+* or it loads a FIT image and returns it to be handled by the SPL
+* code.
+*/
+   ret = spl_sdp_handle(controller_index, spl_image);
+   debug("SDP ended\n");
 
-   return -EINVAL;
+   return ret;
 }
 SPL_LOAD_IMAGE_METHOD("USB SDP", 0, BOOT_DEVICE_BOARD, spl_sdp_load_image);
diff --git a/drivers/usb/gadget/f_sdp.c b/drivers/usb/gadget/f_sdp.c
index ae97ab2b49..fab7ce6f97 100644
--- a/drivers/usb/gadget/f_sdp.c
+++ b/drivers/usb/gadget/f_sdp.c
@@ -638,7 +638,20 @@ static u32 sdp_jump_imxheader(void *address)
return 0;
 }
 
-static void sdp_handle_in_ep(void)
+#ifdef CONFIG_SPL_BUILD
+#ifdef CONFIG_SPL_LOAD_FIT
+static ulong sdp_fit_read(struct spl_load_info *load, ulong sector,
+ ulong count, void *buf)
+{
+   debug("%s: sector %lx, count %lx, buf %lx\n",
+ __func__, sector, count, (ulong)buf);
+   memcpy(buf, (void *)(load->dev + sector), count);
+   return count;
+}
+#endif
+#endif
+
+static void sdp_handle_in_ep(struct spl_image_info *spl_image)
 {
u8 *data = sdp_func->in_req->buf;
u32 status;
@@ -690,10 +703,25 @@ static void sdp_handle_in_ep(void)
/* If imx header fails, try some U-Boot specific headers */
if (status) {
 #ifdef CONFIG_SPL_BUILD
+   image_header_t *header =
+   sdp_ptr(sdp_func->jmp_address);
+#ifdef CONFIG_SPL_LOAD_FIT
+   if (image_get_magic(header) == FDT_MAGIC) {
+   struct spl_load_info load;
+
+   debug("Found FIT\n");
+   load.dev = header;
+   load.bl_len = 1;
+   load.read = sdp_fit_read;
+   spl_load_simple_fit(spl_image, , 0,
+   header);
+
+   return;
+   }
+#endif
/* In SPL, allow jumps to U-Boot images */
struct spl_image_info spl_image = {};
-   spl_parse_image_header(_image,
-   (struct image_header *)sdp_func->jmp_address);
+   spl_parse_image_header(_image, header);
jump_to_image_no_args(_image);
 #else
/* In U-Boot, allow jumps to scripts */
@@ -715,19 +743,32 @@ static void sdp_handle_in_ep(void)
};
 }
 
-void sdp_handle(int controller_index)
+#ifndef CONFIG_SPL_BUILD
+int sdp_handle(int controller_index)
+#else
+int spl_sdp_handle(int controller_index, struct spl_image_info *spl_image)
+#endif
 {
printf("SDP: handle requests...\n");
while (1) {
if (ctrlc()) {
puts("\rCTRL+C - Operation aborted.\n");
-   return;
+   return -EINVAL;
}
 
+#ifdef CONFIG_SPL_BUILD
+   if (spl_image->flags & SPL_FIT_FOUND)
+   return 0;
+#endif
+
WATCHDOG_RESET();
usb_gadget_handle_interrupts(controller_index);
 
-   sdp_handle_in_ep();
+#ifdef CONFIG_SPL_BUILD
+   sdp_handle_in_ep(spl_image);
+#else
+   sdp_handle_in_ep(NULL);
+#endif
}
 }
 
diff --git a/include/sdp.h b/include/sdp.h
index f6252d027f..6ac64fb1f3 100644
--- a/include/sdp.h
+++ b/include/sdp.h
@@ -10,6 +10,13 @@
 #define __SDP_H_
 
 int sdp_init(int controller_index);
-void sdp_handle(int controller_index);
+
+#ifdef CONFIG_SPL_BUILD
+#include 
+
+int spl_sdp_handle(int controller_index, struct spl_image_info *spl_image);
+#else
+int sdp_handle(int controller_index);
+#endif
 
 #endif /* __SDP_H_ */
-- 
2.20.1

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


[U-Boot] [PATCH v2 1/3] mx6sabreauto: Remove CONFIG_SPL_DM to decrease the SPL size

2019-06-04 Thread Sjoerd Simons
The i.mx6 SPL binary cannot be bigger then 68K, while with the current
defconfig for sabreauto it's only about 56K as soon as USB support gets
added the size will overflows.

Signed-off-by: Sjoerd Simons 

---

Changes in v2: None

 configs/mx6sabreauto_defconfig | 1 -
 1 file changed, 1 deletion(-)

diff --git a/configs/mx6sabreauto_defconfig b/configs/mx6sabreauto_defconfig
index dc758d7aaf..f9c70c5189 100644
--- a/configs/mx6sabreauto_defconfig
+++ b/configs/mx6sabreauto_defconfig
@@ -55,7 +55,6 @@ CONFIG_MULTI_DTB_FIT=y
 CONFIG_SPL_MULTI_DTB_FIT=y
 CONFIG_ENV_IS_IN_MMC=y
 CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
-CONFIG_SPL_DM=y
 CONFIG_DFU_MMC=y
 CONFIG_DFU_SF=y
 CONFIG_DM_GPIO=y
-- 
2.20.1

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


[U-Boot] [PATCH v2 0/3] Enable usage of SDP for i.MX6 Sabre Auto Boards

2019-06-04 Thread Sjoerd Simons
Being able to upload u-boot over USB is rather useful, so ideally this
functionality should be enabled by the default config for these boards.
Currently however no USB support is built into the SPL nor is SDP
enabled for i.MX6 Sabre Auto boards.

This round only has the patches needed for SDP support, the somewhat unrelated
fixes have been been sent seperately (but without the u-boot image will
fail to boot). And ofcourse fixes the build problem reported by Fabio.

The first patch drops SPL DM support as there is no way to fit that
*and* USB support in at the momenT.

The seconds patch enabled USB & SPL SDP support for the board.

Patch three adds support for loading FIT images over SDP as that is what
is in use for the Sabre auto's main u-boot image.

Patchset tested by using uuu with the following configuration:
```
uuu_version 1.2
SDP: boot -f  SPL
SDPU: write -f u-boot-dtb.img -addr 0x1000
SDPU: jump -addr 0x1000
SDPU: done
```

Changes in v2:
- Fix build with CMD_USB_SDP
- Add SoB from Frieder Schrempf

Frieder Schrempf (1):
  usb: gadget: f_sdp: Allow SPL to load and boot FIT via SDP

Sjoerd Simons (2):
  mx6sabreauto: Remove CONFIG_SPL_DM to decrease the SPL size
  mx6sabreauto: Enable SPL SDP support

 common/spl/spl_sdp.c   | 12 +---
 configs/mx6sabreauto_defconfig |  4 ++-
 drivers/usb/gadget/f_sdp.c | 53 ++
 include/sdp.h  |  9 +-
 4 files changed, 66 insertions(+), 12 deletions(-)

-- 
2.20.1

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


[U-Boot] [PATCH v2 2/3] mx6sabreauto: Enable SPL SDP support

2019-06-04 Thread Sjoerd Simons
To allow loading u-boot over USB enable SDP support in the SPL.

Signed-off-by: Sjoerd Simons 
---

Changes in v2: None

 configs/mx6sabreauto_defconfig | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/configs/mx6sabreauto_defconfig b/configs/mx6sabreauto_defconfig
index f9c70c5189..558b1cd996 100644
--- a/configs/mx6sabreauto_defconfig
+++ b/configs/mx6sabreauto_defconfig
@@ -26,6 +26,9 @@ CONFIG_SPL_SEPARATE_BSS=y
 CONFIG_SPL_FIT_IMAGE_TINY=y
 CONFIG_SPL_FS_EXT4=y
 CONFIG_SPL_I2C_SUPPORT=y
+CONFIG_SPL_USB_HOST_SUPPORT=y
+CONFIG_SPL_USB_GADGET=y
+CONFIG_SPL_USB_SDP_SUPPORT=y
 CONFIG_SPL_WATCHDOG_SUPPORT=y
 CONFIG_HUSH_PARSER=y
 CONFIG_CMD_BOOTZ=y
-- 
2.20.1

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


[U-Boot] [PATCH] usb: gadget: error out if g_dnl registration fails

2019-06-04 Thread Sjoerd Simons
If g_dnl_register fails return an error rather then stubornly
continuing onwards.

Signed-off-by: Sjoerd Simons 
---

 cmd/usb_gadget_sdp.c | 11 ---
 common/spl/spl_sdp.c |  6 +-
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/cmd/usb_gadget_sdp.c b/cmd/usb_gadget_sdp.c
index 808ed974fa..2ead06be9f 100644
--- a/cmd/usb_gadget_sdp.c
+++ b/cmd/usb_gadget_sdp.c
@@ -13,7 +13,7 @@
 
 static int do_sdp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
-   int ret = CMD_RET_FAILURE;
+   int ret;
 
if (argc < 2)
return CMD_RET_USAGE;
@@ -23,7 +23,11 @@ static int do_sdp(cmd_tbl_t *cmdtp, int flag, int argc, char 
* const argv[])
usb_gadget_initialize(controller_index);
 
g_dnl_clear_detach();
-   g_dnl_register("usb_dnl_sdp");
+   ret = g_dnl_register("usb_dnl_sdp");
+   if (ret) {
+   pr_err("SDP dnl register failed: %d\n", ret);
+   goto exit_register;
+   }
 
ret = sdp_init(controller_index);
if (ret) {
@@ -37,9 +41,10 @@ static int do_sdp(cmd_tbl_t *cmdtp, int flag, int argc, char 
* const argv[])
 
 exit:
g_dnl_unregister();
+exit_register:
usb_gadget_release(controller_index);
 
-   return ret;
+   return CMD_RET_FAILURE;
 }
 
 U_BOOT_CMD(sdp, 2, 1, do_sdp,
diff --git a/common/spl/spl_sdp.c b/common/spl/spl_sdp.c
index 807256e908..7fc4404971 100644
--- a/common/spl/spl_sdp.c
+++ b/common/spl/spl_sdp.c
@@ -17,7 +17,11 @@ static int spl_sdp_load_image(struct spl_image_info 
*spl_image,
const int controller_index = 0;
 
g_dnl_clear_detach();
-   g_dnl_register("usb_dnl_sdp");
+   ret = g_dnl_register("usb_dnl_sdp");
+   if (ret) {
+   pr_err("SDP dnl register failed: %d\n", ret);
+   return ret;
+   }
 
ret = sdp_init(controller_index);
if (ret) {
-- 
2.20.1

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


[U-Boot] [PATCH 2/3] mx6sabreauto: set SYS_MALLOC_F for video

2019-06-04 Thread Sjoerd Simons
Sabre Auto boards currently hang with:
```
U-Boot 2019.07-rc3-00057-gc41940c406 (Jun 03 2019 - 14:42:41 +0200)

CPU:   Freescale i.MX6QP rev1.0 996 MHz (running at 792 MHz)
CPU:   Automotive temperature grade (-40C to 125C)Reset cause: WDOG
Model: Freescale i.MX6 Quad Plus SABRE Automotive Board
Board: MX6Q-Sabreauto revA
I2C:   ready
DRAM:  2 GiB
Video device 'ipu@240' cannot allocate frame buffer memory -ensure the 
device is set up before relocation
Error binding driver 'ipuv3_video': -28
Video device 'ipu@280' cannot allocate frame buffer memory -ensure the 
device is set up before relocation
Error binding driver 'ipuv3_video': -28
Some drivers failed to bind
Error binding driver 'generic_simple_bus': -28
Some drivers failed to bind
initcall sequence 8ffe00b8 failed at call 1780e93b (err=-28)
```

Set SYS_MALLOC_F_LEN to reserve_video to work.

This is similar to the change Peng Fan did for mx6sabresd (9002e735e717)

Signed-off-by: Sjoerd Simons 
Reviewed-by: Peng Fan 

---

 configs/mx6sabreauto_defconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configs/mx6sabreauto_defconfig b/configs/mx6sabreauto_defconfig
index ef965a30e6..dc758d7aaf 100644
--- a/configs/mx6sabreauto_defconfig
+++ b/configs/mx6sabreauto_defconfig
@@ -4,6 +4,7 @@ CONFIG_SYS_TEXT_BASE=0x1780
 CONFIG_SPL_GPIO_SUPPORT=y
 CONFIG_SPL_LIBCOMMON_SUPPORT=y
 CONFIG_SPL_LIBGENERIC_SUPPORT=y
+CONFIG_SYS_MALLOC_F_LEN=0x4000
 CONFIG_TARGET_MX6SABREAUTO=y
 CONFIG_SPL_MMC_SUPPORT=y
 CONFIG_SPL_SERIAL_SUPPORT=y
@@ -11,7 +12,6 @@ CONFIG_NR_DRAM_BANKS=1
 CONFIG_SPL=y
 CONFIG_SPL_LIBDISK_SUPPORT=y
 CONFIG_NXP_BOARD_REVISION=y
-# CONFIG_SYS_MALLOC_F is not set
 CONFIG_FIT=y
 CONFIG_SPL_FIT_PRINT=y
 CONFIG_SPL_LOAD_FIT=y
-- 
2.20.1

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


[U-Boot] [PATCH 3/3] arm: dts: imx6qdl-u-boot: Alias usb0 to usbotg

2019-06-04 Thread Sjoerd Simons
All i.mx6 boards seems to have moved to DM_USB, however gadget support
for mx6 is still pre-DM as CI_UDC isn't converted yet. To make this work
the usb otg controller used for gadgets needs to be usb number 0.
Add an alias for this directly in the main u-boot mx6qdl dtsi so it
doesn't need to be done for each board separately.

This fixes regressions wrt. usb gadget functionality in several boards
that have gadget functions enabled in their config, but no usb0 alias in
their device-tree.

Signed-off-by: Sjoerd Simons 
---

 arch/arm/dts/imx6qdl-u-boot.dtsi | 4 
 1 file changed, 4 insertions(+)

diff --git a/arch/arm/dts/imx6qdl-u-boot.dtsi b/arch/arm/dts/imx6qdl-u-boot.dtsi
index 0aa29e38b8..e161ebb9af 100644
--- a/arch/arm/dts/imx6qdl-u-boot.dtsi
+++ b/arch/arm/dts/imx6qdl-u-boot.dtsi
@@ -4,6 +4,10 @@
  */
 
 / {
+   aliases {
+   usb0 = 
+   };
+
soc {
u-boot,dm-spl;
 
-- 
2.20.1

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


[U-Boot] [PATCH 1/3] mx6sabreauto: Select pinctrl driver

2019-06-04 Thread Sjoerd Simons
With the conversion to DM we should select the pinctrl driver.

Signed-off-by: Sjoerd Simons 
Reviewed-by: Peng Fan 

---

 configs/mx6sabreauto_defconfig | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/configs/mx6sabreauto_defconfig b/configs/mx6sabreauto_defconfig
index d0f302e9d0..ef965a30e6 100644
--- a/configs/mx6sabreauto_defconfig
+++ b/configs/mx6sabreauto_defconfig
@@ -70,6 +70,8 @@ CONFIG_SF_DEFAULT_SPEED=2000
 CONFIG_SPI_FLASH_STMICRO=y
 CONFIG_PHYLIB=y
 CONFIG_MII=y
+CONFIG_PINCTRL=y
+CONFIG_PINCTRL_IMX6=y
 CONFIG_DM_REGULATOR=y
 CONFIG_SPI=y
 CONFIG_DM_SPI=y
-- 
2.20.1

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


[U-Boot] [PATCH 0/3] i.mx6 (sabre auto) fixes for 2019.07

2019-06-04 Thread Sjoerd Simons
To make things easier i've split the `Enable usage of SDP for i.MX6
Sabre Auto Boards` patchset i sent yesterday up so it'll be hopefully
easier to merge.

The first two are the same as yesterday (Thanks Peng for the review).
The last one is new and fixes regressions in usb gadget usage of
various mx6 board that were converted to DM_USB.


Sjoerd Simons (3):
  mx6sabreauto: Select pinctrl driver
  mx6sabreauto: set SYS_MALLOC_F for video
  arm: dts: imx6qdl-u-boot: Alias usb0 to usbotg

 arch/arm/dts/imx6qdl-u-boot.dtsi | 4 
 configs/mx6sabreauto_defconfig   | 4 +++-
 2 files changed, 7 insertions(+), 1 deletion(-)

-- 
2.20.1

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


Re: [U-Boot] [PATCH 4/5] usb: gadget: f_sdp: Allow SPL to load and boot FIT via SDP

2019-06-03 Thread Sjoerd Simons
On Mon, 2019-06-03 at 16:17 -0300, Fabio Estevam wrote:
> Hi Sjoerd,
> 
> On Mon, Jun 3, 2019 at 4:02 PM Sjoerd Simons
>  wrote:
> > From: Frieder Schrempf 
> > 
> > Add support for loading u-boot FIT images over the USB SPD protocol
> > in
> > the SPL
> > 
> > [Small fixes to build]
> 
> Applied this patch against U-Boot master and it still does not build
> for me when using mx6sabresd_defconfig:

Ah; that has CONFIG_CMD_USB_SDP which i didn't enable in the sabre auto
defconfig (and thus didn't notice the failure). Will fix that.

> cmd/usb_gadget_sdp.c: In function ‘do_sdp’:
> cmd/usb_gadget_sdp.c:35:2: error: too few arguments to function
> ‘sdp_handle’
>   sdp_handle(controller_index);
>   ^~
> In file included from cmd/usb_gadget_sdp.c:11:0:
> include/sdp.h:15:5: note: declared here
>  int sdp_handle(int controller_index, struct spl_image_info
> *spl_image);
>  ^~
> scripts/Makefile.build:278: recipe for target 'cmd/usb_gadget_sdp.o'
> failed
> make[1]: *** [cmd/usb_gadget_sdp.o] Error

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


[U-Boot] [PATCH 1/5] mx6sabreauto: Remove CONFIG_SPL_DM to decrease the SPL size

2019-06-03 Thread Sjoerd Simons
The i.mx6 SPL binary cannot be bigger then 68K, while with the current
defconfig for sabreauto it's only about 56K as soon as USB support gets
added the size will overflows.

Signed-off-by: Sjoerd Simons 

---

 configs/mx6sabreauto_defconfig | 1 -
 1 file changed, 1 deletion(-)

diff --git a/configs/mx6sabreauto_defconfig b/configs/mx6sabreauto_defconfig
index d0f302e9d0..bf163a2a6e 100644
--- a/configs/mx6sabreauto_defconfig
+++ b/configs/mx6sabreauto_defconfig
@@ -55,7 +55,6 @@ CONFIG_MULTI_DTB_FIT=y
 CONFIG_SPL_MULTI_DTB_FIT=y
 CONFIG_ENV_IS_IN_MMC=y
 CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
-CONFIG_SPL_DM=y
 CONFIG_DFU_MMC=y
 CONFIG_DFU_SF=y
 CONFIG_DM_GPIO=y
-- 
2.20.1

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


[U-Boot] [PATCH 3/5] mx6sabreauto: Enable SPL SDP support

2019-06-03 Thread Sjoerd Simons
To allow loading u-boot over USB enable SPD support in the SPL.

Signed-off-by: Sjoerd Simons 
---

 configs/mx6sabreauto_defconfig | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/configs/mx6sabreauto_defconfig b/configs/mx6sabreauto_defconfig
index 91ea1ca9e4..6903048d85 100644
--- a/configs/mx6sabreauto_defconfig
+++ b/configs/mx6sabreauto_defconfig
@@ -26,6 +26,9 @@ CONFIG_SPL_SEPARATE_BSS=y
 CONFIG_SPL_FIT_IMAGE_TINY=y
 CONFIG_SPL_FS_EXT4=y
 CONFIG_SPL_I2C_SUPPORT=y
+CONFIG_SPL_USB_HOST_SUPPORT=y
+CONFIG_SPL_USB_GADGET=y
+CONFIG_SPL_USB_SDP_SUPPORT=y
 CONFIG_SPL_WATCHDOG_SUPPORT=y
 CONFIG_HUSH_PARSER=y
 CONFIG_CMD_BOOTZ=y
-- 
2.20.1

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


[U-Boot] [PATCH 5/5] mx6sabreauto: set SYS_MALLOC_F for video

2019-06-03 Thread Sjoerd Simons
Sabre Auto boards currently hang with:
```
U-Boot 2019.07-rc3-00057-gc41940c406 (Jun 03 2019 - 14:42:41 +0200)

CPU:   Freescale i.MX6QP rev1.0 996 MHz (running at 792 MHz)
CPU:   Automotive temperature grade (-40C to 125C)Reset cause: WDOG
Model: Freescale i.MX6 Quad Plus SABRE Automotive Board
Board: MX6Q-Sabreauto revA
I2C:   ready
DRAM:  2 GiB
Video device 'ipu@240' cannot allocate frame buffer memory -ensure the 
device is set up before relocation
Error binding driver 'ipuv3_video': -28
Video device 'ipu@280' cannot allocate frame buffer memory -ensure the 
device is set up before relocation
Error binding driver 'ipuv3_video': -28
Some drivers failed to bind
Error binding driver 'generic_simple_bus': -28
Some drivers failed to bind
initcall sequence 8ffe00b8 failed at call 1780e93b (err=-28)
```

Set SYS_MALLOC_F_LEN to reserve_video to work.

This is similar to the change Peng Fan did for mx6sabresd (9002e735e717)

Signed-off-by: Sjoerd Simons 

---

 configs/mx6sabreauto_defconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configs/mx6sabreauto_defconfig b/configs/mx6sabreauto_defconfig
index 6903048d85..558b1cd996 100644
--- a/configs/mx6sabreauto_defconfig
+++ b/configs/mx6sabreauto_defconfig
@@ -4,6 +4,7 @@ CONFIG_SYS_TEXT_BASE=0x1780
 CONFIG_SPL_GPIO_SUPPORT=y
 CONFIG_SPL_LIBCOMMON_SUPPORT=y
 CONFIG_SPL_LIBGENERIC_SUPPORT=y
+CONFIG_SYS_MALLOC_F_LEN=0x4000
 CONFIG_TARGET_MX6SABREAUTO=y
 CONFIG_SPL_MMC_SUPPORT=y
 CONFIG_SPL_SERIAL_SUPPORT=y
@@ -11,7 +12,6 @@ CONFIG_NR_DRAM_BANKS=1
 CONFIG_SPL=y
 CONFIG_SPL_LIBDISK_SUPPORT=y
 CONFIG_NXP_BOARD_REVISION=y
-# CONFIG_SYS_MALLOC_F is not set
 CONFIG_FIT=y
 CONFIG_SPL_FIT_PRINT=y
 CONFIG_SPL_LOAD_FIT=y
-- 
2.20.1

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


[U-Boot] [PATCH 4/5] usb: gadget: f_sdp: Allow SPL to load and boot FIT via SDP

2019-06-03 Thread Sjoerd Simons
From: Frieder Schrempf 

Add support for loading u-boot FIT images over the USB SPD protocol in
the SPL

[Small fixes to build]
Signed-off-by: Sjoerd Simons 
---

 common/spl/spl_sdp.c   | 11 --
 drivers/usb/gadget/f_sdp.c | 41 --
 include/sdp.h  |  4 +++-
 3 files changed, 47 insertions(+), 9 deletions(-)

diff --git a/common/spl/spl_sdp.c b/common/spl/spl_sdp.c
index 807256e908..dc57171966 100644
--- a/common/spl/spl_sdp.c
+++ b/common/spl/spl_sdp.c
@@ -26,9 +26,16 @@ static int spl_sdp_load_image(struct spl_image_info 
*spl_image,
}
 
/* This command typically does not return but jumps to an image */
-   sdp_handle(controller_index);
+   sdp_handle(controller_index, spl_image);
pr_err("SDP ended\n");
+   /*
+* This command either loads a legacy image, jumps and never returns,
+* or it loads a FIT image and returns it to be handled by the SPL
+* code.
+*/
+   ret = sdp_handle(controller_index, spl_image);
+   debug("SDP ended\n");
 
-   return -EINVAL;
+   return ret;
 }
 SPL_LOAD_IMAGE_METHOD("USB SDP", 0, BOOT_DEVICE_BOARD, spl_sdp_load_image);
diff --git a/drivers/usb/gadget/f_sdp.c b/drivers/usb/gadget/f_sdp.c
index ae97ab2b49..2a23160d91 100644
--- a/drivers/usb/gadget/f_sdp.c
+++ b/drivers/usb/gadget/f_sdp.c
@@ -638,7 +638,18 @@ static u32 sdp_jump_imxheader(void *address)
return 0;
 }
 
-static void sdp_handle_in_ep(void)
+#ifdef CONFIG_SPL_LOAD_FIT
+static ulong sdp_fit_read(struct spl_load_info *load, ulong sector,
+ ulong count, void *buf)
+{
+   debug("%s: sector %lx, count %lx, buf %lx\n",
+ __func__, sector, count, (ulong)buf);
+   memcpy(buf, (void *)(load->dev + sector), count);
+   return count;
+}
+#endif
+
+static void sdp_handle_in_ep(struct spl_image_info *spl_image)
 {
u8 *data = sdp_func->in_req->buf;
u32 status;
@@ -689,11 +700,26 @@ static void sdp_handle_in_ep(void)
 
/* If imx header fails, try some U-Boot specific headers */
if (status) {
+   image_header_t *header =
+   sdp_ptr(sdp_func->jmp_address);
 #ifdef CONFIG_SPL_BUILD
+#ifdef CONFIG_SPL_LOAD_FIT
+   if (image_get_magic(header) == FDT_MAGIC) {
+   struct spl_load_info load;
+
+   debug("Found FIT\n");
+   load.dev = header;
+   load.bl_len = 1;
+   load.read = sdp_fit_read;
+   spl_load_simple_fit(spl_image, , 0,
+   header);
+
+   return;
+   }
+#endif
/* In SPL, allow jumps to U-Boot images */
struct spl_image_info spl_image = {};
-   spl_parse_image_header(_image,
-   (struct image_header *)sdp_func->jmp_address);
+   spl_parse_image_header(_image, header);
jump_to_image_no_args(_image);
 #else
/* In U-Boot, allow jumps to scripts */
@@ -715,19 +741,22 @@ static void sdp_handle_in_ep(void)
};
 }
 
-void sdp_handle(int controller_index)
+int sdp_handle(int controller_index, struct spl_image_info *spl_image)
 {
printf("SDP: handle requests...\n");
while (1) {
if (ctrlc()) {
puts("\rCTRL+C - Operation aborted.\n");
-   return;
+   return -EINVAL;
}
 
+   if (spl_image->flags & SPL_FIT_FOUND)
+   return 0;
+
WATCHDOG_RESET();
usb_gadget_handle_interrupts(controller_index);
 
-   sdp_handle_in_ep();
+   sdp_handle_in_ep(spl_image);
}
 }
 
diff --git a/include/sdp.h b/include/sdp.h
index f6252d027f..f30e2bca19 100644
--- a/include/sdp.h
+++ b/include/sdp.h
@@ -9,7 +9,9 @@
 #ifndef __SDP_H_
 #define __SDP_H_
 
+#include 
+
 int sdp_init(int controller_index);
-void sdp_handle(int controller_index);
+int sdp_handle(int controller_index, struct spl_image_info *spl_image);
 
 #endif /* __SDP_H_ */
-- 
2.20.1

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


[U-Boot] [PATCH 2/5] mx6sabreauto: Select pinctrl driver

2019-06-03 Thread Sjoerd Simons
With the conversion to DM we should select the pinctrl driver.

Signed-off-by: Sjoerd Simons 
---

 configs/mx6sabreauto_defconfig | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/configs/mx6sabreauto_defconfig b/configs/mx6sabreauto_defconfig
index bf163a2a6e..91ea1ca9e4 100644
--- a/configs/mx6sabreauto_defconfig
+++ b/configs/mx6sabreauto_defconfig
@@ -69,6 +69,8 @@ CONFIG_SF_DEFAULT_SPEED=2000
 CONFIG_SPI_FLASH_STMICRO=y
 CONFIG_PHYLIB=y
 CONFIG_MII=y
+CONFIG_PINCTRL=y
+CONFIG_PINCTRL_IMX6=y
 CONFIG_DM_REGULATOR=y
 CONFIG_SPI=y
 CONFIG_DM_SPI=y
-- 
2.20.1

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


[U-Boot] [PATCH 0/5] Enable usage of SDP for i.MX6 Sabre Auto Boards

2019-06-03 Thread Sjoerd Simons

Being able to upload u-boot over USB is rather useful, so ideally this
functionality should be enabled by the default config for these boards.
Currently however no USB support is built into the SPL nor is SDP
enabled for i.MX6 Sabre Auto boards.

The first two patches in this series adjust the defconfig in a similar
way as Fabio has done in a recent patchset for Sabre SD. The first one
drops SPL DM support as there is no way to fit that *and* USB support in
at the moment, the second one adds missing pinctrl configuration for the
main u-boot binary.

The third patch enabled USB & SPL SDP support.

Patch four adds support for loading FIT images over SDP as that is what
is in use for the Sabre auto's main u-boot image. This is simply the
patch Frieder Schrempf submitted to the mainlinglist earlier, but made
to build on current git master. (Frieder could you be so kind to add
your SoB?).

The final patch fixes the u-boot image failing to start due to DM_VIDEO.

Patchset tested by using uuu with the following configuration:
```
uuu_version 1.2
SDP: boot -f  SPL
SDPU: write -f u-boot-dtb.img -addr 0x1000
SDPU: jump -addr 0x1000
SPDU: done
```

I suspect these patches are to late for 2019.07, especially since FIT
support in SDP would be a new feature? If so I'm happy to split this set
out of patches that should definatly land for 2019.07 (Making sabre auto
work) and submit the others for 2019.10


Frieder Schrempf (1):
  usb: gadget: f_sdp: Allow SPL to load and boot FIT via SDP

Sjoerd Simons (4):
  mx6sabreauto: Remove CONFIG_SPL_DM to decrease the SPL size
  mx6sabreauto: Select pinctrl driver
  mx6sabreauto: Enable SPL SDP support
  mx6sabreauto: set SYS_MALLOC_F for video

 common/spl/spl_sdp.c   | 11 +++--
 configs/mx6sabreauto_defconfig |  8 +--
 drivers/usb/gadget/f_sdp.c | 41 +-
 include/sdp.h  |  4 +++-
 4 files changed, 53 insertions(+), 11 deletions(-)

-- 
2.20.1

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


[U-Boot] [PATCH v2] Kconfig: Enlarge default SYS_MALLOC_F_LEN for AM33XX

2018-04-12 Thread Sjoerd Simons
Since commit 8e14ba7bd524 ("gpio: omap_gpio: Add DM_FLAG_PRE_RELOC
flag") omap GPIO gets bound before relocation.  Unfortunately due to
this, on at least the beaglebone black, the pre-relocation memory pool
gets exhausted before probing the serial port. This then causes u-boot
to panic as CONFIG_REQUIRE_SERIAL_CONSOLE is set...

Resolve this by resizing the default size of the pre-relocation malloc
pool for AM335X platforms.

Signed-off-by: Sjoerd Simons <sjoerd.sim...@collabora.co.uk>

---

Changes in v2:
- Set the default in the toplevel kConfig file rather then the omap2plus one

 Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Kconfig b/Kconfig
index 6670913799..55dddc844d 100644
--- a/Kconfig
+++ b/Kconfig
@@ -131,6 +131,7 @@ config SYS_MALLOC_F
 config SYS_MALLOC_F_LEN
hex "Size of malloc() pool before relocation"
depends on SYS_MALLOC_F
+   default 0x1000 if AM33XX
default 0x400
help
  Before relocation, memory is very limited on many platforms. Still,
-- 
2.17.0

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


Re: [U-Boot] [PATCH] arm: mach-omap2: Enlarge SYS_MALLOC_F_LEN

2018-04-12 Thread Sjoerd Simons
On Wed, 2018-04-11 at 16:58 -0400, Tom Rini wrote:
> On Wed, Apr 11, 2018 at 09:26:40PM +0200, Sjoerd Simons wrote:
> 
> > Since commit 8e14ba7bd524 ("gpio: omap_gpio: Add DM_FLAG_PRE_RELOC
> > flag") omap GPIO gets bound before relocation.  Unfortunately due
> > to
> > this, on at least the beaglebone black, the pre-relocation memory
> > pool
> > gets exhausted before probing the serial port. This then causes u-
> > boot
> > to panic as CONFIG_REQUIRE_SERIAL_CONSOLE is set...
> 
> Ah, so, you're using am335x_boneblack_defconfig and not
> am335x_evm_defconfig which is why I didn't see this problem myself.
> 
> > Resolve this by doubling the default size of the pre-relocation
> > malloc
> > pool on mach-omap2.
> > 
> > Signed-off-by: Sjoerd Simons <sjoerd.sim...@collabora.co.uk>
> > 
> > ---
> > 
> >  arch/arm/mach-omap2/Kconfig | 3 +++
> >  1 file changed, 3 insertions(+)
> > 
> > diff --git a/arch/arm/mach-omap2/Kconfig b/arch/arm/mach-
> > omap2/Kconfig
> > index 3bb1ecb58d..02c5a4c0b8 100644
> > --- a/arch/arm/mach-omap2/Kconfig
> > +++ b/arch/arm/mach-omap2/Kconfig
> > @@ -186,4 +186,7 @@ source "board/compulab/cm_t43/Kconfig"
> >  config SPL_LDSCRIPT
> >  default "arch/arm/mach-omap2/u-boot-spl.lds"
> >  
> > +config SYS_MALLOC_F_LEN
> > +   default 0x0800
> 
> This isn't the first bad example, ugh, but we shouldn't go this
> route.
> Ideally we should modify the top-level Kconfig, as that declares
> SYS_MALLOC_F_LEN, to be default 0x800 if ARCH_OMAP2PLUS.

Fwiw I proposed it that way around as various machs (tegra, zync,
bmips, meson, integrator, etc) and the x86 arch seems to doing it like
that.

> That said, most of the am335x platforms set SYS_MALLOC_F_LEN to
> either
> 0x1000 or 0x2000.  At this point, I would recommend tweaking
> configs/am335x_evm* and configs/am335x_boneblack* to be consistent
> and
> use 0x1000 as I don't know if the HS variants can safely be pushed up
> to
> 0x2000 (adding in Andrew).  Thanks!

Happy to prepare a patch for that; but the one thing that worries me is
that there are probably more defconfigs broken due to this then just
those. So changing the default via kconfig is probably more robust.

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


[U-Boot] [PATCH] arm: mach-omap2: Enlarge SYS_MALLOC_F_LEN

2018-04-11 Thread Sjoerd Simons
Since commit 8e14ba7bd524 ("gpio: omap_gpio: Add DM_FLAG_PRE_RELOC
flag") omap GPIO gets bound before relocation.  Unfortunately due to
this, on at least the beaglebone black, the pre-relocation memory pool
gets exhausted before probing the serial port. This then causes u-boot
to panic as CONFIG_REQUIRE_SERIAL_CONSOLE is set...

Resolve this by doubling the default size of the pre-relocation malloc
pool on mach-omap2.

Signed-off-by: Sjoerd Simons <sjoerd.sim...@collabora.co.uk>

---

 arch/arm/mach-omap2/Kconfig | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/arm/mach-omap2/Kconfig b/arch/arm/mach-omap2/Kconfig
index 3bb1ecb58d..02c5a4c0b8 100644
--- a/arch/arm/mach-omap2/Kconfig
+++ b/arch/arm/mach-omap2/Kconfig
@@ -186,4 +186,7 @@ source "board/compulab/cm_t43/Kconfig"
 config SPL_LDSCRIPT
 default "arch/arm/mach-omap2/u-boot-spl.lds"
 
+config SYS_MALLOC_F_LEN
+   default 0x0800
+
 endif
-- 
2.17.0

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


  1   2   3   4   >