1
0
Fork 0
forked from len0rd/rockbox

Gigabeat: Pin initialization for the USB and ATA interface. This also adds proper coldstart detection for the ATA interface.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13103 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Karl Kurbjun 2007-04-11 05:30:15 +00:00
parent f8f05860a2
commit 60fed9aeb6
2 changed files with 48 additions and 17 deletions

View file

@ -28,29 +28,54 @@
#include "mmu-meg-fx.h"
#include "backlight-target.h"
/* ARESET on C7C68300 and RESET on ATA interface (Active Low) */
#define ATA_RESET_ENABLE GPGDAT &= ~(1 << 10)
#define ATA_RESET_DISABLE GPGDAT |= (1 << 10)
/* ATA_EN on C7C68300 */
#define USB_ATA_ENABLE GPBDAT |= (1 << 5)
#define USB_ATA_DISABLE GPBDAT &= ~(1 << 5)
void ata_reset(void)
{
GPGDAT &= ~(1 << 10);
ATA_RESET_ENABLE;
sleep(1); /* > 25us */
GPGDAT |= (1 << 10);
ATA_RESET_DISABLE;
sleep(1); /* > 2ms */
}
/* This function is called before enabling the USB bus */
void ata_enable(bool on)
{
if(on)
GPGDAT &= ~(1 << 12);
USB_ATA_DISABLE;
else
GPGDAT |= (1 << 12);
USB_ATA_ENABLE;
GPBCON=( GPGCON&~(1<<11) ) | (1<<10); /* Make the pin an output */
GPBUP|=1<<5; /* Disable pullup in SOC as we are now driving */
/* Code was originally: (Does not seem that GPG12 is connected in the F series)
if(on)
GPGDAT &= 1<<12;
else
GPGDAT |= 1<<12;
*/
}
bool ata_is_coldstart(void)
{
return true; /* TODO */
/* Check the pin configuration - return true when pin is unconfigured */
return (GPGCON & 0x00300000) == 0;
}
void ata_device_init(void)
{
/* ATA reset */
ATA_RESET_DISABLE; /* Set the pin to disable an active low reset */
GPGCON=( GPGCON&~(1<<21) ) | (1<<20); /* Make the pin an output */
GPGUP |= 1<<10; /* Disable pullup in SOC as we are now driving */
}
#if !defined(BOOTLOADER)

View file

@ -21,18 +21,16 @@
#include "cpu.h"
#include "system.h"
#include "kernel.h"
#include "ata.h"
#define USB_RST_ASSERT GPBDAT &= ~(1 << 4)
#define USB_RST_DEASSERT GPBDAT |= (1 << 4)
#define USB_ATA_ENABLE GPBDAT |= (1 << 5)
#define USB_ATA_DISABLE GPBDAT &= ~(1 << 5)
#define USB_VPLUS_PWR_ASSERT GPBDAT |= (1 << 6)
#define USB_VPLUS_PWR_DEASSERT GPBDAT &= ~(1 << 6)
#define USB_UNIT_IS_PRESENT !(GPFDAT & 0x01)
#define USB_CRADLE_IS_PRESENT ((GPFDAT &0x02)&&!(GPGDAT&0x00004000))
#define USB_CRADLE_IS_PRESENT ((GPFDAT &0x02)&&!(GPGDAT&1<<14))
#define USB_CRADLE_BUS_ENABLE GPHDAT |= (1 << 8)
#define USB_CRADLE_BUS_DISABLE GPHDAT &= ~(1 << 8)
@ -45,22 +43,30 @@ inline bool usb_detect(void)
void usb_init_device(void)
{
/* Input is the default configuration, only pullups need to be disabled */
GPFUP|=0x03;
GPGUP|= 1<<14;
USB_VPLUS_PWR_ASSERT;
GPBCON=( GPBCON&~(1<<13) ) | (1 << 12);
GPBUP|= 1<<6;
sleep(HZ/20);
/* Reset the usb port */
/* Make sure the cpu pin for reset line is set to output */
GPBCON = (GPBCON & ~0x300) | 0x100;
USB_RST_ASSERT;
GPBCON = (GPBCON & ~0x200) | 0x100; /* Make sure reset line is an output */
GPBUP |= 1<<4; /* Make sure pullup is disabled */
sleep(HZ/25);
USB_RST_DEASSERT;
/* needed to complete the reset */
USB_ATA_ENABLE;
ata_enable(false);
sleep(HZ/15); /* 66ms */
USB_ATA_DISABLE;
ata_enable(true);
sleep(HZ/25);
@ -74,18 +80,18 @@ void usb_enable(bool on)
{
if (on)
{
/* make sure ata_en is high */
USB_VPLUS_PWR_ASSERT;
USB_ATA_ENABLE;
if(USB_CRADLE_IS_PRESENT) USB_CRADLE_BUS_ENABLE;
}
else
{
/* make sure ata_en is low */
if(USB_CRADLE_IS_PRESENT) USB_CRADLE_BUS_DISABLE;
USB_ATA_DISABLE;
USB_VPLUS_PWR_DEASSERT;
}
/* Make sure USB_CRADLE_BUS pin is an output */
GPHCON=( GPGCON&~(1<<17) ) | (1<<16); /* Make the pin an output */
GPBUP|=1<<8; /* Disable pullup in SOC as we are now driving */
sleep(HZ/20); // > 50ms for detecting the enable state change
}