Skip to content
Snippets Groups Projects
  1. Feb 10, 2025
  2. Apr 26, 2024
  3. Mar 14, 2024
    • Jonas Karlman's avatar
      phy: rockchip-inno-usb2: Limit changes made to regs · b055c895
      Jonas Karlman authored
      
      The USB2PHY regs already contain working default reset values for RK3328
      and RK35xx as evidenced by the fact that this driver never has changed a
      single value for these SoCs.
      
      Reduce to only configure utmi_suspend_n and utmi_sel bits similar to
      what is currently done on RK3399. Also add missing clkout_ctl for RK3588.
      
      When enabled utmi_suspend_n is changed to normal mode and utmi_sel to
      use otg/host controller utmi interface to phy. When disabled
      utmi_suspend_n is changed to suspend mode and utmi_sel to use GRF utmi
      interface to phy.
      
      Signed-off-by: default avatarJonas Karlman <jonas@kwiboo.se>
      b055c895
    • Jonas Karlman's avatar
      phy: rockchip-inno-usb2: Write to correct GRF · 803fbdfd
      Jonas Karlman authored
      
      On RK3399 the USB2PHY regs are located in the common GRF, remaining SoCs
      that is supported by this driver have the USB2PHY regs in a different
      GRF.
      
      When support for RK356x, RK3588 and RK3328 was added this driver was
      never updated to use correct GRF and have instead incorrectly written
      to wrong GRF for these SoCs.
      
      The default reset values for the USB2PHY have made USB mostly working
      even when wrong GRF was used, however, following have been observed:
      
        scanning bus usb@fd840000 for devices...
        ERROR:  USB-error: DEVICENOTRESPONDING: Device did not respond to token (IN) or did
        not provide a handshake (OUT) (5)
        ERROR: USB-error: DEVICENOTRESPONDING: Device did not respond to token (IN) or did
        not provide a handshake (OUT) (5)
        unable to get device descriptor (error=-1)
      
      Fix this by using a regmap from rockchip,usbgrf prop and fall back to
      getting a regmap for parent udevice instead of always getting the
      common GRF.
      
      Also protect against accidental clear of bit 0 in a reg with offset 0,
      only bind driver to enabled otg/host-ports and remove unused headers.
      
      Fixes: 3da15f0b ("phy: rockchip-inno-usb2: Add USB2 PHY for rk3568")
      Fixes: cdf9010f ("phy: rockchip-inno-usb2: add initial support for rk3588 PHY")
      Fixes: 9aa93d84 ("phy: rockchip-inno-usb2: Add USB2 PHY for RK3328")
      Signed-off-by: default avatarJonas Karlman <jonas@kwiboo.se>
      Reviewed-by: default avatarKever Yang <kever.yang@rock-chips.com>
      803fbdfd
  4. Jul 31, 2023
  5. Jun 29, 2023
    • Eugen Hristev's avatar
      phy: rockchip: inno-usb2: fix phy reg=0 case · 3cc53784
      Eugen Hristev authored
      
      The support for #address-cells=2 has a loophole: if the reg is actually 0,
      but the #address-cells is actually 1, like in such case below:
      
      syscon {
      	#address-cells = <1>;
      
      	phy {
      		reg = <0 0x10>;
      	};
      };
      
      then the second u32 of the 'reg' is the size, not the address.
      
      The code should check for the parent's #address-cells value, and not
      assume that if the first u32 is 0, then the #address-cells is 2, and the
      reg property is something like
      	reg = <0 0xff00 0x10>;
      
      Fixed this by looking for the #address-cells value and retrieving the
      reg address only if this is ==2.
      To avoid breaking anything I also kept the check `if reg==0` as some DT's
      may have a wrong #address-cells as parent and even if this commit is
      correct, it might break the existing wrong device-trees.
      
      Fixes: d538efb9 ("phy: rockchip: inno-usb2: Add support #address_cells = 2")
      Signed-off-by: default avatarEugen Hristev <eugen.hristev@collabora.com>
      Reviewed-by: default avatarKever Yang <kever.yang@rock-chips.com>
      3cc53784
  6. Jun 07, 2023
    • Xavier Drudis Ferran's avatar
      phy: rockchip-inno-usb2: Implement clock operations for usb2phy clock · 40359c94
      Xavier Drudis Ferran authored
      This clock doesn't seem needed but appears in a phandle list used by
      ehci-generic.c to bulk enable it. The phandle list comes from linux,
      where it is needed for suspend/resume to work [1].
      
      My tests give the same results with or without this patch, but Marek
      Vasut found it weird to declare an empty clk_ops [2].
      
      So I adapted the code from linux 6.1-rc8 so that it hopefully works
      if it ever has some user. For now, without real use, it seems to
      at least not give any errors when called.
      
      Link: [1] https://lkml.kernel.org/lkml/1731551.Q6cHK6n5ZM@phil/T/
            [2] https://patchwork.ozlabs.org/project/uboot/patch/Y5IWpjYLB4aXMy9o@localhost/
      
      
      
      Cc: Simon Glass <sjg@chromium.org>
      Cc: Philipp Tomsich <philipp.tomsich@vrull.eu>
      Cc: Kever Yang <kever.yang@rock-chips.com>
      Cc: Lukasz Majewski <lukma@denx.de>
      Cc: Sean Anderson <seanga2@gmail.com>
      Cc: Marek Vasut <marex@denx.de>
      Cc: Christoph Fritz <chf.fritz@googlemail.com>
      Cc: Jagan Teki <jagan@amarulasolutions.com>
      
      Signed-off-by: default avatarXavier Drudis Ferran <xdrudis@tinet.cat>
      Reviewed-by: default avatarKever Yang <kever.yang@rock-chips.com>
      Reviewed-by: default avatarJagan Teki <jagan@amarulasolutions.com>
      Tested-by: Jagan Teki <jagan@amarulasolutions.com> # rk3399, rk3328, rv1126
      40359c94
    • Xavier Drudis Ferran's avatar
      phy: rockchip-inno-usb2: Add usb2phy clock provider of 480MHz clock · e81512ac
      Xavier Drudis Ferran authored
      arch/arm/dts/rk3399.dtsi has a node
      
        usb_host0_ehci: usb@fe380000 {
             compatible = "generic-ehci";
      
      with clocks:
      
             clocks = <&cru HCLK_HOST0>, <&cru HCLK_HOST0_ARB>,
                      <&u2phy0>;
      
      The first 2 refer to nodes with class UCLASS_CLK, but &u2phy0
      has class UCLASS_PHY.
      
        u2phy0: usb2phy@e450 {
             compatible = "rockchip,rk3399-usb2phy";
      
      Since clk_get_bulk() only looks for devices with UCLASS_CLK,
      it fails with -ENODEV and then ehci_usb_probe() aborts.
      
      The consequence is peripherals connected to a USB 2 port (e.g. in a
      Rock Pi 4 the white port, nearer the edge) not being detected.
      They're detected if CONFIG_USB_OHCI_GENERIC is selected in Kconfig,
      because ohci_usb_probe() does not abort when one clk_get_by_index()
      fails, but then they work in USB 1 mode.
      
      rk3399.dtsi comes from linux and the  u2phy0 was added[1] to the clock
      list in:
      
          commit b5d1c57299734f5b54035ef2e61706b83041f20c
          Author: William wu <wulf@rock-chips.com>
          Date:   Wed Dec 21 18:41:05 2016 +0800
      
          arm64: dts: rockchip: add u2phy clock for ehci and ohci of rk3399
      
          We found that the suspend process was blocked when it run into
          ehci/ohci module due to clk-480m of usb2-phy was disabled.
          [...]
      
      Suspend concerns don't apply to U-Boot, and the problem with U-Boot
      failing to probe EHCI doesn't apply to linux, because in linux
      rockchip_usb2phy_clk480m_register makes u2phy0 a proper clock provider
      when called by rockchip_usb2phy_probe().
      
      So I can think of a few alternative solutions:
      
      1- Change ehci_usb_probe() to make it more similar to
         ohci_usb_probe(), and survive failure to get one clock. Looks a
         little harder, and I don't know whether it could break something if
         it ignored a clock that was important for something else than
         suspend.
      
      2- Change rk3399.dtsi effectively reverting the linux commit
         b5d1c57299734f5b54035ef2e61706b83041f20c. This dealigns the .dtsi
         from linux and seems fragile at the next synchronisation.
      
      3- Change the clock list in rk3399-u-boot.dtsi or somewhere else.
         This survives .dts* sync but may survive "too much" and miss some
         change from linux that we might want.
      
      4- Enable CONFIG_USB_OHCI_GENERIC and use the ports in USB 1 mode.
         This would need to be made for all boards using rk3399.  In a
         simple test reading one file from USB storage it gave 769.5 KiB/s
         instead of 20.5 MiB/s with solution 2.
      
      5- Trying to replicate linux and have usb2phy somehow provide a clk,
         or have a separate clock device for usb2phy in addition to the phy
         device.
      
      This patch tries to implement option 5 as Marek Vasut requested in
      December 5th.  Options 1 and 3 didn't get through [2][3].
      
      It just registers usb2phy as a clock driver (device_bind_driver()
      didn't work but device_bind_driver_to_node() did), without any
      specific operations, so that ehci-generic.c finds it and is happy. It
      worked in my tests on a Rock Pi 4 B+ (rk3399).
      
      Link: [1] https://lkml.kernel.org/lkml/1731551.Q6cHK6n5ZM@phil/T/
            [2] https://patchwork.ozlabs.org/project/uboot/patch/20220701185959.GC1700@begut/
            [3] https://patchwork.ozlabs.org/project/uboot/patch/Y44+ayJfUlI08ptM@localhost/
      
      
      
      Cc: Simon Glass <sjg@chromium.org>
      Cc: Philipp Tomsich <philipp.tomsich@vrull.eu>
      Cc: Kever Yang <kever.yang@rock-chips.com>
      Cc: Lukasz Majewski <lukma@denx.de>
      Cc: Sean Anderson <seanga2@gmail.com>
      Cc: Marek Vasut <marex@denx.de>
      Cc: Christoph Fritz <chf.fritz@googlemail.com>
      Cc: Jagan Teki <jagan@amarulasolutions.com>
      
      Signed-off-by: default avatarXavier Drudis Ferran <xdrudis@tinet.cat>
      Reviewed-by: default avatarKever Yang <kever.yang@rock-chips.com>
      Reviewed-by: default avatarJagan Teki <jagan@amarulasolutions.com>
      Tested-by: Jagan Teki <jagan@amarulasolutions.com> # rk3399, rk3328, rv1126
      e81512ac
  7. May 17, 2023
  8. Feb 28, 2023
  9. Dec 19, 2022
  10. Feb 02, 2021
    • Simon Glass's avatar
      common: Drop asm/global_data.h from common header · 401d1c4f
      Simon Glass authored
      
      Move this out of the common header and include it only where needed.  In
      a number of cases this requires adding "struct udevice;" to avoid adding
      another large header or in other cases replacing / adding missing header
      files that had been pulled in, very indirectly.   Finally, we have a few
      cases where we did not need to include <asm/global_data.h> at all, so
      remove that include.
      
      Signed-off-by: default avatarSimon Glass <sjg@chromium.org>
      Signed-off-by: default avatarTom Rini <trini@konsulko.com>
      401d1c4f
  11. Dec 13, 2020
    • Simon Glass's avatar
      dm: treewide: Rename auto_alloc_size members to be shorter · 41575d8e
      Simon Glass authored
      
      This construct is quite long-winded. In earlier days it made some sense
      since auto-allocation was a strange concept. But with driver model now
      used pretty universally, we can shorten this to 'auto'. This reduces
      verbosity and makes it easier to read.
      
      Coincidentally it also ensures that every declaration is on one line,
      thus making dtoc's job easier.
      
      Signed-off-by: default avatarSimon Glass <sjg@chromium.org>
      41575d8e
  12. May 29, 2020
Loading