Lines Matching defs:ahc
253 ahc_print_path(struct ahc_softc *ahc, struct scb *scb)
256 ahc->platform_data->host->host_no,
257 scb != NULL ? SCB_GET_CHANNEL(ahc, scb) : 'X',
258 scb != NULL ? SCB_GET_TARGET(ahc, scb) : -1,
364 static void ahc_linux_queue_cmd_complete(struct ahc_softc *ahc,
366 static void ahc_linux_freeze_simq(struct ahc_softc *ahc);
367 static void ahc_linux_release_simq(struct ahc_softc *ahc);
369 static void ahc_linux_initialize_scsi_bus(struct ahc_softc *ahc);
370 static u_int ahc_linux_user_tagdepth(struct ahc_softc *ahc,
399 ahc_inb(struct ahc_softc * ahc, long port)
403 if (ahc->tag == BUS_SPACE_MEMIO) {
404 x = readb(ahc->bsh.maddr + port);
406 x = inb(ahc->bsh.ioport + port);
413 ahc_outb(struct ahc_softc * ahc, long port, uint8_t val)
415 if (ahc->tag == BUS_SPACE_MEMIO) {
416 writeb(val, ahc->bsh.maddr + port);
418 outb(val, ahc->bsh.ioport + port);
424 ahc_outsb(struct ahc_softc * ahc, long port, uint8_t *array, int count)
434 ahc_outb(ahc, port, *array++);
438 ahc_insb(struct ahc_softc * ahc, long port, uint8_t *array, int count)
448 *array++ = ahc_inb(ahc, port);
454 static int ahc_linux_map_seg(struct ahc_softc *ahc, struct scb *scb,
459 ahc_linux_unmap_scb(struct ahc_softc *ahc, struct scb *scb)
464 ahc_sync_sglist(ahc, scb, BUS_DMASYNC_POSTWRITE);
470 ahc_linux_map_seg(struct ahc_softc *ahc, struct scb *scb,
484 && (ahc->flags & AHC_39BIT_ADDRESSING) != 0)
500 struct ahc_softc *ahc;
503 ahc = *(struct ahc_softc **)host->hostdata;
507 strcat(bp, ahc->description);
510 ahc_controller_info(ahc, ahc_info);
523 struct ahc_softc *ahc;
528 ahc = *(struct ahc_softc **)cmd->device->host->hostdata;
530 ahc_lock(ahc, &flags);
531 if (ahc->platform_data->qfrozen == 0) {
534 rtn = ahc_linux_run_command(ahc, dev, cmd);
536 ahc_unlock(ahc, &flags);
546 struct ahc_softc *ahc =
554 return &ahc->platform_data->starget[target_offset];
560 struct ahc_softc *ahc =
562 struct seeprom_config *sc = ahc->seep_config;
568 unsigned int our_id = ahc->our_id;
576 our_id = ahc->our_id_b;
578 ahc_lock(ahc, &flags);
589 if (ahc->flags & AHC_NEWEEPROM_FMT) {
601 if ((ahc->features & AHC_ULTRA2) != 0) {
612 ahc_find_period(ahc, scsirate, maxsync);
617 ahc_set_syncrate(ahc, &devinfo, NULL, 0, 0, 0,
619 ahc_set_width(ahc, &devinfo, MSG_EXT_WDTR_BUS_8_BIT,
621 ahc_unlock(ahc, &flags);
637 struct ahc_softc *ahc =
643 printk("%s: Slave Alloc %d\n", ahc_name(ahc), sdev->id);
693 struct ahc_softc *ahc;
696 ahc = *((struct ahc_softc **)sdev->host->hostdata);
709 extended = (ahc->flags & AHC_EXTENDED_TRANS_A) != 0;
711 extended = (ahc->flags & AHC_EXTENDED_TRANS_B) != 0;
758 struct ahc_softc *ahc;
762 ahc = *(struct ahc_softc **)cmd->device->host->hostdata;
764 ahc_lock(ahc, &flags);
765 found = ahc_reset_channel(ahc, scmd_channel(cmd) + 'A',
767 ahc_unlock(ahc, &flags);
771 "%d SCBs aborted.\n", ahc_name(ahc), found);
803 #define BUILD_SCSIID(ahc, cmd) \
805 | (((cmd)->device->channel == 0) ? (ahc)->our_id : (ahc)->our_id_b) \
810 ahc_dma_tag_create(struct ahc_softc *ahc, bus_dma_tag_t parent,
838 ahc_dma_tag_destroy(struct ahc_softc *ahc, bus_dma_tag_t dmat)
844 ahc_dmamem_alloc(struct ahc_softc *ahc, bus_dma_tag_t dmat, void** vaddr,
848 *vaddr = dma_alloc_coherent(ahc->dev, dmat->maxsize, mapp, GFP_ATOMIC);
855 ahc_dmamem_free(struct ahc_softc *ahc, bus_dma_tag_t dmat,
858 dma_free_coherent(ahc->dev, dmat->maxsize, vaddr, map);
862 ahc_dmamap_load(struct ahc_softc *ahc, bus_dma_tag_t dmat, bus_dmamap_t map,
879 ahc_dmamap_destroy(struct ahc_softc *ahc, bus_dma_tag_t dmat, bus_dmamap_t map)
884 ahc_dmamap_unload(struct ahc_softc *ahc, bus_dma_tag_t dmat, bus_dmamap_t map)
1070 ahc_linux_register_host(struct ahc_softc *ahc, struct scsi_host_template *template)
1078 template->name = ahc->description;
1083 *((struct ahc_softc **)host->hostdata) = ahc;
1084 ahc->platform_data->host = host;
1088 host->this_id = ahc->our_id;
1089 host->irq = ahc->platform_data->irq;
1090 host->max_id = (ahc->features & AHC_WIDE) ? 16 : 8;
1092 host->max_channel = (ahc->features & AHC_TWIN) ? 1 : 0;
1094 ahc_lock(ahc, &s);
1095 ahc_set_unit(ahc, ahc_linux_unit++);
1096 ahc_unlock(ahc, &s);
1101 ahc_set_name(ahc, new_name);
1103 host->unique_id = ahc->unit;
1104 ahc_linux_initialize_scsi_bus(ahc);
1105 ahc_intr_enable(ahc, TRUE);
1109 retval = scsi_add_host(host, ahc->dev);
1126 ahc_linux_initialize_scsi_bus(struct ahc_softc *ahc)
1135 ahc_lock(ahc, &s);
1138 ahc->flags &= ~(AHC_RESET_BUS_A|AHC_RESET_BUS_B);
1140 if ((ahc->flags & AHC_RESET_BUS_A) != 0)
1141 ahc_reset_channel(ahc, 'A', /*initiate_reset*/TRUE);
1143 numtarg = (ahc->features & AHC_WIDE) ? 16 : 8;
1145 if ((ahc->features & AHC_TWIN) != 0) {
1147 if ((ahc->flags & AHC_RESET_BUS_B) != 0) {
1148 ahc_reset_channel(ahc, 'B', /*initiate_reset*/TRUE);
1169 our_id = ahc->our_id;
1171 if (i > 7 && (ahc->features & AHC_TWIN) != 0) {
1173 our_id = ahc->our_id_b;
1176 tinfo = ahc_fetch_transinfo(ahc, channel, our_id,
1180 ahc_update_neg_request(ahc, &devinfo, tstate,
1183 ahc_unlock(ahc, &s);
1185 if ((ahc->flags & (AHC_RESET_BUS_A|AHC_RESET_BUS_B)) != 0) {
1186 ahc_linux_freeze_simq(ahc);
1188 ahc_linux_release_simq(ahc);
1193 ahc_platform_alloc(struct ahc_softc *ahc, void *platform_arg)
1196 ahc->platform_data =
1198 if (ahc->platform_data == NULL)
1200 ahc->platform_data->irq = AHC_LINUX_NOIRQ;
1201 ahc_lockinit(ahc);
1202 ahc->seltime = (aic7xxx_seltime & 0x3) << 4;
1203 ahc->seltime_b = (aic7xxx_seltime & 0x3) << 4;
1205 ahc->flags |= AHC_DISABLE_PCI_PERR;
1211 ahc_platform_free(struct ahc_softc *ahc)
1216 if (ahc->platform_data != NULL) {
1219 starget = ahc->platform_data->starget[i];
1221 ahc->platform_data->starget[i] = NULL;
1225 if (ahc->platform_data->irq != AHC_LINUX_NOIRQ)
1226 free_irq(ahc->platform_data->irq, ahc);
1227 if (ahc->tag == BUS_SPACE_PIO
1228 && ahc->bsh.ioport != 0)
1229 release_region(ahc->bsh.ioport, 256);
1230 if (ahc->tag == BUS_SPACE_MEMIO
1231 && ahc->bsh.maddr != NULL) {
1232 iounmap(ahc->bsh.maddr);
1233 release_mem_region(ahc->platform_data->mem_busaddr,
1237 if (ahc->platform_data->host)
1238 scsi_host_put(ahc->platform_data->host);
1240 kfree(ahc->platform_data);
1245 ahc_platform_freeze_devq(struct ahc_softc *ahc, struct scb *scb)
1247 ahc_platform_abort_scbs(ahc, SCB_GET_TARGET(ahc, scb),
1248 SCB_GET_CHANNEL(ahc, scb),
1254 ahc_platform_set_tags(struct ahc_softc *ahc, struct scsi_device *sdev,
1289 usertags = ahc_linux_user_tagdepth(ahc, devinfo);
1334 ahc_platform_abort_scbs(struct ahc_softc *ahc, int target, char channel,
1341 ahc_linux_user_tagdepth(struct ahc_softc *ahc, struct ahc_devinfo *devinfo)
1347 if ((ahc->user_discenable & devinfo->target_mask) != 0) {
1348 if (ahc->unit >= ARRAY_SIZE(aic7xxx_tag_info)) {
1362 tag_info = &aic7xxx_tag_info[ahc->unit];
1379 struct ahc_softc *ahc = *((struct ahc_softc **)sdev->host->hostdata);
1383 ? ahc->our_id : ahc->our_id_b,
1387 tags = ahc_linux_user_tagdepth(ahc, &devinfo);
1390 ahc_platform_set_tags(ahc, sdev, &devinfo, AHC_QUEUE_TAGGED);
1391 ahc_send_async(ahc, devinfo.channel, devinfo.target,
1393 ahc_print_devinfo(ahc, &devinfo);
1396 ahc_platform_set_tags(ahc, sdev, &devinfo, AHC_QUEUE_NONE);
1397 ahc_send_async(ahc, devinfo.channel, devinfo.target,
1403 ahc_linux_run_command(struct ahc_softc *ahc, struct ahc_linux_device *dev,
1418 if (ahc->platform_data->qfrozen != 0)
1428 && (ahc->features & AHC_SCB_BTT) == 0) {
1432 untagged_q = &(ahc->untagged_queues[target_offset]);
1446 scb = ahc_get_scb(ahc);
1461 hscb->scsiid = BUILD_SCSIID(ahc, cmd);
1463 mask = SCB_GET_TARGET_MASK(ahc, scb);
1464 tinfo = ahc_fetch_transinfo(ahc, SCB_GET_CHANNEL(ahc, scb),
1466 SCB_GET_TARGET(ahc, scb), &tstate);
1472 if ((ahc->user_discenable & mask) != 0)
1521 consumed = ahc_linux_map_seg(ahc, scb,
1548 LIST_INSERT_HEAD(&ahc->pending_scbs, scb, pending_links);
1560 ahc_queue_scb(ahc, scb);
1570 struct ahc_softc *ahc;
1574 ahc = (struct ahc_softc *) dev_id;
1575 ahc_lock(ahc, &flags);
1576 ours = ahc_intr(ahc);
1577 ahc_unlock(ahc, &flags);
1582 ahc_platform_flushwork(struct ahc_softc *ahc)
1588 ahc_send_async(struct ahc_softc *ahc, char channel,
1602 tinfo = ahc_fetch_transinfo(ahc, channel,
1603 channel == 'A' ? ahc->our_id
1604 : ahc->our_id_b,
1625 starget = ahc->platform_data->starget[target_offset];
1653 scsi_report_device_reset(ahc->platform_data->host,
1658 if (ahc->platform_data->host != NULL) {
1659 scsi_report_bus_reset(ahc->platform_data->host,
1672 ahc_done(struct ahc_softc *ahc, struct scb *scb)
1682 target_offset = SCB_GET_TARGET_OFFSET(ahc, scb);
1683 untagged_q = &(ahc->untagged_queues[target_offset]);
1693 ahc_dump_card_state(ahc);
1704 ahc_linux_unmap_scb(ahc, scb);
1723 ahc_print_path(ahc, scb);
1741 ahc_print_path(ahc, scb);
1746 ahc_print_path(ahc, scb);
1757 ahc_linux_handle_scsi_status(ahc, cmd->device, scb);
1785 if (ahc->platform_data->eh_done)
1786 complete(ahc->platform_data->eh_done);
1789 ahc_free_scb(ahc, scb);
1790 ahc_linux_queue_cmd_complete(ahc, cmd);
1794 ahc_linux_handle_scsi_status(struct ahc_softc *ahc,
1801 ahc->our_id,
1836 ahc_get_sense_buf(ahc, scb), sense_size);
1876 ahc_print_path(ahc, scb);
1893 ahc_print_path(ahc, scb);
1903 ahc_platform_set_tags(ahc, sdev, &devinfo,
1914 ahc_platform_set_tags(ahc, sdev, &devinfo,
1923 ahc_linux_queue_cmd_complete(struct ahc_softc *ahc, struct scsi_cmnd *cmd)
1993 ahc_linux_freeze_simq(struct ahc_softc *ahc)
1997 ahc_lock(ahc, &s);
1998 ahc->platform_data->qfrozen++;
1999 if (ahc->platform_data->qfrozen == 1) {
2000 scsi_block_requests(ahc->platform_data->host);
2003 ahc_platform_abort_scbs(ahc, CAM_TARGET_WILDCARD, ALL_CHANNELS,
2007 ahc_unlock(ahc, &s);
2011 ahc_linux_release_simq(struct ahc_softc *ahc)
2017 ahc_lock(ahc, &s);
2018 if (ahc->platform_data->qfrozen > 0)
2019 ahc->platform_data->qfrozen--;
2020 if (ahc->platform_data->qfrozen == 0)
2022 ahc_unlock(ahc, &s);
2030 scsi_unblock_requests(ahc->platform_data->host);
2036 struct ahc_softc *ahc;
2054 ahc = *(struct ahc_softc **)cmd->device->host->hostdata;
2064 ahc_lock(ahc, &flags);
2081 ahc_name(ahc), cmd->device->channel, cmd->device->id,
2088 && ahc_search_untagged_queues(ahc, cmd, cmd->device->id,
2093 ahc_name(ahc), cmd->device->channel, cmd->device->id,
2102 LIST_FOREACH(pending_scb, &ahc->pending_scbs, pending_links) {
2110 LIST_FOREACH(pending_scb, &ahc->pending_scbs, pending_links) {
2111 if (ahc_match_scb(ahc, pending_scb, scmd_id(cmd),
2137 was_paused = ahc_is_paused(ahc);
2138 ahc_pause_and_flushwork(ahc);
2147 ahc_name(ahc), was_paused ? "" : "not ");
2148 ahc_dump_card_state(ahc);
2152 if (ahc_search_qinfifo(ahc, cmd->device->id,
2159 ahc_name(ahc), cmd->device->channel,
2164 } else if (ahc_search_qinfifo(ahc, cmd->device->id,
2173 if (disconnected && (ahc_inb(ahc, SEQ_FLAGS) & NOT_IDENTIFIED) == 0) {
2176 bus_scb = ahc_lookup_scb(ahc, ahc_inb(ahc, SCB_TAG));
2180 && ahc_inb(ahc, SAVED_SCSIID) == pending_scb->hscb->scsiid
2181 && ahc_inb(ahc, SAVED_LUN) == SCB_GET_LUN(pending_scb))
2193 last_phase = ahc_inb(ahc, LASTPHASE);
2194 saved_scbptr = ahc_inb(ahc, SCBPTR);
2195 active_scb_index = ahc_inb(ahc, SCB_TAG);
2196 saved_scsiid = ahc_inb(ahc, SAVED_SCSIID);
2200 && SCSIID_TARGET(ahc, saved_scsiid) == scmd_id(cmd)))) {
2206 pending_scb = ahc_lookup_scb(ahc, active_scb_index);
2208 ahc_outb(ahc, MSG_OUT, HOST_MSG);
2209 ahc_outb(ahc, SCSISIGO, last_phase|ATNO);
2240 ahc_search_disc_list(ahc, cmd->device->id,
2254 if ((ahc->flags & AHC_PAGESCBS) == 0) {
2255 ahc_outb(ahc, SCBPTR, pending_scb->hscb->tag);
2256 ahc_outb(ahc, SCB_CONTROL,
2257 ahc_inb(ahc, SCB_CONTROL)|MK_MESSAGE);
2265 ahc_search_qinfifo(ahc, cmd->device->id,
2270 ahc_qinfifo_requeue_tail(ahc, pending_scb);
2271 ahc_outb(ahc, SCBPTR, saved_scbptr);
2272 ahc_print_path(ahc, pending_scb);
2291 ahc_unpause(ahc);
2295 ahc->platform_data->eh_done = &done;
2296 ahc_unlock(ahc, &flags);
2300 ahc_lock(ahc, &flags);
2301 ahc->platform_data->eh_done = NULL;
2302 ahc_unlock(ahc, &flags);
2309 ahc_unlock(ahc, &flags);
2316 struct ahc_softc *ahc = *((struct ahc_softc **)shost->hostdata);
2322 ahc_lock(ahc, &flags);
2323 ahc_set_width(ahc, &devinfo, width, AHC_TRANS_GOAL, FALSE);
2324 ahc_unlock(ahc, &flags);
2330 struct ahc_softc *ahc = *((struct ahc_softc **)shost->hostdata);
2333 = ahc_fetch_transinfo(ahc,
2364 syncrate = ahc_find_syncrate(ahc, &period, &ppr_options, AHC_SYNCRATE_DT);
2365 ahc_lock(ahc, &flags);
2366 ahc_set_syncrate(ahc, &devinfo, syncrate, period, offset,
2368 ahc_unlock(ahc, &flags);
2374 struct ahc_softc *ahc = *((struct ahc_softc **)shost->hostdata);
2377 = ahc_fetch_transinfo(ahc,
2389 syncrate = ahc_find_syncrate(ahc, &period, &ppr_options, AHC_SYNCRATE_DT);
2393 ahc_lock(ahc, &flags);
2394 ahc_set_syncrate(ahc, &devinfo, syncrate, period, offset,
2396 ahc_unlock(ahc, &flags);
2402 struct ahc_softc *ahc = *((struct ahc_softc **)shost->hostdata);
2405 = ahc_fetch_transinfo(ahc,
2425 syncrate = ahc_find_syncrate(ahc, &period, &ppr_options,AHC_SYNCRATE_DT);
2426 ahc_lock(ahc, &flags);
2427 ahc_set_syncrate(ahc, &devinfo, syncrate, period, tinfo->goal.offset,
2429 ahc_unlock(ahc, &flags);
2440 struct ahc_softc *ahc = *((struct ahc_softc **)shost->hostdata);
2443 = ahc_fetch_transinfo(ahc,
2458 syncrate = ahc_find_syncrate(ahc, &period, &ppr_options, AHC_SYNCRATE_DT);
2459 ahc_lock(ahc, &flags);
2460 ahc_set_syncrate(ahc, &devinfo, syncrate, period, tinfo->goal.offset,
2462 ahc_unlock(ahc, &flags);
2468 struct ahc_softc *ahc = *((struct ahc_softc **)shost->hostdata);
2471 = ahc_fetch_transinfo(ahc,
2486 syncrate = ahc_find_syncrate(ahc, &period, &ppr_options, AHC_SYNCRATE_DT);
2487 ahc_lock(ahc, &flags);
2488 ahc_set_syncrate(ahc, &devinfo, syncrate, period, tinfo->goal.offset,
2490 ahc_unlock(ahc, &flags);
2496 struct ahc_softc *ahc = *(struct ahc_softc **)shost->hostdata;
2500 if (!(ahc->features & AHC_ULTRA2)) {
2503 ahc->features & AHC_HVD ?
2509 ahc_lock(ahc, &flags);
2510 ahc_pause(ahc);
2511 mode = ahc_inb(ahc, SBLKCTL);
2512 ahc_unpause(ahc);
2513 ahc_unlock(ahc, &flags);