From patchwork Fri Jul 4 09:55:45 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 33080 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pa0-f72.google.com (mail-pa0-f72.google.com [209.85.220.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 0E1A0203AC for ; Fri, 4 Jul 2014 10:01:25 +0000 (UTC) Received: by mail-pa0-f72.google.com with SMTP id rd3sf8966012pab.3 for ; Fri, 04 Jul 2014 03:01:25 -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=myIRoWIHL8X4mC2bWBxc1b3qhK9ZoIGRRiOYEzj/6to=; b=mc6DxXC5P3beop5OS3KZIl7taYSz+UP9lNcMUbSXcjGgly8qsP6n/zdegvqsZKcYDl eelDL+f5ylD+Tv44KhViQ/d9jD+uRRk9rQm+tC5n0lqEXyNYJv+71swW38B5YnTbyId+ VTmA8VVgtWaI4NmH50RgfQvgDs3ulKMiZXGRd2+2d74y2OpJhwTkHAme2eEgxpixsYwn n+QR2dPRcglcDX7Q7G33gxBKjr5vdxYDLn8uNWOfIu6aGYfjRbPq8KJtSmT/yvq12H+I b4iPumKz0Y3/8g5iU6jfZqlDCS3GYqm07r+M5xzoTnT4bN0GRC6LlGkBFFL5NJ0mgd9N WvdQ== X-Gm-Message-State: ALoCoQl6js9qOwKs9TmIeUdpa38pJIxS9OFidwP6Pmy0FnCnBny3sNb3RLRPj7CTc4qNuFL0pK0F X-Received: by 10.70.44.46 with SMTP id b14mr4604594pdm.4.1404468085264; Fri, 04 Jul 2014 03:01:25 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.108.34 with SMTP id i31ls794880qgf.51.gmail; Fri, 04 Jul 2014 03:01:25 -0700 (PDT) X-Received: by 10.58.119.75 with SMTP id ks11mr9202729veb.20.1404468085170; Fri, 04 Jul 2014 03:01:25 -0700 (PDT) Received: from mail-vc0-f176.google.com (mail-vc0-f176.google.com [209.85.220.176]) by mx.google.com with ESMTPS id yw1si15296391vdb.44.2014.07.04.03.01.25 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 04 Jul 2014 03:01:25 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.176 as permitted sender) client-ip=209.85.220.176; Received: by mail-vc0-f176.google.com with SMTP id ik5so1383236vcb.21 for ; Fri, 04 Jul 2014 03:01:25 -0700 (PDT) X-Received: by 10.220.190.197 with SMTP id dj5mr8826197vcb.19.1404468085100; Fri, 04 Jul 2014 03:01:25 -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 tc5csp453678vcb; Fri, 4 Jul 2014 03:01:24 -0700 (PDT) X-Received: by 10.70.91.170 with SMTP id cf10mr9406434pdb.72.1404468084247; Fri, 04 Jul 2014 03:01:24 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w7si1794565pdl.180.2014.07.04.03.01.23; Fri, 04 Jul 2014 03:01:23 -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 S1758740AbaGDKBO (ORCPT + 27 others); Fri, 4 Jul 2014 06:01:14 -0400 Received: from devils.ext.ti.com ([198.47.26.153]:56910 "EHLO devils.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030213AbaGDJ4H (ORCPT ); Fri, 4 Jul 2014 05:56:07 -0400 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id s649u6fB018910; Fri, 4 Jul 2014 04:56:06 -0500 Received: from DFLE73.ent.ti.com (dfle73.ent.ti.com [128.247.5.110]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id s649u6ND010577; Fri, 4 Jul 2014 04:56:06 -0500 Received: from dlep32.itg.ti.com (157.170.170.100) by DFLE73.ent.ti.com (128.247.5.110) with Microsoft SMTP Server id 14.3.174.1; Fri, 4 Jul 2014 04:56:05 -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 s649tpYg017971; Fri, 4 Jul 2014 04:56:02 -0500 From: Roger Quadros To: , , CC: , , , , , , , Roger Quadros Subject: [PATCH v2 3/6] phy: core: Support regulator supply for PHY power Date: Fri, 4 Jul 2014 12:55:45 +0300 Message-ID: <1404467748-12154-4-git-send-email-rogerq@ti.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1404467748-12154-1-git-send-email-rogerq@ti.com> References: <1404467748-12154-1-git-send-email-rogerq@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: rogerq@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.176 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: , 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 --- 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; }; /**