[PATCH 0/3] video: seps525: Add new driver for seps525 OLED display

2020-12-03 Thread Michal Simek
Hi,

This driver is connected via spi on one ZynqMP board. Only 8bit SPI
connection is supported now. Spi zynq driver was used for testing this
driver.
We have tested load image via BMP command and also using it as console as
is visible from log in the last patch.

Thanks,
Michal


Michal Simek (2):
  video: Introduce video_sync call
  video: seps525: Add seps525 SPI driver

Vikhyat Goyal (1):
  video: seps525: Add dt binding description

 MAINTAINERS   |   2 +
 .../video/syncoam,seps525.txt |  24 ++
 drivers/video/Kconfig |   6 +
 drivers/video/Makefile|   1 +
 drivers/video/seps525.c   | 327 ++
 drivers/video/video-uclass.c  |   5 +
 include/video.h   |  13 +
 7 files changed, 378 insertions(+)
 create mode 100644 doc/device-tree-bindings/video/syncoam,seps525.txt
 create mode 100644 drivers/video/seps525.c

-- 
2.29.2



[PATCH 1/3] video: Introduce video_sync call

2020-12-03 Thread Michal Simek
Some drivers like LCD connected via SPI requires explicit sync function
which copy framebuffer content over SPI to controller to display.
This hook doesn't exist yet that's why introduce it via video operations.

Signed-off-by: Michal Simek 
---

Simon: Please review this. I didn't find existing way how this can be done
that's why I am introducing this hook. Also maybe name can be named a
little bit differently. That's why waiting for better suggestion.
---
 drivers/video/video-uclass.c |  5 +
 include/video.h  | 13 +
 2 files changed, 18 insertions(+)

diff --git a/drivers/video/video-uclass.c b/drivers/video/video-uclass.c
index 650891e49dd0..ba52a6c7125b 100644
--- a/drivers/video/video-uclass.c
+++ b/drivers/video/video-uclass.c
@@ -174,6 +174,11 @@ void video_set_default_colors(struct udevice *dev, bool 
invert)
 /* Flush video activity to the caches */
 void video_sync(struct udevice *vid, bool force)
 {
+   struct video_ops *ops = video_get_ops(vid);
+
+   if (ops && ops->video_sync)
+   (void)ops->video_sync(vid);
+
/*
 * flush_dcache_range() is declared in common.h but it seems that some
 * architectures do not actually implement it. Is there a way to find
diff --git a/include/video.h b/include/video.h
index 9d09d2409af6..acac3f6b3c8d 100644
--- a/include/video.h
+++ b/include/video.h
@@ -115,7 +115,20 @@ struct video_priv {
 };
 
 /* Placeholder - there are no video operations at present */
+/**
+ * struct video_ops - structure for keeping video operations
+ */
 struct video_ops {
+   /**
+* video_sync - Synchronize FB with device
+*
+* Some device like SPI based LCD displays needs synchronization when
+* data in an FB is available. For these devices implement video_sync
+* hook to call a sync function
+*
+* @vid:Video device udevice structure
+*/
+   int (*video_sync)(struct udevice *vid);
 };
 
 #define video_get_ops(dev)((struct video_ops *)(dev)->driver->ops)
-- 
2.29.2



[PATCH 2/3] video: seps525: Add dt binding description

2020-12-03 Thread Michal Simek
From: Vikhyat Goyal 

Added dt binding for seps525 display driver.

Signed-off-by: Vikhyat Goyal 
Signed-off-by: Michal Simek 
---

 MAINTAINERS   |  1 +
 .../video/syncoam,seps525.txt | 24 +++
 2 files changed, 25 insertions(+)
 create mode 100644 doc/device-tree-bindings/video/syncoam,seps525.txt

diff --git a/MAINTAINERS b/MAINTAINERS
index 874cf2c0e576..2f908843da72 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -547,6 +547,7 @@ S:  Maintained
 T: git https://gitlab.denx.de/u-boot/custodians/u-boot-microblaze.git
 F: arch/arm/mach-zynq/
 F: doc/board/xilinx/
+F: doc/device-tree-bindings/video/syncoam,seps525.txt
 F: drivers/clk/clk_zynq.c
 F: drivers/fpga/zynqpl.c
 F: drivers/gpio/zynq_gpio.c
diff --git a/doc/device-tree-bindings/video/syncoam,seps525.txt 
b/doc/device-tree-bindings/video/syncoam,seps525.txt
new file mode 100644
index ..e1e0db9d71fb
--- /dev/null
+++ b/doc/device-tree-bindings/video/syncoam,seps525.txt
@@ -0,0 +1,24 @@
+spi based seps525 framebuffer display driver
+
+Driver for seps525 display controller (in spi mode), This binding supports 
selection
+of spi chipselect, spi max frequency, gpio to drive dc and reset pin of seps525
+controller and spi transaction bit length.
+
+Required properties:
+- compatible: "syncoam,seps525"
+- reg: Specifies the chip-select the seps525 is connected to on the spi bus
+- reset-gpios: gpio connected to reset pin of seps525 controller.
+- dc-gpios: gpio connected to dc pin of seps525 controller:
+- buswidth: bitlength of each spi transaction
+
+Example:
+   displayspi@0 {
+   compatible = "syncoam,seps525";
+   reg = <0>;
+   spi-max-frequency = <1000>;
+   spi-cpol;
+   spi-cpha;
+   buswidth = <8>;
+   reset-gpios = <&gpio 0x1c GPIO_ACTIVE_LOW>;
+   dc-gpios = <&gpio 0x1b GPIO_ACTIVE_HIGH>;
+   };
-- 
2.29.2



[PATCH 3/3] video: seps525: Add seps525 SPI driver

2020-12-03 Thread Michal Simek
Add support for the WiseChip Semiconductor Inc. (UG-6028GDEBF02) display
using the SEPS525 (Syncoam) LCD Controller. Syncoam Seps525 PM-Oled is RGB
160x128 display. This driver has been tested through zynq-spi driver.

ZynqMP> load mmc 1 10 rainbow.bmp
61562 bytes read in 20 ms (2.9 MiB/s)
ZynqMP> bmp info 10
Image size: 160 x 128
Bits per pixel: 24
Compression   : 0
ZynqMP> bmp display 10
ZynqMP> setenv stdout vidconsole

Signed-off-by: Michal Simek 
---

 MAINTAINERS |   1 +
 drivers/video/Kconfig   |   6 +
 drivers/video/Makefile  |   1 +
 drivers/video/seps525.c | 327 
 4 files changed, 335 insertions(+)
 create mode 100644 drivers/video/seps525.c

diff --git a/MAINTAINERS b/MAINTAINERS
index 2f908843da72..178a43f2b46e 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -589,6 +589,7 @@ F:  drivers/spi/zynq_qspi.c
 F: drivers/spi/zynq_spi.c
 F: drivers/timer/cadence-ttc.c
 F: drivers/usb/host/ehci-zynq.c
+F: drivers/video/seps525.c
 F: drivers/watchdog/cdns_wdt.c
 F: include/zynqmppl.h
 F: include/zynqmp_firmware.h
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index 998271b9b628..b354709890b6 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -979,4 +979,10 @@ config VIDEO_VCXK
  This enables VCXK driver which can be used with VC2K, VC4K
  and VC8K devices on various boards from BuS Elektronik GmbH.
 
+config SEPS525
+   bool "SEPS525"
+   help
+ Enable support for the Syncoam PM-OLED display driver (RGB 160x128).
+ Currently driver is supporting only SPI interface.
+
 endmenu
diff --git a/drivers/video/Makefile b/drivers/video/Makefile
index 67a492a2d60d..6e4e35c58de7 100644
--- a/drivers/video/Makefile
+++ b/drivers/video/Makefile
@@ -70,6 +70,7 @@ obj-$(CONFIG_VIDEO_SIMPLE) += simplefb.o
 obj-$(CONFIG_VIDEO_TEGRA20) += tegra.o
 obj-$(CONFIG_VIDEO_VCXK) += bus_vcxk.o
 obj-$(CONFIG_VIDEO_VESA) += vesa.o
+obj-$(CONFIG_SEPS525) += seps525.o
 
 obj-y += bridge/
 obj-y += sunxi/
diff --git a/drivers/video/seps525.c b/drivers/video/seps525.c
new file mode 100644
index ..b4b99b61fb2f
--- /dev/null
+++ b/drivers/video/seps525.c
@@ -0,0 +1,327 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * FB driver for the WiseChip Semiconductor Inc. (UG-6028GDEBF02) display
+ * using the SEPS525 (Syncoam) LCD Controller
+ *
+ * Copyright (C) 2020 Xilinx Inc.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define WIDTH  160
+#define HEIGHT 128
+
+#define SEPS525_INDEX  0x00
+#define SEPS525_STATUS_RD  0x01
+#define SEPS525_OSC_CTL0x02
+#define SEPS525_IREF   0x80
+#define SEPS525_CLOCK_DIV  0x03
+#define SEPS525_REDUCE_CURRENT 0x04
+#define SEPS525_SOFT_RST   0x05
+#define SEPS525_DISP_ONOFF 0x06
+#define SEPS525_PRECHARGE_TIME_R   0x08
+#define SEPS525_PRECHARGE_TIME_G   0x09
+#define SEPS525_PRECHARGE_TIME_B   0x0A
+#define SEPS525_PRECHARGE_CURRENT_R0x0B
+#define SEPS525_PRECHARGE_CURRENT_G0x0C
+#define SEPS525_PRECHARGE_CURRENT_B0x0D
+#define SEPS525_DRIVING_CURRENT_R  0x10
+#define SEPS525_DRIVING_CURRENT_G  0x11
+#define SEPS525_DRIVING_CURRENT_B  0x12
+#define SEPS525_DISPLAYMODE_SET0x13
+#define SEPS525_RGBIF  0x14
+#define SEPS525_RGB_POL0x15
+#define SEPS525_MEMORY_WRITEMODE   0x16
+#define SEPS525_MX1_ADDR   0x17
+#define SEPS525_MX2_ADDR   0x18
+#define SEPS525_MY1_ADDR   0x19
+#define SEPS525_MY2_ADDR   0x1A
+#define SEPS525_MEMORY_ACCESS_POINTER_X0x20
+#define SEPS525_MEMORY_ACCESS_POINTER_Y0x21
+#define SEPS525_DDRAM_DATA_ACCESS_PORT 0x22
+#define SEPS525_GRAY_SCALE_TABLE_INDEX 0x50
+#define SEPS525_GRAY_SCALE_TABLE_DATA  0x51
+#define SEPS525_DUTY   0x28
+#define SEPS525_DSL0x29
+#define SEPS525_D1_DDRAM_FAC   0x2E
+#define SEPS525_D1_DDRAM_FAR   0x2F
+#define SEPS525_D2_DDRAM_SAC   0x31
+#define SEPS525_D2_DDRAM_SAR   0x32
+#define SEPS525_SCR1_FX1   0x33
+#define SEPS525_SCR1_FX2   0x34
+#define SEPS525_SCR1_FY1   0x35
+#define SEPS525_SCR1_FY2   0x36
+#define SEPS525_SCR2_SX1   0x37
+#define SEPS525_SCR2_SX2   0x38
+#define SEPS525_SCR2_SY1   0x39
+#define SEPS525_SCR2_SY2   0x3A
+#define SEPS525_SCREEN_SAVER_CONTEROL  0x3B
+#define SEPS525_SS_SLEEP_TIMER 0x3C
+#define SEPS525_SCREEN_SAVER_MODE  0x3D
+#define SEPS525_SS_SCR1_FU 0x3E
+#define SEPS525_SS_SCR1_MXY0x3F
+#define SEPS525_SS_SCR2_FU 0x40
+#define SEPS525_SS_SCR2_MXY0x41
+#define SEPS525_MOVING_DIRECTION  

[PATCH 2/6] peach-pit: configs: remove VIDCONSOLE_AS_LCD

2020-12-03 Thread Patrick Delaunay
Remove the obsolete CONFIG_VIDCONSOLE_AS_LCD as vidconsole is used in
./include/configs/peach-pit.h => configs/exynos5-dt-common.h since the
commit bb5930d5c97f ("exynos: video: Convert several boards to driver
model for video")

Signed-off-by: Patrick Delaunay 
---

 configs/peach-pit_defconfig | 1 -
 1 file changed, 1 deletion(-)

diff --git a/configs/peach-pit_defconfig b/configs/peach-pit_defconfig
index c6646dcd6e..4d8da7307d 100644
--- a/configs/peach-pit_defconfig
+++ b/configs/peach-pit_defconfig
@@ -74,7 +74,6 @@ CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_HOST_ETHER=y
 CONFIG_DM_VIDEO=y
 # CONFIG_VIDEO_BPP8 is not set
-CONFIG_VIDCONSOLE_AS_LCD=y
 CONFIG_DISPLAY=y
 CONFIG_VIDEO_BRIDGE=y
 CONFIG_VIDEO_BRIDGE_PARADE_PS862X=y
-- 
2.17.1



[PATCH 1/6] tbs2910: configs: remove VIDCONSOLE_AS_LCD

2020-12-03 Thread Patrick Delaunay
Remove the obsolete CONFIG_VIDCONSOLE_AS_LCD as vidconsole is used in
./include/configs/tbs2910.h since commit 513acd04452f ("tbs2910: migrate
to DM_VIDEO").

Signed-off-by: Patrick Delaunay 
---

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

diff --git a/configs/tbs2910_defconfig b/configs/tbs2910_defconfig
index e43fab208d..b5580abbfd 100644
--- a/configs/tbs2910_defconfig
+++ b/configs/tbs2910_defconfig
@@ -103,7 +103,6 @@ CONFIG_DM_VIDEO=y
 # CONFIG_VIDEO_ANSI is not set
 CONFIG_SYS_WHITE_ON_BLACK=y
 # CONFIG_PANEL is not set
-CONFIG_VIDCONSOLE_AS_LCD=y
 CONFIG_I2C_EDID=y
 CONFIG_VIDEO_IPUV3=y
 CONFIG_VIDEO_BMP_RLE8=y
-- 
2.17.1



[PATCH 3/6] snow: configs: remove VIDCONSOLE_AS_LCD

2020-12-03 Thread Patrick Delaunay
Remove the obsolete CONFIG_VIDCONSOLE_AS_LCD as vidconsole is used in
./include/configs/snow.h => configs/exynos5-dt-common.h since the
commit bb5930d5c97f ("exynos: video: Convert several boards to driver
model for video")

Signed-off-by: Patrick Delaunay 
---

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

diff --git a/configs/snow_defconfig b/configs/snow_defconfig
index 76215034ac..0f31d7f963 100644
--- a/configs/snow_defconfig
+++ b/configs/snow_defconfig
@@ -85,7 +85,6 @@ CONFIG_USB_HOST_ETHER=y
 CONFIG_USB_ETHER_ASIX88179=y
 CONFIG_DM_VIDEO=y
 # CONFIG_VIDEO_BPP8 is not set
-CONFIG_VIDCONSOLE_AS_LCD=y
 CONFIG_DISPLAY=y
 CONFIG_VIDEO_BRIDGE=y
 CONFIG_VIDEO_BRIDGE_PARADE_PS862X=y
-- 
2.17.1



[PATCH 4/6] peach-pi: configs: remove VIDCONSOLE_AS_LCD

2020-12-03 Thread Patrick Delaunay
Remove the obsolete CONFIG_VIDCONSOLE_AS_LCD as vidconsole is used in
./include/configs/peach-pi.h => configs/exynos5-dt-common.h since the
commit bb5930d5c97f ("exynos: video: Convert several boards to driver
model for video")

Signed-off-by: Patrick Delaunay 
---

 configs/peach-pi_defconfig | 1 -
 1 file changed, 1 deletion(-)

diff --git a/configs/peach-pi_defconfig b/configs/peach-pi_defconfig
index 01054b0ee4..0625305bd7 100644
--- a/configs/peach-pi_defconfig
+++ b/configs/peach-pi_defconfig
@@ -75,7 +75,6 @@ CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_HOST_ETHER=y
 CONFIG_DM_VIDEO=y
 # CONFIG_VIDEO_BPP8 is not set
-CONFIG_VIDCONSOLE_AS_LCD=y
 CONFIG_DISPLAY=y
 CONFIG_VIDEO_BRIDGE=y
 CONFIG_VIDEO_BRIDGE_PARADE_PS862X=y
-- 
2.17.1



[PATCH 5/6] spring: configs: remove VIDCONSOLE_AS_LCD

2020-12-03 Thread Patrick Delaunay
Remove the obsolete CONFIG_VIDCONSOLE_AS_LCD as vidconsole is used in
./include/configs/spring.h => configs/exynos5-dt-common.h since the
commit bb5930d5c97f ("exynos: video: Convert several boards to driver
model for video")

Signed-off-by: Patrick Delaunay 
---

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

diff --git a/configs/spring_defconfig b/configs/spring_defconfig
index a1fdf1d1f6..eaf3a9fe1c 100644
--- a/configs/spring_defconfig
+++ b/configs/spring_defconfig
@@ -86,7 +86,6 @@ CONFIG_USB_HOST_ETHER=y
 CONFIG_USB_ETHER_ASIX88179=y
 CONFIG_DM_VIDEO=y
 # CONFIG_VIDEO_BPP8 is not set
-CONFIG_VIDCONSOLE_AS_LCD=y
 CONFIG_DISPLAY=y
 CONFIG_VIDEO_BRIDGE=y
 CONFIG_VIDEO_BRIDGE_PARADE_PS862X=y
-- 
2.17.1



[PATCH 0/6] video: remove VIDCONSOLE_AS_LCD and VIDCONSOLE_AS_NAME

2020-12-03 Thread Patrick Delaunay


I propose this serie to remove the vidconsole work-around, activated with
the 2 options VIDCONSOLE_AS_LCD and VIDCONSOLE_AS_NAME and cleanup
the associated code in console.c (under #ifdef CONFIG_VIDCONSOLE_AS_LCD)

This options are now obsolete and they was planned to be
removed around the end of 2020.

I propose this patchset for v2021.04 even if I don't
test this serie on real boards.

Patrick.



Patrick Delaunay (6):
  tbs2910: configs: remove VIDCONSOLE_AS_LCD
  peach-pit: configs: remove VIDCONSOLE_AS_LCD
  snow: configs: remove VIDCONSOLE_AS_LCD
  peach-pi: configs: remove VIDCONSOLE_AS_LCD
  spring: configs: remove VIDCONSOLE_AS_LCD
  video: remove VIDCONSOLE_AS_LCD and VIDCONSOLE_AS_NAME

 common/console.c| 10 --
 configs/peach-pi_defconfig  |  1 -
 configs/peach-pit_defconfig |  1 -
 configs/snow_defconfig  |  1 -
 configs/spring_defconfig|  1 -
 configs/tbs2910_defconfig   |  1 -
 drivers/video/Kconfig   | 22 --
 7 files changed, 37 deletions(-)

-- 
2.17.1



[PATCH 6/6] video: remove VIDCONSOLE_AS_LCD and VIDCONSOLE_AS_NAME

2020-12-03 Thread Patrick Delaunay
Remove as planned (option will be removed around the end of 2020)
the workaround for boards which have 'lcd' or 'vga' in their stdout
environment variable.

These options are no more used in any defconfig and this patch simplify
the code in console.c file.

Signed-off-by: Patrick Delaunay 
---

 common/console.c  | 10 --
 drivers/video/Kconfig | 22 --
 2 files changed, 32 deletions(-)

diff --git a/common/console.c b/common/console.c
index 3348436da6..dce28723d5 100644
--- a/common/console.c
+++ b/common/console.c
@@ -730,11 +730,6 @@ struct stdio_dev *search_device(int flags, const char 
*name)
struct stdio_dev *dev;
 
dev = stdio_get_by_name(name);
-#ifdef CONFIG_VIDCONSOLE_AS_LCD
-   if (!dev && !strcmp(name, CONFIG_VIDCONSOLE_AS_NAME))
-   dev = stdio_get_by_name("vidconsole");
-#endif
-
if (dev && (dev->flags & flags))
return dev;
 
@@ -914,11 +909,6 @@ done:
 #ifndef CONFIG_SYS_CONSOLE_INFO_QUIET
stdio_print_current_devices();
 #endif /* CONFIG_SYS_CONSOLE_INFO_QUIET */
-#ifdef CONFIG_VIDCONSOLE_AS_LCD
-   if (strstr(stdoutname, CONFIG_VIDCONSOLE_AS_NAME))
-   printf("Warning: Please change '%s' to 'vidconsole' in 
stdout/stderr environment vars\n",
-  CONFIG_VIDCONSOLE_AS_NAME);
-#endif
 
 #ifdef CONFIG_SYS_CONSOLE_ENV_OVERWRITE
/* set the environment variables (will overwrite previous env settings) 
*/
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index 998271b9b6..e4bf04a561 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -207,28 +207,6 @@ config SIMPLE_PANEL
 
 source "drivers/video/fonts/Kconfig"
 
-config VIDCONSOLE_AS_LCD
-   bool "Use 'vidconsole' when CONFIG_VIDCONSOLE_AS_NAME string is seen in 
stdout"
-   depends on DM_VIDEO
-   help
- This is a work-around for boards which have 'lcd' or 'vga' in their
- stdout environment variable, but have moved to use driver model for
- video. In this case the console will no-longer work. While it is
- possible to update the environment, the breakage may be confusing for
- users. This option will be removed around the end of 2020.
-
-config VIDCONSOLE_AS_NAME
-   string "Use 'vidconsole' when string defined here is seen in stdout"
-   depends on VIDCONSOLE_AS_LCD
-   default "lcd" if LCD || TEGRA_COMMON
-   default "vga" if !LCD
-   help
- This is a work-around for boards which have 'lcd' or 'vga' in their
- stdout environment variable, but have moved to use driver model for
- video. In this case the console will no-longer work. While it is
- possible to update the environment, the breakage may be confusing for
- users. This option will be removed around the end of 2020.
-
 config VIDEO_COREBOOT
bool "Enable coreboot framebuffer driver support"
depends on X86 && SYS_COREBOOT
-- 
2.17.1



[PATCH 0/4] console: remove #ifdef CONFIG when it is possible

2020-12-03 Thread Patrick Delaunay


Use 'if (IS_ENABLED(CONFIG...))' instead of '#if or #ifdef' where possible

This patchset can applied on master branch after the serie [1]
(for the new order of test in function putc() and puts()
 done in "console: allow to record console output before ready"
)

I will push a separate serie to remove the remaining
#ifdef CONFIG_VIDCONSOLE_AS_LCD

And I remove the sandox code in [2] (with the associated tests
#ifdef CONFIG_SANDBOX)

[1] http://patchwork.ozlabs.org/project/uboot/list/?series=217079
"log: don't build the trace buffer when log is not ready"

[2] 
http://patchwork.ozlabs.org/project/uboot/patch/20201127114927.2.Ida70f4fb1524187703e9240d63e436f8ae5adaab@changeid/
"[2/2] console: sandbox: remove unnecessary sandbox code"



Patrick Delaunay (4):
  console: remove #ifdef CONFIG when it is possible
  console: add function console_devices_set
  console: remove #ifdef CONFIG_CONSOLE_RECORD
  console: add console_tstc_check helper function for CONSOLE_MUX

 common/console.c | 291 ++-
 1 file changed, 164 insertions(+), 127 deletions(-)

-- 
2.17.1



[PATCH 1/4] console: remove #ifdef CONFIG when it is possible

2020-12-03 Thread Patrick Delaunay
Remove #ifdef or #ifndef for CONFIG when it is possible to simplify
the console.c code and respect the U-Boot coding rules.

Signed-off-by: Patrick Delaunay 
---

 common/console.c | 149 +++
 1 file changed, 61 insertions(+), 88 deletions(-)

diff --git a/common/console.c b/common/console.c
index c3d552bb3e..6fc3957024 100644
--- a/common/console.c
+++ b/common/console.c
@@ -44,14 +44,15 @@ static int on_console(const char *name, const char *value, 
enum env_op op,
case env_op_create:
case env_op_overwrite:
 
-#if CONFIG_IS_ENABLED(CONSOLE_MUX)
-   if (iomux_doenv(console, value))
-   return 1;
-#else
-   /* Try assigning specified device */
-   if (console_assign(console, value) < 0)
-   return 1;
-#endif
+   if (CONFIG_IS_ENABLED(CONSOLE_MUX)) {
+   if (iomux_doenv(console, value))
+   return 1;
+   } else {
+   /* Try assigning specified device */
+   if (console_assign(console, value) < 0)
+   return 1;
+   }
+
return 0;
 
case env_op_delete:
@@ -69,14 +70,13 @@ U_BOOT_ENV_CALLBACK(console, on_console);
 static int on_silent(const char *name, const char *value, enum env_op op,
int flags)
 {
-#if !CONFIG_IS_ENABLED(SILENT_CONSOLE_UPDATE_ON_SET)
-   if (flags & H_INTERACTIVE)
-   return 0;
-#endif
-#if !CONFIG_IS_ENABLED(SILENT_CONSOLE_UPDATE_ON_RELOC)
-   if ((flags & H_INTERACTIVE) == 0)
-   return 0;
-#endif
+   if (!CONFIG_IS_ENABLED(SILENT_CONSOLE_UPDATE_ON_SET))
+   if (flags & H_INTERACTIVE)
+   return 0;
+
+   if (!CONFIG_IS_ENABLED(SILENT_CONSOLE_UPDATE_ON_RELOC))
+   if ((flags & H_INTERACTIVE) == 0)
+   return 0;
 
if (value != NULL)
gd->flags |= GD_FLG_SILENT;
@@ -159,14 +159,13 @@ static bool console_dev_is_serial(struct stdio_dev *sdev)
 {
bool is_serial;
 
-#ifdef CONFIG_DM_SERIAL
-   if (sdev->flags & DEV_FLAGS_DM) {
+   if (IS_ENABLED(CONFIG_DM_SERIAL) && (sdev->flags & DEV_FLAGS_DM)) {
struct udevice *dev = sdev->priv;
 
is_serial = device_get_uclass_id(dev) == UCLASS_SERIAL;
-   } else
-#endif
-   is_serial = !strcmp(sdev->name, "serial");
+   } else {
+   is_serial = !strcmp(sdev->name, "serial");
+   }
 
return is_serial;
 }
@@ -350,13 +349,12 @@ int fgetc(int file)
if (console_tstc(file))
return console_getc(file);
 #endif
-#ifdef CONFIG_WATCHDOG
/*
 * If the watchdog must be rate-limited then it should
 * already be handled in board-specific code.
 */
-udelay(1);
-#endif
+   if (IS_ENABLED(CONFIG_WATCHDOG))
+   udelay(1);
}
}
 
@@ -406,10 +404,8 @@ int fprintf(int file, const char *fmt, ...)
 
 int getchar(void)
 {
-#ifdef CONFIG_DISABLE_CONSOLE
-   if (gd->flags & GD_FLG_DISABLE_CONSOLE)
+   if (IS_ENABLED(CONFIG_DISABLE_CONSOLE) && (gd->flags & 
GD_FLG_DISABLE_CONSOLE))
return 0;
-#endif
 
if (!gd->have_console)
return 0;
@@ -434,10 +430,8 @@ int getchar(void)
 
 int tstc(void)
 {
-#ifdef CONFIG_DISABLE_CONSOLE
-   if (gd->flags & GD_FLG_DISABLE_CONSOLE)
+   if (IS_ENABLED(CONFIG_DISABLE_CONSOLE) && (gd->flags & 
GD_FLG_DISABLE_CONSOLE))
return 0;
-#endif
 
if (!gd->have_console)
return 0;
@@ -485,10 +479,8 @@ static void print_pre_console_buffer(int flushpoint)
char buf_out[CONFIG_PRE_CON_BUF_SZ + 1];
char *buf_in;
 
-#ifdef CONFIG_SILENT_CONSOLE
-   if (gd->flags & GD_FLG_SILENT)
+   if (IS_ENABLED(CONFIG_SILENT_CONSOLE) && (gd->flags & GD_FLG_SILENT))
return;
-#endif
 
buf_in = map_sysmem(CONFIG_PRE_CON_BUF_ADDR, CONFIG_PRE_CON_BUF_SZ);
if (gd->precon_buf_idx > CONFIG_PRE_CON_BUF_SZ)
@@ -530,25 +522,20 @@ void putc(const char c)
return;
}
 #endif
-#ifdef CONFIG_DEBUG_UART
/* if we don't have a console yet, use the debug UART */
-   if (!(gd->flags & GD_FLG_SERIAL_READY)) {
+   if (IS_ENABLED(CONFIG_DEBUG_UART) && !(gd->flags & 
GD_FLG_SERIAL_READY)) {
printch(c);
return;
}
-#endif
-#ifdef CONFIG_SILENT_CONSOLE
-   if (gd->flags & GD_FLG_SILENT) {
+
+   if (IS_ENABLED(CONFIG_SILENT_CONSOLE) && (gd->flags & GD_FLG_SILENT)) {
if (!(gd->flags & GD_FLG_DEVINIT))
pre_console_putc(c);
return;
}
-#endif
 
-#ifdef CONFIG_D

[PATCH 4/4] console: add console_tstc_check helper function for CONSOLE_MUX

2020-12-03 Thread Patrick Delaunay
Add the helper function console_tstc_check() and replace the test
#if CONFIG_IS_ENABLED(CONSOLE_MUX) to a simple if to respect the
U-Boot coding rule.

No functional change.

Signed-off-by: Patrick Delaunay 
---

 common/console.c | 36 
 1 file changed, 24 insertions(+), 12 deletions(-)

diff --git a/common/console.c b/common/console.c
index 0b86bb..c570cd88cf 100644
--- a/common/console.c
+++ b/common/console.c
@@ -248,6 +248,12 @@ static int console_getc(int file)
return ret;
 }
 
+/*  Upper layer may have already called tstc(): check the saved result */
+static bool console_tstc_check(void)
+{
+   return !!tstcdev;
+}
+
 static int console_tstc(int file)
 {
int i, ret;
@@ -340,6 +346,11 @@ static inline int console_getc(int file)
return stdio_devices[file]->getc(stdio_devices[file]);
 }
 
+static bool console_tstc_check(void)
+{
+   return false;
+}
+
 static inline int console_tstc(int file)
 {
return stdio_devices[file]->tstc(stdio_devices[file]);
@@ -397,18 +408,19 @@ int fgetc(int file)
 */
for (;;) {
WATCHDOG_RESET();
-#if CONFIG_IS_ENABLED(CONSOLE_MUX)
-   /*
-* Upper layer may have already called tstc() so
-* check for that first.
-*/
-   if (tstcdev != NULL)
-   return console_getc(file);
-   console_tstc(file);
-#else
-   if (console_tstc(file))
-   return console_getc(file);
-#endif
+   if (CONFIG_IS_ENABLED(CONSOLE_MUX)) {
+   /*
+* Upper layer may have already called tstc() so
+* check for that first.
+*/
+   if (console_tstc_check())
+   return console_getc(file);
+   console_tstc(file);
+   } else {
+   if (console_tstc(file))
+   return console_getc(file);
+   }
+
/*
 * If the watchdog must be rate-limited then it should
 * already be handled in board-specific code.
-- 
2.17.1



[PATCH 3/4] console: remove #ifdef CONFIG_CONSOLE_RECORD

2020-12-03 Thread Patrick Delaunay
Add helper functions to access to gd->console_out and gd->console_in
with membuff API and replace the #ifdef CONFIG_CONSOLE_RECORD test
by if (IS_ENABLED(CONFIG_CONSOLE_RECORD)) to respect the U-Boot
coding rule.

Signed-off-by: Patrick Delaunay 
# Conflicts:
#   common/console.c
---

 common/console.c | 86 +---
 1 file changed, 66 insertions(+), 20 deletions(-)

diff --git a/common/console.c b/common/console.c
index 9a63eaa664..0b86bb 100644
--- a/common/console.c
+++ b/common/console.c
@@ -88,6 +88,56 @@ static int on_silent(const char *name, const char *value, 
enum env_op op,
 U_BOOT_ENV_CALLBACK(silent, on_silent);
 #endif
 
+#ifdef CONFIG_CONSOLE_RECORD
+/* helper function: access to gd->console_out and gd->console_in */
+static void console_record_putc(const char c)
+{
+   if  (gd->console_out.start)
+   membuff_putbyte((struct membuff *)&gd->console_out, c);
+}
+
+static void console_record_puts(const char *s)
+{
+   if  (gd->console_out.start)
+   membuff_put((struct membuff *)&gd->console_out, s, strlen(s));
+}
+
+static int console_record_getc(void)
+{
+   if (!gd->console_in.start)
+   return -1;
+
+   return membuff_getbyte((struct membuff *)&gd->console_in);
+}
+
+static int console_record_tstc(void)
+{
+   if (gd->console_in.start) {
+   if (membuff_peekbyte((struct membuff *)&gd->console_in) != -1)
+   return 1;
+   }
+   return 0;
+}
+#else
+static void console_record_putc(char c)
+{
+}
+
+static void console_record_puts(const char *s)
+{
+}
+
+static int console_record_getc(void)
+{
+   return -1;
+}
+
+static int console_record_tstc(void)
+{
+   return 0;
+}
+#endif
+
 #if CONFIG_IS_ENABLED(SYS_CONSOLE_IS_IN_ENV)
 /*
  * if overwrite_console returns 1, the stdin, stderr and stdout
@@ -420,15 +470,13 @@ int getchar(void)
if (!gd->have_console)
return 0;
 
-#ifdef CONFIG_CONSOLE_RECORD
-   if (gd->console_in.start) {
-   int ch;
+   if (IS_ENABLED(CONFIG_CONSOLE_RECORD)) {
+   int ch = console_record_getc();
 
-   ch = membuff_getbyte((struct membuff *)&gd->console_in);
if (ch != -1)
-   return 1;
+   return ch;
}
-#endif
+
if (gd->flags & GD_FLG_DEVINIT) {
/* Get from the standard input */
return fgetc(stdin);
@@ -445,12 +493,10 @@ int tstc(void)
 
if (!gd->have_console)
return 0;
-#ifdef CONFIG_CONSOLE_RECORD
-   if (gd->console_in.start) {
-   if (membuff_peekbyte((struct membuff *)&gd->console_in) != -1)
-   return 1;
-   }
-#endif
+
+   if (IS_ENABLED(CONFIG_CONSOLE_RECORD) && console_record_tstc())
+   return 1;
+
if (gd->flags & GD_FLG_DEVINIT) {
/* Test the standard input */
return ftstc(stdin);
@@ -521,10 +567,10 @@ void putc(const char c)
 {
if (!gd)
return;
-#ifdef CONFIG_CONSOLE_RECORD
-   if ((gd->flags & GD_FLG_RECORD) && gd->console_out.start)
-   membuff_putbyte((struct membuff *)&gd->console_out, c);
-#endif
+
+   if (IS_ENABLED(CONFIG_CONSOLE_RECORD) && (gd->flags & GD_FLG_RECORD))
+   console_record_putc(c);
+
 #ifdef CONFIG_SANDBOX
/* sandbox can send characters to stdout before it has a console */
if (!(gd->flags & GD_FLG_SERIAL_READY)) {
@@ -564,10 +610,10 @@ void puts(const char *s)
 {
if (!gd)
return;
-#ifdef CONFIG_CONSOLE_RECORD
-   if ((gd->flags & GD_FLG_RECORD) && gd->console_out.start)
-   membuff_put((struct membuff *)&gd->console_out, s, strlen(s));
-#endif
+
+   if (IS_ENABLED(CONFIG_CONSOLE_RECORD) && (gd->flags & GD_FLG_RECORD))
+   console_record_puts(s);
+
 #ifdef CONFIG_SANDBOX
/* sandbox can send characters to stdout before it has a console */
if (!(gd->flags & GD_FLG_SERIAL_READY)) {
-- 
2.17.1



[PATCH 2/4] console: add function console_devices_set

2020-12-03 Thread Patrick Delaunay
Add a new function to access to console_devices only defined if
CONFIG_IS_ENABLED(CONSOLE_MUX).

This path allows to remove #if CONFIG_IS_ENABLED(CONSOLE_MUX)
in console_getc function.

Signed-off-by: Patrick Delaunay 
---

 common/console.c | 20 +---
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/common/console.c b/common/console.c
index 6fc3957024..9a63eaa664 100644
--- a/common/console.c
+++ b/common/console.c
@@ -177,6 +177,11 @@ static struct stdio_dev *tstcdev;
 struct stdio_dev **console_devices[MAX_FILES];
 int cd_count[MAX_FILES];
 
+static void __maybe_unused console_devices_set(int file, struct stdio_dev *dev)
+{
+   console_devices[file][0] = dev;
+}
+
 /*
  * This depends on tstc() always being called before getchar().
  * This is guaranteed to be true because this routine is called
@@ -275,6 +280,11 @@ static inline void console_doenv(int file, struct 
stdio_dev *dev)
 }
 #endif
 #else
+
+static void __maybe_unused console_devices_set(int file, struct stdio_dev *dev)
+{
+}
+
 static inline int console_getc(int file)
 {
return stdio_devices[file]->getc(stdio_devices[file]);
@@ -961,18 +971,14 @@ int console_init_r(void)
if (outputdev != NULL) {
console_setfile(stdout, outputdev);
console_setfile(stderr, outputdev);
-#if CONFIG_IS_ENABLED(CONSOLE_MUX)
-   console_devices[stdout][0] = outputdev;
-   console_devices[stderr][0] = outputdev;
-#endif
+   console_devices_set(stdout, outputdev);
+   console_devices_set(stderr, outputdev);
}
 
/* Initializes input console */
if (inputdev != NULL) {
console_setfile(stdin, inputdev);
-#if CONFIG_IS_ENABLED(CONSOLE_MUX)
-   console_devices[stdin][0] = inputdev;
-#endif
+   console_devices_set(stdin, inputdev);
}
 
if (!IS_ENABLED(CONFIG_SYS_CONSOLE_INFO_QUIET))
-- 
2.17.1



Re: [PATCH v7 2/4] mmc: renesas-sdhi: Add SDHI quirks for R-Car M3-W and RZ/G2M

2020-12-03 Thread Jaehoon Chung
On 11/27/20 11:52 PM, Biju Das wrote:
> Add SDHI quirks for R-Car M3-W and RZ/G2M SoC.
> 
> Signed-off-by: Biju Das 
> Reviewed-by: Lad Prabhakar 

Reviewed-by: Jaehoon chung 

Best Regards,
Jaehoon Chung

> ---
> v7:
>  * Incorporated Jaehoon Chung's review comments.
>  * Fixed the build error on Renesas ARM32 platforms.
> v6:
>  * New patch. quirks using soc_device_match.
> ---
>  drivers/mmc/renesas-sdhi.c | 117 +
>  1 file changed, 117 insertions(+)
> 
> diff --git a/drivers/mmc/renesas-sdhi.c b/drivers/mmc/renesas-sdhi.c
> index d80b3fc28f..7e3ea92cbf 100644
> --- a/drivers/mmc/renesas-sdhi.c
> +++ b/drivers/mmc/renesas-sdhi.c
> @@ -19,6 +19,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include "tmio-common.h"
>  
> @@ -855,6 +856,115 @@ static ulong renesas_sdhi_clk_get_rate(struct 
> tmio_sd_priv *priv)
>   return clk_get_rate(&priv->clk);
>  }
>  
> +#if CONFIG_IS_ENABLED(MMC_UHS_SUPPORT) || \
> +CONFIG_IS_ENABLED(MMC_HS200_SUPPORT) || \
> +CONFIG_IS_ENABLED(MMC_HS400_SUPPORT)
> +
> +#define SDHI_CALIB_TABLE_MAX 32
> +
> +struct renesas_sdhi_quirks {
> + bool hs400_disabled;
> + bool hs400_4taps;
> + u32 hs400_bad_taps;
> + const u8 (*hs400_calib_table)[SDHI_CALIB_TABLE_MAX];
> +};
> +
> +static const struct renesas_sdhi_quirks sdhi_quirks_4tap_nohs400_b17_dtrend 
> = {
> + .hs400_disabled = true,
> + .hs400_4taps = true,
> +};
> +
> +static const struct renesas_sdhi_quirks sdhi_quirks_4tap_nohs400 = {
> + .hs400_disabled = true,
> + .hs400_4taps = true,
> +};
> +
> +static const struct renesas_sdhi_quirks sdhi_quirks_r8a7796_es12 = {
> + .hs400_4taps = true,
> + .hs400_bad_taps = BIT(2) | BIT(3) | BIT(6) | BIT(7),
> + .hs400_calib_table = r8a7796_rev1_calib_table,
> +};
> +
> +static const struct renesas_sdhi_quirks sdhi_quirks_r8a7796_es13 = {
> + .hs400_bad_taps = BIT(1) | BIT(3) | BIT(5) | BIT(7),
> + .hs400_calib_table = r8a7796_rev3_calib_table,
> +};
> +
> +/*
> + * Note for r8a7796 / r8a774a1: we can't distinguish ES1.1 and 1.2 as of now.
> + * So, we want to treat them equally and only have a match for ES1.2 to 
> enforce
> + * this if there ever will be a way to distinguish ES1.2.
> + */
> +static const struct soc_attr sdhi_quirks_match[]  = {
> + { .soc_id = "r8a774a1",
> +   .revision = "ES1.0",
> +   .data = &sdhi_quirks_4tap_nohs400_b17_dtrend
> + },
> + { .soc_id = "r8a774a1",
> +   .revision = "ES1.1",
> +   .data = &sdhi_quirks_4tap_nohs400
> + },
> + { .soc_id = "r8a774a1",
> +   .revision = "ES1.2",
> +   .data = &sdhi_quirks_r8a7796_es12
> + },
> + { .soc_id = "r8a774a1",
> +   .revision = "ES1.3",
> +   .data = &sdhi_quirks_r8a7796_es13
> + },
> + { .soc_id = "r8a7796",
> +   .revision = "ES1.0",
> +   .data = &sdhi_quirks_4tap_nohs400_b17_dtrend
> + },
> + { .soc_id = "r8a7796",
> +   .revision = "ES1.1",
> +   .data = &sdhi_quirks_4tap_nohs400
> + },
> + { .soc_id = "r8a7796",
> +   .revision = "ES1.2",
> +   .data = &sdhi_quirks_r8a7796_es12
> + },
> + { .soc_id = "r8a7796",
> +   .revision = "ES1.3",
> +   .data = &sdhi_quirks_r8a7796_es13
> + },
> + { /* Sentinel. */ },
> +};
> +
> +static void renesas_sdhi_add_quirks(struct tmio_sd_plat *plat,
> + struct tmio_sd_priv *priv,
> + const struct renesas_sdhi_quirks *quirks)
> +{
> + priv->read_poll_flag = TMIO_SD_DMA_INFO1_END_RD2;
> + priv->nrtaps = 8;
> +
> + if (!quirks)
> + return;
> +
> + if (quirks->hs400_disabled) {
> + plat->cfg.host_caps &= ~MMC_MODE_HS400;
> + if (quirks == &sdhi_quirks_4tap_nohs400_b17_dtrend)
> + priv->read_poll_flag = TMIO_SD_DMA_INFO1_END_RD;
> + }
> +
> + if (quirks->hs400_4taps)
> + priv->nrtaps = 4;
> +
> + if (quirks->hs400_bad_taps)
> + priv->hs400_bad_tap = quirks->hs400_bad_taps;
> +
> + if (quirks->hs400_calib_table) {
> + priv->adjust_hs400_enable = true;
> + priv->adjust_hs400_calib_table =
> + quirks->hs400_calib_table[!rmobile_is_gen3_mmc0(priv)];
> + if (quirks == &sdhi_quirks_r8a7796_es12)
> + priv->adjust_hs400_offset = 3;
> + else if (quirks == &sdhi_quirks_r8a7796_es13)
> + priv->adjust_hs400_offset = 0;
> + }
> +}
> +#endif
> +
>  static void renesas_sdhi_filter_caps(struct udevice *dev)
>  {
>   struct tmio_sd_priv *priv = dev_get_priv(dev);
> @@ -866,6 +976,13 @@ static void renesas_sdhi_filter_caps(struct udevice *dev)
>  CONFIG_IS_ENABLED(MMC_HS200_SUPPORT) || \
>  CONFIG_IS_ENABLED(MMC_HS400_SUPPORT)
>   struct tmio_sd_plat *plat = dev_get_platdata(dev);
> + const struct soc_attr *attr;
> +
> + attr = soc_device_

Re: [PATCH v7 3/4] mmc: renesas-sdhi: Add SDHI quirks for R-Car M3-N and RZ/G2N

2020-12-03 Thread Jaehoon Chung
On 11/27/20 11:52 PM, Biju Das wrote:
> Add SDHI quirks for R-Car M3-N and RZ/G2N SoC.
> 
> Signed-off-by: Biju Das 
> Reviewed-by: Lad Prabhakar 

Reviewed-by: Jaehoon chung 

Best Regards,
Jaehoon Chung

> ---
> v7:
>  * No Change.
> v6: 
>  * New patch. quirks using soc_device_match.
> ---
>  drivers/mmc/renesas-sdhi.c | 14 +-
>  1 file changed, 13 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/mmc/renesas-sdhi.c b/drivers/mmc/renesas-sdhi.c
> index 7e3ea92cbf..b84cfaa9a3 100644
> --- a/drivers/mmc/renesas-sdhi.c
> +++ b/drivers/mmc/renesas-sdhi.c
> @@ -890,6 +890,11 @@ static const struct renesas_sdhi_quirks 
> sdhi_quirks_r8a7796_es13 = {
>   .hs400_calib_table = r8a7796_rev3_calib_table,
>  };
>  
> +static const struct renesas_sdhi_quirks sdhi_quirks_r8a77965 = {
> + .hs400_bad_taps = BIT(2) | BIT(3) | BIT(6) | BIT(7),
> + .hs400_calib_table = r8a77965_calib_table,
> +};
> +
>  /*
>   * Note for r8a7796 / r8a774a1: we can't distinguish ES1.1 and 1.2 as of now.
>   * So, we want to treat them equally and only have a match for ES1.2 to 
> enforce
> @@ -912,6 +917,9 @@ static const struct soc_attr sdhi_quirks_match[]  = {
> .revision = "ES1.3",
> .data = &sdhi_quirks_r8a7796_es13
>   },
> + { .soc_id = "r8a774b1",
> +   .data = &sdhi_quirks_r8a77965
> + },
>   { .soc_id = "r8a7796",
> .revision = "ES1.0",
> .data = &sdhi_quirks_4tap_nohs400_b17_dtrend
> @@ -928,6 +936,9 @@ static const struct soc_attr sdhi_quirks_match[]  = {
> .revision = "ES1.3",
> .data = &sdhi_quirks_r8a7796_es13
>   },
> + { .soc_id = "r8a77965",
> +   .data = &sdhi_quirks_r8a77965
> + },
>   { /* Sentinel. */ },
>  };
>  
> @@ -957,7 +968,8 @@ static void renesas_sdhi_add_quirks(struct tmio_sd_plat 
> *plat,
>   priv->adjust_hs400_enable = true;
>   priv->adjust_hs400_calib_table =
>   quirks->hs400_calib_table[!rmobile_is_gen3_mmc0(priv)];
> - if (quirks == &sdhi_quirks_r8a7796_es12)
> + if (quirks == &sdhi_quirks_r8a7796_es12 ||
> + quirks == &sdhi_quirks_r8a77965)
>   priv->adjust_hs400_offset = 3;
>   else if (quirks == &sdhi_quirks_r8a7796_es13)
>   priv->adjust_hs400_offset = 0;
> 



Re: [PATCH v7 4/4] mmc: renesas-sdhi: Add SDHI quirks for R-Car H3 and RZ/G2H

2020-12-03 Thread Jaehoon Chung
On 11/27/20 11:53 PM, Biju Das wrote:
> Add SDHI quirks for R-Car H3 and RZ/G2H SoC.
> 
> Signed-off-by: Biju Das 
> Reviewed-by: Lad Prabhakar 

Reviewed-by: Jaehoon chung 

Best Regards,
Jaehoon Chung

> ---
> v7:
>   * No Change.
> v6:
>   * New patch. quirks using soc_device_match.
> ---
>  drivers/mmc/renesas-sdhi.c | 33 -
>  1 file changed, 32 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/mmc/renesas-sdhi.c b/drivers/mmc/renesas-sdhi.c
> index b84cfaa9a3..09d8a2aa0a 100644
> --- a/drivers/mmc/renesas-sdhi.c
> +++ b/drivers/mmc/renesas-sdhi.c
> @@ -879,6 +879,16 @@ static const struct renesas_sdhi_quirks 
> sdhi_quirks_4tap_nohs400 = {
>   .hs400_4taps = true,
>  };
>  
> +static const struct renesas_sdhi_quirks sdhi_quirks_4tap = {
> + .hs400_4taps = true,
> + .hs400_bad_taps = BIT(2) | BIT(3) | BIT(6) | BIT(7),
> +};
> +
> +static const struct renesas_sdhi_quirks sdhi_quirks_r8a7795_es30 = {
> + .hs400_bad_taps = BIT(2) | BIT(3) | BIT(6) | BIT(7),
> + .hs400_calib_table = r8a7795_calib_table,
> +};
> +
>  static const struct renesas_sdhi_quirks sdhi_quirks_r8a7796_es12 = {
>   .hs400_4taps = true,
>   .hs400_bad_taps = BIT(2) | BIT(3) | BIT(6) | BIT(7),
> @@ -920,6 +930,26 @@ static const struct soc_attr sdhi_quirks_match[]  = {
>   { .soc_id = "r8a774b1",
> .data = &sdhi_quirks_r8a77965
>   },
> + { .soc_id = "r8a774e1",
> +   .revision = "ES3.0",
> +   .data = &sdhi_quirks_r8a7795_es30
> + },
> + { .soc_id = "r8a7795",
> +   .revision = "ES1.0",
> +   .data = &sdhi_quirks_4tap_nohs400_b17_dtrend
> + },
> + { .soc_id = "r8a7795",
> +   .revision = "ES1.1",
> +   .data = &sdhi_quirks_4tap_nohs400_b17_dtrend
> + },
> + { .soc_id = "r8a7795",
> +   .revision = "ES2.0",
> +   .data = &sdhi_quirks_4tap
> + },
> + { .soc_id = "r8a7795",
> +   .revision = "ES3.0",
> +   .data = &sdhi_quirks_r8a7795_es30
> + },
>   { .soc_id = "r8a7796",
> .revision = "ES1.0",
> .data = &sdhi_quirks_4tap_nohs400_b17_dtrend
> @@ -971,7 +1001,8 @@ static void renesas_sdhi_add_quirks(struct tmio_sd_plat 
> *plat,
>   if (quirks == &sdhi_quirks_r8a7796_es12 ||
>   quirks == &sdhi_quirks_r8a77965)
>   priv->adjust_hs400_offset = 3;
> - else if (quirks == &sdhi_quirks_r8a7796_es13)
> + else if (quirks == &sdhi_quirks_r8a7796_es13 ||
> +  quirks == &sdhi_quirks_r8a7795_es30)
>   priv->adjust_hs400_offset = 0;
>   }
>  }
> 



Re: [PATCH 29/34] configs: sama7g5: add mmc config for sdmmc0

2020-12-03 Thread Jaehoon Chung
Hi,

On 12/3/20 6:28 PM, Eugen Hristev wrote:
> Add new config for storing environment from sdmmc0.
> Also clean-up sama7g5ek_emmc1 to point to the proper mmc device.

Just one question, Sorry, i didn't check entire patchset.

What is different between sama7g5ek_mmc1 and sama7g5ek_mmc?

Best Regards,
Jaehoon Chung

> 
> Signed-off-by: Eugen Hristev 
> ---
>  board/atmel/sama7g5ek/MAINTAINERS |  1 +
>  configs/sama7g5ek_mmc1_defconfig  |  7 ++--
>  configs/sama7g5ek_mmc_defconfig   | 67 +++
>  3 files changed, 72 insertions(+), 3 deletions(-)
>  create mode 100644 configs/sama7g5ek_mmc_defconfig
> 
> diff --git a/board/atmel/sama7g5ek/MAINTAINERS 
> b/board/atmel/sama7g5ek/MAINTAINERS
> index f66953ac4e..eac972968d 100644
> --- a/board/atmel/sama7g5ek/MAINTAINERS
> +++ b/board/atmel/sama7g5ek/MAINTAINERS
> @@ -4,4 +4,5 @@ S: Maintained
>  F: board/atmel/sama7g5ek.c
>  F: include/configs/sama7g5ek.h
>  F: configs/sama7g5ek_mmc1_defconfig
> +F: configs/sama7g5ek_mmc_defconfig
>  
> diff --git a/configs/sama7g5ek_mmc1_defconfig 
> b/configs/sama7g5ek_mmc1_defconfig
> index fa4c88ffa6..b6d2f4dd05 100644
> --- a/configs/sama7g5ek_mmc1_defconfig
> +++ b/configs/sama7g5ek_mmc1_defconfig
> @@ -2,9 +2,10 @@ CONFIG_ARM=y
>  CONFIG_ARCH_AT91=y
>  CONFIG_SYS_TEXT_BASE=0x66f0
>  CONFIG_TARGET_SAMA7G5EK=y
> -CONFIG_NR_DRAM_BANKS=1
>  CONFIG_SYS_MALLOC_F_LEN=0x11000
> +CONFIG_NR_DRAM_BANKS=1
>  CONFIG_ENV_SIZE=0x4000
> +CONFIG_DM_GPIO=y
>  CONFIG_DEBUG_UART_BOARD_INIT=y
>  CONFIG_DEBUG_UART_BASE=0xe1824200
>  CONFIG_DEBUG_UART_CLOCK=2
> @@ -14,6 +15,7 @@ CONFIG_ENV_VARS_UBOOT_CONFIG=y
>  CONFIG_FIT=y
>  CONFIG_SD_BOOT=y
>  CONFIG_USE_BOOTARGS=y
> +CONFIG_BOOTARGS="console=ttyS0,115200 root=/dev/mmcblk1p2 rw rootwait"
>  CONFIG_MISC_INIT_R=y
>  CONFIG_HUSH_PARSER=y
>  CONFIG_CMD_BOOTZ=y
> @@ -35,6 +37,7 @@ CONFIG_CMD_EXT4=y
>  CONFIG_CMD_FAT=y
>  CONFIG_OF_CONTROL=y
>  CONFIG_ENV_IS_IN_FAT=y
> +CONFIG_ENV_FAT_DEVICE_AND_PART="1:1"
>  CONFIG_SYS_RELOC_GD_ENV_ADDR=y
>  CONFIG_DM=y
>  CONFIG_CLK=y
> @@ -44,7 +47,6 @@ CONFIG_AT91_UTMI=y
>  CONFIG_AT91_GENERIC_CLK=y
>  CONFIG_AT91_SAM9X60_PLL=y
>  CONFIG_CPU=y
> -CONFIG_DM_GPIO=y
>  CONFIG_ATMEL_PIO4=y
>  CONFIG_DM_I2C=y
>  CONFIG_DM_MMC=y
> @@ -56,7 +58,6 @@ CONFIG_DM_ETH=y
>  CONFIG_MACB=y
>  CONFIG_PINCTRL=y
>  CONFIG_PINCTRL_AT91PIO4=y
> -# CONFIG_RAM_ROCKCHIP_DEBUG is not set
>  CONFIG_DM_SERIAL=y
>  CONFIG_DEBUG_UART_ANNOUNCE=y
>  CONFIG_ATMEL_USART=y
> diff --git a/configs/sama7g5ek_mmc_defconfig b/configs/sama7g5ek_mmc_defconfig
> new file mode 100644
> index 00..894a64983f
> --- /dev/null
> +++ b/configs/sama7g5ek_mmc_defconfig
> @@ -0,0 +1,67 @@
> +CONFIG_ARM=y
> +CONFIG_ARCH_AT91=y
> +CONFIG_SYS_TEXT_BASE=0x66f0
> +CONFIG_TARGET_SAMA7G5EK=y
> +CONFIG_SYS_MALLOC_F_LEN=0x11000
> +CONFIG_NR_DRAM_BANKS=1
> +CONFIG_ENV_SIZE=0x4000
> +CONFIG_DM_GPIO=y
> +CONFIG_DEBUG_UART_BOARD_INIT=y
> +CONFIG_DEBUG_UART_BASE=0xe1824200
> +CONFIG_DEBUG_UART_CLOCK=2
> +CONFIG_DEFAULT_DEVICE_TREE="sama7g5ek"
> +CONFIG_DEBUG_UART=y
> +CONFIG_ENV_VARS_UBOOT_CONFIG=y
> +CONFIG_FIT=y
> +CONFIG_SD_BOOT=y
> +CONFIG_USE_BOOTARGS=y
> +CONFIG_BOOTARGS="console=ttyS0,115200 root=/dev/mmcblk0p2 rw rootwait"
> +CONFIG_MISC_INIT_R=y
> +CONFIG_HUSH_PARSER=y
> +CONFIG_CMD_BOOTZ=y
> +# CONFIG_CMD_IMI is not set
> +CONFIG_CMD_MD5SUM=y
> +CONFIG_CMD_MEMTEST=y
> +CONFIG_SYS_MEMTEST_START=0x6000
> +CONFIG_SYS_MEMTEST_END=0x7000
> +CONFIG_CMD_STRINGS=y
> +CONFIG_CMD_DM=y
> +CONFIG_CMD_GPIO=y
> +CONFIG_CMD_I2C=y
> +# CONFIG_CMD_LOADS is not set
> +CONFIG_CMD_MMC=y
> +CONFIG_CMD_DHCP=y
> +CONFIG_CMD_MII=y
> +CONFIG_CMD_PING=y
> +CONFIG_CMD_EXT4=y
> +CONFIG_CMD_FAT=y
> +CONFIG_OF_CONTROL=y
> +CONFIG_ENV_IS_IN_FAT=y
> +CONFIG_ENV_FAT_DEVICE_AND_PART="0:1"
> +CONFIG_SYS_RELOC_GD_ENV_ADDR=y
> +CONFIG_DM=y
> +CONFIG_CLK=y
> +CONFIG_CLK_CCF=y
> +CONFIG_CLK_AT91=y
> +CONFIG_AT91_UTMI=y
> +CONFIG_AT91_GENERIC_CLK=y
> +CONFIG_AT91_SAM9X60_PLL=y
> +CONFIG_CPU=y
> +CONFIG_ATMEL_PIO4=y
> +CONFIG_DM_I2C=y
> +CONFIG_DM_MMC=y
> +CONFIG_MMC_SDHCI=y
> +CONFIG_MMC_SDHCI_ATMEL=y
> +CONFIG_PHY_MICREL=y
> +CONFIG_PHY_MICREL_KSZ90X1=y
> +CONFIG_DM_ETH=y
> +CONFIG_MACB=y
> +CONFIG_PINCTRL=y
> +CONFIG_PINCTRL_AT91PIO4=y
> +CONFIG_DM_SERIAL=y
> +CONFIG_DEBUG_UART_ANNOUNCE=y
> +CONFIG_ATMEL_USART=y
> +CONFIG_TIMER=y
> +CONFIG_MCHP_PIT64B_TIMER=y
> +CONFIG_OF_LIBFDT_OVERLAY=y
> +# CONFIG_EFI_LOADER_HII is not set
> 



Re: [PATCH 29/34] configs: sama7g5: add mmc config for sdmmc0

2020-12-03 Thread Jaehoon Chung
On 12/3/20 7:47 PM, eugen.hris...@microchip.com wrote:
> On 03.12.2020 12:38, Jaehoon Chung wrote:
>> Hi,
>>
>> On 12/3/20 6:28 PM, Eugen Hristev wrote:
>>> Add new config for storing environment from sdmmc0.
>>> Also clean-up sama7g5ek_emmc1 to point to the proper mmc device.
>>
>> Just one question, Sorry, i didn't check entire patchset.
>>
>> What is different between sama7g5ek_mmc1 and sama7g5ek_mmc?
> 
> Sama7g5ek_mmc is set to store the environment in the eMMC device 
> soldered on the board which is connected on the SDMMC0 hardware block.
> 
> sama7g5ek_mmc1 is set to store the environment on the SD-Card which can 
> be inserted in the SD slot on the board which is connected on the SDMMC1 
> hardware block.
> 
> So basically we have two possible boot/env store configurations, one on 
> eMMC and one on SD-Card .

If device can know which device is used to boot, then i think that it doesn't 
need to add one more config.
It can know where env is stored at runtime.
(with CONFIG_ENV_FAT_DEVICE_AND_PART ":" and implement 
mmc_get_env_dev())


commit 6731bef6966ea2b26cdcfe0109ff5a950003fd03
Refs: v2020.07-1080-g6731bef696
Author: David Woodhouse 
AuthorDate: Fri Jun 19 23:07:17 2020 +0100
Commit: Tom Rini 
CommitDate: Sun Jul 26 14:35:12 2020 -0400

env/fat.c: allow loading from a FAT partition on the MMC boot device

I don't want to have to specify the device; only the partition.

This allows me to use the same image on internal eMMC or SD card for
Banana Pi R2, and it finds its own environment either way.

Signed-off-by: David Woodhouse 
[trini: Add #if/#else/#endif logic around CONFIG_SYS_MMC_ENV_DEV usage,
whitespace changes]
Signed-off-by: Tom Rini 


Best Regards,
Jaehoon Chung

> 
> Eugen
>>
>> Best Regards,
>> Jaehoon Chung
>>
>>>
>>> Signed-off-by: Eugen Hristev 
>>> ---
>>>   board/atmel/sama7g5ek/MAINTAINERS |  1 +
>>>   configs/sama7g5ek_mmc1_defconfig  |  7 ++--
>>>   configs/sama7g5ek_mmc_defconfig   | 67 +++
>>>   3 files changed, 72 insertions(+), 3 deletions(-)
>>>   create mode 100644 configs/sama7g5ek_mmc_defconfig
>>>
>>> diff --git a/board/atmel/sama7g5ek/MAINTAINERS 
>>> b/board/atmel/sama7g5ek/MAINTAINERS
>>> index f66953ac4e..eac972968d 100644
>>> --- a/board/atmel/sama7g5ek/MAINTAINERS
>>> +++ b/board/atmel/sama7g5ek/MAINTAINERS
>>> @@ -4,4 +4,5 @@ S: Maintained
>>>   F: board/atmel/sama7g5ek.c
>>>   F: include/configs/sama7g5ek.h
>>>   F: configs/sama7g5ek_mmc1_defconfig
>>> +F: configs/sama7g5ek_mmc_defconfig
>>>
>>> diff --git a/configs/sama7g5ek_mmc1_defconfig 
>>> b/configs/sama7g5ek_mmc1_defconfig
>>> index fa4c88ffa6..b6d2f4dd05 100644
>>> --- a/configs/sama7g5ek_mmc1_defconfig
>>> +++ b/configs/sama7g5ek_mmc1_defconfig
>>> @@ -2,9 +2,10 @@ CONFIG_ARM=y
>>>   CONFIG_ARCH_AT91=y
>>>   CONFIG_SYS_TEXT_BASE=0x66f0
>>>   CONFIG_TARGET_SAMA7G5EK=y
>>> -CONFIG_NR_DRAM_BANKS=1
>>>   CONFIG_SYS_MALLOC_F_LEN=0x11000
>>> +CONFIG_NR_DRAM_BANKS=1
>>>   CONFIG_ENV_SIZE=0x4000
>>> +CONFIG_DM_GPIO=y
>>>   CONFIG_DEBUG_UART_BOARD_INIT=y
>>>   CONFIG_DEBUG_UART_BASE=0xe1824200
>>>   CONFIG_DEBUG_UART_CLOCK=2
>>> @@ -14,6 +15,7 @@ CONFIG_ENV_VARS_UBOOT_CONFIG=y
>>>   CONFIG_FIT=y
>>>   CONFIG_SD_BOOT=y
>>>   CONFIG_USE_BOOTARGS=y
>>> +CONFIG_BOOTARGS="console=ttyS0,115200 root=/dev/mmcblk1p2 rw rootwait"
>>>   CONFIG_MISC_INIT_R=y
>>>   CONFIG_HUSH_PARSER=y
>>>   CONFIG_CMD_BOOTZ=y
>>> @@ -35,6 +37,7 @@ CONFIG_CMD_EXT4=y
>>>   CONFIG_CMD_FAT=y
>>>   CONFIG_OF_CONTROL=y
>>>   CONFIG_ENV_IS_IN_FAT=y
>>> +CONFIG_ENV_FAT_DEVICE_AND_PART="1:1"
>>>   CONFIG_SYS_RELOC_GD_ENV_ADDR=y
>>>   CONFIG_DM=y
>>>   CONFIG_CLK=y
>>> @@ -44,7 +47,6 @@ CONFIG_AT91_UTMI=y
>>>   CONFIG_AT91_GENERIC_CLK=y
>>>   CONFIG_AT91_SAM9X60_PLL=y
>>>   CONFIG_CPU=y
>>> -CONFIG_DM_GPIO=y
>>>   CONFIG_ATMEL_PIO4=y
>>>   CONFIG_DM_I2C=y
>>>   CONFIG_DM_MMC=y
>>> @@ -56,7 +58,6 @@ CONFIG_DM_ETH=y
>>>   CONFIG_MACB=y
>>>   CONFIG_PINCTRL=y
>>>   CONFIG_PINCTRL_AT91PIO4=y
>>> -# CONFIG_RAM_ROCKCHIP_DEBUG is not set
>>>   CONFIG_DM_SERIAL=y
>>>   CONFIG_DEBUG_UART_ANNOUNCE=y
>>>   CONFIG_ATMEL_USART=y
>>> diff --git a/configs/sama7g5ek_mmc_defconfig 
>>> b/configs/sama7g5ek_mmc_defconfig
>>> new file mode 100644
>>> index 00..894a64983f
>>> --- /dev/null
>>> +++ b/configs/sama7g5ek_mmc_defconfig
>>> @@ -0,0 +1,67 @@
>>> +CONFIG_ARM=y
>>> +CONFIG_ARCH_AT91=y
>>> +CONFIG_SYS_TEXT_BASE=0x66f0
>>> +CONFIG_TARGET_SAMA7G5EK=y
>>> +CONFIG_SYS_MALLOC_F_LEN=0x11000
>>> +CONFIG_NR_DRAM_BANKS=1
>>> +CONFIG_ENV_SIZE=0x4000
>>> +CONFIG_DM_GPIO=y
>>> +CONFIG_DEBUG_UART_BOARD_INIT=y
>>> +CONFIG_DEBUG_UART_BASE=0xe1824200
>>> +CONFIG_DEBUG_UART_CLOCK=2
>>> +CONFIG_DEFAULT_DEVICE_TREE="sama7g5ek"
>>> +CONFIG_DEBUG_UART=y
>>> +CONFIG_ENV_VARS_UBOOT_CONFIG=y
>>> +CONFIG_FIT=y
>>> +CONFIG_SD_BOOT=y
>>> +CONFIG_USE_BOOTARGS=y
>>> +CONFIG_BOOTARGS="console=ttyS0,115200 root=/dev/mmcblk0p2 rw rootwait"
>>> +CONFIG_MISC_INIT_R=y

[PATCH 2/2] net: phy: micrel: fix typo

2020-12-03 Thread Claudiu Beznea
Fix typo.

Signed-off-by: Claudiu Beznea 
---
 drivers/net/phy/micrel_ksz90x1.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/phy/micrel_ksz90x1.c b/drivers/net/phy/micrel_ksz90x1.c
index d6694c5cd88f..77fad4a8fc9e 100644
--- a/drivers/net/phy/micrel_ksz90x1.c
+++ b/drivers/net/phy/micrel_ksz90x1.c
@@ -491,7 +491,7 @@ static int ksz9131_config(struct phy_device *phydev)
 }
 
 static struct phy_driver ksz9131_driver = {
-   .name = "Micrel ksz9031",
+   .name = "Micrel ksz9131",
.uid  = PHY_ID_KSZ9131,
.mask = MII_KSZ9x31_SILICON_REV_MASK,
.features = PHY_GBIT_FEATURES,
-- 
2.7.4



[PATCH 1/2] net: phy: micrel: add support for DLL setup on ksz9131

2020-12-03 Thread Claudiu Beznea
Add support for DLL setup on KSZ9131.

Signed-off-by: Claudiu Beznea 
---
 drivers/net/phy/micrel_ksz90x1.c | 63 +++-
 1 file changed, 62 insertions(+), 1 deletion(-)

diff --git a/drivers/net/phy/micrel_ksz90x1.c b/drivers/net/phy/micrel_ksz90x1.c
index f0032e8ce166..d6694c5cd88f 100644
--- a/drivers/net/phy/micrel_ksz90x1.c
+++ b/drivers/net/phy/micrel_ksz90x1.c
@@ -396,9 +396,70 @@ static struct phy_driver ksz9031_driver = {
 /*
  * KSZ9131
  */
+
+#define KSZ9131RN_MMD_COMMON_CTRL_REG  2
+#define KSZ9131RN_RXC_DLL_CTRL 76
+#define KSZ9131RN_TXC_DLL_CTRL 77
+#define KSZ9131RN_DLL_CTRL_BYPASS  BIT_MASK(12)
+#define KSZ9131RN_DLL_ENABLE_DELAY 0
+#define KSZ9131RN_DLL_DISABLE_DELAYBIT(12)
+
+static int ksz9131_config_rgmii_delay(struct phy_device *phydev)
+{
+   struct phy_driver *drv = phydev->drv;
+   u16 rxcdll_val, txcdll_val, val;
+   int ret;
+
+   switch (phydev->interface) {
+   case PHY_INTERFACE_MODE_RGMII:
+   rxcdll_val = KSZ9131RN_DLL_DISABLE_DELAY;
+   txcdll_val = KSZ9131RN_DLL_DISABLE_DELAY;
+   break;
+   case PHY_INTERFACE_MODE_RGMII_ID:
+   rxcdll_val = KSZ9131RN_DLL_ENABLE_DELAY;
+   txcdll_val = KSZ9131RN_DLL_ENABLE_DELAY;
+   break;
+   case PHY_INTERFACE_MODE_RGMII_RXID:
+   rxcdll_val = KSZ9131RN_DLL_ENABLE_DELAY;
+   txcdll_val = KSZ9131RN_DLL_DISABLE_DELAY;
+   break;
+   case PHY_INTERFACE_MODE_RGMII_TXID:
+   rxcdll_val = KSZ9131RN_DLL_DISABLE_DELAY;
+   txcdll_val = KSZ9131RN_DLL_ENABLE_DELAY;
+   break;
+   default:
+   return 0;
+   }
+
+   val = drv->readext(phydev, 0, KSZ9131RN_MMD_COMMON_CTRL_REG,
+  KSZ9131RN_RXC_DLL_CTRL);
+   val &= ~KSZ9131RN_DLL_CTRL_BYPASS;
+   val |= rxcdll_val;
+   ret = drv->writeext(phydev, 0, KSZ9131RN_MMD_COMMON_CTRL_REG,
+   KSZ9131RN_RXC_DLL_CTRL, val);
+   if (ret)
+   return ret;
+
+   val = drv->readext(phydev, 0, KSZ9131RN_MMD_COMMON_CTRL_REG,
+  KSZ9131RN_TXC_DLL_CTRL);
+
+   val &= ~KSZ9131RN_DLL_CTRL_BYPASS;
+   val |= txcdll_val;
+   ret = drv->writeext(phydev, 0, KSZ9131RN_MMD_COMMON_CTRL_REG,
+   KSZ9131RN_TXC_DLL_CTRL, val);
+
+   return ret;
+}
+
 static int ksz9131_config(struct phy_device *phydev)
 {
-   /* TBD: Implement Skew values for dts */
+   int ret;
+
+   if (phy_interface_is_rgmii(phydev)) {
+   ret = ksz9131_config_rgmii_delay(phydev);
+   if (ret)
+   return ret;
+   }
 
/* add an option to disable the gigabit feature of this PHY */
if (env_get("disable_giga")) {
-- 
2.7.4



[PATCH 0/2] add support for dll setup on ksz9131

2020-12-03 Thread Claudiu Beznea
Hi,

KSZ9131 has an internal DLL used to add proper delay on TX/RX lines
to confirm with RGMII timings. The series add support for this. Along
with this I included a typo patch.

Thank you,
Claudiu Beznea

Claudiu Beznea (2):
  net: phy: micrel: add support for DLL setup on ksz9131
  net: phy: micrel: fix typo

 drivers/net/phy/micrel_ksz90x1.c | 65 ++--
 1 file changed, 63 insertions(+), 2 deletions(-)

-- 
2.7.4



[PATCH 0/6] add support for sama7g5 ethernet interfaces

2020-12-03 Thread Claudiu Beznea
Hi,

This series add support for SAMA7G5 ethernet interfaces: one
gigabit interface and one 10/100Mbps interface.

Thank you,
Claudiu Beznea

Claudiu Beznea (6):
  net: macb: use dummy descriptor for RBQP
  net: macb: add user io config data structure
  net: macb: check clk_set_rate return value to be negative
  net: macb: add support for sama7g5 gmac
  net: macb: add support for sama7g5 emac
  net: macb: take into account all RGMII interface types

 drivers/net/macb.c | 103 +
 drivers/net/macb.h |   2 ++
 2 files changed, 90 insertions(+), 15 deletions(-)

-- 
2.7.4



[PATCH 1/6] net: macb: use dummy descriptor for RBQP

2020-12-03 Thread Claudiu Beznea
In case of multiple queues on RX side the queue scheduler
will try to use all the available configured queues (with
descriptors having TX_USED bit cleared). If at least one RBQP
points to a descriptor with a valid used bit configuration then
the reception may block as this may point to any memory. To avoid
this scenario all the queues (except queue zero) were disabled by
setting DMA descriptors with used bit set on proper RBQP. The driver
anyway uses only queue 0 for TX/RX.

Signed-off-by: Claudiu Beznea 
---
 drivers/net/macb.c | 4 +++-
 drivers/net/macb.h | 2 ++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/net/macb.c b/drivers/net/macb.c
index b80a259ff757..836eb85ec96a 100644
--- a/drivers/net/macb.c
+++ b/drivers/net/macb.c
@@ -732,8 +732,10 @@ static int gmac_init_multi_queues(struct macb_device *macb)
flush_dcache_range(macb->dummy_desc_dma, macb->dummy_desc_dma +
ALIGN(MACB_TX_DUMMY_DMA_DESC_SIZE, PKTALIGN));
 
-   for (i = 1; i < num_queues; i++)
+   for (i = 1; i < num_queues; i++) {
gem_writel_queue_TBQP(macb, macb->dummy_desc_dma, i - 1);
+   gem_writel_queue_RBQP(macb, macb->dummy_desc_dma, i - 1);
+   }
 
return 0;
 }
diff --git a/drivers/net/macb.h b/drivers/net/macb.h
index 9b16383eba46..28c7fe306883 100644
--- a/drivers/net/macb.h
+++ b/drivers/net/macb.h
@@ -768,5 +768,7 @@
 #define GEM_RX_CSUM_CHECKED_MASK   2
 #define gem_writel_queue_TBQP(port, value, queue_num)  \
writel((value), (port)->regs + GEM_TBQP(queue_num))
+#define gem_writel_queue_RBQP(port, value, queue_num)  \
+   writel((value), (port)->regs + GEM_RBQP(queue_num))
 
 #endif /* __DRIVERS_MACB_H__ */
-- 
2.7.4



[PATCH 2/6] net: macb: add user io config data structure

2020-12-03 Thread Claudiu Beznea
Different implementation of USER IO register needs different
mapping for bit fields of this register. Add implementation
for this and, since clken is part of USER IO and it needs to
be activated based on per SoC capabilities, add caps in
macb_config where clken specific information needs to be filled.

Signed-off-by: Claudiu Beznea 
---
 drivers/net/macb.c | 52 
 1 file changed, 40 insertions(+), 12 deletions(-)

diff --git a/drivers/net/macb.c b/drivers/net/macb.c
index 836eb85ec96a..585d126a17f9 100644
--- a/drivers/net/macb.c
+++ b/drivers/net/macb.c
@@ -135,10 +135,19 @@ struct macb_device {
 #endif
 };
 
+struct macb_usrio_cfg {
+   unsigned intmii;
+   unsigned intrmii;
+   unsigned intrgmii;
+   unsigned intclken;
+};
+
 struct macb_config {
unsigned intdma_burst_length;
+   unsigned intcaps;
 
int (*clk_init)(struct udevice *dev, ulong rate);
+   const struct macb_usrio_cfg *usrio;
 };
 
 #ifndef CONFIG_DM_ETH
@@ -818,6 +827,7 @@ static int _macb_init(struct macb_device *macb, const char 
*name)
macb_writel(macb, TBQP, macb->tx_ring_dma);
 
if (macb_is_gem(macb)) {
+   unsigned int val = 0;
/* Initialize DMA properties */
gmac_configure_dma(macb);
/* Check the multi queue and initialize the queue for tx */
@@ -830,11 +840,17 @@ static int _macb_init(struct macb_device *macb, const 
char *name)
 * to select interface between RMII and MII.
 */
 #ifdef CONFIG_DM_ETH
-   if ((macb->phy_interface == PHY_INTERFACE_MODE_RMII) ||
-   (macb->phy_interface == PHY_INTERFACE_MODE_RGMII))
-   gem_writel(macb, USRIO, GEM_BIT(RGMII));
-   else
-   gem_writel(macb, USRIO, 0);
+   if (macb->phy_interface == PHY_INTERFACE_MODE_RGMII)
+   val = macb->config->usrio->rgmii;
+   else if (macb->phy_interface == PHY_INTERFACE_MODE_RMII)
+   val = macb->config->usrio->rmii;
+   else if (macb->phy_interface == PHY_INTERFACE_MODE_MII)
+   val = macb->config->usrio->mii;
+
+   if (macb->config->caps & MACB_CAPS_USRIO_HAS_CLKEN)
+   val |= macb->config->usrio->clken;
+
+   gem_writel(macb, USRIO, val);
 
if (macb->phy_interface == PHY_INTERFACE_MODE_SGMII) {
unsigned int ncfgr = macb_readl(macb, NCFGR);
@@ -844,7 +860,7 @@ static int _macb_init(struct macb_device *macb, const char 
*name)
}
 #else
 #if defined(CONFIG_RGMII) || defined(CONFIG_RMII)
-   gem_writel(macb, USRIO, GEM_BIT(RGMII));
+   gem_writel(macb, USRIO, macb->config->usrio->rgmii);
 #else
gem_writel(macb, USRIO, 0);
 #endif
@@ -855,28 +871,30 @@ static int _macb_init(struct macb_device *macb, const 
char *name)
 #ifdef CONFIG_AT91FAMILY
if (macb->phy_interface == PHY_INTERFACE_MODE_RMII) {
macb_writel(macb, USRIO,
-   MACB_BIT(RMII) | MACB_BIT(CLKEN));
+   macb->config->usrio->rmii |
+   macb->config->usrio->clken);
} else {
-   macb_writel(macb, USRIO, MACB_BIT(CLKEN));
+   macb_writel(macb, USRIO, macb->config->usrio->clken);
}
 #else
if (macb->phy_interface == PHY_INTERFACE_MODE_RMII)
macb_writel(macb, USRIO, 0);
else
-   macb_writel(macb, USRIO, MACB_BIT(MII));
+   macb_writel(macb, USRIO, macb->config->usrio->mii);
 #endif
 #else
 #ifdef CONFIG_RMII
 #ifdef CONFIG_AT91FAMILY
-   macb_writel(macb, USRIO, MACB_BIT(RMII) | MACB_BIT(CLKEN));
+   macb_writel(macb, USRIO, macb->config->usrio->rmii |
+   macb->config->usrio->clken);
 #else
macb_writel(macb, USRIO, 0);
 #endif
 #else
 #ifdef CONFIG_AT91FAMILY
-   macb_writel(macb, USRIO, MACB_BIT(CLKEN));
+   macb_writel(macb, USRIO, macb->config->usrio->clken);
 #else
-   macb_writel(macb, USRIO, MACB_BIT(MII));
+   macb_writel(macb, USRIO, macb->config->usrio->mii);
 #endif
 #endif /* CONFIG_RMII */
 #endif
@@ -1217,9 +1235,17 @@ static int macb_enable_clk(struct udevice *dev)
 }
 #endif
 
+static const struct macb_usrio_cfg macb_default_usrio = {
+   .mii = MACB_BIT(MII),
+   .rmii = MACB_BIT(RMII),
+   .rgmii = GEM_BIT(RGMII),
+   .clken = MACB_BIT(CLKEN),
+};
+
 static const struct macb_config default_gem_config = {
.dma_burst_length = 16,
.clk_init = NULL,
+   .usrio = &macb_default_usrio,
 };
 
 static int macb_eth_probe(struc

[PATCH 5/6] net: macb: add support for sama7g5 emac

2020-12-03 Thread Claudiu Beznea
Add support for SAMA7G5 EMAC.

Signed-off-by: Claudiu Beznea 
---
 drivers/net/macb.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/drivers/net/macb.c b/drivers/net/macb.c
index 8039a53d4f4c..e3003cb4a619 100644
--- a/drivers/net/macb.c
+++ b/drivers/net/macb.c
@@ -1374,12 +1374,20 @@ static const struct macb_config sama7g5_gmac_config = {
.usrio = &sama7g5_usrio,
 };
 
+static const struct macb_config sama7g5_emac_config = {
+   .caps = MACB_CAPS_USRIO_HAS_CLKEN,
+   .dma_burst_length = 16,
+   .usrio = &sama7g5_usrio,
+};
+
 static const struct udevice_id macb_eth_ids[] = {
{ .compatible = "cdns,macb" },
{ .compatible = "cdns,at91sam9260-macb" },
{ .compatible = "cdns,sam9x60-macb" },
{ .compatible = "cdns,sama7g5-gem",
  .data = (ulong)&sama7g5_gmac_config },
+   { .compatible = "cdns,sama7g5-emac",
+ .data = (ulong)&sama7g5_emac_config },
{ .compatible = "atmel,sama5d2-gem" },
{ .compatible = "atmel,sama5d3-gem" },
{ .compatible = "atmel,sama5d4-gem", .data = (ulong)&sama5d4_config },
-- 
2.7.4



[PATCH 4/6] net: macb: add support for sama7g5 gmac

2020-12-03 Thread Claudiu Beznea
Add support for SAMA7G5 GMAC.

Signed-off-by: Claudiu Beznea 
---
 drivers/net/macb.c | 32 
 1 file changed, 32 insertions(+)

diff --git a/drivers/net/macb.c b/drivers/net/macb.c
index 439d1706485c..8039a53d4f4c 100644
--- a/drivers/net/macb.c
+++ b/drivers/net/macb.c
@@ -528,6 +528,23 @@ static int macb_sifive_clk_init(struct udevice *dev, ulong 
rate)
return 0;
 }
 
+static int macb_sama7g5_clk_init(struct udevice *dev, ulong rate)
+{
+   struct clk clk;
+   int ret;
+
+   ret = clk_get_by_name(dev, "tx_clk", &clk);
+   if (ret)
+   return ret;
+
+   /*
+* This is for using GCK. Clock rate is addressed via assigned-clock
+* property, so only clock enable is needed here. The switching to
+* proper clock rate depending on link speed is managed by IP logic.
+*/
+   return clk_enable(&clk);
+}
+
 int __weak macb_linkspd_cb(struct udevice *dev, unsigned int speed)
 {
 #ifdef CONFIG_CLK
@@ -1332,6 +1349,13 @@ static int macb_eth_ofdata_to_platdata(struct udevice 
*dev)
return macb_late_eth_ofdata_to_platdata(dev);
 }
 
+static const struct macb_usrio_cfg sama7g5_usrio = {
+   .mii = 0,
+   .rmii = 1,
+   .rgmii = 2,
+   .clken = BIT(2),
+};
+
 static const struct macb_config sama5d4_config = {
.dma_burst_length = 4,
.clk_init = NULL,
@@ -1344,10 +1368,18 @@ static const struct macb_config sifive_config = {
.usrio = &macb_default_usrio,
 };
 
+static const struct macb_config sama7g5_gmac_config = {
+   .dma_burst_length = 16,
+   .clk_init = macb_sama7g5_clk_init,
+   .usrio = &sama7g5_usrio,
+};
+
 static const struct udevice_id macb_eth_ids[] = {
{ .compatible = "cdns,macb" },
{ .compatible = "cdns,at91sam9260-macb" },
{ .compatible = "cdns,sam9x60-macb" },
+   { .compatible = "cdns,sama7g5-gem",
+ .data = (ulong)&sama7g5_gmac_config },
{ .compatible = "atmel,sama5d2-gem" },
{ .compatible = "atmel,sama5d3-gem" },
{ .compatible = "atmel,sama5d4-gem", .data = (ulong)&sama5d4_config },
-- 
2.7.4



[PATCH 3/6] net: macb: check clk_set_rate return value to be negative

2020-12-03 Thread Claudiu Beznea
clk_set_rate() returns the set rate in case of success and a
negative number in case of failure. Consider failure only the
negative numbers.

Fixes: 3ef6de157 ("dm: net: macb: Implement link speed change callback")
Signed-off-by: Claudiu Beznea 
---
 drivers/net/macb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/macb.c b/drivers/net/macb.c
index 585d126a17f9..439d1706485c 100644
--- a/drivers/net/macb.c
+++ b/drivers/net/macb.c
@@ -564,7 +564,7 @@ int __weak macb_linkspd_cb(struct udevice *dev, unsigned 
int speed)
 
if (tx_clk.dev) {
ret = clk_set_rate(&tx_clk, rate);
-   if (ret)
+   if (ret < 0)
return ret;
}
 #endif
-- 
2.7.4



[PATCH 6/6] net: macb: take into account all RGMII interface types

2020-12-03 Thread Claudiu Beznea
Take into account all RGMII interface types. Depending on it
the RGMII PHY's timings are setup.

Signed-off-by: Claudiu Beznea 
---
 drivers/net/macb.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/net/macb.c b/drivers/net/macb.c
index e3003cb4a619..127d6e899bad 100644
--- a/drivers/net/macb.c
+++ b/drivers/net/macb.c
@@ -630,7 +630,7 @@ static int macb_phy_init(struct macb_device *macb, const 
char *name)
 #else
/* need to consider other phy interface mode */
macb->phydev = phy_connect(macb->bus, macb->phy_addr, &macb->netdev,
-PHY_INTERFACE_MODE_RGMII);
+  macb->phy_interface);
 #endif
if (!macb->phydev) {
printf("phy_connect failed\n");
@@ -857,7 +857,10 @@ static int _macb_init(struct macb_device *macb, const char 
*name)
 * to select interface between RMII and MII.
 */
 #ifdef CONFIG_DM_ETH
-   if (macb->phy_interface == PHY_INTERFACE_MODE_RGMII)
+   if (macb->phy_interface == PHY_INTERFACE_MODE_RGMII ||
+   macb->phy_interface == PHY_INTERFACE_MODE_RGMII_ID ||
+   macb->phy_interface == PHY_INTERFACE_MODE_RGMII_RXID ||
+   macb->phy_interface == PHY_INTERFACE_MODE_RGMII_TXID)
val = macb->config->usrio->rgmii;
else if (macb->phy_interface == PHY_INTERFACE_MODE_RMII)
val = macb->config->usrio->rmii;
-- 
2.7.4



[PATCH 00/34] Sama7g5 Evaluation Kit support

2020-12-03 Thread Eugen Hristev
Hello,

This series adds support for sama7g5 SoC DT and the sama7g5ek board.
I kept the original incremental development for this board, with each
commit's author and designated change, for traceability and for easier
reviewing.

The series starts from a basic devicetree and ends with a fully functional
board including SD-Card/MMC, i2c eeproms, ethernet.

Thanks,
Eugen

Claudiu Beznea (20):
  board: atmel: sama7g5ek: add SYS_MALLOC_F_LEN to SYS_INIT_SP_ADDR
  configs: sama7g5ek: set malloc pool to 68K
  configs: sama7g5ek: enable pll driver
  ARM: dts: sama7g5: move clock frequencies for xtals in board file
  ARM: dts: sama7g5: add slow rc and main rc oscillators
  ARM: dts: sama7g5: add u-boot,dm-pre-reloc bindings for xtals
  ARM: dts: sama7g5: add slow clock bindings
  ARM: dts: sama7g5: add PMC bindings
  ARM: dts: sama7g5: switch to PMC bindings
  configs: sama7g5: enable CONFIG_CPU
  ARM: dts: sama7g5: add CPU bindings
  configs: sama7g5: use PIT64B
  ARM: dts: sama7g5: enable autoboot
  ARM: dts: sama7g5: add pit64b support
  configs: sama7g5ek: enable mii command
  ARM: dts: sama7g5: add GMAC0
  ARM: dts: sama7g5: add GMAC1
  board: atmel: sama7g5ek: increase arp timeout and retry count
  configs: sama7g5ek: enable support for KSZ9131
  configs: sama7g5ek: enable CCF

Eugen Hristev (13):
  ARM: dts: sama7g5: add initial DT for sama7g5 SoC
  board: atmel: sama7g5ek: add initial support for sama7g5ek
  ARM: dts: at91: sama7g5: add pinctrl node
  ARM: dts: at91: sama7g5ek: add pinctrl for sdmmc1 and flx3
  ARM: dts: at91: sama7g5: add assigned clocks for sdmmc1
  ARM: dts: at91: sama7g5: add node for sdmmc0
  ARM: dts: at91: sama7g5ek: enable sdmmc0 with pinctrl
  board: atmel: sama7g5ek: clean-up header bootcommand
  configs: sama7g5: add mmc config for sdmmc0
  ARM: dts: at91: sama7g5: add flexcom1 and i2c subnode
  ARM: dts: sama7g5ek: add i2c1 bus and eeproms
  board: atmel: sama7g5ek: add support for MAC address retreival
  configs: sama7g5ek: add i2c and eeprom

Nicolas Ferre (1):
  ARM: dts: sama7g5ek: fix TXC pin configuration

 arch/arm/dts/Makefile  |   3 +
 arch/arm/dts/sama7g5.dtsi  | 169 
 arch/arm/dts/sama7g5ek-u-boot.dtsi |  65 ++
 arch/arm/dts/sama7g5ek.dts | 202 +
 arch/arm/mach-at91/Kconfig |   8 ++
 board/atmel/sama7g5ek/Kconfig  |  15 +++
 board/atmel/sama7g5ek/MAINTAINERS  |   8 ++
 board/atmel/sama7g5ek/Makefile |   7 +
 board/atmel/sama7g5ek/sama7g5ek.c  |  76 +++
 configs/sama7g5ek_mmc1_defconfig   |  70 ++
 configs/sama7g5ek_mmc_defconfig|  70 ++
 include/configs/sama7g5ek.h|  45 +++
 12 files changed, 738 insertions(+)
 create mode 100644 arch/arm/dts/sama7g5.dtsi
 create mode 100644 arch/arm/dts/sama7g5ek-u-boot.dtsi
 create mode 100644 arch/arm/dts/sama7g5ek.dts
 create mode 100644 board/atmel/sama7g5ek/Kconfig
 create mode 100644 board/atmel/sama7g5ek/MAINTAINERS
 create mode 100644 board/atmel/sama7g5ek/Makefile
 create mode 100644 board/atmel/sama7g5ek/sama7g5ek.c
 create mode 100644 configs/sama7g5ek_mmc1_defconfig
 create mode 100644 configs/sama7g5ek_mmc_defconfig
 create mode 100644 include/configs/sama7g5ek.h

-- 
2.25.1



[PATCH 01/34] ARM: dts: sama7g5: add initial DT for sama7g5 SoC

2020-12-03 Thread Eugen Hristev
Add initial basic devicetree for sama7g5 SoC

Signed-off-by: Eugen Hristev 
---
 arch/arm/dts/sama7g5.dtsi | 65 +++
 1 file changed, 65 insertions(+)
 create mode 100644 arch/arm/dts/sama7g5.dtsi

diff --git a/arch/arm/dts/sama7g5.dtsi b/arch/arm/dts/sama7g5.dtsi
new file mode 100644
index 00..24b6f90957
--- /dev/null
+++ b/arch/arm/dts/sama7g5.dtsi
@@ -0,0 +1,65 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * sama7g5.dtsi - Device Tree Include file for SAMA7G5 SoC.
+ *
+ * Copyright (C) 2020 Microchip Technology Inc. and its subsidiaries
+ *
+ * Author: Eugen Hristev 
+ * Author: Claudiu Beznea 
+ *
+ */
+
+#include "skeleton.dtsi"
+
+/ {
+   model = "Microchip SAMA7G5 family SoC";
+   compatible = "microchip,sama7g5";
+
+   clocks {
+   slow_xtal: slow_xtal {
+   compatible = "fixed-clock";
+   #clock-cells = <0>;
+   clock-frequency = <0>;
+   };
+
+   main_xtal: main_xtal {
+   compatible = "fixed-clock";
+   #clock-cells = <0>;
+   clock-frequency = <0>;
+   };
+
+   mck: mck {
+   compatible = "fixed-clock";
+   #clock-cells = <0>;
+   clock-frequency = <2>;
+   };
+   };
+
+   ahb {
+   compatible = "simple-bus";
+   #address-cells = <1>;
+   #size-cells = <1>;
+
+   apb {
+   compatible = "simple-bus";
+   #address-cells = <1>;
+   #size-cells = <1>;
+
+   sdmmc1: sdio-host@e1208000 {
+   compatible = "microchip,sama7g5-sdhci";
+   reg = <0xe1208000 0x300>;
+   clocks = <&mck>, <&mck>, <&mck>;
+   clock-names = "hclock", "multclk", "baseclk";
+   status = "disabled";
+   };
+
+   uart0: serial@e1824200 {
+   compatible = "atmel,at91sam9260-usart";
+   reg = <0xe1824200 0x200>;
+   clocks = <&mck>;
+   clock-names = "usart";
+   status = "disabled";
+   };
+   };
+   };
+};
-- 
2.25.1



[PATCH 02/34] board: atmel: sama7g5ek: add initial support for sama7g5ek

2020-12-03 Thread Eugen Hristev
Add initial support for sama7g5 evaluation kit board.

Signed-off-by: Eugen Hristev 
---
 arch/arm/dts/Makefile  |  3 ++
 arch/arm/dts/sama7g5ek-u-boot.dtsi | 33 +++
 arch/arm/dts/sama7g5ek.dts | 39 +
 arch/arm/mach-at91/Kconfig |  8 
 board/atmel/sama7g5ek/Kconfig  | 15 +++
 board/atmel/sama7g5ek/MAINTAINERS  |  7 +++
 board/atmel/sama7g5ek/Makefile |  7 +++
 board/atmel/sama7g5ek/sama7g5ek.c  | 68 ++
 configs/sama7g5ek_mmc1_defconfig   | 59 ++
 include/configs/sama7g5ek.h| 46 
 10 files changed, 285 insertions(+)
 create mode 100644 arch/arm/dts/sama7g5ek-u-boot.dtsi
 create mode 100644 arch/arm/dts/sama7g5ek.dts
 create mode 100644 board/atmel/sama7g5ek/Kconfig
 create mode 100644 board/atmel/sama7g5ek/MAINTAINERS
 create mode 100644 board/atmel/sama7g5ek/Makefile
 create mode 100644 board/atmel/sama7g5ek/sama7g5ek.c
 create mode 100644 configs/sama7g5ek_mmc1_defconfig
 create mode 100644 include/configs/sama7g5ek.h

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 5308713df7..fa5590561a 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -886,6 +886,9 @@ dtb-$(CONFIG_TARGET_OMAP4_SDP4430) += \
 dtb-$(CONFIG_TARGET_OMAP5_UEVM) += \
omap5-uevm.dtb
 
+dtb-$(CONFIG_TARGET_SAMA7G5EK) += \
+   sama7g5ek.dtb
+
 dtb-$(CONFIG_TARGET_SAMA5D2_PTC_EK) += \
at91-sama5d2_ptc_ek.dtb
 
diff --git a/arch/arm/dts/sama7g5ek-u-boot.dtsi 
b/arch/arm/dts/sama7g5ek-u-boot.dtsi
new file mode 100644
index 00..c0f8f94027
--- /dev/null
+++ b/arch/arm/dts/sama7g5ek-u-boot.dtsi
@@ -0,0 +1,33 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * sama7g5ek-u-boot.dts - Device Tree file for SAMA7G5 SoC u-boot properties.
+ *
+ * Copyright (C) 2020 Microchip Technology Inc. and its subsidiaries
+ *
+ * Author: Eugen Hristev 
+ * Author: Claudiu Beznea 
+ *
+ */
+
+/ {
+   chosen {
+   u-boot,dm-pre-reloc;
+   };
+
+   ahb {
+   u-boot,dm-pre-reloc;
+
+   apb {
+   u-boot,dm-pre-reloc;
+   };
+   };
+};
+
+&uart0 {
+   u-boot,dm-pre-reloc;
+};
+
+&mck {
+   u-boot,dm-pre-reloc;
+};
+
diff --git a/arch/arm/dts/sama7g5ek.dts b/arch/arm/dts/sama7g5ek.dts
new file mode 100644
index 00..41a754df6f
--- /dev/null
+++ b/arch/arm/dts/sama7g5ek.dts
@@ -0,0 +1,39 @@
+// SPDX-License-Identifier: GPL-2.0+ OR MIT
+/*
+ * sama7g5ek.dts - Device Tree file for SAMA7G5 EK
+ *SAMA7G5 Evaluation Kit
+ *
+ *  Copyright (c) 2020, Microchip Technology Inc.
+ *2020, Eugen Hristev 
+ *   2020, Claudiu Beznea 
+ */
+/dts-v1/;
+#include "sama7g5.dtsi"
+#include "sama7g5-pinfunc.h"
+
+/ {
+   model = "Microchip SAMA7G5 Evaluation Kit";
+   compatible = "microchip,sama7g5ek", "microchip,sama7g54", 
"microchip,sama7g5", "microchip,sama7";
+
+   aliases {
+   serial0 = &uart0;
+   };
+
+   chosen {
+   stdout-path = "serial0:115200n8";
+   };
+
+   ahb {
+
+   apb {
+   sdmmc1: sdio-host@e1208000 {
+   bus-width = <4>;
+   status = "okay";
+   };
+
+   uart0: serial@e1824200 {
+   status = "okay";
+   };
+   };
+   };
+};
diff --git a/arch/arm/mach-at91/Kconfig b/arch/arm/mach-at91/Kconfig
index be1415f909..c78a308f48 100644
--- a/arch/arm/mach-at91/Kconfig
+++ b/arch/arm/mach-at91/Kconfig
@@ -265,6 +265,13 @@ config TARGET_CORVUS
select SUPPORT_SPL
imply CMD_DM
 
+config TARGET_SAMA7G5EK
+   bool "SAMA7G5 EK board"
+   select SAMA7G5
+   select BOARD_EARLY_INIT_F
+   select BOARD_LATE_INIT
+
+
 config TARGET_TAURUS
bool "Support taurus"
select AT91SAM9G20
@@ -327,6 +334,7 @@ source "board/atmel/at91sam9n12ek/Kconfig"
 source "board/atmel/at91sam9rlek/Kconfig"
 source "board/atmel/at91sam9x5ek/Kconfig"
 source "board/atmel/sam9x60ek/Kconfig"
+source "board/atmel/sama7g5ek/Kconfig"
 source "board/atmel/sama5d2_ptc_ek/Kconfig"
 source "board/atmel/sama5d2_xplained/Kconfig"
 source "board/atmel/sama5d27_som1_ek/Kconfig"
diff --git a/board/atmel/sama7g5ek/Kconfig b/board/atmel/sama7g5ek/Kconfig
new file mode 100644
index 00..a89db8d8a8
--- /dev/null
+++ b/board/atmel/sama7g5ek/Kconfig
@@ -0,0 +1,15 @@
+if TARGET_SAMA7G5EK
+
+config SYS_BOARD
+   default "sama7g5ek"
+
+config SYS_VENDOR
+   default "atmel"
+
+config SYS_SOC
+   default "at91"
+
+config SYS_CONFIG_NAME
+   default "sama7g5ek"
+
+endif
diff --git a/board/atmel/sama7g5ek/MAINTAINERS 
b/board/atmel/sama7g5ek/MAINTAINERS
new file mode 100644
index 00..f66953ac4e
--- /dev/null
+++ b/board/atmel/sama7g5ek/MAINTAINERS
@@ -0,0 +1,7 @@
+SAMA7G5 

[PATCH 03/34] board: atmel: sama7g5ek: add SYS_MALLOC_F_LEN to SYS_INIT_SP_ADDR

2020-12-03 Thread Eugen Hristev
From: Claudiu Beznea 

Heap base address is computed based on SYS_INIT_SP_ADDR by
subtracting the SYS_MALLOC_F_LEN value in
board_init_f_init_reserve().

Signed-off-by: Claudiu Beznea 
---
 include/configs/sama7g5ek.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/configs/sama7g5ek.h b/include/configs/sama7g5ek.h
index 3b3432ba5e..fbf0274b38 100644
--- a/include/configs/sama7g5ek.h
+++ b/include/configs/sama7g5ek.h
@@ -20,7 +20,8 @@
 #define CONFIG_SYS_INIT_SP_ADDR0x218000
 #else
 #define CONFIG_SYS_INIT_SP_ADDR \
-   (CONFIG_SYS_SDRAM_BASE + 16 * 1024 - GENERATED_GBL_DATA_SIZE)
+   (CONFIG_SYS_SDRAM_BASE + 16 * 1024 + CONFIG_SYS_MALLOC_F_LEN - \
+GENERATED_GBL_DATA_SIZE)
 #endif
 
 #define CONFIG_SYS_LOAD_ADDR   0x6200 /* load address */
-- 
2.25.1



[PATCH 04/34] configs: sama7g5ek: set malloc pool to 68K

2020-12-03 Thread Eugen Hristev
From: Claudiu Beznea 

Set malloc pool to 68K for sama7g5ek.

Signed-off-by: Claudiu Beznea 
---
 configs/sama7g5ek_mmc1_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configs/sama7g5ek_mmc1_defconfig b/configs/sama7g5ek_mmc1_defconfig
index d54af0ccbf..2da766d4e2 100644
--- a/configs/sama7g5ek_mmc1_defconfig
+++ b/configs/sama7g5ek_mmc1_defconfig
@@ -3,6 +3,7 @@ CONFIG_ARCH_AT91=y
 CONFIG_SYS_TEXT_BASE=0x66f0
 CONFIG_TARGET_SAMA7G5EK=y
 CONFIG_NR_DRAM_BANKS=1
+CONFIG_SYS_MALLOC_F_LEN=0x11000
 CONFIG_ENV_SIZE=0x4000
 CONFIG_DM_GPIO=y
 CONFIG_DEBUG_UART_BOARD_INIT=y
-- 
2.25.1



[PATCH 09/34] ARM: dts: sama7g5: add slow clock bindings

2020-12-03 Thread Eugen Hristev
From: Claudiu Beznea 

Add DT bindings for slow clock driver.

Signed-off-by: Claudiu Beznea 
---
 arch/arm/dts/sama7g5.dtsi | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/arch/arm/dts/sama7g5.dtsi b/arch/arm/dts/sama7g5.dtsi
index c2410959ed..9d390db5ff 100644
--- a/arch/arm/dts/sama7g5.dtsi
+++ b/arch/arm/dts/sama7g5.dtsi
@@ -55,6 +55,13 @@
#address-cells = <1>;
#size-cells = <1>;
 
+   clk32: sckc@e001d050 {
+   compatible = "microchip,sam9x60-sckc";
+   reg = <0xe001d050 0x4>;
+   clocks = <&slow_rc_osc>, <&slow_xtal>;
+   #clock-cells = <1>;
+   };
+
sdmmc1: sdio-host@e1208000 {
compatible = "microchip,sama7g5-sdhci";
reg = <0xe1208000 0x300>;
-- 
2.25.1



[PATCH 06/34] ARM: dts: sama7g5: move clock frequencies for xtals in board file

2020-12-03 Thread Eugen Hristev
From: Claudiu Beznea 

Move clock frequencies for crystals on board specific files.

Signed-off-by: Claudiu Beznea 
---
 arch/arm/dts/sama7g5.dtsi  |  2 --
 arch/arm/dts/sama7g5ek.dts | 10 ++
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/arch/arm/dts/sama7g5.dtsi b/arch/arm/dts/sama7g5.dtsi
index 24b6f90957..618f3a37d5 100644
--- a/arch/arm/dts/sama7g5.dtsi
+++ b/arch/arm/dts/sama7g5.dtsi
@@ -19,13 +19,11 @@
slow_xtal: slow_xtal {
compatible = "fixed-clock";
#clock-cells = <0>;
-   clock-frequency = <0>;
};
 
main_xtal: main_xtal {
compatible = "fixed-clock";
#clock-cells = <0>;
-   clock-frequency = <0>;
};
 
mck: mck {
diff --git a/arch/arm/dts/sama7g5ek.dts b/arch/arm/dts/sama7g5ek.dts
index 41a754df6f..03c7aa07ea 100644
--- a/arch/arm/dts/sama7g5ek.dts
+++ b/arch/arm/dts/sama7g5ek.dts
@@ -23,6 +23,16 @@
stdout-path = "serial0:115200n8";
};
 
+   clocks {
+   slow_xtal: slow_xtal {
+   clock-frequency = <32768>;
+   };
+
+   main_xtal: main_xtal {
+   clock-frequency = <2400>;
+   };
+   };
+
ahb {
 
apb {
-- 
2.25.1



[PATCH 05/34] configs: sama7g5ek: enable pll driver

2020-12-03 Thread Eugen Hristev
From: Claudiu Beznea 

Enable PLL driver for SAMA7G5.

Signed-off-by: Claudiu Beznea 
---
 configs/sama7g5ek_mmc1_defconfig | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/configs/sama7g5ek_mmc1_defconfig b/configs/sama7g5ek_mmc1_defconfig
index 2da766d4e2..d43d07da78 100644
--- a/configs/sama7g5ek_mmc1_defconfig
+++ b/configs/sama7g5ek_mmc1_defconfig
@@ -5,7 +5,6 @@ CONFIG_TARGET_SAMA7G5EK=y
 CONFIG_NR_DRAM_BANKS=1
 CONFIG_SYS_MALLOC_F_LEN=0x11000
 CONFIG_ENV_SIZE=0x4000
-CONFIG_DM_GPIO=y
 CONFIG_DEBUG_UART_BOARD_INIT=y
 CONFIG_DEBUG_UART_BASE=0xe1824200
 CONFIG_DEBUG_UART_CLOCK=2
@@ -42,6 +41,8 @@ CONFIG_CLK=y
 CONFIG_CLK_AT91=y
 CONFIG_AT91_UTMI=y
 CONFIG_AT91_GENERIC_CLK=y
+CONFIG_AT91_SAM9X60_PLL=y
+CONFIG_DM_GPIO=y
 CONFIG_ATMEL_PIO4=y
 CONFIG_DM_I2C=y
 CONFIG_DM_MMC=y
-- 
2.25.1



[PATCH 07/34] ARM: dts: sama7g5: add slow rc and main rc oscillators

2020-12-03 Thread Eugen Hristev
From: Claudiu Beznea 

Add slow rc and main rc oscillators to dtsi.

Signed-off-by: Claudiu Beznea 
---
 arch/arm/dts/sama7g5.dtsi  | 12 
 arch/arm/dts/sama7g5ek-u-boot.dtsi |  8 
 2 files changed, 20 insertions(+)

diff --git a/arch/arm/dts/sama7g5.dtsi b/arch/arm/dts/sama7g5.dtsi
index 618f3a37d5..c2410959ed 100644
--- a/arch/arm/dts/sama7g5.dtsi
+++ b/arch/arm/dts/sama7g5.dtsi
@@ -16,6 +16,18 @@
compatible = "microchip,sama7g5";
 
clocks {
+   slow_rc_osc: slow_rc_osc {
+   compatible = "fixed-clock";
+   #clock-cells = <0>;
+   clock-frequency = <18500>;
+   };
+
+   main_rc: main_rc {
+   compatible = "fixed-clock";
+   #clock-cells = <0>;
+   clock-frequency = <1200>;
+   };
+
slow_xtal: slow_xtal {
compatible = "fixed-clock";
#clock-cells = <0>;
diff --git a/arch/arm/dts/sama7g5ek-u-boot.dtsi 
b/arch/arm/dts/sama7g5ek-u-boot.dtsi
index c0f8f94027..06af2f74ee 100644
--- a/arch/arm/dts/sama7g5ek-u-boot.dtsi
+++ b/arch/arm/dts/sama7g5ek-u-boot.dtsi
@@ -23,6 +23,14 @@
};
 };
 
+&main_rc {
+   u-boot,dm-pre-reloc;
+};
+
+&slow_rc_osc {
+   u-boot,dm-pre-reloc;
+};
+
 &uart0 {
u-boot,dm-pre-reloc;
 };
-- 
2.25.1



[PATCH 08/34] ARM: dts: sama7g5: add u-boot, dm-pre-reloc bindings for xtals

2020-12-03 Thread Eugen Hristev
From: Claudiu Beznea 

Add dm-pre-reloc DT binding property for cristals.

Signed-off-by: Claudiu Beznea 
---
 arch/arm/dts/sama7g5ek-u-boot.dtsi | 8 
 1 file changed, 8 insertions(+)

diff --git a/arch/arm/dts/sama7g5ek-u-boot.dtsi 
b/arch/arm/dts/sama7g5ek-u-boot.dtsi
index 06af2f74ee..d10448e031 100644
--- a/arch/arm/dts/sama7g5ek-u-boot.dtsi
+++ b/arch/arm/dts/sama7g5ek-u-boot.dtsi
@@ -27,10 +27,18 @@
u-boot,dm-pre-reloc;
 };
 
+&main_xtal {
+   u-boot,dm-pre-reloc;
+};
+
 &slow_rc_osc {
u-boot,dm-pre-reloc;
 };
 
+&slow_xtal {
+   u-boot,dm-pre-reloc;
+};
+
 &uart0 {
u-boot,dm-pre-reloc;
 };
-- 
2.25.1



[PATCH 10/34] ARM: dts: sama7g5: add PMC bindings

2020-12-03 Thread Eugen Hristev
From: Claudiu Beznea 

Add DT bindings for PMC driver.

Signed-off-by: Claudiu Beznea 
---
 arch/arm/dts/sama7g5.dtsi  | 9 +
 arch/arm/dts/sama7g5ek-u-boot.dtsi | 4 
 2 files changed, 13 insertions(+)

diff --git a/arch/arm/dts/sama7g5.dtsi b/arch/arm/dts/sama7g5.dtsi
index 9d390db5ff..28faa412dd 100644
--- a/arch/arm/dts/sama7g5.dtsi
+++ b/arch/arm/dts/sama7g5.dtsi
@@ -55,6 +55,15 @@
#address-cells = <1>;
#size-cells = <1>;
 
+   pmc: pmc@e0018000 {
+   compatible = "microchip,sama7g5-pmc";
+   reg = <0xe0018000 0x200>;
+   #clock-cells = <2>;
+   clocks = <&clk32 1>, <&clk32 0>, <&main_xtal>, 
<&main_rc>;
+   clock-names = "td_slck", "md_slck", 
"main_xtal", "main_rc";
+   status = "okay";
+   };
+
clk32: sckc@e001d050 {
compatible = "microchip,sam9x60-sckc";
reg = <0xe001d050 0x4>;
diff --git a/arch/arm/dts/sama7g5ek-u-boot.dtsi 
b/arch/arm/dts/sama7g5ek-u-boot.dtsi
index d10448e031..428b98c303 100644
--- a/arch/arm/dts/sama7g5ek-u-boot.dtsi
+++ b/arch/arm/dts/sama7g5ek-u-boot.dtsi
@@ -31,6 +31,10 @@
u-boot,dm-pre-reloc;
 };
 
+&pmc {
+   u-boot,dm-pre-reloc;
+};
+
 &slow_rc_osc {
u-boot,dm-pre-reloc;
 };
-- 
2.25.1



[PATCH 11/34] ARM: dts: sama7g5: switch to PMC bindings

2020-12-03 Thread Eugen Hristev
From: Claudiu Beznea 

Get rid of software defined MCK and switch to PMC bindings
for IPs currently present in device tree.

Signed-off-by: Claudiu Beznea 
---
 arch/arm/dts/sama7g5.dtsi  | 13 -
 arch/arm/dts/sama7g5ek-u-boot.dtsi |  4 
 2 files changed, 4 insertions(+), 13 deletions(-)

diff --git a/arch/arm/dts/sama7g5.dtsi b/arch/arm/dts/sama7g5.dtsi
index 28faa412dd..94e0b535cc 100644
--- a/arch/arm/dts/sama7g5.dtsi
+++ b/arch/arm/dts/sama7g5.dtsi
@@ -10,6 +10,7 @@
  */
 
 #include "skeleton.dtsi"
+#include 
 
 / {
model = "Microchip SAMA7G5 family SoC";
@@ -37,12 +38,6 @@
compatible = "fixed-clock";
#clock-cells = <0>;
};
-
-   mck: mck {
-   compatible = "fixed-clock";
-   #clock-cells = <0>;
-   clock-frequency = <2>;
-   };
};
 
ahb {
@@ -74,15 +69,15 @@
sdmmc1: sdio-host@e1208000 {
compatible = "microchip,sama7g5-sdhci";
reg = <0xe1208000 0x300>;
-   clocks = <&mck>, <&mck>, <&mck>;
-   clock-names = "hclock", "multclk", "baseclk";
+   clocks = <&pmc PMC_TYPE_PERIPHERAL 81>, <&pmc 
PMC_TYPE_GCK 81>;
+   clock-names = "hclock", "multclk";
status = "disabled";
};
 
uart0: serial@e1824200 {
compatible = "atmel,at91sam9260-usart";
reg = <0xe1824200 0x200>;
-   clocks = <&mck>;
+   clocks = <&pmc PMC_TYPE_PERIPHERAL 41>;
clock-names = "usart";
status = "disabled";
};
diff --git a/arch/arm/dts/sama7g5ek-u-boot.dtsi 
b/arch/arm/dts/sama7g5ek-u-boot.dtsi
index 428b98c303..95d9c3bff2 100644
--- a/arch/arm/dts/sama7g5ek-u-boot.dtsi
+++ b/arch/arm/dts/sama7g5ek-u-boot.dtsi
@@ -47,7 +47,3 @@
u-boot,dm-pre-reloc;
 };
 
-&mck {
-   u-boot,dm-pre-reloc;
-};
-
-- 
2.25.1



[PATCH 12/34] configs: sama7g5: enable CONFIG_CPU

2020-12-03 Thread Eugen Hristev
From: Claudiu Beznea 

Enable CONFIG_CPU.

Signed-off-by: Claudiu Beznea 
---
 configs/sama7g5ek_mmc1_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configs/sama7g5ek_mmc1_defconfig b/configs/sama7g5ek_mmc1_defconfig
index d43d07da78..936d9cd73f 100644
--- a/configs/sama7g5ek_mmc1_defconfig
+++ b/configs/sama7g5ek_mmc1_defconfig
@@ -42,6 +42,7 @@ CONFIG_CLK_AT91=y
 CONFIG_AT91_UTMI=y
 CONFIG_AT91_GENERIC_CLK=y
 CONFIG_AT91_SAM9X60_PLL=y
+CONFIG_CPU=y
 CONFIG_DM_GPIO=y
 CONFIG_ATMEL_PIO4=y
 CONFIG_DM_I2C=y
-- 
2.25.1



[PATCH 14/34] configs: sama7g5: use PIT64B

2020-12-03 Thread Eugen Hristev
From: Claudiu Beznea 

Use PIT64B driver. ATMEL_PIT is not available for SAMA7G5.

Signed-off-by: Claudiu Beznea 
---
 configs/sama7g5ek_mmc1_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configs/sama7g5ek_mmc1_defconfig b/configs/sama7g5ek_mmc1_defconfig
index 936d9cd73f..7d4d409532 100644
--- a/configs/sama7g5ek_mmc1_defconfig
+++ b/configs/sama7g5ek_mmc1_defconfig
@@ -58,5 +58,6 @@ CONFIG_DM_SERIAL=y
 CONFIG_DEBUG_UART_ANNOUNCE=y
 CONFIG_ATMEL_USART=y
 CONFIG_TIMER=y
+CONFIG_MCHP_PIT64B_TIMER=y
 CONFIG_OF_LIBFDT_OVERLAY=y
 # CONFIG_EFI_LOADER_HII is not set
-- 
2.25.1



[PATCH 13/34] ARM: dts: sama7g5: add CPU bindings

2020-12-03 Thread Eugen Hristev
From: Claudiu Beznea 

Add CPU DT bindings.

Signed-off-by: Claudiu Beznea 
---
 arch/arm/dts/sama7g5.dtsi | 12 
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/dts/sama7g5.dtsi b/arch/arm/dts/sama7g5.dtsi
index 94e0b535cc..a2554dcfff 100644
--- a/arch/arm/dts/sama7g5.dtsi
+++ b/arch/arm/dts/sama7g5.dtsi
@@ -40,6 +40,18 @@
};
};
 
+   cpus {
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   A7_0: cpu@0 {
+   device_type = "cpu";
+   compatible = "arm,cortex-a7";
+   clocks = <&pmc PMC_TYPE_CORE 8>, <&pmc PMC_TYPE_CORE 
22>, <&main_xtal>;
+   clock-names = "cpu", "master", "xtal";
+   };
+   };
+
ahb {
compatible = "simple-bus";
#address-cells = <1>;
-- 
2.25.1



[PATCH 16/34] ARM: dts: sama7g5: add pit64b support

2020-12-03 Thread Eugen Hristev
From: Claudiu Beznea 

Add DT bindings for PIT64B driver.

Signed-off-by: Claudiu Beznea 
---
 arch/arm/dts/sama7g5.dtsi  | 8 
 arch/arm/dts/sama7g5ek-u-boot.dtsi | 4 
 2 files changed, 12 insertions(+)

diff --git a/arch/arm/dts/sama7g5.dtsi b/arch/arm/dts/sama7g5.dtsi
index a2554dcfff..f633c2f81e 100644
--- a/arch/arm/dts/sama7g5.dtsi
+++ b/arch/arm/dts/sama7g5.dtsi
@@ -86,6 +86,14 @@
status = "disabled";
};
 
+   pit64b0: timer@e180 {
+   compatible = "microchip,sama7g5-pit64b";
+   reg = <0xe180 0x4000>;
+   clocks = <&pmc PMC_TYPE_PERIPHERAL 70>, <&pmc 
PMC_TYPE_GCK 70>;
+   clock-names = "pclk", "gclk";
+   status = "okay";
+   };
+
uart0: serial@e1824200 {
compatible = "atmel,at91sam9260-usart";
reg = <0xe1824200 0x200>;
diff --git a/arch/arm/dts/sama7g5ek-u-boot.dtsi 
b/arch/arm/dts/sama7g5ek-u-boot.dtsi
index 95d9c3bff2..27e0f316f3 100644
--- a/arch/arm/dts/sama7g5ek-u-boot.dtsi
+++ b/arch/arm/dts/sama7g5ek-u-boot.dtsi
@@ -31,6 +31,10 @@
u-boot,dm-pre-reloc;
 };
 
+&pit64b0 {
+   u-boot,dm-pre-reloc;
+};
+
 &pmc {
u-boot,dm-pre-reloc;
 };
-- 
2.25.1



[PATCH 15/34] ARM: dts: sama7g5: enable autoboot

2020-12-03 Thread Eugen Hristev
From: Claudiu Beznea 

Enable autoboot.

Signed-off-by: Claudiu Beznea 
---
 configs/sama7g5ek_mmc1_defconfig | 1 -
 1 file changed, 1 deletion(-)

diff --git a/configs/sama7g5ek_mmc1_defconfig b/configs/sama7g5ek_mmc1_defconfig
index 7d4d409532..99e2439516 100644
--- a/configs/sama7g5ek_mmc1_defconfig
+++ b/configs/sama7g5ek_mmc1_defconfig
@@ -16,7 +16,6 @@ CONFIG_SD_BOOT=y
 CONFIG_USE_BOOTARGS=y
 CONFIG_MISC_INIT_R=y
 CONFIG_HUSH_PARSER=y
-# CONFIG_AUTOBOOT is not set
 CONFIG_CMD_BOOTZ=y
 # CONFIG_CMD_IMI is not set
 CONFIG_CMD_MD5SUM=y
-- 
2.25.1



[PATCH 17/34] ARM: dts: at91: sama7g5: add pinctrl node

2020-12-03 Thread Eugen Hristev
Add pioA pinctrl node.

Signed-off-by: Eugen Hristev 
---
 arch/arm/dts/sama7g5.dtsi  | 13 +
 arch/arm/dts/sama7g5ek-u-boot.dtsi |  8 
 2 files changed, 21 insertions(+)

diff --git a/arch/arm/dts/sama7g5.dtsi b/arch/arm/dts/sama7g5.dtsi
index f633c2f81e..d9208d68d5 100644
--- a/arch/arm/dts/sama7g5.dtsi
+++ b/arch/arm/dts/sama7g5.dtsi
@@ -62,6 +62,19 @@
#address-cells = <1>;
#size-cells = <1>;
 
+   pioA: pinctrl@e0014000 {
+   compatible = "atmel,sama5d2-gpio";
+   reg = <0xe0014000 0x800>;
+   gpio-controller;
+   #gpio-cells = <2>;
+   clocks = <&pmc PMC_TYPE_PERIPHERAL 11>;
+   status = "okay";
+
+   pinctrl: pinctrl_default {
+   compatible = 
"microchip,sama7g5-pinctrl";
+   };
+   };
+
pmc: pmc@e0018000 {
compatible = "microchip,sama7g5-pmc";
reg = <0xe0018000 0x200>;
diff --git a/arch/arm/dts/sama7g5ek-u-boot.dtsi 
b/arch/arm/dts/sama7g5ek-u-boot.dtsi
index 27e0f316f3..4af4d1bb5b 100644
--- a/arch/arm/dts/sama7g5ek-u-boot.dtsi
+++ b/arch/arm/dts/sama7g5ek-u-boot.dtsi
@@ -31,6 +31,14 @@
u-boot,dm-pre-reloc;
 };
 
+&pioA {
+   u-boot,dm-pre-reloc;
+
+   pinctrl {
+   u-boot,dm-pre-reloc;
+   };
+};
+
 &pit64b0 {
u-boot,dm-pre-reloc;
 };
-- 
2.25.1



[PATCH 19/34] configs: sama7g5ek: enable mii command

2020-12-03 Thread Eugen Hristev
From: Claudiu Beznea 

Enable mii command as ethernet's PHY specific programming is
based on it.

Signed-off-by: Claudiu Beznea 
---
 configs/sama7g5ek_mmc1_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configs/sama7g5ek_mmc1_defconfig b/configs/sama7g5ek_mmc1_defconfig
index 99e2439516..176f4f3000 100644
--- a/configs/sama7g5ek_mmc1_defconfig
+++ b/configs/sama7g5ek_mmc1_defconfig
@@ -29,6 +29,7 @@ CONFIG_CMD_I2C=y
 # CONFIG_CMD_LOADS is not set
 CONFIG_CMD_MMC=y
 CONFIG_CMD_DHCP=y
+CONFIG_CMD_MII=y
 CONFIG_CMD_PING=y
 CONFIG_CMD_EXT4=y
 CONFIG_CMD_FAT=y
-- 
2.25.1



[PATCH 18/34] ARM: dts: at91: sama7g5ek: add pinctrl for sdmmc1 and flx3

2020-12-03 Thread Eugen Hristev
Add pinctrl for sdmmc1 and flx3.

Signed-off-by: Eugen Hristev 
---
 arch/arm/dts/sama7g5ek-u-boot.dtsi |  4 
 arch/arm/dts/sama7g5ek.dts | 30 ++
 2 files changed, 34 insertions(+)

diff --git a/arch/arm/dts/sama7g5ek-u-boot.dtsi 
b/arch/arm/dts/sama7g5ek-u-boot.dtsi
index 4af4d1bb5b..5e1a0d53a5 100644
--- a/arch/arm/dts/sama7g5ek-u-boot.dtsi
+++ b/arch/arm/dts/sama7g5ek-u-boot.dtsi
@@ -39,6 +39,10 @@
};
 };
 
+&pinctrl_flx3_default {
+   u-boot,dm-pre-reloc;
+};
+
 &pit64b0 {
u-boot,dm-pre-reloc;
 };
diff --git a/arch/arm/dts/sama7g5ek.dts b/arch/arm/dts/sama7g5ek.dts
index 03c7aa07ea..a9190bfcb3 100644
--- a/arch/arm/dts/sama7g5ek.dts
+++ b/arch/arm/dts/sama7g5ek.dts
@@ -38,12 +38,42 @@
apb {
sdmmc1: sdio-host@e1208000 {
bus-width = <4>;
+   pinctrl-names = "default";
+   pinctrl-0 = <&pinctrl_sdmmc1_cmd_data_default
+
&pinctrl_sdmmc1_ck_cd_rstn_vddsel_default>;
status = "okay";
};
 
uart0: serial@e1824200 {
+   pinctrl-names = "default";
+   pinctrl-0 = <&pinctrl_flx3_default>;
status = "okay";
};
};
};
 };
+
+&pinctrl {
+   pinctrl_flx3_default: flx3_default {
+   pinmux = ,
+;
+   bias-disable;
+   };
+
+   pinctrl_sdmmc1_cmd_data_default: sdmmc1_cmd_data_default {
+   pinmux = ,
+,
+,
+,
+;
+   bias-pull-up;
+   };
+
+   pinctrl_sdmmc1_ck_cd_rstn_vddsel_default: 
sdmmc1_ck_cd_rstn_vddsel_default {
+   pinmux = ,
+,
+,
+;
+   bias-pull-up;
+   };
+};
-- 
2.25.1



[PATCH 20/34] ARM: dts: sama7g5: add GMAC0

2020-12-03 Thread Eugen Hristev
From: Claudiu Beznea 

Add GMAC0.

Signed-off-by: Claudiu Beznea 
---
 arch/arm/dts/sama7g5.dtsi  | 11 +++
 arch/arm/dts/sama7g5ek.dts | 32 
 2 files changed, 43 insertions(+)

diff --git a/arch/arm/dts/sama7g5.dtsi b/arch/arm/dts/sama7g5.dtsi
index d9208d68d5..33589f3ad9 100644
--- a/arch/arm/dts/sama7g5.dtsi
+++ b/arch/arm/dts/sama7g5.dtsi
@@ -114,6 +114,17 @@
clock-names = "usart";
status = "disabled";
};
+
+   gmac0: ethernet@e280 {
+   compatible = "cdns,sama7g5-gem";
+   reg = <0xe280 0x4000>;
+   clocks = <&pmc PMC_TYPE_PERIPHERAL 51>, <&pmc 
PMC_TYPE_PERIPHERAL 51>, <&pmc PMC_TYPE_GCK 51>;
+   clock-names = "hclk", "pclk", "tx_clk";
+   assigned-clocks = <&pmc PMC_TYPE_GCK 51>;
+   assigned-clock-parents = <&pmc PMC_TYPE_CORE 
21>; /* eth pll div. */
+   assigned-clock-rates = <12500>;
+   status = "disabled";
+   };
};
};
 };
diff --git a/arch/arm/dts/sama7g5ek.dts b/arch/arm/dts/sama7g5ek.dts
index a9190bfcb3..194f4644b5 100644
--- a/arch/arm/dts/sama7g5ek.dts
+++ b/arch/arm/dts/sama7g5ek.dts
@@ -53,6 +53,19 @@
};
 };
 
+&gmac0 {
+   #address-cells = <1>;
+   #size-cells = <0>;
+   pinctrl-names = "default";
+   pinctrl-0 = <&pinctrl_gmac0_default>;
+   phy-mode = "rgmii-id";
+   status = "okay";
+
+   ethernet-phy@7 {
+   reg = <0x7>;
+   };
+};
+
 &pinctrl {
pinctrl_flx3_default: flx3_default {
pinmux = ,
@@ -76,4 +89,23 @@
 ;
bias-pull-up;
};
+
+   pinctrl_gmac0_default: gmac0_default {
+   pinmux = ,
+,
+,
+,
+,
+,
+,
+,
+,
+,
+,
+,
+,
+,
+;
+   bias-disable;
+   };
 };
-- 
2.25.1



[PATCH 21/34] ARM: dts: sama7g5: add GMAC1

2020-12-03 Thread Eugen Hristev
From: Claudiu Beznea 

Add GMAC1.

Signed-off-by: Claudiu Beznea 
---
 arch/arm/dts/sama7g5.dtsi  |  8 
 arch/arm/dts/sama7g5ek.dts | 27 +++
 2 files changed, 35 insertions(+)

diff --git a/arch/arm/dts/sama7g5.dtsi b/arch/arm/dts/sama7g5.dtsi
index 33589f3ad9..43fac992ee 100644
--- a/arch/arm/dts/sama7g5.dtsi
+++ b/arch/arm/dts/sama7g5.dtsi
@@ -125,6 +125,14 @@
assigned-clock-rates = <12500>;
status = "disabled";
};
+
+   gmac1: ethernet@e2804000 {
+   compatible = "cdns,sama7g5-emac";
+   reg = <0xe2804000 0x1000>;
+   clocks = <&pmc PMC_TYPE_PERIPHERAL 52>, <&pmc 
PMC_TYPE_PERIPHERAL 52>;
+   clock-names = "pclk", "hclk";
+   status = "disabled";
+   };
};
};
 };
diff --git a/arch/arm/dts/sama7g5ek.dts b/arch/arm/dts/sama7g5ek.dts
index 194f4644b5..3eac94896d 100644
--- a/arch/arm/dts/sama7g5ek.dts
+++ b/arch/arm/dts/sama7g5ek.dts
@@ -66,6 +66,19 @@
};
 };
 
+&gmac1 {
+   #address-cells = <1>;
+   #size-cells = <0>;
+   pinctrl-names = "default";
+   pinctrl-0 = <&pinctrl_gmac1_default>;
+   phy-mode = "rmii";
+   status = "okay";
+
+   ethernet-phy@0 {
+   reg = <0x0>;
+   };
+};
+
 &pinctrl {
pinctrl_flx3_default: flx3_default {
pinmux = ,
@@ -108,4 +121,18 @@
 ;
bias-disable;
};
+
+   pinctrl_gmac1_default: gmac1_default {
+   pinmux = ,
+,
+,
+,
+,
+,
+,
+,
+,
+;
+   bias-disable;
+   };
 };
-- 
2.25.1



[PATCH 22/34] board: atmel: sama7g5ek: increase arp timeout and retry count

2020-12-03 Thread Eugen Hristev
From: Claudiu Beznea 

Increase ARP timeout and retry count as this will increase
the speed of communication.

Signed-off-by: Claudiu Beznea 
---
 include/configs/sama7g5ek.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/include/configs/sama7g5ek.h b/include/configs/sama7g5ek.h
index fbf0274b38..dc6cf4c700 100644
--- a/include/configs/sama7g5ek.h
+++ b/include/configs/sama7g5ek.h
@@ -44,4 +44,7 @@
 /* Size of malloc() pool */
 #define CONFIG_SYS_MALLOC_LEN  (4 * 1024 * 1024)
 
+#define CONFIG_ARP_TIMEOUT 200
+#define CONFIG_NET_RETRY_COUNT 50
+
 #endif
-- 
2.25.1



[PATCH 23/34] configs: sama7g5ek: enable support for KSZ9131

2020-12-03 Thread Eugen Hristev
From: Claudiu Beznea 

Enable support for KSZ9131.

Signed-off-by: Claudiu Beznea 
---
 configs/sama7g5ek_mmc1_defconfig | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/configs/sama7g5ek_mmc1_defconfig b/configs/sama7g5ek_mmc1_defconfig
index 176f4f3000..7e3cf49da0 100644
--- a/configs/sama7g5ek_mmc1_defconfig
+++ b/configs/sama7g5ek_mmc1_defconfig
@@ -49,6 +49,8 @@ CONFIG_DM_I2C=y
 CONFIG_DM_MMC=y
 CONFIG_MMC_SDHCI=y
 CONFIG_MMC_SDHCI_ATMEL=y
+CONFIG_PHY_MICREL=y
+CONFIG_PHY_MICREL_KSZ90X1=y
 CONFIG_DM_ETH=y
 CONFIG_MACB=y
 CONFIG_PINCTRL=y
-- 
2.25.1



[PATCH 24/34] configs: sama7g5ek: enable CCF

2020-12-03 Thread Eugen Hristev
From: Claudiu Beznea 

Enable CCF for SAMA7G5.

Signed-off-by: Claudiu Beznea 
---
 configs/sama7g5ek_mmc1_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configs/sama7g5ek_mmc1_defconfig b/configs/sama7g5ek_mmc1_defconfig
index 7e3cf49da0..fa4c88ffa6 100644
--- a/configs/sama7g5ek_mmc1_defconfig
+++ b/configs/sama7g5ek_mmc1_defconfig
@@ -38,6 +38,7 @@ CONFIG_ENV_IS_IN_FAT=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_DM=y
 CONFIG_CLK=y
+CONFIG_CLK_CCF=y
 CONFIG_CLK_AT91=y
 CONFIG_AT91_UTMI=y
 CONFIG_AT91_GENERIC_CLK=y
-- 
2.25.1



[PATCH 25/34] ARM: dts: at91: sama7g5: add assigned clocks for sdmmc1

2020-12-03 Thread Eugen Hristev
SDMMC1 requires clock specification with assigned-clocks, such that
the PMC will know which parent to assign and the initial start-up frequency.

Signed-off-by: Eugen Hristev 
---
 arch/arm/dts/sama7g5.dtsi | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/arm/dts/sama7g5.dtsi b/arch/arm/dts/sama7g5.dtsi
index 43fac992ee..826828bb17 100644
--- a/arch/arm/dts/sama7g5.dtsi
+++ b/arch/arm/dts/sama7g5.dtsi
@@ -96,6 +96,9 @@
reg = <0xe1208000 0x300>;
clocks = <&pmc PMC_TYPE_PERIPHERAL 81>, <&pmc 
PMC_TYPE_GCK 81>;
clock-names = "hclock", "multclk";
+   assigned-clocks = <&pmc PMC_TYPE_GCK 81>;
+   assigned-clock-rates = <2>;
+   assigned-clock-parents = <&pmc PMC_TYPE_CORE 
10>; /* sys pll div. */
status = "disabled";
};
 
-- 
2.25.1



[PATCH 29/34] configs: sama7g5: add mmc config for sdmmc0

2020-12-03 Thread Eugen Hristev
Add new config for storing environment from sdmmc0.
Also clean-up sama7g5ek_emmc1 to point to the proper mmc device.

Signed-off-by: Eugen Hristev 
---
 board/atmel/sama7g5ek/MAINTAINERS |  1 +
 configs/sama7g5ek_mmc1_defconfig  |  7 ++--
 configs/sama7g5ek_mmc_defconfig   | 67 +++
 3 files changed, 72 insertions(+), 3 deletions(-)
 create mode 100644 configs/sama7g5ek_mmc_defconfig

diff --git a/board/atmel/sama7g5ek/MAINTAINERS 
b/board/atmel/sama7g5ek/MAINTAINERS
index f66953ac4e..eac972968d 100644
--- a/board/atmel/sama7g5ek/MAINTAINERS
+++ b/board/atmel/sama7g5ek/MAINTAINERS
@@ -4,4 +4,5 @@ S: Maintained
 F: board/atmel/sama7g5ek.c
 F: include/configs/sama7g5ek.h
 F: configs/sama7g5ek_mmc1_defconfig
+F: configs/sama7g5ek_mmc_defconfig
 
diff --git a/configs/sama7g5ek_mmc1_defconfig b/configs/sama7g5ek_mmc1_defconfig
index fa4c88ffa6..b6d2f4dd05 100644
--- a/configs/sama7g5ek_mmc1_defconfig
+++ b/configs/sama7g5ek_mmc1_defconfig
@@ -2,9 +2,10 @@ CONFIG_ARM=y
 CONFIG_ARCH_AT91=y
 CONFIG_SYS_TEXT_BASE=0x66f0
 CONFIG_TARGET_SAMA7G5EK=y
-CONFIG_NR_DRAM_BANKS=1
 CONFIG_SYS_MALLOC_F_LEN=0x11000
+CONFIG_NR_DRAM_BANKS=1
 CONFIG_ENV_SIZE=0x4000
+CONFIG_DM_GPIO=y
 CONFIG_DEBUG_UART_BOARD_INIT=y
 CONFIG_DEBUG_UART_BASE=0xe1824200
 CONFIG_DEBUG_UART_CLOCK=2
@@ -14,6 +15,7 @@ CONFIG_ENV_VARS_UBOOT_CONFIG=y
 CONFIG_FIT=y
 CONFIG_SD_BOOT=y
 CONFIG_USE_BOOTARGS=y
+CONFIG_BOOTARGS="console=ttyS0,115200 root=/dev/mmcblk1p2 rw rootwait"
 CONFIG_MISC_INIT_R=y
 CONFIG_HUSH_PARSER=y
 CONFIG_CMD_BOOTZ=y
@@ -35,6 +37,7 @@ CONFIG_CMD_EXT4=y
 CONFIG_CMD_FAT=y
 CONFIG_OF_CONTROL=y
 CONFIG_ENV_IS_IN_FAT=y
+CONFIG_ENV_FAT_DEVICE_AND_PART="1:1"
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_DM=y
 CONFIG_CLK=y
@@ -44,7 +47,6 @@ CONFIG_AT91_UTMI=y
 CONFIG_AT91_GENERIC_CLK=y
 CONFIG_AT91_SAM9X60_PLL=y
 CONFIG_CPU=y
-CONFIG_DM_GPIO=y
 CONFIG_ATMEL_PIO4=y
 CONFIG_DM_I2C=y
 CONFIG_DM_MMC=y
@@ -56,7 +58,6 @@ CONFIG_DM_ETH=y
 CONFIG_MACB=y
 CONFIG_PINCTRL=y
 CONFIG_PINCTRL_AT91PIO4=y
-# CONFIG_RAM_ROCKCHIP_DEBUG is not set
 CONFIG_DM_SERIAL=y
 CONFIG_DEBUG_UART_ANNOUNCE=y
 CONFIG_ATMEL_USART=y
diff --git a/configs/sama7g5ek_mmc_defconfig b/configs/sama7g5ek_mmc_defconfig
new file mode 100644
index 00..894a64983f
--- /dev/null
+++ b/configs/sama7g5ek_mmc_defconfig
@@ -0,0 +1,67 @@
+CONFIG_ARM=y
+CONFIG_ARCH_AT91=y
+CONFIG_SYS_TEXT_BASE=0x66f0
+CONFIG_TARGET_SAMA7G5EK=y
+CONFIG_SYS_MALLOC_F_LEN=0x11000
+CONFIG_NR_DRAM_BANKS=1
+CONFIG_ENV_SIZE=0x4000
+CONFIG_DM_GPIO=y
+CONFIG_DEBUG_UART_BOARD_INIT=y
+CONFIG_DEBUG_UART_BASE=0xe1824200
+CONFIG_DEBUG_UART_CLOCK=2
+CONFIG_DEFAULT_DEVICE_TREE="sama7g5ek"
+CONFIG_DEBUG_UART=y
+CONFIG_ENV_VARS_UBOOT_CONFIG=y
+CONFIG_FIT=y
+CONFIG_SD_BOOT=y
+CONFIG_USE_BOOTARGS=y
+CONFIG_BOOTARGS="console=ttyS0,115200 root=/dev/mmcblk0p2 rw rootwait"
+CONFIG_MISC_INIT_R=y
+CONFIG_HUSH_PARSER=y
+CONFIG_CMD_BOOTZ=y
+# CONFIG_CMD_IMI is not set
+CONFIG_CMD_MD5SUM=y
+CONFIG_CMD_MEMTEST=y
+CONFIG_SYS_MEMTEST_START=0x6000
+CONFIG_SYS_MEMTEST_END=0x7000
+CONFIG_CMD_STRINGS=y
+CONFIG_CMD_DM=y
+CONFIG_CMD_GPIO=y
+CONFIG_CMD_I2C=y
+# CONFIG_CMD_LOADS is not set
+CONFIG_CMD_MMC=y
+CONFIG_CMD_DHCP=y
+CONFIG_CMD_MII=y
+CONFIG_CMD_PING=y
+CONFIG_CMD_EXT4=y
+CONFIG_CMD_FAT=y
+CONFIG_OF_CONTROL=y
+CONFIG_ENV_IS_IN_FAT=y
+CONFIG_ENV_FAT_DEVICE_AND_PART="0:1"
+CONFIG_SYS_RELOC_GD_ENV_ADDR=y
+CONFIG_DM=y
+CONFIG_CLK=y
+CONFIG_CLK_CCF=y
+CONFIG_CLK_AT91=y
+CONFIG_AT91_UTMI=y
+CONFIG_AT91_GENERIC_CLK=y
+CONFIG_AT91_SAM9X60_PLL=y
+CONFIG_CPU=y
+CONFIG_ATMEL_PIO4=y
+CONFIG_DM_I2C=y
+CONFIG_DM_MMC=y
+CONFIG_MMC_SDHCI=y
+CONFIG_MMC_SDHCI_ATMEL=y
+CONFIG_PHY_MICREL=y
+CONFIG_PHY_MICREL_KSZ90X1=y
+CONFIG_DM_ETH=y
+CONFIG_MACB=y
+CONFIG_PINCTRL=y
+CONFIG_PINCTRL_AT91PIO4=y
+CONFIG_DM_SERIAL=y
+CONFIG_DEBUG_UART_ANNOUNCE=y
+CONFIG_ATMEL_USART=y
+CONFIG_TIMER=y
+CONFIG_MCHP_PIT64B_TIMER=y
+CONFIG_OF_LIBFDT_OVERLAY=y
+# CONFIG_EFI_LOADER_HII is not set
-- 
2.25.1



[PATCH 27/34] ARM: dts: at91: sama7g5ek: enable sdmmc0 with pinctrl

2020-12-03 Thread Eugen Hristev
Enable sdmmc0 on this board. A non-removable eMMC is connected on this
block.
Configure pincontrol accordingly.

Signed-off-by: Eugen Hristev 
---
 arch/arm/dts/sama7g5ek.dts | 30 ++
 1 file changed, 30 insertions(+)

diff --git a/arch/arm/dts/sama7g5ek.dts b/arch/arm/dts/sama7g5ek.dts
index 3eac94896d..452bf425df 100644
--- a/arch/arm/dts/sama7g5ek.dts
+++ b/arch/arm/dts/sama7g5ek.dts
@@ -36,6 +36,15 @@
ahb {
 
apb {
+   sdmmc0: sdio-host@e1204000 {
+   bus-width = <8>;
+   non-removable;
+   pinctrl-names = "default";
+   pinctrl-0 = <&pinctrl_sdmmc0_cmd_data_default
+
&pinctrl_sdmmc0_ck_rstn_ds_cd_default>;
+   status = "okay";
+   };
+
sdmmc1: sdio-host@e1208000 {
bus-width = <4>;
pinctrl-names = "default";
@@ -86,6 +95,27 @@
bias-disable;
};
 
+   pinctrl_sdmmc0_cmd_data_default: sdmmc0_cmd_data_default {
+   pinmux = ,
+,
+,
+,
+,
+,
+,
+,
+;
+   bias-pull-up;
+   };
+
+   pinctrl_sdmmc0_ck_rstn_ds_cd_default: sdmmc0_ck_rstn_ds_cd_default {
+   pinmux = ,
+,
+,
+;
+   bias-pull-up;
+   };
+
pinctrl_sdmmc1_cmd_data_default: sdmmc1_cmd_data_default {
pinmux = ,
 ,
-- 
2.25.1



[PATCH 26/34] ARM: dts: at91: sama7g5: add node for sdmmc0

2020-12-03 Thread Eugen Hristev
Add node for sdmmc0 block.

Signed-off-by: Eugen Hristev 
---
 arch/arm/dts/sama7g5.dtsi | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/arch/arm/dts/sama7g5.dtsi b/arch/arm/dts/sama7g5.dtsi
index 826828bb17..4c571befad 100644
--- a/arch/arm/dts/sama7g5.dtsi
+++ b/arch/arm/dts/sama7g5.dtsi
@@ -91,6 +91,17 @@
#clock-cells = <1>;
};
 
+   sdmmc0: sdio-host@e1204000 {
+   compatible = "microchip,sama7g5-sdhci";
+   reg = <0xe1204000 0x300>;
+   clocks = <&pmc PMC_TYPE_PERIPHERAL 80>, <&pmc 
PMC_TYPE_GCK 80>;
+   clock-names = "hclock", "multclk";
+   assigned-clocks = <&pmc PMC_TYPE_GCK 80>;
+   assigned-clock-rates = <2>;
+   assigned-clock-parents = <&pmc PMC_TYPE_CORE 
10>; /* sys pll div. */
+   status = "disabled";
+   };
+
sdmmc1: sdio-host@e1208000 {
compatible = "microchip,sama7g5-sdhci";
reg = <0xe1208000 0x300>;
-- 
2.25.1



[PATCH 28/34] board: atmel: sama7g5ek: clean-up header bootcommand

2020-12-03 Thread Eugen Hristev
Clean-up boot command to use the predefined device and part for FAT
environment.
According to this device and partition, select the proper boot media.

Signed-off-by: Eugen Hristev 
---
 include/configs/sama7g5ek.h | 11 +++
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/include/configs/sama7g5ek.h b/include/configs/sama7g5ek.h
index dc6cf4c700..ef3bfa36fd 100644
--- a/include/configs/sama7g5ek.h
+++ b/include/configs/sama7g5ek.h
@@ -29,16 +29,11 @@
 #undef CONFIG_BOOTCOMMAND
 #ifdef CONFIG_SD_BOOT
 /* u-boot env in sd/mmc card */
-#define FAT_ENV_INTERFACE  "mmc"
-#define FAT_ENV_DEVICE_AND_PART"0"
-#define FAT_ENV_FILE   "uboot.env"
+
 /* bootstrap + u-boot + env in sd card */
-#define CONFIG_BOOTCOMMAND "fatload mmc 0:1 0x6100 at91-sama7g5ek.dtb; 
" \
-   "fatload mmc 0:1 0x6200 zImage; " \
+#define CONFIG_BOOTCOMMAND "fatload mmc " CONFIG_ENV_FAT_DEVICE_AND_PART " 
0x6100 at91-sama7g5ek.dtb; " \
+   "fatload mmc " CONFIG_ENV_FAT_DEVICE_AND_PART " 
0x6200 zImage; " \
"bootz 0x6200 - 0x6100"
-#undef CONFIG_BOOTARGS
-#define CONFIG_BOOTARGS \
-   "console=ttyS0,115200 root=/dev/mmcblk0p2 rw rootwait"
 #endif
 
 /* Size of malloc() pool */
-- 
2.25.1



[PATCH 30/34] ARM: dts: at91: sama7g5: add flexcom1 and i2c subnode

2020-12-03 Thread Eugen Hristev
Add flexcom1 and i2c subnode.

Signed-off-by: Eugen Hristev 
---
 arch/arm/dts/sama7g5.dtsi | 17 +
 1 file changed, 17 insertions(+)

diff --git a/arch/arm/dts/sama7g5.dtsi b/arch/arm/dts/sama7g5.dtsi
index 4c571befad..4846778ed9 100644
--- a/arch/arm/dts/sama7g5.dtsi
+++ b/arch/arm/dts/sama7g5.dtsi
@@ -121,6 +121,23 @@
status = "okay";
};
 
+   flx1: flexcom@e181c000 {
+   compatible = "atmel,sama5d2-flexcom";
+   reg = <0xe181c000 0x200>;
+   clocks = <&pmc PMC_TYPE_PERIPHERAL 39>;
+   #address-cells = <1>;
+   #size-cells = <1>;
+   ranges = <0x0 0xe181c000 0x800>;
+   status = "disabled";
+
+   i2c1: i2c@600 {
+   compatible = "atmel,sama5d2-i2c";
+   reg = <0x600 0x200>;
+   #address-cells = <1>;
+   #size-cells = <0>;
+   clocks = <&pmc PMC_TYPE_PERIPHERAL 39>;
+   };
+   };
uart0: serial@e1824200 {
compatible = "atmel,at91sam9260-usart";
reg = <0xe1824200 0x200>;
-- 
2.25.1



[PATCH 31/34] ARM: dts: sama7g5ek: add i2c1 bus and eeproms

2020-12-03 Thread Eugen Hristev
Add node for flx1 i2c1 subnode (and alias to bus 0)
This bus has two eeprom devices connected.

Signed-off-by: Eugen Hristev 
---
 arch/arm/dts/sama7g5ek.dts | 30 ++
 1 file changed, 30 insertions(+)

diff --git a/arch/arm/dts/sama7g5ek.dts b/arch/arm/dts/sama7g5ek.dts
index 452bf425df..0812b0cc00 100644
--- a/arch/arm/dts/sama7g5ek.dts
+++ b/arch/arm/dts/sama7g5ek.dts
@@ -17,6 +17,7 @@
 
aliases {
serial0 = &uart0;
+   i2c0 = &i2c1;
};
 
chosen {
@@ -62,6 +63,29 @@
};
 };
 
+&flx1 {
+   atmel,flexcom-mode = <3>;
+   status = "okay";
+};
+
+&i2c1 {
+   pinctrl-names = "default";
+   pinctrl-0 = <&pinctrl_flx1_default>;
+   status = "okay";
+
+   eeprom@52 {
+   compatible = "atmel,24c32";
+   reg = <0x52>;
+   pagesize = <16>;
+   };
+
+   eeprom@53 {
+   compatible = "atmel,24c32";
+   reg = <0x53>;
+   pagesize = <16>;
+   };
+};
+
 &gmac0 {
#address-cells = <1>;
#size-cells = <0>;
@@ -89,6 +113,12 @@
 };
 
 &pinctrl {
+   pinctrl_flx1_default: flx1_default {
+   pinmux = ,
+;
+   bias-disable;
+   };
+
pinctrl_flx3_default: flx3_default {
pinmux = ,
 ;
-- 
2.25.1



[PATCH 34/34] ARM: dts: sama7g5ek: fix TXC pin configuration

2020-12-03 Thread Eugen Hristev
From: Nicolas Ferre 

TXC line is directly connected from the SoC to the KSZ9131 PHY. There
is a transient state on this signal, before configuring it to RGMII,
which leads to packet transmit being blocked.
Keeping a pull-up when muxing this pin as function A (G0_TXCK) fixes
the issue.

Signed-off-by: Nicolas Ferre 
---
 arch/arm/dts/sama7g5ek.dts | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/arch/arm/dts/sama7g5ek.dts b/arch/arm/dts/sama7g5ek.dts
index 0812b0cc00..41818cc911 100644
--- a/arch/arm/dts/sama7g5ek.dts
+++ b/arch/arm/dts/sama7g5ek.dts
@@ -90,7 +90,7 @@
#address-cells = <1>;
#size-cells = <0>;
pinctrl-names = "default";
-   pinctrl-0 = <&pinctrl_gmac0_default>;
+   pinctrl-0 = <&pinctrl_gmac0_default &pinctrl_gmac0_txc_default>;
phy-mode = "rgmii-id";
status = "okay";
 
@@ -173,7 +173,6 @@
 ,
 ,
 ,
-,
 ,
 ,
 ,
@@ -182,6 +181,11 @@
bias-disable;
};
 
+   pinctrl_gmac0_txc_default: gmac0_txc_default {
+   pinmux = ;
+   bias-pull-up;
+   };
+
pinctrl_gmac1_default: gmac1_default {
pinmux = ,
 ,
-- 
2.25.1



[PATCH 32/34] board: atmel: sama7g5ek: add support for MAC address retreival

2020-12-03 Thread Eugen Hristev
Obtain two MAC addresses from the two EEPROMs and configure the two
available Ethernet interfaces accordingly.

Signed-off-by: Eugen Hristev 
---
 board/atmel/sama7g5ek/sama7g5ek.c | 18 +-
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/board/atmel/sama7g5ek/sama7g5ek.c 
b/board/atmel/sama7g5ek/sama7g5ek.c
index 1d7a01593d..ed1cf80da7 100644
--- a/board/atmel/sama7g5ek/sama7g5ek.c
+++ b/board/atmel/sama7g5ek/sama7g5ek.c
@@ -46,6 +46,19 @@ int board_early_init_f(void)
return 0;
 }
 
+#define MAC24AA_MAC_OFFSET 0xfa
+
+#ifdef CONFIG_MISC_INIT_R
+int misc_init_r(void)
+{
+#ifdef CONFIG_I2C_EEPROM
+   at91_set_ethaddr(MAC24AA_MAC_OFFSET);
+   at91_set_eth1addr(MAC24AA_MAC_OFFSET);
+#endif
+   return 0;
+}
+#endif
+
 int board_init(void)
 {
/* address of boot parameters */
@@ -61,8 +74,3 @@ int dram_init(void)
return 0;
 }
 
-int misc_init_r(void)
-{
-   return 0;
-}
-
-- 
2.25.1



[PATCH 33/34] configs: sama7g5ek: add i2c and eeprom

2020-12-03 Thread Eugen Hristev
Add drivers for flexcom, i2c and eeproms

Signed-off-by: Eugen Hristev 
---
 configs/sama7g5ek_mmc1_defconfig | 3 +++
 configs/sama7g5ek_mmc_defconfig  | 3 +++
 2 files changed, 6 insertions(+)

diff --git a/configs/sama7g5ek_mmc1_defconfig b/configs/sama7g5ek_mmc1_defconfig
index b6d2f4dd05..af362021b9 100644
--- a/configs/sama7g5ek_mmc1_defconfig
+++ b/configs/sama7g5ek_mmc1_defconfig
@@ -49,6 +49,9 @@ CONFIG_AT91_SAM9X60_PLL=y
 CONFIG_CPU=y
 CONFIG_ATMEL_PIO4=y
 CONFIG_DM_I2C=y
+CONFIG_SYS_I2C_AT91=y
+CONFIG_I2C_EEPROM=y
+CONFIG_MICROCHIP_FLEXCOM=y
 CONFIG_DM_MMC=y
 CONFIG_MMC_SDHCI=y
 CONFIG_MMC_SDHCI_ATMEL=y
diff --git a/configs/sama7g5ek_mmc_defconfig b/configs/sama7g5ek_mmc_defconfig
index 894a64983f..bbd1a0c659 100644
--- a/configs/sama7g5ek_mmc_defconfig
+++ b/configs/sama7g5ek_mmc_defconfig
@@ -49,6 +49,9 @@ CONFIG_AT91_SAM9X60_PLL=y
 CONFIG_CPU=y
 CONFIG_ATMEL_PIO4=y
 CONFIG_DM_I2C=y
+CONFIG_SYS_I2C_AT91=y
+CONFIG_I2C_EEPROM=y
+CONFIG_MICROCHIP_FLEXCOM=y
 CONFIG_DM_MMC=y
 CONFIG_MMC_SDHCI=y
 CONFIG_MMC_SDHCI_ATMEL=y
-- 
2.25.1



Re: [PATCH 29/34] configs: sama7g5: add mmc config for sdmmc0

2020-12-03 Thread Eugen.Hristev
On 03.12.2020 12:38, Jaehoon Chung wrote:
> Hi,
> 
> On 12/3/20 6:28 PM, Eugen Hristev wrote:
>> Add new config for storing environment from sdmmc0.
>> Also clean-up sama7g5ek_emmc1 to point to the proper mmc device.
> 
> Just one question, Sorry, i didn't check entire patchset.
> 
> What is different between sama7g5ek_mmc1 and sama7g5ek_mmc?

Sama7g5ek_mmc is set to store the environment in the eMMC device 
soldered on the board which is connected on the SDMMC0 hardware block.

sama7g5ek_mmc1 is set to store the environment on the SD-Card which can 
be inserted in the SD slot on the board which is connected on the SDMMC1 
hardware block.

So basically we have two possible boot/env store configurations, one on 
eMMC and one on SD-Card .

Eugen
> 
> Best Regards,
> Jaehoon Chung
> 
>>
>> Signed-off-by: Eugen Hristev 
>> ---
>>   board/atmel/sama7g5ek/MAINTAINERS |  1 +
>>   configs/sama7g5ek_mmc1_defconfig  |  7 ++--
>>   configs/sama7g5ek_mmc_defconfig   | 67 +++
>>   3 files changed, 72 insertions(+), 3 deletions(-)
>>   create mode 100644 configs/sama7g5ek_mmc_defconfig
>>
>> diff --git a/board/atmel/sama7g5ek/MAINTAINERS 
>> b/board/atmel/sama7g5ek/MAINTAINERS
>> index f66953ac4e..eac972968d 100644
>> --- a/board/atmel/sama7g5ek/MAINTAINERS
>> +++ b/board/atmel/sama7g5ek/MAINTAINERS
>> @@ -4,4 +4,5 @@ S: Maintained
>>   F: board/atmel/sama7g5ek.c
>>   F: include/configs/sama7g5ek.h
>>   F: configs/sama7g5ek_mmc1_defconfig
>> +F: configs/sama7g5ek_mmc_defconfig
>>
>> diff --git a/configs/sama7g5ek_mmc1_defconfig 
>> b/configs/sama7g5ek_mmc1_defconfig
>> index fa4c88ffa6..b6d2f4dd05 100644
>> --- a/configs/sama7g5ek_mmc1_defconfig
>> +++ b/configs/sama7g5ek_mmc1_defconfig
>> @@ -2,9 +2,10 @@ CONFIG_ARM=y
>>   CONFIG_ARCH_AT91=y
>>   CONFIG_SYS_TEXT_BASE=0x66f0
>>   CONFIG_TARGET_SAMA7G5EK=y
>> -CONFIG_NR_DRAM_BANKS=1
>>   CONFIG_SYS_MALLOC_F_LEN=0x11000
>> +CONFIG_NR_DRAM_BANKS=1
>>   CONFIG_ENV_SIZE=0x4000
>> +CONFIG_DM_GPIO=y
>>   CONFIG_DEBUG_UART_BOARD_INIT=y
>>   CONFIG_DEBUG_UART_BASE=0xe1824200
>>   CONFIG_DEBUG_UART_CLOCK=2
>> @@ -14,6 +15,7 @@ CONFIG_ENV_VARS_UBOOT_CONFIG=y
>>   CONFIG_FIT=y
>>   CONFIG_SD_BOOT=y
>>   CONFIG_USE_BOOTARGS=y
>> +CONFIG_BOOTARGS="console=ttyS0,115200 root=/dev/mmcblk1p2 rw rootwait"
>>   CONFIG_MISC_INIT_R=y
>>   CONFIG_HUSH_PARSER=y
>>   CONFIG_CMD_BOOTZ=y
>> @@ -35,6 +37,7 @@ CONFIG_CMD_EXT4=y
>>   CONFIG_CMD_FAT=y
>>   CONFIG_OF_CONTROL=y
>>   CONFIG_ENV_IS_IN_FAT=y
>> +CONFIG_ENV_FAT_DEVICE_AND_PART="1:1"
>>   CONFIG_SYS_RELOC_GD_ENV_ADDR=y
>>   CONFIG_DM=y
>>   CONFIG_CLK=y
>> @@ -44,7 +47,6 @@ CONFIG_AT91_UTMI=y
>>   CONFIG_AT91_GENERIC_CLK=y
>>   CONFIG_AT91_SAM9X60_PLL=y
>>   CONFIG_CPU=y
>> -CONFIG_DM_GPIO=y
>>   CONFIG_ATMEL_PIO4=y
>>   CONFIG_DM_I2C=y
>>   CONFIG_DM_MMC=y
>> @@ -56,7 +58,6 @@ CONFIG_DM_ETH=y
>>   CONFIG_MACB=y
>>   CONFIG_PINCTRL=y
>>   CONFIG_PINCTRL_AT91PIO4=y
>> -# CONFIG_RAM_ROCKCHIP_DEBUG is not set
>>   CONFIG_DM_SERIAL=y
>>   CONFIG_DEBUG_UART_ANNOUNCE=y
>>   CONFIG_ATMEL_USART=y
>> diff --git a/configs/sama7g5ek_mmc_defconfig 
>> b/configs/sama7g5ek_mmc_defconfig
>> new file mode 100644
>> index 00..894a64983f
>> --- /dev/null
>> +++ b/configs/sama7g5ek_mmc_defconfig
>> @@ -0,0 +1,67 @@
>> +CONFIG_ARM=y
>> +CONFIG_ARCH_AT91=y
>> +CONFIG_SYS_TEXT_BASE=0x66f0
>> +CONFIG_TARGET_SAMA7G5EK=y
>> +CONFIG_SYS_MALLOC_F_LEN=0x11000
>> +CONFIG_NR_DRAM_BANKS=1
>> +CONFIG_ENV_SIZE=0x4000
>> +CONFIG_DM_GPIO=y
>> +CONFIG_DEBUG_UART_BOARD_INIT=y
>> +CONFIG_DEBUG_UART_BASE=0xe1824200
>> +CONFIG_DEBUG_UART_CLOCK=2
>> +CONFIG_DEFAULT_DEVICE_TREE="sama7g5ek"
>> +CONFIG_DEBUG_UART=y
>> +CONFIG_ENV_VARS_UBOOT_CONFIG=y
>> +CONFIG_FIT=y
>> +CONFIG_SD_BOOT=y
>> +CONFIG_USE_BOOTARGS=y
>> +CONFIG_BOOTARGS="console=ttyS0,115200 root=/dev/mmcblk0p2 rw rootwait"
>> +CONFIG_MISC_INIT_R=y
>> +CONFIG_HUSH_PARSER=y
>> +CONFIG_CMD_BOOTZ=y
>> +# CONFIG_CMD_IMI is not set
>> +CONFIG_CMD_MD5SUM=y
>> +CONFIG_CMD_MEMTEST=y
>> +CONFIG_SYS_MEMTEST_START=0x6000
>> +CONFIG_SYS_MEMTEST_END=0x7000
>> +CONFIG_CMD_STRINGS=y
>> +CONFIG_CMD_DM=y
>> +CONFIG_CMD_GPIO=y
>> +CONFIG_CMD_I2C=y
>> +# CONFIG_CMD_LOADS is not set
>> +CONFIG_CMD_MMC=y
>> +CONFIG_CMD_DHCP=y
>> +CONFIG_CMD_MII=y
>> +CONFIG_CMD_PING=y
>> +CONFIG_CMD_EXT4=y
>> +CONFIG_CMD_FAT=y
>> +CONFIG_OF_CONTROL=y
>> +CONFIG_ENV_IS_IN_FAT=y
>> +CONFIG_ENV_FAT_DEVICE_AND_PART="0:1"
>> +CONFIG_SYS_RELOC_GD_ENV_ADDR=y
>> +CONFIG_DM=y
>> +CONFIG_CLK=y
>> +CONFIG_CLK_CCF=y
>> +CONFIG_CLK_AT91=y
>> +CONFIG_AT91_UTMI=y
>> +CONFIG_AT91_GENERIC_CLK=y
>> +CONFIG_AT91_SAM9X60_PLL=y
>> +CONFIG_CPU=y
>> +CONFIG_ATMEL_PIO4=y
>> +CONFIG_DM_I2C=y
>> +CONFIG_DM_MMC=y
>> +CONFIG_MMC_SDHCI=y
>> +CONFIG_MMC_SDHCI_ATMEL=y
>> +CONFIG_PHY_MICREL=y
>> +CONFIG_PHY_MICREL_KSZ90X1=y
>> +CONFIG_DM_ETH=y
>> +CONFIG_MACB=y
>> +CONFIG_PINCTRL=y
>> +CONFIG_PINCTRL_AT91PIO4=y
>> +CONFIG_DM_SERIAL=y
>> +CONFIG_DEBUG_UART_ANNOUNCE=y
>> +CONFIG_ATMEL_USART=y
>> +CONFIG_TI

Please convert last remaining file to UTF-8 encoding

2020-12-03 Thread Nicolas Boulenguez
Hello.
Please convert last remaining file to UTF-8 encoding
A trivial patch is attached.
Thanks.
>From 38cde811be6878d9a6d10ae88980e0af55a31418 Mon Sep 17 00:00:00 2001
From: Nicolas Boulenguez 
Date: Thu, 3 Dec 2020 15:22:58 +0100
Subject: [PATCH] Convert last remaining file to UTF-8 encoding

---
 arch/arm/dts/sun4i-a10-inet97fv2.dts | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/dts/sun4i-a10-inet97fv2.dts b/arch/arm/dts/sun4i-a10-inet97fv2.dts
index 5d096528e7..71c27ea0b5 100644
--- a/arch/arm/dts/sun4i-a10-inet97fv2.dts
+++ b/arch/arm/dts/sun4i-a10-inet97fv2.dts
@@ -1,7 +1,7 @@
 /*
  * Copyright 2014 Open Source Support GmbH
  *
- * David Lanzendörfer 
+ * David Lanzendörfer 
  *
  * This file is dual-licensed: you can use it either under the terms
  * of the GPL or the X11 license, at your option. Note that this dual
-- 
2.20.1



Re: [PATCH 29/34] configs: sama7g5: add mmc config for sdmmc0

2020-12-03 Thread Eugen.Hristev
On 03.12.2020 13:11, Jaehoon Chung wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the 
> content is safe
> 
> On 12/3/20 7:47 PM, eugen.hris...@microchip.com wrote:
>> On 03.12.2020 12:38, Jaehoon Chung wrote:
>>> Hi,
>>>
>>> On 12/3/20 6:28 PM, Eugen Hristev wrote:
 Add new config for storing environment from sdmmc0.
 Also clean-up sama7g5ek_emmc1 to point to the proper mmc device.
>>>
>>> Just one question, Sorry, i didn't check entire patchset.
>>>
>>> What is different between sama7g5ek_mmc1 and sama7g5ek_mmc?
>>
>> Sama7g5ek_mmc is set to store the environment in the eMMC device
>> soldered on the board which is connected on the SDMMC0 hardware block.
>>
>> sama7g5ek_mmc1 is set to store the environment on the SD-Card which can
>> be inserted in the SD slot on the board which is connected on the SDMMC1
>> hardware block.
>>
>> So basically we have two possible boot/env store configurations, one on
>> eMMC and one on SD-Card .
> 
> If device can know which device is used to boot, then i think that it doesn't 
> need to add one more config.
> It can know where env is stored at runtime.
> (with CONFIG_ENV_FAT_DEVICE_AND_PART ":" and implement 
> mmc_get_env_dev())
> 

Can you explain a little more ? I do not understand how.
How will u-boot know if it should read the env from SD or eMMC ?

> 
> commit 6731bef6966ea2b26cdcfe0109ff5a950003fd03
> Refs: v2020.07-1080-g6731bef696
> Author: David Woodhouse 
> AuthorDate: Fri Jun 19 23:07:17 2020 +0100
> Commit: Tom Rini 
> CommitDate: Sun Jul 26 14:35:12 2020 -0400
> 
>  env/fat.c: allow loading from a FAT partition on the MMC boot device
> 
>  I don't want to have to specify the device; only the partition.
> 
>  This allows me to use the same image on internal eMMC or SD card for
>  Banana Pi R2, and it finds its own environment either way.
> 
>  Signed-off-by: David Woodhouse 
>  [trini: Add #if/#else/#endif logic around CONFIG_SYS_MMC_ENV_DEV usage,
>  whitespace changes]
>  Signed-off-by: Tom Rini 
> 
> 
> Best Regards,
> Jaehoon Chung
> 
>>
>> Eugen
>>>
>>> Best Regards,
>>> Jaehoon Chung
>>>

 Signed-off-by: Eugen Hristev 
 ---
board/atmel/sama7g5ek/MAINTAINERS |  1 +
configs/sama7g5ek_mmc1_defconfig  |  7 ++--
configs/sama7g5ek_mmc_defconfig   | 67 +++
3 files changed, 72 insertions(+), 3 deletions(-)
create mode 100644 configs/sama7g5ek_mmc_defconfig

 diff --git a/board/atmel/sama7g5ek/MAINTAINERS 
 b/board/atmel/sama7g5ek/MAINTAINERS
 index f66953ac4e..eac972968d 100644
 --- a/board/atmel/sama7g5ek/MAINTAINERS
 +++ b/board/atmel/sama7g5ek/MAINTAINERS
 @@ -4,4 +4,5 @@ S: Maintained
F: board/atmel/sama7g5ek.c
F: include/configs/sama7g5ek.h
F: configs/sama7g5ek_mmc1_defconfig
 +F: configs/sama7g5ek_mmc_defconfig

 diff --git a/configs/sama7g5ek_mmc1_defconfig 
 b/configs/sama7g5ek_mmc1_defconfig
 index fa4c88ffa6..b6d2f4dd05 100644
 --- a/configs/sama7g5ek_mmc1_defconfig
 +++ b/configs/sama7g5ek_mmc1_defconfig
 @@ -2,9 +2,10 @@ CONFIG_ARM=y
CONFIG_ARCH_AT91=y
CONFIG_SYS_TEXT_BASE=0x66f0
CONFIG_TARGET_SAMA7G5EK=y
 -CONFIG_NR_DRAM_BANKS=1
CONFIG_SYS_MALLOC_F_LEN=0x11000
 +CONFIG_NR_DRAM_BANKS=1
CONFIG_ENV_SIZE=0x4000
 +CONFIG_DM_GPIO=y
CONFIG_DEBUG_UART_BOARD_INIT=y
CONFIG_DEBUG_UART_BASE=0xe1824200
CONFIG_DEBUG_UART_CLOCK=2
 @@ -14,6 +15,7 @@ CONFIG_ENV_VARS_UBOOT_CONFIG=y
CONFIG_FIT=y
CONFIG_SD_BOOT=y
CONFIG_USE_BOOTARGS=y
 +CONFIG_BOOTARGS="console=ttyS0,115200 root=/dev/mmcblk1p2 rw rootwait"
CONFIG_MISC_INIT_R=y
CONFIG_HUSH_PARSER=y
CONFIG_CMD_BOOTZ=y
 @@ -35,6 +37,7 @@ CONFIG_CMD_EXT4=y
CONFIG_CMD_FAT=y
CONFIG_OF_CONTROL=y
CONFIG_ENV_IS_IN_FAT=y
 +CONFIG_ENV_FAT_DEVICE_AND_PART="1:1"
CONFIG_SYS_RELOC_GD_ENV_ADDR=y
CONFIG_DM=y
CONFIG_CLK=y
 @@ -44,7 +47,6 @@ CONFIG_AT91_UTMI=y
CONFIG_AT91_GENERIC_CLK=y
CONFIG_AT91_SAM9X60_PLL=y
CONFIG_CPU=y
 -CONFIG_DM_GPIO=y
CONFIG_ATMEL_PIO4=y
CONFIG_DM_I2C=y
CONFIG_DM_MMC=y
 @@ -56,7 +58,6 @@ CONFIG_DM_ETH=y
CONFIG_MACB=y
CONFIG_PINCTRL=y
CONFIG_PINCTRL_AT91PIO4=y
 -# CONFIG_RAM_ROCKCHIP_DEBUG is not set
CONFIG_DM_SERIAL=y
CONFIG_DEBUG_UART_ANNOUNCE=y
CONFIG_ATMEL_USART=y
 diff --git a/configs/sama7g5ek_mmc_defconfig 
 b/configs/sama7g5ek_mmc_defconfig
 new file mode 100644
 index 00..894a64983f
 --- /dev/null
 +++ b/configs/sama7g5ek_mmc_defconfig
 @@ -0,0 +1,67 @@
 +CONFIG_ARM=y
 +CONFIG_ARCH_AT91=y
 +CONFIG_SYS_TEXT_BASE=0x66f0
 +CONFIG_TARGET_SAMA7G5EK=y
 +CONFIG_SYS_MALLOC_F_LE

[PATCH v1 1/3] f_rockusb: Use NULL instead of 0 for pointers

2020-12-03 Thread Andy Shevchenko
get_rkusb() mistakenly uses integers without cast.
Convert them to proper type.

Signed-off-by: Andy Shevchenko 
---
 drivers/usb/gadget/f_rockusb.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/gadget/f_rockusb.c b/drivers/usb/gadget/f_rockusb.c
index 9ae02ae78c1e..9dd10f9e9aa1 100644
--- a/drivers/usb/gadget/f_rockusb.c
+++ b/drivers/usb/gadget/f_rockusb.c
@@ -110,7 +110,7 @@ struct f_rockusb *get_rkusb(void)
if (!f_rkusb) {
f_rkusb = memalign(CONFIG_SYS_CACHELINE_SIZE, sizeof(*f_rkusb));
if (!f_rkusb)
-   return 0;
+   return NULL;
 
rockusb_func = f_rkusb;
memset(f_rkusb, 0, sizeof(*f_rkusb));
@@ -120,7 +120,7 @@ struct f_rockusb *get_rkusb(void)
f_rkusb->buf_head = memalign(CONFIG_SYS_CACHELINE_SIZE,
 RKUSB_BUF_SIZE);
if (!f_rkusb->buf_head)
-   return 0;
+   return NULL;
 
f_rkusb->buf = f_rkusb->buf_head;
memset(f_rkusb->buf_head, 0, RKUSB_BUF_SIZE);
-- 
2.29.2



[PATCH v1 2/3] f_rockusb: Avoid use-after-free in the global pointer variable

2020-12-03 Thread Andy Shevchenko
In case of usb_add_function() failure the error path has two issues:
 - the potentially allocated structure isn't getting freed
 - the global pointer variable is assigned to garbage

Fix the above mentioned issues by freeing memory and assigning NULL.

Signed-off-by: Andy Shevchenko 
---
 drivers/usb/gadget/f_rockusb.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/f_rockusb.c b/drivers/usb/gadget/f_rockusb.c
index 9dd10f9e9aa1..bd846ce9a77b 100644
--- a/drivers/usb/gadget/f_rockusb.c
+++ b/drivers/usb/gadget/f_rockusb.c
@@ -309,8 +309,9 @@ static int rockusb_add(struct usb_configuration *c)
 
status = usb_add_function(c, &f_rkusb->usb_function);
if (status) {
+   free(f_rkusb->buf_head);
free(f_rkusb);
-   rockusb_func = f_rkusb;
+   rockusb_func = NULL;
}
return status;
 }
-- 
2.29.2



[PATCH v1 3/3] f_fastboot: Avoid use-after-free in the global pointer variable

2020-12-03 Thread Andy Shevchenko
In case of usb_add_function() failure the error path has an issue,
i.e the global pointer variable is assigned to garbage

Fix the above mentioned issue by assigning pointer to NULL.

Signed-off-by: Andy Shevchenko 
---
 drivers/usb/gadget/f_fastboot.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c
index d1d087e12b2b..d0d865cf3d08 100644
--- a/drivers/usb/gadget/f_fastboot.c
+++ b/drivers/usb/gadget/f_fastboot.c
@@ -315,7 +315,7 @@ static int fastboot_add(struct usb_configuration *c)
status = usb_add_function(c, &f_fb->usb_function);
if (status) {
free(f_fb);
-   fastboot_func = f_fb;
+   fastboot_func = NULL;
}
 
return status;
-- 
2.29.2



[PATCH v1] x86: edison: BINMAN selection is specific to the board

2020-12-03 Thread Andy Shevchenko
The platforms based on Intel Tangier may have different requirements
how to create bootloader bundle to supply to a device. Currently
the BINMAN approach is for Intel Edison only.

Signed-off-by: Andy Shevchenko 
---
 arch/x86/cpu/tangier/Kconfig | 1 -
 board/intel/edison/Kconfig   | 1 +
 2 files changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/cpu/tangier/Kconfig b/arch/x86/cpu/tangier/Kconfig
index 571470c74b28..d2b7edecd604 100644
--- a/arch/x86/cpu/tangier/Kconfig
+++ b/arch/x86/cpu/tangier/Kconfig
@@ -12,7 +12,6 @@ config INTEL_TANGIER
imply MMC_SDHCI_TANGIER
imply USB
imply USB_DWC3
-   imply BINMAN
 
 if INTEL_TANGIER
 
diff --git a/board/intel/edison/Kconfig b/board/intel/edison/Kconfig
index 05d65445e407..23b2af4821d8 100644
--- a/board/intel/edison/Kconfig
+++ b/board/intel/edison/Kconfig
@@ -31,5 +31,6 @@ config BOARD_SPECIFIC_OPTIONS # dummy
select INTEL_TANGIER
select BOARD_LATE_INIT
select MD5
+   imply BINMAN
 
 endif
-- 
2.29.2



Re: [PATCH 4/4] arm: mvebu: Espressobin: Detect presence of emmc at runtime

2020-12-03 Thread Pali Rohár
On Wednesday 02 December 2020 15:35:08 Andre Heider wrote:
> On 25/11/2020 19:20, Pali Rohár wrote:
> > Try to initialize emmc in board_late_init() and if it fails then we know
> > that emmc device is not connected.
> > 
> > This allows to use in U-Boot just one DTS file for all Espressobin variants
> > and also to correctly set fdtfile env variable for Linux kernel.
> > 
> > Signed-off-by: Pali Rohár 
> > Tested-by: Gérald Kerma 
> 
> Small nit below, with that:
> Reviewed-by: Andre Heider 
> 
> > ---
> >   board/Marvell/mvebu_armada-37xx/board.c | 6 +-
> >   1 file changed, 5 insertions(+), 1 deletion(-)
> > 
> > diff --git a/board/Marvell/mvebu_armada-37xx/board.c 
> > b/board/Marvell/mvebu_armada-37xx/board.c
> > index 73d69e0388..f67b04b78c 100644
> > --- a/board/Marvell/mvebu_armada-37xx/board.c
> > +++ b/board/Marvell/mvebu_armada-37xx/board.c
> > @@ -8,6 +8,7 @@
> >   #include 
> >   #include 
> >   #include 
> > +#include 
> >   #include 
> >   #include 
> >   #include 
> > @@ -83,6 +84,7 @@ int board_init(void)
> >   #ifdef CONFIG_BOARD_LATE_INIT
> >   int board_late_init(void)
> >   {
> > +   struct mmc *mmc_dev;
> > bool ddr4, emmc;
> > if (env_get("fdtfile"))
> > @@ -95,7 +97,9 @@ int board_late_init(void)
> > ddr4 = ((readl(A3700_CH0_MC_CTRL2_REG) >> 
> > A3700_MC_CTRL2_SDRAM_TYPE_OFFS)
> > & A3700_MC_CTRL2_SDRAM_TYPE_MASK) == 
> > A3700_MC_CTRL2_SDRAM_TYPE_DDR4;
> > -   emmc = of_machine_is_compatible("globalscale,espressobin-emmc");
> > +   /* eMMC is mmc dev num 1 */
> > +   mmc_dev = find_mmc_device(1);
> > +   emmc = (mmc_dev && mmc_init(mmc_dev) == 0);
> 
> I think you meant "mmc_dev && (mmc_init(mmc_dev) == 0);"?

Hm... no... I usually do not put parenthesis around || and && operators.

But both variants are same right?

If U-Boot coding style prefers second (your) variant, I do not have
a problem to change it.

Stefan, do you need to change this styling?

> > if (ddr4 && emmc)
> > env_set("fdtfile", 
> > "marvell/armada-3720-espressobin-v7-emmc.dtb");
> > 
> 


[PATCH] Missing regulator-init-microvolt in rk3399-firefly-u-boot.dtsi

2020-12-03 Thread Piotr Lobacz
Missing of this regulator caused the kernel to stop on loading pwm-regulator
and rk808-regulator modules.

--- ../u-boot-master.orig/arch/arm/dts/rk3399-firefly-u-boot.dtsi   
2020-11-26
15:30:37.972005178 +0100
+++ ../u-boot-master/arch/arm/dts/rk3399-firefly-u-boot.dtsi2020-12-03
16:39:42.843959966 +0100
@@ -11,3 +11,7 @@
u-boot,spl-boot-order = "same-as-spl", &sdhci, &sdmmc;
};
 };
+
+&vdd_log {
+regulator-init-microvolt = <110>;
+};



--
Sent from: http://u-boot.10912.n7.nabble.com/


[PATCH v1 1/2] x86: edison: Use dwc3-generic driver for Intel Edison

2020-12-03 Thread Andy Shevchenko
Use generic Synopsys DesignWare 3 driver on Intel Edison.
For now it's just a stub which allows future refactoring.

Signed-off-by: Andy Shevchenko 
---
 arch/x86/cpu/tangier/Kconfig| 3 +++
 arch/x86/dts/edison.dts | 4 
 drivers/usb/dwc3/dwc3-generic.c | 1 +
 3 files changed, 8 insertions(+)

diff --git a/arch/x86/cpu/tangier/Kconfig b/arch/x86/cpu/tangier/Kconfig
index d2b7edecd604..94d9d74a325c 100644
--- a/arch/x86/cpu/tangier/Kconfig
+++ b/arch/x86/cpu/tangier/Kconfig
@@ -10,8 +10,11 @@ config INTEL_TANGIER
imply MMC_SDHCI
imply MMC_SDHCI_SDMA
imply MMC_SDHCI_TANGIER
+   imply MISC
imply USB
+   imply USB_XHCI_HCD
imply USB_DWC3
+   imply USB_DWC3_GENERIC
 
 if INTEL_TANGIER
 
diff --git a/arch/x86/dts/edison.dts b/arch/x86/dts/edison.dts
index 97cc6ec386c2..600d6d256246 100644
--- a/arch/x86/dts/edison.dts
+++ b/arch/x86/dts/edison.dts
@@ -105,6 +105,10 @@
reg = <0xff009000 0x1000>;
};
 
+   usb: usb@f910 {
+   compatible = "intel,tangier-dwc3";
+   };
+
watchdog: wdt@0 {
compatible = "intel,tangier-wdt";
};
diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c
index a936f71d2e5d..222358d39593 100644
--- a/drivers/usb/dwc3/dwc3-generic.c
+++ b/drivers/usb/dwc3/dwc3-generic.c
@@ -449,6 +449,7 @@ static const struct udevice_id dwc3_glue_ids[] = {
{ .compatible = "rockchip,rk3328-dwc3" },
{ .compatible = "rockchip,rk3399-dwc3" },
{ .compatible = "qcom,dwc3" },
+   { .compatible = "intel,tangier-dwc3" },
{ }
 };
 
-- 
2.29.2



[PATCH v1 2/2] x86: edison: Switch to DM_USB_GADGET

2020-12-03 Thread Andy Shevchenko
DM is the modern default approach for the drivers in U-Boot.
It also allows to configure code via Device Tree.

Move Intel Edison to use DM_USB_GADGET and drop hard coded values.

Signed-off-by: Andy Shevchenko 
---
 arch/x86/dts/edison.dts |  8 
 board/intel/edison/edison.c | 35 ---
 configs/edison_defconfig|  1 +
 3 files changed, 9 insertions(+), 35 deletions(-)

diff --git a/arch/x86/dts/edison.dts b/arch/x86/dts/edison.dts
index 600d6d256246..8d245bffc2f3 100644
--- a/arch/x86/dts/edison.dts
+++ b/arch/x86/dts/edison.dts
@@ -107,6 +107,14 @@
 
usb: usb@f910 {
compatible = "intel,tangier-dwc3";
+   #address-cells = <1>;
+   #size-cells = <1>;
+
+   dwc3: dwc3 {
+   reg = <0xf910 0x10>;
+   maximum-speed = "high-speed";
+   dr_mode = "peripheral";
+   };
};
 
watchdog: wdt@0 {
diff --git a/board/intel/edison/edison.c b/board/intel/edison/edison.c
index 652f9755155f..11e7f74e47cc 100644
--- a/board/intel/edison/edison.c
+++ b/board/intel/edison/edison.c
@@ -3,15 +3,10 @@
  * Copyright (c) 2017 Intel Corporation
  */
 #include 
-#include 
 #include 
 #include 
 #include 
 #include 
-#include 
-#include 
-
-#include 
 
 #include 
 #include 
@@ -27,36 +22,6 @@ int board_early_init_r(void)
return 0;
 }
 
-static struct dwc3_device dwc3_device_data = {
-   .maximum_speed = USB_SPEED_HIGH,
-   .base = CONFIG_SYS_USB_OTG_BASE,
-   .dr_mode = USB_DR_MODE_PERIPHERAL,
-   .index = 0,
-};
-
-int usb_gadget_handle_interrupts(int controller_index)
-{
-   dwc3_uboot_handle_interrupt(controller_index);
-   WATCHDOG_RESET();
-   return 0;
-}
-
-int board_usb_init(int index, enum usb_init_type init)
-{
-   if (index == 0 && init == USB_INIT_DEVICE)
-   return dwc3_uboot_init(&dwc3_device_data);
-   return -EINVAL;
-}
-
-int board_usb_cleanup(int index, enum usb_init_type init)
-{
-   if (index == 0 && init == USB_INIT_DEVICE) {
-   dwc3_uboot_exit(index);
-   return 0;
-   }
-   return -EINVAL;
-}
-
 static void assign_serial(void)
 {
struct mmc *mmc = find_mmc_device(0);
diff --git a/configs/edison_defconfig b/configs/edison_defconfig
index ab2811eca9dc..304a172a1b9f 100644
--- a/configs/edison_defconfig
+++ b/configs/edison_defconfig
@@ -37,6 +37,7 @@ CONFIG_DFU_TIMEOUT=y
 CONFIG_DFU_MMC=y
 CONFIG_DFU_RAM=y
 CONFIG_SUPPORT_EMMC_BOOT=y
+CONFIG_DM_USB_GADGET=y
 CONFIG_USB_GADGET=y
 CONFIG_USB_GADGET_MANUFACTURER="Intel"
 CONFIG_USB_GADGET_VENDOR_NUM=0x8087
-- 
2.29.2



Re: [PATCH 4/4] arm: mvebu: Espressobin: Detect presence of emmc at runtime

2020-12-03 Thread Stefan Roese

On 03.12.20 16:56, Pali Rohár wrote:

On Wednesday 02 December 2020 15:35:08 Andre Heider wrote:

On 25/11/2020 19:20, Pali Rohár wrote:

Try to initialize emmc in board_late_init() and if it fails then we know
that emmc device is not connected.

This allows to use in U-Boot just one DTS file for all Espressobin variants
and also to correctly set fdtfile env variable for Linux kernel.

Signed-off-by: Pali Rohár 
Tested-by: Gérald Kerma 


Small nit below, with that:
Reviewed-by: Andre Heider 


---
   board/Marvell/mvebu_armada-37xx/board.c | 6 +-
   1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/board/Marvell/mvebu_armada-37xx/board.c 
b/board/Marvell/mvebu_armada-37xx/board.c
index 73d69e0388..f67b04b78c 100644
--- a/board/Marvell/mvebu_armada-37xx/board.c
+++ b/board/Marvell/mvebu_armada-37xx/board.c
@@ -8,6 +8,7 @@
   #include 
   #include 
   #include 
+#include 
   #include 
   #include 
   #include 
@@ -83,6 +84,7 @@ int board_init(void)
   #ifdef CONFIG_BOARD_LATE_INIT
   int board_late_init(void)
   {
+   struct mmc *mmc_dev;
bool ddr4, emmc;
if (env_get("fdtfile"))
@@ -95,7 +97,9 @@ int board_late_init(void)
ddr4 = ((readl(A3700_CH0_MC_CTRL2_REG) >> 
A3700_MC_CTRL2_SDRAM_TYPE_OFFS)
& A3700_MC_CTRL2_SDRAM_TYPE_MASK) == 
A3700_MC_CTRL2_SDRAM_TYPE_DDR4;
-   emmc = of_machine_is_compatible("globalscale,espressobin-emmc");
+   /* eMMC is mmc dev num 1 */
+   mmc_dev = find_mmc_device(1);
+   emmc = (mmc_dev && mmc_init(mmc_dev) == 0);


I think you meant "mmc_dev && (mmc_init(mmc_dev) == 0);"?


Hm... no... I usually do not put parenthesis around || and && operators.

But both variants are same right?


Yours still has parenthesis around the (a && b) part, which is not
needed. But this is nitpicking AFAIAC.


If U-Boot coding style prefers second (your) variant, I do not have
a problem to change it.


checkpatch should complain if something does not match the coding style.


Stefan, do you need to change this styling?


No, not from my point of view.

Thanks,
Stefan


Re: [PATCH] remove obsolete option CONFIG_JFFS2_CMDLINE

2020-12-03 Thread Tom Rini
On Thu, Nov 05, 2020 at 10:15:37AM +0100, Holger Brunck wrote:

> This option is obsolete since 2009 and can be removed globally.
> 
> CC: Stefan Roese 
> Signed-off-by: Holger Brunck 
> Reviewed-by: Stefan Roese 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH] km/common: remove CONFIG_MTD_CONCAT

2020-12-03 Thread Tom Rini
On Thu, Nov 05, 2020 at 10:28:51AM +0100, Holger Brunck wrote:

> This was used for a board which is not supproted anymore and can
> therefore be dropped.
> 
> CC: Stefan Roese 
> Signed-off-by: Holger Brunck 
> Reviewed-by: Stefan Roese 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v2] common: update: fix an "unused" warning against update_flash()

2020-12-03 Thread Tom Rini
On Thu, Nov 19, 2020 at 09:37:19AM +0900, AKASHI Takahiro wrote:

> Since update_flash() is used only in update_tftp(), it should be
> guarded with appropriate config options.
> 
> After the commit 3149e524fc1e, common/update.c will be built under
> either CONFIG_UDATE_TFTP, CONFIG_DFU_TFTP or CONFIG_UPDATE_FIT.
> Since CONFIG_UPDATE_FIT, hence fit_update(), doesn't rely on
> update_flash(), the compiler may cause an "unused" warning if
> CONFIG_UPDATE_FIT=y and CONFIG_UPDATE_TFTP=n and CONFIG_DFU_TFTP=n.
> 
> This is, for example, the case for sandbox defconfig where
> EFI_CAPSULE_FIRMWARE_FIT is enabled for test purpose.
> 
> Fixes: 3149e524fc1e ("common: update: add a generic interface for FIT
>image")
> Signed-off-by: AKASHI Takahiro 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v1] linux/compat.h: Remove debug() from spin_lock_irqsave()

2020-12-03 Thread Tom Rini
On Thu, Nov 19, 2020 at 09:26:20PM +0200, Andy Shevchenko wrote:

> It seems nobody tested the debug() option in spin_lock_irqsave().
> Currently, when #define DEBUG, it spoils the compiler with
> 
> In file included from drivers/usb/dwc3/gadget.c:18:
> drivers/usb/dwc3/gadget.c: In function ‘dwc3_gadget_set_selfpowered’:
> include/log.h:235:4: warning: ‘flags’ is used uninitialized in this function 
> [-Wuninitialized]
>   235 |printf(pr_fmt(fmt), ##args); \
>   |^~
> drivers/usb/dwc3/gadget.c:1347:17: note: ‘flags’ was declared here
>  1347 |  unsigned long  flags;
>   | ^
> 
> and so on...
> Drop useless debug() call to make compiler happy.
> 
> Fixes: 0c06db598367 ("lib, linux: move linux specific defines to 
> linux/compat.h")
> Cc: Heiko Schocher 
> Cc: Tom Rini 
> Signed-off-by: Andy Shevchenko 
> Reviewed-by: Oleksandr Andrushchenko 
> Reviewed-by: Heiko Schocher 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH] fs/squashfs: sqfs_close/sqfs_read_sblk: set ctxt.sblk to NULL after free

2020-12-03 Thread Tom Rini
On Tue, Nov 24, 2020 at 06:07:52PM +0100, Richard Genoud wrote:

> This will prevent a double free error if sqfs_close() is called twice.
> 
> Signed-off-by: Richard Genoud 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH] watchdog: sbsa: timeout should be in "millisecond"

2020-12-03 Thread Tom Rini
On Wed, Nov 25, 2020 at 12:55:47PM +0800, Qiang Zhao wrote:

> From: Zhao Qiang 
> 
> timeout should be in "millisecond" instead of second,
> so divided it by 1000 when calculate the load value.
> 
> Signed-off-by: Zhao Qiang 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH 1/2] log: Fix comment for LOGC_BOOT

2020-12-03 Thread Tom Rini
On Sun, Nov 29, 2020 at 05:07:04PM -0700, Simon Glass wrote:

> This comment is in the wrong format, so reports an error with
> 'make htmldocs'. Fix it.
> 
> Fixes: b73d61a5565 ("x86: zimage: Add a little more logging")
> Signed-off-by: Simon Glass 
> Reviewed-by: Heinrich Schuchardt 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH 1/1] log: typos in include/log.h

2020-12-03 Thread Tom Rini
On Mon, Nov 30, 2020 at 09:04:48AM +0100, Heinrich Schuchardt wrote:

> Correct several typos.
> 
> Signed-off-by: Heinrich Schuchardt 
> Reviewed-by: Simon Glass 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH 1/1] MAINTAINERS: assign include/log.h

2020-12-03 Thread Tom Rini
On Mon, Nov 30, 2020 at 09:08:12AM +0100, Heinrich Schuchardt wrote:

> include/log.h belongs to LOGGING.
> 
> Signed-off-by: Heinrich Schuchardt 
> Reviewed-by: Simon Glass 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH 2/2] global_data: Fix comment for dm_driver_rt

2020-12-03 Thread Tom Rini
On Sun, Nov 29, 2020 at 05:07:05PM -0700, Simon Glass wrote:

> This comment is in the wrong format, so reports an error with
> 'make htmldocs'. Fix it.
> 
> Fixes: a294ead8d25 ("dm: Use an allocated array for run-time device info")
> Signed-off-by: Simon Glass 
> Reviewed-by: Heinrich Schuchardt 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH] mtd: spi-nor-ids: add Winbond W25Q32JW-IM flash

2020-12-03 Thread Tom Rini
On Tue, Dec 01, 2020 at 12:12:39AM +0100, Michael Walle wrote:

> The Kontron SMARC-sAL28 board uses that flash.
> 
> This is the same change as in the linux commit f3418718c0ec ("mtd:
> spi-nor: Add support for w25q32jwm").
> 
> Signed-off-by: Michael Walle 
> Reported-by: Leo Krueger 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: Please convert last remaining file to UTF-8 encoding

2020-12-03 Thread Tom Rini
On Thu, Dec 03, 2020 at 03:27:44PM +0100, Nicolas Boulenguez wrote:

> Hello.
> Please convert last remaining file to UTF-8 encoding
> A trivial patch is attached.
> Thanks.

> From 38cde811be6878d9a6d10ae88980e0af55a31418 Mon Sep 17 00:00:00 2001
> From: Nicolas Boulenguez 
> Date: Thu, 3 Dec 2020 15:22:58 +0100
> Subject: [PATCH] Convert last remaining file to UTF-8 encoding
> 
> ---
>  arch/arm/dts/sun4i-a10-inet97fv2.dts | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/arm/dts/sun4i-a10-inet97fv2.dts 
> b/arch/arm/dts/sun4i-a10-inet97fv2.dts
> index 5d096528e7..71c27ea0b5 100644
> --- a/arch/arm/dts/sun4i-a10-inet97fv2.dts
> +++ b/arch/arm/dts/sun4i-a10-inet97fv2.dts
> @@ -1,7 +1,7 @@
>  /*
>   * Copyright 2014 Open Source Support GmbH
>   *
> - * David Lanzend?rfer 
> + * David Lanzendörfer 
>   *
>   * This file is dual-licensed: you can use it either under the terms
>   * of the GPL or the X11 license, at your option. Note that this dual

As this comes from the Linux kernel, has it been corrected there?
Thanks!

-- 
Tom


signature.asc
Description: PGP signature


[scan-ad...@coverity.com: New Defects reported by Coverity Scan for Das U-Boot]

2020-12-03 Thread Tom Rini
This latest run also closed a number of open defects (the CIDs of which
are sadly not in the summary).

- Forwarded message from scan-ad...@coverity.com -

Date: Mon, 30 Nov 2020 18:33:34 + (UTC)
From: scan-ad...@coverity.com
To: tom.r...@gmail.com
Subject: New Defects reported by Coverity Scan for Das U-Boot

Hi,

Please find the latest report on new defect(s) introduced to Das U-Boot found 
with Coverity Scan.

5 new defect(s) introduced to Das U-Boot found with Coverity Scan.
17 defect(s), reported by Coverity Scan earlier, were marked fixed in the 
recent build analyzed by Coverity Scan.

New defect(s) Reported-by: Coverity Scan
Showing 5 of 5 defect(s)


** CID 313548:  Uninitialized variables  (UNINIT)
/drivers/mmc/mmc.c: 2194 in mmc_select_mode_and_width()



*** CID 313548:  Uninitialized variables  (UNINIT)
/drivers/mmc/mmc.c: 2194 in mmc_select_mode_and_width()
2188   EXT_CSD_BUS_WIDTH, 
EXT_CSD_BUS_WIDTH_1);
2189mmc_select_mode(mmc, MMC_LEGACY);
2190mmc_set_bus_width(mmc, 1);
2191}
2192}
2193 
>>> CID 313548:  Uninitialized variables  (UNINIT)
>>> Using uninitialized value "err" when calling "printf".
2194pr_err("unable to select a mode : %d\n", err);
2195 
2196return -ENOTSUPP;
2197 }
2198 #endif
2199 

** CID 313547:  Null pointer dereferences  (FORWARD_NULL)
/fs/squashfs/sqfs.c: 953 in sqfs_opendir()



*** CID 313547:  Null pointer dereferences  (FORWARD_NULL)
/fs/squashfs/sqfs.c: 953 in sqfs_opendir()
947 dirs->table += SQFS_DIR_HEADER_SIZE;
948 
949 *dirsp = (struct fs_dir_stream *)dirs;
950 
951 out:
952 for (j = 0; j < token_count; j++)
>>> CID 313547:  Null pointer dereferences  (FORWARD_NULL)
>>> Dereferencing null pointer "token_list".
953 free(token_list[j]);
954 free(token_list);
955 free(pos_list);
956 free(path);
957 if (ret) {
958 free(inode_table);

** CID 313546:  Null pointer dereferences  (FORWARD_NULL)
/fs/squashfs/sqfs.c: 1605 in sqfs_size()



*** CID 313546:  Null pointer dereferences  (FORWARD_NULL)
/fs/squashfs/sqfs.c: 1605 in sqfs_size()
1599printf("File not found.\n");
1600*size = 0;
1601ret = -EINVAL;
1602goto free_strings;
1603}
1604 
>>> CID 313546:  Null pointer dereferences  (FORWARD_NULL)
>>> Dereferencing null pointer "dirs->entry".
1605i_number = dirs->dir_header->inode_number + 
dirs->entry->inode_offset;
1606ipos = sqfs_find_inode(dirs->inode_table, i_number, 
sblk->inodes,
1607   sblk->block_size);
1608free(dirs->entry);
1609dirs->entry = NULL;
1610 

** CID 313545:(FORWARD_NULL)
/fs/squashfs/sqfs.c: 516 in sqfs_search_dir()
/fs/squashfs/sqfs.c: 516 in sqfs_search_dir()



*** CID 313545:(FORWARD_NULL)
/fs/squashfs/sqfs.c: 516 in sqfs_search_dir()
510 printf("** Cannot find directory. **\n");
511 ret = -EINVAL;
512 goto out;
513 }
514 
515 /* Redefine inode as the found token */
>>> CID 313545:(FORWARD_NULL)
>>> Dereferencing null pointer "dirs->entry".
516 new_inode_number = dirs->entry->inode_offset +
517 dirs->dir_header->inode_number;
518 
519 /* Get reference to inode in the inode table */
520 table = sqfs_find_inode(dirs->inode_table, 
new_inode_number,
521 sblk->inodes, sblk->block_size);
/fs/squashfs/sqfs.c: 516 in sqfs_search_dir()
510 printf("** Cannot find directory. **\n");
511 ret = -EINVAL;
512 goto out;
513 }
514 
515 /* Redefine inode as the found token */
>>> CID 313545:(FORWARD_NULL)
>>> Dereferencing null pointer "dirs->entry".
516 new_inode_number = dirs->entry->inode_offset +
517 dirs->dir_header->inode_number;
518 
519 /* Get reference to inode in the inode table */
520 table = sqfs_find_inode(dirs->inode_table,

Re: [PATCH v1 2/2] x86: edison: Switch to DM_USB_GADGET

2020-12-03 Thread Andy Shevchenko
On Thu, Dec 3, 2020 at 6:26 PM Andy Shevchenko
 wrote:
>
> DM is the modern default approach for the drivers in U-Boot.
> It also allows to configure code via Device Tree.
>
> Move Intel Edison to use DM_USB_GADGET and drop hard coded values.

Missed one more file to be slightly cleaned up.

I'll send v2 soon.


-- 
With Best Regards,
Andy Shevchenko


[PATCH] sunxi: dram: h6: Improve DDR3 config detection

2020-12-03 Thread Jernej Skrabec
It turns out that in rare cases, current analytical approach to detect
correct DRAM bus width and rank on H6 doesn't work. On some TV boxes
with DDR3, incorrect DRAM configuration triggers write leveling error
which immediately stops initialization process. Exact reason why this
error appears isn't known. However, if correct configuration is used,
initalization works without problem.

In order to fix this issue, simply try another configuration when any
kind of error appears during initialization, not just those related to
rank and bus width.

Tested-by: Thomas Graichen 
Signed-off-by: Jernej Skrabec 
---
 arch/arm/mach-sunxi/dram_sun50i_h6.c | 95 +++-
 1 file changed, 51 insertions(+), 44 deletions(-)

diff --git a/arch/arm/mach-sunxi/dram_sun50i_h6.c 
b/arch/arm/mach-sunxi/dram_sun50i_h6.c
index 9e34da474798..1cde6132be2c 100644
--- a/arch/arm/mach-sunxi/dram_sun50i_h6.c
+++ b/arch/arm/mach-sunxi/dram_sun50i_h6.c
@@ -37,9 +37,9 @@
 
 static void mctl_sys_init(struct dram_para *para);
 static void mctl_com_init(struct dram_para *para);
-static void mctl_channel_init(struct dram_para *para);
+static bool mctl_channel_init(struct dram_para *para);
 
-static void mctl_core_init(struct dram_para *para)
+static bool mctl_core_init(struct dram_para *para)
 {
mctl_sys_init(para);
mctl_com_init(para);
@@ -51,7 +51,7 @@ static void mctl_core_init(struct dram_para *para)
default:
panic("Unsupported DRAM type!");
};
-   mctl_channel_init(para);
+   return mctl_channel_init(para);
 }
 
 /* PHY initialisation */
@@ -411,7 +411,7 @@ static void mctl_bit_delay_set(struct dram_para *para)
}
 }
 
-static void mctl_channel_init(struct dram_para *para)
+static bool mctl_channel_init(struct dram_para *para)
 {
struct sunxi_mctl_com_reg * const mctl_com =
(struct sunxi_mctl_com_reg *)SUNXI_DRAM_COM_BASE;
@@ -528,46 +528,15 @@ static void mctl_channel_init(struct dram_para *para)
clrbits_le32(&mctl_phy->dx[i].gcr[3], ~0x3);
udelay(10);
 
-   if (readl(&mctl_phy->pgsr[0]) & 0x40)
-   {
-   /* Check for single rank and optionally half DQ. */
-   if ((readl(&mctl_phy->dx[0].rsr[0]) & 0x3) == 2 &&
-   (readl(&mctl_phy->dx[1].rsr[0]) & 0x3) == 2) {
-   para->ranks = 1;
-
-   if ((readl(&mctl_phy->dx[2].rsr[0]) & 0x3) != 2 ||
-   (readl(&mctl_phy->dx[3].rsr[0]) & 0x3) != 2)
-   para->bus_full_width = 0;
-
-   /* Restart DRAM initialization from scratch. */
-   mctl_core_init(para);
-   return;
-   }
-
-   /*
-* Check for dual rank and half DQ. NOTE: This combination
-* is highly unlikely and was not tested. Condition is the
-* same as in libdram, though.
-*/
-   if ((readl(&mctl_phy->dx[0].rsr[0]) & 0x3) == 0 &&
-   (readl(&mctl_phy->dx[1].rsr[0]) & 0x3) == 0) {
-   para->bus_full_width = 0;
-
-   /* Restart DRAM initialization from scratch. */
-   mctl_core_init(para);
-   return;
-   }
-
-   panic("This DRAM setup is currently not supported.\n");
-   }
-
if (readl(&mctl_phy->pgsr[0]) & 0xff0) {
/* Oops! There's something wrong! */
debug("PLL = %x\n", readl(0x3001010));
debug("DRAM PHY PGSR0 = %x\n", readl(&mctl_phy->pgsr[0]));
for (i = 0; i < 4; i++)
debug("DRAM PHY DX%dRSR0 = %x\n", i, 
readl(&mctl_phy->dx[i].rsr[0]));
-   panic("Error while initializing DRAM PHY!\n");
+   debug("Error while initializing DRAM PHY!\n");
+
+   return false;
}
 
if (sunxi_dram_is_lpddr(para->type))
@@ -582,13 +551,54 @@ static void mctl_channel_init(struct dram_para *para)
writel(0x, &mctl_com->maer0);
writel(0x7ff, &mctl_com->maer1);
writel(0x, &mctl_com->maer2);
+
+   return true;
+}
+
+static void mctl_auto_detect_rank_width(struct dram_para *para)
+{
+   /* this is minimum size that it's supported */
+   para->cols = 8;
+   para->rows = 13;
+
+   /*
+* Strategy here is to test most demanding combination first and least
+* demanding last, otherwise HW might not be fully utilized. For
+* example, half bus width and rank = 1 combination would also work
+* on HW with full bus width and rank = 2, but only 1/4 RAM would be
+* visible.
+*/
+
+   debug("testing 32-bit width, rank = 2\n");
+   para->bus_full_width = 1;
+   para->ranks = 2;
+   if (mctl_core_init(para))
+   return;
+
+   debug("testing 32-bi

[PATCH v2 1/2] x86: edison: Use dwc3-generic driver for Intel Edison

2020-12-03 Thread Andy Shevchenko
Use generic Synopsys DesignWare 3 driver on Intel Edison.
For now it's just a stub which allows future refactoring.

Signed-off-by: Andy Shevchenko 
---
v2: no changes
 arch/x86/cpu/tangier/Kconfig| 3 +++
 arch/x86/dts/edison.dts | 4 
 drivers/usb/dwc3/dwc3-generic.c | 1 +
 3 files changed, 8 insertions(+)

diff --git a/arch/x86/cpu/tangier/Kconfig b/arch/x86/cpu/tangier/Kconfig
index d2b7edecd604..94d9d74a325c 100644
--- a/arch/x86/cpu/tangier/Kconfig
+++ b/arch/x86/cpu/tangier/Kconfig
@@ -10,8 +10,11 @@ config INTEL_TANGIER
imply MMC_SDHCI
imply MMC_SDHCI_SDMA
imply MMC_SDHCI_TANGIER
+   imply MISC
imply USB
+   imply USB_XHCI_HCD
imply USB_DWC3
+   imply USB_DWC3_GENERIC
 
 if INTEL_TANGIER
 
diff --git a/arch/x86/dts/edison.dts b/arch/x86/dts/edison.dts
index 97cc6ec386c2..600d6d256246 100644
--- a/arch/x86/dts/edison.dts
+++ b/arch/x86/dts/edison.dts
@@ -105,6 +105,10 @@
reg = <0xff009000 0x1000>;
};
 
+   usb: usb@f910 {
+   compatible = "intel,tangier-dwc3";
+   };
+
watchdog: wdt@0 {
compatible = "intel,tangier-wdt";
};
diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c
index a936f71d2e5d..222358d39593 100644
--- a/drivers/usb/dwc3/dwc3-generic.c
+++ b/drivers/usb/dwc3/dwc3-generic.c
@@ -449,6 +449,7 @@ static const struct udevice_id dwc3_glue_ids[] = {
{ .compatible = "rockchip,rk3328-dwc3" },
{ .compatible = "rockchip,rk3399-dwc3" },
{ .compatible = "qcom,dwc3" },
+   { .compatible = "intel,tangier-dwc3" },
{ }
 };
 
-- 
2.29.2



[PATCH v2 2/2] x86: edison: Switch to DM_USB_GADGET

2020-12-03 Thread Andy Shevchenko
DM is the modern default approach for the drivers in U-Boot.
It also allows to configure code via Device Tree.

Move Intel Edison to use DM_USB_GADGET and drop hard coded values.

Signed-off-by: Andy Shevchenko 
---
v2: cleaned up arch/x86/cpu/tangier/Kconfig as well

 arch/x86/cpu/tangier/Kconfig |  4 
 arch/x86/dts/edison.dts  |  8 
 board/intel/edison/edison.c  | 35 ---
 configs/edison_defconfig |  1 +
 4 files changed, 9 insertions(+), 39 deletions(-)

diff --git a/arch/x86/cpu/tangier/Kconfig b/arch/x86/cpu/tangier/Kconfig
index 94d9d74a325c..19aaf165d6a3 100644
--- a/arch/x86/cpu/tangier/Kconfig
+++ b/arch/x86/cpu/tangier/Kconfig
@@ -29,8 +29,4 @@ config SYS_CAR_SIZE
  Space in bytes in eSRAM used as Cache-As-RAM (CAR).
  Note this size must not exceed eSRAM's total size.
 
-config SYS_USB_OTG_BASE
-   hex
-   default 0xf910
-
 endif
diff --git a/arch/x86/dts/edison.dts b/arch/x86/dts/edison.dts
index 600d6d256246..8d245bffc2f3 100644
--- a/arch/x86/dts/edison.dts
+++ b/arch/x86/dts/edison.dts
@@ -107,6 +107,14 @@
 
usb: usb@f910 {
compatible = "intel,tangier-dwc3";
+   #address-cells = <1>;
+   #size-cells = <1>;
+
+   dwc3: dwc3 {
+   reg = <0xf910 0x10>;
+   maximum-speed = "high-speed";
+   dr_mode = "peripheral";
+   };
};
 
watchdog: wdt@0 {
diff --git a/board/intel/edison/edison.c b/board/intel/edison/edison.c
index 652f9755155f..11e7f74e47cc 100644
--- a/board/intel/edison/edison.c
+++ b/board/intel/edison/edison.c
@@ -3,15 +3,10 @@
  * Copyright (c) 2017 Intel Corporation
  */
 #include 
-#include 
 #include 
 #include 
 #include 
 #include 
-#include 
-#include 
-
-#include 
 
 #include 
 #include 
@@ -27,36 +22,6 @@ int board_early_init_r(void)
return 0;
 }
 
-static struct dwc3_device dwc3_device_data = {
-   .maximum_speed = USB_SPEED_HIGH,
-   .base = CONFIG_SYS_USB_OTG_BASE,
-   .dr_mode = USB_DR_MODE_PERIPHERAL,
-   .index = 0,
-};
-
-int usb_gadget_handle_interrupts(int controller_index)
-{
-   dwc3_uboot_handle_interrupt(controller_index);
-   WATCHDOG_RESET();
-   return 0;
-}
-
-int board_usb_init(int index, enum usb_init_type init)
-{
-   if (index == 0 && init == USB_INIT_DEVICE)
-   return dwc3_uboot_init(&dwc3_device_data);
-   return -EINVAL;
-}
-
-int board_usb_cleanup(int index, enum usb_init_type init)
-{
-   if (index == 0 && init == USB_INIT_DEVICE) {
-   dwc3_uboot_exit(index);
-   return 0;
-   }
-   return -EINVAL;
-}
-
 static void assign_serial(void)
 {
struct mmc *mmc = find_mmc_device(0);
diff --git a/configs/edison_defconfig b/configs/edison_defconfig
index ab2811eca9dc..304a172a1b9f 100644
--- a/configs/edison_defconfig
+++ b/configs/edison_defconfig
@@ -37,6 +37,7 @@ CONFIG_DFU_TIMEOUT=y
 CONFIG_DFU_MMC=y
 CONFIG_DFU_RAM=y
 CONFIG_SUPPORT_EMMC_BOOT=y
+CONFIG_DM_USB_GADGET=y
 CONFIG_USB_GADGET=y
 CONFIG_USB_GADGET_MANUFACTURER="Intel"
 CONFIG_USB_GADGET_VENDOR_NUM=0x8087
-- 
2.29.2



[PATCH v2 1/6] net: macb: use dummy descriptor for RBQP

2020-12-03 Thread Claudiu Beznea
In case of multiple queues on RX side the queue scheduler
will try to use all the available configured queues (with
descriptors having TX_USED bit cleared). If at least one RBQP
points to a descriptor with a valid used bit configuration then
the reception may block as this may point to any memory. To avoid
this scenario all the queues (except queue zero) were disabled by
setting DMA descriptors with used bit set on proper RBQP. The driver
anyway uses only queue 0 for TX/RX.

Signed-off-by: Claudiu Beznea 
---
 drivers/net/macb.c | 4 +++-
 drivers/net/macb.h | 2 ++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/net/macb.c b/drivers/net/macb.c
index b80a259ff757..836eb85ec96a 100644
--- a/drivers/net/macb.c
+++ b/drivers/net/macb.c
@@ -732,8 +732,10 @@ static int gmac_init_multi_queues(struct macb_device *macb)
flush_dcache_range(macb->dummy_desc_dma, macb->dummy_desc_dma +
ALIGN(MACB_TX_DUMMY_DMA_DESC_SIZE, PKTALIGN));
 
-   for (i = 1; i < num_queues; i++)
+   for (i = 1; i < num_queues; i++) {
gem_writel_queue_TBQP(macb, macb->dummy_desc_dma, i - 1);
+   gem_writel_queue_RBQP(macb, macb->dummy_desc_dma, i - 1);
+   }
 
return 0;
 }
diff --git a/drivers/net/macb.h b/drivers/net/macb.h
index 9b16383eba46..28c7fe306883 100644
--- a/drivers/net/macb.h
+++ b/drivers/net/macb.h
@@ -768,5 +768,7 @@
 #define GEM_RX_CSUM_CHECKED_MASK   2
 #define gem_writel_queue_TBQP(port, value, queue_num)  \
writel((value), (port)->regs + GEM_TBQP(queue_num))
+#define gem_writel_queue_RBQP(port, value, queue_num)  \
+   writel((value), (port)->regs + GEM_RBQP(queue_num))
 
 #endif /* __DRIVERS_MACB_H__ */
-- 
2.7.4



[PATCH v2 2/6] net: macb: add user io config data structure

2020-12-03 Thread Claudiu Beznea
Different implementation of USER IO register needs different
mapping for bit fields of this register. Add implementation
for this and, since clken is part of USER IO and it needs to
be activated based on per SoC capabilities, add caps in
macb_config where clken specific information needs to be filled.

Signed-off-by: Claudiu Beznea 
---
 drivers/net/macb.c | 52 
 1 file changed, 40 insertions(+), 12 deletions(-)

diff --git a/drivers/net/macb.c b/drivers/net/macb.c
index 836eb85ec96a..049ade6a7470 100644
--- a/drivers/net/macb.c
+++ b/drivers/net/macb.c
@@ -135,10 +135,19 @@ struct macb_device {
 #endif
 };
 
+struct macb_usrio_cfg {
+   unsigned intmii;
+   unsigned intrmii;
+   unsigned intrgmii;
+   unsigned intclken;
+};
+
 struct macb_config {
unsigned intdma_burst_length;
+   unsigned intcaps;
 
int (*clk_init)(struct udevice *dev, ulong rate);
+   const struct macb_usrio_cfg *usrio;
 };
 
 #ifndef CONFIG_DM_ETH
@@ -773,6 +782,7 @@ static int _macb_init(struct macb_device *macb, const char 
*name)
 {
 #ifdef CONFIG_DM_ETH
struct macb_device *macb = dev_get_priv(dev);
+   unsigned int val = 0;
 #endif
unsigned long paddr;
int ret;
@@ -830,11 +840,17 @@ static int _macb_init(struct macb_device *macb, const 
char *name)
 * to select interface between RMII and MII.
 */
 #ifdef CONFIG_DM_ETH
-   if ((macb->phy_interface == PHY_INTERFACE_MODE_RMII) ||
-   (macb->phy_interface == PHY_INTERFACE_MODE_RGMII))
-   gem_writel(macb, USRIO, GEM_BIT(RGMII));
-   else
-   gem_writel(macb, USRIO, 0);
+   if (macb->phy_interface == PHY_INTERFACE_MODE_RGMII)
+   val = macb->config->usrio->rgmii;
+   else if (macb->phy_interface == PHY_INTERFACE_MODE_RMII)
+   val = macb->config->usrio->rmii;
+   else if (macb->phy_interface == PHY_INTERFACE_MODE_MII)
+   val = macb->config->usrio->mii;
+
+   if (macb->config->caps & MACB_CAPS_USRIO_HAS_CLKEN)
+   val |= macb->config->usrio->clken;
+
+   gem_writel(macb, USRIO, val);
 
if (macb->phy_interface == PHY_INTERFACE_MODE_SGMII) {
unsigned int ncfgr = macb_readl(macb, NCFGR);
@@ -844,7 +860,7 @@ static int _macb_init(struct macb_device *macb, const char 
*name)
}
 #else
 #if defined(CONFIG_RGMII) || defined(CONFIG_RMII)
-   gem_writel(macb, USRIO, GEM_BIT(RGMII));
+   gem_writel(macb, USRIO, macb->config->usrio->rgmii);
 #else
gem_writel(macb, USRIO, 0);
 #endif
@@ -855,28 +871,30 @@ static int _macb_init(struct macb_device *macb, const 
char *name)
 #ifdef CONFIG_AT91FAMILY
if (macb->phy_interface == PHY_INTERFACE_MODE_RMII) {
macb_writel(macb, USRIO,
-   MACB_BIT(RMII) | MACB_BIT(CLKEN));
+   macb->config->usrio->rmii |
+   macb->config->usrio->clken);
} else {
-   macb_writel(macb, USRIO, MACB_BIT(CLKEN));
+   macb_writel(macb, USRIO, macb->config->usrio->clken);
}
 #else
if (macb->phy_interface == PHY_INTERFACE_MODE_RMII)
macb_writel(macb, USRIO, 0);
else
-   macb_writel(macb, USRIO, MACB_BIT(MII));
+   macb_writel(macb, USRIO, macb->config->usrio->mii);
 #endif
 #else
 #ifdef CONFIG_RMII
 #ifdef CONFIG_AT91FAMILY
-   macb_writel(macb, USRIO, MACB_BIT(RMII) | MACB_BIT(CLKEN));
+   macb_writel(macb, USRIO, macb->config->usrio->rmii |
+   macb->config->usrio->clken);
 #else
macb_writel(macb, USRIO, 0);
 #endif
 #else
 #ifdef CONFIG_AT91FAMILY
-   macb_writel(macb, USRIO, MACB_BIT(CLKEN));
+   macb_writel(macb, USRIO, macb->config->usrio->clken);
 #else
-   macb_writel(macb, USRIO, MACB_BIT(MII));
+   macb_writel(macb, USRIO, macb->config->usrio->mii);
 #endif
 #endif /* CONFIG_RMII */
 #endif
@@ -1217,9 +1235,17 @@ static int macb_enable_clk(struct udevice *dev)
 }
 #endif
 
+static const struct macb_usrio_cfg macb_default_usrio = {
+   .mii = MACB_BIT(MII),
+   .rmii = MACB_BIT(RMII),
+   .rgmii = GEM_BIT(RGMII),
+   .clken = MACB_BIT(CLKEN),
+};
+
 static const struct macb_config default_gem_config = {
.dma_burst_length = 16,
.clk_init = NULL,
+   .usrio = &macb_default_usrio,
 };
 
 static int macb_eth_probe(struct udevice *dev)
@@ -1309,11 +1335,13 @@ static int macb_eth_ofdata_to_platdata(struct udevice 
*dev)
 static const struct macb_c

[PATCH v2 0/6] add support for sama7g5 ethernet interfaces

2020-12-03 Thread Claudiu Beznea
Hi,

This series add support for SAMA7G5 ethernet interfaces: one
gigabit interface and one 10/100Mbps interface.

Thank you,
Claudiu Beznea

Changes in v2:
- fix compilation error on patch 6/6 for wb50n_defconfig

Claudiu Beznea (6):
  net: macb: use dummy descriptor for RBQP
  net: macb: add user io config data structure
  net: macb: check clk_set_rate return value to be negative
  net: macb: add support for sama7g5 gmac
  net: macb: add support for sama7g5 emac
  net: macb: take into account all RGMII interface types

 drivers/net/macb.c | 101 +
 drivers/net/macb.h |   2 ++
 2 files changed, 89 insertions(+), 14 deletions(-)

-- 
2.7.4



[PATCH v2 3/6] net: macb: check clk_set_rate return value to be negative

2020-12-03 Thread Claudiu Beznea
clk_set_rate() returns the set rate in case of success and a
negative number in case of failure. Consider failure only the
negative numbers.

Fixes: 3ef6de157 ("dm: net: macb: Implement link speed change callback")
Signed-off-by: Claudiu Beznea 
---
 drivers/net/macb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/macb.c b/drivers/net/macb.c
index 049ade6a7470..241b42a6e9d3 100644
--- a/drivers/net/macb.c
+++ b/drivers/net/macb.c
@@ -564,7 +564,7 @@ int __weak macb_linkspd_cb(struct udevice *dev, unsigned 
int speed)
 
if (tx_clk.dev) {
ret = clk_set_rate(&tx_clk, rate);
-   if (ret)
+   if (ret < 0)
return ret;
}
 #endif
-- 
2.7.4



[PATCH v2 6/6] net: macb: take into account all RGMII interface types

2020-12-03 Thread Claudiu Beznea
Take into account all RGMII interface types. Depending on it
the RGMII PHY's timings are setup.

Signed-off-by: Claudiu Beznea 
---
 drivers/net/macb.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/net/macb.c b/drivers/net/macb.c
index 827f34bb172d..fe299af4d5d3 100644
--- a/drivers/net/macb.c
+++ b/drivers/net/macb.c
@@ -857,7 +857,10 @@ static int _macb_init(struct macb_device *macb, const char 
*name)
 * to select interface between RMII and MII.
 */
 #ifdef CONFIG_DM_ETH
-   if (macb->phy_interface == PHY_INTERFACE_MODE_RGMII)
+   if (macb->phy_interface == PHY_INTERFACE_MODE_RGMII ||
+   macb->phy_interface == PHY_INTERFACE_MODE_RGMII_ID ||
+   macb->phy_interface == PHY_INTERFACE_MODE_RGMII_RXID ||
+   macb->phy_interface == PHY_INTERFACE_MODE_RGMII_TXID)
val = macb->config->usrio->rgmii;
else if (macb->phy_interface == PHY_INTERFACE_MODE_RMII)
val = macb->config->usrio->rmii;
-- 
2.7.4



  1   2   >