Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2882475pxj; Mon, 17 May 2021 12:05:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzxNLHUTXvy7krmjf02hkNdHhDNfr6b6t7INT74D1bc6gChO8r8hpOLv+CjLZnfWr+wuVHx X-Received: by 2002:aa7:dc17:: with SMTP id b23mr1790110edu.359.1621278356259; Mon, 17 May 2021 12:05:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621278356; cv=none; d=google.com; s=arc-20160816; b=Dr7yRlBAxUy6iN98yaKcJRxfFUg9X/o5QYo8FkRIxYCC9+ljsb5TpPmutZky1LmcIn 6EhEoY0AbGoZqsFsjlop3tfW2yHuyNp5KjEjAPiJ1CDydw2rh6PaCKRh4selVy/P4TkA 9P5Fj5rpmibpuqohQRADfQEr849inhfDMc86yeHIcHff3p00xsZr/cbGt+OFiztrXPye VYVrKr/7FWQ9EyYhPWb1bsf0NaiFcZlSH7dTiIUTzUEe760QQc1DNrksWjDl8bGR3bM3 wYX9urVRpMRsDwCzUgwXAstobV8aZBaox0X/WNtJ5wOF4OorkYX9UXQPQjukNKfQJUI6 ctlQ== 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=LzEUtcBl5pVBtyEpXyWBLOkaQVQnRU19JtdKM5oa9at9jMz8V9h4CSiztqkFQTuvxY hofNIXdcDT+DkiahqoCVg2Vc8lC5uhrzuCfctc4IFrXtzwrbGpVuvPwyVz1Zlk9u1FfY UBPWJ/jGIOCr4aWqJw+P3hpCaDR8aO5Pr0utATq7B92PlJOMHsJFqjETxxMZloReHS/9 k+/CoZtGCFwQugcSRU+/NUFCqyyBZNDIW6Evs42/FL9LrEl/WGJf/9lZ6Axpq25qtEfP emHvgA8VqAXQ4pW1+5nKzjeN5xQUxLCE1zwQ5CL8VESeadH2462yg5tKO1hME2r1Iqki s6ew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@foss.st.com header.s=selector1 header.b=385JZpGw; 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 g8si16825736edb.70.2021.05.17.12.05.29; Mon, 17 May 2021 12:05:56 -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=385JZpGw; 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 S236915AbhEQMKr (ORCPT + 99 others); Mon, 17 May 2021 08:10:47 -0400 Received: from mx07-00178001.pphosted.com ([185.132.182.106]:40030 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236859AbhEQMKq (ORCPT ); Mon, 17 May 2021 08:10:46 -0400 Received: from pps.filterd (m0241204.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 14HC5Z7f008635; Mon, 17 May 2021 14:08:28 +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=385JZpGwsRXOH0R+XqYOdRc0bj1NCZlTWKhWt55LKQXMHPfEAvt8xwUJjPznPKpw1DCo OQYaTXOTbEsudLNusDajGSk9RLmtd5hn2s4IiYqlE0FOR99KWxl9baQS1WrgfC/OP/h5 US/pPr/olOAJ4966qbG2ug/glogb0CD0CkzKKx19nyuTnvz57zCpLENjD3JA6JZCPMwd jnEqMgv8Jz7g0cJaRje1OMRyjuTH78g4LtKQAabj8OROB36O239AGujrIBIPEAC7uDuy zUq1HdIMtVQNM01SIvIHA5qfMsCZBnwiHKSu0euputTpf8ENMUPqalNT0x5QVWzxHBbz Lg== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 38k5dq4p4x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 17 May 2021 14:08:28 +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 9708710002A; Mon, 17 May 2021 14:08:27 +0200 (CEST) Received: from Webmail-eu.st.com (sfhdag2node3.st.com [10.75.127.6]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 7C4C922D636; Mon, 17 May 2021 14:08:27 +0200 (CEST) Received: from localhost (10.75.127.50) by SFHDAG2NODE3.st.com (10.75.127.6) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 17 May 2021 14:08:27 +0200 From: Amelie Delaunay To: Kishon Vijay Abraham I , Vinod Koul , Rob Herring , Alexandre Torgue , Maxime Coquelin CC: , , , , , Amelie Delaunay Subject: [RESEND PATCH v2 2/2] phy: stm32: manage optional vbus regulator on phy_power_on/off Date: Mon, 17 May 2021 14:08:21 +0200 Message-ID: <20210517120821.26466-3-amelie.delaunay@foss.st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210517120821.26466-1-amelie.delaunay@foss.st.com> References: <20210517120821.26466-1-amelie.delaunay@foss.st.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.75.127.50] X-ClientProxiedBy: SFHDAG3NODE2.st.com (10.75.127.8) 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-05-17_04:2021-05-17,2021-05-17 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