07 Sep, 2020

1 commit


13 May, 2020

1 commit

  • Right now we don't report to user-space a role switch when doing a
    usb_role_switch_set_role() despite having registered the uevent callbacks.

    This patch switches on the notifications allowing user-space to see
    role-switch change notifications and subsequently determine the current
    controller data-role.

    example:
    PFX=/devices/platform/soc/78d9000.usb/ci_hdrc.0

    root@somebox# udevadm monitor -p

    KERNEL[49.894994] change $PFX/usb_role/ci_hdrc.0-role-switch (usb_role)
    ACTION=change
    DEVPATH=$PFX/usb_role/ci_hdrc.0-role-switch
    SUBSYSTEM=usb_role
    DEVTYPE=usb_role_switch
    USB_ROLE_SWITCH=ci_hdrc.0-role-switch
    SEQNUM=2432

    Cc: Heikki Krogerus
    Cc: Greg Kroah-Hartman
    Cc: Chunfeng Yun
    Cc: Suzuki K Poulose
    Cc: Alexandre Belloni
    Cc: Wen Yang
    Cc: chenqiwu
    Cc: linux-kernel@vger.kernel.org
    Signed-off-by: Bryan O'Donoghue
    Link: https://lore.kernel.org/r/20200508162937.2566818-1-bryan.odonoghue@linaro.org
    Signed-off-by: Greg Kroah-Hartman

    Bryan O'Donoghue
     

04 Mar, 2020

3 commits

  • The switch devices have been named by using the name of the
    parent device as base for now, but if for example the
    parent device controls multiple muxes, that will not work.

    Adding an optional member "name" to the switch descriptor
    that can be used for naming the switch during registration.

    Signed-off-by: Heikki Krogerus
    Link: https://lore.kernel.org/r/20200302135353.56659-7-heikki.krogerus@linux.intel.com
    Signed-off-by: Greg Kroah-Hartman

    Heikki Krogerus
     
  • The USB role callback functions had a parameter pointing to
    the parent device (struct device) of the switch. The
    assumption was that the switch parent is always the
    controller. Firstly, that may not be true in every case, and
    secondly, it prevents us from supporting devices that supply
    multiple muxes.

    Changing the first parameter of usb_role_switch_set_t and
    usb_role_switch_get_t from struct device to struct
    usb_role_switch.

    Cc: Peter Chen
    Cc: Felipe Balbi
    Cc: Chunfeng Yun
    Cc: Bin Liu
    Signed-off-by: Heikki Krogerus
    Link: https://lore.kernel.org/r/20200302135353.56659-6-heikki.krogerus@linux.intel.com
    Signed-off-by: Greg Kroah-Hartman

    Heikki Krogerus
     
  • Adding usb_role_switch_get/set_drvdata() functions that the
    switch drivers can use for setting and getting private data
    pointer that is associated with the switch.

    Signed-off-by: Heikki Krogerus
    Link: https://lore.kernel.org/r/20200302135353.56659-5-heikki.krogerus@linux.intel.com
    Signed-off-by: Greg Kroah-Hartman

    Heikki Krogerus
     

15 Feb, 2020

1 commit

  • Use kobj_to_dev() API instead of container_of().

    Signed-off-by: chenqiwu
    Link: https://lore.kernel.org/r/1581683820-9978-1-git-send-email-qiwuchen55@gmail.com
    Signed-off-by: Greg Kroah-Hartman

    chenqiwu
     

06 Jan, 2020

1 commit


10 Dec, 2019

1 commit

  • Free the sw structure only after we are done using it.
    This patch just moves the put_device() down a bit to avoid the
    use after free.

    Fixes: 5c54fcac9a9d ("usb: roles: Take care of driver module reference counting")
    Signed-off-by: Wen Yang
    Reviewed-by: Heikki Krogerus
    Reviewed-by: Peter Chen
    Cc: stable
    Cc: Hans de Goede
    Cc: Chunfeng Yun
    Cc: Suzuki K Poulose
    Cc: linux-usb@vger.kernel.org
    Cc: linux-kernel@vger.kernel.org
    Link: https://lore.kernel.org/r/20191124142236.25671-1-wenyang@linux.alibaba.com
    Signed-off-by: Greg Kroah-Hartman

    Wen Yang
     

04 Nov, 2019

1 commit

  • Simple wrapper function that searches USB role switches with
    class_find_device_by_fwnode().

    Signed-off-by: Heikki Krogerus
    Reviewed-by: Hans de Goede
    Tested-by: Hans de Goede
    Link: https://lore.kernel.org/r/20191008122600.22340-2-heikki.krogerus@linux.intel.com
    Signed-off-by: Greg Kroah-Hartman

    Heikki Krogerus
     

19 Sep, 2019

1 commit

  • Pull USB updates from Greg KH:
    "Here is the big set of USB patches for 5.4-rc1.

    Two major chunks of code are moving out of the tree and into the
    staging directory, uwb and wusb (wireless USB support), because there
    are no devices that actually use this protocol anymore, and what we
    have today probably doesn't work at all given that the maintainers
    left many many years ago. So move it to staging where it will be
    removed in a few releases if no one screams.

    Other than that, lots of little things. The usual gadget and xhci and
    usb serial driver updates, along with a bunch of sysfs file cleanups
    due to the driver core changes to support that. Nothing really major,
    just constant forward progress.

    All of these have been in linux-next for a while with no reported
    issues"

    * tag 'usb-5.4-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (159 commits)
    USB: usbcore: Fix slab-out-of-bounds bug during device reset
    usb: cdns3: Remove redundant dev_err call in cdns3_probe()
    USB: rio500: Fix lockdep violation
    USB: rio500: simplify locking
    usb: mtu3: register a USB Role Switch for dual role mode
    usb: common: add USB GPIO based connection detection driver
    usb: common: create Kconfig file
    usb: roles: get usb-role-switch from parent
    usb: roles: Add fwnode_usb_role_switch_get() function
    device connection: Add fwnode_connection_find_match()
    usb: roles: Introduce stubs for the exiting functions in role.h
    dt-bindings: usb: mtu3: add properties about USB Role Switch
    dt-bindings: usb: add binding for USB GPIO based connection detection driver
    dt-bindings: connector: add optional properties for Type-B
    dt-binding: usb: add usb-role-switch property
    usbip: Implement SG support to vhci-hcd and stub driver
    usb: roles: intel: Enable static DRD mode for role switch
    xhci-ext-caps.c: Add property to disable Intel SW switch
    usb: dwc3: remove generic PHY calibrate() calls
    usb: core: phy: add support for PHY calibration
    ...

    Linus Torvalds
     

18 Sep, 2019

1 commit

  • Pull device properties framework updates from Rafael Wysocki:
    "Improve software node support (Heikki Krogerus) and clean up two
    assorted pieces of code (Andy Shevchenko, Geert Uytterhoeven)"

    * tag 'devprop-5.4-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm:
    software node: Initialize the return value in software_node_find_by_name()
    software node: Initialize the return value in software_node_to_swnode()
    ACPI / property: Fix acpi_graph_get_remote_endpoint() name in kerneldoc
    device property: Remove duplicate test for NULL
    platform/x86: intel_cht_int33fe: Use new API to gain access to the role switch
    usb: roles: intel_xhci: Supplying software node for the role mux
    software node: Add software_node_find_by_name()

    Linus Torvalds
     

04 Sep, 2019

1 commit

  • when the USB host controller is the parent of the connector,
    usually type-B, sometimes don't need the graph, so we should
    check whether it's parent registers usb-role-switch or not
    firstly, and get it if exists.

    Suggested-by: Heikki Krogerus
    Signed-off-by: Chunfeng Yun
    Link: https://lore.kernel.org/r/1567070558-29417-9-git-send-email-chunfeng.yun@mediatek.com
    Signed-off-by: Greg Kroah-Hartman

    Chunfeng Yun
     

03 Sep, 2019

3 commits

  • The lookup helpers are needed here.

    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     
  • The fwnode_usb_role_switch_get() function is exactly the
    same as usb_role_switch_get(), except that it takes struct
    fwnode_handle as parameter instead of struct device.

    Signed-off-by: Heikki Krogerus
    Signed-off-by: Chunfeng Yun
    Tested-by: Biju Das
    Link: https://lore.kernel.org/r/1567070558-29417-8-git-send-email-chunfeng.yun@mediatek.com
    Signed-off-by: Greg Kroah-Hartman

    Heikki Krogerus
     
  • Enable static DRD mode in Intel platforms which guarantees
    successful role switch all the time. This fixes issues like
    software role switch failure after cold boot and issue with
    role switch when USB 3.0 cable is used. But, do not enable
    static DRD mode for Cherrytrail devices which rely on firmware
    for role switch.

    Signed-off-by: Saranya Gopal
    Signed-off-by: Balaji Manoharan
    Reviewed-by: Heikki Krogerus
    Reviewed-by: Hans de Goede
    Tested-by: Hans de Goede
    Link: https://lore.kernel.org/r/1567079760-24822-2-git-send-email-saranya.gopal@intel.com
    Signed-off-by: Greg Kroah-Hartman

    Saranya Gopal
     

26 Aug, 2019

1 commit

  • The primary purpose for this node will be to allow linking
    the users of the switch to it. The users will be for example
    USB Type-C connectors. By supplying a reference to this
    node in the software nodes representing the USB Type-C
    controllers or connectors, the drivers for those devices can
    access the switch.

    Signed-off-by: Heikki Krogerus
    Reviewed-by: Andy Shevchenko
    Signed-off-by: Rafael J. Wysocki

    Heikki Krogerus
     

30 Jul, 2019

2 commits

  • Add a helper to match the firmware node handle of a device and provide
    wrappers for {bus/class/driver}_find_device() APIs to avoid proliferation
    of duplicate custom match functions.

    Cc: "David S. Miller"
    Cc: Doug Ledford
    Cc: Jason Gunthorpe
    Cc: linux-usb@vger.kernel.org
    Cc: "Rafael J. Wysocki"
    Cc: Ulf Hansson
    Cc: Joe Perches
    Cc: Will Deacon
    Cc: Joerg Roedel
    Signed-off-by: Suzuki K Poulose
    Acked-by: Robin Murphy
    Reviewed-by: Mathieu Poirier
    Reviewed-by: Heikki Krogerus
    Link: https://lore.kernel.org/r/20190723221838.12024-4-suzuki.poulose@arm.com
    Signed-off-by: Greg Kroah-Hartman

    Suzuki K Poulose
     
  • Add a helper to match the device name for device lookup. Also
    reuse this generic exported helper for the existing bus_find_device_by_name().
    and add similar variants for driver/class.

    Cc: Alessandro Zummo
    Cc: Alexander Aring
    Cc: Alexander Shishkin
    Cc: Arnd Bergmann
    Cc: Dan Murphy
    Cc: Harald Freudenberger
    Cc: Heiko Carstens
    Cc: Jacek Anaszewski
    Cc: Lee Jones
    Cc: linux-leds@vger.kernel.org
    Cc: linux-rtc@vger.kernel.org
    Cc: linux-usb@vger.kernel.org
    Cc: linux-wpan@vger.kernel.org
    Cc: Maxime Coquelin
    Cc: Pavel Machek
    Cc: Peter Oberparleiter
    Cc: "Rafael J. Wysocki"
    Cc: Stefan Schmidt
    Cc: Greg Kroah-Hartman
    Cc: "Rafael J. Wysocki"
    Signed-off-by: Suzuki K Poulose
    Reviewed-by: Heikki Krogerus
    Acked-by: Alexandre Belloni
    Link: https://lore.kernel.org/r/20190723221838.12024-2-suzuki.poulose@arm.com
    Signed-off-by: Greg Kroah-Hartman

    Suzuki K Poulose
     

03 Jun, 2019

1 commit


14 Feb, 2019

1 commit

  • When the connections are defined in firmware, struct
    device_connection will have the fwnode member pointing to
    the device node (struct fwnode_handle) of the requested
    device, and the endpoint will not be used at all in that
    case.

    Acked-by: Hans de Goede
    Reviewed-by: Andy Shevchenko
    Reviewed-by: Jun Li
    Tested-by: Jun Li
    Signed-off-by: Heikki Krogerus
    Signed-off-by: Greg Kroah-Hartman

    Heikki Krogerus
     

22 Jan, 2019

1 commit


17 Dec, 2018

1 commit

  • That makes the USB role switch support option visible and
    selectable for the user. The class driver is also moved to
    drivers/usb/roles/ directory.

    This will fix an issue that we have with the Intel USB role
    switch driver on systems that don't have USB Type-C connectors:

    Intel USB role switch driver depends on the USB role switch
    class as it should, but since there was no way for the user
    to enable the USB role switch class, there was also no way
    to select that driver. USB Type-C drivers select the USB
    role switch class which makes the Intel USB role switch
    driver available and therefore hides the problem.

    So in practice Intel USB role switch driver was depending on
    USB Type-C drivers.

    Fixes: f6fb9ec02be1 ("usb: roles: Add Intel xHCI USB role switch driver")
    Cc:
    Signed-off-by: Heikki Krogerus
    Signed-off-by: Greg Kroah-Hartman

    Heikki Krogerus
     

09 Oct, 2018

1 commit

  • Add missing pm_runtime_disable() to remove(), in order to avoid
    an Unbalanced pm_runtime_enable when the module is removed and
    re-probed.

    Error log:
    root@intel-corei7-64:~# modprobe -r intel_xhci_usb_role_switch
    root@intel-corei7-64:~# modprobe intel_xhci_usb_role_switch
    intel_xhci_usb_sw intel_xhci_usb_sw: Unbalanced pm_runtime_enable!

    Fixes: cb2968468605 (usb: roles: intel_xhci: Enable runtime PM)
    Cc:
    Reviewed-by: Heikki Krogerus
    Signed-off-by: Wan Ahmad Zainie
    Signed-off-by: Greg Kroah-Hartman

    Wan Ahmad Zainie
     

25 May, 2018

2 commits

  • This fixes an issue where the mux does not get configured
    when the parent device is suspended. The registers for this
    mux are mapped to the parent device MMIO (usually xHCI PCI
    device), so in order for the driver to be able to program
    the registers, the parent device must be resumed.

    Reported-by: Sathyanarayanan Kuppuswamy
    Fixes: f6fb9ec02be1 ("usb: roles: Add Intel xHCI USB role switch driver")
    Signed-off-by: Heikki Krogerus
    Signed-off-by: Greg Kroah-Hartman

    Heikki Krogerus
     
  • Trying to determine the USB port type with this mux is very
    difficult. To simplify the situation, always allow user
    control, even if the port is USB Type-C port.

    Reviewed-by: Hans de Goede
    Signed-off-by: Heikki Krogerus
    Signed-off-by: Greg Kroah-Hartman

    Heikki Krogerus
     

22 Apr, 2018

1 commit

  • platform_get_resource() may fail and return NULL, so we should
    better check it's return value to avoid a NULL pointer dereference
    a bit later in the code.

    This is detected by Coccinelle semantic patch.

    @@
    expression pdev, res, n, t, e, e1, e2;
    @@

    res = platform_get_resource(pdev, t, n);
    + if (!res)
    + return -EINVAL;
    ... when != res == NULL
    e = devm_ioremap_nocache(e1, res->start, e2);

    Signed-off-by: Wei Yongjun
    Signed-off-by: Greg Kroah-Hartman

    Wei Yongjun
     

26 Mar, 2018

1 commit

  • In case of error, the function devm_ioremap_nocache() returns NULL
    pointer not ERR_PTR(). The IS_ERR() test in the return value check
    should be replaced with NULL test.

    Fixes: f6fb9ec02be1 ("usb: roles: Add Intel xHCI USB role switch driver")
    Signed-off-by: Wei Yongjun
    Reviewed-by: Hans de Goede
    Signed-off-by: Greg Kroah-Hartman

    Wei Yongjun
     

22 Mar, 2018

1 commit

  • Various Intel SoCs (Cherry Trail, Broxton and others) have an internal USB
    role switch for swiching the OTG USB data lines between the xHCI host
    controller and the dwc3 gadget controller.

    Note on some Cherry Trail systems there is ACPI/AML code listening to
    edge interrupts on the id-pin (through an _AIE ACPI method) and switching
    the role between ROLE_HOST and ROLE_NONE based on the id-pin. Note it does
    not set the role to ROLE_DEVICE, because device-mode is usually not used
    under Windows.

    The presence of AML code which modifies the cfg0 reg (on some systems)
    means that our read/write/modify of cfg0 may race with the AML code
    doing the same to avoid this we take the global ACPI lock while doing
    the read/write/modify.

    Signed-off-by: Hans de Goede
    Reviewed-by: Andy Shevchenko
    Signed-off-by: Heikki Krogerus
    Signed-off-by: Greg Kroah-Hartman

    Hans de Goede