public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Mattijs Korpershoek <mkorpershoek@baylibre.com>
To: Marek Vasut <marex@denx.de>, u-boot@lists.denx.de
Cc: Marek Vasut <marex@denx.de>, Angus Ainslie <angus@akkea.ca>,
	Dmitrii Merkurev <dimorinny@google.com>,
	Eddie Cai <eddie.cai.linux@gmail.com>,
	Kever Yang <kever.yang@rock-chips.com>,
	Lukasz Majewski <lukma@denx.de>,
	Miquel Raynal <miquel.raynal@bootlin.com>,
	Nishanth Menon <nm@ti.com>,
	Patrice Chotard <patrice.chotard@foss.st.com>,
	Patrick Delaunay <patrick.delaunay@foss.st.com>,
	Philipp Tomsich <philipp.tomsich@vrull.eu>,
	Simon Glass <sjg@chromium.org>, Stefan Roese <sr@denx.de>,
	kernel@puri.sm
Subject: Re: [PATCH 17/17] board: usb: Replace legacy usb_gadget_handle_interrupts()
Date: Tue, 22 Aug 2023 18:58:33 +0200	[thread overview]
Message-ID: <87r0nvqaiu.fsf@baylibre.com> (raw)
In-Reply-To: <20230819142407.49632-17-marex@denx.de>

On sam., août 19, 2023 at 16:24, Marek Vasut <marex@denx.de> wrote:

> The usb_gadget_handle_interrupts() is no longer used anywhere,
> replace the remaining uses with dm_usb_gadget_handle_interrupts()
> which takes udevice as a parameter.
>
> Some of the UDC drivers currently ignore the index parameter altogether,
> those also ignore the udevice and have to be reworked. Other like the
> dwc3_uboot_handle_interrupt() had to be switched from index to udevice
> look up to avoid breakage.
>
> Signed-off-by: Marek Vasut <marex@denx.de>
> ---
> NOTE: Next step, get rid of dwc3_uboot_init()/dwc3_uboot_exit()
> ---
> Cc: Angus Ainslie <angus@akkea.ca>
> Cc: Dmitrii Merkurev <dimorinny@google.com>
> Cc: Eddie Cai <eddie.cai.linux@gmail.com>
> Cc: Kever Yang <kever.yang@rock-chips.com>
> Cc: Lukasz Majewski <lukma@denx.de>
> Cc: Miquel Raynal <miquel.raynal@bootlin.com>
> Cc: Mattijs Korpershoek <mkorpershoek@baylibre.com>
> Cc: Nishanth Menon <nm@ti.com>
> Cc: Patrice Chotard <patrice.chotard@foss.st.com>
> Cc: Patrick Delaunay <patrick.delaunay@foss.st.com>
> Cc: Philipp Tomsich <philipp.tomsich@vrull.eu>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Stefan Roese <sr@denx.de>
> Cc: kernel@puri.sm
> ---
>  arch/arm/mach-rockchip/board.c      |  4 ++--
>  board/purism/librem5/spl.c          |  4 ++--
>  board/samsung/common/exynos5-dt.c   |  4 ++--
>  board/st/stih410-b2260/board.c      |  4 ++--
>  board/ti/am43xx/board.c             |  6 +++---
>  drivers/usb/dwc3/core.c             |  6 +++---
>  drivers/usb/dwc3/dwc3-omap.c        |  8 ++++----
>  drivers/usb/gadget/at91_udc.c       |  2 +-
>  drivers/usb/gadget/atmel_usba_udc.c |  3 +--
>  drivers/usb/gadget/ci_udc.c         |  4 ++--
>  drivers/usb/gadget/dwc2_udc_otg.c   | 12 ++----------
>  drivers/usb/gadget/udc/udc-uclass.c | 12 ------------
>  drivers/usb/host/usb-sandbox.c      |  5 -----
>  drivers/usb/musb-new/musb_uboot.c   |  2 +-
>  include/dwc3-omap-uboot.h           |  2 +-
>  include/dwc3-uboot.h                |  2 +-
>  include/linux/usb/gadget.h          |  2 +-
>  17 files changed, 28 insertions(+), 54 deletions(-)

Tested that I could reflash the vim3 bootloader (on mmc2boot0)

Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
Tested-by: Mattijs Korpershoek <mkorpershoek@baylibre.com> # on khadas vim3

>
> diff --git a/arch/arm/mach-rockchip/board.c b/arch/arm/mach-rockchip/board.c
> index 8d7b39ba157..57f08e0be0e 100644
> --- a/arch/arm/mach-rockchip/board.c
> +++ b/arch/arm/mach-rockchip/board.c
> @@ -299,9 +299,9 @@ static struct dwc3_device dwc3_device_data = {
>  	.hsphy_mode = USBPHY_INTERFACE_MODE_UTMIW,
>  };
>  
> -int usb_gadget_handle_interrupts(int index)
> +int dm_usb_gadget_handle_interrupts(struct udevice *dev)
>  {
> -	dwc3_uboot_handle_interrupt(0);
> +	dwc3_uboot_handle_interrupt(dev);
>  	return 0;
>  }
>  
> diff --git a/board/purism/librem5/spl.c b/board/purism/librem5/spl.c
> index 90f1fcf415f..581f0929662 100644
> --- a/board/purism/librem5/spl.c
> +++ b/board/purism/librem5/spl.c
> @@ -418,9 +418,9 @@ out:
>  	return rv;
>  }
>  
> -int usb_gadget_handle_interrupts(int index)
> +int dm_usb_gadget_handle_interrupts(struct udevice *dev)
>  {
> -	dwc3_uboot_handle_interrupt(0);
> +	dwc3_uboot_handle_interrupt(dev);
>  	return 0;
>  }
>  
> diff --git a/board/samsung/common/exynos5-dt.c b/board/samsung/common/exynos5-dt.c
> index cde77d79a0f..726b7f0667a 100644
> --- a/board/samsung/common/exynos5-dt.c
> +++ b/board/samsung/common/exynos5-dt.c
> @@ -126,9 +126,9 @@ static struct dwc3_device dwc3_device_data = {
>  	.index = 0,
>  };
>  
> -int usb_gadget_handle_interrupts(int index)
> +int dm_usb_gadget_handle_interrupts(struct udevice *dev)
>  {
> -	dwc3_uboot_handle_interrupt(0);
> +	dwc3_uboot_handle_interrupt(dev);
>  	return 0;
>  }
>  
> diff --git a/board/st/stih410-b2260/board.c b/board/st/stih410-b2260/board.c
> index cd3a7dc51a2..e21cbc270e9 100644
> --- a/board/st/stih410-b2260/board.c
> +++ b/board/st/stih410-b2260/board.c
> @@ -50,9 +50,9 @@ static struct dwc3_device dwc3_device_data = {
>  	.index = 0,
>  };
>  
> -int usb_gadget_handle_interrupts(int index)
> +int dm_usb_gadget_handle_interrupts(struct udevice *dev)
>  {
> -	dwc3_uboot_handle_interrupt(index);
> +	dwc3_uboot_handle_interrupt(dev);
>  	return 0;
>  }
>  
> diff --git a/board/ti/am43xx/board.c b/board/ti/am43xx/board.c
> index 87e552a4701..58bfe7cd455 100644
> --- a/board/ti/am43xx/board.c
> +++ b/board/ti/am43xx/board.c
> @@ -760,13 +760,13 @@ static struct ti_usb_phy_device usb_phy2_device = {
>  	.index = 1,
>  };
>  
> -int usb_gadget_handle_interrupts(int index)
> +int dm_usb_gadget_handle_interrupts(struct udevice *dev)
>  {
>  	u32 status;
>  
> -	status = dwc3_omap_uboot_interrupt_status(index);
> +	status = dwc3_omap_uboot_interrupt_status(dev);
>  	if (status)
> -		dwc3_uboot_handle_interrupt(index);
> +		dwc3_uboot_handle_interrupt(dev);
>  
>  	return 0;
>  }
> diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
> index 49f6a1900b0..7ca9d09824e 100644
> --- a/drivers/usb/dwc3/core.c
> +++ b/drivers/usb/dwc3/core.c
> @@ -986,18 +986,18 @@ void dwc3_uboot_exit(int index)
>  
>  /**
>   * dwc3_uboot_handle_interrupt - handle dwc3 core interrupt
> - * @index: index of this controller
> + * @dev: device of this controller
>   *
>   * Invokes dwc3 gadget interrupts.
>   *
>   * Generally called from board file.
>   */
> -void dwc3_uboot_handle_interrupt(int index)
> +void dwc3_uboot_handle_interrupt(struct udevice *dev)
>  {
>  	struct dwc3 *dwc = NULL;
>  
>  	list_for_each_entry(dwc, &dwc3_list, list) {
> -		if (dwc->index != index)
> +		if (dwc->dev != dev)
>  			continue;
>  
>  		dwc3_gadget_uboot_handle_interrupt(dwc);
> diff --git a/drivers/usb/dwc3/dwc3-omap.c b/drivers/usb/dwc3/dwc3-omap.c
> index 9596bf144c3..ff4ebfb4447 100644
> --- a/drivers/usb/dwc3/dwc3-omap.c
> +++ b/drivers/usb/dwc3/dwc3-omap.c
> @@ -119,7 +119,7 @@
>  #define USBOTGSS_UTMI_OTG_STATUS_VBUSVALID	(1 << 1)
>  
>  struct dwc3_omap {
> -	struct device		*dev;
> +	struct udevice		*dev;
>  
>  	void __iomem		*base;
>  
> @@ -429,19 +429,19 @@ void dwc3_omap_uboot_exit(int index)
>  
>  /**
>   * dwc3_omap_uboot_interrupt_status - check the status of interrupt
> - * @index: index of this controller
> + * @dev: device of this controller
>   *
>   * Checks the status of interrupts and returns true if an interrupt
>   * is detected or false otherwise.
>   *
>   * Generally called from board file.
>   */
> -int dwc3_omap_uboot_interrupt_status(int index)
> +int dwc3_omap_uboot_interrupt_status(struct udevice *dev)
>  {
>  	struct dwc3_omap *omap = NULL;
>  
>  	list_for_each_entry(omap, &dwc3_omap_list, list)
> -		if (omap->index == index)
> +		if (omap->dev == dev)
>  			return dwc3_omap_interrupt(-1, omap);
>  
>  	return 0;
> diff --git a/drivers/usb/gadget/at91_udc.c b/drivers/usb/gadget/at91_udc.c
> index baa4c431fed..61d2aa5b929 100644
> --- a/drivers/usb/gadget/at91_udc.c
> +++ b/drivers/usb/gadget/at91_udc.c
> @@ -1429,7 +1429,7 @@ static const struct at91_udc_caps at91sam9261_udc_caps = {
>  };
>  #endif
>  
> -int usb_gadget_handle_interrupts(int index)
> +int dm_usb_gadget_handle_interrupts(struct udevice *dev)
>  {
>  	struct at91_udc *udc = controller;
>  
> diff --git a/drivers/usb/gadget/atmel_usba_udc.c b/drivers/usb/gadget/atmel_usba_udc.c
> index f4dcd205a4f..90b248a0777 100644
> --- a/drivers/usb/gadget/atmel_usba_udc.c
> +++ b/drivers/usb/gadget/atmel_usba_udc.c
> @@ -1198,14 +1198,13 @@ static struct usba_udc controller = {
>  	},
>  };
>  
> -int usb_gadget_handle_interrupts(int index)
> +int dm_usb_gadget_handle_interrupts(struct udevice *dev)
>  {
>  	struct usba_udc *udc = &controller;
>  
>  	return usba_udc_irq(udc);
>  }
>  
> -
>  int usb_gadget_register_driver(struct usb_gadget_driver *driver)
>  {
>  	struct usba_udc *udc = &controller;
> diff --git a/drivers/usb/gadget/ci_udc.c b/drivers/usb/gadget/ci_udc.c
> index 5bb26d7ab4a..44d2da0b4fb 100644
> --- a/drivers/usb/gadget/ci_udc.c
> +++ b/drivers/usb/gadget/ci_udc.c
> @@ -869,10 +869,10 @@ void udc_irq(void)
>  	}
>  }
>  
> -int usb_gadget_handle_interrupts(int index)
> +int dm_usb_gadget_handle_interrupts(struct udevice *dev)
>  {
> -	u32 value;
>  	struct ci_udc *udc = (struct ci_udc *)controller.ctrl->hcor;
> +	u32 value;
>  
>  	value = readl(&udc->usbsts);
>  	if (value)
> diff --git a/drivers/usb/gadget/dwc2_udc_otg.c b/drivers/usb/gadget/dwc2_udc_otg.c
> index 0a3bc0886e6..ff5173eda68 100644
> --- a/drivers/usb/gadget/dwc2_udc_otg.c
> +++ b/drivers/usb/gadget/dwc2_udc_otg.c
> @@ -941,15 +941,12 @@ int dwc2_udc_handle_interrupt(void)
>  	return 0;
>  }
>  
> -#if !CONFIG_IS_ENABLED(DM_USB_GADGET)
> -
> -int usb_gadget_handle_interrupts(int index)
> +int dm_usb_gadget_handle_interrupts(struct udevice *dev)
>  {
>  	return dwc2_udc_handle_interrupt();
>  }
>  
> -#else /* CONFIG_IS_ENABLED(DM_USB_GADGET) */
> -
> +#if CONFIG_IS_ENABLED(DM_USB_GADGET)
>  struct dwc2_priv_data {
>  	struct clk_bulk		clks;
>  	struct reset_ctl_bulk	resets;
> @@ -957,11 +954,6 @@ struct dwc2_priv_data {
>  	struct udevice *usb33d_supply;
>  };
>  
> -int dm_usb_gadget_handle_interrupts(struct udevice *dev)
> -{
> -	return dwc2_udc_handle_interrupt();
> -}
> -
>  static int dwc2_phy_setup(struct udevice *dev, struct phy_bulk *phys)
>  {
>  	int ret;
> diff --git a/drivers/usb/gadget/udc/udc-uclass.c b/drivers/usb/gadget/udc/udc-uclass.c
> index 7f54a3b00cb..9dfae08313b 100644
> --- a/drivers/usb/gadget/udc/udc-uclass.c
> +++ b/drivers/usb/gadget/udc/udc-uclass.c
> @@ -41,18 +41,6 @@ int udc_device_put(struct udevice *udev)
>  	return -ENOSYS;
>  #endif
>  }
> -
> -int usb_gadget_handle_interrupts(int index)
> -{
> -	struct udevice *udc;
> -	int ret;
> -
> -	ret = udc_device_get_by_index(index, &udc);
> -	if (ret)
> -		return ret;
> -
> -	return dm_usb_gadget_handle_interrupts(udc);
> -}
>  #else
>  /* Backwards hardware compatibility -- switch to DM_USB_GADGET */
>  static int legacy_index;
> diff --git a/drivers/usb/host/usb-sandbox.c b/drivers/usb/host/usb-sandbox.c
> index 582f72d00c1..3d4f8d653b5 100644
> --- a/drivers/usb/host/usb-sandbox.c
> +++ b/drivers/usb/host/usb-sandbox.c
> @@ -130,11 +130,6 @@ int dm_usb_gadget_handle_interrupts(struct udevice *dev)
>  	return 0;
>  }
>  #else
> -int usb_gadget_handle_interrupts(int index)
> -{
> -	return 0;
> -}
> -
>  int usb_gadget_register_driver(struct usb_gadget_driver *driver)
>  {
>  	struct sandbox_udc *dev = this_controller;
> diff --git a/drivers/usb/musb-new/musb_uboot.c b/drivers/usb/musb-new/musb_uboot.c
> index 67dc11669d2..0dcc428efeb 100644
> --- a/drivers/usb/musb-new/musb_uboot.c
> +++ b/drivers/usb/musb-new/musb_uboot.c
> @@ -376,7 +376,7 @@ struct dm_usb_ops musb_usb_ops = {
>  #if defined(CONFIG_USB_MUSB_GADGET) && !CONFIG_IS_ENABLED(DM_USB_GADGET)
>  static struct musb *gadget;
>  
> -int usb_gadget_handle_interrupts(int index)
> +int dm_usb_gadget_handle_interrupts(struct udevice *dev)
>  {
>  	schedule();
>  	if (!gadget || !gadget->isr)
> diff --git a/include/dwc3-omap-uboot.h b/include/dwc3-omap-uboot.h
> index 7c982e3798b..9e0e717dc98 100644
> --- a/include/dwc3-omap-uboot.h
> +++ b/include/dwc3-omap-uboot.h
> @@ -27,5 +27,5 @@ struct dwc3_omap_device {
>  
>  int dwc3_omap_uboot_init(struct dwc3_omap_device *dev);
>  void dwc3_omap_uboot_exit(int index);
> -int dwc3_omap_uboot_interrupt_status(int index);
> +int dwc3_omap_uboot_interrupt_status(struct udevice *dev);
>  #endif /* __DWC3_OMAP_UBOOT_H_ */
> diff --git a/include/dwc3-uboot.h b/include/dwc3-uboot.h
> index e08530ec4e5..bb0436c0973 100644
> --- a/include/dwc3-uboot.h
> +++ b/include/dwc3-uboot.h
> @@ -44,7 +44,7 @@ struct dwc3_device {
>  
>  int dwc3_uboot_init(struct dwc3_device *dev);
>  void dwc3_uboot_exit(int index);
> -void dwc3_uboot_handle_interrupt(int index);
> +void dwc3_uboot_handle_interrupt(struct udevice *dev);
>  
>  struct phy;
>  #if CONFIG_IS_ENABLED(PHY) && CONFIG_IS_ENABLED(DM_USB)
> diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
> index 54875d2716e..40228e320b3 100644
> --- a/include/linux/usb/gadget.h
> +++ b/include/linux/usb/gadget.h
> @@ -1004,7 +1004,7 @@ extern struct usb_ep *usb_ep_autoconfig(struct usb_gadget *,
>  
>  extern void usb_ep_autoconfig_reset(struct usb_gadget *);
>  
> -extern int usb_gadget_handle_interrupts(int index);
> +extern int dm_usb_gadget_handle_interrupts(struct udevice *);
>  
>  /**
>   * udc_device_get_by_index() - Get UDC udevice by index
> -- 
> 2.40.1

  reply	other threads:[~2023-08-22 16:58 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-19 14:23 [PATCH 01/17] dm: usb: udc: Factor out plain udevice handler functions Marek Vasut
2023-08-19 14:23 ` [PATCH 02/17] usb: sandbox: Add DM_USB_GADGET support Marek Vasut
2023-08-20 17:48   ` Simon Glass
2023-08-22 16:10   ` Mattijs Korpershoek
2023-08-19 14:23 ` [PATCH 03/17] configs: sandbox: Enable DM_USB_GADGET Marek Vasut
2023-08-20 17:48   ` Simon Glass
2023-08-22 16:10   ` Mattijs Korpershoek
2023-08-19 14:23 ` [PATCH 04/17] cmd: fastboot: Use plain udevice for UDC controller interaction Marek Vasut
2023-08-22 16:22   ` Mattijs Korpershoek
2023-08-19 14:23 ` [PATCH 05/17] cmd: rockusb: " Marek Vasut
2023-08-19 14:23 ` [PATCH 06/17] cmd: sdp: Reorder variable declaration Marek Vasut
2023-08-22 16:24   ` Mattijs Korpershoek
2023-08-19 14:23 ` [PATCH 07/17] cmd: thordown: " Marek Vasut
2023-08-19 14:23 ` [PATCH 08/17] cmd: ums: Use plain udevice for UDC controller interaction Marek Vasut
2023-08-22 16:29   ` Mattijs Korpershoek
2023-08-19 14:23 ` [PATCH 09/17] dfu: Detach the controller on error Marek Vasut
2023-08-22 16:32   ` Mattijs Korpershoek
2023-08-19 14:24 ` [PATCH 10/17] dfu: Use plain udevice for UDC controller interaction Marek Vasut
2023-08-22 16:33   ` Mattijs Korpershoek
2023-08-19 14:24 ` [PATCH 11/17] spl: sdp: Detach the controller on error Marek Vasut
2023-08-22 16:44   ` Mattijs Korpershoek
2023-09-01  9:52     ` Marek Vasut
2023-08-19 14:24 ` [PATCH 12/17] sdp: Use plain udevice for UDC controller interaction Marek Vasut
2023-08-22 16:46   ` Mattijs Korpershoek
2023-08-19 14:24 ` [PATCH 13/17] thordown: " Marek Vasut
2023-08-19 14:24 ` [PATCH 14/17] usb: gadget: acm: " Marek Vasut
2023-08-19 14:24 ` [PATCH 15/17] usb: gadget: ether: " Marek Vasut
2023-08-19 14:24 ` [PATCH 16/17] dm: usb: udc: Drop legacy udevice handler functions Marek Vasut
2023-08-22 16:52   ` Mattijs Korpershoek
2023-08-19 14:24 ` [PATCH 17/17] board: usb: Replace legacy usb_gadget_handle_interrupts() Marek Vasut
2023-08-22 16:58   ` Mattijs Korpershoek [this message]
2023-08-21  8:39 ` [PATCH 01/17] dm: usb: udc: Factor out plain udevice handler functions Miquel Raynal
2023-08-22 16:07 ` Mattijs Korpershoek

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=87r0nvqaiu.fsf@baylibre.com \
    --to=mkorpershoek@baylibre.com \
    --cc=angus@akkea.ca \
    --cc=dimorinny@google.com \
    --cc=eddie.cai.linux@gmail.com \
    --cc=kernel@puri.sm \
    --cc=kever.yang@rock-chips.com \
    --cc=lukma@denx.de \
    --cc=marex@denx.de \
    --cc=miquel.raynal@bootlin.com \
    --cc=nm@ti.com \
    --cc=patrice.chotard@foss.st.com \
    --cc=patrick.delaunay@foss.st.com \
    --cc=philipp.tomsich@vrull.eu \
    --cc=sjg@chromium.org \
    --cc=sr@denx.de \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox