42 #ifndef _AIC79XX_LINUX_H_
43 #define _AIC79XX_LINUX_H_
45 #include <linux/types.h>
49 #include <linux/pci.h>
51 #include <linux/module.h>
52 #include <linux/slab.h>
53 #include <asm/byteorder.h>
56 #include <scsi/scsi.h>
66 #define AIC_LIB_PREFIX ahd
80 #ifdef CONFIG_AIC79XX_DEBUG_ENABLE
81 #ifdef CONFIG_AIC79XX_DEBUG_MASK
83 #define AHD_DEBUG_OPTS CONFIG_AIC79XX_DEBUG_MASK
89 #define AHD_DEBUG_OPTS 0
95 #define powerof2(x) ((((x)-1)&(x))==0)
103 #define ahd_htobe16(x) cpu_to_be16(x)
104 #define ahd_htobe32(x) cpu_to_be32(x)
105 #define ahd_htobe64(x) cpu_to_be64(x)
106 #define ahd_htole16(x) cpu_to_le16(x)
107 #define ahd_htole32(x) cpu_to_le32(x)
108 #define ahd_htole64(x) cpu_to_le64(x)
110 #define ahd_be16toh(x) be16_to_cpu(x)
111 #define ahd_be32toh(x) be32_to_cpu(x)
112 #define ahd_be64toh(x) be64_to_cpu(x)
113 #define ahd_le16toh(x) le16_to_cpu(x)
114 #define ahd_le32toh(x) le32_to_cpu(x)
115 #define ahd_le64toh(x) le64_to_cpu(x)
154 #define BUS_DMA_WAITOK 0x0
155 #define BUS_DMA_NOWAIT 0x1
156 #define BUS_DMA_ALLOCNOW 0x2
157 #define BUS_DMA_LOAD_SEGS 0x4
162 #define BUS_SPACE_MAXADDR 0xFFFFFFFF
163 #define BUS_SPACE_MAXADDR_32BIT 0xFFFFFFFF
164 #define BUS_SPACE_MAXSIZE_32BIT 0xFFFFFFFF
196 #define BUS_DMASYNC_PREREAD 0x01
197 #define BUS_DMASYNC_POSTREAD 0x02
198 #define BUS_DMASYNC_PREWRITE 0x04
199 #define BUS_DMASYNC_POSTWRITE 0x08
209 #define ahd_dmamap_sync(ahd, dma_tag, dmamap, offset, len, op)
215 #ifdef CONFIG_AIC79XX_REG_PRETTY_PRINT
216 #define AIC_DEBUG_REGISTERS 1
218 #define AIC_DEBUG_REGISTERS 0
223 #define ahd_timer_init init_timer
224 #define ahd_timer_stop del_timer_sync
229 #define AIC79XX_DRIVER_VERSION "3.0"
284 #define AHD_TAG_SUCCESS_INTERVAL 50
311 #define AHD_LOCK_TAGS_COUNT 50
323 #define AHD_OTAG_THRESH 500
360 #define AHD_LINUX_NOIRQ ((uint32_t)~0)
406 spin_unlock_irqrestore(&ahd->
platform_data->spin_lock, *flags);
419 #define PCIR_DEVVENDOR 0x00
420 #define PCIR_VENDOR 0x00
421 #define PCIR_DEVICE 0x02
422 #define PCIR_COMMAND 0x04
423 #define PCIM_CMD_PORTEN 0x0001
424 #define PCIM_CMD_MEMEN 0x0002
425 #define PCIM_CMD_BUSMASTEREN 0x0004
426 #define PCIM_CMD_MWRICEN 0x0010
427 #define PCIM_CMD_PERRESPEN 0x0040
428 #define PCIM_CMD_SERRESPEN 0x0100
429 #define PCIR_STATUS 0x06
430 #define PCIR_REVID 0x08
431 #define PCIR_PROGIF 0x09
432 #define PCIR_SUBCLASS 0x0a
433 #define PCIR_CLASS 0x0b
434 #define PCIR_CACHELNSZ 0x0c
435 #define PCIR_LATTIMER 0x0d
436 #define PCIR_HEADERTYPE 0x0e
437 #define PCIM_MFDEV 0x80
438 #define PCIR_BIST 0x0f
439 #define PCIR_CAP_PTR 0x34
442 #define PCIR_MAPS 0x10
443 #define PCIR_SUBVEND_0 0x2c
444 #define PCIR_SUBDEV_0 0x2e
447 #define PCIXR_COMMAND 0x96
448 #define PCIXR_DEVADDR 0x98
449 #define PCIXM_DEVADDR_FNUM 0x0003
450 #define PCIXM_DEVADDR_DNUM 0x00F8
451 #define PCIXM_DEVADDR_BNUM 0xFF00
452 #define PCIXR_STATUS 0x9A
453 #define PCIXM_STATUS_64BIT 0x0001
454 #define PCIXM_STATUS_133CAP 0x0002
455 #define PCIXM_STATUS_SCDISC 0x0004
456 #define PCIXM_STATUS_UNEXPSC 0x0008
457 #define PCIXM_STATUS_CMPLEXDEV 0x0010
458 #define PCIXM_STATUS_MAXMRDBC 0x0060
459 #define PCIXM_STATUS_MAXSPLITS 0x0380
460 #define PCIXM_STATUS_MAXCRDS 0x1C00
461 #define PCIXM_STATUS_RCVDSCEM 0x2000
486 static inline int ahd_get_pci_function(ahd_dev_softc_t);
488 ahd_get_pci_function(ahd_dev_softc_t pci)
493 static inline int ahd_get_pci_slot(ahd_dev_softc_t);
495 ahd_get_pci_slot(ahd_dev_softc_t pci)
500 static inline int ahd_get_pci_bus(ahd_dev_softc_t);
502 ahd_get_pci_bus(ahd_dev_softc_t pci)
504 return (pci->
bus->number);
507 static inline void ahd_flush_device_writes(
struct ahd_softc *);
509 ahd_flush_device_writes(
struct ahd_softc *ahd)
521 static inline void ahd_set_transaction_status(
struct scb *,
uint32_t);
523 static inline void ahd_set_scsi_status(
struct scb *,
uint32_t);
525 static inline uint32_t ahd_get_transaction_status(
struct scb *);
527 static inline uint32_t ahd_get_scsi_status(
struct scb *);
528 static inline void ahd_set_transaction_tag(
struct scb *,
int,
u_int);
529 static inline u_long ahd_get_transfer_length(
struct scb *);
530 static inline int ahd_get_transfer_dir(
struct scb *);
531 static inline void ahd_set_residual(
struct scb *,
u_long);
532 static inline void ahd_set_sense_residual(
struct scb *
scb,
u_long resid);
533 static inline u_long ahd_get_residual(
struct scb *);
534 static inline u_long ahd_get_sense_residual(
struct scb *);
535 static inline int ahd_perform_autosense(
struct scb *);
538 static inline void ahd_notify_xfer_settings_change(
struct ahd_softc *,
540 static inline void ahd_platform_scb_free(
struct ahd_softc *ahd,
542 static inline void ahd_freeze_scb(
struct scb *
scb);
548 cmd->
result |= status << 16;
554 ahd_cmd_set_transaction_status(scb->
io_ctx,status);
567 ahd_cmd_set_scsi_status(scb->
io_ctx, status);
579 return (ahd_cmd_get_transaction_status(scb->
io_ctx));
585 return (cmd->
result & 0xFFFF);
589 uint32_t ahd_get_scsi_status(
struct scb *scb)
591 return (ahd_cmd_get_scsi_status(scb->
io_ctx));
604 u_long ahd_get_transfer_length(
struct scb *scb)
610 int ahd_get_transfer_dir(
struct scb *scb)
616 void ahd_set_residual(
struct scb *scb,
u_long resid)
618 scsi_set_resid(scb->
io_ctx, resid);
622 void ahd_set_sense_residual(
struct scb *scb,
u_long resid)
628 u_long ahd_get_residual(
struct scb *scb)
630 return scsi_get_resid(scb->
io_ctx);
634 u_long ahd_get_sense_residual(
struct scb *scb)
640 int ahd_perform_autosense(
struct scb *scb)
651 ahd_get_sense_bufsize(
struct ahd_softc *ahd,
struct scb *scb)
657 ahd_notify_xfer_settings_change(
struct ahd_softc *ahd,
664 ahd_platform_scb_free(
struct ahd_softc *ahd,
struct scb *scb)
675 ahd_freeze_scb(
struct scb *scb)
696 #define AHD_PCI_CONFIG 1
698 #define AHD_PCI_CONFIG 0
700 #define bootverbose aic79xx_verbose