From patchwork Wed Nov 16 12:01:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abel Vesa X-Patchwork-Id: 625175 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 43A65C43217 for ; Wed, 16 Nov 2022 12:08:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237254AbiKPMIe (ORCPT ); Wed, 16 Nov 2022 07:08:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54160 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232431AbiKPMHn (ORCPT ); Wed, 16 Nov 2022 07:07:43 -0500 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 841CA17591 for ; Wed, 16 Nov 2022 04:02:14 -0800 (PST) Received: by mail-wm1-x332.google.com with SMTP id fn7-20020a05600c688700b003b4fb113b86so1320057wmb.0 for ; Wed, 16 Nov 2022 04:02:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=fUtf3C2ksBbvfzIaOIaKX58DNV9jeGzhpCM3Ny/zr3U=; b=e5n4nBklX5Iiqsx6kpUPhyZxhS00j53WfDrZBv2hrpk2TmMXA9iRGk5CDY8OV4Dcrg 9l1ErAfJqCw4CO3OTt+T7CTu+wjKIRWpfnLq0WnaN8vm5OerwTjir0+Hc4FNMjZvh5oS hqIiQhzOGFUU9CqqncfVUbMJuXA12xf3aKcbRxufTlOmFgN38mqoGbqkQyiCplZoRt32 EALfIC3ONCa4HUEm8B0BiY4OXBCesDymm3vJ0RaxKmQr1YduJHXgPgvUg8hzPm+xrYQq ofeQ6VZJJXrHD8ey36lF1gKUuRMGqbHOZAHNAYeiV2S/QSAayJMymSUB70d1fcogYDUb 7Jvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fUtf3C2ksBbvfzIaOIaKX58DNV9jeGzhpCM3Ny/zr3U=; b=1gPJfIKGIZg9oFRa5SVFuw2QQ7qNuW7i2tQxjyxAnkZvaF8ilpM6x0k+tW5TgrfKWD HVS5+BYcTUVVfUfk28MYz5/IxByDufnSHZQeVskq9stptaCI7RoOHO2cBfp808ayzMmq DA53M0TPoL4JIsEsCx7TxzclcnoTsm0iPKXhLqIREqfCTE4IoZTmvywnwmfIOesn7yC1 jFpfJmbY9JenIGHdpeF8cpvBZwZbGVFYok3VgvirFBk4xwOQuZAYnuRWfcmo4XqB30LT xZrmFOwEanLzT2bsJiR3Brph7ktzRnZ9Rgv8KptjBWXk33F5nuPKif3gnmv/VIFbqxFC w7VA== X-Gm-Message-State: ANoB5pn5UjyDxqPyjGgQEsK68G7Xsax/Jq6dVnaqEW0wtGf5/UEn19dI oqxglrYaI8z9GVv2s9Sz3T7fmw== X-Google-Smtp-Source: AA0mqf4meWqOJc601nNZH4xS8Bsb3vR2BsVZXEudb+jRGR88kf8EdA1OeUJzvCsCNOBn9lD3OBTv/w== X-Received: by 2002:a05:600c:2e51:b0:3cf:6e9b:21f1 with SMTP id q17-20020a05600c2e5100b003cf6e9b21f1mr1893472wmf.90.1668600133083; Wed, 16 Nov 2022 04:02:13 -0800 (PST) Received: from localhost.localdomain ([94.52.112.99]) by smtp.gmail.com with ESMTPSA id r8-20020a056000014800b002206203ed3dsm15120109wrx.29.2022.11.16.04.02.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Nov 2022 04:02:12 -0800 (PST) From: Abel Vesa To: Andy Gross , Bjorn Andersson , Konrad Dybcio , "vkoul@kernel.org" , Kishon Vijay Abraham I , Rob Herring , Krzysztof Kozlowski Cc: Linux Kernel Mailing List , devicetree@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-phy@lists.infradead.org, Neil Armstrong Subject: [PATCH 10/10] phy: qualcomm: phy-qcom-snps-eusb2: Add support for eUSB2 repeater Date: Wed, 16 Nov 2022 14:01:57 +0200 Message-Id: <20221116120157.2706810-11-abel.vesa@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221116120157.2706810-1-abel.vesa@linaro.org> References: <20221116120157.2706810-1-abel.vesa@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: Neil Armstrong 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 Signed-off-by: Abel Vesa Signed-off-by: Neil Armstrong --- drivers/phy/qualcomm/phy-qcom-snps-eusb2.c | 39 ++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/drivers/phy/qualcomm/phy-qcom-snps-eusb2.c b/drivers/phy/qualcomm/phy-qcom-snps-eusb2.c index 1bb42ec14703..921502ffc55b 100644 --- a/drivers/phy/qualcomm/phy-qcom-snps-eusb2.c +++ b/drivers/phy/qualcomm/phy-qcom-snps-eusb2.c @@ -16,6 +16,8 @@ #include #include #include +#include + #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);