From patchwork Wed Jun 29 10:06:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rui Miguel Silva X-Patchwork-Id: 585815 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:5036:0:0:0:0 with SMTP id e22csp190198mab; Wed, 29 Jun 2022 03:06:43 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uaFko7cS7u9+2xXj+ssb5PbyGMKkQRstLrOhb26MmpYXIwLUPUf8eOMNIHckbIr2ucdx1M X-Received: by 2002:a05:651c:a0f:b0:25b:c834:4604 with SMTP id k15-20020a05651c0a0f00b0025bc8344604mr1277988ljq.252.1656497203483; Wed, 29 Jun 2022 03:06:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656497203; cv=none; d=google.com; s=arc-20160816; b=DtpN7/v0nnvt8pj7junrTRvkVyzNXRzzRmxAI8yZJo/iRl0bxdbyXdtwr3sPSgJ2GN suN0Ve4nGDsiOR59eJrSU4OWkoSZMnot92W+CCFti7cDaca9jgKx3ijKohHm0CC3N/+f cO20pYnFUGhjnN0o12qvJxWn0x4jDI3EuGNwVFhy5AaMaTFL1Czs+/hJ8Z1IXPVEI5OF CIIJzGJEZ6nUhMziRyZT8R9JEMVU5cdiuWzFjpoQqEvyi2goSUMasYV1e3xwixzAKQWf fkqGBHUlDVGrd9IehPBLO96YDABpZKMFSLrmRXquZu07xm8hRsBG7IBXWb52C89qcxtW ql2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=NbVgw8hWnObQzC6QysACiS7dVpq/UiUf+DPFUJ5fOl4=; b=xQ53JoFICak0WfNc2q4zz/d/1t333SrA3qaiBnFCtZ5VIsX6SJgTRtbcwS5NFkm92u 9SeoO1bpXq0vofJtWKqw/mOtxfGsChkJJ9zF4z3OYlcKgtIXFEBgKcTqLBI2PllV/atS ovKym/bEauDgxcW9jjDtTnwNliSjB819OV42NN+3lKMxB4DYfPv3jjAs5RQaU/6PHA0w gM6kcUoqEMXrAVA+Petyj2hFjO36jPryw3ZbmjUtU8IfSkeVRusecuWtZBh7nuGWWgZH gTXJLzANtxFHgiF4SnRlEp/AtghF4dfZqVAo+G7zO+/eNKmh/+g/JH+bsKcvys+dqRba IY/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KG5cg43a; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id c5-20020a2e9d85000000b00253f7e348basi13721786ljj.334.2022.06.29.03.06.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Jun 2022 03:06:43 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KG5cg43a; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B4B7D843CE; Wed, 29 Jun 2022 12:06:35 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="KG5cg43a"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id DCC838437A; Wed, 29 Jun 2022 12:06:33 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id AD0D5842C0 for ; Wed, 29 Jun 2022 12:06:29 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=rui.silva@linaro.org Received: by mail-wm1-x332.google.com with SMTP id c130-20020a1c3588000000b0039c6fd897b4so11080410wma.4 for ; Wed, 29 Jun 2022 03:06:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=NbVgw8hWnObQzC6QysACiS7dVpq/UiUf+DPFUJ5fOl4=; b=KG5cg43aNa/l7+l3wwC+/SB80GpGnYodtRMnOS7lzsleNyL3Roa4A6BFY/ofqcjGoa ZIrGuoUXrpjzRN0n6ZoPAs40WMVVRjr3Hgn7ZIwAVl8/PwWDXT5cPG3783cfruox1XvW dLbqKGC5K7kiStbAKvSMNUvsHOFoKE8xIrvrGTQCWgtelAAi9MHW552ILIvLK66mBmM4 v1xTggk8rRiY0m3e6QiLXEMYv/TAghhaX2cW3pMfHYU9zpfMf6hH3JO/I5zySVwPaMby GQaU1x2S0Cjryvc3crHpGyJEw0c+2GHmQdVTdbN3HegxyfWn5ERpwoPO45lI+hAM0YAu KoNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=NbVgw8hWnObQzC6QysACiS7dVpq/UiUf+DPFUJ5fOl4=; b=Zle3TDe7VJLSs+qBnDoSORu/LVhkiba6qECb1sgchoUTcxa+ZmR7uOiSssn26V7IXN p7oRFFJGWZcfCpEpaoeZeStLALd7NNtR0aOlL+kdswsLlJ8EQBoWrKEFkVqUiFsj/n1M F1+rvOhTwxAKW7Cm+V5ivjf+vJCtfX3TSUZGpYCV57BAZGfA3Yv7xLAuNa1ZpA85bj1g x3UTeBFe7uOP8AMofj5cTFzNvjlOw9TBBeEsNdemAsy7nXxXUUZjQWRBBizJPgOipauM YzvEKWO5gTaS1yFLvnqkCXlpogN2XEm6+j3JaEtJTY941FKGk+pcCMn2aHB54tlJ/1kr Lyfw== X-Gm-Message-State: AJIora9Ri+dGw/pYreH/IMUjQot/iNlzLLHj2jSXuQ2PSQP5Cp1z+ckT sGMmyoNCag8/c41gJY4FCwAc/q3D/B1SOQ== X-Received: by 2002:a05:600c:1c94:b0:3a0:4c46:b823 with SMTP id k20-20020a05600c1c9400b003a04c46b823mr4758480wms.161.1656497188841; Wed, 29 Jun 2022 03:06:28 -0700 (PDT) Received: from arch-thunder.local (a109-49-33-111.cpe.netcabo.pt. [109.49.33.111]) by smtp.gmail.com with ESMTPSA id h4-20020a5d4304000000b0021b829d111csm16526076wrq.112.2022.06.29.03.06.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Jun 2022 03:06:28 -0700 (PDT) From: Rui Miguel Silva To: u-boot@lists.denx.de, Marek Vasut Cc: Tom Rini , Rui Miguel Silva Subject: [PATCH v5 1/3] usb: common: move urb code to common Date: Wed, 29 Jun 2022 11:06:14 +0100 Message-Id: <20220629100616.417550-2-rui.silva@linaro.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220629100616.417550-1-rui.silva@linaro.org> References: <20220629100616.417550-1-rui.silva@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean Move urb code from musb only use to a more common scope, so other drivers in the future can use the handling of urb in usb. Signed-off-by: Rui Miguel Silva --- drivers/usb/common/Makefile | 3 + drivers/usb/common/usb_urb.c | 160 ++++++++++++++++++ drivers/usb/host/r8a66597-hcd.c | 30 +--- drivers/usb/musb-new/musb_core.c | 2 +- drivers/usb/musb-new/musb_host.c | 2 +- drivers/usb/musb-new/musb_host.h | 2 +- drivers/usb/musb-new/musb_uboot.c | 38 +---- drivers/usb/musb-new/musb_uboot.h | 2 +- .../linux/usb/usb_urb_compat.h | 47 ++++- include/usb_defs.h | 32 ++++ 10 files changed, 242 insertions(+), 76 deletions(-) create mode 100644 drivers/usb/common/usb_urb.c rename drivers/usb/musb-new/usb-compat.h => include/linux/usb/usb_urb_compat.h (59%) diff --git a/drivers/usb/common/Makefile b/drivers/usb/common/Makefile index 3bedbf213f47..7eacc909f2d9 100644 --- a/drivers/usb/common/Makefile +++ b/drivers/usb/common/Makefile @@ -4,5 +4,8 @@ # obj-$(CONFIG_$(SPL_)DM_USB) += common.o +obj-$(CONFIG_USB_MUSB_HOST) += usb_urb.o +obj-$(CONFIG_USB_MUSB_GADGET) += usb_urb.o +obj-$(CONFIG_USB_R8A66597_HCD) += usb_urb.o obj-$(CONFIG_USB_EHCI_FSL) += fsl-dt-fixup.o fsl-errata.o obj-$(CONFIG_USB_XHCI_FSL) += fsl-dt-fixup.o fsl-errata.o diff --git a/drivers/usb/common/usb_urb.c b/drivers/usb/common/usb_urb.c new file mode 100644 index 000000000000..be3b6b9f32e8 --- /dev/null +++ b/drivers/usb/common/usb_urb.c @@ -0,0 +1,160 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Common code for usb urb handling, based on the musb-new code + * + * Copyright 2021 Linaro, Rui Miguel Silva + * + */ + +#include +#include +#include + +#include +#include + +#if CONFIG_IS_ENABLED(DM_USB) +struct usb_device *usb_dev_get_parent(struct usb_device *udev) +{ + struct udevice *parent = udev->dev->parent; + + /* + * When called from usb-uclass.c: usb_scan_device() udev->dev points + * to the parent udevice, not the actual udevice belonging to the + * udev as the device is not instantiated yet. + * + * If dev is an usb-bus, then we are called from usb_scan_device() for + * an usb-device plugged directly into the root port, return NULL. + */ + if (device_get_uclass_id(udev->dev) == UCLASS_USB) + return NULL; + + /* + * If these 2 are not the same we are being called from + * usb_scan_device() and udev itself is the parent. + */ + if (dev_get_parent_priv(udev->dev) != udev) + return udev; + + /* We are being called normally, use the parent pointer */ + if (device_get_uclass_id(parent) == UCLASS_USB_HUB) + return dev_get_parent_priv(parent); + + return NULL; +} +#else +struct usb_device *usb_dev_get_parent(struct usb_device *udev) +{ + return udev->parent; +} +#endif + +static void usb_urb_complete(struct urb *urb) +{ + urb->dev->status &= ~USB_ST_NOT_PROC; + urb->dev->act_len = urb->actual_length; + + if (urb->status == -EINPROGRESS) + urb->status = 0; +} + +void usb_urb_fill(struct urb *urb, struct usb_host_endpoint *hep, + struct usb_device *dev, int endpoint_type, + unsigned long pipe, void *buffer, int len, + struct devrequest *setup, int interval) +{ + int epnum = usb_pipeendpoint(pipe); + int is_in = usb_pipein(pipe); + u16 maxpacketsize = is_in ? dev->epmaxpacketin[epnum] : + dev->epmaxpacketout[epnum]; + + memset(urb, 0, sizeof(struct urb)); + memset(hep, 0, sizeof(struct usb_host_endpoint)); + INIT_LIST_HEAD(&hep->urb_list); + INIT_LIST_HEAD(&urb->urb_list); + urb->ep = hep; + urb->complete = usb_urb_complete; + urb->status = -EINPROGRESS; + urb->dev = dev; + urb->pipe = pipe; + urb->transfer_buffer = buffer; + urb->transfer_dma = (unsigned long)buffer; + urb->transfer_buffer_length = len; + urb->setup_packet = (unsigned char *)setup; + + urb->ep->desc.wMaxPacketSize = __cpu_to_le16(maxpacketsize); + urb->ep->desc.bmAttributes = endpoint_type; + urb->ep->desc.bEndpointAddress = ((is_in ? USB_DIR_IN : USB_DIR_OUT) | + epnum); + urb->ep->desc.bInterval = interval; +} + +int usb_urb_submit(struct usb_hcd *hcd, struct urb *urb) +{ + const struct usb_urb_ops *ops = hcd->urb_ops; + unsigned long timeout; + int ret; + + if (!ops) + return -EINVAL; + + ret = ops->urb_enqueue(hcd, urb, 0); + if (ret < 0) { + printf("Failed to enqueue URB to controller\n"); + return ret; + } + + timeout = get_timer(0) + USB_TIMEOUT_MS(urb->pipe); + do { + if (ctrlc()) + return -EIO; + ops->isr(0, hcd); + } while (urb->status == -EINPROGRESS && get_timer(0) < timeout); + + if (urb->status == -EINPROGRESS) + ops->urb_dequeue(hcd, urb, -ETIME); + + return urb->status; +} + +int usb_urb_submit_control(struct usb_hcd *hcd, struct urb *urb, + struct usb_host_endpoint *hep, + struct usb_device *dev, unsigned long pipe, + void *buffer, int len, struct devrequest *setup, + int interval, enum usb_device_speed speed) +{ + const struct usb_urb_ops *ops = hcd->urb_ops; + + usb_urb_fill(urb, hep, dev, USB_ENDPOINT_XFER_CONTROL, pipe, buffer, + len, setup, 0); + + /* Fix speed for non hub-attached devices */ + if (!usb_dev_get_parent(dev)) { + dev->speed = speed; + if (ops->hub_control) + return ops->hub_control(hcd, dev, pipe, buffer, len, + setup); + } + + return usb_urb_submit(hcd, urb); +} + +int usb_urb_submit_bulk(struct usb_hcd *hcd, struct urb *urb, + struct usb_host_endpoint *hep, struct usb_device *dev, + unsigned long pipe, void *buffer, int len) +{ + usb_urb_fill(urb, hep, dev, USB_ENDPOINT_XFER_BULK, pipe, buffer, len, + NULL, 0); + + return usb_urb_submit(hcd, urb); +} + +int usb_urb_submit_irq(struct usb_hcd *hcd, struct urb *urb, + struct usb_host_endpoint *hep, struct usb_device *dev, + unsigned long pipe, void *buffer, int len, int interval) +{ + usb_urb_fill(urb, hep, dev, USB_ENDPOINT_XFER_INT, pipe, buffer, len, + NULL, interval); + + return usb_urb_submit(hcd, urb); +} diff --git a/drivers/usb/host/r8a66597-hcd.c b/drivers/usb/host/r8a66597-hcd.c index f1fc93f3d403..3ccbc16da379 100644 --- a/drivers/usb/host/r8a66597-hcd.c +++ b/drivers/usb/host/r8a66597-hcd.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include "r8a66597.h" @@ -24,35 +25,6 @@ #define R8A66597_DPRINT(...) #endif -static inline struct usb_device *usb_dev_get_parent(struct usb_device *udev) -{ - struct udevice *parent = udev->dev->parent; - - /* - * When called from usb-uclass.c: usb_scan_device() udev->dev points - * to the parent udevice, not the actual udevice belonging to the - * udev as the device is not instantiated yet. - * - * If dev is an usb-bus, then we are called from usb_scan_device() for - * an usb-device plugged directly into the root port, return NULL. - */ - if (device_get_uclass_id(udev->dev) == UCLASS_USB) - return NULL; - - /* - * If these 2 are not the same we are being called from - * usb_scan_device() and udev itself is the parent. - */ - if (dev_get_parent_priv(udev->dev) != udev) - return udev; - - /* We are being called normally, use the parent pointer */ - if (device_get_uclass_id(parent) == UCLASS_USB_HUB) - return dev_get_parent_priv(parent); - - return NULL; -} - static void get_hub_data(struct usb_device *dev, u16 *hub_devnum, u16 *hubport) { struct usb_device *parent = usb_dev_get_parent(dev); diff --git a/drivers/usb/musb-new/musb_core.c b/drivers/usb/musb-new/musb_core.c index 18d9bc805f8a..fc7af7484e4c 100644 --- a/drivers/usb/musb-new/musb_core.c +++ b/drivers/usb/musb-new/musb_core.c @@ -89,9 +89,9 @@ #include #include #include +#include #include #include "linux-compat.h" -#include "usb-compat.h" #endif #include "musb_core.h" diff --git a/drivers/usb/musb-new/musb_host.c b/drivers/usb/musb-new/musb_host.c index acb2d40f3b5a..e5905d90d66f 100644 --- a/drivers/usb/musb-new/musb_host.c +++ b/drivers/usb/musb-new/musb_host.c @@ -26,8 +26,8 @@ #include #include #include +#include #include "linux-compat.h" -#include "usb-compat.h" #endif #include "musb_core.h" diff --git a/drivers/usb/musb-new/musb_host.h b/drivers/usb/musb-new/musb_host.h index afc8fa35a738..5a604bdb0cf2 100644 --- a/drivers/usb/musb-new/musb_host.h +++ b/drivers/usb/musb-new/musb_host.h @@ -10,7 +10,7 @@ #ifndef _MUSB_HOST_H #define _MUSB_HOST_H #ifdef __UBOOT__ -#include "usb-compat.h" +#include #endif static inline struct usb_hcd *musb_to_hcd(struct musb *musb) diff --git a/drivers/usb/musb-new/musb_uboot.c b/drivers/usb/musb-new/musb_uboot.c index 61ff68def2fa..d186facc7e02 100644 --- a/drivers/usb/musb-new/musb_uboot.c +++ b/drivers/usb/musb-new/musb_uboot.c @@ -8,10 +8,10 @@ #include #include #include +#include #include #include "linux-compat.h" -#include "usb-compat.h" #include "musb_core.h" #include "musb_host.h" #include "musb_gadget.h" @@ -453,39 +453,3 @@ struct musb *musb_register(struct musb_hdrc_platform_data *plat, void *bdata, return *musbp; } - -#if CONFIG_IS_ENABLED(DM_USB) -struct usb_device *usb_dev_get_parent(struct usb_device *udev) -{ - struct udevice *parent = udev->dev->parent; - - /* - * When called from usb-uclass.c: usb_scan_device() udev->dev points - * to the parent udevice, not the actual udevice belonging to the - * udev as the device is not instantiated yet. - * - * If dev is an usb-bus, then we are called from usb_scan_device() for - * an usb-device plugged directly into the root port, return NULL. - */ - if (device_get_uclass_id(udev->dev) == UCLASS_USB) - return NULL; - - /* - * If these 2 are not the same we are being called from - * usb_scan_device() and udev itself is the parent. - */ - if (dev_get_parent_priv(udev->dev) != udev) - return udev; - - /* We are being called normally, use the parent pointer */ - if (device_get_uclass_id(parent) == UCLASS_USB_HUB) - return dev_get_parent_priv(parent); - - return NULL; -} -#else -struct usb_device *usb_dev_get_parent(struct usb_device *udev) -{ - return udev->parent; -} -#endif diff --git a/drivers/usb/musb-new/musb_uboot.h b/drivers/usb/musb-new/musb_uboot.h index 18282efccc9d..6b162f03b19e 100644 --- a/drivers/usb/musb-new/musb_uboot.h +++ b/drivers/usb/musb-new/musb_uboot.h @@ -8,8 +8,8 @@ #define __MUSB_UBOOT_H__ #include +#include #include "linux-compat.h" -#include "usb-compat.h" #include "musb_core.h" struct musb_host_data { diff --git a/drivers/usb/musb-new/usb-compat.h b/include/linux/usb/usb_urb_compat.h similarity index 59% rename from drivers/usb/musb-new/usb-compat.h rename to include/linux/usb/usb_urb_compat.h index df68c9220a7a..2e8c9d8db79a 100644 --- a/drivers/usb/musb-new/usb-compat.h +++ b/include/linux/usb/usb_urb_compat.h @@ -1,16 +1,32 @@ -#ifndef __USB_COMPAT_H__ -#define __USB_COMPAT_H__ +/* SPDX-License-Identifier: GPL-2.0+ */ -#include "usb.h" +#ifndef __USB_URB_COMPAT_H__ +#define __USB_URB_COMPAT_H__ + +#include +#include struct udevice; +struct urb; +struct usb_hcd; + +struct usb_urb_ops { + int (*urb_enqueue)(struct usb_hcd *hcd, struct urb *urb, + gfp_t mem_flags); + int (*urb_dequeue)(struct usb_hcd *hcd, struct urb *urb, int status); + int (*hub_control)(struct usb_hcd *hcd, struct usb_device *dev, + unsigned long pipe, void *buffer, int len, + struct devrequest *setup); + irqreturn_t (*isr)(int irq, void *priv); +}; struct usb_hcd { void *hcd_priv; + const struct usb_urb_ops *urb_ops; }; struct usb_host_endpoint { - struct usb_endpoint_descriptor desc; + struct usb_endpoint_descriptor desc; struct list_head urb_list; void *hcpriv; }; @@ -23,8 +39,6 @@ struct usb_host_endpoint { #define URB_SHORT_NOT_OK 0x0001 /* report short reads as errors */ #define URB_ZERO_PACKET 0x0040 /* Finish bulk OUT with short packet */ -struct urb; - typedef void (*usb_complete_t)(struct urb *); struct urb { @@ -76,4 +90,25 @@ static inline int usb_hcd_unmap_urb_for_dma(struct usb_hcd *hcd, */ struct usb_device *usb_dev_get_parent(struct usb_device *udev); +int usb_urb_submit_control(struct usb_hcd *hcd, struct urb *urb, + struct usb_host_endpoint *hep, + struct usb_device *dev, unsigned long pipe, + void *buffer, int len, struct devrequest *setup, + int interval, enum usb_device_speed speed); + +int usb_urb_submit_bulk(struct usb_hcd *hcd, struct urb *urb, + struct usb_host_endpoint *hep, struct usb_device *dev, + unsigned long pipe, void *buffer, int len); + +int usb_urb_submit_irq(struct usb_hcd *hcd, struct urb *urb, + struct usb_host_endpoint *hep, struct usb_device *dev, + unsigned long pipe, void *buffer, int len, int interval); + +void usb_urb_fill(struct urb *urb, struct usb_host_endpoint *hep, + struct usb_device *dev, int endpoint_type, + unsigned long pipe, void *buffer, int len, + struct devrequest *setup, int interval); + +int usb_urb_submit(struct usb_hcd *hcd, struct urb *urb); + #endif /* __USB_COMPAT_H__ */ diff --git a/include/usb_defs.h b/include/usb_defs.h index 6dd2c997f9b3..ec00161710a5 100644 --- a/include/usb_defs.h +++ b/include/usb_defs.h @@ -81,6 +81,32 @@ #define EndpointOutRequest \ ((USB_DIR_OUT | USB_TYPE_STANDARD | USB_RECIP_INTERFACE) << 8) +/* class requests from the USB 2.0 hub spec, table 11-15 */ +#define HUB_CLASS_REQ(dir, type, request) ((((dir) | (type)) << 8) | (request)) +/* GetBusState and SetHubDescriptor are optional, omitted */ +#define ClearHubFeature HUB_CLASS_REQ(USB_DIR_OUT, USB_RT_HUB, \ + USB_REQ_CLEAR_FEATURE) +#define ClearPortFeature HUB_CLASS_REQ(USB_DIR_OUT, USB_RT_PORT, \ + USB_REQ_CLEAR_FEATURE) +#define GetHubDescriptor HUB_CLASS_REQ(USB_DIR_IN, USB_RT_HUB, \ + USB_REQ_GET_DESCRIPTOR) +#define GetHubStatus HUB_CLASS_REQ(USB_DIR_IN, USB_RT_HUB, \ + USB_REQ_GET_STATUS) +#define GetPortStatus HUB_CLASS_REQ(USB_DIR_IN, USB_RT_PORT, \ + USB_REQ_GET_STATUS) +#define SetHubFeature HUB_CLASS_REQ(USB_DIR_OUT, USB_RT_HUB, \ + USB_REQ_SET_FEATURE) +#define SetPortFeature HUB_CLASS_REQ(USB_DIR_OUT, USB_RT_PORT, \ + USB_REQ_SET_FEATURE) +#define ClearTTBuffer HUB_CLASS_REQ(USB_DIR_OUT, USB_RT_PORT, \ + HUB_CLEAR_TT_BUFFER) +#define ResetTT HUB_CLASS_REQ(USB_DIR_OUT, USB_RT_PORT, \ + HUB_RESET_TT) +#define GetTTState HUB_CLASS_REQ(USB_DIR_IN, USB_RT_PORT, \ + HUB_GET_TT_STATE) +#define StopTT HUB_CLASS_REQ(USB_DIR_OUT, USB_RT_PORT, \ + HUB_STOP_TT) + /* Descriptor types */ #define USB_DT_DEVICE 0x01 #define USB_DT_CONFIG 0x02 @@ -289,10 +315,16 @@ #define USB_SS_PORT_STAT_C_CONFIG_ERROR 0x0080 /* wHubCharacteristics (masks) */ +#define HUB_CHAR_COMMON_OCPM 0x0000 /* All ports Over-Current reporting */ +#define HUB_CHAR_INDV_PORT_LPSM 0x0001 /* per-port power control */ +#define HUB_CHAR_NO_LPSM 0x0002 /* no power switching */ #define HUB_CHAR_LPSM 0x0003 #define HUB_CHAR_COMPOUND 0x0004 +#define HUB_CHAR_INDV_PORT_OCPM 0x0008 /* per-port Over-current reporting */ +#define HUB_CHAR_NO_OCPM 0x0010 /* No Over-current Protection support */ #define HUB_CHAR_OCPM 0x0018 #define HUB_CHAR_TTTT 0x0060 /* TT Think Time mask */ +#define HUB_CHAR_PORTIND 0x0080 /* per-port indicators (LEDs) */ /* * Hub Status & Hub Change bit masks