summaryrefslogtreecommitdiffstats
path: root/firmware/target/arm/imx233/ata-target.h
diff options
context:
space:
mode:
authorAmaury Pouly <amaury.pouly@gmail.com>2013-06-18 16:39:11 +0200
committerAmaury Pouly <amaury.pouly@gmail.com>2013-06-18 16:41:13 +0200
commit0b6198f8a859700e3816254222e31466014ea553 (patch)
tree5b7cd61707943f0b4146881cfacf37451b65c8c3 /firmware/target/arm/imx233/ata-target.h
parentbbb789120ce4c2eb470233920e602e5f79c62430 (diff)
downloadrockbox-0b6198f8a859700e3816254222e31466014ea553.tar.gz
rockbox-0b6198f8a859700e3816254222e31466014ea553.zip
imx233: add basic ATA driver
The current driver only works in PIO mode. Change-Id: I1cf2eaedcce0172a254c3bab0e1257886226d3a0
Diffstat (limited to 'firmware/target/arm/imx233/ata-target.h')
-rw-r--r--firmware/target/arm/imx233/ata-target.h78
1 files changed, 78 insertions, 0 deletions
diff --git a/firmware/target/arm/imx233/ata-target.h b/firmware/target/arm/imx233/ata-target.h
new file mode 100644
index 0000000000..a95ea03247
--- /dev/null
+++ b/firmware/target/arm/imx233/ata-target.h
@@ -0,0 +1,78 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2013 Amaury Pouly
+ *
+ * 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.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+#ifndef ATA_TARGET_H
+#define ATA_TARGET_H
+
+#include "config.h"
+
+#ifdef BOOTLOADER
+#define ATA_DRIVER_CLOSE
+#endif
+
+#ifdef HAVE_ATA_DMA
+/* FIXME does this chips does MWDMA ? */
+#define ATA_MAX_MWDMA 2
+#define ATA_MAX_UDMA 4
+#endif
+
+uint8_t imx233_ata_inb(unsigned reg);
+uint16_t imx233_ata_inw(unsigned reg);
+void imx233_ata_outb(unsigned reg, uint8_t v);
+void imx233_ata_outw(unsigned reg, uint16_t v);
+
+#define IMX233_ATA_REG(cs,addr) ((cs) << 3 | (addr))
+#define IMX233_ATA_REG_CS(reg) ((reg) >> 3)
+#define IMX233_ATA_REG_ADDR(reg) ((reg) & 0x7)
+/* use register address (see ATA spec) */
+#define ATA_DATA IMX233_ATA_REG(0, 0)
+#define ATA_ERROR IMX233_ATA_REG(0, 1)
+#define ATA_NSECTOR IMX233_ATA_REG(0, 2)
+#define ATA_SECTOR IMX233_ATA_REG(0, 3)
+#define ATA_LCYL IMX233_ATA_REG(0, 4)
+#define ATA_HCYL IMX233_ATA_REG(0, 5)
+#define ATA_SELECT IMX233_ATA_REG(0, 6)
+#define ATA_COMMAND IMX233_ATA_REG(0, 7)
+#define ATA_CONTROL IMX233_ATA_REG(1, 6)
+
+/* keep consistent with definition of IMX233_ATA_REG */
+#define ATA_OUT8(reg, data) imx233_ata_outb(reg, data)
+#define ATA_OUT16(reg, data) imx233_ata_outw(reg, data)
+#define ATA_IN8(reg) imx233_ata_inb(reg)
+#define ATA_IN16(reg) imx233_ata_inw(reg)
+
+#define ATA_SET_PIO_TIMING
+
+#define ATA_TARGET_POLLING
+
+void ata_set_pio_timings(int mode);
+void ata_reset(void);
+void ata_enable(bool on);
+bool ata_is_coldstart(void);
+#ifdef HAVE_ATA_DMA
+void ata_dma_set_mode(unsigned char mode);
+bool ata_dma_setup(void *addr, unsigned long bytes, bool write);
+bool ata_dma_finish(void);
+#endif
+int ata_wait_for_bsy(void);
+int ata_wait_for_rdy(void);
+void ata_device_init(void);
+
+#endif /* ATA_TARGET_H */