From patchwork Mon Aug 18 14:28:23 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kishon Vijay Abraham I X-Patchwork-Id: 35519 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ig0-f198.google.com (mail-ig0-f198.google.com [209.85.213.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 3B76120676 for ; Mon, 18 Aug 2014 15:10:00 +0000 (UTC) Received: by mail-ig0-f198.google.com with SMTP id h18sf23587463igc.5 for ; Mon, 18 Aug 2014 08:09:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:mime-version:subject:precedence:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:sender:errors-to :x-original-sender:x-original-authentication-results:mailing-list :content-type:content-transfer-encoding; bh=AfhF6uNATh2DFJuEeiUrjGiZYtqfdQM8azLqu/5cCKQ=; b=Sr2RkRlStAmVZwwMij4Op0ly1gOb0QGoYRFNTYBxL+wCM/4SWMDsTiwvGOOgwG01A2 dZVxGqOZj8XvQGB7WRxPFWEMlowR83W/mYSfydswrbavwPSxKmHTK3e/9Wvv4g9MPMWx 5PaZzW/4PDAgqLUdxeu2Jg4C+35sxyItncwnV5HCiBiu9iOeWGua3ISpSjZsu3jCdqHQ 5BHQwpvFIMQ6P0L4zKjE1WW8tyvEujmmkh3nvorVFRcnRKp9st2dhFBnjsv+X9zRdP3H iAqwNtAdUuQhSF0lc0LQS9aGaOGjT/09YTZVM5wF7XfpPd+dokKVGzNYn3HjqDAK2Eg5 xTig== X-Gm-Message-State: ALoCoQlahN1txu71R+0Am03yxdvKZtK2MtDKmhSTs0WZjcv7p1XLKjP6qqdOWm9xmJhTJOr1g/gB X-Received: by 10.182.4.73 with SMTP id i9mr11743668obi.28.1408374599758; Mon, 18 Aug 2014 08:09:59 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.85.48 with SMTP id m45ls2448601qgd.18.gmail; Mon, 18 Aug 2014 08:09:59 -0700 (PDT) X-Received: by 10.52.141.76 with SMTP id rm12mr435737vdb.71.1408374599643; Mon, 18 Aug 2014 08:09:59 -0700 (PDT) Received: from mail-vc0-f172.google.com (mail-vc0-f172.google.com [209.85.220.172]) by mx.google.com with ESMTPS id dc15si4987970vec.70.2014.08.18.08.09.59 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 18 Aug 2014 08:09:59 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.172 as permitted sender) client-ip=209.85.220.172; Received: by mail-vc0-f172.google.com with SMTP id im17so5960553vcb.3 for ; Mon, 18 Aug 2014 08:09:59 -0700 (PDT) X-Received: by 10.220.97.5 with SMTP id j5mr25487944vcn.16.1408374599554; Mon, 18 Aug 2014 08:09:59 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.37.5 with SMTP id tc5csp160301vcb; Mon, 18 Aug 2014 08:09:58 -0700 (PDT) X-Received: by 10.180.12.239 with SMTP id b15mr74376085wic.75.1408374598219; Mon, 18 Aug 2014 08:09:58 -0700 (PDT) Received: from theia.denx.de (theia.denx.de. [85.214.87.163]) by mx.google.com with ESMTP id uk5si25848633wjc.61.2014.08.18.08.09.57 for ; Mon, 18 Aug 2014 08:09:58 -0700 (PDT) Received-SPF: none (google.com: u-boot-bounces@lists.denx.de does not designate permitted sender hosts) client-ip=85.214.87.163; Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id B64C94B5E9; Mon, 18 Aug 2014 17:09:03 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id XAREd8CSLWme; Mon, 18 Aug 2014 17:09:03 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id ECD824B60F; Mon, 18 Aug 2014 17:07:57 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id BC6744B576 for ; Mon, 18 Aug 2014 16:29:14 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Ap445kZnONPR for ; Mon, 18 Aug 2014 16:29:08 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from arroyo.ext.ti.com (arroyo.ext.ti.com [192.94.94.40]) by theia.denx.de (Postfix) with ESMTPS id E3A274A040 for ; Mon, 18 Aug 2014 16:28:53 +0200 (CEST) Received: from dflxv15.itg.ti.com ([128.247.5.124]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id s7IEShWG006413 for ; Mon, 18 Aug 2014 09:28:45 -0500 Received: from DFLE72.ent.ti.com (dfle72.ent.ti.com [128.247.5.109]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id s7IEShmb027360 for ; Mon, 18 Aug 2014 09:28:43 -0500 Received: from dlep32.itg.ti.com (157.170.170.100) by DFLE72.ent.ti.com (128.247.5.109) with Microsoft SMTP Server id 14.3.174.1; Mon, 18 Aug 2014 09:28:42 -0500 Received: from a0393678lt.apr.dhcp.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep32.itg.ti.com (8.14.3/8.13.8) with ESMTP id s7IESbM2003614; Mon, 18 Aug 2014 09:28:40 -0500 From: Kishon Vijay Abraham I To: , , , , , , Date: Mon, 18 Aug 2014 19:58:23 +0530 Message-ID: <1408372115-4570-2-git-send-email-kishon@ti.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1408372115-4570-1-git-send-email-kishon@ti.com> References: <1408372115-4570-1-git-send-email-kishon@ti.com> MIME-Version: 1.0 X-Mailman-Approved-At: Mon, 18 Aug 2014 17:07:53 +0200 Subject: [U-Boot] [UBOOT RFC PATCH 01/13] include: linux: preparation for porting dwc3 from linux kernel X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: kishon@ti.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.172 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 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 --- 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 + #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 #include +/* + * 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 */