public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [PATCH v3 1/3] usb: ehci: mxs: Fix the USB node pointer retrieval
@ 2023-10-09 13:15 Fabio Estevam
  2023-10-09 13:15 ` [PATCH v3 2/3] usb: ehci: mxs: Use regulator_set_enable_if_allowed() Fabio Estevam
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Fabio Estevam @ 2023-10-09 13:15 UTC (permalink / raw)
  To: marex; +Cc: sbabic, u-boot, Fabio Estevam

From: Fabio Estevam <festevam@denx.de>

Use dev_ofnode() to retrieve the USB node pointer from the udevice
structure.

This fixes the following build error:

drivers/usb/host/ehci-mxs.c:143:38: error: 'struct udevice' has no member named 'node_'

Signed-off-by: Fabio Estevam <festevam@denx.de>
Reviewed-by: Marek Vasut <marex@denx.de>
---
Changes since v2:
- None
Changes since v1:
- Only collected Marek's Reviewed-by tag.

 drivers/usb/host/ehci-mxs.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/host/ehci-mxs.c b/drivers/usb/host/ehci-mxs.c
index 147b2fa145d6..092c79fd4bc5 100644
--- a/drivers/usb/host/ehci-mxs.c
+++ b/drivers/usb/host/ehci-mxs.c
@@ -136,11 +136,12 @@ static int ehci_usb_ofdata_to_platdata(struct udevice *dev)
 	struct usb_plat *plat = dev_get_plat(dev);
 	struct ehci_mxs_port *port = &priv->port;
 	u32 phandle, phy_reg, clk_reg, clk_id;
+	ofnode np = dev_ofnode(dev);
 	ofnode phy_node, clk_node;
 	const char *mode;
 	int ret;
 
-	mode = ofnode_read_string(dev->node_, "dr_mode");
+	mode = ofnode_read_string(np, "dr_mode");
 	if (mode) {
 		if (strcmp(mode, "peripheral") == 0)
 			plat->init_type = USB_INIT_DEVICE;
@@ -151,12 +152,12 @@ static int ehci_usb_ofdata_to_platdata(struct udevice *dev)
 	}
 
 	/* Read base address of the USB IP block */
-	ret = ofnode_read_u32(dev->node_, "reg", &port->usb_regs);
+	ret = ofnode_read_u32(np, "reg", &port->usb_regs);
 	if (ret)
 		return ret;
 
 	/* Read base address of the USB PHY IP block */
-	ret = ofnode_read_u32(dev->node_, "fsl,usbphy", &phandle);
+	ret = ofnode_read_u32(np, "fsl,usbphy", &phandle);
 	if (ret)
 		return ret;
 
-- 
2.34.1


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

* [PATCH v3 2/3] usb: ehci: mxs: Use regulator_set_enable_if_allowed()
  2023-10-09 13:15 [PATCH v3 1/3] usb: ehci: mxs: Fix the USB node pointer retrieval Fabio Estevam
@ 2023-10-09 13:15 ` Fabio Estevam
  2023-10-16  9:23   ` sbabic
  2023-10-09 13:15 ` [PATCH v3 3/3] mx28evk: Add USB Mass Storage support Fabio Estevam
  2023-10-16  9:22 ` [PATCH v3 1/3] usb: ehci: mxs: Fix the USB node pointer retrieval sbabic
  2 siblings, 1 reply; 7+ messages in thread
From: Fabio Estevam @ 2023-10-09 13:15 UTC (permalink / raw)
  To: marex; +Cc: sbabic, u-boot, Fabio Estevam

From: Fabio Estevam <festevam@denx.de>

Since commit 4fcba5d556b4 ("regulator: implement basic reference
counter") the return value of regulator_set_enable() may be EALREADY or
EBUSY for fixed/GPIO regulators.

Switch to using the more relaxed regulator_set_enable_if_allowed() to
continue if regulator already was enabled or disabled.

This fixes the following error when running the 'ums' command:

=> ums 0 mmc 0
UMS: LUN 0, dev mmc 0, hwpart 0, sector 0x0, count 0xece000
Error enabling VBUS supply
g_dnl_register: failed!, error: -114
g_dnl_register failed

Signed-off-by: Fabio Estevam <festevam@denx.de>
Reviewed-by: Marek Vasut <marex@denx.de>
---
Changes since v2:
- None
Changes since v1:
- Only collected Marek's Reviewed-by tag.

 drivers/usb/host/ehci-mxs.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/host/ehci-mxs.c b/drivers/usb/host/ehci-mxs.c
index 092c79fd4bc5..ddf7cc2d00a7 100644
--- a/drivers/usb/host/ehci-mxs.c
+++ b/drivers/usb/host/ehci-mxs.c
@@ -236,9 +236,9 @@ static int ehci_usb_probe(struct udevice *dev)
 		debug("%s: No vbus supply\n", dev->name);
 
 	if (!ret && priv->vbus_supply) {
-		ret = regulator_set_enable(priv->vbus_supply,
-					   (type == USB_INIT_DEVICE) ?
-					   false : true);
+		ret = regulator_set_enable_if_allowed(priv->vbus_supply,
+						      (type == USB_INIT_DEVICE) ?
+						      false : true);
 		if (ret) {
 			puts("Error enabling VBUS supply\n");
 			return ret;
@@ -265,7 +265,7 @@ static int ehci_usb_remove(struct udevice *dev)
 
 #if CONFIG_IS_ENABLED(DM_REGULATOR)
 	if (priv->vbus_supply) {
-		ret = regulator_set_enable(priv->vbus_supply, false);
+		ret = regulator_set_enable_if_allowed(priv->vbus_supply, false);
 		if (ret) {
 			puts("Error disabling VBUS supply\n");
 			return ret;
-- 
2.34.1


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

* [PATCH v3 3/3] mx28evk: Add USB Mass Storage support
  2023-10-09 13:15 [PATCH v3 1/3] usb: ehci: mxs: Fix the USB node pointer retrieval Fabio Estevam
  2023-10-09 13:15 ` [PATCH v3 2/3] usb: ehci: mxs: Use regulator_set_enable_if_allowed() Fabio Estevam
@ 2023-10-09 13:15 ` Fabio Estevam
  2023-10-09 13:17   ` Marek Vasut
  2023-10-16  9:21   ` sbabic
  2023-10-16  9:22 ` [PATCH v3 1/3] usb: ehci: mxs: Fix the USB node pointer retrieval sbabic
  2 siblings, 2 replies; 7+ messages in thread
From: Fabio Estevam @ 2023-10-09 13:15 UTC (permalink / raw)
  To: marex; +Cc: sbabic, u-boot, Fabio Estevam

From: Fabio Estevam <festevam@denx.de>

Select the USB options to allow running "ums 0 mmc 0".

Signed-off-by: Fabio Estevam <festevam@denx.de>
---
Changes since v2:
- Removed further unrelated options. (Marek)
Changes since v1:
- Remove unrelated config options. (Marek)

 configs/mx28evk_defconfig | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/configs/mx28evk_defconfig b/configs/mx28evk_defconfig
index df0cceaea719..4058d08f961a 100644
--- a/configs/mx28evk_defconfig
+++ b/configs/mx28evk_defconfig
@@ -32,6 +32,7 @@ CONFIG_CMD_DM=y
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_MMC=y
 CONFIG_CMD_NAND_TRIMFFS=y
+CONFIG_CMD_USB_MASS_STORAGE=y
 CONFIG_CMD_CACHE=y
 CONFIG_CMD_DATE=y
 CONFIG_CMD_EXT4=y
@@ -65,3 +66,11 @@ CONFIG_RTC_MXS=y
 CONFIG_DM_SERIAL=y
 CONFIG_SPI=y
 CONFIG_USB=y
+CONFIG_USB_EHCI_HCD=y
+CONFIG_USB_MAX_CONTROLLER_COUNT=2
+CONFIG_USB_GADGET=y
+CONFIG_USB_GADGET_MANUFACTURER="FSL"
+CONFIG_USB_GADGET_VENDOR_NUM=0x0525
+CONFIG_USB_GADGET_PRODUCT_NUM=0xa4a5
+CONFIG_CI_UDC=y
+CONFIG_USB_GADGET_DOWNLOAD=y
-- 
2.34.1


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

* Re: [PATCH v3 3/3] mx28evk: Add USB Mass Storage support
  2023-10-09 13:15 ` [PATCH v3 3/3] mx28evk: Add USB Mass Storage support Fabio Estevam
@ 2023-10-09 13:17   ` Marek Vasut
  2023-10-16  9:21   ` sbabic
  1 sibling, 0 replies; 7+ messages in thread
From: Marek Vasut @ 2023-10-09 13:17 UTC (permalink / raw)
  To: Fabio Estevam; +Cc: sbabic, u-boot, Fabio Estevam

On 10/9/23 15:15, Fabio Estevam wrote:
> From: Fabio Estevam <festevam@denx.de>
> 
> Select the USB options to allow running "ums 0 mmc 0".
> 
> Signed-off-by: Fabio Estevam <festevam@denx.de>

Reviewed-by: Marek Vasut <marex@denx.de>

Thanks !

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

* [PATCH v3 3/3] mx28evk: Add USB Mass Storage support
  2023-10-09 13:15 ` [PATCH v3 3/3] mx28evk: Add USB Mass Storage support Fabio Estevam
  2023-10-09 13:17   ` Marek Vasut
@ 2023-10-16  9:21   ` sbabic
  1 sibling, 0 replies; 7+ messages in thread
From: sbabic @ 2023-10-16  9:21 UTC (permalink / raw)
  To: Fabio Estevam, u-boot

> From: Fabio Estevam <festevam@denx.de>
> Select the USB options to allow running "ums 0 mmc 0".
> Signed-off-by: Fabio Estevam <festevam@denx.de>
> Reviewed-by: Marek Vasut <marex@denx.de>
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

-- 
=====================================================================
DENX Software Engineering GmbH,        Managing Director: Erika Unter  
HRB 165235 Munich,   Office: Kirchenstr.5, 82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic@denx.de
=====================================================================

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

* [PATCH v3 1/3] usb: ehci: mxs: Fix the USB node pointer retrieval
  2023-10-09 13:15 [PATCH v3 1/3] usb: ehci: mxs: Fix the USB node pointer retrieval Fabio Estevam
  2023-10-09 13:15 ` [PATCH v3 2/3] usb: ehci: mxs: Use regulator_set_enable_if_allowed() Fabio Estevam
  2023-10-09 13:15 ` [PATCH v3 3/3] mx28evk: Add USB Mass Storage support Fabio Estevam
@ 2023-10-16  9:22 ` sbabic
  2 siblings, 0 replies; 7+ messages in thread
From: sbabic @ 2023-10-16  9:22 UTC (permalink / raw)
  To: Fabio Estevam, u-boot

> From: Fabio Estevam <festevam@denx.de>
> Use dev_ofnode() to retrieve the USB node pointer from the udevice
> structure.
> This fixes the following build error:
> drivers/usb/host/ehci-mxs.c:143:38: error: 'struct udevice' has no member named 'node_'
> Signed-off-by: Fabio Estevam <festevam@denx.de>
> Reviewed-by: Marek Vasut <marex@denx.de>
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

-- 
=====================================================================
DENX Software Engineering GmbH,        Managing Director: Erika Unter  
HRB 165235 Munich,   Office: Kirchenstr.5, 82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic@denx.de
=====================================================================

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

* [PATCH v3 2/3] usb: ehci: mxs: Use regulator_set_enable_if_allowed()
  2023-10-09 13:15 ` [PATCH v3 2/3] usb: ehci: mxs: Use regulator_set_enable_if_allowed() Fabio Estevam
@ 2023-10-16  9:23   ` sbabic
  0 siblings, 0 replies; 7+ messages in thread
From: sbabic @ 2023-10-16  9:23 UTC (permalink / raw)
  To: Fabio Estevam, u-boot

> From: Fabio Estevam <festevam@denx.de>
> Since commit 4fcba5d556b4 ("regulator: implement basic reference
> counter") the return value of regulator_set_enable() may be EALREADY or
> EBUSY for fixed/GPIO regulators.
> Switch to using the more relaxed regulator_set_enable_if_allowed() to
> continue if regulator already was enabled or disabled.
> This fixes the following error when running the 'ums' command:
> => ums 0 mmc 0
> UMS: LUN 0, dev mmc 0, hwpart 0, sector 0x0, count 0xece000
> Error enabling VBUS supply
> g_dnl_register: failed!, error: -114
> g_dnl_register failed
> Signed-off-by: Fabio Estevam <festevam@denx.de>
> Reviewed-by: Marek Vasut <marex@denx.de>
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

-- 
=====================================================================
DENX Software Engineering GmbH,        Managing Director: Erika Unter  
HRB 165235 Munich,   Office: Kirchenstr.5, 82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic@denx.de
=====================================================================

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

end of thread, other threads:[~2023-10-16  9:30 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-09 13:15 [PATCH v3 1/3] usb: ehci: mxs: Fix the USB node pointer retrieval Fabio Estevam
2023-10-09 13:15 ` [PATCH v3 2/3] usb: ehci: mxs: Use regulator_set_enable_if_allowed() Fabio Estevam
2023-10-16  9:23   ` sbabic
2023-10-09 13:15 ` [PATCH v3 3/3] mx28evk: Add USB Mass Storage support Fabio Estevam
2023-10-09 13:17   ` Marek Vasut
2023-10-16  9:21   ` sbabic
2023-10-16  9:22 ` [PATCH v3 1/3] usb: ehci: mxs: Fix the USB node pointer retrieval sbabic

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