2008-04-24 20:08:28 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright (C) 2008 by Maurus Cuelenaere
|
|
|
|
*
|
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.
|
2008-04-24 20:08:28 +00:00
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include "cpu.h"
|
|
|
|
#include "kernel.h"
|
|
|
|
#include "thread.h"
|
|
|
|
#include "system.h"
|
|
|
|
#include "power.h"
|
|
|
|
#include "panic.h"
|
|
|
|
#include "ata-target.h"
|
2008-05-03 13:43:26 +00:00
|
|
|
#include "dm320.h"
|
|
|
|
|
|
|
|
void sleep_ms(int ms)
|
|
|
|
{
|
|
|
|
sleep(ms*HZ/1000);
|
|
|
|
}
|
2008-04-24 20:08:28 +00:00
|
|
|
|
2008-04-25 21:44:18 +00:00
|
|
|
void ide_power_enable(bool on)
|
|
|
|
{
|
2008-05-03 13:43:26 +00:00
|
|
|
/* Disabled until figured out what's wrong */
|
2008-04-24 20:08:28 +00:00
|
|
|
#if 0
|
2008-05-03 13:43:26 +00:00
|
|
|
int old_level = disable_irq_save();
|
2008-04-24 20:08:28 +00:00
|
|
|
if(on)
|
|
|
|
{
|
|
|
|
IO_GIO_BITSET0 = (1 << 14);
|
|
|
|
ata_reset();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
IO_GIO_BITCLR0 = (1 << 14);
|
2008-05-03 13:43:26 +00:00
|
|
|
restore_irq(old_level);
|
2008-04-25 21:44:18 +00:00
|
|
|
#else
|
|
|
|
(void)on;
|
2008-04-24 20:08:28 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2008-04-25 21:44:18 +00:00
|
|
|
inline bool ide_powered()
|
|
|
|
{
|
2008-04-24 20:08:28 +00:00
|
|
|
#if 0
|
2008-04-25 21:44:18 +00:00
|
|
|
return (IO_GIO_BITSET0 & (1 << 14));
|
2008-04-24 20:08:28 +00:00
|
|
|
#else
|
|
|
|
return true;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void ata_reset(void)
|
|
|
|
{
|
2008-05-03 13:43:26 +00:00
|
|
|
int old_level = disable_irq_save();
|
2008-04-25 21:44:18 +00:00
|
|
|
if(!ide_powered())
|
|
|
|
{
|
2008-04-24 20:08:28 +00:00
|
|
|
ide_power_enable(true);
|
2008-05-03 13:43:26 +00:00
|
|
|
sleep_ms(150);
|
2008-04-25 21:44:18 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
IO_GIO_BITSET0 = (1 << 5);
|
|
|
|
IO_GIO_BITCLR0 = (1 << 3);
|
2008-05-03 13:43:26 +00:00
|
|
|
sleep_ms(1);
|
2008-04-25 21:44:18 +00:00
|
|
|
}
|
|
|
|
IO_GIO_BITCLR0 = (1 << 5);
|
2008-05-03 13:43:26 +00:00
|
|
|
sleep_ms(10);
|
2008-04-25 21:44:18 +00:00
|
|
|
IO_GIO_BITSET0 = (1 << 3);
|
|
|
|
while(!(ATA_COMMAND & STATUS_RDY))
|
2008-05-03 13:43:26 +00:00
|
|
|
sleep_ms(10);
|
|
|
|
restore_irq(old_level);
|
2008-04-24 20:08:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ata_enable(bool on)
|
|
|
|
{
|
2008-04-25 21:44:18 +00:00
|
|
|
(void)on;
|
|
|
|
return;
|
2008-04-24 20:08:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ata_is_coldstart(void)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ata_device_init(void)
|
|
|
|
{
|
2008-05-03 13:43:26 +00:00
|
|
|
IO_INTC_EINT1 |= INTR_EINT1_EXT2; /* enable GIO2 interrupt */
|
2008-04-24 20:08:28 +00:00
|
|
|
//TODO: mimic OF inits...
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
void GIO2(void)
|
|
|
|
{
|
|
|
|
#ifdef DEBUG
|
2008-05-03 13:43:26 +00:00
|
|
|
logf("GIO2 interrupt...");
|
2008-04-24 20:08:28 +00:00
|
|
|
#endif
|
2008-05-03 13:43:26 +00:00
|
|
|
IO_INTC_IRQ1 = INTR_IRQ1_EXT2; /* Mask GIO2 interrupt */
|
2008-04-24 20:08:28 +00:00
|
|
|
return;
|
|
|
|
}
|