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