Skip to content
Snippets Groups Projects
  1. Oct 01, 2017
    • Bin Meng's avatar
      dm: usb: emul: Drop usb_emul_reset() · ad56e4b6
      Bin Meng authored
      
      With the root hub unbinding in usb_stop(), there is no need to do
      a Sandbox-specific reset operation. usb_emul_reset() is no longer
      used anywhere, drop it.
      
      Signed-off-by: default avatarBin Meng <bmeng.cn@gmail.com>
      ad56e4b6
    • Bin Meng's avatar
      dm: usb: Remove no longer needed blk_unbind_all() · ad0a9378
      Bin Meng authored
      
      With the root hub unbinding in usb_stop(), there is no need to do
      a blk uclass specific unbind operation.
      
      Signed-off-by: default avatarBin Meng <bmeng.cn@gmail.com>
      ad0a9378
    • Bin Meng's avatar
      dm: usb: Fix broken usb_stop() · d4efefe3
      Bin Meng authored
      
      At present we only do device_remove() during usb stop. The DM API
      device_remove() only marks the device state as inactivated, but
      still keeps its USB topology (eg: parent, children, etc) in the DM
      device structure. There is no issue if we only start USB subsystem
      once and never stop it. But a big issue occurs when we do 'usb stop'
      and 'usb start' multiple times.
      
      Strange things may be observed with current implementation, like:
      - the enumeration may report only 1 mass storage device is detected,
        but the total number of USB devices is correct.
      - USB keyboard does not work anymore after a bunch of 'usb reset'
        even if 'usb tree' shows it is correctly identified.
      - read/write flash drive via 'fatload usb' may complain "Bad device"
      
      In fact, every time when USB host controller starts the enumeration
      process, it takes random time for each USB port to show up online,
      hence each USB device may appear in a different order from previous
      enumeration, and gets assigned to a totally different USB address.
      As a result, we end up using a stale USB topology in the DM device
      structure which still reflects the previous enumeration result, and
      it may create an exact same DM device name like generic_bus_0_dev_7
      that is already in the DM device structure. And since the DM device
      structure is there, there is no device_bind() call to bind driver to
      the device during current enumeration process, eventually creating
      an inconsistent software representation of the hardware topology, a
      non-working USB subsystem.
      
      The fix is to clear the unused USB topology in the usb_stop(), by
      calling device_unbind() on each controller's root hub device, and
      the unbinding will unbind all of its children automatically.
      
      For Sandbox, we need scan the device tree each time when we start
      the USB stack, in order to re-create the emulated USB devices and
      bind drivers for them before we actually do the driver probe.
      
      Signed-off-by: default avatarBin Meng <bmeng.cn@gmail.com>
      d4efefe3
    • Bin Meng's avatar
      usb: emul: hub: Report the actual device speed of the emulation device · d7771f0c
      Bin Meng authored
      
      At present the usb hub emulator always reports its downstream port
      speed as full speed. Actually it is high speed for sandbox-flash,
      and low speed for sandbox-keyb. We can determine the device speed
      by checking its device descriptor bcdUSB field, and do the proper
      hub port status report based on that.
      
      Signed-off-by: default avatarBin Meng <bmeng.cn@gmail.com>
      d7771f0c
    • Bin Meng's avatar
      usb: emul: Expose find_descriptor() as a public API · 848436a4
      Bin Meng authored
      
      This can be useful outside of the sandbox usb emulation uclass
      driver. Expose it as a public API with a proper prefix (usb_emul_).
      
      Signed-off-by: default avatarBin Meng <bmeng.cn@gmail.com>
      848436a4
    • Bin Meng's avatar
      usb: sandbox: Fix emulator device select logic in usb_emul_find_devnum() · 84aa8536
      Bin Meng authored
      
      Current emulator select logic in usb_emul_find_devnum() is to test
      the USB address. The USB address of the device being enumerated is
      initialized to zero at the beginning of the enumeration process in
      usb_setup_device(). At this point, the saved USB address in the
      platform data has not been assigned to any valid USB address either.
      This means: the logic will select an emulator device according to
      its sequence of declaring order in the device tree. Take test.dts
      for example, flash-stick@0 will be selected before flash-stick@1.
      But unfortunately such logic is wrong.
      
      In fact USB devices show up in a random order during the enumeration
      which means usb_emul_find_devnum() may be called on port 3 for keyb@3
      before on port 0 for flash-stick@0.
      
      To fix this, we introduce a new emulator uclass specific platdata
      to store the USB device's port number on its parent hub, and update
      the logic to test the port number instead.
      
      Signed-off-by: default avatarBin Meng <bmeng.cn@gmail.com>
      84aa8536
    • Bin Meng's avatar
      usb: sandbox: Initialize root hub's device speed to high speed · 813f74ea
      Bin Meng authored
      
      At present 'usb tree' shows that the root hub on the Sandbox USB
      controller is at full speed. But its device descriptor says it's
      USB 2.0, so let's report it as a high speed device.
      
      Signed-off-by: default avatarBin Meng <bmeng.cn@gmail.com>
      813f74ea
    • Bin Meng's avatar
      usb: Fix comments of usb_emul_find_for_dev() · 8d36c687
      Bin Meng authored
      
      There is no such a parameter called 'bus'.
      
      Signed-off-by: default avatarBin Meng <bmeng.cn@gmail.com>
      8d36c687
    • Bin Meng's avatar
      usb: emul: Remove maxpacketsize in usb_emul_setup_device() · 98b639fc
      Bin Meng authored
      
      This parameter is never used.
      
      Signed-off-by: default avatarBin Meng <bmeng.cn@gmail.com>
      98b639fc
  2. Sep 27, 2017
  3. Sep 26, 2017
  4. Sep 25, 2017
Loading