2007-09-20 04:46:41 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
2007-09-22 15:43:38 +00:00
|
|
|
* $Id$
|
2007-09-20 04:46:41 +00:00
|
|
|
*
|
2009-06-08 00:19:16 +00:00
|
|
|
* Copyright (C) 2007, 2009 by Karl Kurbjun
|
2007-09-20 04:46:41 +00:00
|
|
|
*
|
2008-06-28 18:10:04 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2007-09-20 04:46:41 +00:00
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
2009-11-03 16:25:03 +00:00
|
|
|
/*#define LOGF_ENABLE*/
|
2007-09-20 04:46:41 +00:00
|
|
|
|
|
|
|
#include "config.h"
|
2009-06-08 00:19:16 +00:00
|
|
|
#include "logf.h"
|
2007-09-20 04:46:41 +00:00
|
|
|
#include "cpu.h"
|
|
|
|
#include "system.h"
|
|
|
|
|
2009-06-08 00:19:16 +00:00
|
|
|
#include "m66591.h"
|
2007-09-20 04:46:41 +00:00
|
|
|
|
2009-06-08 00:19:16 +00:00
|
|
|
void usb_init_device(void) {
|
|
|
|
logf("mxx: SOC Init");
|
2007-09-20 04:46:41 +00:00
|
|
|
|
2009-11-02 04:37:57 +00:00
|
|
|
/* The following EMIF timing values are from the OF:
|
2009-06-08 00:19:16 +00:00
|
|
|
* IO_EMIF_CS4CTRL1 = 0x66AB;
|
|
|
|
* IO_EMIF_CS4CTRL2 = 0x4220;
|
2009-11-02 04:37:57 +00:00
|
|
|
*
|
|
|
|
* These EMIF timing values are more agressive, but appear to work as long
|
|
|
|
* as USB_TRANS_BLOCK is defined in the USB driver:
|
|
|
|
* IO_EMIF_CS4CTRL1 = 0x2245;
|
|
|
|
* IO_EMIF_CS4CTRL2 = 0x4110;
|
|
|
|
*
|
|
|
|
* When USB_TRANS_BLOCK is not defined the USB driver does not work unless
|
|
|
|
* the values from the OF are used.
|
2009-06-08 00:19:16 +00:00
|
|
|
*/
|
2009-11-02 04:37:57 +00:00
|
|
|
|
2009-06-08 00:19:16 +00:00
|
|
|
IO_EMIF_CS4CTRL1 = 0x2245;
|
|
|
|
IO_EMIF_CS4CTRL2 = 0x4110;
|
2007-09-20 04:46:41 +00:00
|
|
|
|
2009-11-02 04:37:57 +00:00
|
|
|
/* Setup the m66591 reset signal */
|
2009-12-15 01:06:16 +00:00
|
|
|
/* 2: output, non-inverted, no-irq, falling edge, no-chat, normal */
|
|
|
|
dm320_set_io(2, false, false, false, false, false, 0x00);
|
|
|
|
|
2009-11-02 04:37:57 +00:00
|
|
|
/* Setup the m66591 interrupt signal */
|
2009-12-15 01:06:16 +00:00
|
|
|
/* 3: input , non-inverted, irq, falling edge, no-chat, normal */
|
|
|
|
dm320_set_io(3, true, false, true, false, false, 0x00);
|
2009-11-02 04:37:57 +00:00
|
|
|
|
|
|
|
udelay(100);
|
2009-06-08 00:19:16 +00:00
|
|
|
|
|
|
|
/* Drive the reset pin low */
|
2009-11-02 04:37:57 +00:00
|
|
|
IO_GIO_BITCLR0 = 1<<2;
|
2009-06-08 00:19:16 +00:00
|
|
|
|
|
|
|
/* Wait a bit */
|
2009-11-02 04:37:57 +00:00
|
|
|
udelay(100);
|
2007-09-20 04:46:41 +00:00
|
|
|
|
2009-06-08 00:19:16 +00:00
|
|
|
/* Release the reset (drive it high) */
|
2009-11-02 04:37:57 +00:00
|
|
|
IO_GIO_BITSET0 = 1<<2;
|
2009-06-08 00:19:16 +00:00
|
|
|
|
2009-11-02 04:37:57 +00:00
|
|
|
udelay(500);
|
2009-06-08 00:19:16 +00:00
|
|
|
|
|
|
|
/* Enable the MXX interrupt */
|
|
|
|
IO_INTC_EINT1 |= (1<<8); /* IRQ_GIO3 */
|
2007-09-20 04:46:41 +00:00
|
|
|
}
|
|
|
|
|
2009-06-08 00:19:16 +00:00
|
|
|
/* This is the initial interupt handler routine for the USB controller */
|
2009-08-13 04:20:46 +00:00
|
|
|
void GIO3 (void) __attribute__ ((section(".icode")));
|
2009-06-08 00:19:16 +00:00
|
|
|
void GIO3 (void) {
|
|
|
|
/* Clear the interrupt, this is critical to do before running the full
|
|
|
|
* handler otherwise you might miss an interrupt and everything will stop
|
|
|
|
* working.
|
|
|
|
*
|
|
|
|
* The M66591 interrupt line is attached to GPIO3.
|
|
|
|
*/
|
|
|
|
IO_INTC_IRQ1 = (1<<8);
|
|
|
|
|
|
|
|
/* Start the full handler which is located in the driver */
|
|
|
|
USB_DEVICE();
|
2007-09-20 04:46:41 +00:00
|
|
|
}
|
2009-06-08 00:19:16 +00:00
|
|
|
|