Lines Matching defs:fdc

235 static int set_dor(int fdc, char mask, char data);
303 #define UNIT(x) ((x) & 0x03) /* drive on fdc */
304 #define FDC(x) (((x) & 0x04) >> 2) /* fdc of drive */
305 /* reverse mapping from unit and fdc to drive */
306 #define REVDRIVE(fdc, unit) ((unit) + ((fdc) << 2))
582 /* fdc related variables, should end up in a struct */
584 static int current_fdc; /* current fdc */
595 static inline unsigned char fdc_inb(int fdc, int reg)
597 return fd_inb(fdc_state[fdc].address, reg);
600 static inline void fdc_outb(unsigned char value, int fdc, int reg)
602 fd_outb(value, fdc_state[fdc].address, reg);
735 int fdc = FDC(drive);
739 if (!(fdc_state[fdc].dor & (0x10 << UNIT(drive))) ||
740 (fdc_state[fdc].dor & 3) != UNIT(drive) || fdc != FDC(drive)) {
742 DPRINT("drive=%d fdc=%d dor=%x\n", drive, FDC(drive),
743 (unsigned int)fdc_state[fdc].dor);
750 fdc_inb(fdc, FD_DIR) & 0x80);
757 if ((fdc_inb(fdc, FD_DIR) ^ drive_params[drive].flags) & 0x80) {
793 static int set_dor(int fdc, char mask, char data)
800 if (fdc_state[fdc].address == -1)
803 olddor = fdc_state[fdc].dor;
808 drive = REVDRIVE(fdc, unit);
813 fdc_state[fdc].dor = newdor;
814 fdc_outb(newdor, fdc, FD_DOR);
818 drive = REVDRIVE(fdc, unit);
825 static void twaddle(int fdc, int drive)
829 fdc_outb(fdc_state[fdc].dor & ~(0x10 << UNIT(drive)),
830 fdc, FD_DOR);
831 fdc_outb(fdc_state[fdc].dor, fdc, FD_DOR);
836 * Reset all driver information about the specified fdc.
839 static void reset_fdc_info(int fdc, int mode)
843 fdc_state[fdc].spec1 = fdc_state[fdc].spec2 = -1;
844 fdc_state[fdc].need_configure = 1;
845 fdc_state[fdc].perp_mode = 1;
846 fdc_state[fdc].rawcmd = 0;
848 if (FDC(drive) == fdc &&
854 * selects the fdc and drive, and enables the fdc's input/dma.
859 unsigned int fdc;
866 fdc = FDC(drive);
867 if (fdc >= N_FDC) {
868 pr_info("bad fdc value\n");
872 set_dor(fdc, ~0, 8);
874 set_dor(1 - fdc, ~8, 0);
876 if (fdc_state[fdc].rawcmd == 2)
877 reset_fdc_info(fdc, 1);
878 if (fdc_inb(fdc, FD_STATUS) != STATUS_READY)
879 fdc_state[fdc].reset = 1;
882 current_fdc = fdc;
892 "Trying to lock fdc while usage count=0\n"))
900 reschedule_timeout(drive, "lock fdc");
936 int fdc = FDC(drive);
938 if (!(fdc_state[fdc].dor & (0x10 << UNIT(drive))))
1110 static void show_floppy(int fdc);
1112 /* waits until the fdc becomes ready */
1113 static int wait_til_ready(int fdc)
1118 if (fdc_state[fdc].reset)
1121 status = fdc_inb(fdc, FD_STATUS);
1126 DPRINT("Getstatus times out (%x) on fdc %d\n", status, fdc);
1127 show_floppy(fdc);
1129 fdc_state[fdc].reset = 1;
1133 /* sends a command byte to the fdc */
1134 static int output_byte(int fdc, char byte)
1136 int status = wait_til_ready(fdc);
1142 fdc_outb(byte, fdc, FD_DATA);
1149 fdc_state[fdc].reset = 1;
1152 byte, fdc, status);
1153 show_floppy(fdc);
1158 /* gets the response from the fdc */
1159 static int result(int fdc)
1165 status = wait_til_ready(fdc);
1175 reply_buffer[i] = fdc_inb(fdc, FD_DATA);
1181 fdc, status, i);
1182 show_floppy(fdc);
1184 fdc_state[fdc].reset = 1;
1189 /* does the fdc need more output? */
1190 static int need_more_output(int fdc)
1192 int status = wait_til_ready(fdc);
1200 return result(fdc);
1206 static void perpendicular_mode(int fdc)
1221 fdc_state[fdc].reset = 1;
1232 if (fdc_state[fdc].perp_mode == perp_mode)
1234 if (fdc_state[fdc].version >= FDC_82077_ORIG) {
1235 output_byte(fdc, FD_PERPENDICULAR);
1236 output_byte(fdc, perp_mode);
1237 fdc_state[fdc].perp_mode = perp_mode;
1246 static int fdc_configure(int fdc)
1249 output_byte(fdc, FD_CONFIGURE);
1250 if (need_more_output(fdc) != MORE_OUTPUT)
1252 output_byte(fdc, 0);
1253 output_byte(fdc, 0x10 | (no_fifo & 0x20) | (fifo_depth & 0xf));
1254 output_byte(fdc, 0); /* pre-compensation from track 0 upwards */
1279 static void fdc_specify(int fdc, int drive)
1291 if (fdc_state[fdc].need_configure &&
1292 fdc_state[fdc].version >= FDC_82072A) {
1293 fdc_configure(fdc);
1294 fdc_state[fdc].need_configure = 0;
1303 if (fdc_state[fdc].version >= FDC_82078) {
1306 output_byte(fdc, FD_DRIVESPEC);
1307 if (need_more_output(fdc) == MORE_OUTPUT) {
1308 output_byte(fdc, UNIT(drive));
1309 output_byte(fdc, 0xc0);
1318 if (fdc_state[fdc].version >= FDC_82072) {
1351 if (fdc_state[fdc].spec1 != spec1 ||
1352 fdc_state[fdc].spec2 != spec2) {
1354 output_byte(fdc, FD_SPECIFY);
1355 output_byte(fdc, fdc_state[fdc].spec1 = spec1);
1356 output_byte(fdc, fdc_state[fdc].spec2 = spec2);
1567 static void check_wp(int fdc, int drive)
1571 output_byte(fdc, FD_GETSTATUS);
1572 output_byte(fdc, UNIT(drive));
1573 if (result(fdc) != 1) {
1574 fdc_state[fdc].reset = 1;
1729 pr_info("floppy interrupt on bizarre fdc %d\n", current_fdc);
1731 is_alive(__func__, "bizarre fdc");
1738 * emit SENSEI's to clear the interrupt line. And fdc_state[fdc].reset
1826 static void show_floppy(int fdc)
1849 pr_info("status=%x\n", fdc_inb(fdc, FD_STATUS));
2953 /* fdc busy, this new request will be treated when the
4330 static char __init get_fdc_version(int fdc)
4334 output_byte(fdc, FD_DUMPREGS); /* 82072 and better know DUMPREGS */
4335 if (fdc_state[fdc].reset)
4337 r = result(fdc);
4341 pr_info("FDC %d is an 8272A\n", fdc);
4346 fdc, r);
4350 if (!fdc_configure(fdc)) {
4351 pr_info("FDC %d is an 82072\n", fdc);
4355 output_byte(fdc, FD_PERPENDICULAR);
4356 if (need_more_output(fdc) == MORE_OUTPUT) {
4357 output_byte(fdc, 0);
4359 pr_info("FDC %d is an 82072A\n", fdc);
4363 output_byte(fdc, FD_UNLOCK);
4364 r = result(fdc);
4366 pr_info("FDC %d is a pre-1991 82077\n", fdc);
4372 fdc, r);
4375 output_byte(fdc, FD_PARTID);
4376 r = result(fdc);
4379 fdc, r);
4383 pr_info("FDC %d is a post-1991 82077\n", fdc);
4389 pr_info("FDC %d is an 82078.\n", fdc);
4392 pr_info("FDC %d is a 44pin 82078\n", fdc);
4395 pr_info("FDC %d is a S82078B\n", fdc);
4398 pr_info("FDC %d is a National Semiconductor PC87306\n", fdc);
4402 fdc, reply_buffer[0] >> 5);
4565 int fdc;
4569 for (fdc = 0; fdc < N_FDC; fdc++)
4570 if (fdc_state[fdc].address != -1)
4571 user_reset_fdc(REVDRIVE(fdc, 0), FD_RESET_ALWAYS, false);
4703 current_fdc = 0; /* reset fdc in case of unexpected interrupt */
4854 static void floppy_release_allocated_regions(int fdc, const struct io_region *p)
4858 release_region(fdc_state[fdc].address + p->offset, p->size);
4864 static int floppy_request_regions(int fdc)
4869 if (!request_region(fdc_state[fdc].address + p->offset,
4872 fdc_state[fdc].address + p->offset);
4873 floppy_release_allocated_regions(fdc, p);
4880 static void floppy_release_regions(int fdc)
4882 floppy_release_allocated_regions(fdc, ARRAY_END(io_regions));
4887 int fdc;
4916 for (fdc = 0; fdc < N_FDC; fdc++) {
4917 if (fdc_state[fdc].address != -1) {
4918 if (floppy_request_regions(fdc))
4922 for (fdc = 0; fdc < N_FDC; fdc++) {
4923 if (fdc_state[fdc].address != -1) {
4924 reset_fdc_info(fdc, 1);
4925 fdc_outb(fdc_state[fdc].dor, fdc, FD_DOR);
4931 for (fdc = 0; fdc < N_FDC; fdc++)
4932 if (fdc_state[fdc].address != -1)
4933 fdc_outb(fdc_state[fdc].dor, fdc, FD_DOR);
4944 while (--fdc >= 0)
4945 floppy_release_regions(fdc);
4953 int fdc;
4994 for (fdc = 0; fdc < N_FDC; fdc++)
4995 if (fdc_state[fdc].address != -1)
4996 floppy_release_regions(fdc);