565 Commits

Author SHA1 Message Date
Andre Przywara
f917e69d75 fel: Skip uploading empty image
Our FEL code does not deal very well with the upload size being 0.

Check for that before calling any USB routines, and skip the call
entirely. Mark the buffer as "const" on the way, since we have no
business other than reading from it.

That helps to properly skip dummy images later.

Signed-off-by: Andre Przywara <osp@andrep.de>
2021-01-11 09:34:06 +00:00
Chen-Yu Tsai
7a6a2221ad
Merge pull request #154 from apritzel/larger_spl
fel: Allow larger SPL payload
2021-01-03 17:48:18 +08:00
Andre Przywara
ada2483093 fel: A64/H5: Allow bigger SPL size
The A64 and H5 have a rather generous SRAM C directly adjacent to
SRAM A1, so we can make use of the larger continuous SRAM area to
increase the maximum SPL size.

Move the location of the FEL stack backup buffer up, towards the end of
SRAM C. We restrict ourselves to the slightly tighter requirements of
the H5, to be able to still share the joint swap_buffers data structure.

Signed-off-by: Andre Przywara <osp@andrep.de>
2020-12-31 18:14:54 +00:00
Andre Przywara
2f59b574ba fel: H6: Allow bigger SPL size
The H6 has quite a large chunk of continuous SRAM, and also the BROM
allows to load eGON images far bigger than 32KB.

Move the FEL stack backup buffers and the thunk address towards the end
of SRAM C, so that we have a larger chunk of continuous SRAM available
for the SPL.

Signed-off-by: Andre Przywara <osp@andrep.de>
2020-12-31 18:14:38 +00:00
Andre Przywara
2a2af190d4 fel: H616: Allow bigger SPL size
The H616 has quite a large chunk of continuous SRAM, and also the BROM
allows to load eGON images far bigger than 32KB. U-Boot's SPL is
actually relying on this, as we need more code for the PMIC and DRAM
driver.

Move the FEL stack backup buffers and the thunk address towards the end
of SRAM C, so that we have a larger chunk of continuous SRAM available
for the SPL.

Signed-off-by: Andre Przywara <osp@andrep.de>
2020-12-31 18:13:59 +00:00
Andre Przywara
4c6a1a0150 fel: Observe SRAM size to extend SPL load size
At the moment we limit the maximum SPL load size to 32 KB, because this
was a BROM limit in previous SoCs.
Newer SoCs (H6 and later) lift this limit, but also this tool is not
bound by the BROM limit, since we can load any size.

Use the just introduced SRAM size to establish an upper limit for the
SPL size, then limit this as we go if any part of the memory is used for
the FEL backup buffers.

Given the buffer addresses chosen wisely, this can drastically increase
the maximum SPL load size, even on those SoCs with a 32KB BROM limit.

Signed-off-by: Andre Przywara <osp@andrep.de>
2020-12-31 18:13:51 +00:00
Andre Przywara
276a97da6c soc_info: Introduce SRAM size
At the moment we assume the SPL load size to be limited to 32KB, even
though many SoCs have more SRAM A1 or a large SRAM C directly after SRAM
A1.

To later allow to extend the SPL load size, let's introduce a SoC
specific variable to hold the SRAM size after the SPL load address. This
could either cover the whole of SRAM A1, or even SRAM C, if that is
contiguous to SRAM A1.

Eventually this variable is meant to hold the *usable* SRAM size, so not
including regions that are used by the BROM code. However this value is
very SoC specific and not documented, and the SPL size is limited by the
thunk and stack buffers anyway at the moment, so the values used here
right now are just taken from the respective manuals.

Signed-off-by: Andre Przywara <osp@andrep.de>
2020-12-31 18:13:51 +00:00
Andre Przywara
75960dd232 fel: Check actual SPL size before considering U-Boot proper
At the moment we always use a 32KB offset to place the U-Boot image
after the SPL.
Newer SoCs can (and will) have bigger SPLs, so we need to become more
flexible with this offset.

Read the actual SPL size, and assume the U-Boot payload is located right
behind the SPL, if the SPL size is bigger than 32KB.
We use at least 32KB, because this is how U-Boot is doing it today, even
when the SPL size is actually smaller than that.

Signed-off-by: Andre Przywara <osp@andrep.de>
2020-12-29 02:03:48 +00:00
Andre Przywara
2b67b2d784 fel: Fix SPL size check against thunk addr
We have a check to avoid that the SPL accidentally overwrites the thunk
buffer we use to execute code on the board.

Unfortunately this compares the SPL *size* against the thunk *address*,
which is only valid when the SPL starts at 0 (older 32-bit SoCs).

Factor in the SoC dependent SPL start address, to make this check work
properly on newer (64-bit) SoCs.

Signed-off-by: Andre Przywara <osp@andrep.de>
2020-12-29 02:03:48 +00:00
Andre Przywara
8af203ec45 fel: Check for U-Boot image before considering checksum
Currently we check the U-Boot (legacy!) image header checksum very early
and bail out with an error message if it does not match.

Move that check later into the function, *after* we have established
that we are actually dealing with such an U-Boot image.

This avoids confusing error messages in case there is no U-Boot image
used at all.

Signed-off-by: Andre Przywara <osp@andrep.de>
2020-12-29 00:06:41 +00:00
Icenowy Zheng
8347b64538
Merge pull request #151 from apritzel/spiflash-h616
spi: Add H616 support
2020-11-23 11:49:35 +08:00
Andre Przywara
63ce5ad517 spi: Add H616 support
The H616 SPI is very similar to the H6, only differs in the GPIOs
(again).
Add the SoC-ID at the right places and add the GPIOs according to the
manual.

Tested on OrangePi Zero 2.

Signed-off-by: Andre Przywara <osp@andrep.de>
2020-11-19 20:22:24 +00:00
Chen-Yu Tsai
2601dfa012
Merge pull request #149 from apritzel/wdreset
wdreset: Add remaining SoCs
2020-11-12 19:51:32 +08:00
Chen-Yu Tsai
54a0fe5bd0
Merge pull request #150 from apritzel/spiflash-h6-new
Enabling SPI flash support for H6 & R40 (+ fixes)
2020-11-10 22:05:34 +08:00
Chen-Yu Tsai
47f0bfc835
Merge pull request #144 from daym/meminfo
meminfo: Replace sys/io.h by direct register accesses.
2020-11-10 22:05:05 +08:00
Andre Przywara
205e208a70 spi: Observe proper clock initialisation order
The CCU section in all Allwinner manuals asks to de-assert the reset
signal first, then to ungate the bus clock.
On a nearby note it also requires to switch dividers before changing the
clock source.

The SPI flash code violated those two rules, fix this to make the code
more robust.

Signed-off-by: Andre Przywara <osp@andrep.de>
2020-11-10 10:58:57 +00:00
Andre Przywara
de784a7c7b spi: Avoid signed shifts
Shifting signed types to the left is dodgy, especially by 31 bits, since
it depends on the result type whether the result is undefined or not.

Do not take any chances here, and mark those shift bases as unsigned where
we can or will hit bit 31, to avoid undefined behaviour.

Signed-off-by: Andre Przywara <osp@andrep.de>
2020-11-10 10:58:57 +00:00
Andre Przywara
6814036708 spi: Add support for H6
As Icenowy rightfully assumed, the V831 SPI support covers the H6 as
well. The only difference was a slight deviation in the pinmux setup:
the H6 has the SPI0-CS on pin PC5, the V831 on pin PC1.

Just add the right SoC ID and tweak the pinmux setup to enable it.

Tested on a Pine H64.

Signed-off-by: Andre Przywara <osp@andrep.de>
2020-11-10 10:58:08 +00:00
Andre Przywara
47b611ccdc spi: Add support for R40
The R40 is closely related to the A20, but has in fact a newer
generation SPI controller.
Add the R40 SoC ID to the right places to enable SPI support.

Tested on a Bananapi M2 Berry with SPI flash attached to header pins.

Signed-off-by: Andre Przywara <osp@andrep.de>
2020-11-10 00:08:12 +00:00
Andre Przywara
ac432c4c77 wdreset: Add remaining SoCs
The "wdreset" command so far only covered a few SoCs.

Add the watchdog data for the other ones as well.

Signed-off-by: Andre Przywara <osp@andrep.de>
2020-11-08 16:38:12 +00:00
Chen-Yu Tsai
14ff3e360d
Merge pull request #145 from gediz/gpio-base-fix
spi: fix GPIO base address
2020-10-20 11:02:55 +08:00
Nazım Gediz Aydındoğmuş
4e3eeb5d6d spi: fix GPIO base address
Resolve typo for GPIO base address for SoCs other than V831.

Signed-off-by: Nazım Gediz Aydındoğmuş <gedizaydindogmus@gmail.com>
2020-10-19 22:13:13 +03:00
Danny Milosavljevic
783cbd59fc
meminfo: Replace sys/io.h by direct register accesses.
Signed-off-by: Danny Milosavljevic <dannym@scratchpost.org>
2020-10-08 23:01:31 +02:00
Icenowy Zheng
3fb85399e2
Merge pull request #142 from jernejsk/h616
Add support for H616
2020-10-06 14:12:33 +08:00
Jernej Skrabec
40ac9dafe1 Add support for H616 2020-10-02 17:42:25 +02:00
Chen-Yu Tsai
7cc37c883b
Merge pull request #140 from Icenowy/v831
V831 SoC support
2020-09-29 17:39:49 +08:00
Icenowy Zheng
eac43cf7e9 spi: add support for V831
The Allwinner V831 SoC has similar memory map and CCU with H6.

Add support for it by make the code to dynamically acquire the SPI0
memory base and add clock setup for V831.

These code should work on H6 too, but I am too lazy to test it.

Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
2020-09-29 14:28:12 +08:00
Icenowy Zheng
3c2faa16d5 uart0-helloworld-sdboot: add support for V831 SoC
V831 SoC is one of sun8i family (with Cortex-A7 CPUs), and it follows a
similar memory map with H6.

Add support for it. The detection for H6-style memory map is positive on
V831, because it have the same version of GIC at the same address.

Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
2020-09-29 14:28:12 +08:00
Icenowy Zheng
c6111193f6 fel: add initial SoC info for V831
The non-IRQ stack is moved to near the end of the SRAM C, which is very
high, and have no need to save.

Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
2020-09-29 14:28:08 +08:00
Chen-Yu Tsai
e334ccf5b2
Merge pull request #110 from jackmitch/master
fel: enable A83T MMU
2020-09-29 14:21:48 +08:00
Chen-Yu Tsai
2783524e6f
Merge pull request #141 from Icenowy/eon-flash
fel: SPI: add Eon support
2020-09-29 14:20:16 +08:00
Chen-Yu Tsai
ef85882169
Merge pull request #139 from Icenowy/v3s-spi
spi: add support for V3s SoC
2020-09-29 14:08:29 +08:00
Icenowy Zheng
bf02fd31f5 fel: SPI: add Eon support
Add the JEDEC manufacturer ID for Eon to the list of recognized
vendors, also add the EN25QH series to the list of supported chips.
Those chips are used on some internal boards with V831 from Sipeed now,
but the chips themselves are widely available on the market. Tag the
struct definition with the member names on the way to improve readability
of the SPI flash chip description.

Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
2020-09-20 07:44:29 +08:00
Icenowy Zheng
b330eeb844 spi: add support for V3s SoC
The Allwinner V3s SoC have the same SPI0 pinmux configuration, SPI clock
configuration and SPI controller (base address and the controller) with
H3.

Add spiflash support for it.

Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
2020-09-20 07:41:10 +08:00
Chen-Yu Tsai
613e4bae5c
Merge pull request #138 from anistor/a10-spiflash-support
Add support for reading A10 SPI flash
2020-09-14 16:36:52 +08:00
Adrian Nistor
2767489196 Add support for reading A10 SPI flash 2020-09-14 10:23:57 +03:00
Chen-Yu Tsai
c714fb068a
Merge pull request #133 from plaes/a20-wdreset
A20 wdreset support
2020-06-14 20:00:44 +08:00
Chen-Yu Tsai
ce6897eaa7
Merge pull request #131 from karlp/wdreset
Provide a wrapper for reset via watchdog
Tested-By: Priit Laes plaes@plaes.org # On A20 with custom patch
2020-06-14 20:00:29 +08:00
Priit Laes
6e825a0b33 FEL: Add wdreset support to Allwinner A20 SoC
Signed-off-by: Priit Laes <plaes@plaes.org>
2020-06-14 14:54:48 +03:00
Karl Palsson
39bd0d1dd8 Provide a wrapper for reset via watchdog
The watchdog register isn't in the same place, nor uses the same values
to trigger a reset.

Signed-off-by: Karl Palsson <karlp@tweak.net.au>
2020-06-14 14:50:34 +03:00
Karl Palsson
353a5ae0f8 Provide a wrapper for reset via watchdog
The watchdog register isn't in the same place, nor uses the same values
to trigger a reset.

Signed-off-by: Karl Palsson <karlp@tweak.net.au>
2020-04-20 11:03:42 +00:00
Icenowy Zheng
42ffc5f76a
Merge pull request #118 from Icenowy/spl-sematic-versioning
FEL: introduce semantic versioning for SPL header
2019-06-04 15:25:10 +08:00
Chen-Yu Tsai
7fe6024211
Merge pull request #119 from plaes/spi-a20
Add support for SPI on A20
2019-03-18 20:07:31 +08:00
Priit Laes
5831d54aa9 spi: Add A20 pinmux configuration
A20 (as does A10) uses pins 0,1,2 and 23 in bank C
for SPI 0.

Signed-off-by: Priit Laes <priit.laes@paf.com>
2019-01-08 16:55:46 +02:00
Priit Laes
5325533ce7 spi: Be more verbose in case of unsupported SoCs
Signed-off-by: Priit Laes <priit.laes@paf.com>
2019-01-08 15:54:18 +02:00
Andre Przywara
8fa2f24dc5 FEL: introduce semantic versioning for SPL header
Every addition of a new feature to the SPL header currently requires us
to update the FEL tool, to teach it about the new supported maximum
value. Many times the FEL tool doesn't really care, but complains
anyway - and refuses to load.
Let's introduce semantic versioning [1] for this field, where backwards
compatible additions just increase a minor number, but incompatible
changes require bumping the major version.
We have 8 bits for the SPL header version, let's split this to have 3 bits
for the major and 5 bit for the minor version number.

[1] https://semver.org

Signed-off-by: Andre Przywara <osp@andrep.de>
Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
2018-12-02 17:31:15 +08:00
Chen-Yu Tsai
6d598a0ed7
Merge pull request #114 from apritzel/v1.5-rc1
v1.5-rc1
2018-11-14 11:31:58 +08:00
Ian Campbell
585cb1d499 Fix two warnings about implicit fallthrough.
In the first case:

    pio.c: In function ‘main’:
    pio.c:355:4: warning: this statement may fall through [-Wimplicit-fallthrough=]
        usage(0);
        ^~~~~~~~
    pio.c:356:3: note: here
       case 'm':
       ^~~~

The fallthrough is not intended because `usage()` never returns (it calls
`exit` unconditionally). Annotate as `noreturn` so the compiler realises this.

In the second case:

    fexc.c: In function ‘main’:
    fexc.c:312:15: warning: this statement may fall through [-Wimplicit-fallthrough=]
       filename[1] = argv[optind+1]; /* out */
       ~~~~~~~~~~~~^~~~~~~~~~~~~~~~
    fexc.c:313:2: note: here
      case 1:
      ^~~~

The fallthrough appears to be intended (the two argument case is a superset of
the one argument case). Annotate with a comment which tells the compiler this
is intended.

Signed-off-by: Ian Campbell <ijc@hellion.org.uk>
2018-07-09 09:16:25 +01:00
Andre Przywara
fbe2dee762 fel: SPI: add Macronix support
Add the JEDEC manufacturer ID for Macronix to the list of recognized
vendors, also add the MX25L series to the list of supported chips.
Those chips are used on the OrangePi PC 2 boards, for instance.
Tag the struct definition with the member names on the way to improve
readability of the SPI flash chip description.

Signed-off-by: Andre Przywara <osp@andrep.de>
2018-07-09 09:16:25 +01:00
Siarhei Siamashka
3c9bc29f39 fel: Add SPI flash programmer implementation
Using the new AAPCS function remote execution support, add support to
read from and write to SPI flash connected to a device.
This allows flashing boot code to a device.

Signed-off-by: Siarhei Siamashka <siarhei.siamashka@gmail.com>
[Andre: adjust to upstream changes]
Signed-off-by: Andre Przywara <osp@andrep.de>
2018-07-09 09:16:24 +01:00