Lines Matching refs:fdc
234 static int set_dor(int fdc, char mask, char data);
305 #define REVDRIVE(fdc, unit) ((unit) + ((fdc) << 2)) argument
595 static inline unsigned char fdc_inb(int fdc, int reg) in fdc_inb() argument
597 return fd_inb(fdc_state[fdc].address, reg); in fdc_inb()
600 static inline void fdc_outb(unsigned char value, int fdc, int reg) in fdc_outb() argument
602 fd_outb(value, fdc_state[fdc].address, reg); in fdc_outb()
735 int fdc = FDC(drive); in disk_change() local
739 if (!(fdc_state[fdc].dor & (0x10 << UNIT(drive))) || in disk_change()
740 (fdc_state[fdc].dor & 3) != UNIT(drive) || fdc != FDC(drive)) { in disk_change()
743 (unsigned int)fdc_state[fdc].dor); in disk_change()
750 fdc_inb(fdc, FD_DIR) & 0x80); in disk_change()
757 if ((fdc_inb(fdc, FD_DIR) ^ drive_params[drive].flags) & 0x80) { in disk_change()
793 static int set_dor(int fdc, char mask, char data) in set_dor() argument
800 if (fdc_state[fdc].address == -1) in set_dor()
803 olddor = fdc_state[fdc].dor; in set_dor()
808 drive = REVDRIVE(fdc, unit); in set_dor()
813 fdc_state[fdc].dor = newdor; in set_dor()
814 fdc_outb(newdor, fdc, FD_DOR); in set_dor()
818 drive = REVDRIVE(fdc, unit); in set_dor()
825 static void twaddle(int fdc, int drive) in twaddle() argument
829 fdc_outb(fdc_state[fdc].dor & ~(0x10 << UNIT(drive)), in twaddle()
830 fdc, FD_DOR); in twaddle()
831 fdc_outb(fdc_state[fdc].dor, fdc, FD_DOR); in twaddle()
839 static void reset_fdc_info(int fdc, int mode) in reset_fdc_info() argument
843 fdc_state[fdc].spec1 = fdc_state[fdc].spec2 = -1; in reset_fdc_info()
844 fdc_state[fdc].need_configure = 1; in reset_fdc_info()
845 fdc_state[fdc].perp_mode = 1; in reset_fdc_info()
846 fdc_state[fdc].rawcmd = 0; in reset_fdc_info()
848 if (FDC(drive) == fdc && in reset_fdc_info()
859 unsigned int fdc; in set_fdc() local
866 fdc = FDC(drive); in set_fdc()
867 if (fdc >= N_FDC) { in set_fdc()
872 set_dor(fdc, ~0, 8); in set_fdc()
874 set_dor(1 - fdc, ~8, 0); in set_fdc()
876 if (fdc_state[fdc].rawcmd == 2) in set_fdc()
877 reset_fdc_info(fdc, 1); in set_fdc()
878 if (fdc_inb(fdc, FD_STATUS) != STATUS_READY) in set_fdc()
879 fdc_state[fdc].reset = 1; in set_fdc()
882 current_fdc = fdc; in set_fdc()
936 int fdc = FDC(drive); in floppy_off() local
938 if (!(fdc_state[fdc].dor & (0x10 << UNIT(drive)))) in floppy_off()
1110 static void show_floppy(int fdc);
1113 static int wait_til_ready(int fdc) in wait_til_ready() argument
1118 if (fdc_state[fdc].reset) in wait_til_ready()
1121 status = fdc_inb(fdc, FD_STATUS); in wait_til_ready()
1126 DPRINT("Getstatus times out (%x) on fdc %d\n", status, fdc); in wait_til_ready()
1127 show_floppy(fdc); in wait_til_ready()
1129 fdc_state[fdc].reset = 1; in wait_til_ready()
1134 static int output_byte(int fdc, char byte) in output_byte() argument
1136 int status = wait_til_ready(fdc); in output_byte()
1142 fdc_outb(byte, fdc, FD_DATA); in output_byte()
1149 fdc_state[fdc].reset = 1; in output_byte()
1152 byte, fdc, status); in output_byte()
1153 show_floppy(fdc); in output_byte()
1159 static int result(int fdc) in result() argument
1165 status = wait_til_ready(fdc); in result()
1175 reply_buffer[i] = fdc_inb(fdc, FD_DATA); in result()
1181 fdc, status, i); in result()
1182 show_floppy(fdc); in result()
1184 fdc_state[fdc].reset = 1; in result()
1190 static int need_more_output(int fdc) in need_more_output() argument
1192 int status = wait_til_ready(fdc); in need_more_output()
1200 return result(fdc); in need_more_output()
1206 static void perpendicular_mode(int fdc) in perpendicular_mode() argument
1221 fdc_state[fdc].reset = 1; in perpendicular_mode()
1232 if (fdc_state[fdc].perp_mode == perp_mode) in perpendicular_mode()
1234 if (fdc_state[fdc].version >= FDC_82077_ORIG) { in perpendicular_mode()
1235 output_byte(fdc, FD_PERPENDICULAR); in perpendicular_mode()
1236 output_byte(fdc, perp_mode); in perpendicular_mode()
1237 fdc_state[fdc].perp_mode = perp_mode; in perpendicular_mode()
1246 static int fdc_configure(int fdc) in fdc_configure() argument
1249 output_byte(fdc, FD_CONFIGURE); in fdc_configure()
1250 if (need_more_output(fdc) != MORE_OUTPUT) in fdc_configure()
1252 output_byte(fdc, 0); in fdc_configure()
1253 output_byte(fdc, 0x10 | (no_fifo & 0x20) | (fifo_depth & 0xf)); in fdc_configure()
1254 output_byte(fdc, 0); /* pre-compensation from track 0 upwards */ in fdc_configure()
1279 static void fdc_specify(int fdc, int drive) in fdc_specify() argument
1291 if (fdc_state[fdc].need_configure && in fdc_specify()
1292 fdc_state[fdc].version >= FDC_82072A) { in fdc_specify()
1293 fdc_configure(fdc); in fdc_specify()
1294 fdc_state[fdc].need_configure = 0; in fdc_specify()
1303 if (fdc_state[fdc].version >= FDC_82078) { in fdc_specify()
1306 output_byte(fdc, FD_DRIVESPEC); in fdc_specify()
1307 if (need_more_output(fdc) == MORE_OUTPUT) { in fdc_specify()
1308 output_byte(fdc, UNIT(drive)); in fdc_specify()
1309 output_byte(fdc, 0xc0); in fdc_specify()
1318 if (fdc_state[fdc].version >= FDC_82072) { in fdc_specify()
1351 if (fdc_state[fdc].spec1 != spec1 || in fdc_specify()
1352 fdc_state[fdc].spec2 != spec2) { in fdc_specify()
1354 output_byte(fdc, FD_SPECIFY); in fdc_specify()
1355 output_byte(fdc, fdc_state[fdc].spec1 = spec1); in fdc_specify()
1356 output_byte(fdc, fdc_state[fdc].spec2 = spec2); in fdc_specify()
1567 static void check_wp(int fdc, int drive) in check_wp() argument
1571 output_byte(fdc, FD_GETSTATUS); in check_wp()
1572 output_byte(fdc, UNIT(drive)); in check_wp()
1573 if (result(fdc) != 1) { in check_wp()
1574 fdc_state[fdc].reset = 1; in check_wp()
1826 static void show_floppy(int fdc) in show_floppy() argument
1849 pr_info("status=%x\n", fdc_inb(fdc, FD_STATUS)); in show_floppy()
4238 static char __init get_fdc_version(int fdc) in get_fdc_version() argument
4242 output_byte(fdc, FD_DUMPREGS); /* 82072 and better know DUMPREGS */ in get_fdc_version()
4243 if (fdc_state[fdc].reset) in get_fdc_version()
4245 r = result(fdc); in get_fdc_version()
4249 pr_info("FDC %d is an 8272A\n", fdc); in get_fdc_version()
4254 fdc, r); in get_fdc_version()
4258 if (!fdc_configure(fdc)) { in get_fdc_version()
4259 pr_info("FDC %d is an 82072\n", fdc); in get_fdc_version()
4263 output_byte(fdc, FD_PERPENDICULAR); in get_fdc_version()
4264 if (need_more_output(fdc) == MORE_OUTPUT) { in get_fdc_version()
4265 output_byte(fdc, 0); in get_fdc_version()
4267 pr_info("FDC %d is an 82072A\n", fdc); in get_fdc_version()
4271 output_byte(fdc, FD_UNLOCK); in get_fdc_version()
4272 r = result(fdc); in get_fdc_version()
4274 pr_info("FDC %d is a pre-1991 82077\n", fdc); in get_fdc_version()
4280 fdc, r); in get_fdc_version()
4283 output_byte(fdc, FD_PARTID); in get_fdc_version()
4284 r = result(fdc); in get_fdc_version()
4287 fdc, r); in get_fdc_version()
4291 pr_info("FDC %d is a post-1991 82077\n", fdc); in get_fdc_version()
4297 pr_info("FDC %d is an 82078.\n", fdc); in get_fdc_version()
4300 pr_info("FDC %d is a 44pin 82078\n", fdc); in get_fdc_version()
4303 pr_info("FDC %d is a S82078B\n", fdc); in get_fdc_version()
4306 pr_info("FDC %d is a National Semiconductor PC87306\n", fdc); in get_fdc_version()
4310 fdc, reply_buffer[ST0] >> 5); in get_fdc_version()
4473 int fdc; in floppy_resume() local
4477 for (fdc = 0; fdc < N_FDC; fdc++) in floppy_resume()
4478 if (fdc_state[fdc].address != -1) in floppy_resume()
4479 user_reset_fdc(REVDRIVE(fdc, 0), FD_RESET_ALWAYS, false); in floppy_resume()
4796 static void floppy_release_allocated_regions(int fdc, const struct io_region *p) in floppy_release_allocated_regions() argument
4800 release_region(fdc_state[fdc].address + p->offset, p->size); in floppy_release_allocated_regions()
4806 static int floppy_request_regions(int fdc) in floppy_request_regions() argument
4811 if (!request_region(fdc_state[fdc].address + p->offset, in floppy_request_regions()
4814 fdc_state[fdc].address + p->offset); in floppy_request_regions()
4815 floppy_release_allocated_regions(fdc, p); in floppy_request_regions()
4822 static void floppy_release_regions(int fdc) in floppy_release_regions() argument
4824 floppy_release_allocated_regions(fdc, ARRAY_END(io_regions)); in floppy_release_regions()
4829 int fdc; in floppy_grab_irq_and_dma() local
4858 for (fdc = 0; fdc < N_FDC; fdc++) { in floppy_grab_irq_and_dma()
4859 if (fdc_state[fdc].address != -1) { in floppy_grab_irq_and_dma()
4860 if (floppy_request_regions(fdc)) in floppy_grab_irq_and_dma()
4864 for (fdc = 0; fdc < N_FDC; fdc++) { in floppy_grab_irq_and_dma()
4865 if (fdc_state[fdc].address != -1) { in floppy_grab_irq_and_dma()
4866 reset_fdc_info(fdc, 1); in floppy_grab_irq_and_dma()
4867 fdc_outb(fdc_state[fdc].dor, fdc, FD_DOR); in floppy_grab_irq_and_dma()
4873 for (fdc = 0; fdc < N_FDC; fdc++) in floppy_grab_irq_and_dma()
4874 if (fdc_state[fdc].address != -1) in floppy_grab_irq_and_dma()
4875 fdc_outb(fdc_state[fdc].dor, fdc, FD_DOR); in floppy_grab_irq_and_dma()
4886 while (--fdc >= 0) in floppy_grab_irq_and_dma()
4887 floppy_release_regions(fdc); in floppy_grab_irq_and_dma()
4895 int fdc; in floppy_release_irq_and_dma() local
4936 for (fdc = 0; fdc < N_FDC; fdc++) in floppy_release_irq_and_dma()
4937 if (fdc_state[fdc].address != -1) in floppy_release_irq_and_dma()
4938 floppy_release_regions(fdc); in floppy_release_irq_and_dma()