Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp14434410pxu; Tue, 5 Jan 2021 01:10:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJwIPae/9lrN+g/lnBcwZA6KLk+oTkHVrfX6s5KvNzhFbeCjmjUgio98iX1bQwtJ6ozN/qeW X-Received: by 2002:a50:e848:: with SMTP id k8mr74595972edn.77.1609837814353; Tue, 05 Jan 2021 01:10:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609837814; cv=none; d=google.com; s=arc-20160816; b=rrebe6KIrbu9wvuRHuVDQCe+tE1fy1ztyQiRDvkCEfCeYhBLQ281YwByLxMmiDmfe6 MhZts31VCcSigdBUciT/D04OEeN69+3mTnlcUKctYSbQQzrBFCuZqxLX84iLy+mc6jf2 8oFdwceIo4ULEoEBnyIcgBV6fpXqMnLxSWyNXiXyXcFd+37BlWKL4a4kvIb3jmrwvFKN r30S/21CG6U7udtlUFvo/CVy5p4gmzORZWKMGMF8FshSc+RbFkpoKRlRGG6R+WY7doUw bj8dY70n92R4avtvquYPJ+6/P0ODcJzNl42kq+BQ+cUW2XTVJf2DWSuFc22EJtdObXOW iLmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=2Z6aA2xM5KmOkEYCXhXC5WTtn79IXskuK3OjvQYi6L4=; b=tUJ1xTGbuwHfE4Mg5iLT/bXJsLgyRFzdEo1D0ETVDvaTEN2O4owu0KB7yEPvVC0k3V tohrdY52TQr8Is3tIgFWETGfsCgCbrWbRJDW/PtIFboxOaCiLkzJCqvGBwoI6MP+MboQ vAGRdNtVwb+hEU1dpP8QF13+Rg/9+FtY0VKRHAogJro/Ac0q7NYusK93z2sAKOFtSFJN Q5pJf840ttP5isLsYso9Eq/hI3d0DGmVlWUeLbHdtE8XEQi9YBNsmhPkSeserAqv4Wtk wUwklpCKCMzgNnCiTR5h2hKUrtCCqSRGJS1cb/5JKDymIp1Sze8uxEVWpCBU0h9FBplL fSNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@foss.st.com header.s=selector1 header.b=m5AqsyWP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foss.st.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gs12si29354942ejb.87.2021.01.05.01.09.51; Tue, 05 Jan 2021 01:10:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@foss.st.com header.s=selector1 header.b=m5AqsyWP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foss.st.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727808AbhAEJGo (ORCPT + 99 others); Tue, 5 Jan 2021 04:06:44 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:8850 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727670AbhAEJGa (ORCPT ); Tue, 5 Jan 2021 04:06:30 -0500 Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 10593vKQ012821; Tue, 5 Jan 2021 10:05:38 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=selector1; bh=2Z6aA2xM5KmOkEYCXhXC5WTtn79IXskuK3OjvQYi6L4=; b=m5AqsyWPSgn8+MS+QlKJG9tBG5h05Ok1tTEbW9F3jVmtqbIfdeMsIUdF7h/8kaOmrVHr 1HskGu//68mUb+vwEiSHxhSxOxonXlKdEVZ02/YnSE9efjzYkQb5ex2fTJjvkFrZbfkj +jR2t9PuZabgsQpYM/30x8h3IkJFvpkjDENgt2h+f7sc0/cEQWDmzRtYvIif1V3jxmGO KYvygDOm5j0fRXKBetav02WJ8m27w8iApUEUDFl1psHbkwQLMmTD/d4BFa/8+D6kAoNo AR6u5quq2Ks+C37BA90e8ZIsYvLyl7juMNgxhg2Xif2T9OJvnwcfG5K/XrgzjlxL7Bs0 kA== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 35teuuywxk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 05 Jan 2021 10:05:38 +0100 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id BF89410002A; Tue, 5 Jan 2021 10:05:37 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag2node3.st.com [10.75.127.6]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id ADCB822AA5B; Tue, 5 Jan 2021 10:05:37 +0100 (CET) Received: from localhost (10.75.127.47) by SFHDAG2NODE3.st.com (10.75.127.6) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Tue, 5 Jan 2021 10:05:37 +0100 From: Amelie Delaunay To: Kishon Vijay Abraham I , Vinod Koul , Rob Herring , Alexandre Torgue , Maxime Coquelin CC: , , , , Amelie Delaunay Subject: [PATCH v2 4/6] phy: stm32: ensure pll is disabled before phys creation Date: Tue, 5 Jan 2021 10:05:23 +0100 Message-ID: <20210105090525.23164-5-amelie.delaunay@foss.st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210105090525.23164-1-amelie.delaunay@foss.st.com> References: <20210105090525.23164-1-amelie.delaunay@foss.st.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.75.127.47] X-ClientProxiedBy: SFHDAG2NODE2.st.com (10.75.127.5) To SFHDAG2NODE3.st.com (10.75.127.6) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.343,18.0.737 definitions=2021-01-05_01:2021-01-05,2021-01-05 signatures=0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org To ensure a good balancing of regulators, force PLL disable either by reset or by clearing the PLLEN bit. If waiting the powerdown pulse delay isn't enough, return -EPROBE_DEFER instead of polling the PLLEN bit, which will be low at the next probe. Signed-off-by: Amelie Delaunay --- drivers/phy/st/phy-stm32-usbphyc.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/drivers/phy/st/phy-stm32-usbphyc.c b/drivers/phy/st/phy-stm32-usbphyc.c index 8ef97c8806ff..33367a325612 100644 --- a/drivers/phy/st/phy-stm32-usbphyc.c +++ b/drivers/phy/st/phy-stm32-usbphyc.c @@ -8,7 +8,7 @@ #include #include #include -#include +#include #include #include #include @@ -334,7 +334,7 @@ static int stm32_usbphyc_probe(struct platform_device *pdev) struct device *dev = &pdev->dev; struct device_node *child, *np = dev->of_node; struct phy_provider *phy_provider; - u32 version; + u32 pllen, version; int ret, port = 0; usbphyc = devm_kzalloc(dev, sizeof(*usbphyc), GFP_KERNEL); @@ -366,6 +366,19 @@ static int stm32_usbphyc_probe(struct platform_device *pdev) ret = PTR_ERR(usbphyc->rst); if (ret == -EPROBE_DEFER) goto clk_disable; + + stm32_usbphyc_clr_bits(usbphyc->base + STM32_USBPHYC_PLL, PLLEN); + } + + /* + * Wait for minimum width of powerdown pulse (ENABLE = Low): + * we have to ensure the PLL is disabled before phys initialization. + */ + if (readl_relaxed_poll_timeout(usbphyc->base + STM32_USBPHYC_PLL, + pllen, !(pllen & PLLEN), 5, 50)) { + dev_warn(usbphyc->dev, "PLL not reset\n"); + ret = -EPROBE_DEFER; + goto clk_disable; } usbphyc->switch_setup = -EINVAL; -- 2.17.1