Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp2862239pxb; Tue, 13 Apr 2021 12:02:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz7U0Wp8fwtYhcIfd5kM3DDBewoqlUxBjf58hTM8vUihegrZvkhVMDBqctKSFtlgm0rdvVL X-Received: by 2002:a50:cdd1:: with SMTP id h17mr36308646edj.178.1618340578498; Tue, 13 Apr 2021 12:02:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618340578; cv=none; d=google.com; s=arc-20160816; b=nF5a+uz35lzBpANuHYDYwZ5xQ8kX2QfC0fxYEmCCngf9m92mnjGIwTu7Ojgh3YqBqX 48IlleWPKoLxH8FmrMe47/vUfTkVwQi/cDaAsvcdsPVQwsTxwC79oAr3miEnp7RRXMC3 w7xQQqhaJnbnBNfOM+P1iVMq5cG6FkvY4RjtrMG6PunSHADbmkgYSUABZUacl7I7i4Uw K9T7ZXdbZ5ktANelS9J3fblJgpBQ6WoJNn6GORJyHh8CCUcSQI1sT1XqHbGNCSVJ8PFe eDd8u8NR42F5wa91gY0mjl0VbnQBJmfYlYp38o0HIsccwIk0uSFLWEVHwMkMjTGtecU+ itIw== 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=pjdn0iPLZsVnMrs5LhG4TkO0pVvE9Vj+yQMAhrHcFD4=; b=aNCAOC8O3lstCb3hdrMPwtQ5+ge0Zy15MQw2UBo2qUEb1qIFReocRuPmvkGDvwGtIj 2thuOC1YrMlmCF08huuhqaYSbOoqe0g+xQ8MBXg8JtYQhrX6PB1p1+DN+xDL5tYD9rFL mUfwGbku1mq0dyQPTQEzifcuPDZUEwn5ZivEsTqY+0NYApHpjQmANEzkfz8fRbYvtXUp zU/YuQU03V/Q0/bMeTj0HLGO19I9+Pnfc+u65zSCjPqTsf1Yi7Y/aK4ezHCgw5nxHe69 6Wbr18UOyU8DvMM/CJYYc6QXSN7g588Nmmmouo6kbv02bA8YO9bTWiLxY7iFFNY3hc30 jriw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@foss.st.com header.s=selector1 header.b=D8o3fopu; 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 a10si8893455ejr.711.2021.04.13.12.02.33; Tue, 13 Apr 2021 12:02:58 -0700 (PDT) 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=D8o3fopu; 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 S1343519AbhDMOd3 (ORCPT + 99 others); Tue, 13 Apr 2021 10:33:29 -0400 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:33430 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S243824AbhDMOc4 (ORCPT ); Tue, 13 Apr 2021 10:32:56 -0400 Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 13DENfbF013334; Tue, 13 Apr 2021 16:32:17 +0200 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=pjdn0iPLZsVnMrs5LhG4TkO0pVvE9Vj+yQMAhrHcFD4=; b=D8o3fopuhzzacBsQEBYvQTpOZjtYCfs7A40Lsqg9qTYRetxwbeP/tRK0uiwTIZAGiq2o mQG1SsVSv8VtLnkzeKPgCENWi3Og7b7XYsROd9NE9KMszI2bnrT9p9XnvUJgphP85hIv 3Yi0QnniZOhG8ctweBUAdvSP0xb3u4ObVFxEhT4ltCMrFIWtARaQewhdMyR2gJDRB9/6 jYXzjZ/qUzzRbHycYtQg/mRm2bTl8nkRaldDmv++l2UxpukU3wGWDhVaqj92EWba2M/9 TQq1o9qmJjRtFBbeGUm1CXXgChJI7nBaV8/5oN3BlVuXnUF2o/nWR4Jj/g8K+cSG/s92 ow== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 37vu4e5b92-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 13 Apr 2021 16:32:17 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 32EE5100038; Tue, 13 Apr 2021 16:32:17 +0200 (CEST) Received: from Webmail-eu.st.com (sfhdag2node3.st.com [10.75.127.6]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 23D87246F3E; Tue, 13 Apr 2021 16:32:17 +0200 (CEST) Received: from localhost (10.75.127.46) by SFHDAG2NODE3.st.com (10.75.127.6) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 13 Apr 2021 16:32:16 +0200 From: Amelie Delaunay To: Kishon Vijay Abraham I , Vinod Koul , Rob Herring , Alexandre Torgue , Maxime Coquelin CC: , , , , , Amelie Delaunay Subject: [PATCH v2 2/2] phy: stm32: manage optional vbus regulator on phy_power_on/off Date: Tue, 13 Apr 2021 16:31:41 +0200 Message-ID: <20210413143141.12919-3-amelie.delaunay@foss.st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210413143141.12919-1-amelie.delaunay@foss.st.com> References: <20210413143141.12919-1-amelie.delaunay@foss.st.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.75.127.46] 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.391,18.0.761 definitions=2021-04-13_08:2021-04-13,2021-04-13 signatures=0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch adds support for optional vbus regulator. It is managed on phy_power_on/off calls and may be needed for host mode. Signed-off-by: Amelie Delaunay --- No changes in v2. --- drivers/phy/st/phy-stm32-usbphyc.c | 31 ++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/drivers/phy/st/phy-stm32-usbphyc.c b/drivers/phy/st/phy-stm32-usbphyc.c index c184f4e34584..3e491dfb2525 100644 --- a/drivers/phy/st/phy-stm32-usbphyc.c +++ b/drivers/phy/st/phy-stm32-usbphyc.c @@ -57,6 +57,7 @@ struct pll_params { struct stm32_usbphyc_phy { struct phy *phy; struct stm32_usbphyc *usbphyc; + struct regulator *vbus; u32 index; bool active; }; @@ -291,9 +292,31 @@ static int stm32_usbphyc_phy_exit(struct phy *phy) return stm32_usbphyc_pll_disable(usbphyc); } +static int stm32_usbphyc_phy_power_on(struct phy *phy) +{ + struct stm32_usbphyc_phy *usbphyc_phy = phy_get_drvdata(phy); + + if (usbphyc_phy->vbus) + return regulator_enable(usbphyc_phy->vbus); + + return 0; +} + +static int stm32_usbphyc_phy_power_off(struct phy *phy) +{ + struct stm32_usbphyc_phy *usbphyc_phy = phy_get_drvdata(phy); + + if (usbphyc_phy->vbus) + return regulator_disable(usbphyc_phy->vbus); + + return 0; +} + static const struct phy_ops stm32_usbphyc_phy_ops = { .init = stm32_usbphyc_phy_init, .exit = stm32_usbphyc_phy_exit, + .power_on = stm32_usbphyc_phy_power_on, + .power_off = stm32_usbphyc_phy_power_off, .owner = THIS_MODULE, }; @@ -519,6 +542,14 @@ static int stm32_usbphyc_probe(struct platform_device *pdev) usbphyc->phys[port]->index = index; usbphyc->phys[port]->active = false; + usbphyc->phys[port]->vbus = devm_regulator_get_optional(&phy->dev, "vbus"); + if (IS_ERR(usbphyc->phys[port]->vbus)) { + ret = PTR_ERR(usbphyc->phys[port]->vbus); + if (ret == -EPROBE_DEFER) + goto put_child; + usbphyc->phys[port]->vbus = NULL; + } + port++; } -- 2.17.1