FS#11968 by Peter Lecky - Slovak language update
[maemo-rb.git] / firmware / target / coldfire / mpio / ata-mpio.c
blobcf4276b5a01d9cc2e9560b6065870bd44b62a516
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
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 ****************************************************************************/
22 #include "config.h"
23 #include "cpu.h"
24 #include <stdbool.h>
25 #include "kernel.h"
26 #include "system.h"
27 #include "power.h"
28 #include "ata-target.h"
30 void ata_reset(void)
32 /* GPIO19 */
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 */
52 if (on)
54 and_l(~(1<<4), &GPIO1_OUT);
55 #ifndef BOOTLOADER
56 if ( !init )
58 ide_power_enable(false);
59 sleep(1);
60 ide_power_enable(true);
62 #endif
63 init = false;
65 else
67 #ifndef BOOTLOADER
68 ide_power_enable(false);
69 sleep(1);
70 ide_power_enable(true);
71 #endif
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
81 * as GPIO
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);