From patchwork Tue Jul 22 10:56:35 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: 34042 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vc0-f198.google.com (mail-vc0-f198.google.com [209.85.220.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D2C0020540 for ; Tue, 22 Jul 2014 10:57:52 +0000 (UTC) Received: by mail-vc0-f198.google.com with SMTP id hu12sf24096056vcb.1 for ; Tue, 22 Jul 2014 03:57:52 -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=D/sjzxSwZB6lzcRUeyxa1/op6DetqOZVY83vci+jVA5L2ISKzjWsrHfdkn2OVnaMWX R61J+8Hca0dGNfNpReqc2V4Hr+Cs9ktUDkjvgB752zpqhoFyu8QgMa0wJZ1FIhZ5XYXS 8LCRgPbACWtvpdNpNBLvn9MyEMwWeDGfB1hvw6Iy0uI9rDiN9H8zzH5lXYy48QQY6LvX osO5S0CHcM+aO1IppYcQqWB1cEunSDaxpBb05uS3/issqhS1LHFAee8XcSZA86oE+u2h /vgFNCosVKyqyRXwYSxrQcqhXoi2EEmMfYRuPYFKdHWPHzzcDzF9fOS/p4P3ACEQhazN 16ow== X-Gm-Message-State: ALoCoQmJVEwtH/Egn/QvkrruuSe21KcY84Po3g6ubyjMyEu9/D5Q0VEWfn7HLRpaSViASq/lBvFN X-Received: by 10.52.231.97 with SMTP id tf1mr13626439vdc.3.1406026672666; Tue, 22 Jul 2014 03:57:52 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.98.175 with SMTP id o44ls2411504qge.55.gmail; Tue, 22 Jul 2014 03:57:52 -0700 (PDT) X-Received: by 10.221.44.69 with SMTP id uf5mr26889460vcb.4.1406026672553; Tue, 22 Jul 2014 03:57:52 -0700 (PDT) Received: from mail-vc0-f180.google.com (mail-vc0-f180.google.com [209.85.220.180]) by mx.google.com with ESMTPS id o6si29166vcn.83.2014.07.22.03.57.52 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 22 Jul 2014 03:57:52 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.180 as permitted sender) client-ip=209.85.220.180; Received: by mail-vc0-f180.google.com with SMTP id ij19so14264838vcb.25 for ; Tue, 22 Jul 2014 03:57:52 -0700 (PDT) X-Received: by 10.220.44.141 with SMTP id a13mr11199689vcf.71.1406026672392; Tue, 22 Jul 2014 03:57:52 -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 tc5csp185668vcb; Tue, 22 Jul 2014 03:57:51 -0700 (PDT) X-Received: by 10.70.109.196 with SMTP id hu4mr239738pdb.58.1406026670983; Tue, 22 Jul 2014 03:57:50 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id dn2si8668784pdb.500.2014.07.22.03.57.48 for ; Tue, 22 Jul 2014 03:57:48 -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 S1754747AbaGVK5c (ORCPT + 12 others); Tue, 22 Jul 2014 06:57:32 -0400 Received: from arroyo.ext.ti.com ([192.94.94.40]:56773 "EHLO arroyo.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754591AbaGVK53 (ORCPT ); Tue, 22 Jul 2014 06:57:29 -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 s6MAvSfc005547; Tue, 22 Jul 2014 05:57:28 -0500 Received: from DLEE70.ent.ti.com (dlee70.ent.ti.com [157.170.170.113]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id s6MAvSXe018177; Tue, 22 Jul 2014 05:57:28 -0500 Received: from dlep32.itg.ti.com (157.170.170.100) by DLEE70.ent.ti.com (157.170.170.113) with Microsoft SMTP Server id 14.3.174.1; Tue, 22 Jul 2014 05:57:27 -0500 Received: from localhost.localdomain (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep32.itg.ti.com (8.14.3/8.13.8) with ESMTP id s6MAv7qp027221; Tue, 22 Jul 2014 05:57:26 -0500 From: Kishon Vijay Abraham I To: CC: , Subject: [PATCH 12/28] phy: core: Support regulator supply for PHY power Date: Tue, 22 Jul 2014 16:26:35 +0530 Message-ID: <1406026611-30493-13-git-send-email-kishon@ti.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1406026611-30493-1-git-send-email-kishon@ti.com> References: <1406026611-30493-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.220.180 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; }; /**