staging: dwc2: register common irq handler in dwc2_core_init
[cascardo/linux.git] / drivers / staging / dwc2 / core.h
1 /*
2  * core.h - DesignWare HS OTG Controller common declarations
3  *
4  * Copyright (C) 2004-2013 Synopsys, Inc.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions, and the following disclaimer,
11  *    without modification.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  * 3. The names of the above-listed copyright holders may not be used
16  *    to endorse or promote products derived from this software without
17  *    specific prior written permission.
18  *
19  * ALTERNATIVELY, this software may be distributed under the terms of the
20  * GNU General Public License ("GPL") as published by the Free Software
21  * Foundation; either version 2 of the License, or (at your option) any
22  * later version.
23  *
24  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
25  * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
26  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
27  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
28  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
29  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
30  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
31  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
32  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
33  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
34  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35  */
36
37 #ifndef __DWC2_CORE_H__
38 #define __DWC2_CORE_H__
39
40 #include <linux/usb/phy.h>
41 #include "hw.h"
42
43 #ifdef DWC2_LOG_WRITES
44 static inline void do_write(u32 value, void *addr)
45 {
46         writel(value, addr);
47         pr_info("INFO:: wrote %08x to %p\n", value, addr);
48 }
49
50 #undef writel
51 #define writel(v, a)    do_write(v, a)
52 #endif
53
54 /* Maximum number of Endpoints/HostChannels */
55 #define MAX_EPS_CHANNELS        16
56
57 struct dwc2_hsotg;
58 struct dwc2_host_chan;
59
60 /* Device States */
61 enum dwc2_lx_state {
62         DWC2_L0,        /* On state */
63         DWC2_L1,        /* LPM sleep state */
64         DWC2_L2,        /* USB suspend state */
65         DWC2_L3,        /* Off state */
66 };
67
68 /**
69  * struct dwc2_core_params - Parameters for configuring the core
70  *
71  * @otg_cap:            Specifies the OTG capabilities. The driver will
72  *                      automatically detect the value for this parameter if
73  *                      none is specified.
74  *                       0 - HNP and SRP capable (default)
75  *                       1 - SRP Only capable
76  *                       2 - No HNP/SRP capable
77  * @dma_enable:         Specifies whether to use slave or DMA mode for accessing
78  *                      the data FIFOs. The driver will automatically detect the
79  *                      value for this parameter if none is specified.
80  *                       0 - Slave
81  *                       1 - DMA (default, if available)
82  * @dma_desc_enable:    When DMA mode is enabled, specifies whether to use
83  *                      address DMA mode or descriptor DMA mode for accessing
84  *                      the data FIFOs. The driver will automatically detect the
85  *                      value for this if none is specified.
86  *                       0 - Address DMA
87  *                       1 - Descriptor DMA (default, if available)
88  * @speed:              Specifies the maximum speed of operation in host and
89  *                      device mode. The actual speed depends on the speed of
90  *                      the attached device and the value of phy_type.
91  *                       0 - High Speed (default)
92  *                       1 - Full Speed
93  * @host_support_fs_ls_low_power: Specifies whether low power mode is supported
94  *                      when attached to a Full Speed or Low Speed device in
95  *                      host mode.
96  *                       0 - Don't support low power mode (default)
97  *                       1 - Support low power mode
98  * @host_ls_low_power_phy_clk: Specifies the PHY clock rate in low power mode
99  *                      when connected to a Low Speed device in host mode. This
100  *                      parameter is applicable only if
101  *                      host_support_fs_ls_low_power is enabled. If phy_type is
102  *                      set to FS then defaults to 6 MHZ otherwise 48 MHZ.
103  *                       0 - 48 MHz
104  *                       1 - 6 MHz
105  * @enable_dynamic_fifo: 0 - Use coreConsultant-specified FIFO size parameters
106  *                       1 - Allow dynamic FIFO sizing (default)
107  * @host_rx_fifo_size:  Number of 4-byte words in the Rx FIFO in host mode when
108  *                      dynamic FIFO sizing is enabled
109  *                       16 to 32768 (default 1024)
110  * @host_nperio_tx_fifo_size: Number of 4-byte words in the non-periodic Tx FIFO
111  *                      in host mode when dynamic FIFO sizing is enabled
112  *                       16 to 32768 (default 1024)
113  * @host_perio_tx_fifo_size: Number of 4-byte words in the periodic Tx FIFO in
114  *                      host mode when dynamic FIFO sizing is enabled
115  *                       16 to 32768 (default 1024)
116  * @max_transfer_size:  The maximum transfer size supported, in bytes
117  *                       2047 to 65,535 (default 65,535)
118  * @max_packet_count:   The maximum number of packets in a transfer
119  *                       15 to 511 (default 511)
120  * @host_channels:      The number of host channel registers to use
121  *                       1 to 16 (default 12)
122  * @phy_type:           Specifies the type of PHY interface to use. By default,
123  *                      the driver will automatically detect the phy_type.
124  * @phy_utmi_width:     Specifies the UTMI+ Data Width (in bits). This parameter
125  *                      is applicable for a phy_type of UTMI+ or ULPI. (For a
126  *                      ULPI phy_type, this parameter indicates the data width
127  *                      between the MAC and the ULPI Wrapper.) Also, this
128  *                      parameter is applicable only if the OTG_HSPHY_WIDTH cC
129  *                      parameter was set to "8 and 16 bits", meaning that the
130  *                      core has been configured to work at either data path
131  *                      width.
132  *                       8 or 16 (default 16)
133  * @phy_ulpi_ddr:       Specifies whether the ULPI operates at double or single
134  *                      data rate. This parameter is only applicable if phy_type
135  *                      is ULPI.
136  *                       0 - single data rate ULPI interface with 8 bit wide
137  *                           data bus (default)
138  *                       1 - double data rate ULPI interface with 4 bit wide
139  *                           data bus
140  * @phy_ulpi_ext_vbus:  For a ULPI phy, specifies whether to use the internal or
141  *                      external supply to drive the VBus
142  * @i2c_enable:         Specifies whether to use the I2Cinterface for a full
143  *                      speed PHY. This parameter is only applicable if phy_type
144  *                      is FS.
145  *                       0 - No (default)
146  *                       1 - Yes
147  * @ulpi_fs_ls:         True to make ULPI phy operate in FS/LS mode only
148  * @ts_dline:           True to enable Term Select Dline pulsing
149  * @en_multiple_tx_fifo: Specifies whether dedicated per-endpoint transmit FIFOs
150  *                      are enabled
151  * @reload_ctl:         True to allow dynamic reloading of HFIR register during
152  *                      runtime
153  * @ahb_single:         This bit enables SINGLE transfers for remainder data in
154  *                      a transfer for DMA mode of operation.
155  *                       0 - remainder data will be sent using INCR burst size
156  *                       1 - remainder data will be sent using SINGLE burst size
157  * @otg_ver:            OTG version supported
158  *                       0 - 1.3
159  *                       1 - 2.0
160  *
161  * The following parameters may be specified when starting the module. These
162  * parameters define how the DWC_otg controller should be configured.
163  */
164 struct dwc2_core_params {
165         int otg_cap;
166         int otg_ver;
167         int dma_enable;
168         int dma_desc_enable;
169         int speed;
170         int enable_dynamic_fifo;
171         int en_multiple_tx_fifo;
172         int host_rx_fifo_size;
173         int host_nperio_tx_fifo_size;
174         int host_perio_tx_fifo_size;
175         int max_transfer_size;
176         int max_packet_count;
177         int host_channels;
178         int phy_type;
179         int phy_utmi_width;
180         int phy_ulpi_ddr;
181         int phy_ulpi_ext_vbus;
182         int i2c_enable;
183         int ulpi_fs_ls;
184         int host_support_fs_ls_low_power;
185         int host_ls_low_power_phy_clk;
186         int ts_dline;
187         int reload_ctl;
188         int ahb_single;
189 };
190
191 /**
192  * struct dwc2_hsotg - Holds the state of the driver, including the non-periodic
193  * and periodic schedules
194  *
195  * @dev:                The struct device pointer
196  * @regs:               Pointer to controller regs
197  * @core_params:        Parameters that define how the core should be configured
198  * @hwcfg1:             Hardware Configuration - stored here for convenience
199  * @hwcfg2:             Hardware Configuration - stored here for convenience
200  * @hwcfg3:             Hardware Configuration - stored here for convenience
201  * @hwcfg4:             Hardware Configuration - stored here for convenience
202  * @hptxfsiz:           Hardware Configuration - stored here for convenience
203  * @snpsid:             Value from SNPSID register
204  * @total_fifo_size:    Total internal RAM for FIFOs (bytes)
205  * @rx_fifo_size:       Size of Rx FIFO (bytes)
206  * @nperio_tx_fifo_size: Size of Non-periodic Tx FIFO (Bytes)
207  * @op_state:           The operational State, during transitions (a_host=>
208  *                      a_peripheral and b_device=>b_host) this may not match
209  *                      the core, but allows the software to determine
210  *                      transitions
211  * @queuing_high_bandwidth: True if multiple packets of a high-bandwidth
212  *                      transfer are in process of being queued
213  * @srp_success:        Stores status of SRP request in the case of a FS PHY
214  *                      with an I2C interface
215  * @wq_otg:             Workqueue object used for handling of some interrupts
216  * @wf_otg:             Work object for handling Connector ID Status Change
217  *                      interrupt
218  * @wkp_timer:          Timer object for handling Wakeup Detected interrupt
219  * @lx_state:           Lx state of connected device
220  * @flags:              Flags for handling root port state changes
221  * @non_periodic_sched_inactive: Inactive QHs in the non-periodic schedule.
222  *                      Transfers associated with these QHs are not currently
223  *                      assigned to a host channel.
224  * @non_periodic_sched_active: Active QHs in the non-periodic schedule.
225  *                      Transfers associated with these QHs are currently
226  *                      assigned to a host channel.
227  * @non_periodic_qh_ptr: Pointer to next QH to process in the active
228  *                      non-periodic schedule
229  * @periodic_sched_inactive: Inactive QHs in the periodic schedule. This is a
230  *                      list of QHs for periodic transfers that are _not_
231  *                      scheduled for the next frame. Each QH in the list has an
232  *                      interval counter that determines when it needs to be
233  *                      scheduled for execution. This scheduling mechanism
234  *                      allows only a simple calculation for periodic bandwidth
235  *                      used (i.e. must assume that all periodic transfers may
236  *                      need to execute in the same frame). However, it greatly
237  *                      simplifies scheduling and should be sufficient for the
238  *                      vast majority of OTG hosts, which need to connect to a
239  *                      small number of peripherals at one time. Items move from
240  *                      this list to periodic_sched_ready when the QH interval
241  *                      counter is 0 at SOF.
242  * @periodic_sched_ready:  List of periodic QHs that are ready for execution in
243  *                      the next frame, but have not yet been assigned to host
244  *                      channels. Items move from this list to
245  *                      periodic_sched_assigned as host channels become
246  *                      available during the current frame.
247  * @periodic_sched_assigned: List of periodic QHs to be executed in the next
248  *                      frame that are assigned to host channels. Items move
249  *                      from this list to periodic_sched_queued as the
250  *                      transactions for the QH are queued to the DWC_otg
251  *                      controller.
252  * @periodic_sched_queued: List of periodic QHs that have been queued for
253  *                      execution. Items move from this list to either
254  *                      periodic_sched_inactive or periodic_sched_ready when the
255  *                      channel associated with the transfer is released. If the
256  *                      interval for the QH is 1, the item moves to
257  *                      periodic_sched_ready because it must be rescheduled for
258  *                      the next frame. Otherwise, the item moves to
259  *                      periodic_sched_inactive.
260  * @periodic_usecs:     Total bandwidth claimed so far for periodic transfers.
261  *                      This value is in microseconds per (micro)frame. The
262  *                      assumption is that all periodic transfers may occur in
263  *                      the same (micro)frame.
264  * @frame_number:       Frame number read from the core at SOF. The value ranges
265  *                      from 0 to HFNUM_MAX_FRNUM.
266  * @periodic_qh_count:  Count of periodic QHs, if using several eps. Used for
267  *                      SOF enable/disable.
268  * @free_hc_list:       Free host channels in the controller. This is a list of
269  *                      struct dwc2_host_chan items.
270  * @periodic_channels:  Number of host channels assigned to periodic transfers.
271  *                      Currently assuming that there is a dedicated host
272  *                      channel for each periodic transaction and at least one
273  *                      host channel is available for non-periodic transactions.
274  * @non_periodic_channels: Number of host channels assigned to non-periodic
275  *                      transfers
276  * @hc_ptr_array:       Array of pointers to the host channel descriptors.
277  *                      Allows accessing a host channel descriptor given the
278  *                      host channel number. This is useful in interrupt
279  *                      handlers.
280  * @status_buf:         Buffer used for data received during the status phase of
281  *                      a control transfer.
282  * @status_buf_dma:     DMA address for status_buf
283  * @start_work:         Delayed work for handling host A-cable connection
284  * @reset_work:         Delayed work for handling a port reset
285  * @lock:               Spinlock that protects all the driver data structures
286  * @priv:               Stores a pointer to the struct usb_hcd
287  * @otg_port:           OTG port number
288  * @frame_list:         Frame list
289  * @frame_list_dma:     Frame list DMA address
290  */
291 struct dwc2_hsotg {
292         struct device *dev;
293         void __iomem *regs;
294         struct dwc2_core_params *core_params;
295         u32 hwcfg1;
296         u32 hwcfg2;
297         u32 hwcfg3;
298         u32 hwcfg4;
299         u32 hptxfsiz;
300         u32 snpsid;
301         u16 total_fifo_size;
302         u16 rx_fifo_size;
303         u16 nperio_tx_fifo_size;
304         enum usb_otg_state op_state;
305
306         unsigned int queuing_high_bandwidth:1;
307         unsigned int srp_success:1;
308
309         struct workqueue_struct *wq_otg;
310         struct work_struct wf_otg;
311         struct timer_list wkp_timer;
312         enum dwc2_lx_state lx_state;
313
314         union dwc2_hcd_internal_flags {
315                 u32 d32;
316                 struct {
317                         unsigned port_connect_status_change:1;
318                         unsigned port_connect_status:1;
319                         unsigned port_reset_change:1;
320                         unsigned port_enable_change:1;
321                         unsigned port_suspend_change:1;
322                         unsigned port_over_current_change:1;
323                         unsigned port_l1_change:1;
324                         unsigned reserved:26;
325                 } b;
326         } flags;
327
328         struct list_head non_periodic_sched_inactive;
329         struct list_head non_periodic_sched_active;
330         struct list_head *non_periodic_qh_ptr;
331         struct list_head periodic_sched_inactive;
332         struct list_head periodic_sched_ready;
333         struct list_head periodic_sched_assigned;
334         struct list_head periodic_sched_queued;
335         u16 periodic_usecs;
336         u16 frame_number;
337         u16 periodic_qh_count;
338
339 #ifdef CONFIG_USB_DWC2_TRACK_MISSED_SOFS
340 #define FRAME_NUM_ARRAY_SIZE 1000
341         u16 last_frame_num;
342         u16 *frame_num_array;
343         u16 *last_frame_num_array;
344         int frame_num_idx;
345         int dumped_frame_num_array;
346 #endif
347
348         struct list_head free_hc_list;
349         int periodic_channels;
350         int non_periodic_channels;
351         struct dwc2_host_chan *hc_ptr_array[MAX_EPS_CHANNELS];
352         u8 *status_buf;
353         dma_addr_t status_buf_dma;
354 #define DWC2_HCD_STATUS_BUF_SIZE 64
355
356         struct delayed_work start_work;
357         struct delayed_work reset_work;
358         spinlock_t lock;
359         void *priv;
360         u8 otg_port;
361         u32 *frame_list;
362         dma_addr_t frame_list_dma;
363
364         /* DWC OTG HW Release versions */
365 #define DWC2_CORE_REV_2_71a     0x4f54271a
366 #define DWC2_CORE_REV_2_90a     0x4f54290a
367 #define DWC2_CORE_REV_2_92a     0x4f54292a
368 #define DWC2_CORE_REV_2_94a     0x4f54294a
369 #define DWC2_CORE_REV_3_00a     0x4f54300a
370
371 #ifdef DEBUG
372         u32 frrem_samples;
373         u64 frrem_accum;
374
375         u32 hfnum_7_samples_a;
376         u64 hfnum_7_frrem_accum_a;
377         u32 hfnum_0_samples_a;
378         u64 hfnum_0_frrem_accum_a;
379         u32 hfnum_other_samples_a;
380         u64 hfnum_other_frrem_accum_a;
381
382         u32 hfnum_7_samples_b;
383         u64 hfnum_7_frrem_accum_b;
384         u32 hfnum_0_samples_b;
385         u64 hfnum_0_frrem_accum_b;
386         u32 hfnum_other_samples_b;
387         u64 hfnum_other_frrem_accum_b;
388 #endif
389 };
390
391 /* Reasons for halting a host channel */
392 enum dwc2_halt_status {
393         DWC2_HC_XFER_NO_HALT_STATUS,
394         DWC2_HC_XFER_COMPLETE,
395         DWC2_HC_XFER_URB_COMPLETE,
396         DWC2_HC_XFER_ACK,
397         DWC2_HC_XFER_NAK,
398         DWC2_HC_XFER_NYET,
399         DWC2_HC_XFER_STALL,
400         DWC2_HC_XFER_XACT_ERR,
401         DWC2_HC_XFER_FRAME_OVERRUN,
402         DWC2_HC_XFER_BABBLE_ERR,
403         DWC2_HC_XFER_DATA_TOGGLE_ERR,
404         DWC2_HC_XFER_AHB_ERR,
405         DWC2_HC_XFER_PERIODIC_INCOMPLETE,
406         DWC2_HC_XFER_URB_DEQUEUE,
407 };
408
409 /*
410  * The following functions support initialization of the core driver component
411  * and the DWC_otg controller
412  */
413 extern void dwc2_core_host_init(struct dwc2_hsotg *hsotg);
414
415 /*
416  * Host core Functions.
417  * The following functions support managing the DWC_otg controller in host
418  * mode.
419  */
420 extern void dwc2_hc_init(struct dwc2_hsotg *hsotg, struct dwc2_host_chan *chan);
421 extern void dwc2_hc_halt(struct dwc2_hsotg *hsotg, struct dwc2_host_chan *chan,
422                          enum dwc2_halt_status halt_status);
423 extern void dwc2_hc_cleanup(struct dwc2_hsotg *hsotg,
424                             struct dwc2_host_chan *chan);
425 extern void dwc2_hc_start_transfer(struct dwc2_hsotg *hsotg,
426                                    struct dwc2_host_chan *chan);
427 extern void dwc2_hc_start_transfer_ddma(struct dwc2_hsotg *hsotg,
428                                         struct dwc2_host_chan *chan);
429 extern int dwc2_hc_continue_transfer(struct dwc2_hsotg *hsotg,
430                                      struct dwc2_host_chan *chan);
431 extern void dwc2_hc_do_ping(struct dwc2_hsotg *hsotg,
432                             struct dwc2_host_chan *chan);
433 extern void dwc2_enable_host_interrupts(struct dwc2_hsotg *hsotg);
434 extern void dwc2_disable_host_interrupts(struct dwc2_hsotg *hsotg);
435
436 extern u32 dwc2_calc_frame_interval(struct dwc2_hsotg *hsotg);
437 extern int dwc2_check_core_status(struct dwc2_hsotg *hsotg);
438
439 /*
440  * Common core Functions.
441  * The following functions support managing the DWC_otg controller in either
442  * device or host mode.
443  */
444 extern void dwc2_read_packet(struct dwc2_hsotg *hsotg, u8 *dest, u16 bytes);
445 extern void dwc2_flush_tx_fifo(struct dwc2_hsotg *hsotg, const int num);
446 extern void dwc2_flush_rx_fifo(struct dwc2_hsotg *hsotg);
447
448 extern int dwc2_core_init(struct dwc2_hsotg *hsotg, bool select_phy, int irq);
449 extern void dwc2_enable_global_interrupts(struct dwc2_hsotg *hcd);
450 extern void dwc2_disable_global_interrupts(struct dwc2_hsotg *hcd);
451
452 /* This function should be called on every hardware interrupt. */
453 extern irqreturn_t dwc2_handle_common_intr(int irq, void *dev);
454
455 /* OTG Core Parameters */
456
457 /*
458  * Specifies the OTG capabilities. The driver will automatically
459  * detect the value for this parameter if none is specified.
460  * 0 - HNP and SRP capable (default)
461  * 1 - SRP Only capable
462  * 2 - No HNP/SRP capable
463  */
464 extern int dwc2_set_param_otg_cap(struct dwc2_hsotg *hsotg, int val);
465 #define DWC2_CAP_PARAM_HNP_SRP_CAPABLE          0
466 #define DWC2_CAP_PARAM_SRP_ONLY_CAPABLE         1
467 #define DWC2_CAP_PARAM_NO_HNP_SRP_CAPABLE       2
468
469 /*
470  * Specifies whether to use slave or DMA mode for accessing the data
471  * FIFOs. The driver will automatically detect the value for this
472  * parameter if none is specified.
473  * 0 - Slave
474  * 1 - DMA (default, if available)
475  */
476 extern int dwc2_set_param_dma_enable(struct dwc2_hsotg *hsotg, int val);
477
478 /*
479  * When DMA mode is enabled specifies whether to use
480  * address DMA or DMA Descritor mode for accessing the data
481  * FIFOs in device mode. The driver will automatically detect
482  * the value for this parameter if none is specified.
483  * 0 - address DMA
484  * 1 - DMA Descriptor(default, if available)
485  */
486 extern int dwc2_set_param_dma_desc_enable(struct dwc2_hsotg *hsotg, int val);
487
488 /*
489  * Specifies the maximum speed of operation in host and device mode.
490  * The actual speed depends on the speed of the attached device and
491  * the value of phy_type. The actual speed depends on the speed of the
492  * attached device.
493  * 0 - High Speed (default)
494  * 1 - Full Speed
495  */
496 extern int dwc2_set_param_speed(struct dwc2_hsotg *hsotg, int val);
497 #define DWC2_SPEED_PARAM_HIGH   0
498 #define DWC2_SPEED_PARAM_FULL   1
499
500 /*
501  * Specifies whether low power mode is supported when attached
502  * to a Full Speed or Low Speed device in host mode.
503  *
504  * 0 - Don't support low power mode (default)
505  * 1 - Support low power mode
506  */
507 extern int dwc2_set_param_host_support_fs_ls_low_power(struct dwc2_hsotg *hsotg,
508                                                        int val);
509
510 /*
511  * Specifies the PHY clock rate in low power mode when connected to a
512  * Low Speed device in host mode. This parameter is applicable only if
513  * HOST_SUPPORT_FS_LS_LOW_POWER is enabled. If PHY_TYPE is set to FS
514  * then defaults to 6 MHZ otherwise 48 MHZ.
515  *
516  * 0 - 48 MHz
517  * 1 - 6 MHz
518  */
519 extern int dwc2_set_param_host_ls_low_power_phy_clk(struct dwc2_hsotg *hsotg,
520                                                     int val);
521 #define DWC2_HOST_LS_LOW_POWER_PHY_CLK_PARAM_48MHZ      0
522 #define DWC2_HOST_LS_LOW_POWER_PHY_CLK_PARAM_6MHZ       1
523
524 /*
525  * 0 - Use cC FIFO size parameters
526  * 1 - Allow dynamic FIFO sizing (default)
527  */
528 extern int dwc2_set_param_enable_dynamic_fifo(struct dwc2_hsotg *hsotg,
529                                               int val);
530
531 /*
532  * Number of 4-byte words in the Rx FIFO in host mode when dynamic
533  * FIFO sizing is enabled.
534  * 16 to 32768 (default 1024)
535  */
536 extern int dwc2_set_param_host_rx_fifo_size(struct dwc2_hsotg *hsotg, int val);
537
538 /*
539  * Number of 4-byte words in the non-periodic Tx FIFO in host mode
540  * when Dynamic FIFO sizing is enabled in the core.
541  * 16 to 32768 (default 256)
542  */
543 extern int dwc2_set_param_host_nperio_tx_fifo_size(struct dwc2_hsotg *hsotg,
544                                                    int val);
545
546 /*
547  * Number of 4-byte words in the host periodic Tx FIFO when dynamic
548  * FIFO sizing is enabled.
549  * 16 to 32768 (default 256)
550  */
551 extern int dwc2_set_param_host_perio_tx_fifo_size(struct dwc2_hsotg *hsotg,
552                                                   int val);
553
554 /*
555  * The maximum transfer size supported in bytes.
556  * 2047 to 65,535  (default 65,535)
557  */
558 extern int dwc2_set_param_max_transfer_size(struct dwc2_hsotg *hsotg, int val);
559
560 /*
561  * The maximum number of packets in a transfer.
562  * 15 to 511  (default 511)
563  */
564 extern int dwc2_set_param_max_packet_count(struct dwc2_hsotg *hsotg, int val);
565
566 /*
567  * The number of host channel registers to use.
568  * 1 to 16 (default 11)
569  * Note: The FPGA configuration supports a maximum of 11 host channels.
570  */
571 extern int dwc2_set_param_host_channels(struct dwc2_hsotg *hsotg, int val);
572
573 /*
574  * Specifies the type of PHY interface to use. By default, the driver
575  * will automatically detect the phy_type.
576  *
577  * 0 - Full Speed PHY
578  * 1 - UTMI+ (default)
579  * 2 - ULPI
580  */
581 extern int dwc2_set_param_phy_type(struct dwc2_hsotg *hsotg, int val);
582 #define DWC2_PHY_TYPE_PARAM_FS          0
583 #define DWC2_PHY_TYPE_PARAM_UTMI        1
584 #define DWC2_PHY_TYPE_PARAM_ULPI        2
585
586 /*
587  * Specifies the UTMI+ Data Width. This parameter is
588  * applicable for a PHY_TYPE of UTMI+ or ULPI. (For a ULPI
589  * PHY_TYPE, this parameter indicates the data width between
590  * the MAC and the ULPI Wrapper.) Also, this parameter is
591  * applicable only if the OTG_HSPHY_WIDTH cC parameter was set
592  * to "8 and 16 bits", meaning that the core has been
593  * configured to work at either data path width.
594  *
595  * 8 or 16 bits (default 16)
596  */
597 extern int dwc2_set_param_phy_utmi_width(struct dwc2_hsotg *hsotg, int val);
598
599 /*
600  * Specifies whether the ULPI operates at double or single
601  * data rate. This parameter is only applicable if PHY_TYPE is
602  * ULPI.
603  *
604  * 0 - single data rate ULPI interface with 8 bit wide data
605  * bus (default)
606  * 1 - double data rate ULPI interface with 4 bit wide data
607  * bus
608  */
609 extern int dwc2_set_param_phy_ulpi_ddr(struct dwc2_hsotg *hsotg, int val);
610
611 /*
612  * Specifies whether to use the internal or external supply to
613  * drive the vbus with a ULPI phy.
614  */
615 extern int dwc2_set_param_phy_ulpi_ext_vbus(struct dwc2_hsotg *hsotg, int val);
616 #define DWC2_PHY_ULPI_INTERNAL_VBUS     0
617 #define DWC2_PHY_ULPI_EXTERNAL_VBUS     1
618
619 /*
620  * Specifies whether to use the I2Cinterface for full speed PHY. This
621  * parameter is only applicable if PHY_TYPE is FS.
622  * 0 - No (default)
623  * 1 - Yes
624  */
625 extern int dwc2_set_param_i2c_enable(struct dwc2_hsotg *hsotg, int val);
626
627 extern int dwc2_set_param_ulpi_fs_ls(struct dwc2_hsotg *hsotg, int val);
628
629 extern int dwc2_set_param_ts_dline(struct dwc2_hsotg *hsotg, int val);
630
631 /*
632  * Specifies whether dedicated transmit FIFOs are
633  * enabled for non periodic IN endpoints in device mode
634  * 0 - No
635  * 1 - Yes
636  */
637 extern int dwc2_set_param_en_multiple_tx_fifo(struct dwc2_hsotg *hsotg,
638                                               int val);
639
640 extern int dwc2_set_param_reload_ctl(struct dwc2_hsotg *hsotg, int val);
641
642 extern int dwc2_set_param_ahb_single(struct dwc2_hsotg *hsotg, int val);
643
644 extern int dwc2_set_param_otg_ver(struct dwc2_hsotg *hsotg, int val);
645
646 /*
647  * Dump core registers and SPRAM
648  */
649 extern void dwc2_dump_dev_registers(struct dwc2_hsotg *hsotg);
650 extern void dwc2_dump_host_registers(struct dwc2_hsotg *hsotg);
651 extern void dwc2_dump_global_registers(struct dwc2_hsotg *hsotg);
652
653 /*
654  * Return OTG version - either 1.3 or 2.0
655  */
656 extern u16 dwc2_get_otg_version(struct dwc2_hsotg *hsotg);
657
658 #endif /* __DWC2_CORE_H__ */