Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp995030pxu; Mon, 23 Nov 2020 09:04:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJyL9QWVSdXleHbViEY7Z7dKudix9EXc/H1ejAZjeId3cfrzJfcbP5IxEtiwbZ9TCTrrenT/ X-Received: by 2002:a50:e68b:: with SMTP id z11mr132057edm.25.1606151049934; Mon, 23 Nov 2020 09:04:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606151049; cv=none; d=google.com; s=arc-20160816; b=maGcNcpR7zeUWhXZtVC+3CfjOorBu6LWLdaHjHJwjaXlpBvXvcqCBz2hIFDReXZoya Sr+3Wz4OiG6TKRJmQEwveyZawxkpIrys17fRllAr7xgzkj0h1nmh8p1DH1RpYIm+Kl9e +EVgYg62VddsngQyBLAoGDnmm7XW8Fjz3lz0rTHKCRxKBUZ5t9CVdGr3o3rMMyBci+3U ImVIbNPyA17ZTMKsG/zRxVHD3U+CKpGuk/e5O7hJ5PI6HZbD/A9bs08IdVFYiYtMjhmN Z+pxno5yDVQH6NCK7oBq3SjFjIjCdTB85dFOcZ6Cfpa6hL+XMw5TZKFvlqYOImVSsxas AD+A== 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=OhkM3GnsryVwRniGczOnyMv/O1v+dH40168fq4YXBNM=; b=L8Wqi2nHkoM3r60kbsqVyOUQ3f7F2s0kCqmosT3odWoWAzAgN5DBd2AsqHqU/a4d4r SpPNVlzA5+wipaUUGYZXJ8dh30I0KxegAeC8myzSXuIuhQDQYbnHAG1hrrqqBdcmvIDJ 6qmzLpoWmcNNlf5OC9GMHOrC2/U6TznSwlpmjCRAfJaZEDsKAk9TItOhhKUCjRsLGlpn IgP5CX3eC63E0ENXVKl26eBjCVWHvAn4No+n8IJYGVxeuJ0xtGZP+y4uITiMmTfdQhyH q4RDmrMOgiMfkxFNtPEQ4dI2xMmHEiC9Bd0R1sjUm+cnl5lXR2nu5w+mhHu7k4CcVh+j 1DuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@st.com header.s=STMicroelectronics header.b=V7ImlZJ5; 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=st.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l13si6964896edn.43.2020.11.23.09.03.45; Mon, 23 Nov 2020 09:04:09 -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=@st.com header.s=STMicroelectronics header.b=V7ImlZJ5; 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=st.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390102AbgKWRCA (ORCPT + 99 others); Mon, 23 Nov 2020 12:02:00 -0500 Received: from mx07-00178001.pphosted.com ([185.132.182.106]:32030 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387746AbgKWRB6 (ORCPT ); Mon, 23 Nov 2020 12:01:58 -0500 Received: from pps.filterd (m0046668.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 0ANGw36W020959; Mon, 23 Nov 2020 18:01:41 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=STMicroelectronics; bh=OhkM3GnsryVwRniGczOnyMv/O1v+dH40168fq4YXBNM=; b=V7ImlZJ5slggkYPBVrMwCw0IGyOTStkBpt0fU/s8I3zP0U0SllYdLHESAtSeLDKmaiLx Cc4WHDJ0yrPcuu912zn/00uZ7ZHMeToWy8CGE8B6QFToZXkcYF+id7y/Dt8CjFX857jK st1wBF0fnTZBC0nm+mE/I+MSC5Ss9CagHOQAckfSO5+j5NLUtGeZDr3HfqW7Io9J5+jm svvixi25I4mmWXPPrVd8Iq5CLCmN+vAxXqk1Z+NYZahqL987jfXCvgRl64949qKmWvJO DbCs3r33Qm490+q8MwEVCWPETyUO8Ajg3KxdXluYLpZYnDRsMYfokkSQPWWe+x+N/gLg Vg== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 34y05h2eu5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 23 Nov 2020 18:01:41 +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 4FF7010002A; Mon, 23 Nov 2020 18:01:41 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag3node2.st.com [10.75.127.8]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 420F32BA2D0; Mon, 23 Nov 2020 18:01:41 +0100 (CET) Received: from localhost (10.75.127.46) by SFHDAG3NODE2.st.com (10.75.127.8) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Mon, 23 Nov 2020 18:01:40 +0100 From: Amelie Delaunay To: Kishon Vijay Abraham I , Vinod Koul , Rob Herring , Alexandre Torgue , Maxime Coquelin CC: , , , , Amelie Delaunay Subject: [PATCH 4/6] phy: stm32: ensure pll is disabled before phys creation Date: Mon, 23 Nov 2020 18:01:30 +0100 Message-ID: <20201123170132.17859-5-amelie.delaunay@st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201123170132.17859-1-amelie.delaunay@st.com> References: <20201123170132.17859-1-amelie.delaunay@st.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.75.127.46] X-ClientProxiedBy: SFHDAG1NODE1.st.com (10.75.127.1) To SFHDAG3NODE2.st.com (10.75.127.8) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.312,18.0.737 definitions=2020-11-23_14:2020-11-23,2020-11-23 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