/***************************************************************************** ** FILE NAME : dwc_otg_plat.h ** PROJECT : USB Host and Device driver ** MODULES : USB Host and Device driver ** SRC VERSION : 2.0 ** DATE : 1/March/2008 ** AUTHOR : Chen, Howard based on Synopsys Original ** DESCRIPTION : This file contains the Platform Specific constants, interfaces (functions and macros) for Linux. ** FUNCTIONS : ** COMPILER : gcc ** REFERENCE : ** COPYRIGHT : ** Version Control Section ** ** $Author$ ** $Date$ ** $Revisions$ ** $Log$ Revision history *****************************************************************************/ /*! \file dwc_otg_plat.h \brief This file contains the Platform Specific constants, interfaces (functions and macros) for Linux. */ #if !defined(__DWC_OTG_PLAT_H__) #define __DWC_OTG_PLAT_H__ #include #include #include #include #include #if !defined(__LINUX__) #error "The contents of this file is Linux specific!!!" #endif /** \brief Reads the content of a register. \param _reg address of register to read. \return contents of the register. \code Usage: uint32_t dev_ctl = dwc_read_reg32(&dev_regs->dctl); \endcode */ static __inline__ uint32_t dwc_read_reg32( volatile uint32_t *_reg) { return (*(_reg)); }; /** \brief Writes a register with a 32 bit value. \param _reg address of register to read. \param _value to write to _reg. \code Usage: dwc_write_reg32(&dev_regs->dctl, 0); \endcode */ static __inline__ void dwc_write_reg32( volatile uint32_t *_reg, const uint32_t _value) { *(_reg)=_value; }; /** \brief This function modifies bit values in a register. Using the algorithm: (reg_contents & ~clear_mask) | set_mask. \param _reg address of register to read. \param _clear_mask bit mask to be cleared. \param _set_mask bit mask to be set. Usage: \code // Clear the SOF Interrupt Mask bit and
// set the OTG Interrupt mask bit, leaving all others as they were. dwc_modify_reg32(&dev_regs->gintmsk, DWC_SOF_INT, DWC_OTG_INT); \endcode */ static __inline__ void dwc_modify_reg32( volatile uint32_t *_reg, const uint32_t _clear_mask, const uint32_t _set_mask) { uint32_t v; v= *(_reg); v&=(~_clear_mask); v|= _set_mask; *(_reg)=v ; }; /** * Wrapper for the OS micro-second delay function. * @param[in] _usecs Microseconds of delay */ static __inline__ void UDELAY( const uint32_t _usecs ) { udelay( _usecs ); } /** * Wrapper for the OS milli-second delay function. * @param[in] _msecs milliseconds of delay */ static __inline__ void MDELAY( const uint32_t _msecs ) { mdelay( _msecs ); } /** * Wrapper for the Linux spin_lock. On the ARM (Integrator) * spin_lock() is a nop. * * @param _lock Pointer to the spinlock. */ static __inline__ void SPIN_LOCK( spinlock_t *_lock ) { spin_lock(_lock); } /** \brief Wrapper for the Linux spin_unlock. On the ARM (Integrator) spin_lock() is a nop. \param _lock Pointer to the spinlock. */ static __inline__ void SPIN_UNLOCK( spinlock_t *_lock ) { spin_unlock(_lock); } /** \brief Wrapper (macro) for the Linux spin_lock_irqsave. On the ARM (Integrator) spin_lock() is a nop. \param _l Pointer to the spinlock. \param _f unsigned long for irq flags storage. */ #define SPIN_LOCK_IRQSAVE( _l, _f ) \ { \ spin_lock_irqsave(_l,_f); \ } /** \brief Wrapper (macro) for the Linux spin_unlock_irqrestore. On the ARM (Integrator) spin_lock() is a nop. \param _l Pointer to the spinlock. \param _f unsigned long for irq flags storage. */ #define SPIN_UNLOCK_IRQRESTORE( _l,_f ) \ { \ spin_unlock_irqrestore(_l,_f); \ } /* * Debugging support vanishes in non-debug builds. */ /** * \brief The Debug Level bit-mask variable. */ extern uint32_t g_dbg_lvl; /* * Set the Debug Level variable. */ static inline uint32_t SET_DEBUG_LEVEL( const uint32_t _new ) { uint32_t old = g_dbg_lvl; g_dbg_lvl = _new; return old; } /** When debug level has the DBG_CIL bit set, display CIL Debug messages. */ #define DBG_CIL (0x2) /** \brief When debug level has the DBG_CILV bit set, display CIL Verbose debug messages */ #define DBG_CILV (0x20) /** When debug level has the DBG_PCD bit set, display PCD (Device) debug messages */ #define DBG_PCD (0x4) /** When debug level has the DBG_PCDV set, display PCD (Device) Verbose debug messages */ #define DBG_PCDV (0x40) /** When debug level has the DBG_HCD bit set, display Host debug messages */ #define DBG_HCD (0x8) /** When debug level has the DBG_HCDV bit set, display Verbose Host debug messages */ #define DBG_HCDV (0x80) /** When debug level has the DBG_HCD_URB bit set, display enqueued URBs in host mode. */ #define DBG_HCD_URB (0x800) /** When debug level has any bit set, display debug messages */ #define DBG_ANY (0xFF) /** All debug messages off */ #define DBG_OFF 0 /* Prefix string for DWC_DEBUG print macros. */ #define USB_DWC "DWC_otg: " /** \brief Print a debug message when the Global debug level variable contains the bit defined in lvl. \param[in] lvl - Debug level, use one of the DBG_ constants above. \param[in] x - like printf Example: \code DWC_DEBUGPL( DBG_ANY, "%s(%p)\n", __func__, _reg_base_addr); results in: usb-DWC_otg: dwc_otg_cil_init(ca867000) \endcode */ #ifdef DEBUG # define DWC_DEBUGPL(lvl, x...) do{ if ((lvl)&g_dbg_lvl)printk( KERN_DEBUG USB_DWC x ); }while(0) # define DWC_DEBUGP(x...) DWC_DEBUGPL(DBG_ANY, x ) # define CHK_DEBUG_LEVEL(level) ((level) & g_dbg_lvl) #else # define DWC_DEBUGPL(lvl, x...) do{}while(0) # define DWC_DEBUGP(x...) # define CHK_DEBUG_LEVEL(level) (0) #endif /*DEBUG*/ /* * Print an Error message. */ #define DWC_ERROR(x...) printk( KERN_ERR USB_DWC x ) /* * Print a Warning message. */ #define DWC_WARN(x...) printk( KERN_WARNING USB_DWC x ) /* * Print a notice (normal but significant message). */ #define DWC_NOTICE(x...) printk( KERN_NOTICE USB_DWC x ) /* * Basic message printing. */ #define DWC_PRINT(x...) printk( KERN_INFO USB_DWC x ) #endif