From: Kishon Vijay Abraham I <kishon@ti.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [UBOOT RFC PATCH 01/13] include: linux: preparation for porting dwc3 from linux kernel
Date: Mon, 18 Aug 2014 19:58:23 +0530 [thread overview]
Message-ID: <1408372115-4570-2-git-send-email-kishon@ti.com> (raw)
In-Reply-To: <1408372115-4570-1-git-send-email-kishon@ti.com>
Fixes a bunch of header files in linux/usb in order to seamlessly
port dwc3 usb driver from linux kernel to uboot.
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
---
include/linux/compat.h | 12 +++++--
include/linux/usb/composite.h | 12 +++++++
include/linux/usb/gadget.h | 75 ++++++++++++++++++++++++++++++++++++++---
include/linux/usb/otg.h | 20 +++++++++++
include/usb/lin_gadget_compat.h | 8 ++++-
5 files changed, 119 insertions(+), 8 deletions(-)
create mode 100644 include/linux/usb/otg.h
diff --git a/include/linux/compat.h b/include/linux/compat.h
index 3fdfb39..d54ff18 100644
--- a/include/linux/compat.h
+++ b/include/linux/compat.h
@@ -1,6 +1,8 @@
#ifndef _LINUX_COMPAT_H_
#define _LINUX_COMPAT_H_
+#include <common.h>
+
#define ndelay(x) udelay(1)
#define dev_dbg(dev, fmt, args...) \
@@ -53,8 +55,14 @@
#define BUG_ON(condition) do { if (condition) BUG(); } while(0)
#endif /* BUG */
-#define WARN_ON(x) if (x) {printf("WARNING in %s line %d\n" \
- , __FILE__, __LINE__); }
+#define WARN_ON(x) _WARN_ON((int)(x), __FILE__, __LINE__)
+static inline int _WARN_ON(int x, char *file, int line)
+{
+ if (x) {
+ printf("WARNING in %s line %d\n", file, line);
+ }
+ return x;
+}
#define PAGE_SIZE 4096
#endif
diff --git a/include/linux/usb/composite.h b/include/linux/usb/composite.h
index f833d10..9063aee 100644
--- a/include/linux/usb/composite.h
+++ b/include/linux/usb/composite.h
@@ -27,6 +27,18 @@
#include <linux/usb/gadget.h>
#include <usb/lin_gadget_compat.h>
+/*
+ * USB function drivers should return USB_GADGET_DELAYED_STATUS if they
+ * wish to delay the data/status stages of the control transfer till they
+ * are ready. The control transfer will then be kept from completing till
+ * all the function drivers that requested for USB_GADGET_DELAYED_STAUS
+ * invoke usb_composite_setup_continue().
+ *
+ * TODO: Fully port "usb: gadget: composite: Allow function drivers to
+ * pause control transfers" to uboot
+ */
+#define USB_GADGET_DELAYED_STATUS 0x7fff /* Impossibly large value */
+
struct usb_configuration;
/**
diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
index a8a5763..3d533f0 100644
--- a/include/linux/usb/gadget.h
+++ b/include/linux/usb/gadget.h
@@ -30,6 +30,10 @@ struct usb_ep;
* @dma: DMA address corresponding to 'buf'. If you don't set this
* field, and the usb controller needs one, it is responsible
* for mapping and unmapping the buffer.
+ * @sg: a scatterlist for SG-capable controllers.
+ * @num_sgs: number of SG entries
+ * @num_mapped_sgs: number of SG entries mapped to DMA (internal)
+ * @stream_id: The stream id, when USB3.0 bulk streams are being used
* @length: Length of that data
* @no_interrupt: If true, hints that no completion irq is needed.
* Helpful sometimes with deep request queues that are handled
@@ -84,6 +88,11 @@ struct usb_request {
unsigned length;
dma_addr_t dma;
+ struct scatterlist *sg;
+ unsigned num_sgs;
+ unsigned num_mapped_sgs;
+
+ unsigned stream_id:16;
unsigned no_interrupt:1;
unsigned zero:1;
unsigned short_not_ok:1;
@@ -120,6 +129,7 @@ struct usb_ep_ops {
int (*dequeue) (struct usb_ep *ep, struct usb_request *req);
int (*set_halt) (struct usb_ep *ep, int value);
+ int (*set_wedge) (struct usb_ep *ep);
int (*fifo_status) (struct usb_ep *ep);
void (*fifo_flush) (struct usb_ep *ep);
};
@@ -132,8 +142,18 @@ struct usb_ep_ops {
* @maxpacket:The maximum packet size used on this endpoint. The initial
* value can sometimes be reduced (hardware allowing), according to
* the endpoint descriptor used to configure the endpoint.
+ * @maxpacket_limit:The maximum packet size value which can be handled by this
+ * endpoint. It's set once by UDC driver when endpoint is initialized, and
+ * should not be changed. Should not be confused with maxpacket.
+ * @max_streams: The maximum number of streams supported
+ * by this EP (0 - 16, actual number is 2^n)
+ * @maxburst: the maximum number of bursts supported by this EP (for usb3)
* @driver_data:for use by the gadget driver. all other fields are
* read-only to gadget drivers.
+ * @desc: endpoint descriptor. This pointer is set before the endpoint is
+ * enabled and remains valid until the endpoint is disabled.
+ * @comp_desc: In case of SuperSpeed support, this is the endpoint companion
+ * descriptor that is used to configure the endpoint
*
* the bus controller driver lists all the general purpose endpoints in
* gadget->ep_list. the control endpoint (gadget->ep0) is not in that list,
@@ -145,11 +165,31 @@ struct usb_ep {
const struct usb_ep_ops *ops;
struct list_head ep_list;
unsigned maxpacket:16;
+ unsigned maxpacket_limit:16;
+ unsigned max_streams:16;
+ unsigned maxburst:5;
+ const struct usb_endpoint_descriptor *desc;
+ const struct usb_ss_ep_comp_descriptor *comp_desc;
};
/*-------------------------------------------------------------------------*/
/**
+ * usb_ep_set_maxpacket_limit - set maximum packet size limit for endpoint
+ * @ep:the endpoint being configured
+ * @maxpacket_limit:value of maximum packet size limit
+ *
+ * This function shoud be used only in UDC drivers to initialize endpoint
+ * (usually in probe function).
+ */
+static inline void usb_ep_set_maxpacket_limit(struct usb_ep *ep,
+ unsigned maxpacket_limit)
+{
+ ep->maxpacket_limit = maxpacket_limit;
+ ep->maxpacket = maxpacket_limit;
+}
+
+/**
* usb_ep_enable - configure endpoint, making it usable
* @ep:the endpoint being configured. may not be the endpoint named "ep0".
* drivers discover endpoints through the ep_list of a usb_gadget.
@@ -395,7 +435,7 @@ static inline void usb_ep_fifo_flush(struct usb_ep *ep)
/*-------------------------------------------------------------------------*/
struct usb_gadget;
-
+struct usb_gadget_driver;
/* the rest of the api to the controller hardware: device operations,
* which don't involve endpoints (or i/o).
*/
@@ -408,9 +448,13 @@ struct usb_gadget_ops {
int (*pullup) (struct usb_gadget *, int is_on);
int (*ioctl)(struct usb_gadget *,
unsigned code, unsigned long param);
+ int (*udc_start)(struct usb_gadget *,
+ struct usb_gadget_driver *);
+ int (*udc_stop)(struct usb_gadget *,
+ struct usb_gadget_driver *);
};
-struct device {
+struct usb_gadget_device {
void *driver_data; /* data private to the driver */
void *device_data; /* data private to the device */
};
@@ -422,6 +466,10 @@ struct device {
* driver setup() requests
* @ep_list: List of other endpoints supported by the device.
* @speed: Speed of current connection to USB host.
+ * @max_speed: Maximal speed the UDC can handle. UDC must support this
+ * and all slower speeds.
+ * @state: the state we are now (attached, suspended, configured, etc)
+ * @sg_supported: true if we can handle scatter-gather
* @is_dualspeed: true if the controller supports both high and full speed
* operation. If it does, the gadget driver must also support both.
* @is_otg: true if the USB device port uses a Mini-AB jack, so that the
@@ -438,6 +486,8 @@ struct device {
* @name: Identifies the controller hardware type. Used in diagnostics
* and sometimes configuration.
* @dev: Driver model state for this abstract device.
+ * @quirk_ep_out_aligned_size: epout requires buffer size to be aligned to
+ * MaxPacketSize.
*
* Gadgets have a mostly-portable "gadget driver" implementing device
* functions, handling all usb configurations and interfaces. Gadget
@@ -463,6 +513,9 @@ struct usb_gadget {
struct usb_ep *ep0;
struct list_head ep_list; /* of usb_ep */
enum usb_device_speed speed;
+ enum usb_device_speed max_speed;
+ unsigned sg_supported:1;
+ enum usb_device_state state;
unsigned is_dualspeed:1;
unsigned is_otg:1;
unsigned is_a_peripheral:1;
@@ -470,7 +523,8 @@ struct usb_gadget {
unsigned a_hnp_support:1;
unsigned a_alt_hnp_support:1;
const char *name;
- struct device dev;
+ struct usb_gadget_device dev;
+ unsigned quirk_ep_out_aligned_size:1;
};
static inline void set_gadget_data(struct usb_gadget *gadget, void *data)
@@ -483,7 +537,8 @@ static inline void *get_gadget_data(struct usb_gadget *gadget)
return gadget->dev.driver_data;
}
-static inline struct usb_gadget *dev_to_usb_gadget(struct device *dev)
+static inline
+struct usb_gadget *dev_to_usb_gadget(struct usb_gadget_device *dev)
{
return container_of(dev, struct usb_gadget, dev);
}
@@ -689,7 +744,8 @@ static inline int usb_gadget_disconnect(struct usb_gadget *gadget)
/*-------------------------------------------------------------------------*/
/**
- * struct usb_gadget_driver - driver for usb 'slave' devices
+ * struct usb_gadget_driver - driver for uisb 'slave' devices
+ * @function: String describing the gadget's function
* @speed: Highest speed the driver handles.
* @bind: Invoked when the driver is bound to a gadget, usually
* after registering the driver.
@@ -757,6 +813,7 @@ static inline int usb_gadget_disconnect(struct usb_gadget *gadget)
* power is maintained.
*/
struct usb_gadget_driver {
+ char *function;
enum usb_device_speed speed;
int (*bind)(struct usb_gadget *);
void (*unbind)(struct usb_gadget *);
@@ -861,4 +918,12 @@ extern void usb_ep_autoconfig_reset(struct usb_gadget *);
extern int usb_gadget_handle_interrupts(void);
+/* utility to set gadget state properly */
+
+extern void usb_gadget_set_state(struct usb_gadget *gadget,
+ enum usb_device_state state);
+extern int usb_add_gadget_udc_release(struct usb_gadget *gadget);
+extern int usb_add_gadget_udc(struct usb_gadget *gadget);
+extern void usb_del_gadget_udc(struct usb_gadget *gadget);
+
#endif /* __LINUX_USB_GADGET_H */
diff --git a/include/linux/usb/otg.h b/include/linux/usb/otg.h
new file mode 100644
index 0000000..08bed6f
--- /dev/null
+++ b/include/linux/usb/otg.h
@@ -0,0 +1,20 @@
+/* include/linux/usb/otg.h
+ *
+ * Copyright (c) 2014 Texas Instruments Incorporated - http://www.ti.com
+ *
+ * USB OTG (On The Go) defines
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#ifndef __LINUX_USB_OTG_H
+#define __LINUX_USB_OTG_H
+
+enum usb_dr_mode {
+ USB_DR_MODE_UNKNOWN,
+ USB_DR_MODE_HOST,
+ USB_DR_MODE_PERIPHERAL,
+ USB_DR_MODE_OTG,
+};
+
+#endif /* __LINUX_USB_OTG_H */
diff --git a/include/usb/lin_gadget_compat.h b/include/usb/lin_gadget_compat.h
index a25e9d9..58be177 100644
--- a/include/usb/lin_gadget_compat.h
+++ b/include/usb/lin_gadget_compat.h
@@ -27,7 +27,13 @@
#define GFP_KERNEL 0
-#define IRQ_HANDLED 1
+enum irqreturn {
+ IRQ_NONE,
+ IRQ_HANDLED,
+ IRQ_WAKE_THREAD,
+};
+
+typedef enum irqreturn irqreturn_t;
#define ENOTSUPP 524 /* Operation is not supported */
--
1.9.1
next prev parent reply other threads:[~2014-08-18 14:28 UTC|newest]
Thread overview: 57+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-18 14:28 [U-Boot] [UBOOT RFC PATCH 00/13] DRA7xx: Add DWC3 USB driver and enable DFU Kishon Vijay Abraham I
2014-08-18 14:28 ` Kishon Vijay Abraham I [this message]
2014-08-18 14:28 ` [U-Boot] [UBOOT RFC PATCH 02/13] usb: gadget: udc-core: Add minimal udc-core from linux kernel Kishon Vijay Abraham I
2014-08-18 14:36 ` Felipe Balbi
2014-08-19 14:58 ` Kishon Vijay Abraham I
2014-08-19 8:52 ` Lukasz Majewski
2014-08-19 15:11 ` Felipe Balbi
2014-08-19 15:18 ` Kishon Vijay Abraham I
2014-08-19 15:28 ` Felipe Balbi
2014-08-19 15:38 ` Lukasz Majewski
2014-08-19 16:06 ` Kishon Vijay Abraham I
2014-08-20 7:02 ` Lukasz Majewski
2014-08-18 14:28 ` [U-Boot] [UBOOT RFC PATCH 03/13] ARM: DRA7: Enable clocks for USB OTGSS and USB PHY Kishon Vijay Abraham I
2014-08-18 14:28 ` [U-Boot] [UBOOT RFC PATCH 04/13] usb: dwc3: Add dwc3 driver Kishon Vijay Abraham I
2014-08-18 14:37 ` Felipe Balbi
2014-08-19 15:19 ` Kishon Vijay Abraham I
2014-08-18 14:28 ` [U-Boot] [UBOOT RFC PATCH 05/13] usb: dwc3-omap: Add dwc3 glue driver for OMAP Kishon Vijay Abraham I
2014-08-18 14:28 ` [U-Boot] [UBOOT RFC PATCH 06/13] usb: dwc3: TI PHY: PHY driver for dwc3 in TI platforms Kishon Vijay Abraham I
2014-08-18 14:28 ` [U-Boot] [UBOOT RFC PATCH 07/13] usb: gadget: g_dnl: Explicitly set the max packet size in descriptor Kishon Vijay Abraham I
2014-08-18 14:38 ` Felipe Balbi
2014-08-18 14:49 ` Lukasz Majewski
2014-08-18 14:56 ` Lukasz Majewski
2014-08-19 15:38 ` Kishon Vijay Abraham I
2014-08-19 15:44 ` Felipe Balbi
2014-08-20 7:34 ` Lukasz Majewski
2014-08-20 16:11 ` Felipe Balbi
2014-08-21 8:00 ` Lukasz Majewski
2014-08-21 13:50 ` Felipe Balbi
2014-08-20 7:23 ` Lukasz Majewski
2014-08-19 15:34 ` Kishon Vijay Abraham I
2014-08-19 15:39 ` Felipe Balbi
2014-08-19 15:42 ` Kishon Vijay Abraham I
2014-08-19 15:48 ` Felipe Balbi
2014-08-19 15:53 ` Kishon Vijay Abraham I
2014-08-18 14:28 ` [U-Boot] [UBOOT RFC PATCH 08/13] common: cmd_dfu: invoke board_usb_cleanup() for cleaning up Kishon Vijay Abraham I
2014-08-18 14:28 ` [U-Boot] [UBOOT RFC PATCH 09/13] common: cmd_dfu: add an API that takes controller index for handling interrupts Kishon Vijay Abraham I
2014-08-19 8:53 ` Lukasz Majewski
2014-08-19 16:09 ` Kishon Vijay Abraham I
2014-08-20 7:37 ` Lukasz Majewski
2014-08-18 14:28 ` [U-Boot] [UBOOT RFC PATCH 10/13] board: ti: DRA7: added USB initializtion code Kishon Vijay Abraham I
2014-08-18 14:40 ` Felipe Balbi
2014-08-19 16:13 ` Kishon Vijay Abraham I
2014-08-19 16:26 ` Felipe Balbi
2014-08-22 10:47 ` Kishon Vijay Abraham I
2014-08-18 14:28 ` [U-Boot] [UBOOT RFC PATCH 11/13] commom: usb: implement "__weak" functions to make compiler happy Kishon Vijay Abraham I
2014-08-19 8:28 ` Lukasz Majewski
2014-08-19 16:14 ` Kishon Vijay Abraham I
2014-08-21 17:32 ` Tom Rini
2014-08-18 14:28 ` [U-Boot] [UBOOT RFC PATCH 12/13] include: configs: Enable DWC3 and DFU in DRA7xx Kishon Vijay Abraham I
2014-08-18 14:28 ` [U-Boot] [UBOOT RFC PATCH 13/13] dwc3: core: Change the bounce buffer size to 4096 Kishon Vijay Abraham I
2014-08-18 14:41 ` Felipe Balbi
2014-08-19 16:15 ` Kishon Vijay Abraham I
2014-08-19 16:27 ` Felipe Balbi
2014-08-22 11:02 ` Kishon Vijay Abraham I
2014-08-22 13:54 ` Felipe Balbi
2014-08-18 15:29 ` [U-Boot] [UBOOT RFC PATCH 00/13] DRA7xx: Add DWC3 USB driver and enable DFU Tom Rini
2014-08-19 8:56 ` Lukasz Majewski
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=1408372115-4570-2-git-send-email-kishon@ti.com \
--to=kishon@ti.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.