Lines Matching refs:fdc

234 static int set_dor(int fdc, char mask, char data);
305 #define REVDRIVE(fdc, unit) ((unit) + ((fdc) << 2)) argument
594 static inline unsigned char fdc_inb(int fdc, int reg) in fdc_inb() argument
596 return fd_inb(fdc_state[fdc].address, reg); in fdc_inb()
599 static inline void fdc_outb(unsigned char value, int fdc, int reg) in fdc_outb() argument
601 fd_outb(value, fdc_state[fdc].address, reg); in fdc_outb()
734 int fdc = FDC(drive); in disk_change() local
738 if (!(fdc_state[fdc].dor & (0x10 << UNIT(drive))) || in disk_change()
739 (fdc_state[fdc].dor & 3) != UNIT(drive) || fdc != FDC(drive)) { in disk_change()
742 (unsigned int)fdc_state[fdc].dor); in disk_change()
749 fdc_inb(fdc, FD_DIR) & 0x80); in disk_change()
756 if ((fdc_inb(fdc, FD_DIR) ^ drive_params[drive].flags) & 0x80) { in disk_change()
792 static int set_dor(int fdc, char mask, char data) in set_dor() argument
799 if (fdc_state[fdc].address == -1) in set_dor()
802 olddor = fdc_state[fdc].dor; in set_dor()
807 drive = REVDRIVE(fdc, unit); in set_dor()
812 fdc_state[fdc].dor = newdor; in set_dor()
813 fdc_outb(newdor, fdc, FD_DOR); in set_dor()
817 drive = REVDRIVE(fdc, unit); in set_dor()
824 static void twaddle(int fdc, int drive) in twaddle() argument
828 fdc_outb(fdc_state[fdc].dor & ~(0x10 << UNIT(drive)), in twaddle()
829 fdc, FD_DOR); in twaddle()
830 fdc_outb(fdc_state[fdc].dor, fdc, FD_DOR); in twaddle()
838 static void reset_fdc_info(int fdc, int mode) in reset_fdc_info() argument
842 fdc_state[fdc].spec1 = fdc_state[fdc].spec2 = -1; in reset_fdc_info()
843 fdc_state[fdc].need_configure = 1; in reset_fdc_info()
844 fdc_state[fdc].perp_mode = 1; in reset_fdc_info()
845 fdc_state[fdc].rawcmd = 0; in reset_fdc_info()
847 if (FDC(drive) == fdc && in reset_fdc_info()
858 unsigned int fdc; in set_fdc() local
865 fdc = FDC(drive); in set_fdc()
866 if (fdc >= N_FDC) { in set_fdc()
871 set_dor(fdc, ~0, 8); in set_fdc()
873 set_dor(1 - fdc, ~8, 0); in set_fdc()
875 if (fdc_state[fdc].rawcmd == 2) in set_fdc()
876 reset_fdc_info(fdc, 1); in set_fdc()
877 if (fdc_inb(fdc, FD_STATUS) != STATUS_READY) in set_fdc()
878 fdc_state[fdc].reset = 1; in set_fdc()
881 current_fdc = fdc; in set_fdc()
935 int fdc = FDC(drive); in floppy_off() local
937 if (!(fdc_state[fdc].dor & (0x10 << UNIT(drive)))) in floppy_off()
1113 static void show_floppy(int fdc);
1116 static int wait_til_ready(int fdc) in wait_til_ready() argument
1121 if (fdc_state[fdc].reset) in wait_til_ready()
1124 status = fdc_inb(fdc, FD_STATUS); in wait_til_ready()
1129 DPRINT("Getstatus times out (%x) on fdc %d\n", status, fdc); in wait_til_ready()
1130 show_floppy(fdc); in wait_til_ready()
1132 fdc_state[fdc].reset = 1; in wait_til_ready()
1137 static int output_byte(int fdc, char byte) in output_byte() argument
1139 int status = wait_til_ready(fdc); in output_byte()
1145 fdc_outb(byte, fdc, FD_DATA); in output_byte()
1152 fdc_state[fdc].reset = 1; in output_byte()
1155 byte, fdc, status); in output_byte()
1156 show_floppy(fdc); in output_byte()
1162 static int result(int fdc) in result() argument
1168 status = wait_til_ready(fdc); in result()
1178 reply_buffer[i] = fdc_inb(fdc, FD_DATA); in result()
1184 fdc, status, i); in result()
1185 show_floppy(fdc); in result()
1187 fdc_state[fdc].reset = 1; in result()
1193 static int need_more_output(int fdc) in need_more_output() argument
1195 int status = wait_til_ready(fdc); in need_more_output()
1203 return result(fdc); in need_more_output()
1209 static void perpendicular_mode(int fdc) in perpendicular_mode() argument
1224 fdc_state[fdc].reset = 1; in perpendicular_mode()
1235 if (fdc_state[fdc].perp_mode == perp_mode) in perpendicular_mode()
1237 if (fdc_state[fdc].version >= FDC_82077_ORIG) { in perpendicular_mode()
1238 output_byte(fdc, FD_PERPENDICULAR); in perpendicular_mode()
1239 output_byte(fdc, perp_mode); in perpendicular_mode()
1240 fdc_state[fdc].perp_mode = perp_mode; in perpendicular_mode()
1249 static int fdc_configure(int fdc) in fdc_configure() argument
1252 output_byte(fdc, FD_CONFIGURE); in fdc_configure()
1253 if (need_more_output(fdc) != MORE_OUTPUT) in fdc_configure()
1255 output_byte(fdc, 0); in fdc_configure()
1256 output_byte(fdc, 0x10 | (no_fifo & 0x20) | (fifo_depth & 0xf)); in fdc_configure()
1257 output_byte(fdc, 0); /* pre-compensation from track 0 upwards */ in fdc_configure()
1282 static void fdc_specify(int fdc, int drive) in fdc_specify() argument
1294 if (fdc_state[fdc].need_configure && in fdc_specify()
1295 fdc_state[fdc].version >= FDC_82072A) { in fdc_specify()
1296 fdc_configure(fdc); in fdc_specify()
1297 fdc_state[fdc].need_configure = 0; in fdc_specify()
1306 if (fdc_state[fdc].version >= FDC_82078) { in fdc_specify()
1309 output_byte(fdc, FD_DRIVESPEC); in fdc_specify()
1310 if (need_more_output(fdc) == MORE_OUTPUT) { in fdc_specify()
1311 output_byte(fdc, UNIT(drive)); in fdc_specify()
1312 output_byte(fdc, 0xc0); in fdc_specify()
1321 if (fdc_state[fdc].version >= FDC_82072) { in fdc_specify()
1354 if (fdc_state[fdc].spec1 != spec1 || in fdc_specify()
1355 fdc_state[fdc].spec2 != spec2) { in fdc_specify()
1357 output_byte(fdc, FD_SPECIFY); in fdc_specify()
1358 output_byte(fdc, fdc_state[fdc].spec1 = spec1); in fdc_specify()
1359 output_byte(fdc, fdc_state[fdc].spec2 = spec2); in fdc_specify()
1570 static void check_wp(int fdc, int drive) in check_wp() argument
1574 output_byte(fdc, FD_GETSTATUS); in check_wp()
1575 output_byte(fdc, UNIT(drive)); in check_wp()
1576 if (result(fdc) != 1) { in check_wp()
1577 fdc_state[fdc].reset = 1; in check_wp()
1829 static void show_floppy(int fdc) in show_floppy() argument
1852 pr_info("status=%x\n", fdc_inb(fdc, FD_STATUS)); in show_floppy()
4242 static char __init get_fdc_version(int fdc) in get_fdc_version() argument
4246 output_byte(fdc, FD_DUMPREGS); /* 82072 and better know DUMPREGS */ in get_fdc_version()
4247 if (fdc_state[fdc].reset) in get_fdc_version()
4249 r = result(fdc); in get_fdc_version()
4253 pr_info("FDC %d is an 8272A\n", fdc); in get_fdc_version()
4258 fdc, r); in get_fdc_version()
4262 if (!fdc_configure(fdc)) { in get_fdc_version()
4263 pr_info("FDC %d is an 82072\n", fdc); in get_fdc_version()
4267 output_byte(fdc, FD_PERPENDICULAR); in get_fdc_version()
4268 if (need_more_output(fdc) == MORE_OUTPUT) { in get_fdc_version()
4269 output_byte(fdc, 0); in get_fdc_version()
4271 pr_info("FDC %d is an 82072A\n", fdc); in get_fdc_version()
4275 output_byte(fdc, FD_UNLOCK); in get_fdc_version()
4276 r = result(fdc); in get_fdc_version()
4278 pr_info("FDC %d is a pre-1991 82077\n", fdc); in get_fdc_version()
4284 fdc, r); in get_fdc_version()
4287 output_byte(fdc, FD_PARTID); in get_fdc_version()
4288 r = result(fdc); in get_fdc_version()
4291 fdc, r); in get_fdc_version()
4295 pr_info("FDC %d is a post-1991 82077\n", fdc); in get_fdc_version()
4301 pr_info("FDC %d is an 82078.\n", fdc); in get_fdc_version()
4304 pr_info("FDC %d is a 44pin 82078\n", fdc); in get_fdc_version()
4307 pr_info("FDC %d is a S82078B\n", fdc); in get_fdc_version()
4310 pr_info("FDC %d is a National Semiconductor PC87306\n", fdc); in get_fdc_version()
4314 fdc, reply_buffer[ST0] >> 5); in get_fdc_version()
4477 int fdc; in floppy_resume() local
4481 for (fdc = 0; fdc < N_FDC; fdc++) in floppy_resume()
4482 if (fdc_state[fdc].address != -1) in floppy_resume()
4483 user_reset_fdc(REVDRIVE(fdc, 0), FD_RESET_ALWAYS, false); in floppy_resume()
4803 static void floppy_release_allocated_regions(int fdc, const struct io_region *p) in floppy_release_allocated_regions() argument
4807 release_region(fdc_state[fdc].address + p->offset, p->size); in floppy_release_allocated_regions()
4813 static int floppy_request_regions(int fdc) in floppy_request_regions() argument
4818 if (!request_region(fdc_state[fdc].address + p->offset, in floppy_request_regions()
4821 fdc_state[fdc].address + p->offset); in floppy_request_regions()
4822 floppy_release_allocated_regions(fdc, p); in floppy_request_regions()
4829 static void floppy_release_regions(int fdc) in floppy_release_regions() argument
4831 floppy_release_allocated_regions(fdc, ARRAY_END(io_regions)); in floppy_release_regions()
4836 int fdc; in floppy_grab_irq_and_dma() local
4865 for (fdc = 0; fdc < N_FDC; fdc++) { in floppy_grab_irq_and_dma()
4866 if (fdc_state[fdc].address != -1) { in floppy_grab_irq_and_dma()
4867 if (floppy_request_regions(fdc)) in floppy_grab_irq_and_dma()
4871 for (fdc = 0; fdc < N_FDC; fdc++) { in floppy_grab_irq_and_dma()
4872 if (fdc_state[fdc].address != -1) { in floppy_grab_irq_and_dma()
4873 reset_fdc_info(fdc, 1); in floppy_grab_irq_and_dma()
4874 fdc_outb(fdc_state[fdc].dor, fdc, FD_DOR); in floppy_grab_irq_and_dma()
4880 for (fdc = 0; fdc < N_FDC; fdc++) in floppy_grab_irq_and_dma()
4881 if (fdc_state[fdc].address != -1) in floppy_grab_irq_and_dma()
4882 fdc_outb(fdc_state[fdc].dor, fdc, FD_DOR); in floppy_grab_irq_and_dma()
4893 while (--fdc >= 0) in floppy_grab_irq_and_dma()
4894 floppy_release_regions(fdc); in floppy_grab_irq_and_dma()
4902 int fdc; in floppy_release_irq_and_dma() local
4943 for (fdc = 0; fdc < N_FDC; fdc++) in floppy_release_irq_and_dma()
4944 if (fdc_state[fdc].address != -1) in floppy_release_irq_and_dma()
4945 floppy_release_regions(fdc); in floppy_release_irq_and_dma()