struct map_node {
bus_dmamap_t dmamap;
- bus_addr_t physaddr;
+ dma_addr_t physaddr;
uint8_t *vaddr;
SLIST_ENTRY(map_node) links;
};
struct map_node *sense_map;
void *sg_list;
uint8_t *sense_data;
- bus_addr_t sg_list_busaddr;
- bus_addr_t sense_busaddr;
+ dma_addr_t sg_list_busaddr;
+ dma_addr_t sense_busaddr;
u_int sg_count;/* How full ahd_dma_seg is */
#define AHD_MAX_LQ_CRC_ERRORS 5
u_int crc_retry_count;
bus_dma_tag_t parent_dmat;
bus_dma_tag_t shared_data_dmat;
bus_dmamap_t shared_data_dmamap;
- bus_addr_t shared_data_busaddr;
+ dma_addr_t shared_data_busaddr;
/* Information saved through suspend/resume cycles */
struct ahd_suspend_state suspend_state;
static void
ahd_dmamap_cb(void *arg, bus_dma_segment_t *segs, int nseg, int error)
{
- bus_addr_t *baddr;
+ dma_addr_t *baddr;
- baddr = (bus_addr_t *)arg;
+ baddr = (dma_addr_t *)arg;
*baddr = segs->ds_addr;
}
struct map_node *sense_map;
uint8_t *segs;
uint8_t *sense_data;
- bus_addr_t hscb_busaddr;
- bus_addr_t sg_busaddr;
- bus_addr_t sense_busaddr;
+ dma_addr_t hscb_busaddr;
+ dma_addr_t sg_busaddr;
+ dma_addr_t sense_busaddr;
int newcount;
int i;
{
uint8_t *base_vaddr;
uint8_t *next_vaddr;
- bus_addr_t next_baddr;
+ dma_addr_t next_baddr;
size_t driver_data_size;
int i;
int error;
if (ahd_dma_tag_create(ahd, ahd->parent_dmat, /*alignment*/1,
/*boundary*/BUS_SPACE_MAXADDR_32BIT + 1,
/*lowaddr*/ahd->flags & AHD_39BIT_ADDRESSING
- ? (bus_addr_t)0x7FFFFFFFFFULL
+ ? (dma_addr_t)0x7FFFFFFFFFULL
: BUS_SPACE_MAXADDR_32BIT,
/*highaddr*/BUS_SPACE_MAXADDR,
/*filter*/NULL, /*filterarg*/NULL,
/*********************** Scatter Gather List Handling *************************/
static __inline void *ahd_sg_setup(struct ahd_softc *ahd, struct scb *scb,
- void *sgptr, bus_addr_t addr,
+ void *sgptr, dma_addr_t addr,
bus_size_t len, int last);
static __inline void ahd_setup_scb_common(struct ahd_softc *ahd,
struct scb *scb);
static __inline void *
ahd_sg_setup(struct ahd_softc *ahd, struct scb *scb,
- void *sgptr, bus_addr_t addr, bus_size_t len, int last)
+ void *sgptr, dma_addr_t addr, bus_size_t len, int last)
{
scb->sg_count++;
- if (sizeof(bus_addr_t) > 4
+ if (sizeof(dma_addr_t) > 4
&& (ahd->flags & AHD_64BIT_ADDRESSING) != 0) {
struct ahd_dma64_seg *sg;
static __inline void *
ahd_sg_bus_to_virt(struct ahd_softc *ahd, struct scb *scb, uint32_t sg_busaddr)
{
- bus_addr_t sg_offset;
+ dma_addr_t sg_offset;
/* sg_list_phys points to entry 1, not 0 */
sg_offset = sg_busaddr - (scb->sg_list_busaddr - ahd_sg_size(ahd));
static __inline uint32_t
ahd_sg_virt_to_bus(struct ahd_softc *ahd, struct scb *scb, void *sg)
{
- bus_addr_t sg_offset;
+ dma_addr_t sg_offset;
/* sg_list_phys points to entry 1, not 0 */
sg_offset = ((uint8_t *)sg - (uint8_t *)scb->sg_list)
*/
#include "aiclib.c"
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,0)
#include <linux/init.h> /* __setup */
-#endif
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
#include "sd.h" /* For geometry detection */
*/
spinlock_t ahd_list_spinlock;
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0)
-struct proc_dir_entry proc_scsi_aic79xx = {
- PROC_SCSI_AIC79XX, 7, "aic79xx",
- S_IFDIR | S_IRUGO | S_IXUGO, 2,
- 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL
-};
-#endif
-
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
/* For dynamic sglist size calculation. */
u_int ahd_linux_nseg;
static __inline int ahd_linux_map_seg(struct ahd_softc *ahd, struct scb *scb,
struct ahd_dma_seg *sg,
- bus_addr_t addr, bus_size_t len);
+ dma_addr_t addr, bus_size_t len);
static __inline void
ahd_schedule_completeq(struct ahd_softc *ahd)
static __inline void
ahd_schedule_runq(struct ahd_softc *ahd)
{
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
tasklet_schedule(&ahd->platform_data->runq_tasklet);
-#else
- /*
- * Tasklets are not available, so run inline.
- */
- ahd_runq_tasklet((unsigned long)ahd);
-#endif
}
static __inline
void ahd_setup_runq_tasklet(struct ahd_softc *ahd)
{
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
tasklet_init(&ahd->platform_data->runq_tasklet, ahd_runq_tasklet,
(unsigned long)ahd);
-#endif
}
static __inline void
ahd_teardown_runq_tasklet(struct ahd_softc *ahd)
{
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
tasklet_kill(&ahd->platform_data->runq_tasklet);
-#endif
}
static __inline struct ahd_linux_device*
static __inline int
ahd_linux_map_seg(struct ahd_softc *ahd, struct scb *scb,
- struct ahd_dma_seg *sg, bus_addr_t addr, bus_size_t len)
+ struct ahd_dma_seg *sg, dma_addr_t addr, bus_size_t len)
{
int consumed;
sg->addr = ahd_htole32(addr & 0xFFFFFFFF);
scb->platform_data->xfer_len += len;
- if (sizeof(bus_addr_t) > 4
+ if (sizeof(dma_addr_t) > 4
&& (ahd->flags & AHD_39BIT_ADDRESSING) != 0)
len |= (addr >> 8) & AHD_SG_HIGH_ADDR_MASK;
"aic79xx: insmod or else it might trash certain memory areas.\n");
#endif
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,3,0)
template->proc_name = "aic79xx";
-#else
- template->proc_dir = &proc_scsi_aic79xx;
-#endif
/*
* Initialize our softc list lock prior to
{
struct ahd_softc* ahd;
struct ahd_linux_device *dev;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
u_long flags;
-#endif
ahd = (struct ahd_softc *)data;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
ahd_lock(ahd, &flags);
-#endif
while ((dev = ahd_linux_next_device_to_run(ahd)) != NULL) {
TAILQ_REMOVE(&ahd->platform_data->device_runq, dev, links);
dev->flags &= ~AHD_DEV_ON_RUN_LIST;
ahd_linux_check_device_queue(ahd, dev);
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
/* Yeild to our interrupt handler */
ahd_unlock(ahd, &flags);
ahd_lock(ahd, &flags);
-#endif
}
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
ahd_unlock(ahd, &flags);
-#endif
}
/******************************** Bus DMA *************************************/
int
ahd_dma_tag_create(struct ahd_softc *ahd, bus_dma_tag_t parent,
bus_size_t alignment, bus_size_t boundary,
- bus_addr_t lowaddr, bus_addr_t highaddr,
+ dma_addr_t lowaddr, dma_addr_t highaddr,
bus_dma_filter_t *filter, void *filterarg,
bus_size_t maxsize, int nsegments,
bus_size_t maxsegsz, int flags, bus_dma_tag_t *ret_tag)
{
bus_dmamap_t map;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,0)
map = malloc(sizeof(*map), M_DEVBUF, M_NOWAIT);
if (map == NULL)
return (ENOMEM);
* our dma mask when doing allocations.
*/
if (ahd->dev_softc != NULL)
- if (ahd_pci_set_dma_mask(ahd->dev_softc, 0xFFFFFFFF)) {
+ if (pci_set_dma_mask(ahd->dev_softc, 0xFFFFFFFF)) {
printk(KERN_WARNING "aic79xx: No suitable DMA available.\n");
kfree(map);
return (ENODEV);
*vaddr = pci_alloc_consistent(ahd->dev_softc,
dmat->maxsize, &map->bus_addr);
if (ahd->dev_softc != NULL)
- if (ahd_pci_set_dma_mask(ahd->dev_softc,
+ if (pci_set_dma_mask(ahd->dev_softc,
ahd->platform_data->hw_dma_mask)) {
printk(KERN_WARNING "aic79xx: No suitable DMA available.\n");
kfree(map);
return (ENODEV);
}
-#else /* LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0) */
- /*
- * At least in 2.2.14, malloc is a slab allocator so all
- * allocations are aligned. We assume for these kernel versions
- * that all allocations will be bellow 4Gig, physically contiguous,
- * and accessible via DMA by the controller.
- */
- map = NULL; /* No additional information to store */
- *vaddr = malloc(dmat->maxsize, M_DEVBUF, M_NOWAIT);
-#endif
if (*vaddr == NULL)
return (ENOMEM);
*mapp = map;
ahd_dmamem_free(struct ahd_softc *ahd, bus_dma_tag_t dmat,
void* vaddr, bus_dmamap_t map)
{
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,0)
pci_free_consistent(ahd->dev_softc, dmat->maxsize,
vaddr, map->bus_addr);
-#else
- free(vaddr, M_DEVBUF);
-#endif
}
int
*/
bus_dma_segment_t stack_sg;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,0)
stack_sg.ds_addr = map->bus_addr;
-#else
-#define VIRT_TO_BUS(a) (uint32_t)virt_to_bus((void *)(a))
- stack_sg.ds_addr = VIRT_TO_BUS(buf);
-#endif
stack_sg.ds_len = dmat->maxsize;
cb(cb_arg, &stack_sg, /*nseg*/1, /*error*/0);
return (0);
return 1;
}
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,3,0)
__setup("aic79xx=", aic79xx_setup);
-#endif
uint32_t aic79xx_verbose;
ahd_set_name(ahd, new_name);
}
host->unique_id = ahd->unit;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,4) && \
- LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
scsi_set_pci_device(host, ahd->dev_softc);
#endif
ahd_linux_setup_user_rd_strm_settings(ahd);
ahd->platform_data->completeq_timer.data = (u_long)ahd;
ahd->platform_data->completeq_timer.function =
(ahd_linux_callback_t *)ahd_linux_thread_run_complete_queue;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,0)
init_MUTEX_LOCKED(&ahd->platform_data->eh_sem);
init_MUTEX_LOCKED(&ahd->platform_data->dv_sem);
init_MUTEX_LOCKED(&ahd->platform_data->dv_cmd_sem);
-#else
- ahd->platform_data->eh_sem = MUTEX_LOCKED;
- ahd->platform_data->dv_sem = MUTEX_LOCKED;
- ahd->platform_data->dv_cmd_sem = MUTEX_LOCKED;
-#endif
ahd_setup_runq_tasklet(ahd);
ahd->seltime = (aic79xx_seltime & 0x3) << 4;
return (0);
base_addr = (u_long)ahd->bshs[0].maddr;
base_addr &= PAGE_MASK;
iounmap((void *)base_addr);
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
release_mem_region(ahd->platform_data->mem_busaddr,
0x1000);
-#endif
}
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0) && \
- LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
/*
* In 2.4 we detach from the scsi midlayer before the PCI
* layer invokes our remove callback. No per-instance
cmd->use_sg, dir);
scb->platform_data->xfer_len = 0;
for (sg = scb->sg_list; nseg > 0; nseg--, cur_seg++) {
- bus_addr_t addr;
+ dma_addr_t addr;
bus_size_t len;
addr = sg_dma_address(cur_seg);
}
} else if (cmd->request_bufflen != 0) {
void *sg;
- bus_addr_t addr;
+ dma_addr_t addr;
int dir;
sg = scb->sg_list;
WARN_ON(lun != CAM_LUN_WILDCARD);
scsi_report_device_reset(ahd->platform_data->host,
channel - 'A', target);
-#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,0)
+#else
Scsi_Device *scsi_dev;
/*
break;
}
case AC_BUS_RESET:
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,0)
if (ahd->platform_data->host != NULL) {
scsi_report_bus_reset(ahd->platform_data->host,
channel - 'A');
}
-#endif
break;
default:
panic("ahd_send_async: Unexpected async event");
#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 ahd
/***************************** 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 struct bus_dma_segment
{
- bus_addr_t ds_addr;
+ dma_addr_t ds_addr;
bus_size_t ds_len;
} bus_dma_segment_t;
struct ahd_linux_dmamap
{
- bus_addr_t bus_addr;
+ dma_addr_t bus_addr;
};
typedef struct ahd_linux_dmamap* bus_dmamap_t;
-typedef int bus_dma_filter_t(void*, bus_addr_t);
+typedef int bus_dma_filter_t(void*, dma_addr_t);
typedef void bus_dmamap_callback_t(void *, bus_dma_segment_t *, int, int);
#define BUS_DMA_WAITOK 0x0
int ahd_dma_tag_create(struct ahd_softc *, bus_dma_tag_t /*parent*/,
bus_size_t /*alignment*/, bus_size_t /*boundary*/,
- bus_addr_t /*lowaddr*/, bus_addr_t /*highaddr*/,
+ dma_addr_t /*lowaddr*/, dma_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 AHD_SCSI_HAS_HOST_LOCK 1
struct scb_platform_data {
struct ahd_linux_device *dev;
- bus_addr_t buf_busaddr;
+ dma_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 */
ahd_linux_scb_flags flags;
};
struct ahd_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 */
- bus_addr_t hw_dma_mask;
+ dma_addr_t hw_dma_mask;
ahd_linux_softc_flags flags;
};
#define PCIXM_STATUS_MAXCRDS 0x1C00 /* Maximum Cumulative Read Size */
#define PCIXM_STATUS_RCVDSCEM 0x2000 /* Received a Split Comp w/Error msg */
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
extern struct pci_driver aic79xx_pci_driver;
-#endif
typedef enum
{
ahd_inb(ahd, 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 ahd_pci_set_dma_mask pci_set_dma_mask
-#else
-/*
- * Always "return" 0 for success.
- */
-#define ahd_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 ahd_linux_proc_info(char *, char **, off_t, int, int, int);
static __inline
int ahd_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 ahd_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 ahd_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
#include "aic79xx_osm.h"
#include "aic79xx_inline.h"
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)
-struct pci_device_id
-{
-};
-#endif
-
static int ahd_linux_pci_dev_probe(struct pci_dev *pdev,
const struct pci_device_id *ent);
static int ahd_linux_pci_reserve_io_regions(struct ahd_softc *ahd,
static int ahd_linux_pci_reserve_mem_region(struct ahd_softc *ahd,
u_long *bus_addr,
uint8_t **maddr);
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
static void ahd_linux_pci_dev_remove(struct pci_dev *pdev);
/* We do our own ID filtering. So, grab all SCSI storage class devices. */
}
ahd_list_unlock(&l);
}
-#endif /* !LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0) */
static int
ahd_linux_pci_dev_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
ahd = ahd_alloc(NULL, name);
if (ahd == NULL)
return (-ENOMEM);
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
if (pci_enable_device(pdev)) {
ahd_free(ahd);
return (-ENODEV);
}
pci_set_master(pdev);
- if (sizeof(bus_addr_t) > 4) {
+ if (sizeof(dma_addr_t) > 4) {
uint64_t memsize;
- bus_addr_t mask_64bit;
- bus_addr_t mask_39bit;
+ dma_addr_t mask_64bit;
+ dma_addr_t mask_39bit;
memsize = ahd_linux_get_memsize();
- mask_64bit = (bus_addr_t)0xFFFFFFFFFFFFFFFFULL;
- mask_39bit = (bus_addr_t)0x7FFFFFFFFFULL;
+ mask_64bit = (dma_addr_t)0xFFFFFFFFFFFFFFFFULL;
+ mask_39bit = (dma_addr_t)0x7FFFFFFFFFULL;
if (memsize >= 0x8000000000ULL
- && ahd_pci_set_dma_mask(pdev, mask_64bit) == 0) {
+ && pci_set_dma_mask(pdev, mask_64bit) == 0) {
ahd->flags |= AHD_64BIT_ADDRESSING;
ahd->platform_data->hw_dma_mask = mask_64bit;
} else if (memsize > 0x80000000
- && ahd_pci_set_dma_mask(pdev, mask_39bit) == 0) {
+ && pci_set_dma_mask(pdev, mask_39bit) == 0) {
ahd->flags |= AHD_39BIT_ADDRESSING;
ahd->platform_data->hw_dma_mask = mask_39bit;
}
} else {
- ahd_pci_set_dma_mask(pdev, 0xFFFFFFFF);
+ pci_set_dma_mask(pdev, 0xFFFFFFFF);
ahd->platform_data->hw_dma_mask = 0xFFFFFFFF;
}
-#endif
ahd->dev_softc = pci;
error = ahd_pci_config(ahd, entry);
if (error != 0) {
ahd_free(ahd);
return (-error);
}
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
pci_set_drvdata(pdev, ahd);
if (aic79xx_detect_complete) {
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
return (-ENODEV);
#endif
}
-#endif
return (0);
}
int
ahd_linux_pci_init(void)
{
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
return (pci_module_init(&aic79xx_pci_driver));
-#else
- struct pci_dev *pdev;
- u_int class;
- int found;
-
- /* If we don't have a PCI bus, we can't find any adapters. */
- if (pci_present() == 0)
- return (0);
-
- found = 0;
- pdev = NULL;
- class = PCI_CLASS_STORAGE_SCSI << 8;
- while ((pdev = pci_find_class(class, pdev)) != NULL) {
- ahd_dev_softc_t pci;
- int error;
-
- pci = pdev;
- error = ahd_linux_pci_dev_probe(pdev, /*pci_devid*/NULL);
- if (error == 0)
- found++;
- }
- return (found);
-#endif
}
void
ahd_linux_pci_reserve_io_regions(struct ahd_softc *ahd, u_long *base,
u_long *base2)
{
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,0)
*base = pci_resource_start(ahd->dev_softc, 0);
/*
* This is really the 3rd bar and should be at index 2,
* bars.
*/
*base2 = pci_resource_start(ahd->dev_softc, 3);
-#else
- *base = ahd_pci_read_config(ahd->dev_softc, AHD_PCI_IOADDR0, 4);
- *base2 = ahd_pci_read_config(ahd->dev_softc, AHD_PCI_IOADDR1, 4);
- *base &= PCI_BASE_ADDRESS_IO_MASK;
- *base2 &= PCI_BASE_ADDRESS_IO_MASK;
-#endif
if (*base == 0 || *base2 == 0)
return (ENOMEM);
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)
- if (check_region(*base, 256) != 0
- || check_region(*base2, 256) != 0)
- return (ENOMEM);
- request_region(*base, 256, "aic79xx");
- request_region(*base2, 256, "aic79xx");
-#else
if (request_region(*base, 256, "aic79xx") == 0)
return (ENOMEM);
if (request_region(*base2, 256, "aic79xx") == 0) {
release_region(*base2, 256);
return (ENOMEM);
}
-#endif
return (0);
}
return (ENOMEM);
error = 0;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,0)
start = pci_resource_start(ahd->dev_softc, 1);
base_page = start & PAGE_MASK;
base_offset = start - base_page;
-#else
- start = ahd_pci_read_config(ahd->dev_softc, PCIR_MAPS+4, 4);
- base_offset = start & PCI_BASE_ADDRESS_MEM_MASK;
- base_page = base_offset & PAGE_MASK;
- base_offset -= base_page;
-#endif
if (start != 0) {
*bus_addr = start;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
if (request_mem_region(start, 0x1000, "aic79xx") == 0)
error = ENOMEM;
-#endif
if (error == 0) {
*maddr = ioremap_nocache(base_page, base_offset + 256);
if (*maddr == NULL) {
error = ENOMEM;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
release_mem_region(start, 0x1000);
-#endif
} else
*maddr += base_offset;
}
ahd_get_pci_slot(ahd->dev_softc),
ahd_get_pci_function(ahd->dev_softc));
iounmap((void *)((u_long)maddr & PAGE_MASK));
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
release_mem_region(ahd->platform_data->mem_busaddr,
0x1000);
-#endif
ahd->bshs[0].maddr = NULL;
maddr = NULL;
} else
void
ahd_power_state_change(struct ahd_softc *ahd, ahd_power_state new_state)
{
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
pci_set_power_state(ahd->dev_softc, new_state);
-#else
- uint32_t cap;
- u_int cap_offset;
-
- /*
- * Traverse the capability list looking for
- * the power management capability.
- */
- cap = 0;
- cap_offset = ahd_pci_read_config(ahd->dev_softc,
- PCIR_CAP_PTR, /*bytes*/1);
- while (cap_offset != 0) {
-
- cap = ahd_pci_read_config(ahd->dev_softc,
- cap_offset, /*bytes*/4);
- if ((cap & 0xFF) == 1
- && ((cap >> 16) & 0x3) > 0) {
- uint32_t pm_control;
-
- pm_control = ahd_pci_read_config(ahd->dev_softc,
- cap_offset + 4,
- /*bytes*/4);
- pm_control &= ~0x3;
- pm_control |= new_state;
- ahd_pci_write_config(ahd->dev_softc,
- cap_offset + 4,
- pm_control, /*bytes*/2);
- break;
- }
- cap_offset = (cap >> 8) & 0xFF;
- }
-#endif
}
CAM_STATUS_MASK = 0x3F
} cam_status;
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0)
-#define SCSI_DATA_READ 1
-#define SCSI_DATA_WRITE 2
-#define SCSI_DATA_NONE 3
-#endif
-
/*
* Definitions for the asynchronous callback CCB fields.
*/