Hello Alan, thanks for the reply. On Mon, Jan 10, 2011 at 9:00 PM, Alan Stern <stern@xxxxxxxxxxxxxxxxxxx> wrote: > On Mon, 10 Jan 2011, Pratyush Anand wrote: > >> Hi All, >> >> As per USB 2.0 specification(Section 11.12.5 Over-current Reporting >> and Recovery): >> >> When a hub experiences an over-current condition, it must place all >> affected ports in the Powered-off state. >> >> It does not specify whether this action is to be done by hardware or software. > > Yes it does. It says "When a hub ... it must place ..." The word "it" > refers back to the word "hub". This means that the hub must place all > affected ports in the Powered-off state. In others words, the action > is to be done by hardware. > OK. >> I am working with controller where it expects port power off to be >> done by software in case of overcurrent detection interrupt. > > Root hubs are different from external hubs. It is reasonable to expect > software to turn off port power for root hubs. > The code which I had referred was from linux (except hub_power_off part). linux+v2.6.37/drivers/usb/core/hub.c line no: 3416 3416 if (hubchange & HUB_CHANGE_OVERCURRENT) { 3417 dev_dbg (hub_dev, "overcurrent change\n"); 3418 msleep(500); /* Cool down */ 3419 clear_hub_feature(hdev, C_HUB_OVER_CURRENT); 3420 hub_power_on(hub, true); 3421 } 3422 } But, It does not turn off port power for root hubs. Regards Pratyush >> So , implementation would be something like: >> >> if (hubchange & HUB_CHANGE_OVERCURRENT) { >> dev_dbg (hub_dev, "overcurrent change\n"); >> >> hub_power_off(hub); >> msleep(500); /* Cool down */ >> clear_hub_feature(hdev, C_HUB_OVER_CURRENT); >> hub_power_on(hub, true); >> } >> >> Is this implementation correct? > > Not really. The spec also states: "Host waits for over-current status > bit to be cleared to 0". Your code always waits for 500 ms, which > could be either too long or too short. On the other hand, you mustn't > wait indefinitely. > > Also, you have to do more or less the same thing when any ports report > over-current status. In this case you would have to first turn off the > power to all the affected ports, then wait, then turn on power to all > of them. > > Alan Stern > > -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html