Home | History | Annotate | Download | only in dev

Lines Matching defs:fdc

171 CFATTACH_DECL_NEW(fdc, sizeof(struct fdc_softc),
335 fdc_dmastart(struct fdc_softc *fdc, int read, void *addr, vsize_t count)
342 error = bus_dmamap_load(fdc->sc_dmat, fdc->sc_dmamap, addr, count,
348 bus_dmamap_sync(fdc->sc_dmat, fdc->sc_dmamap, 0, count,
355 * specify FDC data register address for clarification.
357 * FDC is connected to LSB 8 bits of X68000 16 bit bus
359 * so each FDC register is mapped at sparse odd address.
361 * XXX: No proper API to get DMA address of FDC register for DMAC.
363 fdc->sc_xfer = dmac_prepare_xfer(fdc->sc_dmachan, fdc->sc_dmat,
364 fdc->sc_dmamap,
367 fdc->sc_addr + fddata * 2 + 1);
369 fdc->sc_read = read;
370 dmac_start_xfer(fdc->sc_dmachan->ch_softc, fdc->sc_xfer);
374 fdc_dmaabort(struct fdc_softc *fdc)
377 dmac_abort_xfer(fdc->sc_dmachan->ch_softc, fdc->sc_xfer);
378 bus_dmamap_unload(fdc->sc_dmat, fdc->sc_dmamap);
384 struct fdc_softc *fdc = arg;
386 bus_dmamap_sync(fdc->sc_dmat, fdc->sc_dmamap,
387 0, fdc->sc_dmamap->dm_mapsize,
388 fdc->sc_read ?
390 bus_dmamap_unload(fdc->sc_dmat, fdc->sc_dmamap);
410 if (strcmp(ia->ia_name, "fdc") != 0)
443 * the drive). If `fdc' is not NULL, the drive was found but was not
449 fdprint(void *aux, const char *fdc)
453 if (fdc == NULL)
461 struct fdc_softc *fdc = device_private(self);
478 callout_init(&fdc->sc_timo_ch, 0);
479 callout_init(&fdc->sc_intr_ch, 0);
481 fdc->sc_iot = iot;
482 fdc->sc_ioh = ioh;
483 fdc->sc_addr = (void *)ia->ia_addr;
485 fdc->sc_dmat = ia->ia_dmat;
486 fdc->sc_state = DEVIDLE;
487 TAILQ_INIT(&fdc->sc_drives);
490 fdc->sc_dmachan = dmac_alloc_channel(parent, ia->ia_dma, "fdc",
491 ia->ia_dmaintr, fdcdmaintr, fdc,
492 ia->ia_dmaintr + 1, fdcdmaerrintr, fdc,
496 if (bus_dmamap_create(fdc->sc_dmat, FDC_MAXIOSIZE, 1, DMAC_MAXSEGSZ,
497 0, BUS_DMA_NOWAIT | BUS_DMA_ALLOCNOW, &fdc->sc_dmamap)) {
502 if (intio_intr_establish(ia->ia_intr, "fdc", fdcintr, fdc) != 0)
509 fdcresult(fdc);
510 fdcreset(fdc);
512 aprint_normal_dev(self, "uPD72065 FDC\n");
526 fdcreset(struct fdc_softc *fdc)
529 bus_space_write_1(fdc->sc_iot, fdc->sc_ioh, fdsts, NE7CMD_RESET);
533 fdcpoll(struct fdc_softc *fdc)
539 out_fdc(fdc->sc_iot, fdc->sc_ioh, NE7CMD_SENSEI);
540 fdcresult(fdc);
551 struct fdc_softc *fdc = device_private(parent);
555 bus_space_tag_t iot = fdc->sc_iot;
556 bus_space_handle_t ioh = fdc->sc_ioh;
570 (void)fdcresult(fdc);
577 fdcpoll(fdc);
587 n = fdcresult(fdc);
598 DPRINTF((" %x", fdc->sc_status[_i]));
604 if ((fdc->sc_status[0] & 0xf0) == 0x20)
606 else if ((fdc->sc_status[0] & 0xf0) == 0xc0)
611 bus_space_write_1(fdc->sc_iot, fdc->sc_ioh,
628 struct fdc_softc *fdc = device_private(parent);
652 fdc->sc_fd[drive] = fd;
749 struct fdc_softc *fdc;
751 fdc = device_private(device_parent(fd->sc_dev));
752 if (fdc->sc_state == DEVIDLE) {
754 fdcstart(fdc);
769 struct fdc_softc *fdc = device_private(device_parent(fd->sc_dev));
770 int active = !TAILQ_EMPTY(&fdc->sc_drives);
774 TAILQ_INSERT_TAIL(&fdc->sc_drives, fd, sc_drivechain);
778 fdcstart(fdc);
784 struct fdc_softc *fdc = device_private(device_parent(fd->sc_dev));
795 TAILQ_REMOVE(&fdc->sc_drives, fd, sc_drivechain);
797 TAILQ_INSERT_TAIL(&fdc->sc_drives, fd, sc_drivechain);
809 fdc->sc_state = DEVIDLE;
827 fd_set_motor(struct fdc_softc *fdc, int reset)
834 fd = fdc->sc_fd[n];
836 bus_space_write_1(fdc->sc_iot, fdc->sc_ioh, fdctl,
845 struct fdc_softc *fdc = device_private(device_parent(fd->sc_dev));
852 bus_space_write_1(fdc->sc_iot, fdc->sc_ioh, fdctl,
855 fd_set_motor(fdc, 0); /* XXX */
865 struct fdc_softc *fdc = device_private(device_parent(fd->sc_dev));
872 if ((TAILQ_FIRST(&fdc->sc_drives) == fd) &&
873 (fdc->sc_state == MOTORWAIT))
874 (void)fdcintr(fdc);
880 fdcresult(struct fdc_softc *fdc)
882 bus_space_tag_t iot = fdc->sc_iot;
883 bus_space_handle_t ioh = fdc->sc_ioh;
895 if (n >= sizeof(fdc->sc_status)) {
899 fdc->sc_status[n++] =
929 struct fdc_softc *fdc;
943 fdc = device_private(device_parent(fd->sc_dev));
946 bus_space_write_1(fdc->sc_iot, fdc->sc_ioh, fdout,
948 bus_space_write_1(fdc->sc_iot, fdc->sc_ioh, fdout, 0x40);
973 struct fdc_softc *fdc = device_private(device_parent(fd->sc_dev));
990 bus_space_write_1(fdc->sc_iot, fdc->sc_ioh, fdout,
992 bus_space_write_1(fdc->sc_iot, fdc->sc_ioh, fdout, 0);
998 fdcstart(struct fdc_softc *fdc)
1006 if (fdc->sc_state != DEVIDLE) {
1011 (void)fdcintr(fdc);
1016 fdcpstatus(int n, struct fdc_softc *fdc)
1025 snprintb(bits, sizeof(bits), NE7_ST0BITS, fdc->sc_status[0]);
1026 printf(" (st0 %s cyl %d)\n", bits, fdc->sc_status[1]);
1029 snprintb(bits, sizeof(bits), NE7_ST0BITS, fdc->sc_status[0]);
1031 snprintb(bits, sizeof(bits), NE7_ST1BITS, fdc->sc_status[1]);
1033 snprintb(bits, sizeof(bits), NE7_ST2BITS, fdc->sc_status[2]);
1036 fdc->sc_status[3], fdc->sc_status[4], fdc->sc_status[5]);
1049 struct fdc_softc *fdc = device_private(device_parent(dv));
1052 out_fdc(fdc->sc_iot, fdc->sc_ioh, NE7CMD_SENSEI);
1053 (void)fdcresult(fdc);
1057 printf("%s: %s: state %d", device_xname(dv), s, fdc->sc_state);
1058 fdcpstatus(n, fdc);
1064 struct fdc_softc *fdc = arg;
1065 struct fd_softc *fd = TAILQ_FIRST(&fdc->sc_drives);
1072 fdc->sc_state++;
1074 fdc->sc_state = DEVIDLE;
1076 (void)fdcintr(fdc);
1085 struct fdc_softc *fdc = arg;
1089 (void)fdcintr(fdc);
1097 struct fdc_softc *fdc = arg;
1098 #define st0 fdc->sc_status[0]
1099 #define cyl fdc->sc_status[1]
1102 bus_space_tag_t iot = fdc->sc_iot;
1103 bus_space_handle_t ioh = fdc->sc_ioh;
1110 fd = TAILQ_FIRST(&fdc->sc_drives);
1113 if (fdc->sc_state == DEVIDLE) {
1117 if ((tmp = fdcresult(fdc)) != 2 ||
1124 fdc->sc_state = DEVIDLE;
1132 TAILQ_REMOVE(&fdc->sc_drives, fd, sc_drivechain);
1140 switch (fdc->sc_state) {
1143 fdc->sc_errors = 0;
1149 fdc->sc_state = MOTORWAIT;
1156 struct fd_softc *ofd = fdc->sc_fd[i];
1166 fd_set_motor(fdc, 0);
1167 fdc->sc_state = MOTORWAIT;
1176 fd_set_motor(fdc, 0);
1194 fdc->sc_state = SEEKWAIT;
1199 callout_reset(&fdc->sc_timo_ch, 4 * hz, fdctimeout, fdc);
1279 fdc_dmastart(fdc, read, (char *)bp->b_data + fd->sc_skip,
1284 fdc->sc_errors = 4;
1285 fdcretry(fdc);
1307 fdc->sc_state = IOCOMPLETE;
1312 callout_reset(&fdc->sc_timo_ch, 2 * hz, fdctimeout, fdc);
1325 fdc_dmastart(fdc, B_READ, fd->sc_copybuf, 1024);
1335 fdc->sc_state = COPYCOMPLETE;
1337 callout_reset(&fdc->sc_timo_ch, 2 * hz, fdctimeout, fdc);
1371 fdc->sc_state = IOCOMPLETE;
1377 fdc_dmastart(fdc, read, fd->sc_copybuf, 1024);
1388 fdc->sc_state = IOCOMPLETE;
1390 callout_reset(&fdc->sc_timo_ch, 2 * hz, fdctimeout, fdc);
1394 callout_stop(&fdc->sc_timo_ch);
1395 fdc->sc_state = SEEKCOMPLETE;
1398 callout_reset(&fdc->sc_intr_ch, hz / 50, fdcpseudointr, fdc);
1404 DPRINTF(("fdcintr: SEEKCOMPLETE: FDC status = %x\n",
1405 bus_space_read_1(fdc->sc_iot, fdc->sc_ioh, fdsts)));
1407 tmp = fdcresult(fdc);
1410 fdc->sc_state = DORECAL;
1418 fdcretry(fdc);
1425 fdc_dmaabort(fdc);
1429 fdcretry(fdc);
1433 callout_stop(&fdc->sc_timo_ch);
1435 if ((tmp = fdcresult(fdc)) != 7 || (st0 & 0xf8) != 0) {
1436 fdc_dmaabort(fdc);
1441 fdcretry(fdc);
1445 if (fdc->sc_errors) {
1449 fdc->sc_errors = 0;
1466 callout_stop(&fdc->sc_timo_ch);
1467 if ((tmp = fdcresult(fdc)) != 7 || (st0 & 0xf8) != 0) {
1469 fdc_dmaabort(fdc);
1474 fdcretry(fdc);
1482 fd_set_motor(fdc, 1);
1484 fd_set_motor(fdc, 0);
1485 fdc->sc_state = RESETCOMPLETE;
1486 callout_reset(&fdc->sc_timo_ch, hz / 2, fdctimeout, fdc);
1491 callout_stop(&fdc->sc_timo_ch);
1495 (void)fdcresult(fdc);
1503 fdc->sc_state = RECALWAIT;
1504 callout_reset(&fdc->sc_timo_ch, 5 * hz, fdctimeout, fdc);
1509 callout_stop(&fdc->sc_timo_ch);
1510 fdc->sc_state = RECALCOMPLETE;
1513 callout_reset(&fdc->sc_intr_ch, hz / 30, fdcpseudointr, fdc);
1520 tmp = fdcresult(fdc);
1523 fdc->sc_state = DORECAL;
1529 fdcretry(fdc);
1543 tmp = fdcresult(fdc);
1547 fdcpstatus(7, fdc);
1566 fdcretry(struct fdc_softc *fdc)
1572 fd = TAILQ_FIRST(&fdc->sc_drives);
1578 switch (fdc->sc_errors) {
1581 fdc->sc_state = SEEKCOMPLETE;
1588 fdc->sc_state = DORECAL;
1593 fdc->sc_state = DORESET;
1601 fdcpstatus(7, fdc);
1607 fdc->sc_errors++;
1614 struct fdc_softc *fdc = device_private(device_parent(fd->sc_dev));
1798 fd_do_eject(fdc, FDUNIT(dev));
1853 fd_do_eject(struct fdc_softc *fdc, int unit)
1856 bus_space_write_1(fdc->sc_iot, fdc->sc_ioh, fdout, 0x20 | (1 << unit));
1858 bus_space_write_1(fdc->sc_iot, fdc->sc_ioh, fdout, 0x20);
1911 struct fdc_softc *fdc = device_private(device_parent(fd->sc_dev));
1915 fd_do_eject(fdc, device_unit(dev));