summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2012-12-05 16:26:30 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2012-12-07 12:19:41 +0100
commit1d9e9d1b8a9e92a7a3b6dd4a2454e32c6c927cbf (patch)
treee6073a9954cdc49a35484d76456e34eb3ff0f3db /include
parentdd97d796961eb1bd5f3ee9bbbf0533be98718609 (diff)
downloadbarebox-1d9e9d1b8a9e92a7a3b6dd4a2454e32c6c927cbf.tar.gz
barebox-1d9e9d1b8a9e92a7a3b6dd4a2454e32c6c927cbf.tar.xz
ata: split ide sff suport to separate file
Currently we only support oldschool IDE SFF devices. This is done by registering a register layout struct and everything else is done by the generic IDE SFF driver. Since modern ATA devices still use ATA, but not the SFF interface anymore, split out the IDE SFF support to a separate file to allow for other types of ata interfaces. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'include')
-rw-r--r--include/ata_drive.h42
1 files changed, 41 insertions, 1 deletions
diff --git a/include/ata_drive.h b/include/ata_drive.h
index cdd8049f0d..10edd51e3b 100644
--- a/include/ata_drive.h
+++ b/include/ata_drive.h
@@ -16,6 +16,8 @@
#ifndef ATA_DISK_H
# define ATA_DISK
+#include <block.h>
+
/* IDE register file */
#define IDE_REG_DATA 0x00
#define IDE_REG_ERR 0x01
@@ -33,6 +35,25 @@
#define IDE_REG_DEV_CTL 0x00
#define IDE_REG_DRV_ADDR 0x01
+#define ATA_CMD_ID_DEVICE 0xEC
+#define ATA_CMD_RD_CONF 0x40
+#define ATA_CMD_RD 0x20
+#define ATA_CMD_WR 0x30
+
+/* drive's status flags */
+#define ATA_STATUS_BUSY (1 << 7)
+#define ATA_STATUS_READY (1 << 6)
+#define ATA_STATUS_WR_FLT (1 << 5)
+#define ATA_STATUS_DSC (1 << 4)
+#define ATA_STATUS_DRQ (1 << 3)
+#define ATA_STATUS_CORR (1 << 2)
+#define ATA_STATUS_IDX (1 << 1)
+#define ATA_STATUS_ERROR (1 << 0)
+/* command flags */
+#define LBA_FLAG (1 << 6)
+#define ATA_DEVCTL_SOFT_RESET (1 << 2)
+#define ATA_DEVCTL_INTR_DISABLE (1 << 1)
+
/** addresses of each individual IDE drive register */
struct ata_ioports {
void __iomem *cmd_addr;
@@ -55,8 +76,27 @@ struct ata_ioports {
int dataif_be; /* true if 16 bit data register is big endian */
};
+struct ata_port;
+
+struct ata_port_operations {
+ int (*read)(struct ata_port *port, void *buf, unsigned int block, int num_blocks);
+ int (*write)(struct ata_port *port, const void *buf, unsigned int block, int num_blocks);
+ int (*read_id)(struct ata_port *port, void *buf);
+ int (*reset)(struct ata_port *port);
+};
+
+struct ata_port {
+ struct ata_port_operations *ops;
+ struct device_d *dev;
+ void *drvdata;
+ struct block_device blk;
+ uint16_t *id;
+};
+
+int ide_port_register(struct device_d *, struct ata_ioports *);
+int ata_port_register(struct ata_port *port);
+
struct device_d;
-extern int register_ata_drive(struct device_d*, struct ata_ioports*);
/**
* @file