/**HEADER********************************************************************
* 
* Copyright (c) 2008 Freescale Semiconductor;
* All Rights Reserved                       
*
* Copyright (c) 1989-2008 ARC International;
* All Rights Reserved
*
*************************************************************************** 
*
* THIS SOFTWARE IS PROVIDED BY FREESCALE "AS IS" AND ANY EXPRESSED OR 
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  
* IN NO EVENT SHALL FREESCALE OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 
* THE POSSIBILITY OF SUCH DAMAGE.
*
**************************************************************************
*
* $FileName: mcf522x_usbotg.h$
* $Version : 3.0.8.0$
* $Date    : Jan-20-2009$
*
* Comments:
*
*   This file contains the type definitions for the mcf522x usbotg module.
*
*END************************************************************************/

#ifndef __mcf522x_usbotg_h__
#define __mcf522x_usbotg_h__

#define __mcf522x_usbotg_h__version "$Version:3.0.8.0$"
#define __mcf522x_usbotg_h__date    "$Date:Jan-20-2009$"

#ifdef __cplusplus
extern "C" {
#endif

/*------------------------------------------------------------------------*/
/*
** USB OTG
*/

/* Bit definitions and macros for PER_ID */
#define MCF522X_USBOTG_PER_ID_ID(x)             (((x)&0x3F)<<0)

/* Bit definitions and macros for ID_COMP */
#define MCF522X_USBOTG_ID_COMP_NID(x)           (((x)&0x3F)<<0)

/* Bit definitions and macros for REV */
#define MCF522X_USBOTG_REV_REV(x)               (((x)&0xFF)<<0)

/* Bit definitions and macros for ADD_INFO */
#define MCF522X_USBOTG_ADD_INFO_IEHOST          (0x1)
#define MCF522X_USBOTG_ADD_INFO_IRQ_NUM(x)      (((x)&0x1F)<<0x3)

/* Bit definitions and macros for OTG_INT_STAT */
#define MCF522X_USBOTG_OTG_INT_STAT_A_VBUS_CHG  (0x1)
#define MCF522X_USBOTG_OTG_INT_STAT_B_SESS_CHG  (0x4)
#define MCF522X_USBOTG_OTG_INT_STAT_SESS_VLD_CHG (0x8)
#define MCF522X_USBOTG_OTG_INT_STAT_LINE_STATE_CHG (0x20)
#define MCF522X_USBOTG_OTG_INT_STAT_1_MSEC      (0x40)
#define MCF522X_USBOTG_OTG_INT_STAT_ID_CHG      (0x80)

/* Bit definitions and macros for OTG_INT_EN */
#define MCF522X_USBOTG_OTG_INT_EN_A_VBUS_EN     (0x1)
#define MCF522X_USBOTG_OTG_INT_EN_B_SESS_EN     (0x4)
#define MCF522X_USBOTG_OTG_INT_EN_SESS_VLD_EN   (0x8)
#define MCF522X_USBOTG_OTG_INT_EN_LINE_STATE_EN (0x20)
#define MCF522X_USBOTG_OTG_INT_EN_1_MSEC_EN     (0x40)
#define MCF522X_USBOTG_OTG_INT_EN_ID_EN         (0x80)

/* Bit definitions and macros for OTG_STAT */
#define MCF522X_USBOTG_OTG_STAT_A_VBUS_VLD      (0x1)
#define MCF522X_USBOTG_OTG_STAT_B_SESS_END      (0x4)
#define MCF522X_USBOTG_OTG_STAT_SESS_VLD        (0x8)
#define MCF522X_USBOTG_OTG_STAT_LINE_STATE_STABLE (0x20)
#define MCF522X_USBOTG_OTG_STAT_1_MSEC_EN       (0x40)
#define MCF522X_USBOTG_OTG_STAT_ID              (0x80)

/* Bit definitions and macros for OTG_CTRL */
#define MCF522X_USBOTG_OTG_CTRL_VBUS_DSCHG      (0x1)
#define MCF522X_USBOTG_OTG_CTRL_VBUS_CHG        (0x2)
#define MCF522X_USBOTG_OTG_CTRL_OTG_EN          (0x4)
#define MCF522X_USBOTG_OTG_CTRL_VBUS_ON         (0x8)
#define MCF522X_USBOTG_OTG_CTRL_DM_LOW          (0x10)
#define MCF522X_USBOTG_OTG_CTRL_DP_LOW          (0x20)
#define MCF522X_USBOTG_OTG_CTRL_DM_HIGH         (0x40)
#define MCF522X_USBOTG_OTG_CTRL_DP_HIGH         (0x80)

/* Bit definitions and macros for INT_STAT */
#define MCF522X_USBOTG_INT_STAT_USB_RST         (0x1)
#define MCF522X_USBOTG_INT_STAT_ERROR           (0x2)
#define MCF522X_USBOTG_INT_STAT_SOF_TOK         (0x4)
#define MCF522X_USBOTG_INT_STAT_TOK_DNE         (0x8)
#define MCF522X_USBOTG_INT_STAT_SLEEP           (0x10)
#define MCF522X_USBOTG_INT_STAT_RESUME          (0x20)
#define MCF522X_USBOTG_INT_STAT_ATTACH          (0x40)
#define MCF522X_USBOTG_INT_STAT_STALL           (0x80)

/* Bit definitions and macros for INT_ENB */
#define MCF522X_USBOTG_INT_ENB_USB_RST_EN       (0x1)
#define MCF522X_USBOTG_INT_ENB_ERROR_EN         (0x2)
#define MCF522X_USBOTG_INT_ENB_SOF_TOK_EN       (0x4)
#define MCF522X_USBOTG_INT_ENB_TOK_DNE_EN       (0x8)
#define MCF522X_USBOTG_INT_ENB_SLEEP_EN         (0x10)
#define MCF522X_USBOTG_INT_ENB_RESUME_EN        (0x20)
#define MCF522X_USBOTG_INT_ENB_ATTACH_EN        (0x40)
#define MCF522X_USBOTG_INT_ENB_STALL_EN         (0x80)

/* Bit definitions and macros for ERR_STAT */
#define MCF522X_USBOTG_ERR_STAT_PID_ERR         (0x1)
#define MCF522X_USBOTG_ERR_STAT_CRC5_EOF        (0x2)
#define MCF522X_USBOTG_ERR_STAT_CRC16           (0x4)
#define MCF522X_USBOTG_ERR_STAT_DFN8            (0x8)
#define MCF522X_USBOTG_ERR_STAT_BTO_ERR         (0x10)
#define MCF522X_USBOTG_ERR_STAT_DMA_ERR         (0x20)
#define MCF522X_USBOTG_ERR_STAT_BTS_ERR         (0x80)

/* Bit definitions and macros for ERR_ENB */
#define MCF522X_USBOTG_ERR_ENB_PID_ERR_EN       (0x1)
#define MCF522X_USBOTG_ERR_ENB_CRC5_EOF_EN      (0x2)
#define MCF522X_USBOTG_ERR_ENB_CRC16_EN         (0x4)
#define MCF522X_USBOTG_ERR_ENB_DFN8_EN          (0x8)
#define MCF522X_USBOTG_ERR_ENB_BTO_ERR_EN       (0x10)
#define MCF522X_USBOTG_ERR_ENB_DMA_ERR_EN       (0x20)
#define MCF522X_USBOTG_ERR_ENB_BTS_ERR_EN       (0x80)

/* Bit definitions and macros for STAT */
#define MCF522X_USBOTG_STAT_ODD                 (0x4)
#define MCF522X_USBOTG_STAT_TX                  (0x8)
#define MCF522X_USBOTG_STAT_ENDP(x)             (((x)&0xF)<<0x4)

/* Bit definitions and macros for OTG_CTL */
#define MCF522X_USBOTG_CTL_USB_EN_SOF_EN        (0x1)
#define MCF522X_USBOTG_CTL_ODD_RST              (0x2)
#define MCF522X_USBOTG_CTL_RESUME               (0x4)
#define MCF522X_USBOTG_CTL_HOST_MODE_EN         (0x8)
#define MCF522X_USBOTG_CTL_RESET                (0x10)
#define MCF522X_USBOTG_CTL_TXSUSPEND_TOKENBUSY  (0x20)
#define MCF522X_USBOTG_CTL_SE0                  (0x40)
#define MCF522X_USBOTG_CTL_JSTATE               (0x80)

/* Bit definitions and macros for ADDR */
#define MCF522X_USBOTG_ADDR_ADDR(x)             (((x)&0x7F)<<0)
#define MCF522X_USBOTG_ADDR_LS_EN               (0x80)

/* Bit definitions and macros for BDT_PAGE_01 */
#define MCF522X_USBOTG_BDT_PAGE_01_BDT_BA9      (0x2)
#define MCF522X_USBOTG_BDT_PAGE_01_BDT_BA10     (0x4)
#define MCF522X_USBOTG_BDT_PAGE_01_BDT_BA11     (0x8)
#define MCF522X_USBOTG_BDT_PAGE_01_BDT_BA12     (0x10)
#define MCF522X_USBOTG_BDT_PAGE_01_BDT_BA13     (0x20)
#define MCF522X_USBOTG_BDT_PAGE_01_BDT_BA14     (0x40)
#define MCF522X_USBOTG_BDT_PAGE_01_BDT_BA15     (0x80)

/* Bit definitions and macros for FRM_NUML */
#define MCF522X_USBOTG_FRM_NUML_FRM0            (0x1)
#define MCF522X_USBOTG_FRM_NUML_FRM1            (0x2)
#define MCF522X_USBOTG_FRM_NUML_FRM2            (0x4)
#define MCF522X_USBOTG_FRM_NUML_FRM3            (0x8)
#define MCF522X_USBOTG_FRM_NUML_FRM4            (0x10)
#define MCF522X_USBOTG_FRM_NUML_FRM5            (0x20)
#define MCF522X_USBOTG_FRM_NUML_FRM6            (0x40)
#define MCF522X_USBOTG_FRM_NUML_FRM7            (0x80)

/* Bit definitions and macros for FRM_NUMH */
#define MCF522X_USBOTG_FRM_NUMH_FRM8            (0x1)
#define MCF522X_USBOTG_FRM_NUMH_FRM9            (0x2)
#define MCF522X_USBOTG_FRM_NUMH_FRM10           (0x4)

/* Bit definitions and macros for TOKEN */
#define MCF522X_USBOTG_TOKEN_TOKEN_ENDPT(x)     (((x)&0xF)<<0)
#define MCF522X_USBOTG_TOKEN_TOKEN_PID(x)       (((x)&0xF)<<0x4)
#define MCF522X_USBOTG_TOKEN_TOKEN_PID_OUT      (0x10)
#define MCF522X_USBOTG_TOKEN_TOKEN_PID_IN       (0x90)
#define MCF522X_USBOTG_TOKEN_TOKEN_PID_SETUP    (0xD0)

/* Bit definitions and macros for SOF_THLD */
#define MCF522X_USBOTG_SOF_THLD_CNT0            (0x1)
#define MCF522X_USBOTG_SOF_THLD_CNT1            (0x2)
#define MCF522X_USBOTG_SOF_THLD_CNT2            (0x4)
#define MCF522X_USBOTG_SOF_THLD_CNT3            (0x8)
#define MCF522X_USBOTG_SOF_THLD_CNT4            (0x10)
#define MCF522X_USBOTG_SOF_THLD_CNT5            (0x20)
#define MCF522X_USBOTG_SOF_THLD_CNT6            (0x40)
#define MCF522X_USBOTG_SOF_THLD_CNT7            (0x80)

/* Bit definitions and macros for BDT_PAGE_02 */
#define MCF522X_USBOTG_BDT_PAGE_02_BDT_BA16     (0x1)
#define MCF522X_USBOTG_BDT_PAGE_02_BDT_BA17     (0x2)
#define MCF522X_USBOTG_BDT_PAGE_02_BDT_BA18     (0x4)
#define MCF522X_USBOTG_BDT_PAGE_02_BDT_BA19     (0x8)
#define MCF522X_USBOTG_BDT_PAGE_02_BDT_BA20     (0x10)
#define MCF522X_USBOTG_BDT_PAGE_02_BDT_BA21     (0x20)
#define MCF522X_USBOTG_BDT_PAGE_02_BDT_BA22     (0x40)
#define MCF522X_USBOTG_BDT_PAGE_02_BDT_BA23     (0x80)

/* Bit definitions and macros for BDT_PAGE_03 */
#define MCF522X_USBOTG_BDT_PAGE_03_BDT_BA24     (0x1)
#define MCF522X_USBOTG_BDT_PAGE_03_BDT_BA25     (0x2)
#define MCF522X_USBOTG_BDT_PAGE_03_BDT_BA26     (0x4)
#define MCF522X_USBOTG_BDT_PAGE_03_BDT_BA27     (0x8)
#define MCF522X_USBOTG_BDT_PAGE_03_BDT_BA28     (0x10)
#define MCF522X_USBOTG_BDT_PAGE_03_BDT_BA29     (0x20)
#define MCF522X_USBOTG_BDT_PAGE_03_BDT_BA30     (0x40)
#define MCF522X_USBOTG_BDT_PAGE_03_BDT_BA31     (0x80)

/* Bit definitions and macros for ENDPT */
#define MCF522X_USBOTG_ENDPT_EP_HSHK            (0x1)
#define MCF522X_USBOTG_ENDPT_EP_STALL           (0x2)
#define MCF522X_USBOTG_ENDPT_EP_TX_EN           (0x4)
#define MCF522X_USBOTG_ENDPT_EP_RX_EN           (0x8)
#define MCF522X_USBOTG_ENDPT_EP_CTL_DIS         (0x10)
#define MCF522X_USBOTG_ENDPT_RETRY_DIS          (0x40)
#define MCF522X_USBOTG_ENDPT_HOST_WO_HUB        (0x80)

/* Bit definitions and macros for USB_CTRL */
#define MCF522X_USBOTG_USB_CTRL_CLK_SRC(x)      (((x)&0x3)<<0)
#define MCF522X_USBOTG_USB_CTRL_CLK_SRC_ALTCLK  (0)
#define MCF522X_USBOTG_USB_CTRL_CLK_SRC_OSCCLK  (0x1)
#define MCF522X_USBOTG_USB_CTRL_CLK_SRC_SYSCLK  (0x3)
#define MCF522X_USBOTG_USB_CTRL_PDE             (0x40)
#define MCF522X_USBOTG_USB_CTRL_SUSP            (0x80)

/* Bit definitions and macros for OTG_OBSERVE */
#define MCF522X_USBOTG_USB_OTG_OBSERVE_VBUSDIS  (0x2)
#define MCF522X_USBOTG_USB_OTG_OBSERVE_VBUSCHG  (0x4)
#define MCF522X_USBOTG_USB_OTG_OBSERVE_VBUSE    (0x8)
#define MCF522X_USBOTG_USB_OTG_OBSERVE_DM_PD    (0x10)
#define MCF522X_USBOTG_USB_OTG_OBSERVE_DP_PD    (0x40)
#define MCF522X_USBOTG_USB_OTG_OBSERVE_DP_PU    (0x80)

/* Bit definitions and macros for OTG_CONTROL */
#define MCF522X_USBOTG_USB_OTG_CONTROL_SESSEND  (0x1)
#define MCF522X_USBOTG_USB_OTG_CONTROL_SESSVLD  (0x2)
#define MCF522X_USBOTG_USB_OTG_CONTROL_VBUSVLD  (0x4)
#define MCF522X_USBOTG_USB_OTG_CONTROL_ID       (0x8)
#define MCF522X_USBOTG_USB_OTG_CONTROL_VBUSD    (0x10)

/* Bit definitons and macros for USB buffer descriptor */
#define MCF522X_USBOTG_BD_BC(n)                 ((n & 0x3ff) << 16)
#define MCF522X_USBOTG_BD_OWN                   0x80
#define MCF522X_USBOTG_BD_DATA01(n)             ((n & 1) << 6)
//#define MCF522X_USBOTG_BD_DATA0                 0
//#define MCF522X_USBOTG_BD_DATA1                 0x40
#define MCF522X_USBOTG_BD_KEEP                  0x20
#define MCF522X_USBOTG_BD_NINC                  0x10
#define MCF522X_USBOTG_BD_DTS                   0x08
#define MCF522X_USBOTG_BD_STALL                 0x04

#define MCF522X_USBOTG_BD_PID(n)                ((n & 0x0f) << 2)

/*------------------------------------------------------------------------*/
/*
** MCF522X_USBOTG_STRUCT
** USB OTG
*/
typedef struct mcf522x_usbotg_struct
{   
	uchar   PER_ID;          // 
	uchar   filler0[3];
	uchar   ID_COMP;          // 
	uchar   filler1[3];
	uchar   REV;          // 
	uchar   filler2[3];
	uchar   ADD_INFO;          // 
	uchar   filler3[3];
	uchar   OTG_INT_STAT;          // 
	uchar   filler4[3];
	uchar   OTG_INT_EN;          // 
	uchar   filler5[3];
	uchar   OTG_STATUS;          // 
	uchar   filler6[3];
	uchar   OTG_CTRL;          // 
	uchar   filler7[99];
	uchar   INT_STAT;          // 
	uchar   filler8[3];
	uchar   INT_ENB;          // 
	uchar   filler9[3];
	uchar   ERR_STAT;          // 
	uchar   filler10[3];
	uchar   ERR_ENB;          // 
	uchar   filler11[3];
	uchar   STAT;          // 
	uchar   filler12[3];
	uchar   CTL;          // 
	uchar   filler13[3];
	uchar   ADDR;          // 
	uchar   filler14[3];
	uchar   BDT_PAGE_01;        // 
	uchar   filler15[3];
	uchar   FRM_NUML;        // 
	uchar   filler16[3];
	uchar   FRM_NUMH;        // 
	uchar   filler17[3];
	uchar   TOKEN;           // 
	uchar   filler18[3];
	uchar   SOF_THLD;        // 
	uchar   filler19[3];
	uchar   BDT_PAGE_02;     // 
	uchar   filler20[3];
	uchar   BDT_PAGE_03;     // 
	uchar   filler21[11];
	uchar   ENDPT0;          // Endpoint Control Register 0
	uchar   filler22[3];
	uchar   ENDPT1;          // Endpoint Control Register 1
	uchar   filler23[3];
	uchar   ENDPT2;          // Endpoint Control Register 2
	uchar   filler24[3];
	uchar   ENDPT3;          // Endpoint Control Register 3
	uchar   filler25[3];
	uchar   ENDPT4;          // Endpoint Control Register 4
	uchar   filler26[3];
	uchar   ENDPT5;          // Endpoint Control Register 5
	uchar   filler27[3];
	uchar   ENDPT6;          // Endpoint Control Register 6
	uchar   filler28[3];
	uchar   ENDPT7;          // Endpoint Control Register 7
	uchar   filler29[3];
	uchar   ENDPT8;          // Endpoint Control Register 8
	uchar   filler30[3];
	uchar   ENDPT9;          // Endpoint Control Register 9
	uchar   filler31[3];
	uchar   ENDPT10;         // Endpoint Control Register 10
	uchar   filler32[3];
	uchar   ENDPT11;         // Endpoint Control Register 11
	uchar   filler33[3];
	uchar   ENDPT12;         // Endpoint Control Register 12
	uchar   filler34[3];
	uchar   ENDPT13;         // Endpoint Control Register 13
	uchar   filler35[3];
	uchar   ENDPT14;         // Endpoint Control Register 14
	uchar   filler36[3];
	uchar   ENDPT15;         // Endpoint Control Register 15
	uchar   filler37[3];
	uchar   USB_CTRL;        // 
	uchar   filler38[3];
	uchar   USB_OTG_OBSERVE; // 
	uchar   filler39[3];
	uchar   USB_OTG_CONTROL; // 	
	uchar   filler40[3];
	uchar	filler[0xfef4];   
} MCF522X_USBOTG_STRUCT, _PTR_ MCF522X_USBOTG_STRUCT_PTR;
typedef volatile struct mcf522x_usbotg_struct _PTR_ VMCF522X_USBOTG_STRUCT_PTR;

#ifdef __cplusplus
}
#endif


#endif
