[10/10] phy: qualcomm: phy-qcom-snps-eusb2: Add support for eUSB2 repeater
Commit Message
From: Neil Armstrong <neil.armstrong@linaro.org>
For USB 2.0 compliance, eUSB2 needs a repeater. The PHY needs to
initialize and reset it. So add repeater support
Co-developed-by: Abel Vesa <abel.vesa@linaro.org>
Signed-off-by: Abel Vesa <abel.vesa@linaro.org>
Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
---
drivers/phy/qualcomm/phy-qcom-snps-eusb2.c | 39 ++++++++++++++++++++++
1 file changed, 39 insertions(+)
Comments
Hi Abel,
I love your patch! Yet something to improve:
[auto build test ERROR on next-20221116]
[cannot apply to robh/for-next linus/master v6.1-rc5 v6.1-rc4 v6.1-rc3 v6.1-rc5]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Abel-Vesa/phy-qualcomm-Add-support-for-SM8550/20221116-200911
patch link: https://lore.kernel.org/r/20221116120157.2706810-11-abel.vesa%40linaro.org
patch subject: [PATCH 10/10] phy: qualcomm: phy-qcom-snps-eusb2: Add support for eUSB2 repeater
config: s390-allyesconfig
compiler: s390-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/05e41426432fca60ef9f4389b0275f0c5c44cc31
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Abel-Vesa/phy-qualcomm-Add-support-for-SM8550/20221116-200911
git checkout 05e41426432fca60ef9f4389b0275f0c5c44cc31
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=s390 SHELL=/bin/bash
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
All errors (new ones prefixed by >>):
>> drivers/phy/qualcomm/phy-qcom-snps-eusb2.c:19:10: fatal error: linux/usb/repeater.h: No such file or directory
19 | #include <linux/usb/repeater.h>
| ^~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
vim +19 drivers/phy/qualcomm/phy-qcom-snps-eusb2.c
> 19 #include <linux/usb/repeater.h>
20
21
@@ -16,6 +16,8 @@
#include <linux/regulator/consumer.h>
#include <linux/reset.h>
#include <linux/slab.h>
+#include <linux/usb/repeater.h>
+
#define USB_PHY_UTMI_CTRL0 (0x3c)
#define SLEEPM BIT(0)
@@ -135,6 +137,8 @@ struct qcom_snps_eusb2_hsphy {
struct regulator_bulk_data vregs[EUSB2_NUM_VREGS];
enum phy_mode mode;
+
+ struct usb_repeater *repeater;
};
static int qcom_snps_eusb2_hsphy_set_mode(struct phy *p, enum phy_mode mode, int submode)
@@ -231,6 +235,28 @@ static int qcom_eusb2_ref_clk_init(struct qcom_snps_eusb2_hsphy *phy)
return 0;
}
+static int qcom_snps_eusb2_hsphy_repeater_reset_and_init(struct qcom_snps_eusb2_hsphy *phy)
+{
+ struct device *dev = &phy->phy->dev;
+ int ret;
+
+ /* TOFIX set mode, default to device */
+
+ ret = usb_repeater_power_on(phy->repeater);
+ if (ret)
+ dev_err(dev, "repeater power on failed.\n");
+
+ ret = usb_repeater_reset(phy->repeater, true);
+ if (ret)
+ dev_err(dev, "repeater reset failed.\n");
+
+ ret = usb_repeater_init(phy->repeater);
+ if (ret)
+ dev_err(dev, "repeater init failed.\n");
+
+ return ret;
+}
+
static int qcom_snps_eusb2_hsphy_init(struct phy *p)
{
struct qcom_snps_eusb2_hsphy *phy = phy_get_drvdata(p);
@@ -240,6 +266,11 @@ static int qcom_snps_eusb2_hsphy_init(struct phy *p)
if (ret)
return ret;
+ /* Bring eUSB2 repeater out of reset and initialized before eUSB2 PHY */
+ ret = qcom_snps_eusb2_hsphy_repeater_reset_and_init(phy);
+ if (ret)
+ goto disable_vreg;
+
ret = clk_prepare_enable(phy->ref_clk);
if (ret) {
dev_err(&p->dev, "failed to enable ref clock, %d\n", ret);
@@ -347,6 +378,8 @@ static int qcom_snps_eusb2_hsphy_exit(struct phy *p)
regulator_bulk_disable(ARRAY_SIZE(phy->vregs), phy->vregs);
+ usb_repeater_power_off(phy->repeater);
+
return 0;
}
@@ -391,6 +424,12 @@ static int qcom_snps_eusb2_hsphy_probe(struct platform_device *pdev)
if (ret)
return dev_err_probe(dev, ret,
"failed to get regulator supplies\n");
+
+ phy->repeater = devm_usb_get_repeater_by_phandle(dev, "usb-repeater", 0);
+ if (IS_ERR(phy->repeater))
+ return dev_err_probe(dev, PTR_ERR(phy->repeater),
+ "failed to get repeater\n");
+
generic_phy = devm_phy_create(dev, NULL, &qcom_snps_eusb2_hsphy_ops);
if (IS_ERR(generic_phy)) {
dev_err(dev, "failed to create phy %d\n", ret);