summaryrefslogtreecommitdiff
path: root/plat/allwinner
AgeCommit message (Collapse)Author
2019-06-28Remove MULTI_CONSOLE_API flag and references to itAmbroise Vincent
The new API becomes the default one. Change-Id: Ic1d602da3dff4f4ebbcc158b885295c902a24fec Signed-off-by: Ambroise Vincent <ambroise.vincent@arm.com>
2019-06-08allwinner: Disable unused features to save spaceSamuel Holland
As all Allwinner platforms are single-cluster A53 chips, we can disable support for newer, unsupported architecture extensions. We can also avoid some cache maintenance code, since no platform-specific setup is required to enable coherency. These changes reduce the size of .text on a default build with GCC 9.1 enough that .vectors again fits in the second half of a page, instead of requiring its own page. This commit was boot-tested on the Pinebook. Signed-off-by: Samuel Holland <samuel@sholland.org> Change-Id: Ib90454ef0c798d5e714b7780c585be0b1ed49c6d
2019-04-11plat: allwinner: common: use r_wdog instead of wdogClément Péron
Some Allwinner H6 has a broken watchdog that doesn't make the soc reboot. Use the R_WATCHDOG instead. Signed-off-by: Clément Péron <peron.clem@gmail.com> Change-Id: Ie95cc30a80ed517b60b30d6bc2e655a1b53f18ba
2019-03-08allwinner: regulators: pick correct DT subnodeAndre Przywara
So far the DT node describing the AXP803 PMIC used in many Allwinner A64 boards had only one subnode, so our code just entering the first subnode to find all regulators worked fine. However recent DT updates in the Linux kernel add more subnodes *before* that, so we need to make sure to explicitly enter the "regulators" subnode to find the information we are after. Improve some DT node parsing error handling on the way. Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2019-02-17allwinner: Clean up CPU ops functionsSamuel Holland
Convert them to take an mpidr instead of a (cluster, core) pair. This simplifies all of the call sites, and actually makes the functions a bit smaller. Signed-off-by: Samuel Holland <samuel@sholland.org>
2019-02-17allwinner: Constify data structuresSamuel Holland
This maximizes the amount of data protected by the MMU. Signed-off-by: Samuel Holland <samuel@sholland.org>
2019-01-04Sanitise includes across codebaseAntonio Nino Diaz
Enforce full include path for includes. Deprecate old paths. The following folders inside include/lib have been left unchanged: - include/lib/cpus/${ARCH} - include/lib/el3_runtime/${ARCH} The reason for this change is that having a global namespace for includes isn't a good idea. It defeats one of the advantages of having folders and it introduces problems that are sometimes subtle (because you may not know the header you are actually including if there are two of them). For example, this patch had to be created because two headers were called the same way: e0ea0928d5b7 ("Fix gpio includes of mt8173 platform to avoid collision."). More recently, this patch has had similar problems: 46f9b2c3a282 ("drivers: add tzc380 support"). This problem was introduced in commit 4ecca33988b9 ("Move include and source files to logical locations"). At that time, there weren't too many headers so it wasn't a real issue. However, time has shown that this creates problems. Platforms that want to preserve the way they include headers may add the removed paths to PLAT_INCLUDES, but this is discouraged. Change-Id: I39dc53ed98f9e297a5966e723d1936d6ccf2fc8f Signed-off-by: Antonio Nino Diaz <antonio.ninodiaz@arm.com>
2018-12-06drivers/console: Link console framework code by defaultJulius Werner
This patch makes the build system link the console framework code by default, like it already does with other common libraries (e.g. cache helpers). This should not make a difference in practice since TF is linked with --gc-sections, so the linker will garbage collect all functions and data that are not referenced by any other code. Thus, if a platform doesn't want to include console code for size reasons and doesn't make any references to console functions, the code will not be included in the final binary. To avoid compatibility issues with older platform ports, only make this change for the MULTI_CONSOLE_API. Change-Id: I153a9dbe680d57aadb860d1c829759ba701130d3 Signed-off-by: Julius Werner <jwerner@chromium.org>
2018-11-14allwinner: power: Add DCDC6 power railAndre Przywara
The DCDC6 power rail is typically driving VDD_SYS in the SoC, so it is on by default and uses the default voltage. As there seems to be at least on board using a different voltage, add the rail to the list of known voltage lines, so we can setup the right voltage as early as possible. Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2018-11-14allwinner: power: add enable switches for DCDC1/5Andre Przywara
The DCDC1 and DCDC5 power rails didn't specify the enable bits. This isn't critical, since those rails are on by default (and are needed for every board), but it is inconsistent. Add the respective enable bits for those two rails. Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2018-11-14allwinner: power: fix DRIVEVBUS pin setupAndre Przywara
The DRIVEVBUS pin setup was broken in two ways: - To configure this pin as an output pin, one has to *clear* the bit in register 0x8f. It is 0 by default, but rebooting from Linux might have left this bit set. - Doing this just configures the pin as an output pin, but doesn't actually drive power to it. This is done via bit 2 in register 0x30. Fix the routine to both properly configure the pin and drive power to it. Add an axp_clrsetbits() helper on the way. Now this isn't really perfect, still: We only need to setup the PMIC power rails that are needed for U-Boot. DRIVEVBUS typically controls the VBUS voltage for the host function of an USB-OTG port, something we typically don't want in U-Boot (fastboot, using the USB *device* functionality, is much more common). The BananaPi-M64 uses the regulator in this way, but the Remix Mini PC actually controls the power of both its USB ports via this line. Technically we should differentiate here: if DRIVEVBUS controls a microUSB-B socket, the power should stay off, any host-type A sockets should be supplied, though. For now just always enable the power, that shouldn't really hurt the USB-OTG functionality anyway. Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2018-11-14allwinner: A64/H5: setup missing bus clocksAndre Przywara
The legacy Allwinner ATF port used to setup some clocks, and U-Boot is still relying on this. We don't need to setup the full set, as the SPL is doing most of it, but it misses one clock (AHB2) and programs another (AHB1) to quite conservative values. Fix this up during the platform setup to improve USB and Ethernet performance, iperf values go up by 31% in my setup with that patch. Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2018-11-08Standardise header guards across codebaseAntonio Nino Diaz
All identifiers, regardless of use, that start with two underscores are reserved. This means they can't be used in header guards. The style that this project is now to use the full name of the file in capital letters followed by 'H'. For example, for a file called "uart_example.h", the header guard is UART_EXAMPLE_H. The exceptions are files that are imported from other projects: - CryptoCell driver - dt-bindings folders - zlib headers Change-Id: I50561bf6c88b491ec440d0c8385c74650f3c106e Signed-off-by: Antonio Nino Diaz <antonio.ninodiaz@arm.com>
2018-10-20allwinner: Use the arisc to turn off ARM coresAndre Przywara
PSCI requires a core to turn itself off, which we can't do properly by just executing an algorithm on that very core. As a consequence we just put a core into WFI on CPU_OFF right now. To fix this let's task the "arisc" management processor (an OpenRISC core) with that task of asserting reset and turning off the core's power domain. We use a handcrafted sequence of OpenRISC instructions to achieve this, and hand this data over to the new sunxi_execute_arisc_code() routine. The commented source code for this routine is provided in a separate file, but the ATF code contains the already encoded instructions as data. The H6 uses the same algorithm, but differs in the MMIO addresses, so provide a SoC (family) specific copy of that code. Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2018-10-20allwinner: Prepare for executing code on the management processorAndre Przywara
The more recent Allwinner SoCs contain an OpenRISC management controller (called arisc or CPUS), which shares the bus with the ARM cores, but runs on a separate power domain. This is meant to handle power management with the ARM cores off. There are efforts to run sophisticated firmware on that core (communicating via SCPI with the ARM world), but for now can use it for the rather simple task of helping to turn the ARM cores off. As this cannot be done by ARM code itself (because execution stops at the first of the three required steps), we can offload some instructions to this management processor. This introduces a helper function to hand over a bunch of instructions and triggers execution. We introduce a bakery lock to avoid two cores trying to use that (single) arisc core. The arisc code is expected to put itself into reset after is has finished execution. Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2018-10-20allwinner: PMIC: AXP803: Delay activation of DC1SW switchAndre Przywara
There are reports that activating the DC1SW before certain other regulators leads to the PMIC overheating and consequently shutting down. To avoid this situation, delay the activation of the DC1SW line until the very end, so those other lines are always activated earlier. Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2018-10-20allwinner: PMIC: AXP803: Setup basic voltage railsAndre Przywara
Based on the just introduced PMIC FDT framework, we check the DT for more voltage rails that need to be setup early: - DCDC1 is typically the main board power rail, used for I/O pins, for instance. The PMIC's default is 3.0V, but 3.3V is what most boards use, so this needs to be adjusted as soon as possible. - DCDC5 is supposed to be connected to the DRAM. The AXP has some configurable reset voltage, but some boards get that wrong, so we better set up this here to avoid over- or under-volting. - DLDO1,2,3 and FLDO1 mostly drive some graphics related IP, some boards need this to be up to enable HDMI or the LCD screen, so we get screen output in U-Boot. To get the right setup, but still being flexible, we query the DT for the required voltage and whether that regulator is actually used. That gives us some robust default setup U-Boot is happy with. Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2018-10-20allwinner: Scan AXP803 FDT node to setup initial power railsAndre Przywara
Now that we have a pointer to the device tree blob, let's use that to do some initial setup of the PMIC: - We scan the DT for the compatible string to find the PMIC node. - We switch the N_VBUSEN pin if the DT property tells us so. - We scan over all regulator subnodes, and switch DC1SW if there is at least one other node referencing it (judging by the existence of a phandle property in that subnode). This is just the first part of the setup, a follow up patch will setup voltages. Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2018-10-20allwinner: Pass FDT address to sunxi_pmic_setup()Andre Przywara
For Allwinner boards we now use some heuritistics to find a preloaded .dtb file. Pass this address on to the PMIC setup routine, so that it can use the information contained therein to setup some initial power rails. Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2018-10-20allwinner: Find DTB in BL33 imageAndre Przywara
The initial PMIC setup for the Allwinner platform is quite board specific, and used to be guarded by reading the .dtb stub *name* from the SPL image in the legacy ATF port. This doesn't scale particularly well, and requires constant maintainance. Instead having the actual .dtb available would be much better, as the PMIC setup requirements could be read from there directly. The only available BL33 for Allwinner platforms so far is U-Boot, and fortunately U-Boot comes with the full featured .dtb, appended to the end of the U-Boot image. Introduce some code that scans the beginning of the BL33 image to look for the load address, which is followed by the image size. Adding those two values together gives us the end of the image and thus the .dtb address. Verify that this heuristic is valid by sanitising some values and checking the DTB magic. Print out the DTB address and the model name, if specified in the root node. Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2018-10-20allwinner: A64: Add AXP803 PMIC support to power off the boardAndre Przywara
Boards with the Allwinner A64 SoC are mostly paired with an AXP803 PMIC, which allows to programmatically power down the board. Use the newly introduced RSB driver to detect and program the PMIC on boot, then later to turn off the main voltage rails when receiving a PSCI SYSTEM_POWER_OFF command. Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2018-10-20allwinner: H6: Factor out I2C platform setupAndre Przywara
In the H6 platform code there is a routine to do the platform initialisation of the R_I2C controller. We will need a very similar setup routine to initialise the RSB controller on the A64. Move this code to sunxi_common.c and generalise it to support all SoCs and also to cover the related RSB bus. Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2018-10-20allwinner: H5: Implement power down for H5 reference design boardsAndre Przywara
Allwinner produces reference board designs, which apparently most board vendors copy from. So every H5 board I checked uses regulators which are controlled by the same PortL GPIO pins to power the ARM CPU cores, the DRAM and the I/O ports. Add a SoC specific power down routine, which turns those regulators off when ATF detects running on an H5 SoC and the rich OS triggers a SYSTEM_POWEROFF PSCI call. NOTE: It sounds very tempting to turn the CPU power off, but this is not working as expected, instead the system is rebooting. Most probably this is due to VCC-SYS also being controlled by the same GPIO line, and turning this off requires an elaborate and not fully understood setup. Apparently not even Allwinner reference code is turning this regulator off. So for now we refrain to pulling down PL8, the power consumption is quite low anyway, so we are as close to poweroff as reasonably possible. Many thanks to Samuel for doing some research on that topic. Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2018-10-20allwinner: Introduce GPIO helper functionAndre Przywara
Many boards without a dedicated PMIC contain simple regulators, which can be controlled via GPIO pins. To later allow turning them off easily, introduce a simple function to configure a given pin as a GPIO out pin and set it to the desired level. Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2018-10-20allwinner: Export sunxi_private.hAndre Przywara
So far we have a sunxi_private.h header file in the common code directory. This holds the prototypes of various functions we share in *common* code. However we will need some of those in the platform specific code parts as well, and want to introduce new functions shared across the whole platform port. So move the sunxi_private.h file into the common/include directory, so that it becomes visible to all parts of the platform code. Fix up the existing #includes and add missing ones, also add the sunxi_read_soc_id() prototype here. This will be used in follow up patches. Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2018-10-20allwinner: A64/H5: Add basic and generic shutdown methodAndre Przywara
Some boards don't have a PMIC, so they can't easily turn their power off. To cover those boards anyway, let's turn off as many devices and clocks as possible, so that the power consumption is reduced. Then halt the last core, as before. This will later be extended with proper PMIC support for supported boards. Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2018-10-20allwinner: Pass SoC ID to sunxi_pmic_setup()Andre Przywara
In the BL31 platform setup we read the Allwinner SoC ID to identify the chip and print its name. In addition to that we will need to differentiate the power setup between the SoCs, to pass on the SoC ID to the PMIC setup routine. Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2018-10-20allwinner: Introduce names for SoC IDsAndre Przywara
We will soon make more use of the Allwinner SoC ID, to differentiate the platform setup. Introduce definitions to avoid dealing with magic numbers and make the code more readable. Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2018-10-20allwinner: H6: Fix SRAM sizeAndre Przywara
The SRAM in the Allwinner H6 SoC starts at 0x2000, with the last part ending at 0x117fff (although with gaps in between). So SUNXI_SRAM_SIZE should be 0xf8000, not 0x98000. Fix this to map the arisc exception vector area, which we will need shortly. Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2018-10-20allwinner: Disable USE_COHERENT_MEMAndre Przywara
According to the documentation, platforms may choose to trade memory footprint for performance (and elegancy) by not providing a separately mapped coherent page. Since a debug build is getting close to the SRAM size limit already, this allows us to save about 3.5KB of BSS and have some room for future enhancements. Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2018-10-20allwinner: Adjust memory mapping to fit into 256MBAndre Przywara
At the moment we map as much of the DRAM into EL3 as possible, however we actually don't use it. The only exception is the secure DRAM for BL32 (if that is configured). To decrease the memory footprint of ATF, we save on some page tables by reducing the memory mapping to the actually required regions: SRAM, device MMIO, secure DRAM and U-Boot (to be used later). This introduces a non-identity mapping for the DRAM regions. Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2018-10-20allwinner: Unify platform.mk filesAndre Przywara
For the two different platforms we support in the Allwinner port we mostly rely on header files covering the differences. This leads to the platform.mk files in the respective directories to be almost identical. To avoid further divergence and make sure that one platform doesn't break accidentally, let's create a shared allwinner-common.mk file and include that from the platform directory. Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2018-09-28allwinner: Remove references to removed build flagsAntonio Nino Diaz
Change-Id: I206478597dd9855d3fe1577e7e2c0fe6d2af1cc5 Tested-by: Andre Przywara <andre.przywara@arm.com> Signed-off-by: Antonio Nino Diaz <antonio.ninodiaz@arm.com>
2018-09-19drivers: i2c: mentor: move platform code into header filesAndre Przywara
At the moment we have two I2C stub drivers (for the Allwinner and the Marvell platform), which #include the actual .c driver file. Change this into the more usual design, by renaming and moving the stub drivers into platform specific header files and including these from the actual driver file. The platform specific include directories make sure the driver picks up the right header automatically. Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2018-09-17allwinner: sun50i_h6: initialise I2C just before powering downAndre Przywara
Even though we initialise the platform part and the I2C controller itself at boot time, we actually only access the bus on power down. Meanwhile a rich OS might have configured the I2C pins differently or even disabled the controller. So repeat the platform setup and controller initialisation just before we actually access the bus to power off the system. This is safe, because at this point the rich OS should no longer be running. Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2018-09-17allwinner: sun50i_h6: improve I2C setupAndre Przywara
Drop the unnecessary check for the I2C pins being already configured as I2C pins (we actually don't care). Also avoid resetting *every* peripheral that is covered by the PRCM reset controller, instead just clear the one line connected to the I2C controller. Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2018-09-07allwinner: implement system power down on H6 w/ AXP805Icenowy Zheng
The AXP805 PMIC used with H6 is capable of shutting down the system. Add support for using it to shut down the system power. The original placeholder power off code is moved to A64 code, as it's still TODO to implement PMIC operations for A64. Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
2018-09-07allwinner: sun50i_h6: add initial AXP805 PMIC codeIcenowy Zheng
The OTT reference design of Allwinner H6 SoC uses an X-Powers AXP805 PMIC. Add initial code for it. Currently it's only detected. Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
2018-09-07allwinner: call PMIC setup codeIcenowy Zheng
As the ATF may need to do some power initialization on Allwinner platform with AXP PMICs, call the PMIC setup code in BL31. Stub of PMIC setup code is added, to prevent undefined reference. Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
2018-07-20PSCI: Fix types of definitionsAntonio Nino Diaz
Also change header guards to fix defects of MISRA C-2012 Rule 21.1. Change-Id: Ied0d4b0e557ef6119ab669d106d2ac5d99620c57 Acked-by: Sumit Garg <sumit.garg@linaro.org> Acked-by: Anson Huang <Anson.Huang@nxp.com> Signed-off-by: Antonio Nino Diaz <antonio.ninodiaz@arm.com>
2018-07-03allwinner: Add Allwinner H6 SoC supportAndre Przywara
The H6 is Allwinner's most recent SoC. It shares most peripherals with the other ARMv8 Allwinner SoCs (A64/H5), but has a completely different memory map. Introduce a separate platform target, which includes a different header file to cater for the address differences. Also add the new build target to the documentation. The new ATF platform name is "sun50i_h6". Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2018-06-28allwinner: Detect and output current SoCAndre Przywara
So far we already support booting on two different SoCs, and we will shortly add a third, so add some code to determine the current SoC type. This can be later used to runtime detect certain properties. Also print the SoC name to the console, to give valuable debug information. Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2018-06-28allwinner: Don't map boot ROMAndre Przywara
There is nothing we need from the BootROM area, so we also don't need to map it in EL3. Remove the mapping and reduce the number of MMAP regions by one. Reported-by: Samuel Holland <samuel@sholland.org> Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2018-06-28allwinner: Relax PSCI entry point checkAndre Przywara
The DRAM controller supports up to 4GB of DRAM, and there are actually boards out there where we can use at least 3GB of this. Relax the PSCI entry point check, to be not restricted to 2GB of DRAM. Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2018-06-28allwinner: security: Fix SPC guardAndre Przywara
The "#ifdef SUNXI_SPC_BASE" guard was meant to allow the build on SoCs without a Secure Peripherals Controller, so that we skip that part of the security setup. But in the current position this will trigger a warning about an unused variable. Simply move the guard one line up to cover the variable as well. Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2018-06-28allwinner: cpu-ops: avoid PSCI on/off outputAndre Przywara
The "INFO" output in sunxi_cpu_ops.c is quite verbose, so make this more obvious by changing the log level to "VERBOSE" and so avoiding it to be printed in a normal (even debug) build. Reported-by: Samuel Holland <samuel@sholland.org> Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2018-06-28allwinner: sun50i_a64: remove unneeded VER_REG offsetAndre Przywara
The relative VER_REG *offset* is the same across all known SoCs, so we can define this offset near it's user. Remove it from the memory map. Reported-by: Samuel Holland <samuel@sholland.org> Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2018-06-28allwinner: common: add missing headerAndre Przywara
Some code in sunxi_common.c requires symbols defined in sunxi_private.h, so add the header to that file. It was included via another header before, but let's make this explicit. Reported-by: Samuel Holland <samuel@sholland.org> Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2018-06-28allwinner: Add BL32 (corresponds to Trusted OS) supportAmit Singh Tomar
This patch is an attempt to run Trusted OS (OP-TEE OS being one of them) along side BL31 image. ATF supports multiple SPD's that can take dispatcher name (opteed for OP-TEE OS) as an input using the 'SPD=<dispatcher name>' option during bl31 build. Signed-off-by: Amit Singh Tomar <amittomer25@gmail.com>
2018-06-15allwinner: Add security setupAndre Przywara
Some peripherals are TrustZone aware, so they need to be configured to be accessible from non-secure world, as we don't need any of them being exclusive to the secure world. This affects some clocks, DMA channels and the Secure Peripheral Controller (SPC). The latter controls access to most devices, but is not active unless booting with the secure boot fuse burnt. Signed-off-by: Andre Przywara <andre.przywara@arm.com>