From patchwork Thu Jan 9 10:56:01 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 22998 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f199.google.com (mail-ie0-f199.google.com [209.85.223.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D9682216D9 for ; Thu, 9 Jan 2014 10:57:06 +0000 (UTC) Received: by mail-ie0-f199.google.com with SMTP id lx4sf11741436iec.2 for ; Thu, 09 Jan 2014 02:57:06 -0800 (PST) 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=22QnKubATilY5xRdfT32wcFT81I4vk8bbYAOSfAeRso=; b=FZSj/wRDFzL58FMRLcnQmBKmKBuNr7qtFeQ3aCcyS5xpXqU1CrmRlvxMslTogTiwlH BLne0DvUEXaaFC8edDpE3ftND5USJN3e2cAYq6l8wrl6TgNIR+VHCBxDpXyXnMW+CysB C/P+Is1bPI7DmqF7BMVbWTFSeNPni23gzhENJ3X4D6OS1exubHcbWtitAndq36Ldcvlu +Ij64SXxsgsa/byBkenk9Z/jvxli9NCP7iM4FTyZuJSN4S897cTEeiX5M7ArDtOKUSZT IVDDNAzpRGtyR7omZDG997jdKmg9snGgjXAMzX7UhNU5doF43eun3OidQlObYzdVVKGm cl9g== X-Gm-Message-State: ALoCoQlstQhPMpMafk8bH9JfvsHW/OgKbxK5hn4j9ovdaMcs72j/ZCQiqwxOfhlApgwu1/MysnGV X-Received: by 10.182.33.6 with SMTP id n6mr909063obi.6.1389265026153; Thu, 09 Jan 2014 02:57:06 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.36.229 with SMTP id t5ls941273qej.61.gmail; Thu, 09 Jan 2014 02:57:06 -0800 (PST) X-Received: by 10.58.205.170 with SMTP id lh10mr1621130vec.18.1389265026013; Thu, 09 Jan 2014 02:57:06 -0800 (PST) Received: from mail-ve0-f176.google.com (mail-ve0-f176.google.com [209.85.128.176]) by mx.google.com with ESMTPS id tc7si2619641vdc.35.2014.01.09.02.57.05 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 09 Jan 2014 02:57:05 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.176 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.176; Received: by mail-ve0-f176.google.com with SMTP id oz11so2205304veb.7 for ; Thu, 09 Jan 2014 02:57:05 -0800 (PST) X-Received: by 10.58.106.70 with SMTP id gs6mr1514453veb.28.1389265025874; Thu, 09 Jan 2014 02:57:05 -0800 (PST) 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.59.13.131 with SMTP id ey3csp4131ved; Thu, 9 Jan 2014 02:57:05 -0800 (PST) X-Received: by 10.68.252.5 with SMTP id zo5mr3073293pbc.10.1389265024855; Thu, 09 Jan 2014 02:57:04 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id zq7si3581573pac.159.2014.01.09.02.57.04; Thu, 09 Jan 2014 02:57:04 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754667AbaAIK4v (ORCPT + 26 others); Thu, 9 Jan 2014 05:56:51 -0500 Received: from bear.ext.ti.com ([192.94.94.41]:60503 "EHLO bear.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754357AbaAIK42 (ORCPT ); Thu, 9 Jan 2014 05:56:28 -0500 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id s09AuH2a003444; Thu, 9 Jan 2014 04:56:17 -0600 Received: from DFLE72.ent.ti.com (dfle72.ent.ti.com [128.247.5.109]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id s09AuHso009137; Thu, 9 Jan 2014 04:56:17 -0600 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.2.342.3; Thu, 9 Jan 2014 04:56:16 -0600 Received: from rockdesk.local.lan (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id s09Au4Ke012806; Thu, 9 Jan 2014 04:56:13 -0600 From: Roger Quadros To: CC: , , , , , , , , Balaji T K , Roger Quadros Subject: [PATCH v4 2/3] ata: ahci_platform: Manage SATA PHY Date: Thu, 9 Jan 2014 16:26:01 +0530 Message-ID: <1389264962-22858-3-git-send-email-rogerq@ti.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1389264962-22858-1-git-send-email-rogerq@ti.com> References: <1389264962-22858-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=neutral (google.com: 209.85.128.176 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) 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: Balaji T K Some platforms have a PHY hooked up to the SATA controller. The PHY needs to be initialized and powered up for SATA to work. We do that using the PHY framework. [Roger Q] Cleaned up. CC: Tejun Heo Signed-off-by: Balaji T K Signed-off-by: Roger Quadros --- drivers/ata/ahci.h | 2 ++ drivers/ata/ahci_platform.c | 46 ++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/drivers/ata/ahci.h b/drivers/ata/ahci.h index 2289efd..f9bbada 100644 --- a/drivers/ata/ahci.h +++ b/drivers/ata/ahci.h @@ -37,6 +37,7 @@ #include #include +#include /* Enclosure Management Control */ #define EM_CTRL_MSG_TYPE 0x000f0000 @@ -322,6 +323,7 @@ struct ahci_host_priv { u32 em_buf_sz; /* EM buffer size in byte */ u32 em_msg_type; /* EM message type */ struct clk *clk; /* Only for platforms supporting clk */ + struct phy *phy; /* If platform uses phy */ void *plat_data; /* Other platform data */ }; diff --git a/drivers/ata/ahci_platform.c b/drivers/ata/ahci_platform.c index d5ced13..b476642 100644 --- a/drivers/ata/ahci_platform.c +++ b/drivers/ata/ahci_platform.c @@ -142,6 +142,39 @@ static int ahci_probe(struct platform_device *pdev) } } + hpriv->phy = devm_phy_get(dev, "sata-phy"); + if (IS_ERR(hpriv->phy)) { + rc = PTR_ERR(hpriv->phy); + switch (rc) { + case -ENODEV: + case -ENOSYS: + /* continue normally */ + hpriv->phy = NULL; + break; + + case -EPROBE_DEFER: + goto disable_unprepare_clk; + break; + + default: + dev_err(dev, "couldn't get sata-phy\n"); + goto disable_unprepare_clk; + break; + } + } + + if (hpriv->phy) { + rc = phy_init(hpriv->phy); + if (rc) + goto disable_unprepare_clk; + + rc = phy_power_on(hpriv->phy); + if (rc) { + phy_exit(hpriv->phy); + goto disable_unprepare_clk; + } + } + /* * Some platforms might need to prepare for mmio region access, * which could be done in the following init call. So, the mmio @@ -151,7 +184,7 @@ static int ahci_probe(struct platform_device *pdev) if (pdata && pdata->init) { rc = pdata->init(dev, hpriv->mmio); if (rc) - goto disable_unprepare_clk; + goto disable_phy; } ahci_save_initial_config(dev, hpriv, @@ -221,6 +254,12 @@ static int ahci_probe(struct platform_device *pdev) pdata_exit: if (pdata && pdata->exit) pdata->exit(dev); +disable_phy: + if (hpriv->phy) { + phy_power_off(hpriv->phy); + phy_exit(hpriv->phy); + } + disable_unprepare_clk: if (!IS_ERR(hpriv->clk)) clk_disable_unprepare(hpriv->clk); @@ -239,6 +278,11 @@ static void ahci_host_stop(struct ata_host *host) if (pdata && pdata->exit) pdata->exit(dev); + if (hpriv->phy) { + phy_power_off(hpriv->phy); + phy_exit(hpriv->phy); + } + if (!IS_ERR(hpriv->clk)) { clk_disable_unprepare(hpriv->clk); clk_put(hpriv->clk);