12 Jun, 2024

1 commit

  • [ Upstream commit 4b653e82ae18f2dc91c7132b54f5785c4d56bab4 ]

    kernel-doc validator is not happy:

    warning: Function parameter or struct member 'fotg' not described in 'fotg210_vbus'

    Add missing description.

    Fixes: 3e679bde529e ("usb: fotg210-udc: Implement VBUS session")
    Signed-off-by: Andy Shevchenko
    Reviewed-by: Linus Walleij
    Link: https://lore.kernel.org/r/20240510152641.2421298-1-andriy.shevchenko@linux.intel.com
    Signed-off-by: Greg Kroah-Hartman
    Signed-off-by: Sasha Levin

    Andy Shevchenko
     

01 Jan, 2024

1 commit

  • commit 7fbcd195e2b8cc952e4aeaeb50867b798040314c upstream.

    Here "temp" is the number of characters that we have written and "size"
    is the size of the buffer. The intent was clearly to say that if we have
    written to the end of the buffer then stop.

    However, for that to work the comparison should have been done on the
    original "size" value instead of the "size -= temp" value. Not only
    will that not trigger when we want to, but there is a small chance that
    it will trigger incorrectly before we want it to and we break from the
    loop slightly earlier than intended.

    This code was recently changed from using snprintf() to scnprintf(). With
    snprintf() we likely would have continued looping and passed a negative
    size parameter to snprintf(). This would have triggered an annoying
    WARN(). Now that we have converted to scnprintf() "size" will never
    drop below 1 and there is no real need for this test. We could change
    the condition to "if (temp
    Signed-off-by: Dan Carpenter
    Reviewed-by: Linus Walleij
    Reviewed-by: Lee Jones
    Link: https://lore.kernel.org/r/ZXmwIwHe35wGfgzu@suswa
    Signed-off-by: Greg Kroah-Hartman

    Dan Carpenter
     

28 May, 2023

1 commit

  • The .remove() callback for a platform driver returns an int which makes
    many driver authors wrongly assume it's possible to do error handling by
    returning an error code. However the value returned is ignored (apart from
    emitting a warning) and this typically results in resource leaks. To improve
    here there is a quest to make the remove callback return void. In the first
    step of this quest all drivers are converted to .remove_new() which already
    returns void. Eventually after all drivers are converted, .remove_new() is
    renamed to .remove().

    Trivially convert this driver from always returning zero in the remove
    callback to the void returning variant.

    Signed-off-by: Uwe Kleine-König
    Acked-by: Linus Walleij
    Link: https://lore.kernel.org/r/20230517230239.187727-24-u.kleine-koenig@pengutronix.de
    Signed-off-by: Greg Kroah-Hartman

    Uwe Kleine-König
     

06 Feb, 2023

2 commits


02 Feb, 2023

1 commit

  • Before the commit fc274c1e9973 ("USB: gadget: Add a new bus for gadgets")
    gadget driver.bus was unused. For whatever reason, many UDC drivers set
    this field explicitly to NULL in udc_start(). With the newly added gadget
    bus, doing this will crash the driver during the attach.

    The problem was first reported, fixed and tested with OMAP UDC and g_ether.
    Other drivers are changed based on code analysis only.

    Fixes: fc274c1e9973 ("USB: gadget: Add a new bus for gadgets")
    Cc: stable
    Signed-off-by: Aaro Koskinen
    Acked-by: Alan Stern
    Link: https://lore.kernel.org/r/20230201220125.GD2415@darkstar.musicnaut.iki.fi
    Signed-off-by: Greg Kroah-Hartman

    Aaro Koskinen
     

31 Jan, 2023

1 commit

  • devm_platform_get_and_ioremap_resource() never returns NULL pointer,
    it will return ERR_PTR() when it fails, so replace the check with
    IS_ERR().

    Fixes: baef5330d35b ("usb: fotg210: Acquire memory resource in core")
    Signed-off-by: Yang Yingliang
    Reviewed-by: Linus Walleij
    Link: https://lore.kernel.org/r/20230130120633.3342285-1-yangyingliang@huawei.com
    Signed-off-by: Greg Kroah-Hartman

    Yang Yingliang
     

25 Jan, 2023

9 commits

  • Correct a spelling mistake (reported by codespell).

    Signed-off-by: Randy Dunlap
    Reviewed-by: Linus Walleij
    Link: https://lore.kernel.org/r/20230124233511.23616-1-rdunlap@infradead.org
    Signed-off-by: Greg Kroah-Hartman

    Randy Dunlap
     
  • Convert platform_get_resource(), devm_ioremap_resource() to a single
    call to devm_platform_get_and_ioremap_resource(), as this is exactly
    what this function does.

    Signed-off-by: Andy Shevchenko
    Link: https://lore.kernel.org/r/20230120154437.22025-5-andriy.shevchenko@linux.intel.com
    Signed-off-by: Greg Kroah-Hartman

    Andy Shevchenko
     
  • Switch to use dev_err_probe() to simplify the error paths and
    unify message template.

    Signed-off-by: Andy Shevchenko
    Link: https://lore.kernel.org/r/20230120154437.22025-4-andriy.shevchenko@linux.intel.com
    Signed-off-by: Greg Kroah-Hartman

    Andy Shevchenko
     
  • A call to platform_get_irq() already prints an error on failure within
    its own implementation. So printing another error based on its return
    value in the caller is redundant and should be removed. The clean up
    also makes if condition block braces unnecessary. Remove that as well.

    Signed-off-by: Andy Shevchenko
    Link: https://lore.kernel.org/r/20230120154437.22025-3-andriy.shevchenko@linux.intel.com
    Signed-off-by: Greg Kroah-Hartman

    Andy Shevchenko
     
  • kstrtox() along with regmap API can return different error codes based on
    circumstances.

    Don't shadow them when returning to the caller.

    Signed-off-by: Andy Shevchenko
    Link: https://lore.kernel.org/r/20230120154437.22025-2-andriy.shevchenko@linux.intel.com
    Signed-off-by: Greg Kroah-Hartman

    Andy Shevchenko
     
  • Follow the advice of the Documentation/filesystems/sysfs.rst and show()
    should only use sysfs_emit() or sysfs_emit_at() when formatting the
    value to be returned to user space.

    Signed-off-by: Andy Shevchenko
    Link: https://lore.kernel.org/r/20230120154437.22025-1-andriy.shevchenko@linux.intel.com
    Signed-off-by: Greg Kroah-Hartman

    Andy Shevchenko
     
  • Reset the device explicitly to get into a known state and also set the chip
    enable bit. Additionally, mask interrupts which aren't handled.

    Signed-off-by: Fabian Vogt
    Signed-off-by: Linus Walleij
    Link: https://lore.kernel.org/r/20230123073508.2350402-4-linus.walleij@linaro.org
    Signed-off-by: Greg Kroah-Hartman

    Fabian Vogt
     
  • This is in preparation of support for devices where interrupts are acked
    differently.

    Signed-off-by: Fabian Vogt
    Signed-off-by: Linus Walleij
    Link: https://lore.kernel.org/r/20230123073508.2350402-3-linus.walleij@linaro.org
    Signed-off-by: Greg Kroah-Hartman

    Fabian Vogt
     
  • This is used when responding to GET_STATUS requests. Without this, it
    crashes on completion.

    Fixes: b84a8dee23fd ("usb: gadget: add Faraday fotg210_udc driver")
    Signed-off-by: Fabian Vogt
    Signed-off-by: Linus Walleij
    Link: https://lore.kernel.org/r/20230123073508.2350402-2-linus.walleij@linaro.org
    Signed-off-by: Greg Kroah-Hartman

    Fabian Vogt
     

19 Jan, 2023

6 commits

  • Implement VBUS session handling for FOTG210. This is
    mainly used by the UDC driver which needs to call down to
    the FOTG210 core and enable/disable VBUS, as this needs to be
    handled outside of the HCD and UDC drivers, by platform
    specific glue code.

    The Gemini has a special bit in a system register to turn
    VBUS on and off so we implement this in the FOTG210 core.

    Signed-off-by: Linus Walleij
    Link: https://lore.kernel.org/r/20230103-gemini-fotg210-usb-v2-7-100388af9810@linaro.org
    Signed-off-by: Greg Kroah-Hartman

    Linus Walleij
     
  • Follow the example set by other drivers to assign of_node
    and speed to the driver when binding, also print bound
    info akin to other UDC drivers.

    Signed-off-by: Linus Walleij
    Link: https://lore.kernel.org/r/20230103-gemini-fotg210-usb-v2-6-100388af9810@linaro.org
    Signed-off-by: Greg Kroah-Hartman

    Linus Walleij
     
  • Read the role register and check that we are in host/peripheral
    mode and issue warnings if we're not in the right role when
    probing respective driver.

    Signed-off-by: Linus Walleij
    Link: https://lore.kernel.org/r/20230103-gemini-fotg210-usb-v2-5-100388af9810@linaro.org
    Signed-off-by: Greg Kroah-Hartman

    Linus Walleij
     
  • Grab the optional silicon block clock, prepare and enable it in
    the core before proceeding to prepare the host or peripheral
    driver. This saves duplicate code and also uses the simple
    devm_clk_get_optional_enabled() to do everything we really
    want to do.

    Signed-off-by: Linus Walleij
    Link: https://lore.kernel.org/r/20230103-gemini-fotg210-usb-v2-4-100388af9810@linaro.org
    Signed-off-by: Greg Kroah-Hartman

    Linus Walleij
     
  • The subdrivers are obtaining and mapping the memory resource
    separately. Create a common state container for the shared
    resources and start populating this by acquiring the IO
    memory resource and remap it and pass this to the subdrivers
    for host and peripheral.

    Signed-off-by: Linus Walleij
    Link: https://lore.kernel.org/r/20230103-gemini-fotg210-usb-v2-3-100388af9810@linaro.org
    Signed-off-by: Greg Kroah-Hartman

    Linus Walleij
     
  • There are at least two variants of the FOTG: FOTG200 and
    FOTG210. Handle them in this driver and let's add
    more quirks as we go along.

    Signed-off-by: Linus Walleij
    Link: https://lore.kernel.org/r/20230103-gemini-fotg210-usb-v2-2-100388af9810@linaro.org
    Signed-off-by: Greg Kroah-Hartman

    Linus Walleij
     

06 Jan, 2023

1 commit

  • After commit 5f217ccd520f ("fotg210-udc: Support optional external PHY"),
    the error code is re-assigned to 0 in fotg210_udc_probe(), if allocate or
    map memory fails after the assignment, it can't return an error code. Set
    the error code to -ENOMEM to fix this problem.

    Fixes: 5f217ccd520f ("fotg210-udc: Support optional external PHY")
    Signed-off-by: Yang Yingliang
    Reviewed-by: Linus Walleij
    Link: https://lore.kernel.org/r/20221230065427.944586-1-yangyingliang@huawei.com
    Signed-off-by: Greg Kroah-Hartman

    Yang Yingliang
     

28 Dec, 2022

1 commit

  • The fotg210 module combines the HCD and OTG drivers, which then
    fails to build when only the USB gadget support is enabled
    in the kernel but host support is not:

    aarch64-linux-ld: drivers/usb/fotg210/fotg210-core.o: in function `fotg210_init':
    fotg210-core.c:(.init.text+0xc): undefined reference to `usb_disabled'

    Move the check for usb_disabled() after the check for the HCD module,
    and let the OTG driver still be probed in this configuration.

    A nicer approach might be to have the common portion built as a
    library module, with the two platform other files registering
    their own platform_driver instances separately.

    Fixes: ddacd6ef44ca ("usb: fotg210: Fix Kconfig for USB host modules")
    Reviewed-by: Linus Walleij
    Signed-off-by: Arnd Bergmann
    Link: https://lore.kernel.org/r/20221215165728.2062984-1-arnd@kernel.org
    Signed-off-by: Greg Kroah-Hartman

    Arnd Bergmann
     

08 Dec, 2022

1 commit

  • In fotg210_udc_probe(), if devm_clk_get() or clk_prepare_enable()
    fails, 'fotg210' will not be freed, which will lead to a memory leak.
    Fix it by moving kfree() to a proper location.

    In addition,we can use "return -ENOMEM" instead of "goto err"
    to simplify the code.

    Fixes: 718a38d092ec ("fotg210-udc: Handle PCLK")
    Reviewed-by: Andrzej Pietrasiewicz
    Reviewed-by: Linus Walleij
    Signed-off-by: Yi Yang
    Link: https://lore.kernel.org/r/20221202012126.246953-1-yiyang13@huawei.com
    Signed-off-by: Greg Kroah-Hartman

    Yi Yang
     

23 Nov, 2022

7 commits

  • There is no need to use an intermediate array for these memory allocations,
    so, axe it.

    While at it, turn a '== NULL' into a shorter '!' when testing memory
    allocation failure.

    Signed-off-by: Christophe JAILLET
    Reviewed-by: Linus Walleij
    Link: https://lore.kernel.org/r/deab9696fc4000499470e7ccbca7c36fca17bd4e.1668458274.git.christophe.jaillet@wanadoo.fr
    Signed-off-by: Greg Kroah-Hartman

    Christophe JAILLET
     
  • The platform_get_irq() is necessary to use to get dynamic
    IRQ resolution when instantiating the device from the
    device tree. IRQs are not passed as resources in that
    case.

    Signed-off-by: Linus Walleij
    Link: https://lore.kernel.org/r/20221114115201.302887-4-linus.walleij@linaro.org
    Signed-off-by: Greg Kroah-Hartman

    Linus Walleij
     
  • This adds optional handling of the peripheral clock PCLK.

    Signed-off-by: Linus Walleij
    Link: https://lore.kernel.org/r/20221114115201.302887-3-linus.walleij@linaro.org
    Signed-off-by: Greg Kroah-Hartman

    Linus Walleij
     
  • This adds support for an optional external PHY to the FOTG210
    UDC driver.

    Tested with the GPIO VBUS PHY driver on the Gemini SoC.

    Signed-off-by: Linus Walleij
    Link: https://lore.kernel.org/r/20221114115201.302887-2-linus.walleij@linaro.org
    Signed-off-by: Greg Kroah-Hartman

    Linus Walleij
     
  • Add a local struct device *dev pointer and use dev_err()
    etc to report status.

    Signed-off-by: Linus Walleij
    Link: https://lore.kernel.org/r/20221114115201.302887-1-linus.walleij@linaro.org
    Signed-off-by: Greg Kroah-Hartman

    Linus Walleij
     
  • The Faraday Technology FOTG210 USB2 Dual Role Controller is only present
    on Cortina Systems Gemini SoCs. Hence add a dependency on ARCH_GEMINI,
    to prevent asking the user about its drivers when configuring a kernel
    without Cortina Systems Gemini SoC support.

    Fixes: 1dd33a9f1b95ab59 ("usb: fotg210: Collect pieces of dual mode controller")
    Signed-off-by: Geert Uytterhoeven
    Reviewed-by: Linus Walleij
    Link: https://lore.kernel.org/r/a989b3b798ecaf3b45f35160e30e605636d66a77.1669044086.git.geert+renesas@glider.be
    Signed-off-by: Greg Kroah-Hartman

    Geert Uytterhoeven
     
  • The kernel robot reports a link failure when activating the
    FOTG210 host subdriver with =y on a system where the USB host
    core is a module (CONFIG_USB=m).

    This is a bit of special case, so mimic the Kconfig incantations
    from DWC3: let the subdrivers for host or peripheral depend
    on the host or gadget support being =y or the same as the
    FOTG210 core itself.

    This should ensure that either:

    - The host (CONFIG_USB) or gadget (CONFIG_GADGET) is compiled
    in and then the FOTG210 can be either module or compiled
    in.

    - The host or gadget is modular, and then the FOTG210 module
    must be a module too, or we cannot resolve the symbols
    at link time.

    Reported-by: kernel test robot
    Link: https://lore.kernel.org/linux-usb/202211112132.0BUPGKCd-lkp@intel.com/
    Cc: Arnd Bergmann
    Signed-off-by: Linus Walleij
    Link: https://lore.kernel.org/r/20221111144821.113665-1-linus.walleij@linaro.org
    Signed-off-by: Greg Kroah-Hartman

    Linus Walleij
     

11 Nov, 2022

2 commits

  • The code in the FOTG210 driver isn't entirely endianness-agnostic
    as reported by the kernel robot sparse testing. This came to
    the surface while moving the files around.

    The driver is only used on little-endian systems, so this causes
    no real-world regression, but it is nice to be strict and have
    some compile coverage also on big endian machines, so fix it
    up with the right LE accessors.

    Fixes: b84a8dee23fd ("usb: gadget: add Faraday fotg210_udc driver")
    Reported-by: kernel test robot
    Link: https://lore.kernel.org/linux-usb/202211110910.0dJ7nZCn-lkp@intel.com/
    Signed-off-by: Linus Walleij
    Link: https://lore.kernel.org/r/20221111090317.94228-1-linus.walleij@linaro.org
    Signed-off-by: Greg Kroah-Hartman

    Linus Walleij
     
  • The Cortina Systems Gemini has bolted on a PHY inside the
    silicon that can be handled by six bits in a MISC register in
    the system controller.

    If we are running on Gemini, look up a syscon regmap through
    a phandle and enable VBUS and optionally the Mini-B connector.

    If the device is flagged as "wakeup-source" using the standard
    DT bindings, we also enable this in the global controller for
    respective port.

    Signed-off-by: Linus Walleij
    Link: https://lore.kernel.org/r/20221109200554.1957185-1-linus.walleij@linaro.org
    Signed-off-by: Greg Kroah-Hartman

    Linus Walleij
     

09 Nov, 2022

3 commits

  • Check which mode the hardware is in, and selecte the peripheral
    driver if the hardware is in explicit peripheral mode, otherwise
    select host mode.

    This should solve the immediate problem that both subdrivers
    can get probed.

    Cc: Fabian Vogt
    Cc: Yuan-Hsin Chen
    Cc: Felipe Balbi
    Signed-off-by: Linus Walleij
    Link: https://lore.kernel.org/r/20221023144708.3596563-3-linus.walleij@linaro.org
    Signed-off-by: Greg Kroah-Hartman

    Linus Walleij
     
  • It is since ages perfectly possible to compile both of these
    modules into the same kernel, which makes no sense since it
    is one piece of hardware.

    Compile one module named "fotg210.ko" for both HCD and UDC
    drivers by collecting the init calls into a fotg210-core.c
    file and start to centralize things handling one and the same
    piece of hardware.

    Stub out the initcalls if one or the other part of the driver
    was not selected.

    Tested by compiling one or the other or both of the drivers
    into the kernel and as modules.

    Cc: Fabian Vogt
    Cc: Yuan-Hsin Chen
    Cc: Felipe Balbi
    Signed-off-by: Linus Walleij
    Link: https://lore.kernel.org/r/20221023144708.3596563-2-linus.walleij@linaro.org
    Signed-off-by: Greg Kroah-Hartman

    Linus Walleij
     
  • The Faraday FOTG210 is a dual-mode OTG USB controller that can
    act as host, peripheral or both. To be able to probe from one
    hardware description and to follow the pattern of other dual-
    mode controllers such as MUSB or MTU3 we need to collect the
    two, currently completely separate drivers in the same
    directory.

    After this, users need to select the main symbol USB_FOTG210
    and then each respective subdriver. We pave the road to
    compile both drivers into the same kernel and select the
    one we want to use at probe() time, and possibly add OTG
    support in the end.

    This patch doesn't do much more than create the new symbol
    and collect the drivers in one place. We also add a comment
    for the section of dual-mode controllers in the Kconfig
    file so people can see what these selections are about.

    Also add myself as maintainer as there has been little
    response on my patches to these drivers.

    Cc: Fabian Vogt
    Cc: Yuan-Hsin Chen
    Cc: Felipe Balbi
    Signed-off-by: Linus Walleij
    Link: https://lore.kernel.org/r/20221023144708.3596563-1-linus.walleij@linaro.org
    Signed-off-by: Greg Kroah-Hartman

    Linus Walleij