diff options
Diffstat (limited to 'include')
| -rw-r--r-- | include/ata.h | 60 | ||||
| -rw-r--r-- | include/configs/sc520_cdp.h | 9 | ||||
| -rw-r--r-- | include/sata.h | 108 | 
3 files changed, 177 insertions, 0 deletions
| diff --git a/include/ata.h b/include/ata.h index 8584226eb..d36bdf6cd 100644 --- a/include/ata.h +++ b/include/ata.h @@ -83,6 +83,66 @@  #define ATA_DEVICE(x)	((x & 1)<<4)  #define ATA_LBA		0xE0 +enum { +	ATA_MAX_DEVICES = 1,	/* per bus/port */ +	ATA_MAX_PRD = 256,	/* we could make these 256/256 */ +	ATA_SECT_SIZE = 256,	/*256 words per sector */ + +	/* bits in ATA command block registers */ +	ATA_HOB = (1 << 7),	/* LBA48 selector */ +	ATA_NIEN = (1 << 1),	/* disable-irq flag */ +	/*ATA_LBA                 = (1 << 6), *//* LBA28 selector */ +	ATA_DEV1 = (1 << 4),	/* Select Device 1 (slave) */ +	ATA_DEVICE_OBS = (1 << 7) | (1 << 5),	/* obs bits in dev reg */ +	ATA_DEVCTL_OBS = (1 << 3),	/* obsolete bit in devctl reg */ +	ATA_BUSY = (1 << 7),	/* BSY status bit */ +	ATA_DRDY = (1 << 6),	/* device ready */ +	ATA_DF = (1 << 5),	/* device fault */ +	ATA_DRQ = (1 << 3),	/* data request i/o */ +	ATA_ERR = (1 << 0),	/* have an error */ +	ATA_SRST = (1 << 2),	/* software reset */ +	ATA_ABORTED = (1 << 2),	/* command aborted */ +	/* ATA command block registers */ +	ATA_REG_DATA = 0x00, +	ATA_REG_ERR = 0x01, +	ATA_REG_NSECT = 0x02, +	ATA_REG_LBAL = 0x03, +	ATA_REG_LBAM = 0x04, +	ATA_REG_LBAH = 0x05, +	ATA_REG_DEVICE = 0x06, +	ATA_REG_STATUS = 0x07, +	ATA_PCI_CTL_OFS = 0x02, +	/* and their aliases */ +	ATA_REG_FEATURE = ATA_REG_ERR, +	ATA_REG_CMD = ATA_REG_STATUS, +	ATA_REG_BYTEL = ATA_REG_LBAM, +	ATA_REG_BYTEH = ATA_REG_LBAH, +	ATA_REG_DEVSEL = ATA_REG_DEVICE, +	ATA_REG_IRQ = ATA_REG_NSECT, + +	/* SETFEATURES stuff */ +	SETFEATURES_XFER = 0x03, +	XFER_UDMA_7 = 0x47, +	XFER_UDMA_6 = 0x46, +	XFER_UDMA_5 = 0x45, +	XFER_UDMA_4 = 0x44, +	XFER_UDMA_3 = 0x43, +	XFER_UDMA_2 = 0x42, +	XFER_UDMA_1 = 0x41, +	XFER_UDMA_0 = 0x40, +	XFER_MW_DMA_2 = 0x22, +	XFER_MW_DMA_1 = 0x21, +	XFER_MW_DMA_0 = 0x20, +	XFER_PIO_4 = 0x0C, +	XFER_PIO_3 = 0x0B, +	XFER_PIO_2 = 0x0A, +	XFER_PIO_1 = 0x09, +	XFER_PIO_0 = 0x08, +	XFER_SW_DMA_2 = 0x12, +	XFER_SW_DMA_1 = 0x11, +	XFER_SW_DMA_0 = 0x10, +	XFER_PIO_SLOW = 0x00 +};  /*   * ATA Commands (only mandatory commands listed here)   */ diff --git a/include/configs/sc520_cdp.h b/include/configs/sc520_cdp.h index d7d07a62f..8b2ec077b 100644 --- a/include/configs/sc520_cdp.h +++ b/include/configs/sc520_cdp.h @@ -182,6 +182,15 @@  #undef  CONFIG_IDE_RESET_ROUTINE	/* no special reset function */  /************************************************************ +*SATA/Native Stuff +************************************************************/ +#define CFG_SATA_SUPPORTED      1 +#define CFG_SATA_MAXBUS         2       /*Max Sata buses supported */ +#define CFG_SATA_DEVS_PER_BUS   2      /*Max no. of devices per bus/port */ +#define CFG_SATA_MAXDEVICES     (CFG_SATA_MAXBUS* CFG_SATA_DEVS_PER_BUS) +#define CFG_ATA_PIIX            1       /*Supports ata_piix driver */ + +/************************************************************   * ATAPI support (experimental)   ************************************************************/  #define CONFIG_ATAPI			/* enable ATAPI Support */ diff --git a/include/sata.h b/include/sata.h new file mode 100644 index 000000000..c6fa2ab5b --- /dev/null +++ b/include/sata.h @@ -0,0 +1,108 @@ + +#if (DEBUG_SATA) +#define PRINTF(fmt,args...)	printf (fmt ,##args) +#else +#define PRINTF(fmt,args...) +#endif + +struct sata_ioports { +	unsigned long cmd_addr; +	unsigned long data_addr; +	unsigned long error_addr; +	unsigned long feature_addr; +	unsigned long nsect_addr; +	unsigned long lbal_addr; +	unsigned long lbam_addr; +	unsigned long lbah_addr; +	unsigned long device_addr; +	unsigned long status_addr; +	unsigned long command_addr; +	unsigned long altstatus_addr; +	unsigned long ctl_addr; +	unsigned long bmdma_addr; +	unsigned long scr_addr; +}; + +struct sata_port { +	unsigned char port_no;	/*primary-0, secondary=1 */ +	struct sata_ioports ioaddr;	/*ATA cmd/ctl/dma reg blks */ +	unsigned char ctl_reg; +	unsigned char last_ctl; +	unsigned char port_state;	/*1-port is present and  +					   0-port is not available */ +	unsigned char dev_mask; +}; + +/***********SATA LIBRARY SPECIFIC DEFINITIONS AND DECLARATIONS**************/ +#ifdef SATA_DECL		/*SATA library specific declarations */ +#define ata_id_has_lba48(id)    ((id)[83] & (1 << 10)) +#define ata_id_has_lba(id)      ((id)[49] & (1 << 9)) +#define ata_id_has_dma(id)      ((id)[49] & (1 << 8)) +#define ata_id_u32(id,n)        \ +	(((u32) (id)[(n) + 1] << 16) | ((u32) (id)[(n)])) +#define ata_id_u64(id,n)        \ +	(((u64) (id)[(n) + 3] << 48) | \ +	((u64) (id)[(n) + 2] << 32) | \ +	((u64) (id)[(n) + 1] << 16) | \ +	((u64) (id)[(n) + 0]) ) +#endif + +#ifdef SATA_DECL		/*SATA library specific declarations */ +static inline void +ata_dump_id (u16 * id) +{ +	PRINTF ("49==0x%04x  " +		"53==0x%04x  " +		"63==0x%04x  " +		"64==0x%04x  " +		"75==0x%04x  \n", id[49], id[53], id[63], id[64], id[75]); +	PRINTF ("80==0x%04x  " +		"81==0x%04x  " +		"82==0x%04x  " +		"83==0x%04x  " +		"84==0x%04x  \n", id[80], id[81], id[82], id[83], id[84]); +	PRINTF ("88==0x%04x  " "93==0x%04x\n", id[88], id[93]); +} +#endif + +#ifdef SATA_DECL		/*SATA library specific declarations */ +int sata_bus_softreset (int num); +void sata_identify (int num, int dev); +void sata_port (struct sata_ioports *ioport); +void set_Feature_cmd (int num, int dev); +int sata_devchk (struct sata_ioports *ioaddr, int dev); +void dev_select (struct sata_ioports *ioaddr, int dev); +u8 sata_busy_wait (struct sata_ioports *ioaddr, int bits, unsigned int max); +u8 sata_chk_status (struct sata_ioports *ioaddr); +ulong sata_read (int device, lbaint_t blknr, ulong blkcnt, ulong * buffer); +ulong sata_write (int device, lbaint_t blknr, ulong blkcnt, ulong * buffer); +void msleep (int count); +#else +extern int sata_bus_softreset (int num); +extern void sata_identify (int num, int dev); +extern void sata_port (struct sata_ioports *ioport); +extern void set_Feature_cmd (int num, int dev); +extern ulong sata_read (int device, lbaint_t blknr, +			ulong blkcnt, ulong * buffer); +extern ulong sata_write (int device, lbaint_t blknr, +			 ulong blkcnt, ulong * buffer); +extern void msleep (int count); +#endif + +/************DRIVER SPECIFIC DEFINITIONS AND DECLARATIONS**************/ + +#ifdef DRV_DECL			/*Driver specific declaration */ +int init_sata (void); +#else +extern int init_sata (void); +#endif + +#ifdef DRV_DECL			/*Defines Driver Specific variables */ +struct sata_port port[CFG_SATA_MAXBUS]; +block_dev_desc_t sata_dev_desc[CFG_SATA_MAXDEVICES]; +int curr_dev = -1; +#else +extern struct sata_port port[CFG_SATA_MAXBUS]; +extern block_dev_desc_t sata_dev_desc[CFG_SATA_MAXDEVICES]; +extern int curr_dev; +#endif |