ARM: dts: rockchip: rk3588-rock-5b-u-boot: add USB 2.0 host
PATCH v4 1/5 ARM: dts: rockchip: rk3588-rock-5b-u-boot: add USB 2.0 host
Add USB 2.0 host nodes and PHYs.
---
Changes in v4:
- removed u-boot,dm-spl on regulator which was useless
- moved usb nodes to rk3588s-u-boot-dtsi
Changes in v2,v3:
- none
arch/arm/dts/rk3588-rock-5b-u-boot.dtsi | 82 +++++++++++++++++++++++ arch/arm/dts/rk3588s-u-boot.dtsi | 86 +++++++++++++++++++++++++ 2 files changed, 168 insertions(+)
arch/arm/dts/rk3588-rock-5b-u-boot.dtsi +82 -0
@@ -4,6 +4,9 @@ */ #include "rk3588-u-boot.dtsi" +#include <dt-bindings/pinctrl/rockchip.h> +#include <dt-bindings/input/input.h> +#include <dt-bindings/gpio/gpio.h> / { aliases {
@@ -13,6 +16,18 @@ chosen { u-boot,spl-boot-order = &sdmmc; }; + + vcc5v0_host: vcc5v0-host-regulator { + compatible = "regulator-fixed"; + regulator-name = "vcc5v0_host"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + enable-active-high; + gpio = <&gpio4 RK_PB0 GPIO_ACTIVE_HIGH>; + pinctrl-names = "default"; + pinctrl-0 = <&vcc5v0_host_en>; + vin-supply = <&vcc5v0_sys>; + }; }; &sdmmc {
@@ -20,3 +35,70 @@ bootph-pre-ram; status = "okay"; }; + +&pinctrl { + usb { + vcc5v0_host_en: vcc5v0-host-en { + rockchip,pins = <4 RK_PB0 RK_FUNC_GPIO &pcfg_pull_none>; + }; + }; +}; + +&usb_host0_ehci { + companion = <&usb_host0_ohci>; + phys = <&u2phy2_host>; + phy-names = "usb2-phy"; + status = "okay"; +}; + +&usb_host0_ohci { + phys = <&u2phy2_host>; + phy-names = "usb2-phy"; + status = "okay"; +}; + +&usb2phy2_grf { + status = "okay"; +}; + +&u2phy2 { + resets = <&cru SRST_OTGPHY_U2_0>, <&cru SRST_P_USB2PHY_U2_0_GRF0>; + reset-names = "phy", "apb"; + clock-output-names = "usb480m_phy2"; + status = "okay"; +}; + +&u2phy2_host { + phy-supply = <&vcc5v0_host>; + status = "okay"; +}; + +&usb_host1_ehci { + companion = <&usb_host1_ohci>; + phys = <&u2phy3_host>; + phy-names = "usb2-phy"; + status = "okay"; +}; + +&usb_host1_ohci { + phys = <&u2phy3_host>; + phy-names = "usb2-phy"; + status = "okay"; +}; + +&usb2phy3_grf { + status = "okay"; +}; + +&u2phy3 { + resets = <&cru SRST_OTGPHY_U2_1>, <&cru SRST_P_USB2PHY_U2_1_GRF0>; + reset-names = "phy", "apb"; + clock-output-names = "usb480m_phy3"; + status = "okay"; +}; + +&u2phy3_host { + phy-supply = <&vcc5v0_host>; + status = "okay"; +}; +
arch/arm/dts/rk3588s-u-boot.dtsi +86 -0
98 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH v4 2/5 configs: rockchip: rock5b-rk3588: enable USB and regulators
Enable USB command, USB drivers, PHY and regulators, for USB host operations.
--- configs/rock5b-rk3588_defconfig | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
configs/rock5b-rk3588_defconfig +17 -0
@@ -41,7 +41,9 @@ CONFIG_SPL_STACK_R=y CONFIG_SPL_ATF=y CONFIG_CMD_GPT=y CONFIG_CMD_MMC=y +CONFIG_CMD_USB=y # CONFIG_CMD_SETEXPR is not set +CONFIG_CMD_REGULATOR=y # CONFIG_SPL_DOS_PARTITION is not set CONFIG_SPL_OF_CONTROL=y CONFIG_OF_LIVE=y
@@ -61,7 +63,9 @@ CONFIG_MMC_SDHCI_SDMA=y CONFIG_MMC_SDHCI_ROCKCHIP=y CONFIG_ETH_DESIGNWARE=y CONFIG_GMAC_ROCKCHIP=y +CONFIG_PHY_ROCKCHIP_INNO_USB2=y CONFIG_REGULATOR_PWM=y +CONFIG_DM_REGULATOR_FIXED=y CONFIG_PWM_ROCKCHIP=y CONFIG_SPL_RAM=y CONFIG_BAUDRATE=1500000
@@ -69,4 +73,17 @@ CONFIG_DEBUG_UART_SHIFT=2 CONFIG_DEBUG_UART_ANNOUNCE=y CONFIG_SYSRESET=y # CONFIG_BINMAN_FDT is not set +CONFIG_USB=y +CONFIG_USB_EHCI_HCD=y +CONFIG_USB_EHCI_GENERIC=y +CONFIG_USB_OHCI_HCD=y +CONFIG_USB_OHCI_GENERIC=y +CONFIG_USB_HOST_ETHER=y +CONFIG_USB_ETHER_ASIX=y +CONFIG_USB_ETHER_ASIX88179=y +CONFIG_USB_ETHER_LAN75XX=y +CONFIG_USB_ETHER_LAN78XX=y +CONFIG_USB_ETHER_MCS7830=y +CONFIG_USB_ETHER_RTL8152=y +CONFIG_USB_ETHER_SMSC95XX=y CONFIG_ERRNO_STR=y
Signature · 1 line
2.34.1
PATCH v4 3/5 phy: add support for phy-supply
In reply to Eugen HristevSome phys require a phy-supply property that is a phandle to a regulator that needs to be enabled for phy operations.
Implement basic supply lookup, enable and disabling, if DM_REGULATOR is available.
--- drivers/phy/phy-uclass.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
drivers/phy/phy-uclass.c +22 -0
@@ -12,6 +12,7 @@#include <dm/devres.h> #include <generic-phy.h> #include <linux/list.h> +#include <power/regulator.h> /** * struct phy_counts - Init and power-on counts of a single PHY port
@@ -29,12 +30,14 @@* without a matching generic_phy_exit() afterwards * @list: Handle for a linked list of these structures corresponding to * ports of the same PHY provider +* @supply: Handle to a phy-supply device */ struct phy_counts {unsigned long id;int power_on_count;int init_count;struct list_head list; +struct udevice *supply; };static inline struct phy_ops *phy_dev_ops (struct udevice *dev)
@@ -224,6 +227,12 @@ int generic_phy_init(struct phy *phy)return 0 ; } +#if CONFIG_IS_ENABLED (DM_REGULATOR ) +device_get_supply_regulator (phy->dev,"phy-supply" , &counts->supply); +if (IS_ERR (counts->supply)) +dev_dbg (phy->dev,"no phy-supply property found\n" ); +#endif + ret = ops->init (phy);if (ret) dev_err(phy->dev, "PHY: Failed to init %s: %d.\n",
@@ -272,6 +281,12 @@ int generic_phy_exit(struct phy *phy)return 0 ; } +#if CONFIG_IS_ENABLED (DM_REGULATOR ) +if (!IS_ERR_OR_NULL (counts->supply)) { + ret =regulator_set_enable (counts->supply, false); +dev_dbg (phy->dev,"supply disable status: %d\n" , ret); + } +#endif ret = ops->exit (phy);if (ret) dev_err(phy->dev, "PHY: Failed to exit %s: %d.\n",
@@ -300,6 +315,13 @@ int generic_phy_power_on(struct phy *phy)return 0 ; } +#if CONFIG_IS_ENABLED (DM_REGULATOR ) +if (!IS_ERR_OR_NULL (counts->supply)) { + ret =regulator_set_enable (counts->supply, true); +dev_dbg (phy->dev,"supply enable status: %d\n" , ret); + } +#endif + ret = ops->power_on (phy);if (ret) dev_err(phy->dev, "PHY: Failed to power on %s: %d.\n",
Signature · 1 line
2.34.1
Re: [PATCH v4 3/5] phy: add support for phy-supply
Hi Eugen,
Quoted 4 lines · Eugen Hristev
Some phys require a phy-supply property that is a phandle to a regulator that needs to be enabled for phy operations.
Implement basic supply lookup, enable and disabling, ifDM_REGULATORis available.
Thanks for looking at this, I have now had some time to test this and it turned out there was some minor issues.
First, the regulator is enabled in power_on and disabled in exit. It should probably be disabled after power_off ops has been called.
Second, the return value is ignored, this will change the meson code to continue with the call to the power_on ops, before it would have stopped and returned early with an error from the power_on ops.
Third, there seem to be a possibility that the counts in regulator core can end up uneven when any of init/exit/power_on/power_off ops is NULL.
I created "fixup! phy: add support for phy-supply" and "phy: Keep balance of counts when ops is missing" at [1] during my testing, please feel free to fixup/squash/rework any code :-)
Tested with USB (multiple usb start/reset/stop cycles) and PCIe (multiple pci enum) on RK3568 together with your "regulator: implement basic reference counter".
[1] https://github.com/Kwiboo/u-boot-rockchip/commits/rk3568-usb-v1
Regards,
Jonas
Quoted 73 lines
Signed-off-by Eugen Hristev <[email protected]>--- drivers/phy/phy-uclass.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)drivers/phy/phy-uclass.c +22
-0@@ -12,6 +12,7 @@#include <dm/devres.h> #include <generic-phy.h> #include <linux/list.h> +#include <power/regulator.h> /** * struct phy_counts - Init and power-on counts of a single PHY port @@ -29,12 +30,14 @@* without a matching generic_phy_exit() afterwards * @list: Handle for a linked list of these structures corresponding to * ports of the same PHY provider +* @supply: Handle to a phy-supply device */ struct phy_counts {unsigned long id;int power_on_count;int init_count;struct list_head list; +struct udevice *supply; };static inline struct phy_ops *phy_dev_ops (struct udevice *dev)@@ -224,6 +227,12 @@ int generic_phy_init(struct phy *phy)return 0 ; } +#if CONFIG_IS_ENABLED (DM_REGULATOR ) +device_get_supply_regulator (phy->dev,"phy-supply" , &counts->supply); +if (IS_ERR (counts->supply)) +dev_dbg (phy->dev,"no phy-supply property found\n" ); +#endif + ret = ops->init (phy);if (ret) dev_err(phy->dev, "PHY: Failed to init %s: %d.\n",@@ -272,6 +281,12 @@ int generic_phy_exit(struct phy *phy)return 0 ; } +#if CONFIG_IS_ENABLED (DM_REGULATOR ) +if (!IS_ERR_OR_NULL (counts->supply)) { + ret =regulator_set_enable (counts->supply, false); +dev_dbg (phy->dev,"supply disable status: %d\n" , ret); + } +#endif ret = ops->exit (phy);if (ret) dev_err(phy->dev, "PHY: Failed to exit %s: %d.\n",@@ -300,6 +315,13 @@ int generic_phy_power_on(struct phy *phy)return 0 ; } +#if CONFIG_IS_ENABLED (DM_REGULATOR ) +if (!IS_ERR_OR_NULL (counts->supply)) { + ret =regulator_set_enable (counts->supply, true); +dev_dbg (phy->dev,"supply enable status: %d\n" , ret); + } +#endif + ret = ops->power_on (phy);if (ret) dev_err(phy->dev, "PHY: Failed to power on %s: %d.\n",
Re: [PATCH v4 3/5] phy: add support for phy-supply
Quoted 11 lines · Jonas Karlman
Hi Eugen,
Quoted 4 lines · Eugen Hristev
Some phys require a phy-supply property that is a phandle to a regulator that needs to be enabled for phy operations.
Implement basic supply lookup, enable and disabling, ifDM_REGULATORis available.Thanks for looking at this, I have now had some time to test this and it turned out there was some minor issues.
Quoted 6 lines
First, the regulator is enabled in
power_onand disabled in exit. It should probably be disabled afterpower_offops has been called.Second, the return value is ignored, this will change the meson code to continue with the call to the
power_onops, before it would have stopped and returned early with an error from thepower_onops.
While indeed there is a change, I do not want to stop when there is an error with phy supply.
First, the enabling of the regulator could return EALREADY on enable, or EBUSY on disable, which is not really an error, so this has to be treated accordingly
Second, all this time the code has lived without phy supply except for some few drivers, so, if now we stop and break on phy supply not working, we may break a lot of other boards which simply ignored phy supply until today. Because of that, my whole patch has treated phy supply as basically an optional property which is requested, but not mandatory to continue without.
Quoted 7 lines
Third, there seem to be a possibility that the counts in regulator core can end up uneven when any of
init/exit/power_on/power_offops is NULL. > I created "fixup! phy: add support for phy-supply" and "phy: Keep balance of counts when ops is missing" at [1] during my testing, please feel free to fixup/squash/rework any code :-)
do you want to add this second patch to my series ?
and squash the first into my patches with you as co-author ? but I will change a bit what you wrote, namely handling EBUSY and EALREADY e.g.
Quoted 83 lines
Tested with USB (multiple usb start/reset/stop cycles) and PCIe (multiple pci enum) on RK3568 together with your "regulator: implement basic reference counter".
[1] https://github.com/Kwiboo/u-boot-rockchip/commits/rk3568-usb-v1
Regards,
JonasQuoted 73 lines
Signed-off-by Eugen Hristev <[email protected]>--- drivers/phy/phy-uclass.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)drivers/phy/phy-uclass.c +22
-0@@ -12,6 +12,7 @@#include <dm/devres.h> #include <generic-phy.h> #include <linux/list.h> +#include <power/regulator.h> /** * struct phy_counts - Init and power-on counts of a single PHY port @@ -29,12 +30,14 @@* without a matching generic_phy_exit() afterwards * @list: Handle for a linked list of these structures corresponding to * ports of the same PHY provider +* @supply: Handle to a phy-supply device */ struct phy_counts {unsigned long id;int power_on_count;int init_count;struct list_head list; +struct udevice *supply; };static inline struct phy_ops *phy_dev_ops (struct udevice *dev)@@ -224,6 +227,12 @@ int generic_phy_init(struct phy *phy)return 0 ; } +#if CONFIG_IS_ENABLED (DM_REGULATOR ) +device_get_supply_regulator (phy->dev,"phy-supply" , &counts->supply); +if (IS_ERR (counts->supply)) +dev_dbg (phy->dev,"no phy-supply property found\n" ); +#endif + ret = ops->init (phy);if (ret) dev_err(phy->dev, "PHY: Failed to init %s: %d.\n",@@ -272,6 +281,12 @@ int generic_phy_exit(struct phy *phy)return 0 ; } +#if CONFIG_IS_ENABLED (DM_REGULATOR ) +if (!IS_ERR_OR_NULL (counts->supply)) { + ret =regulator_set_enable (counts->supply, false); +dev_dbg (phy->dev,"supply disable status: %d\n" , ret); + } +#endif ret = ops->exit (phy);if (ret) dev_err(phy->dev, "PHY: Failed to exit %s: %d.\n",@@ -300,6 +315,13 @@ int generic_phy_power_on(struct phy *phy)return 0 ; } +#if CONFIG_IS_ENABLED (DM_REGULATOR ) +if (!IS_ERR_OR_NULL (counts->supply)) { + ret =regulator_set_enable (counts->supply, true); +dev_dbg (phy->dev,"supply enable status: %d\n" , ret); + } +#endif + ret = ops->power_on (phy);if (ret) dev_err(phy->dev, "PHY: Failed to power on %s: %d.\n",
Re: [PATCH v4 3/5] phy: add support for phy-supply
Hi Eugen,
Quoted 19 lines · Eugen Hristev
Quoted 11 lines · Jonas Karlman
Hi Eugen,
Quoted 4 lines · Eugen Hristev
Some phys require a phy-supply property that is a phandle to a regulator that needs to be enabled for phy operations.
Implement basic supply lookup, enable and disabling, ifDM_REGULATORis available.Thanks for looking at this, I have now had some time to test this and it turned out there was some minor issues.
Quoted 6 lines
First, the regulator is enabled in
power_onand disabled in exit. It should probably be disabled afterpower_offops has been called.Second, the return value is ignored, this will change the meson code to continue with the call to the
power_onops, before it would have stopped and returned early with an error from thepower_onops.
Quoted 11 lines
While indeed there is a change, I do not want to stop when there is an error with phy supply.
First, the enabling of the regulator could return EALREADY on enable, or EBUSY on disable, which is not really an error, so this has to be treated accordingly
Second, all this time the code has lived without phy supply except for some few drivers, so, if now we stop and break on phy supply not working, we may break a lot of other boards which simply ignored phy supply until today.
Because of that, my whole patch has treated phy supply as basically an optional property which is requested, but not mandatory to continue without.
Understandable, and I was expecting that regulator_set_enable_if_allowed handled that, it return -ENOSYS when it is unsupported or 0 on anything that could be treated like a success and only an error if there is an error while changing the regulator.
Looking at the phy-supply defined in device trees in u-boot it is mostly used for ethernet or usb on imx, meson, rockchip and sunxi. So hopefully a relaxed error handling should not affect that much and could help keeping the regulator enable_count balanced.
Quoted 8 lines
Quoted 8 lines
Third, there seem to be a possibility that the counts in regulator core can end up uneven when any of
init/exit/power_on/power_offops is NULL. > I created "fixup! phy: add support for phy-supply" and "phy: Keep balance of counts when ops is missing" at [1] during my testing, please feel free to fixup/squash/rework any code :-)
Quoted 4 lines
do you want to add this second patch to my series ?
and squash the first into my patches with you as co-author ? but I will change a bit what you wrote, namely handling EBUSY and EALREADY e.g.
Please pick/squash as you see best fit, no need for co-author :-)
The counts balance change was inspired by linux drivers/phy/phy-core.c
Regards,
Jonas
Quoted 85 lines
Quoted 84 lines
Tested with USB (multiple usb start/reset/stop cycles) and PCIe (multiple pci enum) on RK3568 together with your "regulator: implement basic reference counter".
[1] https://github.com/Kwiboo/u-boot-rockchip/commits/rk3568-usb-v1
Regards,
JonasQuoted 73 lines
Signed-off-by Eugen Hristev <[email protected]>--- drivers/phy/phy-uclass.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)drivers/phy/phy-uclass.c +22
-0@@ -12,6 +12,7 @@#include <dm/devres.h> #include <generic-phy.h> #include <linux/list.h> +#include <power/regulator.h> /** * struct phy_counts - Init and power-on counts of a single PHY port @@ -29,12 +30,14 @@* without a matching generic_phy_exit() afterwards * @list: Handle for a linked list of these structures corresponding to * ports of the same PHY provider +* @supply: Handle to a phy-supply device */ struct phy_counts {unsigned long id;int power_on_count;int init_count;struct list_head list; +struct udevice *supply; };static inline struct phy_ops *phy_dev_ops (struct udevice *dev)@@ -224,6 +227,12 @@ int generic_phy_init(struct phy *phy)return 0 ; } +#if CONFIG_IS_ENABLED (DM_REGULATOR ) +device_get_supply_regulator (phy->dev,"phy-supply" , &counts->supply); +if (IS_ERR (counts->supply)) +dev_dbg (phy->dev,"no phy-supply property found\n" ); +#endif + ret = ops->init (phy);if (ret) dev_err(phy->dev, "PHY: Failed to init %s: %d.\n",@@ -272,6 +281,12 @@ int generic_phy_exit(struct phy *phy)return 0 ; } +#if CONFIG_IS_ENABLED (DM_REGULATOR ) +if (!IS_ERR_OR_NULL (counts->supply)) { + ret =regulator_set_enable (counts->supply, false); +dev_dbg (phy->dev,"supply disable status: %d\n" , ret); + } +#endif ret = ops->exit (phy);if (ret) dev_err(phy->dev, "PHY: Failed to exit %s: %d.\n",@@ -300,6 +315,13 @@ int generic_phy_power_on(struct phy *phy)return 0 ; } +#if CONFIG_IS_ENABLED (DM_REGULATOR ) +if (!IS_ERR_OR_NULL (counts->supply)) { + ret =regulator_set_enable (counts->supply, true); +dev_dbg (phy->dev,"supply enable status: %d\n" , ret); + } +#endif + ret = ops->power_on (phy);if (ret) dev_err(phy->dev, "PHY: Failed to power on %s: %d.\n",
PATCH v4 4/5 phy: remove phy-supply related code
In reply to Eugen Hristevphy-supply is now handled at uclass level. Remove it from the drivers that implement it at the driver level.
--- drivers/phy/meson-g12a-usb2.c | 48 ----------------------------------- drivers/phy/meson-gxbb-usb2.c | 38 --------------------------- drivers/phy/meson-gxl-usb2.c | 30 ---------------------- 3 files changed, 116 deletions(-)
drivers/phy/meson-g12a-usb2.c +0 -48
@@ -54,50 +54,12 @@struct phy_meson_g12a_usb2_priv {struct regmap *regmap; -#if CONFIG_IS_ENABLED (DM_REGULATOR ) -struct udevice *phy_supply; -#endif #if CONFIG_IS_ENABLED (CLK )struct clk clk;#endif struct reset_ctl reset; }; - -static int phy_meson_g12a_usb2_power_on (struct phy *phy) -{ -#if CONFIG_IS_ENABLED (DM_REGULATOR ) -struct udevice *dev = phy->dev; -struct phy_meson_g12a_usb2_priv *priv =dev_get_priv (dev); - -if (priv->phy_supply) { -int ret =regulator_set_enable (priv->phy_supply, true); -if (ret) -return ret; - } -#endif - -return 0 ; -} - -static int phy_meson_g12a_usb2_power_off (struct phy *phy) -{ -#if CONFIG_IS_ENABLED (DM_REGULATOR ) -struct udevice *dev = phy->dev; -struct phy_meson_g12a_usb2_priv *priv =dev_get_priv (dev); - -if (priv->phy_supply) { -int ret =regulator_set_enable (priv->phy_supply, false); -if (ret) { -pr_err ("Error disabling PHY supply\n" ); -return ret; - } - } -#endif - -return 0 ; -} -static int phy_meson_g12a_usb2_init (struct phy *phy) {struct udevice *dev = phy->dev;
@@ -155,8 +117,6 @@ static int phy_meson_g12a_usb2_exit(struct phy *phy)struct phy_ops meson_g12a_usb2_phy_ops = { .init = phy_meson_g12a_usb2_init, .exit = phy_meson_g12a_usb2_exit, - .power_on = phy_meson_g12a_usb2_power_on, - .power_off = phy_meson_g12a_usb2_power_off, };int meson_g12a_usb2_phy_probe (struct udevice *dev)
@@ -193,14 +153,6 @@ int meson_g12a_usb2_phy_probe(struct udevice *dev) }#endif -#if CONFIG_IS_ENABLED (DM_REGULATOR ) - ret =device_get_supply_regulator (dev,"phy-supply" , &priv->phy_supply); -if (ret && ret != -ENOENT ) { -pr_err ("Failed to get PHY regulator\n" ); -return ret; - } -#endif -return 0 ; }
drivers/phy/meson-gxbb-usb2.c +0 -38
@@ -12,7 +12,6 @@#include <clk.h> #include <dm.h> #include <generic-phy.h> -#include <power/regulator.h> #include <regmap.h> #include <reset.h> #include <linux/bitops.h>
@@ -81,9 +80,6 @@struct phy_meson_gxbb_usb2_priv {struct regmap *regmap;struct reset_ctl_bulk resets; -#if CONFIG_IS_ENABLED (DM_REGULATOR ) -struct udevice *phy_supply; -#endif };static int phy_meson_gxbb_usb2_power_on (struct phy *phy)
@@ -92,15 +88,6 @@ static int phy_meson_gxbb_usb2_power_on(struct phy *phy)struct phy_meson_gxbb_usb2_priv *priv =dev_get_priv (dev);uint val; -#if CONFIG_IS_ENABLED (DM_REGULATOR ) -if (priv->phy_supply) { -int ret =regulator_set_enable (priv->phy_supply, true); - -if (ret) -return ret; - } -#endif -regmap_update_bits (priv->regmap,REG_CONFIG , REG_CONFIG_CLK_32k_ALTSEL, REG_CONFIG_CLK_32k_ALTSEL);
@@ -140,26 +127,8 @@ static int phy_meson_gxbb_usb2_power_on(struct phy *phy)return 0 ; } -static int phy_meson_gxbb_usb2_power_off (struct phy *phy) -{ -#if CONFIG_IS_ENABLED (DM_REGULATOR ) -struct udevice *dev = phy->dev; -struct phy_meson_gxbb_usb2_priv *priv =dev_get_priv (dev); - -if (priv->phy_supply) { -int ret =regulator_set_enable (priv->phy_supply, false); - -if (ret) -return ret; - } -#endif - -return 0 ; -} -static struct phy_ops meson_gxbb_usb2_phy_ops = { .power_on = phy_meson_gxbb_usb2_power_on, - .power_off = phy_meson_gxbb_usb2_power_off, };static int meson_gxbb_usb2_phy_probe (struct udevice *dev)
@@ -192,13 +161,6 @@ static int meson_gxbb_usb2_phy_probe(struct udevice *dev)return ret; } -#if CONFIG_IS_ENABLED (DM_REGULATOR ) - ret =device_get_supply_regulator (dev,"phy-supply" , &priv->phy_supply); -if (ret && ret != -ENOENT ) { -pr_err ("Failed to get PHY regulator\n" ); -return ret; - } -#endif ret =reset_get_bulk (dev, &priv->resets);if (!ret) { ret =reset_deassert_bulk (&priv->resets);
drivers/phy/meson-gxl-usb2.c +0 -30
@@ -16,7 +16,6 @@#include <generic-phy.h> #include <regmap.h> #include <linux/delay.h> -#include <power/regulator.h> #include <clk.h> #include <linux/usb/otg.h>
@@ -101,9 +100,6 @@struct phy_meson_gxl_usb2_priv {struct regmap *regmap; -#if CONFIG_IS_ENABLED (DM_REGULATOR ) -struct udevice *phy_supply; -#endif #if CONFIG_IS_ENABLED (CLK )struct clk clk;#endif
@@ -167,14 +163,6 @@ static int phy_meson_gxl_usb2_power_on(struct phy *phy)phy_meson_gxl_usb2_set_mode (phy,USB_DR_MODE_HOST ); -#if CONFIG_IS_ENABLED (DM_REGULATOR ) -if (priv->phy_supply) { -int ret =regulator_set_enable (priv->phy_supply, true); -if (ret) -return ret; - } -#endif -return 0 ; }
@@ -189,16 +177,6 @@ static int phy_meson_gxl_usb2_power_off(struct phy *phy) val |=U2P_R0_POWER_ON_RESET ;regmap_write (priv->regmap,U2P_R0 , val); -#if CONFIG_IS_ENABLED (DM_REGULATOR ) -if (priv->phy_supply) { -int ret =regulator_set_enable (priv->phy_supply, false); -if (ret) { -pr_err ("Error disabling PHY supply\n" ); -return ret; - } - } -#endif -return 0 ; }
@@ -229,14 +207,6 @@ int meson_gxl_usb2_phy_probe(struct udevice *dev) }#endif -#if CONFIG_IS_ENABLED (DM_REGULATOR ) - ret =device_get_supply_regulator (dev,"phy-supply" , &priv->phy_supply); -if (ret && ret != -ENOENT ) { -pr_err ("Failed to get PHY regulator\n" ); -return ret; - } -#endif -return 0 ; }
Signature · 1 line
2.34.1
PATCH v4 5/5 phy: rockchip-inno-usb2: add initial support for rk3588 PHY
In reply to Eugen HristevAdd initial support for the rk3588 PHY variant.
The lookup for the host-port reg inside the struct now does a do {} while() instead of a while() {} in order to allow a first check for reg == 0.
---
Changes in v4:
- moved all vbus/phy-supply to the core
Changes in v3:
- add handling of -EBUSY and -EALREADY for regulator return
Changes in v2:
- add handling of -EACCES
drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 60 ++++++++++++++++++- 1 file changed, 58 insertions(+), 2 deletions(-)
drivers/phy/rockchip/phy-rockchip-inno-usb2.c +58 -2
@@ -201,14 +201,14 @@ static int rockchip_usb2phy_probe(struct udevice *dev)/* find out a proper config which can be matched with dt. */ index =0 ; -while (phy_cfgs[index].reg) { +do {if (phy_cfgs[index].reg == reg) { priv->phy_cfg = &phy_cfgs[index];break ; } ++index; - } + }while (phy_cfgs[index].reg);if (!priv->phy_cfg) {dev_err (dev,"failed find proper phy-cfg\n" );
@@ -348,6 +348,58 @@ static const struct rockchip_usb2phy_cfg rk3568_phy_cfgs[] = { {/* sentinel */ } }; +static const struct rockchip_usb2phy_cfg rk3588_phy_cfgs[] = { + { + .reg =0x0000 , + .port_cfgs = { + [USB2PHY_PORT_OTG ] = { + .phy_sus = {0x000c ,11 ,11 ,0 ,1 }, + .ls_det_en = {0x0080 ,0 ,0 ,0 ,1 }, + .ls_det_st = {0x0084 ,0 ,0 ,0 ,1 }, + .ls_det_clr = {0x0088 ,0 ,0 ,0 ,1 }, + .utmi_ls = {0x00c0 ,10 ,9 ,0 ,1 }, + } + }, + }, + { + .reg =0x4000 , + .port_cfgs = { + [USB2PHY_PORT_OTG ] = { + .phy_sus = {0x000c ,11 ,11 ,0 ,0 }, + .ls_det_en = {0x0080 ,0 ,0 ,0 ,1 }, + .ls_det_st = {0x0084 ,0 ,0 ,0 ,1 }, + .ls_det_clr = {0x0088 ,0 ,0 ,0 ,1 }, + .utmi_ls = {0x00c0 ,10 ,9 ,0 ,1 }, + } + }, + }, + { + .reg =0x8000 , + .port_cfgs = { + [USB2PHY_PORT_HOST ] = { + .phy_sus = {0x0008 ,2 ,2 ,0 ,1 }, + .ls_det_en = {0x0080 ,0 ,0 ,0 ,1 }, + .ls_det_st = {0x0084 ,0 ,0 ,0 ,1 }, + .ls_det_clr = {0x0088 ,0 ,0 ,0 ,1 }, + .utmi_ls = {0x00c0 ,10 ,9 ,0 ,1 }, + } + }, + }, + { + .reg =0xc000 , + .port_cfgs = { + [USB2PHY_PORT_HOST ] = { + .phy_sus = {0x0008 ,2 ,2 ,0 ,1 }, + .ls_det_en = {0x0080 ,0 ,0 ,0 ,1 }, + .ls_det_st = {0x0084 ,0 ,0 ,0 ,1 }, + .ls_det_clr = {0x0088 ,0 ,0 ,0 ,1 }, + .utmi_ls = {0x00c0 ,10 ,9 ,0 ,1 }, + } + }, + }, + {/* sentinel */ } +}; +static const struct udevice_id rockchip_usb2phy_ids[] = { { .compatible ="rockchip,rk3399-usb2phy" ,
@@ -357,6 +409,10 @@ static const struct udevice_id rockchip_usb2phy_ids[] = { .compatible = "rockchip,rk3568-usb2phy", .data = (ulong)&rk3568_phy_cfgs, }, + { + .compatible = "rockchip,rk3588-usb2phy", + .data = (ulong)&rk3588_phy_cfgs, + }, {/* sentinel */ } };
Signature · 1 line
2.34.1