Re: [RFC] pci: mediatek: add PCIe controller support for Filogic

2024-05-10 Thread Frank Wunderlich
Am 10. Mai 2024 15:08:19 MESZ schrieb Tom Rini :
>On Fri, May 10, 2024 at 01:57:26PM +0200, Frank Wunderlich wrote:
>
>> a gentle ping...any comments?
>
>Seems fine?

> Can we switch to OF_UPSTREAM first however?

Pulling mediatek devicetrees from linux will afaik break network in uboot for 
mt7622,7623,mt7986 and mt7988 bananapi boards because switch (mt753x) binding 
is different to linux.

regards Frank


Aw: [RFC] pci: mediatek: add PCIe controller support for Filogic

2024-05-10 Thread Frank Wunderlich
a gentle ping...any comments?

regards Frank


> Gesendet: Freitag, 12. April 2024 um 16:10 Uhr
> Von: "Frank Wunderlich" 
> An: "Tom Rini" , "Lukasz Majewski" , "Sean 
> Anderson" , "Ryder Lee" , "Weijie 
> Gao" , "Chunfeng Yun" , 
> "GSS_MTK_Uboot_upstream" , "John 
> Crispin" 
> Cc: "Frank Wunderlich" , u-boot@lists.denx.de
> Betreff: [RFC] pci: mediatek: add PCIe controller support for Filogic
>
> From: John Crispin 
>
> This adds PCIe controller support for the MediaTek Filogic family..
>
> Signed-off-by: John Crispin 
> Signed-off-by: Frank Wunderlich 
> ---
> Note for mt7988: pcie2 needs a dedicated phy which has no driver
> in uboot yet, so this pcie port is not enabled in the board device-
> trees.
>
> Note for mt7981: i have no board and have no dts nodes yet for it,
> so only clock change first.
> ---
>  arch/arm/dts/mt7986.dtsi   |  46 +++
>  arch/arm/dts/mt7988-rfb.dts|  12 +
>  arch/arm/dts/mt7988-sd-rfb.dts |  12 +
>  arch/arm/dts/mt7988.dtsi   | 164 +++
>  drivers/clk/mediatek/clk-mt7986.c  |   5 +-
>  drivers/pci/Kconfig|   7 +
>  drivers/pci/Makefile   |   1 +
>  drivers/pci/pcie_mediatek_gen3.c   | 382 +
>  include/dt-bindings/clock/mt7981-clk.h |   3 +-
>  include/dt-bindings/clock/mt7986-clk.h |   3 +-
>  10 files changed, 631 insertions(+), 4 deletions(-)
>  create mode 100644 drivers/pci/pcie_mediatek_gen3.c
>
> diff --git a/arch/arm/dts/mt7986.dtsi b/arch/arm/dts/mt7986.dtsi
> index c9aeeaca2b11..9a9b0b64cc68 100644
> --- a/arch/arm/dts/mt7986.dtsi
> +++ b/arch/arm/dts/mt7986.dtsi
> @@ -375,5 +375,51 @@
>   #phy-cells = <1>;
>   status = "okay";
>   };
> +
> + pcie_port: pcie-phy@11c0 {
> + reg = <0x11c0 0x2>;
> + clocks = <_clk>;
> + clock-names = "ref";
> + #phy-cells = <1>;
> + status = "okay";
> + };
> + };
> +
> + pcie: pcie@1128 {
> + compatible = "mediatek,mt7986-pcie",
> +  "mediatek,mt8192-pcie";
> + device_type = "pci";
> + reg = <0x1128 0x4000>;
> + reg-names = "pcie-mac";
> + #address-cells = <3>;
> + #size-cells = <2>;
> +
> + clocks = <_ao CK_INFRA_IPCIE_PIPE_CK>,
> +  <_ao CK_INFRA_IPCIE_CK>,
> +  <_ao CK_INFRA_IPCIER_CK>,
> +  <_ao CK_INFRA_IPCIEB_CK>;
> + clock-names = "pl_250m", "tl_26m", "peri_26m", "top_133m";
> +
> + bus-range = <0x00 0xff>;
> + ranges = <0x8200 0 0x2000 0x2000 0 0x1000>;
> +
> + interrupts = ;
> + #interrupt-cells = <2>;
> + interrupt-map-mask = <0 0 0 7>;
> + interrupt-map = <0 0 0 1 _intc 0>, /* INTA */
> + <0 0 0 2 _intc 1>, /* INTB */
> + <0 0 0 3 _intc 2>, /* INTC */
> + <0 0 0 4 _intc 3>; /* INTD */
> +
> + phy-names = "pcie-phy";
> + phys = <_port PHY_TYPE_PCIE>;
> +
> + status = "okay";
> +
> + pcie_intc: legacy-interrupt-controller {
> + interrupt-controller;
> + #address-cells = <0>;
> + #interrupt-cells = <1>;
> + };
>   };
>  };
> diff --git a/arch/arm/dts/mt7988-rfb.dts b/arch/arm/dts/mt7988-rfb.dts
> index 2c1142843091..2f0d00b6950b 100644
> --- a/arch/arm/dts/mt7988-rfb.dts
> +++ b/arch/arm/dts/mt7988-rfb.dts
> @@ -180,3 +180,15 @@
>   non-removable;
>   status = "okay";
>  };
> +
> + {
> + status = "okay";
> +};
> +
> + {
> + status = "okay";
> +};
> +
> + {
> + status = "okay";
> +};
> diff --git a/arch/arm/dts/mt7988-sd-rfb.dts b/arch/arm/dts/mt7988-sd-rfb.dts
> index a3df37d252de..0a3eb5360d21 100644
> --- a/arch/arm/dts/mt7988-sd-rfb.dts
> +++ b/arch/arm/dts/mt7988-sd-rfb.dts
> @@ -132,3 +132,15 @@
>   vqmmc-supply = <_3p3v>;
>   status 

[RFC] pci: mediatek: add PCIe controller support for Filogic

2024-04-12 Thread Frank Wunderlich
From: John Crispin 

This adds PCIe controller support for the MediaTek Filogic family..

Signed-off-by: John Crispin 
Signed-off-by: Frank Wunderlich 
---
Note for mt7988: pcie2 needs a dedicated phy which has no driver
in uboot yet, so this pcie port is not enabled in the board device-
trees.

Note for mt7981: i have no board and have no dts nodes yet for it,
so only clock change first.
---
 arch/arm/dts/mt7986.dtsi   |  46 +++
 arch/arm/dts/mt7988-rfb.dts|  12 +
 arch/arm/dts/mt7988-sd-rfb.dts |  12 +
 arch/arm/dts/mt7988.dtsi   | 164 +++
 drivers/clk/mediatek/clk-mt7986.c  |   5 +-
 drivers/pci/Kconfig|   7 +
 drivers/pci/Makefile   |   1 +
 drivers/pci/pcie_mediatek_gen3.c   | 382 +
 include/dt-bindings/clock/mt7981-clk.h |   3 +-
 include/dt-bindings/clock/mt7986-clk.h |   3 +-
 10 files changed, 631 insertions(+), 4 deletions(-)
 create mode 100644 drivers/pci/pcie_mediatek_gen3.c

diff --git a/arch/arm/dts/mt7986.dtsi b/arch/arm/dts/mt7986.dtsi
index c9aeeaca2b11..9a9b0b64cc68 100644
--- a/arch/arm/dts/mt7986.dtsi
+++ b/arch/arm/dts/mt7986.dtsi
@@ -375,5 +375,51 @@
#phy-cells = <1>;
status = "okay";
};
+
+   pcie_port: pcie-phy@11c0 {
+   reg = <0x11c0 0x2>;
+   clocks = <_clk>;
+   clock-names = "ref";
+   #phy-cells = <1>;
+   status = "okay";
+   };
+   };
+
+   pcie: pcie@1128 {
+   compatible = "mediatek,mt7986-pcie",
+"mediatek,mt8192-pcie";
+   device_type = "pci";
+   reg = <0x1128 0x4000>;
+   reg-names = "pcie-mac";
+   #address-cells = <3>;
+   #size-cells = <2>;
+
+   clocks = <_ao CK_INFRA_IPCIE_PIPE_CK>,
+<_ao CK_INFRA_IPCIE_CK>,
+<_ao CK_INFRA_IPCIER_CK>,
+<_ao CK_INFRA_IPCIEB_CK>;
+   clock-names = "pl_250m", "tl_26m", "peri_26m", "top_133m";
+
+   bus-range = <0x00 0xff>;
+   ranges = <0x8200 0 0x2000 0x2000 0 0x1000>;
+
+   interrupts = ;
+   #interrupt-cells = <2>;
+   interrupt-map-mask = <0 0 0 7>;
+   interrupt-map = <0 0 0 1 _intc 0>, /* INTA */
+   <0 0 0 2 _intc 1>, /* INTB */
+   <0 0 0 3 _intc 2>, /* INTC */
+   <0 0 0 4 _intc 3>; /* INTD */
+
+   phy-names = "pcie-phy";
+   phys = <_port PHY_TYPE_PCIE>;
+
+   status = "okay";
+
+   pcie_intc: legacy-interrupt-controller {
+   interrupt-controller;
+   #address-cells = <0>;
+   #interrupt-cells = <1>;
+   };
};
 };
diff --git a/arch/arm/dts/mt7988-rfb.dts b/arch/arm/dts/mt7988-rfb.dts
index 2c1142843091..2f0d00b6950b 100644
--- a/arch/arm/dts/mt7988-rfb.dts
+++ b/arch/arm/dts/mt7988-rfb.dts
@@ -180,3 +180,15 @@
non-removable;
status = "okay";
 };
+
+ {
+   status = "okay";
+};
+
+ {
+   status = "okay";
+};
+
+ {
+   status = "okay";
+};
diff --git a/arch/arm/dts/mt7988-sd-rfb.dts b/arch/arm/dts/mt7988-sd-rfb.dts
index a3df37d252de..0a3eb5360d21 100644
--- a/arch/arm/dts/mt7988-sd-rfb.dts
+++ b/arch/arm/dts/mt7988-sd-rfb.dts
@@ -132,3 +132,15 @@
vqmmc-supply = <_3p3v>;
status = "okay";
 };
+
+ {
+   status = "okay";
+};
+
+ {
+   status = "okay";
+};
+
+ {
+   status = "okay";
+};
diff --git a/arch/arm/dts/mt7988.dtsi b/arch/arm/dts/mt7988.dtsi
index ac476d5cdd7f..b2e2724732fc 100644
--- a/arch/arm/dts/mt7988.dtsi
+++ b/arch/arm/dts/mt7988.dtsi
@@ -194,6 +194,152 @@
status = "okay";
};
 
+   pcie2: pcie@1128 {
+   compatible = "mediatek,mt7988-pcie",
+"mediatek,mt7986-pcie",
+"mediatek,mt8192-pcie";
+   device_type = "pci";
+   #address-cells = <3>;
+   #size-cells = <2>;
+   reg = <0 0x1128 0 0x2000>;
+   reg-names = "pcie-mac";
+   linux,pci-domain = <3>;
+   interrupts = ;
+   bus-range = <0x00 0xff>;
+  

[PATCH v6] board: rockchip: Add Bananapi R2Pro Board

2023-10-04 Thread Frank Wunderlich
From: Frank Wunderlich 

Add Bananapi R2 Pro board.

tested:
- sdcard
- both front usb-ports
- sata
- wan-port

lan-ports are connected to mt7531 switch where driver needs to be
separated from mtk ethernet-driver.

Signed-off-by: Frank Wunderlich 
Reviewed-by: Kever Yang 
Reviewed-by: Jonas Karlman 
---
because iodomain is different to evb and now iodomain driver is sent as
patch we need to separate between EVB and R2Pro else board can be bricked.

ethernet support depends on these series from jonas:

rockchip: Port IO-domain driver for RK3568 from linux
https://patchwork.ozlabs.org/project/uboot/cover/20230821223020.3918620-1-jo...@kwiboo.se/
and
rockchip: Add GMAC support for RK3568 and RK3588
https://patchwork.ozlabs.org/project/uboot/cover/20230807000817.1701012-1-jo...@kwiboo.se/
---
v6:
- fix missing dtb extension in CONFIG_DEFAULT_FDT_FILE
- drop CONFIG_REGULATOR_PWM
- add RBs
- board name in maintainers file full uppercase

v5:
- add line break in description
- reorder in makefile
- drop special dts-handling
  (deletion of switchnode, disable of usb and gmac0)
- add MAINTAINERS entry
- changes to defconfig suggested by jonas
  - remove "pinctrl-0 pinctrl-names" from CONFIG_OF_SPL_REMOVE_PROPS
  - add CONFIG_SPL_DM_SEQ_ALIAS=y
  - add CONFIG_SPL_PINCTRL=y
  - remove CONFIG_USB_UHCI_HCD
  - enable EFI_LOADER (defaults to y)
  - drop CONFIG_SYSRESET_PSCI (reset works without)

v4:
- add r2pro board to readme
- update r2pro dts to linux version
- remove switch node from linux dts
- disable gmac0 because switch driver does not work yet
  to solve timeout error:
  ethernet@fe2a Waiting for PHY auto negotiation to complete. 
TIMEOUT!
  phy_startup() failed: -110FAILED: -110ethernet@fe01 Waiting for PHY auto 
nee
- cleanup r2pro u-boot.dtsi like jonas suggests
- update and reorder defconfig based on jonas suggestions
- dts: disable usb_host0_ohci because of error on usb-start
  scanning bus usb@fd84 for devices...
  ERROR: USB-error: DEVICENOTRESPONDING: Device did not respond to token (IN) 
or did
  not provide a handshake (OUT) (5)
  unable to get device descriptor (error=-1)
- pcie is not yet working, so not adding these options
  rockchip_pcie3phy phy@fe8c: lock failed 0x689
  rockchip_pcie3phy phy@fe8c: PHY: Failed to init phy@fe8c: -110.
  pcie_dw_rockchip pcie@fe27: failed to init phy (ret=-110)
  rockchip_pcie3phy phy@fe8c: lock failed 0x689
  rockchip_pcie3phy phy@fe8c: PHY: Failed to init phy@fe8c: -110.
  pcie_dw_rockchip pcie@fe28: failed to init phy (ret=-110)
- emmc not tested as it is empty on my board because it breaks sdcard boot
- rename dts and defconfig (add minus sign)
- enable efi_loader in defconfig

v3:
- disable gmac0 as switch-driver is not yet ready to attach to the mac

v2:
- drop switch-node for now as u-boot driver works differently to linux
---
 arch/arm/dts/Makefile  |   1 +
 arch/arm/dts/rk3568-bpi-r2-pro-u-boot.dtsi |  19 +
 arch/arm/dts/rk3568-bpi-r2-pro.dts | 852 +
 board/rockchip/evb_rk3568/MAINTAINERS  |   7 +
 configs/bpi-r2-pro-rk3568_defconfig|  93 +++
 doc/board/rockchip/rockchip.rst|   1 +
 6 files changed, 973 insertions(+)
 create mode 100644 arch/arm/dts/rk3568-bpi-r2-pro-u-boot.dtsi
 create mode 100644 arch/arm/dts/rk3568-bpi-r2-pro.dts
 create mode 100644 configs/bpi-r2-pro-rk3568_defconfig

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index bde2176ec7f6..fba7dfed26ba 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -177,6 +177,7 @@ dtb-$(CONFIG_ROCKCHIP_RK3568) += \
rk3566-soquartz-blade.dtb \
rk3566-soquartz-cm4.dtb \
rk3566-soquartz-model-a.dtb \
+   rk3568-bpi-r2-pro.dtb \
rk3568-evb.dtb \
rk3568-lubancat-2.dtb \
rk3568-nanopi-r5c.dtb \
diff --git a/arch/arm/dts/rk3568-bpi-r2-pro-u-boot.dtsi 
b/arch/arm/dts/rk3568-bpi-r2-pro-u-boot.dtsi
new file mode 100644
index ..60a3b21f2d45
--- /dev/null
+++ b/arch/arm/dts/rk3568-bpi-r2-pro-u-boot.dtsi
@@ -0,0 +1,19 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * (C) Copyright 2021 Rockchip Electronics Co., Ltd
+ */
+
+#include "rk356x-u-boot.dtsi"
+
+/ {
+   chosen {
+   stdout-path = 
+   };
+};
+
+ {
+   clock-frequency = <2400>;
+   bootph-pre-ram;
+   status = "okay";
+};
+
diff --git a/arch/arm/dts/rk3568-bpi-r2-pro.dts 
b/arch/arm/dts/rk3568-bpi-r2-pro.dts
new file mode 100644
index ..f9127ddfbb7d
--- /dev/null
+++ b/arch/arm/dts/rk3568-bpi-r2-pro.dts
@@ -0,0 +1,852 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Author: Frank Wunderlich 
+ *
+ */
+
+/dts-v1/;
+#include 
+#include 
+#include 
+#include 
+#include "rk3568.dtsi"
+
+/ {
+   model = "Bananapi-R2 Pro (RK3568) DDR4 Board";
+   compatible = "rockchip,rk3568-bpi-r2pro", "rockchip,rk3568"

Aw: Re: [PATCH v5] board: rockchip: Add Bananapi R2Pro Board

2023-10-04 Thread Frank Wunderlich
Hi Jonas

thanks for your review.

> Gesendet: Dienstag, 03. Oktober 2023 um 22:27 Uhr
> Von: "Jonas Karlman" 
> An: "Frank Wunderlich" , "Frank Wunderlich" 
> , "Kever Yang" 
> Cc: "Simon Glass" , "Philipp Tomsich" 
> , "Joseph Chen" , 
> u-boot@lists.denx.de
> Betreff: Re: [PATCH v5] board: rockchip: Add Bananapi R2Pro Board
>
> Hi Frank,
>
> On 2023-09-20 20:40, Frank Wunderlich wrote:
> > From: Frank Wunderlich 
> >
> > Add Bananapi R2 Pro board.
> >
> > tested:
> > - sdcard
> > - both front usb-ports
> > - sata
> > - wan-port
> >
> > lan-ports are connected to mt7531 switch where driver needs to be
> > separated from mtk ethernet-driver.
> >
> > Signed-off-by: Frank Wunderlich 
> > ---
> > because iodomain is different to evb and now iodomain driver is sent as
> > patch we need to separate between EVB and R2Pro else board can be bricked.
> >
> > ethernet support depends on these series from jonas:
> >
> > rockchip: Port IO-domain driver for RK3568 from linux
> > https://patchwork.ozlabs.org/project/uboot/cover/20230821223020.3918620-1-jo...@kwiboo.se/
> > and
> > rockchip: Add GMAC support for RK3568 and RK3588
> > https://patchwork.ozlabs.org/project/uboot/cover/20230807000817.1701012-1-jo...@kwiboo.se/
> > ---
> > v5:
> > - add line break in description
> > - reorder in makefile
> > - drop special dts-handling
> >   (deletion of switchnode, disable of usb and gmac0)
> > - add MAINTAINERS entry
> > - changes to defconfig suggested by jonas
> >   - remove "pinctrl-0 pinctrl-names" from CONFIG_OF_SPL_REMOVE_PROPS
> >   - add CONFIG_SPL_DM_SEQ_ALIAS=y
> >   - add CONFIG_SPL_PINCTRL=y
> >   - remove CONFIG_USB_UHCI_HCD
> >   - enable EFI_LOADER (defaults to y)
> >   - drop CONFIG_SYSRESET_PSCI (reset works without)
> >
> > v4:
> > - add r2pro board to readme
> > - update r2pro dts to linux version
> > - remove switch node from linux dts
> > - disable gmac0 because switch driver does not work yet
> >   to solve timeout error:
> >   ethernet@fe2a Waiting for PHY auto negotiation to complete. 
> > TIMEOUT!
> >   phy_startup() failed: -110FAILED: -110ethernet@fe01 Waiting for PHY 
> > auto nee
> > - cleanup r2pro u-boot.dtsi like jonas suggests
> > - update and reorder defconfig based on jonas suggestions
> > - dts: disable usb_host0_ohci because of error on usb-start
> >   scanning bus usb@fd84 for devices...
> >   ERROR: USB-error: DEVICENOTRESPONDING: Device did not respond to token 
> > (IN) or did
> >   not provide a handshake (OUT) (5)
> >   unable to get device descriptor (error=-1)
> > - pcie is not yet working, so not adding these options
> >   rockchip_pcie3phy phy@fe8c: lock failed 0x689
> >   rockchip_pcie3phy phy@fe8c: PHY: Failed to init phy@fe8c: -110.
> >   pcie_dw_rockchip pcie@fe27: failed to init phy (ret=-110)
> >   rockchip_pcie3phy phy@fe8c: lock failed 0x689
> >   rockchip_pcie3phy phy@fe8c: PHY: Failed to init phy@fe8c: -110.
> >   pcie_dw_rockchip pcie@fe28: failed to init phy (ret=-110)
> > - emmc not tested as it is empty on my board because it breaks sdcard boot
> > - rename dts and defconfig (add minus sign)
> > - enable efi_loader in defconfig
> >
> > v3:
> > - disable gmac0 as switch-driver is not yet ready to attach to the mac
> >
> > v2:
> > - drop switch-node for now as u-boot driver works differently to linux
> > ---
> >  arch/arm/dts/Makefile  |   1 +
> >  arch/arm/dts/rk3568-bpi-r2-pro-u-boot.dtsi |  19 +
> >  arch/arm/dts/rk3568-bpi-r2-pro.dts | 852 +
> >  board/rockchip/evb_rk3568/MAINTAINERS  |   7 +
> >  configs/bpi-r2-pro-rk3568_defconfig|  94 +++
> >  doc/board/rockchip/rockchip.rst|   1 +
> >  6 files changed, 974 insertions(+)
> >  create mode 100644 arch/arm/dts/rk3568-bpi-r2-pro-u-boot.dtsi
> >  create mode 100644 arch/arm/dts/rk3568-bpi-r2-pro.dts
> >  create mode 100644 configs/bpi-r2-pro-rk3568_defconfig
> >
>
> [...]
>
> > diff --git a/board/rockchip/evb_rk3568/MAINTAINERS 
> > b/board/rockchip/evb_rk3568/MAINTAINERS
> > index cc9eb432a8b5..8c506162c01e 100644
> > --- a/board/rockchip/evb_rk3568/MAINTAINERS
> > +++ b/board/rockchip/evb_rk3568/MAINTAINERS
> > @@ -7,6 +7,13 @@ F: configs/evb-rk3568_defconfig
> >  F: arch/arm/dts/rk3568-evb-u-boot.dtsi
> 

Aw: Re: Re: [PATCH v2 0/7] rockchip: rk3568: Fix use of PCIe bifurcation

2023-10-02 Thread Frank Wunderlich
Hi Jonas,

> Gesendet: Montag, 02. Oktober 2023 um 10:33 Uhr
> Von: "Jonas Karlman" 
> An: "Frank Wunderlich" , "Sebastian Reichel" 
> 
> Cc: "Kever Yang" , "Simon Glass" 
> , "Philipp Tomsich" , "Eugen 
> Hristev" , "Jon Lin" , 
> "FUKAUMI Naoki" , "John Clark" , 
> u-boot@lists.denx.de
> Betreff: Re: Aw: Re: [PATCH v2 0/7] rockchip: rk3568: Fix use of PCIe 
> bifurcation
>
> Hi Frank,
>
> On 2023-10-02 09:17, Frank Wunderlich wrote:
> > Hi,
> >
> >> Gesendet: Sonntag, 01. Oktober 2023 um 21:11 Uhr
> >> Von: "Sebastian Reichel" 
> >> An: "Jonas Karlman" 
> >> Cc: "Kever Yang" , "Simon Glass" 
> >> , "Philipp Tomsich" , "Eugen 
> >> Hristev" , "Jon Lin" 
> >> , "FUKAUMI Naoki" , "John Clark" 
> >> , u-boot@lists.denx.de
> >> Betreff: Re: [PATCH v2 0/7] rockchip: rk3568: Fix use of PCIe bifurcation
> >>
> >> Hi,
> >>
> >> On Wed, Sep 27, 2023 at 06:07:59PM +, Jonas Karlman wrote:
> >>> Above works with this series in U-Boot and also in mainline linux. Not
> >>> sure the RK3588 bifurcation part of driver have been verified on real HW,
> >>> rk3588 boards available for testing have typicality not used bifurcation.
> >>
> >> Upstream kernel bifurcation code looks ok to me. It's quite different
> >> from Rockchip vendor implementation, which might have confused Kever.
> >> I also missed this when having a quick look initially. As you said
> >> Rock 5A, Rock 5B and EVB1 do not use bifurcation, so no testing happened
> >> on our side.
> >
> > my Bananapi R2Pro (rk3568) uses bifurcation and it is working in mainline 
> > Linux, but not yet in uboot.
>
> The issue on your Bananapi R2Pro is most likely not related to the
> pcie bifurcation code added in this series.
>
> The coded added in this series works same/very similar as on mainline
> linux and fixes bifurcation use on devices such as Radxa E25 and NanoPi
> R5C/R5S.
>
> Please clarify if pcie work in mainline linux when booting with mainline
> u-boot, or does it only work when booting with vendor u-boot? (in case
> vendor u-boot set different/default pinconf).
>
> >
> > posted my test-results here:
> > https://patchwork.ozlabs.org/project/uboot/patch/20230918173624.31464-1-li...@fw-web.de/#3183519
>
> From your pci enum command I only see an expected pcie@fe27 (ngff)
> link fail. Does it also print out link fail for pcie@fe28 (minipcie)?

good catch, you're right, no message of mpcie, only ngff (no card)

#initial status (before enabling pcie-related regulators)
BPI-R2PRO> regulator status
Name EnableduV mA Mode   Status
vdd_logicenabled90  - -  0
vdd_gpu  enabled90  - -  0
vcc_ddr  enabled50  - -  0
vdd_npu  disabled   50  - -  0
vcc_1v8  enabled   180  - -  0
vdda0v9_imageenabled90  - -  0
vdda_0v9 enabled90  - -  0
vdda0v9_pmu  enabled90  - -  0
vccio_acodec enabled   330  - -  0
vccio_sd enabled   330  - -  0
vcc3v3_pmu   enabled   330  - -  0
vcca_1v8 enabled   180  - -  0
vcca1v8_pmu  enabled   180  - -  0
vcca1v8_imageenabled   180  - -  0
vcc_3v3  enabled 0  - -  0
vcc3v3_sdenabled 0  - -  0
dc_12v   enabled  1200  - -  0
vcc3v3_sys   enabled   330  - -  0
vcc5v0_sys   enabled   500  - -  0
pcie30_avdd0v9   enabled90  - -  0
pcie30_avdd1v8   enabled   180  - -  0
vcc3v3_pcie  disabled  330  - -  0
vcc3v3_minipcie  disabled  330  - -  0
vcc3v3_ngff  disabled  330  - -  0
vcc5v0_usb   enabled   500  - -  0
vcc5v0_usb_host  disabled  500  - -  0
vcc5v0_usb_otg   disabled  500  - -  0
BPI-R2PRO> regulator dev vcc3v3_pcie
dev: vcc3v3_pcie @ vcc3v3-pi6c-05-regulator
BP

Aw: Re: [PATCH v2 0/7] rockchip: rk3568: Fix use of PCIe bifurcation

2023-10-02 Thread Frank Wunderlich
Hi,

> Gesendet: Sonntag, 01. Oktober 2023 um 21:11 Uhr
> Von: "Sebastian Reichel" 
> An: "Jonas Karlman" 
> Cc: "Kever Yang" , "Simon Glass" 
> , "Philipp Tomsich" , "Eugen 
> Hristev" , "Jon Lin" , 
> "FUKAUMI Naoki" , "John Clark" , 
> u-boot@lists.denx.de
> Betreff: Re: [PATCH v2 0/7] rockchip: rk3568: Fix use of PCIe bifurcation
>
> Hi,
>
> On Wed, Sep 27, 2023 at 06:07:59PM +, Jonas Karlman wrote:
> > Above works with this series in U-Boot and also in mainline linux. Not
> > sure the RK3588 bifurcation part of driver have been verified on real HW,
> > rk3588 boards available for testing have typicality not used bifurcation.
>
> Upstream kernel bifurcation code looks ok to me. It's quite different
> from Rockchip vendor implementation, which might have confused Kever.
> I also missed this when having a quick look initially. As you said
> Rock 5A, Rock 5B and EVB1 do not use bifurcation, so no testing happened
> on our side.

my Bananapi R2Pro (rk3568) uses bifurcation and it is working in mainline 
Linux, but not yet in uboot.

posted my test-results here:
https://patchwork.ozlabs.org/project/uboot/patch/20230918173624.31464-1-li...@fw-web.de/#3183519

regards Frank




Aw: Re: [PATCH v5] board: rockchip: Add Bananapi R2Pro Board

2023-10-02 Thread Frank Wunderlich
Hi

Thank you kever for review.

Tom can you take this and the depencies into next release (2024-01)?

regards Frank


> Gesendet: Mittwoch, 27. September 2023 um 04:42 Uhr
> Von: "Kever Yang" 
> An: "Frank Wunderlich" , u-boot@lists.denx.de
> Cc: "Frank Wunderlich" , "Simon Glass" 
> , "Philipp Tomsich" , "Joseph 
> Chen" , "Jonas Karlman" 
> Betreff: Re: [PATCH v5] board: rockchip: Add Bananapi R2Pro Board
>
>
> On 2023/9/21 02:40, Frank Wunderlich wrote:
> > From: Frank Wunderlich 
> >
> > Add Bananapi R2 Pro board.
> >
> > tested:
> > - sdcard
> > - both front usb-ports
> > - sata
> > - wan-port
> >
> > lan-ports are connected to mt7531 switch where driver needs to be
> > separated from mtk ethernet-driver.
> >
> > Signed-off-by: Frank Wunderlich 
> Reviewed-by: Kever Yang 
>
> Thanks,
> - Kever
> > ---
> > because iodomain is different to evb and now iodomain driver is sent as
> > patch we need to separate between EVB and R2Pro else board can be bricked.
> >
> > ethernet support depends on these series from jonas:
> >
> > rockchip: Port IO-domain driver for RK3568 from linux
> > https://patchwork.ozlabs.org/project/uboot/cover/20230821223020.3918620-1-jo...@kwiboo.se/
> > and
> > rockchip: Add GMAC support for RK3568 and RK3588
> > https://patchwork.ozlabs.org/project/uboot/cover/20230807000817.1701012-1-jo...@kwiboo.se/



Aw: Re: github dependabot alert on py / pytest

2023-09-30 Thread Frank Wunderlich


> Gesendet: Samstag, 30. September 2023 um 16:44 Uhr
> Von: "Tom Rini" 
> An: "Frank Wunderlich" 
> Cc: "u-bootlists.denx.de" 
> Betreff: Re: github dependabot alert on py / pytest
>
> On Sat, Sep 30, 2023 at 03:13:30PM +0200, Frank Wunderlich wrote:
> > Hi,
> >
> > dependabot reports a high security issue
> >
> > https://github.com/frank-w/u-boot/security/dependabot/1
> >
> > it seems it is not yet fixed in master and next as there py is still in and 
> > pytest==6.2.5
> >
> > I have not yet seen any topics for this...are you aware of this? I know 
> > tests are run in
> > isolated environment through gitlab-pipeline, but maybe this can have still 
> > a risk.
>
> The dependabot requests aren't public.  But I don't see one myself when
> pushing to GitHub, can you please elaborate on what it's saying we
> should have updated?

it says py-package is affected till 1.11.0 and pytest after 7.2.0 does not have 
requirement for it...
so dropping py package and upgrade pytest to at least 7.2.0 should be the right 
fix

i guess you do not use subversion (so basicly no security issue), but maybe we 
can fix this by upgrading
pytest to avoid the alerts in future

full report:

ReDoS in py library when used with subversion #1


Package: py (pip)
Affected versions: <= 1.11.0
Patched version: None

The py library through 1.11.0 for Python allows remote attackers to conduct a 
ReDoS (Regular expression Denial of Service) attack via a Subversion repository 
with crafted info data, because the InfoSvnCommand argument is mishandled.

The particular codepath in question is the regular expression at 
py._path.svnurl.InfoSvnCommand.lspattern and is only relevant when dealing with 
subversion (svn) projects. Notably the codepath is not used in the popular 
pytest project. The developers of the pytest package have released version 
7.2.0 which removes their dependency on py. Users of pytest seeing alerts 
relating to this advisory may update to version 7.2.0 of pytest to resolve this 
issue. See https://github.com/pytest-dev/py/issues/287#issuecomment-1290407715 
(comment) for additional context.

Severity
High
7.5 / 10
CVSS base metrics
Attack vector
Network
Attack complexity
Low
Privileges required
None
User interaction
None
Scope
Unchanged
Confidentiality
None
Integrity
None
Availability
High
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
Tags
Direct dependency
Weaknesses
Weakness CWE-1333
CVE ID
CVE-2022-42969


regards Frank


github dependabot alert on py / pytest

2023-09-30 Thread Frank Wunderlich
Hi,

dependabot reports a high security issue

https://github.com/frank-w/u-boot/security/dependabot/1

it seems it is not yet fixed in master and next as there py is still in and 
pytest==6.2.5

I have not yet seen any topics for this...are you aware of this? I know tests 
are run in
isolated environment through gitlab-pipeline, but maybe this can have still a 
risk.

regards Frank



[PATCH v5] board: rockchip: Add Bananapi R2Pro Board

2023-09-20 Thread Frank Wunderlich
From: Frank Wunderlich 

Add Bananapi R2 Pro board.

tested:
- sdcard
- both front usb-ports
- sata
- wan-port

lan-ports are connected to mt7531 switch where driver needs to be
separated from mtk ethernet-driver.

Signed-off-by: Frank Wunderlich 
---
because iodomain is different to evb and now iodomain driver is sent as
patch we need to separate between EVB and R2Pro else board can be bricked.

ethernet support depends on these series from jonas:

rockchip: Port IO-domain driver for RK3568 from linux
https://patchwork.ozlabs.org/project/uboot/cover/20230821223020.3918620-1-jo...@kwiboo.se/
and
rockchip: Add GMAC support for RK3568 and RK3588
https://patchwork.ozlabs.org/project/uboot/cover/20230807000817.1701012-1-jo...@kwiboo.se/
---
v5:
- add line break in description
- reorder in makefile
- drop special dts-handling
  (deletion of switchnode, disable of usb and gmac0)
- add MAINTAINERS entry
- changes to defconfig suggested by jonas
  - remove "pinctrl-0 pinctrl-names" from CONFIG_OF_SPL_REMOVE_PROPS
  - add CONFIG_SPL_DM_SEQ_ALIAS=y
  - add CONFIG_SPL_PINCTRL=y
  - remove CONFIG_USB_UHCI_HCD
  - enable EFI_LOADER (defaults to y)
  - drop CONFIG_SYSRESET_PSCI (reset works without)

v4:
- add r2pro board to readme
- update r2pro dts to linux version
- remove switch node from linux dts
- disable gmac0 because switch driver does not work yet
  to solve timeout error:
  ethernet@fe2a Waiting for PHY auto negotiation to complete. 
TIMEOUT!
  phy_startup() failed: -110FAILED: -110ethernet@fe01 Waiting for PHY auto 
nee
- cleanup r2pro u-boot.dtsi like jonas suggests
- update and reorder defconfig based on jonas suggestions
- dts: disable usb_host0_ohci because of error on usb-start
  scanning bus usb@fd84 for devices...
  ERROR: USB-error: DEVICENOTRESPONDING: Device did not respond to token (IN) 
or did
  not provide a handshake (OUT) (5)
  unable to get device descriptor (error=-1)
- pcie is not yet working, so not adding these options
  rockchip_pcie3phy phy@fe8c: lock failed 0x689
  rockchip_pcie3phy phy@fe8c: PHY: Failed to init phy@fe8c: -110.
  pcie_dw_rockchip pcie@fe27: failed to init phy (ret=-110)
  rockchip_pcie3phy phy@fe8c: lock failed 0x689
  rockchip_pcie3phy phy@fe8c: PHY: Failed to init phy@fe8c: -110.
  pcie_dw_rockchip pcie@fe28: failed to init phy (ret=-110)
- emmc not tested as it is empty on my board because it breaks sdcard boot
- rename dts and defconfig (add minus sign)
- enable efi_loader in defconfig

v3:
- disable gmac0 as switch-driver is not yet ready to attach to the mac

v2:
- drop switch-node for now as u-boot driver works differently to linux
---
 arch/arm/dts/Makefile  |   1 +
 arch/arm/dts/rk3568-bpi-r2-pro-u-boot.dtsi |  19 +
 arch/arm/dts/rk3568-bpi-r2-pro.dts | 852 +
 board/rockchip/evb_rk3568/MAINTAINERS  |   7 +
 configs/bpi-r2-pro-rk3568_defconfig|  94 +++
 doc/board/rockchip/rockchip.rst|   1 +
 6 files changed, 974 insertions(+)
 create mode 100644 arch/arm/dts/rk3568-bpi-r2-pro-u-boot.dtsi
 create mode 100644 arch/arm/dts/rk3568-bpi-r2-pro.dts
 create mode 100644 configs/bpi-r2-pro-rk3568_defconfig

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 85fd5b1157b1..016eb5556513 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -177,6 +177,7 @@ dtb-$(CONFIG_ROCKCHIP_RK3568) += \
rk3566-soquartz-blade.dtb \
rk3566-soquartz-cm4.dtb \
rk3566-soquartz-model-a.dtb \
+   rk3568-bpi-r2-pro.dtb \
rk3568-evb.dtb \
rk3568-lubancat-2.dtb \
rk3568-nanopi-r5c.dtb \
diff --git a/arch/arm/dts/rk3568-bpi-r2-pro-u-boot.dtsi 
b/arch/arm/dts/rk3568-bpi-r2-pro-u-boot.dtsi
new file mode 100644
index ..60a3b21f2d45
--- /dev/null
+++ b/arch/arm/dts/rk3568-bpi-r2-pro-u-boot.dtsi
@@ -0,0 +1,19 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * (C) Copyright 2021 Rockchip Electronics Co., Ltd
+ */
+
+#include "rk356x-u-boot.dtsi"
+
+/ {
+   chosen {
+   stdout-path = 
+   };
+};
+
+ {
+   clock-frequency = <2400>;
+   bootph-pre-ram;
+   status = "okay";
+};
+
diff --git a/arch/arm/dts/rk3568-bpi-r2-pro.dts 
b/arch/arm/dts/rk3568-bpi-r2-pro.dts
new file mode 100644
index ..f9127ddfbb7d
--- /dev/null
+++ b/arch/arm/dts/rk3568-bpi-r2-pro.dts
@@ -0,0 +1,852 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Author: Frank Wunderlich 
+ *
+ */
+
+/dts-v1/;
+#include 
+#include 
+#include 
+#include 
+#include "rk3568.dtsi"
+
+/ {
+   model = "Bananapi-R2 Pro (RK3568) DDR4 Board";
+   compatible = "rockchip,rk3568-bpi-r2pro", "rockchip,rk3568";
+
+   aliases {
+   ethernet0 = 
+   ethernet1 = 
+   mmc0 = 
+   mmc1 = 
+   };
+
+   chosen: chosen {
+   stdout-path =

Aw: Re: [PATCH v4] board: rockchip: Add Bananapi R2Pro Board

2023-09-19 Thread Frank Wunderlich
Hi Jonas

> Gesendet: Montag, 18. September 2023 um 23:45 Uhr
> Von: "Jonas Karlman" 
> An: "Frank Wunderlich" 
> Cc: "Frank Wunderlich" , "Simon Glass" 
> , "Philipp Tomsich" , "Kever 
> Yang" , u-boot@lists.denx.de
> Betreff: Re: [PATCH v4] board: rockchip: Add Bananapi R2Pro Board
>
> Hi Frank,
>
> On 2023-09-18 19:36, Frank Wunderlich wrote:
> > From: Frank Wunderlich 
> >
> > Add Bananapi R2 Pro board.
> >
> > tested:
> > - sdcard
> > - both front usb-ports
> > - sata
> > - wan-port
> >
> > lan-ports are connected to mt7531 switch where driver needs to be separated 
> > from mtk ethernet-driver.
> >
> > Signed-off-by: Frank Wunderlich 
> > ---
> > because iodomain is different to evb and now iodomain driver is sent as
> > patch we need to separate between EVB and R2Pro else board can be bricked.
> > ---
> > v4:
> > - add r2pro board to readme
> > - update r2pro dts to linux version
> > - remove switch node from linux dts
> > - disable gmac0 because switch driver does not work yet
> >   to solve timeout error:
> >   ethernet@fe2a Waiting for PHY auto negotiation to complete. 
> > TIMEOUT!
> >   phy_startup() failed: -110FAILED: -110ethernet@fe01 Waiting for PHY 
> > auto nee
> > - cleanup r2pro u-boot.dtsi like jonas suggests
> > - update and reorder defconfig based on jonas suggestions
> > - dts: disable usb_host0_ohci because of error on usb-start
> >   scanning bus usb@fd84 for devices...
> >   ERROR: USB-error: DEVICENOTRESPONDING: Device did not respond to token 
> > (IN) or did
> >   not provide a handshake (OUT) (5)
> >   unable to get device descriptor (error=-1)
> > - pcie is not yet working, so not adding these options
> >   rockchip_pcie3phy phy@fe8c: lock failed 0x689
> >   rockchip_pcie3phy phy@fe8c: PHY: Failed to init phy@fe8c: -110.
> >   pcie_dw_rockchip pcie@fe27: failed to init phy (ret=-110)
> >   rockchip_pcie3phy phy@fe8c: lock failed 0x689
> >   rockchip_pcie3phy phy@fe8c: PHY: Failed to init phy@fe8c: -110.
> >   pcie_dw_rockchip pcie@fe28: failed to init phy (ret=-110)
>
> Looks like this board use PCIe bifurcation and would depend on my rk35xx
> PCIe bifurcation series to at least have a chance to work. (looks like
> it is applied based on your log rows).

yes i have added your series to my tree...

https://github.com/frank-w/u-boot/commits/2023-10-bpi-r2pro_2

and yes, board uses bifurcation to split pcie3 to an mPCIe slot and an m.2 slot.

> Could there be an issue with a regulator not being enabled in time?
> Please use regulator cmd to enable all regulators prior to running the
> pci enum cmd, and see if that changes anything.

at least the output changes...

there are 3 pcie-regulators, first is for clock

vcc3v3_pcie  disabled  330  - -  0
vcc3v3_minipcie  disabled  330  - -  0
vcc3v3_ngff  disabled  330  - -  0

BPI-R2PRO> regulator dev vcc3v3_pcie
dev: vcc3v3_pcie @ vcc3v3-pi6c-05-regulator
BPI-R2PRO> regulator enable
BPI-R2PRO> regulator dev vcc3v3_minipcie
dev: vcc3v3_minipcie @ vcc3v3-minipcie-regulator
BPI-R2PRO> regulator enable

vcc3v3_pcie  enabled   330  - -  0
vcc3v3_minipcie  enabled   330  - -  0
vcc3v3_ngff  disabled  330  - -  0

BPI-R2PRO> pci enum
pcie_dw_rockchip pcie@fe27: PCIe-0 Link Fail

(card is in mpcie-slot)

> > - emmc not tested as it is empty on my board because it breaks sdcard boot
> >
> > v3:
> > - disable gmac0 as switch-driver is not yet ready to attach to the mac
> >
> > v2:
> > - drop switch-node for now as u-boot driver works differently to linux
> > ---
> >  arch/arm/dts/Makefile |   3 +-
> >  arch/arm/dts/rk3568-bpi-r2pro-u-boot.dtsi |  28 +
> >  arch/arm/dts/rk3568-bpi-r2pro.dts | 852 ++
> >  configs/bpi-r2pro-rk3568_defconfig|  95 +++
> >  doc/board/rockchip/rockchip.rst   |   1 +
> >  5 files changed, 978 insertions(+), 1 deletion(-)
> >  create mode 100644 arch/arm/dts/rk3568-bpi-r2pro-u-boot.dtsi
> >  create mode 100644 arch/arm/dts/rk3568-bpi-r2pro.dts
>
> The DT file is named rk3568-bpi-r2-pro.dts in linux, please use same
> name in U-Boot. Same goes for defconfig-file, please name it
> bpi-r2-pro-rk3568_defconfig to match DT filename.
>
> >  create mode 100644 configs/bpi-r2pro-rk3568_defconfig
> >

Re: [PATCH v4] board: rockchip: Add Bananapi R2Pro Board

2023-09-18 Thread Frank Wunderlich
Am 18. September 2023 20:59:55 MESZ schrieb Mark Kettenis 
:
>> Date: Mon, 18 Sep 2023 20:09:54 +0200
>> From: Frank Wunderlich 
>> 
>> Am 18. September 2023 19:52:31 MESZ schrieb Mark Kettenis 
>> :
>> >> From: Frank Wunderlich 
>> >> Date: Mon, 18 Sep 2023 19:36:24 +0200
>> 
>> Hi Mark,
>
>Hello Frank,
>
>> >> --- /dev/null
>> >> +++ b/arch/arm/dts/rk3568-bpi-r2pro-u-boot.dtsi
>> >> @@ -0,0 +1,28 @@
>> >> +// SPDX-License-Identifier: GPL-2.0+
>> >> +/*
>> >> + * (C) Copyright 2021 Rockchip Electronics Co., Ltd
>> >> + */
>> >> +
>> >> +#include "rk356x-u-boot.dtsi"
>> >> +
>> >> +/ {
>> >> + chosen {
>> >> + stdout-path = 
>> >> + };
>> >> +};
>> >> +
>> >> + {
>> >> + clock-frequency = <2400>;
>> >> + bootph-pre-ram;
>> >> + status = "okay";
>> >> +};
>> >> +
>> >> + {
>> >> + status = "disabled";
>> >> +};
>> >> +
>> >> +/delete-node/ &{/ethernet@fe2a/mdio/switch@0};
>> >
>> >Why are you deleting the switch node?  This way an OS that uses the
>> >device tree provided by U-boot will not have a working switch...
>> 
>> Is there such an OS?
>
>Yes, OpenBSD tends to rely on the device tree provided by U-Boot.  It
>is impossible to include device trees for all possible boards on the
>installation media.  And if U-Boot provides the device tree for the
>board we don't need to (as long as the device tree uses the "official"
>bindings).
>
>> Linux uses own dts.
>
>Well, Linux *may* use its own dts.  Some boards never make it in the
>official Linux tree.  Or a generic Linux distro may use a kernel that
>was released before the board made it to the market.  So generic Linux
>distros face the same problem as OpenBSD in that it isn't practical to
>include device trees for every possible board on the installation
>media.
>
>So the goal is that U-Boot provides a usable device tree for as many
>boards as possible.
>
>> The switch will also not work because the gmac0 is deactivated to
>> fix the timeout in uboot because phy does not answer.
>
>I missed that.  But that is a bug in U-Boot that should be fixed.
>Probably by adding support for "fixed-link" switch ports.  Now I
>appreciate that having a U-Boot that partly works is better than no
>U-Boot at all.  So that may justify what you did.  However...

I'm not sure if it is the fixed link that causes the 
timeout or that switch is not initialized due to 
missing driver. I guess last one...

>> I can leave the switch-node, but i do not want the timeout on network access 
>> on gmac0.
>
>...such a timeout could be seen as a reminder that the work isn't
>finished yet.

I wanted to work cleanly on u-boot,but of course i
can send without these "fixes" and add them in
my own tree if this is the better way.

>> >> + {
>> >> + #address-cells = <1>;
>> >> + #size-cells = <0>;
>> >> +
>> >> + switch@0 {
>> >> + compatible = "mediatek,mt7531";
>> >> + reg = <0>;
>> >> +
>> >> + ports {
>> >> + #address-cells = <1>;
>> >> + #size-cells = <0>;
>> >> +
>> >> + port@1 {
>> >> + reg = <1>;
>> >> + label = "lan0";
>> >> + };
>> >> +
>> >> + port@2 {
>> >> + reg = <2>;
>> >> + label = "lan1";
>> >> + };
>> >> +
>> >> + port@3 {
>> >> + reg = <3>;
>> >> + label = "lan2";
>> >> + };
>> >> +
>> >> + port@4 {
>> >> + reg = <4>;
>> >> + label = "lan3";
>> >> + };
>> >> +
>> >> + port@5 {
>> >> + reg = <5>;
>> >> + label = "cpu";
>> >> + ethernet = <>;
>> >> + phy-mode = "rgmii";
>> >> +
>> >> + fixed-link {
>> >> + speed = <1000>;
>> >> + full-duplex;
>> >> + pause;
>> >> + };
>> >> + };
>> >> + };
>> >> + };
>> >> +};
>> 
>> 
>> regards Frank
>> 


regards Frank


Re: [PATCH v4] board: rockchip: Add Bananapi R2Pro Board

2023-09-18 Thread Frank Wunderlich
Am 18. September 2023 19:52:31 MESZ schrieb Mark Kettenis 
:
>> From: Frank Wunderlich 
>> Date: Mon, 18 Sep 2023 19:36:24 +0200

Hi Mark,

>> --- /dev/null
>> +++ b/arch/arm/dts/rk3568-bpi-r2pro-u-boot.dtsi
>> @@ -0,0 +1,28 @@
>> +// SPDX-License-Identifier: GPL-2.0+
>> +/*
>> + * (C) Copyright 2021 Rockchip Electronics Co., Ltd
>> + */
>> +
>> +#include "rk356x-u-boot.dtsi"
>> +
>> +/ {
>> +chosen {
>> +stdout-path = 
>> +};
>> +};
>> +
>> + {
>> +clock-frequency = <2400>;
>> +bootph-pre-ram;
>> +status = "okay";
>> +};
>> +
>> + {
>> +status = "disabled";
>> +};
>> +
>> +/delete-node/ &{/ethernet@fe2a/mdio/switch@0};
>
>Why are you deleting the switch node?  This way an OS that uses the
>device tree provided by U-boot will not have a working switch...

Is there such an OS? Linux uses own dts.

The switch will also not work because the gmac0 is deactivated to fix the 
timeout in uboot because phy does not answer.

I can leave the switch-node, but i do not want the timeout on network access on 
gmac0.

>> + {
>> +#address-cells = <1>;
>> +#size-cells = <0>;
>> +
>> +switch@0 {
>> +compatible = "mediatek,mt7531";
>> +reg = <0>;
>> +
>> +ports {
>> +#address-cells = <1>;
>> +#size-cells = <0>;
>> +
>> +port@1 {
>> +reg = <1>;
>> +label = "lan0";
>> +};
>> +
>> +port@2 {
>> +reg = <2>;
>> +label = "lan1";
>> +};
>> +
>> +port@3 {
>> +reg = <3>;
>> +label = "lan2";
>> +};
>> +
>> +port@4 {
>> +reg = <4>;
>> +label = "lan3";
>> +};
>> +
>> +port@5 {
>> +reg = <5>;
>> +label = "cpu";
>> +ethernet = <>;
>> +phy-mode = "rgmii";
>> +
>> +fixed-link {
>> +speed = <1000>;
>> +full-duplex;
>> +pause;
>> +};
>> +};
>> +};
>> +};
>> +};


regards Frank


[PATCH v4] board: rockchip: Add Bananapi R2Pro Board

2023-09-18 Thread Frank Wunderlich
From: Frank Wunderlich 

Add Bananapi R2 Pro board.

tested:
- sdcard
- both front usb-ports
- sata
- wan-port

lan-ports are connected to mt7531 switch where driver needs to be separated 
from mtk ethernet-driver.

Signed-off-by: Frank Wunderlich 
---
because iodomain is different to evb and now iodomain driver is sent as
patch we need to separate between EVB and R2Pro else board can be bricked.
---
v4:
- add r2pro board to readme
- update r2pro dts to linux version
- remove switch node from linux dts
- disable gmac0 because switch driver does not work yet
  to solve timeout error:
  ethernet@fe2a Waiting for PHY auto negotiation to complete. 
TIMEOUT!
  phy_startup() failed: -110FAILED: -110ethernet@fe01 Waiting for PHY auto 
nee
- cleanup r2pro u-boot.dtsi like jonas suggests
- update and reorder defconfig based on jonas suggestions
- dts: disable usb_host0_ohci because of error on usb-start
  scanning bus usb@fd84 for devices...
  ERROR: USB-error: DEVICENOTRESPONDING: Device did not respond to token (IN) 
or did
  not provide a handshake (OUT) (5)
  unable to get device descriptor (error=-1)
- pcie is not yet working, so not adding these options
  rockchip_pcie3phy phy@fe8c: lock failed 0x689
  rockchip_pcie3phy phy@fe8c: PHY: Failed to init phy@fe8c: -110.
  pcie_dw_rockchip pcie@fe27: failed to init phy (ret=-110)
  rockchip_pcie3phy phy@fe8c: lock failed 0x689
  rockchip_pcie3phy phy@fe8c: PHY: Failed to init phy@fe8c: -110.
  pcie_dw_rockchip pcie@fe28: failed to init phy (ret=-110)
- emmc not tested as it is empty on my board because it breaks sdcard boot

v3:
- disable gmac0 as switch-driver is not yet ready to attach to the mac

v2:
- drop switch-node for now as u-boot driver works differently to linux
---
 arch/arm/dts/Makefile |   3 +-
 arch/arm/dts/rk3568-bpi-r2pro-u-boot.dtsi |  28 +
 arch/arm/dts/rk3568-bpi-r2pro.dts | 852 ++
 configs/bpi-r2pro-rk3568_defconfig|  95 +++
 doc/board/rockchip/rockchip.rst   |   1 +
 5 files changed, 978 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/dts/rk3568-bpi-r2pro-u-boot.dtsi
 create mode 100644 arch/arm/dts/rk3568-bpi-r2pro.dts
 create mode 100644 configs/bpi-r2pro-rk3568_defconfig

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 85fd5b1157b1..71c557e87e9e 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -183,7 +183,8 @@ dtb-$(CONFIG_ROCKCHIP_RK3568) += \
rk3568-nanopi-r5s.dtb \
rk3568-odroid-m1.dtb \
rk3568-radxa-e25.dtb \
-   rk3568-rock-3a.dtb
+   rk3568-rock-3a.dtb \
+   rk3568-bpi-r2pro.dtb
 
 dtb-$(CONFIG_ROCKCHIP_RK3588) += \
rk3588-edgeble-neu6a-io.dtb \
diff --git a/arch/arm/dts/rk3568-bpi-r2pro-u-boot.dtsi 
b/arch/arm/dts/rk3568-bpi-r2pro-u-boot.dtsi
new file mode 100644
index ..089e54f8cece
--- /dev/null
+++ b/arch/arm/dts/rk3568-bpi-r2pro-u-boot.dtsi
@@ -0,0 +1,28 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * (C) Copyright 2021 Rockchip Electronics Co., Ltd
+ */
+
+#include "rk356x-u-boot.dtsi"
+
+/ {
+   chosen {
+   stdout-path = 
+   };
+};
+
+ {
+   clock-frequency = <2400>;
+   bootph-pre-ram;
+   status = "okay";
+};
+
+ {
+   status = "disabled";
+};
+
+/delete-node/ &{/ethernet@fe2a/mdio/switch@0};
+
+_host0_ohci {
+   status = "disabled";
+};
diff --git a/arch/arm/dts/rk3568-bpi-r2pro.dts 
b/arch/arm/dts/rk3568-bpi-r2pro.dts
new file mode 100644
index ..f9127ddfbb7d
--- /dev/null
+++ b/arch/arm/dts/rk3568-bpi-r2pro.dts
@@ -0,0 +1,852 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Author: Frank Wunderlich 
+ *
+ */
+
+/dts-v1/;
+#include 
+#include 
+#include 
+#include 
+#include "rk3568.dtsi"
+
+/ {
+   model = "Bananapi-R2 Pro (RK3568) DDR4 Board";
+   compatible = "rockchip,rk3568-bpi-r2pro", "rockchip,rk3568";
+
+   aliases {
+   ethernet0 = 
+   ethernet1 = 
+   mmc0 = 
+   mmc1 = 
+   };
+
+   chosen: chosen {
+   stdout-path = "serial2:150n8";
+   };
+
+   leds {
+   compatible = "gpio-leds";
+   pinctrl-names = "default";
+   pinctrl-0 = <_led_pin _led_pin>;
+
+   blue_led: led-0 {
+   color = ;
+   default-state = "off";
+   function = LED_FUNCTION_STATUS;
+   gpios = < RK_PD6 GPIO_ACTIVE_HIGH>;
+   };
+
+   green_led: led-1 {
+   color = ;
+   default-state = "on";
+   function = LED_FUNCTION_POWER;
+   gpios = < RK_PD5 GPIO_ACTIVE_HIGH>

Aw: Re: [PATCH v3] board: rockchip: Add Bananapi R2Pro Board

2023-09-17 Thread Frank Wunderlich
Hi,

thank you for your suggestions

> Gesendet: Sonntag, 17. September 2023 um 00:51 Uhr
> Von: "Jonas Karlman" 
> An: "Frank Wunderlich" 
> Cc: "Frank Wunderlich" , "Simon Glass" 
> , "Philipp Tomsich" , "Kever 
> Yang" , "Marek Vasut" , 
> u-boot@lists.denx.de
> Betreff: Re: [PATCH v3] board: rockchip: Add Bananapi R2Pro Board
>
> Hi Frank,
>
> On 2023-08-20 18:00, Frank Wunderlich wrote:
> > From: Frank Wunderlich 
> >
> > Add Bananapi R2 Pro board.
> >
> > Till now evb dts could be used, but iodomain is different
> > (evb has 1v8 on vccio2 and vccio4 which are 3v3 on r2pro)
> > and with iodomain driver this can cause hardware fault.
> >
> > Devicetree in mainline-Linux:
> > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/arm64/boot/dts/rockchip/rk3568-bpi-r2-pro.dts
> >
> > Signed-off-by: Frank Wunderlich 
> > ---
> > v3:
> > - disable gmac0 as switch-driver is not yet ready to attach to the mac
> > v2:
> > - drop switch-node for now as u-boot driver works differently to linux
> > ---
> >  arch/arm/dts/Makefile |   3 +-
> >  arch/arm/dts/rk3568-bpi-r2pro-u-boot.dtsi |  23 +
> >  arch/arm/dts/rk3568-bpi-r2pro.dts | 549 ++
> >  configs/bpi-r2pro-rk3568_defconfig| 101 
> >  4 files changed, 675 insertions(+), 1 deletion(-)
> >  create mode 100644 arch/arm/dts/rk3568-bpi-r2pro-u-boot.dtsi
> >  create mode 100644 arch/arm/dts/rk3568-bpi-r2pro.dts
> >  create mode 100644 configs/bpi-r2pro-rk3568_defconfig
> >
> > diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
> > index bd518064f35f..767bf9db39fb 100644
> > --- a/arch/arm/dts/Makefile
> > +++ b/arch/arm/dts/Makefile
> > @@ -182,7 +182,8 @@ dtb-$(CONFIG_ROCKCHIP_RK3568) += \
> > rk3568-nanopi-r5s.dtb \
> > rk3568-odroid-m1.dtb \
> > rk3568-radxa-e25.dtb \
> > -   rk3568-rock-3a.dtb
> > +   rk3568-rock-3a.dtb \
> > +   rk3568-bpi-r2pro.dtb
> >
> >  dtb-$(CONFIG_ROCKCHIP_RK3588) += \
> > rk3588-edgeble-neu6a-io.dtb \
> > diff --git a/arch/arm/dts/rk3568-bpi-r2pro-u-boot.dtsi 
> > b/arch/arm/dts/rk3568-bpi-r2pro-u-boot.dtsi
> > new file mode 100644
> > index ..382a52a28b10
> > --- /dev/null
> > +++ b/arch/arm/dts/rk3568-bpi-r2pro-u-boot.dtsi
> > @@ -0,0 +1,23 @@
> > +// SPDX-License-Identifier: GPL-2.0+
> > +/*
> > + * (C) Copyright 2021 Rockchip Electronics Co., Ltd
> > + */
> > +
> > +#include "rk356x-u-boot.dtsi"
> > +
> > +/ {
> > +   chosen {
> > +   stdout-path = 
> > +   u-boot,spl-boot-order = "same-as-spl", , 
>
> This is the default order in rk356x-u-boot.dtsi and can be dropped.
>
> > +   };
> > +};
> > +
> > + {
> > +   status = "okay";
>
> sdmmc0 is already enabled in rk3568-bpi-r2pro.dts
>
> > +};
> > +
> > + {
> > +   clock-frequency = <2400>;
> > +   bootph-pre-ram;
> > +   status = "okay";
> > +};

then i have only the uart here...right? do you remember i missed the 
-uboot.dtsi in first try and board does not find mmc in spl.

do i really not need the first 2 nodes here?

> > diff --git a/arch/arm/dts/rk3568-bpi-r2pro.dts 
> > b/arch/arm/dts/rk3568-bpi-r2pro.dts
> > new file mode 100644
> > index ..e4fcbb8a1174
> > --- /dev/null
> > +++ b/arch/arm/dts/rk3568-bpi-r2pro.dts
>
> Should be a 1:1 copy from kernel.

i try to do so, but this will result in many nodes not used in uboot like the 
switch i remove in the dtsi and graphics.
thx for pointing to the pcie driver then i can let these nodes in.

> [...]
>
> > diff --git a/configs/bpi-r2pro-rk3568_defconfig 
> > b/configs/bpi-r2pro-rk3568_defconfig
> > new file mode 100644
> > index ..e8936261eab3
> > --- /dev/null
> > +++ b/configs/bpi-r2pro-rk3568_defconfig
> > @@ -0,0 +1,101 @@
> > +CONFIG_ARM=y
> > +CONFIG_SKIP_LOWLEVEL_INIT=y
> > +CONFIG_COUNTER_FREQUENCY=2400
> > +CONFIG_ARCH_ROCKCHIP=y
> > +CONFIG_TEXT_BASE=0x00a0
> > +CONFIG_SPL_LIBCOMMON_SUPPORT=y
> > +CONFIG_SPL_LIBGENERIC_SUPPORT=y
> > +CONFIG_NR_DRAM_BANKS=2
> > +CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
> > +CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0xc0
> > +CONFIG_DEFAULT_DEVICE_TREE="rk3568-bpi-r2pro"
> > +CONFIG_ROCKCHIP_RK3568=y
> > +CONFIG_SPL_ROCKCHIP_COMMON_BOARD=y
> > +CONFIG_SPL_SERIA

Re: Aw: [PATCH v3] board: rockchip: Add Bananapi R2Pro Board

2023-09-16 Thread Frank Wunderlich
Am 16. September 2023 18:07:44 MESZ schrieb Marek Vasut :
>On 9/16/23 16:18, Frank Wunderlich wrote:
>> Hi,
>> 
>> just a friedly reminder. would be great if it can be merged in next 
>> uboot-version.
>
>+CC Tom
>
>> regards Frank
>> 
>> 
>>> Gesendet: Sonntag, 20. August 2023 um 18:00 Uhr
>>> Von: "Frank Wunderlich" 
>>> An: u-boot@lists.denx.de
>>> Cc: "Frank Wunderlich" , "Simon Glass" 
>>> , "Philipp Tomsich" , "Kever 
>>> Yang" , "Marek Vasut" , "Jonas 
>>> Karlman" 
>>> Betreff: [PATCH v3] board: rockchip: Add Bananapi R2Pro Board
>>> 
>>> From: Frank Wunderlich 
>>> 
>>> Add Bananapi R2 Pro board.
>>> 
>>> Till now evb dts could be used, but iodomain is different
>>> (evb has 1v8 on vccio2 and vccio4 which are 3v3 on r2pro)
>>> and with iodomain driver this can cause hardware fault.
>>> 
>>> Devicetree in mainline-Linux:
>>> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/arm64/boot/dts/rockchip/rk3568-bpi-r2-pro.dts
>
>What would be real helpful is a commit ID from which the DT was copied , so it 
>can be easily updated in the future.

It is no plain copy...i removed parts not relevant for uboot now (from current 
linux version). E.g. switch driver is currently bundled in mtk ethernet driver 
and using different devicetree structure than linux dsa driver. We have to 
separate it before we can use it on r2pro. But this will take some time...also 
pcie(-phy) does not have a driver yet,so before adding dead code i dropped 
these parts for now.

regards Frank


Aw: [PATCH v3] board: rockchip: Add Bananapi R2Pro Board

2023-09-16 Thread Frank Wunderlich
Hi,

just a friedly reminder. would be great if it can be merged in next 
uboot-version.

regards Frank


> Gesendet: Sonntag, 20. August 2023 um 18:00 Uhr
> Von: "Frank Wunderlich" 
> An: u-boot@lists.denx.de
> Cc: "Frank Wunderlich" , "Simon Glass" 
> , "Philipp Tomsich" , "Kever 
> Yang" , "Marek Vasut" , "Jonas 
> Karlman" 
> Betreff: [PATCH v3] board: rockchip: Add Bananapi R2Pro Board
>
> From: Frank Wunderlich 
>
> Add Bananapi R2 Pro board.
>
> Till now evb dts could be used, but iodomain is different
> (evb has 1v8 on vccio2 and vccio4 which are 3v3 on r2pro)
> and with iodomain driver this can cause hardware fault.
>
> Devicetree in mainline-Linux:
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/arm64/boot/dts/rockchip/rk3568-bpi-r2-pro.dts
>
> Signed-off-by: Frank Wunderlich 
> ---
> v3:
> - disable gmac0 as switch-driver is not yet ready to attach to the mac
> v2:
> - drop switch-node for now as u-boot driver works differently to linux
> ---
>  arch/arm/dts/Makefile |   3 +-
>  arch/arm/dts/rk3568-bpi-r2pro-u-boot.dtsi |  23 +
>  arch/arm/dts/rk3568-bpi-r2pro.dts | 549 ++
>  configs/bpi-r2pro-rk3568_defconfig| 101 
>  4 files changed, 675 insertions(+), 1 deletion(-)
>  create mode 100644 arch/arm/dts/rk3568-bpi-r2pro-u-boot.dtsi
>  create mode 100644 arch/arm/dts/rk3568-bpi-r2pro.dts
>  create mode 100644 configs/bpi-r2pro-rk3568_defconfig



[PATCH v3] board: rockchip: Add Bananapi R2Pro Board

2023-08-20 Thread Frank Wunderlich
From: Frank Wunderlich 

Add Bananapi R2 Pro board.

Till now evb dts could be used, but iodomain is different
(evb has 1v8 on vccio2 and vccio4 which are 3v3 on r2pro)
and with iodomain driver this can cause hardware fault.

Devicetree in mainline-Linux:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/arm64/boot/dts/rockchip/rk3568-bpi-r2-pro.dts

Signed-off-by: Frank Wunderlich 
---
v3:
- disable gmac0 as switch-driver is not yet ready to attach to the mac
v2:
- drop switch-node for now as u-boot driver works differently to linux
---
 arch/arm/dts/Makefile |   3 +-
 arch/arm/dts/rk3568-bpi-r2pro-u-boot.dtsi |  23 +
 arch/arm/dts/rk3568-bpi-r2pro.dts | 549 ++
 configs/bpi-r2pro-rk3568_defconfig| 101 
 4 files changed, 675 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/dts/rk3568-bpi-r2pro-u-boot.dtsi
 create mode 100644 arch/arm/dts/rk3568-bpi-r2pro.dts
 create mode 100644 configs/bpi-r2pro-rk3568_defconfig

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index bd518064f35f..767bf9db39fb 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -182,7 +182,8 @@ dtb-$(CONFIG_ROCKCHIP_RK3568) += \
rk3568-nanopi-r5s.dtb \
rk3568-odroid-m1.dtb \
rk3568-radxa-e25.dtb \
-   rk3568-rock-3a.dtb
+   rk3568-rock-3a.dtb \
+   rk3568-bpi-r2pro.dtb
 
 dtb-$(CONFIG_ROCKCHIP_RK3588) += \
rk3588-edgeble-neu6a-io.dtb \
diff --git a/arch/arm/dts/rk3568-bpi-r2pro-u-boot.dtsi 
b/arch/arm/dts/rk3568-bpi-r2pro-u-boot.dtsi
new file mode 100644
index ..382a52a28b10
--- /dev/null
+++ b/arch/arm/dts/rk3568-bpi-r2pro-u-boot.dtsi
@@ -0,0 +1,23 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * (C) Copyright 2021 Rockchip Electronics Co., Ltd
+ */
+
+#include "rk356x-u-boot.dtsi"
+
+/ {
+   chosen {
+   stdout-path = 
+   u-boot,spl-boot-order = "same-as-spl", , 
+   };
+};
+
+ {
+   status = "okay";
+};
+
+ {
+   clock-frequency = <2400>;
+   bootph-pre-ram;
+   status = "okay";
+};
diff --git a/arch/arm/dts/rk3568-bpi-r2pro.dts 
b/arch/arm/dts/rk3568-bpi-r2pro.dts
new file mode 100644
index ..e4fcbb8a1174
--- /dev/null
+++ b/arch/arm/dts/rk3568-bpi-r2pro.dts
@@ -0,0 +1,549 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Author: Frank Wunderlich 
+ *
+ */
+
+/dts-v1/;
+#include 
+#include 
+#include 
+#include "rk3568.dtsi"
+
+/ {
+   model = "Bananapi-R2 Pro (RK3568) DDR4 Board";
+   compatible = "rockchip,rk3568-bpi-r2pro", "rockchip,rk3568";
+
+   aliases {
+   ethernet0 = 
+   ethernet1 = 
+   mmc0 = 
+   mmc1 = 
+   };
+
+   chosen: chosen {
+   stdout-path = "serial2:150n8";
+   };
+
+   leds {
+   compatible = "gpio-leds";
+   pinctrl-names = "default";
+   pinctrl-0 = <_led_pin _led_pin>;
+
+   blue_led: led-0 {
+   color = ;
+   default-state = "off";
+   function = LED_FUNCTION_STATUS;
+   gpios = < RK_PD6 GPIO_ACTIVE_HIGH>;
+   };
+
+   green_led: led-1 {
+   color = ;
+   default-state = "on";
+   function = LED_FUNCTION_POWER;
+   gpios = < RK_PD5 GPIO_ACTIVE_HIGH>;
+   };
+   };
+
+   dc_12v: dc-12v-regulator {
+   compatible = "regulator-fixed";
+   regulator-name = "dc_12v";
+   regulator-always-on;
+   regulator-boot-on;
+   regulator-min-microvolt = <1200>;
+   regulator-max-microvolt = <1200>;
+   };
+
+   vcc3v3_sys: vcc3v3-sys-regulator {
+   compatible = "regulator-fixed";
+   regulator-name = "vcc3v3_sys";
+   regulator-always-on;
+   regulator-boot-on;
+   regulator-min-microvolt = <330>;
+   regulator-max-microvolt = <330>;
+   vin-supply = <_12v>;
+   };
+
+   vcc5v0_sys: vcc5v0-sys-regulator {
+   compatible = "regulator-fixed";
+   regulator-name = "vcc5v0_sys";
+   regulator-always-on;
+   regulator-boot-on;
+   regulator-min-microvolt = <500>;
+   regulator-max-microvolt = <500>;
+   vin-supply = <_12v>;
+   };
+
+   vcc5v0_usb: vcc5v0-usb-regulator {
+   compatible = "regulator-fixed";
+   regulator-name = "vcc5v0_usb&quo

Re: [PATCH] arm: dts: mediatek: convert gmac link mode to 2500base-x for r3

2023-08-18 Thread Frank Wunderlich
Am 18. August 2023 19:49:45 MESZ schrieb Tom Rini :
>On Thu, Aug 03, 2023 at 06:52:58PM +0200, Frank Wunderlich wrote:
>
>> From: Frank Wunderlich 
>> 
>> Ethernet on Bananapi-r3 is broken after
>> 
>> commit bd70f3cea353 ("net: mediatek: add support for SGMII 1Gbps 
>> auto-negotiation mode")
>> 
>> because changes from this commit were not applied to bpi-r3 devicetree too:
>> 
>> commit aef54ea16cac ("arm: dts: medaitek: convert gmac link mode to 
>> 2500base-x")
>> 
>> Signed-off-by: Frank Wunderlich 
>> Reviewed-by: Weijie Gao 
>
>Applied to u-boot/next, thanks!
>
>-- 
>Tom

Thx,but this leaves ethernet broken on 2023.10 for r3...could this be added to 
this release too?

regards Frank


Re: [PATCH v1] board: rockchip: Add Bananapi R2Pro Board

2023-08-13 Thread Frank Wunderlich
Am 12. August 2023 03:50:14 MESZ schrieb Kever Yang :
>Hi Frank,
>
>On 2023/8/8 01:14, Frank Wunderlich wrote:
>> From: Frank Wunderlich 
>> 
>> Add rk3568 based Bananapi R2 Pro board.
>> 
>> Signed-off-by: Frank Wunderlich 
>> ---
>> because iodomain is different to evb and now iodomain driver is sent as
>> patch we need to separate between EVB and R2Pro else board can be bricked.
>What's the detail difference before and after the iodomain driver for this 
>board?

Sorry, missed this question somehow.

Evb defines these iodomains

_io_domains {
pmuio1-supply = <_pmu>;
pmuio2-supply = <_pmu>;
vccio1-supply = <_acodec>;
vccio2-supply = <_1v8>;
vccio3-supply = <_sd>;
vccio4-supply = <_1v8>;
vccio5-supply = <_3v3>;
vccio6-supply = <_1v8>;
vccio7-supply = <_3v3>;
status = "okay";
};

So vccio2 and vccio4 are 1v8 too which will brick these 2 io if still using 
this dts on r2pro which has these 2 3v3 (default).

>> diff --git a/arch/arm/dts/rk3568-bpi-r2pro.dts 
>> b/arch/arm/dts/rk3568-bpi-r2pro.dts
>> new file mode 100644
>> index ..9295e9836a56
>> --- /dev/null
>> +++ b/arch/arm/dts/rk3568-bpi-r2pro.dts
...
>> +_io_domains {
>> +pmuio1-supply = <_pmu>;
>> +pmuio2-supply = <_pmu>;
>> +vccio1-supply = <_acodec>;
>> +vccio3-supply = <_sd>;
>> +vccio4-supply = <_3v3>;
>> +vccio5-supply = <_3v3>;
>> +vccio6-supply = <_1v8>;
>> +vccio7-supply = <_3v3>;
>> +status = "okay";
>> +};


regards Frank


Aw: Re: [PATCH v1] board: rockchip: Add Bananapi R2Pro Board

2023-08-12 Thread Frank Wunderlich
Hi

> Gesendet: Samstag, 12. August 2023 um 03:50 Uhr
> Von: "Kever Yang" 
> An: "Frank Wunderlich" , u-boot@lists.denx.de
> Cc: "Frank Wunderlich" , "Simon Glass" 
> , "Philipp Tomsich" , "Jonas 
> Karlman" , "Jagan Teki" , "zhangqing" 
> 
> Betreff: Re: [PATCH v1] board: rockchip: Add Bananapi R2Pro Board
>
> Hi Frank,
> 
> On 2023/8/8 01:14, Frank Wunderlich wrote:
> > From: Frank Wunderlich 
> >
> > Add rk3568 based Bananapi R2 Pro board.
> >
> > Signed-off-by: Frank Wunderlich 
> > ---
> > because iodomain is different to evb and now iodomain driver is sent as
> > patch we need to separate between EVB and R2Pro else board can be bricked.
> What's the detail difference before and after the iodomain driver for 
> this board?
> > ---
> >   arch/arm/dts/Makefile |   3 +-
> >   arch/arm/dts/rk3568-bpi-r2pro-u-boot.dtsi |  23 +
> >   arch/arm/dts/rk3568-bpi-r2pro.dts | 597 ++
> 
>      Does this dts already available in mainline kernel, if yes, please 
> add info in commit message.

yes:

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/arm64/boot/dts/rockchip/rk3568-bpi-r2-pro.dts

should i really add this link to commit description?

i tried to leave dts compatible with linux dts and only added relevant parts, 
but switch-driver works differently in 
uboot so i dropped it in v2 (and plan to disable gmac in v3). have not yet 
tried ethernet. only bootup, usb and sata 
(mmc is same as evb).

as u-boot doesn't care iodomain till jonas patches i have used evb 
devicetree/defconfig, but if this gets activated 
and users do not recognize this they brick their board. So imho this should be 
added before iodomain gets enabled in 
evb defconfig.

> Thanks,
> 
> - Kever



Aw: Re: [PATCH v2] board: rockchip: Add Bananapi R2Pro Board

2023-08-08 Thread Frank Wunderlich
Hi

thx for first look

> Gesendet: Dienstag, 08. August 2023 um 13:18 Uhr
> Von: "Eugen Hristev" 
> Hi Frank,
>
> On 8/8/23 11:09, Frank Wunderlich wrote:
> > From: Frank Wunderlich 
> >
> > Add Bananapi R2 Pro board.
> >
> > Signed-off-by: Frank Wunderlich 
> > ---
> > because iodomain is different to evb and now iodomain driver is sent as
> > patch we need to separate between EVB and R2Pro else board can be bricked.
> > ---
> > v2:
> > - drop switch-node for now as u-boot driver works differently to linux
> > ---
> >   arch/arm/dts/Makefile |   3 +-
> >   arch/arm/dts/rk3568-bpi-r2pro-u-boot.dtsi |  23 +
> >   arch/arm/dts/rk3568-bpi-r2pro.dts | 549 ++
> >   configs/bpi-r2pro-rk3568_defconfig| 101 
> >   4 files changed, 675 insertions(+), 1 deletion(-)
> >   create mode 100644 arch/arm/dts/rk3568-bpi-r2pro-u-boot.dtsi
> >   create mode 100644 arch/arm/dts/rk3568-bpi-r2pro.dts
> >   create mode 100644 configs/bpi-r2pro-rk3568_defconfig
> >
> > diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
> > index bd518064f35f..767bf9db39fb 100644
> > --- a/arch/arm/dts/Makefile
> > +++ b/arch/arm/dts/Makefile
> > @@ -182,7 +182,8 @@ dtb-$(CONFIG_ROCKCHIP_RK3568) += \
> > rk3568-nanopi-r5s.dtb \
> > rk3568-odroid-m1.dtb \
> > rk3568-radxa-e25.dtb \
> > -   rk3568-rock-3a.dtb
> > +   rk3568-rock-3a.dtb \
> > +   rk3568-bpi-r2pro.dtb
> >
> >   dtb-$(CONFIG_ROCKCHIP_RK3588) += \
> > rk3588-edgeble-neu6a-io.dtb \
> > diff --git a/arch/arm/dts/rk3568-bpi-r2pro-u-boot.dtsi 
> > b/arch/arm/dts/rk3568-bpi-r2pro-u-boot.dtsi
> > new file mode 100644
> > index ..382a52a28b10
> > --- /dev/null
> > +++ b/arch/arm/dts/rk3568-bpi-r2pro-u-boot.dtsi
> > @@ -0,0 +1,23 @@
> > +// SPDX-License-Identifier: GPL-2.0+
> > +/*
> > + * (C) Copyright 2021 Rockchip Electronics Co., Ltd
> > + */
> > +
> > +#include "rk356x-u-boot.dtsi"
>
> Isn't rk356x-u-boot.dtsi automatically included if rk356x.dtsi is included ?

afaik this -u-boot file is for SPL and i need it to boot successful. This adds 
nodes for DRAM and
MMC needed in first boot stage.

I based this file, dts and defconfig on the EVB.

> > +
> > +/ {
> > +   chosen {
> > +   stdout-path = 
> > +   u-boot,spl-boot-order = "same-as-spl", , 
> > +   };
> > +};
> > +
> > + {
> > +   status = "okay";
> > +};
> > +
> > + {
> > +   clock-frequency = <2400>;
> > +   bootph-pre-ram;
> > +   status = "okay";
> > +};
> > diff --git a/arch/arm/dts/rk3568-bpi-r2pro.dts 
> > b/arch/arm/dts/rk3568-bpi-r2pro.dts
> > new file mode 100644
> > index ..d99f29ab0bcb
> > --- /dev/null
> > +++ b/arch/arm/dts/rk3568-bpi-r2pro.dts
> > @@ -0,0 +1,549 @@
> > +// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
> > +/*
> > + * Author: Frank Wunderlich 
> > + *
> > + */
> > +
> > +/dts-v1/;
> > +#include 
> > +#include 
> > +#include 
> > +#include "rk3568.dtsi"
> ... as it's included here and rk3568.dtsi includes rk356x.dtsi

yes, but this DTS is used for second stage and not taken for SPL.

> > diff --git a/configs/bpi-r2pro-rk3568_defconfig 
> > b/configs/bpi-r2pro-rk3568_defconfig
> > new file mode 100644
> > index ..e8936261eab3
> > --- /dev/null
> > +++ b/configs/bpi-r2pro-rk3568_defconfig
> > @@ -0,0 +1,101 @@
> > +CONFIG_ARM=y
> > +CONFIG_SKIP_LOWLEVEL_INIT=y
> > +CONFIG_COUNTER_FREQUENCY=2400
> > +CONFIG_ARCH_ROCKCHIP=y
> > +CONFIG_TEXT_BASE=0x00a0
> > +CONFIG_SPL_LIBCOMMON_SUPPORT=y
> > +CONFIG_SPL_LIBGENERIC_SUPPORT=y
> > +CONFIG_NR_DRAM_BANKS=2
> > +CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
> > +CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0xc0
> > +CONFIG_DEFAULT_DEVICE_TREE="rk3568-bpi-r2pro"
> > +CONFIG_ROCKCHIP_RK3568=y
> > +CONFIG_SPL_ROCKCHIP_COMMON_BOARD=y
> > +CONFIG_SPL_SERIAL=y
> > +CONFIG_SPL_STACK_R_ADDR=0x60
> > +CONFIG_SPL_STACK=0x40
> > +CONFIG_DEBUG_UART_BASE=0xFE66
> > +CONFIG_DEBUG_UART_CLOCK=2400
> > +CONFIG_SYS_LOAD_ADDR=0xc00800
> > +CONFIG_DEBUG_UART=y
> > +CONFIG_FIT=y
> > +CONFIG_FIT_VERBOSE=y
> > +CONFIG_SPL_FIT_SIGNATURE=y
> > +CONFIG_SPL_LOAD_FIT=y
> > +CONFIG_LEGACY_IMAGE_FORMAT=y
> > +#CONFIG_OF_SYSTEM_SETUP=y
> > +CONFIG_DEFAULT_FDT_FILE=&quo

[PATCH v2] board: rockchip: Add Bananapi R2Pro Board

2023-08-08 Thread Frank Wunderlich
From: Frank Wunderlich 

Add Bananapi R2 Pro board.

Signed-off-by: Frank Wunderlich 
---
because iodomain is different to evb and now iodomain driver is sent as
patch we need to separate between EVB and R2Pro else board can be bricked.
---
v2:
- drop switch-node for now as u-boot driver works differently to linux
---
 arch/arm/dts/Makefile |   3 +-
 arch/arm/dts/rk3568-bpi-r2pro-u-boot.dtsi |  23 +
 arch/arm/dts/rk3568-bpi-r2pro.dts | 549 ++
 configs/bpi-r2pro-rk3568_defconfig| 101 
 4 files changed, 675 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/dts/rk3568-bpi-r2pro-u-boot.dtsi
 create mode 100644 arch/arm/dts/rk3568-bpi-r2pro.dts
 create mode 100644 configs/bpi-r2pro-rk3568_defconfig

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index bd518064f35f..767bf9db39fb 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -182,7 +182,8 @@ dtb-$(CONFIG_ROCKCHIP_RK3568) += \
rk3568-nanopi-r5s.dtb \
rk3568-odroid-m1.dtb \
rk3568-radxa-e25.dtb \
-   rk3568-rock-3a.dtb
+   rk3568-rock-3a.dtb \
+   rk3568-bpi-r2pro.dtb
 
 dtb-$(CONFIG_ROCKCHIP_RK3588) += \
rk3588-edgeble-neu6a-io.dtb \
diff --git a/arch/arm/dts/rk3568-bpi-r2pro-u-boot.dtsi 
b/arch/arm/dts/rk3568-bpi-r2pro-u-boot.dtsi
new file mode 100644
index ..382a52a28b10
--- /dev/null
+++ b/arch/arm/dts/rk3568-bpi-r2pro-u-boot.dtsi
@@ -0,0 +1,23 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * (C) Copyright 2021 Rockchip Electronics Co., Ltd
+ */
+
+#include "rk356x-u-boot.dtsi"
+
+/ {
+   chosen {
+   stdout-path = 
+   u-boot,spl-boot-order = "same-as-spl", , 
+   };
+};
+
+ {
+   status = "okay";
+};
+
+ {
+   clock-frequency = <2400>;
+   bootph-pre-ram;
+   status = "okay";
+};
diff --git a/arch/arm/dts/rk3568-bpi-r2pro.dts 
b/arch/arm/dts/rk3568-bpi-r2pro.dts
new file mode 100644
index ..d99f29ab0bcb
--- /dev/null
+++ b/arch/arm/dts/rk3568-bpi-r2pro.dts
@@ -0,0 +1,549 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Author: Frank Wunderlich 
+ *
+ */
+
+/dts-v1/;
+#include 
+#include 
+#include 
+#include "rk3568.dtsi"
+
+/ {
+   model = "Bananapi-R2 Pro (RK3568) DDR4 Board";
+   compatible = "rockchip,rk3568-bpi-r2pro", "rockchip,rk3568";
+
+   aliases {
+   ethernet0 = 
+   ethernet1 = 
+   mmc0 = 
+   mmc1 = 
+   };
+
+   chosen: chosen {
+   stdout-path = "serial2:150n8";
+   };
+
+   leds {
+   compatible = "gpio-leds";
+   pinctrl-names = "default";
+   pinctrl-0 = <_led_pin _led_pin>;
+
+   blue_led: led-0 {
+   color = ;
+   default-state = "off";
+   function = LED_FUNCTION_STATUS;
+   gpios = < RK_PD6 GPIO_ACTIVE_HIGH>;
+   };
+
+   green_led: led-1 {
+   color = ;
+   default-state = "on";
+   function = LED_FUNCTION_POWER;
+   gpios = < RK_PD5 GPIO_ACTIVE_HIGH>;
+   };
+   };
+
+   dc_12v: dc-12v-regulator {
+   compatible = "regulator-fixed";
+   regulator-name = "dc_12v";
+   regulator-always-on;
+   regulator-boot-on;
+   regulator-min-microvolt = <1200>;
+   regulator-max-microvolt = <1200>;
+   };
+
+   vcc3v3_sys: vcc3v3-sys-regulator {
+   compatible = "regulator-fixed";
+   regulator-name = "vcc3v3_sys";
+   regulator-always-on;
+   regulator-boot-on;
+   regulator-min-microvolt = <330>;
+   regulator-max-microvolt = <330>;
+   vin-supply = <_12v>;
+   };
+
+   vcc5v0_sys: vcc5v0-sys-regulator {
+   compatible = "regulator-fixed";
+   regulator-name = "vcc5v0_sys";
+   regulator-always-on;
+   regulator-boot-on;
+   regulator-min-microvolt = <500>;
+   regulator-max-microvolt = <500>;
+   vin-supply = <_12v>;
+   };
+
+   vcc5v0_usb: vcc5v0-usb-regulator {
+   compatible = "regulator-fixed";
+   regulator-name = "vcc5v0_usb";
+   regulator-always-on;
+   regulator-boot-on;
+   regulator-min-microvolt = <500>;
+   regulator-max-microvolt = <500>;
+   vin-supply = <_12v>;
+   };
+
+   vcc5v0_usb_host:

Aw: Re: [PATCH v1] board: rockchip: Add Bananapi R2Pro Board

2023-08-07 Thread Frank Wunderlich
> Gesendet: Montag, 07. August 2023 um 19:20 Uhr
> Von: "Pali Rohár" 
> Could you stop sending me these rockchip emails? What is not
> understandable on the fact that I'm not rockchip maintainer?
> https://lists.denx.de/pipermail/u-boot/2023-March/511199.html
> https://lists.denx.de/pipermail/u-boot/2023-April/515012.html

sorry, but maintainer.pl returns you for the changes 
(added_lines:16/181=9%,removed_lines:12/62=19%)...not maintainer, but because 
of email i thought it could be interesting for you too...sorry about that.

maintainers.pl imho should not return you here (i guess because of 
vendor-independ arm/dts directory/makefile).

Dropped some more people from thread which may not involved into 
rockchip-changes.

maybe this should be changed like linux kernel does for arm64 
(dts//...)? then maintainer-script can show the right people here.

regards Frank


[PATCH v1] board: rockchip: Add Bananapi R2Pro Board

2023-08-07 Thread Frank Wunderlich
From: Frank Wunderlich 

Add rk3568 based Bananapi R2 Pro board.

Signed-off-by: Frank Wunderlich 
---
because iodomain is different to evb and now iodomain driver is sent as
patch we need to separate between EVB and R2Pro else board can be bricked.
---
 arch/arm/dts/Makefile |   3 +-
 arch/arm/dts/rk3568-bpi-r2pro-u-boot.dtsi |  23 +
 arch/arm/dts/rk3568-bpi-r2pro.dts | 597 ++
 configs/bpi-r2pro-rk3568_defconfig| 101 
 4 files changed, 723 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/dts/rk3568-bpi-r2pro-u-boot.dtsi
 create mode 100644 arch/arm/dts/rk3568-bpi-r2pro.dts
 create mode 100644 configs/bpi-r2pro-rk3568_defconfig

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 8f43dba58632..1bd48a7e0535 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -182,7 +182,8 @@ dtb-$(CONFIG_ROCKCHIP_RK3568) += \
rk3568-nanopi-r5s.dtb \
rk3568-odroid-m1.dtb \
rk3568-radxa-e25.dtb \
-   rk3568-rock-3a.dtb
+   rk3568-rock-3a.dtb \
+   rk3568-bpi-r2pro.dtb
 
 dtb-$(CONFIG_ROCKCHIP_RK3588) += \
rk3588-edgeble-neu6a-io.dtb \
diff --git a/arch/arm/dts/rk3568-bpi-r2pro-u-boot.dtsi 
b/arch/arm/dts/rk3568-bpi-r2pro-u-boot.dtsi
new file mode 100644
index ..382a52a28b10
--- /dev/null
+++ b/arch/arm/dts/rk3568-bpi-r2pro-u-boot.dtsi
@@ -0,0 +1,23 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * (C) Copyright 2021 Rockchip Electronics Co., Ltd
+ */
+
+#include "rk356x-u-boot.dtsi"
+
+/ {
+   chosen {
+   stdout-path = 
+   u-boot,spl-boot-order = "same-as-spl", , 
+   };
+};
+
+ {
+   status = "okay";
+};
+
+ {
+   clock-frequency = <2400>;
+   bootph-pre-ram;
+   status = "okay";
+};
diff --git a/arch/arm/dts/rk3568-bpi-r2pro.dts 
b/arch/arm/dts/rk3568-bpi-r2pro.dts
new file mode 100644
index ..9295e9836a56
--- /dev/null
+++ b/arch/arm/dts/rk3568-bpi-r2pro.dts
@@ -0,0 +1,597 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Author: Frank Wunderlich 
+ *
+ */
+
+/dts-v1/;
+#include 
+#include 
+#include 
+#include "rk3568.dtsi"
+
+/ {
+   model = "Bananapi-R2 Pro (RK3568) DDR4 Board";
+   compatible = "rockchip,rk3568-bpi-r2pro", "rockchip,rk3568";
+
+   aliases {
+   ethernet0 = 
+   ethernet1 = 
+   mmc0 = 
+   mmc1 = 
+   };
+
+   chosen: chosen {
+   stdout-path = "serial2:150n8";
+   };
+
+   leds {
+   compatible = "gpio-leds";
+   pinctrl-names = "default";
+   pinctrl-0 = <_led_pin _led_pin>;
+
+   blue_led: led-0 {
+   color = ;
+   default-state = "off";
+   function = LED_FUNCTION_STATUS;
+   gpios = < RK_PD6 GPIO_ACTIVE_HIGH>;
+   };
+
+   green_led: led-1 {
+   color = ;
+   default-state = "on";
+   function = LED_FUNCTION_POWER;
+   gpios = < RK_PD5 GPIO_ACTIVE_HIGH>;
+   };
+   };
+
+   dc_12v: dc-12v-regulator {
+   compatible = "regulator-fixed";
+   regulator-name = "dc_12v";
+   regulator-always-on;
+   regulator-boot-on;
+   regulator-min-microvolt = <1200>;
+   regulator-max-microvolt = <1200>;
+   };
+
+   vcc3v3_sys: vcc3v3-sys-regulator {
+   compatible = "regulator-fixed";
+   regulator-name = "vcc3v3_sys";
+   regulator-always-on;
+   regulator-boot-on;
+   regulator-min-microvolt = <330>;
+   regulator-max-microvolt = <330>;
+   vin-supply = <_12v>;
+   };
+
+   vcc5v0_sys: vcc5v0-sys-regulator {
+   compatible = "regulator-fixed";
+   regulator-name = "vcc5v0_sys";
+   regulator-always-on;
+   regulator-boot-on;
+   regulator-min-microvolt = <500>;
+   regulator-max-microvolt = <500>;
+   vin-supply = <_12v>;
+   };
+
+   vcc5v0_usb: vcc5v0-usb-regulator {
+   compatible = "regulator-fixed";
+   regulator-name = "vcc5v0_usb";
+   regulator-always-on;
+   regulator-boot-on;
+   regulator-min-microvolt = <500>;
+   regulator-max-microvolt = <500>;
+   vin-supply = <_12v>;
+   };
+
+   vcc5v0_usb_host: vcc5v0-usb-host-regulator {
+   compatib

[PATCH] arm: mediatek: add usb support for MT7988

2023-08-03 Thread Frank Wunderlich
From: Frank Wunderlich 

MT7988 has a t-phy and an x-phy controller. There is already a driver for
t-phy so we can add USB support for this phy type.

Signed-off-by: Frank Wunderlich 
---
 arch/arm/dts/mt7988.dtsi | 60 
 1 file changed, 60 insertions(+)

diff --git a/arch/arm/dts/mt7988.dtsi b/arch/arm/dts/mt7988.dtsi
index ddd629e8c99d..ac476d5cdd7f 100644
--- a/arch/arm/dts/mt7988.dtsi
+++ b/arch/arm/dts/mt7988.dtsi
@@ -9,6 +9,7 @@
 #include 
 #include 
 #include 
+#include 
 
 / {
compatible = "mediatek,mt7988-rfb";
@@ -161,6 +162,65 @@
#clock-cells = <1>;
};
 
+   dummy_clk: dummy12m {
+   compatible = "fixed-clock";
+   clock-frequency = <1200>;
+   #clock-cells = <0>;
+   /* must need this line, or uart uanable to get dummy_clk */
+   bootph-all;
+   };
+
+   xhci1: xhci@1120 {
+   compatible = "mediatek,mt7988-xhci",
+"mediatek,mtk-xhci";
+   reg = <0 0x1120 0 0x2e00>,
+ <0 0x11203e00 0 0x0100>;
+   reg-names = "mac", "ippc";
+   interrupts = ;
+   phys = < PHY_TYPE_USB2>,
+  < PHY_TYPE_USB3>;
+   clocks = <_clk>,
+<_clk>,
+<_clk>,
+<_clk>,
+<_clk>;
+   clock-names = "sys_ck",
+ "xhci_ck",
+ "ref_ck",
+ "mcu_ck",
+ "dma_ck";
+   #address-cells = <2>;
+   #size-cells = <2>;
+   status = "okay";
+   };
+
+   usbtphy: usb-phy@11c5 {
+   compatible = "mediatek,mt7988",
+"mediatek,generic-tphy-v2";
+   #address-cells = <2>;
+   #size-cells = <2>;
+   ranges;
+   status = "okay";
+
+   tphyu2port0: usb-phy@11c5 {
+   reg = <0 0x11c5 0 0x700>;
+   clocks = <_clk>;
+   clock-names = "ref";
+   #phy-cells = <1>;
+   status = "okay";
+   };
+
+   tphyu3port0: usb-phy@11c50700 {
+   reg = <0 0x11c50700 0 0x900>;
+   clocks = <_clk>;
+   clock-names = "ref";
+   #phy-cells = <1>;
+   mediatek,usb3-pll-ssc-delta;
+   mediatek,usb3-pll-ssc-delta1;
+   status = "okay";
+   };
+   };
+
xfi_pextp0: syscon@11f2 {
compatible = "mediatek,mt7988-xfi_pextp_0", "syscon";
reg = <0 0x11f2 0 0x1>;
-- 
2.34.1



[PATCH] arm: dts: mediatek: convert gmac link mode to 2500base-x for r3

2023-08-03 Thread Frank Wunderlich
From: Frank Wunderlich 

Ethernet on Bananapi-r3 is broken after

commit bd70f3cea353 ("net: mediatek: add support for SGMII 1Gbps 
auto-negotiation mode")

because changes from this commit were not applied to bpi-r3 devicetree too:

commit aef54ea16cac ("arm: dts: medaitek: convert gmac link mode to 2500base-x")

Signed-off-by: Frank Wunderlich 
---
 arch/arm/dts/mt7986a-bpi-r3-sd.dts | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/dts/mt7986a-bpi-r3-sd.dts 
b/arch/arm/dts/mt7986a-bpi-r3-sd.dts
index 15256302b86b..c156a8136343 100644
--- a/arch/arm/dts/mt7986a-bpi-r3-sd.dts
+++ b/arch/arm/dts/mt7986a-bpi-r3-sd.dts
@@ -76,12 +76,12 @@
  {
status = "okay";
mediatek,gmac-id = <0>;
-   phy-mode = "sgmii";
+   phy-mode = "2500base-x";
mediatek,switch = "mt7531";
reset-gpios = < 5 GPIO_ACTIVE_HIGH>;
 
fixed-link {
-   speed = <1000>;
+   speed = <2500>;
full-duplex;
};
 };
-- 
2.34.1



Aw: Re: [PATCH 21/29] arm: dts: medaitek: convert gmac link mode to 2500base-x

2023-07-20 Thread Frank Wunderlich
Gesendet: Donnerstag, 20. Juli 2023 um 02:58 Uhr
Von: "Weijie Gao (高惟杰)" 
> > On Wed, 2023-07-19 at 14:08 +0200, Frank Wunderlich wrote:

> > noticed some build-warnings from the pinctrl-patch which are not
> > critical, but should be fixed.
> > 
> > e.g. this (seems for each call of PINCTRL_PIN_GROUP)
> > 
> > drivers/pinctrl/mediatek/pinctrl-mt7988.c:1148:42: warning:
> > initialization discards 'const' qualifier from pointer target type [-
> > Wdiscarded-qualifiers]
> >  1148 |  PINCTRL_PIN_GROUP("net_wo1_uart_txd_1",
> > mt7988_net_wo1_uart_txd_1),
> >   |  ^~~~
> > ~
> > drivers/pinctrl/mediatek/pinctrl-mtk-common.h:31:3: note: in
> > definition of macro 'PINCTRL_PIN_GROUP'
> >31 |   id##_funcs,  \
> >   |   ^~

> This is due to on of the patch was missing because its size exceeds
> 100KB. Please refer to:
> https://patchwork.ozlabs.org/project/uboot/patch/7c0cfbdeb17abcf805138eb69be583d5a068231b.1689756363.git.weijie@mediatek.com/

> I have to split it into two patches in v2.

indeed, part 12 was missing in my series-export from patchwork...all clean 
after applying it. thx for pointing to it.

regards Frank


Aw: [PATCH 21/29] arm: dts: medaitek: convert gmac link mode to 2500base-x

2023-07-19 Thread Frank Wunderlich
Hi

> Gesendet: Mittwoch, 19. Juli 2023 um 11:17 Uhr
> Von: "Weijie Gao" 
> An: u-boot@lists.denx.de
> Cc: "GSS_MTK_Uboot_upstream" , "Daniel 
> Golle" , "Frank Wunderlich" , "Weijie 
> Gao" 
> Betreff: [PATCH 21/29] arm: dts: medaitek: convert gmac link mode to 
> 2500base-x
>
> Now that individual 2.5Gbps SGMII support has been added to
> mtk-eth, all boards that use 2.5Gbps link with mt7531 must be
> converted to use "2500base-x" instead of "sgmii".
>
> Signed-off-by: Weijie Gao 
> ---
>  arch/arm/dts/mt7622-bananapi-bpi-r64.dts | 4 ++--
>  arch/arm/dts/mt7622-rfb.dts  | 4 ++--
>  arch/arm/dts/mt7629-rfb.dts  | 4 ++--
>  arch/arm/dts/mt7981-emmc-rfb.dts | 4 ++--
>  arch/arm/dts/mt7981-rfb.dts  | 4 ++--
>  arch/arm/dts/mt7981-sd-rfb.dts   | 4 ++--
>  arch/arm/dts/mt7986a-rfb.dts | 4 ++--
>  arch/arm/dts/mt7986a-sd-rfb.dts  | 4 ++--
>  arch/arm/dts/mt7986b-rfb.dts | 4 ++--
>  arch/arm/dts/mt7986b-sd-rfb.dts  | 4 ++--

you miss arch/arm/dts/mt7986a-bpi-r3-sd.dts here which was added in 2023.07

i tested series on Bananapi-R4/mt7988, sdcard and network-support (many thx for 
this) works so far (not tested i2c, spi and others yet), also have not done 
tests on my other boards yet.

noticed some build-warnings from the pinctrl-patch which are not critical, but 
should be fixed.

e.g. this (seems for each call of PINCTRL_PIN_GROUP)

drivers/pinctrl/mediatek/pinctrl-mt7988.c:1148:42: warning: initialization 
discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
 1148 |  PINCTRL_PIN_GROUP("net_wo1_uart_txd_1", mt7988_net_wo1_uart_txd_1),
  |  ^
drivers/pinctrl/mediatek/pinctrl-mtk-common.h:31:3: note: in definition of 
macro 'PINCTRL_PIN_GROUP'
   31 |   id##_funcs,  \
  |   ^~


regards Frank


Aw: [PATCH 21/29] arm: dts: medaitek: convert gmac link mode to 2500base-x

2023-07-19 Thread Frank Wunderlich
Hi,

thank you very much for your work on mt7988 support and faster than expected ;)
Nice to see that ethernet-support is already included, i see some changes to 
mt753x..

I will try out this series as fast as possible.

> Gesendet: Mittwoch, 19. Juli 2023 um 11:17 Uhr
> Von: "Weijie Gao" 
> An: u-boot@lists.denx.de
> Cc: "GSS_MTK_Uboot_upstream" , "Daniel 
> Golle" , "Frank Wunderlich" , "Weijie 
> Gao" 
> Betreff: [PATCH 21/29] arm: dts: medaitek: convert gmac link mode to 
> 2500base-x

so far only noticed a typo (medaitek => mediatek) in this part here

regards Frank

> Now that individual 2.5Gbps SGMII support has been added to
> mtk-eth, all boards that use 2.5Gbps link with mt7531 must be
> converted to use "2500base-x" instead of "sgmii".
>
> Signed-off-by: Weijie Gao 



Re: [ANN] U-Boot v2023.07 released

2023-07-11 Thread Frank Wunderlich
Hi,

Btw. Githubs dependa-bot reports some security related issues with pythons 
setup-tools. As far as i see it should only affects tests...as i don't use the 
tests i cannot say if it breaks anything and so not send a patch in ML.

maybe this can be done directly in original uboot repo.

https://github.com/frank-w/u-boot/pull/6

I hope this way of reporting is ok :)
regards Frank


Aw: Re: Re: Re: distro_boot vs. env-based bootmenu

2023-07-01 Thread Frank Wunderlich
Hi Jonas

thx again for your valuable answer

> Gesendet: Samstag, 01. Juli 2023 um 10:12 Uhr
> Von: "Jonas Karlman" 
> An: "Frank Wunderlich" 
> Cc: "Simon Glass" , "U-Boot Mailing List" 
> , "Heinrich Schuchardt" 
> , "Ilias Apalodimas" 
> 
> Betreff: Re: Aw: Re: Re: distro_boot vs. env-based bootmenu
>
> Hi Frank,
> On 2023-06-30 19:51, Frank Wunderlich wrote:
> > Hi Jonas
> > 
> > sorry for the delay. i came back to this and tried your way. Thx for your 
> > information...there is no real example in the docs (or i didn't found it) 
> > for manual trigger the extlinux-boot, so your information helps a lot.
> > 
> >> Gesendet: Sonntag, 30. April 2023 um 19:40 Uhr
> >> Von: "Jonas Karlman" 
> >> An: "Frank Wunderlich" , "Simon Glass" 
> >> 
> >> Cc: "U-Boot Mailing List" , "Heinrich Schuchardt" 
> >> , "Ilias Apalodimas" 
> >> 
> >> Betreff: Re: Aw: Re: distro_boot vs. env-based bootmenu
> >>
> >> Hi Frank,
> >>
> >> On 2023-04-30 15:25, Frank Wunderlich wrote:
> >>> Hi
> >>>
> >>> I tried to find out why distroboot is enabled (i have not set it in my 
> >>> defconfig) and i think this is why:
> >>>
> >>>   │ Symbol: DISTRO_DEFAULTS [=y]  
> >>>   │  
> >>>   │ Type  : bool  
> >>>   │  
> >>>   │ Prompt: Select defaults suitable for booting general purpose Linux 
> >>> dist │  
> >>>   │   Location:   
> >>>   │  
> >>>   │ (3) -> Boot options   
> >>>   │  
> >>>   │   Defined at boot/Kconfig:833 
> >>>   │  
> >>>   │   Selects: BOOT_DEFAULTS [=y] && AUTO_COMPLETE [=y] && 
> >>> CMDLINE_EDITING  │  
> >>>   │   Implied by [y]: 
> >>>   │  
> >>>   │   - ARCH_ROCKCHIP [=y] &&  && !ROCKCHIP_RK3399 [=n]
> >>>
> >>> as far as i see you've got a response from Jonas about this option and he 
> >>> changed Kconfig file to BOOTSTD_DEFAULTS
> >>>
> >>> as i have not used BOOTSTD_DEFAULTS before, what needs to be changed to 
> >>> have it working?
> >>
> >> Please update to latest master branch, rk356x is not fully working
> >> with v2023.04 or earlier, especially BOOTSTD without extra CONFIGs.
> >>
> >> With latest master branch CONFIG_BOOTSTD_DEFAULTS=y should be set by
> >> default for all ARCH_ROCKCHIP. And should work very similar to if you
> >> used to have "run distro_bootcmd" as your bootcmd.
> > 
> > As i use builtin-environment there is no distro_bootcmd which i can run.
> >  
> >> It is still unclear what script/bootcmd you are trying to use, or if
> >> you used to have "run distro_bootcmd" as a fallback. Replacing
> >> "run distro_bootcmd" with "bootflow scan -lb" or "bootflow scan"
> >> could work as such fallback option.
> > 
> > but with "bootflow scan -lb" it works except 1 thing: old bootchain looked 
> > in config directory for the files (kernel+fdt) whereas new way looks in 
> > root of partition and now needs additional extlinux prefix.
> 
> This could be related to an issue that was fixed in v2023.07-rc5:
> 
>   bootstd: Fix relative path use in extlinux bootmeth
> 
> See 
> https://source.denx.de/u-boot/u-boot/-/commit/a7e4dffcd8c582bf4344548270d2fc7ac6c0f9ec
> 
> If not then please provide more details, in case this is a bug.

thx, after rebase on rc5 it works as expected...rebased on rc4 a few hours 
before rc5 was relasted :p

as this commit was done by you thx for fixing this ;)

> > 
> > and yes i want distroboot as fallback...
> > 
> > is there a way to avoid this to hold the file compatible?
> 
> The intent is that the new standard boot should be as compatible as
> possible as the old script based distro boot, depending on you boot
> script.
> 
> If you use any of the script part that the old distro boot provided you
> will have to adjust your boot script, e.g. replace "run distro_bootcmd"
> with "bootflow scan -lb" or "bootflow scan", and 

Aw: Re: distro_boot vs. env-based bootmenu

2023-07-01 Thread Frank Wunderlich
Hi

thanks for your anser

> Gesendet: Samstag, 01. Juli 2023 um 04:08 Uhr
> Von: "AKASHI Takahiro" 
> Hi,
>
> On Wed, Apr 12, 2023 at 11:22:23AM +0200, Frank Wunderlich wrote:
> > Hi,
> >
> > i try to move from distro-boot (extlinux-config files) to an env-based 
> > bootmenu (builtin-environment) for
> > my bananapi r2pro.
> >
> > basicly it works, but i see more bootmenu-entries than i have defined in my 
> > environment
> >
> >  *** U-Boot Boot Menu ***
> >
> >   1. Boot from SD/EMMC.
> >   mmc 1:2
> >   mmc 1:3
> >   mmc 1:4
> >   U-Boot consoleHit any key to stop autoboot: 2
> >
> > i have only defined one botmenu-entry (first one in uEnv_r2pro.txt)
> >
> > bootmenu_0=1. Boot from SD/EMMC.=run newboot
> > bootmenu_default=0
> >
> > i guess the 3 mmc 1:x entries are part from distro-boot. i see a series 
> > from simon where he drops
> > distroboot for rockchip-boards.
>
> Probably they came from UEFI's removable media support, specifically
> commit c606c0059f7f
> Author: Masahisa Kojima 
> Date:   Thu Apr 28 17:09:42 2022 +0900
>
> bootmenu: add UEFI boot entry into bootmenu

yes, thats right, disabling efi (that was somehow enabled by default as i do 
not find any EFI in my defconfig)

https://github.com/frank-w/u-boot/blob/2023-07-bpi/configs/evb-rk3568_defconfig

> > https://patchwork.ozlabs.org/project/uboot/patch/20230409084454.v9.8.I4cf7708a1ba953b9abd81375d93af34665c7b251@changeid/
> >
> > can anyone explain me where i can disable the mmc 1:x entries? i wanted to 
> > leave distro_boot as
> > fallback but it seems this is not possible.
>
> Try to disable either CONFIG_CMD_EFICONFIG or CONFIG_CMD_BOOTEFI_BOOTMGR,
> even CONFIG_EFI_LOADER if you don't need UEFI subsystem at all.

disabled CONFIG_EFI_LOADER=n and CONFIG_EFI_LOADER and now the menuitems are 
disappeared and i have no efi-options set

> -Takahiro Akashi

regards Frank


Aw: Re: Re: distro_boot vs. env-based bootmenu

2023-06-30 Thread Frank Wunderlich
Hi Jonas

sorry for the delay. i came back to this and tried your way. Thx for your 
information...there is no real example in the docs (or i didn't found it) for 
manual trigger the extlinux-boot, so your information helps a lot.

> Gesendet: Sonntag, 30. April 2023 um 19:40 Uhr
> Von: "Jonas Karlman" 
> An: "Frank Wunderlich" , "Simon Glass" 
> 
> Cc: "U-Boot Mailing List" , "Heinrich Schuchardt" 
> , "Ilias Apalodimas" 
> 
> Betreff: Re: Aw: Re: distro_boot vs. env-based bootmenu
>
> Hi Frank,
> 
> On 2023-04-30 15:25, Frank Wunderlich wrote:
> > Hi
> > 
> > I tried to find out why distroboot is enabled (i have not set it in my 
> > defconfig) and i think this is why:
> > 
> >   │ Symbol: DISTRO_DEFAULTS [=y]
> > │  
> >   │ Type  : bool
> > │  
> >   │ Prompt: Select defaults suitable for booting general purpose Linux dist 
> > │  
> >   │   Location: 
> > │  
> >   │ (3) -> Boot options 
> > │  
> >   │   Defined at boot/Kconfig:833   
> > │  
> >   │   Selects: BOOT_DEFAULTS [=y] && AUTO_COMPLETE [=y] && CMDLINE_EDITING  
> > │  
> >   │   Implied by [y]:   
> > │  
> >   │   - ARCH_ROCKCHIP [=y] &&  && !ROCKCHIP_RK3399 [=n]
> > 
> > as far as i see you've got a response from Jonas about this option and he 
> > changed Kconfig file to BOOTSTD_DEFAULTS
> > 
> > as i have not used BOOTSTD_DEFAULTS before, what needs to be changed to 
> > have it working?
> 
> Please update to latest master branch, rk356x is not fully working
> with v2023.04 or earlier, especially BOOTSTD without extra CONFIGs.
> 
> With latest master branch CONFIG_BOOTSTD_DEFAULTS=y should be set by
> default for all ARCH_ROCKCHIP. And should work very similar to if you
> used to have "run distro_bootcmd" as your bootcmd.

As i use builtin-environment there is no distro_bootcmd which i can run.
 
> It is still unclear what script/bootcmd you are trying to use, or if
> you used to have "run distro_bootcmd" as a fallback. Replacing
> "run distro_bootcmd" with "bootflow scan -lb" or "bootflow scan"
> could work as such fallback option.

but with "bootflow scan -lb" it works except 1 thing: old bootchain looked in 
config directory for the files (kernel+fdt) whereas new way looks in root of 
partition and now needs additional extlinux prefix.

and yes i want distroboot as fallback...

is there a way to avoid this to hold the file compatible?

why i use the environment bootmenu? i do a bit more in the menuitems (and 
before) e.g. loading a uEnv.txt to override some options
and for testing. have bootargs only defined once, have testkernels with initrd 
and some special stuff with asking for user input
(list kernels from mmc/tftp/... and let user choose which 
kernel/fdt/initrd/...). Such things are imho not possible with extlinux 
way.

currently only bpi-r2pro uses extlinux boot and the other 3 boards using the 
builtin environment bootmenu. So to keep all boards nearly same i want to have 
the same for r2pro but allow users with extlinux still using this.

> > basicly my Plan is to script the bootup via env in script with a bootmenu 
> > (default entry + additional ones which can be 
> > changed by an env.txt file), but i do not want to break existing setups 
> > (using extlinux/*.conf behaviour) and no additional
> > bootmenu-entries.
> 
> The "distro" bootmeth described at the documentation you linked to will
> looks for a file called extlinux/extlinux.conf.
> 
> Is there a special reason why you need to use a custom bootmenu script
> and are moving from distro-boot (extlinux-config files)?
> 
> > 
> > is there any documentation describing the "Standard boot"?
> > 
> > i found this, but it looks like the "old" distro-boot...or is is same from 
> > users PoV?
> > 
> > https://u-boot.readthedocs.io/en/latest/develop/bootstd.html
> 
> This is the documentation for standard boot.
> 
> I recommend you try out the commands bootdev, bootflow and bootmeth with
> CONFIG_BOOTSTD_FULL=y to get a better handling on how it would work on
> your device and how you can use them in your script.
> 
> Regards,
> Jonas

regards Frank



Aw: [PATCH v2 0/2] Add DTS for BPI-R3

2023-04-30 Thread Frank Wunderlich
Hi,

Is it possible to take this series in upcoming release?

regards Frank


> Gesendet: Dienstag, den 11.04.2023 um 17:19 Uhr
> Von: "Frank Wunderlich" 
> An: u-boot@lists.denx.de
> Cc: "Frank Wunderlich" , "Sam Shih" 
> , "William Zhang" , 
> "Philippe Reynes" , "Marek Vasut" 
> , "Fabio Estevam" , "Marcel Ziswiler" 
> , "Samuel Holland" , "Pali 
> Rohár" , "Daniel Golle" , "Simon 
> Glass" , "Weijie Gao" 
> Betreff: [PATCH v2 0/2] Add DTS for BPI-R3
> 
> From: Frank Wunderlich 
> 
> Add board specific devicetree for BananaPi R3.
> 
> It is taken from openwrt
> https://git.openwrt.org/?p=openwrt/openwrt.git;a=blob;f=package/boot/uboot-mediatek/patches/430-add-bpi-r3.patch;hb=HEAD
> only enabled the factory button which was disabled because a HW-bug in
> rev 1.0 of r3.
> 
> v2: changed label for wps-button (used as reset in openwrt)
> 
> Daniel Golle (1):
>   board: mediatek: add Bananapi-R3 devicetree
> 
> Frank Wunderlich (1):
>   configs: change bpi-r3 to board specific dts and change prompt
> 
>  arch/arm/dts/Makefile|   2 +
>  arch/arm/dts/mt7986a-bpi-r3-emmc.dts |  32 
>  arch/arm/dts/mt7986a-bpi-r3-sd.dts   | 268 +++
>  configs/mt7986a_bpir3_emmc_defconfig |   6 +-
>  configs/mt7986a_bpir3_sd_defconfig   |   6 +-
>  5 files changed, 308 insertions(+), 6 deletions(-)
>  create mode 100644 arch/arm/dts/mt7986a-bpi-r3-emmc.dts
>  create mode 100644 arch/arm/dts/mt7986a-bpi-r3-sd.dts
> 
> -- 
> 2.34.1
>


Aw: Re: distro_boot vs. env-based bootmenu

2023-04-30 Thread Frank Wunderlich
Hi

I tried to find out why distroboot is enabled (i have not set it in my 
defconfig) and i think this is why:

  │ Symbol: DISTRO_DEFAULTS [=y]│  
  │ Type  : bool│  
  │ Prompt: Select defaults suitable for booting general purpose Linux dist │  
  │   Location: │  
  │ (3) -> Boot options │  
  │   Defined at boot/Kconfig:833   │  
  │   Selects: BOOT_DEFAULTS [=y] && AUTO_COMPLETE [=y] && CMDLINE_EDITING  │  
  │   Implied by [y]:   │  
  │   - ARCH_ROCKCHIP [=y] &&  && !ROCKCHIP_RK3399 [=n]

as far as i see you've got a response from Jonas about this option and he 
changed Kconfig file to BOOTSTD_DEFAULTS

as i have not used BOOTSTD_DEFAULTS before, what needs to be changed to have it 
working?

basicly my Plan is to script the bootup via env in script with a bootmenu 
(default entry + additional ones which can be 
changed by an env.txt file), but i do not want to break existing setups (using 
extlinux/*.conf behaviour) and no additional
bootmenu-entries.

is there any documentation describing the "Standard boot"?

i found this, but it looks like the "old" distro-boot...or is is same from 
users PoV?

https://u-boot.readthedocs.io/en/latest/develop/bootstd.html

regards Frank


> On Mon, 24 Apr 2023 at 15:22, Frank Wunderlich  
> wrote:
> >
> > Am 24. April 2023 21:44:25 MESZ schrieb Simon Glass :
> > >Hi Frank,
> > >
> > >On Fri, 21 Apr 2023 at 10:03, Frank Wunderlich  
> > >wrote:
> > >>
> > >> Maybe you have an idea because your patch removes distro-boot
> > >>
> > >> https://patchwork.ozlabs.org/project/uboot/patch/20230409084454.v9.8.I4cf7708a1ba953b9abd81375d93af34665c7b251@changeid/
> > >>
> > >> For missing linebreak for autoboot this seems to be a calculation issue
> > >>
> > >> https://source.denx.de/u-boot/u-boot/-/blob/master/common/menu.c#L439
> > >
> > >Are you able to fix it with a patch?
> >
> > Have not yet figured out which part of u-boot creates the mmc-entries on 
> > top of my bootmenu (i guess this comes from my still enabled distroboot 
> > options).
> >
> > For missing linebreak i guess position calculation is wrong in this case.
> >
> > >Or if not, do you have a patch for the 'move to env-based bootmenu' so
> > >I can try it?
> >
> > I have i builtin env file (uEnv_r2pro.txt) in my tree here and add (enable 
> > pepared option) the config-option to use this env file in topmost commit.
> >
> > https://github.com/frank-w/u-boot/commits/2023-04-bpi-r2pro
> >
> > I had this in but disabled but this overrides the env created by 
> > distroboot-defines...but now enabling it to get rid of distroboot.
> >
> > >>  Ursprüngliche Nachricht 
> > >> Von: Frank Wunderlich 
> > >> Gesendet: 12. April 2023 11:22:23 MESZ
> > >> An: u-boot@lists.denx.de
> > >> Betreff: distro_boot vs. env-based bootmenu
> > >>
> > >> Hi,
> > >>
> > >> i try to move from distro-boot (extlinux-config files) to an env-based 
> > >> bootmenu (builtin-environment) for
> > >> my bananapi r2pro.
> > >>
> > >> basicly it works, but i see more bootmenu-entries than i have defined in 
> > >> my environment
> > >>
> > >>  *** U-Boot Boot Menu ***
> > >>
> > >>   1. Boot from SD/EMMC.
> > >>   mmc 1:2
> > >>   mmc 1:3
> > >>   mmc 1:4
> > >>   U-Boot consoleHit any key to stop autoboot: 2
> > >>
> > >> i have only defined one botmenu-entry (first one in uEnv_r2pro.txt)
> > >>
> > >> bootmenu_0=1. Boot from SD/EMMC.=run newboot
> > >> bootmenu_default=0
> > >>
> > >> i guess the 3 mmc 1:x entries are part from distro-boot. i see a series 
> > >> from simon where he drops
> > >> distroboot for rockchip-boards.
> > >>
> > >> https://patchwork.ozlabs.org/project/uboot/patch/20230409084454.v9.8.I4cf7708a1ba953b9abd81375d93af34665c7b251@changeid/
> > >>
> > >> can anyone explain me where i can disable the mmc 1:x entries? i wanted 
> > >> to leave distro_boot as
> > >> fallback but it seems this is not possible.
> > >>
> > >> maybe i have to disable these?
> > >>
> > >> BOOTMETH_DISTRO [=y]
> > >> DISTRO_DEFAULTS [=y]
> > >>
> > >> can i keep distro-boot (seems to works with env too, but overridden by 
> > >> my builtin env) somehow and drop the mmc-entries from my bootmenu?
> > >>
> > >> any idea why i have no linebreak after u-Boot console?
> > >>
> > >> i use u-boot 2023.04 my source for this conversion/tests is there:
> > >> https://github.com/frank-w/u-boot/tree/2023-04-bpi-r2pro
> > >> using modified configs/evb-rk3568_defconfig



Re: distro_boot vs. env-based bootmenu

2023-04-24 Thread Frank Wunderlich
Am 24. April 2023 21:44:25 MESZ schrieb Simon Glass :
>Hi Frank,
>
>On Fri, 21 Apr 2023 at 10:03, Frank Wunderlich  wrote:
>>
>> Maybe you have an idea because your patch removes distro-boot
>>
>> https://patchwork.ozlabs.org/project/uboot/patch/20230409084454.v9.8.I4cf7708a1ba953b9abd81375d93af34665c7b251@changeid/
>>
>> For missing linebreak for autoboot this seems to be a calculation issue
>>
>> https://source.denx.de/u-boot/u-boot/-/blob/master/common/menu.c#L439
>
>Are you able to fix it with a patch?

Have not yet figured out which part of u-boot creates the mmc-entries on top of 
my bootmenu (i guess this comes from my still enabled distroboot options).

For missing linebreak i guess position calculation is wrong in this case.

>Or if not, do you have a patch for the 'move to env-based bootmenu' so
>I can try it?

I have i builtin env file (uEnv_r2pro.txt) in my tree here and add (enable 
pepared option) the config-option to use this env file in topmost commit.

https://github.com/frank-w/u-boot/commits/2023-04-bpi-r2pro

I had this in but disabled but this overrides the env created by 
distroboot-defines...but now enabling it to get rid of distroboot.

>Regards,
>Simon
>
>
>
>>
>>
>>
>>  Ursprüngliche Nachricht 
>> Von: Frank Wunderlich 
>> Gesendet: 12. April 2023 11:22:23 MESZ
>> An: u-boot@lists.denx.de
>> Betreff: distro_boot vs. env-based bootmenu
>>
>> Hi,
>>
>> i try to move from distro-boot (extlinux-config files) to an env-based 
>> bootmenu (builtin-environment) for
>> my bananapi r2pro.
>>
>> basicly it works, but i see more bootmenu-entries than i have defined in my 
>> environment
>>
>>  *** U-Boot Boot Menu ***
>>
>>   1. Boot from SD/EMMC.
>>   mmc 1:2
>>   mmc 1:3
>>   mmc 1:4
>>   U-Boot consoleHit any key to stop autoboot: 2
>>
>> i have only defined one botmenu-entry (first one in uEnv_r2pro.txt)
>>
>> bootmenu_0=1. Boot from SD/EMMC.=run newboot
>> bootmenu_default=0
>>
>> i guess the 3 mmc 1:x entries are part from distro-boot. i see a series from 
>> simon where he drops
>> distroboot for rockchip-boards.
>>
>> https://patchwork.ozlabs.org/project/uboot/patch/20230409084454.v9.8.I4cf7708a1ba953b9abd81375d93af34665c7b251@changeid/
>>
>> can anyone explain me where i can disable the mmc 1:x entries? i wanted to 
>> leave distro_boot as
>> fallback but it seems this is not possible.
>>
>> maybe i have to disable these?
>>
>> BOOTMETH_DISTRO [=y]
>> DISTRO_DEFAULTS [=y]
>>
>> can i keep distro-boot (seems to works with env too, but overridden by my 
>> builtin env) somehow and drop the mmc-entries from my bootmenu?
>>
>> any idea why i have no linebreak after u-Boot console?
>>
>> i use u-boot 2023.04 my source for this conversion/tests is there:
>> https://github.com/frank-w/u-boot/tree/2023-04-bpi-r2pro
>> using modified configs/evb-rk3568_defconfig
>>
>> regards Frank
>> regards Frank


regards Frank


Aw: [PATCH] pinctrl: mediatek: set R1/R0 in case pullen/pullsel succeeded

2023-04-13 Thread Frank Wunderlich
FYI...this issue affects only specific eMMC-Chips (vendor SEC) on the 
Bananapi-R2 (v1.2).

i have a v1.1 with a Samsung eMMC where i had no problems with the missing 
pullups/pulldowns
(maybe this has internal resistors)

more information about this special case:
https://forum.banana-pi.org/t/problem-trying-to-use-emmc/11253

tested the patch on my device for regressions...no problems

Tested-By: Frank Wunderlich 


distro_boot vs. env-based bootmenu

2023-04-12 Thread Frank Wunderlich
Hi,

i try to move from distro-boot (extlinux-config files) to an env-based bootmenu 
(builtin-environment) for
my bananapi r2pro.

basicly it works, but i see more bootmenu-entries than i have defined in my 
environment

 *** U-Boot Boot Menu ***

  1. Boot from SD/EMMC.
  mmc 1:2
  mmc 1:3
  mmc 1:4
  U-Boot consoleHit any key to stop autoboot: 2

i have only defined one botmenu-entry (first one in uEnv_r2pro.txt)

bootmenu_0=1. Boot from SD/EMMC.=run newboot
bootmenu_default=0

i guess the 3 mmc 1:x entries are part from distro-boot. i see a series from 
simon where he drops
distroboot for rockchip-boards.

https://patchwork.ozlabs.org/project/uboot/patch/20230409084454.v9.8.I4cf7708a1ba953b9abd81375d93af34665c7b251@changeid/

can anyone explain me where i can disable the mmc 1:x entries? i wanted to 
leave distro_boot as
fallback but it seems this is not possible.

maybe i have to disable these?

BOOTMETH_DISTRO [=y]
DISTRO_DEFAULTS [=y]

can i keep distro-boot (seems to works with env too, but overridden by my 
builtin env) somehow and drop the mmc-entries from my bootmenu?

any idea why i have no linebreak after u-Boot console?

i use u-boot 2023.04 my source for this conversion/tests is there:
https://github.com/frank-w/u-boot/tree/2023-04-bpi-r2pro
using modified configs/evb-rk3568_defconfig

regards Frank


[PATCH v2 1/2] board: mediatek: add Bananapi-R3 devicetree

2023-04-11 Thread Frank Wunderlich
From: Daniel Golle 

Add board specific devicetree for Bananapi R3 SBC.

Signed-off-by: Daniel Golle 
Signed-off-by: Frank Wunderlich 
---
taken from openwrt
https://git.openwrt.org/?p=openwrt/openwrt.git;a=blob;f=package/boot/uboot-mediatek/patches/430-add-bpi-r3.patch;hb=HEAD
only enabled the factory button which was disabled because a HW-bug in
rev 1.0 of r3.

v2:
 - change label for wps-button
---
 arch/arm/dts/Makefile|   2 +
 arch/arm/dts/mt7986a-bpi-r3-emmc.dts |  32 
 arch/arm/dts/mt7986a-bpi-r3-sd.dts   | 268 +++
 3 files changed, 302 insertions(+)
 create mode 100644 arch/arm/dts/mt7986a-bpi-r3-emmc.dts
 create mode 100644 arch/arm/dts/mt7986a-bpi-r3-sd.dts

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 0a9b1f7749d5..de0c0e35b8c3 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -1296,6 +1296,8 @@ dtb-$(CONFIG_ARCH_MEDIATEK) += \
mt7981-rfb.dtb \
mt7981-emmc-rfb.dtb \
mt7981-sd-rfb.dtb \
+   mt7986a-bpi-r3-sd.dtb \
+   mt7986a-bpi-r3-emmc.dtb \
mt7986a-rfb.dtb \
mt7986b-rfb.dtb \
mt7986a-sd-rfb.dtb \
diff --git a/arch/arm/dts/mt7986a-bpi-r3-emmc.dts 
b/arch/arm/dts/mt7986a-bpi-r3-emmc.dts
new file mode 100644
index ..4e2e5262f536
--- /dev/null
+++ b/arch/arm/dts/mt7986a-bpi-r3-emmc.dts
@@ -0,0 +1,32 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2021 MediaTek Inc.
+ * Author: Sam Shih 
+ */
+
+/dts-v1/;
+#include "mt7986a-bpi-r3-sd.dts"
+#include 
+/ {
+   reg_1p8v: regulator-1p8v {
+   compatible = "regulator-fixed";
+   regulator-name = "fixed-1.8V";
+   regulator-min-microvolt = <180>;
+   regulator-max-microvolt = <180>;
+   regulator-boot-on;
+   regulator-always-on;
+   };
+};
+
+ {
+   pinctrl-names = "default";
+   pinctrl-0 = <_pins_default>;
+   bus-width = <8>;
+   max-frequency = <2>;
+   cap-mmc-highspeed;
+   cap-mmc-hw-reset;
+   vmmc-supply = <_3p3v>;
+   vqmmc-supply = <_1p8v>;
+   non-removable;
+   status = "okay";
+};
diff --git a/arch/arm/dts/mt7986a-bpi-r3-sd.dts 
b/arch/arm/dts/mt7986a-bpi-r3-sd.dts
new file mode 100644
index ..4d12440fa3c0
--- /dev/null
+++ b/arch/arm/dts/mt7986a-bpi-r3-sd.dts
@@ -0,0 +1,268 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2021 MediaTek Inc.
+ * Author: Sam Shih 
+ */
+
+/dts-v1/;
+#include "mt7986.dtsi"
+#include 
+
+/ {
+   #address-cells = <1>;
+   #size-cells = <1>;
+   model = "BananaPi BPi-R3";
+   compatible = "mediatek,mt7986", "mediatek,mt7986-sd-rfb";
+
+   chosen {
+   stdout-path = 
+   tick-timer = 
+   };
+
+   reg_3p3v: regulator-3p3v {
+   compatible = "regulator-fixed";
+   regulator-name = "fixed-3.3V";
+   regulator-min-microvolt = <330>;
+   regulator-max-microvolt = <330>;
+   regulator-boot-on;
+   regulator-always-on;
+   };
+
+   keys {
+   compatible = "gpio-keys";
+
+   factory {
+   label = "reset";
+   gpios = < 9 GPIO_ACTIVE_LOW>;
+   };
+
+   wps {
+   label = "wps";
+   gpios = < 10 GPIO_ACTIVE_LOW>;
+   };
+   };
+
+   leds {
+   compatible = "gpio-leds";
+
+   led_status_green: green {
+   label = "green:status";
+   gpios = < 69 GPIO_ACTIVE_HIGH>;
+   };
+
+   led_status_blue: blue {
+   label = "blue:status";
+   gpios = < 86 GPIO_ACTIVE_HIGH>;
+   };
+   };
+
+};
+
+ {
+   status = "okay";
+};
+
+ {
+   pinctrl-names = "default";
+   pinctrl-0 = <_pins>;
+   status = "disabled";
+};
+
+ {
+   status = "okay";
+   mediatek,gmac-id = <0>;
+   phy-mode = "sgmii";
+   mediatek,switch = "mt7531";
+   reset-gpios = < 5 GPIO_ACTIVE_HIGH>;
+
+   fixed-link {
+   speed = <1000>;
+   full-duplex;
+   };
+};
+
+ {
+   spic_pins: spi1-pins-func-1 {
+   mux {
+   function = "spi";
+   groups = "spi1_2";
+   };
+   };
+
+   uart1_pins: spi1-pins-func-3 {
+   mux {
+   function = "uart";
+   g

[PATCH v2 2/2] configs: change bpi-r3 to board specific dts and change prompt

2023-04-11 Thread Frank Wunderlich
From: Frank Wunderlich 

Use own devicetree for the board and change the prompt.

Signed-off-by: Frank Wunderlich 
---
 configs/mt7986a_bpir3_emmc_defconfig | 6 +++---
 configs/mt7986a_bpir3_sd_defconfig   | 6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/configs/mt7986a_bpir3_emmc_defconfig 
b/configs/mt7986a_bpir3_emmc_defconfig
index 2d4876f299f4..5b76512a46f6 100644
--- a/configs/mt7986a_bpir3_emmc_defconfig
+++ b/configs/mt7986a_bpir3_emmc_defconfig
@@ -7,15 +7,15 @@ CONFIG_SYS_MALLOC_F_LEN=0x4000
 CONFIG_NR_DRAM_BANKS=1
 CONFIG_ENV_SIZE=0x8
 CONFIG_ENV_OFFSET=0x30
-CONFIG_DEFAULT_DEVICE_TREE="mt7986a-emmc-rfb"
-CONFIG_SYS_PROMPT="MT7986> "
+CONFIG_DEFAULT_DEVICE_TREE="mt7986a-bpi-r3-emmc"
+CONFIG_SYS_PROMPT="BPI-R3> "
 CONFIG_TARGET_MT7986=y
 CONFIG_DEBUG_UART_BASE=0x11002000
 CONFIG_DEBUG_UART_CLOCK=4000
 CONFIG_SYS_LOAD_ADDR=0x4600
 CONFIG_DEBUG_UART=y
 # CONFIG_AUTOBOOT is not set
-CONFIG_DEFAULT_FDT_FILE="mt7986a-emmc-rfb"
+CONFIG_DEFAULT_FDT_FILE="mt7986a-bpi-r3-emmc"
 CONFIG_LOGLEVEL=7
 CONFIG_LOG=y
 CONFIG_SYS_CBSIZE=512
diff --git a/configs/mt7986a_bpir3_sd_defconfig 
b/configs/mt7986a_bpir3_sd_defconfig
index 08edfe7ac409..36547db91423 100644
--- a/configs/mt7986a_bpir3_sd_defconfig
+++ b/configs/mt7986a_bpir3_sd_defconfig
@@ -7,15 +7,15 @@ CONFIG_SYS_MALLOC_F_LEN=0x4000
 CONFIG_NR_DRAM_BANKS=1
 CONFIG_ENV_SIZE=0x8
 CONFIG_ENV_OFFSET=0x30
-CONFIG_DEFAULT_DEVICE_TREE="mt7986a-sd-rfb"
-CONFIG_SYS_PROMPT="MT7986> "
+CONFIG_DEFAULT_DEVICE_TREE="mt7986a-bpi-r3-sd"
+CONFIG_SYS_PROMPT="BPI-R3> "
 CONFIG_TARGET_MT7986=y
 CONFIG_DEBUG_UART_BASE=0x11002000
 CONFIG_DEBUG_UART_CLOCK=4000
 CONFIG_SYS_LOAD_ADDR=0x4600
 CONFIG_DEBUG_UART=y
 # CONFIG_AUTOBOOT is not set
-CONFIG_DEFAULT_FDT_FILE="mt7986a-sd-rfb"
+CONFIG_DEFAULT_FDT_FILE="mt7986a-bpi-r3-sd"
 CONFIG_LOGLEVEL=7
 CONFIG_LOG=y
 CONFIG_SYS_CBSIZE=512
-- 
2.34.1



[PATCH v2 0/2] Add DTS for BPI-R3

2023-04-11 Thread Frank Wunderlich
From: Frank Wunderlich 

Add board specific devicetree for BananaPi R3.

It is taken from openwrt
https://git.openwrt.org/?p=openwrt/openwrt.git;a=blob;f=package/boot/uboot-mediatek/patches/430-add-bpi-r3.patch;hb=HEAD
only enabled the factory button which was disabled because a HW-bug in
rev 1.0 of r3.

v2: changed label for wps-button (used as reset in openwrt)

Daniel Golle (1):
  board: mediatek: add Bananapi-R3 devicetree

Frank Wunderlich (1):
  configs: change bpi-r3 to board specific dts and change prompt

 arch/arm/dts/Makefile|   2 +
 arch/arm/dts/mt7986a-bpi-r3-emmc.dts |  32 
 arch/arm/dts/mt7986a-bpi-r3-sd.dts   | 268 +++
 configs/mt7986a_bpir3_emmc_defconfig |   6 +-
 configs/mt7986a_bpir3_sd_defconfig   |   6 +-
 5 files changed, 308 insertions(+), 6 deletions(-)
 create mode 100644 arch/arm/dts/mt7986a-bpi-r3-emmc.dts
 create mode 100644 arch/arm/dts/mt7986a-bpi-r3-sd.dts

-- 
2.34.1



Aw: [v1 1/2] board: mediatek: add Bananapi-R3 devicetree

2023-04-08 Thread Frank Wunderlich
Hi

noticed that i need to change the label of wps button back to "wps" when 
enabling the factory
button (else there will be 2 buttons with same label).

> Gesendet: Freitag, 07. April 2023 um 23:26 Uhr
> Von: "Frank Wunderlich" 
> Betreff: [v1 1/2] board: mediatek: add Bananapi-R3 devicetree
>
> From: Daniel Golle 
>
> Add board specific devicetree for Bananapi R3 SBC.
>
> Signed-off-by: Daniel Golle 
> Signed-off-by: Frank Wunderlich 
> ---
> taken from openwrt
> https://git.openwrt.org/?p=openwrt/openwrt.git;a=blob;f=package/boot/uboot-mediatek/patches/430-add-bpi-r3.patch;hb=HEAD
> only enabled the factory button which was disabled because a HW-bug in
> rev 1.0 of r3.
> ---
> diff --git a/arch/arm/dts/mt7986a-bpi-r3-sd.dts 
> b/arch/arm/dts/mt7986a-bpi-r3-sd.dts
> new file mode 100644
> index ..82a3975c7de8
> --- /dev/null
> +++ b/arch/arm/dts/mt7986a-bpi-r3-sd.dts

> + keys {
> + compatible = "gpio-keys";
> +
> + factory {
> + label = "reset";
> + gpios = < 9 GPIO_ACTIVE_LOW>;
> + };
> +
> + wps {
> + label = "reset";

label was changed in openwrt to use this button for reset, but hw bug fixed in 
newer v1.1 versions of
the board. I will change this to "wps" like in linux in next version.

just tell me if the structure is right or if there any other things need to be 
changed.

> + gpios = < 10 GPIO_ACTIVE_LOW>;
> + };
> + };

regards Frank


[v1 1/2] board: mediatek: add Bananapi-R3 devicetree

2023-04-07 Thread Frank Wunderlich
From: Daniel Golle 

Add board specific devicetree for Bananapi R3 SBC.

Signed-off-by: Daniel Golle 
Signed-off-by: Frank Wunderlich 
---
taken from openwrt
https://git.openwrt.org/?p=openwrt/openwrt.git;a=blob;f=package/boot/uboot-mediatek/patches/430-add-bpi-r3.patch;hb=HEAD
only enabled the factory button which was disabled because a HW-bug in
rev 1.0 of r3.
---
 arch/arm/dts/Makefile|   2 +
 arch/arm/dts/mt7986a-bpi-r3-emmc.dts |  32 
 arch/arm/dts/mt7986a-bpi-r3-sd.dts   | 268 +++
 3 files changed, 302 insertions(+)
 create mode 100644 arch/arm/dts/mt7986a-bpi-r3-emmc.dts
 create mode 100644 arch/arm/dts/mt7986a-bpi-r3-sd.dts

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 0a9b1f7749d5..de0c0e35b8c3 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -1296,6 +1296,8 @@ dtb-$(CONFIG_ARCH_MEDIATEK) += \
mt7981-rfb.dtb \
mt7981-emmc-rfb.dtb \
mt7981-sd-rfb.dtb \
+   mt7986a-bpi-r3-sd.dtb \
+   mt7986a-bpi-r3-emmc.dtb \
mt7986a-rfb.dtb \
mt7986b-rfb.dtb \
mt7986a-sd-rfb.dtb \
diff --git a/arch/arm/dts/mt7986a-bpi-r3-emmc.dts 
b/arch/arm/dts/mt7986a-bpi-r3-emmc.dts
new file mode 100644
index ..4e2e5262f536
--- /dev/null
+++ b/arch/arm/dts/mt7986a-bpi-r3-emmc.dts
@@ -0,0 +1,32 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2021 MediaTek Inc.
+ * Author: Sam Shih 
+ */
+
+/dts-v1/;
+#include "mt7986a-bpi-r3-sd.dts"
+#include 
+/ {
+   reg_1p8v: regulator-1p8v {
+   compatible = "regulator-fixed";
+   regulator-name = "fixed-1.8V";
+   regulator-min-microvolt = <180>;
+   regulator-max-microvolt = <180>;
+   regulator-boot-on;
+   regulator-always-on;
+   };
+};
+
+ {
+   pinctrl-names = "default";
+   pinctrl-0 = <_pins_default>;
+   bus-width = <8>;
+   max-frequency = <2>;
+   cap-mmc-highspeed;
+   cap-mmc-hw-reset;
+   vmmc-supply = <_3p3v>;
+   vqmmc-supply = <_1p8v>;
+   non-removable;
+   status = "okay";
+};
diff --git a/arch/arm/dts/mt7986a-bpi-r3-sd.dts 
b/arch/arm/dts/mt7986a-bpi-r3-sd.dts
new file mode 100644
index ..82a3975c7de8
--- /dev/null
+++ b/arch/arm/dts/mt7986a-bpi-r3-sd.dts
@@ -0,0 +1,268 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2021 MediaTek Inc.
+ * Author: Sam Shih 
+ */
+
+/dts-v1/;
+#include "mt7986.dtsi"
+#include 
+
+/ {
+   #address-cells = <1>;
+   #size-cells = <1>;
+   model = "BananaPi BPi-R3";
+   compatible = "mediatek,mt7986", "mediatek,mt7986-sd-rfb";
+
+   chosen {
+   stdout-path = 
+   tick-timer = 
+   };
+
+   reg_3p3v: regulator-3p3v {
+   compatible = "regulator-fixed";
+   regulator-name = "fixed-3.3V";
+   regulator-min-microvolt = <330>;
+   regulator-max-microvolt = <330>;
+   regulator-boot-on;
+   regulator-always-on;
+   };
+
+   keys {
+   compatible = "gpio-keys";
+
+   factory {
+   label = "reset";
+   gpios = < 9 GPIO_ACTIVE_LOW>;
+   };
+
+   wps {
+   label = "reset";
+   gpios = < 10 GPIO_ACTIVE_LOW>;
+   };
+   };
+
+   leds {
+   compatible = "gpio-leds";
+
+   led_status_green: green {
+   label = "green:status";
+   gpios = < 69 GPIO_ACTIVE_HIGH>;
+   };
+
+   led_status_blue: blue {
+   label = "blue:status";
+   gpios = < 86 GPIO_ACTIVE_HIGH>;
+   };
+   };
+
+};
+
+ {
+   status = "okay";
+};
+
+ {
+   pinctrl-names = "default";
+   pinctrl-0 = <_pins>;
+   status = "disabled";
+};
+
+ {
+   status = "okay";
+   mediatek,gmac-id = <0>;
+   phy-mode = "sgmii";
+   mediatek,switch = "mt7531";
+   reset-gpios = < 5 GPIO_ACTIVE_HIGH>;
+
+   fixed-link {
+   speed = <1000>;
+   full-duplex;
+   };
+};
+
+ {
+   spic_pins: spi1-pins-func-1 {
+   mux {
+   function = "spi";
+   groups = "spi1_2";
+   };
+   };
+
+   uart1_pins: spi1-pins-func-3 {
+   mux {
+   function = "uart";
+   groups = "uart1_2";
+   };
+   

[v1 2/2] configs: change bpi-r3 to board specific dts and change prompt

2023-04-07 Thread Frank Wunderlich
From: Frank Wunderlich 

Use own devicetree for the board and change the prompt.

Signed-off-by: Frank Wunderlich 
---
 configs/mt7986a_bpir3_emmc_defconfig | 6 +++---
 configs/mt7986a_bpir3_sd_defconfig   | 6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/configs/mt7986a_bpir3_emmc_defconfig 
b/configs/mt7986a_bpir3_emmc_defconfig
index 2d4876f299f4..5b76512a46f6 100644
--- a/configs/mt7986a_bpir3_emmc_defconfig
+++ b/configs/mt7986a_bpir3_emmc_defconfig
@@ -7,15 +7,15 @@ CONFIG_SYS_MALLOC_F_LEN=0x4000
 CONFIG_NR_DRAM_BANKS=1
 CONFIG_ENV_SIZE=0x8
 CONFIG_ENV_OFFSET=0x30
-CONFIG_DEFAULT_DEVICE_TREE="mt7986a-emmc-rfb"
-CONFIG_SYS_PROMPT="MT7986> "
+CONFIG_DEFAULT_DEVICE_TREE="mt7986a-bpi-r3-emmc"
+CONFIG_SYS_PROMPT="BPI-R3> "
 CONFIG_TARGET_MT7986=y
 CONFIG_DEBUG_UART_BASE=0x11002000
 CONFIG_DEBUG_UART_CLOCK=4000
 CONFIG_SYS_LOAD_ADDR=0x4600
 CONFIG_DEBUG_UART=y
 # CONFIG_AUTOBOOT is not set
-CONFIG_DEFAULT_FDT_FILE="mt7986a-emmc-rfb"
+CONFIG_DEFAULT_FDT_FILE="mt7986a-bpi-r3-emmc"
 CONFIG_LOGLEVEL=7
 CONFIG_LOG=y
 CONFIG_SYS_CBSIZE=512
diff --git a/configs/mt7986a_bpir3_sd_defconfig 
b/configs/mt7986a_bpir3_sd_defconfig
index 08edfe7ac409..36547db91423 100644
--- a/configs/mt7986a_bpir3_sd_defconfig
+++ b/configs/mt7986a_bpir3_sd_defconfig
@@ -7,15 +7,15 @@ CONFIG_SYS_MALLOC_F_LEN=0x4000
 CONFIG_NR_DRAM_BANKS=1
 CONFIG_ENV_SIZE=0x8
 CONFIG_ENV_OFFSET=0x30
-CONFIG_DEFAULT_DEVICE_TREE="mt7986a-sd-rfb"
-CONFIG_SYS_PROMPT="MT7986> "
+CONFIG_DEFAULT_DEVICE_TREE="mt7986a-bpi-r3-sd"
+CONFIG_SYS_PROMPT="BPI-R3> "
 CONFIG_TARGET_MT7986=y
 CONFIG_DEBUG_UART_BASE=0x11002000
 CONFIG_DEBUG_UART_CLOCK=4000
 CONFIG_SYS_LOAD_ADDR=0x4600
 CONFIG_DEBUG_UART=y
 # CONFIG_AUTOBOOT is not set
-CONFIG_DEFAULT_FDT_FILE="mt7986a-sd-rfb"
+CONFIG_DEFAULT_FDT_FILE="mt7986a-bpi-r3-sd"
 CONFIG_LOGLEVEL=7
 CONFIG_LOG=y
 CONFIG_SYS_CBSIZE=512
-- 
2.34.1



[v1 0/2] Add DTS for BPI-R3

2023-04-07 Thread Frank Wunderlich
From: Frank Wunderlich 

Add board specific devicetree for BananaPi R3.

It is taken from openwrt
https://git.openwrt.org/?p=openwrt/openwrt.git;a=blob;f=package/boot/uboot-mediatek/patches/430-add-bpi-r3.patch;hb=HEAD
only enabled the factory button which was disabled because a HW-bug in
rev 1.0 of r3.

Daniel Golle (1):
  board: mediatek: add Bananapi-R3 devicetree

Frank Wunderlich (1):
  configs: change bpi-r3 to board specific dts and change prompt

 arch/arm/dts/Makefile|   2 +
 arch/arm/dts/mt7986a-bpi-r3-emmc.dts |  32 
 arch/arm/dts/mt7986a-bpi-r3-sd.dts   | 268 +++
 configs/mt7986a_bpir3_emmc_defconfig |   6 +-
 configs/mt7986a_bpir3_sd_defconfig   |   6 +-
 5 files changed, 308 insertions(+), 6 deletions(-)
 create mode 100644 arch/arm/dts/mt7986a-bpi-r3-emmc.dts
 create mode 100644 arch/arm/dts/mt7986a-bpi-r3-sd.dts

-- 
2.34.1



Aw: [PATCH v5 2/6] rockchip: Use an external TPL binary on RK3568

2023-03-01 Thread Frank Wunderlich
Tested full series on bananapi r2pro

Tested-by: Frank Wunderlich 

regards Frank


Aw: [PATCH v4 0/4] rockchip: Use external TPL binary to create a working firmware image

2023-02-22 Thread Frank Wunderlich
Hi,

tested this series on top of 2023.04-rc2 on bananapi r2, works well if i 
disable CONFIG_OF_SYSTEM_SETUP

else i get this error:

LD u-boot
aarch64-linux-gnu-ld.bfd: boot/image-fdt.o: in function `image_setup_libfdt':
/media/data_nvme/git/uboot/u-boot/boot/image-fdt.c:661: undefined reference to 
`ft_system_setup'
aarch64-linux-gnu-ld.bfd: cmd/fdt.o: in function `do_fdt':
/media/data_nvme/git/uboot/u-boot/cmd/fdt.c:272: undefined reference to 
`ft_system_setup'
Segmentation fault (core dumped)
make: *** [Makefile:1753: u-boot] Error 139
make: *** Deleting file 'u-boot'
build failed!

because there is no implementation for this function for rockchip:

https://elixir.bootlin.com/u-boot/v2023.04-rc2/C/ident/ft_system_setup

i had this option set in my defconfig from 2022-04 before it was broken by 
binman patches, but do not remember why i have added it.

but basicly it works again, so

Tested-By: Frank Wunderlich 

regards Frank


> Gesendet: Sonntag, 19. Februar 2023 um 16:06 Uhr
> Von: "Jonas Karlman" 
> An: "Simon Glass" , "Philipp Tomsich" 
> , "Kever Yang" , "Joseph 
> Chen" , "Alper Nebi Yasak" 
> Cc: "Quentin Schulz" , "Jagan Teki" 
> , "Heinrich Schuchardt" , 
> u-boot@lists.denx.de, "Jonas Karlman" 
> Betreff: [PATCH v4 0/4] rockchip: Use external TPL binary to create a working 
> firmware image
>
> Rockchip SoCs typically use U-Boot TPL to initialize DRAM, then jumps
> back to BootRom to load next stage, U-Boot SPL, into DRAM. BootRom then
> jumps to U-Boot SPL to continue the boot flow.
>
> For RK356x there is no support to initialize DRAM using U-Boot
> TPL and instead an external TPL binary must be used to generate a
> bootable u-boot-rockchip.bin image.
>
> This adds a new rockchip-tpl entry to binman and make use of this new
> entry in rockchip-u-boot.dtsi.
>
> Build U-Boot with ROCKCHIP_TPL=/path/to/ddr.bin to generate a
> bootable u-boot-rockchip.bin image for RK356x.
>
> I have dropped the RFC patch that was related to showing a friendly
> message instead of a generic file not found message when TPL blob is
> missing in v3. Will address that in a follow-up series.
>
> The last patch that updates evb-rk3568_defconfig was dropped in v4.
> Will address that and more config options in a follow-up series.
>
> Changes in v4:
> - Only change init size limit for rk3328 and rk3568
> - Drop update evb-rk3568_defconfig patch
>
> Changes in v3:
> - Move test function last
> - Add help text to Kconfig option
> - Add build step for rk3568 to documentation
> - Resync init size limit table
> - Drop missing message RFC patch
>
> Changes in v2:
> - Renamed external-tpl to rockchip-tpl
> - Renamed EXTERNAL_TPL to ROCKCHIP_TPL
> - Add CONFIG_ROCKCHIP_EXTERNAL_TPL Kconfig option
> - New patch to sync init size limit in mkimage
> - New RFC patch to improve allow-missing/fake-ext-blobs handling for
>   binman mkimage entry
>
> Jonas Karlman (4):
>   binman: Add support for a rockchip-tpl entry
>   rockchip: Use an external TPL binary on RK3568
>   Revert "board: rockchip: Fix binman_init failure on EVB-RK3568"
>   rockchip: mkimage: Update init size limit for RK3328 and RK3568
>
>  Makefile   |  1 +
>  arch/arm/dts/rockchip-u-boot.dtsi  | 10 --
>  arch/arm/mach-rockchip/Kconfig |  8 
>  configs/evb-rk3568_defconfig   |  1 -
>  doc/board/rockchip/rockchip.rst| 11 +++
>  tools/binman/entries.rst   | 14 ++
>  tools/binman/etype/rockchip_tpl.py | 20 
>  tools/binman/ftest.py  |  7 +++
>  tools/binman/missing-blob-help |  5 +
>  tools/binman/test/277_rockchip_tpl.dts | 16 
>  tools/rkcommon.c   |  4 ++--
>  11 files changed, 92 insertions(+), 5 deletions(-)
>  create mode 100644 tools/binman/etype/rockchip_tpl.py
>  create mode 100644 tools/binman/test/277_rockchip_tpl.dts
>
> --
> 2.39.2
>
>


Aw: Nand write from uboot

2022-10-22 Thread Frank Wunderlich
Hi,

this is how i do nand-write on a mediatek board, if your driver is capable with 
mtd it should be similar:

https://www.fw-web.de/dokuwiki/doku.php?id=en:bpi-r3:uboot#nand_flash

HTH

regards Frank


Aw: extend environment with file

2021-12-21 Thread Frank Wunderlich
Hi,

as far as i have debugged it:

soc-config is in CONFIG_EXTRA_ENV_SETTINGS
distroboot (include/config_distro_bootcmd.h) lands in BOOTENV

magic is in include/env_default.h where at least CONFIG_EXTRA_ENV_SETTINGS is 
only mapped
if CONFIG_USE_DEFAULT_ENV_FILE is not set, if set a generated headerfile 
generated/defaultenv_autogenerated.h
is included which contains some magic numbers (i guess hex-values of the chars 
from the file). this seems to
be generated in main Makefile, but i'm not sure how exactly (anyhow with 
tools/env/).

any idea to concatenate both sources?

regards Frank


> Gesendet: Dienstag, 21. Dezember 2021 um 13:56 Uhr
> Von: "Frank Wunderlich" 
> An: "U-Boot Mailing List" 
> Betreff: extend environment with file
>
> Hi,
>
> currently i use distroboot on my board which sets some environment-variables, 
> some other (memory addresses) were set in my soc-specific header file 
> (include/configs/rk3568_common.h).
>
> But distroboot is a bit too limited for my needs (no tftp, no script, ...), 
> so imho i need to use the bootmenu way here, but for local kernel-bootup run 
> distro_bootcmd.
>
> I want to add some more variables (e.g. for bootmenu) and for easier 
> maintaining i used a txt-file for it and defined
>
> CONFIG_DEFAULT_ENV_FILE="uEnv_r2pro.txt"
>
> but this option seems to clear the previous environment from distroboot and 
> soc header file...i have now only the vars from the file defined.
>
> i tried adding CONFIG_ENV_APPEND=y but i have still only the vars from the 
> file.
>
> Is there a way to append (distrocmd + soc-header + uenv-file) instead of 
> overwriting?
>
> regards Frank
>


extend environment with file

2021-12-21 Thread Frank Wunderlich
Hi,

currently i use distroboot on my board which sets some environment-variables, 
some other (memory addresses) were set in my soc-specific header file 
(include/configs/rk3568_common.h).

But distroboot is a bit too limited for my needs (no tftp, no script, ...), so 
imho i need to use the bootmenu way here, but for local kernel-bootup run 
distro_bootcmd.

I want to add some more variables (e.g. for bootmenu) and for easier 
maintaining i used a txt-file for it and defined

CONFIG_DEFAULT_ENV_FILE="uEnv_r2pro.txt"

but this option seems to clear the previous environment from distroboot and soc 
header file...i have now only the vars from the file defined.

i tried adding CONFIG_ENV_APPEND=y but i have still only the vars from the file.

Is there a way to append (distrocmd + soc-header + uenv-file) instead of 
overwriting?

regards Frank


Aw: [PATCH v2] Cubieboard2:SUN7I:Add LED BOOT support

2021-12-08 Thread Frank Wunderlich
Hi,

you should add maintainer email for your patch

$ scripts/get_maintainer.pl board/sunxi/board.c
Jagan Teki  (maintainer:ARM SUNXI)
Andre Przywara  (maintainer:ARM SUNXI)
u-boot@lists.denx.de (open list)

regards Frank


> Gesendet: Mittwoch, 08. Dezember 2021 um 15:22 Uhr
> Von: "Javad Rahimi" 
> An: u-boot@lists.denx.de
> Cc: "Javad Rahimi" 
> Betreff: [PATCH v2] Cubieboard2:SUN7I:Add LED BOOT support
>
> This feature makes it possible to assign one of
> LED1(PH20) and LED2(PH21) to BOOT process LED.
> User should activates the "Enable status LED API" in
> "Device Drivers -> LED Support"
>
> Signed-off-by: Javad Rahimi 
> ---
> This is my first contributation in open source world.
> I'm sorry if I have mistakes in my commits and versioning.
> I do my best to learn fast.
>
> Changes in v2:
> - Missed braces added
> - Unnecessary debug removed
> - Some typo fixed
>
>  board/sunxi/board.c | 49 +
>  1 file changed, 49 insertions(+)
>
> diff --git a/board/sunxi/board.c b/board/sunxi/board.c
> index 4f5747c34a..5e2f6ae902 100644
> --- a/board/sunxi/board.c
> +++ b/board/sunxi/board.c
> @@ -1002,3 +1002,52 @@ int board_fit_config_name_match(const char *name)
>   return ret;
>  }
>  #endif
> +
> +#if defined(CONFIG_LED_STATUS) && defined(CONFIG_LED_STATUS_BOOT) && 
> defined(CONFIG_LED_STATUS_BOARD_SPECIFIC)
> +
> +#define CUBIE2_LED_BOOT_GPIO  "PH20"
> +static int gpio_boot_led;
> +
> +void __led_init(led_id_t mask, int state)
> +{
> + int ret;
> +
> + if (mask != CONFIG_LED_STATUS_BOOT)
> + return;
> +
> + ret = gpio_lookup_name(CUBIE2_LED_BOOT_GPIO, NULL, NULL, 
> _boot_led);
> +
> + if (ret)
> + return;
> +
> + ret = gpio_request(gpio_boot_led, "boot_led");
> + if (ret == -1) {
> + debug("[gpio_request] Error:%d\n", ret);
> + return;
> + }
> +
> + ret = gpio_direction_output(gpio_boot_led, 1);
> + if (ret == -1) {
> + debug("[gpio_direction_output] Error:%d\n", ret);
> + return;
> + }
> + __led_set(mask, state);
> +}
> +
> +void __led_set(led_id_t mask, int state)
> +{
> + if (mask != CONFIG_LED_STATUS_BOOT)
> + return;
> +
> + gpio_set_value(gpio_boot_led, state);
> +}
> +
> +void __led_toggle(led_id_t mask)
> +{
> + if (mask != CONFIG_LED_STATUS_BOOT)
> + return;
> +
> + gpio_set_value(gpio_boot_led, !gpio_get_value(gpio_boot_led));
> +}
> +
> +#endif
> --
> 2.25.1
>
>


Aw: Re: debugging crash for arm64

2021-12-08 Thread Frank Wunderlich
Hi,

thanks for answer, but it seems it is there

arch/arm/mach-rockchip/rk3568/rk3568.c:50:  .attrs = 
PTE_BLOCK_MEMTYPE(MT_NORMAL) |
arch/arm/mach-rockchip/rk3568/rk3568.c:56:  .attrs = 
PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
arch/arm/mach-rockchip/rk3568/rk3568.c:63:  .attrs = 
PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |

or is there a mem-region not defined? if yes which?

static struct mm_region rk3568_mem_map[] = {
{
.virt = 0x0UL,
.phys = 0x0UL,
.size = 0xf000UL,
.attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
 PTE_BLOCK_INNER_SHARE
}, {
.virt = 0xf000UL,
.phys = 0xf000UL,
.size = 0x1000UL,
.attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
 PTE_BLOCK_NON_SHARE |
 PTE_BLOCK_PXN | PTE_BLOCK_UXN
}, {
.virt = 0x3,
.phys = 0x3,
.size = 0x0c0c0,
.attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
 PTE_BLOCK_NON_SHARE |
 PTE_BLOCK_PXN | PTE_BLOCK_UXN
}, {
/* List terminator */
0,
}
};

struct mm_region *mem_map = rk3568_mem_map;


regards Frank


> Gesendet: Mittwoch, 08. Dezember 2021 um 12:49 Uhr
> Von: "Joakim Tjernlund" 
> An: "Frank Wunderlich" , "u-boot@lists.denx.de" 
> 
> Betreff: Re: debugging crash for arm64
>
> Just had the same and you are probably missing to map that mem area to the 
> MMU. grep for PTE_BLOCK_MEMTYPE in board
> and you will see how to.
> That said, I think the error msg in u-boot can be a bit better, some SEGV msg 
> perhaps.
>
>  Jocke
>
> ____
> From: U-Boot  on behalf of Frank Wunderlich 
> 
> Sent: 08 December 2021 12:12
> To: u-boot@lists.denx.de
> Subject: debugging crash for arm64
>
> Hi,
>
> i got a crash on uboot while running reset-command in rk3568 board 
> (bananapi-r2 pro, currently not in upstream).
>
> maybe a callback is missing (e.g. reset_cpu())??
>
> i tried to analyse it using the documentation:
> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fu-boot.readthedocs.io%2Fen%2Flatest%2Fdevelop%2Fcrash_dumps.html=04%7C01%7Cjoakim.tjernlund%40infinera.com%7C59463e6ea58d41f0ca9008d9ba3b9a99%7C285643de5f5b4b03a1530ae2dc8aaf77%7C1%7C1%7C637745587442544318%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000=2PrM0CxcISTGINRz2DvLtMXB0UWow0x%2Bl0y58JkpkK0%3D=0
>
> Resetting CPU ...
>
> resetting ...
> "Synchronous Abort" handler, esr 0x9645
> elr: 00a25f78 lr : 00a25f48 (reloc)
> elr: 7ff94f78 lr : 7ff94f48
> x0 : fdd2 x1 : 1401
> x2 : fdb9 x3 : 7df5cd48
> x4 : 7df4fe88 x5 : 7df5c710
> x6 : 001a x7 : 7df459f0
> x8 : 0001 x9 : 000c
> x10: 000186a0 x11: ffd0
> x12: 0010 x13: 0001869f
> x14: 7ff70158 x15: 0021
> x16: 7ff94f2c x17: 
> x18: 7df4fdd0 x19: 
> x20: 0001 x21: 
> x22: 7df5ddd0 x23: 0001
> x24: 7ffe8800 x25: 
> x26:  x27: 
> x28: 7df5e980 x29: 7df45990
>
> Code: d65f03c0 d5033fbf b9400661 529d9502 (b8206822)
>
> $ echo 'Code: d65f03c0 d5033fbf b9400661 529d9502 (b8206822)' |   
> CROSS_COMPILE=aarch64-linux-gnu- ARCH=arm64 scripts/decodecode
> Code: d65f03c0 d5033fbf b9400661 529d9502 (b8206822)
> All code
> 
>0:   d65f03c0ret
>4:   d5033fbfdmb sy
>8:   b9400661ldr w1, [x19, #4]
>c:   529d9502mov w2, #0xeca8 // #60584
>   10:*  b8206822str w2, [x1, x0]<-- trapping 
> instruction
>
> Code starting with the faulting instruction
> ===
>0:   b8206822str w2, [x1, x0]
>
>
> now i'm here
>
> "Now lets use the locations provided by the elr and lr registers after 
> subtracting the relocation offset to find out where in the code the crash 
> occurred and from where it was invoked."
>
> does that means that i have to subtract values of first 2 lines of trace?
>
> 0x7ff94f78 - 0x00a25f78 = 0x7F56F000
>
> "File u-boot.map contains the memory layout of the U-Boot binary. Here we 
> find these lines:"
>
> this is 

debugging crash for arm64

2021-12-08 Thread Frank Wunderlich
Hi,

i got a crash on uboot while running reset-command in rk3568 board (bananapi-r2 
pro, currently not in upstream).

maybe a callback is missing (e.g. reset_cpu())??

i tried to analyse it using the documentation:
https://u-boot.readthedocs.io/en/latest/develop/crash_dumps.html

Resetting CPU ...

resetting ...
"Synchronous Abort" handler, esr 0x9645
elr: 00a25f78 lr : 00a25f48 (reloc)
elr: 7ff94f78 lr : 7ff94f48
x0 : fdd2 x1 : 1401
x2 : fdb9 x3 : 7df5cd48
x4 : 7df4fe88 x5 : 7df5c710
x6 : 001a x7 : 7df459f0
x8 : 0001 x9 : 000c
x10: 000186a0 x11: ffd0
x12: 0010 x13: 0001869f
x14: 7ff70158 x15: 0021
x16: 7ff94f2c x17: 
x18: 7df4fdd0 x19: 
x20: 0001 x21: 
x22: 7df5ddd0 x23: 0001
x24: 7ffe8800 x25: 
x26:  x27: 
x28: 7df5e980 x29: 7df45990

Code: d65f03c0 d5033fbf b9400661 529d9502 (b8206822)

$ echo 'Code: d65f03c0 d5033fbf b9400661 529d9502 (b8206822)' |   
CROSS_COMPILE=aarch64-linux-gnu- ARCH=arm64 scripts/decodecode
Code: d65f03c0 d5033fbf b9400661 529d9502 (b8206822)
All code

   0:   d65f03c0ret
   4:   d5033fbfdmb sy
   8:   b9400661ldr w1, [x19, #4]
   c:   529d9502mov w2, #0xeca8 // #60584
  10:*  b8206822str w2, [x1, x0]<-- trapping instruction

Code starting with the faulting instruction
===
   0:   b8206822str w2, [x1, x0]


now i'm here

"Now lets use the locations provided by the elr and lr registers after 
subtracting the relocation offset to find out where in the code the crash 
occurred and from where it was invoked."

does that means that i have to subtract values of first 2 lines of trace?

0x7ff94f78 - 0x00a25f78 = 0x7F56F000

"File u-boot.map contains the memory layout of the U-Boot binary. Here we find 
these lines:"

this is not clear enough for me too...i did not found 0x7F56F000 in the file.

i expect to do anything with the address in the disassembled code (0xb8206822), 
but i do not know what :p

i've uploaded the matching u-boot.map and u-boot.dbg (output of objdump) here:

https://drive.google.com/drive/folders/10rJbjWNdkYTA_pjnfXEADIZO-7yo4ZhC?usp=sharing

regards Frank



Aw: Re: uboot FIT signature difference

2021-10-25 Thread Frank Wunderlich
> Gesendet: Sonntag, 24. Oktober 2021 um 21:53 Uhr
> Von: "Simon Glass" 
> An: "Frank Wunderlich" 
> Cc: "Philipp Tomsich" , "Kever Yang" 
> , "U-Boot Mailing List" 
> Betreff: Re: uboot FIT signature difference
>
> Hi Frank,
>
> On Sun, 10 Oct 2021 at 11:51, Frank Wunderlich  
> wrote:
> >
> > Hi,
> >
> > i try to create a upstream uboot binary for use with rockchip rk3568 
> > (bananapi r2 pro). Currently i'm on preparation phase as i don't have the 
> > hardware yet (so i cannot test it).
> >
> > First thanks to everybody upstreamed support for this SOC in uboot and 
> > linux.
> >
> > i found a compiled uboot.img with this signature:
> >
> > FIT Image with ATF/OP-TEE/U-Boot
> >
> > my created itb (make u-boot.itb) has this signature:
> >
> > FIT image for U-Boot with bl31 (TF-A)
> >
> > can anybody give me a hint how to create same signature as above? or where 
> > i have to look...
>
> As far as I know this is just the description, which you can change by
> updating the 'description' of your .its file, or binman node if you
> are using that.

Hi,

i found the signature of my binary here:

https://github.com/frank-w/u-boot/blob/2020-10-bpi/arch/arm/mach-rockchip/make_fit_atf.py#L25

string on the possible source of the other binary differs...maybe it is somehow 
changed

compile-progress seems to be this:

https://gitlab.com/pgwipeout/quartz64_ci/-/blob/main/.gitlab-ci.yml#L58

so it looks like this python-script is used:

https://gitlab.com/pgwipeout/u-boot-rockchip/-/blob/quartz64/arch/arm/mach-rockchip/make_fit_atf.py

but still different...anyway thanks for looking into it

Regards Frank

> > i guess the uboot.img is created using this source:
> > https://github.com/rockchip-linux/u-boot
> >
> > as far as i see the itb gets generated from the dtb
> >
> >   OBJCOPY u-boot-nodtb.bin
> > ./"arch/arm/mach-rockchip/make_fit_atf.py" \
> > arch/arm/dts/rk3568-evb.dtb > u-boot.its
> >   RELOC   u-boot-nodtb.bin
> >   MKIMAGE u-boot.itb
> >
> > op-tee seems to be a lib only in rockchip repo, not upstream
> >
> > https://github.com/rockchip-linux/u-boot/tree/next-dev/lib/optee_clientApi
> >
> > seems to be some kind of secure boot, idk if this is needed to boot the 
> > device
> >
> > i wonder why uboot differentiate between ATF and BL31...imho BL31 is part 
> > of ATF, do i need all parts of ATF (at least BL2) to get same signature? i 
> > have some rk3568_ddr_MHz_v1.08.bin which can be BL2 (did not found any 
> > signature and Rockchip ATF source is afaik not yet released, at least not 
> > for rk35xx which is new).
> >
> > "my" source is this:
> >
> > https://github.com/frank-w/u-boot/tree/2021-10-bpi-r2-pro
>
> I'm not sure about all these flows. It is all quite complicated these days...

no worry, i try my binary on the board if i get it ;)

> Regards,
> Simon


uboot FIT signature difference

2021-10-10 Thread Frank Wunderlich
Hi,

i try to create a upstream uboot binary for use with rockchip rk3568 (bananapi 
r2 pro). Currently i'm on preparation phase as i don't have the hardware yet 
(so i cannot test it).

First thanks to everybody upstreamed support for this SOC in uboot and linux.

i found a compiled uboot.img with this signature:

FIT Image with ATF/OP-TEE/U-Boot

my created itb (make u-boot.itb) has this signature:

FIT image for U-Boot with bl31 (TF-A)

can anybody give me a hint how to create same signature as above? or where i 
have to look...

i guess the uboot.img is created using this source:
https://github.com/rockchip-linux/u-boot

as far as i see the itb gets generated from the dtb

  OBJCOPY u-boot-nodtb.bin
./"arch/arm/mach-rockchip/make_fit_atf.py" \
arch/arm/dts/rk3568-evb.dtb > u-boot.its
  RELOC   u-boot-nodtb.bin
  MKIMAGE u-boot.itb

op-tee seems to be a lib only in rockchip repo, not upstream

https://github.com/rockchip-linux/u-boot/tree/next-dev/lib/optee_clientApi

seems to be some kind of secure boot, idk if this is needed to boot the device

i wonder why uboot differentiate between ATF and BL31...imho BL31 is part of 
ATF, do i need all parts of ATF (at least BL2) to get same signature? i have 
some rk3568_ddr_MHz_v1.08.bin which can be BL2 (did not found any signature 
and Rockchip ATF source is afaik not yet released, at least not for rk35xx 
which is new).

"my" source is this:

https://github.com/frank-w/u-boot/tree/2021-10-bpi-r2-pro

regards Frank


[PATCH] ahci: mediatek: fix undefined reference of dev_err

2021-03-16 Thread Frank Wunderlich
From: Frank Wunderlich 

building with MTK_AHCI enabled results in implicit declaration and
undefined reference of dev_err followed by a segfault of gcc

drivers/ata/mtk_ahci.c: In function 'mtk_ahci_parse_property':
drivers/ata/mtk_ahci.c:65:4: warning:
implicit declaration of function 'dev_err'
drivers/ata/mtk_ahci.c:65: undefined reference to `dev_err'
in function `mtk_ahci_probe':
drivers/ata/mtk_ahci.c:92: undefined reference to `dev_err'
Segmentation fault

fix this by adding the dm/device_compat.h to includes

Signed-off-by: Frank Wunderlich 
---
 drivers/ata/mtk_ahci.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/ata/mtk_ahci.c b/drivers/ata/mtk_ahci.c
index 554175bc0051..2c5227df306b 100644
--- a/drivers/ata/mtk_ahci.c
+++ b/drivers/ata/mtk_ahci.c
@@ -21,6 +21,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #define SYS_CFG0x14
 #define SYS_CFG_SATA_MSK   GENMASK(31, 30)
-- 
2.25.1



Aw: Re: [PATCH] board: mediatek: disable watchdog on BananaPi R2

2021-01-11 Thread Frank Wunderlich


> Gesendet: Montag, 11. Januar 2021 um 09:57 Uhr
> Von: "Heinrich Schuchardt" 

> I observed that on some recent version Linux before 5.10 booting seemed
> to be delayed by dozens of seconds on many boards. On which Linux
> version did you see the problem?
>
> >>>
> >>> I've not much experience (yet) with the "EFI stub". But if it takes
> >>> this
> >>> long, wouldn't it make sense that this stub also supports the WDT?
> >>
> >> efi_timer_check() calls WATCHDOG_RESET() trying to avoid that the
> >> hardware watchdog is triggered.

> > So efi_timer_check() is called quite frequently and should be enough
> > to reset the U-Boot WDT while residing in EFI? Not sure, why the reset
> > occurs in Matthias's case then.

Matthias could you check if/when/how often efi_timer_check is called in you 
bootprocess?

> efi_timer_check() is only invoked, if the UEFI API is invoked.
> Especially if the problem occurs after ExitBootServices() it is not
> called anymore.
>
> >
> >> There is a software watchdog
> >> defaulting to 5 minutes in efi_watchdog.c which can be modified
> >> via the EFI API.

> It would be interesting to understand if your problem occurs before or
> after efi_exit_boot_services() is called. You could you add printf()
> statements after EFI_ENTRY() and before EFI_EXIT() to see if it is reached.
>
> Could you further, please, test if adding wdt_stop() to the start of
> do_bootefi() in cmd/bootefi.c solves your problem.

should efi_timer_check not be called there to reset WDT-timer a last time to 
leave the
maximum time for booting linux kernel? maybe a wdt_stop is not neccessary 
anymore then

regards Frank


Aw: Detecting network loaded uboot

2020-11-07 Thread Frank Wunderlich
Hi,
i don't think this is possible, because uboot is loaded in both cases to memory 
before it is executed. maybe you can set some kind of memory-flag outside the 
executions range before loading from storage/network.

regards Frank


> Gesendet: Freitag, 06. November 2020 um 22:52 Uhr
> Von: "Spaker, Erich" 
> An: "u-boot@lists.denx.de" 
> Betreff: Detecting network loaded uboot
>
> I would like to configure uboot to default to network booting, if uboot.img 
> was loaded from the network itself (by SPL). Otherwise booting from the drive.
> I presume some information is passed from SPL to uboot. Is the source of 
> uboot.img (network, mmc) known to uboot after it starts?
>
> If not, I'd like to patch spl to pass this info, but I'm not sure the 
> appropriate mechanism.
> Bloblist seems appropriate, but there seemed to be some alternatives 
> discussed here 
> http://u-boot.10912.n7.nabble.com/passing-info-from-SPL-to-U-Boot-td361636.html.
>
> I am working with an am335x/beaglebone black.
> Bloblist is not configured in the standard config, I'm not sure if this 
> because of incompatibility or what the constraints are on choosing an address.
>


Re: [PATCH] PCI: mediatek: Release the resource when PCIe enable port fail

2020-09-10 Thread Frank Wunderlich
Am 10. September 2020 21:33:01 MESZ schrieb Tom Rini :

>Yes, OK, thanks for letting me know.  I've queued this up for master
>when I push again.  Is there anything else currently that's outstanding
>for MediaTek and should be in this release?

Hi,

For my boards only xhci 0.96 support is outstanding,but this is more 
functionality than bugfix and missing it does not break (only usb not working 
on bpi r2/r64). So i guess it will go in next.
regards Frank


Re: [PATCH] PCI: mediatek: Release the resource when PCIe enable port fail

2020-09-10 Thread Frank Wunderlich
Am 10. September 2020 20:40:10 MESZ schrieb Tom Rini :
>Applied to u-boot/next, thanks!

Thanks

Can it be applied to current release too as it is a fix (hang till watchdog 
reset on pci enum if no card inserted in pcie slot,but sata chip connected)?
regards Frank


Re: [PATCH v3 9/9] usb: xhci: convert to readx_poll_sleep_timeout()

2020-09-08 Thread Frank Wunderlich



Am 8. September 2020 18:47:47 MESZ schrieb Marek Vasut :

>Resend please, if I wanted to comment on any of those patches, I won't
>be able.

Have resend with bit reduced recipients (afair ryder and weijie are in GSS 
mailinglist),because this floods others mailbox. It's only a workaround.

Have you found problem or any idea why you not able to receive from chunfeng 
directly?
regards Frank


[PATCH RESEND v4 8/9] usb: xhci: use macros with parameter to fill ep_info2

2020-09-08 Thread Frank Wunderlich
From: Chunfeng Yun 

Use macros with parameter to fill ep_info2, then some macros
for MASK and SHIFT can be removed

Signed-off-by: Chunfeng Yun 
Reviewed-by: Bin Meng 
---
 drivers/usb/host/xhci-mem.c | 15 +--
 drivers/usb/host/xhci.c |  6 ++
 include/usb/xhci.h  |  6 --
 3 files changed, 7 insertions(+), 20 deletions(-)

diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index d627aa..0b49614995 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -825,25 +825,22 @@ void xhci_setup_addressable_virt_dev(struct xhci_ctrl 
*ctrl,
 
/* Step 4 - ring already allocated */
/* Step 5 */
-   ep0_ctx->ep_info2 = cpu_to_le32(CTRL_EP << EP_TYPE_SHIFT);
+   ep0_ctx->ep_info2 = cpu_to_le32(EP_TYPE(CTRL_EP));
debug("SPEED = %d\n", speed);
 
switch (speed) {
case USB_SPEED_SUPER:
-   ep0_ctx->ep_info2 |= cpu_to_le32(((512 & MAX_PACKET_MASK) <<
-   MAX_PACKET_SHIFT));
+   ep0_ctx->ep_info2 |= cpu_to_le32(MAX_PACKET(512));
debug("Setting Packet size = 512bytes\n");
break;
case USB_SPEED_HIGH:
/* USB core guesses at a 64-byte max packet first for FS devices */
case USB_SPEED_FULL:
-   ep0_ctx->ep_info2 |= cpu_to_le32(((64 & MAX_PACKET_MASK) <<
-   MAX_PACKET_SHIFT));
+   ep0_ctx->ep_info2 |= cpu_to_le32(MAX_PACKET(64));
debug("Setting Packet size = 64bytes\n");
break;
case USB_SPEED_LOW:
-   ep0_ctx->ep_info2 |= cpu_to_le32(((8 & MAX_PACKET_MASK) <<
-   MAX_PACKET_SHIFT));
+   ep0_ctx->ep_info2 |= cpu_to_le32(MAX_PACKET(8));
debug("Setting Packet size = 8bytes\n");
break;
default:
@@ -852,9 +849,7 @@ void xhci_setup_addressable_virt_dev(struct xhci_ctrl *ctrl,
}
 
/* EP 0 can handle "burst" sizes of 1, so Max Burst Size field is 0 */
-   ep0_ctx->ep_info2 |=
-   cpu_to_le32(((0 & MAX_BURST_MASK) << MAX_BURST_SHIFT) |
-   ((3 & ERROR_COUNT_MASK) << ERROR_COUNT_SHIFT));
+   ep0_ctx->ep_info2 |= cpu_to_le32(MAX_BURST(0) | ERROR_COUNT(3));
 
trb_64 = virt_to_phys(virt_dev->eps[0].ring->first_seg->trbs);
ep0_ctx->deq = cpu_to_le64(trb_64 | virt_dev->eps[0].ring->cycle_state);
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 5f3a0fba4b..fe30101d93 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -618,8 +618,7 @@ static int xhci_set_configuration(struct usb_device *udev)
cpu_to_le32(EP_MAX_ESIT_PAYLOAD_HI(max_esit_payload) |
EP_INTERVAL(interval) | EP_MULT(mult));
 
-   ep_ctx[ep_index]->ep_info2 =
-   cpu_to_le32(ep_type << EP_TYPE_SHIFT);
+   ep_ctx[ep_index]->ep_info2 = cpu_to_le32(EP_TYPE(ep_type));
ep_ctx[ep_index]->ep_info2 |=
cpu_to_le32(MAX_PACKET
(get_unaligned(_desc->wMaxPacketSize)));
@@ -832,8 +831,7 @@ int xhci_check_maxpacket(struct usb_device *udev)
ctrl->devs[slot_id]->out_ctx, ep_index);
in_ctx = ctrl->devs[slot_id]->in_ctx;
ep_ctx = xhci_get_ep_ctx(ctrl, in_ctx, ep_index);
-   ep_ctx->ep_info2 &= cpu_to_le32(~((0x & MAX_PACKET_MASK)
-   << MAX_PACKET_SHIFT));
+   ep_ctx->ep_info2 &= cpu_to_le32(~MAX_PACKET(MAX_PACKET_MASK));
ep_ctx->ep_info2 |= cpu_to_le32(MAX_PACKET(max_packet_size));
 
/*
diff --git a/include/usb/xhci.h b/include/usb/xhci.h
index 07b1aebc69..e1d382369a 100644
--- a/include/usb/xhci.h
+++ b/include/usb/xhci.h
@@ -632,11 +632,8 @@ struct xhci_ep_ctx {
  */
 #defineFORCE_EVENT (0x1)
 #define ERROR_COUNT(p) (((p) & 0x3) << 1)
-#define ERROR_COUNT_SHIFT  (1)
-#define ERROR_COUNT_MASK   (0x3)
 #define CTX_TO_EP_TYPE(p)  (((p) >> 3) & 0x7)
 #define EP_TYPE(p) ((p) << 3)
-#define EP_TYPE_SHIFT  (3)
 #define ISOC_OUT_EP1
 #define BULK_OUT_EP2
 #define INT_OUT_EP 3
@@ -647,13 +644,10 @@ struct xhci_ep_ctx {
 /* bit 6 reserved */
 /* bit 7 is Host Initiate Disable - for disabling stream selection */
 #define MAX_BURST(p)   (((p)&0xff) << 8)
-#define MAX_BURST_MASK (0xff)
-#define MAX_BURST_SHIFT(8)
 #define CTX_TO_MAX_BURST(p)(((p) >> 8) & 0xff)
 #define MAX_PACKET(p)  (((p)&0x) << 16)
 #define MAX_PACKET_MASK(0x)
 #define MAX_PACKET_DECODED(p)  (((p) >> 16) & 0x)
-#define MAX_PACKET_SHIFT   (16)
 
 /* Get max packet size from ep desc. Bit 10..0 specify the max 

[PATCH RESEND v4 9/9] usb: xhci: convert to readx_poll_sleep_timeout()

2020-09-08 Thread Frank Wunderlich
From: Chunfeng Yun 

Use readx_poll_sleep_timeout() to poll the register status

Signed-off-by: Chunfeng Yun 
Reviewed-by: Bin Meng 
---
 drivers/usb/host/xhci.c | 25 +++--
 1 file changed, 11 insertions(+), 14 deletions(-)

diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index fe30101d93..3547a9bad1 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -33,6 +33,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #ifndef CONFIG_USB_MAX_CONTROLLER_COUNT
@@ -143,23 +144,19 @@ struct xhci_ctrl *xhci_get_ctrl(struct usb_device *udev)
  * @param usec time to wait till
  * @return 0 if handshake is success else < 0 on failure
  */
-static int handshake(uint32_t volatile *ptr, uint32_t mask,
-   uint32_t done, int usec)
+static int
+handshake(uint32_t volatile *ptr, uint32_t mask, uint32_t done, int usec)
 {
uint32_t result;
+   int ret;
+
+   ret = readx_poll_sleep_timeout(xhci_readl, ptr, result,
+(result & mask) == done || result == U32_MAX,
+1, usec);
+   if (result == U32_MAX)  /* card removed */
+   return -ENODEV;
 
-   do {
-   result = xhci_readl(ptr);
-   if (result == ~(uint32_t)0)
-   return -ENODEV;
-   result &= mask;
-   if (result == done)
-   return 0;
-   usec--;
-   udelay(1);
-   } while (usec > 0);
-
-   return -ETIMEDOUT;
+   return ret;
 }
 
 /**
-- 
2.25.1



[PATCH RESEND v4 5/9] usb: xhci: convert to TRB_TYPE()

2020-09-08 Thread Frank Wunderlich
From: Chunfeng Yun 

Use TRB_TYPE(p) instead of ((p) << TRB_TYPE_SHIFT)

Signed-off-by: Chunfeng Yun 
Reviewed-by: Bin Meng 
---
 drivers/usb/host/xhci-mem.c  |  3 +--
 drivers/usb/host/xhci-ring.c | 11 +--
 include/usb/xhci.h   |  1 -
 3 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index 1da0524aa0..d627aa 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -236,8 +236,7 @@ static void xhci_link_segments(struct xhci_segment *prev,
 */
val = le32_to_cpu(prev->trbs[TRBS_PER_SEGMENT-1].link.control);
val &= ~TRB_TYPE_BITMASK;
-   val |= (TRB_LINK << TRB_TYPE_SHIFT);
-
+   val |= TRB_TYPE(TRB_LINK);
prev->trbs[TRBS_PER_SEGMENT-1].link.control = cpu_to_le32(val);
}
 }
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 3f915ae115..13c98fb09a 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -696,7 +696,7 @@ int xhci_bulk_tx(struct usb_device *udev, unsigned long 
pipe,
trb_fields[0] = lower_32_bits(addr);
trb_fields[1] = upper_32_bits(addr);
trb_fields[2] = length_field;
-   trb_fields[3] = field | (TRB_NORMAL << TRB_TYPE_SHIFT);
+   trb_fields[3] = field | TRB_TYPE(TRB_NORMAL);
 
queue_trb(ctrl, ring, (num_trbs > 1), trb_fields);
 
@@ -823,7 +823,7 @@ int xhci_ctrl_tx(struct usb_device *udev, unsigned long 
pipe,
/* Queue setup TRB - see section 6.4.1.2.1 */
/* FIXME better way to translate setup_packet into two u32 fields? */
field = 0;
-   field |= TRB_IDT | (TRB_SETUP << TRB_TYPE_SHIFT);
+   field |= TRB_IDT | TRB_TYPE(TRB_SETUP);
if (start_cycle == 0)
field |= 0x1;
 
@@ -860,9 +860,9 @@ int xhci_ctrl_tx(struct usb_device *udev, unsigned long 
pipe,
/* If there's data, queue data TRBs */
/* Only set interrupt on short packet for IN endpoints */
if (usb_pipein(pipe))
-   field = TRB_ISP | (TRB_DATA << TRB_TYPE_SHIFT);
+   field = TRB_ISP | TRB_TYPE(TRB_DATA);
else
-   field = (TRB_DATA << TRB_TYPE_SHIFT);
+   field = TRB_TYPE(TRB_DATA);
 
remainder = xhci_td_remainder(ctrl, 0, length, length,
  usb_maxpacket(udev, pipe), true);
@@ -904,8 +904,7 @@ int xhci_ctrl_tx(struct usb_device *udev, unsigned long 
pipe,
trb_fields[2] = ((0 & TRB_INTR_TARGET_MASK) << TRB_INTR_TARGET_SHIFT);
/* Event on completion */
trb_fields[3] = field | TRB_IOC |
-   (TRB_STATUS << TRB_TYPE_SHIFT) |
-   ep_ring->cycle_state;
+   TRB_TYPE(TRB_STATUS) | ep_ring->cycle_state;
 
queue_trb(ctrl, ep_ring, false, trb_fields);
 
diff --git a/include/usb/xhci.h b/include/usb/xhci.h
index cf4c0208b2..bdba51df59 100644
--- a/include/usb/xhci.h
+++ b/include/usb/xhci.h
@@ -903,7 +903,6 @@ union xhci_trb {
 /* TRB bit mask */
 #defineTRB_TYPE_BITMASK(0xfc00)
 #define TRB_TYPE(p)((p) << 10)
-#define TRB_TYPE_SHIFT (10)
 #define TRB_FIELD_TO_TYPE(p)   (((p) & TRB_TYPE_BITMASK) >> 10)
 
 /* TRB type IDs */
-- 
2.25.1



[PATCH RESEND v4 7/9] usb: xhci: convert to TRB_TX_TYPE()

2020-09-08 Thread Frank Wunderlich
From: Chunfeng Yun 

Use TRB_TX_TYPE() instead of (TRB_DATA_OUT/IN << TRB_TX_TYPE_SHIFT)

Signed-off-by: Chunfeng Yun 
Reviewed-by: Bin Meng 
---
 drivers/usb/host/xhci-ring.c | 4 ++--
 include/usb/xhci.h   | 1 -
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 9ef72efe95..b118207d93 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -830,9 +830,9 @@ int xhci_ctrl_tx(struct usb_device *udev, unsigned long 
pipe,
if (ctrl->hci_version >= 0x100 || ctrl->quirks & XHCI_MTK_HOST) {
if (length > 0) {
if (req->requesttype & USB_DIR_IN)
-   field |= (TRB_DATA_IN << TRB_TX_TYPE_SHIFT);
+   field |= TRB_TX_TYPE(TRB_DATA_IN);
else
-   field |= (TRB_DATA_OUT << TRB_TX_TYPE_SHIFT);
+   field |= TRB_TX_TYPE(TRB_DATA_OUT);
}
}
 
diff --git a/include/usb/xhci.h b/include/usb/xhci.h
index 35c66042ba..07b1aebc69 100644
--- a/include/usb/xhci.h
+++ b/include/usb/xhci.h
@@ -879,7 +879,6 @@ struct xhci_event_cmd {
 /* Control transfer TRB specific fields */
 #define TRB_DIR_IN (1<<16)
 #defineTRB_TX_TYPE(p)  ((p) << 16)
-#defineTRB_TX_TYPE_SHIFT   (16)
 #defineTRB_DATA_OUT2
 #defineTRB_DATA_IN 3
 
-- 
2.25.1



[PATCH RESEND v4 3/9] usb: xhci: add quirks flag to support MediaTek xHCI 0.96

2020-09-08 Thread Frank Wunderlich
From: Chunfeng Yun 

There some vendor quirks for MTK xHCI 0.96 host controller:
1. It defines some extra SW scheduling parameters for HW
   to minimize the scheduling effort for synchronous and
   interrupt endpoints. The parameters are put into reserved
   DWs of slot context and endpoint context.
2. Its TDS in  Normal TRB defines a number of packets that
   remains to be transferred for a TD after processing all
   Max packets in all previous TRBs.

Signed-off-by: Chunfeng Yun 
Tested-by: Frank Wunderlich 
Reviewed-by: Bin Meng 
---
 drivers/usb/host/xhci-mtk.c  | 1 +
 drivers/usb/host/xhci-ring.c | 9 +++--
 drivers/usb/host/xhci.c  | 2 +-
 include/usb/xhci.h   | 2 ++
 4 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c
index 8ff71854fc..f3f181dae0 100644
--- a/drivers/usb/host/xhci-mtk.c
+++ b/drivers/usb/host/xhci-mtk.c
@@ -258,6 +258,7 @@ static int xhci_mtk_probe(struct udevice *dev)
if (ret)
goto ssusb_init_err;
 
+   mtk->ctrl.quirks = XHCI_MTK_HOST;
hcor = (struct xhci_hcor *)((uintptr_t)mtk->hcd +
HC_LENGTH(xhci_readl(>hcd->cr_capbase)));
 
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 603e0e5b76..3f915ae115 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -332,7 +332,8 @@ static u32 xhci_td_remainder(struct xhci_ctrl *ctrl, int 
transferred,
 {
u32 total_packet_count;
 
-   if (ctrl->hci_version < 0x100)
+   /* MTK xHCI 0.96 contains some features from 1.0 */
+   if (ctrl->hci_version < 0x100 && !(ctrl->quirks & XHCI_MTK_HOST))
return ((td_total_len - transferred) >> 10);
 
/* One TRB with a zero-length data packet. */
@@ -340,6 +341,10 @@ static u32 xhci_td_remainder(struct xhci_ctrl *ctrl, int 
transferred,
trb_buff_len == td_total_len)
return 0;
 
+   /* for MTK xHCI 0.96, TD size include this TRB, but not in 1.x */
+   if ((ctrl->quirks & XHCI_MTK_HOST) && (ctrl->hci_version < 0x100))
+   trb_buff_len = 0;
+
total_packet_count = DIV_ROUND_UP(td_total_len, maxp);
 
/* Queueing functions don't count the current TRB into transferred */
@@ -823,7 +828,7 @@ int xhci_ctrl_tx(struct usb_device *udev, unsigned long 
pipe,
field |= 0x1;
 
/* xHCI 1.0 6.4.1.2.1: Transfer Type field */
-   if (ctrl->hci_version >= 0x100) {
+   if (ctrl->hci_version >= 0x100 || ctrl->quirks & XHCI_MTK_HOST) {
if (length > 0) {
if (req->requesttype & USB_DIR_IN)
field |= (TRB_DATA_IN << TRB_TX_TYPE_SHIFT);
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 4be1411243..51edeb22c1 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -650,7 +650,7 @@ static int xhci_set_configuration(struct usb_device *udev)
 * are put into reserved DWs in Slot and Endpoint Contexts
 * for synchronous endpoints.
 */
-   if (IS_ENABLED(CONFIG_USB_XHCI_MTK)) {
+   if (ctrl->quirks & XHCI_MTK_HOST) {
ep_ctx[ep_index]->reserved[0] =
cpu_to_le32(EP_BPKTS(1) | EP_BBM(1));
}
diff --git a/include/usb/xhci.h b/include/usb/xhci.h
index 15926eb9f4..3de46cd95e 100644
--- a/include/usb/xhci.h
+++ b/include/usb/xhci.h
@@ -1230,6 +1230,8 @@ struct xhci_ctrl {
struct xhci_virt_device *devs[MAX_HC_SLOTS];
int rootdev;
u16 hci_version;
+   u32 quirks;
+#define XHCI_MTK_HOST  BIT(0)
 };
 
 unsigned long trb_addr(struct xhci_segment *seg, union xhci_trb *trb);
-- 
2.25.1



[PATCH RESEND v4 2/9] usb: xhci: create one unified function to calculate TRB TD remainder

2020-09-08 Thread Frank Wunderlich
From: Chunfeng Yun 

xhci versions 1.0 and later report the untransferred data remaining in a
TD a bit differently than older hosts.

We used to have separate functions for these, and needed to check host
version before calling the right function.

Now Mediatek host has an additional quirk on how it uses the TD Size
field for remaining data. To prevent yet another function for calculating
remainder we instead want to make one quirk friendly unified function.

Porting from the Linux:
c840d6ce772d("xhci: create one unified function to calculate TRB TD remainder.")
124c39371114("xhci: use boolean to indicate last trb in td remainder 
calculation")

Signed-off-by: Chunfeng Yun 
Reviewed-by: Bin Meng 
---
 drivers/usb/host/xhci-ring.c | 105 +--
 include/usb/xhci.h   |   2 +
 2 files changed, 52 insertions(+), 55 deletions(-)

diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 79bfc349f4..603e0e5b76 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -298,55 +298,52 @@ void xhci_queue_command(struct xhci_ctrl *ctrl, u8 *ptr, 
u32 slot_id,
xhci_writel(>dba->doorbell[0], DB_VALUE_HOST);
 }
 
-/**
- * The TD size is the number of bytes remaining in the TD (including this TRB),
- * right shifted by 10.
- * It must fit in bits 21:17, so it can't be bigger than 31.
+/*
+ * For xHCI 1.0 host controllers, TD size is the number of max packet sized
+ * packets remaining in the TD (*not* including this TRB).
  *
- * @param remainderremaining packets to be sent
- * @return remainder if remainder is less than max else max
- */
-static u32 xhci_td_remainder(unsigned int remainder)
-{
-   u32 max = (1 << (21 - 17 + 1)) - 1;
-
-   if ((remainder >> 10) >= max)
-   return max << 17;
-   else
-   return (remainder >> 10) << 17;
-}
-
-/**
- * Finds out the remanining packets to be sent
+ * Total TD packet count = total_packet_count =
+ * DIV_ROUND_UP(TD size in bytes / wMaxPacketSize)
+ *
+ * Packets transferred up to and including this TRB = packets_transferred =
+ * rounddown(total bytes transferred including this TRB / wMaxPacketSize)
+ *
+ * TD size = total_packet_count - packets_transferred
  *
- * @param running_totaltotal size sent so far
+ * For xHCI 0.96 and older, TD size field should be the remaining bytes
+ * including this TRB, right shifted by 10
+ *
+ * For all hosts it must fit in bits 21:17, so it can't be bigger than 31.
+ * This is taken care of in the TRB_TD_SIZE() macro
+ *
+ * The last TRB in a TD must have the TD size set to zero.
+ *
+ * @param ctrl host controller data structure
+ * @param transferred  total size sent so far
  * @param trb_buff_len length of the TRB Buffer
- * @param total_packet_count   total packet count
- * @param maxpacketsizemax packet size of current pipe
- * @param num_trbs_leftnumber of TRBs left to be processed
- * @return 0 if running_total or trb_buff_len is 0, else remainder
+ * @param td_total_len total packet count
+ * @param maxp max packet size of current pipe
+ * @param more_trbs_coming indicate last trb in TD
+ * @return remainder
  */
-static u32 xhci_v1_0_td_remainder(int running_total,
-   int trb_buff_len,
-   unsigned int total_packet_count,
-   int maxpacketsize,
-   unsigned int num_trbs_left)
+static u32 xhci_td_remainder(struct xhci_ctrl *ctrl, int transferred,
+int trb_buff_len, unsigned int td_total_len,
+int maxp, bool more_trbs_coming)
 {
-   int packets_transferred;
+   u32 total_packet_count;
+
+   if (ctrl->hci_version < 0x100)
+   return ((td_total_len - transferred) >> 10);
 
/* One TRB with a zero-length data packet. */
-   if (num_trbs_left == 0 || (running_total == 0 && trb_buff_len == 0))
+   if (!more_trbs_coming || (transferred == 0 && trb_buff_len == 0) ||
+   trb_buff_len == td_total_len)
return 0;
 
-   /*
-* All the TRB queueing functions don't count the current TRB in
-* running_total.
-*/
-   packets_transferred = (running_total + trb_buff_len) / maxpacketsize;
+   total_packet_count = DIV_ROUND_UP(td_total_len, maxp);
 
-   if ((total_packet_count - packets_transferred) > 31)
-   return 31 << 17;
-   return (total_packet_count - packets_transferred) << 17;
+   /* Queueing functions don't count the current TRB into transferred */
+   return (total_packet_count - ((transferred + trb_buff_len) / maxp));
 }
 
 /**
@@ -572,7 +569,7 @@ int xhci_bulk_tx(struct usb_device *udev, unsigned long 
pipe,
union xhci_trb *event;
 
int running_total, trb_buff_len;
-   unsigned int total_packet_count;
+   bool more_trbs_coming = true;
int 

[PATCH RESEND v4 6/9] usb: xhci: convert to TRB_LEN() and TRB_INTR_TARGET()

2020-09-08 Thread Frank Wunderlich
From: Chunfeng Yun 

For normal TRB fields:
use TRB_LEN(x) instead of ((x) & TRB_LEN_MASK);
and use TRB_INTR_TARGET(x) instead of
(((x) & TRB_INTR_TARGET_MASK) << TRB_INTR_TARGET_SHIFT)

Signed-off-by: Chunfeng Yun 
Reviewed-by: Bin Meng 
---
 drivers/usb/host/xhci-ring.c | 16 +++-
 include/usb/xhci.h   |  3 ---
 2 files changed, 7 insertions(+), 12 deletions(-)

diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 13c98fb09a..9ef72efe95 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -688,10 +688,9 @@ int xhci_bulk_tx(struct usb_device *udev, unsigned long 
pipe,
  length, maxpacketsize,
  more_trbs_coming);
 
-   length_field = ((trb_buff_len & TRB_LEN_MASK) |
+   length_field = (TRB_LEN(trb_buff_len) |
TRB_TD_SIZE(remainder) |
-   ((0 & TRB_INTR_TARGET_MASK) <<
-   TRB_INTR_TARGET_SHIFT));
+   TRB_INTR_TARGET(0));
 
trb_fields[0] = lower_32_bits(addr);
trb_fields[1] = upper_32_bits(addr);
@@ -849,8 +848,7 @@ int xhci_ctrl_tx(struct usb_device *udev, unsigned long 
pipe,
trb_fields[1] = le16_to_cpu(req->index) |
le16_to_cpu(req->length) << 16;
/* TRB_LEN | (TRB_INTR_TARGET) */
-   trb_fields[2] = (8 | ((0 & TRB_INTR_TARGET_MASK) <<
-   TRB_INTR_TARGET_SHIFT));
+   trb_fields[2] = (TRB_LEN(8) | TRB_INTR_TARGET(0));
/* Immediate data in pointer */
trb_fields[3] = field;
queue_trb(ctrl, ep_ring, true, trb_fields);
@@ -866,11 +864,11 @@ int xhci_ctrl_tx(struct usb_device *udev, unsigned long 
pipe,
 
remainder = xhci_td_remainder(ctrl, 0, length, length,
  usb_maxpacket(udev, pipe), true);
-   length_field = (length & TRB_LEN_MASK) | TRB_TD_SIZE(remainder) |
-   ((0 & TRB_INTR_TARGET_MASK) << TRB_INTR_TARGET_SHIFT);
+   length_field = TRB_LEN(length) | TRB_TD_SIZE(remainder) |
+  TRB_INTR_TARGET(0);
debug("length_field = %d, length = %d,"
"xhci_td_remainder(length) = %d , TRB_INTR_TARGET(0) = %d\n",
-   length_field, (length & TRB_LEN_MASK),
+   length_field, TRB_LEN(length),
TRB_TD_SIZE(remainder), 0);
 
if (length > 0) {
@@ -901,7 +899,7 @@ int xhci_ctrl_tx(struct usb_device *udev, unsigned long 
pipe,
 
trb_fields[0] = 0;
trb_fields[1] = 0;
-   trb_fields[2] = ((0 & TRB_INTR_TARGET_MASK) << TRB_INTR_TARGET_SHIFT);
+   trb_fields[2] = TRB_INTR_TARGET(0);
/* Event on completion */
trb_fields[3] = field | TRB_IOC |
TRB_TYPE(TRB_STATUS) | ep_ring->cycle_state;
diff --git a/include/usb/xhci.h b/include/usb/xhci.h
index bdba51df59..35c66042ba 100644
--- a/include/usb/xhci.h
+++ b/include/usb/xhci.h
@@ -847,12 +847,9 @@ struct xhci_event_cmd {
 /* Normal TRB fields */
 /* transfer_len bitmasks - bits 0:16 */
 #defineTRB_LEN(p)  ((p) & 0x1)
-#defineTRB_LEN_MASK(0x1)
 /* TD Size, packets remaining in this TD, bits 21:17 (5 bits, so max 31) */
 #define TRB_TD_SIZE(p)  (min((p), (u32)31) << 17)
 /* Interrupter Target - which MSI-X vector to target the completion event at */
-#defineTRB_INTR_TARGET_SHIFT   (22)
-#defineTRB_INTR_TARGET_MASK(0x3ff)
 #define TRB_INTR_TARGET(p) (((p) & 0x3ff) << 22)
 #define GET_INTR_TARGET(p) (((p) >> 22) & 0x3ff)
 #define TRB_TBC(p) (((p) & 0x3) << 7)
-- 
2.25.1



[PATCH RESEND v4 1/9] usb: xhci: add a member hci_version in xhci_ctrl struct

2020-09-08 Thread Frank Wunderlich
From: Chunfeng Yun 

Add a member to save xHCI version, it's used some times.

Signed-off-by: Chunfeng Yun 
Reviewed-by: Bin Meng 
---
 drivers/usb/host/xhci-ring.c | 4 ++--
 drivers/usb/host/xhci.c  | 1 +
 include/usb/xhci.h   | 1 +
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 092ed6eaf1..79bfc349f4 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -682,7 +682,7 @@ int xhci_bulk_tx(struct usb_device *udev, unsigned long 
pipe,
field |= TRB_ISP;
 
/* Set the TRB length, TD size, and interrupter fields. */
-   if (HC_VERSION(xhci_readl(>hccr->cr_capbase)) < 0x100)
+   if (ctrl->hci_version < 0x100)
remainder = xhci_td_remainder(length - running_total);
else
remainder = xhci_v1_0_td_remainder(running_total,
@@ -830,7 +830,7 @@ int xhci_ctrl_tx(struct usb_device *udev, unsigned long 
pipe,
field |= 0x1;
 
/* xHCI 1.0 6.4.1.2.1: Transfer Type field */
-   if (HC_VERSION(xhci_readl(>hccr->cr_capbase)) >= 0x100) {
+   if (ctrl->hci_version >= 0x100) {
if (length > 0) {
if (req->requesttype & USB_DIR_IN)
field |= (TRB_DATA_IN << TRB_TX_TYPE_SHIFT);
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 126dabc11b..4be1411243 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -1283,6 +1283,7 @@ static int xhci_lowlevel_init(struct xhci_ctrl *ctrl)
 
reg = HC_VERSION(xhci_readl(>cr_capbase));
printf("USB XHCI %x.%02x\n", reg >> 8, reg & 0xff);
+   ctrl->hci_version = reg;
 
return 0;
 }
diff --git a/include/usb/xhci.h b/include/usb/xhci.h
index 7d34103fd5..a3e5914b10 100644
--- a/include/usb/xhci.h
+++ b/include/usb/xhci.h
@@ -1227,6 +1227,7 @@ struct xhci_ctrl {
struct xhci_scratchpad *scratchpad;
struct xhci_virt_device *devs[MAX_HC_SLOTS];
int rootdev;
+   u16 hci_version;
 };
 
 unsigned long trb_addr(struct xhci_segment *seg, union xhci_trb *trb);
-- 
2.25.1



[PATCH RESEND v4 4/9] usb: xhci: convert to HCS_MAX_PORTS()

2020-09-08 Thread Frank Wunderlich
From: Chunfeng Yun 

Use HCS_MAX_PORTS(p) instead of
((p & HCS_MAX_PORTS_MASK) >> HCS_MAX_PORTS_SHIFT)

Signed-off-by: Chunfeng Yun 
Reviewed-by: Bin Meng 
---
 drivers/usb/host/xhci.c | 3 +--
 include/usb/xhci.h  | 2 --
 2 files changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 51edeb22c1..5f3a0fba4b 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -1257,8 +1257,7 @@ static int xhci_lowlevel_init(struct xhci_ctrl *ctrl)
return -ENOMEM;
 
reg = xhci_readl(>cr_hcsparams1);
-   descriptor.hub.bNbrPorts = ((reg & HCS_MAX_PORTS_MASK) >>
-   HCS_MAX_PORTS_SHIFT);
+   descriptor.hub.bNbrPorts = HCS_MAX_PORTS(reg);
printf("Register %x NbrPorts %d\n", reg, descriptor.hub.bNbrPorts);
 
/* Port Indicators */
diff --git a/include/usb/xhci.h b/include/usb/xhci.h
index 3de46cd95e..cf4c0208b2 100644
--- a/include/usb/xhci.h
+++ b/include/usb/xhci.h
@@ -101,8 +101,6 @@ struct xhci_hccr {
 /* bits 8:18, Max Interrupters */
 #define HCS_MAX_INTRS(p)   (((p) >> 8) & 0x7ff)
 /* bits 24:31, Max Ports - max value is 0x7F = 127 ports */
-#define HCS_MAX_PORTS_SHIFT24
-#define HCS_MAX_PORTS_MASK (0xff << HCS_MAX_PORTS_SHIFT)
 #define HCS_MAX_PORTS(p)   (((p) >> 24) & 0xff)
 
 /* HCSPARAMS2 - hcs_params2 - bitmasks */
-- 
2.25.1



Re: [PATCH v3 9/9] usb: xhci: convert to readx_poll_sleep_timeout()

2020-09-08 Thread Frank Wunderlich



Am 8. September 2020 18:15:05 MESZ schrieb Marek Vasut :
>Thank you, I cannot apply a patchset which only has "Re:" in my
>mailbox,
>because the original patches are just not there.

Should i resend v4? Or could you apply from Patchwork (series link in upper 
right of Patch)? Thats the way i use :)

https://patchwork.ozlabs.org/project/uboot/list/?series=200140
regards Frank


[RESEND PATCH v2 11/11] usb: xhci: convert to readx_poll_sleep_timeout()

2020-09-02 Thread Frank Wunderlich
From: Chunfeng Yun 

Use readx_poll_sleep_timeout() to poll the register status

Change-Id: If05a68baf52c54ab30029279e349be6076f1d0ca
Signed-off-by: Chunfeng Yun 
---
 drivers/usb/host/xhci.c | 25 +++--
 1 file changed, 11 insertions(+), 14 deletions(-)

diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index fe30101d93..3547a9bad1 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -33,6 +33,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #ifndef CONFIG_USB_MAX_CONTROLLER_COUNT
@@ -143,23 +144,19 @@ struct xhci_ctrl *xhci_get_ctrl(struct usb_device *udev)
  * @param usec time to wait till
  * @return 0 if handshake is success else < 0 on failure
  */
-static int handshake(uint32_t volatile *ptr, uint32_t mask,
-   uint32_t done, int usec)
+static int
+handshake(uint32_t volatile *ptr, uint32_t mask, uint32_t done, int usec)
 {
uint32_t result;
+   int ret;
+
+   ret = readx_poll_sleep_timeout(xhci_readl, ptr, result,
+(result & mask) == done || result == U32_MAX,
+1, usec);
+   if (result == U32_MAX)  /* card removed */
+   return -ENODEV;
 
-   do {
-   result = xhci_readl(ptr);
-   if (result == ~(uint32_t)0)
-   return -ENODEV;
-   result &= mask;
-   if (result == done)
-   return 0;
-   usec--;
-   udelay(1);
-   } while (usec > 0);
-
-   return -ETIMEDOUT;
+   return ret;
 }
 
 /**
-- 
2.25.1



[RESEND PATCH v2 10/11] usb: xhci: use macros with parameter to fill ep_info2

2020-09-02 Thread Frank Wunderlich
From: Chunfeng Yun 

Use macros with parameter to fill ep_info2, then some macros
for MASK and SHIFT can be removed

Signed-off-by: Chunfeng Yun 
---
 drivers/usb/host/xhci-mem.c | 13 -
 drivers/usb/host/xhci.c |  3 +--
 include/usb/xhci.h  |  5 -
 3 files changed, 5 insertions(+), 16 deletions(-)

diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index 6292542210..0b49614995 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -830,20 +830,17 @@ void xhci_setup_addressable_virt_dev(struct xhci_ctrl 
*ctrl,
 
switch (speed) {
case USB_SPEED_SUPER:
-   ep0_ctx->ep_info2 |= cpu_to_le32(((512 & MAX_PACKET_MASK) <<
-   MAX_PACKET_SHIFT));
+   ep0_ctx->ep_info2 |= cpu_to_le32(MAX_PACKET(512));
debug("Setting Packet size = 512bytes\n");
break;
case USB_SPEED_HIGH:
/* USB core guesses at a 64-byte max packet first for FS devices */
case USB_SPEED_FULL:
-   ep0_ctx->ep_info2 |= cpu_to_le32(((64 & MAX_PACKET_MASK) <<
-   MAX_PACKET_SHIFT));
+   ep0_ctx->ep_info2 |= cpu_to_le32(MAX_PACKET(64));
debug("Setting Packet size = 64bytes\n");
break;
case USB_SPEED_LOW:
-   ep0_ctx->ep_info2 |= cpu_to_le32(((8 & MAX_PACKET_MASK) <<
-   MAX_PACKET_SHIFT));
+   ep0_ctx->ep_info2 |= cpu_to_le32(MAX_PACKET(8));
debug("Setting Packet size = 8bytes\n");
break;
default:
@@ -852,9 +849,7 @@ void xhci_setup_addressable_virt_dev(struct xhci_ctrl *ctrl,
}
 
/* EP 0 can handle "burst" sizes of 1, so Max Burst Size field is 0 */
-   ep0_ctx->ep_info2 |=
-   cpu_to_le32(((0 & MAX_BURST_MASK) << MAX_BURST_SHIFT) |
-   ((3 & ERROR_COUNT_MASK) << ERROR_COUNT_SHIFT));
+   ep0_ctx->ep_info2 |= cpu_to_le32(MAX_BURST(0) | ERROR_COUNT(3));
 
trb_64 = virt_to_phys(virt_dev->eps[0].ring->first_seg->trbs);
ep0_ctx->deq = cpu_to_le64(trb_64 | virt_dev->eps[0].ring->cycle_state);
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 6244f25c33..fe30101d93 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -831,8 +831,7 @@ int xhci_check_maxpacket(struct usb_device *udev)
ctrl->devs[slot_id]->out_ctx, ep_index);
in_ctx = ctrl->devs[slot_id]->in_ctx;
ep_ctx = xhci_get_ep_ctx(ctrl, in_ctx, ep_index);
-   ep_ctx->ep_info2 &= cpu_to_le32(~((0x & MAX_PACKET_MASK)
-   << MAX_PACKET_SHIFT));
+   ep_ctx->ep_info2 &= cpu_to_le32(~MAX_PACKET(MAX_PACKET_MASK));
ep_ctx->ep_info2 |= cpu_to_le32(MAX_PACKET(max_packet_size));
 
/*
diff --git a/include/usb/xhci.h b/include/usb/xhci.h
index c534297cc0..e1d382369a 100644
--- a/include/usb/xhci.h
+++ b/include/usb/xhci.h
@@ -632,8 +632,6 @@ struct xhci_ep_ctx {
  */
 #defineFORCE_EVENT (0x1)
 #define ERROR_COUNT(p) (((p) & 0x3) << 1)
-#define ERROR_COUNT_SHIFT  (1)
-#define ERROR_COUNT_MASK   (0x3)
 #define CTX_TO_EP_TYPE(p)  (((p) >> 3) & 0x7)
 #define EP_TYPE(p) ((p) << 3)
 #define ISOC_OUT_EP1
@@ -646,13 +644,10 @@ struct xhci_ep_ctx {
 /* bit 6 reserved */
 /* bit 7 is Host Initiate Disable - for disabling stream selection */
 #define MAX_BURST(p)   (((p)&0xff) << 8)
-#define MAX_BURST_MASK (0xff)
-#define MAX_BURST_SHIFT(8)
 #define CTX_TO_MAX_BURST(p)(((p) >> 8) & 0xff)
 #define MAX_PACKET(p)  (((p)&0x) << 16)
 #define MAX_PACKET_MASK(0x)
 #define MAX_PACKET_DECODED(p)  (((p) >> 16) & 0x)
-#define MAX_PACKET_SHIFT   (16)
 
 /* Get max packet size from ep desc. Bit 10..0 specify the max packet size.
  * USB2.0 spec 9.6.6.
-- 
2.25.1



[RESEND PATCH v2 09/11] usb: xhci: convert to EP_TYPE()

2020-09-02 Thread Frank Wunderlich
From: Chunfeng Yun 

Use EP_TYPE(type) macro instead of ((type) << EP_TYPE_SHIFT)

Signed-off-by: Chunfeng Yun 
---
 drivers/usb/host/xhci-mem.c | 2 +-
 drivers/usb/host/xhci.c | 3 +--
 include/usb/xhci.h  | 1 -
 3 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index d627aa..6292542210 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -825,7 +825,7 @@ void xhci_setup_addressable_virt_dev(struct xhci_ctrl *ctrl,
 
/* Step 4 - ring already allocated */
/* Step 5 */
-   ep0_ctx->ep_info2 = cpu_to_le32(CTRL_EP << EP_TYPE_SHIFT);
+   ep0_ctx->ep_info2 = cpu_to_le32(EP_TYPE(CTRL_EP));
debug("SPEED = %d\n", speed);
 
switch (speed) {
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 5f3a0fba4b..6244f25c33 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -618,8 +618,7 @@ static int xhci_set_configuration(struct usb_device *udev)
cpu_to_le32(EP_MAX_ESIT_PAYLOAD_HI(max_esit_payload) |
EP_INTERVAL(interval) | EP_MULT(mult));
 
-   ep_ctx[ep_index]->ep_info2 =
-   cpu_to_le32(ep_type << EP_TYPE_SHIFT);
+   ep_ctx[ep_index]->ep_info2 = cpu_to_le32(EP_TYPE(ep_type));
ep_ctx[ep_index]->ep_info2 |=
cpu_to_le32(MAX_PACKET
(get_unaligned(_desc->wMaxPacketSize)));
diff --git a/include/usb/xhci.h b/include/usb/xhci.h
index 07b1aebc69..c534297cc0 100644
--- a/include/usb/xhci.h
+++ b/include/usb/xhci.h
@@ -636,7 +636,6 @@ struct xhci_ep_ctx {
 #define ERROR_COUNT_MASK   (0x3)
 #define CTX_TO_EP_TYPE(p)  (((p) >> 3) & 0x7)
 #define EP_TYPE(p) ((p) << 3)
-#define EP_TYPE_SHIFT  (3)
 #define ISOC_OUT_EP1
 #define BULK_OUT_EP2
 #define INT_OUT_EP 3
-- 
2.25.1



[RESEND PATCH v2 04/11] usb: xhci: convert to HCS_MAX_PORTS()

2020-09-02 Thread Frank Wunderlich
From: Chunfeng Yun 

Use HCS_MAX_PORTS(p) instead of
((p & HCS_MAX_PORTS_MASK) >> HCS_MAX_PORTS_SHIFT)

Signed-off-by: Chunfeng Yun 
---
 drivers/usb/host/xhci.c | 3 +--
 include/usb/xhci.h  | 2 --
 2 files changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 51edeb22c1..5f3a0fba4b 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -1257,8 +1257,7 @@ static int xhci_lowlevel_init(struct xhci_ctrl *ctrl)
return -ENOMEM;
 
reg = xhci_readl(>cr_hcsparams1);
-   descriptor.hub.bNbrPorts = ((reg & HCS_MAX_PORTS_MASK) >>
-   HCS_MAX_PORTS_SHIFT);
+   descriptor.hub.bNbrPorts = HCS_MAX_PORTS(reg);
printf("Register %x NbrPorts %d\n", reg, descriptor.hub.bNbrPorts);
 
/* Port Indicators */
diff --git a/include/usb/xhci.h b/include/usb/xhci.h
index 3de46cd95e..cf4c0208b2 100644
--- a/include/usb/xhci.h
+++ b/include/usb/xhci.h
@@ -101,8 +101,6 @@ struct xhci_hccr {
 /* bits 8:18, Max Interrupters */
 #define HCS_MAX_INTRS(p)   (((p) >> 8) & 0x7ff)
 /* bits 24:31, Max Ports - max value is 0x7F = 127 ports */
-#define HCS_MAX_PORTS_SHIFT24
-#define HCS_MAX_PORTS_MASK (0xff << HCS_MAX_PORTS_SHIFT)
 #define HCS_MAX_PORTS(p)   (((p) >> 24) & 0xff)
 
 /* HCSPARAMS2 - hcs_params2 - bitmasks */
-- 
2.25.1



[RESEND PATCH v2 08/11] usb: xhci: convert to TRB_TX_TYPE()

2020-09-02 Thread Frank Wunderlich
From: Chunfeng Yun 

Use TRB_TX_TYPE() instead of (TRB_DATA_OUT/IN << TRB_TX_TYPE_SHIFT)

Signed-off-by: Chunfeng Yun 
---
 drivers/usb/host/xhci-ring.c | 4 ++--
 include/usb/xhci.h   | 1 -
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 99c84f95b3..ccf2a35b9f 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -830,9 +830,9 @@ int xhci_ctrl_tx(struct usb_device *udev, unsigned long 
pipe,
if (ctrl->hci_version >= 0x100 || ctrl->quirks & XHCI_MTK_HOST) {
if (length > 0) {
if (req->requesttype & USB_DIR_IN)
-   field |= (TRB_DATA_IN << TRB_TX_TYPE_SHIFT);
+   field |= TRB_TX_TYPE(TRB_DATA_IN);
else
-   field |= (TRB_DATA_OUT << TRB_TX_TYPE_SHIFT);
+   field |= TRB_TX_TYPE(TRB_DATA_OUT);
}
}
 
diff --git a/include/usb/xhci.h b/include/usb/xhci.h
index 35c66042ba..07b1aebc69 100644
--- a/include/usb/xhci.h
+++ b/include/usb/xhci.h
@@ -879,7 +879,6 @@ struct xhci_event_cmd {
 /* Control transfer TRB specific fields */
 #define TRB_DIR_IN (1<<16)
 #defineTRB_TX_TYPE(p)  ((p) << 16)
-#defineTRB_TX_TYPE_SHIFT   (16)
 #defineTRB_DATA_OUT2
 #defineTRB_DATA_IN 3
 
-- 
2.25.1



[RESEND PATCH v2 06/11] usb: xhci: convert to TRB_INTR_TARGET()

2020-09-02 Thread Frank Wunderlich
From: Chunfeng Yun 

Use TRB_INTR_TARGET(x) instead of
(((x) & TRB_INTR_TARGET_MASK) << TRB_INTR_TARGET_SHIFT)

Signed-off-by: Chunfeng Yun 
---
 drivers/usb/host/xhci-ring.c | 10 --
 include/usb/xhci.h   |  2 --
 2 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 87891fdb58..16d2e02cfa 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -690,8 +690,7 @@ int xhci_bulk_tx(struct usb_device *udev, unsigned long 
pipe,
 
length_field = ((trb_buff_len & TRB_LEN_MASK) |
TRB_TD_SIZE(remainder) |
-   ((0 & TRB_INTR_TARGET_MASK) <<
-   TRB_INTR_TARGET_SHIFT));
+   TRB_INTR_TARGET(0));
 
trb_fields[0] = lower_32_bits(addr);
trb_fields[1] = upper_32_bits(addr);
@@ -849,8 +848,7 @@ int xhci_ctrl_tx(struct usb_device *udev, unsigned long 
pipe,
trb_fields[1] = le16_to_cpu(req->index) |
le16_to_cpu(req->length) << 16;
/* TRB_LEN | (TRB_INTR_TARGET) */
-   trb_fields[2] = (8 | ((0 & TRB_INTR_TARGET_MASK) <<
-   TRB_INTR_TARGET_SHIFT));
+   trb_fields[2] = (8 | TRB_INTR_TARGET(0));
/* Immediate data in pointer */
trb_fields[3] = field;
queue_trb(ctrl, ep_ring, true, trb_fields);
@@ -867,7 +865,7 @@ int xhci_ctrl_tx(struct usb_device *udev, unsigned long 
pipe,
remainder = xhci_td_remainder(ctrl, 0, length, length,
  usb_maxpacket(udev, pipe), 1);
length_field = (length & TRB_LEN_MASK) | TRB_TD_SIZE(remainder) |
-   ((0 & TRB_INTR_TARGET_MASK) << TRB_INTR_TARGET_SHIFT);
+   TRB_INTR_TARGET(0);
debug("length_field = %d, length = %d,"
"xhci_td_remainder(length) = %d , TRB_INTR_TARGET(0) = %d\n",
length_field, (length & TRB_LEN_MASK),
@@ -901,7 +899,7 @@ int xhci_ctrl_tx(struct usb_device *udev, unsigned long 
pipe,
 
trb_fields[0] = 0;
trb_fields[1] = 0;
-   trb_fields[2] = ((0 & TRB_INTR_TARGET_MASK) << TRB_INTR_TARGET_SHIFT);
+   trb_fields[2] = TRB_INTR_TARGET(0);
/* Event on completion */
trb_fields[3] = field | TRB_IOC |
TRB_TYPE(TRB_STATUS) | ep_ring->cycle_state;
diff --git a/include/usb/xhci.h b/include/usb/xhci.h
index bdba51df59..ca3d99b954 100644
--- a/include/usb/xhci.h
+++ b/include/usb/xhci.h
@@ -851,8 +851,6 @@ struct xhci_event_cmd {
 /* TD Size, packets remaining in this TD, bits 21:17 (5 bits, so max 31) */
 #define TRB_TD_SIZE(p)  (min((p), (u32)31) << 17)
 /* Interrupter Target - which MSI-X vector to target the completion event at */
-#defineTRB_INTR_TARGET_SHIFT   (22)
-#defineTRB_INTR_TARGET_MASK(0x3ff)
 #define TRB_INTR_TARGET(p) (((p) & 0x3ff) << 22)
 #define GET_INTR_TARGET(p) (((p) >> 22) & 0x3ff)
 #define TRB_TBC(p) (((p) & 0x3) << 7)
-- 
2.25.1



[RESEND PATCH v2 07/11] usb: xhci: convert to TRB_LEN()

2020-09-02 Thread Frank Wunderlich
From: Chunfeng Yun 

Use TRB_LEN(x) instead of ((x) & TRB_LEN_MASK)

Signed-off-by: Chunfeng Yun 
---
 drivers/usb/host/xhci-ring.c | 8 
 include/usb/xhci.h   | 1 -
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 16d2e02cfa..99c84f95b3 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -688,7 +688,7 @@ int xhci_bulk_tx(struct usb_device *udev, unsigned long 
pipe,
  length, maxpacketsize,
  more_trbs_coming);
 
-   length_field = ((trb_buff_len & TRB_LEN_MASK) |
+   length_field = (TRB_LEN(trb_buff_len) |
TRB_TD_SIZE(remainder) |
TRB_INTR_TARGET(0));
 
@@ -848,7 +848,7 @@ int xhci_ctrl_tx(struct usb_device *udev, unsigned long 
pipe,
trb_fields[1] = le16_to_cpu(req->index) |
le16_to_cpu(req->length) << 16;
/* TRB_LEN | (TRB_INTR_TARGET) */
-   trb_fields[2] = (8 | TRB_INTR_TARGET(0));
+   trb_fields[2] = (TRB_LEN(8) | TRB_INTR_TARGET(0));
/* Immediate data in pointer */
trb_fields[3] = field;
queue_trb(ctrl, ep_ring, true, trb_fields);
@@ -864,11 +864,11 @@ int xhci_ctrl_tx(struct usb_device *udev, unsigned long 
pipe,
 
remainder = xhci_td_remainder(ctrl, 0, length, length,
  usb_maxpacket(udev, pipe), 1);
-   length_field = (length & TRB_LEN_MASK) | TRB_TD_SIZE(remainder) |
+   length_field = TRB_LEN(length) | TRB_TD_SIZE(remainder) |
TRB_INTR_TARGET(0);
debug("length_field = %d, length = %d,"
"xhci_td_remainder(length) = %d , TRB_INTR_TARGET(0) = %d\n",
-   length_field, (length & TRB_LEN_MASK),
+   length_field, TRB_LEN(length),
TRB_TD_SIZE(remainder), 0);
 
if (length > 0) {
diff --git a/include/usb/xhci.h b/include/usb/xhci.h
index ca3d99b954..35c66042ba 100644
--- a/include/usb/xhci.h
+++ b/include/usb/xhci.h
@@ -847,7 +847,6 @@ struct xhci_event_cmd {
 /* Normal TRB fields */
 /* transfer_len bitmasks - bits 0:16 */
 #defineTRB_LEN(p)  ((p) & 0x1)
-#defineTRB_LEN_MASK(0x1)
 /* TD Size, packets remaining in this TD, bits 21:17 (5 bits, so max 31) */
 #define TRB_TD_SIZE(p)  (min((p), (u32)31) << 17)
 /* Interrupter Target - which MSI-X vector to target the completion event at */
-- 
2.25.1



[RESEND PATCH v2 02/11] usb: xhci: create one unified function to calculate TRB TD remainder.

2020-09-02 Thread Frank Wunderlich
From: Chunfeng Yun 

xhci versions 1.0 and later report the untransferred data remaining in a
TD a bit differently than older hosts.

We used to have separate functions for these, and needed to check host
version before calling the right function.

Now Mediatek host has an additional quirk on how it uses the TD Size
field for remaining data. To prevent yet another function for calculating
remainder we instead want to make one quirk friendly unified function.

Porting from the Linux:
c840d6ce772d("xhci: create one unified function to calculate TRB TD remainder.")
124c39371114("xhci: use boolean to indicate last trb in td remainder 
calculation")

Signed-off-by: Chunfeng Yun 
---
 drivers/usb/host/xhci-ring.c | 105 +--
 include/usb/xhci.h   |   2 +
 2 files changed, 52 insertions(+), 55 deletions(-)

diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 79bfc349f4..0f86b011f3 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -298,55 +298,52 @@ void xhci_queue_command(struct xhci_ctrl *ctrl, u8 *ptr, 
u32 slot_id,
xhci_writel(>dba->doorbell[0], DB_VALUE_HOST);
 }
 
-/**
- * The TD size is the number of bytes remaining in the TD (including this TRB),
- * right shifted by 10.
- * It must fit in bits 21:17, so it can't be bigger than 31.
+/*
+ * For xHCI 1.0 host controllers, TD size is the number of max packet sized
+ * packets remaining in the TD (*not* including this TRB).
  *
- * @param remainderremaining packets to be sent
- * @return remainder if remainder is less than max else max
- */
-static u32 xhci_td_remainder(unsigned int remainder)
-{
-   u32 max = (1 << (21 - 17 + 1)) - 1;
-
-   if ((remainder >> 10) >= max)
-   return max << 17;
-   else
-   return (remainder >> 10) << 17;
-}
-
-/**
- * Finds out the remanining packets to be sent
+ * Total TD packet count = total_packet_count =
+ * DIV_ROUND_UP(TD size in bytes / wMaxPacketSize)
+ *
+ * Packets transferred up to and including this TRB = packets_transferred =
+ * rounddown(total bytes transferred including this TRB / wMaxPacketSize)
+ *
+ * TD size = total_packet_count - packets_transferred
  *
- * @param running_totaltotal size sent so far
+ * For xHCI 0.96 and older, TD size field should be the remaining bytes
+ * including this TRB, right shifted by 10
+ *
+ * For all hosts it must fit in bits 21:17, so it can't be bigger than 31.
+ * This is taken care of in the TRB_TD_SIZE() macro
+ *
+ * The last TRB in a TD must have the TD size set to zero.
+ *
+ * @param ctrl host controller data structure
+ * @param transferred  total size sent so far
  * @param trb_buff_len length of the TRB Buffer
- * @param total_packet_count   total packet count
- * @param maxpacketsizemax packet size of current pipe
- * @param num_trbs_leftnumber of TRBs left to be processed
- * @return 0 if running_total or trb_buff_len is 0, else remainder
+ * @param td_total_len total packet count
+ * @param maxp max packet size of current pipe
+ * @param more_trbs_coming indicate last trb in TD
+ * @return remainder
  */
-static u32 xhci_v1_0_td_remainder(int running_total,
-   int trb_buff_len,
-   unsigned int total_packet_count,
-   int maxpacketsize,
-   unsigned int num_trbs_left)
+static u32 xhci_td_remainder(struct xhci_ctrl *ctrl, int transferred,
+int trb_buff_len, unsigned int td_total_len,
+int maxp, bool more_trbs_coming)
 {
-   int packets_transferred;
+   u32 total_packet_count;
+
+   if (ctrl->hci_version < 0x100)
+   return ((td_total_len - transferred) >> 10);
 
/* One TRB with a zero-length data packet. */
-   if (num_trbs_left == 0 || (running_total == 0 && trb_buff_len == 0))
+   if (!more_trbs_coming || (transferred == 0 && trb_buff_len == 0) ||
+   trb_buff_len == td_total_len)
return 0;
 
-   /*
-* All the TRB queueing functions don't count the current TRB in
-* running_total.
-*/
-   packets_transferred = (running_total + trb_buff_len) / maxpacketsize;
+   total_packet_count = DIV_ROUND_UP(td_total_len, maxp);
 
-   if ((total_packet_count - packets_transferred) > 31)
-   return 31 << 17;
-   return (total_packet_count - packets_transferred) << 17;
+   /* Queueing functions don't count the current TRB into transferred */
+   return (total_packet_count - ((transferred + trb_buff_len) / maxp));
 }
 
 /**
@@ -572,7 +569,7 @@ int xhci_bulk_tx(struct usb_device *udev, unsigned long 
pipe,
union xhci_trb *event;
 
int running_total, trb_buff_len;
-   unsigned int total_packet_count;
+   bool more_trbs_coming = true;
int maxpacketsize;
u64 

[RESEND PATCH v2 05/11] usb: xhci: convert to TRB_TYPE()

2020-09-02 Thread Frank Wunderlich
From: Chunfeng Yun 

Use TRB_TYPE(p) instead of ((p) << TRB_TYPE_SHIFT)

Signed-off-by: Chunfeng Yun 
---
 drivers/usb/host/xhci-mem.c  |  3 +--
 drivers/usb/host/xhci-ring.c | 11 +--
 include/usb/xhci.h   |  1 -
 3 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index 1da0524aa0..d627aa 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -236,8 +236,7 @@ static void xhci_link_segments(struct xhci_segment *prev,
 */
val = le32_to_cpu(prev->trbs[TRBS_PER_SEGMENT-1].link.control);
val &= ~TRB_TYPE_BITMASK;
-   val |= (TRB_LINK << TRB_TYPE_SHIFT);
-
+   val |= TRB_TYPE(TRB_LINK);
prev->trbs[TRBS_PER_SEGMENT-1].link.control = cpu_to_le32(val);
}
 }
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index cf8b9d2362..87891fdb58 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -696,7 +696,7 @@ int xhci_bulk_tx(struct usb_device *udev, unsigned long 
pipe,
trb_fields[0] = lower_32_bits(addr);
trb_fields[1] = upper_32_bits(addr);
trb_fields[2] = length_field;
-   trb_fields[3] = field | (TRB_NORMAL << TRB_TYPE_SHIFT);
+   trb_fields[3] = field | TRB_TYPE(TRB_NORMAL);
 
queue_trb(ctrl, ring, (num_trbs > 1), trb_fields);
 
@@ -823,7 +823,7 @@ int xhci_ctrl_tx(struct usb_device *udev, unsigned long 
pipe,
/* Queue setup TRB - see section 6.4.1.2.1 */
/* FIXME better way to translate setup_packet into two u32 fields? */
field = 0;
-   field |= TRB_IDT | (TRB_SETUP << TRB_TYPE_SHIFT);
+   field |= TRB_IDT | TRB_TYPE(TRB_SETUP);
if (start_cycle == 0)
field |= 0x1;
 
@@ -860,9 +860,9 @@ int xhci_ctrl_tx(struct usb_device *udev, unsigned long 
pipe,
/* If there's data, queue data TRBs */
/* Only set interrupt on short packet for IN endpoints */
if (usb_pipein(pipe))
-   field = TRB_ISP | (TRB_DATA << TRB_TYPE_SHIFT);
+   field = TRB_ISP | TRB_TYPE(TRB_DATA);
else
-   field = (TRB_DATA << TRB_TYPE_SHIFT);
+   field = TRB_TYPE(TRB_DATA);
 
remainder = xhci_td_remainder(ctrl, 0, length, length,
  usb_maxpacket(udev, pipe), 1);
@@ -904,8 +904,7 @@ int xhci_ctrl_tx(struct usb_device *udev, unsigned long 
pipe,
trb_fields[2] = ((0 & TRB_INTR_TARGET_MASK) << TRB_INTR_TARGET_SHIFT);
/* Event on completion */
trb_fields[3] = field | TRB_IOC |
-   (TRB_STATUS << TRB_TYPE_SHIFT) |
-   ep_ring->cycle_state;
+   TRB_TYPE(TRB_STATUS) | ep_ring->cycle_state;
 
queue_trb(ctrl, ep_ring, false, trb_fields);
 
diff --git a/include/usb/xhci.h b/include/usb/xhci.h
index cf4c0208b2..bdba51df59 100644
--- a/include/usb/xhci.h
+++ b/include/usb/xhci.h
@@ -903,7 +903,6 @@ union xhci_trb {
 /* TRB bit mask */
 #defineTRB_TYPE_BITMASK(0xfc00)
 #define TRB_TYPE(p)((p) << 10)
-#define TRB_TYPE_SHIFT (10)
 #define TRB_FIELD_TO_TYPE(p)   (((p) & TRB_TYPE_BITMASK) >> 10)
 
 /* TRB type IDs */
-- 
2.25.1



[RESEND PATCH v2 01/11] usb: xhci: add a member hci_version in xhci_ctrl struct

2020-09-02 Thread Frank Wunderlich
From: Chunfeng Yun 

Add a member to save xHCI version, it's used some times.

Signed-off-by: Chunfeng Yun 
---
 drivers/usb/host/xhci-ring.c | 4 ++--
 drivers/usb/host/xhci.c  | 1 +
 include/usb/xhci.h   | 1 +
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 092ed6eaf1..79bfc349f4 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -682,7 +682,7 @@ int xhci_bulk_tx(struct usb_device *udev, unsigned long 
pipe,
field |= TRB_ISP;
 
/* Set the TRB length, TD size, and interrupter fields. */
-   if (HC_VERSION(xhci_readl(>hccr->cr_capbase)) < 0x100)
+   if (ctrl->hci_version < 0x100)
remainder = xhci_td_remainder(length - running_total);
else
remainder = xhci_v1_0_td_remainder(running_total,
@@ -830,7 +830,7 @@ int xhci_ctrl_tx(struct usb_device *udev, unsigned long 
pipe,
field |= 0x1;
 
/* xHCI 1.0 6.4.1.2.1: Transfer Type field */
-   if (HC_VERSION(xhci_readl(>hccr->cr_capbase)) >= 0x100) {
+   if (ctrl->hci_version >= 0x100) {
if (length > 0) {
if (req->requesttype & USB_DIR_IN)
field |= (TRB_DATA_IN << TRB_TX_TYPE_SHIFT);
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 126dabc11b..4be1411243 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -1283,6 +1283,7 @@ static int xhci_lowlevel_init(struct xhci_ctrl *ctrl)
 
reg = HC_VERSION(xhci_readl(>cr_capbase));
printf("USB XHCI %x.%02x\n", reg >> 8, reg & 0xff);
+   ctrl->hci_version = reg;
 
return 0;
 }
diff --git a/include/usb/xhci.h b/include/usb/xhci.h
index 7d34103fd5..a3e5914b10 100644
--- a/include/usb/xhci.h
+++ b/include/usb/xhci.h
@@ -1227,6 +1227,7 @@ struct xhci_ctrl {
struct xhci_scratchpad *scratchpad;
struct xhci_virt_device *devs[MAX_HC_SLOTS];
int rootdev;
+   u16 hci_version;
 };
 
 unsigned long trb_addr(struct xhci_segment *seg, union xhci_trb *trb);
-- 
2.25.1



[RESEND PATCH v2 03/11] usb: xhci: add quirks flag to support MediaTek xHCI 0.96

2020-09-02 Thread Frank Wunderlich
From: Chunfeng Yun 

There some vendor quirks for MTK xHCI 0.96 host controller:
1. It defines some extra SW scheduling parameters for HW
   to minimize the scheduling effort for synchronous and
   interrupt endpoints. The parameters are put into reseved
   DWs of slot context and endpoint context.
2. Its TDS in  Normal TRB defines a number of packets that
   remains to be transferred for a TD after processing all
   Max packets in all previous TRBs.

Signed-off-by: Chunfeng Yun 
Tested-by: Frank Wunderlich 
---
 drivers/usb/host/xhci-mtk.c  | 1 +
 drivers/usb/host/xhci-ring.c | 9 +++--
 drivers/usb/host/xhci.c  | 2 +-
 include/usb/xhci.h   | 2 ++
 4 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c
index 8ff71854fc..f3f181dae0 100644
--- a/drivers/usb/host/xhci-mtk.c
+++ b/drivers/usb/host/xhci-mtk.c
@@ -258,6 +258,7 @@ static int xhci_mtk_probe(struct udevice *dev)
if (ret)
goto ssusb_init_err;
 
+   mtk->ctrl.quirks = XHCI_MTK_HOST;
hcor = (struct xhci_hcor *)((uintptr_t)mtk->hcd +
HC_LENGTH(xhci_readl(>hcd->cr_capbase)));
 
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 0f86b011f3..cf8b9d2362 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -332,7 +332,8 @@ static u32 xhci_td_remainder(struct xhci_ctrl *ctrl, int 
transferred,
 {
u32 total_packet_count;
 
-   if (ctrl->hci_version < 0x100)
+   /* MTK xHCI 0.96 contains some features from 1.0 */
+   if (ctrl->hci_version < 0x100 && !(ctrl->quirks & XHCI_MTK_HOST))
return ((td_total_len - transferred) >> 10);
 
/* One TRB with a zero-length data packet. */
@@ -340,6 +341,10 @@ static u32 xhci_td_remainder(struct xhci_ctrl *ctrl, int 
transferred,
trb_buff_len == td_total_len)
return 0;
 
+   /* for MTK xHCI 0.96, TD size include this TRB, but not in 1.x */
+   if ((ctrl->quirks & XHCI_MTK_HOST) && (ctrl->hci_version < 0x100))
+   trb_buff_len = 0;
+
total_packet_count = DIV_ROUND_UP(td_total_len, maxp);
 
/* Queueing functions don't count the current TRB into transferred */
@@ -823,7 +828,7 @@ int xhci_ctrl_tx(struct usb_device *udev, unsigned long 
pipe,
field |= 0x1;
 
/* xHCI 1.0 6.4.1.2.1: Transfer Type field */
-   if (ctrl->hci_version >= 0x100) {
+   if (ctrl->hci_version >= 0x100 || ctrl->quirks & XHCI_MTK_HOST) {
if (length > 0) {
if (req->requesttype & USB_DIR_IN)
field |= (TRB_DATA_IN << TRB_TX_TYPE_SHIFT);
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 4be1411243..51edeb22c1 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -650,7 +650,7 @@ static int xhci_set_configuration(struct usb_device *udev)
 * are put into reserved DWs in Slot and Endpoint Contexts
 * for synchronous endpoints.
 */
-   if (IS_ENABLED(CONFIG_USB_XHCI_MTK)) {
+   if (ctrl->quirks & XHCI_MTK_HOST) {
ep_ctx[ep_index]->reserved[0] =
cpu_to_le32(EP_BPKTS(1) | EP_BBM(1));
}
diff --git a/include/usb/xhci.h b/include/usb/xhci.h
index 15926eb9f4..3de46cd95e 100644
--- a/include/usb/xhci.h
+++ b/include/usb/xhci.h
@@ -1230,6 +1230,8 @@ struct xhci_ctrl {
struct xhci_virt_device *devs[MAX_HC_SLOTS];
int rootdev;
u16 hci_version;
+   u32 quirks;
+#define XHCI_MTK_HOST  BIT(0)
 };
 
 unsigned long trb_addr(struct xhci_segment *seg, union xhci_trb *trb);
-- 
2.25.1



Aw: [PATCH] PCI: mediatek: Release the resource when PCIe enable port fail

2020-08-31 Thread Frank Wunderlich
Hi,

thank you for fixing this issue :)

regards Frank


> Gesendet: Montag, 31. August 2020 um 09:53 Uhr
> Von: "Chuanjia Liu" 
> On the mt7623 platform, if one port enable fail and other port
> enable succeed. It will hang on when using pci enum
> because the resource was not released correctly.
>
> Signed-off-by: Chuanjia Liu 
> Tested-by: Frank Wunderlich 

if fixes-Tag is needed:

Fixes: 42d37450e5 ("pci: mediatek: add PCIe controller support for MT7623")


Aw: [PATCH RESEND v2 01/11] usb: xhci: add a member hci_version in xhci_ctrl struct

2020-08-27 Thread Frank Wunderlich
Hi,

any change to get this series into 2020-10?

i'm asking because tom write that merge window for next will be opened soon. 
imho that means that current release cycle allows only fixes, right?

usb for mt7622/23 needs these patches to work properly (currently only 
controller is detected with my dts-patches)

regards Frank


Re: [PATCH v6 0/7] Add MTK AHCI driver, BPI-R64 dts and USB-Nodes for mt7622>

2020-08-22 Thread Frank Wunderlich
Pcie is already merged and usb is v2

https://patchwork.ozlabs.org/project/uboot/list/?series=195873
regards Frank


[PATCH v6 6/7] arm: dts: mt7622: add USB nodes

2020-08-20 Thread Frank Wunderlich
From: Frank Wunderlich 

Add DTS nodes for MT7622/BPI-R64

Signed-off-by: Frank Wunderlich 
Reviewed-by: Chunfeng Yun 
---
v1->v2:
 - remove clk25m as it's not needed
---
 arch/arm/dts/mt7622-bananapi-bpi-r64.dts |  8 
 arch/arm/dts/mt7622-rfb.dts  |  8 
 arch/arm/dts/mt7622.dtsi | 56 
 3 files changed, 72 insertions(+)

diff --git a/arch/arm/dts/mt7622-bananapi-bpi-r64.dts 
b/arch/arm/dts/mt7622-bananapi-bpi-r64.dts
index 51287cea3a..4f2f04851d 100644
--- a/arch/arm/dts/mt7622-bananapi-bpi-r64.dts
+++ b/arch/arm/dts/mt7622-bananapi-bpi-r64.dts
@@ -244,3 +244,11 @@
output-low;
};
 };
+
+ {
+   status = "okay";
+};
+
+ {
+   status = "okay";
+};
diff --git a/arch/arm/dts/mt7622-rfb.dts b/arch/arm/dts/mt7622-rfb.dts
index 317fc78abd..ef7d0f0270 100644
--- a/arch/arm/dts/mt7622-rfb.dts
+++ b/arch/arm/dts/mt7622-rfb.dts
@@ -222,3 +222,11 @@
full-duplex;
};
 };
+
+ {
+   status = "okay";
+};
+
+ {
+   status = "okay";
+};
diff --git a/arch/arm/dts/mt7622.dtsi b/arch/arm/dts/mt7622.dtsi
index c43ad65702..d888545809 100644
--- a/arch/arm/dts/mt7622.dtsi
+++ b/arch/arm/dts/mt7622.dtsi
@@ -192,6 +192,14 @@
status = "disabled";
};
 
+   ssusbsys: ssusbsys@1a00 {
+   compatible = "mediatek,mt7622-ssusbsys",
+"syscon";
+   reg = <0x1a00 0x1000>;
+   #clock-cells = <1>;
+   #reset-cells = <1>;
+   };
+
pciesys: pciesys@1a100800 {
compatible = "mediatek,mt7622-pciesys", "syscon";
reg = <0x1a100800 0x1000>;
@@ -302,6 +310,54 @@
};
};
 
+   ssusb: usb@1a0c {
+   compatible = "mediatek,mt7622-xhci",
+"mediatek,mtk-xhci";
+   reg = <0x1a0c 0x01000>,
+ <0x1a0c4700 0x0100>;
+   reg-names = "mac", "ippc";
+   interrupts = ;
+   power-domains = < MT7629_POWER_DOMAIN_HIF1>;
+   clocks = < CLK_SSUSB_SYS_EN>,
+< CLK_SSUSB_REF_EN>,
+< CLK_SSUSB_MCU_EN>,
+< CLK_SSUSB_DMA_EN>;
+   clock-names = "sys_ck", "ref_ck", "mcu_ck", "dma_ck";
+   phys = < PHY_TYPE_USB2>,
+  < PHY_TYPE_USB3>,
+  < PHY_TYPE_USB2>;
+   status = "disabled";
+   };
+
+   u3phy: usb-phy@1a0c4000 {
+   compatible = "mediatek,mt7622-u3phy",
+"mediatek,generic-tphy-v1";
+   reg = <0x1a0c4000 0x700>;
+   #address-cells = <1>;
+   #size-cells = <1>;
+   ranges;
+   status = "disabled";
+
+   u2port0: usb-phy@1a0c4800 {
+   reg = <0x1a0c4800 0x0100>;
+   #phy-cells = <1>;
+   clocks = < CLK_SSUSB_U2_PHY_EN>;
+   clock-names = "ref";
+   };
+
+   u3port0: usb-phy@1a0c4900 {
+   reg = <0x1a0c4900 0x0700>;
+   #phy-cells = <1>;
+   };
+
+   u2port1: usb-phy@1a0c5000 {
+   reg = <0x1a0c5000 0x0100>;
+   #phy-cells = <1>;
+   clocks = < CLK_SSUSB_U2_PHY_1P_EN>;
+   clock-names = "ref";
+   };
+   };
+
ethsys: syscon@1b00 {
compatible = "mediatek,mt7622-ethsys", "syscon";
reg = <0x1b00 0x1000>;
-- 
2.25.1



[PATCH v6 5/7] arm: dts: rename mt7622-bpi-r64.dts

2020-08-20 Thread Frank Wunderlich
From: Frank Wunderlich 

rename mt7622-bpi-r64.dts to mt7622-bananapi-bpi-r64.dts
to follow naming convensions

Signed-off-by: Frank Wunderlich 
---
 arch/arm/dts/Makefile   | 2 +-
 .../arm/dts/{mt7622-bpi-r64.dts => mt7622-bananapi-bpi-r64.dts} | 0
 2 files changed, 1 insertion(+), 1 deletion(-)
 rename arch/arm/dts/{mt7622-bpi-r64.dts => mt7622-bananapi-bpi-r64.dts} (100%)

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index b2b5360f6d..9a28958103 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -962,7 +962,7 @@ dtb-$(CONFIG_SOC_K3_J721E) += 
k3-j721e-common-proc-board.dtb \
 dtb-$(CONFIG_ARCH_MEDIATEK) += \
mt7622-rfb.dtb \
mt7623a-unielec-u7623-02-emmc.dtb \
-   mt7622-bpi-r64.dtb \
+   mt7622-bananapi-bpi-r64.dtb \
mt7623n-bananapi-bpi-r2.dtb \
mt7629-rfb.dtb \
mt8512-bm1-emmc.dtb \
diff --git a/arch/arm/dts/mt7622-bpi-r64.dts 
b/arch/arm/dts/mt7622-bananapi-bpi-r64.dts
similarity index 100%
rename from arch/arm/dts/mt7622-bpi-r64.dts
rename to arch/arm/dts/mt7622-bananapi-bpi-r64.dts
-- 
2.25.1



[PATCH v6 7/7] arm: dts: mt7623: add USB nodes

2020-08-20 Thread Frank Wunderlich
From: Frank Wunderlich 

This adds USB nodes for MT7623/BPI-R2

Signed-off-by: Frank Wunderlich 
Reviewed-by: Chunfeng Yun 
---
 arch/arm/dts/mt7623.dtsi | 46 
 arch/arm/dts/mt7623n-bananapi-bpi-r2.dts | 16 +
 2 files changed, 62 insertions(+)

diff --git a/arch/arm/dts/mt7623.dtsi b/arch/arm/dts/mt7623.dtsi
index 0452889ef8..b5a802552b 100644
--- a/arch/arm/dts/mt7623.dtsi
+++ b/arch/arm/dts/mt7623.dtsi
@@ -352,6 +352,52 @@
};
};
 
+   usb1: usb@1a1c {
+   compatible = "mediatek,mt7623-xhci", "mediatek,mtk-xhci";
+   reg = <0x1a1c 0x1000>, <0x1a1c4700 0x0100>;
+   reg-names = "mac", "ippc";
+   power-domains = < MT7623_POWER_DOMAIN_HIF>;
+   clocks = < CLK_HIFSYS_USB0PHY>, < 
CLK_TOP_ETHIF_SEL>;
+   clock-names = "sys_ck", "ref_ck";
+   phys = < PHY_TYPE_USB2>, < PHY_TYPE_USB3>;
+   status = "disabled";
+   };
+
+   u3phy1: usb-phy@1a1c4000 {
+   compatible = "mediatek,mt7623-tphy", "mediatek,generic-tphy-v1";
+
+   reg = <0x1a1c4000 0x0700>;
+   #address-cells = <1>;
+   #size-cells = <1>;
+   ranges;
+   status = "disabled";
+
+   u2port0: usb-phy@1a1c4800 {
+   reg = <0x1a1c4800 0x0100>;
+   #phy-cells = <1>;
+   clocks = < CLK_TOP_USB_PHY48M>;
+   clock-names = "ref";
+   };
+
+   u3port0: usb-phy@1a1c4900 {
+   reg = <0x1a1c4900 0x0700>;
+   #phy-cells = <1>;
+   clocks = <>;
+   clock-names = "ref";
+   };
+   };
+
+   usb2: usb@1a24 {
+   compatible = "mediatek,mt7623-xhci", "mediatek,mtk-xhci";
+   reg = <0x1a24 0x1000>, <0x1a244700 0x0100>;
+   reg-names = "mac", "ippc";
+   power-domains = < MT7623_POWER_DOMAIN_HIF>;
+   clocks = < CLK_HIFSYS_USB1PHY>, < 
CLK_TOP_ETHIF_SEL>;
+   clock-names = "sys_ck", "ref_ck";
+   phys = < PHY_TYPE_USB2>, < PHY_TYPE_USB3>;
+   status = "disabled";
+   };
+
u3phy2: usb-phy@1a244000 {
compatible = "mediatek,generic-tphy-v1";
reg = <0x1a244000 0x0700>;
diff --git a/arch/arm/dts/mt7623n-bananapi-bpi-r2.dts 
b/arch/arm/dts/mt7623n-bananapi-bpi-r2.dts
index bcedcf20f1..ef07369627 100644
--- a/arch/arm/dts/mt7623n-bananapi-bpi-r2.dts
+++ b/arch/arm/dts/mt7623n-bananapi-bpi-r2.dts
@@ -248,3 +248,19 @@
pinctrl-0 = <_pins_a>;
status = "okay";
 };
+
+ {
+   status = "okay";
+};
+
+ {
+   status = "okay";
+};
+
+ {
+   status = "okay";
+};
+
+ {
+   status = "okay";
+};
-- 
2.25.1



[PATCH v6 3/7] ahci: mediatek: fix copyright and author-lines

2020-08-20 Thread Frank Wunderlich
From: Frank Wunderlich 

after review of sam copyright should be on one line and link should
not between author lines

just remove the link and put ryder first as he is author of linux-driver

Signed-off-by: Frank Wunderlich 
---
 drivers/ata/mtk_ahci.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/ata/mtk_ahci.c b/drivers/ata/mtk_ahci.c
index 8e09c5f9e6..4ad260a5bb 100644
--- a/drivers/ata/mtk_ahci.c
+++ b/drivers/ata/mtk_ahci.c
@@ -2,12 +2,10 @@
 /*
  * MTK SATA platform driver
  *
- * (C) Copyright 2020
- * Mediatek
+ * Copyright (C) 2020 MediaTek Inc.
  *
- * Author: Frank Wunderlich 
- * based on 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/ata/ahci_mtk.c
  * Author: Ryder Lee 
+ * Author: Frank Wunderlich 
  */
 
 #include 
-- 
2.25.1



[PATCH v6 4/7] clk: mt7622: add needed clocks for ssusb-node

2020-08-20 Thread Frank Wunderlich
From: Frank Wunderlich 

MT7622 needs additional clock definitions to work properly

Signed-off-by: Frank Wunderlich 
---
 drivers/clk/mediatek/clk-mt7622.c | 42 +++
 1 file changed, 42 insertions(+)

diff --git a/drivers/clk/mediatek/clk-mt7622.c 
b/drivers/clk/mediatek/clk-mt7622.c
index a1a35f72a3..0246149107 100644
--- a/drivers/clk/mediatek/clk-mt7622.c
+++ b/drivers/clk/mediatek/clk-mt7622.c
@@ -521,6 +521,20 @@ static const struct mtk_gate_regs sgmii_cg_regs = {
.flags = CLK_GATE_NO_SETCLR_INV | CLK_PARENT_TOPCKGEN,  \
 }
 
+static const struct mtk_gate_regs ssusb_cg_regs = {
+   .set_ofs = 0x30,
+   .clr_ofs = 0x30,
+   .sta_ofs = 0x30,
+};
+
+#define GATE_SSUSB(_id, _parent, _shift) {  \
+   .id = _id,  \
+   .parent = _parent,  \
+   .regs = _cg_regs, \
+   .shift = _shift,\
+   .flags = CLK_GATE_NO_SETCLR_INV | CLK_PARENT_TOPCKGEN,  \
+}
+
 static const struct mtk_gate sgmii_cgs[] = {
GATE_SGMII(CLK_SGMII_TX250M_EN, CLK_TOP_SSUSB_TX250M, 2),
GATE_SGMII(CLK_SGMII_RX250M_EN, CLK_TOP_SSUSB_EQ_RX250M, 3),
@@ -528,6 +542,15 @@ static const struct mtk_gate sgmii_cgs[] = {
GATE_SGMII(CLK_SGMII_CDR_FB, CLK_TOP_SSUSB_CDR_FB, 5),
 };
 
+static const struct mtk_gate ssusb_cgs[] = {
+   GATE_SSUSB(CLK_SSUSB_U2_PHY_1P_EN, CLK_TOP_TO_U2_PHY_1P, 0),
+   GATE_SSUSB(CLK_SSUSB_U2_PHY_EN, CLK_TOP_TO_U2_PHY, 1),
+   GATE_SSUSB(CLK_SSUSB_REF_EN, CLK_TOP_TO_USB3_REF, 5),
+   GATE_SSUSB(CLK_SSUSB_SYS_EN, CLK_TOP_TO_USB3_SYS, 6),
+   GATE_SSUSB(CLK_SSUSB_MCU_EN, CLK_TOP_AXI_SEL, 7),
+   GATE_SSUSB(CLK_SSUSB_DMA_EN, CLK_TOP_HIF_SEL, 8),
+};
+
 static const struct mtk_clk_tree mt7622_clk_tree = {
.xtal_rate = 25 * MHZ,
.xtal2_rate = 25 * MHZ,
@@ -630,6 +653,11 @@ static int mt7622_sgmiisys_probe(struct udevice *dev)
return mtk_common_clk_gate_init(dev, _clk_tree, sgmii_cgs);
 }
 
+static int mt7622_ssusbsys_probe(struct udevice *dev)
+{
+   return mtk_common_clk_gate_init(dev, _clk_tree, ssusb_cgs);
+}
+
 static const struct udevice_id mt7622_apmixed_compat[] = {
{ .compatible = "mediatek,mt7622-apmixedsys" },
{ }
@@ -670,6 +698,11 @@ static const struct udevice_id mt7622_mcucfg_compat[] = {
{ }
 };
 
+static const struct udevice_id mt7622_ssusbsys_compat[] = {
+   { .compatible = "mediatek,mt7622-ssusbsys" },
+   { }
+};
+
 U_BOOT_DRIVER(mtk_mcucfg) = {
.name = "mt7622-mcucfg",
.id = UCLASS_SYSCON,
@@ -746,3 +779,12 @@ U_BOOT_DRIVER(mtk_clk_sgmiisys) = {
.priv_auto_alloc_size = sizeof(struct mtk_cg_priv),
.ops = _clk_gate_ops,
 };
+
+U_BOOT_DRIVER(mtk_clk_ssusbsys) = {
+   .name = "mt7622-clock-ssusbsys",
+   .id = UCLASS_CLK,
+   .of_match = mt7622_ssusbsys_compat,
+   .probe = mt7622_ssusbsys_probe,
+   .priv_auto_alloc_size = sizeof(struct mtk_cg_priv),
+   .ops = _clk_gate_ops,
+};
-- 
2.25.1



[PATCH v6 0/7] Add MTK AHCI driver, BPI-R64 dts and USB-Nodes for mt7622>

2020-08-20 Thread Frank Wunderlich
From: Frank Wunderlich 

This series adds Mediatek AHCI driver, makes neccessary phy modifications
creates new dts for bananapi-r64 (because it's a bit different to rfb)
and adds all DTS nodes to get SATA and USB working on mt7622 and mt7623

they are based on top of this:

Add PCIe and its clock support for mt7622
https://patchwork.ozlabs.org/project/uboot/list/?series=194888

and to get USB working (no hard depency, ports get enumerated without it):
usb: xhci: add a member hci_version in xhci_ctrl struct
https://patchwork.ozlabs.org/project/uboot/list/?series=195331

v5->v6:
 - fix commit-subjects/messages to take care of actual changes in part 2+3
   there are only small changes like dropping comment and reorder Authors
 - rename now existing bpi-r64.dts to follow naming convensions
 - drop commits creating new r64 dts and adding sata-nodes
v4->v5:
 - rebased on master because old series got merged
v3->v4:
 - fix wrong squashing of pciesys-comment
v2->v3:
 - fixed code style suggested by sam
v1->v2:
 - made register of phy optional for tphy v1 and remove it in dts


Frank Wunderlich (7):
  phy: mtk-tphy: make shared reg optional for v1
  reset: drop unnecessary comment for pciesys
  ahci: mediatek: fix copyright and author-lines
  clk: mt7622: add needed clocks for ssusb-node
  arm: dts: rename mt7622-bpi-r64.dts
  arm: dts: mt7622: add USB nodes
  arm: dts: mt7623: add USB nodes

 arch/arm/dts/Makefile |  2 +-
 ...pi-r64.dts => mt7622-bananapi-bpi-r64.dts} |  8 +++
 arch/arm/dts/mt7622-rfb.dts   |  8 +++
 arch/arm/dts/mt7622.dtsi  | 56 +++
 arch/arm/dts/mt7623.dtsi  | 46 +++
 arch/arm/dts/mt7623n-bananapi-bpi-r2.dts  | 16 ++
 drivers/ata/mtk_ahci.c|  6 +-
 drivers/clk/mediatek/clk-mt7622.c | 43 +-
 drivers/phy/phy-mtk-tphy.c|  5 +-
 9 files changed, 181 insertions(+), 9 deletions(-)
 rename arch/arm/dts/{mt7622-bpi-r64.dts => mt7622-bananapi-bpi-r64.dts} (98%)

-- 
2.25.1



[PATCH v6 2/7] reset: drop unnecessary comment for pciesys

2020-08-20 Thread Frank Wunderlich
From: Frank Wunderlich 

after review from sam this comment should be removed

Signed-off-by: Frank Wunderlich 
---
 drivers/clk/mediatek/clk-mt7622.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/clk/mediatek/clk-mt7622.c 
b/drivers/clk/mediatek/clk-mt7622.c
index d53ed69189..a1a35f72a3 100644
--- a/drivers/clk/mediatek/clk-mt7622.c
+++ b/drivers/clk/mediatek/clk-mt7622.c
@@ -599,7 +599,6 @@ static int mt7622_pciesys_bind(struct udevice *dev)
int ret = 0;
 
if (IS_ENABLED(CONFIG_RESET_MEDIATEK)) {
-// PCIESYS uses in linux also 0x34 = ETHSYS reset controller
ret = mediatek_reset_bind(dev, ETHSYS_HIFSYS_RST_CTRL_OFS, 1);
if (ret)
debug("Warning: failed to bind reset controller\n");
-- 
2.25.1



[PATCH v6 1/7] phy: mtk-tphy: make shared reg optional for v1

2020-08-20 Thread Frank Wunderlich
From: Frank Wunderlich 

make the shared reg optional when version is v1 for sata

Suggested-by: Chunfeng Yun 
Signed-off-by: Frank Wunderlich 
Reviewed-by: Chunfeng Yun 
---
 drivers/phy/phy-mtk-tphy.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/phy/phy-mtk-tphy.c b/drivers/phy/phy-mtk-tphy.c
index 326227a30d..3d7b9cd2b1 100644
--- a/drivers/phy/phy-mtk-tphy.c
+++ b/drivers/phy/phy-mtk-tphy.c
@@ -698,11 +698,10 @@ static int mtk_tphy_probe(struct udevice *dev)
tphy->dev = dev;
tphy->version = dev_get_driver_data(dev);
 
-   /* v1 has shared banks */
+   /* v1 has shared banks for usb/pcie mode, */
+   /* but not for sata mode */
if (tphy->version == MTK_TPHY_V1) {
tphy->sif_base = dev_read_addr_ptr(dev);
-   if (!tphy->sif_base)
-   return -ENOENT;
}
 
dev_for_each_subnode(subnode, dev) {
-- 
2.25.1



Re: [PATCH v5 5/8] arm: dts: add dts for Bananapi-R64

2020-08-20 Thread Frank Wunderlich
Here i change to rename the now existing bpi-r64.dts to bananapi-bpi-r64 to 
follow naming sheme like bpi-2 instead of creating a new one
regards Frank


Aw: [PATCH v5 3/8] ahci: mediatek: add ahci driver

2020-08-20 Thread Frank Wunderlich
mhm, maybe i should change commit-subject/message because there are only 
changes suggested from sam...same for part2

regards Frank


> Gesendet: Donnerstag, 20. August 2020 um 15:40 Uhr
> Von: "Frank Wunderlich" 
> Betreff: [PATCH v5 3/8] ahci: mediatek: add ahci driver
>
> add AHCI driver ported from linux
> diff --git a/drivers/ata/mtk_ahci.c b/drivers/ata/mtk_ahci.c
> index 8e09c5f9e6..4ad260a5bb 100644
> --- a/drivers/ata/mtk_ahci.c
> +++ b/drivers/ata/mtk_ahci.c
> @@ -2,12 +2,10 @@
>  /*
>   * MTK SATA platform driver
>   *
> - * (C) Copyright 2020
> - * Mediatek
> + * Copyright (C) 2020 MediaTek Inc.
>   *
> - * Author: Frank Wunderlich 
> - * based on 
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/ata/ahci_mtk.c
>   * Author: Ryder Lee 
> + * Author: Frank Wunderlich 
>   */



[PATCH v5 8/8] arm: dts: mt7623: add USB nodes

2020-08-20 Thread Frank Wunderlich
From: Frank Wunderlich 

This adds USB nodes for MT7623/BPI-R2

Signed-off-by: Frank Wunderlich 
Reviewed-by: Chunfeng Yun 
---
 arch/arm/dts/mt7623.dtsi | 46 
 arch/arm/dts/mt7623n-bananapi-bpi-r2.dts | 16 +
 2 files changed, 62 insertions(+)

diff --git a/arch/arm/dts/mt7623.dtsi b/arch/arm/dts/mt7623.dtsi
index 0452889ef8..b5a802552b 100644
--- a/arch/arm/dts/mt7623.dtsi
+++ b/arch/arm/dts/mt7623.dtsi
@@ -352,6 +352,52 @@
};
};
 
+   usb1: usb@1a1c {
+   compatible = "mediatek,mt7623-xhci", "mediatek,mtk-xhci";
+   reg = <0x1a1c 0x1000>, <0x1a1c4700 0x0100>;
+   reg-names = "mac", "ippc";
+   power-domains = < MT7623_POWER_DOMAIN_HIF>;
+   clocks = < CLK_HIFSYS_USB0PHY>, < 
CLK_TOP_ETHIF_SEL>;
+   clock-names = "sys_ck", "ref_ck";
+   phys = < PHY_TYPE_USB2>, < PHY_TYPE_USB3>;
+   status = "disabled";
+   };
+
+   u3phy1: usb-phy@1a1c4000 {
+   compatible = "mediatek,mt7623-tphy", "mediatek,generic-tphy-v1";
+
+   reg = <0x1a1c4000 0x0700>;
+   #address-cells = <1>;
+   #size-cells = <1>;
+   ranges;
+   status = "disabled";
+
+   u2port0: usb-phy@1a1c4800 {
+   reg = <0x1a1c4800 0x0100>;
+   #phy-cells = <1>;
+   clocks = < CLK_TOP_USB_PHY48M>;
+   clock-names = "ref";
+   };
+
+   u3port0: usb-phy@1a1c4900 {
+   reg = <0x1a1c4900 0x0700>;
+   #phy-cells = <1>;
+   clocks = <>;
+   clock-names = "ref";
+   };
+   };
+
+   usb2: usb@1a24 {
+   compatible = "mediatek,mt7623-xhci", "mediatek,mtk-xhci";
+   reg = <0x1a24 0x1000>, <0x1a244700 0x0100>;
+   reg-names = "mac", "ippc";
+   power-domains = < MT7623_POWER_DOMAIN_HIF>;
+   clocks = < CLK_HIFSYS_USB1PHY>, < 
CLK_TOP_ETHIF_SEL>;
+   clock-names = "sys_ck", "ref_ck";
+   phys = < PHY_TYPE_USB2>, < PHY_TYPE_USB3>;
+   status = "disabled";
+   };
+
u3phy2: usb-phy@1a244000 {
compatible = "mediatek,generic-tphy-v1";
reg = <0x1a244000 0x0700>;
diff --git a/arch/arm/dts/mt7623n-bananapi-bpi-r2.dts 
b/arch/arm/dts/mt7623n-bananapi-bpi-r2.dts
index bcedcf20f1..ef07369627 100644
--- a/arch/arm/dts/mt7623n-bananapi-bpi-r2.dts
+++ b/arch/arm/dts/mt7623n-bananapi-bpi-r2.dts
@@ -248,3 +248,19 @@
pinctrl-0 = <_pins_a>;
status = "okay";
 };
+
+ {
+   status = "okay";
+};
+
+ {
+   status = "okay";
+};
+
+ {
+   status = "okay";
+};
+
+ {
+   status = "okay";
+};
-- 
2.25.1



[PATCH v5 7/8] arm: dts: mt7622: add USB nodes

2020-08-20 Thread Frank Wunderlich
From: Frank Wunderlich 

Add DTS nodes for MT7622/BPI-R64

Signed-off-by: Frank Wunderlich 
Reviewed-by: Chunfeng Yun 
---
v1->v2:
 - remove clk25m as it's not needed
---
 arch/arm/dts/mt7622-bananapi-bpi-r64.dts |  8 
 arch/arm/dts/mt7622-rfb.dts  |  8 
 arch/arm/dts/mt7622.dtsi | 56 
 3 files changed, 72 insertions(+)

diff --git a/arch/arm/dts/mt7622-bananapi-bpi-r64.dts 
b/arch/arm/dts/mt7622-bananapi-bpi-r64.dts
index c36ec8f8d0..7cd581cf7d 100644
--- a/arch/arm/dts/mt7622-bananapi-bpi-r64.dts
+++ b/arch/arm/dts/mt7622-bananapi-bpi-r64.dts
@@ -213,3 +213,11 @@
output-low;
};
 };
+
+ {
+   status = "okay";
+};
+
+ {
+   status = "okay";
+};
diff --git a/arch/arm/dts/mt7622-rfb.dts b/arch/arm/dts/mt7622-rfb.dts
index 317fc78abd..ef7d0f0270 100644
--- a/arch/arm/dts/mt7622-rfb.dts
+++ b/arch/arm/dts/mt7622-rfb.dts
@@ -222,3 +222,11 @@
full-duplex;
};
 };
+
+ {
+   status = "okay";
+};
+
+ {
+   status = "okay";
+};
diff --git a/arch/arm/dts/mt7622.dtsi b/arch/arm/dts/mt7622.dtsi
index 6b4260407e..5a4dab185f 100644
--- a/arch/arm/dts/mt7622.dtsi
+++ b/arch/arm/dts/mt7622.dtsi
@@ -192,6 +192,14 @@
status = "disabled";
};
 
+   ssusbsys: ssusbsys@1a00 {
+   compatible = "mediatek,mt7622-ssusbsys",
+"syscon";
+   reg = <0x1a00 0x1000>;
+   #clock-cells = <1>;
+   #reset-cells = <1>;
+   };
+
pciesys: pciesys@1a100800 {
compatible = "mediatek,mt7622-pciesys", "syscon";
reg = <0x1a100800 0x1000>;
@@ -301,6 +309,54 @@
};
};
 
+   ssusb: usb@1a0c {
+   compatible = "mediatek,mt7622-xhci",
+"mediatek,mtk-xhci";
+   reg = <0x1a0c 0x01000>,
+ <0x1a0c4700 0x0100>;
+   reg-names = "mac", "ippc";
+   interrupts = ;
+   power-domains = < MT7629_POWER_DOMAIN_HIF1>;
+   clocks = < CLK_SSUSB_SYS_EN>,
+< CLK_SSUSB_REF_EN>,
+< CLK_SSUSB_MCU_EN>,
+< CLK_SSUSB_DMA_EN>;
+   clock-names = "sys_ck", "ref_ck", "mcu_ck", "dma_ck";
+   phys = < PHY_TYPE_USB2>,
+  < PHY_TYPE_USB3>,
+  < PHY_TYPE_USB2>;
+   status = "disabled";
+   };
+
+   u3phy: usb-phy@1a0c4000 {
+   compatible = "mediatek,mt7622-u3phy",
+"mediatek,generic-tphy-v1";
+   reg = <0x1a0c4000 0x700>;
+   #address-cells = <1>;
+   #size-cells = <1>;
+   ranges;
+   status = "disabled";
+
+   u2port0: usb-phy@1a0c4800 {
+   reg = <0x1a0c4800 0x0100>;
+   #phy-cells = <1>;
+   clocks = < CLK_SSUSB_U2_PHY_EN>;
+   clock-names = "ref";
+   };
+
+   u3port0: usb-phy@1a0c4900 {
+   reg = <0x1a0c4900 0x0700>;
+   #phy-cells = <1>;
+   };
+
+   u2port1: usb-phy@1a0c5000 {
+   reg = <0x1a0c5000 0x0100>;
+   #phy-cells = <1>;
+   clocks = < CLK_SSUSB_U2_PHY_1P_EN>;
+   clock-names = "ref";
+   };
+   };
+
ethsys: syscon@1b00 {
compatible = "mediatek,mt7622-ethsys", "syscon";
reg = <0x1b00 0x1000>;
-- 
2.25.1



[PATCH v5 3/8] ahci: mediatek: add ahci driver

2020-08-20 Thread Frank Wunderlich
From: Frank Wunderlich 

add AHCI driver ported from linux

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/ata/ahci_mtk.c

Signed-off-by: Frank Wunderlich 
---
 drivers/ata/mtk_ahci.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/ata/mtk_ahci.c b/drivers/ata/mtk_ahci.c
index 8e09c5f9e6..4ad260a5bb 100644
--- a/drivers/ata/mtk_ahci.c
+++ b/drivers/ata/mtk_ahci.c
@@ -2,12 +2,10 @@
 /*
  * MTK SATA platform driver
  *
- * (C) Copyright 2020
- * Mediatek
+ * Copyright (C) 2020 MediaTek Inc.
  *
- * Author: Frank Wunderlich 
- * based on 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/ata/ahci_mtk.c
  * Author: Ryder Lee 
+ * Author: Frank Wunderlich 
  */
 
 #include 
-- 
2.25.1



  1   2   3   4   >