From patchwork Mon Jan 20 14:41:27 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 23403 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qe0-f69.google.com (mail-qe0-f69.google.com [209.85.128.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 06C882107B for ; Mon, 20 Jan 2014 14:42:29 +0000 (UTC) Received: by mail-qe0-f69.google.com with SMTP id cz11sf2398994qeb.8 for ; Mon, 20 Jan 2014 06:42:29 -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=K/vZPcudrYWl6syo0obCl72oEPVZUTdp1CC9TUHUb18=; b=aJU5Y3qgsae+wL3b1qAKdrjadjYVF6tgRysGcC46tNlAUon6fE+eW5EdaSlgkz31KA OkFszi8MI+HoiMq19b8uI3dzR0FZAuIjxk3jEMvB3BIavGaTOINsoRBwriUf0NAvRTds FFW/bevdXiT1/48NXLYnwIjeir45enHwKIIdEgaZ/6kVnIlKLlxcpWCtr5xWEXc72Ebf wObZ9OlXIFlpPrK5Hg/syKvFcAPPhgtll7DZcVzI3WTGSWHI92NsX5yi53UN/ntOc7Qj 9kLbTWERLOusS/ShdMh1iJoNODPl3PnPSRhyxM+FkLGZAV65CaIX5F/nszLNxri9OXBL yH/Q== X-Gm-Message-State: ALoCoQnPVJhOqF+djqGdjPPT5takScBsfQr92PJAMBYAl+8/JTneEAjA8hSiE29Yk6/2vDwIpu5R X-Received: by 10.58.253.229 with SMTP id ad5mr6290678ved.30.1390228949237; Mon, 20 Jan 2014 06:42:29 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.99.71 with SMTP id eo7ls1724309qeb.20.gmail; Mon, 20 Jan 2014 06:42:29 -0800 (PST) X-Received: by 10.221.39.138 with SMTP id tm10mr10901131vcb.7.1390228949075; Mon, 20 Jan 2014 06:42:29 -0800 (PST) Received: from mail-ve0-f179.google.com (mail-ve0-f179.google.com [209.85.128.179]) by mx.google.com with ESMTPS id kp12si412355vcb.16.2014.01.20.06.42.29 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 20 Jan 2014 06:42:29 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.179 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.179; Received: by mail-ve0-f179.google.com with SMTP id jx11so562805veb.24 for ; Mon, 20 Jan 2014 06:42:29 -0800 (PST) X-Received: by 10.220.191.134 with SMTP id dm6mr10958461vcb.16.1390228948996; Mon, 20 Jan 2014 06:42:28 -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.220.174.196 with SMTP id u4csp61203vcz; Mon, 20 Jan 2014 06:42:28 -0800 (PST) X-Received: by 10.66.121.68 with SMTP id li4mr19160136pab.33.1390228946983; Mon, 20 Jan 2014 06:42:26 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n8si1686307pax.276.2014.01.20.06.42.18; Mon, 20 Jan 2014 06:42:18 -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 S1753725AbaATOmB (ORCPT + 26 others); Mon, 20 Jan 2014 09:42:01 -0500 Received: from arroyo.ext.ti.com ([192.94.94.40]:47797 "EHLO arroyo.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753779AbaATOly (ORCPT ); Mon, 20 Jan 2014 09:41:54 -0500 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id s0KEfimK024432; Mon, 20 Jan 2014 08:41:44 -0600 Received: from DFLE73.ent.ti.com (dfle73.ent.ti.com [128.247.5.110]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id s0KEfinT017416; Mon, 20 Jan 2014 08:41:44 -0600 Received: from dflp32.itg.ti.com (10.64.6.15) by DFLE73.ent.ti.com (128.247.5.110) with Microsoft SMTP Server id 14.2.342.3; Mon, 20 Jan 2014 08:41:43 -0600 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 s0KEfUYo010156; Mon, 20 Jan 2014 08:41:41 -0600 From: Roger Quadros To: CC: , , , , , , , , Balaji T K , Roger Quadros Subject: [PATCH v5 3/4] ata: ahci_platform: Manage SATA PHY Date: Mon, 20 Jan 2014 16:41:27 +0200 Message-ID: <1390228888-5537-4-git-send-email-rogerq@ti.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1390228888-5537-1-git-send-email-rogerq@ti.com> References: <1390228888-5537-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.179 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. Signed-off-by: Balaji T K Signed-off-by: Roger Quadros Reviewed-by: Bartlomiej Zolnierkiewicz Acked-by: Kishon Vijay Abraham I --- drivers/ata/ahci.h | 2 ++ drivers/ata/ahci_platform.c | 44 +++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 45 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..580567f 100644 --- a/drivers/ata/ahci_platform.c +++ b/drivers/ata/ahci_platform.c @@ -142,6 +142,37 @@ 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; + + default: + dev_err(dev, "couldn't get sata-phy\n"); + goto disable_unprepare_clk; + } + } + + 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 +182,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 +252,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 +276,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);