We already discussed a bit about it and we know this is a feature to allow role switching in otg sessions without changing the cable. But what does this really mean? Who handle this? Which device(s) already support it? How should I know that my device supports HNP? Is there any public code for that?
That's what we're taking a look today. Take a look by clicking at the next link
Overview
From OTG Specs Rev1.3 HNP means:
"HNP is used to transfer control of a connection from the default Host (A-device) to the default Peripheral (B-device). This is accomplished by having the A-device condition the B-device to be able to take control of the bus, and then having the A-device present an opportunity for the B-device to take control."
This means, in practical terms, that B-device will become Host (b_host state) and A-device will become peripheral (a_peripheral state).
In order for the B-device to be able to issue HNP it should send a SetFeature(b_hnp_enable) command and suspend the bus. If B-device wants to use the bus at that moment, it send a disconnect to A-device. The transfer will be completed when the A-device turns on its pull-up resistor on D+ (Data+).
Whenever B-device finishes using the bus, it'll give control back to A-device by stopping all activities on the bus and turning on its pull-up resistor on D+. A-device will detect this and turn off its pull-up resistor, after that B-device will connect and A-device will resume the bus activity.
That's mostly what happens. A bit complicated isn't it? Let's see a picture.
A) A-device suspends the bus;
B) B-device turns off its D+ pull-up resistor;
C) A-devices turns on its D+ pull-up resistor;
D) B-device asserts bus reset;
E) After using the bus, B-device stops all bus activity;
F) A-devices turns off it's D+ pull-up resistor;
G) B-devices turns on it's D+ pull-up resistor;
H) A-device asserts bus reset after connect from B-device.
Who handle these?
All this logic is handled on the controller, we just use its functionalities by writing bits to some register (mostly). So, there's not much to worry with all this logic, it's just good to understand how HNP really happens.
Which device(s) already support it?
At the time of this writing, N810 is the only full otg certified device in the world. If anyone knows any other device that supports HNP, list it as a comment.
Here's a picture of my n810
All of you can see I'm not really good as a photographer nor with gimp, but here's the picture anyway :-p.
How should I know that my device supports HNP?
That's really easy on linux boxes. You just attach the device to USB port and issue:
# lsusb -v -d VENDORID:PRODID
On N810 you should see something like:
# lsusb -v -d 0421:0096 Bus 003 Device 006: ID 0421:0096 Nokia Mobile Phones Nokia N810 Internet Tablet Device Descriptor: bLength 18 bDescriptorType 1 bcdUSB 2.00 bDeviceClass 0 (Defined at Interface level) bDeviceSubClass 0 bDeviceProtocol 0 bMaxPacketSize0 64 idVendor 0x0421 Nokia Mobile Phones idProduct 0x0096 Nokia N810 Internet Tablet bcdDevice 3.16 iManufacturer 1 Nokia iProduct 2 Nokia N810 Internet Tablet iSerial 3 3238204E6F76 bNumConfigurations 1 OTG Descriptor: bLength 3 bDescriptorType 9 bmAttributes 0x03 SRP (Session Request Protocol) HNP (Host Negotiation Protocol) Configuration Descriptor: bLength 9 bDescriptorType 2 wTotalLength 35 bNumInterfaces 1 bConfigurationValue 1 iConfiguration 4 Self-powered bmAttributes 0xc0 Self Powered MaxPower 50mA Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 0 bAlternateSetting 0 bNumEndpoints 2 bInterfaceClass 8 Mass Storage bInterfaceSubClass 6 SCSI bInterfaceProtocol 80 Bulk (Zip) iInterface 5 Mass Storage Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x81 EP 1 IN bmAttributes 2 Transfer Type Bulk Synch Type None Usage Type Data wMaxPacketSize 0x0200 1x 512 bytes bInterval 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x01 EP 1 OUT bmAttributes 2 Transfer Type Bulk Synch Type None Usage Type Data wMaxPacketSize 0x0200 1x 512 bytes bInterval 1 Device Qualifier (for other device speed): bLength 10 bDescriptorType 6 bcdUSB 2.00 bDeviceClass 0 (Defined at Interface level) bDeviceSubClass 0 bDeviceProtocol 0 bMaxPacketSize0 64 bNumConfigurations 1 Device Status: 0x0001 Self Powered
One can see that HNP is supported by the line
HNP (Host Negotiation Protocol)
And that's all for today. Wait for more and comment out

