summaryrefslogtreecommitdiff
path: root/firmware/target/sh/archos/ata-archos.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/sh/archos/ata-archos.c')
-rwxr-xr-xfirmware/target/sh/archos/ata-archos.c76
1 files changed, 76 insertions, 0 deletions
diff --git a/firmware/target/sh/archos/ata-archos.c b/firmware/target/sh/archos/ata-archos.c
new file mode 100755
index 0000000000..73e56b8d84
--- /dev/null
+++ b/firmware/target/sh/archos/ata-archos.c
@@ -0,0 +1,76 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2006 by Jens Arnold
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19
20#include "config.h"
21#include "cpu.h"
22#include <stdbool.h>
23#include "kernel.h"
24#include "system.h"
25#include "ata-target.h"
26#include "hwcompat.h"
27
28volatile unsigned char* ata_control;
29int ata_io_address; /* 0x300 or 0x200 */
30
31void ata_reset(void)
32{
33 /* state HRR0 */
34 and_b(~0x02, &PADRH); /* assert _RESET */
35 sleep(1); /* > 25us */
36
37 /* state HRR1 */
38 or_b(0x02, &PADRH); /* negate _RESET */
39 sleep(1); /* > 2ms */
40}
41
42void ata_address_detect(void)
43{
44 if (read_hw_mask() & ATA_ADDRESS_200)
45 {
46 ata_io_address = 0x200; /* For debug purposes only */
47 ata_control = ATA_CONTROL1;
48 }
49 else
50 {
51 ata_io_address = 0x300; /* For debug purposes only */
52 ata_control = ATA_CONTROL2;
53 }
54}
55
56void ata_enable(bool on)
57{
58 if(on)
59 and_b(~0x80, &PADRL); /* enable ATA */
60 else
61 or_b(0x80, &PADRL); /* disable ATA */
62
63 or_b(0x80, &PAIORL);
64}
65
66void ata_device_init(void)
67{
68 or_b(0x02, &PAIORH); /* output for ATA reset */
69 or_b(0x02, &PADRH); /* release ATA reset */
70 PACR2 &= 0xBFFF; /* GPIO function for PA7 (IDE enable) */
71}
72
73bool ata_is_coldstart(void)
74{
75 return (PACR2 & 0x4000) != 0;
76}