From patchwork Mon Jul 7 06:48:23 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kishon Vijay Abraham I X-Patchwork-Id: 33123 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ve0-f200.google.com (mail-ve0-f200.google.com [209.85.128.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 56046235AB for ; Mon, 7 Jul 2014 06:49:04 +0000 (UTC) Received: by mail-ve0-f200.google.com with SMTP id i13sf16340609veh.3 for ; Sun, 06 Jul 2014 23:49:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe:content-type; bh=DnbCP6JL7iR4splvugqgpaVORKr5x4XIO9pErR0KLsc=; b=hyXfrdFMQtTcCtCp/CnCvsBD5daZnqkYQ/tkFnpWr026Q4PYh696k6HaFW3wiWOC3/ EBcrJHKzeV1rLwBtsIs0hWdnLNY/kohBsrh2g1GLP6vWe43CYjpGyVp7Flk1wiXumbF/ ByWf38cGapreI7CNt9TMCl/43N2TIrQKQPu1sM84/XUjQoekQ+gbOgVFm8wLccU2VM7+ BJwgqKyHrYdCO0tjBR/9EIIrMT0NjMtWoNXxb35cdItOn4zLepQyyo29eG6iHvKdYa71 Qz2IJ6NL7JmxYJt6nPNrk40+1eqfp16wtZj312d3tF0QwQsNzmd7wCRIHDizvbw1SA46 PZhg== X-Gm-Message-State: ALoCoQnTxvkc2IAJASDNhHZWH77Z0hbFQ0ex1w/4+067JHHXZ0L+jq2j9lihlST3v2MVQpAW2J6T X-Received: by 10.52.146.133 with SMTP id tc5mr11349486vdb.6.1404715744129; Sun, 06 Jul 2014 23:49:04 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.18.242 with SMTP id 105ls1530000qgf.83.gmail; Sun, 06 Jul 2014 23:49:04 -0700 (PDT) X-Received: by 10.52.248.209 with SMTP id yo17mr647757vdc.60.1404715743989; Sun, 06 Jul 2014 23:49:03 -0700 (PDT) Received: from mail-ve0-f181.google.com (mail-ve0-f181.google.com [209.85.128.181]) by mx.google.com with ESMTPS id d7si13023553vcy.33.2014.07.06.23.49.03 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 06 Jul 2014 23:49:03 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.181 as permitted sender) client-ip=209.85.128.181; Received: by mail-ve0-f181.google.com with SMTP id db11so3519794veb.26 for ; Sun, 06 Jul 2014 23:49:03 -0700 (PDT) X-Received: by 10.52.84.162 with SMTP id a2mr21851481vdz.23.1404715743918; Sun, 06 Jul 2014 23:49:03 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.37.5 with SMTP id tc5csp643746vcb; Sun, 6 Jul 2014 23:49:03 -0700 (PDT) X-Received: by 10.70.42.8 with SMTP id j8mr24890677pdl.14.1404715742499; Sun, 06 Jul 2014 23:49:02 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ks7si40373000pab.173.2014.07.06.23.49.01; Sun, 06 Jul 2014 23:49:01 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751952AbaGGGs5 (ORCPT + 27 others); Mon, 7 Jul 2014 02:48:57 -0400 Received: from arroyo.ext.ti.com ([192.94.94.40]:50422 "EHLO arroyo.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750855AbaGGGsw (ORCPT ); Mon, 7 Jul 2014 02:48:52 -0400 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id s676mpmC021087; Mon, 7 Jul 2014 01:48:51 -0500 Received: from DFLE72.ent.ti.com (dfle72.ent.ti.com [128.247.5.109]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id s676mpJb008022; Mon, 7 Jul 2014 01:48:51 -0500 Received: from dflp32.itg.ti.com (10.64.6.15) by DFLE72.ent.ti.com (128.247.5.109) with Microsoft SMTP Server id 14.3.174.1; Mon, 7 Jul 2014 01:48:51 -0500 Received: from localhost.localdomain (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id s676meMC028360; Mon, 7 Jul 2014 01:48:50 -0500 From: Kishon Vijay Abraham I To: CC: , Subject: [PATCH 6/8] phy: core: Support regulator supply for PHY power Date: Mon, 7 Jul 2014 12:18:23 +0530 Message-ID: <1404715705-5041-7-git-send-email-kishon@ti.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1404715705-5041-1-git-send-email-kishon@ti.com> References: <1404715705-5041-1-git-send-email-kishon@ti.com> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: kishon@ti.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.181 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Roger Quadros Some PHYs can be powered by an external power regulator. e.g. USB_HS PHY on DRA7 SoC. Make the PHY core support a power regulator. Signed-off-by: Roger Quadros Signed-off-by: Kishon Vijay Abraham I --- drivers/phy/phy-core.c | 26 ++++++++++++++++++++++++++ include/linux/phy/phy.h | 2 ++ 2 files changed, 28 insertions(+) diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index 49c4465..75c9739 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c @@ -21,6 +21,7 @@ #include #include #include +#include static struct class *phy_class; static DEFINE_MUTEX(phy_provider_mutex); @@ -226,6 +227,12 @@ int phy_power_on(struct phy *phy) if (!phy) return 0; + if (phy->pwr) { + ret = regulator_enable(phy->pwr); + if (ret) + return ret; + } + ret = phy_pm_runtime_get_sync(phy); if (ret < 0 && ret != -ENOTSUPP) return ret; @@ -247,6 +254,8 @@ int phy_power_on(struct phy *phy) out: mutex_unlock(&phy->mutex); phy_pm_runtime_put_sync(phy); + if (phy->pwr) + regulator_disable(phy->pwr); return ret; } @@ -272,6 +281,9 @@ int phy_power_off(struct phy *phy) mutex_unlock(&phy->mutex); phy_pm_runtime_put(phy); + if (phy->pwr) + regulator_disable(phy->pwr); + return 0; } EXPORT_SYMBOL_GPL(phy_power_off); @@ -588,6 +600,16 @@ struct phy *phy_create(struct device *dev, const struct phy_ops *ops, goto free_phy; } + /* phy-supply */ + phy->pwr = regulator_get_optional(dev, "phy"); + if (IS_ERR(phy->pwr)) { + if (PTR_ERR(phy->pwr) == -EPROBE_DEFER) { + ret = -EPROBE_DEFER; + goto free_ida; + } + phy->pwr = NULL; + } + device_initialize(&phy->dev); mutex_init(&phy->mutex); @@ -617,6 +639,9 @@ put_dev: put_device(&phy->dev); /* calls phy_release() which frees resources */ return ERR_PTR(ret); +free_ida: + ida_simple_remove(&phy_ida, phy->id); + free_phy: kfree(phy); return ERR_PTR(ret); @@ -800,6 +825,7 @@ static void phy_release(struct device *dev) phy = to_phy(dev); dev_vdbg(dev, "releasing '%s'\n", dev_name(dev)); + regulator_put(phy->pwr); ida_simple_remove(&phy_ida, phy->id); kfree(phy); } diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h index 2760744..9a86945 100644 --- a/include/linux/phy/phy.h +++ b/include/linux/phy/phy.h @@ -18,6 +18,7 @@ #include #include #include +#include struct phy; @@ -65,6 +66,7 @@ struct phy { int init_count; int power_count; struct phy_attrs attrs; + struct regulator *pwr; }; /**