public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Minda Chen <minda.chen@starfivetech.com>
To: Marek Vasut <marex@denx.de>, Tom Rini <trini@konsulko.com>,
	Roger Quadros <rogerq@kernel.org>, Rick Chen <rick@andestech.com>,
	Leo <ycliang@andestech.com>,
	Neil Armstrong <neil.armstrong@linaro.org>,
	Alexey Romanov <avromanov@salutedevices.com>,
	Sumit Garg <sumit.garg@linaro.org>,
	Mark Kettenis <kettenis@openbsd.org>, Nishanth Menon <nm@ti.com>
Cc: u-boot@lists.denx.de, Heinrich Schuchardt <xypron.glpk@gmx.de>,
	Simon Glass <sjg@chromium.org>, E Shattow <lucent@gmail.com>,
	Minda Chen <minda.chen@starfivetech.com>
Subject: [PATCH v4 8/9] spl: starfive: star64: Setup USB fdt fixup function
Date: Thu, 29 Aug 2024 09:30:57 +0800	[thread overview]
Message-ID: <20240829013058.6178-9-minda.chen@starfivetech.com> (raw)
In-Reply-To: <20240829013058.6178-1-minda.chen@starfivetech.com>

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) */
+	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"));
+}
+
 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


  parent reply	other threads:[~2024-08-29  1:32 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` Minda Chen [this message]
2024-08-30  3:30   ` [PATCH v4 8/9] spl: starfive: star64: Setup USB fdt fixup function 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240829013058.6178-9-minda.chen@starfivetech.com \
    --to=minda.chen@starfivetech.com \
    --cc=avromanov@salutedevices.com \
    --cc=kettenis@openbsd.org \
    --cc=lucent@gmail.com \
    --cc=marex@denx.de \
    --cc=neil.armstrong@linaro.org \
    --cc=nm@ti.com \
    --cc=rick@andestech.com \
    --cc=rogerq@kernel.org \
    --cc=sjg@chromium.org \
    --cc=sumit.garg@linaro.org \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    --cc=xypron.glpk@gmx.de \
    --cc=ycliang@andestech.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox