#include <asm/byteorder.h>
#include <asm/io.h>
+#ifndef KERNEL_VERSION
+#define KERNEL_VERSION(x,y,z) (((x)<<16)+((y)<<8)+(z))
+#endif
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
#include <linux/interrupt.h> /* For tasklet support. */
#include <linux/config.h>
#include <linux/slab.h>
+#else
+#include <linux/malloc.h>
+#endif
/* Core SCSI definitions */
#define AIC_LIB_PREFIX ahc
/***************************** Bus Space/DMA **********************************/
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,2,17)
+typedef dma_addr_t bus_addr_t;
+#else
+typedef uint32_t bus_addr_t;
+#endif
typedef uint32_t bus_size_t;
typedef enum {
typedef union {
u_long ioport;
- volatile uint8_t __iomem *maddr;
+ volatile uint8_t *maddr;
} bus_space_handle_t;
typedef struct bus_dma_segment
{
- dma_addr_t ds_addr;
+ bus_addr_t ds_addr;
bus_size_t ds_len;
} bus_dma_segment_t;
struct ahc_linux_dmamap
{
- dma_addr_t bus_addr;
+ bus_addr_t bus_addr;
};
typedef struct ahc_linux_dmamap* bus_dmamap_t;
-typedef int bus_dma_filter_t(void*, dma_addr_t);
+typedef int bus_dma_filter_t(void*, bus_addr_t);
typedef void bus_dmamap_callback_t(void *, bus_dma_segment_t *, int, int);
#define BUS_DMA_WAITOK 0x0
int ahc_dma_tag_create(struct ahc_softc *, bus_dma_tag_t /*parent*/,
bus_size_t /*alignment*/, bus_size_t /*boundary*/,
- dma_addr_t /*lowaddr*/, dma_addr_t /*highaddr*/,
+ bus_addr_t /*lowaddr*/, bus_addr_t /*highaddr*/,
bus_dma_filter_t*/*filter*/, void */*filterarg*/,
bus_size_t /*maxsize*/, int /*nsegments*/,
bus_size_t /*maxsegsz*/, int /*flags*/,
}
/***************************** SMP support ************************************/
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,17)
#include <linux/spinlock.h>
+#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,93)
+#include <linux/smp.h>
+#endif
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) || defined(SCSI_HAS_HOST_LOCK))
#define AHC_SCSI_HAS_HOST_LOCK 1
struct scb_platform_data {
struct ahc_linux_device *dev;
- dma_addr_t buf_busaddr;
+ bus_addr_t buf_busaddr;
uint32_t xfer_len;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0)
+ uint32_t resid; /* Transfer residual */
+#endif
uint32_t sense_resid; /* Auto-Sense residual */
ahc_linux_scb_flags flags;
};
struct ahc_completeq completeq;
spinlock_t spin_lock;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
struct tasklet_struct runq_tasklet;
+#endif
u_int qfrozen;
pid_t dv_pid;
struct timer_list completeq_timer;
uint32_t irq; /* IRQ for this adapter */
uint32_t bios_address;
uint32_t mem_busaddr; /* Mem Base Addr */
- uint64_t hw_dma_mask;
+ bus_addr_t hw_dma_mask;
ahc_linux_softc_flags flags;
};
#define PCIR_SUBVEND_0 0x2c
#define PCIR_SUBDEV_0 0x2e
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
extern struct pci_driver aic7xxx_pci_driver;
+#endif
typedef enum
{
ahc_inb(ahc, INTSTAT);
}
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,3,0)
+#define pci_map_sg(pdev, sg_list, nseg, direction) (nseg)
+#define pci_unmap_sg(pdev, sg_list, nseg, direction)
+#define sg_dma_address(sg) (VIRT_TO_BUS((sg)->address))
+#define sg_dma_len(sg) ((sg)->length)
+#define pci_map_single(pdev, buffer, bufflen, direction) \
+ (VIRT_TO_BUS(buffer))
+#define pci_unmap_single(pdev, buffer, buflen, direction)
+#endif
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,3)
+#define ahc_pci_set_dma_mask pci_set_dma_mask
+#else
+/*
+ * Always "return" 0 for success.
+ */
+#define ahc_pci_set_dma_mask(dev_softc, mask) \
+ (((dev_softc)->dma_mask = mask) && 0)
+#endif
/**************************** Proc FS Support *********************************/
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
int ahc_linux_proc_info(char *, char **, off_t, int, int, int);
static __inline
int ahc_get_transfer_dir(struct scb *scb)
{
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,40)
return (scb->io_ctx->sc_data_direction);
+#else
+ if (scb->io_ctx->bufflen == 0)
+ return (CAM_DIR_NONE);
+
+ switch(scb->io_ctx->cmnd[0]) {
+ case 0x08: /* READ(6) */
+ case 0x28: /* READ(10) */
+ case 0xA8: /* READ(12) */
+ return (CAM_DIR_IN);
+ case 0x0A: /* WRITE(6) */
+ case 0x2A: /* WRITE(10) */
+ case 0xAA: /* WRITE(12) */
+ return (CAM_DIR_OUT);
+ default:
+ return (CAM_DIR_NONE);
+ }
+#endif
}
static __inline
void ahc_set_residual(struct scb *scb, u_long resid)
{
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,0)
scb->io_ctx->resid = resid;
+#else
+ scb->platform_data->resid = resid;
+#endif
}
static __inline
static __inline
u_long ahc_get_residual(struct scb *scb)
{
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,0)
return (scb->io_ctx->resid);
+#else
+ return (scb->platform_data->resid);
+#endif
}
static __inline