public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [PATCH v4 0/9] Add Starfive JH7110 Cadence USB driver
@ 2024-08-29  1:30 Minda Chen
  2024-08-29  1:30 ` [PATCH v4 1/9] usb: cdns3: Set USB PHY mode in cdns3_drd_update_mode() Minda Chen
                   ` (8 more replies)
  0 siblings, 9 replies; 22+ messages in thread
From: Minda Chen @ 2024-08-29  1:30 UTC (permalink / raw)
  To: Marek Vasut, Tom Rini, Roger Quadros, Rick Chen, Leo,
	Neil Armstrong, Alexey Romanov, Sumit Garg, Mark Kettenis,
	Nishanth Menon
  Cc: u-boot, Heinrich Schuchardt, Simon Glass, E Shattow, Minda Chen

Add Starfive JH7110 Cadence USB driver and related PHY driver.
So the codes can be used in visionfive2 and star64 7110 board.

The driver is almost the same with kernel driver.

Test with Star64 JH7110 board USB 3.0 + USB 2.0 host.
The code can work.

- previous version
  v1: https://patchwork.ozlabs.org/project/uboot/cover/20240504150358.19600-1-minda.chen@starfivetech.com/
  v2: https://patchwork.ozlabs.org/project/uboot/cover/20240704055014.55117-1-minda.chen@starfivetech.com/
  v3: https://patchwork.ozlabs.org/project/uboot/cover/20240719013822.101374-1-minda.chen@starfivetech.com/

- patch description.

patch1: Add set phy mode function in cdns3 core driver
        which is used by Starfive JH7110.
patch2-3: USB and PCIe 2.0 (usb 3.0) PHY drivier
patch4: Cadence USB wrapper driver.
patch5: Add JH7110 USB default overcurrent pin.
patch6-7 dts, config update.
patch8: Add star64 spl dts fixup patch
patch9: MAINTAINERS update

- change:
        v4:
        - patch 2 Add usb split setting, default set USB 2.0 only.
        - patch 5 move to spl stage.
        - Add a new patch 8 for star64 board usb host, vbus pin setting
          and usb 3.0  
	v3:
	- patch 1 Move the added code to cdns3_drd_update_mode().
	- patch 1-4 correct the code format.(follow Rogers's comments.)
	- patch 3 using regmap_field.

	v2:
	- patch 1 Move the added code to cdns3_core_init_role(). Must
	  set PHY mode before calling cdns3 role start function.
	- patch 1-4 correct the code format.(follow Marek's comments.)
	- patch 2 Add set 125M clock in PHY init function.
	- Add new patch5.

Minda Chen (9):
  usb: cdns3: Set USB PHY mode in cdns3_drd_update_mode()
  phy: starfive: Add Starfive JH7110 USB 2.0 PHY driver
  phy: starfive: Add Starfive JH7110 PCIe 2.0 PHY driver
  usb: cdns: starfive: Add cdns USB driver
  spl: starfive: visionfive2: Disable USB overcurrent pin by default.
  configs: starfive: Add visionfive2 cadence USB configuration
  dts: starfive: Add JH7110 Cadence USB dts node
  spl: starfive: star64: Setup USB fdt fixup function
  MAINTAINERS: Update Starfive visionfive2 maintain files.

 .../dts/jh7110-starfive-visionfive-2.dtsi     |   5 +
 arch/riscv/dts/jh7110.dtsi                    |  53 ++++
 arch/riscv/include/asm/arch-jh7110/gpio.h     |   5 +
 board/starfive/visionfive2/MAINTAINERS        |   2 +
 board/starfive/visionfive2/spl.c              |  69 +++++
 configs/starfive_visionfive2_defconfig        |   9 +
 drivers/phy/Kconfig                           |   1 +
 drivers/phy/Makefile                          |   1 +
 drivers/phy/starfive/Kconfig                  |  21 ++
 drivers/phy/starfive/Makefile                 |   7 +
 drivers/phy/starfive/phy-jh7110-pcie.c        | 237 ++++++++++++++++++
 drivers/phy/starfive/phy-jh7110-usb2.c        | 166 ++++++++++++
 drivers/usb/cdns3/Kconfig                     |   7 +
 drivers/usb/cdns3/Makefile                    |   2 +
 drivers/usb/cdns3/cdns3-starfive.c            | 191 ++++++++++++++
 drivers/usb/cdns3/drd.c                       |  14 ++
 16 files changed, 790 insertions(+)
 create mode 100644 drivers/phy/starfive/Kconfig
 create mode 100644 drivers/phy/starfive/Makefile
 create mode 100644 drivers/phy/starfive/phy-jh7110-pcie.c
 create mode 100644 drivers/phy/starfive/phy-jh7110-usb2.c
 create mode 100644 drivers/usb/cdns3/cdns3-starfive.c


base-commit: ee2af844ba1b27b2e959c4e649e4b769fbeb4074
-- 
2.17.1


^ permalink raw reply	[flat|nested] 22+ messages in thread
* Re: [PATCH v4 8/9] spl: starfive: star64: Setup USB fdt fixup function
@ 2024-10-11 12:28 Minda Chen
  0 siblings, 0 replies; 22+ messages in thread
From: Minda Chen @ 2024-10-11 12:28 UTC (permalink / raw)
  To: E Shattow
  Cc: Marek Vasut, Tom Rini, Roger Quadros, Rick Chen, Leo,
	Neil Armstrong, Alexey Romanov, Sumit Garg, Mark Kettenis,
	Nishanth Menon, u-boot@lists.denx.de, Heinrich Schuchardt,
	Simon Glass



> 
> Hi Minda,
> 
> On Wed, Aug 28, 2024 at 6:31 PM Minda Chen <minda.chen@starfivetech.com>
> wrote:
> >
> > Setup star64 USB fdt fixup function. Set dr_mode to host, and add vbus
> > pin (GPIO25), and set USB 3.0 mode.
> > the functions can be used by other 7110 board like Milk-V board.
> >
> > Signed-off-by: Minda Chen <minda.chen@starfivetech.com>
> > ---
> >  board/starfive/visionfive2/spl.c | 66
> > ++++++++++++++++++++++++++++++++
> >  1 file changed, 66 insertions(+)
> >
> > diff --git a/board/starfive/visionfive2/spl.c
> > b/board/starfive/visionfive2/spl.c
> > index 388a06e4d9..b3034b19a3 100644
> > --- a/board/starfive/visionfive2/spl.c
> > +++ b/board/starfive/visionfive2/spl.c
> > @@ -123,6 +123,69 @@ static const struct starfive_vf2_pro star64_pine64[]
> = {
> >                 "tx-internal-delay-ps", "300"},  };
> >
> > +static void spl_fdt_fixup_usb_vbus_pin(void *fdt, int pin) {
> > +       int offset, pin_offset;
> > +
> > +       offset = fdt_path_offset(fdt, "/soc/pinctrl@13040000"); /* &sysgpio
> */
> > +       fdt_add_subnode(fdt, offset, "usb0-0");
> > +       fdt_setprop_string(fdt, fdt_path_offset(fdt, "/__symbols__"),
> > +                          "usb_pins",
> "/soc/pinctrl@13040000/usb0-0");
> > +       offset = fdt_path_offset(fdt, "/soc/pinctrl@13040000/usb0-0");
> > +
> > +       /* usb_pins */
> > +       fdt_create_phandle(fdt, offset);
> > +       fdt_add_subnode(fdt, offset, "driver-vbus-pin");
> > +       offset = fdt_path_offset(fdt,
> "/soc/pinctrl@13040000/usb0-0/driver-vbus-pin");
> > +       /* GPIOMUX(25, GPOUT_SYS_USB_DRIVE_VBUS, GPOEN_ENABLE,
> > + GPI_NONE) */
> 
> This comment may now be updated:
> 
> /* GPIOMUX(pin, GPOUT_SYS_USB_DRIVE_VBUS, GPOEN_ENABLE, GPI_NONE)
> */
> 
> Aside I am confused why we do not use the GPIOMUX macro directly here.
> Can anyone say if that would be a problem to just use the macro GPIOMUX what
> we are pretending to be here?
> 
> I think it will not be a problem here anymore when OF_UPSTREAM is
> implemented to jh7110 boards in U-Boot so it is enough now to update the
> comment about GPIOMUX.
> 
I can Can use GPIOMUX(....

Now Hal commit the OF_UPSTREAM patch. Maybe this patch can be deleted.
Add the dts setting to star64 board dts.

> > +       fdt_setprop_u32(fdt, offset, "pinmux", (0xff07 << 16) | pin);
> > +       fdt_setprop_empty(fdt, offset, "bias-disable");
> > +       fdt_setprop_empty(fdt, offset, "input-disable");
> > +       fdt_setprop_empty(fdt, offset, "input-schmitt-disable");
> > +       fdt_setprop_u32(fdt, offset, "slew-rate", 0);
> > +
> > +       offset = fdt_path_offset(fdt, "/soc/usb@10100000"); /* &usb0 */
> > +       fdt_setprop_string(fdt, offset, "pinctrl-names", "default");
> > +       pin_offset = fdt_path_offset(fdt, "/soc/pinctrl@13040000/usb0-0");
> > +       fdt_setprop_u32(fdt, offset, "pinctrl-0",
> > +                       fdt_get_phandle(fdt, pin_offset)); }
> > +
> > +static void spl_fdt_fixup_usb_host(void *fdt) {
> > +       int offset;
> > +
> > +       offset = fdt_path_offset(fdt, "/soc/usb@10100000/usb@0");
> /*&usb_cdns3 */
> > +       fdt_setprop_string(fdt, offset, "dr_mode", "host"); }
> > +
> > +static void spl_fdt_fixup_set_usb3(void *fdt) {
> > +       int offset, phy_offset;
> > +
> > +       /* disable pcie0 */
> > +       offset = fdt_path_offset(fdt, "/soc/pcie@2b000000"); /* &pcie0 */
> > +       fdt_setprop_string(fdt, offset, "status", "disabled");
> > +
> > +       offset = fdt_path_offset(fdt, "/soc/phy@10210000"); /* &pciephy0
> */
> > +       fdt_setprop_u32(fdt, offset, "starfive,sys-syscon", /* syscon */
> > +                       fdt_get_phandle(fdt,
> > +                                       fdt_path_offset(fdt,
> "/soc/sys_syscon@13030000")));
> > +       fdt_appendprop_u32(fdt, offset, "starfive,sys-syscon", 0x18); /*
> append reg offset */
> > +       fdt_setprop_u32(fdt, offset, "starfive,stg-syscon",
> > +                       fdt_get_phandle(fdt, fdt_path_offset(fdt,
> "/soc/stg_syscon@10240000")));
> > +       /* append reg offset */
> > +       fdt_appendprop_u32(fdt, offset, "starfive,stg-syscon", 0x148);
> > +       fdt_appendprop_u32(fdt, offset, "starfive,stg-syscon", 0x1f4);
> > +
> > +       offset = fdt_path_offset(fdt, "/soc/usb@10100000/usb@0"); /*
> usb_cdns3 */
> > +       phy_offset = fdt_path_offset(fdt, "/soc/phy@10210000"); /*
> <&pciephy0> */
> > +       /* append <&pciephy0> */
> > +       fdt_appendprop_u32(fdt, offset, "phys", fdt_get_phandle(fdt,
> phy_offset));
> > +       fdt_setprop(fdt, offset, "phy-names",
> "cdns3,usb2-phy\0cdns3,usb3-phy",
> > +                   sizeof("cdns3,usb2-phy\0cdns3,usb3-phy"));
> > +}
> > +
> 
> Code readability can be better with fdt_appendprop_string helper. As:
> 
> fdt_setprop_string(fdt, offset, "phy-names", "cdns3,usb2-phy");
> fdt_appendprop_string(fdt, offset, "phy-names", "cdns3,usb3-phy");
> 
> Some people prefer it to have "\0" and avoid the fdt_appendprop_string helper.
> What you should do is not my choice here to make.
> 
> Anyway, and again, I think this will not be our problem after OF_UPSTREAM is
> realized for JH7110 boards in U-Boot.
> 
> >  void spl_fdt_fixup_mars(void *fdt)
> >  {
> >         static const char compat[] = "milkv,mars\0starfive,jh7110"; @@
> > -335,6 +398,9 @@ void spl_fdt_fixup_star64(void *fdt)
> >                                 break;
> >                 }
> >         }
> > +       spl_fdt_fixup_usb_host(fdt);
> > +       spl_fdt_fixup_usb_vbus_pin(fdt, 25);
> > +       spl_fdt_fixup_set_usb3(fdt);
> >  }
> >
> >  void spl_perform_fixups(struct spl_image_info *spl_image)
> > --
> > 2.17.1
> >
> 
> I have now tested Mars CM Lite:
> 
> +       spl_fdt_fixup_usb_host(fdt);
> +       spl_fdt_fixup_usb_vbus_pin(fdt, 25);
> 
> added to the Milk-V Mars CM fix-up routine:  in U-Boot there is both working
> USB and PCIe. I would note also an error for PCIe in Linux if continuing from
> U-Boot with the fdt of U-Boot into Grub2, then Linux:
> 
> Loading Linux 6.11-rc4-riscv64 ...
> Loading initial ramdisk ...
> [   11.718961] pcie-starfive 2b000000.pcie: error -ENODEV: failed to
> get valid pcie domain
> [   11.727238] cadence-qspi 13010000.spi: couldn't determine
> trigger-address
> [   11.730479] pcie-starfive 2c000000.pcie: error -ENODEV: failed to
> get valid pcie domain
> [   11.734112] cadence-qspi 13010000.spi: Cannot get mandatory OF
> data.
> Gave up waiting for suspend/resume device
> 
The u-boot dts and Linux is different. The OF_UPSTREAM patch can fix it. 


^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2024-10-26 16:24 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-29  1:30 [PATCH v4 0/9] Add Starfive JH7110 Cadence USB driver Minda Chen
2024-08-29  1:30 ` [PATCH v4 1/9] usb: cdns3: Set USB PHY mode in cdns3_drd_update_mode() Minda Chen
2024-08-30  1:11   ` Marek Vasut
2024-08-29  1:30 ` [PATCH v4 2/9] phy: starfive: Add Starfive JH7110 USB 2.0 PHY driver Minda Chen
2024-08-30  1:15   ` Marek Vasut
2024-09-06  8:08     ` Minda Chen
2024-09-06 17:23       ` Marek Vasut
2024-08-29  1:30 ` [PATCH v4 3/9] phy: starfive: Add Starfive JH7110 PCIe " Minda Chen
2024-08-30  1:17   ` Marek Vasut
2024-08-29  1:30 ` [PATCH v4 4/9] usb: cdns: starfive: Add cdns USB driver Minda Chen
2024-08-30  1:20   ` Marek Vasut
2024-08-29  1:30 ` [PATCH v4 5/9] spl: starfive: visionfive2: Disable USB overcurrent pin by default Minda Chen
2024-10-26 16:23   ` E Shattow
2024-08-29  1:30 ` [PATCH v4 6/9] configs: starfive: Add visionfive2 cadence USB configuration Minda Chen
2024-08-29  1:30 ` [PATCH v4 7/9] dts: starfive: Add JH7110 Cadence USB dts node Minda Chen
2024-08-29  4:47   ` Sumit Garg
2024-08-29  4:57     ` E Shattow
2024-08-30  5:52       ` Minda Chen
2024-08-29  1:30 ` [PATCH v4 8/9] spl: starfive: star64: Setup USB fdt fixup function Minda Chen
2024-08-30  3:30   ` E Shattow
2024-08-29  1:30 ` [PATCH v4 9/9] MAINTAINERS: Update Starfive visionfive2 maintain files Minda Chen
  -- strict thread matches above, loose matches on Subject: below --
2024-10-11 12:28 [PATCH v4 8/9] spl: starfive: star64: Setup USB fdt fixup function Minda Chen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox