staging: dwc2: add driver parameter to set AHB config register value
[firefly-linux-kernel-4.4.55.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  * @ahbcfg:             This field allows the default value of the GAHBCFG
154  *                      register to be overridden
155  *                       -1         - GAHBCFG value will not be overridden
156  *                       all others - GAHBCFG value will be overridden with
157  *                                    this value
158  * @otg_ver:            OTG version supported
159  *                       0 - 1.3
160  *                       1 - 2.0
161  *
162  * The following parameters may be specified when starting the module. These
163  * parameters define how the DWC_otg controller should be configured.
164  */
165 struct dwc2_core_params {
166         /*
167          * Don't add any non-int members here, this will break
168          * dwc2_set_all_params!
169          */
170         int otg_cap;
171         int otg_ver;
172         int dma_enable;
173         int dma_desc_enable;
174         int speed;
175         int enable_dynamic_fifo;
176         int en_multiple_tx_fifo;
177         int host_rx_fifo_size;
178         int host_nperio_tx_fifo_size;
179         int host_perio_tx_fifo_size;
180         int max_transfer_size;
181         int max_packet_count;
182         int host_channels;
183         int phy_type;
184         int phy_utmi_width;
185         int phy_ulpi_ddr;
186         int phy_ulpi_ext_vbus;
187         int i2c_enable;
188         int ulpi_fs_ls;
189         int host_support_fs_ls_low_power;
190         int host_ls_low_power_phy_clk;
191         int ts_dline;
192         int reload_ctl;
193         int ahbcfg;
194 };
195
196 /**
197  * struct dwc2_hsotg - Holds the state of the driver, including the non-periodic
198  * and periodic schedules
199  *
200  * @dev:                The struct device pointer
201  * @regs:               Pointer to controller regs
202  * @core_params:        Parameters that define how the core should be configured
203  * @hwcfg1:             Hardware Configuration - stored here for convenience
204  * @hwcfg2:             Hardware Configuration - stored here for convenience
205  * @hwcfg3:             Hardware Configuration - stored here for convenience
206  * @hwcfg4:             Hardware Configuration - stored here for convenience
207  * @hptxfsiz:           Hardware Configuration - stored here for convenience
208  * @snpsid:             Value from SNPSID register
209  * @total_fifo_size:    Total internal RAM for FIFOs (bytes)
210  * @rx_fifo_size:       Size of Rx FIFO (bytes)
211  * @nperio_tx_fifo_size: Size of Non-periodic Tx FIFO (Bytes)
212  * @op_state:           The operational State, during transitions (a_host=>
213  *                      a_peripheral and b_device=>b_host) this may not match
214  *                      the core, but allows the software to determine
215  *                      transitions
216  * @queuing_high_bandwidth: True if multiple packets of a high-bandwidth
217  *                      transfer are in process of being queued
218  * @srp_success:        Stores status of SRP request in the case of a FS PHY
219  *                      with an I2C interface
220  * @wq_otg:             Workqueue object used for handling of some interrupts
221  * @wf_otg:             Work object for handling Connector ID Status Change
222  *                      interrupt
223  * @wkp_timer:          Timer object for handling Wakeup Detected interrupt
224  * @lx_state:           Lx state of connected device
225  * @flags:              Flags for handling root port state changes
226  * @non_periodic_sched_inactive: Inactive QHs in the non-periodic schedule.
227  *                      Transfers associated with these QHs are not currently
228  *                      assigned to a host channel.
229  * @non_periodic_sched_active: Active QHs in the non-periodic schedule.
230  *                      Transfers associated with these QHs are currently
231  *                      assigned to a host channel.
232  * @non_periodic_qh_ptr: Pointer to next QH to process in the active
233  *                      non-periodic schedule
234  * @periodic_sched_inactive: Inactive QHs in the periodic schedule. This is a
235  *                      list of QHs for periodic transfers that are _not_
236  *                      scheduled for the next frame. Each QH in the list has an
237  *                      interval counter that determines when it needs to be
238  *                      scheduled for execution. This scheduling mechanism
239  *                      allows only a simple calculation for periodic bandwidth
240  *                      used (i.e. must assume that all periodic transfers may
241  *                      need to execute in the same frame). However, it greatly
242  *                      simplifies scheduling and should be sufficient for the
243  *                      vast majority of OTG hosts, which need to connect to a
244  *                      small number of peripherals at one time. Items move from
245  *                      this list to periodic_sched_ready when the QH interval
246  *                      counter is 0 at SOF.
247  * @periodic_sched_ready:  List of periodic QHs that are ready for execution in
248  *                      the next frame, but have not yet been assigned to host
249  *                      channels. Items move from this list to
250  *                      periodic_sched_assigned as host channels become
251  *                      available during the current frame.
252  * @periodic_sched_assigned: List of periodic QHs to be executed in the next
253  *                      frame that are assigned to host channels. Items move
254  *                      from this list to periodic_sched_queued as the
255  *                      transactions for the QH are queued to the DWC_otg
256  *                      controller.
257  * @periodic_sched_queued: List of periodic QHs that have been queued for
258  *                      execution. Items move from this list to either
259  *                      periodic_sched_inactive or periodic_sched_ready when the
260  *                      channel associated with the transfer is released. If the
261  *                      interval for the QH is 1, the item moves to
262  *                      periodic_sched_ready because it must be rescheduled for
263  *                      the next frame. Otherwise, the item moves to
264  *                      periodic_sched_inactive.
265  * @periodic_usecs:     Total bandwidth claimed so far for periodic transfers.
266  *                      This value is in microseconds per (micro)frame. The
267  *                      assumption is that all periodic transfers may occur in
268  *                      the same (micro)frame.
269  * @frame_number:       Frame number read from the core at SOF. The value ranges
270  *                      from 0 to HFNUM_MAX_FRNUM.
271  * @periodic_qh_count:  Count of periodic QHs, if using several eps. Used for
272  *                      SOF enable/disable.
273  * @free_hc_list:       Free host channels in the controller. This is a list of
274  *                      struct dwc2_host_chan items.
275  * @periodic_channels:  Number of host channels assigned to periodic transfers.
276  *                      Currently assuming that there is a dedicated host
277  *                      channel for each periodic transaction and at least one
278  *                      host channel is available for non-periodic transactions.
279  * @non_periodic_channels: Number of host channels assigned to non-periodic
280  *                      transfers
281  * @hc_ptr_array:       Array of pointers to the host channel descriptors.
282  *                      Allows accessing a host channel descriptor given the
283  *                      host channel number. This is useful in interrupt
284  *                      handlers.
285  * @status_buf:         Buffer used for data received during the status phase of
286  *                      a control transfer.
287  * @status_buf_dma:     DMA address for status_buf
288  * @start_work:         Delayed work for handling host A-cable connection
289  * @reset_work:         Delayed work for handling a port reset
290  * @lock:               Spinlock that protects all the driver data structures
291  * @priv:               Stores a pointer to the struct usb_hcd
292  * @otg_port:           OTG port number
293  * @frame_list:         Frame list
294  * @frame_list_dma:     Frame list DMA address
295  */
296 struct dwc2_hsotg {
297         struct device *dev;
298         void __iomem *regs;
299         struct dwc2_core_params *core_params;
300         u32 hwcfg1;
301         u32 hwcfg2;
302         u32 hwcfg3;
303         u32 hwcfg4;
304         u32 hptxfsiz;
305         u32 snpsid;
306         u16 total_fifo_size;
307         u16 rx_fifo_size;
308         u16 nperio_tx_fifo_size;
309         enum usb_otg_state op_state;
310
311         unsigned int queuing_high_bandwidth:1;
312         unsigned int srp_success:1;
313
314         struct workqueue_struct *wq_otg;
315         struct work_struct wf_otg;
316         struct timer_list wkp_timer;
317         enum dwc2_lx_state lx_state;
318
319         union dwc2_hcd_internal_flags {
320                 u32 d32;
321                 struct {
322                         unsigned port_connect_status_change:1;
323                         unsigned port_connect_status:1;
324                         unsigned port_reset_change:1;
325                         unsigned port_enable_change:1;
326                         unsigned port_suspend_change:1;
327                         unsigned port_over_current_change:1;
328                         unsigned port_l1_change:1;
329                         unsigned reserved:26;
330                 } b;
331         } flags;
332
333         struct list_head non_periodic_sched_inactive;
334         struct list_head non_periodic_sched_active;
335         struct list_head *non_periodic_qh_ptr;
336         struct list_head periodic_sched_inactive;
337         struct list_head periodic_sched_ready;
338         struct list_head periodic_sched_assigned;
339         struct list_head periodic_sched_queued;
340         u16 periodic_usecs;
341         u16 frame_number;
342         u16 periodic_qh_count;
343
344 #ifdef CONFIG_USB_DWC2_TRACK_MISSED_SOFS
345 #define FRAME_NUM_ARRAY_SIZE 1000
346         u16 last_frame_num;
347         u16 *frame_num_array;
348         u16 *last_frame_num_array;
349         int frame_num_idx;
350         int dumped_frame_num_array;
351 #endif
352
353         struct list_head free_hc_list;
354         int periodic_channels;
355         int non_periodic_channels;
356         struct dwc2_host_chan *hc_ptr_array[MAX_EPS_CHANNELS];
357         u8 *status_buf;
358         dma_addr_t status_buf_dma;
359 #define DWC2_HCD_STATUS_BUF_SIZE 64
360
361         struct delayed_work start_work;
362         struct delayed_work reset_work;
363         spinlock_t lock;
364         void *priv;
365         u8 otg_port;
366         u32 *frame_list;
367         dma_addr_t frame_list_dma;
368
369         /* DWC OTG HW Release versions */
370 #define DWC2_CORE_REV_2_71a     0x4f54271a
371 #define DWC2_CORE_REV_2_90a     0x4f54290a
372 #define DWC2_CORE_REV_2_92a     0x4f54292a
373 #define DWC2_CORE_REV_2_94a     0x4f54294a
374 #define DWC2_CORE_REV_3_00a     0x4f54300a
375
376 #ifdef DEBUG
377         u32 frrem_samples;
378         u64 frrem_accum;
379
380         u32 hfnum_7_samples_a;
381         u64 hfnum_7_frrem_accum_a;
382         u32 hfnum_0_samples_a;
383         u64 hfnum_0_frrem_accum_a;
384         u32 hfnum_other_samples_a;
385         u64 hfnum_other_frrem_accum_a;
386
387         u32 hfnum_7_samples_b;
388         u64 hfnum_7_frrem_accum_b;
389         u32 hfnum_0_samples_b;
390         u64 hfnum_0_frrem_accum_b;
391         u32 hfnum_other_samples_b;
392         u64 hfnum_other_frrem_accum_b;
393 #endif
394 };
395
396 /* Reasons for halting a host channel */
397 enum dwc2_halt_status {
398         DWC2_HC_XFER_NO_HALT_STATUS,
399         DWC2_HC_XFER_COMPLETE,
400         DWC2_HC_XFER_URB_COMPLETE,
401         DWC2_HC_XFER_ACK,
402         DWC2_HC_XFER_NAK,
403         DWC2_HC_XFER_NYET,
404         DWC2_HC_XFER_STALL,
405         DWC2_HC_XFER_XACT_ERR,
406         DWC2_HC_XFER_FRAME_OVERRUN,
407         DWC2_HC_XFER_BABBLE_ERR,
408         DWC2_HC_XFER_DATA_TOGGLE_ERR,
409         DWC2_HC_XFER_AHB_ERR,
410         DWC2_HC_XFER_PERIODIC_INCOMPLETE,
411         DWC2_HC_XFER_URB_DEQUEUE,
412 };
413
414 /*
415  * The following functions support initialization of the core driver component
416  * and the DWC_otg controller
417  */
418 extern void dwc2_core_host_init(struct dwc2_hsotg *hsotg);
419
420 /*
421  * Host core Functions.
422  * The following functions support managing the DWC_otg controller in host
423  * mode.
424  */
425 extern void dwc2_hc_init(struct dwc2_hsotg *hsotg, struct dwc2_host_chan *chan);
426 extern void dwc2_hc_halt(struct dwc2_hsotg *hsotg, struct dwc2_host_chan *chan,
427                          enum dwc2_halt_status halt_status);
428 extern void dwc2_hc_cleanup(struct dwc2_hsotg *hsotg,
429                             struct dwc2_host_chan *chan);
430 extern void dwc2_hc_start_transfer(struct dwc2_hsotg *hsotg,
431                                    struct dwc2_host_chan *chan);
432 extern void dwc2_hc_start_transfer_ddma(struct dwc2_hsotg *hsotg,
433                                         struct dwc2_host_chan *chan);
434 extern int dwc2_hc_continue_transfer(struct dwc2_hsotg *hsotg,
435                                      struct dwc2_host_chan *chan);
436 extern void dwc2_hc_do_ping(struct dwc2_hsotg *hsotg,
437                             struct dwc2_host_chan *chan);
438 extern void dwc2_enable_host_interrupts(struct dwc2_hsotg *hsotg);
439 extern void dwc2_disable_host_interrupts(struct dwc2_hsotg *hsotg);
440
441 extern u32 dwc2_calc_frame_interval(struct dwc2_hsotg *hsotg);
442 extern int dwc2_check_core_status(struct dwc2_hsotg *hsotg);
443
444 /*
445  * Common core Functions.
446  * The following functions support managing the DWC_otg controller in either
447  * device or host mode.
448  */
449 extern void dwc2_read_packet(struct dwc2_hsotg *hsotg, u8 *dest, u16 bytes);
450 extern void dwc2_flush_tx_fifo(struct dwc2_hsotg *hsotg, const int num);
451 extern void dwc2_flush_rx_fifo(struct dwc2_hsotg *hsotg);
452
453 extern int dwc2_core_init(struct dwc2_hsotg *hsotg, bool select_phy, int irq);
454 extern void dwc2_enable_global_interrupts(struct dwc2_hsotg *hcd);
455 extern void dwc2_disable_global_interrupts(struct dwc2_hsotg *hcd);
456
457 /* This function should be called on every hardware interrupt. */
458 extern irqreturn_t dwc2_handle_common_intr(int irq, void *dev);
459
460 /* OTG Core Parameters */
461
462 /*
463  * Specifies the OTG capabilities. The driver will automatically
464  * detect the value for this parameter if none is specified.
465  * 0 - HNP and SRP capable (default)
466  * 1 - SRP Only capable
467  * 2 - No HNP/SRP capable
468  */
469 extern int dwc2_set_param_otg_cap(struct dwc2_hsotg *hsotg, int val);
470 #define DWC2_CAP_PARAM_HNP_SRP_CAPABLE          0
471 #define DWC2_CAP_PARAM_SRP_ONLY_CAPABLE         1
472 #define DWC2_CAP_PARAM_NO_HNP_SRP_CAPABLE       2
473
474 /*
475  * Specifies whether to use slave or DMA mode for accessing the data
476  * FIFOs. The driver will automatically detect the value for this
477  * parameter if none is specified.
478  * 0 - Slave
479  * 1 - DMA (default, if available)
480  */
481 extern int dwc2_set_param_dma_enable(struct dwc2_hsotg *hsotg, int val);
482
483 /*
484  * When DMA mode is enabled specifies whether to use
485  * address DMA or DMA Descritor mode for accessing the data
486  * FIFOs in device mode. The driver will automatically detect
487  * the value for this parameter if none is specified.
488  * 0 - address DMA
489  * 1 - DMA Descriptor(default, if available)
490  */
491 extern int dwc2_set_param_dma_desc_enable(struct dwc2_hsotg *hsotg, int val);
492
493 /*
494  * Specifies the maximum speed of operation in host and device mode.
495  * The actual speed depends on the speed of the attached device and
496  * the value of phy_type. The actual speed depends on the speed of the
497  * attached device.
498  * 0 - High Speed (default)
499  * 1 - Full Speed
500  */
501 extern int dwc2_set_param_speed(struct dwc2_hsotg *hsotg, int val);
502 #define DWC2_SPEED_PARAM_HIGH   0
503 #define DWC2_SPEED_PARAM_FULL   1
504
505 /*
506  * Specifies whether low power mode is supported when attached
507  * to a Full Speed or Low Speed device in host mode.
508  *
509  * 0 - Don't support low power mode (default)
510  * 1 - Support low power mode
511  */
512 extern int dwc2_set_param_host_support_fs_ls_low_power(struct dwc2_hsotg *hsotg,
513                                                        int val);
514
515 /*
516  * Specifies the PHY clock rate in low power mode when connected to a
517  * Low Speed device in host mode. This parameter is applicable only if
518  * HOST_SUPPORT_FS_LS_LOW_POWER is enabled. If PHY_TYPE is set to FS
519  * then defaults to 6 MHZ otherwise 48 MHZ.
520  *
521  * 0 - 48 MHz
522  * 1 - 6 MHz
523  */
524 extern int dwc2_set_param_host_ls_low_power_phy_clk(struct dwc2_hsotg *hsotg,
525                                                     int val);
526 #define DWC2_HOST_LS_LOW_POWER_PHY_CLK_PARAM_48MHZ      0
527 #define DWC2_HOST_LS_LOW_POWER_PHY_CLK_PARAM_6MHZ       1
528
529 /*
530  * 0 - Use cC FIFO size parameters
531  * 1 - Allow dynamic FIFO sizing (default)
532  */
533 extern int dwc2_set_param_enable_dynamic_fifo(struct dwc2_hsotg *hsotg,
534                                               int val);
535
536 /*
537  * Number of 4-byte words in the Rx FIFO in host mode when dynamic
538  * FIFO sizing is enabled.
539  * 16 to 32768 (default 1024)
540  */
541 extern int dwc2_set_param_host_rx_fifo_size(struct dwc2_hsotg *hsotg, int val);
542
543 /*
544  * Number of 4-byte words in the non-periodic Tx FIFO in host mode
545  * when Dynamic FIFO sizing is enabled in the core.
546  * 16 to 32768 (default 256)
547  */
548 extern int dwc2_set_param_host_nperio_tx_fifo_size(struct dwc2_hsotg *hsotg,
549                                                    int val);
550
551 /*
552  * Number of 4-byte words in the host periodic Tx FIFO when dynamic
553  * FIFO sizing is enabled.
554  * 16 to 32768 (default 256)
555  */
556 extern int dwc2_set_param_host_perio_tx_fifo_size(struct dwc2_hsotg *hsotg,
557                                                   int val);
558
559 /*
560  * The maximum transfer size supported in bytes.
561  * 2047 to 65,535  (default 65,535)
562  */
563 extern int dwc2_set_param_max_transfer_size(struct dwc2_hsotg *hsotg, int val);
564
565 /*
566  * The maximum number of packets in a transfer.
567  * 15 to 511  (default 511)
568  */
569 extern int dwc2_set_param_max_packet_count(struct dwc2_hsotg *hsotg, int val);
570
571 /*
572  * The number of host channel registers to use.
573  * 1 to 16 (default 11)
574  * Note: The FPGA configuration supports a maximum of 11 host channels.
575  */
576 extern int dwc2_set_param_host_channels(struct dwc2_hsotg *hsotg, int val);
577
578 /*
579  * Specifies the type of PHY interface to use. By default, the driver
580  * will automatically detect the phy_type.
581  *
582  * 0 - Full Speed PHY
583  * 1 - UTMI+ (default)
584  * 2 - ULPI
585  */
586 extern int dwc2_set_param_phy_type(struct dwc2_hsotg *hsotg, int val);
587 #define DWC2_PHY_TYPE_PARAM_FS          0
588 #define DWC2_PHY_TYPE_PARAM_UTMI        1
589 #define DWC2_PHY_TYPE_PARAM_ULPI        2
590
591 /*
592  * Specifies the UTMI+ Data Width. This parameter is
593  * applicable for a PHY_TYPE of UTMI+ or ULPI. (For a ULPI
594  * PHY_TYPE, this parameter indicates the data width between
595  * the MAC and the ULPI Wrapper.) Also, this parameter is
596  * applicable only if the OTG_HSPHY_WIDTH cC parameter was set
597  * to "8 and 16 bits", meaning that the core has been
598  * configured to work at either data path width.
599  *
600  * 8 or 16 bits (default 16)
601  */
602 extern int dwc2_set_param_phy_utmi_width(struct dwc2_hsotg *hsotg, int val);
603
604 /*
605  * Specifies whether the ULPI operates at double or single
606  * data rate. This parameter is only applicable if PHY_TYPE is
607  * ULPI.
608  *
609  * 0 - single data rate ULPI interface with 8 bit wide data
610  * bus (default)
611  * 1 - double data rate ULPI interface with 4 bit wide data
612  * bus
613  */
614 extern int dwc2_set_param_phy_ulpi_ddr(struct dwc2_hsotg *hsotg, int val);
615
616 /*
617  * Specifies whether to use the internal or external supply to
618  * drive the vbus with a ULPI phy.
619  */
620 extern int dwc2_set_param_phy_ulpi_ext_vbus(struct dwc2_hsotg *hsotg, int val);
621 #define DWC2_PHY_ULPI_INTERNAL_VBUS     0
622 #define DWC2_PHY_ULPI_EXTERNAL_VBUS     1
623
624 /*
625  * Specifies whether to use the I2Cinterface for full speed PHY. This
626  * parameter is only applicable if PHY_TYPE is FS.
627  * 0 - No (default)
628  * 1 - Yes
629  */
630 extern int dwc2_set_param_i2c_enable(struct dwc2_hsotg *hsotg, int val);
631
632 extern int dwc2_set_param_ulpi_fs_ls(struct dwc2_hsotg *hsotg, int val);
633
634 extern int dwc2_set_param_ts_dline(struct dwc2_hsotg *hsotg, int val);
635
636 /*
637  * Specifies whether dedicated transmit FIFOs are
638  * enabled for non periodic IN endpoints in device mode
639  * 0 - No
640  * 1 - Yes
641  */
642 extern int dwc2_set_param_en_multiple_tx_fifo(struct dwc2_hsotg *hsotg,
643                                               int val);
644
645 extern int dwc2_set_param_reload_ctl(struct dwc2_hsotg *hsotg, int val);
646
647 extern int dwc2_set_param_ahbcfg(struct dwc2_hsotg *hsotg, int val);
648
649 extern int dwc2_set_param_otg_ver(struct dwc2_hsotg *hsotg, int val);
650
651 /*
652  * Dump core registers and SPRAM
653  */
654 extern void dwc2_dump_dev_registers(struct dwc2_hsotg *hsotg);
655 extern void dwc2_dump_host_registers(struct dwc2_hsotg *hsotg);
656 extern void dwc2_dump_global_registers(struct dwc2_hsotg *hsotg);
657
658 /*
659  * Return OTG version - either 1.3 or 2.0
660  */
661 extern u16 dwc2_get_otg_version(struct dwc2_hsotg *hsotg);
662
663 #endif /* __DWC2_CORE_H__ */