| .. | .. |
|---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-only */ |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * arch/arm/include/asm/floppy.h |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Copyright (C) 1996-2000 Russell King |
|---|
| 5 | 6 | * |
|---|
| 6 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 7 | | - * it under the terms of the GNU General Public License version 2 as |
|---|
| 8 | | - * published by the Free Software Foundation. |
|---|
| 9 | | - * |
|---|
| 10 | 7 | * Note that we don't touch FLOPPY_DMA nor FLOPPY_IRQ here |
|---|
| 11 | 8 | */ |
|---|
| 12 | 9 | #ifndef __ASM_ARM_FLOPPY_H |
|---|
| 13 | 10 | #define __ASM_ARM_FLOPPY_H |
|---|
| 14 | | -#if 0 |
|---|
| 15 | | -#include <mach/floppy.h> |
|---|
| 16 | | -#endif |
|---|
| 17 | 11 | |
|---|
| 18 | | -#define fd_outb(val,port) \ |
|---|
| 19 | | - do { \ |
|---|
| 20 | | - if ((port) == (u32)FD_DOR) \ |
|---|
| 21 | | - fd_setdor((val)); \ |
|---|
| 22 | | - else \ |
|---|
| 23 | | - outb((val),(port)); \ |
|---|
| 12 | +#define fd_outb(val, base, reg) \ |
|---|
| 13 | + do { \ |
|---|
| 14 | + int new_val = (val); \ |
|---|
| 15 | + if ((reg) == FD_DOR) { \ |
|---|
| 16 | + if (new_val & 0xf0) \ |
|---|
| 17 | + new_val = (new_val & 0x0c) | \ |
|---|
| 18 | + floppy_selects[new_val & 3]; \ |
|---|
| 19 | + else \ |
|---|
| 20 | + new_val &= 0x0c; \ |
|---|
| 21 | + } \ |
|---|
| 22 | + outb(new_val, (base) + (reg)); \ |
|---|
| 24 | 23 | } while(0) |
|---|
| 25 | 24 | |
|---|
| 26 | | -#define fd_inb(port) inb((port)) |
|---|
| 25 | +#define fd_inb(base, reg) inb((base) + (reg)) |
|---|
| 27 | 26 | #define fd_request_irq() request_irq(IRQ_FLOPPYDISK,floppy_interrupt,\ |
|---|
| 28 | 27 | 0,"floppy",NULL) |
|---|
| 29 | 28 | #define fd_free_irq() free_irq(IRQ_FLOPPYDISK,NULL) |
|---|
| .. | .. |
|---|
| 56 | 55 | * to a non-zero track, and then restoring it to track 0. If an error occurs, |
|---|
| 57 | 56 | * then there is no floppy drive present. [to be put back in again] |
|---|
| 58 | 57 | */ |
|---|
| 59 | | -static unsigned char floppy_selects[2][4] = |
|---|
| 60 | | -{ |
|---|
| 61 | | - { 0x10, 0x21, 0x23, 0x33 }, |
|---|
| 62 | | - { 0x10, 0x21, 0x23, 0x33 } |
|---|
| 63 | | -}; |
|---|
| 64 | | - |
|---|
| 65 | | -#define fd_setdor(dor) \ |
|---|
| 66 | | -do { \ |
|---|
| 67 | | - int new_dor = (dor); \ |
|---|
| 68 | | - if (new_dor & 0xf0) \ |
|---|
| 69 | | - new_dor = (new_dor & 0x0c) | floppy_selects[fdc][new_dor & 3]; \ |
|---|
| 70 | | - else \ |
|---|
| 71 | | - new_dor &= 0x0c; \ |
|---|
| 72 | | - outb(new_dor, FD_DOR); \ |
|---|
| 73 | | -} while (0) |
|---|
| 74 | | - |
|---|
| 75 | | -/* |
|---|
| 76 | | - * Someday, we'll automatically detect which drives are present... |
|---|
| 77 | | - */ |
|---|
| 78 | | -static inline void fd_scandrives (void) |
|---|
| 79 | | -{ |
|---|
| 80 | | -#if 0 |
|---|
| 81 | | - int floppy, drive_count; |
|---|
| 82 | | - |
|---|
| 83 | | - fd_disable_irq(); |
|---|
| 84 | | - raw_cmd = &default_raw_cmd; |
|---|
| 85 | | - raw_cmd->flags = FD_RAW_SPIN | FD_RAW_NEED_SEEK; |
|---|
| 86 | | - raw_cmd->track = 0; |
|---|
| 87 | | - raw_cmd->rate = ?; |
|---|
| 88 | | - drive_count = 0; |
|---|
| 89 | | - for (floppy = 0; floppy < 4; floppy ++) { |
|---|
| 90 | | - current_drive = drive_count; |
|---|
| 91 | | - /* |
|---|
| 92 | | - * Turn on floppy motor |
|---|
| 93 | | - */ |
|---|
| 94 | | - if (start_motor(redo_fd_request)) |
|---|
| 95 | | - continue; |
|---|
| 96 | | - /* |
|---|
| 97 | | - * Set up FDC |
|---|
| 98 | | - */ |
|---|
| 99 | | - fdc_specify(); |
|---|
| 100 | | - /* |
|---|
| 101 | | - * Tell FDC to recalibrate |
|---|
| 102 | | - */ |
|---|
| 103 | | - output_byte(FD_RECALIBRATE); |
|---|
| 104 | | - LAST_OUT(UNIT(floppy)); |
|---|
| 105 | | - /* wait for command to complete */ |
|---|
| 106 | | - if (!successful) { |
|---|
| 107 | | - int i; |
|---|
| 108 | | - for (i = drive_count; i < 3; i--) |
|---|
| 109 | | - floppy_selects[fdc][i] = floppy_selects[fdc][i + 1]; |
|---|
| 110 | | - floppy_selects[fdc][3] = 0; |
|---|
| 111 | | - floppy -= 1; |
|---|
| 112 | | - } else |
|---|
| 113 | | - drive_count++; |
|---|
| 114 | | - } |
|---|
| 115 | | -#else |
|---|
| 116 | | - floppy_selects[0][0] = 0x10; |
|---|
| 117 | | - floppy_selects[0][1] = 0x21; |
|---|
| 118 | | - floppy_selects[0][2] = 0x23; |
|---|
| 119 | | - floppy_selects[0][3] = 0x33; |
|---|
| 120 | | -#endif |
|---|
| 121 | | -} |
|---|
| 58 | +static unsigned char floppy_selects[4] = { 0x10, 0x21, 0x23, 0x33 }; |
|---|
| 122 | 59 | |
|---|
| 123 | 60 | #define FDC1 (0x3f0) |
|---|
| 124 | 61 | |
|---|
| .. | .. |
|---|
| 138 | 75 | */ |
|---|
| 139 | 76 | static void driveswap(int *ints, int dummy, int dummy2) |
|---|
| 140 | 77 | { |
|---|
| 141 | | - floppy_selects[0][0] ^= floppy_selects[0][1]; |
|---|
| 142 | | - floppy_selects[0][1] ^= floppy_selects[0][0]; |
|---|
| 143 | | - floppy_selects[0][0] ^= floppy_selects[0][1]; |
|---|
| 78 | + swap(floppy_selects[0], floppy_selects[1]); |
|---|
| 144 | 79 | } |
|---|
| 145 | 80 | |
|---|
| 146 | 81 | #define EXTRA_FLOPPY_PARAMS ,{ "driveswap", &driveswap, NULL, 0, 0 } |
|---|