Kernel driver i2c-floppy Author: Herbert Poetzl This driver is for a simple do-it-yourself floppy controller to I2C adapter which uses direct I/O access and the sense command to control the output lines and query the input lines. Potential output lines are (for now): Motor Enable A [/MOTEA, 10] Drive Select B [/DRVSB, 12] Drive Select A [/DRVSA, 14] Motor Enable B [/MOTEB, 16] Head Select [/SIDE1, 32] Potential input lines are (for now): Track 0 [/TRK00, 26] Write Protect [/WPT, 28] Disk Change [/DSKCHG, 34] Not all possible combinations are useable, as for example the Drive Select lines depend on the respective Motor Enable line. Nevertheless, the possible combinations can be selected from the following table: Mode ENA SDA SCL ------------------------------------------------------- 1 - /MOTEA [10] /MOTEB [16] 2 /SIDE1 [32] /MOTEA [10] /MOTEB [16] ----------------------------------------------------- 3 - /MOTEA [10] /DRVSB [12] 4 /MOTEB [16] /MOTEA [10] /DRVSB [12] 5 /SIDE1 [32] /MOTEA [10] /DRVSB [12] ----------------------------------------------------- 6 - /MOTEA [10] /SIDE1 [32] 7 /MOTEB [16] /MOTEA [10] /SIDE1 [32] 8 /DRVSB [12] /MOTEA [10] /SIDE1 [32] ----------------------------------------------------- 9 - /MOTEB [16] /DRVSA [14] 10 [0a] /MOTEA [10] /MOTEB [16] /DRVSA [14] 11 [0b] /SIDE1 [32] /MOTEB [16] /DRVSA [14] ----------------------------------------------------- 12 [0c] - /MOTEB [16] /SIDE1 [32] 13 [0d] /MOTEA [10] /MOTEB [16] /SIDE1 [32] 14 [0e] /DRVSA [14] /MOTEB [16] /SIDE1 [32] ----------------------------------------------------- 15 [0f] - /SIDE1 [32] /DRVSA [14] 16 [10] /MOTEA [10] /SIDE1 [32] /DRVSA [14] 17 [11] /MOTEB [16] /SIDE1 [32] /DRVSA [14] 18 [12] /DRVSB [12] /SIDE1 [32] /DRVSA [14] ----------------------------------------------------- 19 [13] - /SIDE1 [32] /DRVSB [12] 20 [14] /MOTEA [10] /SIDE1 [32] /DRVSB [12] 21 [15] /MOTEB [16] /SIDE1 [32] /DRVSB [12] 22 [16] /DRVSA [14] /SIDE1 [32] /DRVSB [12] ------------------------------------------------------- The following modifiers can be added to the selection: 32 0x0020 Swap SCL and SDA 64 0x0040 Invert SDA Output 128 0x0080 Invert SCL Output 256 0x0100 Invert ENA Output The input can be selected in a similar way, although it is probably easier to use the autodetect feature there. Nevertheless here is the table: Mode ENA SDA SCL ------------------------------------------------------- 0 auto detect auto detect auto detect ----------------------------------------------------- 1 - /DSKCHG [34] - 2 - /TRK00 [26] - 3 - /WPT [28] - ----------------------------------------------------- 4 - /DSKCHG [34] /TRK00 [26] 5 - /TRK00 [26] /WPT [28] 6 - /WPT [28] /DSKCHG [34] ----------------------------------------------------- 7 /DSKCHG [34] /TRK00 [26] - 8 /DSKCHG [34] /WPT [28] - 9 /DSKCHG [34] /TRK00 [26] /WPT [28] ----------------------------------------------------- 10 [0a] /TRK00 [26] /DSKCHG [34] - 11 [0b] /TRK00 [26] /WPT [28] - 12 [0c] /TRK00 [26] /WPT [28] /DSKCHG [34] ----------------------------------------------------- 13 [0d] /WPT [28] /DSKCHG [34] - 14 [0e] /WPT [28] /TRK00 [26] - 15 [0f] /WPT [28] /DSKCHG [34] /TRK00 [26] ------------------------------------------------------- And the same modifiers can be applied as for the output. The following (minimal) circuit is not suited to be used together with a Floppy drive (which would need some logic to work properly) but as replacement. +---+ | F | Motor Enable A [/MOTEA,10] -------------- SCL | L | | O | Motor Enable B [/MOTEB,16] ------+------- SDA | P | | | P | | | Y | Disk Change [/DSKCHG,34] ------+ +-- GND +-+-+ | | | GND GND The Motor Enable output of floppy disk controllers is an open drain output (48mA), usually pulled up to +5V via 1k or higher, and the Disk Change is a Schmitt Trigger (0.8V/2.2V) input with max 150uA input current (data taken from the WD/FDC 37C6xx Floppy Disk Subsystem Controller datasheets, which basically combine all the necessary parts of the PC floppy circuit). So it should be fine to connect it to all 5V I2C devices, and most 3.3V devices (which are usually capable of handling 5V I2C bus voltages). Power for those devices can be drawn from either the Floppy power connector (+5V/+12V) or from the SATA 3.3V lines (or if you prefer from some external source). Here is a slightly more advanced circuit, which allows for SCL readback (and thus for clock stretching) and which works on controllers with reduce functionality (i.e. without control for a second drive): +---+ | | Motor Enable A [/MOTEA,10] -------------- ENA | F | | L | Drive Select A [/DRVSA,14] ------+------- SDA | O | | | P | Write Protect [/WPT,28] --------+ | P | | Y | Head Select [/SIDE1,32] ------+------- SCL | | | | | Disk Change [/DSKCHG,34] -----+ +-- GND +-+-+ | | | GND GND