fdc.c (1b67be7b750ed0f074d730bf1164a82fe1bcf83b) fdc.c (ec200f23d21d60792f2fa307994c4b63000a26e8)
1/*-
2 * Copyright (c) 2004 Poul-Henning Kamp
3 * Copyright (c) 1990 The Regents of the University of California.
4 * All rights reserved.
5 *
6 * This code is derived from software contributed to Berkeley by
7 * Don Ahn.
8 *

--- 1546 unchanged lines hidden (view full) ---

1555 return (0);
1556}
1557
1558int
1559fdc_initial_reset(device_t dev, struct fdc_data *fdc)
1560{
1561 int ic_type, part_id;
1562
1/*-
2 * Copyright (c) 2004 Poul-Henning Kamp
3 * Copyright (c) 1990 The Regents of the University of California.
4 * All rights reserved.
5 *
6 * This code is derived from software contributed to Berkeley by
7 * Don Ahn.
8 *

--- 1546 unchanged lines hidden (view full) ---

1555 return (0);
1556}
1557
1558int
1559fdc_initial_reset(device_t dev, struct fdc_data *fdc)
1560{
1561 int ic_type, part_id;
1562
1563 /* First, reset the floppy controller. */
1563 /*
1564 * A status value of 0xff is very unlikely, but not theoretically
1565 * impossible, but it is far more likely to indicate an empty bus.
1566 */
1567 if (fdsts_rd(fdc) == 0xff)
1568 return (ENXIO);
1569
1570 /*
1571 * Assert a reset to the floppy controller and check that the status
1572 * register goes to zero.
1573 */
1564 fdout_wr(fdc, 0);
1574 fdout_wr(fdc, 0);
1565 DELAY(100);
1575 fdout_wr(fdc, 0);
1576 if (fdsts_rd(fdc) != 0)
1577 return (ENXIO);
1578
1579 /*
1580 * Clear the reset and see it come ready.
1581 */
1566 fdout_wr(fdc, FDO_FRST);
1582 fdout_wr(fdc, FDO_FRST);
1583 DELAY(100);
1584 if (fdsts_rd(fdc) != 0x80)
1585 return (ENXIO);
1567
1568 /* Then, see if it can handle a command. */
1569 if (fdc_cmd(fdc, 3, NE7CMD_SPECIFY, 0xaf, 0x1e, 0))
1570 return (ENXIO);
1571
1572 /*
1573 * Try to identify the chip.
1574 *
1575 * The i8272 datasheet documents that unknown commands
1576 * will return ST0 as 0x80. The i8272 is supposedly identical
1577 * to the NEC765.
1578 * The i82077SL datasheet says 0x90 for the VERSION command,
1579 * and several "superio" chips emulate this.
1580 */
1581 if (fdc_cmd(fdc, 1, NE7CMD_VERSION, 1, &ic_type))
1582 return (ENXIO);
1583 if (fdc_cmd(fdc, 1, 0x18, 1, &part_id))
1584 return (ENXIO);
1586
1587 /* Then, see if it can handle a command. */
1588 if (fdc_cmd(fdc, 3, NE7CMD_SPECIFY, 0xaf, 0x1e, 0))
1589 return (ENXIO);
1590
1591 /*
1592 * Try to identify the chip.
1593 *
1594 * The i8272 datasheet documents that unknown commands
1595 * will return ST0 as 0x80. The i8272 is supposedly identical
1596 * to the NEC765.
1597 * The i82077SL datasheet says 0x90 for the VERSION command,
1598 * and several "superio" chips emulate this.
1599 */
1600 if (fdc_cmd(fdc, 1, NE7CMD_VERSION, 1, &ic_type))
1601 return (ENXIO);
1602 if (fdc_cmd(fdc, 1, 0x18, 1, &part_id))
1603 return (ENXIO);
1585 printf("ic_type %02x part_id %02x\n", ic_type, part_id);
1604 device_printf(dev, "ic_type %02x part_id %02x\n", ic_type, part_id);
1586 switch (ic_type & 0xff) {
1587 case 0x80:
1588 device_set_desc(dev, "NEC 765 or clone");
1589 fdc->fdct = FDC_NE765;
1590 break;
1591 case 0x81:
1592 case 0x90:
1593 device_set_desc(dev,

--- 347 unchanged lines hidden ---
1605 switch (ic_type & 0xff) {
1606 case 0x80:
1607 device_set_desc(dev, "NEC 765 or clone");
1608 fdc->fdct = FDC_NE765;
1609 break;
1610 case 0x81:
1611 case 0x90:
1612 device_set_desc(dev,

--- 347 unchanged lines hidden ---