/*------------------------------------------------------------------------------------------*\
\*------------------------------------------------------------------------------------------*/
#ifndef _vlynq_init_h_
#define _vlynq_init_h_


/*------------------------------------------------------------------------------------------*\
\*------------------------------------------------------------------------------------------*/
/***********************************************************************************
 * Taken from "Merging the V2USB drivers to a BasePSP Linux kernel", DRAFT, 20040609 
 */

typedef struct {

	unsigned long		int_vector;
	unsigned long		map_vector;
	VLYNQ_DEV_TYPE		dev;
	VLYNQ_INTR_POLARITY	pol;
	VLYNQ_INTR_TYPE		type;
	unsigned long		int_enable;
} VECMAP;

static VECMAP vecmap[] = {

	/*
	 * FIXME: All interrupts enabled... which ones are required for V2U?
	 */
	
	{ 0, 2, VLYNQ_REMOTE_DVC, VLYNQ_INTR_ACTIVE_HIGH, VLYNQ_INTR_PULSED, 1 },
	{ 1, 3, VLYNQ_REMOTE_DVC, VLYNQ_INTR_ACTIVE_HIGH, VLYNQ_INTR_PULSED, 1 },
	{ 2, 4, VLYNQ_REMOTE_DVC, VLYNQ_INTR_ACTIVE_LOW,  VLYNQ_INTR_LEVEL,  1 },
	{ 3, 5, VLYNQ_REMOTE_DVC, VLYNQ_INTR_ACTIVE_LOW,  VLYNQ_INTR_LEVEL,  1 },
	{ 4, 6, VLYNQ_REMOTE_DVC, VLYNQ_INTR_ACTIVE_HIGH, VLYNQ_INTR_LEVEL,  1 },
	{ 5, 7, VLYNQ_REMOTE_DVC, VLYNQ_INTR_ACTIVE_HIGH, VLYNQ_INTR_PULSED, 1 },
	{ 6, 8, VLYNQ_REMOTE_DVC, VLYNQ_INTR_ACTIVE_HIGH, VLYNQ_INTR_PULSED, 1 },
	{ 7, 9, VLYNQ_REMOTE_DVC, VLYNQ_INTR_ACTIVE_HIGH, VLYNQ_INTR_PULSED, 1 }
} ;

/*------------------------------------------------------------------------------------------*\
\*------------------------------------------------------------------------------------------*/
unsigned int vlynq_config_memory;

struct _vlynq_dev_config {
    enum vlynq_dev_config_name {
        ti_vlynq_tnetw1130,
        ti_vlynq_tnetw1350,
        ti_vlynq_usb
    } name;
    UINT32 dev_idx; 
    UINT32 module_base;
    VLYNQ_CLK_SOURCE clk_source;
    UINT32  clk_div;
    VLYNQ_DRV_STATE state;
    VLYNQ_MEMORY_MAP local_mem;
    VLYNQ_MEMORY_MAP remote_mem;
    VLYNQ_INTERRUPT_CNTRL  local_irq;
    VLYNQ_INTERRUPT_CNTRL  remote_irq;
};


/*------------------------------------------------------------------------------------------*\
 * Index 0:  WLAN (TNETW1130)
 * Index 1:  VLYNQ USB Controler
 * Index 2:  WLAN (TNETW1350)
\*------------------------------------------------------------------------------------------*/
struct _vlynq_dev_config vlynq_dev_config0[] = {
    {
        ti_vlynq_tnetw1130,
        0, /*--- index ---*/
        AVALANCHE_LOW_VLYNQ_CONTROL_BASE,  /*--- VLYNQ module base address ---*/
#if defined(CONFIG_AVALANCHE_VLYNQ_CLK_LOCAL)
        VLYNQ_CLK_SOURCE_LOCAL,
#else
        VLYNQ_CLK_SOURCE_REMOTE,
#endif
        2,  /*--- clk divisor ---*/
        VLYNQ_DRV_STATE_UNINIT, /* State of the VLYNQ driver, set to VLYNQ_DRV_STATE_UNINIT, when initializing */
   
        /*--- local memory mapping ---*/
        {
            PHYSADDR(AVALANCHE_LOW_VLYNQ_MEM_MAP_BASE),
            {
                AVALANCHE_SDRAM_BASE,
                0,
                0,
                0
            },
            {
                0,  /*--- memsize zur laufzeit setzen ---*/
                0,
                0,
                0
            }
        },
   
        /*--- remote memory mapping ---*/
        {
            0,
            {
                VLYNQ_ACX111_MEM_OFFSET,
                VLYNQ_ACX111_REG_OFFSET,
                0,
                0
            },
            {
                VLYNQ_ACX111_MEM_SIZE,
                VLYNQ_ACX111_REG_SIZE,
                0,
                0
            }
        },
   
        /*--- Local module interrupt params ---*/ 
        {
            VLYNQ_INT_LOCAL,
            VLYNQ_INT_ROOT_ISR,
            SYS_VLYNQ_LOCAL_INTERRUPT_VECTOR,
            0
        },
   
        /*--- remote module interrupt params ---*/ 
        {
            VLYNQ_INT_REMOTE,
            VLYNQ_INT_ROOT_ISR,
            SYS_VLYNQ_REMOTE_INTERRUPT_VECTOR,
            AVALANCHE_INTC_BASE
        }
    },
    /*--------------------------------------------------------------------------------------*\
    \*--------------------------------------------------------------------------------------*/
    {
        ti_vlynq_usb,
        1, /*--- index ---*/
        AVALANCHE_LOW_VLYNQ_CONTROL_BASE,  /*--- VLYNQ module base address ---*/
#if defined(CONFIG_AVALANCHE_VLYNQ_CLK_LOCAL)
        VLYNQ_CLK_SOURCE_LOCAL,
#else
        VLYNQ_CLK_SOURCE_REMOTE,
#endif
        2,  /*--- clk divisor ---*/
        VLYNQ_DRV_STATE_UNINIT, /* State of the VLYNQ driver, set to VLYNQ_DRV_STATE_UNINIT, when initializing */
   
        /*--- local memory mapping ---*/
        {
            PHYSADDR(AVALANCHE_LOW_VLYNQ_MEM_MAP_BASE),
            {
                AVALANCHE_SDRAM_BASE,
                0,
                0,
                0
            },
            {
	            0x4000000,		/* 64M */
                0,
                0,
                0
            }
        },
   
        /*--- remote memory mapping ---*/
        {
            0,
            {
	            VLYNQ0_REMOTE_WINDOW1_OFFSET,
                0,
                0,
                0
            },
            {
                VLYNQ0_REMOTE_WINDOW1_SIZE,
                0,
                0,
                0
            }
        },
   
        /*--- Local module interrupt params ---*/ 
        {
            VLYNQ_INT_LOCAL,
            VLYNQ_INT_ROOT_ISR,
            0,
            0
        },
   
        /*--- remote module interrupt params ---*/ 
        {
            VLYNQ_INT_REMOTE,
            VLYNQ_INT_ROOT_ISR,
            1,
            0
        }
    },
    {
        ti_vlynq_tnetw1350, 
        2, /*--- index ---*/
        AVALANCHE_LOW_VLYNQ_CONTROL_BASE,  /*--- VLYNQ module base address ---*/
#if defined(CONFIG_AVALANCHE_VLYNQ_CLK_LOCAL)
        VLYNQ_CLK_SOURCE_LOCAL,
#else
        VLYNQ_CLK_SOURCE_REMOTE,
#endif
        2,  /*--- clk divisor ---*/
        VLYNQ_DRV_STATE_UNINIT, /* State of the VLYNQ driver, set to VLYNQ_DRV_STATE_UNINIT, when initializing */
   
        /*--- local memory mapping ---*/
        {
            PHYSADDR(AVALANCHE_LOW_VLYNQ_MEM_MAP_BASE),
            {
                AVALANCHE_SDRAM_BASE,
                0,
                0,
                0
            },
            {
                0,  /*--- memsize zur laufzeit setzen ---*/
                0,
                0,
                0
            }
        },
   
        /*--- remote memory mapping ---*/
        {
            0x60000000,
            {
                0x00000000 /*VLYNQ_ACX111_MEM_OFFSET*/,
                0x00300000 /*VLYNQ_ACX111_REG_OFFSET*/,
                0,
                0
            },
            {
                0x00080000 /*VLYNQ_ACX111_MEM_SIZE*/,
                0x00100000 /*VLYNQ_ACX111_REG_SIZE*/,
                0,
                0
            }
        },
   
        /*--- Local module interrupt params ---*/ 
        {
            VLYNQ_INT_LOCAL,
            VLYNQ_INT_ROOT_ISR,
            SYS_VLYNQ_LOCAL_INTERRUPT_VECTOR,
            0
        },
   
        /*--- remote module interrupt params ---*/ 
        {
            VLYNQ_INT_REMOTE,
            VLYNQ_INT_ROOT_ISR,
            SYS_VLYNQ_REMOTE_INTERRUPT_VECTOR,
            AVALANCHE_INTC_BASE
        }
    },
    /*--------------------------------------------------------------------------------------*\
    \*--------------------------------------------------------------------------------------*/
};

#define MAX_VLYNQ_CONFIG0 (sizeof(vlynq_dev_config0)/sizeof(vlynq_dev_config0[0])) 

/*------------------------------------------------------------------------------------------*\
\*------------------------------------------------------------------------------------------*/
#if defined(AVALANCHE_HIGH_VLYNQ_CONTROL_BASE)
struct _vlynq_dev_config vlynq_dev_config1[] = {

    /*--------------------------------------------------------------------------------------*\
    \*--------------------------------------------------------------------------------------*/
    {
        ti_vlynq_tnetw1130,				/* type (enum) */
        0,					/* index */
        AVALANCHE_HIGH_VLYNQ_CONTROL_BASE,	/* VLYNQ1 module base address */
#if defined(CONFIG_AVALANCHE_VLYNQ_CLK_LOCAL)
        VLYNQ_CLK_SOURCE_LOCAL,
#else
        VLYNQ_CLK_SOURCE_REMOTE,
#endif
        2,					/* clk divisor */
        VLYNQ_DRV_STATE_UNINIT,			/* Initial state of the VLYNQ driver */
   
        /* local memory mapping */
        {
            PHYSADDR(AVALANCHE_HIGH_VLYNQ_MEM_MAP_BASE),	/* THESE REGISTER VALUES NEED TO BE CHECKED!!!		*/
            { AVALANCHE_SDRAM_BASE, 0, 0, 0 },			/* THIS IS NOTHING BUT A COPIED AND PASTED VERSION	*/
            { 0, 0, 0, 0 }					/* OF THE ABOVE TABLE ENTRY!!! UNTESTED!!!		*/
        },
   
        /* remote memory mapping */
        {
            0,
            { VLYNQ_ACX111_MEM_OFFSET, VLYNQ_ACX111_REG_OFFSET, 0, 0 },
            { VLYNQ_ACX111_MEM_SIZE, VLYNQ_ACX111_REG_SIZE, 0, 0 }
        },
   
        /* local module interrupt params */ 
        {
            VLYNQ_INT_LOCAL,
            VLYNQ_INT_ROOT_ISR,
            SYS_VLYNQ_LOCAL_INTERRUPT_VECTOR,
            0
        },
   
        /* remote module interrupt params */ 
        {
            VLYNQ_INT_REMOTE,
            VLYNQ_INT_ROOT_ISR,
            SYS_VLYNQ_REMOTE_INTERRUPT_VECTOR,
            AVALANCHE_INTC_BASE
        }
    },
    
    /*--------------------------------------------------------------------------------------*\
    \*--------------------------------------------------------------------------------------*/
    {
        ti_vlynq_usb,				/* type (enum) */
        1,					/* index */
        AVALANCHE_HIGH_VLYNQ_CONTROL_BASE,	/* VLYNQ1 module base address */
#if defined(CONFIG_AVALANCHE_VLYNQ_CLK_LOCAL)
        VLYNQ_CLK_SOURCE_LOCAL,
#else
        VLYNQ_CLK_SOURCE_REMOTE,
#endif
        2,					/* clk divisor */
        VLYNQ_DRV_STATE_UNINIT,			/* Initial state of the VLYNQ driver */
   
        /* local memory mapping */
        {
            PHYSADDR(AVALANCHE_HIGH_VLYNQ_MEM_MAP_BASE),
            { AVALANCHE_SDRAM_BASE, 0, 0, 0 },
            { 0x4000000 /* 64M */, 0, 0, 0 }
        },
   
        /* remote memory mapping */
        {
            0,
            { VLYNQ0_REMOTE_WINDOW1_OFFSET, 0, 0, 0 },
            { VLYNQ0_REMOTE_WINDOW1_SIZE, 0, 0, 0 }
        },
   
        /* Local module interrupt params */ 
        {
            VLYNQ_INT_LOCAL,
            VLYNQ_INT_ROOT_ISR,
            0,
            0
        },
   
        /* remote module interrupt params */ 
        {
            VLYNQ_INT_REMOTE,
            VLYNQ_INT_ROOT_ISR,
            1,
            0
        }
    },
    /*--------------------------------------------------------------------------------------*\
    \*--------------------------------------------------------------------------------------*/
    {
        ti_vlynq_tnetw1350,				/* type (enum) */
        2,					/* index */
        AVALANCHE_HIGH_VLYNQ_CONTROL_BASE,	/* VLYNQ1 module base address */
#if defined(CONFIG_AVALANCHE_VLYNQ_CLK_LOCAL)
        VLYNQ_CLK_SOURCE_LOCAL,
#else
        VLYNQ_CLK_SOURCE_REMOTE,
#endif
        2,					/* clk divisor */
        VLYNQ_DRV_STATE_UNINIT,			/* Initial state of the VLYNQ driver */
   
        /* local memory mapping */
        {
            PHYSADDR(AVALANCHE_HIGH_VLYNQ_MEM_MAP_BASE),	/* THESE REGISTER VALUES NEED TO BE CHECKED!!!		*/
            { AVALANCHE_SDRAM_BASE, 0, 0, 0 },			/* THIS IS NOTHING BUT A COPIED AND PASTED VERSION	*/
            { 0, 0, 0, 0 }					/* OF THE ABOVE TABLE ENTRY!!! UNTESTED!!!		*/
        },
   
        /* remote memory mapping */
        {
            0,
            { 0x00000000 /*VLYNQ_ACX111_MEM_OFFSET*/, 0x00300000 /*VLYNQ_ACX111_REG_OFFSET*/, 0, 0 },
            { 0x00080000 /*VLYNQ_ACX111_MEM_SIZE*/, 0x00100000 /*VLYNQ_ACX111_REG_SIZE*/, 0, 0 }
        },
   
        /* local module interrupt params */ 
        {
            VLYNQ_INT_LOCAL,
            VLYNQ_INT_ROOT_ISR,
            SYS_VLYNQ_LOCAL_INTERRUPT_VECTOR,
            0
        },
   
        /* remote module interrupt params */ 
        {
            VLYNQ_INT_REMOTE,
            VLYNQ_INT_ROOT_ISR,
            SYS_VLYNQ_REMOTE_INTERRUPT_VECTOR,
            AVALANCHE_INTC_BASE
        }
    },
    
    /*--------------------------------------------------------------------------------------*\
    \*--------------------------------------------------------------------------------------*/
} ;

#define MAX_VLYNQ_CONFIG1 (sizeof(vlynq_dev_config1)/sizeof(vlynq_dev_config1[0]))

#endif /*--- #if defined(AVALANCHE_HIGH_VLYNQ_CONTROL_BASE) ---*/
#endif /*--- #ifndef _vlynq_init_h_ ---*/
