⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 libata.h

📁 Axis 221 camera embedded programing interface
💻 H
📖 第 1 页 / 共 3 页
字号:
/* *  Copyright 2003-2005 Red Hat, Inc.  All rights reserved. *  Copyright 2003-2005 Jeff Garzik * * *  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, or (at your option) *  any later version. * *  This program is distributed in the hope that it will be useful, *  but WITHOUT ANY WARRANTY; without even the implied warranty of *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the *  GNU General Public License for more details. * *  You should have received a copy of the GNU General Public License *  along with this program; see the file COPYING.  If not, write to *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * * *  libata documentation is available via 'make {ps|pdf}docs', *  as Documentation/DocBook/libata.* * */#ifndef __LINUX_LIBATA_H__#define __LINUX_LIBATA_H__#include <linux/delay.h>#include <linux/interrupt.h>#include <linux/pci.h>#include <linux/dma-mapping.h>#include <asm/scatterlist.h>#include <asm/io.h>#include <linux/ata.h>#include <linux/workqueue.h>#include <scsi/scsi_host.h>/* * Define if arch has non-standard setup.  This is a _PCI_ standard * not a legacy or ISA standard. */#ifdef CONFIG_ATA_NONSTANDARD#include <asm/libata-portmap.h>#else#include <asm-generic/libata-portmap.h>#endif/* * compile-time options: to be removed as soon as all the drivers are * converted to the new debugging mechanism */#undef ATA_DEBUG		/* debugging output */#undef ATA_VERBOSE_DEBUG	/* yet more debugging output */#undef ATA_IRQ_TRAP		/* define to ack screaming irqs */#undef ATA_NDEBUG		/* define to disable quick runtime checks */#define ATA_ENABLE_PATA		/* define to enable PATA support in some				 * low-level drivers *//* note: prints function name for you */#ifdef ATA_DEBUG#define DPRINTK(fmt, args...) printk(KERN_ERR "%s: " fmt, __FUNCTION__, ## args)#ifdef ATA_VERBOSE_DEBUG#define VPRINTK(fmt, args...) printk(KERN_ERR "%s: " fmt, __FUNCTION__, ## args)#else#define VPRINTK(fmt, args...)#endif	/* ATA_VERBOSE_DEBUG */#else#define DPRINTK(fmt, args...)#define VPRINTK(fmt, args...)#endif	/* ATA_DEBUG */#define BPRINTK(fmt, args...) if (ap->flags & ATA_FLAG_DEBUGMSG) printk(KERN_ERR "%s: " fmt, __FUNCTION__, ## args)/* NEW: debug levels */#define HAVE_LIBATA_MSG 1enum {	ATA_MSG_DRV	= 0x0001,	ATA_MSG_INFO	= 0x0002,	ATA_MSG_PROBE	= 0x0004,	ATA_MSG_WARN	= 0x0008,	ATA_MSG_MALLOC	= 0x0010,	ATA_MSG_CTL	= 0x0020,	ATA_MSG_INTR	= 0x0040,	ATA_MSG_ERR	= 0x0080,};#define ata_msg_drv(p)    ((p)->msg_enable & ATA_MSG_DRV)#define ata_msg_info(p)   ((p)->msg_enable & ATA_MSG_INFO)#define ata_msg_probe(p)  ((p)->msg_enable & ATA_MSG_PROBE)#define ata_msg_warn(p)   ((p)->msg_enable & ATA_MSG_WARN)#define ata_msg_malloc(p) ((p)->msg_enable & ATA_MSG_MALLOC)#define ata_msg_ctl(p)    ((p)->msg_enable & ATA_MSG_CTL)#define ata_msg_intr(p)   ((p)->msg_enable & ATA_MSG_INTR)#define ata_msg_err(p)    ((p)->msg_enable & ATA_MSG_ERR)static inline u32 ata_msg_init(int dval, int default_msg_enable_bits){	if (dval < 0 || dval >= (sizeof(u32) * 8))		return default_msg_enable_bits; /* should be 0x1 - only driver info msgs */	if (!dval)		return 0;	return (1 << dval) - 1;}/* defines only for the constants which don't work well as enums */#define ATA_TAG_POISON		0xfafbfcfdU/* move to PCI layer? */#define PCI_VDEVICE(vendor, device)		\	PCI_VENDOR_ID_##vendor, (device),	\	PCI_ANY_ID, PCI_ANY_ID, 0, 0static inline struct device *pci_dev_to_dev(struct pci_dev *pdev){	return &pdev->dev;}enum {	/* various global constants */	LIBATA_MAX_PRD		= ATA_MAX_PRD / 2,	ATA_MAX_PORTS		= 8,	ATA_DEF_QUEUE		= 1,	/* tag ATA_MAX_QUEUE - 1 is reserved for internal commands */	ATA_MAX_QUEUE		= 32,	ATA_TAG_INTERNAL	= ATA_MAX_QUEUE - 1,	ATA_MAX_BUS		= 2,	ATA_DEF_BUSY_WAIT	= 10000,	ATA_SHORT_PAUSE		= (HZ >> 6) + 1,	ATA_SHT_EMULATED	= 1,	ATA_SHT_CMD_PER_LUN	= 1,	ATA_SHT_THIS_ID		= -1,	ATA_SHT_USE_CLUSTERING	= 1,	/* struct ata_device stuff */	ATA_DFLAG_LBA		= (1 << 0), /* device supports LBA */	ATA_DFLAG_LBA48		= (1 << 1), /* device supports LBA48 */	ATA_DFLAG_CDB_INTR	= (1 << 2), /* device asserts INTRQ when ready for CDB */	ATA_DFLAG_NCQ		= (1 << 3), /* device supports NCQ */	ATA_DFLAG_FLUSH_EXT	= (1 << 4), /* do FLUSH_EXT instead of FLUSH */	ATA_DFLAG_CFG_MASK	= (1 << 8) - 1,	ATA_DFLAG_PIO		= (1 << 8), /* device limited to PIO mode */	ATA_DFLAG_NCQ_OFF	= (1 << 9), /* device limited to non-NCQ mode */	ATA_DFLAG_SUSPENDED	= (1 << 10), /* device suspended */	ATA_DFLAG_INIT_MASK	= (1 << 16) - 1,	ATA_DFLAG_DETACH	= (1 << 16),	ATA_DFLAG_DETACHED	= (1 << 17),	ATA_DEV_UNKNOWN		= 0,	/* unknown device */	ATA_DEV_ATA		= 1,	/* ATA device */	ATA_DEV_ATA_UNSUP	= 2,	/* ATA device (unsupported) */	ATA_DEV_ATAPI		= 3,	/* ATAPI device */	ATA_DEV_ATAPI_UNSUP	= 4,	/* ATAPI device (unsupported) */	ATA_DEV_NONE		= 5,	/* no device */	/* struct ata_port flags */	ATA_FLAG_SLAVE_POSS	= (1 << 0), /* host supports slave dev */					    /* (doesn't imply presence) */	ATA_FLAG_SATA		= (1 << 1),	ATA_FLAG_NO_LEGACY	= (1 << 2), /* no legacy mode check */	ATA_FLAG_MMIO		= (1 << 3), /* use MMIO, not PIO */	ATA_FLAG_SRST		= (1 << 4), /* (obsolete) use ATA SRST, not E.D.D. */	ATA_FLAG_SATA_RESET	= (1 << 5), /* (obsolete) use COMRESET */	ATA_FLAG_NO_ATAPI	= (1 << 6), /* No ATAPI support */	ATA_FLAG_PIO_DMA	= (1 << 7), /* PIO cmds via DMA */	ATA_FLAG_PIO_LBA48	= (1 << 8), /* Host DMA engine is LBA28 only */	ATA_FLAG_PIO_POLLING	= (1 << 9), /* use polling PIO if LLD					     * doesn't handle PIO interrupts */	ATA_FLAG_NCQ		= (1 << 10), /* host supports NCQ */	ATA_FLAG_HRST_TO_RESUME	= (1 << 11), /* hardreset to resume phy */	ATA_FLAG_SKIP_D2H_BSY	= (1 << 12), /* can't wait for the first D2H					      * Register FIS clearing BSY */	ATA_FLAG_DEBUGMSG	= (1 << 13),	ATA_FLAG_SETXFER_POLLING= (1 << 14), /* use polling for SETXFER */	ATA_FLAG_IGN_SIMPLEX	= (1 << 15), /* ignore SIMPLEX */	/* The following flag belongs to ap->pflags but is kept in	 * ap->flags because it's referenced in many LLDs and will be	 * removed in not-too-distant future.	 */	ATA_FLAG_DISABLED	= (1 << 23), /* port is disabled, ignore it */	/* bits 24:31 of ap->flags are reserved for LLD specific flags */	/* struct ata_port pflags */	ATA_PFLAG_EH_PENDING	= (1 << 0), /* EH pending */	ATA_PFLAG_EH_IN_PROGRESS = (1 << 1), /* EH in progress */	ATA_PFLAG_FROZEN	= (1 << 2), /* port is frozen */	ATA_PFLAG_RECOVERED	= (1 << 3), /* recovery action performed */	ATA_PFLAG_LOADING	= (1 << 4), /* boot/loading probe */	ATA_PFLAG_UNLOADING	= (1 << 5), /* module is unloading */	ATA_PFLAG_SCSI_HOTPLUG	= (1 << 6), /* SCSI hotplug scheduled */	ATA_PFLAG_FLUSH_PORT_TASK = (1 << 16), /* flush port task */	ATA_PFLAG_SUSPENDED	= (1 << 17), /* port is suspended (power) */	ATA_PFLAG_PM_PENDING	= (1 << 18), /* PM operation pending */	/* struct ata_queued_cmd flags */	ATA_QCFLAG_ACTIVE	= (1 << 0), /* cmd not yet ack'd to scsi lyer */	ATA_QCFLAG_SG		= (1 << 1), /* have s/g table? */	ATA_QCFLAG_SINGLE	= (1 << 2), /* no s/g, just a single buffer */	ATA_QCFLAG_DMAMAP	= ATA_QCFLAG_SG | ATA_QCFLAG_SINGLE,	ATA_QCFLAG_IO		= (1 << 3), /* standard IO command */	ATA_QCFLAG_RESULT_TF	= (1 << 4), /* result TF requested */	ATA_QCFLAG_FAILED	= (1 << 16), /* cmd failed and is owned by EH */	ATA_QCFLAG_SENSE_VALID	= (1 << 17), /* sense data valid */	ATA_QCFLAG_EH_SCHEDULED = (1 << 18), /* EH scheduled (obsolete) */	/* host set flags */	ATA_HOST_SIMPLEX	= (1 << 0),	/* Host is simplex, one DMA channel per host only */	/* various lengths of time */	ATA_TMOUT_BOOT		= 30 * HZ,	/* heuristic */	ATA_TMOUT_BOOT_QUICK	= 7 * HZ,	/* heuristic */	ATA_TMOUT_INTERNAL	= 30 * HZ,	ATA_TMOUT_INTERNAL_QUICK = 5 * HZ,	/* ATA bus states */	BUS_UNKNOWN		= 0,	BUS_DMA			= 1,	BUS_IDLE		= 2,	BUS_NOINTR		= 3,	BUS_NODATA		= 4,	BUS_TIMER		= 5,	BUS_PIO			= 6,	BUS_EDD			= 7,	BUS_IDENTIFY		= 8,	BUS_PACKET		= 9,	/* SATA port states */	PORT_UNKNOWN		= 0,	PORT_ENABLED		= 1,	PORT_DISABLED		= 2,	/* encoding various smaller bitmaps into a single	 * unsigned int bitmap	 */	ATA_BITS_PIO		= 7,	ATA_BITS_MWDMA		= 5,	ATA_BITS_UDMA		= 8,	ATA_SHIFT_PIO		= 0,	ATA_SHIFT_MWDMA		= ATA_SHIFT_PIO + ATA_BITS_PIO,	ATA_SHIFT_UDMA		= ATA_SHIFT_MWDMA + ATA_BITS_MWDMA,	ATA_MASK_PIO		= ((1 << ATA_BITS_PIO) - 1) << ATA_SHIFT_PIO,	ATA_MASK_MWDMA		= ((1 << ATA_BITS_MWDMA) - 1) << ATA_SHIFT_MWDMA,	ATA_MASK_UDMA		= ((1 << ATA_BITS_UDMA) - 1) << ATA_SHIFT_UDMA,	/* size of buffer to pad xfers ending on unaligned boundaries */	ATA_DMA_PAD_SZ		= 4,	ATA_DMA_PAD_BUF_SZ	= ATA_DMA_PAD_SZ * ATA_MAX_QUEUE,	/* masks for port functions */	ATA_PORT_PRIMARY	= (1 << 0),	ATA_PORT_SECONDARY	= (1 << 1),	/* ering size */	ATA_ERING_SIZE		= 32,	/* desc_len for ata_eh_info and context */	ATA_EH_DESC_LEN		= 80,	/* reset / recovery action types */	ATA_EH_REVALIDATE	= (1 << 0),	ATA_EH_SOFTRESET	= (1 << 1),	ATA_EH_HARDRESET	= (1 << 2),	ATA_EH_SUSPEND		= (1 << 3),	ATA_EH_RESUME		= (1 << 4),	ATA_EH_PM_FREEZE	= (1 << 5),	ATA_EH_RESET_MASK	= ATA_EH_SOFTRESET | ATA_EH_HARDRESET,	ATA_EH_PERDEV_MASK	= ATA_EH_REVALIDATE | ATA_EH_SUSPEND |				  ATA_EH_RESUME | ATA_EH_PM_FREEZE,	/* ata_eh_info->flags */	ATA_EHI_HOTPLUGGED	= (1 << 0),  /* could have been hotplugged */	ATA_EHI_RESUME_LINK	= (1 << 1),  /* resume link (reset modifier) */	ATA_EHI_NO_AUTOPSY	= (1 << 2),  /* no autopsy */	ATA_EHI_QUIET		= (1 << 3),  /* be quiet */	ATA_EHI_DID_RESET	= (1 << 16), /* already reset this port */	ATA_EHI_PRINTINFO	= (1 << 17), /* print configuration info */	ATA_EHI_SETMODE		= (1 << 18), /* configure transfer mode */	ATA_EHI_POST_SETMODE	= (1 << 19), /* revaildating after setmode */	ATA_EHI_RESET_MODIFIER_MASK = ATA_EHI_RESUME_LINK,	/* max repeat if error condition is still set after ->error_handler */	ATA_EH_MAX_REPEAT	= 5,	/* how hard are we gonna try to probe/recover devices */	ATA_PROBE_MAX_TRIES	= 3,	ATA_EH_RESET_TRIES	= 3,	ATA_EH_DEV_TRIES	= 3,	/* Drive spinup time (time from power-on to the first D2H FIS)	 * in msecs - 8s currently.  Failing to get ready in this time	 * isn't critical.  It will result in reset failure for	 * controllers which can't wait for the first D2H FIS.  libata	 * will retry, so it just has to be long enough to spin up	 * most devices.	 */	ATA_SPINUP_WAIT		= 8000,		/* Horkage types. May be set by libata or controller on drives	   (some horkage may be drive/controller pair dependant */	ATA_HORKAGE_DIAGNOSTIC	= (1 << 0),	/* Failed boot diag */	ATA_HORKAGE_NODMA	= (1 << 1),	/* DMA problems */	ATA_HORKAGE_NONCQ	= (1 << 2),	/* Don't use NCQ */};enum hsm_task_states {	HSM_ST_IDLE,		/* no command on going */	HSM_ST,			/* (waiting the device to) transfer data */	HSM_ST_LAST,		/* (waiting the device to) complete command */	HSM_ST_ERR,		/* error */	HSM_ST_FIRST,		/* (waiting the device to)				   write CDB or first data block */};enum ata_completion_errors {	AC_ERR_DEV		= (1 << 0), /* device reported error */	AC_ERR_HSM		= (1 << 1), /* host state machine violation */	AC_ERR_TIMEOUT		= (1 << 2), /* timeout */	AC_ERR_MEDIA		= (1 << 3), /* media error */	AC_ERR_ATA_BUS		= (1 << 4), /* ATA bus error */	AC_ERR_HOST_BUS		= (1 << 5), /* host bus error */	AC_ERR_SYSTEM		= (1 << 6), /* system error */	AC_ERR_INVALID		= (1 << 7), /* invalid argument */	AC_ERR_OTHER		= (1 << 8), /* unknown */	AC_ERR_NODEV_HINT	= (1 << 9), /* polling device detection hint */};/* forward declarations */struct scsi_device;struct ata_port_operations;struct ata_port;struct ata_queued_cmd;/* typedefs */typedef void (*ata_qc_cb_t) (struct ata_queued_cmd *qc);typedef int (*ata_prereset_fn_t)(struct ata_port *ap);typedef int (*ata_reset_fn_t)(struct ata_port *ap, unsigned int *classes);typedef void (*ata_postreset_fn_t)(struct ata_port *ap, unsigned int *classes);struct ata_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 ata_probe_ent {	struct list_head	node;	struct device 		*dev;	const struct ata_port_operations *port_ops;	struct scsi_host_template *sht;	struct ata_ioports	port[ATA_MAX_PORTS];	unsigned int		n_ports;	unsigned int		dummy_port_mask;	unsigned int		pio_mask;	unsigned int		mwdma_mask;	unsigned int		udma_mask;	unsigned long		irq;	unsigned long		irq2;	unsigned int		irq_flags;	unsigned long		port_flags;	unsigned long		_host_flags;	void __iomem		*mmio_base;	void			*private_data;	/* port_info for the secondary port.  Together with irq2, it's	 * used to implement non-uniform secondary port.  Currently,	 * the only user is ata_piix combined mode.  This workaround	 * will be removed together with ata_probe_ent when init model	 * is updated.	 */	const struct ata_port_info *pinfo2;};struct ata_host {	spinlock_t		lock;	struct device 		*dev;	unsigned long		irq;	unsigned long		irq2;	void __iomem		*mmio_base;	unsigned int		n_ports;	void			*private_data;	const struct ata_port_operations *ops;	unsigned long		flags;	int			simplex_claimed;	/* Keep seperate in case we							   ever need to do this locked */	struct ata_port		*ports[0];};struct ata_queued_cmd {	struct ata_port		*ap;	struct ata_device	*dev;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -