Re: [PATCH 1/2] arm: mvebu: Implement the mac command (Marvell hw_info)

2021-10-13 Thread Luka Kovacic
> > Is anyone already working on a nvmem framework to support nvmem
> > providers in U-Boot?
>
> AFAIK no, but I am planning to look into this.

Ok. I'd be happy to assist in any way you see fit with this in my free
time.

> In the meantime implement the hw_info mac command.

Okay.

> I will send proposal for dt-binding.

Sounds good.

Kind regards,
Luka


Re: [PATCH 1/2] arm: mvebu: Implement the mac command (Marvell hw_info)

2021-10-11 Thread Luka Kovacic
Hello Marek,

> These differences between Marvell's version and U-Boot's standard
> environment version can be specified in device-tree (via compatible or
> other properties) and handled by one driver.
>
> A driver for nvmem provider of standard U-Boot env could have this
> binding (with "denx,u-boot-env" as compatible, changing it to
> "marvell,hw-info" would make it work with spaces instead of '=' as
> separator):

An nvmem provider would be an interesting approach to read U-Boot
environment parameters from Linux and to maybe even get the U-Boot env
partition location in U-Boot (like DM for the env).

A single driver would work, maybe support for the checksum would get more
difficult to integrate.

>
>   spi-flash {
> blah blah blah;
>
> partitions {
>   compatible = "fixed-partitions";
>   #address-cells = <1>;
>   #size-cells = <1>;
>
>   hw-info@18000 {
> compatible = "denx,u-boot-env";
> reg = <0x18000 0x1000>;
> label = "hw-info";
>
> eth0_mac_addr: ethaddr {
>   compatible = "mac-address-string";
>   name = "ethaddr";
> };
>
> eth1_mac_addr: eth1addr {
>   compatible = "mac-address-string";
>   name = "eth1addr";
> };

I don't see any better approach than just matching strings to retrieve
values for specific keys (for MACs), so this looks good to me.

>   };
> };
>   };
>
>   ethernet@3 {
> nvmem-cells = <_mac_addr>;
> nvmem-cell-names = "mac-address";
>   };
>
>
> On Turris MOX, we have the MAC address of the device stored in
> One-Time-Programmable memory accesible only by the secure coprocessor,
> which Linux communicates with via the turris-mox-rwtm kernel driver.
>
> Currently this driver does not register itself as a nvmem provider, and
> so isn't use by the ethernet controller driver to get MAC addresses.
> MAC addresses are currently read by U-Boot board code and the
> controller keeps these to Linux.
>
> But I plan to extend the turris-mox-rwtm driver to also provide MAC
> addresses via nvmem API, and then specify in device-tree
>{
> nvmem-cells = <_eth1_mac>;
> nvmem-cell-names = "address";
>   };
>
> Maybe in the future you will also want to implement this in Linux.
> It could be done simply by adding a new type of nvmem provider, with
> compatible = "marvell,hw-info".
>
> Luka, what do you think?

> Also we need to add nvmem API into U-Boot and get rid of the ad-hoc
> efuse/mac/hw_mac nonsense.

I agree, a real nvmem API would be much cleaner than the current U-Boot
implementation, as there is currently no way to programmatically access
these parameters and the implementations have different user interfaces.

As there is currently no nvmem framework, I recommend that the basic,
futureproof DT bindings are defined and DT parsing is temporarily
implemented in the hw_info mac command. What do you think?

Is anyone already working on a nvmem framework to support nvmem
providers in U-Boot?

Kind regards,
Luka


Re: [PATCH 1/2] arm: mvebu: Implement the mac command (Marvell hw_info)

2021-10-11 Thread Luka Kovacic
Hello Pali,

> Something like this? compatible = "marvell,hw-info"

This compatible string looks good to me.
We will send a new patch version, which implements the discussed DT
functionality.

> > I am sure Luka knows more about the format than me.

The Marvell hw_info partition is very similar to the U-Boot environment.
The only difference is in the separator between the "key=value" pairs,
which is 0x20/space in the case of hw_info.
This is also prevents us to hard-code the parameter addresses in the
device tree, because they can move around.

The checksum is stored before the hw_info environment - this would
have to be investigated further to implement checksum verification.

Kind regards,
Luka


Re: [PATCH 1/2] arm: mvebu: Implement the mac command (Marvell hw_info)

2021-10-08 Thread Luka Kovacic
Hello Pali,

On Fri, Oct 8, 2021 at 2:53 PM Pali Rohár  wrote:
>
> Hello!
>
> On Friday 08 October 2021 14:09:23 Robert Marko wrote:
> > From: Luka Kovacic 
> >
> > The mac command is implemented to enable parsing Marvell hw_info formatted
> > environments. This format is often used on Marvell Armada devices to store
> > parameters like the board serial number, factory MAC addresses and some
> > other information.
> > These parameters are usually written to the flash in the factory.
> >
> > Currently the mac command supports reading/writing parameters and dumping
> > the current hw_info parameters.
> > EEPROM config pattern and checksum aren't supported.
>
> Is there any documentation how is checksum stored in this hw_info
> structure?
>

There probably isn't any public documentation.
This implementation was written using the public Marvell U-Boot source code
which is hosted on GitHub (MarvellEmbeddedProcessors/u-boot-marvell).

Anyway, this shouldn't be much of a problem for the initial version, as SPI
flash is quite reliable and data written here can also be read by the official
version and vice versa.

> > This functionality has been tested on the GST ESPRESSOBin-Ultra board
> > successfully, both reading the stock U-Boot parameters in mainline U-Boot
> > and reading the parameters written by this command in the stock U-Boot.
> >
> > Support for this command is added for Marvell Armada A37XX and 7K/8K
> > devices.
> >
> > Usage example:
> >  => mac read
> >  => saveenv
> >
> > Signed-off-by: Luka Kovacic 
> > Cc: Luka Perkov 
> > Cc: Robert Marko 
> > ---
> >  arch/arm/mach-mvebu/Kconfig |   1 +
> >  board/Marvell/common/Kconfig|  29 +++
> >  board/Marvell/common/Makefile   |   5 +
> >  board/Marvell/common/mac.c  | 391 
> >  include/configs/mvebu_armada-37xx.h |   7 +
> >  include/configs/mvebu_armada-8k.h   |   7 +
> >  lib/hashtable.c |   2 +-
> >  7 files changed, 441 insertions(+), 1 deletion(-)
> >  create mode 100644 board/Marvell/common/Kconfig
> >  create mode 100644 board/Marvell/common/Makefile
> >  create mode 100644 board/Marvell/common/mac.c
> >
> > diff --git a/arch/arm/mach-mvebu/Kconfig b/arch/arm/mach-mvebu/Kconfig
> > index 087643725e..d48de626ea 100644
> > --- a/arch/arm/mach-mvebu/Kconfig
> > +++ b/arch/arm/mach-mvebu/Kconfig
> > @@ -336,6 +336,7 @@ config SECURED_MODE_CSK_INDEX
> >   default 0
> >   depends on SECURED_MODE_IMAGE
> >
> > +source "board/Marvell/common/Kconfig"
> >  source "board/solidrun/clearfog/Kconfig"
> >  source "board/kobol/helios4/Kconfig"
> >
> > diff --git a/board/Marvell/common/Kconfig b/board/Marvell/common/Kconfig
> > new file mode 100644
> > index 00..473a83b05b
> > --- /dev/null
> > +++ b/board/Marvell/common/Kconfig
> > @@ -0,0 +1,29 @@
> > +menu "Marvell Armada common configuration"
> > +depends on TARGET_MVEBU_ARMADA_37XX || TARGET_MVEBU_ARMADA_8K
> > +
> > +config MVEBU_MAC_HW_INFO
> > + bool "Marvell hw_info (mac) support"
> > + depends on SPI_FLASH && ENV_IS_IN_SPI_FLASH && ARCH_MVEBU
> > + default n
> > + help
> > +   Enable loading of the Marvell hw_info parameters from the
> > +   SPI flash hw_info area. Parameters (usually the board serial
> > +   number and MAC addresses) are then imported into the
> > +   existing U-Boot environment.
> > +   Implementation of this command is compatible with the
> > +   original Marvell U-Boot command. Reading and writing is
> > +   supported.
> > +   EEPROM config pattern and checksum aren't supported.
> > +   After enabled, these parameters are managed from the common
> > +   U-Boot mac command.
> > +
> > +config MVEBU_MAC_HW_INFO_OFFSET
> > + hex "Marvell hw_info (mac) SPI flash offset"
> > + depends on MVEBU_MAC_HW_INFO
> > + default 0x3E
> > + help
> > +   This option defines the SPI flash offset of the Marvell
> > +   hw_info area. This defaults to 0x3E on most Armada
> > +   A3720 platforms.
>
> Have you tried to specify this offset directly into DTS file? Because
> in DTS file is already specified this hw info partition and it seems
> like that this kind of information belongs to DTS.

I haven't encountered a board, which has a different offset so far.
This can be treated as a nicer way of defining this offset, rath

Re: [PATCH v3 3/3] arm: mvebu: Initial ESPRESSOBin-Ultra board support

2021-09-27 Thread Luka Kovacic
Hello Pali,

> Hello Luka! Do you need some help with this?

I wasn't able to get to this yet, as I am working on something else
right now and will circle back to the ESPRESSOBin-Ultra shortly.

Kind regards,
Luka


Re: [PATCH v3 3/3] arm: mvebu: Initial ESPRESSOBin-Ultra board support

2021-08-16 Thread Luka Kovacic
Hello Gerald,

On Sat, Aug 14, 2021 at 9:59 AM Gérald Kerma  wrote:
>
> Héllo,
> > Message: 2
> > Date: Fri, 13 Aug 2021 12:03:57 +0200
> > From: Luka Kovacic
> > To: Pali Roh?r
> > Cc:u-boot@lists.denx.de, Robert Marko,
> >   Luka Perkov, Marek Behun
> >   ,s...@denx.de,s...@chromium.org,
> >   patrick.delau...@foss.st.com,xypron.g...@gmx.de
> > Subject: Re: [PATCH v3 3/3] arm: mvebu: Initial ESPRESSOBin-Ultra
> >   board support
> > Message-ID:
> >   
> > Content-Type: text/plain; charset="UTF-8"
> >
> > Hello Pali,
> >
> > On Fri, Aug 13, 2021 at 11:27 AM Pali Roh?r  wrote:
> >> On Friday 13 August 2021 01:39:38 Luka Kovacic wrote:
> >>> Add initial support for the ESPRESSOBin-Ultra board from Globalscale
> >>> Technologies, Inc.
> >>>
> >>> The board is based on the 64-bit dual-core Marvell Armada 3720 SoC.
> >>> Peripherals:
> >>>   - 5 Gigabit Ethernet ports (WAN has PoE, up to 30W, Topaz 6341 switch)
> >>>   - RTC clock (PCF8563)
> >>>   - USB 3.0 port
> >>>   - USB 2.0 port
> >>>   - 4x LED
> >>>   - UART over Micro-USB
> >>>   - M.2 slot (2280)
> >>>   - Mini PCI-E slot
> >>>
> >>> Additionally, automatic import of the Marvell hw_info parameters is
> >>> enabled via the recently added mac command for A37XX platforms.
> >>> The parameters stored in Marvell hw_info are usually the board serial
> >>> number and MAC addresses.
> >>>
> >>> Signed-off-by: Luka Kovacic
> >>> Cc: Luka Perkov
> >>> Cc: Robert Marko
> >>> ---
> >>>   arch/arm/dts/Makefile |   1 +
> >>>   .../arm/dts/armada-3720-espressobin-ultra.dts | 114 ++
> >>>   arch/arm/dts/armada-3720-espressobin.dts  | 199 +
> >>>   arch/arm/dts/armada-3720-espressobin.dtsi | 210 ++
> >>>   board/Marvell/mvebu_armada-37xx/MAINTAINERS   |   8 +
> >>>   board/Marvell/mvebu_armada-37xx/board.c   |  92 +++-
> >>>   .../mvebu_espressobin-ultra-88f3720_defconfig |  93 
> >>>   7 files changed, 514 insertions(+), 203 deletions(-)
> >>>   create mode 100644 arch/arm/dts/armada-3720-espressobin-ultra.dts
> >>>   create mode 100644 arch/arm/dts/armada-3720-espressobin.dtsi
> >>>   create mode 100644 configs/mvebu_espressobin-ultra-88f3720_defconfig
> >> ...
>
> Thanks, all, for this job.
>
> I am available for testing (if needed) on EspressoBin V7, with eMMC, and
> EspressoBin Ultra.

Thanks for offering your help. Can you test the following patchset
(v4), when it's out,
as some implementation issues still have to be resolved here?

>
> I have issue on EspressoBin Ultra, with the v2 patch for
> EspressoBin-Ultra, on OpenWrt 21.02-RC, fw_printenv do not works... (CRC
> Error)
> I have the same issue with the Marvell (GlobalScale) u-Boot, factory and
> upgraded version.

Did you specify the U-Boot environment location correctly in the fw_printenv
config?

> Environments variables are correctly managed from the u-Boot itself.
>
> Regards,
> Gérald Kerma
>
> PS : I am only registered to the digest, so I hope my mail will not be
> disturbing...

Kind regards,
Luka


Re: [PATCH v3 3/3] arm: mvebu: Initial ESPRESSOBin-Ultra board support

2021-08-16 Thread Luka Kovacic
Hello Pali,

On Fri, Aug 13, 2021 at 12:59 PM Pali Rohár  wrote:
>
> On Friday 13 August 2021 12:33:25 Luka Kovacic wrote:
> > On Fri, Aug 13, 2021 at 12:22 PM Pali Rohár  wrote:
> > >
> > > On Friday 13 August 2021 12:03:57 Luka Kovacic wrote:
> > > > Hello Pali,
> > > >
> > > > On Fri, Aug 13, 2021 at 11:27 AM Pali Rohár  wrote:
> > > > >
> > > > > On Friday 13 August 2021 01:39:38 Luka Kovacic wrote:
> > > > > > Add initial support for the ESPRESSOBin-Ultra board from Globalscale
> > > > > > Technologies, Inc.
> > > > > >
> > > > > > The board is based on the 64-bit dual-core Marvell Armada 3720 SoC.
> > > > > > Peripherals:
> > > > > >  - 5 Gigabit Ethernet ports (WAN has PoE, up to 30W, Topaz 6341 
> > > > > > switch)
> > > > > >  - RTC clock (PCF8563)
> > > > > >  - USB 3.0 port
> > > > > >  - USB 2.0 port
> > > > > >  - 4x LED
> > > > > >  - UART over Micro-USB
> > > > > >  - M.2 slot (2280)
> > > > > >  - Mini PCI-E slot
> > > > > >
> > > > > > Additionally, automatic import of the Marvell hw_info parameters is
> > > > > > enabled via the recently added mac command for A37XX platforms.
> > > > > > The parameters stored in Marvell hw_info are usually the board 
> > > > > > serial
> > > > > > number and MAC addresses.
> > > > > >
> > > > > > Signed-off-by: Luka Kovacic 
> > > > > > Cc: Luka Perkov 
> > > > > > Cc: Robert Marko 
> > > > > > ---
> > > > > >  arch/arm/dts/Makefile |   1 +
> > > > > >  .../arm/dts/armada-3720-espressobin-ultra.dts | 114 ++
> > > > > >  arch/arm/dts/armada-3720-espressobin.dts  | 199 
> > > > > > +
> > > > > >  arch/arm/dts/armada-3720-espressobin.dtsi | 210 
> > > > > > ++
> > > > > >  board/Marvell/mvebu_armada-37xx/MAINTAINERS   |   8 +
> > > > > >  board/Marvell/mvebu_armada-37xx/board.c   |  92 +++-
> > > > > >  .../mvebu_espressobin-ultra-88f3720_defconfig |  93 
> > > > > >  7 files changed, 514 insertions(+), 203 deletions(-)
> > > > > >  create mode 100644 arch/arm/dts/armada-3720-espressobin-ultra.dts
> > > > > >  create mode 100644 arch/arm/dts/armada-3720-espressobin.dtsi
> > > > > >  create mode 100644 
> > > > > > configs/mvebu_espressobin-ultra-88f3720_defconfig
> > > > > ...
> > > > > > diff --git a/board/Marvell/mvebu_armada-37xx/board.c 
> > > > > > b/board/Marvell/mvebu_armada-37xx/board.c
> > > > > > index 2de9c2ac17..21c1eb7b22 100644
> > > > > > --- a/board/Marvell/mvebu_armada-37xx/board.c
> > > > > > +++ b/board/Marvell/mvebu_armada-37xx/board.c
> > > > > > @@ -11,6 +11,7 @@
> > > > > >  #include 
> > > > > >  #include 
> > > > > >  #include 
> > > > > > +#include 
> > > > > >  #include 
> > > > > >  #include 
> > > > > >  #include 
> > > > > > @@ -55,6 +56,15 @@ DECLARE_GLOBAL_DATA_PTR;
> > > > > >  #define MVEBU_G2_SMI_PHY_CMD_REG (24)
> > > > > >  #define MVEBU_G2_SMI_PHY_DATA_REG(25)
> > > > > >
> > > > > > +/* Marvell 88E1512 */
> > > > > > +#define MII_MARVELL_PHY_PAGE 22
> > > > > > +
> > > > > > +#define MV88E1512_GENERAL_CTRL   20
> > > > > > +#define MV88E1512_MODE_SGMII 1
> > > > > > +#define MV88E1512_RESET_OFFS 15
> > > > > > +
> > > > > > +#define ULTRA_MV88E1512_PHYADDR  0x1
> > > > > > +
> > > > > >  /*
> > > > > >   * Memory Controller Registers
> > > > > >   *
> > > > > > @@ -282,12 +292,68 @@ static int mii_multi_chip_mode_write(struct 
> > > > > > mii_dev *bus, int dev_smi_addr,
> > > > > >   return 0;
> > > > > >  }
> > > > > >
> > > > > > -/* Bring-up bo

Re: [PATCH v3 2/3] arm: mvebu: mvebu_armada-37xx: Define the loadaddr environment variable

2021-08-16 Thread Luka Kovacic
Hello Pali,

On Fri, Aug 13, 2021 at 3:59 PM Pali Rohár  wrote:
>
> On Friday 13 August 2021 01:39:37 Luka Kovacic wrote:
> > Add the loadaddr U-Boot environment variable, as this is available in
> > the stock Marvell U-Boot by default on Marvell Armada A37XX platforms.
> >
> > Signed-off-by: Luka Kovacic 
> > Cc: Luka Perkov 
> > Cc: Robert Marko 
> > ---
> >  include/configs/mvebu_armada-37xx.h | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/include/configs/mvebu_armada-37xx.h 
> > b/include/configs/mvebu_armada-37xx.h
> > index 8e8bcfa018..6901680e32 100644
> > --- a/include/configs/mvebu_armada-37xx.h
> > +++ b/include/configs/mvebu_armada-37xx.h
> > @@ -110,6 +110,7 @@
> >
> >  /* fdt_addr and kernel_addr are needed for existing distribution boot 
> > scripts */
> >  #define CONFIG_EXTRA_ENV_SETTINGS\
> > + "loadaddr=0x600\0"  \
>
> Now I see where is the issue...
>
> In file include/env_default.h is:
>
> #ifdef  CONFIG_LOADADDR
> "loadaddr=" __stringify(CONFIG_LOADADDR)"\0"
> #endif
>
> So default value for loadaddr= is set only when CONFIG_LOADADDR is
> defined.
>
> But lot of cmd load commands are using config option
> CONFIG_SYS_LOAD_ADDR as a default value for load address.
>
> And also for espressobin we set correct value into CONFIG_SYS_LOAD_ADDR.
>
> I'm looking at the u-boot code and CONFIG_LOADADDR is used only by
> cmd/qfw.c and include/env_default.h. And on all other places (in cmd
> load commands) is used CONFIG_SYS_LOAD_ADDR.
>
> So for me it looks like that cmd/qfw.c and include/env_default.h should
> be fixed to use CONFIG_SYS_LOAD_ADDR instead of CONFIG_LOADADDR.

Thanks, this makes sense now.
I can correct this in the next patchset if that's okay with you.

>
> >   "scriptaddr=0x6d0\0"\
> >   "pxefile_addr_r=0x6e0\0"\
> >   "fdt_addr=0x6f0\0"  \
> > --
> > 2.31.1
> >

Kind regards,
Luka


Re: [PATCH v3 1/3] arm: mvebu: mvebu_armada-37xx: Implement the mac command (Marvell hw_info)

2021-08-13 Thread Luka Kovacic
On Fri, Aug 13, 2021 at 12:29 PM Pali Rohár  wrote:
>
> On Friday 13 August 2021 01:39:36 Luka Kovacic wrote:
> > diff --git a/board/Marvell/mvebu_armada-37xx/Kconfig 
> > b/board/Marvell/mvebu_armada-37xx/Kconfig
> > new file mode 100644
> > index 00..b84dd20023
> > --- /dev/null
> > +++ b/board/Marvell/mvebu_armada-37xx/Kconfig
> > @@ -0,0 +1,29 @@
> > +menu "Marvell Armada 37xx configuration"
> > +depends on TARGET_MVEBU_ARMADA_37XX
> > +
> > +config MVEBU_MAC_HW_INFO
> > + bool "Marvell hw_info (mac) support"
> > + depends on SPI_FLASH && ENV_IS_IN_SPI_FLASH && ARCH_MVEBU
> > + default n
> > + help
> > +   Enable loading of the Marvell hw_info parameters from the
> > +   SPI flash hw_info area. Parameters (usually the board serial
> > +   number and MAC addresses) are then imported into the
> > +   existing U-Boot environment.
> > +   Implementation of this command is compatible with the
> > +   original Marvell U-Boot command. Reading and writing is
> > +   supported.
> > +   EEPROM config pattern and checksum aren't supported.
> > +   After enabled, these parameters are managed from the common
> > +   U-Boot mac command.
> > +
> > +config MVEBU_MAC_HW_INFO_OFFSET
> > + hex "Marvell hw_info (mac) SPI flash offset"
> > + depends on MVEBU_MAC_HW_INFO
> > + default 0x3E
> > + help
> > +   This option defines the SPI flash offset of the Marvell
> > +   hw_info area. This defaults to 0x3E on most Armada
> > +   A3720 platforms.
>
> Just a question, cannot we load this offset from DTS? In DTS are already
> specified SPI partitions, so this could eliminate need for defining this
> offset at two places. But I really do not know at which time is this
> code called, if DTB is available at this time or not.

The code is called right after cpu_secondary_init_r.
I'm not sure, there also some other values, which are hard-coded and
so far I didn't really see any other possible offset.

Are you aware of any other relevant board with the Marvell hw_info
parameters?

>
> > +endmenu

Kind regards,
Luka


Re: [PATCH v3 3/3] arm: mvebu: Initial ESPRESSOBin-Ultra board support

2021-08-13 Thread Luka Kovacic
On Fri, Aug 13, 2021 at 12:22 PM Pali Rohár  wrote:
>
> On Friday 13 August 2021 12:03:57 Luka Kovacic wrote:
> > Hello Pali,
> >
> > On Fri, Aug 13, 2021 at 11:27 AM Pali Rohár  wrote:
> > >
> > > On Friday 13 August 2021 01:39:38 Luka Kovacic wrote:
> > > > Add initial support for the ESPRESSOBin-Ultra board from Globalscale
> > > > Technologies, Inc.
> > > >
> > > > The board is based on the 64-bit dual-core Marvell Armada 3720 SoC.
> > > > Peripherals:
> > > >  - 5 Gigabit Ethernet ports (WAN has PoE, up to 30W, Topaz 6341 switch)
> > > >  - RTC clock (PCF8563)
> > > >  - USB 3.0 port
> > > >  - USB 2.0 port
> > > >  - 4x LED
> > > >  - UART over Micro-USB
> > > >  - M.2 slot (2280)
> > > >  - Mini PCI-E slot
> > > >
> > > > Additionally, automatic import of the Marvell hw_info parameters is
> > > > enabled via the recently added mac command for A37XX platforms.
> > > > The parameters stored in Marvell hw_info are usually the board serial
> > > > number and MAC addresses.
> > > >
> > > > Signed-off-by: Luka Kovacic 
> > > > Cc: Luka Perkov 
> > > > Cc: Robert Marko 
> > > > ---
> > > >  arch/arm/dts/Makefile |   1 +
> > > >  .../arm/dts/armada-3720-espressobin-ultra.dts | 114 ++
> > > >  arch/arm/dts/armada-3720-espressobin.dts  | 199 +
> > > >  arch/arm/dts/armada-3720-espressobin.dtsi | 210 ++
> > > >  board/Marvell/mvebu_armada-37xx/MAINTAINERS   |   8 +
> > > >  board/Marvell/mvebu_armada-37xx/board.c   |  92 +++-
> > > >  .../mvebu_espressobin-ultra-88f3720_defconfig |  93 
> > > >  7 files changed, 514 insertions(+), 203 deletions(-)
> > > >  create mode 100644 arch/arm/dts/armada-3720-espressobin-ultra.dts
> > > >  create mode 100644 arch/arm/dts/armada-3720-espressobin.dtsi
> > > >  create mode 100644 configs/mvebu_espressobin-ultra-88f3720_defconfig
> > > ...
> > > > diff --git a/board/Marvell/mvebu_armada-37xx/board.c 
> > > > b/board/Marvell/mvebu_armada-37xx/board.c
> > > > index 2de9c2ac17..21c1eb7b22 100644
> > > > --- a/board/Marvell/mvebu_armada-37xx/board.c
> > > > +++ b/board/Marvell/mvebu_armada-37xx/board.c
> > > > @@ -11,6 +11,7 @@
> > > >  #include 
> > > >  #include 
> > > >  #include 
> > > > +#include 
> > > >  #include 
> > > >  #include 
> > > >  #include 
> > > > @@ -55,6 +56,15 @@ DECLARE_GLOBAL_DATA_PTR;
> > > >  #define MVEBU_G2_SMI_PHY_CMD_REG (24)
> > > >  #define MVEBU_G2_SMI_PHY_DATA_REG(25)
> > > >
> > > > +/* Marvell 88E1512 */
> > > > +#define MII_MARVELL_PHY_PAGE 22
> > > > +
> > > > +#define MV88E1512_GENERAL_CTRL   20
> > > > +#define MV88E1512_MODE_SGMII 1
> > > > +#define MV88E1512_RESET_OFFS 15
> > > > +
> > > > +#define ULTRA_MV88E1512_PHYADDR  0x1
> > > > +
> > > >  /*
> > > >   * Memory Controller Registers
> > > >   *
> > > > @@ -282,12 +292,68 @@ static int mii_multi_chip_mode_write(struct 
> > > > mii_dev *bus, int dev_smi_addr,
> > > >   return 0;
> > > >  }
> > > >
> > > > -/* Bring-up board-specific network stuff */
> > > > -int board_network_enable(struct mii_dev *bus)
> > > > +void force_phy_88e1512_sgmii_to_copper(u16 devaddr)
> > > >  {
> > > > - if (!of_machine_is_compatible("globalscale,espressobin"))
> > > > - return 0;
> > > > + const char *name;
> > > > + u16 reg;
> > > > +
> > > > + name = miiphy_get_current_dev();
> > > > + if (name) {
> > >
> > > It is possible that phy is not available? As you are calling code below
> > > only in case name is not-NULL.
> >
> > Well, according to common/miiphyutil.c, it could also happen that it's NULL.
>
> I see. But if it happens, is not it fatal error for this board? If name
> is NULL then you cannot correctly configure board correctly, right?
>
> > >
> > > > + /* SGMII-to-Copper mode initialization */
> > >

Re: [PATCH v3 3/3] arm: mvebu: Initial ESPRESSOBin-Ultra board support

2021-08-13 Thread Luka Kovacic
Hello Stefan and Pali,

On Fri, Aug 13, 2021 at 11:58 AM Stefan Roese  wrote:
>
> Hi,
>
> On 13.08.21 11:54, Pali Rohár wrote:
> > On Friday 13 August 2021 11:08:08 Luka Kovacic wrote:
> >> Hello Pali,
> >>
> >> On Fri, Aug 13, 2021 at 10:14 AM Pali Rohár  wrote:
> >>>
> >>> On Friday 13 August 2021 01:39:38 Luka Kovacic wrote:
> >>>> Add initial support for the ESPRESSOBin-Ultra board from Globalscale
> >>>> Technologies, Inc.
> >>>>
> >>>> The board is based on the 64-bit dual-core Marvell Armada 3720 SoC.
> >>>> Peripherals:
> >>>>   - 5 Gigabit Ethernet ports (WAN has PoE, up to 30W, Topaz 6341 switch)
> >>>>   - RTC clock (PCF8563)
> >>>>   - USB 3.0 port
> >>>>   - USB 2.0 port
> >>>>   - 4x LED
> >>>>   - UART over Micro-USB
> >>>>   - M.2 slot (2280)
> >>>>   - Mini PCI-E slot
> >>>>
> >>>> Additionally, automatic import of the Marvell hw_info parameters is
> >>>> enabled via the recently added mac command for A37XX platforms.
> >>>> The parameters stored in Marvell hw_info are usually the board serial
> >>>> number and MAC addresses.
> >>>>
> >>>> Signed-off-by: Luka Kovacic 
> >>>> Cc: Luka Perkov 
> >>>> Cc: Robert Marko 
> >>>> ---
> >>>>   arch/arm/dts/Makefile |   1 +
> >>>>   .../arm/dts/armada-3720-espressobin-ultra.dts | 114 ++
> >>>>   arch/arm/dts/armada-3720-espressobin.dts  | 199 +
> >>>>   arch/arm/dts/armada-3720-espressobin.dtsi | 210 ++
> >>>>   board/Marvell/mvebu_armada-37xx/MAINTAINERS   |   8 +
> >>>>   board/Marvell/mvebu_armada-37xx/board.c   |  92 +++-
> >>>>   .../mvebu_espressobin-ultra-88f3720_defconfig |  93 
> >>>>   7 files changed, 514 insertions(+), 203 deletions(-)
> >>>>   create mode 100644 arch/arm/dts/armada-3720-espressobin-ultra.dts
> >>>>   create mode 100644 arch/arm/dts/armada-3720-espressobin.dtsi
> >>>>   create mode 100644 configs/mvebu_espressobin-ultra-88f3720_defconfig
> >>>
> >>> Hello Luka! Please look at my comments from previous review:
> >>> https://lore.kernel.org/u-boot/20210227004852.5urcwnn6uxehuk72@pali/
> >>>
> >>> I think it is not a good idea to duplicate espressobin code, specially
> >>> now when differences between v5, v7, non-emmc and emmc were
> >>> de-duplicated and correctly detected at runtime. Just use one DTS and
> >>> one config file and differences can be handled in board code functions
> >>> "board_fix_fdt" and "board_late_init".
> >>
> >> I believe that patching the DTS at runtime diminishes the value of
> >> device trees in the first case.
> >>
> >> As far as the v5, v7, non-emmc and emmc boards go I do understand
> >> that, as they are physically similar and more or less different revisions
> >> of the same board.
> >>
> >> The ESPRESSOBin Ultra board is completely different from those boards
> >> physically and so I doesn't make sense to me, why we would merge all
> >> of them into one device tree.
> >
> > See email for reasons:
> > https://lore.kernel.org/u-boot/20210301154101.ke5j2r3lazjlxrsl@pali/
> >
> > Anyway, I'm looking at differences between ultra and non-ultra boards
> > which are used by U-Boot... And I see only:
> > * switch configuration & phy
> > * i2c rtc
> > * sdhci slot
> >
> > Other changes are not used by U-Boot (led).
> >
> > For switch configuration & phy there is already custom code in U-Boot
> > board file. For sdhci slot there is also (to enable/disable eMMC after
> > detection).
> >
> > So the only difference is presence of i2c rtc, right?
> >
> > I guess it does not make much sense to copy and duplicate whole DTS and
> > also defconfig file for such small differences. Insertion of just few
> > nodes is not a big problem.
> >
> > These boars are not very different, and having tons of u-boot binaries
> > for every combination just complicate it as explained in above email.
>
> I fully agree with Pali. It's much more conveniant to just have one
> U-Boot target (and binary) which can handle multiple board variants
> by runtime detection. I would very much welc

Re: [PATCH v3 1/3] arm: mvebu: mvebu_armada-37xx: Implement the mac command (Marvell hw_info)

2021-08-13 Thread Luka Kovacic
On Fri, Aug 13, 2021 at 12:09 PM Pali Rohár  wrote:
>
> On Friday 13 August 2021 11:51:02 Luka Kovacic wrote:
> > Hello Pali,
> >
> > On Fri, Aug 13, 2021 at 11:41 AM Pali Rohár  wrote:
> > >
> > > On Friday 13 August 2021 11:23:15 Luka Kovacic wrote:
> > > > Hello Marek and Pali,
> > > >
> > > > On Fri, Aug 13, 2021 at 10:23 AM Pali Rohár  wrote:
> > > > >
> > > > > On Friday 13 August 2021 01:39:36 Luka Kovacic wrote:
> > > > > > The mac command is implemented to enable parsing Marvell hw_info 
> > > > > > formatted
> > > > > > environments. This format is often used on Marvell Armada A37XX 
> > > > > > based
> > > > > > devices to store parameters like the board serial number, factory
> > > > > > MAC addresses and some other information.
> > > > > > These parameters are usually written to the flash in the factory.
> > > > > >
> > > > > > Currently the mac command supports reading/writing parameters and 
> > > > > > dumping
> > > > > > the current hw_info parameters.
> > > > > > EEPROM config pattern and checksum aren't supported.
> > > > > >
> > > > > > This functionality has been tested on the GST ESPRESSOBin-Ultra 
> > > > > > board
> > > > > > successfully, both reading the stock U-Boot parameters in mainline 
> > > > > > U-Boot
> > > > > > and reading the parameters written by this command in the stock 
> > > > > > U-Boot.
> > > > > >
> > > > > > Usage example:
> > > > > >  => mac read
> > > > > >  => saveenv
> > > > >
> > > > > Hello Luka!
> > > > >
> > > > > You are just using above commands for accessing following variables,
> > > > > right?
> > > > >
> > > > > pcb_slm
> > > > > pcb_rev
> > > > > eco_rev
> > > > > pcb_sn
> > > > > ethaddr
> > > > > eth1addr
> > > > > eth2addr
> > > > > eth3addr
> > > > > eth4addr
> > > > > eth5addr
> > > > > eth6addr
> > > > > eth7addr
> > > > > eth8addr
> > > > > eth9addr
> > > > >
> > > >
> > > > Yes, I am accessing these variables.
> > > >
> > > > > So why is additional command required? Espressobin boards can already
> > > > > load and use correct eth*addr variables, which is implemented in board
> > > > > file.
> > > >
> > > > The current implementation in the board file preserves currently stored 
> > > > MAC
> > > > addresses, which are in the U-Boot environment.
> > >
> > > Yes, this is for v5/v7 variants. But it can be easily modified for ultra
> > > to read mac addresses from this custom storage.
> > >
> > > > My implementation is suitable for the ESPRESSOBin-Ultra, as the MACs
> > > > are stored in the hw_info area of the SPI flash and the tool imports 
> > > > them
> > > > into the normal U-Boot env.
> > > > They can also be modified using the tool - we won't be able to get this
> > > > functionality in the board file.
> > >
> > > Modification by env variables is also possible from the board file. Look
> > > at U_BOOT_ENV_CALLBACK() functionality, which allows to call custom code
> > > when trying to change/delete particular env variable.
> > >
> > > > > So what about implementing this import for all above variables for 
> > > > > ultra
> > > > > variant in board file, like it is already for all other variants? I 
> > > > > have
> > > > > already suggested it in the past. As I think this approach is just one
> > > > > giant and complicated hack...
> > > > > https://lore.kernel.org/u-boot/20210301151721.xt62rdun5dnlevqk@pali/
> > > > >
> > > > > I guess that it should be enough to import variables from SPI to env 
> > > > > in
> > > > > board_late_init() function.
> > > >
> > > > Currently, the MACs are automatically imported from the
> > > > common/board_r.c file at boot, I think this is more standard and 
> > > > cleaner.
> > 

Re: [PATCH v3 3/3] arm: mvebu: Initial ESPRESSOBin-Ultra board support

2021-08-13 Thread Luka Kovacic
Hello Pali,

On Fri, Aug 13, 2021 at 11:27 AM Pali Rohár  wrote:
>
> On Friday 13 August 2021 01:39:38 Luka Kovacic wrote:
> > Add initial support for the ESPRESSOBin-Ultra board from Globalscale
> > Technologies, Inc.
> >
> > The board is based on the 64-bit dual-core Marvell Armada 3720 SoC.
> > Peripherals:
> >  - 5 Gigabit Ethernet ports (WAN has PoE, up to 30W, Topaz 6341 switch)
> >  - RTC clock (PCF8563)
> >  - USB 3.0 port
> >  - USB 2.0 port
> >  - 4x LED
> >  - UART over Micro-USB
> >  - M.2 slot (2280)
> >  - Mini PCI-E slot
> >
> > Additionally, automatic import of the Marvell hw_info parameters is
> > enabled via the recently added mac command for A37XX platforms.
> > The parameters stored in Marvell hw_info are usually the board serial
> > number and MAC addresses.
> >
> > Signed-off-by: Luka Kovacic 
> > Cc: Luka Perkov 
> > Cc: Robert Marko 
> > ---
> >  arch/arm/dts/Makefile |   1 +
> >  .../arm/dts/armada-3720-espressobin-ultra.dts | 114 ++
> >  arch/arm/dts/armada-3720-espressobin.dts  | 199 +
> >  arch/arm/dts/armada-3720-espressobin.dtsi | 210 ++
> >  board/Marvell/mvebu_armada-37xx/MAINTAINERS   |   8 +
> >  board/Marvell/mvebu_armada-37xx/board.c   |  92 +++-
> >  .../mvebu_espressobin-ultra-88f3720_defconfig |  93 
> >  7 files changed, 514 insertions(+), 203 deletions(-)
> >  create mode 100644 arch/arm/dts/armada-3720-espressobin-ultra.dts
> >  create mode 100644 arch/arm/dts/armada-3720-espressobin.dtsi
> >  create mode 100644 configs/mvebu_espressobin-ultra-88f3720_defconfig
> ...
> > diff --git a/board/Marvell/mvebu_armada-37xx/board.c 
> > b/board/Marvell/mvebu_armada-37xx/board.c
> > index 2de9c2ac17..21c1eb7b22 100644
> > --- a/board/Marvell/mvebu_armada-37xx/board.c
> > +++ b/board/Marvell/mvebu_armada-37xx/board.c
> > @@ -11,6 +11,7 @@
> >  #include 
> >  #include 
> >  #include 
> > +#include 
> >  #include 
> >  #include 
> >  #include 
> > @@ -55,6 +56,15 @@ DECLARE_GLOBAL_DATA_PTR;
> >  #define MVEBU_G2_SMI_PHY_CMD_REG (24)
> >  #define MVEBU_G2_SMI_PHY_DATA_REG(25)
> >
> > +/* Marvell 88E1512 */
> > +#define MII_MARVELL_PHY_PAGE 22
> > +
> > +#define MV88E1512_GENERAL_CTRL   20
> > +#define MV88E1512_MODE_SGMII 1
> > +#define MV88E1512_RESET_OFFS 15
> > +
> > +#define ULTRA_MV88E1512_PHYADDR  0x1
> > +
> >  /*
> >   * Memory Controller Registers
> >   *
> > @@ -282,12 +292,68 @@ static int mii_multi_chip_mode_write(struct mii_dev 
> > *bus, int dev_smi_addr,
> >   return 0;
> >  }
> >
> > -/* Bring-up board-specific network stuff */
> > -int board_network_enable(struct mii_dev *bus)
> > +void force_phy_88e1512_sgmii_to_copper(u16 devaddr)
> >  {
> > - if (!of_machine_is_compatible("globalscale,espressobin"))
> > - return 0;
> > + const char *name;
> > + u16 reg;
> > +
> > + name = miiphy_get_current_dev();
> > + if (name) {
>
> It is possible that phy is not available? As you are calling code below
> only in case name is not-NULL.

Well, according to common/miiphyutil.c, it could also happen that it's NULL.

>
> > + /* SGMII-to-Copper mode initialization */
> > +
> > + /* Select page 18 */
> > + miiphy_write(name, devaddr, MII_MARVELL_PHY_PAGE, 0x12);
> > + /* In reg 20, write MODE[2:0] = 0x1 (SGMII to Copper) */
> > + miiphy_read(name, devaddr, MV88E1512_GENERAL_CTRL, );
> > + reg &= ~0x7;
> > + reg |= MV88E1512_MODE_SGMII;
> > + miiphy_write(name, devaddr, MV88E1512_GENERAL_CTRL, reg);
> > + /* PHY reset is necessary after changing MODE[2:0] */
> > + miiphy_read(name, devaddr, MV88E1512_GENERAL_CTRL, );
> > + reg |= 1 << MV88E1512_RESET_OFFS;
> > + miiphy_write(name, devaddr, MV88E1512_GENERAL_CTRL, reg);
> > + /* Reset page selection */
> > + miiphy_write(name, devaddr, MII_MARVELL_PHY_PAGE, 0);
> > + udelay(100);
> > + }
> > +}
> > +
> > +int board_network_enable_espressobin_ultra(struct mii_dev *bus)
> > +{
> > + int i;
> > + /* Setup 88E1512 SGMII-to-Copper mode */
> > + force_phy_88e1512_sgmii_to_copper(ULTRA_MV88E1512_PHYADDR);
> >

Re: [PATCH v3 1/3] arm: mvebu: mvebu_armada-37xx: Implement the mac command (Marvell hw_info)

2021-08-13 Thread Luka Kovacic
Hello Pali,

On Fri, Aug 13, 2021 at 11:41 AM Pali Rohár  wrote:
>
> On Friday 13 August 2021 11:23:15 Luka Kovacic wrote:
> > Hello Marek and Pali,
> >
> > On Fri, Aug 13, 2021 at 10:23 AM Pali Rohár  wrote:
> > >
> > > On Friday 13 August 2021 01:39:36 Luka Kovacic wrote:
> > > > The mac command is implemented to enable parsing Marvell hw_info 
> > > > formatted
> > > > environments. This format is often used on Marvell Armada A37XX based
> > > > devices to store parameters like the board serial number, factory
> > > > MAC addresses and some other information.
> > > > These parameters are usually written to the flash in the factory.
> > > >
> > > > Currently the mac command supports reading/writing parameters and 
> > > > dumping
> > > > the current hw_info parameters.
> > > > EEPROM config pattern and checksum aren't supported.
> > > >
> > > > This functionality has been tested on the GST ESPRESSOBin-Ultra board
> > > > successfully, both reading the stock U-Boot parameters in mainline 
> > > > U-Boot
> > > > and reading the parameters written by this command in the stock U-Boot.
> > > >
> > > > Usage example:
> > > >  => mac read
> > > >  => saveenv
> > >
> > > Hello Luka!
> > >
> > > You are just using above commands for accessing following variables,
> > > right?
> > >
> > > pcb_slm
> > > pcb_rev
> > > eco_rev
> > > pcb_sn
> > > ethaddr
> > > eth1addr
> > > eth2addr
> > > eth3addr
> > > eth4addr
> > > eth5addr
> > > eth6addr
> > > eth7addr
> > > eth8addr
> > > eth9addr
> > >
> >
> > Yes, I am accessing these variables.
> >
> > > So why is additional command required? Espressobin boards can already
> > > load and use correct eth*addr variables, which is implemented in board
> > > file.
> >
> > The current implementation in the board file preserves currently stored MAC
> > addresses, which are in the U-Boot environment.
>
> Yes, this is for v5/v7 variants. But it can be easily modified for ultra
> to read mac addresses from this custom storage.
>
> > My implementation is suitable for the ESPRESSOBin-Ultra, as the MACs
> > are stored in the hw_info area of the SPI flash and the tool imports them
> > into the normal U-Boot env.
> > They can also be modified using the tool - we won't be able to get this
> > functionality in the board file.
>
> Modification by env variables is also possible from the board file. Look
> at U_BOOT_ENV_CALLBACK() functionality, which allows to call custom code
> when trying to change/delete particular env variable.
>
> > > So what about implementing this import for all above variables for ultra
> > > variant in board file, like it is already for all other variants? I have
> > > already suggested it in the past. As I think this approach is just one
> > > giant and complicated hack...
> > > https://lore.kernel.org/u-boot/20210301151721.xt62rdun5dnlevqk@pali/
> > >
> > > I guess that it should be enough to import variables from SPI to env in
> > > board_late_init() function.
> >
> > Currently, the MACs are automatically imported from the
> > common/board_r.c file at boot, I think this is more standard and cleaner.
>
> Hm... then I somehow misunderstood how it works.
>
> Because I do not see any change in common/board_r.c which could read or
> import mac addresses via calling this new "mac read" command.

The function mac_read_from_eeprom() is called, if CONFIG_ID_EEPROM is
enabled. This has also been tested and a mechanism was added to avoid
duplicate imports (if the user wants to modify the MAC address, so it then
isn't overwritten).

https://source.denx.de/u-boot/u-boot/-/blob/master/common/board_r.c#L724

>
> > Nevertheless, I believe this a sufficient solution for now,
> > as this has been suggested as a solution in the previous patchset
> > comments too.
> >
> > >
> > > > Signed-off-by: Luka Kovacic 
> > > > Cc: Luka Perkov 
> > > > Cc: Robert Marko 
> > > > ---
> > > >  arch/arm/mach-mvebu/Kconfig   |   1 +
> > > >  board/Marvell/mvebu_armada-37xx/Kconfig   |  29 ++
> > > >  board/Marvell/mvebu_armada-37xx/Makefile  |   3 +-
> > > >  board/Marvell/mvebu_armada-37xx/mac/Makefile  |   5 +
> > > >  board/Marvell/

Re: [PATCH v3 2/3] arm: mvebu: mvebu_armada-37xx: Define the loadaddr environment variable

2021-08-13 Thread Luka Kovacic
Hello Pali,

On Fri, Aug 13, 2021 at 11:31 AM Pali Rohár  wrote:
>
> On Friday 13 August 2021 10:59:33 Luka Kovacic wrote:
> > Hello Pali,
> >
> > On Fri, Aug 13, 2021 at 10:08 AM Pali Rohár  wrote:
> > >
> > > On Friday 13 August 2021 01:39:37 Luka Kovacic wrote:
> > > > Add the loadaddr U-Boot environment variable, as this is available in
> > > > the stock Marvell U-Boot by default on Marvell Armada A37XX platforms.
> > >
> > > Hello Luka! Why is this change needed? Reason that it is in historic
> > > vendor U-Boot does not mean that it has to be also in new mainline
> > > version.
> > >
> > > I have already wrote some reasons in previous review thread:
> > > https://lore.kernel.org/u-boot/20210301150505.3iajeeufi7ahsnk3@pali/
> > >
> > > I think this change was needed when CONFIG_SYS_LOAD_ADDR was set to
> > > incorrect value, which is already fixed in mainline U-Boot.
> >
> > This value is very useful when building custom Linux boot scripts.
> > Yesterday, I booted the board without this patch and there was no loadaddr
> > variable.
> >
> > Do I understand this correctly? Are you saying that the value in the 
> > loadaddr
> > variable should be automatically inherited from CONFIG_SYS_LOAD_ADDR
> > even without this patch?
>
> If you do not specify load address then address from
> CONFIG_SYS_LOAD_ADDR is used. But as I mentioned in above email,
> CONFIG_SYS_LOAD_ADDR was defined incorrectly and which cause that it did
> not worked and caused crashes...

I tried not specifying it and then the loadaddr variable doesn't even exist.

>
> > >
> > > > Signed-off-by: Luka Kovacic 
> > > > Cc: Luka Perkov 
> > > > Cc: Robert Marko 
> > > > ---
> > > >  include/configs/mvebu_armada-37xx.h | 1 +
> > > >  1 file changed, 1 insertion(+)
> > > >
> > > > diff --git a/include/configs/mvebu_armada-37xx.h 
> > > > b/include/configs/mvebu_armada-37xx.h
> > > > index 8e8bcfa018..6901680e32 100644
> > > > --- a/include/configs/mvebu_armada-37xx.h
> > > > +++ b/include/configs/mvebu_armada-37xx.h
> > > > @@ -110,6 +110,7 @@
> > > >
> > > >  /* fdt_addr and kernel_addr are needed for existing distribution boot 
> > > > scripts */
> > > >  #define CONFIG_EXTRA_ENV_SETTINGS\
> > > > + "loadaddr=0x600\0"  \
> > > >   "scriptaddr=0x6d0\0"\
> > > >   "pxefile_addr_r=0x6e0\0"\
> > > >   "fdt_addr=0x6f0\0"  \
> > > > --
> > > > 2.31.1
> > > >
> >
> > Kind regards,
> > Luka

Kind regards,
Luka


Re: [PATCH v3 1/3] arm: mvebu: mvebu_armada-37xx: Implement the mac command (Marvell hw_info)

2021-08-13 Thread Luka Kovacic
Hello Marek and Pali,

On Fri, Aug 13, 2021 at 10:23 AM Pali Rohár  wrote:
>
> On Friday 13 August 2021 01:39:36 Luka Kovacic wrote:
> > The mac command is implemented to enable parsing Marvell hw_info formatted
> > environments. This format is often used on Marvell Armada A37XX based
> > devices to store parameters like the board serial number, factory
> > MAC addresses and some other information.
> > These parameters are usually written to the flash in the factory.
> >
> > Currently the mac command supports reading/writing parameters and dumping
> > the current hw_info parameters.
> > EEPROM config pattern and checksum aren't supported.
> >
> > This functionality has been tested on the GST ESPRESSOBin-Ultra board
> > successfully, both reading the stock U-Boot parameters in mainline U-Boot
> > and reading the parameters written by this command in the stock U-Boot.
> >
> > Usage example:
> >  => mac read
> >  => saveenv
>
> Hello Luka!
>
> You are just using above commands for accessing following variables,
> right?
>
> pcb_slm
> pcb_rev
> eco_rev
> pcb_sn
> ethaddr
> eth1addr
> eth2addr
> eth3addr
> eth4addr
> eth5addr
> eth6addr
> eth7addr
> eth8addr
> eth9addr
>

Yes, I am accessing these variables.

> So why is additional command required? Espressobin boards can already
> load and use correct eth*addr variables, which is implemented in board
> file.

The current implementation in the board file preserves currently stored MAC
addresses, which are in the U-Boot environment.

My implementation is suitable for the ESPRESSOBin-Ultra, as the MACs
are stored in the hw_info area of the SPI flash and the tool imports them
into the normal U-Boot env.
They can also be modified using the tool - we won't be able to get this
functionality in the board file.

>
> So what about implementing this import for all above variables for ultra
> variant in board file, like it is already for all other variants? I have
> already suggested it in the past. As I think this approach is just one
> giant and complicated hack...
> https://lore.kernel.org/u-boot/20210301151721.xt62rdun5dnlevqk@pali/
>
> I guess that it should be enough to import variables from SPI to env in
> board_late_init() function.

Currently, the MACs are automatically imported from the
common/board_r.c file at boot, I think this is more standard and cleaner.

Nevertheless, I believe this a sufficient solution for now,
as this has been suggested as a solution in the previous patchset
comments too.

>
> > Signed-off-by: Luka Kovacic 
> > Cc: Luka Perkov 
> > Cc: Robert Marko 
> > ---
> >  arch/arm/mach-mvebu/Kconfig   |   1 +
> >  board/Marvell/mvebu_armada-37xx/Kconfig   |  29 ++
> >  board/Marvell/mvebu_armada-37xx/Makefile  |   3 +-
> >  board/Marvell/mvebu_armada-37xx/mac/Makefile  |   5 +
> >  board/Marvell/mvebu_armada-37xx/mac/hw_info.c | 391 ++
> >  include/configs/mvebu_armada-37xx.h   |   7 +
> >  lib/hashtable.c   |   2 +-
> >  7 files changed, 436 insertions(+), 2 deletions(-)
> >  create mode 100644 board/Marvell/mvebu_armada-37xx/Kconfig
> >  create mode 100644 board/Marvell/mvebu_armada-37xx/mac/Makefile
> >  create mode 100644 board/Marvell/mvebu_armada-37xx/mac/hw_info.c
> >
> > diff --git a/arch/arm/mach-mvebu/Kconfig b/arch/arm/mach-mvebu/Kconfig
> > index 89737a37ad..dff9f05b28 100644
> > --- a/arch/arm/mach-mvebu/Kconfig
> > +++ b/arch/arm/mach-mvebu/Kconfig
> > @@ -312,6 +312,7 @@ config SECURED_MODE_CSK_INDEX
> >   default 0
> >   depends on SECURED_MODE_IMAGE
> >
> > +source "board/Marvell/mvebu_armada-37xx/Kconfig"
> >  source "board/solidrun/clearfog/Kconfig"
> >  source "board/kobol/helios4/Kconfig"
> >
> > diff --git a/board/Marvell/mvebu_armada-37xx/Kconfig 
> > b/board/Marvell/mvebu_armada-37xx/Kconfig
> > new file mode 100644
> > index 00..b84dd20023
> > --- /dev/null
> > +++ b/board/Marvell/mvebu_armada-37xx/Kconfig
> > @@ -0,0 +1,29 @@
> > +menu "Marvell Armada 37xx configuration"
> > +depends on TARGET_MVEBU_ARMADA_37XX
> > +
> > +config MVEBU_MAC_HW_INFO
> > + bool "Marvell hw_info (mac) support"
> > + depends on SPI_FLASH && ENV_IS_IN_SPI_FLASH && ARCH_MVEBU
> > + default n
> > + help
> > +   Enable loading of the Marvell hw_info parameters from the
> > +   SPI flash hw_info area. Parameters (usually the board serial
> > +   number and MAC addresses)

Re: [PATCH v3 3/3] arm: mvebu: Initial ESPRESSOBin-Ultra board support

2021-08-13 Thread Luka Kovacic
Hello Pali,

On Fri, Aug 13, 2021 at 10:14 AM Pali Rohár  wrote:
>
> On Friday 13 August 2021 01:39:38 Luka Kovacic wrote:
> > Add initial support for the ESPRESSOBin-Ultra board from Globalscale
> > Technologies, Inc.
> >
> > The board is based on the 64-bit dual-core Marvell Armada 3720 SoC.
> > Peripherals:
> >  - 5 Gigabit Ethernet ports (WAN has PoE, up to 30W, Topaz 6341 switch)
> >  - RTC clock (PCF8563)
> >  - USB 3.0 port
> >  - USB 2.0 port
> >  - 4x LED
> >  - UART over Micro-USB
> >  - M.2 slot (2280)
> >  - Mini PCI-E slot
> >
> > Additionally, automatic import of the Marvell hw_info parameters is
> > enabled via the recently added mac command for A37XX platforms.
> > The parameters stored in Marvell hw_info are usually the board serial
> > number and MAC addresses.
> >
> > Signed-off-by: Luka Kovacic 
> > Cc: Luka Perkov 
> > Cc: Robert Marko 
> > ---
> >  arch/arm/dts/Makefile |   1 +
> >  .../arm/dts/armada-3720-espressobin-ultra.dts | 114 ++
> >  arch/arm/dts/armada-3720-espressobin.dts  | 199 +
> >  arch/arm/dts/armada-3720-espressobin.dtsi | 210 ++
> >  board/Marvell/mvebu_armada-37xx/MAINTAINERS   |   8 +
> >  board/Marvell/mvebu_armada-37xx/board.c   |  92 +++-
> >  .../mvebu_espressobin-ultra-88f3720_defconfig |  93 
> >  7 files changed, 514 insertions(+), 203 deletions(-)
> >  create mode 100644 arch/arm/dts/armada-3720-espressobin-ultra.dts
> >  create mode 100644 arch/arm/dts/armada-3720-espressobin.dtsi
> >  create mode 100644 configs/mvebu_espressobin-ultra-88f3720_defconfig
>
> Hello Luka! Please look at my comments from previous review:
> https://lore.kernel.org/u-boot/20210227004852.5urcwnn6uxehuk72@pali/
>
> I think it is not a good idea to duplicate espressobin code, specially
> now when differences between v5, v7, non-emmc and emmc were
> de-duplicated and correctly detected at runtime. Just use one DTS and
> one config file and differences can be handled in board code functions
> "board_fix_fdt" and "board_late_init".

I believe that patching the DTS at runtime diminishes the value of
device trees in the first case.

As far as the v5, v7, non-emmc and emmc boards go I do understand
that, as they are physically similar and more or less different revisions
of the same board.

The ESPRESSOBin Ultra board is completely different from those boards
physically and so I doesn't make sense to me, why we would merge all
of them into one device tree.

I resorted to the Linux way and used a common dtsi for both the
ESPRESSOBin - which is the base and the ESPRESSOBin-Ultra.

>
> > diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
> > index c42715ead4..f21c9c94d3 100644
> > --- a/arch/arm/dts/Makefile
> > +++ b/arch/arm/dts/Makefile
> > @@ -213,6 +213,7 @@ dtb-$(CONFIG_ARCH_TEGRA) += tegra20-harmony.dtb \
> >  dtb-$(CONFIG_ARCH_MVEBU) +=  \
> >   armada-3720-db.dtb  \
> >   armada-3720-espressobin.dtb \
> > + armada-3720-espressobin-ultra.dtb   \
> >   armada-3720-turris-mox.dtb  \
> >   armada-3720-uDPU.dtb\
> >   armada-375-db.dtb   \
> > diff --git a/arch/arm/dts/armada-3720-espressobin-ultra.dts 
> > b/arch/arm/dts/armada-3720-espressobin-ultra.dts
> > new file mode 100644
> > index 00..5ad0c723e3
> > --- /dev/null
> > +++ b/arch/arm/dts/armada-3720-espressobin-ultra.dts
> > @@ -0,0 +1,114 @@
> > +// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
> > +/*
> > + * Device Tree file for ESPRESSObin-Ultra board
> > + * Copyright (C) 2016 Marvell
> > + * Copyright (C) 2019 Globalscale technologies, Inc.
> > + * Copyright (C) 2021 Sartura Ltd.
> > + *
> > + * Author: Jason Hung 
> > + * Author: Luka Kovacic 
> > + * Author: Vladimir Vid 
> > + */
> > +
> > +/dts-v1/;
> > +
> > +#include "armada-3720-espressobin.dtsi"
> > +
> > +/ {
> > + model = "Globalscale Marvell ESPRESSOBin Ultra Board";
> > + compatible = "globalscale,espressobin-ultra", "marvell,armada3720", 
> > "marvell,armada3710";
> > +
> > + gpio-leds {
> > + pinctrl-names = "default";
> > + pinctrl-0 = <_pins>, <_pins>, <_pins>, 
> > <_pins>;
> > + compatible = "gpio-leds";
> > +
> > + led1 {
> > +

Re: [PATCH v3 2/3] arm: mvebu: mvebu_armada-37xx: Define the loadaddr environment variable

2021-08-13 Thread Luka Kovacic
Hello Pali,

On Fri, Aug 13, 2021 at 10:08 AM Pali Rohár  wrote:
>
> On Friday 13 August 2021 01:39:37 Luka Kovacic wrote:
> > Add the loadaddr U-Boot environment variable, as this is available in
> > the stock Marvell U-Boot by default on Marvell Armada A37XX platforms.
>
> Hello Luka! Why is this change needed? Reason that it is in historic
> vendor U-Boot does not mean that it has to be also in new mainline
> version.
>
> I have already wrote some reasons in previous review thread:
> https://lore.kernel.org/u-boot/20210301150505.3iajeeufi7ahsnk3@pali/
>
> I think this change was needed when CONFIG_SYS_LOAD_ADDR was set to
> incorrect value, which is already fixed in mainline U-Boot.

This value is very useful when building custom Linux boot scripts.
Yesterday, I booted the board without this patch and there was no loadaddr
variable.

Do I understand this correctly? Are you saying that the value in the loadaddr
variable should be automatically inherited from CONFIG_SYS_LOAD_ADDR
even without this patch?

>
> > Signed-off-by: Luka Kovacic 
> > Cc: Luka Perkov 
> > Cc: Robert Marko 
> > ---
> >  include/configs/mvebu_armada-37xx.h | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/include/configs/mvebu_armada-37xx.h 
> > b/include/configs/mvebu_armada-37xx.h
> > index 8e8bcfa018..6901680e32 100644
> > --- a/include/configs/mvebu_armada-37xx.h
> > +++ b/include/configs/mvebu_armada-37xx.h
> > @@ -110,6 +110,7 @@
> >
> >  /* fdt_addr and kernel_addr are needed for existing distribution boot 
> > scripts */
> >  #define CONFIG_EXTRA_ENV_SETTINGS\
> > + "loadaddr=0x600\0"  \
> >   "scriptaddr=0x6d0\0"\
> >   "pxefile_addr_r=0x6e0\0"\
> >   "fdt_addr=0x6f0\0"  \
> > --
> > 2.31.1
> >

Kind regards,
Luka


[PATCH v3 3/3] arm: mvebu: Initial ESPRESSOBin-Ultra board support

2021-08-12 Thread Luka Kovacic
Add initial support for the ESPRESSOBin-Ultra board from Globalscale
Technologies, Inc.

The board is based on the 64-bit dual-core Marvell Armada 3720 SoC.
Peripherals:
 - 5 Gigabit Ethernet ports (WAN has PoE, up to 30W, Topaz 6341 switch)
 - RTC clock (PCF8563)
 - USB 3.0 port
 - USB 2.0 port
 - 4x LED
 - UART over Micro-USB
 - M.2 slot (2280)
 - Mini PCI-E slot

Additionally, automatic import of the Marvell hw_info parameters is
enabled via the recently added mac command for A37XX platforms.
The parameters stored in Marvell hw_info are usually the board serial
number and MAC addresses.

Signed-off-by: Luka Kovacic 
Cc: Luka Perkov 
Cc: Robert Marko 
---
 arch/arm/dts/Makefile |   1 +
 .../arm/dts/armada-3720-espressobin-ultra.dts | 114 ++
 arch/arm/dts/armada-3720-espressobin.dts  | 199 +
 arch/arm/dts/armada-3720-espressobin.dtsi | 210 ++
 board/Marvell/mvebu_armada-37xx/MAINTAINERS   |   8 +
 board/Marvell/mvebu_armada-37xx/board.c   |  92 +++-
 .../mvebu_espressobin-ultra-88f3720_defconfig |  93 
 7 files changed, 514 insertions(+), 203 deletions(-)
 create mode 100644 arch/arm/dts/armada-3720-espressobin-ultra.dts
 create mode 100644 arch/arm/dts/armada-3720-espressobin.dtsi
 create mode 100644 configs/mvebu_espressobin-ultra-88f3720_defconfig

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index c42715ead4..f21c9c94d3 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -213,6 +213,7 @@ dtb-$(CONFIG_ARCH_TEGRA) += tegra20-harmony.dtb \
 dtb-$(CONFIG_ARCH_MVEBU) +=\
armada-3720-db.dtb  \
armada-3720-espressobin.dtb \
+   armada-3720-espressobin-ultra.dtb   \
armada-3720-turris-mox.dtb  \
armada-3720-uDPU.dtb\
armada-375-db.dtb   \
diff --git a/arch/arm/dts/armada-3720-espressobin-ultra.dts 
b/arch/arm/dts/armada-3720-espressobin-ultra.dts
new file mode 100644
index 00..5ad0c723e3
--- /dev/null
+++ b/arch/arm/dts/armada-3720-espressobin-ultra.dts
@@ -0,0 +1,114 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Device Tree file for ESPRESSObin-Ultra board
+ * Copyright (C) 2016 Marvell
+ * Copyright (C) 2019 Globalscale technologies, Inc.
+ * Copyright (C) 2021 Sartura Ltd.
+ *
+ * Author: Jason Hung 
+ * Author: Luka Kovacic 
+ * Author: Vladimir Vid 
+ */
+
+/dts-v1/;
+
+#include "armada-3720-espressobin.dtsi"
+
+/ {
+   model = "Globalscale Marvell ESPRESSOBin Ultra Board";
+   compatible = "globalscale,espressobin-ultra", "marvell,armada3720", 
"marvell,armada3710";
+
+   gpio-leds {
+   pinctrl-names = "default";
+   pinctrl-0 = <_pins>, <_pins>, <_pins>, 
<_pins>;
+   compatible = "gpio-leds";
+
+   led1 {
+   label = "led1";
+   gpios = < 11 GPIO_ACTIVE_LOW>;
+   default-state = "on";
+   };
+   led2 {
+   label = "led2";
+   gpios = < 12 GPIO_ACTIVE_LOW>;
+   default-state = "on";
+   };
+   led3 {
+   label = "led3";
+   gpios = < 13 GPIO_ACTIVE_LOW>;
+   default-state = "on";
+   };
+   led4 {
+   label = "led4";
+   gpios = < 14 GPIO_ACTIVE_LOW>;
+   default-state = "on";
+   };
+   };
+};
+
+_nb {
+   led1_pins: led1-pins {
+   groups = "pwm0";
+   function = "gpio";
+   };
+   led2_pins: led2-pins {
+   groups = "pwm1";
+   function = "gpio";
+   };
+   led3_pins: led3-pins {
+   groups = "pwm2";
+   function = "gpio";
+   };
+   led4_pins: led4-pins {
+   groups = "pwm3";
+   function = "gpio";
+   };
+};
+
+ {
+   status = "okay";
+   phy_addr = <0x3>;
+};
+
+ {
+   status = "okay";
+   #address-cells = <1>;
+   #size-cells = <0>;
+   rtc@51 {
+   compatible = "nxp,pcf8563";
+   reg = <0x51>;
+   };
+};
+
+ {
+   status = "okay";
+};
+
+ {
+   status = "disabled";
+};
+
+ {
+   status = "okay";
+};
+
+ {
+   status = "okay";
+};
+
+/* Exported on the micro USB connector through an FTDI */
+ {
+   status = "okay";
+};
+
+ {
+   status = "okay";

[PATCH v3 1/3] arm: mvebu: mvebu_armada-37xx: Implement the mac command (Marvell hw_info)

2021-08-12 Thread Luka Kovacic
The mac command is implemented to enable parsing Marvell hw_info formatted
environments. This format is often used on Marvell Armada A37XX based
devices to store parameters like the board serial number, factory
MAC addresses and some other information.
These parameters are usually written to the flash in the factory.

Currently the mac command supports reading/writing parameters and dumping
the current hw_info parameters.
EEPROM config pattern and checksum aren't supported.

This functionality has been tested on the GST ESPRESSOBin-Ultra board
successfully, both reading the stock U-Boot parameters in mainline U-Boot
and reading the parameters written by this command in the stock U-Boot.

Usage example:
 => mac read
 => saveenv

Signed-off-by: Luka Kovacic 
Cc: Luka Perkov 
Cc: Robert Marko 
---
 arch/arm/mach-mvebu/Kconfig   |   1 +
 board/Marvell/mvebu_armada-37xx/Kconfig   |  29 ++
 board/Marvell/mvebu_armada-37xx/Makefile  |   3 +-
 board/Marvell/mvebu_armada-37xx/mac/Makefile  |   5 +
 board/Marvell/mvebu_armada-37xx/mac/hw_info.c | 391 ++
 include/configs/mvebu_armada-37xx.h   |   7 +
 lib/hashtable.c   |   2 +-
 7 files changed, 436 insertions(+), 2 deletions(-)
 create mode 100644 board/Marvell/mvebu_armada-37xx/Kconfig
 create mode 100644 board/Marvell/mvebu_armada-37xx/mac/Makefile
 create mode 100644 board/Marvell/mvebu_armada-37xx/mac/hw_info.c

diff --git a/arch/arm/mach-mvebu/Kconfig b/arch/arm/mach-mvebu/Kconfig
index 89737a37ad..dff9f05b28 100644
--- a/arch/arm/mach-mvebu/Kconfig
+++ b/arch/arm/mach-mvebu/Kconfig
@@ -312,6 +312,7 @@ config SECURED_MODE_CSK_INDEX
default 0
depends on SECURED_MODE_IMAGE
 
+source "board/Marvell/mvebu_armada-37xx/Kconfig"
 source "board/solidrun/clearfog/Kconfig"
 source "board/kobol/helios4/Kconfig"
 
diff --git a/board/Marvell/mvebu_armada-37xx/Kconfig 
b/board/Marvell/mvebu_armada-37xx/Kconfig
new file mode 100644
index 00..b84dd20023
--- /dev/null
+++ b/board/Marvell/mvebu_armada-37xx/Kconfig
@@ -0,0 +1,29 @@
+menu "Marvell Armada 37xx configuration"
+depends on TARGET_MVEBU_ARMADA_37XX
+
+config MVEBU_MAC_HW_INFO
+   bool "Marvell hw_info (mac) support"
+   depends on SPI_FLASH && ENV_IS_IN_SPI_FLASH && ARCH_MVEBU
+   default n
+   help
+ Enable loading of the Marvell hw_info parameters from the
+ SPI flash hw_info area. Parameters (usually the board serial
+ number and MAC addresses) are then imported into the
+ existing U-Boot environment.
+ Implementation of this command is compatible with the
+ original Marvell U-Boot command. Reading and writing is
+ supported.
+ EEPROM config pattern and checksum aren't supported.
+ After enabled, these parameters are managed from the common
+ U-Boot mac command.
+
+config MVEBU_MAC_HW_INFO_OFFSET
+   hex "Marvell hw_info (mac) SPI flash offset"
+   depends on MVEBU_MAC_HW_INFO
+   default 0x3E
+   help
+ This option defines the SPI flash offset of the Marvell
+ hw_info area. This defaults to 0x3E on most Armada
+ A3720 platforms.
+
+endmenu
diff --git a/board/Marvell/mvebu_armada-37xx/Makefile 
b/board/Marvell/mvebu_armada-37xx/Makefile
index 27221557c7..6f6ac6b193 100644
--- a/board/Marvell/mvebu_armada-37xx/Makefile
+++ b/board/Marvell/mvebu_armada-37xx/Makefile
@@ -2,4 +2,5 @@
 #
 # Copyright (C) 2016 Stefan Roese 
 
-obj-y  := board.o
+obj-y += board.o
+obj-y += mac/
diff --git a/board/Marvell/mvebu_armada-37xx/mac/Makefile 
b/board/Marvell/mvebu_armada-37xx/mac/Makefile
new file mode 100644
index 00..7c30fe6194
--- /dev/null
+++ b/board/Marvell/mvebu_armada-37xx/mac/Makefile
@@ -0,0 +1,5 @@
+# SPDX-License-Identifier: GPL-2.0+
+#
+# Copyright (c) 2021 Sartura Ltd.
+
+obj-$(CONFIG_ID_EEPROM) += hw_info.o
diff --git a/board/Marvell/mvebu_armada-37xx/mac/hw_info.c 
b/board/Marvell/mvebu_armada-37xx/mac/hw_info.c
new file mode 100644
index 00..91e5cd8dcf
--- /dev/null
+++ b/board/Marvell/mvebu_armada-37xx/mac/hw_info.c
@@ -0,0 +1,391 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Marvell hw_info (mac) command implementation
+ * Helper command for interfacing with the Marvell hw_info parameters
+ *
+ * Copyright (c) 2021 Sartura Ltd.
+ * Copyright (c) 2018 Marvell International Ltd.
+ *
+ * Author: Luka Kovacic 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define HW_INFO_SPI_FLASH_OFFSET   CONFIG_MVEBU_MAC_HW_INFO_OFFSET
+
+#define HW_INFO_MAX_ENV_SIZE   0x1F0
+#define HW_INFO_ENV_OFFSET 0xA
+#define HW_INFO_ENV_SEP0x20
+
+#define HW_INFO_MAX_NAME_LEN   32
+
+#define HW_INFO_MERGED_VARIABLE"read_board_hw_info"
+
+static char hw_info_allowed_parameters[][HW_INF

[PATCH v3 2/3] arm: mvebu: mvebu_armada-37xx: Define the loadaddr environment variable

2021-08-12 Thread Luka Kovacic
Add the loadaddr U-Boot environment variable, as this is available in
the stock Marvell U-Boot by default on Marvell Armada A37XX platforms.

Signed-off-by: Luka Kovacic 
Cc: Luka Perkov 
Cc: Robert Marko 
---
 include/configs/mvebu_armada-37xx.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/configs/mvebu_armada-37xx.h 
b/include/configs/mvebu_armada-37xx.h
index 8e8bcfa018..6901680e32 100644
--- a/include/configs/mvebu_armada-37xx.h
+++ b/include/configs/mvebu_armada-37xx.h
@@ -110,6 +110,7 @@
 
 /* fdt_addr and kernel_addr are needed for existing distribution boot scripts 
*/
 #define CONFIG_EXTRA_ENV_SETTINGS  \
+   "loadaddr=0x600\0"  \
"scriptaddr=0x6d0\0"\
"pxefile_addr_r=0x6e0\0"\
"fdt_addr=0x6f0\0"  \
-- 
2.31.1



[PATCH v3 0/3] Add support for the GST ESPRESSOBin-Ultra board

2021-08-12 Thread Luka Kovacic
This patchset adds initial support for the ESPRESSOBin-Ultra board from
Globalscale Technologies, Inc.

The board is based on the 64-bit dual-core Marvell Armada 3720 SoC.
Peripherals:
 - 5 Gigabit Ethernet ports (WAN has PoE, up to 30W, Topaz 6341 switch)
 - RTC clock (PCF8563)
 - USB 3.0 port
 - USB 2.0 port
 - 4x LED
 - UART over Micro-USB
 - M.2 slot (2280)
 - Mini PCI-E slot

Additionally support for importing Marvell hw_info formatted environments
is added to fully support the board.

Changes for v3:
  - Use the common mac command instead of the vendor specific hw_info
  - Clean up the device tree to use a dtsi, like in Linux
  - Sync the defconfig with the latest mainline changes

Luka Kovacic (3):
  arm: mvebu: mvebu_armada-37xx: Implement the mac command (Marvell
hw_info)
  arm: mvebu: mvebu_armada-37xx: Define the loadaddr environment
variable
  arm: mvebu: Initial ESPRESSOBin-Ultra board support

 arch/arm/dts/Makefile |   1 +
 .../arm/dts/armada-3720-espressobin-ultra.dts | 114 +
 arch/arm/dts/armada-3720-espressobin.dts  | 199 +
 arch/arm/dts/armada-3720-espressobin.dtsi | 210 ++
 arch/arm/mach-mvebu/Kconfig   |   1 +
 board/Marvell/mvebu_armada-37xx/Kconfig   |  29 ++
 board/Marvell/mvebu_armada-37xx/MAINTAINERS   |   8 +
 board/Marvell/mvebu_armada-37xx/Makefile  |   3 +-
 board/Marvell/mvebu_armada-37xx/board.c   |  92 -
 board/Marvell/mvebu_armada-37xx/mac/Makefile  |   5 +
 board/Marvell/mvebu_armada-37xx/mac/hw_info.c | 391 ++
 .../mvebu_espressobin-ultra-88f3720_defconfig |  93 +
 include/configs/mvebu_armada-37xx.h   |   8 +
 lib/hashtable.c   |   2 +-
 14 files changed, 951 insertions(+), 205 deletions(-)
 create mode 100644 arch/arm/dts/armada-3720-espressobin-ultra.dts
 create mode 100644 arch/arm/dts/armada-3720-espressobin.dtsi
 create mode 100644 board/Marvell/mvebu_armada-37xx/Kconfig
 create mode 100644 board/Marvell/mvebu_armada-37xx/mac/Makefile
 create mode 100644 board/Marvell/mvebu_armada-37xx/mac/hw_info.c
 create mode 100644 configs/mvebu_espressobin-ultra-88f3720_defconfig

-- 
2.31.1



Re: [PATCH 1/3] cmd: mvebu: Implement the Marvell hw_info command

2021-08-11 Thread Luka Kovacic
Hi Gerald,

On Wed, Aug 11, 2021 at 10:35 AM Gerald Kerma  wrote:
>
> From: Kerma Gérald 
>
> The hw_info command is implemented to enable parsing Marvell hw_info
> formatted environments. This format is often used on Marvell Armada A37XX
> based devices to store parameters like the board serial number, factory
> MAC addresses and some other information.
> These parameters are usually written to the flash in the factory.
>
> Currently the command supports reading/writing parameters and dumping the
> current hw_info parameters.
> EEPROM config pattern and checksum aren't supported.
>
> This functionality has been tested on the GST ESPRESSOBin-Ultra board
> successfully, both reading the stock U-Boot parameters in mainline U-Boot
> and reading the parameters written by this command in the stock U-Boot.
>
> Usage example:
>  => hw_info load
>  => saveenv
>
> Signed-off-by: Kerma Gérald 

This patch series has been resent and you have with an exception of a small
PHY -> COMPHY change just "rebranded" the patches and used your SoB, without
acknowledging the previous work.

Link to the original patchset:
https://patchwork.ozlabs.org/project/uboot/list/?series=229617

A new patchset will be sent today, which refactors the original patches.

> Cc: Luka Kovacic 
> Cc: Luka Perkov 
> Cc: Robert Marko 
> ---
>  cmd/mvebu/Kconfig   |  23 
>  cmd/mvebu/Makefile  |   2 +
>  cmd/mvebu/hw_info.c | 312 
>  lib/hashtable.c |   2 +-
>  4 files changed, 338 insertions(+), 1 deletion(-)
>  create mode 100644 cmd/mvebu/hw_info.c
>
> diff --git a/cmd/mvebu/Kconfig b/cmd/mvebu/Kconfig
> index 7c42c75afb..d87220d44c 100644
> --- a/cmd/mvebu/Kconfig
> +++ b/cmd/mvebu/Kconfig
> @@ -9,6 +9,29 @@ config CMD_MVEBU_BUBT
>   For details about bubt command please see the documentation
>   in doc/mvebu/cmd/bubt.txt
>
> +config CMD_MVEBU_HW_INFO
> +   bool "hw_info"
> +   depends on SPI_FLASH && ENV_IS_IN_SPI_FLASH && ARCH_MVEBU
> +   default n
> +   help
> + Enable loading of the Marvell hw_info parameters from the
> + SPI flash hw_info area. Parameters (usually the board serial
> + number and MAC addresses) are then imported into the
> + existing U-Boot environment.
> + Implementation of this command is compatible with the
> + original Marvell U-Boot command. Reading and writing is
> + supported.
> + EEPROM config pattern and checksum aren't supported.
> +
> +config CMD_MVEBU_HW_INFO_OFFSET
> +   hex "Marvell hw_info SPI flash offset"
> +   depends on CMD_MVEBU_HW_INFO
> +   default 0x3E
> +   help
> + This option defines the SPI flash offset of the Marvell
> + hw_info area. This defaults to 0x3E on most Armada
> + A3720 platforms.
> +
>  choice
> prompt "Flash for image"
> default MVEBU_SPI_BOOT
> diff --git a/cmd/mvebu/Makefile b/cmd/mvebu/Makefile
> index ca96ad01d9..c988dca38c 100644
> --- a/cmd/mvebu/Makefile
> +++ b/cmd/mvebu/Makefile
> @@ -6,3 +6,5 @@
>
>  obj-$(CONFIG_CMD_MVEBU_BUBT) += bubt.o
>  obj-$(CONFIG_CMD_MVEBU_COMPHY_RX_TRAINING) += comphy_rx_training.o
> +obj-$(CONFIG_CMD_MVEBU_HW_INFO) += hw_info.o
> +
> diff --git a/cmd/mvebu/hw_info.c b/cmd/mvebu/hw_info.c
> new file mode 100644
> index 00..1ef49d78d4
> --- /dev/null
> +++ b/cmd/mvebu/hw_info.c
> @@ -0,0 +1,312 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * Marvell hw_info command
> + * Helper command for interfacing with the Marvell hw_info parameters
> + *
> + * Copyright (c) 2021 Sartura Ltd.
> + * Copyright (c) 2018 Marvell International Ltd.
> + *
> + * Author: Luka Kovacic 
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#define HW_INFO_SPI_FLASH_OFFSET   CONFIG_CMD_MVEBU_HW_INFO_OFFSET
> +
> +#define HW_INFO_MAX_ENV_SIZE   0x1F0
> +#define HW_INFO_ENV_OFFSET 0xA
> +#define HW_INFO_ENV_SEP0x20
> +
> +#define HW_INFO_MAX_NAME_LEN   32
> +
> +static char hw_info_allowed_parameters[][HW_INFO_MAX_NAME_LEN] = {
> +   "pcb_slm",
> +   "pcb_rev",
> +   "eco_rev",
> +   "pcb_sn",
> +   "ethaddr",
> +   "eth1addr",
> +   "eth2addr",
> +   "eth3addr",
> +   "eth4addr",
> +   "eth5addr",
> +   "eth6addr",
> +   "eth7addr",
> +   "eth8addr",

Re: [PATCH v2 1/3] cmd: mvebu: Implement the Marvell hw_info command

2021-02-28 Thread Luka Kovacic
Hello Marek,

On Sat, Feb 27, 2021 at 2:05 PM Marek Behun  wrote:
>
> Luka, Tom,
>
> I am very against this.
>
> there already is `mac` command in cmd/mac.c with following help
>display and program the system ID and MAC addresses in EEPROM
>[read|save|id|num|errata|date|ports|port_number]
>mac read
>- read EEPROM content into memory data structure
>mac save
>- save memory data structure to the EEPROM
>mac id
>- program system id per hard coded value
>mac num string
>- program system serial number to value string
>mac errata string
>- program errata data to value string
>mac date YYMMDDhhmmss
>- program date to string value YYMMDDhhmmss
>mac ports N
>- program the number of network ports to integer N
>mac X string
>- program MAC addr for port X [X=0,1..] to colon separated string"
>
> Why introducing new, vendor specific commands, when we have a global
> API for such a thing?

I have to admit, I wasn't aware that this command existed.

I will transfer the implementation of the hw_info command into this existing
framework, I completely agree that this is a better solution.
Also when the "mac read" command would be executed, I'd also transfer
all of the other OEM values to the environment (the MACs and the 4
additional values).

Also I'll check how the current implementation is done in some of the boards.

Kind regards,
Luka

>
> Marek


Re: [PATCH v2 1/3] cmd: mvebu: Implement the Marvell hw_info command

2021-02-28 Thread Luka Kovacic
Hello Pali,

On Sat, Feb 27, 2021 at 2:09 AM Pali Rohár  wrote:
>
> On Monday 15 February 2021 20:59:32 Luka Kovacic wrote:
> > The hw_info command is implemented to enable parsing Marvell hw_info
> > formatted environments. This format is often used on Marvell Armada A37XX
> > based devices to store parameters like the board serial number, factory
> > MAC addresses and some other information.
> > These parameters are usually written to the flash in the factory.
>
> CCing Marek, as he does not like introduction of another vendor custom
> command into mainline U-Boot.
>
> > Currently the command supports reading/writing parameters and dumping the
> > current hw_info parameters.
> > EEPROM config pattern and checksum aren't supported.
> >
> > This functionality has been tested on the GST ESPRESSOBin-Ultra board
> > successfully, both reading the stock U-Boot parameters in mainline U-Boot
> > and reading the parameters written by this command in the stock U-Boot.
> >
> > Usage example:
> >  => hw_info load
> >  => saveenv
>
> I'm looking at the code and it loads MAC addresses for espressobin
> ultra variant. But for other espressobin variants there is already code
> which sets correct eth*addr and fdtfile variables in board_late_init()
> function.
>
> I think it should be relatively easy to implement reading these
> variables from SPI to ENV in board_late_init() function. Which would
> mean that it completely replaces this custom 'hw_info load' command.

The board.c file looked really cluttered to me in the current state and
adding more board-specific code wouldn't help it.
Also there are some other potentially useful parameters in the hw_info
SPI flash area, which might be of use (board serial number and some
other values).

>
> Could you look at it? This would have a benefit that 'env default -a'
> would always load correct mac addresses stored in SPI, so it would work
> just via default u-boot commands without need to use something vendor
> specific.

I do agree that a vendor specific solution isn't too elegant.
I might consider the mac command, which Marek has suggested.

Kind regards,
Luka

>
> > Signed-off-by: Luka Kovacic 
> > Cc: Luka Perkov 
> > Cc: Robert Marko 
> > Reviewed-by: Tom Rini 
> > ---
> >  cmd/mvebu/Kconfig   |  23 
> >  cmd/mvebu/Makefile  |   1 +
> >  cmd/mvebu/hw_info.c | 312 
> >  lib/hashtable.c |   2 +-
> >  4 files changed, 337 insertions(+), 1 deletion(-)
> >  create mode 100644 cmd/mvebu/hw_info.c
> >
> > diff --git a/cmd/mvebu/Kconfig b/cmd/mvebu/Kconfig
> > index ad10a572a3..a8e958e7c8 100644
> > --- a/cmd/mvebu/Kconfig
> > +++ b/cmd/mvebu/Kconfig
> > @@ -9,6 +9,29 @@ config CMD_MVEBU_BUBT
> > For details about bubt command please see the documentation
> > in doc/mvebu/cmd/bubt.txt
> >
> > +config CMD_MVEBU_HW_INFO
> > + bool "hw_info"
> > + depends on SPI_FLASH && ENV_IS_IN_SPI_FLASH && ARCH_MVEBU
> > + default n
> > + help
> > +   Enable loading of the Marvell hw_info parameters from the
> > +   SPI flash hw_info area. Parameters (usually the board serial
> > +   number and MAC addresses) are then imported into the
> > +   existing U-Boot environment.
> > +   Implementation of this command is compatible with the
> > +   original Marvell U-Boot command. Reading and writing is
> > +   supported.
> > +   EEPROM config pattern and checksum aren't supported.
> > +
> > +config CMD_MVEBU_HW_INFO_OFFSET
> > + hex "Marvell hw_info SPI flash offset"
> > + depends on CMD_MVEBU_HW_INFO
> > + default 0x3E
> > + help
> > +   This option defines the SPI flash offset of the Marvell
> > +   hw_info area. This defaults to 0x3E on most Armada
> > +   A3720 platforms.
> > +
> >  choice
> >   prompt "Flash for image"
> >   default MVEBU_SPI_BOOT
> > diff --git a/cmd/mvebu/Makefile b/cmd/mvebu/Makefile
> > index 96829c48eb..2b5a8b37be 100644
> > --- a/cmd/mvebu/Makefile
> > +++ b/cmd/mvebu/Makefile
> > @@ -6,3 +6,4 @@
> >
> >
> >  obj-$(CONFIG_CMD_MVEBU_BUBT) += bubt.o
> > +obj-$(CONFIG_CMD_MVEBU_HW_INFO) += hw_info.o
> > diff --git a/cmd/mvebu/hw_info.c b/cmd/mvebu/hw_info.c
> > new file mode 100644
> > index 00..1ef49d78d4
> > --- /dev/null
> > +++ b/cmd/mvebu/hw_info.c
> > @@ -0,0 +1,312 @@
> > +// SPDX-License-Identifier: GPL-2.0+
> > +

Re: [PATCH v2 3/3] arm: mvebu: Initial ESPRESSOBin-Ultra board support

2021-02-28 Thread Luka Kovacic
Hello Marek,

On Sat, Feb 27, 2021 at 2:24 PM Marek Behun  wrote:
>
> In Linux the DTS for espressobin-ultra includes
> armada-3720-espressobin.dtsi and just adds changes.
>
> If possible, please do this as is done in Linux. In fact we want to
> slowly move in the direction to have the dts files just copied from
> Linux.
>
> Marek

Thanks for pointing this out.
As you and Pali have suggested, I will rework this patch to be as
close to the Linux dts as possible.

I'd go with the approach of just creating a dts with changes with
respect to the base ESPRESSOBin.

Kind regards,
Luka


Re: [PATCH v2 2/3] arm: mvebu: mvebu_armada-37xx: Define the loadaddr environment variable

2021-02-28 Thread Luka Kovacic
Hello Pali,

On Sat, Feb 27, 2021 at 1:38 AM Pali Rohár  wrote:
>
> On Monday 15 February 2021 20:59:33 Luka Kovacic wrote:
> > Add the loadaddr U-Boot environment variable, as this is available in
> > the stock Marvell U-Boot by default on Marvell Armada A37XX platforms.
>
> Hello Luka! Why is this change needed? mvebu_armada-37xx.h already
> defines CONFIG_SYS_LOAD_ADDR macro with its default value 0x0600.
> So defining loadaddr variable should not be needed at all. And it is
> suspicious for me why definition is to the same default value.

I've added this to the environment, because it was not present in
U-Boot as a variable.
There's a need for this value in some scripts, are you aware of some
other way to retrieve it easily?
Some other boards also do this similarly.

Kind regards,
Luka
>
> > Signed-off-by: Luka Kovacic 
> > Cc: Luka Perkov 
> > Cc: Robert Marko 
> > ---
> >  include/configs/mvebu_armada-37xx.h | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/include/configs/mvebu_armada-37xx.h 
> > b/include/configs/mvebu_armada-37xx.h
> > index 2ad4325eaf..1041df8d91 100644
> > --- a/include/configs/mvebu_armada-37xx.h
> > +++ b/include/configs/mvebu_armada-37xx.h
> > @@ -103,6 +103,7 @@
> >
> >  /* fdt_addr and kernel_addr are needed for existing distribution boot 
> > scripts */
> >  #define CONFIG_EXTRA_ENV_SETTINGS\
> > + "loadaddr=0x600\0"  \
> >   "scriptaddr=0x6d0\0"\
> >   "pxefile_addr_r=0x6e0\0"\
> >   "fdt_addr=0x6f0\0"  \


[PATCH v2 3/3] arm: mvebu: Initial ESPRESSOBin-Ultra board support

2021-02-15 Thread Luka Kovacic
Add initial support for the ESPRESSOBin-Ultra board from Globalscale
Technologies, Inc.

The board is based on the 64-bit dual-core Marvell Armada 3720 SoC.
Peripherals:
 - 5 Gigabit Ethernet ports (WAN has PoE, up to 30W, Topaz 6341 switch)
 - RTC clock (PCF8563)
 - USB 3.0 port
 - USB 2.0 port
 - 4x LED
 - UART over Micro-USB
 - M.2 slot (2280)
 - Mini PCI-E slot

Additionally, automatic import of the Marvell hw_info parameters is
enabled via the recently added hw_info command.
The parameters stored in Marvell hw_info are usually the board serial
number and MAC addresses.

Signed-off-by: Luka Kovacic 
Cc: Luka Perkov 
Cc: Robert Marko 
---
 arch/arm/dts/Makefile |   1 +
 .../arm/dts/armada-3720-espressobin-ultra.dts | 202 ++
 board/Marvell/mvebu_armada-37xx/MAINTAINERS   |   8 +
 board/Marvell/mvebu_armada-37xx/board.c   |  92 +++-
 .../mvebu_espressobin-ultra-88f3720_defconfig |  92 
 5 files changed, 389 insertions(+), 6 deletions(-)
 create mode 100644 arch/arm/dts/armada-3720-espressobin-ultra.dts
 create mode 100644 configs/mvebu_espressobin-ultra-88f3720_defconfig

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 33e483f4fb..9f544b1caf 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -208,6 +208,7 @@ dtb-$(CONFIG_ARCH_TEGRA) += tegra20-harmony.dtb \
 dtb-$(CONFIG_ARCH_MVEBU) +=\
armada-3720-db.dtb  \
armada-3720-espressobin.dtb \
+   armada-3720-espressobin-ultra.dtb   \
armada-3720-turris-mox.dtb  \
armada-3720-uDPU.dtb\
armada-375-db.dtb   \
diff --git a/arch/arm/dts/armada-3720-espressobin-ultra.dts 
b/arch/arm/dts/armada-3720-espressobin-ultra.dts
new file mode 100644
index 00..70f97fe239
--- /dev/null
+++ b/arch/arm/dts/armada-3720-espressobin-ultra.dts
@@ -0,0 +1,202 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Device Tree file for ESPRESSObin-Ultra board
+ * Copyright (C) 2016 Marvell
+ * Copyright (C) 2019 Globalscale technologies, Inc.
+ * Copyright (C) 2020 Sartura Ltd.
+ *
+ * Author: Jason Hung 
+ * Author: Luka Kovacic 
+ * Author: Vladimir Vid 
+ */
+
+/dts-v1/;
+
+#include "armada-372x.dtsi"
+
+/ {
+   model = "Globalscale Marvell ESPRESSOBin Ultra Board";
+   compatible = "globalscale,espressobin-ultra", "marvell,armada3720", 
"marvell,armada3710";
+
+   chosen {
+   stdout-path = "serial0:115200n8";
+   };
+
+   aliases {
+   ethernet0 = 
+   i2c0 = 
+   spi0 = 
+   };
+
+   memory {
+   device_type = "memory";
+   reg = <0x 0x 0x 0x2000>;
+   };
+
+   vcc_sd_reg0: regulator@0 {
+   compatible = "regulator-gpio";
+   regulator-name = "vcc_sd0";
+   regulator-min-microvolt = <180>;
+   regulator-max-microvolt = <330>;
+   regulator-type = "voltage";
+   states = <180 0x1
+ 330 0x0>;
+   gpios = < 4 GPIO_ACTIVE_HIGH>;
+   };
+
+   gpio-leds {
+   pinctrl-names = "default";
+   pinctrl-0 = <_pins>, <_pins>, <_pins>, 
<_pins>;
+   compatible = "gpio-leds";
+
+   led1 {
+   label = "led1";
+   gpios = < 11 GPIO_ACTIVE_LOW>;
+   default-state = "on";
+   };
+   led2 {
+   label = "led2";
+   gpios = < 12 GPIO_ACTIVE_LOW>;
+   default-state = "on";
+   };
+   led3 {
+   label = "led3";
+   gpios = < 13 GPIO_ACTIVE_LOW>;
+   default-state = "on";
+   };
+   led4 {
+   label = "led4";
+   gpios = < 14 GPIO_ACTIVE_LOW>;
+   default-state = "on";
+   };
+   };
+};
+
+_nb {
+   led1_pins: led1-pins {
+   groups = "pwm0";
+   function = "gpio";
+   };
+   led2_pins: led2-pins {
+   groups = "pwm1";
+   function = "gpio";
+   };
+   led3_pins: led3-pins {
+   groups = "pwm2";
+   function = "gpio";
+   };
+   led4_pins: led4-pins {
+   groups = "pwm3";
+   function = "gpio";
+   };
+};
+
+ {
+   max-lanes = <3>;

[PATCH v2 1/3] cmd: mvebu: Implement the Marvell hw_info command

2021-02-15 Thread Luka Kovacic
The hw_info command is implemented to enable parsing Marvell hw_info
formatted environments. This format is often used on Marvell Armada A37XX
based devices to store parameters like the board serial number, factory
MAC addresses and some other information.
These parameters are usually written to the flash in the factory.

Currently the command supports reading/writing parameters and dumping the
current hw_info parameters.
EEPROM config pattern and checksum aren't supported.

This functionality has been tested on the GST ESPRESSOBin-Ultra board
successfully, both reading the stock U-Boot parameters in mainline U-Boot
and reading the parameters written by this command in the stock U-Boot.

Usage example:
 => hw_info load
 => saveenv

Signed-off-by: Luka Kovacic 
Cc: Luka Perkov 
Cc: Robert Marko 
---
 cmd/mvebu/Kconfig   |  23 
 cmd/mvebu/Makefile  |   1 +
 cmd/mvebu/hw_info.c | 312 
 lib/hashtable.c |   2 +-
 4 files changed, 337 insertions(+), 1 deletion(-)
 create mode 100644 cmd/mvebu/hw_info.c

diff --git a/cmd/mvebu/Kconfig b/cmd/mvebu/Kconfig
index ad10a572a3..a8e958e7c8 100644
--- a/cmd/mvebu/Kconfig
+++ b/cmd/mvebu/Kconfig
@@ -9,6 +9,29 @@ config CMD_MVEBU_BUBT
  For details about bubt command please see the documentation
  in doc/mvebu/cmd/bubt.txt
 
+config CMD_MVEBU_HW_INFO
+   bool "hw_info"
+   depends on SPI_FLASH && ENV_IS_IN_SPI_FLASH && ARCH_MVEBU
+   default n
+   help
+ Enable loading of the Marvell hw_info parameters from the
+ SPI flash hw_info area. Parameters (usually the board serial
+ number and MAC addresses) are then imported into the
+ existing U-Boot environment.
+ Implementation of this command is compatible with the
+ original Marvell U-Boot command. Reading and writing is
+ supported.
+ EEPROM config pattern and checksum aren't supported.
+
+config CMD_MVEBU_HW_INFO_OFFSET
+   hex "Marvell hw_info SPI flash offset"
+   depends on CMD_MVEBU_HW_INFO
+   default 0x3E
+   help
+ This option defines the SPI flash offset of the Marvell
+ hw_info area. This defaults to 0x3E on most Armada
+ A3720 platforms.
+
 choice
prompt "Flash for image"
default MVEBU_SPI_BOOT
diff --git a/cmd/mvebu/Makefile b/cmd/mvebu/Makefile
index 96829c48eb..2b5a8b37be 100644
--- a/cmd/mvebu/Makefile
+++ b/cmd/mvebu/Makefile
@@ -6,3 +6,4 @@
 
 
 obj-$(CONFIG_CMD_MVEBU_BUBT) += bubt.o
+obj-$(CONFIG_CMD_MVEBU_HW_INFO) += hw_info.o
diff --git a/cmd/mvebu/hw_info.c b/cmd/mvebu/hw_info.c
new file mode 100644
index 00..1ef49d78d4
--- /dev/null
+++ b/cmd/mvebu/hw_info.c
@@ -0,0 +1,312 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Marvell hw_info command
+ * Helper command for interfacing with the Marvell hw_info parameters
+ *
+ * Copyright (c) 2021 Sartura Ltd.
+ * Copyright (c) 2018 Marvell International Ltd.
+ *
+ * Author: Luka Kovacic 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define HW_INFO_SPI_FLASH_OFFSET   CONFIG_CMD_MVEBU_HW_INFO_OFFSET
+
+#define HW_INFO_MAX_ENV_SIZE   0x1F0
+#define HW_INFO_ENV_OFFSET 0xA
+#define HW_INFO_ENV_SEP0x20
+
+#define HW_INFO_MAX_NAME_LEN   32
+
+static char hw_info_allowed_parameters[][HW_INFO_MAX_NAME_LEN] = {
+   "pcb_slm",
+   "pcb_rev",
+   "eco_rev",
+   "pcb_sn",
+   "ethaddr",
+   "eth1addr",
+   "eth2addr",
+   "eth3addr",
+   "eth4addr",
+   "eth5addr",
+   "eth6addr",
+   "eth7addr",
+   "eth8addr",
+   "eth9addr",
+};
+
+static int hw_info_allowed_param_count = (sizeof(hw_info_allowed_parameters) /
+   sizeof(hw_info_allowed_parameters[0]));
+
+static int hw_info_check_parameter(char *name)
+{
+   int idx;
+
+   for (idx = 0; idx < hw_info_allowed_param_count; idx++) {
+   if (strcmp(name, hw_info_allowed_parameters[idx]) == 0)
+   return 0;
+   }
+
+   return -EINVAL;
+}
+
+static int read_spi_flash_offset(char *buf, int offset)
+{
+   struct spi_flash *flash;
+   int ret;
+
+   flash = spi_flash_probe(CONFIG_SF_DEFAULT_BUS,
+   CONFIG_SF_DEFAULT_CS,
+   CONFIG_SF_DEFAULT_SPEED,
+   CONFIG_SF_DEFAULT_MODE);
+
+   if (!flash) {
+   printf("Error - unable to probe SPI flash.\n");
+   return -EIO;
+   }
+
+   ret = spi_flash_read(flash, offset, HW_INFO_MAX_ENV_SIZE, buf);
+   if (ret) {
+   printf("Error - unable to read hw_info environment from SPI 
flash.\n&quo

[PATCH v2 2/3] arm: mvebu: mvebu_armada-37xx: Define the loadaddr environment variable

2021-02-15 Thread Luka Kovacic
Add the loadaddr U-Boot environment variable, as this is available in
the stock Marvell U-Boot by default on Marvell Armada A37XX platforms.

Signed-off-by: Luka Kovacic 
Cc: Luka Perkov 
Cc: Robert Marko 
---
 include/configs/mvebu_armada-37xx.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/configs/mvebu_armada-37xx.h 
b/include/configs/mvebu_armada-37xx.h
index 2ad4325eaf..1041df8d91 100644
--- a/include/configs/mvebu_armada-37xx.h
+++ b/include/configs/mvebu_armada-37xx.h
@@ -103,6 +103,7 @@
 
 /* fdt_addr and kernel_addr are needed for existing distribution boot scripts 
*/
 #define CONFIG_EXTRA_ENV_SETTINGS  \
+   "loadaddr=0x600\0"  \
"scriptaddr=0x6d0\0"\
"pxefile_addr_r=0x6e0\0"\
"fdt_addr=0x6f0\0"  \
-- 
2.20.1



[PATCH v2 0/3] Add support for the GST ESPRESSOBin-Ultra board

2021-02-15 Thread Luka Kovacic
This patchset adds initial support for the ESPRESSOBin-Ultra board from
Globalscale Technologies, Inc.

The board is based on the 64-bit dual-core Marvell Armada 3720 SoC.
Peripherals:
 - 5 Gigabit Ethernet ports (WAN has PoE, up to 30W, Topaz 6341 switch)
 - RTC clock (PCF8563)
 - USB 3.0 port
 - USB 2.0 port
 - 4x LED
 - UART over Micro-USB
 - M.2 slot (2280)
 - Mini PCI-E slot

Additionally support for importing Marvell hw_info formatted environments
is added to fully support the board.

Luka Kovacic (3):
  cmd: mvebu: Implement the Marvell hw_info command
  arm: mvebu: mvebu_armada-37xx: Define the loadaddr environment
variable
  arm: mvebu: Initial ESPRESSOBin-Ultra board support

 arch/arm/dts/Makefile |   1 +
 .../arm/dts/armada-3720-espressobin-ultra.dts | 202 
 board/Marvell/mvebu_armada-37xx/MAINTAINERS   |   8 +
 board/Marvell/mvebu_armada-37xx/board.c   |  92 +-
 cmd/mvebu/Kconfig |  23 ++
 cmd/mvebu/Makefile|   1 +
 cmd/mvebu/hw_info.c   | 312 ++
 .../mvebu_espressobin-ultra-88f3720_defconfig |  92 ++
 include/configs/mvebu_armada-37xx.h   |   1 +
 lib/hashtable.c   |   2 +-
 10 files changed, 727 insertions(+), 7 deletions(-)
 create mode 100644 arch/arm/dts/armada-3720-espressobin-ultra.dts
 create mode 100644 cmd/mvebu/hw_info.c
 create mode 100644 configs/mvebu_espressobin-ultra-88f3720_defconfig

-- 
2.20.1



Re: [PATCH 1/3] cmd: env: Add 'env import -h' for Marvell hw_info formatted environments

2021-02-05 Thread Luka Kovacic
On Fri, Feb 5, 2021 at 11:40 PM Tom Rini  wrote:
>
> On Fri, Feb 05, 2021 at 11:36:25PM +0100, Luka Kovacic wrote:
> > On Fri, Feb 5, 2021 at 11:04 PM Tom Rini  wrote:
> > >
> > > On Fri, Feb 05, 2021 at 11:02:23PM +0100, Luka Kovacic wrote:
> > > > Hello Tom,
> > > >
> > > > On Thu, Feb 4, 2021 at 6:06 PM Tom Rini  wrote:
> > > > >
> > > > > On Thu, Feb 04, 2021 at 11:46:35AM +0100, Luka Kovacic wrote:
> > > > >
> > > > > > The '-h' flag is added to the 'env import' command to enable parsing
> > > > > > Marvell hw_info formatted environments.
> > > > > > This format is often used on Marvell Armada A37XX based devices to 
> > > > > > store
> > > > > > parameters like the board serial number, factory MAC addresses and 
> > > > > > some
> > > > > > other information.
> > > > > >
> > > > > > Currently this environment format can only be imported, not 
> > > > > > exported.
> > > > > > These parameters are usually written to the flash in the factory.
> > > > > >
> > > > > > This functionality has been tested on the GST ESPRESSOBin-Ultra 
> > > > > > board
> > > > > > successfully.
> > > > > >
> > > > > > Usage example:
> > > > > >  => sf probe
> > > > > >  => sf read ${loadaddr} 0x003E000A 0x1F0 # Read the environment from
> > > > > > SPI flash
> > > > > >  => env import -h ${loadaddr}
> > > > > >
> > > > > > Signed-off-by: Luka Kovacic 
> > > > > > Cc: Luka Perkov 
> > > > > > Cc: Robert Marko 
> > > > >
> > > > > So, the implementation itself is fine:
> > > > >
> > > > > Reviewed-by: Tom Rini 
> > > > >
> > > > > And I take it as a given that we can't get the boards populated with 
> > > > > an
> > > > > existing separator, so we need to solve this somehow or another.  I am
> > > > > however loathe to increase every platform by a handful of bytes (help
> > > > > text, code text) to cover this case, and adding #ifdef around the help
> > > > > text in particular would be very ugly. Is there any clean way to write
> > > > > this as a board-specific command?  I assume the overall intention is 
> > > > > to
> > > > > import the factory env for the required information, store it in 
> > > > > regular
> > > > > U-Boot environment and then never touch the factory area again.  
> > > > > Thanks!
> > > >
> > > > I have already considered the possibility of implementing this in a
> > > > board-specific way, but I tried implementing it here to avoid 
> > > > unnecessary
> > > > code duplication.
> > > > You are correct, the intention is to use this functionality as a 
> > > > migration
> > > > path. It's good to keep the factory area intact, in case it's still 
> > > > needed in
> > > > the future.
> > > > The Marvell hw_info area is limited to MACs and serial numbers by the
> > > > stock utility.
> > >
> > > OK.  And can we put this in the board-specific path somehow, relatively
> > > cleanly?
> >
> > I've been thinking about the following options:
> >  - Implementing a separate command under cmd/mvebu (hw_info), like done
> > in the stock U-Boot.
> > I'm not inclined to this one, as I don't see real utility in updating
> > this factory
> > area. A positive with this one is that it abstracts reading of the SPI 
> > flash.
> >
> >  - No command, automatic migration, directly from the SPI flash (implemented
> > in the board.c file.
> > I don't see this as a clean way of doing it, the Armada A37XX board.c is
> > already quite full of board-specific init.
> >
> >  - Implemented as is, but with #ifdef
> > This would break CONFIG_CMD_IMPORTENV into smaller pieces.
> > #ifdef wouldn't look too bad around the code, only the inline string changes
> > would be ugly.
> >
> > What would you recommend?
>
> I hate to say it but I prefer the first, especially if it ends up being
> like 50 lines of code or whatever to write the function and all that.
> Or the second option, if the first option really ends up being messy
> once you write it and the second one less messy.  Thanks!

Okay, I agree.

I think the first option should end up cleaner than both other options.
I'll do it this way.

>
> --
> Tom
Kind regards,
Luka


Re: [PATCH 1/3] cmd: env: Add 'env import -h' for Marvell hw_info formatted environments

2021-02-05 Thread Luka Kovacic
On Fri, Feb 5, 2021 at 11:04 PM Tom Rini  wrote:
>
> On Fri, Feb 05, 2021 at 11:02:23PM +0100, Luka Kovacic wrote:
> > Hello Tom,
> >
> > On Thu, Feb 4, 2021 at 6:06 PM Tom Rini  wrote:
> > >
> > > On Thu, Feb 04, 2021 at 11:46:35AM +0100, Luka Kovacic wrote:
> > >
> > > > The '-h' flag is added to the 'env import' command to enable parsing
> > > > Marvell hw_info formatted environments.
> > > > This format is often used on Marvell Armada A37XX based devices to store
> > > > parameters like the board serial number, factory MAC addresses and some
> > > > other information.
> > > >
> > > > Currently this environment format can only be imported, not exported.
> > > > These parameters are usually written to the flash in the factory.
> > > >
> > > > This functionality has been tested on the GST ESPRESSOBin-Ultra board
> > > > successfully.
> > > >
> > > > Usage example:
> > > >  => sf probe
> > > >  => sf read ${loadaddr} 0x003E000A 0x1F0 # Read the environment from
> > > > SPI flash
> > > >  => env import -h ${loadaddr}
> > > >
> > > > Signed-off-by: Luka Kovacic 
> > > > Cc: Luka Perkov 
> > > > Cc: Robert Marko 
> > >
> > > So, the implementation itself is fine:
> > >
> > > Reviewed-by: Tom Rini 
> > >
> > > And I take it as a given that we can't get the boards populated with an
> > > existing separator, so we need to solve this somehow or another.  I am
> > > however loathe to increase every platform by a handful of bytes (help
> > > text, code text) to cover this case, and adding #ifdef around the help
> > > text in particular would be very ugly. Is there any clean way to write
> > > this as a board-specific command?  I assume the overall intention is to
> > > import the factory env for the required information, store it in regular
> > > U-Boot environment and then never touch the factory area again.  Thanks!
> >
> > I have already considered the possibility of implementing this in a
> > board-specific way, but I tried implementing it here to avoid unnecessary
> > code duplication.
> > You are correct, the intention is to use this functionality as a migration
> > path. It's good to keep the factory area intact, in case it's still needed 
> > in
> > the future.
> > The Marvell hw_info area is limited to MACs and serial numbers by the
> > stock utility.
>
> OK.  And can we put this in the board-specific path somehow, relatively
> cleanly?

I've been thinking about the following options:
 - Implementing a separate command under cmd/mvebu (hw_info), like done
in the stock U-Boot.
I'm not inclined to this one, as I don't see real utility in updating
this factory
area. A positive with this one is that it abstracts reading of the SPI flash.

 - No command, automatic migration, directly from the SPI flash (implemented
in the board.c file.
I don't see this as a clean way of doing it, the Armada A37XX board.c is
already quite full of board-specific init.

 - Implemented as is, but with #ifdef
This would break CONFIG_CMD_IMPORTENV into smaller pieces.
#ifdef wouldn't look too bad around the code, only the inline string changes
would be ugly.

What would you recommend?

>
> > I've also compared the resulting u-boot.bin binary size with and without
> > the patch and the difference is about 40 bytes.
>
> Yes, but it's 40 bytes on nearly every single platform.
>
> --
> Tom

Kind regards,
Luka


Re: [PATCH 1/3] cmd: env: Add 'env import -h' for Marvell hw_info formatted environments

2021-02-05 Thread Luka Kovacic
Hello Tom,

On Thu, Feb 4, 2021 at 6:06 PM Tom Rini  wrote:
>
> On Thu, Feb 04, 2021 at 11:46:35AM +0100, Luka Kovacic wrote:
>
> > The '-h' flag is added to the 'env import' command to enable parsing
> > Marvell hw_info formatted environments.
> > This format is often used on Marvell Armada A37XX based devices to store
> > parameters like the board serial number, factory MAC addresses and some
> > other information.
> >
> > Currently this environment format can only be imported, not exported.
> > These parameters are usually written to the flash in the factory.
> >
> > This functionality has been tested on the GST ESPRESSOBin-Ultra board
> > successfully.
> >
> > Usage example:
> >  => sf probe
> >  => sf read ${loadaddr} 0x003E000A 0x1F0 # Read the environment from
> > SPI flash
> >  => env import -h ${loadaddr}
> >
> > Signed-off-by: Luka Kovacic 
> > Cc: Luka Perkov 
> > Cc: Robert Marko 
>
> So, the implementation itself is fine:
>
> Reviewed-by: Tom Rini 
>
> And I take it as a given that we can't get the boards populated with an
> existing separator, so we need to solve this somehow or another.  I am
> however loathe to increase every platform by a handful of bytes (help
> text, code text) to cover this case, and adding #ifdef around the help
> text in particular would be very ugly. Is there any clean way to write
> this as a board-specific command?  I assume the overall intention is to
> import the factory env for the required information, store it in regular
> U-Boot environment and then never touch the factory area again.  Thanks!

I have already considered the possibility of implementing this in a
board-specific way, but I tried implementing it here to avoid unnecessary
code duplication.
You are correct, the intention is to use this functionality as a migration
path. It's good to keep the factory area intact, in case it's still needed in
the future.
The Marvell hw_info area is limited to MACs and serial numbers by the
stock utility.

I've also compared the resulting u-boot.bin binary size with and without
the patch and the difference is about 40 bytes.

>
> --
> Tom

Kind regards,
Luka


[PATCH 3/3] arm: mvebu: Initial ESPRESSOBin-Ultra board support

2021-02-04 Thread Luka Kovacic
Add initial support for the ESPRESSOBin-Ultra board from Globalscale
Technologies, Inc.

The board is based on the 64-bit dual-core Marvell Armada 3720 SoC.
Peripherals:
 - 5 Gigabit Ethernet ports (WAN has PoE, up to 30W, Topaz 6341 switch)
 - RTC clock (PCF8563)
 - USB 3.0 port
 - USB 2.0 port
 - 4x LED
 - UART over Micro-USB
 - M.2 slot (2280)
 - Mini PCI-E slot

Additionally, automatic import of the Marvell hw_info parameters is
enabled via the recently added env import -h flag.
The parameters stored in Marvell hw_info are usually the board serial
number and MAC addresses.

Signed-off-by: Luka Kovacic 
Cc: Luka Perkov 
Cc: Robert Marko 
---
 arch/arm/dts/Makefile |   1 +
 .../arm/dts/armada-3720-espressobin-ultra.dts | 202 ++
 board/Marvell/mvebu_armada-37xx/MAINTAINERS   |   8 +
 board/Marvell/mvebu_armada-37xx/board.c   |  76 ++-
 .../mvebu_espressobin-ultra-88f3720_defconfig |  90 
 5 files changed, 371 insertions(+), 6 deletions(-)
 create mode 100644 arch/arm/dts/armada-3720-espressobin-ultra.dts
 create mode 100644 configs/mvebu_espressobin-ultra-88f3720_defconfig

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 858b79ac97..51455c0271 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -210,6 +210,7 @@ dtb-$(CONFIG_ARCH_TEGRA) += tegra20-harmony.dtb \
 dtb-$(CONFIG_ARCH_MVEBU) +=\
armada-3720-db.dtb  \
armada-3720-espressobin.dtb \
+   armada-3720-espressobin-ultra.dtb   \
armada-3720-turris-mox.dtb  \
armada-3720-uDPU.dtb\
armada-375-db.dtb   \
diff --git a/arch/arm/dts/armada-3720-espressobin-ultra.dts 
b/arch/arm/dts/armada-3720-espressobin-ultra.dts
new file mode 100644
index 00..70f97fe239
--- /dev/null
+++ b/arch/arm/dts/armada-3720-espressobin-ultra.dts
@@ -0,0 +1,202 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Device Tree file for ESPRESSObin-Ultra board
+ * Copyright (C) 2016 Marvell
+ * Copyright (C) 2019 Globalscale technologies, Inc.
+ * Copyright (C) 2020 Sartura Ltd.
+ *
+ * Author: Jason Hung 
+ * Author: Luka Kovacic 
+ * Author: Vladimir Vid 
+ */
+
+/dts-v1/;
+
+#include "armada-372x.dtsi"
+
+/ {
+   model = "Globalscale Marvell ESPRESSOBin Ultra Board";
+   compatible = "globalscale,espressobin-ultra", "marvell,armada3720", 
"marvell,armada3710";
+
+   chosen {
+   stdout-path = "serial0:115200n8";
+   };
+
+   aliases {
+   ethernet0 = 
+   i2c0 = 
+   spi0 = 
+   };
+
+   memory {
+   device_type = "memory";
+   reg = <0x 0x 0x 0x2000>;
+   };
+
+   vcc_sd_reg0: regulator@0 {
+   compatible = "regulator-gpio";
+   regulator-name = "vcc_sd0";
+   regulator-min-microvolt = <180>;
+   regulator-max-microvolt = <330>;
+   regulator-type = "voltage";
+   states = <180 0x1
+ 330 0x0>;
+   gpios = < 4 GPIO_ACTIVE_HIGH>;
+   };
+
+   gpio-leds {
+   pinctrl-names = "default";
+   pinctrl-0 = <_pins>, <_pins>, <_pins>, 
<_pins>;
+   compatible = "gpio-leds";
+
+   led1 {
+   label = "led1";
+   gpios = < 11 GPIO_ACTIVE_LOW>;
+   default-state = "on";
+   };
+   led2 {
+   label = "led2";
+   gpios = < 12 GPIO_ACTIVE_LOW>;
+   default-state = "on";
+   };
+   led3 {
+   label = "led3";
+   gpios = < 13 GPIO_ACTIVE_LOW>;
+   default-state = "on";
+   };
+   led4 {
+   label = "led4";
+   gpios = < 14 GPIO_ACTIVE_LOW>;
+   default-state = "on";
+   };
+   };
+};
+
+_nb {
+   led1_pins: led1-pins {
+   groups = "pwm0";
+   function = "gpio";
+   };
+   led2_pins: led2-pins {
+   groups = "pwm1";
+   function = "gpio";
+   };
+   led3_pins: led3-pins {
+   groups = "pwm2";
+   function = "gpio";
+   };
+   led4_pins: led4-pins {
+   groups = "pwm3";
+   function = "gpio";
+   };
+};
+
+ {
+   max-lanes = <3>;

[PATCH 2/3] arm: mvebu: mvebu_armada-37xx: Define the loadaddr environment variable

2021-02-04 Thread Luka Kovacic
Add the loadaddr U-Boot environment variable, as this is available in
the stock Marvell U-Boot by default on Marvell Armada A37XX platforms.

Signed-off-by: Luka Kovacic 
Cc: Luka Perkov 
Cc: Robert Marko 
---
 include/configs/mvebu_armada-37xx.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/configs/mvebu_armada-37xx.h 
b/include/configs/mvebu_armada-37xx.h
index 0d585606a7..6da82078a4 100644
--- a/include/configs/mvebu_armada-37xx.h
+++ b/include/configs/mvebu_armada-37xx.h
@@ -89,6 +89,7 @@
 
 /* fdt_addr and kernel_addr are needed for existing distribution boot scripts 
*/
 #define CONFIG_EXTRA_ENV_SETTINGS  \
+   "loadaddr=0x600\0"  \
"scriptaddr=0x6d0\0"\
"pxefile_addr_r=0x6e0\0"\
"fdt_addr=0x6f0\0"  \
-- 
2.20.1



[PATCH 1/3] cmd: env: Add 'env import -h' for Marvell hw_info formatted environments

2021-02-04 Thread Luka Kovacic
The '-h' flag is added to the 'env import' command to enable parsing
Marvell hw_info formatted environments.
This format is often used on Marvell Armada A37XX based devices to store
parameters like the board serial number, factory MAC addresses and some
other information.

Currently this environment format can only be imported, not exported.
These parameters are usually written to the flash in the factory.

This functionality has been tested on the GST ESPRESSOBin-Ultra board
successfully.

Usage example:
 => sf probe
 => sf read ${loadaddr} 0x003E000A 0x1F0 # Read the environment from
SPI flash
 => env import -h ${loadaddr}

Signed-off-by: Luka Kovacic 
Cc: Luka Perkov 
Cc: Robert Marko 
---
 cmd/nvedit.c| 22 ++
 lib/hashtable.c |  2 +-
 2 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/cmd/nvedit.c b/cmd/nvedit.c
index d0d2eca904..eab490ac48 100644
--- a/cmd/nvedit.c
+++ b/cmd/nvedit.c
@@ -1060,7 +1060,7 @@ sep_err:
 
 #ifdef CONFIG_CMD_IMPORTENV
 /*
- * env import [-d] [-t [-r] | -b | -c] addr [size] [var ...]
+ * env import [-d] [-t [-r] | -b | -h | -c] addr [size] [var ...]
  * -d: delete existing environment before importing if no var is
  * passed; if vars are passed, if one var is in the current
  * environment but not in the environment at addr, delete var from
@@ -1073,6 +1073,7 @@ sep_err:
  * to import text files created with editors which are using CRLF
  * for line endings. Only effective in addition to -t.
  * -b: assume binary format ('\0' separated, "\0\0" terminated)
+ * -h: assume Marvell hw_info format (0x20 separated, "0x20\0" 
terminated)
  * -c: assume checksum protected environment format
  * addr:   memory address to read from
  * size:   length of input data; if missing, proper '\0'
@@ -1082,6 +1083,14 @@ sep_err:
  * var...  List of the names of the only variables that get imported from
  * the environment at address 'addr'. Without arguments, the whole
  * environment gets imported.
+ *
+ * Using the "-h" flag you can import a Marvell hw_info formatted environment.
+ * This is commonly used on Marvell Armada A37XX devices to store the board 
serial
+ * number, MAC addresses and some other information.
+ * Currently you can only import these by loading the data into memory and 
parse it
+ * using this command. Exporting is currently not supported, due to tight 
memory
+ * restrictions and a strict formatting scheme.
+ * These parameters are usually populated in the factory.
  */
 static int do_env_import(struct cmd_tbl *cmdtp, int flag,
 int argc, char *const argv[])
@@ -1107,6 +1116,11 @@ static int do_env_import(struct cmd_tbl *cmdtp, int flag,
goto sep_err;
sep = '\0';
break;
+   case 'h':   /* Marvell hw_info format */
+   if (fmt++)
+   goto sep_err;
+   sep = 0x20;
+   break;
case 'c':   /* external checksum format */
if (fmt++)
goto sep_err;
@@ -1199,8 +1213,8 @@ static int do_env_import(struct cmd_tbl *cmdtp, int flag,
return 0;
 
 sep_err:
-   printf("## %s: only one of \"-b\", \"-c\" or \"-t\" allowed\n",
-   cmd);
+   printf("## %s: only one of \"-b\", \"-h\", \"-c\" or \"-t\" allowed\n",
+  cmd);
return 1;
 }
 #endif
@@ -1450,7 +1464,7 @@ static char env_help_text[] =
 #endif
 #endif
 #if defined(CONFIG_CMD_IMPORTENV)
-   "env import [-d] [-t [-r] | -b | -c] addr [size] [var ...] - import 
environment\n"
+   "env import [-d] [-t [-r] | -b | -h | -c] addr [size] [var ...] - 
import environment\n"
 #endif
 #if defined(CONFIG_CMD_NVEDIT_INFO)
"env info - display environment information\n"
diff --git a/lib/hashtable.c b/lib/hashtable.c
index ff5ff72639..06322e3304 100644
--- a/lib/hashtable.c
+++ b/lib/hashtable.c
@@ -794,7 +794,7 @@ static int drop_var_from_set(const char *name, int nvars, 
char * vars[])
  * multi-line values.
  *
  * In theory, arbitrary separator characters can be used, but only
- * '\0' and '\n' have really been tested.
+ * '\0', '\n' and 0x20 have been tested.
  */
 
 int himport_r(struct hsearch_data *htab,
-- 
2.20.1



[PATCH 0/3] Add support for the GST ESPRESSOBin-Ultra board

2021-02-04 Thread Luka Kovacic
This patchset adds initial support for the ESPRESSOBin-Ultra board from
Globalscale Technologies, Inc.

The board is based on the 64-bit dual-core Marvell Armada 3720 SoC.
Peripherals:
 - 5 Gigabit Ethernet ports (WAN has PoE, up to 30W, Topaz 6341 switch)
 - RTC clock (PCF8563)
 - USB 3.0 port
 - USB 2.0 port
 - 4x LED
 - UART over Micro-USB
 - M.2 slot (2280)
 - Mini PCI-E slot

Additionally support for importing Marvell hw_info formatted environments
is added to fully support the board.

Luka Kovacic (3):
  cmd: env: Add 'env import -h' for Marvell hw_info formatted
environments
  arm: mvebu: mvebu_armada-37xx: Define the loadaddr environment
variable
  arm: mvebu: Initial ESPRESSOBin-Ultra board support

 arch/arm/dts/Makefile |   1 +
 .../arm/dts/armada-3720-espressobin-ultra.dts | 202 ++
 board/Marvell/mvebu_armada-37xx/MAINTAINERS   |   8 +
 board/Marvell/mvebu_armada-37xx/board.c   |  76 ++-
 cmd/nvedit.c  |  22 +-
 .../mvebu_espressobin-ultra-88f3720_defconfig |  90 
 include/configs/mvebu_armada-37xx.h   |   1 +
 lib/hashtable.c   |   2 +-
 8 files changed, 391 insertions(+), 11 deletions(-)
 create mode 100644 arch/arm/dts/armada-3720-espressobin-ultra.dts
 create mode 100644 configs/mvebu_espressobin-ultra-88f3720_defconfig

-- 
2.20.1



[PATCH] arm: mvebu: puzzle-m801: Add a maintainer

2020-10-29 Thread Luka Kovacic
Add Luka Perkov to Puzzle-M801 BOARD MAINTAINERS.

Signed-off-by: Luka Kovacic 
Cc: Luka Perkov 
---
 board/Marvell/mvebu_armada-8k/MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)

diff --git a/board/Marvell/mvebu_armada-8k/MAINTAINERS 
b/board/Marvell/mvebu_armada-8k/MAINTAINERS
index 15660cd17d..55e485faa9 100644
--- a/board/Marvell/mvebu_armada-8k/MAINTAINERS
+++ b/board/Marvell/mvebu_armada-8k/MAINTAINERS
@@ -13,6 +13,7 @@ F:configs/mvebu_mcbin-88f8040_defconfig
 
 Puzzle-M801 BOARD
 M: Luka Kovacic 
+M: Luka Perkov 
 S: Maintained
 F: configs/mvebu_puzzle-m801-88f8040_defconfig
 F: arch/arm/dts/armada-8040-puzzle-m801.dts
-- 
2.26.2



Re: [PATCH 0/2] iEi Puzzle-M801 board support

2020-09-14 Thread Luka Kovacic
Hello Stefan,

Can you please review the patchset?
Is there anything that should be resolved?

Thanks,
Luka

On Sat, Aug 29, 2020 at 12:36 AM Luka Kovacic  wrote:
>
> This patchset adds board support for the iEi Puzzle-M801 1U Rackmount
> Network Appliance.
>
> The board is based on the quad-core Marvell Armada 8040 SoC and supports
> up to 16 GB of DDR4 2400 MHz ECC RAM. It has a PCIe x16 slot (x2 lanes
> only) and an M.2 type B slot.
>
> Chassis ports:
> 2x 10 GbE SFP+
> 4x 1 GbE RJ45 (Marvell 88E1512P)
> 2x USB 3.0
> 1x RJ45 UART
>
> Luka Kovacic (2):
>   arm: mvebu: Initial iEi Puzzle-M801 support
>   arm: mvebu: mvebu_armada-8k: Add support for initializing iEi
> Puzzle-M801 networking
>
>  arch/arm/dts/Makefile   |   1 +
>  arch/arm/dts/armada-8040-puzzle-m801.dts| 389 
>  board/Marvell/mvebu_armada-8k/MAINTAINERS   |   6 +
>  board/Marvell/mvebu_armada-8k/board.c   |  20 +-
>  configs/mvebu_puzzle-m801-88f8040_defconfig |  91 +
>  5 files changed, 506 insertions(+), 1 deletion(-)
>  create mode 100644 arch/arm/dts/armada-8040-puzzle-m801.dts
>  create mode 100644 configs/mvebu_puzzle-m801-88f8040_defconfig
>
> --
> 2.26.2
>


[PATCH 2/2] arm: mvebu: mvebu_armada-8k: Add support for initializing iEi Puzzle-M801 networking

2020-08-28 Thread Luka Kovacic
Add support for the marvell,armada8040-puzzle-m801 compatible string
in the board/Marvell/mvebu_armada-8k/board.c file to initialize the
networking on iEi Puzzle-M801 board (2x CP1 1 Gb ports).

Signed-off-by: Luka Kovacic 
Cc: Luka Perkov 
---
 board/Marvell/mvebu_armada-8k/board.c | 20 +++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/board/Marvell/mvebu_armada-8k/board.c 
b/board/Marvell/mvebu_armada-8k/board.c
index 60b0024630..bf8a929ec1 100644
--- a/board/Marvell/mvebu_armada-8k/board.c
+++ b/board/Marvell/mvebu_armada-8k/board.c
@@ -34,6 +34,17 @@ DECLARE_GLOBAL_DATA_PTR;
 #define I2C_IO_REG_CL  ((1 << I2C_IO_REG_0_USB_H0_CL) | \
 (1 << I2C_IO_REG_0_USB_H1_CL))
 
+/*
+ * Information specific to the iEi Puzzle-M801 board.
+ */
+
+/* Internal configuration registers */
+#define CP1_CONF_REG_BASE 0xf444
+#define CONF_REG_MPP0 0x0
+#define CONF_REG_MPP1 0x4
+#define CONF_REG_MPP2 0x8
+#define CONF_REG_MPP3 0xC
+
 static int usb_enabled = 0;
 
 /* Board specific xHCI dis-/enable code */
@@ -141,7 +152,14 @@ int board_xhci_enable(fdt_addr_t base)
 
 int board_early_init_f(void)
 {
-   /* Nothing to do (yet), perhaps later some pin-muxing etc */
+   /* Initialize some platform specific memory locations */
+   if (of_machine_is_compatible("marvell,armada8040-puzzle-m801")) {
+   /* MPP setup */
+   writel(0x0044, CP1_CONF_REG_BASE + CONF_REG_MPP0);
+   writel(0x, CP1_CONF_REG_BASE + CONF_REG_MPP1);
+   writel(0x, CP1_CONF_REG_BASE + CONF_REG_MPP2);
+   writel(0x0000, CP1_CONF_REG_BASE + CONF_REG_MPP3);
+   }
 
return 0;
 }
-- 
2.26.2



[PATCH 1/2] arm: mvebu: Initial iEi Puzzle-M801 support

2020-08-28 Thread Luka Kovacic
Add initial U-Boot support for the iEi Puzzle-M801 board based on the
Marvell Armada 88F8040 SoC.

Currently supported hardware:
1x USB 3.0
4x Gigabit Ethernet
2x SFP+ (with NXP PCA9555 and NXP PCA9544)
1x SATA 3.0
1x M.2 type B
1x RJ45 UART
1x SPI flash
1x EPSON RX8010 RTC

Signed-off-by: Luka Kovacic 
Cc: Luka Perkov 
---
 arch/arm/dts/Makefile   |   1 +
 arch/arm/dts/armada-8040-puzzle-m801.dts| 389 
 board/Marvell/mvebu_armada-8k/MAINTAINERS   |   6 +
 configs/mvebu_puzzle-m801-88f8040_defconfig |  91 +
 4 files changed, 487 insertions(+)
 create mode 100644 arch/arm/dts/armada-8040-puzzle-m801.dts
 create mode 100644 configs/mvebu_puzzle-m801-88f8040_defconfig

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index f8f529435b..f13794bc42 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -218,6 +218,7 @@ dtb-$(CONFIG_ARCH_MVEBU) += \
armada-8040-clearfog-gt-8k.dtb  \
armada-8040-db.dtb  \
armada-8040-mcbin.dtb   \
+   armada-8040-puzzle-m801.dtb \
armada-xp-crs305-1g-4s.dtb  \
armada-xp-crs305-1g-4s-bit.dtb  \
armada-xp-crs326-24g-2s.dtb \
diff --git a/arch/arm/dts/armada-8040-puzzle-m801.dts 
b/arch/arm/dts/armada-8040-puzzle-m801.dts
new file mode 100644
index 00..58edb5b3aa
--- /dev/null
+++ b/arch/arm/dts/armada-8040-puzzle-m801.dts
@@ -0,0 +1,389 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2016 Marvell International Ltd.
+ * Copyright (C) 2020 Sartura Ltd.
+ */
+
+#include "armada-8040.dtsi" /* include SoC device tree */
+
+/ {
+   model = "iEi-Puzzle-M801";
+   compatible = "marvell,armada8040-puzzle-m801",
+"marvell,armada8040";
+
+   chosen {
+   stdout-path = "serial0:115200n8";
+   };
+
+   aliases {
+   i2c0 = 
+   i2c1 = _i2c0;
+   i2c2 = _i2c1;
+   i2c3 = _switch;
+   spi0 = 
+   gpio0 = _gpio0;
+   gpio1 = _gpio0;
+   gpio2 = _gpio1;
+   gpio3 = _gpio;
+   };
+
+   memory@ {
+   device_type = "memory";
+   reg = <0x0 0x0 0x0 0x8000>;
+   };
+
+   simple-bus {
+   compatible = "simple-bus";
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   reg_usb3h0_vbus: usb3-vbus0 {
+   compatible = "regulator-fixed";
+   pinctrl-names = "default";
+   pinctrl-0 = <_xhci_vbus_pins>;
+   regulator-name = "reg-usb3h0-vbus";
+   regulator-min-microvolt = <500>;
+   regulator-max-microvolt = <500>;
+   startup-delay-us = <50>;
+   enable-active-high;
+   regulator-always-on;
+   regulator-boot-on;
+   gpio = <_gpio1 15 GPIO_ACTIVE_HIGH>; /* GPIO[47] */
+   };
+   };
+};
+
+ {
+   status = "okay";
+   clock-frequency = <10>;
+
+   rtc@32 {
+   compatible = "epson,rx8010";
+   reg = <0x32>;
+   };
+};
+
+ {
+   status = "okay";
+};
+
+_pinctl {
+   /*
+* MPP Bus:
+* AP SPI0 [0-3]
+* AP I2C [4-5]
+* AP GPIO [6]
+* AP UART 1 RX/TX [7-8]
+* AP GPIO [9-10]
+* AP GPIO [12]
+* UART0 [11,19]
+*/
+ /* 0 1 2 3 4 5 6 7 8 9 */
+   pin-func = < 3 3 3 3 3 3 3 3 3 0
+0 3 0 0 0 0 0 0 0 3 >;
+};
+
+_pinctl {
+   /*
+* MPP Bus:
+* [0-31] = 0xff: Keep default CP0_shared_pins:
+* [11] CLKOUT_MPP_11 (out)
+* [23] LINK_RD_IN_CP2CP (in)
+* [25] CLKOUT_MPP_25 (out)
+* [29] AVS_FB_IN_CP2CP (in)
+* [32,34] SMI
+* [33]MSS power down
+* [35-38] CP0 I2C1 and I2C0
+* [39] MSS CKE Enable
+* [40,41] CP0 UART1 TX/RX
+* [42,43] XSMI (controls two 10G phys)
+* [47] USB VBUS EN
+* [48] FAN PWM
+* [49] 10G port 1 interrupt
+* [50] 10G port 0 interrupt
+* [51] 2.5G SFP TX fault
+* [52] PCIe reset out
+* [53] 2.5G SFP mode
+* [54] 2.5G SFP LOS
+* [55] Micro SD card detect
+* [56-61] Micro SD
+* [62] CP1 SFI SFP FAULT
+*/
+   /*   0123456789 */
+   pin-func = < 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff
+0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff
+

[PATCH 0/2] iEi Puzzle-M801 board support

2020-08-28 Thread Luka Kovacic
This patchset adds board support for the iEi Puzzle-M801 1U Rackmount
Network Appliance.

The board is based on the quad-core Marvell Armada 8040 SoC and supports
up to 16 GB of DDR4 2400 MHz ECC RAM. It has a PCIe x16 slot (x2 lanes
only) and an M.2 type B slot.

Chassis ports:
2x 10 GbE SFP+
4x 1 GbE RJ45 (Marvell 88E1512P)
2x USB 3.0
1x RJ45 UART

Luka Kovacic (2):
  arm: mvebu: Initial iEi Puzzle-M801 support
  arm: mvebu: mvebu_armada-8k: Add support for initializing iEi
Puzzle-M801 networking

 arch/arm/dts/Makefile   |   1 +
 arch/arm/dts/armada-8040-puzzle-m801.dts| 389 
 board/Marvell/mvebu_armada-8k/MAINTAINERS   |   6 +
 board/Marvell/mvebu_armada-8k/board.c   |  20 +-
 configs/mvebu_puzzle-m801-88f8040_defconfig |  91 +
 5 files changed, 506 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/dts/armada-8040-puzzle-m801.dts
 create mode 100644 configs/mvebu_puzzle-m801-88f8040_defconfig

-- 
2.26.2



[PATCH 4/5] arm: mvebu: crs3xx-98dx3236: Add a maintainer

2020-07-23 Thread Luka Kovacic
Add Luka Perkov to CRS3xx-98DX3236 MAINTAINERS.

Signed-off-by: Luka Kovacic 
Cc: Luka Perkov 
Cc: Jakov Petrina 
---
 board/mikrotik/crs3xx-98dx3236/MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)

diff --git a/board/mikrotik/crs3xx-98dx3236/MAINTAINERS 
b/board/mikrotik/crs3xx-98dx3236/MAINTAINERS
index e6fbf3db1c..906ff98970 100644
--- a/board/mikrotik/crs3xx-98dx3236/MAINTAINERS
+++ b/board/mikrotik/crs3xx-98dx3236/MAINTAINERS
@@ -1,5 +1,6 @@
 CRS3XX-98DX3236 BOARD
 M: Luka Kovacic 
+M: Luka Perkov 
 S: Maintained
 F: board/mikrotik/crs3xx-98dx3236/
 F: include/configs/crs3xx-98dx3236.h
-- 
2.26.2



[PATCH 5/5] arm: mvebu: Update CRS305-1G-4S board flash layout

2020-07-23 Thread Luka Kovacic
Update the MikroTik CRS305-1G-4S flash layout to support redundant UBI
partitions.
Additionally enable the UBI commands in crs305-1g-4s_defconfig.

Signed-off-by: Luka Kovacic 
Cc: Luka Perkov 
Cc: Jakov Petrina 
---
 arch/arm/dts/armada-xp-crs305-1g-4s.dtsi | 10 +-
 configs/crs305-1g-4s_defconfig   |  9 -
 2 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/arch/arm/dts/armada-xp-crs305-1g-4s.dtsi 
b/arch/arm/dts/armada-xp-crs305-1g-4s.dtsi
index c8839eac94..1a74ecd5b5 100644
--- a/arch/arm/dts/armada-xp-crs305-1g-4s.dtsi
+++ b/arch/arm/dts/armada-xp-crs305-1g-4s.dtsi
@@ -95,16 +95,16 @@
m25p,fast-read;
 
partition@u-boot {
-   reg = <0x 0x0008>;
+   reg = <0x 0x001f>;
label = "u-boot";
};
partition@u-boot-env {
-   reg = <0x0008 0x0001>;
+   reg = <0x001f 0x0001>;
label = "u-boot-env";
};
-   partition@firmware {
-   reg = <0x0009 0x00f7>;
-   label = "firmware";
+   partition@ubi1 {
+   reg = <0x0020 0x00e0>;
+   label = "ubi1";
};
 
};
diff --git a/configs/crs305-1g-4s_defconfig b/configs/crs305-1g-4s_defconfig
index a360fc5d3f..a62b14e856 100644
--- a/configs/crs305-1g-4s_defconfig
+++ b/configs/crs305-1g-4s_defconfig
@@ -5,14 +5,17 @@ CONFIG_SYS_TEXT_BASE=0x0080
 CONFIG_SYS_MALLOC_F_LEN=0x2000
 CONFIG_TARGET_CRS3XX_98DX3236=y
 CONFIG_ENV_SIZE=0x1
-CONFIG_ENV_OFFSET=0x8
+CONFIG_ENV_OFFSET=0x1F
 CONFIG_ENV_SECT_SIZE=0x1
+CONFIG_BOOTCOUNT_BOOTLIMIT=3
 CONFIG_BUILD_TARGET="u-boot.kwb"
 CONFIG_FIT=y
+CONFIG_FIT_ENABLE_SHA256_SUPPORT=y
 CONFIG_FIT_VERBOSE=y
 CONFIG_FIT_BEST_MATCH=y
 CONFIG_USE_PREBOOT=y
 CONFIG_SYS_CONSOLE_INFO_QUIET=y
+CONFIG_HUSH_PARSER=y
 CONFIG_AUTOBOOT_KEYED=y
 CONFIG_AUTOBOOT_PROMPT="Autoboot in %d seconds, to stop use 's' key\n"
 CONFIG_AUTOBOOT_STOP_STR="s"
@@ -22,11 +25,15 @@ CONFIG_CMD_BOOTZ=y
 CONFIG_CMD_MTD=y
 CONFIG_CMD_SPI=y
 CONFIG_CMD_CACHE=y
+CONFIG_CMD_UBI=y
+CONFIG_CMD_FS_GENERIC=y
 CONFIG_CMD_MTDPARTS=y
 CONFIG_DEFAULT_DEVICE_TREE="armada-xp-crs305-1g-4s"
 CONFIG_ENV_IS_IN_SPI_FLASH=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_BLK=y
+CONFIG_BOOTCOUNT_LIMIT=y
+CONFIG_BOOTCOUNT_ENV=y
 # CONFIG_MMC is not set
 CONFIG_MTD=y
 CONFIG_DM_MTD=y
-- 
2.26.2



[PATCH 0/5] Add support for a series of MikroTik CRS3xx switches

2020-07-23 Thread Luka Kovacic
These patches add support for a series of MikroTik CRS3xx, 98DX3236 based
switches.

Namely, support is added for:
 -  MikroTik CRS305-1G-4S+ Bit variant
 -  MikroTik CRS326-24G-2S+ (including the Bit variant)
 -  MikroTik CRS328-4C-20S-4S+ (including the Bit variant)

The Bit board variant is added for each of the boards.
These boards were modified to use a bigger Macronix flash.

This work is a follow-up on the previous patch, which prepared the board
support for CRS3xx-98DX3236 boards.

Luka Kovacic (5):
  arm: mvebu: Add CRS305-1G-4S Bit board
  arm: mvebu: Add CRS326-24G-2S board
  arm: mvebu: Add CRS328-4C-20S-4S board
  arm: mvebu: crs3xx-98dx3236: Add a maintainer
  arm: mvebu: Update CRS305-1G-4S board flash layout

 arch/arm/dts/Makefile |   5 +
 arch/arm/dts/armada-xp-crs305-1g-4s-bit.dts   |  43 +++
 arch/arm/dts/armada-xp-crs305-1g-4s.dtsi  |  10 +-
 arch/arm/dts/armada-xp-crs326-24g-2s-bit.dts  |  43 +++
 .../dts/armada-xp-crs326-24g-2s-u-boot.dtsi   |  13 +++
 arch/arm/dts/armada-xp-crs326-24g-2s.dts  |  17 +++
 arch/arm/dts/armada-xp-crs326-24g-2s.dtsi | 110 ++
 .../dts/armada-xp-crs328-4c-20s-4s-bit.dts|  43 +++
 .../armada-xp-crs328-4c-20s-4s-u-boot.dtsi|  13 +++
 arch/arm/dts/armada-xp-crs328-4c-20s-4s.dts   |  17 +++
 arch/arm/dts/armada-xp-crs328-4c-20s-4s.dtsi  | 110 ++
 board/mikrotik/crs3xx-98dx3236/MAINTAINERS|  22 
 configs/crs305-1g-4s-bit_defconfig|  54 +
 configs/crs305-1g-4s_defconfig|   9 +-
 configs/crs326-24g-2s-bit_defconfig   |  54 +
 configs/crs326-24g-2s_defconfig   |  54 +
 configs/crs328-4c-20s-4s-bit_defconfig|  54 +
 configs/crs328-4c-20s-4s_defconfig|  54 +
 18 files changed, 719 insertions(+), 6 deletions(-)
 create mode 100644 arch/arm/dts/armada-xp-crs305-1g-4s-bit.dts
 create mode 100644 arch/arm/dts/armada-xp-crs326-24g-2s-bit.dts
 create mode 100644 arch/arm/dts/armada-xp-crs326-24g-2s-u-boot.dtsi
 create mode 100644 arch/arm/dts/armada-xp-crs326-24g-2s.dts
 create mode 100644 arch/arm/dts/armada-xp-crs326-24g-2s.dtsi
 create mode 100644 arch/arm/dts/armada-xp-crs328-4c-20s-4s-bit.dts
 create mode 100644 arch/arm/dts/armada-xp-crs328-4c-20s-4s-u-boot.dtsi
 create mode 100644 arch/arm/dts/armada-xp-crs328-4c-20s-4s.dts
 create mode 100644 arch/arm/dts/armada-xp-crs328-4c-20s-4s.dtsi
 create mode 100644 configs/crs305-1g-4s-bit_defconfig
 create mode 100644 configs/crs326-24g-2s-bit_defconfig
 create mode 100644 configs/crs326-24g-2s_defconfig
 create mode 100644 configs/crs328-4c-20s-4s-bit_defconfig
 create mode 100644 configs/crs328-4c-20s-4s_defconfig

-- 
2.26.2



[PATCH 3/5] arm: mvebu: Add CRS328-4C-20S-4S board

2020-07-23 Thread Luka Kovacic
MikroTik CRS328-4C-20S-4S board has a switch chip with an integrated
Marvell Prestera 98DX3236 CPU.

This commit includes two board variants, namely the factory
default one and a Bit variant. The Bit board variant has a
bigger Macronix flash.

Add basic U-Boot, UART and SPI flash support.

Signed-off-by: Luka Kovacic 
Cc: Luka Perkov 
Cc: Jakov Petrina 
---
 arch/arm/dts/Makefile |   2 +
 .../dts/armada-xp-crs328-4c-20s-4s-bit.dts|  43 +++
 .../armada-xp-crs328-4c-20s-4s-u-boot.dtsi|  13 +++
 arch/arm/dts/armada-xp-crs328-4c-20s-4s.dts   |  17 +++
 arch/arm/dts/armada-xp-crs328-4c-20s-4s.dtsi  | 110 ++
 board/mikrotik/crs3xx-98dx3236/MAINTAINERS|   9 ++
 configs/crs328-4c-20s-4s-bit_defconfig|  54 +
 configs/crs328-4c-20s-4s_defconfig|  54 +
 8 files changed, 302 insertions(+)
 create mode 100644 arch/arm/dts/armada-xp-crs328-4c-20s-4s-bit.dts
 create mode 100644 arch/arm/dts/armada-xp-crs328-4c-20s-4s-u-boot.dtsi
 create mode 100644 arch/arm/dts/armada-xp-crs328-4c-20s-4s.dts
 create mode 100644 arch/arm/dts/armada-xp-crs328-4c-20s-4s.dtsi
 create mode 100644 configs/crs328-4c-20s-4s-bit_defconfig
 create mode 100644 configs/crs328-4c-20s-4s_defconfig

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 9f8ca61f28..deced1ad7d 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -216,6 +216,8 @@ dtb-$(CONFIG_ARCH_MVEBU) += \
armada-xp-crs305-1g-4s-bit.dtb  \
armada-xp-crs326-24g-2s.dtb \
armada-xp-crs326-24g-2s-bit.dtb \
+   armada-xp-crs328-4c-20s-4s.dtb  \
+   armada-xp-crs328-4c-20s-4s-bit.dtb  \
armada-xp-db-xc3-24g4xg.dtb \
armada-xp-gp.dtb\
armada-xp-maxbcm.dtb\
diff --git a/arch/arm/dts/armada-xp-crs328-4c-20s-4s-bit.dts 
b/arch/arm/dts/armada-xp-crs328-4c-20s-4s-bit.dts
new file mode 100644
index 00..d684c895ff
--- /dev/null
+++ b/arch/arm/dts/armada-xp-crs328-4c-20s-4s-bit.dts
@@ -0,0 +1,43 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Device Tree file for MikroTik CRS328-4C-20S-4S+ Bit board
+ *
+ * Copyright (C) 2020 Sartura Ltd.
+ * Author: Luka Kovacic 
+ */
+
+#include "armada-xp-crs328-4c-20s-4s.dtsi"
+
+/ {
+   model = "MikroTik CRS328-4C-20S-4S+ Bit";
+};
+
+ {
+   status = "okay";
+
+   spi-flash@0 {
+   #address-cells = <1>;
+   #size-cells = <1>;
+   compatible = "spi-flash", "jedec,spi-nor";
+   reg = <0>; /* Chip select 0 */
+   spi-max-frequency = <10800>;
+   m25p,fast-read;
+
+   partition@u-boot {
+   reg = <0x 0x001f>;
+   label = "u-boot";
+   };
+   partition@u-boot-env {
+   reg = <0x001f 0x0001>;
+   label = "u-boot-env";
+   };
+   partition@ubi1 {
+   reg = <0x0020 0x03f0>;
+   label = "ubi1";
+   };
+   partition@ubi2 {
+   reg = <0x0410 0x03f0>;
+   label = "ubi2";
+   };
+   };
+};
diff --git a/arch/arm/dts/armada-xp-crs328-4c-20s-4s-u-boot.dtsi 
b/arch/arm/dts/armada-xp-crs328-4c-20s-4s-u-boot.dtsi
new file mode 100644
index 00..8576a02730
--- /dev/null
+++ b/arch/arm/dts/armada-xp-crs328-4c-20s-4s-u-boot.dtsi
@@ -0,0 +1,13 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+
+ {
+   u-boot,dm-pre-reloc;
+};
+
+ {
+   u-boot,dm-pre-reloc;
+
+   spi-flash@0 {
+   u-boot,dm-pre-reloc;
+   };
+};
diff --git a/arch/arm/dts/armada-xp-crs328-4c-20s-4s.dts 
b/arch/arm/dts/armada-xp-crs328-4c-20s-4s.dts
new file mode 100644
index 00..665757f6e1
--- /dev/null
+++ b/arch/arm/dts/armada-xp-crs328-4c-20s-4s.dts
@@ -0,0 +1,17 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Device Tree file for MikroTik CRS328-4C-20S-4S+ board
+ *
+ * Copyright (C) 2020 Sartura Ltd.
+ * Author: Luka Kovacic 
+ */
+
+#include "armada-xp-crs328-4c-20s-4s.dtsi"
+
+/ {
+   model = "MikroTik CRS328-4C-20S-4S+";
+};
+
+ {
+   status = "okay";
+};
diff --git a/arch/arm/dts/armada-xp-crs328-4c-20s-4s.dtsi 
b/arch/arm/dts/armada-xp-crs328-4c-20s-4s.dtsi
new file mode 100644
index 00..daff1af2a2
--- /dev/null
+++ b/arch/arm/dts/armada-xp-crs328-4c-20s-4s.dtsi
@@ -0,0 +1,110 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Device Tree file for CRS328-4C-20S-4S+ board
+ *
+ * Copyright (C) 2016 Allied Telesis Labs
+ * Copyright (C) 2020 Sartura Ltd.
+ *
+ * Based on armada-xp-db.dts

[PATCH 1/5] arm: mvebu: Add CRS305-1G-4S Bit board

2020-07-23 Thread Luka Kovacic
MikroTik CRS305-1G-4S Bit board has a switch chip with an integrated
Marvell Prestera 98DX3236 CPU.

The Bit board variant is added, which has a bigger Macronix flash.

Add basic U-Boot, UART and Winbond SPI flash support.

Signed-off-by: Luka Kovacic 
Cc: Luka Perkov 
Cc: Jakov Petrina 
---
 arch/arm/dts/Makefile   |  1 +
 arch/arm/dts/armada-xp-crs305-1g-4s-bit.dts | 43 
 board/mikrotik/crs3xx-98dx3236/MAINTAINERS  |  3 ++
 configs/crs305-1g-4s-bit_defconfig  | 54 +
 4 files changed, 101 insertions(+)
 create mode 100644 arch/arm/dts/armada-xp-crs305-1g-4s-bit.dts
 create mode 100644 configs/crs305-1g-4s-bit_defconfig

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index cee10f533f..72e1f4fa20 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -213,6 +213,7 @@ dtb-$(CONFIG_ARCH_MVEBU) += \
armada-8040-db.dtb  \
armada-8040-mcbin.dtb   \
armada-xp-crs305-1g-4s.dtb  \
+   armada-xp-crs305-1g-4s-bit.dtb  \
armada-xp-db-xc3-24g4xg.dtb \
armada-xp-gp.dtb\
armada-xp-maxbcm.dtb\
diff --git a/arch/arm/dts/armada-xp-crs305-1g-4s-bit.dts 
b/arch/arm/dts/armada-xp-crs305-1g-4s-bit.dts
new file mode 100644
index 00..059bf48aeb
--- /dev/null
+++ b/arch/arm/dts/armada-xp-crs305-1g-4s-bit.dts
@@ -0,0 +1,43 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Device Tree file for MikroTik CRS305-1G-4S+ Bit board
+ *
+ * Copyright (C) 2020 Sartura Ltd.
+ * Author: Luka Kovacic 
+ */
+
+#include "armada-xp-crs305-1g-4s.dtsi"
+
+/ {
+   model = "MikroTik CRS305-1G-4S+ Bit";
+};
+
+ {
+   status = "okay";
+
+   spi-flash@0 {
+   #address-cells = <1>;
+   #size-cells = <1>;
+   compatible = "spi-flash", "jedec,spi-nor";
+   reg = <0>; /* Chip select 0 */
+   spi-max-frequency = <10800>;
+   m25p,fast-read;
+
+   partition@u-boot {
+   reg = <0x 0x001f>;
+   label = "u-boot";
+   };
+   partition@u-boot-env {
+   reg = <0x001f 0x0001>;
+   label = "u-boot-env";
+   };
+   partition@ubi1 {
+   reg = <0x0020 0x03f0>;
+   label = "ubi1";
+   };
+   partition@ubi2 {
+   reg = <0x0410 0x03f0>;
+   label = "ubi2";
+   };
+   };
+};
diff --git a/board/mikrotik/crs3xx-98dx3236/MAINTAINERS 
b/board/mikrotik/crs3xx-98dx3236/MAINTAINERS
index 127e0eac60..d02584bb1d 100644
--- a/board/mikrotik/crs3xx-98dx3236/MAINTAINERS
+++ b/board/mikrotik/crs3xx-98dx3236/MAINTAINERS
@@ -6,6 +6,9 @@ F:  include/configs/crs3xx-98dx3236.h
 
 CRS305-1G-4S BOARD
 M: Luka Kovacic 
+M: Luka Perkov 
 S: Maintained
 F: configs/crs305-1g-4s_defconfig
+F: configs/crs305-1g-4s-bit_defconfig
 F: arch/arm/dts/armada-xp-crs305-1g-4s.dts
+F: arch/arm/dts/armada-xp-crs305-1g-4s-bit.dts
diff --git a/configs/crs305-1g-4s-bit_defconfig 
b/configs/crs305-1g-4s-bit_defconfig
new file mode 100644
index 00..0ecf11acb2
--- /dev/null
+++ b/configs/crs305-1g-4s-bit_defconfig
@@ -0,0 +1,54 @@
+CONFIG_ARM=y
+CONFIG_ARCH_CPU_INIT=y
+CONFIG_ARCH_MVEBU=y
+CONFIG_SYS_TEXT_BASE=0x0080
+CONFIG_SYS_MALLOC_F_LEN=0x2000
+CONFIG_TARGET_CRS3XX_98DX3236=y
+CONFIG_ENV_SIZE=0x1
+CONFIG_ENV_SECT_SIZE=0x1
+CONFIG_ENV_OFFSET=0x1F
+CONFIG_BOOTCOUNT_BOOTLIMIT=3
+# CONFIG_EFI_LOADER is not set
+CONFIG_BUILD_TARGET="u-boot.kwb"
+CONFIG_USE_PREBOOT=y
+CONFIG_SYS_CONSOLE_INFO_QUIET=y
+CONFIG_HUSH_PARSER=y
+CONFIG_AUTOBOOT_KEYED=y
+CONFIG_AUTOBOOT_PROMPT="Autoboot in %d seconds, to stop use 's' key\n"
+CONFIG_AUTOBOOT_STOP_STR="s"
+CONFIG_AUTOBOOT_KEYED_CTRLC=y
+CONFIG_CMD_BOOTZ=y
+# CONFIG_CMD_FLASH is not set
+# CONFIG_CMD_I2C is not set
+CONFIG_CMD_SPI=y
+CONFIG_CMD_CACHE=y
+CONFIG_CMD_UBI=y
+CONFIG_CMD_FS_GENERIC=y
+CONFIG_CMD_MTD=y
+CONFIG_CMD_MTDPARTS=y
+CONFIG_DEFAULT_DEVICE_TREE="armada-xp-crs305-1g-4s-bit"
+CONFIG_ENV_IS_IN_SPI_FLASH=y
+CONFIG_SYS_RELOC_GD_ENV_ADDR=y
+CONFIG_BLK=y
+CONFIG_BOOTCOUNT_LIMIT=y
+CONFIG_BOOTCOUNT_ENV=y
+# CONFIG_DM_I2C is not set
+# CONFIG_SYS_I2C_MVTWSI is not set
+# CONFIG_MMC is not set
+CONFIG_MTD=y
+CONFIG_MTD_PARTITIONS=y
+CONFIG_DM_MTD=y
+CONFIG_DM_SPI_FLASH=y
+CONFIG_SPI_FLASH_MTD=y
+CONFIG_SPI_FLASH_SFDP_SUPPORT=y
+CONFIG_SPI_FLASH_BAR=y
+CONFIG_SPI_FLASH_MACRONIX=y
+# CONFIG_SPI_FLASH_USE_4K_SECTORS is not set
+CONFIG_FIT=y
+CONFIG_FIT_ENABLE_SHA256_SUPPORT=y
+CONFIG_FIT_VERBOSE=y
+CONFIG_FIT_BEST_MATCH=y
+CONFIG_PCI=y
+CONFIG_PCI_MVEBU=y
+CONFIG_SYS_NS16550=y
+CONFIG_KIRKWOOD_SPI=y
-- 
2.26.2



[PATCH 2/5] arm: mvebu: Add CRS326-24G-2S board

2020-07-23 Thread Luka Kovacic
MikroTik CRS326-24G-2S board has a switch chip with an integrated
Marvell Prestera 98DX3236 CPU.

This commit includes two board variants, namely the factory
default one and a Bit variant. The Bit board variant has a
bigger Macronix flash.

Add basic U-Boot, UART and SPI flash support.

Signed-off-by: Luka Kovacic 
Cc: Luka Perkov 
Cc: Jakov Petrina 
---
 arch/arm/dts/Makefile |   2 +
 arch/arm/dts/armada-xp-crs326-24g-2s-bit.dts  |  43 +++
 .../dts/armada-xp-crs326-24g-2s-u-boot.dtsi   |  13 +++
 arch/arm/dts/armada-xp-crs326-24g-2s.dts  |  17 +++
 arch/arm/dts/armada-xp-crs326-24g-2s.dtsi | 110 ++
 board/mikrotik/crs3xx-98dx3236/MAINTAINERS|   9 ++
 configs/crs326-24g-2s-bit_defconfig   |  54 +
 configs/crs326-24g-2s_defconfig   |  54 +
 8 files changed, 302 insertions(+)
 create mode 100644 arch/arm/dts/armada-xp-crs326-24g-2s-bit.dts
 create mode 100644 arch/arm/dts/armada-xp-crs326-24g-2s-u-boot.dtsi
 create mode 100644 arch/arm/dts/armada-xp-crs326-24g-2s.dts
 create mode 100644 arch/arm/dts/armada-xp-crs326-24g-2s.dtsi
 create mode 100644 configs/crs326-24g-2s-bit_defconfig
 create mode 100644 configs/crs326-24g-2s_defconfig

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 72e1f4fa20..9f8ca61f28 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -214,6 +214,8 @@ dtb-$(CONFIG_ARCH_MVEBU) += \
armada-8040-mcbin.dtb   \
armada-xp-crs305-1g-4s.dtb  \
armada-xp-crs305-1g-4s-bit.dtb  \
+   armada-xp-crs326-24g-2s.dtb \
+   armada-xp-crs326-24g-2s-bit.dtb \
armada-xp-db-xc3-24g4xg.dtb \
armada-xp-gp.dtb\
armada-xp-maxbcm.dtb\
diff --git a/arch/arm/dts/armada-xp-crs326-24g-2s-bit.dts 
b/arch/arm/dts/armada-xp-crs326-24g-2s-bit.dts
new file mode 100644
index 00..b340eedf71
--- /dev/null
+++ b/arch/arm/dts/armada-xp-crs326-24g-2s-bit.dts
@@ -0,0 +1,43 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Device Tree file for MikroTik CRS326-24G-2S+ Bit board
+ *
+ * Copyright (C) 2020 Sartura Ltd.
+ * Author: Luka Kovacic 
+ */
+
+#include "armada-xp-crs326-24g-2s.dtsi"
+
+/ {
+   model = "MikroTik CRS326-24G-2S+ Bit";
+};
+
+ {
+   status = "okay";
+
+   spi-flash@0 {
+   #address-cells = <1>;
+   #size-cells = <1>;
+   compatible = "spi-flash", "jedec,spi-nor";
+   reg = <0>; /* Chip select 0 */
+   spi-max-frequency = <10800>;
+   m25p,fast-read;
+
+   partition@u-boot {
+   reg = <0x 0x001f>;
+   label = "u-boot";
+   };
+   partition@u-boot-env {
+   reg = <0x001f 0x0001>;
+   label = "u-boot-env";
+   };
+   partition@ubi1 {
+   reg = <0x0020 0x03f0>;
+   label = "ubi1";
+   };
+   partition@ubi2 {
+   reg = <0x0410 0x03f0>;
+   label = "ubi2";
+   };
+   };
+};
diff --git a/arch/arm/dts/armada-xp-crs326-24g-2s-u-boot.dtsi 
b/arch/arm/dts/armada-xp-crs326-24g-2s-u-boot.dtsi
new file mode 100644
index 00..8576a02730
--- /dev/null
+++ b/arch/arm/dts/armada-xp-crs326-24g-2s-u-boot.dtsi
@@ -0,0 +1,13 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+
+ {
+   u-boot,dm-pre-reloc;
+};
+
+ {
+   u-boot,dm-pre-reloc;
+
+   spi-flash@0 {
+   u-boot,dm-pre-reloc;
+   };
+};
diff --git a/arch/arm/dts/armada-xp-crs326-24g-2s.dts 
b/arch/arm/dts/armada-xp-crs326-24g-2s.dts
new file mode 100644
index 00..83aef43f66
--- /dev/null
+++ b/arch/arm/dts/armada-xp-crs326-24g-2s.dts
@@ -0,0 +1,17 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Device Tree file for MikroTik CRS326-24G-2S+ board
+ *
+ * Copyright (C) 2020 Sartura Ltd.
+ * Author: Luka Kovacic 
+ */
+
+#include "armada-xp-crs326-24g-2s.dtsi"
+
+/ {
+   model = "MikroTik CRS326-24G-2S+";
+};
+
+ {
+   status = "okay";
+};
diff --git a/arch/arm/dts/armada-xp-crs326-24g-2s.dtsi 
b/arch/arm/dts/armada-xp-crs326-24g-2s.dtsi
new file mode 100644
index 00..e50f3ead13
--- /dev/null
+++ b/arch/arm/dts/armada-xp-crs326-24g-2s.dtsi
@@ -0,0 +1,110 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Device Tree file for CRS326-24G-2S board
+ *
+ * Copyright (C) 2016 Allied Telesis Labs
+ * Copyright (C) 2020 Sartura Ltd.
+ *
+ * Based on armada-xp-db.dts
+ *
+ * Note: this Device Tree assumes that the bootloader has remapped the
+ *

[PATCH v3] arm: mvebu: Convert CRS305-1G-4S board to CRS3xx-98DX3236

2020-05-26 Thread Luka Kovacic
Convert the CRS305-1G-4S board to CRS3xx-98DX3236 to enable easier
implementation of new CRS3xx series boards, based on Marvell Prestera
98DX3236.

Signed-off-by: Luka Kovacic 
Cc: Luka Perkov 
Cc: Jakov Petrina 
---
Changes for v2:
   - Fix the patch failing to merge into the current U-Boot tree
Changes for v3:
   - Fix the patch failing to merge into the current U-Boot tree

 arch/arm/dts/armada-xp-crs305-1g-4s.dts   | 103 +---
 arch/arm/dts/armada-xp-crs305-1g-4s.dtsi  | 111 ++
 arch/arm/mach-mvebu/Kconfig   |  10 +-
 board/mikrotik/crs305-1g-4s/MAINTAINERS   |   7 --
 .../.gitignore|   0
 board/mikrotik/crs3xx-98dx3236/MAINTAINERS|  11 ++
 .../Makefile  |   2 +-
 .../{crs305-1g-4s => crs3xx-98dx3236}/README  |  12 +-
 .../binary.0  |   0
 .../crs3xx-98dx3236.c}|   0
 .../kwbimage.cfg.in   |   2 +-
 configs/crs305-1g-4s_defconfig|  46 
 .../{crs305-1g-4s.h => crs3xx-98dx3236.h} |   6 +-
 13 files changed, 165 insertions(+), 145 deletions(-)
 create mode 100644 arch/arm/dts/armada-xp-crs305-1g-4s.dtsi
 delete mode 100644 board/mikrotik/crs305-1g-4s/MAINTAINERS
 rename board/mikrotik/{crs305-1g-4s => crs3xx-98dx3236}/.gitignore (100%)
 create mode 100644 board/mikrotik/crs3xx-98dx3236/MAINTAINERS
 rename board/mikrotik/{crs305-1g-4s => crs3xx-98dx3236}/Makefile (93%)
 rename board/mikrotik/{crs305-1g-4s => crs3xx-98dx3236}/README (64%)
 rename board/mikrotik/{crs305-1g-4s => crs3xx-98dx3236}/binary.0 (100%)
 rename board/mikrotik/{crs305-1g-4s/crs305-1g-4s.c => 
crs3xx-98dx3236/crs3xx-98dx3236.c} (100%)
 rename board/mikrotik/{crs305-1g-4s => crs3xx-98dx3236}/kwbimage.cfg.in (75%)
 rename include/configs/{crs305-1g-4s.h => crs3xx-98dx3236.h} (87%)

diff --git a/arch/arm/dts/armada-xp-crs305-1g-4s.dts 
b/arch/arm/dts/armada-xp-crs305-1g-4s.dts
index 1116f5c96c..010b83b542 100644
--- a/arch/arm/dts/armada-xp-crs305-1g-4s.dts
+++ b/arch/arm/dts/armada-xp-crs305-1g-4s.dts
@@ -1,110 +1,17 @@
 // SPDX-License-Identifier: (GPL-2.0+ OR MIT)
 /*
- * Device Tree file for CRS305-1G-4S board
+ * Device Tree file for MikroTik CRS305-1G-4S+ board
  *
- * Copyright (C) 2016 Allied Telesis Labs
- *
- * Based on armada-xp-db.dts
- *
- * Note: this Device Tree assumes that the bootloader has remapped the
- * internal registers to 0xf100 (instead of the default
- * 0xd000). The 0xf100 is the default used by the recent,
- * DT-capable, U-Boot bootloaders provided by Marvell. Some earlier
- * boards were delivered with an older version of the bootloader that
- * left internal registers mapped at 0xd000. If you are in this
- * situation, you should either update your bootloader (preferred
- * solution) or the below Device Tree should be adjusted.
+ * Copyright (C) 2020 Sartura Ltd.
+ * Author: Luka Kovacic 
  */
 
-/dts-v1/;
-#include "armada-xp-98dx3236.dtsi"
-#include "armada-xp-crs305-1g-4s-u-boot.dtsi"
+#include "armada-xp-crs305-1g-4s.dtsi"
 
 / {
-   model = "CRS305-1G-4S";
-   compatible = "marvell,armadaxp-98dx3236", "marvell,armadaxp-mv78260", 
"marvell,armadaxp", "marvell,armada-370-xp";
-
-   chosen {
-   stdout-path = "serial0:115200n8";
-   bootargs = "console=ttyS0,115200 earlyprintk";
-   };
-
-   aliases {
-   spi0 = 
-   };
-
-   memory {
-   device_type = "memory";
-   reg = <0 0x 0 0x2000>; /* 512 MB */
-   };
-};
-
- {
-   arm,parity-enable;
-   marvell,ecc-enable;
-};
-
-_bootcs {
-   status = "okay";
-
-   /* Device Bus parameters are required */
-
-   /* Read parameters */
-   devbus,bus-width= <16>;
-   devbus,turn-off-ps  = <6>;
-   devbus,badr-skew-ps = <0>;
-   devbus,acc-first-ps = <124000>;
-   devbus,acc-next-ps  = <248000>;
-   devbus,rd-setup-ps  = <0>;
-   devbus,rd-hold-ps   = <0>;
-
-   /* Write parameters */
-   devbus,sync-enable = <0>;
-   devbus,wr-high-ps  = <6>;
-   devbus,wr-low-ps   = <6>;
-   devbus,ale-wr-ps   = <6>;
-};
-
- {
-   status = "okay";
-};
-
- {
-   status = "okay";
-};
-
- {
-   clock-frequency = <10>;
-   status = "okay";
-};
-
- {
-   status = "okay";
+   model = "MikroTik CRS305-1G-4S+";
 };
 
  {
status = "okay";
-
-   spi-flash@0 {
-   #address-cells = <1>;
-   #size-cells = <1>;
-   compatible = "spi-flash", "jedec,spi-nor";

[PATCH v2] arm: mvebu: Convert CRS305-1G-4S board to CRS3xx-98DX3236

2020-05-07 Thread Luka Kovacic
Convert the CRS305-1G-4S board to CRS3xx-98DX3236 to enable easier
implementation of new CRS3xx series boards, based on Marvell Prestera
98DX3236.

Signed-off-by: Luka Kovacic 
Cc: Luka Perkov 
Cc: Jakov Petrina 
---
Changes for v2:
   - Fix the patch failing to merge into the current U-Boot tree

 arch/arm/dts/armada-xp-crs305-1g-4s.dts   | 103 +---
 arch/arm/dts/armada-xp-crs305-1g-4s.dtsi  | 111 ++
 arch/arm/mach-mvebu/Kconfig   |  10 +-
 board/mikrotik/crs305-1g-4s/MAINTAINERS   |   7 --
 .../.gitignore|   0
 board/mikrotik/crs3xx-98dx3236/MAINTAINERS|  11 ++
 .../Makefile  |   2 +-
 .../{crs305-1g-4s => crs3xx-98dx3236}/README  |  12 +-
 .../binary.0  |   0
 .../crs3xx-98dx3236.c}|   0
 .../kwbimage.cfg.in   |   2 +-
 configs/crs305-1g-4s_defconfig|  44 +++
 .../{crs305-1g-4s.h => crs3xx-98dx3236.h} |   6 +-
 13 files changed, 165 insertions(+), 143 deletions(-)
 create mode 100644 arch/arm/dts/armada-xp-crs305-1g-4s.dtsi
 delete mode 100644 board/mikrotik/crs305-1g-4s/MAINTAINERS
 rename board/mikrotik/{crs305-1g-4s => crs3xx-98dx3236}/.gitignore (100%)
 create mode 100644 board/mikrotik/crs3xx-98dx3236/MAINTAINERS
 rename board/mikrotik/{crs305-1g-4s => crs3xx-98dx3236}/Makefile (93%)
 rename board/mikrotik/{crs305-1g-4s => crs3xx-98dx3236}/README (64%)
 rename board/mikrotik/{crs305-1g-4s => crs3xx-98dx3236}/binary.0 (100%)
 rename board/mikrotik/{crs305-1g-4s/crs305-1g-4s.c => 
crs3xx-98dx3236/crs3xx-98dx3236.c} (100%)
 rename board/mikrotik/{crs305-1g-4s => crs3xx-98dx3236}/kwbimage.cfg.in (75%)
 rename include/configs/{crs305-1g-4s.h => crs3xx-98dx3236.h} (87%)

diff --git a/arch/arm/dts/armada-xp-crs305-1g-4s.dts 
b/arch/arm/dts/armada-xp-crs305-1g-4s.dts
index 1116f5c96c..010b83b542 100644
--- a/arch/arm/dts/armada-xp-crs305-1g-4s.dts
+++ b/arch/arm/dts/armada-xp-crs305-1g-4s.dts
@@ -1,110 +1,17 @@
 // SPDX-License-Identifier: (GPL-2.0+ OR MIT)
 /*
- * Device Tree file for CRS305-1G-4S board
+ * Device Tree file for MikroTik CRS305-1G-4S+ board
  *
- * Copyright (C) 2016 Allied Telesis Labs
- *
- * Based on armada-xp-db.dts
- *
- * Note: this Device Tree assumes that the bootloader has remapped the
- * internal registers to 0xf100 (instead of the default
- * 0xd000). The 0xf100 is the default used by the recent,
- * DT-capable, U-Boot bootloaders provided by Marvell. Some earlier
- * boards were delivered with an older version of the bootloader that
- * left internal registers mapped at 0xd000. If you are in this
- * situation, you should either update your bootloader (preferred
- * solution) or the below Device Tree should be adjusted.
+ * Copyright (C) 2020 Sartura Ltd.
+ * Author: Luka Kovacic 
  */
 
-/dts-v1/;
-#include "armada-xp-98dx3236.dtsi"
-#include "armada-xp-crs305-1g-4s-u-boot.dtsi"
+#include "armada-xp-crs305-1g-4s.dtsi"
 
 / {
-   model = "CRS305-1G-4S";
-   compatible = "marvell,armadaxp-98dx3236", "marvell,armadaxp-mv78260", 
"marvell,armadaxp", "marvell,armada-370-xp";
-
-   chosen {
-   stdout-path = "serial0:115200n8";
-   bootargs = "console=ttyS0,115200 earlyprintk";
-   };
-
-   aliases {
-   spi0 = 
-   };
-
-   memory {
-   device_type = "memory";
-   reg = <0 0x 0 0x2000>; /* 512 MB */
-   };
-};
-
- {
-   arm,parity-enable;
-   marvell,ecc-enable;
-};
-
-_bootcs {
-   status = "okay";
-
-   /* Device Bus parameters are required */
-
-   /* Read parameters */
-   devbus,bus-width= <16>;
-   devbus,turn-off-ps  = <6>;
-   devbus,badr-skew-ps = <0>;
-   devbus,acc-first-ps = <124000>;
-   devbus,acc-next-ps  = <248000>;
-   devbus,rd-setup-ps  = <0>;
-   devbus,rd-hold-ps   = <0>;
-
-   /* Write parameters */
-   devbus,sync-enable = <0>;
-   devbus,wr-high-ps  = <6>;
-   devbus,wr-low-ps   = <6>;
-   devbus,ale-wr-ps   = <6>;
-};
-
- {
-   status = "okay";
-};
-
- {
-   status = "okay";
-};
-
- {
-   clock-frequency = <10>;
-   status = "okay";
-};
-
- {
-   status = "okay";
+   model = "MikroTik CRS305-1G-4S+";
 };
 
  {
status = "okay";
-
-   spi-flash@0 {
-   #address-cells = <1>;
-   #size-cells = <1>;
-   compatible = "spi-flash", "jedec,spi-nor";
-   reg = <0>; /* Chip select 0 */
-   spi-max-frequency = <1080

[PATCH] arm: mvebu: Convert CRS305-1G-4S board to CRS3xx-98DX3236

2020-05-07 Thread Luka Kovacic
Convert the CRS305-1G-4S board to CRS3xx-98DX3236 to enable easier
implementation of new CRS3xx series boards, based on Marvell Prestera
98DX3236.

Signed-off-by: Luka Kovacic 
Cc: Luka Perkov 
Cc: Jakov Petrina 
---
 arch/arm/dts/armada-xp-crs305-1g-4s.dts   | 103 +---
 arch/arm/dts/armada-xp-crs305-1g-4s.dtsi  | 111 ++
 arch/arm/mach-mvebu/Kconfig   |  10 +-
 board/mikrotik/crs305-1g-4s/MAINTAINERS   |   7 --
 .../.gitignore|   0
 board/mikrotik/crs3xx-98dx3236/MAINTAINERS|  11 ++
 .../Makefile  |   2 +-
 .../{crs305-1g-4s => crs3xx-98dx3236}/README  |  12 +-
 .../binary.0  |   0
 .../crs3xx-98dx3236.c}|   0
 .../kwbimage.cfg.in   |   2 +-
 configs/crs305-1g-4s_defconfig|  44 +++
 .../{crs305-1g-4s.h => crs3xx-98dx3236.h} |   6 +-
 13 files changed, 165 insertions(+), 143 deletions(-)
 create mode 100644 arch/arm/dts/armada-xp-crs305-1g-4s.dtsi
 delete mode 100644 board/mikrotik/crs305-1g-4s/MAINTAINERS
 rename board/mikrotik/{crs305-1g-4s => crs3xx-98dx3236}/.gitignore (100%)
 create mode 100644 board/mikrotik/crs3xx-98dx3236/MAINTAINERS
 rename board/mikrotik/{crs305-1g-4s => crs3xx-98dx3236}/Makefile (93%)
 rename board/mikrotik/{crs305-1g-4s => crs3xx-98dx3236}/README (64%)
 rename board/mikrotik/{crs305-1g-4s => crs3xx-98dx3236}/binary.0 (100%)
 rename board/mikrotik/{crs305-1g-4s/crs305-1g-4s.c => 
crs3xx-98dx3236/crs3xx-98dx3236.c} (100%)
 rename board/mikrotik/{crs305-1g-4s => crs3xx-98dx3236}/kwbimage.cfg.in (75%)
 rename include/configs/{crs305-1g-4s.h => crs3xx-98dx3236.h} (87%)

diff --git a/arch/arm/dts/armada-xp-crs305-1g-4s.dts 
b/arch/arm/dts/armada-xp-crs305-1g-4s.dts
index 1116f5c96c..010b83b542 100644
--- a/arch/arm/dts/armada-xp-crs305-1g-4s.dts
+++ b/arch/arm/dts/armada-xp-crs305-1g-4s.dts
@@ -1,110 +1,17 @@
 // SPDX-License-Identifier: (GPL-2.0+ OR MIT)
 /*
- * Device Tree file for CRS305-1G-4S board
+ * Device Tree file for MikroTik CRS305-1G-4S+ board
  *
- * Copyright (C) 2016 Allied Telesis Labs
- *
- * Based on armada-xp-db.dts
- *
- * Note: this Device Tree assumes that the bootloader has remapped the
- * internal registers to 0xf100 (instead of the default
- * 0xd000). The 0xf100 is the default used by the recent,
- * DT-capable, U-Boot bootloaders provided by Marvell. Some earlier
- * boards were delivered with an older version of the bootloader that
- * left internal registers mapped at 0xd000. If you are in this
- * situation, you should either update your bootloader (preferred
- * solution) or the below Device Tree should be adjusted.
+ * Copyright (C) 2020 Sartura Ltd.
+ * Author: Luka Kovacic 
  */
 
-/dts-v1/;
-#include "armada-xp-98dx3236.dtsi"
-#include "armada-xp-crs305-1g-4s-u-boot.dtsi"
+#include "armada-xp-crs305-1g-4s.dtsi"
 
 / {
-   model = "CRS305-1G-4S";
-   compatible = "marvell,armadaxp-98dx3236", "marvell,armadaxp-mv78260", 
"marvell,armadaxp", "marvell,armada-370-xp";
-
-   chosen {
-   stdout-path = "serial0:115200n8";
-   bootargs = "console=ttyS0,115200 earlyprintk";
-   };
-
-   aliases {
-   spi0 = 
-   };
-
-   memory {
-   device_type = "memory";
-   reg = <0 0x 0 0x2000>; /* 512 MB */
-   };
-};
-
- {
-   arm,parity-enable;
-   marvell,ecc-enable;
-};
-
-_bootcs {
-   status = "okay";
-
-   /* Device Bus parameters are required */
-
-   /* Read parameters */
-   devbus,bus-width= <16>;
-   devbus,turn-off-ps  = <6>;
-   devbus,badr-skew-ps = <0>;
-   devbus,acc-first-ps = <124000>;
-   devbus,acc-next-ps  = <248000>;
-   devbus,rd-setup-ps  = <0>;
-   devbus,rd-hold-ps   = <0>;
-
-   /* Write parameters */
-   devbus,sync-enable = <0>;
-   devbus,wr-high-ps  = <6>;
-   devbus,wr-low-ps   = <6>;
-   devbus,ale-wr-ps   = <6>;
-};
-
- {
-   status = "okay";
-};
-
- {
-   status = "okay";
-};
-
- {
-   clock-frequency = <10>;
-   status = "okay";
-};
-
- {
-   status = "okay";
+   model = "MikroTik CRS305-1G-4S+";
 };
 
  {
status = "okay";
-
-   spi-flash@0 {
-   #address-cells = <1>;
-   #size-cells = <1>;
-   compatible = "spi-flash", "jedec,spi-nor";
-   reg = <0>; /* Chip select 0 */
-   spi-max-frequency = <10800>;
-   m25p,fast-read;
-
-   partition@u-boot {
-   

[PATCH 1/1] arm: mvebu: dts: Sort Armada series dts alphabetically

2020-03-20 Thread luka . kovacic
From: Josip Kelečić 

Sort the Armada series dts in the Makefile alphabetically
prior to adding new board support.

Signed-off-by: Josip Kelečić 
Reviewed-by: Luka Kovacic 
Cc: Luka Perkov 
---
 arch/arm/dts/Makefile | 20 ++--
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 9c593b2c98..2c269d63a5 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -188,25 +188,25 @@ dtb-$(CONFIG_ARCH_MVEBU) +=   \
armada-3720-turris-mox.dtb  \
armada-3720-uDPU.dtb\
armada-375-db.dtb   \
+   armada-385-atl-x530.dtb \
+   armada-385-atl-x530DP.dtb   \
+   armada-385-db-88f6820-amc.dtb   \
+   armada-385-turris-omnia.dtb \
armada-388-clearfog.dtb \
armada-388-gp.dtb   \
armada-388-helios4.dtb  \
-   armada-385-db-88f6820-amc.dtb   \
-   armada-385-turris-omnia.dtb \
-   armada-7040-db.dtb  \
+   armada-38x-controlcenterdc.dtb  \
armada-7040-db-nand.dtb \
+   armada-7040-db.dtb  \
+   armada-8040-clearfog-gt-8k.dtb  \
armada-8040-db.dtb  \
armada-8040-mcbin.dtb   \
-   armada-8040-clearfog-gt-8k.dtb  \
+   armada-xp-crs305-1g-4s.dtb  \
+   armada-xp-db-xc3-24g4xg.dtb \
armada-xp-gp.dtb\
armada-xp-maxbcm.dtb\
armada-xp-synology-ds414.dtb\
-   armada-xp-theadorable.dtb   \
-   armada-38x-controlcenterdc.dtb  \
-   armada-385-atl-x530.dtb \
-   armada-385-atl-x530DP.dtb   \
-   armada-xp-db-xc3-24g4xg.dtb \
-   armada-xp-crs305-1g-4s.dtb
+   armada-xp-theadorable.dtb
 
 dtb-$(CONFIG_ARCH_UNIPHIER_LD11) += \
uniphier-ld11-global.dtb \
-- 
2.20.1



[PATCH 1/2 v1] cmd: doc: Update command return values

2020-01-26 Thread luka . kovacic
From: Luka Kovacic 

Update the command return values to CMD_RET_SUCCESS and
CMD_RET_FAILURE in commands documentation.

Signed-off-by: Luka Kovacic 
---
 doc/README.commands | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/doc/README.commands b/doc/README.commands
index e03eb44187..4e9e8098fa 100644
--- a/doc/README.commands
+++ b/doc/README.commands
@@ -83,9 +83,9 @@ argv: Arguments.
 
 Allowable return value are:
 
-CMD_SUCCESSThe command was successfully executed.
+CMD_RET_SUCCESSThe command was successfully executed.
 
-CMD_FAILUREThe command failed.
+CMD_RET_FAILUREThe command failed.
 
 CMD_RET_USAGE  The command was called with invalid parameters. This value
leads to the display of the usage string.
-- 
2.20.1



[PATCH 2/2 v1] cmd: gpio: Add the command return value to the help text

2020-01-26 Thread luka . kovacic
From: Luka Kovacic 

Adds the command return value to the help text, since pin value
is returned.

Cc: Luka Perkov 
Signed-off-by: Luka Kovacic 
---
 cmd/gpio.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/cmd/gpio.c b/cmd/gpio.c
index eff36ab2af..e57d3fb638 100644
--- a/cmd/gpio.c
+++ b/cmd/gpio.c
@@ -245,5 +245,6 @@ static int do_gpio(cmd_tbl_t *cmdtp, int flag, int argc, 
char * const argv[])
 U_BOOT_CMD(gpio, 4, 0, do_gpio,
   "query and control gpio pins",
   " \n"
-  "- input/set/clear/toggle the specified pin\n"
+  "- input/set/clear/toggle the specified pin; pin value is\n"
+  "  returned.\n"
   "gpio status [-a] [ | ]  - show [all/claimed] GPIOs");
-- 
2.20.1



[PATCH 0/1 v1] cmd: gpio: Correct do_gpio() return value

2020-01-06 Thread Luka Kovacic
Hi,
The U-Boot gpio command always returns the value of the pin, which 
is confusing if you are debugging, since calling the command
gpio set pin always results in failure. 

The patch modifies the GPIO command to return CMD_RET_SUCCESS 
on success and CMD_RET_FAILURE on command failure and doesn't
use the pin value as a return value. 

Should this be changed, since users may rely on this in scripts?
What would be the best workaround?

Luka Kovacic (1):
  cmd: gpio: Correct do_gpio() return value

 cmd/gpio.c  | 22 +-
 doc/README.commands |  4 ++--
 2 files changed, 19 insertions(+), 7 deletions(-)

-- 
2.20.1



[PATCH 1/1 v1] cmd: gpio: Correct do_gpio() return value

2020-01-06 Thread Luka Kovacic
Use the correct return value in function do_gpio() and update
commands documentation with the return values from command_ret_t enum.

CMD_RET_SUCCESS is returned on command success and CMD_RET_FAILURE is
returned on command failure.

The command was returning the pin value, which caused confusion when
debugging (#define DEBUG).

Signed-off-by: Luka Kovacic 
Tested-by: Robert Marko 
---
 cmd/gpio.c  | 22 +-
 doc/README.commands |  4 ++--
 2 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/cmd/gpio.c b/cmd/gpio.c
index eff36ab2af..67eef83c95 100644
--- a/cmd/gpio.c
+++ b/cmd/gpio.c
@@ -223,23 +223,35 @@ static int do_gpio(cmd_tbl_t *cmdtp, int flag, int argc, 
char * const argv[])
gpio_direction_output(gpio, value);
}
printf("gpio: pin %s (gpio %u) value is ", str_gpio, gpio);
-   if (IS_ERR_VALUE(value))
+
+   if (IS_ERR_VALUE(value)) {
printf("unknown (ret=%d)\n", value);
-   else
+   goto err;
+   } else {
printf("%d\n", value);
+   }
+
if (sub_cmd != GPIOC_INPUT && !IS_ERR_VALUE(value)) {
int nval = gpio_get_value(gpio);
 
-   if (IS_ERR_VALUE(nval))
+   if (IS_ERR_VALUE(nval)) {
printf("   Warning: no access to GPIO output value\n");
-   else if (nval != value)
+   goto err;
+   } else if (nval != value) {
printf("   Warning: value of pin is still %d\n", nval);
+   goto err;
+   }
}
 
if (ret != -EBUSY)
gpio_free(gpio);
 
-   return value;
+   return CMD_RET_SUCCESS;
+
+err:
+   if (ret != -EBUSY)
+   gpio_free(gpio);
+   return CMD_RET_FAILURE;
 }
 
 U_BOOT_CMD(gpio, 4, 0, do_gpio,
diff --git a/doc/README.commands b/doc/README.commands
index e03eb44187..4e9e8098fa 100644
--- a/doc/README.commands
+++ b/doc/README.commands
@@ -83,9 +83,9 @@ argv: Arguments.
 
 Allowable return value are:
 
-CMD_SUCCESSThe command was successfully executed.
+CMD_RET_SUCCESSThe command was successfully executed.
 
-CMD_FAILUREThe command failed.
+CMD_RET_FAILUREThe command failed.
 
 CMD_RET_USAGE  The command was called with invalid parameters. This value
leads to the display of the usage string.
-- 
2.20.1



Re: [U-Boot] [PATCH 1/1 v1] arm: mvebu: crs305-1g-4s: Enable CMD_BOOTZ and increase SYS_BOOTM_LEN

2019-07-10 Thread Luka Kovacic

On 2019-06-26 07:17, Stefan Roese wrote:

On 25.06.19 13:57, Luka Kovacic wrote:

This change enables CMD_BOOTZ and increases SYS_BOOTM_LEN to
make it easier to work with kernel images.

Signed-off-by: Luka Kovacic 


Reviewed-by: Stefan Roese 

Thanks,
Stefan

Hi,
When will the patch be applied to U-Boot mainline tree?

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


[U-Boot] [PATCH 1/1 v1] arm: mvebu: crs305-1g-4s: Enable CMD_BOOTZ and increase SYS_BOOTM_LEN

2019-06-25 Thread Luka Kovacic
This change enables CMD_BOOTZ and increases SYS_BOOTM_LEN to
make it easier to work with kernel images.

Signed-off-by: Luka Kovacic 
---
 configs/crs305-1g-4s_defconfig | 1 +
 include/configs/crs305-1g-4s.h | 1 +
 2 files changed, 2 insertions(+)

diff --git a/configs/crs305-1g-4s_defconfig b/configs/crs305-1g-4s_defconfig
index 26e1c91f29..df77cb89ca 100644
--- a/configs/crs305-1g-4s_defconfig
+++ b/configs/crs305-1g-4s_defconfig
@@ -7,6 +7,7 @@ CONFIG_BUILD_TARGET="u-boot.kwb"
 CONFIG_SYS_CONSOLE_INFO_QUIET=y
 CONFIG_CMD_MEMTEST=y
 CONFIG_SYS_ALT_MEMTEST=y
+CONFIG_CMD_BOOTZ=y
 # CONFIG_CMD_FLASH is not set
 CONFIG_CMD_I2C=y
 CONFIG_CMD_SF=y
diff --git a/include/configs/crs305-1g-4s.h b/include/configs/crs305-1g-4s.h
index c73cb99b1b..a2df69adc7 100644
--- a/include/configs/crs305-1g-4s.h
+++ b/include/configs/crs305-1g-4s.h
@@ -10,6 +10,7 @@
  * High Level Configuration Options (easy to change)
  */
 
+#define CONFIG_SYS_BOOTM_LEN   (64 * 1024 * 1024) /* 64 MB */
 #define CONFIG_SYS_KWD_CONFIG  $(CONFIG_BOARDDIR)/kwbimage.cfg
 #define CONFIG_SYS_TCLK2   /* 200MHz */
 
-- 
2.20.1

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


[U-Boot] [PATCH 1/1 v4] arm: mvebu: Add CRS305-1G-4S board

2019-05-07 Thread Luka Kovacic
CRS305-1G-4S has a switch chip with an integrated CPU (98DX3236) and
like some of the other similar boards requires bin_hdr.
bin_hdr (DDR3 init stage) is currently retrieved from the stock
bootloader and compiled into the kwb image.

Adds support for U-Boot, enable UART, SPI, Winbond SPI flash chip
support and writing env to SPI flash.

Signed-off-by: Luka Kovacic 
---
v1:
   - arch/arm/dts: Remove unused parameters in DTS for crs305-1g-4s
   - arch/arm/mach-mvebu: Set the proper processor for crs305-1g-4s
 (98DX3236)

Changes for v2:
   - board/mikrotik/crs305-1g-4s: Enable CONFIG_DISPLAY_BOARDINFO

Changes for v3:
   - board/mikrotik/crs305-1g-4s: Remove GPIO1 (Reset Button)

Changes for v4:
   - board/mikrotik/crs305-1g-4s: Rewrite lines that exceed 80 characters

 arch/arm/dts/Makefile |   3 +-
 .../dts/armada-xp-crs305-1g-4s-u-boot.dtsi|  13 +++
 arch/arm/dts/armada-xp-crs305-1g-4s.dts   | 110 ++
 arch/arm/mach-mvebu/Kconfig   |   7 ++
 board/mikrotik/crs305-1g-4s/.gitignore|   1 +
 board/mikrotik/crs305-1g-4s/MAINTAINERS   |   7 ++
 board/mikrotik/crs305-1g-4s/Makefile  |  14 +++
 board/mikrotik/crs305-1g-4s/README|  23 
 board/mikrotik/crs305-1g-4s/binary.0  |  11 ++
 board/mikrotik/crs305-1g-4s/crs305-1g-4s.c|  75 
 board/mikrotik/crs305-1g-4s/kwbimage.cfg.in   |  12 ++
 configs/crs305-1g-4s_defconfig|  52 +
 include/configs/crs305-1g-4s.h|  37 ++
 13 files changed, 364 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/dts/armada-xp-crs305-1g-4s-u-boot.dtsi
 create mode 100644 arch/arm/dts/armada-xp-crs305-1g-4s.dts
 create mode 100644 board/mikrotik/crs305-1g-4s/.gitignore
 create mode 100644 board/mikrotik/crs305-1g-4s/MAINTAINERS
 create mode 100644 board/mikrotik/crs305-1g-4s/Makefile
 create mode 100644 board/mikrotik/crs305-1g-4s/README
 create mode 100644 board/mikrotik/crs305-1g-4s/binary.0
 create mode 100644 board/mikrotik/crs305-1g-4s/crs305-1g-4s.c
 create mode 100644 board/mikrotik/crs305-1g-4s/kwbimage.cfg.in
 create mode 100644 configs/crs305-1g-4s_defconfig
 create mode 100644 include/configs/crs305-1g-4s.h

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 8e082f2840..8d73bcb57f 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -162,7 +162,8 @@ dtb-$(CONFIG_ARCH_MVEBU) += \
armada-38x-controlcenterdc.dtb  \
armada-385-atl-x530.dtb \
armada-385-atl-x530DP.dtb   \
-   armada-xp-db-xc3-24g4xg.dtb
+   armada-xp-db-xc3-24g4xg.dtb \
+   armada-xp-crs305-1g-4s.dtb
 
 dtb-$(CONFIG_ARCH_UNIPHIER_LD11) += \
uniphier-ld11-global.dtb \
diff --git a/arch/arm/dts/armada-xp-crs305-1g-4s-u-boot.dtsi 
b/arch/arm/dts/armada-xp-crs305-1g-4s-u-boot.dtsi
new file mode 100644
index 00..8576a02730
--- /dev/null
+++ b/arch/arm/dts/armada-xp-crs305-1g-4s-u-boot.dtsi
@@ -0,0 +1,13 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+
+ {
+   u-boot,dm-pre-reloc;
+};
+
+ {
+   u-boot,dm-pre-reloc;
+
+   spi-flash@0 {
+   u-boot,dm-pre-reloc;
+   };
+};
diff --git a/arch/arm/dts/armada-xp-crs305-1g-4s.dts 
b/arch/arm/dts/armada-xp-crs305-1g-4s.dts
new file mode 100644
index 00..1116f5c96c
--- /dev/null
+++ b/arch/arm/dts/armada-xp-crs305-1g-4s.dts
@@ -0,0 +1,110 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Device Tree file for CRS305-1G-4S board
+ *
+ * Copyright (C) 2016 Allied Telesis Labs
+ *
+ * Based on armada-xp-db.dts
+ *
+ * Note: this Device Tree assumes that the bootloader has remapped the
+ * internal registers to 0xf100 (instead of the default
+ * 0xd000). The 0xf100 is the default used by the recent,
+ * DT-capable, U-Boot bootloaders provided by Marvell. Some earlier
+ * boards were delivered with an older version of the bootloader that
+ * left internal registers mapped at 0xd000. If you are in this
+ * situation, you should either update your bootloader (preferred
+ * solution) or the below Device Tree should be adjusted.
+ */
+
+/dts-v1/;
+#include "armada-xp-98dx3236.dtsi"
+#include "armada-xp-crs305-1g-4s-u-boot.dtsi"
+
+/ {
+   model = "CRS305-1G-4S";
+   compatible = "marvell,armadaxp-98dx3236", "marvell,armadaxp-mv78260", 
"marvell,armadaxp", "marvell,armada-370-xp";
+
+   chosen {
+   stdout-path = "serial0:115200n8";
+   bootargs = "console=ttyS0,115200 earlyprintk";
+   };
+
+   aliases {
+   spi0 = 
+   };
+
+   memory {
+   device_type = "memory";
+   reg = <0 0x 0 0x2000>; /* 512 MB */
+   };
+};
+
+ {
+   arm,parity-enable;
+   marvell,ecc-enable;
+};
+
+_bootcs {
+   status =

[U-Boot] [PATCH 1/1 v3] arm: mvebu: Add CRS305-1G-4S board

2019-05-06 Thread Luka Kovacic
CRS305-1G-4S has a switch chip with an integrated CPU (98DX3236) and
like some of the other similar boards requires bin_hdr.
bin_hdr (DDR3 init stage) is currently retrieved from the stock
bootloader and compiled into the kwb image.

Adds support for U-Boot, enable UART, SPI, Winbond SPI flash chip
support and writing env to SPI flash.

Signed-off-by: Luka Kovacic 
---
v1:
   - arch/arm/dts: Remove unused parameters in DTS for crs305-1g-4s
   - arch/arm/mach-mvebu: Set the proper processor for crs305-1g-4s
 (98DX3236)

Changes for v2:
   - board/mikrotik/crs305-1g-4s: Enable CONFIG_DISPLAY_BOARDINFO

Changes for v3:
   - board/mikrotik/crs305-1g-4s: Remove GPIO1 (Reset Button)
 
 arch/arm/dts/Makefile |   3 +-
 .../dts/armada-xp-crs305-1g-4s-u-boot.dtsi|  13 +++
 arch/arm/dts/armada-xp-crs305-1g-4s.dts   | 110 ++
 arch/arm/mach-mvebu/Kconfig   |   7 ++
 board/mikrotik/crs305-1g-4s/.gitignore|   1 +
 board/mikrotik/crs305-1g-4s/MAINTAINERS   |   7 ++
 board/mikrotik/crs305-1g-4s/Makefile  |  14 +++
 board/mikrotik/crs305-1g-4s/README|  23 
 board/mikrotik/crs305-1g-4s/binary.0  |  11 ++
 board/mikrotik/crs305-1g-4s/crs305-1g-4s.c|  71 +++
 board/mikrotik/crs305-1g-4s/kwbimage.cfg.in   |  12 ++
 configs/crs305-1g-4s_defconfig|  52 +
 include/configs/crs305-1g-4s.h|  37 ++
 13 files changed, 360 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/dts/armada-xp-crs305-1g-4s-u-boot.dtsi
 create mode 100644 arch/arm/dts/armada-xp-crs305-1g-4s.dts
 create mode 100644 board/mikrotik/crs305-1g-4s/.gitignore
 create mode 100644 board/mikrotik/crs305-1g-4s/MAINTAINERS
 create mode 100644 board/mikrotik/crs305-1g-4s/Makefile
 create mode 100644 board/mikrotik/crs305-1g-4s/README
 create mode 100644 board/mikrotik/crs305-1g-4s/binary.0
 create mode 100644 board/mikrotik/crs305-1g-4s/crs305-1g-4s.c
 create mode 100644 board/mikrotik/crs305-1g-4s/kwbimage.cfg.in
 create mode 100644 configs/crs305-1g-4s_defconfig
 create mode 100644 include/configs/crs305-1g-4s.h

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 8e082f2840..8d73bcb57f 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -162,7 +162,8 @@ dtb-$(CONFIG_ARCH_MVEBU) += \
armada-38x-controlcenterdc.dtb  \
armada-385-atl-x530.dtb \
armada-385-atl-x530DP.dtb   \
-   armada-xp-db-xc3-24g4xg.dtb
+   armada-xp-db-xc3-24g4xg.dtb \
+   armada-xp-crs305-1g-4s.dtb
 
 dtb-$(CONFIG_ARCH_UNIPHIER_LD11) += \
uniphier-ld11-global.dtb \
diff --git a/arch/arm/dts/armada-xp-crs305-1g-4s-u-boot.dtsi 
b/arch/arm/dts/armada-xp-crs305-1g-4s-u-boot.dtsi
new file mode 100644
index 00..8576a02730
--- /dev/null
+++ b/arch/arm/dts/armada-xp-crs305-1g-4s-u-boot.dtsi
@@ -0,0 +1,13 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+
+ {
+   u-boot,dm-pre-reloc;
+};
+
+ {
+   u-boot,dm-pre-reloc;
+
+   spi-flash@0 {
+   u-boot,dm-pre-reloc;
+   };
+};
diff --git a/arch/arm/dts/armada-xp-crs305-1g-4s.dts 
b/arch/arm/dts/armada-xp-crs305-1g-4s.dts
new file mode 100644
index 00..1116f5c96c
--- /dev/null
+++ b/arch/arm/dts/armada-xp-crs305-1g-4s.dts
@@ -0,0 +1,110 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Device Tree file for CRS305-1G-4S board
+ *
+ * Copyright (C) 2016 Allied Telesis Labs
+ *
+ * Based on armada-xp-db.dts
+ *
+ * Note: this Device Tree assumes that the bootloader has remapped the
+ * internal registers to 0xf100 (instead of the default
+ * 0xd000). The 0xf100 is the default used by the recent,
+ * DT-capable, U-Boot bootloaders provided by Marvell. Some earlier
+ * boards were delivered with an older version of the bootloader that
+ * left internal registers mapped at 0xd000. If you are in this
+ * situation, you should either update your bootloader (preferred
+ * solution) or the below Device Tree should be adjusted.
+ */
+
+/dts-v1/;
+#include "armada-xp-98dx3236.dtsi"
+#include "armada-xp-crs305-1g-4s-u-boot.dtsi"
+
+/ {
+   model = "CRS305-1G-4S";
+   compatible = "marvell,armadaxp-98dx3236", "marvell,armadaxp-mv78260", 
"marvell,armadaxp", "marvell,armada-370-xp";
+
+   chosen {
+   stdout-path = "serial0:115200n8";
+   bootargs = "console=ttyS0,115200 earlyprintk";
+   };
+
+   aliases {
+   spi0 = 
+   };
+
+   memory {
+   device_type = "memory";
+   reg = <0 0x 0 0x2000>; /* 512 MB */
+   };
+};
+
+ {
+   arm,parity-enable;
+   marvell,ecc-enable;
+};
+
+_bootcs {
+   status = "okay";
+
+   /* Device Bus parameters are required */
+
+   /* Read param

[U-Boot] [PATCH 1/1] arm: mvebu: Add CRS305-1G-4S board

2019-05-03 Thread Luka Kovacic
CRS305-1G-4S has a switch chip with an integrated CPU (98DX3236) and
like some of the other simillar boards requires bin_hdr.
bin_hdr (DDR3 init stage) is currently retrieved from the stock
bootloader and compiled into the kwb image.

Adds support for U-Boot, enable UART, SPI, Winbond SPI flash chip
support and writing env to SPI flash.

arch/arm/dts: Remove unused parameters in DTS for crs305-1g-4s

arch/arm/mach-mvebu: Set the proper processor for crs305-1g-4s
(98DX3236)

board/mikrotik/crs305-1g-4s: Enable CONFIG_DISPLAY_BOARDINFO

board/mikrotik/crs305-1g-4s: Remove GPIO1 (Reset Button)

Signed-off-by: Luka Kovacic 
---
 arch/arm/dts/Makefile |   3 +-
 .../dts/armada-xp-crs305-1g-4s-u-boot.dtsi|  13 +++
 arch/arm/dts/armada-xp-crs305-1g-4s.dts   | 110 ++
 arch/arm/mach-mvebu/Kconfig   |   7 ++
 board/mikrotik/crs305-1g-4s/.gitignore|   1 +
 board/mikrotik/crs305-1g-4s/MAINTAINERS   |   7 ++
 board/mikrotik/crs305-1g-4s/Makefile  |  14 +++
 board/mikrotik/crs305-1g-4s/README|  23 
 board/mikrotik/crs305-1g-4s/binary.0  |  11 ++
 board/mikrotik/crs305-1g-4s/crs305-1g-4s.c|  71 +++
 board/mikrotik/crs305-1g-4s/kwbimage.cfg.in   |  12 ++
 configs/crs305-1g-4s_defconfig|  52 +
 include/configs/crs305-1g-4s.h|  37 ++
 13 files changed, 360 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/dts/armada-xp-crs305-1g-4s-u-boot.dtsi
 create mode 100644 arch/arm/dts/armada-xp-crs305-1g-4s.dts
 create mode 100644 board/mikrotik/crs305-1g-4s/.gitignore
 create mode 100644 board/mikrotik/crs305-1g-4s/MAINTAINERS
 create mode 100644 board/mikrotik/crs305-1g-4s/Makefile
 create mode 100644 board/mikrotik/crs305-1g-4s/README
 create mode 100644 board/mikrotik/crs305-1g-4s/binary.0
 create mode 100644 board/mikrotik/crs305-1g-4s/crs305-1g-4s.c
 create mode 100644 board/mikrotik/crs305-1g-4s/kwbimage.cfg.in
 create mode 100644 configs/crs305-1g-4s_defconfig
 create mode 100644 include/configs/crs305-1g-4s.h

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 8e082f2840..8d73bcb57f 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -162,7 +162,8 @@ dtb-$(CONFIG_ARCH_MVEBU) += \
armada-38x-controlcenterdc.dtb  \
armada-385-atl-x530.dtb \
armada-385-atl-x530DP.dtb   \
-   armada-xp-db-xc3-24g4xg.dtb
+   armada-xp-db-xc3-24g4xg.dtb \
+   armada-xp-crs305-1g-4s.dtb
 
 dtb-$(CONFIG_ARCH_UNIPHIER_LD11) += \
uniphier-ld11-global.dtb \
diff --git a/arch/arm/dts/armada-xp-crs305-1g-4s-u-boot.dtsi 
b/arch/arm/dts/armada-xp-crs305-1g-4s-u-boot.dtsi
new file mode 100644
index 00..8576a02730
--- /dev/null
+++ b/arch/arm/dts/armada-xp-crs305-1g-4s-u-boot.dtsi
@@ -0,0 +1,13 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+
+ {
+   u-boot,dm-pre-reloc;
+};
+
+ {
+   u-boot,dm-pre-reloc;
+
+   spi-flash@0 {
+   u-boot,dm-pre-reloc;
+   };
+};
diff --git a/arch/arm/dts/armada-xp-crs305-1g-4s.dts 
b/arch/arm/dts/armada-xp-crs305-1g-4s.dts
new file mode 100644
index 00..1116f5c96c
--- /dev/null
+++ b/arch/arm/dts/armada-xp-crs305-1g-4s.dts
@@ -0,0 +1,110 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Device Tree file for CRS305-1G-4S board
+ *
+ * Copyright (C) 2016 Allied Telesis Labs
+ *
+ * Based on armada-xp-db.dts
+ *
+ * Note: this Device Tree assumes that the bootloader has remapped the
+ * internal registers to 0xf100 (instead of the default
+ * 0xd000). The 0xf100 is the default used by the recent,
+ * DT-capable, U-Boot bootloaders provided by Marvell. Some earlier
+ * boards were delivered with an older version of the bootloader that
+ * left internal registers mapped at 0xd000. If you are in this
+ * situation, you should either update your bootloader (preferred
+ * solution) or the below Device Tree should be adjusted.
+ */
+
+/dts-v1/;
+#include "armada-xp-98dx3236.dtsi"
+#include "armada-xp-crs305-1g-4s-u-boot.dtsi"
+
+/ {
+   model = "CRS305-1G-4S";
+   compatible = "marvell,armadaxp-98dx3236", "marvell,armadaxp-mv78260", 
"marvell,armadaxp", "marvell,armada-370-xp";
+
+   chosen {
+   stdout-path = "serial0:115200n8";
+   bootargs = "console=ttyS0,115200 earlyprintk";
+   };
+
+   aliases {
+   spi0 = 
+   };
+
+   memory {
+   device_type = "memory";
+   reg = <0 0x 0 0x2000>; /* 512 MB */
+   };
+};
+
+ {
+   arm,parity-enable;
+   marvell,ecc-enable;
+};
+
+_bootcs {
+   status = "okay";
+
+   /* Device Bus parameters are required */
+
+   /* Read parameters */
+   devbus,bus-width= <16>;
+   de

[U-Boot] [PATCH 0/1] Add MikroTik CRS305-1G-4S+IN board support

2019-05-03 Thread Luka Kovacic
I have commented out the code around MVEBU_GPIO1_BASE.

GPIO1 is a software reset button on the board, I might
use it later for resetting the board. 

GPIO0 is already working. It's currently used to turn
on an LED on board initialization.

Luka Kovacic (1):
  arm: mvebu: Add CRS305-1G-4S board

 arch/arm/dts/Makefile |   3 +-
 .../dts/armada-xp-crs305-1g-4s-u-boot.dtsi|  13 +++
 arch/arm/dts/armada-xp-crs305-1g-4s.dts   | 110 ++
 arch/arm/mach-mvebu/Kconfig   |   7 ++
 board/mikrotik/crs305-1g-4s/.gitignore|   1 +
 board/mikrotik/crs305-1g-4s/MAINTAINERS   |   7 ++
 board/mikrotik/crs305-1g-4s/Makefile  |  14 +++
 board/mikrotik/crs305-1g-4s/README|  23 
 board/mikrotik/crs305-1g-4s/binary.0  |  11 ++
 board/mikrotik/crs305-1g-4s/crs305-1g-4s.c|  71 +++
 board/mikrotik/crs305-1g-4s/kwbimage.cfg.in   |  12 ++
 configs/crs305-1g-4s_defconfig|  52 +
 include/configs/crs305-1g-4s.h|  37 ++
 13 files changed, 360 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/dts/armada-xp-crs305-1g-4s-u-boot.dtsi
 create mode 100644 arch/arm/dts/armada-xp-crs305-1g-4s.dts
 create mode 100644 board/mikrotik/crs305-1g-4s/.gitignore
 create mode 100644 board/mikrotik/crs305-1g-4s/MAINTAINERS
 create mode 100644 board/mikrotik/crs305-1g-4s/Makefile
 create mode 100644 board/mikrotik/crs305-1g-4s/README
 create mode 100644 board/mikrotik/crs305-1g-4s/binary.0
 create mode 100644 board/mikrotik/crs305-1g-4s/crs305-1g-4s.c
 create mode 100644 board/mikrotik/crs305-1g-4s/kwbimage.cfg.in
 create mode 100644 configs/crs305-1g-4s_defconfig
 create mode 100644 include/configs/crs305-1g-4s.h

-- 
2.20.1

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


[U-Boot] [PATCH 1/1] arm: mvebu: Add CRS305-1G-4S board

2019-05-03 Thread Luka Kovacic
CRS305-1G-4S has a switch chip with an integrated CPU (98DX3236) and
like some of the other simillar boards requires bin_hdr.
bin_hdr (DDR3 init stage) is currently retrieved from the stock
bootloader and compiled into the kwb image.

Adds support for U-Boot, enable UART, SPI, Winbond SPI flash chip
support and writing env to SPI flash.

arch/arm/dts: Remove unused parameters in DTS for crs305-1g-4s

arch/arm/mach-mvebu: Set the proper processor for crs305-1g-4s
(98DX3236)

board/mikrotik/crs305-1g-4s: Enable CONFIG_DISPLAY_BOARDINFO

Signed-off-by: Luka Kovacic 
---
 arch/arm/dts/Makefile |   3 +-
 .../dts/armada-xp-crs305-1g-4s-u-boot.dtsi|  13 +++
 arch/arm/dts/armada-xp-crs305-1g-4s.dts   | 110 ++
 arch/arm/mach-mvebu/Kconfig   |   7 ++
 board/mikrotik/crs305-1g-4s/.gitignore|   1 +
 board/mikrotik/crs305-1g-4s/MAINTAINERS   |   7 ++
 board/mikrotik/crs305-1g-4s/Makefile  |  14 +++
 board/mikrotik/crs305-1g-4s/README|  23 
 board/mikrotik/crs305-1g-4s/binary.0  |  11 ++
 board/mikrotik/crs305-1g-4s/crs305-1g-4s.c|  66 +++
 board/mikrotik/crs305-1g-4s/kwbimage.cfg.in   |  12 ++
 configs/crs305-1g-4s_defconfig|  52 +
 include/configs/crs305-1g-4s.h|  37 ++
 13 files changed, 355 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/dts/armada-xp-crs305-1g-4s-u-boot.dtsi
 create mode 100644 arch/arm/dts/armada-xp-crs305-1g-4s.dts
 create mode 100644 board/mikrotik/crs305-1g-4s/.gitignore
 create mode 100644 board/mikrotik/crs305-1g-4s/MAINTAINERS
 create mode 100644 board/mikrotik/crs305-1g-4s/Makefile
 create mode 100644 board/mikrotik/crs305-1g-4s/README
 create mode 100644 board/mikrotik/crs305-1g-4s/binary.0
 create mode 100644 board/mikrotik/crs305-1g-4s/crs305-1g-4s.c
 create mode 100644 board/mikrotik/crs305-1g-4s/kwbimage.cfg.in
 create mode 100644 configs/crs305-1g-4s_defconfig
 create mode 100644 include/configs/crs305-1g-4s.h

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index dfa5b02958..f463485149 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -161,7 +161,8 @@ dtb-$(CONFIG_ARCH_MVEBU) += \
armada-38x-controlcenterdc.dtb  \
armada-385-atl-x530.dtb \
armada-385-atl-x530DP.dtb   \
-   armada-xp-db-xc3-24g4xg.dtb
+   armada-xp-db-xc3-24g4xg.dtb \
+   armada-xp-crs305-1g-4s.dtb
 
 dtb-$(CONFIG_ARCH_UNIPHIER_LD11) += \
uniphier-ld11-global.dtb \
diff --git a/arch/arm/dts/armada-xp-crs305-1g-4s-u-boot.dtsi 
b/arch/arm/dts/armada-xp-crs305-1g-4s-u-boot.dtsi
new file mode 100644
index 00..8576a02730
--- /dev/null
+++ b/arch/arm/dts/armada-xp-crs305-1g-4s-u-boot.dtsi
@@ -0,0 +1,13 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+
+ {
+   u-boot,dm-pre-reloc;
+};
+
+ {
+   u-boot,dm-pre-reloc;
+
+   spi-flash@0 {
+   u-boot,dm-pre-reloc;
+   };
+};
diff --git a/arch/arm/dts/armada-xp-crs305-1g-4s.dts 
b/arch/arm/dts/armada-xp-crs305-1g-4s.dts
new file mode 100644
index 00..1116f5c96c
--- /dev/null
+++ b/arch/arm/dts/armada-xp-crs305-1g-4s.dts
@@ -0,0 +1,110 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Device Tree file for CRS305-1G-4S board
+ *
+ * Copyright (C) 2016 Allied Telesis Labs
+ *
+ * Based on armada-xp-db.dts
+ *
+ * Note: this Device Tree assumes that the bootloader has remapped the
+ * internal registers to 0xf100 (instead of the default
+ * 0xd000). The 0xf100 is the default used by the recent,
+ * DT-capable, U-Boot bootloaders provided by Marvell. Some earlier
+ * boards were delivered with an older version of the bootloader that
+ * left internal registers mapped at 0xd000. If you are in this
+ * situation, you should either update your bootloader (preferred
+ * solution) or the below Device Tree should be adjusted.
+ */
+
+/dts-v1/;
+#include "armada-xp-98dx3236.dtsi"
+#include "armada-xp-crs305-1g-4s-u-boot.dtsi"
+
+/ {
+   model = "CRS305-1G-4S";
+   compatible = "marvell,armadaxp-98dx3236", "marvell,armadaxp-mv78260", 
"marvell,armadaxp", "marvell,armada-370-xp";
+
+   chosen {
+   stdout-path = "serial0:115200n8";
+   bootargs = "console=ttyS0,115200 earlyprintk";
+   };
+
+   aliases {
+   spi0 = 
+   };
+
+   memory {
+   device_type = "memory";
+   reg = <0 0x 0 0x2000>; /* 512 MB */
+   };
+};
+
+ {
+   arm,parity-enable;
+   marvell,ecc-enable;
+};
+
+_bootcs {
+   status = "okay";
+
+   /* Device Bus parameters are required */
+
+   /* Read parameters */
+   devbus,bus-width= <16>;
+   devbus,turn-off-ps  = <6>;
+   devbus,badr

[U-Boot] [PATCH 0/1] Add MikroTik CRS305-1G-4S+IN board support

2019-05-03 Thread Luka Kovacic
This is the corrected patch.
I enabled CONFIG_DISPLAY_BOARDINFO in the defconfig.

Luka Kovacic (1):
  arm: mvebu: Add CRS305-1G-4S board

 arch/arm/dts/Makefile |   3 +-
 .../dts/armada-xp-crs305-1g-4s-u-boot.dtsi|  13 +++
 arch/arm/dts/armada-xp-crs305-1g-4s.dts   | 110 ++
 arch/arm/mach-mvebu/Kconfig   |   7 ++
 board/mikrotik/crs305-1g-4s/.gitignore|   1 +
 board/mikrotik/crs305-1g-4s/MAINTAINERS   |   7 ++
 board/mikrotik/crs305-1g-4s/Makefile  |  14 +++
 board/mikrotik/crs305-1g-4s/README|  23 
 board/mikrotik/crs305-1g-4s/binary.0  |  11 ++
 board/mikrotik/crs305-1g-4s/crs305-1g-4s.c|  66 +++
 board/mikrotik/crs305-1g-4s/kwbimage.cfg.in   |  12 ++
 configs/crs305-1g-4s_defconfig|  52 +
 include/configs/crs305-1g-4s.h|  37 ++
 13 files changed, 355 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/dts/armada-xp-crs305-1g-4s-u-boot.dtsi
 create mode 100644 arch/arm/dts/armada-xp-crs305-1g-4s.dts
 create mode 100644 board/mikrotik/crs305-1g-4s/.gitignore
 create mode 100644 board/mikrotik/crs305-1g-4s/MAINTAINERS
 create mode 100644 board/mikrotik/crs305-1g-4s/Makefile
 create mode 100644 board/mikrotik/crs305-1g-4s/README
 create mode 100644 board/mikrotik/crs305-1g-4s/binary.0
 create mode 100644 board/mikrotik/crs305-1g-4s/crs305-1g-4s.c
 create mode 100644 board/mikrotik/crs305-1g-4s/kwbimage.cfg.in
 create mode 100644 configs/crs305-1g-4s_defconfig
 create mode 100644 include/configs/crs305-1g-4s.h

-- 
2.20.1

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


[U-Boot] [PATCH 0/1] [RESEND] Add MikroTik CRS305-1G-4S+IN board support

2019-05-02 Thread Luka Kovacic
This patch adds support for the MikroTik CRS305-1G-4S+IN switch.

CRS305-1G-4S has a switch chip with an integrated CPU (98DX3236) and 
like some of the other simillar boards requires bin_hdr.

bin_hdr (DDR3 init stage) is currently retrieved from the stock bootloader
and compiled into the kwb image.

The board has 4x SFP+ cages, Gigabit Ethernet (AR8033 PHY), 16 MB SPI flash 
(Winbond) and UART.
This port currently supports booting from UART using kwboot and SPI flash, 
saving the environment
to the SPI flash and loading the kernel from the SPI flash.

I am planning to add Gigabit Ethernet support later, in a new set of 
patches.

Luka Kovacic (1):
  arm: mvebu: Add CRS305-1G-4S board

 arch/arm/dts/Makefile |   3 +-
 .../dts/armada-xp-crs305-1g-4s-u-boot.dtsi|  13 +++
 arch/arm/dts/armada-xp-crs305-1g-4s.dts   | 110 ++
 arch/arm/mach-mvebu/Kconfig   |   7 ++
 board/mikrotik/crs305-1g-4s/.gitignore|   1 +
 board/mikrotik/crs305-1g-4s/MAINTAINERS   |   7 ++
 board/mikrotik/crs305-1g-4s/Makefile  |  14 +++
 board/mikrotik/crs305-1g-4s/README|  23 
 board/mikrotik/crs305-1g-4s/binary.0  |  11 ++
 board/mikrotik/crs305-1g-4s/crs305-1g-4s.c|  68 +++
 board/mikrotik/crs305-1g-4s/kwbimage.cfg.in   |  12 ++
 configs/crs305-1g-4s_defconfig|  51 
 include/configs/crs305-1g-4s.h|  37 ++
 13 files changed, 356 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/dts/armada-xp-crs305-1g-4s-u-boot.dtsi
 create mode 100644 arch/arm/dts/armada-xp-crs305-1g-4s.dts
 create mode 100644 board/mikrotik/crs305-1g-4s/.gitignore
 create mode 100644 board/mikrotik/crs305-1g-4s/MAINTAINERS
 create mode 100644 board/mikrotik/crs305-1g-4s/Makefile
 create mode 100644 board/mikrotik/crs305-1g-4s/README
 create mode 100644 board/mikrotik/crs305-1g-4s/binary.0
 create mode 100644 board/mikrotik/crs305-1g-4s/crs305-1g-4s.c
 create mode 100644 board/mikrotik/crs305-1g-4s/kwbimage.cfg.in
 create mode 100644 configs/crs305-1g-4s_defconfig
 create mode 100644 include/configs/crs305-1g-4s.h

-- 
2.20.1

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


[U-Boot] [PATCH 1/1] [RESEND] arm: mvebu: Add CRS305-1G-4S board

2019-05-02 Thread Luka Kovacic
CRS305-1G-4S has a switch chip with an integrated CPU (98DX3236) and like some 
of the
other simillar boards requires bin_hdr. bin_hdr (DDR3 init stage) is currently 
retrieved
from the stock bootloader and compiled into the kwb image.

Adds support for U-Boot, enable UART, SPI, Winbond SPI flash chip support and 
writing env to SPI flash.

arch/arm/dts: Remove unused parameters in DTS for crs305-1g-4s

arch/arm/mach-mvebu: Set the proper processor for crs305-1g-4s (98DX3236)

Signed-off-by: Luka Kovacic 
---
 arch/arm/dts/Makefile |   3 +-
 .../dts/armada-xp-crs305-1g-4s-u-boot.dtsi|  13 +++
 arch/arm/dts/armada-xp-crs305-1g-4s.dts   | 110 ++
 arch/arm/mach-mvebu/Kconfig   |   7 ++
 board/mikrotik/crs305-1g-4s/.gitignore|   1 +
 board/mikrotik/crs305-1g-4s/MAINTAINERS   |   7 ++
 board/mikrotik/crs305-1g-4s/Makefile  |  14 +++
 board/mikrotik/crs305-1g-4s/README|  23 
 board/mikrotik/crs305-1g-4s/binary.0  |  11 ++
 board/mikrotik/crs305-1g-4s/crs305-1g-4s.c|  68 +++
 board/mikrotik/crs305-1g-4s/kwbimage.cfg.in   |  12 ++
 configs/crs305-1g-4s_defconfig|  51 
 include/configs/crs305-1g-4s.h|  37 ++
 13 files changed, 356 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/dts/armada-xp-crs305-1g-4s-u-boot.dtsi
 create mode 100644 arch/arm/dts/armada-xp-crs305-1g-4s.dts
 create mode 100644 board/mikrotik/crs305-1g-4s/.gitignore
 create mode 100644 board/mikrotik/crs305-1g-4s/MAINTAINERS
 create mode 100644 board/mikrotik/crs305-1g-4s/Makefile
 create mode 100644 board/mikrotik/crs305-1g-4s/README
 create mode 100644 board/mikrotik/crs305-1g-4s/binary.0
 create mode 100644 board/mikrotik/crs305-1g-4s/crs305-1g-4s.c
 create mode 100644 board/mikrotik/crs305-1g-4s/kwbimage.cfg.in
 create mode 100644 configs/crs305-1g-4s_defconfig
 create mode 100644 include/configs/crs305-1g-4s.h

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index dfa5b02958..f463485149 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -161,7 +161,8 @@ dtb-$(CONFIG_ARCH_MVEBU) += \
armada-38x-controlcenterdc.dtb  \
armada-385-atl-x530.dtb \
armada-385-atl-x530DP.dtb   \
-   armada-xp-db-xc3-24g4xg.dtb
+   armada-xp-db-xc3-24g4xg.dtb \
+   armada-xp-crs305-1g-4s.dtb
 
 dtb-$(CONFIG_ARCH_UNIPHIER_LD11) += \
uniphier-ld11-global.dtb \
diff --git a/arch/arm/dts/armada-xp-crs305-1g-4s-u-boot.dtsi 
b/arch/arm/dts/armada-xp-crs305-1g-4s-u-boot.dtsi
new file mode 100644
index 00..8576a02730
--- /dev/null
+++ b/arch/arm/dts/armada-xp-crs305-1g-4s-u-boot.dtsi
@@ -0,0 +1,13 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+
+ {
+   u-boot,dm-pre-reloc;
+};
+
+ {
+   u-boot,dm-pre-reloc;
+
+   spi-flash@0 {
+   u-boot,dm-pre-reloc;
+   };
+};
diff --git a/arch/arm/dts/armada-xp-crs305-1g-4s.dts 
b/arch/arm/dts/armada-xp-crs305-1g-4s.dts
new file mode 100644
index 00..1116f5c96c
--- /dev/null
+++ b/arch/arm/dts/armada-xp-crs305-1g-4s.dts
@@ -0,0 +1,110 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Device Tree file for CRS305-1G-4S board
+ *
+ * Copyright (C) 2016 Allied Telesis Labs
+ *
+ * Based on armada-xp-db.dts
+ *
+ * Note: this Device Tree assumes that the bootloader has remapped the
+ * internal registers to 0xf100 (instead of the default
+ * 0xd000). The 0xf100 is the default used by the recent,
+ * DT-capable, U-Boot bootloaders provided by Marvell. Some earlier
+ * boards were delivered with an older version of the bootloader that
+ * left internal registers mapped at 0xd000. If you are in this
+ * situation, you should either update your bootloader (preferred
+ * solution) or the below Device Tree should be adjusted.
+ */
+
+/dts-v1/;
+#include "armada-xp-98dx3236.dtsi"
+#include "armada-xp-crs305-1g-4s-u-boot.dtsi"
+
+/ {
+   model = "CRS305-1G-4S";
+   compatible = "marvell,armadaxp-98dx3236", "marvell,armadaxp-mv78260", 
"marvell,armadaxp", "marvell,armada-370-xp";
+
+   chosen {
+   stdout-path = "serial0:115200n8";
+   bootargs = "console=ttyS0,115200 earlyprintk";
+   };
+
+   aliases {
+   spi0 = 
+   };
+
+   memory {
+   device_type = "memory";
+   reg = <0 0x 0 0x2000>; /* 512 MB */
+   };
+};
+
+ {
+   arm,parity-enable;
+   marvell,ecc-enable;
+};
+
+_bootcs {
+   status = "okay";
+
+   /* Device Bus parameters are required */
+
+   /* Read parameters */
+   devbus,bus-width= <16>;
+   devbus,turn-off-ps  = <6>;
+   devbus,badr-skew-ps = <0>;
+   devbus,acc-first-ps = <

[U-Boot] [PATCH 1/1] arm: mvebu: Add CRS305-1G-4S board

2019-05-02 Thread Luka Kovacic
t-ps  = <248000>;
+   devbus,rd-setup-ps  = <0>;
+   devbus,rd-hold-ps   = <0>;
+
+   /* Write parameters */
+   devbus,sync-enable = <0>;
+   devbus,wr-high-ps  = <6>;
+   devbus,wr-low-ps   = <6>;
+   devbus,ale-wr-ps   = <6>;
+};
+
+ {
+   status = "okay";
+};
+
+ {
+   status = "okay";
+};
+
+ {
+   clock-frequency = <10>;
+   status = "okay";
+};
+
+ {
+   status = "okay";
+};
+
+ {
+   status = "okay";
+
+   spi-flash@0 {
+   #address-cells = <1>;
+   #size-cells = <1>;
+   compatible = "spi-flash", "jedec,spi-nor";
+   reg = <0>; /* Chip select 0 */
+   spi-max-frequency = <10800>;
+   m25p,fast-read;
+
+   partition@u-boot {
+   reg = <0x 0x0010>;
+   label = "u-boot";
+   };
+   partition@u-boot-env {
+   reg = <0x0010 0x0004>;
+   label = "u-boot-env";
+   };
+   partition@unused {
+   reg = <0x0014 0x00ec>;
+   label = "unused";
+   };
+
+   };
+};
diff --git a/arch/arm/mach-mvebu/Kconfig b/arch/arm/mach-mvebu/Kconfig
index f99bd3bf65..1d49d49203 100644
--- a/arch/arm/mach-mvebu/Kconfig
+++ b/arch/arm/mach-mvebu/Kconfig
@@ -157,6 +157,10 @@ config TARGET_DB_XC3_24G4XG
bool "Support DB-XC3-24G4XG"
select 98DX3336
 
+config TARGET_CRS305_1G_4S
+   bool "Support CRS305-1G-4S"
+   select 98DX3236
+
 endchoice
 
 config SYS_BOARD
@@ -176,6 +180,7 @@ config SYS_BOARD
default "a38x" if TARGET_CONTROLCENTERDC
default "x530" if TARGET_X530
default "db-xc3-24g4xg" if TARGET_DB_XC3_24G4XG
+   default "crs305-1g-4s" if TARGET_CRS305_1G_4S
 
 config SYS_CONFIG_NAME
default "clearfog" if TARGET_CLEARFOG
@@ -194,6 +199,7 @@ config SYS_CONFIG_NAME
default "controlcenterdc" if TARGET_CONTROLCENTERDC
default "x530" if TARGET_X530
default "db-xc3-24g4xg" if TARGET_DB_XC3_24G4XG
+   default "crs305-1g-4s" if TARGET_CRS305_1G_4S
 
 config SYS_VENDOR
default "Marvell" if TARGET_DB_MV784MP_GP
@@ -211,6 +217,7 @@ config SYS_VENDOR
default "CZ.NIC" if TARGET_TURRIS_MOX
default "gdsys" if TARGET_CONTROLCENTERDC
default "alliedtelesis" if TARGET_X530
+   default "mikrotik" if TARGET_CRS305_1G_4S
 
 config SYS_SOC
default "mvebu"
diff --git a/board/mikrotik/crs305-1g-4s/.gitignore 
b/board/mikrotik/crs305-1g-4s/.gitignore
new file mode 100644
index 00..775b9346b8
--- /dev/null
+++ b/board/mikrotik/crs305-1g-4s/.gitignore
@@ -0,0 +1 @@
+kwbimage.cfg
diff --git a/board/mikrotik/crs305-1g-4s/MAINTAINERS 
b/board/mikrotik/crs305-1g-4s/MAINTAINERS
new file mode 100644
index 00..3823489600
--- /dev/null
+++ b/board/mikrotik/crs305-1g-4s/MAINTAINERS
@@ -0,0 +1,7 @@
+CRS305-1G-4S BOARD
+M: Luka Kovacic 
+S: Maintained
+F: board/mikrotik/crs305-1g-4s/
+F: include/configs/crs305-1g-4s.h
+F: configs/crs305-1g-4s_defconfig
+F: arch/arm/dts/armada-xp-crs305-1g-4s.dts
diff --git a/board/mikrotik/crs305-1g-4s/Makefile 
b/board/mikrotik/crs305-1g-4s/Makefile
new file mode 100644
index 00..895331beb8
--- /dev/null
+++ b/board/mikrotik/crs305-1g-4s/Makefile
@@ -0,0 +1,14 @@
+# SPDX-License-Identifier: GPL-2.0+
+#
+# Copyright (C) 2015 Stefan Roese 
+
+obj-y  := crs305-1g-4s.o
+extra-y:= kwbimage.cfg
+
+quiet_cmd_sed = SED $@
+  cmd_sed = sed $(SEDFLAGS_$(@F)) $< >$(dir $<)$(@F)
+
+SEDFLAGS_kwbimage.cfg =-e "s|^BINARY.*|BINARY $(srctree)/$(@D)/binary.0 
005b 0068|"
+$(src)/kwbimage.cfg: $(src)/kwbimage.cfg.in include/autoconf.mk \
+   include/config/auto.conf
+ $(call if_changed,sed)
diff --git a/board/mikrotik/crs305-1g-4s/README 
b/board/mikrotik/crs305-1g-4s/README
new file mode 100644
index 00..f420aabfbf
--- /dev/null
+++ b/board/mikrotik/crs305-1g-4s/README
@@ -0,0 +1,23 @@
+MikroTik CRS305-1G-4S+IN
+
+
+CRS305-1G-4S+IN is a 4x SFP+ switch with a Gigabit Ethernet port for 
management.
+Specifications:
+ - Marvell Prestera 98DX3236 switch with an integrated ARMv7 CPU
+ - 512 MB DDR3 RAM
+ - UART @ 115200bps
+ - 4x SFP+
+ - Gigabit Ethernet (AR8033)
+ - 16 MB SPI flash (Winbond 25Q128JVSM)
+
+Currently supported hardware:
+ - UART boot (using kwboot) and console
+ - SPI boot, environment and load kernel
+
+Planned:
+ - Gigabit Ethernet support
+
+

[U-Boot] [PATCH 0/1] Add MikroTik CRS305-1G-4S+IN board support

2019-05-02 Thread Luka Kovacic
This patch adds support for the MikroTik CRS305-1G-4S+IN switch.

CRS305-1G-4S has a switch chip with an integrated CPU (98DX3236) and 
like some of the other simillar boards requires bin_hdr.

bin_hdr (DDR3 init stage) is currently retrieved from the stock bootloader
and compiled into the kwb image.

The board has 4x SFP+ cages, Gigabit Ethernet (AR8033 PHY), 16 MB SPI flash 
(Winbond) and UART.
This port currently supports booting from UART using kwboot and SPI flash, 
saving the environment
to the SPI flash and loading the kernel from the SPI flash.

I am planning to add Gigabit Ethernet support later, in a new set of 
patches.


Luka Kovacic (1):
  arm: mvebu: Add CRS305-1G-4S board

 arch/arm/dts/Makefile |   3 +-
 .../dts/armada-xp-crs305-1g-4s-u-boot.dtsi|  13 +++
 arch/arm/dts/armada-xp-crs305-1g-4s.dts   | 110 ++
 arch/arm/mach-mvebu/Kconfig   |   7 ++
 board/mikrotik/crs305-1g-4s/.gitignore|   1 +
 board/mikrotik/crs305-1g-4s/MAINTAINERS   |   7 ++
 board/mikrotik/crs305-1g-4s/Makefile  |  14 +++
 board/mikrotik/crs305-1g-4s/README|  23 
 board/mikrotik/crs305-1g-4s/binary.0  |  11 ++
 board/mikrotik/crs305-1g-4s/crs305-1g-4s.c|  68 +++
 board/mikrotik/crs305-1g-4s/kwbimage.cfg.in   |  12 ++
 configs/crs305-1g-4s_defconfig|  51 
 include/configs/crs305-1g-4s.h|  37 ++
 13 files changed, 356 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/dts/armada-xp-crs305-1g-4s-u-boot.dtsi
 create mode 100644 arch/arm/dts/armada-xp-crs305-1g-4s.dts
 create mode 100644 board/mikrotik/crs305-1g-4s/.gitignore
 create mode 100644 board/mikrotik/crs305-1g-4s/MAINTAINERS
 create mode 100644 board/mikrotik/crs305-1g-4s/Makefile
 create mode 100644 board/mikrotik/crs305-1g-4s/README
 create mode 100644 board/mikrotik/crs305-1g-4s/binary.0
 create mode 100644 board/mikrotik/crs305-1g-4s/crs305-1g-4s.c
 create mode 100644 board/mikrotik/crs305-1g-4s/kwbimage.cfg.in
 create mode 100644 configs/crs305-1g-4s_defconfig
 create mode 100644 include/configs/crs305-1g-4s.h

-- 
2.20.1

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