Re: how can host disconnect a device without unplug

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 15 Jun 2011, Amit Nagal wrote:

> On Tue, Jun 14, 2011 at 7:41 PM, Alan Stern <stern@xxxxxxxxxxxxxxxxxxx> wrote:
> > On Tue, 14 Jun 2011, Amit Nagal wrote:
> >
> >> Hi ,
> >>
> >>
> >> How can a usb host  disconnect a usb device without unplug of usb cable ?
> >
> > What exactly do you mean by "disconnect"?
> >
> 
> by disconnect i mean whether , under software control  , it is
> possible for a usb host to electronically disconnect
> a device   though both remain plugged over usb .
> 
> Basically  programatic equivalent of plug / unplug cycle is desired
> on host side .

Okay, I see.  No, it's not possible.

> >> for eg i mean something similar to usb_gadget_disconnect() api
> >> available on gadget side .
> >
> > That API causes the gadget to remove its terminations and pullup
> > resistors from the bus data lines.  Nothing the host does can cause
> > that to happen.
> >
> 
> ya , so using usb_gadget_disconnect() api , a gadget can do a software
> controlled disconnect from usb host .
> i just used it as example though it is on gadget side .
> 
> so similarly  , is there any api() available on host side , so that a
> host can do a software controlled disconnect to a gadget ?

The host cannot cause a device to disconnect.  There's no way to do it 
in hardware and no way to do it in software.

> again , on gadget side , we have usb_gadget_connect() api , using
> which a gadget can do a software controlled connect to a usb host .
> but it is on gadget side .
> 
> so similarly , is there any api() available on host side , so that a
> host can connect a gadget under software control ?

You don't have to ask the same question many times.  The answer is 
always going to be the same.

> >> is it possible to do entirely in software or support from hardware
> >> also is required ?
> >
> 
> i repeat above question here .

I repeat above answer here.

> >> what interfaces in userspace or kernel can be used if possible ?
> >
> > There's the /sys/bus/usb/devices/.../remove attribute file.  Writing to
> > this file is roughly equivalent to pressing the "Safely remove
> > hardware" button in Windows.  But it isn't like physically unplugging
> > the USB cable.
> >
> 
> Thanx for the information . So software controlled unplug can be done
> from host side .

No.  This mechanism is _not_ a software-controlled unplug.  Read what I 
wrote above: It isn't like physically unplugging the USB cable.

> Can we have  replug functionality somehow from host side ?

Since there is no unplug functionality, I don't see any point in having 
replug functionality.

> i also elaborate my need here :
> 
> 1) In one of my embedded targets , host and device are hardwired over usb .
> so i want to have programtic equivalent of unplug/plug cycle in usb
> host  to check connect / disconnect
> functionality and without using rmmod usb modules on host side . Also
> i donot have control over gadget side .

You could turn off power to the host.  That would have pretty much the 
effect you want.  But there's no other way to do it.

There are various things you can do that come close.  But none of them 
is actually a software-controlled unplug.

> 2) i want usb host to reenumerate the device .

If you call usb_reset_device(), the host will read the device 
descriptors.  But it won't go through a complete re-enumeration unless 
the descriptors have changed from their original values.

If you unbind the host controller from its driver and then rebind it, 
every device attached to that host controller will be re-enumerated.  
But the devices won't be disconnected from the host.

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


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux