[info] Silicon Image device hotplug debounce

From: Jeff Garzik
Date: Tue Jul 26 2005 - 12:35:03 EST



This is some info that Silicon Image provided, for use in developing SATA hotplug. This info is public and not NDA as of the publishing of the SiI 311x hardware documentation at

http://gkernel.sourceforge.net/specs/sii/

Kudos again to SiI for opening their 311x and CMD680 [PATA] docs.

Jeff




Here are some writeups for our 3112/3152 hot plug/unplug handling. Hope it will
help in your open source development.

For the 3114 controller, the sequence is essentially the same as the 3112 except
that the PHYRDY change handler does not need to reset the channel and of course
obvious changes to handle the two additional channels of the 3114.

Best regards,
[silicon image person]

During driver initialization:
Write 0xFFFF0000 to both SERROR registers (BAR 5 offsets 0x108 and 0x188)
to clear any pre-existing serial error bits.

Enable the PHYRDY change interrupt (bit 16) of the SIEN registers
(BAR 5 offsets 0x148 and 0x1C8)

Interrupt handler:
Read PCI Bus Master2 - IDE0 register (BAR 5 offset 0x10) and examine
bits 4 and 6. If either bit is set then read the appropriate SERROR
register and look at bit 16. If this bit is set a PHYRDY change
(hot plug/unplug event) has occurred and the PHYRDY change handler
should be called.

PHYRDY change handler:
If PHYRDY debounce timer is currently running, stop it.

Read the appropriate SSTATUS register (BAR 5 offsets 0x104 or 0x184)
and examine bits 0 and 1. If both of these bits are not set then the
device has been unplugged so perform a hard reset on the channel to
cause the ATA status register to be reset to 0x7F to facilitate device
detection later on if a device plugged back in.

Restart the PHYRDY debounce timer (recommended timer period of ~500ms.)

PHYRDY debounce timer handler:
Read the appropriate SSTATUS register (BAR 5 offsets 0x104 or 0x184)
and examine bits 0 and 1.

If both bits are set a device has been plugged in and the driver should
run its normal device detection/configuration code to make the device
ready for use.

If both bits are not set then the device has been unplugged and the
driver should clean-up any outstanding commands to the removed device.