All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sean Anderson <seanga2@gmail.com>
To: u-boot@lists.denx.de
Subject: [PATCH v2 39/46] usb: dwc2: Fix not calling dev_xxx with a device
Date: Tue, 15 Sep 2020 10:45:15 -0400	[thread overview]
Message-ID: <20200915144522.509493-40-seanga2@gmail.com> (raw)
In-Reply-To: <20200915144522.509493-1-seanga2@gmail.com>

This adds a dev argument to some functions so dev_xxx always has a device
to log with. In one instance we must use use a different log function when
we are compiled without DM_USB.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
---

Changes in v2:
- New

 drivers/usb/host/dwc2.c | 39 +++++++++++++++++++++++----------------
 1 file changed, 23 insertions(+), 16 deletions(-)

diff --git a/drivers/usb/host/dwc2.c b/drivers/usb/host/dwc2.c
index cefe9d83b1..f1d13b1c1d 100644
--- a/drivers/usb/host/dwc2.c
+++ b/drivers/usb/host/dwc2.c
@@ -114,7 +114,8 @@ static void init_fslspclksel(struct dwc2_core_regs *regs)
  * @param regs Programming view of DWC_otg controller.
  * @param num Tx FIFO to flush.
  */
-static void dwc_otg_flush_tx_fifo(struct dwc2_core_regs *regs, const int num)
+static void dwc_otg_flush_tx_fifo(struct udevice *dev,
+				  struct dwc2_core_regs *regs, const int num)
 {
 	int ret;
 
@@ -134,7 +135,8 @@ static void dwc_otg_flush_tx_fifo(struct dwc2_core_regs *regs, const int num)
  *
  * @param regs Programming view of DWC_otg controller.
  */
-static void dwc_otg_flush_rx_fifo(struct dwc2_core_regs *regs)
+static void dwc_otg_flush_rx_fifo(struct udevice *dev,
+				  struct dwc2_core_regs *regs)
 {
 	int ret;
 
@@ -152,7 +154,8 @@ static void dwc_otg_flush_rx_fifo(struct dwc2_core_regs *regs)
  * Do core a soft reset of the core.  Be careful with this because it
  * resets all the internal state machines of the core.
  */
-static void dwc_otg_core_reset(struct dwc2_core_regs *regs)
+static void dwc_otg_core_reset(struct udevice *dev,
+			       struct dwc2_core_regs *regs)
 {
 	int ret;
 
@@ -284,8 +287,8 @@ static void dwc_otg_core_host_init(struct udevice *dev,
 	clrbits_le32(&regs->gotgctl, DWC2_GOTGCTL_HSTSETHNPEN);
 
 	/* Make sure the FIFOs are flushed. */
-	dwc_otg_flush_tx_fifo(regs, 0x10);	/* All Tx FIFOs */
-	dwc_otg_flush_rx_fifo(regs);
+	dwc_otg_flush_tx_fifo(dev, regs, 0x10);	/* All Tx FIFOs */
+	dwc_otg_flush_rx_fifo(dev, regs);
 
 	/* Flush out any leftover queued requests. */
 	num_channels = readl(&regs->ghwcfg2);
@@ -306,7 +309,7 @@ static void dwc_otg_core_host_init(struct udevice *dev,
 		ret = wait_for_bit_le32(&regs->hc_regs[i].hcchar,
 					DWC2_HCCHAR_CHEN, false, 1000, false);
 		if (ret)
-			dev_info("%s: Timeout!\n", __func__);
+			dev_info(dev, "%s: Timeout!\n", __func__);
 	}
 
 	/* Turn on the vbus power. */
@@ -330,8 +333,9 @@ static void dwc_otg_core_host_init(struct udevice *dev,
  *
  * @param regs Programming view of the DWC_otg controller
  */
-static void dwc_otg_core_init(struct dwc2_priv *priv)
+static void dwc_otg_core_init(struct udevice *dev)
 {
+	struct dwc2_priv *priv = dev_get_priv(dev);
 	struct dwc2_core_regs *regs = priv->regs;
 	uint32_t ahbcfg = 0;
 	uint32_t usbcfg = 0;
@@ -360,7 +364,7 @@ static void dwc_otg_core_init(struct dwc2_priv *priv)
 	writel(usbcfg, &regs->gusbcfg);
 
 	/* Reset the Controller */
-	dwc_otg_core_reset(regs);
+	dwc_otg_core_reset(dev, regs);
 
 	/*
 	 * This programming sequence needs to happen in FS mode before
@@ -372,7 +376,7 @@ static void dwc_otg_core_init(struct dwc2_priv *priv)
 	setbits_le32(&regs->gusbcfg, DWC2_GUSBCFG_PHYSEL);
 
 	/* Reset after a PHY select */
-	dwc_otg_core_reset(regs);
+	dwc_otg_core_reset(dev, regs);
 
 	/*
 	 * Program DCFG.DevSpd or HCFG.FSLSPclkSel to 48Mhz in FS.
@@ -419,7 +423,7 @@ static void dwc_otg_core_init(struct dwc2_priv *priv)
 	writel(usbcfg, &regs->gusbcfg);
 
 	/* Reset after setting the PHY parameters */
-	dwc_otg_core_reset(regs);
+	dwc_otg_core_reset(dev, regs);
 #endif
 
 	usbcfg = readl(&regs->gusbcfg);
@@ -1128,7 +1132,12 @@ int _submit_int_msg(struct dwc2_priv *priv, struct usb_device *dev,
 	timeout = get_timer(0) + USB_TIMEOUT_MS(pipe);
 	for (;;) {
 		if (get_timer(0) > timeout) {
-			dev_err(dev, "Timeout poll on interrupt endpoint\n");
+#if CONFIG_IS_ENABLED(DM_USB)
+			dev_err(dev->dev,
+				"Timeout poll on interrupt endpoint\n");
+#else
+			log_err("Timeout poll on interrupt endpoint\n");
+#endif
 			return -ETIMEDOUT;
 		}
 		ret = _submit_bulk_msg(priv, dev, pipe, buffer, len);
@@ -1194,7 +1203,7 @@ static int dwc2_init_common(struct udevice *dev, struct dwc2_priv *priv)
 	priv->ext_vbus = 0;
 #endif
 
-	dwc_otg_core_init(priv);
+	dwc_otg_core_init(dev);
 	dwc_otg_core_host_init(dev, regs);
 
 	clrsetbits_le32(&regs->hprt0, DWC2_HPRT0_PRTENA |
@@ -1320,12 +1329,10 @@ static int dwc2_submit_int_msg(struct udevice *dev, struct usb_device *udev,
 static int dwc2_usb_ofdata_to_platdata(struct udevice *dev)
 {
 	struct dwc2_priv *priv = dev_get_priv(dev);
-	fdt_addr_t addr;
 
-	addr = dev_read_addr(dev);
-	if (addr == FDT_ADDR_T_NONE)
+	priv->regs = dev_read_addr_ptr(dev);
+	if (!priv->regs)
 		return -EINVAL;
-	priv->regs = (struct dwc2_core_regs *)addr;
 
 	priv->oc_disable = dev_read_bool(dev, "disable-over-current");
 	priv->hnp_srp_disable = dev_read_bool(dev, "hnp-srp-disable");
-- 
2.28.0

  parent reply	other threads:[~2020-09-15 14:45 UTC|newest]

Thread overview: 79+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-15 14:44 [PATCH v2 00/46] dm: Print device name in dev_xxx like Linux Sean Anderson
2020-09-15 14:44 ` [PATCH v2 01/46] dm: syscon: Fix calling dev_dbg with an uninitialized device Sean Anderson
2020-09-16 12:44   ` Patrick DELAUNAY
2020-09-16 12:51     ` Sean Anderson
2020-09-15 14:44 ` [PATCH v2 02/46] firmware: ti_sci: Fix not calling dev_err with a device Sean Anderson
2020-09-16  1:26   ` Nishanth Menon
2020-09-15 14:44 ` [PATCH v2 03/46] i2c: mxc: Fix dev_err being called on a nonexistant variable Sean Anderson
2020-09-17  1:10   ` Simon Glass
2020-09-17  7:50   ` Heiko Schocher
2020-09-15 14:44 ` [PATCH v2 04/46] mtd: nand: pxa3xx: Fix not calling dev_xxx with a device Sean Anderson
2020-09-15 14:44 ` [PATCH v2 05/46] mtd: nand: sunxi: Fix not calling dev_err " Sean Anderson
2020-09-15 14:44 ` [PATCH v2 06/46] mtd: spi: Include dm.h in spi-nor-core.c Sean Anderson
2020-09-15 14:44 ` [PATCH v2 07/46] mtd: spi: Fix logging in spi-nor-tiny Sean Anderson
2020-09-15 14:44 ` [PATCH v2 08/46] mtd: spi-nand: Fix not calling dev_err with a device Sean Anderson
2020-09-17  1:10   ` Simon Glass
2020-09-15 14:44 ` [PATCH v2 09/46] mmc: Add mmc_dev() Sean Anderson
2020-09-17  1:10   ` Simon Glass
2020-09-15 14:44 ` [PATCH v2 10/46] mmc: bcm2835-host: Fix not calling dev_dbg with a device Sean Anderson
2020-09-15 14:44 ` [PATCH v2 11/46] mmc: mtk-sd: Fix not calling dev_err " Sean Anderson
2020-09-17  1:10   ` Simon Glass
2020-09-15 14:44 ` [PATCH v2 12/46] mailbox: k3: " Sean Anderson
2020-09-17  1:10   ` Simon Glass
2020-09-15 14:44 ` [PATCH v2 13/46] nand: atmel: Fix not calling dev_xxx " Sean Anderson
2020-09-17  1:10   ` Simon Glass
2020-09-15 14:44 ` [PATCH v2 14/46] nand: brcmnand: Fix not calling dev_err() " Sean Anderson
2020-09-15 14:44 ` [PATCH v2 15/46] nand: vybrid: Re-introduce vf610_nfc.dev Sean Anderson
2020-09-15 14:44 ` [PATCH v2 16/46] net: bcm6368: Fix not calling dev_info with a device Sean Anderson
2020-09-15 14:44 ` [PATCH v2 17/46] net: mdio: Fix not calling dev_dbg " Sean Anderson
2020-09-15 14:44 ` [PATCH v2 18/46] net: mvneta: Fix not always calling dev_err " Sean Anderson
2020-09-17  1:10   ` Simon Glass
2020-09-15 14:44 ` [PATCH v2 19/46] net: mvneta: Convert netdev_xxx to dev_xxx Sean Anderson
2020-09-17  1:10   ` Simon Glass
2020-09-15 14:44 ` [PATCH v2 20/46] net: mvpp2: Fix not calling dev_xxx with a device Sean Anderson
2020-09-17  1:10   ` Simon Glass
2020-09-15 14:44 ` [PATCH v2 21/46] net: mvpp2: Convert netdev_xxx to dev_xxx Sean Anderson
2020-09-17  1:10   ` Simon Glass
2020-09-15 14:44 ` [PATCH v2 22/46] linux/compat.h: Remove netdev_xxx functions Sean Anderson
2020-09-17  1:10   ` Simon Glass
2020-09-15 14:44 ` [PATCH v2 23/46] net: sunxi: Fix not calling dev_xxx with a device Sean Anderson
2020-09-17  1:10   ` Simon Glass
2020-09-15 14:45 ` [PATCH v2 24/46] net: sun8i_emac: " Sean Anderson
2020-09-17  1:10   ` Simon Glass
2020-09-15 14:45 ` [PATCH v2 25/46] net: ti: cpsw: Fix not calling dev_dbg " Sean Anderson
2020-09-15 14:45 ` [PATCH v2 26/46] phy: marvell: Fix not calling dev_err " Sean Anderson
2020-09-15 14:45 ` [PATCH v2 27/46] phy: rockchip: " Sean Anderson
2020-09-28  2:43   ` Kever Yang
2020-09-15 14:45 ` [PATCH v2 28/46] phy: sun4i-usb: " Sean Anderson
2020-09-15 14:45 ` [PATCH v2 29/46] phy: ti: " Sean Anderson
2020-09-15 14:45 ` [PATCH v2 30/46] phy: usbphyc: " Sean Anderson
2020-09-16  7:47   ` Patrice CHOTARD
2020-09-16 12:45   ` Patrick DELAUNAY
2020-09-15 14:45 ` [PATCH v2 31/46] remoteproc: Remove unused function rproc_elf_sanity_check Sean Anderson
2020-09-15 14:45 ` [PATCH v2 32/46] remoteproc: k3-r5: Fix not calling dev_xxx with a device Sean Anderson
2020-09-15 14:45 ` [PATCH v2 33/46] remoteproc: k3: " Sean Anderson
2020-09-15 14:45 ` [PATCH v2 34/46] soc: qualcomm: Fix not calling dev_err " Sean Anderson
2020-09-17  1:10   ` Simon Glass
2020-09-15 14:45 ` [PATCH v2 35/46] spi: sunxi: " Sean Anderson
2020-09-15 14:45 ` [PATCH v2 36/46] spi: zynqmp_gqspi: " Sean Anderson
2020-09-16  7:45   ` Michal Simek
2020-09-15 14:45 ` [PATCH v2 37/46] sysreset: ti: " Sean Anderson
2020-09-15 14:45 ` [PATCH v2 38/46] usb: cdns3: Fix not calling dev_xxx " Sean Anderson
2020-09-15 14:45 ` Sean Anderson [this message]
2020-09-16  7:51   ` [PATCH v2 39/46] usb: dwc2: " Patrice CHOTARD
2020-09-16 12:52     ` Sean Anderson
2020-09-16 13:30   ` Patrick DELAUNAY
2020-09-16 13:43     ` Sean Anderson
2020-09-17  7:33       ` Patrick DELAUNAY
2020-09-15 14:45 ` [PATCH v2 40/46] usb: dwc3: " Sean Anderson
2020-09-15 14:45 ` [PATCH v2 41/46] usb: dwc3: ti: Fix not calling dev_err " Sean Anderson
2020-09-15 14:45 ` [PATCH v2 42/46] usb: dwc3: Don't include asm-generic/io.h Sean Anderson
2020-09-15 14:45 ` [PATCH v2 43/46] usb: musb-new: sunxi: Fix not calling dev_err with a device Sean Anderson
2020-09-15 14:45 ` [PATCH v2 44/46] video: stm32: Fix not calling dev_xxx " Sean Anderson
2020-09-16 13:19   ` Patrick DELAUNAY
2020-09-15 14:45 ` [PATCH v2 45/46] dm: Use symbolic constants for log levels in dev_xxx Sean Anderson
2020-09-17  1:10   ` Simon Glass
2020-09-15 14:45 ` [PATCH v2 46/46] dm: Print device name in dev_xxx like Linux Sean Anderson
2020-09-16 13:43 ` [PATCH v2 00/46] " Patrick DELAUNAY
2020-09-30 13:01 ` Tom Rini
2020-09-30 13:08 ` Tom Rini

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=20200915144522.509493-40-seanga2@gmail.com \
    --to=seanga2@gmail.com \
    --cc=u-boot@lists.denx.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.