Lines Matching defs:ahc
263 ahc_print_path(struct ahc_softc *ahc, struct scb *scb)
266 ahc->platform_data->host->host_no,
267 scb != NULL ? SCB_GET_CHANNEL(ahc, scb) : 'X',
268 scb != NULL ? SCB_GET_TARGET(ahc, scb) : -1,
369 static void ahc_linux_queue_cmd_complete(struct ahc_softc *ahc,
371 static void ahc_linux_freeze_simq(struct ahc_softc *ahc);
372 static void ahc_linux_release_simq(struct ahc_softc *ahc);
374 static void ahc_linux_initialize_scsi_bus(struct ahc_softc *ahc);
375 static u_int ahc_linux_user_tagdepth(struct ahc_softc *ahc,
404 ahc_inb(struct ahc_softc * ahc, long port)
408 if (ahc->tag == BUS_SPACE_MEMIO) {
409 x = readb(ahc->bsh.maddr + port);
411 x = inb(ahc->bsh.ioport + port);
418 ahc_outb(struct ahc_softc * ahc, long port, uint8_t val)
420 if (ahc->tag == BUS_SPACE_MEMIO) {
421 writeb(val, ahc->bsh.maddr + port);
423 outb(val, ahc->bsh.ioport + port);
429 ahc_outsb(struct ahc_softc * ahc, long port, uint8_t *array, int count)
439 ahc_outb(ahc, port, *array++);
443 ahc_insb(struct ahc_softc * ahc, long port, uint8_t *array, int count)
453 *array++ = ahc_inb(ahc, port);
459 static int ahc_linux_map_seg(struct ahc_softc *ahc, struct scb *scb,
464 ahc_linux_unmap_scb(struct ahc_softc *ahc, struct scb *scb)
469 ahc_sync_sglist(ahc, scb, BUS_DMASYNC_POSTWRITE);
475 ahc_linux_map_seg(struct ahc_softc *ahc, struct scb *scb,
489 && (ahc->flags & AHC_39BIT_ADDRESSING) != 0)
505 struct ahc_softc *ahc;
508 ahc = *(struct ahc_softc **)host->hostdata;
512 strcat(bp, ahc->description);
515 ahc_controller_info(ahc, ahc_info);
528 struct ahc_softc *ahc;
533 ahc = *(struct ahc_softc **)cmd->device->host->hostdata;
535 ahc_lock(ahc, &flags);
536 if (ahc->platform_data->qfrozen == 0) {
539 rtn = ahc_linux_run_command(ahc, dev, cmd);
541 ahc_unlock(ahc, &flags);
549 struct ahc_softc *ahc =
557 return &ahc->platform_data->starget[target_offset];
563 struct ahc_softc *ahc =
565 struct seeprom_config *sc = ahc->seep_config;
573 unsigned int our_id = ahc->our_id;
581 our_id = ahc->our_id_b;
583 ahc_lock(ahc, &flags);
594 if (ahc->flags & AHC_NEWEEPROM_FMT) {
606 if ((ahc->features & AHC_ULTRA2) != 0) {
617 ahc_find_period(ahc, scsirate, maxsync);
619 tinfo = ahc_fetch_transinfo(ahc, channel, ahc->our_id,
625 ahc_set_syncrate(ahc, &devinfo, NULL, 0, 0, 0,
627 ahc_set_width(ahc, &devinfo, MSG_EXT_WDTR_BUS_8_BIT,
629 ahc_unlock(ahc, &flags);
645 struct ahc_softc *ahc =
651 printk("%s: Slave Alloc %d\n", ahc_name(ahc), sdev->id);
677 struct ahc_softc *ahc;
679 ahc = *((struct ahc_softc **)sdev->host->hostdata);
707 struct ahc_softc *ahc;
710 ahc = *((struct ahc_softc **)sdev->host->hostdata);
728 extended = (ahc->flags & AHC_EXTENDED_TRANS_A) != 0;
730 extended = (ahc->flags & AHC_EXTENDED_TRANS_B) != 0;
777 struct ahc_softc *ahc;
781 ahc = *(struct ahc_softc **)cmd->device->host->hostdata;
783 ahc_lock(ahc, &flags);
784 found = ahc_reset_channel(ahc, scmd_channel(cmd) + 'A',
786 ahc_unlock(ahc, &flags);
790 "%d SCBs aborted.\n", ahc_name(ahc), found);
822 #define BUILD_SCSIID(ahc, cmd) \
824 | (((cmd)->device->channel == 0) ? (ahc)->our_id : (ahc)->our_id_b) \
829 ahc_dma_tag_create(struct ahc_softc *ahc, bus_dma_tag_t parent,
857 ahc_dma_tag_destroy(struct ahc_softc *ahc, bus_dma_tag_t dmat)
863 ahc_dmamem_alloc(struct ahc_softc *ahc, bus_dma_tag_t dmat, void** vaddr,
866 *vaddr = pci_alloc_consistent(ahc->dev_softc,
874 ahc_dmamem_free(struct ahc_softc *ahc, bus_dma_tag_t dmat,
877 pci_free_consistent(ahc->dev_softc, dmat->maxsize,
882 ahc_dmamap_load(struct ahc_softc *ahc, bus_dma_tag_t dmat, bus_dmamap_t map,
899 ahc_dmamap_destroy(struct ahc_softc *ahc, bus_dma_tag_t dmat, bus_dmamap_t map)
904 ahc_dmamap_unload(struct ahc_softc *ahc, bus_dma_tag_t dmat, bus_dmamap_t map)
1086 ahc_linux_register_host(struct ahc_softc *ahc, struct scsi_host_template *template)
1094 template->name = ahc->description;
1099 *((struct ahc_softc **)host->hostdata) = ahc;
1100 ahc->platform_data->host = host;
1103 host->this_id = ahc->our_id;
1104 host->irq = ahc->platform_data->irq;
1105 host->max_id = (ahc->features & AHC_WIDE) ? 16 : 8;
1107 host->max_channel = (ahc->features & AHC_TWIN) ? 1 : 0;
1109 ahc_lock(ahc, &s);
1110 ahc_set_unit(ahc, ahc_linux_unit++);
1111 ahc_unlock(ahc, &s);
1116 ahc_set_name(ahc, new_name);
1118 host->unique_id = ahc->unit;
1119 ahc_linux_initialize_scsi_bus(ahc);
1120 ahc_intr_enable(ahc, TRUE);
1125 (ahc->dev_softc ? &ahc->dev_softc->dev : NULL));
1142 ahc_linux_initialize_scsi_bus(struct ahc_softc *ahc)
1151 ahc_lock(ahc, &s);
1154 ahc->flags &= ~(AHC_RESET_BUS_A|AHC_RESET_BUS_B);
1156 if ((ahc->flags & AHC_RESET_BUS_A) != 0)
1157 ahc_reset_channel(ahc, 'A', /*initiate_reset*/TRUE);
1159 numtarg = (ahc->features & AHC_WIDE) ? 16 : 8;
1161 if ((ahc->features & AHC_TWIN) != 0) {
1163 if ((ahc->flags & AHC_RESET_BUS_B) != 0) {
1164 ahc_reset_channel(ahc, 'B', /*initiate_reset*/TRUE);
1185 our_id = ahc->our_id;
1187 if (i > 7 && (ahc->features & AHC_TWIN) != 0) {
1189 our_id = ahc->our_id_b;
1192 tinfo = ahc_fetch_transinfo(ahc, channel, our_id,
1196 ahc_update_neg_request(ahc, &devinfo, tstate,
1199 ahc_unlock(ahc, &s);
1201 if ((ahc->flags & (AHC_RESET_BUS_A|AHC_RESET_BUS_B)) != 0) {
1202 ahc_linux_freeze_simq(ahc);
1204 ahc_linux_release_simq(ahc);
1209 ahc_platform_alloc(struct ahc_softc *ahc, void *platform_arg)
1212 ahc->platform_data =
1214 if (ahc->platform_data == NULL)
1216 memset(ahc->platform_data, 0, sizeof(struct ahc_platform_data));
1217 ahc->platform_data->irq = AHC_LINUX_NOIRQ;
1218 ahc_lockinit(ahc);
1219 ahc->seltime = (aic7xxx_seltime & 0x3) << 4;
1220 ahc->seltime_b = (aic7xxx_seltime & 0x3) << 4;
1222 ahc->flags |= AHC_DISABLE_PCI_PERR;
1228 ahc_platform_free(struct ahc_softc *ahc)
1233 if (ahc->platform_data != NULL) {
1236 starget = ahc->platform_data->starget[i];
1238 ahc->platform_data->starget[i] = NULL;
1242 if (ahc->platform_data->irq != AHC_LINUX_NOIRQ)
1243 free_irq(ahc->platform_data->irq, ahc);
1244 if (ahc->tag == BUS_SPACE_PIO
1245 && ahc->bsh.ioport != 0)
1246 release_region(ahc->bsh.ioport, 256);
1247 if (ahc->tag == BUS_SPACE_MEMIO
1248 && ahc->bsh.maddr != NULL) {
1249 iounmap(ahc->bsh.maddr);
1250 release_mem_region(ahc->platform_data->mem_busaddr,
1254 if (ahc->platform_data->host)
1255 scsi_host_put(ahc->platform_data->host);
1257 kfree(ahc->platform_data);
1262 ahc_platform_freeze_devq(struct ahc_softc *ahc, struct scb *scb)
1264 ahc_platform_abort_scbs(ahc, SCB_GET_TARGET(ahc, scb),
1265 SCB_GET_CHANNEL(ahc, scb),
1271 ahc_platform_set_tags(struct ahc_softc *ahc, struct scsi_device *sdev,
1306 usertags = ahc_linux_user_tagdepth(ahc, devinfo);
1354 ahc_platform_abort_scbs(struct ahc_softc *ahc, int target, char channel,
1361 ahc_linux_user_tagdepth(struct ahc_softc *ahc, struct ahc_devinfo *devinfo)
1367 if ((ahc->user_discenable & devinfo->target_mask) != 0) {
1368 if (ahc->unit >= ARRAY_SIZE(aic7xxx_tag_info)) {
1382 tag_info = &aic7xxx_tag_info[ahc->unit];
1399 struct ahc_softc *ahc = *((struct ahc_softc **)sdev->host->hostdata);
1403 ? ahc->our_id : ahc->our_id_b,
1407 tags = ahc_linux_user_tagdepth(ahc, &devinfo);
1410 ahc_platform_set_tags(ahc, sdev, &devinfo, AHC_QUEUE_TAGGED);
1411 ahc_send_async(ahc, devinfo.channel, devinfo.target,
1413 ahc_print_devinfo(ahc, &devinfo);
1416 ahc_platform_set_tags(ahc, sdev, &devinfo, AHC_QUEUE_NONE);
1417 ahc_send_async(ahc, devinfo.channel, devinfo.target,
1423 ahc_linux_run_command(struct ahc_softc *ahc, struct ahc_linux_device *dev,
1438 if (ahc->platform_data->qfrozen != 0)
1448 && (ahc->features & AHC_SCB_BTT) == 0) {
1452 untagged_q = &(ahc->untagged_queues[target_offset]);
1466 scb = ahc_get_scb(ahc);
1481 hscb->scsiid = BUILD_SCSIID(ahc, cmd);
1483 mask = SCB_GET_TARGET_MASK(ahc, scb);
1484 tinfo = ahc_fetch_transinfo(ahc, SCB_GET_CHANNEL(ahc, scb),
1486 SCB_GET_TARGET(ahc, scb), &tstate);
1492 if ((ahc->user_discenable & mask) != 0)
1549 consumed = ahc_linux_map_seg(ahc, scb,
1576 LIST_INSERT_HEAD(&ahc->pending_scbs, scb, pending_links);
1588 ahc_queue_scb(ahc, scb);
1598 struct ahc_softc *ahc;
1602 ahc = (struct ahc_softc *) dev_id;
1603 ahc_lock(ahc, &flags);
1604 ours = ahc_intr(ahc);
1605 ahc_unlock(ahc, &flags);
1610 ahc_platform_flushwork(struct ahc_softc *ahc)
1616 ahc_send_async(struct ahc_softc *ahc, char channel,
1637 tinfo = ahc_fetch_transinfo(ahc, channel,
1638 channel == 'A' ? ahc->our_id
1639 : ahc->our_id_b,
1660 starget = ahc->platform_data->starget[target_offset];
1689 scsi_report_device_reset(ahc->platform_data->host,
1694 if (ahc->platform_data->host != NULL) {
1695 scsi_report_bus_reset(ahc->platform_data->host,
1708 ahc_done(struct ahc_softc *ahc, struct scb *scb)
1718 target_offset = SCB_GET_TARGET_OFFSET(ahc, scb);
1719 untagged_q = &(ahc->untagged_queues[target_offset]);
1729 ahc_dump_card_state(ahc);
1740 ahc_linux_unmap_scb(ahc, scb);
1757 ahc_print_path(ahc, scb);
1775 ahc_print_path(ahc, scb);
1780 ahc_print_path(ahc, scb);
1791 ahc_linux_handle_scsi_status(ahc, cmd->device, scb);
1819 if (ahc->platform_data->eh_done)
1820 complete(ahc->platform_data->eh_done);
1823 ahc_free_scb(ahc, scb);
1824 ahc_linux_queue_cmd_complete(ahc, cmd);
1828 ahc_linux_handle_scsi_status(struct ahc_softc *ahc,
1835 ahc->our_id,
1870 ahc_get_sense_buf(ahc, scb), sense_size);
1910 ahc_print_path(ahc, scb);
1927 ahc_print_path(ahc, scb);
1937 ahc_platform_set_tags(ahc, sdev, &devinfo,
1948 ahc_platform_set_tags(ahc, sdev, &devinfo,
1957 ahc_linux_queue_cmd_complete(struct ahc_softc *ahc, struct scsi_cmnd *cmd)
2027 ahc_linux_freeze_simq(struct ahc_softc *ahc)
2031 ahc_lock(ahc, &s);
2032 ahc->platform_data->qfrozen++;
2033 if (ahc->platform_data->qfrozen == 1) {
2034 scsi_block_requests(ahc->platform_data->host);
2036 ahc_platform_abort_scbs(ahc, CAM_TARGET_WILDCARD, ALL_CHANNELS,
2040 ahc_unlock(ahc, &s);
2044 ahc_linux_release_simq(struct ahc_softc *ahc)
2050 ahc_lock(ahc, &s);
2051 if (ahc->platform_data->qfrozen > 0)
2052 ahc->platform_data->qfrozen--;
2053 if (ahc->platform_data->qfrozen == 0)
2055 ahc_unlock(ahc, &s);
2063 scsi_unblock_requests(ahc->platform_data->host);
2069 struct ahc_softc *ahc;
2087 ahc = *(struct ahc_softc **)cmd->device->host->hostdata;
2097 ahc_lock(ahc, &flags);
2114 ahc_name(ahc), cmd->device->channel, cmd->device->id,
2121 && ahc_search_untagged_queues(ahc, cmd, cmd->device->id,
2126 ahc_name(ahc), cmd->device->channel, cmd->device->id,
2135 LIST_FOREACH(pending_scb, &ahc->pending_scbs, pending_links) {
2143 LIST_FOREACH(pending_scb, &ahc->pending_scbs, pending_links) {
2144 if (ahc_match_scb(ahc, pending_scb, scmd_id(cmd),
2170 was_paused = ahc_is_paused(ahc);
2171 ahc_pause_and_flushwork(ahc);
2180 ahc_name(ahc), was_paused ? "" : "not ");
2181 ahc_dump_card_state(ahc);
2185 if (ahc_search_qinfifo(ahc, cmd->device->id,
2192 ahc_name(ahc), cmd->device->channel,
2197 } else if (ahc_search_qinfifo(ahc, cmd->device->id,
2205 if (disconnected && (ahc_inb(ahc, SEQ_FLAGS) & NOT_IDENTIFIED) == 0) {
2208 bus_scb = ahc_lookup_scb(ahc, ahc_inb(ahc, SCB_TAG));
2212 && ahc_inb(ahc, SAVED_SCSIID) == pending_scb->hscb->scsiid
2213 && ahc_inb(ahc, SAVED_LUN) == SCB_GET_LUN(pending_scb))
2225 last_phase = ahc_inb(ahc, LASTPHASE);
2226 saved_scbptr = ahc_inb(ahc, SCBPTR);
2227 active_scb_index = ahc_inb(ahc, SCB_TAG);
2228 saved_scsiid = ahc_inb(ahc, SAVED_SCSIID);
2232 && SCSIID_TARGET(ahc, saved_scsiid) == scmd_id(cmd)))) {
2238 pending_scb = ahc_lookup_scb(ahc, active_scb_index);
2240 ahc_outb(ahc, MSG_OUT, HOST_MSG);
2241 ahc_outb(ahc, SCSISIGO, last_phase|ATNO);
2272 ahc_search_disc_list(ahc, cmd->device->id,
2286 if ((ahc->flags & AHC_PAGESCBS) == 0) {
2287 ahc_outb(ahc, SCBPTR, pending_scb->hscb->tag);
2288 ahc_outb(ahc, SCB_CONTROL,
2289 ahc_inb(ahc, SCB_CONTROL)|MK_MESSAGE);
2297 ahc_search_qinfifo(ahc, cmd->device->id,
2302 ahc_qinfifo_requeue_tail(ahc, pending_scb);
2303 ahc_outb(ahc, SCBPTR, saved_scbptr);
2304 ahc_print_path(ahc, pending_scb);
2323 ahc_unpause(ahc);
2327 ahc->platform_data->eh_done = &done;
2328 ahc_unlock(ahc, &flags);
2332 ahc_lock(ahc, &flags);
2333 ahc->platform_data->eh_done = NULL;
2334 ahc_unlock(ahc, &flags);
2341 ahc_unlock(ahc, &flags);
2346 ahc_platform_dump_card_state(struct ahc_softc *ahc)
2353 struct ahc_softc *ahc = *((struct ahc_softc **)shost->hostdata);
2359 ahc_lock(ahc, &flags);
2360 ahc_set_width(ahc, &devinfo, width, AHC_TRANS_GOAL, FALSE);
2361 ahc_unlock(ahc, &flags);
2367 struct ahc_softc *ahc = *((struct ahc_softc **)shost->hostdata);
2370 = ahc_fetch_transinfo(ahc,
2401 syncrate = ahc_find_syncrate(ahc, &period, &ppr_options, AHC_SYNCRATE_DT);
2402 ahc_lock(ahc, &flags);
2403 ahc_set_syncrate(ahc, &devinfo, syncrate, period, offset,
2405 ahc_unlock(ahc, &flags);
2411 struct ahc_softc *ahc = *((struct ahc_softc **)shost->hostdata);
2414 = ahc_fetch_transinfo(ahc,
2426 syncrate = ahc_find_syncrate(ahc, &period, &ppr_options, AHC_SYNCRATE_DT);
2430 ahc_lock(ahc, &flags);
2431 ahc_set_syncrate(ahc, &devinfo, syncrate, period, offset,
2433 ahc_unlock(ahc, &flags);
2439 struct ahc_softc *ahc = *((struct ahc_softc **)shost->hostdata);
2442 = ahc_fetch_transinfo(ahc,
2462 syncrate = ahc_find_syncrate(ahc, &period, &ppr_options,AHC_SYNCRATE_DT);
2463 ahc_lock(ahc, &flags);
2464 ahc_set_syncrate(ahc, &devinfo, syncrate, period, tinfo->goal.offset,
2466 ahc_unlock(ahc, &flags);
2472 struct ahc_softc *ahc = *(struct ahc_softc **)shost->hostdata;
2476 if (!(ahc->features & AHC_ULTRA2)) {
2479 ahc->features & AHC_HVD ?
2485 ahc_lock(ahc, &flags);
2486 ahc_pause(ahc);
2487 mode = ahc_inb(ahc, SBLKCTL);
2488 ahc_unpause(ahc);
2489 ahc_unlock(ahc, &flags);