1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2010 Marcin Bukat
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
28 #include "ata-target.h"
33 and_l(~(1<<19), &GPIO_OUT
);
34 sleep(1); /* > 25us */
36 or_l((1<<19), &GPIO_OUT
);
37 sleep(1); /* > 25us */
40 void ata_enable(bool on
)
42 static bool init
= true;
44 /* Ide power toggling is a nasty hack to allow USB bridge operation
45 * in rockbox. For some reason GL811E bridge doesn't like the state
46 * in which rockbox leaves drive (and vice versa). The only way
47 * I found out to recover is to do disk power cycle (I tried toggling
48 * reset line of the disk but it doesn't work).
51 /* GPO36 /reset line of GL811E */
54 and_l(~(1<<4), &GPIO1_OUT
);
58 ide_power_enable(false);
60 ide_power_enable(true);
68 ide_power_enable(false);
70 ide_power_enable(true);
72 or_l((1<<4), &GPIO1_OUT
);
74 or_l((1<<4), &GPIO1_ENABLE
);
75 or_l((1<<4), &GPIO1_FUNCTION
);
78 bool ata_is_coldstart(void)
80 /* check if ATA reset line is configured
83 return (GPIO_FUNCTION
& (1<<19)) == 0;
86 void ata_device_init(void)
88 /* ATA reset line config */
89 or_l((1<<19), &GPIO_OUT
);
90 or_l((1<<19), &GPIO_ENABLE
);
91 or_l((1<<19), &GPIO_FUNCTION
);