platform/kernel/u-boot.git
4 years agoarm: enable distro boot for bananapi-r2
Matthias Brugger [Sat, 25 Apr 2020 23:17:46 +0000 (01:17 +0200)]
arm: enable distro boot for bananapi-r2

This patch enables distro boot for the bananapi-r2, based on
a MediaTek mt7623n.

Signed-off-by: Matthias Brugger <mbrugger@suse.com>
4 years agowatchdog MediaTek add upstream compatible
Matthias Brugger [Sat, 25 Apr 2020 23:17:45 +0000 (01:17 +0200)]
watchdog MediaTek add upstream compatible

The upstream compatible is called mt6589-wdt.
Add this compatible to the driver.

Signed-off-by: Matthias Brugger <mbrugger@suse.com>
4 years agotimer MediaTek use upstream compatible
Matthias Brugger [Sat, 25 Apr 2020 23:17:44 +0000 (01:17 +0200)]
timer MediaTek use upstream compatible

The timers compatible string in upstream is called
mt6577-timer. Add this compatible to the driver.

Signed-off-by: Matthias Brugger <mbrugger@suse.com>
4 years agodoc: describe the analysis of crash dumps
Heinrich Schuchardt [Fri, 24 Apr 2020 21:31:20 +0000 (23:31 +0200)]
doc: describe the analysis of crash dumps

Provide an overview of the analysis of U-Boot crash dumps.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
4 years agortc: pcf2127: don't add/subtract 1 to tm_mon
Rasmus Villemoes [Fri, 1 May 2020 13:24:50 +0000 (15:24 +0200)]
rtc: pcf2127: don't add/subtract 1 to tm_mon

As noted in rtc_def.h, the tm_mon field in struct rtc_time is 1-12,
unlike in struct tm where it is 0-11. Currently, running "date" prints
the wrong

Date: 2020-04-01 (Friday)    Time: 13:05:30

and setting the RTC via the date command is also broken.

Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
4 years agoarm: caches: manage phys_addr_t overflow in mmu_set_region_dcache_behaviour
Patrick Delaunay [Fri, 24 Apr 2020 18:20:17 +0000 (20:20 +0200)]
arm: caches: manage phys_addr_t overflow in mmu_set_region_dcache_behaviour

Solved the overflow on phys_addr_t type for start + size in
mmu_set_region_dcache_behaviour() function.

This overflow is avoided by dividing start and end by 2 before addition,
and we only expecting that start and size are even.

This patch doesn't change the current function behavior if the
parameters (start or size) are not aligned on MMU_SECTION_SIZE.

For example, this overflow occurs on ARM32 with:
start = 0xC0000000 and size = 0x40000000
then start + size = 0x100000000 and end = 0x0.

For information the function behavior change with risk of regression,
if we just shift start and size before the addition.
Example with 2MB section size:
  MMU_SECTION_SIZE 0x200000 and MMU_SECTION_SHIFT = 21
  with start = 0x1000000, size = 0x1000000,
  - with the proposed patch, start = 0 and end = 0x1 as previously
  - with the more simple patch:
    end = (start >> MMU_SECTION_SHIFT) + (size >> MMU_SECTION_SHIFT)
    the value of end change:
    start >> 21 = 0, size >> 21 = 0 and end = 0x0 !!!

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
4 years agoarm: caches: add DCACHE_DEFAULT_OPTION
Patrick Delaunay [Fri, 24 Apr 2020 18:20:16 +0000 (20:20 +0200)]
arm: caches: add DCACHE_DEFAULT_OPTION

Add the new flags DCACHE_DEFAULT_OPTION to define the default
option to use according the compilation flags
CONFIG_SYS_ARM_CACHE_*.

This new compilation flag allows to simplify dram_bank_mmu_setup()
and can be used as third parameter (option=dcache option to select)
of mmu_set_region_dcache_behaviour function.

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
4 years agoarm: caches: protect dram_bank_mmu_setup access to bi_dram
Patrick Delaunay [Fri, 24 Apr 2020 18:20:15 +0000 (20:20 +0200)]
arm: caches: protect dram_bank_mmu_setup access to bi_dram

Add protection in dram_bank_mmu_setup() to avoid access to bd->bi_dram
before relocation.

This patch allow to use the generic weak function dram_bank_mmu_setup
to activate the MMU and the data cache in SPL or in U-Boot before
relocation, when bd->bi_dram is not yet initialized.

In this cases, the MMU must be initialized explicitly with
mmu_set_region_dcache_behaviour function.

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
4 years agoconfigs: migrate CONFIG_SYS_ARM_CACHE_* in Kconfig
Patrick Delaunay [Fri, 10 Apr 2020 14:02:02 +0000 (16:02 +0200)]
configs: migrate CONFIG_SYS_ARM_CACHE_* in Kconfig

Move CONFIG_SYS_ARM_CACHE_WRITETHROUGH and
CONFIG_SYS_ARM_CACHE_WRITEALLOC into Kconfig done by moveconfig.py.

Kconfig uses a choice between the 3 values supported in U-Boot,
including the new configuration CONFIG_SYS_ARM_CACHE_WRITEBACK
(the default configuration).

The patch also avoids to select simultaneously 2 configurations.

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
4 years agotiny-printf: Support %i
Marek Vasut [Fri, 10 Apr 2020 18:54:49 +0000 (20:54 +0200)]
tiny-printf: Support %i

The most basic printf("%i", value) formating string was missing,
add it for the sake of convenience.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Simon Glass <sjg@chromium.org>
Cc: Stefan Roese <sr@denx.de>
4 years agonet: smc911x: Add DM support
Marek Vasut [Sun, 15 Mar 2020 16:39:01 +0000 (17:39 +0100)]
net: smc911x: Add DM support

Add support for U-Boot DM and DT probing. Furthermore, build the
SMC911x standalone EEPROM example only for the non-DM case, as it
is not converted yet.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Joe Hershberger <joe.hershberger@ni.com>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
4 years agoarm: imx: Add support for Google's Coral Dev Board
Alifer Moraes [Fri, 6 Mar 2020 10:46:33 +0000 (07:46 -0300)]
arm: imx: Add support for Google's Coral Dev Board

Add initial support for Google's Coral Dev Board based on i.MX8MQ.

https://coral.ai/products/dev-board

The Phanbell naming has been used here to match the naming convention
used in Google's U-Boot source tree:

https://coral.googlesource.com/uboot-imx/

Co-developed-by: Fabio Estevam <festevam@gmail.com>
Signed-off-by: Alifer Moraes <alifer.wsdm@gmail.com>
Tested-by: Marco Franchi <marcofrk@gmail.com>
4 years agoARM: imx8m: Fix reset in SPL on Toradex iMX8MM Verdin
Marek Vasut [Wed, 29 Apr 2020 13:04:27 +0000 (15:04 +0200)]
ARM: imx8m: Fix reset in SPL on Toradex iMX8MM Verdin

Board files should not re-implement do_reset() to work around this
function not being defined in for specific configurations. Rather,
the fix is to compile in drivers which implement this properly.
This patch enables sysreset and watchdog drivers in SPL and ties
them together to implement the same as the do_reset() hack in the
board file, except correctly in the DM/DT framework.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Fabio Estevam <festevam@gmail.com>
Cc: Flavio Suligoi <f.suligoi@asem.it>
Cc: Harald Seiler <hws@denx.de>
Cc: Igor Opaniuk <igor.opaniuk@toradex.com>
Cc: Marcel Ziswiler <marcel.ziswiler@toradex.com>
Cc: Oleksandr Suvorov <oleksandr.suvorov@toradex.com>
Cc: Peng Fan <peng.fan@nxp.com>
Cc: Stefano Babic <sbabic@denx.de>
Reviewed-by: Oleksandr Suvorov <oleksandr.suvorov@toradex.com>
Acked-by: Igor Opaniuk <igor.opaniuk@toradex.com>
Acked-by: Igor Opaniuk <igor.opaniuk@toradex.com>
4 years agoARM: imx8m: Fix reset in SPL on NXP iMX8MP EVK
Marek Vasut [Wed, 29 Apr 2020 13:04:26 +0000 (15:04 +0200)]
ARM: imx8m: Fix reset in SPL on NXP iMX8MP EVK

Board files should not re-implement do_reset() to work around this
function not being defined in for specific configurations. Rather,
the fix is to compile in drivers which implement this properly.
This patch enables sysreset and watchdog drivers in SPL and ties
them together to implement the same as the do_reset() hack in the
board file, except correctly in the DM/DT framework.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Fabio Estevam <festevam@gmail.com>
Cc: Flavio Suligoi <f.suligoi@asem.it>
Cc: Harald Seiler <hws@denx.de>
Cc: Igor Opaniuk <igor.opaniuk@toradex.com>
Cc: Marcel Ziswiler <marcel.ziswiler@toradex.com>
Cc: Oleksandr Suvorov <oleksandr.suvorov@toradex.com>
Cc: Peng Fan <peng.fan@nxp.com>
Cc: Stefano Babic <sbabic@denx.de>
4 years agoARM: imx8m: Fix reset in SPL on NXP iMX8MN EVK
Marek Vasut [Wed, 29 Apr 2020 13:04:25 +0000 (15:04 +0200)]
ARM: imx8m: Fix reset in SPL on NXP iMX8MN EVK

Board files should not re-implement do_reset() to work around this
function not being defined in for specific configurations. Rather,
the fix is to compile in drivers which implement this properly.
This patch enables sysreset and watchdog drivers in SPL and ties
them together to implement the same as the do_reset() hack in the
board file, except correctly in the DM/DT framework.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Fabio Estevam <festevam@gmail.com>
Cc: Flavio Suligoi <f.suligoi@asem.it>
Cc: Harald Seiler <hws@denx.de>
Cc: Igor Opaniuk <igor.opaniuk@toradex.com>
Cc: Marcel Ziswiler <marcel.ziswiler@toradex.com>
Cc: Oleksandr Suvorov <oleksandr.suvorov@toradex.com>
Cc: Peng Fan <peng.fan@nxp.com>
Cc: Stefano Babic <sbabic@denx.de>
4 years agoARM: imx8m: Fix reset in SPL on NXP iMX8MM EVK
Marek Vasut [Wed, 29 Apr 2020 13:04:24 +0000 (15:04 +0200)]
ARM: imx8m: Fix reset in SPL on NXP iMX8MM EVK

Board files should not re-implement do_reset() to work around this
function not being defined in for specific configurations. Rather,
the fix is to compile in drivers which implement this properly.
This patch enables sysreset and watchdog drivers in SPL and ties
them together to implement the same as the do_reset() hack in the
board file, except correctly in the DM/DT framework.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Fabio Estevam <festevam@gmail.com>
Cc: Flavio Suligoi <f.suligoi@asem.it>
Cc: Harald Seiler <hws@denx.de>
Cc: Igor Opaniuk <igor.opaniuk@toradex.com>
Cc: Marcel Ziswiler <marcel.ziswiler@toradex.com>
Cc: Oleksandr Suvorov <oleksandr.suvorov@toradex.com>
Cc: Peng Fan <peng.fan@nxp.com>
Cc: Stefano Babic <sbabic@denx.de>
4 years agoARM: imx8m: Don't use the addr parameter of reset_cpu()
Claudius Heine [Wed, 29 Apr 2020 13:04:23 +0000 (15:04 +0200)]
ARM: imx8m: Don't use the addr parameter of reset_cpu()

imx8m has the only implementation of reset_cpu() which does not ignore
the addr parameter and instead gives it some meaning as the base address
of watchdog registers.  This breaks convention with the rest of U-Boot
where the parameter is ignored and callers are passing in 0.

Fixes: d2041725e84b ("imx8m: restrict reset_cpu")
Co-developed-by: Harald Seiler <hws@denx.de>
Signed-off-by: Harald Seiler <hws@denx.de>
Signed-off-by: Claudius Heine <ch@denx.de>
4 years agoARM: imx8m: Fix indentation of reset_cpu() function
Harald Seiler [Wed, 29 Apr 2020 13:04:22 +0000 (15:04 +0200)]
ARM: imx8m: Fix indentation of reset_cpu() function

Use proper code-style, tabs instead of spaces for indentation.

Signed-off-by: Harald Seiler <hws@denx.de>
4 years agoARM: imx8m: Do not define do_reset() if sysreset is enabled
Marek Vasut [Wed, 29 Apr 2020 13:04:21 +0000 (15:04 +0200)]
ARM: imx8m: Do not define do_reset() if sysreset is enabled

The SPL can also be compiled with sysreset drivers just fine, so
update the condition to cater for that option.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Fabio Estevam <festevam@gmail.com>
Cc: Flavio Suligoi <f.suligoi@asem.it>
Cc: Harald Seiler <hws@denx.de>
Cc: Igor Opaniuk <igor.opaniuk@toradex.com>
Cc: Marcel Ziswiler <marcel.ziswiler@toradex.com>
Cc: Oleksandr Suvorov <oleksandr.suvorov@toradex.com>
Cc: Peng Fan <peng.fan@nxp.com>
Cc: Stefano Babic <sbabic@denx.de>
4 years agodt-bindings: pinctrl: imxrt1020: remove useless comment
Giulio Benetti [Mon, 20 Apr 2020 15:48:12 +0000 (17:48 +0200)]
dt-bindings: pinctrl: imxrt1020: remove useless comment

A comment note has been left after completing pinctrl listing, so let's
remove it since it's useless.

Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
4 years agoARM: imx: imx8m: Do not warn about cpu-idle-states if missing
Marek Vasut [Fri, 24 Apr 2020 19:37:33 +0000 (21:37 +0200)]
ARM: imx: imx8m: Do not warn about cpu-idle-states if missing

If the cpu-idle-states is missing from the DT in the first place, do
not fail on removing in. Just move on and do not even print an error,
since not being able to remove something which is not there in the
first place is not an error and surely does not justify failing to
boot.

Turn the surrounding prints into debugs to reduce the useless noise.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Frieder Schrempf <frieder.schrempf@kontron.de>
Cc: Fabio Estevam <festevam@gmail.com>
Cc: Peng Fan <peng.fan@nxp.com>
Cc: Stefano Babic <sbabic@denx.de>
Reviewed-by: Fabio Estevam <festevam@gmail.com>
4 years agoarm: dts: imx8mm: sync dts from Linux Kernel 5.6.7
Adam Ford [Mon, 27 Apr 2020 12:11:19 +0000 (07:11 -0500)]
arm: dts: imx8mm: sync dts from Linux Kernel 5.6.7

This patch synchronizes the device tree with that from 5.6.7.

This also adds nodes for crypto and ddrc, which makes keeping
the device tree files from individual boards in sync with the
Linux kernel.  This is helpful when boads reference those nodes.

Signed-off-by: Adam Ford <aford173@gmail.com>
4 years agotreewide: Remove unused FSL QSPI config options for IMX platforms
Kuldeep Singh [Thu, 20 Feb 2020 17:27:54 +0000 (22:57 +0530)]
treewide: Remove unused FSL QSPI config options for IMX platforms

Some of these options are not used by the driver anymore and some of them
are obsolete as the information is gathered from the dt.
So, remove the unused config options now.

Signed-off-by: Frieder Schrempf <frieder.schrempf@kontron.de>
Signed-off-by: Ashish Kumar <Ashish.Kumar@nxp.com>
Signed-off-by: Kuldeep Singh <kuldeep.singh@nxp.com>
4 years agoimx8qxp_mek: Run with caches enabled
Fabio Estevam [Mon, 20 Apr 2020 18:55:29 +0000 (15:55 -0300)]
imx8qxp_mek: Run with caches enabled

There is no need to run with caches disabled.

Signed-off-by: Fabio Estevam <festevam@gmail.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
4 years agoimx8qxp_mek: Remove SPL watchdog option
Fabio Estevam [Mon, 20 Apr 2020 12:55:47 +0000 (09:55 -0300)]
imx8qxp_mek: Remove SPL watchdog option

Currently the following watchdog error is seen in SPL:

U-Boot SPL 2020.04-00407-g8d5d3bcf3c (Apr 20 2020 - 09:48:09 -0300)
Normal Boot
WDT:   Not found!
...

There is no watchdog driver for i.MX8 at the moment, nor code for
configuring the watchdog in SPL, so remove the CONFIG_SPL_WATCHDOG_SUPPORT
option for now.

Signed-off-by: Fabio Estevam <festevam@gmail.com>
Reviewed-by: Stefano Babic <sbabic@denx.de>
4 years agoimx8: Run SPL with caches enabled
Fabio Estevam [Tue, 21 Apr 2020 15:02:45 +0000 (12:02 -0300)]
imx8: Run SPL with caches enabled

It is safe to run SPL with caches enabled on i.MX8, so
remove such restriction.

Signed-off-by: Fabio Estevam <festevam@gmail.com>
Acked-by: Peng Fan <peng.fan@nxp.com>
Acked-by: Oliver Graute <oliver.graute@kococonnector.com>
Acked-by: Anatolij Gustschin <agust@denx.de>
Tested-by: Igor Opaniuk <igor.opaniuk@toradex.com>
Acked-by: Igor Opaniuk <igor.opaniuk@toradex.com>
4 years agoconfig: apalis-imx8: Enable FEC TXC delay
Philippe Schenker [Wed, 11 Mar 2020 10:52:59 +0000 (11:52 +0100)]
config: apalis-imx8: Enable FEC TXC delay

define FEC_ENET_ENABLE_TXC_DELAY to enable the delay on TXC line on
the MAC. This has to be done in order to meet RGMII specs.
According to RGMII specs the clock should get delayed so the edges of
the clock are preferrably in the middle of the edges of data-lines so
they can be sampled properly.
Our PHY expects the MAC to delay TXC line, as it is also written
in the spec. This patch makes sure the TXC delay on the FEC is enabled

Signed-off-by: Philippe Schenker <philippe.schenker@toradex.com>
Reviewed-by: Oleksandr Suvorov <oleksandr.suvorov@toradex.com>
4 years agonet: fec: Add possibility to enable TXC delay
Philippe Schenker [Wed, 11 Mar 2020 10:52:58 +0000 (11:52 +0100)]
net: fec: Add possibility to enable TXC delay

This patch enables the possibility to set FEC_ENET_ENABLE_TXC_DELAY or
FEC_ENET_ENABLE_RXC_DELAY so one can via a define enable the RXC or TXC
delay in the MAC.

Signed-off-by: Philippe Schenker <philippe.schenker@toradex.com>
Reviewed-by: Oleksandr Suvorov <oleksandr.suvorov@toradex.com>
4 years agoboard: apalis_imx6: Add KSZ9131 phy skew settings
Philippe Schenker [Wed, 11 Mar 2020 10:59:26 +0000 (11:59 +0100)]
board: apalis_imx6: Add KSZ9131 phy skew settings

This patch adds skew register settings for KSZ9131. It checks first
which phy is on the board and then applies the correct skew settings.

Skew settings calculation for the KSZ9131:
The i.MX6 SoC has an output skew tolerance of -100ps to 900ps. All
PCB traces where routed exactly the same length so we can calculate
the skew settings without taking the length into consideration. The
traces are all length matched.

RXC skew (PHY to MAC):
- We use the 2ns DLL controlled delay on the PHY
- We do not use the skew registers

This results in the following values:

RXC
PHY fixed Delay 2000ps
PHY Added Delay 0ps
T_setup_R min 2.00ns
T_setup_R typ 2.00ns
T_setup_R max 2.00ns
T_hold_R min 1.60ns
T_hold_R typ 2.00ns
T_hold_R max 2.40ns

That means we are well within RGMII specs.

TXC skew (MAC to PHY):
- We use the 2ns DLL controlled delay on the PHY
- We then subtract ~0.6ns with TXD[0:3] and TXC clock pad skew
  register in a resulting ~1.4ns delay.

This results in the following values under consideration of the
tolerances:

TXC min TXC typ TXC max
MAC min -100ps -100ps -100ps
MAC max 900ps 900ps 900ps
PHY fixed Delay 2000ps 2000ps 2000ps
PHY added Delay -340ps -600ps -859ps
T_setup_T min 1.56ns 1.30ns 1.04ns
T_setup_T typ 2.06ns 1.80ns 1.54ns
T_setup_T max 2.56ns 2.30ns 2.04ns
T_hold_T min 1.04ns 1.30ns 1.56ns
T_hold_T typ 1.94ns 2.20ns 2.46ns
T_hold_T max 2.84ns 3.10ns 3.36ns

This shows that T_hold_T min and T_setup_T min times are out of spec
for RGMII timing. However the KSZ9131 has a minimal value for this time
of 0.8ns which is met under all circumstances.

Signed-off-by: Philippe Schenker <philippe.schenker@toradex.com>
4 years agoboard: verdin-imx8mm: Add KSZ9131 phy skew settings
Philippe Schenker [Wed, 11 Mar 2020 10:59:25 +0000 (11:59 +0100)]
board: verdin-imx8mm: Add KSZ9131 phy skew settings

This patch determines which phy is placed on the board with the PHY ID
then it sets the same settings for KSZ9031 as before but for KSZ9131
it enables both RXC and TXC delay lines in the PHY.
This will compensate the missing delay from the MAC. Other skew
settings are not needed as the traces on board are routed exactly the
same length

Signed-off-by: Philippe Schenker <philippe.schenker@toradex.com>
Tested-by: Igor Opaniuk <igor.opaniuk@toradex.com>
Acked-by: Igor Opaniuk <igor.opaniuk@toradex.com>
4 years agoverdin-imx8mm: Change board phy skew values for our ksz9031
Philippe Schenker [Wed, 11 Mar 2020 10:59:24 +0000 (11:59 +0100)]
verdin-imx8mm: Change board phy skew values for our ksz9031

This patches uses the existing functions for interacting with the
KSZ9031 and uses the values appropriate for our board.

Signed-off-by: Philippe Schenker <philippe.schenker@toradex.com>
Tested-by: Igor Opaniuk <igor.opaniuk@toradex.com>
Acked-by: Igor Opaniuk <igor.opaniuk@toradex.com>
4 years agonet: phy: micrel: Add basic support for KSZ9131
Philippe Schenker [Wed, 11 Mar 2020 10:59:23 +0000 (11:59 +0100)]
net: phy: micrel: Add basic support for KSZ9131

This adds basic support for the new Micrel KSZ9131 phy.

Signed-off-by: Philippe Schenker <philippe.schenker@toradex.com>
4 years agonet: phy: micrel: Use defines for PHY_IDs and MASK
Philippe Schenker [Wed, 11 Mar 2020 10:59:22 +0000 (11:59 +0100)]
net: phy: micrel: Use defines for PHY_IDs and MASK

Signed-off-by: Philippe Schenker <philippe.schenker@toradex.com>
4 years agomx8mq_evk: Remove unrelated comment
Fabio Estevam [Mon, 20 Apr 2020 15:38:51 +0000 (12:38 -0300)]
mx8mq_evk: Remove unrelated comment

The comment does not relate to the setup_i2c() function, so just
remove it.

Signed-off-by: Fabio Estevam <festevam@gmail.com>
4 years agoimx8mp_evk: Remove unrelated comment
Fabio Estevam [Mon, 20 Apr 2020 15:38:50 +0000 (12:38 -0300)]
imx8mp_evk: Remove unrelated comment

The comment does not relate to the setup_i2c() function, so just
remove it.

Signed-off-by: Fabio Estevam <festevam@gmail.com>
4 years agoimx: imx8m: Don't use the addr parameter of reset_cpu
Claudius Heine [Wed, 4 Mar 2020 14:23:12 +0000 (15:23 +0100)]
imx: imx8m: Don't use the addr parameter of reset_cpu

imx8m has the only implementation of `reset_cpu` which does not ignore
the addr parameter and instead gives it some meaning as the base address
of watchdog registers.  This breaks convention with the rest of U-Boot
where the parameter is ignored and callers are passing in 0.

Fixes: d2041725e84b ("imx8m: restrict reset_cpu")
Co-Authored-by: Harald Seiler <hws@denx.de>
Signed-off-by: Claudius Heine <ch@denx.de>
Signed-off-by: Harald Seiler <hws@denx.de>
Reviewed-by: Marek Vasut <marex@denx.de>
4 years agoimx: imx8m*: Remove do_reset from board files
Claudius Heine [Wed, 4 Mar 2020 14:23:11 +0000 (15:23 +0100)]
imx: imx8m*: Remove do_reset from board files

Use the `do_reset` implementation of `arch/arm/lib/reset.c` in SPL
instead.  It is very close to what is done here, anyway, and plays
more nicely with the rest of U-Boot than adding a custom `do_reset`
implementation into board files.

`do_reset` from `arch/arm/lib/reset.c` calls `reset_cpu` with 0 as the
addr parameter while the boards are passing WDOG1_BASE_ADDR.  This is
ok because the `reset_cpu` implementation uses WDOG1_BASE_ADDR by
default if 0 is passed in.

Co-Authored-by: Harald Seiler <hws@denx.de>
Signed-off-by: Claudius Heine <ch@denx.de>
Signed-off-by: Harald Seiler <hws@denx.de>
Reviewed-by: Marek Vasut <marex@denx.de>
4 years agoARM: reset: use do_reset in SPL/TPL if SYSRESET was not enabled for them
Claudius Heine [Wed, 4 Mar 2020 14:23:10 +0000 (15:23 +0100)]
ARM: reset: use do_reset in SPL/TPL if SYSRESET was not enabled for them

In case CONFIG_SYSRESET is set, do_reset from reset.c will not be available
anywere, even if SYSRESET is disabled for SPL/TPL.

'do_reset' is called from SPL for instance from the panic handler and
PANIC_HANG is not set

Signed-off-by: Claudius Heine <ch@denx.de>
Reviewed-by: Marek Vasut <marex@denx.de>
4 years agoimx8: Configure SNVS
Franck LENORMAND [Wed, 9 Oct 2019 08:27:43 +0000 (10:27 +0200)]
imx8: Configure SNVS

Add a module to configure the tamper and secure violation of
the SNVS using the SCU API.

The module also adds some commands:
 - snvs_cfg: Configure the SNVS HP and LP registers
 - snvs_dgo_cfg: Configure the SNVS DGO bloc if present (8QXP)
 - tamper_pin_cfg: Change the configuration of the tamper pins
 - snvs_clear_status: Allow to write to LPSR and LPTDSR to clear
   status bits

Reviewed-by: Fabio Estevam <festevam@gmail.com>
Signed-off-by: Franck LENORMAND <franck.lenormand@nxp.com>
Signed-off-by: Ye Li <ye.li@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
4 years agoimx8: Update SCFW API to version 1.5
Ye Li [Thu, 14 Nov 2019 05:20:43 +0000 (21:20 -0800)]
imx8: Update SCFW API to version 1.5

Sync the latest SCFW API with below commit
6dcd0242ae7a53ac ("SCF-105: Revert accidental change") to add
interfaces for PM resource reset and read/write SNVS security
violation and tamper DGO registers.

Reviewed-by: Fabio Estevam <festevam@gmail.com>
Signed-off-by: Ye Li <ye.li@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
4 years agoimx8: scu api: Add support for SECO manufacturing protection APIs
Breno Lima [Wed, 16 Oct 2019 21:10:54 +0000 (18:10 -0300)]
imx8: scu api: Add support for SECO manufacturing protection APIs

SECO provides APIs to support CAAM manufacturing protection:

- sc_seco_get_mp_key()
- sc_seco_get_mp_sign()
- sc_seco_update_mpmr()

Add SCFW APIs support.

Reviewed-by: Fabio Estevam <festevam@gmail.com>
Signed-off-by: Breno Lima <breno.lima@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
4 years agodoc: ahab: Add encrypted boot documentation for i.MX8/8x devices
Breno Lima [Mon, 11 Nov 2019 21:54:09 +0000 (18:54 -0300)]
doc: ahab: Add encrypted boot documentation for i.MX8/8x devices

Add AHAB encrypted boot documentation for i.MX8/8x family devices
covering the following topics:

- How to encrypt and sign the 2nd container in flash.bin image.
- How to encrypt and sign a standalone container image.

Include a CSF example to encrypt 2nd container in flash.bin image.

Reviewed-by: Fabio Estevam <festevam@gmail.com>
Signed-off-by: Catia Han <yaqian.han@nxp.com>
Signed-off-by: Breno Lima <breno.lima@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
4 years agoimx8m: Enable WDOG_B for timeout
Ye Li [Mon, 9 Dec 2019 08:47:18 +0000 (00:47 -0800)]
imx8m: Enable WDOG_B for timeout

When doing reset_cpu, in normal case the WDOG_B outputs immediately
after we clean WDA bit. But on mscale, the WDOG_B may be later than
internal reset, and cause PMIC not reset. As we enabled the SD3.0
support, the PMIC must be reset to reset SD card.

Change the reset_cpu to enable the WDOG_B for timeout as well, and set
WDOG timeout to 1s.

Reviewed-by: Fabio Estevam <festevam@gmail.com>
Acked-by: Peng Fan <peng.fan@nxp.com>
Signed-off-by: Ye Li <ye.li@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
4 years agoimx8mm: clock: fix fracpll decode issue
Ye Li [Tue, 24 Mar 2020 02:54:29 +0000 (19:54 -0700)]
imx8mm: clock: fix fracpll decode issue

The fracpll decoding is using the bit definitions for int pll. Most of
them are same, but the CLKE bit is different. Fix the wrong CLKE_MASK
for fracpll and correct all bit definitions in fracpll decoding.

Reviewed-by: Fabio Estevam <festevam@gmail.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
Signed-off-by: Ye Li <ye.li@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
4 years agoimx8: parser: fix some bad debug message formating
Peng Fan [Wed, 22 Apr 2020 07:45:42 +0000 (15:45 +0800)]
imx8: parser: fix some bad debug message formating

In SPL build, the formatting '%llx' in debug() is not supported.
Also, fix some misplaced parameters in printf.

Modified from Seb Fagard's downstream patch

Reviewed-by: Fabio Estevam <festevam@gmail.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
4 years agoimx8: ahab: fix some bad debug message formating
Seb Fagard [Mon, 30 Mar 2020 15:13:31 +0000 (17:13 +0200)]
imx8: ahab: fix some bad debug message formating

In SPL build, the formatting '%llx' in debug() is not supported.
Also, fix some misplaced parameters in printf.

Reviewed-by: Fabio Estevam <festevam@gmail.com>
Reviewed-by: Ye Li <ye.li@nxp.com>
Signed-off-by: Seb Fagard <sebastien.fagard@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
4 years agoimx8: ahab: fix 'end address' parameter of rm_find_memreg
Peng Fan [Wed, 22 Apr 2020 07:36:34 +0000 (15:36 +0800)]
imx8: ahab: fix 'end address' parameter of rm_find_memreg

parameter 'end address' must be inclusive of address range.

Reviewed-by: Fabio Estevam <festevam@gmail.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
4 years agoimx8: Change to use new SECO API commands
Ye Li [Tue, 15 Oct 2019 06:08:46 +0000 (23:08 -0700)]
imx8: Change to use new SECO API commands

Latest SCFW has removed old MISC SECO commands. So update the codes
to use new SECO commands.

Reviewed-by: Fabio Estevam <festevam@gmail.com>
Signed-off-by: Ye Li <ye.li@nxp.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
4 years agoimx8: parser: fix 'end address' parameter of rm_find_memreg
Peng Fan [Wed, 22 Apr 2020 07:25:31 +0000 (15:25 +0800)]
imx8: parser: fix 'end address' parameter of rm_find_memreg

parameter 'end address' must be inclusive of address range.

Modified from Seb's downstream patch.

Reviewed-by: Fabio Estevam <festevam@gmail.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
4 years agoimx8m: Dump DRAM PLL rate by clocks command
Ye Li [Tue, 24 Mar 2020 02:57:55 +0000 (19:57 -0700)]
imx8m: Dump DRAM PLL rate by clocks command

Add the dump of DRAM PLL into "clocks" command

Reviewed-by: Fabio Estevam <festevam@gmail.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
Signed-off-by: Ye Li <ye.li@nxp.com>
4 years agoimx8mq: Set ARM core clock directly from ARM PLL
Peng Fan [Wed, 22 Apr 2020 03:18:23 +0000 (11:18 +0800)]
imx8mq: Set ARM core clock directly from ARM PLL

For ARM core clock, there are two input branches, and can select via mux:
one from ARM PLL directly, second from CCM A53 clock root.

Currently we are using second branch. But IC confirmed the CCM A53 root
signoff timing is 1Ghz, so we should switch to input from ARM PLL directly.

This patch fixes the CORE SEL slice configuration and switch ARM clock
to ARM PLL.

Reviewed-by: Fabio Estevam <festevam@gmail.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
4 years agoimx8mq: Enable eMMC HS400 and SD UHS mode on EVK
Ye Li [Fri, 25 Oct 2019 08:28:48 +0000 (01:28 -0700)]
imx8mq: Enable eMMC HS400 and SD UHS mode on EVK

iMX8MQ EVK board has a eMMC5.0 chip and supports SD3.0, so enable the UHS
and HS400 configs to enhance the eMMC/SD access.

The change also needs to set usdhc clock to 400Mhz, and add the
off-on-delay-us to SD reset pin, otherwise some SD cards will
fail to select UHS mode in re-initialization.

Reviewed-by: Fabio Estevam <festevam@gmail.com>
Signed-off-by: Ye Li <ye.li@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
4 years agoimx8m: update clock root and fix core_sel
Peng Fan [Wed, 22 Apr 2020 02:55:56 +0000 (10:55 +0800)]
imx8m: update clock root and fix core_sel

Update clock root table to let it be easy to configure clock at
very early stage. Also the core_sel mux parent should be A53 CLK
root and ARM PLL.

Reviewed-by: Fabio Estevam <festevam@gmail.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
4 years agoimx8m: acquire ATF commit hash
Peng Fan [Wed, 22 Apr 2020 02:51:13 +0000 (10:51 +0800)]
imx8m: acquire ATF commit hash

Acquire ATF commit hash when booting U-Boot to make user easy
to know the ATF version.

Reviewed-by: Fabio Estevam <festevam@gmail.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
4 years agoimx8: move SIP macro to common header
Peng Fan [Wed, 22 Apr 2020 02:50:04 +0000 (10:50 +0800)]
imx8: move SIP macro to common header

Move the SIP macro to common header and unify the name to
make others could reuse them.

Reviewed-by: Fabio Estevam <festevam@gmail.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
4 years agoimx: update is_imx6ull to include i.MX6ULZ
Peng Fan [Wed, 5 Feb 2020 12:17:17 +0000 (20:17 +0800)]
imx: update is_imx6ull to include i.MX6ULZ

Update is_imx6ull helper to include i.MX6ULZ SoC. i.MX6ULZ could
share same macro, then we no need to add is_imx6ulz in various drivers.

Reviewed-by: Fabio Estevam <festevam@gmail.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
4 years agoimx: imx8m: add i.MX8MN variants support
Peng Fan [Wed, 5 Feb 2020 09:39:27 +0000 (17:39 +0800)]
imx: imx8m: add i.MX8MN variants support

Add i.MX8MN variants support

Reviewed-by: Fabio Estevam <festevam@gmail.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
4 years agoimx: imx8m: add i.MX8MQ Dual and QuadLite support
Peng Fan [Wed, 5 Feb 2020 09:34:54 +0000 (17:34 +0800)]
imx: imx8m: add i.MX8MQ Dual and QuadLite support

Add i.MX8MQ Dual and QuadLite variants.

Reviewed-by: Fabio Estevam <festevam@gmail.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
4 years agoimx: cpu: support speed grade for i.MX8MP
Peng Fan [Fri, 17 Jan 2020 08:11:29 +0000 (16:11 +0800)]
imx: cpu: support speed grade for i.MX8MP

i.MX8MP speed grade use same layout as i.MX8MN, so reuse it for i.MX8MP

Reviewed-by: Ye Li <ye.li@nxp.com>
Reviewed-by: Fabio Estevam <festevam@gmail.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
4 years agoimx8mn: Update speed grade
Peng Fan [Wed, 12 Dec 2018 10:47:58 +0000 (02:47 -0800)]
imx8mn: Update speed grade

imx8mn speed grade fuse uses new definitions as below. So have
to update get_cpu_speed_grade_hz function to match it.

SPEED_GRADE[5:4]    SPEED_GRADE[3:0]    MHz
      xx                0000            2300
      xx                0001            2200
      xx                0010            2100
      xx                0011            2000
      xx                0100            1900
      xx                0101            1800
      xx                0110            1700
      xx                0111            1600
      xx                1000            1500
      xx                1001            1400
      xx                1010            1300
      xx                1011            1200
      xx                1100            1100
      xx                1101            1000
      xx                1110             900
      xx                1111             800

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Reviewed-by: Fabio Estevam <festevam@gmail.com>
4 years agoimx8mm: Update CPU speed grading
Ye Li [Wed, 17 Oct 2018 06:12:37 +0000 (23:12 -0700)]
imx8mm: Update CPU speed grading

According to iMX8MM datasheet (IMX8MMIEC_Rev_D and IMX8MMCEC_Rev_D),
the speed grading for imx8mm is 800Mhz, 1.2Ghz, 1.6Ghz and 1.8Ghz.
Update them to get_cpu_speed_grade_hz function.

Signed-off-by: Ye Li <ye.li@nxp.com>
Reviewed-by: Fabio Estevam <festevam@gmail.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
4 years agoimx: fix cpu_type helper
Peng Fan [Wed, 5 Feb 2020 09:44:28 +0000 (17:44 +0800)]
imx: fix cpu_type helper

i.MX8MP use 0x182 as its ID, so 0xff is not valid to get the cpu type,
extend it to 0x1ff.

Reviewed-by: Fabio Estevam <festevam@gmail.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
4 years agoARM: imx: imx8mm: Add missing clock entries for FEC clock
Marek Vasut [Fri, 24 Apr 2020 19:37:26 +0000 (21:37 +0200)]
ARM: imx: imx8mm: Add missing clock entries for FEC clock

All the FEC ethernet clock entries for iMX8MM are missing, while they
are already present on iMX8MQ. Fill in the nodes on iMX8MM, as the FEC
ethernet gets bogus clock information otherwise which makes ethernet
inoperable.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Fabio Estevam <festevam@gmail.com>
Cc: Peng Fan <peng.fan@nxp.com>
Cc: Stefano Babic <sbabic@denx.de>
Reviewed-by: Fabio Estevam <festevam@gmail.com>
4 years agonet: smc911x: Split non-DM specific bits from common code
Marek Vasut [Sun, 15 Mar 2020 16:25:27 +0000 (17:25 +0100)]
net: smc911x: Split non-DM specific bits from common code

Split network handling functions into non-DM specific parts and
common code in preparation for conversion to DM.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Joe Hershberger <joe.hershberger@ni.com>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
4 years agonet: smc911x: Clean up the status handling in smc911x_recv()
Marek Vasut [Sun, 15 Mar 2020 16:02:05 +0000 (17:02 +0100)]
net: smc911x: Clean up the status handling in smc911x_recv()

Invert the status handling logic in smc911x_recv(), to make the
function easier to read, no functional change.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Joe Hershberger <joe.hershberger@ni.com>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
4 years agonet: smc911x: Pass around driver private data
Marek Vasut [Sun, 15 Mar 2020 14:36:09 +0000 (15:36 +0100)]
net: smc911x: Pass around driver private data

Introduce a private data structure for this driver with embedded
struct eth_device and pass it around. This prepares the driver to
work with both DM and non-DM systems.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Joe Hershberger <joe.hershberger@ni.com>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
4 years agonet: smc911x: Convert IO accessors to {read,write}{w,l}()
Marek Vasut [Sun, 15 Mar 2020 13:42:23 +0000 (14:42 +0100)]
net: smc911x: Convert IO accessors to {read,write}{w,l}()

Convert the IO accessors to standard ones instead of using volatile
void pointers, as those do not cover all the bus access details.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Joe Hershberger <joe.hershberger@ni.com>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
4 years agonet: smc911x: Drop weak alias from 32bit accessors
Marek Vasut [Sun, 15 Mar 2020 13:38:59 +0000 (14:38 +0100)]
net: smc911x: Drop weak alias from 32bit accessors

These accessors are not overridden by any board, and even if they were,
this is something which should be handled via DM now, so remove the
weak alias option. Moreover, drop the inline keyword, as the compiler
can decide better.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Joe Hershberger <joe.hershberger@ni.com>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
4 years agonet: smc911x: Inline all functions from header file
Marek Vasut [Sun, 15 Mar 2020 14:03:07 +0000 (15:03 +0100)]
net: smc911x: Inline all functions from header file

Inline all the functions from the header file, as they are not used
outside of the driver or the standalone EEPROM example.

Note that this does introduce considerable amount of duplication in
the standalone EEPROM example, however that one has to be rewritten
anyway, roughly such that the SMC911x driver would expose DM EEPROM
interface and the standalone example would use that.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Joe Hershberger <joe.hershberger@ni.com>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
4 years agonet: smc911x: Pull MII registration into separate function
Marek Vasut [Sat, 21 Mar 2020 16:25:41 +0000 (17:25 +0100)]
net: smc911x: Pull MII registration into separate function

Pull the MII interface registration into separate function to avoid the
ifdeffery in smc911x_initialize(). Moreover, adjust the fail path such
that we use goto labels.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Joe Hershberger <joe.hershberger@ni.com>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
4 years agonet: smc911x: Fix potential memleak() in init fail path
Marek Vasut [Sun, 15 Mar 2020 14:57:14 +0000 (15:57 +0100)]
net: smc911x: Fix potential memleak() in init fail path

Fix memleak in the init fail path, where if allocation or registration
of MDIO bus fails, then ethernet interface is not unregistered and the
private data are not freed, yet the probe function reports a failure.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Joe Hershberger <joe.hershberger@ni.com>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
4 years agonet: smc911x: Invert the logic in smc911x_miiphy_{read,write}()
Marek Vasut [Sun, 15 Mar 2020 14:43:20 +0000 (15:43 +0100)]
net: smc911x: Invert the logic in smc911x_miiphy_{read,write}()

Invert the logic in the aforementioned functions to reduce indent,
no functional change.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Joe Hershberger <joe.hershberger@ni.com>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
4 years agonet: smc911x: Rename smc911x_rx() to smc911x_recv()
Marek Vasut [Sun, 15 Mar 2020 14:40:15 +0000 (15:40 +0100)]
net: smc911x: Rename smc911x_rx() to smc911x_recv()

Rename the function to keep the naming scheme consistent,
no functional change.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Joe Hershberger <joe.hershberger@ni.com>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
4 years agonet: smc911x: Replace malloc()+memset() with calloc()
Marek Vasut [Sun, 15 Mar 2020 14:14:18 +0000 (15:14 +0100)]
net: smc911x: Replace malloc()+memset() with calloc()

Replace combination of malloc()+memset() with calloc() as the behavior
is exactly the same and the amount of code is reduced.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Joe Hershberger <joe.hershberger@ni.com>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
4 years agonet: smc911x: Remove pkt_data_{push,pull}
Marek Vasut [Sat, 14 Mar 2020 23:08:31 +0000 (00:08 +0100)]
net: smc911x: Remove pkt_data_{push,pull}

These functions are never used and are likely a pre-DM remnant
from times long past, just remove them.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Joe Hershberger <joe.hershberger@ni.com>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
4 years agonet: rtl8139: Fill in SPDX tag
Marek Vasut [Sun, 12 Apr 2020 21:49:25 +0000 (23:49 +0200)]
net: rtl8139: Fill in SPDX tag

The rtl8139 driver is derived from Etherboot driver, which is in
turn derived from Linux 8139too driver added in Linux 2.2.18pre14.
An undocumented change in Linux 2.4.10.2 added a new field to the
driver, MODULE_LICENSE("GPL"); . According to current Linux kernel
licensing rules, Documentation/process/license-rules.rst, quote:

"GPL" Module is licensed under GPL version 2. This
does not express any distinction between
GPL-2.0-only or GPL-2.0-or-later. The exact
license information can only be determined
via the license information in the
corresponding source files.

And since the code does not contain any "future" clause, the tag
is therefore GPL-2.0 only.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Joe Hershberger <joe.hershberger@ni.com>
4 years agonet: rtl8139: Move functions around
Marek Vasut [Sun, 12 Apr 2020 21:12:11 +0000 (23:12 +0200)]
net: rtl8139: Move functions around

Just move functions around in preparation for easy DM conversion,
rename rtl_bcast_addr() to rtl8139_bcast_addr(), no functional change.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Joe Hershberger <joe.hershberger@ni.com>
4 years agonet: rtl8139: Finish cleanup
Marek Vasut [Sun, 12 Apr 2020 21:01:45 +0000 (23:01 +0200)]
net: rtl8139: Finish cleanup

Finish the checkpatch cleanup of the driver, fix the remaining issues
in probe and init function and in global variables, rename the probe
function to rtl8139_init(), no functional change.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Joe Hershberger <joe.hershberger@ni.com>
4 years agonet: rtl8139: Factor out hardware reset
Marek Vasut [Sun, 12 Apr 2020 20:58:27 +0000 (22:58 +0200)]
net: rtl8139: Factor out hardware reset

This hardware reset and reset-wait implementation was twice in the
driver, factor it out into a separate function. This really should
use wait_for_bit() eventually and return -ETIMEDOUT, but thus far,
handling of any of this is missing from the driver. This must be
added later. Thus far, no functional change.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Joe Hershberger <joe.hershberger@ni.com>
4 years agonet: rtl8139: Minor cleanup of rtl_disable()
Marek Vasut [Sun, 12 Apr 2020 20:55:40 +0000 (22:55 +0200)]
net: rtl8139: Minor cleanup of rtl_disable()

Rename the function to rtl8139_stop(), clean up checkpatch errors in
the stop polling function. No functional change.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Joe Hershberger <joe.hershberger@ni.com>
4 years agonet: rtl8139: Minor cleanup of rtl_poll()
Marek Vasut [Sun, 12 Apr 2020 20:43:16 +0000 (22:43 +0200)]
net: rtl8139: Minor cleanup of rtl_poll()

Rename the function to rtl8139_recv(), clean up various checkpatch errors,
line-over-80 conditions, and malformed comments. No functional change.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Joe Hershberger <joe.hershberger@ni.com>
4 years agonet: rtl8139: Minor cleanup of rtl_transmit()
Marek Vasut [Sun, 12 Apr 2020 20:40:45 +0000 (22:40 +0200)]
net: rtl8139: Minor cleanup of rtl_transmit()

Rename the function to rtl8139_send(), clean up the TX polling, the TX
OK condition at the end, overuse of typecasts, and various line-over-80
problems. No functional change.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Joe Hershberger <joe.hershberger@ni.com>
4 years agonet: rtl8139: Minor cleanup of rtl_reset()
Marek Vasut [Sun, 12 Apr 2020 19:41:56 +0000 (21:41 +0200)]
net: rtl8139: Minor cleanup of rtl_reset()

Rename the function to rtl8139_reset(), clean up the reset polling
and various line-over-80 problems. No functional change.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Joe Hershberger <joe.hershberger@ni.com>
4 years agonet: rtl8139: Minor cleanup of set_rx_mode()
Marek Vasut [Sun, 12 Apr 2020 19:35:12 +0000 (21:35 +0200)]
net: rtl8139: Minor cleanup of set_rx_mode()

Rename the function to rtl8139_set_rx_mode(), use unsigned variables
where applicable and inline mc_filter[] values. No functional chanage.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Joe Hershberger <joe.hershberger@ni.com>
4 years agonet: rtl8139: Consistently use rtl8139_rx_config
Marek Vasut [Sun, 12 Apr 2020 19:30:38 +0000 (21:30 +0200)]
net: rtl8139: Consistently use rtl8139_rx_config

This string of macros is exactly the same thing as rtl8139_rx_config,
so just use rtl8139_rx_config. No functional change.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Joe Hershberger <joe.hershberger@ni.com>
4 years agonet: rtl8139: Minor cleanup of read_eeprom()
Marek Vasut [Sun, 12 Apr 2020 19:28:30 +0000 (21:28 +0200)]
net: rtl8139: Minor cleanup of read_eeprom()

Rename the function to rtl8139_read_eeprom() to keep the naming
consistent, keep the variables sorted in reverse xmas tree. No
functional change.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Joe Hershberger <joe.hershberger@ni.com>
4 years agonet: rtl8139: Rework eeprom_delay() macro
Marek Vasut [Sun, 12 Apr 2020 19:20:31 +0000 (21:20 +0200)]
net: rtl8139: Rework eeprom_delay() macro

The macro assumes ee_addr variable to be present when it's being
used. Rework the macro into a function instead and pass it an
argument specifying the register base address, to make it future
proof for DM conversion.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Joe Hershberger <joe.hershberger@ni.com>
4 years agonet: rtl8139: Register macro cleanup
Marek Vasut [Sun, 12 Apr 2020 18:47:26 +0000 (20:47 +0200)]
net: rtl8139: Register macro cleanup

Clean up the horrible register definitions in the RTL8139 driver.
This does create a couple of checkpatch errors, but the driver is
full of them anyway, and those will be cleaned up later.

No functional change.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Joe Hershberger <joe.hershberger@ni.com>
4 years agonet: dwc_eth_qos: Prevent DMA from writing updated RX DMA descriptor
Marek Vasut [Mon, 23 Mar 2020 01:11:46 +0000 (02:11 +0100)]
net: dwc_eth_qos: Prevent DMA from writing updated RX DMA descriptor

The DMA may attempt to write a DMA descriptor in the ring while it is
being updated. By writing the DMA descriptor buffer address to 0, it
is assured the DMA will not use such a buffer and the buffer can be
updated without any interference.

Reviewed-by: Patrick Delaunay <patrick.delaunay@st.com>
Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Joe Hershberger <joe.hershberger@ni.com>
Cc: Patrice Chotard <patrice.chotard@st.com>
Cc: Patrick Delaunay <patrick.delaunay@st.com>
Cc: Ramon Fried <rfried.dev@gmail.com>
Cc: Stephen Warren <swarren@nvidia.com>
4 years agonet: dwc_eth_qos: Invalidate RX packet DMA buffer
Marek Vasut [Mon, 23 Mar 2020 01:09:55 +0000 (02:09 +0100)]
net: dwc_eth_qos: Invalidate RX packet DMA buffer

This patch prevents an issue where the RX packet might have been
accessed by the CPU, which now has cached data from the packet in
the caches and possibly various write buffers, and these data may
be evicted from the caches into the DRAM while the buffer is also
written by the DMA.

By invalidating the buffer after the CPU accessed it and before the
DMA populates the buffer, it is assured that the buffer will not be
corrupted.

Reviewed-by: Patrick Delaunay <patrick.delaunay@st.com>
Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Joe Hershberger <joe.hershberger@ni.com>
Cc: Patrice Chotard <patrice.chotard@st.com>
Cc: Patrick Delaunay <patrick.delaunay@st.com>
Cc: Ramon Fried <rfried.dev@gmail.com>
Cc: Stephen Warren <swarren@nvidia.com>
4 years agonet: dwc_eth_qos: Invalidate RX descriptor before reading
Marek Vasut [Mon, 23 Mar 2020 01:09:21 +0000 (02:09 +0100)]
net: dwc_eth_qos: Invalidate RX descriptor before reading

The current code polls the RX desciptor ring for new packets by reading
the RX descriptor status. This works by accident, as the RX descriptors
are often in non-cacheable memory. However, the driver does support use
of RX descriptors in cacheable memory.

This patch adds a missing RX descriptor invalidation, which assures the
CPU will read a fresh copy of the RX descriptor instead of a cached one.

Reviewed-by: Patrick Delaunay <patrick.delaunay@st.com>
Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Joe Hershberger <joe.hershberger@ni.com>
Cc: Patrice Chotard <patrice.chotard@st.com>
Cc: Patrick Delaunay <patrick.delaunay@st.com>
Cc: Ramon Fried <rfried.dev@gmail.com>
Cc: Stephen Warren <swarren@nvidia.com>
4 years agonet: dwc_eth_qos: Flush the RX descriptors on init
Marek Vasut [Mon, 23 Mar 2020 01:09:01 +0000 (02:09 +0100)]
net: dwc_eth_qos: Flush the RX descriptors on init

Currently the code only flushes the first RX descriptor, not every entry
in the RX descriptor ring. Fix this, to make sure the DMA engine can pick
the RX descriptors correctly.

Reviewed-by: Patrick Delaunay <patrick.delaunay@st.com>
Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Joe Hershberger <joe.hershberger@ni.com>
Cc: Patrice Chotard <patrice.chotard@st.com>
Cc: Patrick Delaunay <patrick.delaunay@st.com>
Cc: Ramon Fried <rfried.dev@gmail.com>
Cc: Stephen Warren <swarren@nvidia.com>
4 years agonet: dwc_eth_qos: Correctly wrap around TX descriptor tail pointer
Marek Vasut [Mon, 23 Mar 2020 01:03:50 +0000 (02:03 +0100)]
net: dwc_eth_qos: Correctly wrap around TX descriptor tail pointer

This code programs the next descriptor in the TX descriptor ring into
the hardware as the last valid TX descriptor. The problem is that if
the currenty descriptor is the last one in the array, the code will
not wrap around correctly and use TX descriptor 0 again, but instead
will use TX descriptor at address right past the TX descriptor ring,
which is the first descriptor in the RX ring.

Fix this by adding the necessary wrap-around.

Reviewed-by: Patrick Delaunay <patrick.delaunay@st.com>
Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Joe Hershberger <joe.hershberger@ni.com>
Cc: Patrice Chotard <patrice.chotard@st.com>
Cc: Patrick Delaunay <patrick.delaunay@st.com>
Cc: Ramon Fried <rfried.dev@gmail.com>
Cc: Stephen Warren <swarren@nvidia.com>
4 years agonet: dwc_eth_qos: Fully rewrite RX descriptor field 3
Marek Vasut [Mon, 23 Mar 2020 01:02:57 +0000 (02:02 +0100)]
net: dwc_eth_qos: Fully rewrite RX descriptor field 3

The RX descriptor field 3 should contain only OWN and BUF1V bits before
being used for receiving data by the DMA engine. However, right now, if
the descriptor was already used for receiving data and is being cleared,
the field 3 is only modified and the aforementioned two bits are ORRed
into the field. This could lead to a residual dirty bits being left in
the field 3 from previous transfer, and it generally does. Fully set the
field 3 instead to clear those residual dirty bits.

Reviewed-by: Patrick Delaunay <patrick.delaunay@st.com>
Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Joe Hershberger <joe.hershberger@ni.com>
Cc: Patrice Chotard <patrice.chotard@st.com>
Cc: Patrick Delaunay <patrick.delaunay@st.com>
Cc: Ramon Fried <rfried.dev@gmail.com>
Cc: Stephen Warren <swarren@nvidia.com>
4 years agonet: dc2114x: Switch DEBUG_SROM{,2} to debug_cond()
Marek Vasut [Sun, 19 Apr 2020 02:05:44 +0000 (04:05 +0200)]
net: dc2114x: Switch DEBUG_SROM{,2} to debug_cond()

Replace the adhoc debugging ifdeffery with debug_cond() and an
internal SROM_DEBUG macro to select the debug level.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Joe Hershberger <joe.hershberger@ni.com>
4 years agonet: dc2114x: Reorganize driver
Marek Vasut [Sun, 19 Apr 2020 02:00:49 +0000 (04:00 +0200)]
net: dc2114x: Reorganize driver

Move the functions in the driver around to better fit future DM
conversion, drop function forward declarations. No functional
change.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Joe Hershberger <joe.hershberger@ni.com>
4 years agonet: dc2114x: Clean up INL/OUTL functions
Marek Vasut [Sun, 19 Apr 2020 01:40:03 +0000 (03:40 +0200)]
net: dc2114x: Clean up INL/OUTL functions

Rename these functions to dc2114x_{inl,outl}(), use u32 values in
them instead of plain signed integers as all those values are in
fact register values and the driver code does bitwise operations
on them. No functional change intended.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Joe Hershberger <joe.hershberger@ni.com>
4 years agonet: dc2114x: Clean up DE4X5 macros
Marek Vasut [Sun, 19 Apr 2020 01:36:46 +0000 (03:36 +0200)]
net: dc2114x: Clean up DE4X5 macros

Replace these macros with static functions to permit the compiler to
do type checking on the functions. The INL()/OUTL() functions have to
be moved in this patch as well, as those DE4X5 macros are using them.
No functional change.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Joe Hershberger <joe.hershberger@ni.com>
4 years agonet: dc2114x: Clean up remaining driver code
Marek Vasut [Sun, 19 Apr 2020 01:09:26 +0000 (03:09 +0200)]
net: dc2114x: Clean up remaining driver code

Clean up the remaining driver code, macro space alignment, function
declaration indent, replace __attribute__((aligned(32))) with plain
__aligned(32). No functional change.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Joe Hershberger <joe.hershberger@ni.com>
4 years agonet: dc2114x: Clean up SROM operations
Marek Vasut [Sun, 19 Apr 2020 01:11:06 +0000 (03:11 +0200)]
net: dc2114x: Clean up SROM operations

Clean up the SROM accessors to bring them up to standards with
U-Boot coding style. Sort variable into reverse xmas tree. No
functional change.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Joe Hershberger <joe.hershberger@ni.com>