From: Felipe Balbi <balbi@ti.com>
To: <dinguyen@opensource.altera.com>
Cc: <paulz@synopsys.com>, <balbi@ti.com>, <dinh.linux@gmail.com>,
<swarren@wwwdotorg.org>, <b.zolnierkie@samsung.com>,
<matthijs@stdin.nl>, <r.baldyga@samsung.com>,
<jg1.han@samsung.com>, <sachin.kamat@linaro.org>,
<ben-linux@fluff.org>, <dianders@chromium.org>,
<kever.yang@rock-chips.com>, <linux-usb@vger.kernel.org>,
<linux-kernel@vger.kernel.org>
Subject: Re: [PATCHv6 1/8] usb: dwc2: Update the gadget driver to use common dwc2_hsotg structure
Date: Thu, 30 Oct 2014 08:54:06 -0500 [thread overview]
Message-ID: <20141030135406.GB6482@saruman> (raw)
In-Reply-To: <1414538749-14735-2-git-send-email-dinguyen@opensource.altera.com>
[-- Attachment #1: Type: text/plain, Size: 11213 bytes --]
On Tue, Oct 28, 2014 at 06:25:42PM -0500, dinguyen@opensource.altera.com wrote:
> From: Dinh Nguyen <dinguyen@opensource.altera.com>
>
> Adds the gadget data structure and appropriate data structure pointers
> to the common dwc2_hsotg data structure. To keep the driver data
> dereference code looking clean, the gadget variable declares are only available
> for peripheral and dual-role mode. This is needed so that the dwc2_hsotg data
> structure can be used by the hcd and gadget drivers.
>
> Updates gadget.c to use the dwc2_hsotg data structure and gadget pointers
> that have been moved into the common dwc2_hsotg structure.
>
> Signed-off-by: Dinh Nguyen <dinguyen@opensource.altera.com>
> Signed-off-by: Paul Zimmerman <paulz@synopsys.com>
> ---
> v5: Keep the changes to mininum and maintain hcd and gadget driver to build
> and work separately. Use IS_ENABLED() instead of #if defined
> v3: Updated with paulz's suggestion to avoid double pointers.
> v2: Left the function parameter name as 'hsotg' and just changed its type.
> ---
> drivers/usb/dwc2/core.h | 156 ++++++++++++++++++++++++----------------------
> drivers/usb/dwc2/gadget.c | 145 +++++++++++++++++++++---------------------
> 2 files changed, 154 insertions(+), 147 deletions(-)
>
> diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
> index 55c90c5..96c283d 100644
> --- a/drivers/usb/dwc2/core.h
> +++ b/drivers/usb/dwc2/core.h
> @@ -84,7 +84,7 @@ static const char * const s3c_hsotg_supply_names[] = {
> */
> #define EP0_MPS_LIMIT 64
>
> -struct s3c_hsotg;
> +struct dwc2_hsotg;
> struct s3c_hsotg_req;
>
> /**
> @@ -130,7 +130,7 @@ struct s3c_hsotg_req;
> struct s3c_hsotg_ep {
> struct usb_ep ep;
> struct list_head queue;
> - struct s3c_hsotg *parent;
> + struct dwc2_hsotg *parent;
> struct s3c_hsotg_req *req;
> struct dentry *debugfs;
>
> @@ -155,67 +155,6 @@ struct s3c_hsotg_ep {
> };
>
> /**
> - * struct s3c_hsotg - driver state.
> - * @dev: The parent device supplied to the probe function
> - * @driver: USB gadget driver
> - * @phy: The otg phy transceiver structure for phy control.
> - * @uphy: The otg phy transceiver structure for old USB phy control.
> - * @plat: The platform specific configuration data. This can be removed once
> - * all SoCs support usb transceiver.
> - * @regs: The memory area mapped for accessing registers.
> - * @irq: The IRQ number we are using
> - * @supplies: Definition of USB power supplies
> - * @phyif: PHY interface width
> - * @dedicated_fifos: Set if the hardware has dedicated IN-EP fifos.
> - * @num_of_eps: Number of available EPs (excluding EP0)
> - * @debug_root: root directrory for debugfs.
> - * @debug_file: main status file for debugfs.
> - * @debug_fifo: FIFO status file for debugfs.
> - * @ep0_reply: Request used for ep0 reply.
> - * @ep0_buff: Buffer for EP0 reply data, if needed.
> - * @ctrl_buff: Buffer for EP0 control requests.
> - * @ctrl_req: Request for EP0 control packets.
> - * @setup: NAK management for EP0 SETUP
> - * @last_rst: Time of last reset
> - * @eps: The endpoints being supplied to the gadget framework
> - */
> -struct s3c_hsotg {
> - struct device *dev;
> - struct usb_gadget_driver *driver;
> - struct phy *phy;
> - struct usb_phy *uphy;
> - struct s3c_hsotg_plat *plat;
> -
> - spinlock_t lock;
> -
> - void __iomem *regs;
> - int irq;
> - struct clk *clk;
> -
> - struct regulator_bulk_data supplies[ARRAY_SIZE(s3c_hsotg_supply_names)];
> -
> - u32 phyif;
> - int fifo_mem;
> - unsigned int dedicated_fifos:1;
> - unsigned char num_of_eps;
> - u32 fifo_map;
> -
> - struct dentry *debug_root;
> - struct dentry *debug_file;
> - struct dentry *debug_fifo;
> -
> - struct usb_request *ep0_reply;
> - struct usb_request *ctrl_req;
> - u8 ep0_buff[8];
> - u8 ctrl_buff[8];
> -
> - struct usb_gadget gadget;
> - unsigned int setup;
> - unsigned long last_rst;
> - struct s3c_hsotg_ep *eps;
> -};
> -
> -/**
> * struct s3c_hsotg_req - data transfer request
> * @req: The USB gadget request
> * @queue: The list of requests for the endpoint this is queued for.
> @@ -229,6 +168,7 @@ struct s3c_hsotg_req {
> unsigned char mapped;
> };
>
> +#if IS_ENABLED(CONFIG_USB_DWC2_PERIPHERAL) || IS_ENABLED(CONFIG_USB_DWC2_DUAL_ROLE)
> #define call_gadget(_hs, _entry) \
> do { \
> if ((_hs)->gadget.speed != USB_SPEED_UNKNOWN && \
> @@ -238,6 +178,9 @@ do { \
> spin_lock(&_hs->lock); \
> } \
> } while (0)
> +#else
> +#define call_gadget(_hs, _entry) do {} while (0)
> +#endif
>
> struct dwc2_hsotg;
> struct dwc2_host_chan;
> @@ -495,11 +438,13 @@ struct dwc2_hw_params {
> * struct dwc2_hsotg - Holds the state of the driver, including the non-periodic
> * and periodic schedules
> *
> + * These are common for both host and peripheral modes:
> + *
> * @dev: The struct device pointer
> * @regs: Pointer to controller regs
> - * @core_params: Parameters that define how the core should be configured
> * @hw_params: Parameters that were autodetected from the
> * hardware registers
> + * @core_params: Parameters that define how the core should be configured
> * @op_state: The operational State, during transitions (a_host=>
> * a_peripheral and b_device=>b_host) this may not match
> * the core, but allows the software to determine
> @@ -508,6 +453,8 @@ struct dwc2_hw_params {
> * - USB_DR_MODE_PERIPHERAL
> * - USB_DR_MODE_HOST
> * - USB_DR_MODE_OTG
> + * @lock: Spinlock that protects all the driver data structures
> + * @priv: Stores a pointer to the struct usb_hcd
> * @queuing_high_bandwidth: True if multiple packets of a high-bandwidth
> * transfer are in process of being queued
> * @srp_success: Stores status of SRP request in the case of a FS PHY
> @@ -517,6 +464,9 @@ struct dwc2_hw_params {
> * interrupt
> * @wkp_timer: Timer object for handling Wakeup Detected interrupt
> * @lx_state: Lx state of connected device
> + *
> + * These are for host mode:
> + *
> * @flags: Flags for handling root port state changes
> * @non_periodic_sched_inactive: Inactive QHs in the non-periodic schedule.
> * Transfers associated with these QHs are not currently
> @@ -585,11 +535,31 @@ struct dwc2_hw_params {
> * @status_buf_dma: DMA address for status_buf
> * @start_work: Delayed work for handling host A-cable connection
> * @reset_work: Delayed work for handling a port reset
> - * @lock: Spinlock that protects all the driver data structures
> - * @priv: Stores a pointer to the struct usb_hcd
> * @otg_port: OTG port number
> * @frame_list: Frame list
> * @frame_list_dma: Frame list DMA address
> + *
> + * These are for peripheral mode:
> + *
> + * @driver: USB gadget driver
> + * @phy: The otg phy transceiver structure for phy control.
> + * @uphy: The otg phy transceiver structure for old USB phy control.
> + * @plat: The platform specific configuration data. This can be removed once
> + * all SoCs support usb transceiver.
> + * @supplies: Definition of USB power supplies
> + * @phyif: PHY interface width
> + * @dedicated_fifos: Set if the hardware has dedicated IN-EP fifos.
> + * @num_of_eps: Number of available EPs (excluding EP0)
> + * @debug_root: Root directrory for debugfs.
> + * @debug_file: Main status file for debugfs.
> + * @debug_fifo: FIFO status file for debugfs.
> + * @ep0_reply: Request used for ep0 reply.
> + * @ep0_buff: Buffer for EP0 reply data, if needed.
> + * @ctrl_buff: Buffer for EP0 control requests.
> + * @ctrl_req: Request for EP0 control packets.
> + * @setup: NAK management for EP0 SETUP
> + * @last_rst: Time of last reset
> + * @eps: The endpoints being supplied to the gadget framework
> */
> struct dwc2_hsotg {
> struct device *dev;
> @@ -601,6 +571,9 @@ struct dwc2_hsotg {
> enum usb_otg_state op_state;
> enum usb_dr_mode dr_mode;
>
> + spinlock_t lock;
> + void *priv;
> +
> unsigned int queuing_high_bandwidth:1;
> unsigned int srp_success:1;
>
> @@ -609,6 +582,14 @@ struct dwc2_hsotg {
> struct timer_list wkp_timer;
> enum dwc2_lx_state lx_state;
>
> + /* DWC OTG HW Release versions */
> +#define DWC2_CORE_REV_2_71a 0x4f54271a
> +#define DWC2_CORE_REV_2_90a 0x4f54290a
> +#define DWC2_CORE_REV_2_92a 0x4f54292a
> +#define DWC2_CORE_REV_2_94a 0x4f54294a
> +#define DWC2_CORE_REV_3_00a 0x4f54300a
> +
> +#if IS_ENABLED(CONFIG_USB_DWC2_HOST) || IS_ENABLED(CONFIG_USB_DWC2_DUAL_ROLE)
> union dwc2_hcd_internal_flags {
> u32 d32;
> struct {
> @@ -655,19 +636,10 @@ struct dwc2_hsotg {
>
> struct delayed_work start_work;
> struct delayed_work reset_work;
> - spinlock_t lock;
> - void *priv;
> u8 otg_port;
> u32 *frame_list;
> dma_addr_t frame_list_dma;
>
> - /* DWC OTG HW Release versions */
> -#define DWC2_CORE_REV_2_71a 0x4f54271a
> -#define DWC2_CORE_REV_2_90a 0x4f54290a
> -#define DWC2_CORE_REV_2_92a 0x4f54292a
> -#define DWC2_CORE_REV_2_94a 0x4f54294a
> -#define DWC2_CORE_REV_3_00a 0x4f54300a
> -
> #ifdef DEBUG
> u32 frrem_samples;
> u64 frrem_accum;
> @@ -686,6 +658,40 @@ struct dwc2_hsotg {
> u32 hfnum_other_samples_b;
> u64 hfnum_other_frrem_accum_b;
> #endif
> +#endif /* CONFIG_USB_DWC2_HOST || CONFIG_USB_DWC2_DUAL_ROLE */
> +
> +#if IS_ENABLED(CONFIG_USB_DWC2_PERIPHERAL) || IS_ENABLED(CONFIG_USB_DWC2_DUAL_ROLE)
> + /* Gadget structures */
> + struct usb_gadget_driver *driver;
> + struct phy *phy;
this shouldn't be limited to gadget.
> + struct usb_phy *uphy;
this shouldn't be limited to gadget.
> + struct s3c_hsotg_plat *plat;
> +
> + int irq;
this shouldn't be limited to gadget.
> + struct clk *clk;
this shouldn't be limited to gadget.
> +
> + struct regulator_bulk_data supplies[ARRAY_SIZE(s3c_hsotg_supply_names)];
this shouldn't be limited to gadget.
> + u32 phyif;
> + int fifo_mem;
> + unsigned int dedicated_fifos:1;
> + unsigned char num_of_eps;
> + u32 fifo_map;
> +
> + struct dentry *debug_root;
this shouldn't be limited to gadget.
> + struct dentry *debug_file;
this shouldn't be limited to gadget.
> + struct dentry *debug_fifo;
this shouldn't be limited to gadget.
--
balbi
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
next prev parent reply other threads:[~2014-10-30 13:57 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-28 23:25 [PATCHv6 0/8] usb: dwc2: Add support for dual-role dinguyen
2014-10-28 23:25 ` [PATCHv6 1/8] usb: dwc2: Update the gadget driver to use common dwc2_hsotg structure dinguyen
2014-10-30 13:54 ` Felipe Balbi [this message]
2014-10-31 14:55 ` Dinh Nguyen
2014-10-31 2:47 ` Kever Yang
2014-10-31 13:48 ` Felipe Balbi
2014-10-28 23:25 ` [PATCHv6 2/8] usb: dwc2: Move gadget probe function into platform code dinguyen
2014-10-30 13:57 ` Felipe Balbi
2014-10-31 14:59 ` Dinh Nguyen
2014-10-28 23:25 ` [PATCHv6 3/8] usb: dwc2: Initialize the USB core for peripheral mode dinguyen
2014-10-28 23:25 ` [PATCHv6 4/8] usb: dwc2: Update common interrupt handler to call gadget interrupt handler dinguyen
2014-10-30 14:00 ` Felipe Balbi
2014-10-31 15:00 ` Dinh Nguyen
2014-10-31 20:12 ` Paul Zimmerman
2014-10-28 23:25 ` [PATCHv6 5/8] usb: dwc2: Add call_gadget functions for perpheral mode interrupts dinguyen
2014-10-30 14:01 ` Felipe Balbi
2014-10-31 15:01 ` Dinh Nguyen
2014-10-28 23:25 ` [PATCHv6 6/8] usb: dwc2: gadget: Do not fail probe if there isn't a clock node dinguyen
2014-10-29 1:30 ` Paul Zimmerman
2014-10-30 14:04 ` Felipe Balbi
2014-10-31 15:20 ` Dinh Nguyen
2014-10-31 17:42 ` Felipe Balbi
2014-10-31 19:31 ` Dinh Nguyen
2014-10-31 19:56 ` Dinh Nguyen
2014-11-03 15:25 ` Felipe Balbi
2014-10-31 2:38 ` Kever Yang
2014-10-31 13:49 ` Felipe Balbi
2014-10-28 23:25 ` [PATCHv6 7/8] usb: dwc2: Update Kconfig to support dual-role dinguyen
2014-10-28 23:25 ` [PATCHv6 8/8] usb: dwc2: move usb_disabled() call to host driver only dinguyen
2014-10-29 1:26 ` Paul Zimmerman
2014-10-29 13:35 ` Dinh Nguyen
2014-10-30 14:07 ` Felipe Balbi
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=20141030135406.GB6482@saruman \
--to=balbi@ti.com \
--cc=b.zolnierkie@samsung.com \
--cc=ben-linux@fluff.org \
--cc=dianders@chromium.org \
--cc=dinguyen@opensource.altera.com \
--cc=dinh.linux@gmail.com \
--cc=jg1.han@samsung.com \
--cc=kever.yang@rock-chips.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=matthijs@stdin.nl \
--cc=paulz@synopsys.com \
--cc=r.baldyga@samsung.com \
--cc=sachin.kamat@linaro.org \
--cc=swarren@wwwdotorg.org \
/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.