1 /*****************************************************************************
2 ** FILE NAME : ifxusb_cif.h
3 ** PROJECT : IFX USB sub-system V3
4 ** MODULES : IFX USB sub-system Host and Device driver
7 ** AUTHOR : Chen, Howard
8 ** DESCRIPTION : The Core Interface provides basic services for accessing and
9 ** managing the IFX USB hardware. These services are used by both the
10 ** Host Controller Driver and the Peripheral Controller Driver.
13 ** REFERENCE : Synopsys DWC-OTG Driver 2.7
14 ** COPYRIGHT : Copyright (c) 2010
15 ** LANTIQ DEUTSCHLAND GMBH,
16 ** Am Campeon 3, 85579 Neubiberg, Germany
18 ** This program is free software; you can redistribute it and/or modify
19 ** it under the terms of the GNU General Public License as published by
20 ** the Free Software Foundation; either version 2 of the License, or
21 ** (at your option) any later version.
23 ** Version Control Section **
27 ** $Log$ Revision history
28 *****************************************************************************/
31 * This file contains code fragments from Synopsys HS OTG Linux Software Driver.
32 * For this code the following notice is applicable:
34 * ==========================================================================
36 * Synopsys HS OTG Linux Software Driver and documentation (hereinafter,
37 * "Software") is an Unsupported proprietary work of Synopsys, Inc. unless
38 * otherwise expressly agreed to in writing between Synopsys and you.
40 * The Software IS NOT an item of Licensed Software or Licensed Product under
41 * any End User Software License Agreement or Agreement for Licensed Product
42 * with Synopsys or any supplement thereto. You are permitted to use and
43 * redistribute this Software in source and binary forms, with or without
44 * modification, provided that redistributions of source code must retain this
45 * notice. You may not view, use, disclose, copy or distribute this file or
46 * any information contained herein except pursuant to this license grant from
47 * Synopsys. If you do not agree with this notice, including the disclaimer
48 * below, then you are not authorized to use the Software.
50 * THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS" BASIS
51 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
52 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
53 * ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS BE LIABLE FOR ANY DIRECT,
54 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
55 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
56 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
57 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
58 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
59 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
61 * ========================================================================== */
64 \defgroup IFXUSB_DRIVER_V3 IFX USB SS Project
65 \brief IFX USB subsystem V3.x
69 \defgroup IFXUSB_CIF Core Interface APIs
70 \ingroup IFXUSB_DRIVER_V3
71 \brief The Core Interface provides basic services for accessing and
72 managing the IFXUSB hardware. These services are used by both the
73 Host Controller Driver and the Peripheral Controller Driver.
79 \ingroup IFXUSB_DRIVER_V3
80 \brief This file contains the interface to the IFX USB Core.
83 #if !defined(__IFXUSB_CIF_H__)
84 #define __IFXUSB_CIF_H__
86 #include <linux/workqueue.h>
88 #include <linux/version.h>
89 #include <asm/param.h>
91 #include "ifxusb_plat.h"
92 #include "ifxusb_regs.h"
95 #include "linux/timer.h"
98 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
100 #define IFXUSB_PARAM_SPEED_HIGH 0 /*!< Build stage parameter: High Speed */
101 #define IFXUSB_PARAM_SPEED_FULL 1 /*!< Build stage parameter: Full Speed */
103 #define IFXUSB_EP_SPEED_LOW 0 /*!< Run-Time Status: High Speed */
104 #define IFXUSB_EP_SPEED_FULL 1 /*!< Run-Time Status: Full Speed */
105 #define IFXUSB_EP_SPEED_HIGH 2 /*!< Run-Time Status: Low Speed */
107 #define IFXUSB_EP_TYPE_CTRL 0 /*!< Run-Time Status: CTRL */
108 #define IFXUSB_EP_TYPE_ISOC 1 /*!< Run-Time Status: ISOC */
109 #define IFXUSB_EP_TYPE_BULK 2 /*!< Run-Time Status: BULK */
110 #define IFXUSB_EP_TYPE_INTR 3 /*!< Run-Time Status: INTR */
112 #define IFXUSB_HC_PID_DATA0 0 /*!< Run-Time Data Toggle: Data 0 */
113 #define IFXUSB_HC_PID_DATA2 1 /*!< Run-Time Data Toggle: Data 2 */
114 #define IFXUSB_HC_PID_DATA1 2 /*!< Run-Time Data Toggle: Data 1 */
115 #define IFXUSB_HC_PID_MDATA 3 /*!< Run-Time Data Toggle: MData */
116 #define IFXUSB_HC_PID_SETUP 3 /*!< Run-Time Data Toggle: Setup */
120 \addtogroup IFXUSB_CIF
124 /*! typedef ifxusb_params_t
125 \brief IFXUSB Parameters structure.
126 This structure is used for both importing from insmod stage and run-time storage.
127 These parameters define how the IFXUSB controller should be configured.
129 typedef struct ifxusb_params
131 int32_t dma_burst_size; /*!< The DMA Burst size (applicable only for Internal DMA
132 Mode). 0(for single), 1(incr), 4(incr4), 8(incr8) 16(incr16)
134 /* Translate this to GAHBCFG values */
135 int32_t speed; /*!< Specifies the maximum speed of operation in host and device mode.
136 The actual speed depends on the speed of the attached device and
137 the value of phy_type. The actual speed depends on the speed of the
139 0 - High Speed (default)
143 int32_t data_fifo_size; /*!< Total number of dwords in the data FIFO memory. This
144 memory includes the Rx FIFO, non-periodic Tx FIFO, and periodic
149 int32_t rx_fifo_size; /*!< Number of dwords in the Rx FIFO in device mode.
154 int32_t tx_fifo_size[MAX_EPS_CHANNELS]; /*!< Number of dwords in each of the Tx FIFOs in device mode.
158 int32_t thr_ctl; /*!< Threshold control on/off */
159 int32_t tx_thr_length; /*!< Threshold length for Tx */
160 int32_t rx_thr_length; /*!< Threshold length for Rx*/
163 int32_t host_channels; /*!< The number of host channel registers to use.
167 int32_t rx_fifo_size; /*!< Number of dwords in the Rx FIFO in host mode.
171 int32_t nperio_tx_fifo_size;/*!< Number of dwords in the non-periodic Tx FIFO in host mode.
175 int32_t perio_tx_fifo_size; /*!< Number of dwords in the host periodic Tx FIFO.
180 int32_t max_transfer_size; /*!< The maximum transfer size supported in bytes.
184 int32_t max_packet_count; /*!< The maximum number of packets in a transfer.
185 15 to 511 (default 511)
187 int32_t phy_utmi_width; /*!< Specifies the UTMI+ Data Width.
188 8 or 16 bits (default 16)
191 int32_t turn_around_time_hs; /*!< Specifies the Turn-Around time at HS*/
192 int32_t turn_around_time_fs; /*!< Specifies the Turn-Around time at FS*/
194 int32_t timeout_cal_hs; /*!< Specifies the Timeout_Calibration at HS*/
195 int32_t timeout_cal_fs; /*!< Specifies the Timeout_Calibration at FS*/
198 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
199 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
201 /*! typedef ifxusb_core_if_t
202 \brief The ifx_core_if structure contains information needed to manage
203 the IFX USB controller acting in either host or device mode. It
204 represents the programming view of the controller as a whole.
206 typedef struct ifxusb_core_if
208 ifxusb_params_t params; /*!< Run-time Parameters */
210 uint8_t core_no; /*!< core number (used as id when multi-core case */
211 char *core_name; /*!< core name used for registration and informative purpose*/
212 int irq; /*!< irq number this core is hooked */
214 /*****************************************************************
215 * Structures and pointers to physical register interface.
216 *****************************************************************/
217 /** Core Global registers starting at offset 000h. */
218 ifxusb_core_global_regs_t *core_global_regs; /*!< pointer to Core Global Registers, offset at 000h */
220 /** Host-specific registers */
222 /** Host Global Registers starting at offset 400h.*/
223 ifxusb_host_global_regs_t *host_global_regs; /*!< pointer to Host Global Registers, offset at 400h */
224 #define IFXUSB_HOST_GLOBAL_REG_OFFSET 0x400
225 /** Host Port 0 Control and Status Register */
226 volatile uint32_t *hprt0; /*!< pointer to HPRT0 Registers, offset at 440h */
227 #define IFXUSB_HOST_PORT_REGS_OFFSET 0x440
228 /** Host Channel Specific Registers at offsets 500h-5FCh. */
229 ifxusb_hc_regs_t *hc_regs[MAX_EPS_CHANNELS]; /*!< pointer to Host-Channel n Registers, offset at 500h */
230 #define IFXUSB_HOST_CHAN_REGS_OFFSET 0x500
231 #define IFXUSB_CHAN_REGS_OFFSET 0x20
234 /** Device-specific registers */
236 /** Device Global Registers starting at offset 800h */
237 ifxusb_device_global_regs_t *dev_global_regs; /*!< pointer to Device Global Registers, offset at 800h */
238 #define IFXUSB_DEV_GLOBAL_REG_OFFSET 0x800
240 /** Device Logical IN Endpoint-Specific Registers 900h-AFCh */
241 ifxusb_dev_in_ep_regs_t *in_ep_regs[MAX_EPS_CHANNELS]; /*!< pointer to Device IN-EP Registers, offset at 900h */
242 #define IFXUSB_DEV_IN_EP_REG_OFFSET 0x900
243 #define IFXUSB_EP_REG_OFFSET 0x20
244 /** Device Logical OUT Endpoint-Specific Registers B00h-CFCh */
245 ifxusb_dev_out_ep_regs_t *out_ep_regs[MAX_EPS_CHANNELS];/*!< pointer to Device OUT-EP Registers, offset at 900h */
246 #define IFXUSB_DEV_OUT_EP_REG_OFFSET 0xB00
249 /** Power and Clock Gating Control Register */
250 volatile uint32_t *pcgcctl; /*!< pointer to Power and Clock Gating Control Registers, offset at E00h */
251 #define IFXUSB_PCGCCTL_OFFSET 0xE00
253 /** Push/pop addresses for endpoints or host channels.*/
254 uint32_t *data_fifo[MAX_EPS_CHANNELS]; /*!< pointer to FIFO access windows, offset at 1000h */
255 #define IFXUSB_DATA_FIFO_OFFSET 0x1000
256 #define IFXUSB_DATA_FIFO_SIZE 0x1000
258 uint32_t *data_fifo_dbg; /*!< pointer to FIFO debug windows, offset at 1000h */
260 /** Hardware Configuration -- stored here for convenience.*/
261 hwcfg1_data_t hwcfg1; /*!< preserved Hardware Configuration 1 */
262 hwcfg2_data_t hwcfg2; /*!< preserved Hardware Configuration 2 */
263 hwcfg3_data_t hwcfg3; /*!< preserved Hardware Configuration 3 */
264 hwcfg4_data_t hwcfg4; /*!< preserved Hardware Configuration 3 */
265 uint32_t snpsid; /*!< preserved SNPSID */
267 /*****************************************************************
268 * Run-time informations.
269 *****************************************************************/
270 /* Set to 1 if the core PHY interface bits in USBCFG have been initialized. */
271 uint8_t phy_init_done; /*!< indicated PHY is initialized. */
274 uint8_t queuing_high_bandwidth; /*!< Host mode, Queueing High Bandwidth. */
277 #if defined(__UNALIGNED_BUF_ADJ__) || defined(__UNALIGNED_BUF_CHK__)
278 uint32_t unaligned_mask;
286 \fn void *ifxusb_alloc_buf(size_t size, int clear)
287 \brief This function is called to allocate buffer of specified size.
288 The allocated buffer is mapped into DMA accessable address.
289 \param size Size in BYTE to be allocated
290 \param clear 0: don't do clear after buffer allocated, other: do clear to zero
291 \return 0/NULL: Fail; uncached pointer of allocated buffer
295 extern void *ifxusb_alloc_buf_h(size_t size, int clear);
297 extern void *ifxusb_alloc_buf_d(size_t size, int clear);
302 \fn void ifxusb_free_buf(void *vaddr)
303 \brief This function is called to free allocated buffer.
304 \param vaddr the uncached pointer of the buffer
308 extern void ifxusb_free_buf_h(void *vaddr);
310 extern void ifxusb_free_buf_d(void *vaddr);
314 \fn int ifxusb_core_if_init(ifxusb_core_if_t *_core_if,
316 uint32_t _reg_base_addr,
317 uint32_t _fifo_base_addr,
318 uint32_t _fifo_dbg_addr)
319 \brief This function is called to initialize the IFXUSB CSR data
320 structures. The register addresses in the device and host
321 structures are initialized from the base address supplied by the
322 caller. The calling function must make the OS calls to get the
323 base address of the IFXUSB controller registers.
324 \param _core_if Pointer of core_if structure
325 \param _irq irq number
326 \param _reg_base_addr Base address of IFXUSB core registers
327 \param _fifo_base_addr Fifo base address
328 \param _fifo_dbg_addr Fifo debug address
333 extern int ifxusb_core_if_init_h(ifxusb_core_if_t *_core_if,
335 extern int ifxusb_core_if_init_d(ifxusb_core_if_t *_core_if,
338 uint32_t _reg_base_addr,
339 uint32_t _fifo_base_addr,
340 uint32_t _fifo_dbg_addr);
344 \fn void ifxusb_core_if_remove(ifxusb_core_if_t *_core_if)
345 \brief This function free the mapped address in the IFXUSB CSR data structures.
346 \param _core_if Pointer of core_if structure
350 extern void ifxusb_core_if_remove_h(ifxusb_core_if_t *_core_if);
352 extern void ifxusb_core_if_remove_d(ifxusb_core_if_t *_core_if);
356 \fn void ifxusb_enable_global_interrupts( ifxusb_core_if_t *_core_if )
357 \brief This function enbles the controller's Global Interrupt in the AHB Config register.
358 \param _core_if Pointer of core_if structure
361 extern void ifxusb_enable_global_interrupts_h( ifxusb_core_if_t *_core_if );
363 extern void ifxusb_enable_global_interrupts_d( ifxusb_core_if_t *_core_if );
367 \fn void ifxusb_disable_global_interrupts( ifxusb_core_if_t *_core_if )
368 \brief This function disables the controller's Global Interrupt in the AHB Config register.
369 \param _core_if Pointer of core_if structure
373 extern void ifxusb_disable_global_interrupts_h( ifxusb_core_if_t *_core_if );
375 extern void ifxusb_disable_global_interrupts_d( ifxusb_core_if_t *_core_if );
379 \fn void ifxusb_flush_tx_fifo( ifxusb_core_if_t *_core_if, const int _num )
380 \brief Flush a Tx FIFO.
381 \param _core_if Pointer of core_if structure
382 \param _num Tx FIFO to flush. ( 0x10 for ALL TX FIFO )
386 extern void ifxusb_flush_tx_fifo_h( ifxusb_core_if_t *_core_if, const int _num );
388 extern void ifxusb_flush_tx_fifo_d( ifxusb_core_if_t *_core_if, const int _num );
392 \fn void ifxusb_flush_rx_fifo( ifxusb_core_if_t *_core_if )
393 \brief Flush Rx FIFO.
394 \param _core_if Pointer of core_if structure
398 extern void ifxusb_flush_rx_fifo_h( ifxusb_core_if_t *_core_if );
400 extern void ifxusb_flush_rx_fifo_d( ifxusb_core_if_t *_core_if );
404 \fn void ifxusb_flush_both_fifo( ifxusb_core_if_t *_core_if )
405 \brief Flush ALL Rx and Tx FIFO.
406 \param _core_if Pointer of core_if structure
410 extern void ifxusb_flush_both_fifo_h( ifxusb_core_if_t *_core_if );
412 extern void ifxusb_flush_both_fifo_d( ifxusb_core_if_t *_core_if );
417 \fn int ifxusb_core_soft_reset(ifxusb_core_if_t *_core_if)
418 \brief Do core a soft reset of the core. Be careful with this because it
419 resets all the internal state machines of the core.
420 \param _core_if Pointer of core_if structure
424 extern int ifxusb_core_soft_reset_h(ifxusb_core_if_t *_core_if);
426 extern int ifxusb_core_soft_reset_d(ifxusb_core_if_t *_core_if);
431 \brief Turn on the USB Core Power
432 \param _core_if Pointer of core_if structure
436 extern void ifxusb_power_on_h (ifxusb_core_if_t *_core_if);
438 extern void ifxusb_power_on_d (ifxusb_core_if_t *_core_if);
442 \fn void ifxusb_power_off (ifxusb_core_if_t *_core_if)
443 \brief Turn off the USB Core Power
444 \param _core_if Pointer of core_if structure
448 extern void ifxusb_power_off_h (ifxusb_core_if_t *_core_if);
450 extern void ifxusb_power_off_d (ifxusb_core_if_t *_core_if);
454 \fn void ifxusb_phy_power_on (ifxusb_core_if_t *_core_if)
455 \brief Turn on the USB PHY Power
456 \param _core_if Pointer of core_if structure
460 extern void ifxusb_phy_power_on_h (ifxusb_core_if_t *_core_if);
462 extern void ifxusb_phy_power_on_d (ifxusb_core_if_t *_core_if);
467 \fn void ifxusb_phy_power_off (ifxusb_core_if_t *_core_if)
468 \brief Turn off the USB PHY Power
469 \param _core_if Pointer of core_if structure
473 extern void ifxusb_phy_power_off_h (ifxusb_core_if_t *_core_if);
475 extern void ifxusb_phy_power_off_d (ifxusb_core_if_t *_core_if);
479 \fn void ifxusb_hard_reset(ifxusb_core_if_t *_core_if)
480 \brief Reset on the USB Core RCU
481 \param _core_if Pointer of core_if structure
485 extern void ifxusb_hard_reset_h(ifxusb_core_if_t *_core_if);
487 extern void ifxusb_hard_reset_d(ifxusb_core_if_t *_core_if);
491 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
496 \fn void ifxusb_host_core_init(ifxusb_core_if_t *_core_if, ifxusb_params_t *_params)
497 \brief This function initializes the IFXUSB controller registers for Host mode.
498 This function flushes the Tx and Rx FIFOs and it flushes any entries in the
500 \param _core_if Pointer of core_if structure
501 \param _params parameters to be set
504 extern void ifxusb_host_core_init(ifxusb_core_if_t *_core_if, ifxusb_params_t *_params);
507 \fn void ifxusb_host_enable_interrupts(ifxusb_core_if_t *_core_if)
508 \brief This function enables the Host mode interrupts.
509 \param _core_if Pointer of core_if structure
512 extern void ifxusb_host_enable_interrupts(ifxusb_core_if_t *_core_if);
515 \fn void ifxusb_host_disable_interrupts(ifxusb_core_if_t *_core_if)
516 \brief This function disables the Host mode interrupts.
517 \param _core_if Pointer of core_if structure
520 extern void ifxusb_host_disable_interrupts(ifxusb_core_if_t *_core_if);
522 #if defined(__IS_TWINPASS__)
523 extern void ifxusb_enable_afe_oc(void);
527 \fn void ifxusb_vbus_init(ifxusb_core_if_t *_core_if)
528 \brief This function init the VBUS control.
529 \param _core_if Pointer of core_if structure
532 extern void ifxusb_vbus_init(ifxusb_core_if_t *_core_if);
535 \fn void ifxusb_vbus_free(ifxusb_core_if_t *_core_if)
536 \brief This function free the VBUS control.
537 \param _core_if Pointer of core_if structure
540 extern void ifxusb_vbus_free(ifxusb_core_if_t *_core_if);
543 \fn void ifxusb_vbus_on(ifxusb_core_if_t *_core_if)
544 \brief Turn on the USB 5V VBus Power
545 \param _core_if Pointer of core_if structure
548 extern void ifxusb_vbus_on(ifxusb_core_if_t *_core_if);
551 \fn void ifxusb_vbus_off(ifxusb_core_if_t *_core_if)
552 \brief Turn off the USB 5V VBus Power
553 \param _core_if Pointer of core_if structure
556 extern void ifxusb_vbus_off(ifxusb_core_if_t *_core_if);
559 \fn int ifxusb_vbus(ifxusb_core_if_t *_core_if)
560 \brief Read Current VBus status
561 \param _core_if Pointer of core_if structure
564 extern int ifxusb_vbus(ifxusb_core_if_t *_core_if);
567 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
572 \fn void ifxusb_dev_enable_interrupts(ifxusb_core_if_t *_core_if)
573 \brief This function enables the Device mode interrupts.
574 \param _core_if Pointer of core_if structure
577 extern void ifxusb_dev_enable_interrupts(ifxusb_core_if_t *_core_if);
580 \fn uint32_t ifxusb_dev_get_frame_number(ifxusb_core_if_t *_core_if)
581 \brief Gets the current USB frame number. This is the frame number from the last SOF packet.
582 \param _core_if Pointer of core_if structure
585 extern uint32_t ifxusb_dev_get_frame_number(ifxusb_core_if_t *_core_if);
588 \fn void ifxusb_dev_ep_set_stall(ifxusb_core_if_t *_core_if, uint8_t _epno, uint8_t _is_in)
589 \brief Set the EP STALL.
590 \param _core_if Pointer of core_if structure
591 \param _epno EP number
592 \param _is_in 1: is IN transfer
595 extern void ifxusb_dev_ep_set_stall(ifxusb_core_if_t *_core_if, uint8_t _epno, uint8_t _is_in);
598 \fn void ifxusb_dev_ep_clear_stall(ifxusb_core_if_t *_core_if, uint8_t _epno, uint8_t _ep_type, uint8_t _is_in)
599 \brief Set the EP STALL.
600 \param _core_if Pointer of core_if structure
601 \param _epno EP number
602 \param _ep_type EP Type
605 extern void ifxusb_dev_ep_clear_stall(ifxusb_core_if_t *_core_if, uint8_t _epno, uint8_t _ep_type, uint8_t _is_in);
608 \fn void ifxusb_dev_core_init(ifxusb_core_if_t *_core_if, ifxusb_params_t *_params)
609 \brief This function initializes the IFXUSB controller registers for Device mode.
610 This function flushes the Tx and Rx FIFOs and it flushes any entries in the
612 This function validate the imported parameters and store the result in the CIF structure.
614 \param _core_if Pointer of core_if structure
615 \param _params structure of inported parameters
618 extern void ifxusb_dev_core_init(ifxusb_core_if_t *_core_if, ifxusb_params_t *_params);
621 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
623 #if defined(__GADGET_LED__) || defined(__HOST_LED__)
625 \fn void ifxusb_led_init(ifxusb_core_if_t *_core_if)
626 \brief This function init the LED control.
627 \param _core_if Pointer of core_if structure
630 extern void ifxusb_led_init(ifxusb_core_if_t *_core_if);
633 \fn void ifxusb_led_free(ifxusb_core_if_t *_core_if)
634 \brief This function free the LED control.
635 \param _core_if Pointer of core_if structure
638 extern void ifxusb_led_free(ifxusb_core_if_t *_core_if);
641 \fn void ifxusb_led(ifxusb_core_if_t *_core_if)
642 \brief This function trigger the LED access.
643 \param _core_if Pointer of core_if structure
646 extern void ifxusb_led(ifxusb_core_if_t *_core_if);
649 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
651 /* internal routines for debugging */
653 extern void ifxusb_dump_msg_h(const u8 *buf, unsigned int length);
654 extern void ifxusb_dump_spram_h(ifxusb_core_if_t *_core_if);
655 extern void ifxusb_dump_registers_h(ifxusb_core_if_t *_core_if);
657 extern void ifxusb_dump_msg_d(const u8 *buf, unsigned int length);
658 extern void ifxusb_dump_spram_d(ifxusb_core_if_t *_core_if);
659 extern void ifxusb_dump_registers_d(ifxusb_core_if_t *_core_if);
662 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
664 static inline uint32_t ifxusb_read_core_intr(ifxusb_core_if_t *_core_if)
666 return (ifxusb_rreg(&_core_if->core_global_regs->gintsts) &
667 ifxusb_rreg(&_core_if->core_global_regs->gintmsk));
670 static inline uint32_t ifxusb_read_otg_intr (ifxusb_core_if_t *_core_if)
672 return (ifxusb_rreg (&_core_if->core_global_regs->gotgint));
675 static inline uint32_t ifxusb_mode(ifxusb_core_if_t *_core_if)
677 return (ifxusb_rreg( &_core_if->core_global_regs->gintsts ) & 0x1);
679 static inline uint8_t ifxusb_is_device_mode(ifxusb_core_if_t *_core_if)
681 return (ifxusb_mode(_core_if) != 1);
683 static inline uint8_t ifxusb_is_host_mode(ifxusb_core_if_t *_core_if)
685 return (ifxusb_mode(_core_if) == 1);
688 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
691 static inline uint32_t ifxusb_read_hprt0(ifxusb_core_if_t *_core_if)
694 hprt0.d32 = ifxusb_rreg(_core_if->hprt0);
696 hprt0.b.prtconndet = 0;
697 hprt0.b.prtenchng = 0;
698 hprt0.b.prtovrcurrchng = 0;
702 static inline uint32_t ifxusb_read_host_all_channels_intr (ifxusb_core_if_t *_core_if)
704 return (ifxusb_rreg (&_core_if->host_global_regs->haint));
707 static inline uint32_t ifxusb_read_host_channel_intr (ifxusb_core_if_t *_core_if, int hc_num)
709 return (ifxusb_rreg (&_core_if->hc_regs[hc_num]->hcint));
714 static inline uint32_t ifxusb_read_dev_all_in_ep_intr(ifxusb_core_if_t *_core_if)
717 v = ifxusb_rreg(&_core_if->dev_global_regs->daint) &
718 ifxusb_rreg(&_core_if->dev_global_regs->daintmsk);
722 static inline uint32_t ifxusb_read_dev_all_out_ep_intr(ifxusb_core_if_t *_core_if)
725 v = ifxusb_rreg(&_core_if->dev_global_regs->daint) &
726 ifxusb_rreg(&_core_if->dev_global_regs->daintmsk);
727 return ((v & 0xffff0000) >> 16);
730 static inline uint32_t ifxusb_read_dev_in_ep_intr(ifxusb_core_if_t *_core_if, int _ep_num)
733 v = ifxusb_rreg(&_core_if->in_ep_regs[_ep_num]->diepint) &
734 ifxusb_rreg(&_core_if->dev_global_regs->diepmsk);
738 static inline uint32_t ifxusb_read_dev_out_ep_intr(ifxusb_core_if_t *_core_if, int _ep_num)
741 v = ifxusb_rreg(&_core_if->out_ep_regs[_ep_num]->doepint) &
742 ifxusb_rreg(&_core_if->dev_global_regs->doepmsk);
749 extern void ifxusb_attr_create_h (void *_dev);
750 extern void ifxusb_attr_remove_h (void *_dev);
752 extern void ifxusb_attr_create_d (void *_dev);
753 extern void ifxusb_attr_remove_d (void *_dev);
757 extern void do_suspend_h(ifxusb_core_if_t *core_if);
758 extern void do_resume_h(ifxusb_core_if_t *_core_if);
760 extern void do_suspend_d(ifxusb_core_if_t *core_if);
761 extern void do_resume_d(ifxusb_core_if_t *_core_if);
764 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
766 #endif // !defined(__IFXUSB_CIF_H__)