#ifndef __ASM_ARCH_PXA3xx_U2D_H
#define __ASM_ARCH_PXA3xx_U2D_H

#include <mach/bitfield.h>

/*
 * USB2 device controller registers and bits definitions
 */
#define U2DCR		(0x0000)	/* U2D Control Register */
#define U2DCR_NDC	(1   << 31)	/* NAK During Config */
#define U2DCR_HSTC	(0x7 << 28)	/* High Speed Timeout Calibration */
#define U2DCR_SPEOREN	(1   << 27)	/* Short Packet EOR INTR generation Enable */
#define U2DCR_FSTC	(0x7 << 24)	/* Full Speed Timeout Calibration */
#define U2DCR_UCLKOVR	(1   << 22)	/* UTM Clock Override */
#define U2DCR_ABP	(1   << 21)	/* Application Bus Power */
#define U2DCR_ADD	(1   << 20)	/* Application Device Disconnect */
#define U2DCR_CC	(1   << 19)	/* Configuration Change */
#define U2DCR_HS	(1   << 18)	/* High Speed USB Detection */
#define U2DCR_SMAC	(1   << 17)	/* Switch Endpoint Memory to Active Configuration */
#define U2DCR_DWRE	(1   << 16)	/* Device Remote Wake-up Feature */
#define U2DCR_ACN	(0xf << 12)	/* Active U2D Configuration Number */
#define U2DCR_AIN	(0xf << 8)	/* Active U2D Interface Number */
#define U2DCR_AAISN	(0xf << 4)	/* Active U2D Alternate Interface Setting Number */
#define U2DCR_EMCE	(1   << 3)	/* Endpoint Memory Configuration Error */
#define U2DCR_UDR	(1   << 2)	/* U2D Resume */
#define U2DCR_UDA	(1   << 1)	/* U2D Active */
#define U2DCR_UDE	(1   << 0)	/* U2D Enable */

#define U2DICR			(0x0004)	/* U2D Interrupt Control Register */
#define U2DISR			(0x000C)	/* U2D Interrupt Status Register */
#define U2DINT_CC		(1 << 31)	/* Interrupt - Configuration Change */
#define U2DINT_SOF		(1 << 30)	/* Interrupt - SOF */
#define U2DINT_USOF		(1 << 29)	/* Interrupt - micro SOF */
#define U2DINT_RU		(1 << 28)	/* Interrupt - Resume */
#define U2DINT_SU		(1 << 27)	/* Interrupt - Suspend */
#define U2DINT_RS		(1 << 26)	/* Interrupt - Reset */
#define U2DINT_DPE		(1 << 25)	/* Interrupt - Data Packet Error */
#define U2DINT_FIFOERR		(0x4)		/* Interrupt - endpoint FIFO error */
#define U2DINT_PACKETCMP	(0x2)		/* Interrupt - endpoint packet complete */
#define U2DINT_SPACKETCMP	(0x1)		/* Interrupt - endpoint short packet complete */

#define U2DFNR			(0x0014)	/* U2D Frame Number Register */

#define U2DINT(n, intr)		(((intr) & 0x07) << (((n) & 0x07) * 3))
#define U2DICR2			(0x0008)	/* U2D Interrupt Control Register 2 */
#define U2DISR2			(0x0010)	/* U2D Interrupt Status Register 2 */

#define U2DOTGCR		(0x0020)	/* U2D OTG Control Register */
#define U2DOTGCR_OTGEN		(1 << 31)	/* On-The-Go Enable */
#define U2DOTGCR_AALTHNP	(1 << 30)	/* A-device Alternate Host Negotiation Protocal Port Support */
#define U2DOTGCR_AHNP		(1 << 29)	/* A-device Host Negotiation Protocal Support */
#define U2DOTGCR_BHNP		(1 << 28)	/* B-device Host Negotiation Protocal Enable */

#ifdef CONFIG_CPU_PXA930
#define U2DOTGCR_LPA		(1 << 15)	/* ULPI low power mode active */
#define U2DOTGCR_IESI		(1 << 13)	/* OTG interrupt Enable */
#define U2DOTGCR_ISSI		(1 << 12)	/* OTG interrupt status */
#endif

#define U2DOTGCR_CKAF	(1 << 5)	/* Carkit Mode Alternate Function Select */
#define U2DOTGCR_UTMID	(1 << 4)	/* UTMI Interface Disable */
#define U2DOTGCR_ULAF	(1 << 3)	/* ULPI Mode Alternate Function Select */
#define U2DOTGCR_SMAF	(1 << 2)	/* Serial Mode Alternate Function Select */
#define U2DOTGCR_RTSM	(1 << 1)	/* Return to Synchronous Mode (ULPI Mode) */
#define U2DOTGCR_ULE	(1 << 0)	/* ULPI Wrapper Enable */

#define U2DOTGICR	(0x0024)	/* U2D OTG Interrupt Control Register */
#define U2DOTGISR	(0x0028)	/* U2D OTG Interrupt Status Register */

#define U2DOTGINT_SF	(1 << 17)	/* OTG Set Feature Command Received */
#define U2DOTGINT_SI	(1 << 16)	/* OTG Interrupt */
#define U2DOTGINT_RLS1	(1 << 14)	/* RXCMD Linestate[1] Change Interrupt Rise */
#define U2DOTGINT_RLS0	(1 << 13)	/* RXCMD Linestate[0] Change Interrupt Rise */
#define U2DOTGINT_RID	(1 << 12)	/* RXCMD OTG ID Change Interrupt Rise */
#define U2DOTGINT_RSE	(1 << 11)	/* RXCMD OTG Session End Interrupt Rise */
#define U2DOTGINT_RSV	(1 << 10)	/* RXCMD OTG Session Valid Interrupt Rise */
#define U2DOTGINT_RVV	(1 << 9)	/* RXCMD OTG Vbus Valid Interrupt Rise */
#define U2DOTGINT_RCK	(1 << 8)	/* RXCMD Carkit Interrupt Rise */
#define U2DOTGINT_FLS1	(1 << 6)	/* RXCMD Linestate[1] Change Interrupt Fall */
#define U2DOTGINT_FLS0	(1 << 5)	/* RXCMD Linestate[0] Change Interrupt Fall */
#define U2DOTGINT_FID	(1 << 4)	/* RXCMD OTG ID Change Interrupt Fall */
#define U2DOTGINT_FSE	(1 << 3)	/* RXCMD OTG Session End Interrupt Fall */
#define U2DOTGINT_FSV	(1 << 2)	/* RXCMD OTG Session Valid Interrupt Fall */
#define U2DOTGINT_FVV	(1 << 1)	/* RXCMD OTG Vbus Valid Interrupt Fall */
#define U2DOTGINT_FCK	(1 << 0)	/* RXCMD Carkit Interrupt Fall */

#define U2DOTGUSR	(0x002C)	/* U2D OTG ULPI Status Register */
#define U2DOTGUSR_LPA	(1 << 31)	/* ULPI Low Power Mode Active */
#define U2DOTGUSR_S6A	(1 << 30)	/* ULPI Serial Mode (6-pin) Active */
#define U2DOTGUSR_S3A	(1 << 29)	/* ULPI Serial Mode (3-pin) Active */
#define U2DOTGUSR_CKA	(1 << 28)	/* ULPI Car Kit Mode Active */
#define U2DOTGUSR_LS1	(1 << 6)	/* RXCMD Linestate 1 Status */
#define U2DOTGUSR_LS0	(1 << 5)	/* RXCMD Linestate 0 Status */
#define U2DOTGUSR_ID	(1 << 4)	/* OTG IDGnd Status */
#define U2DOTGUSR_SE	(1 << 3)	/* OTG Session End Status */
#define U2DOTGUSR_SV	(1 << 2)	/* OTG Session Valid Status */
#define U2DOTGUSR_VV	(1 << 1)	/* OTG Vbus Valid Status */
#define U2DOTGUSR_CK	(1 << 0)	/* Carkit Interrupt Status */

#define U2DOTGUCR	(0x0030)	/* U2D OTG ULPI Control Register */
#define U2DOTGUCR_RUN	(1    << 25)	/* RUN */
#define U2DOTGUCR_RNW	(1    << 24)	/* Read or Write operation */
#define U2DOTGUCR_ADDR	(0x3f << 16)	/* Address of the ULPI PHY register */
