From patchwork Wed Feb 19 12:01:55 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 24948 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f197.google.com (mail-wi0-f197.google.com [209.85.212.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 5128F2054E for ; Wed, 19 Feb 2014 12:03:46 +0000 (UTC) Received: by mail-wi0-f197.google.com with SMTP id d9sf988194wiv.0 for ; Wed, 19 Feb 2014 04:03:45 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=gAMPAMVxrL95XXaCAx3LsK2YXl57f+7sgNC7nPdkILE=; b=Baj+iMT4MQofr2FldaT9jxisuakURFm8u0uPFSBP1Zemj33aUTqPREAC3DgpGVTPDR F2tlHHPR7SsUMm7ByGynsOXHivuBIH3QK7d3xBxoGJ/K4y56v4X5AaW6t12/koy3REWu SLGu/azBMO7W+kuae4xTPxpW/lTwXgMf6eOqL2VQBFECT+kEOcJBogZnctZladGjM9c0 zHqKUZmcvNkboK5/i0okC1dXQ4OepH1Zp1tGHKXEYYFR67daYDPvb6E3SN3Beldm0+gt CIcnT5QETXRpLeKjLr/sPcbHeFl2/C6Aab8l3weZ6dfFVwzf07FLT4xO7b/28Qu2mS4A Nzpw== X-Gm-Message-State: ALoCoQnJTLdHXTtYYtKilvyjJi3dXkr4J/IcUAvMTw23moVX3Ikju7erzJTaSH3gZMshOVw4YHYO X-Received: by 10.180.89.5 with SMTP id bk5mr820666wib.0.1392811425217; Wed, 19 Feb 2014 04:03:45 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.106.71 with SMTP id d65ls62532qgf.60.gmail; Wed, 19 Feb 2014 04:03:44 -0800 (PST) X-Received: by 10.220.12.193 with SMTP id y1mr214697vcy.75.1392811424763; Wed, 19 Feb 2014 04:03:44 -0800 (PST) Received: from mail-vc0-f182.google.com (mail-vc0-f182.google.com [209.85.220.182]) by mx.google.com with ESMTPS id i3si6657934vcp.127.2014.02.19.04.03.44 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 19 Feb 2014 04:03:44 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.182 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.182; Received: by mail-vc0-f182.google.com with SMTP id id10so267870vcb.13 for ; Wed, 19 Feb 2014 04:03:44 -0800 (PST) X-Received: by 10.52.23.68 with SMTP id k4mr17810024vdf.24.1392811424676; Wed, 19 Feb 2014 04:03:44 -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 u4csp291702vcz; Wed, 19 Feb 2014 04:03:44 -0800 (PST) X-Received: by 10.66.136.229 with SMTP id qd5mr1801050pab.118.1392811423535; Wed, 19 Feb 2014 04:03:43 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r3si21792451pbh.130.2014.02.19.04.03.42; Wed, 19 Feb 2014 04:03:42 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of devicetree-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 S1752883AbaBSMDm (ORCPT + 9 others); Wed, 19 Feb 2014 07:03:42 -0500 Received: from mx1.redhat.com ([209.132.183.28]:48724 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752701AbaBSMDl (ORCPT ); Wed, 19 Feb 2014 07:03:41 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s1JC3DAc021083 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 19 Feb 2014 07:03:13 -0500 Received: from shalem.localdomain.com (vpn1-4-52.ams2.redhat.com [10.36.4.52]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id s1JC24jN012728; Wed, 19 Feb 2014 07:03:08 -0500 From: Hans de Goede To: Tejun Heo , Maxime Ripard Cc: Oliver Schinagl , Richard Zhu , Roger Quadros , Lee Jones , linux-ide@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree , linux-sunxi@googlegroups.com, Balaji T K , Hans de Goede Subject: [PATCH v6 13/18] ata: ahci_platform: Manage SATA PHY Date: Wed, 19 Feb 2014 13:01:55 +0100 Message-Id: <1392811320-3132-14-git-send-email-hdegoede@redhat.com> In-Reply-To: <1392811320-3132-1-git-send-email-hdegoede@redhat.com> References: <1392811320-3132-1-git-send-email-hdegoede@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 Sender: devicetree-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: devicetree@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: hdegoede@redhat.com X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.182 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: Roger Quadros 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. CC: Balaji T K Signed-off-by: Roger Quadros Signed-off-by: Hans de Goede --- drivers/ata/Kconfig | 1 + drivers/ata/ahci_platform.c | 40 ++++++++++++++++++++++++++++++++++++++++ include/linux/ahci.h | 2 ++ 3 files changed, 43 insertions(+) diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig index cc67cc0..96176f4 100644 --- a/drivers/ata/Kconfig +++ b/drivers/ata/Kconfig @@ -91,6 +91,7 @@ config SATA_AHCI config SATA_AHCI_PLATFORM tristate "Platform AHCI SATA support" + depends on GENERIC_PHY || !GENERIC_PHY help This option enables support for Platform AHCI Serial ATA controllers. diff --git a/drivers/ata/ahci_platform.c b/drivers/ata/ahci_platform.c index 962ec25..073931a 100644 --- a/drivers/ata/ahci_platform.c +++ b/drivers/ata/ahci_platform.c @@ -23,6 +23,7 @@ #include #include #include +#include #include "ahci.h" static void ahci_host_stop(struct ata_host *host); @@ -131,8 +132,23 @@ int ahci_platform_enable_resources(struct ahci_host_priv *hpriv) if (rc) goto disable_regulator; + if (hpriv->phy) { + rc = phy_init(hpriv->phy); + if (rc) + goto disable_clks; + + rc = phy_power_on(hpriv->phy); + if (rc) { + phy_exit(hpriv->phy); + goto disable_clks; + } + } + return 0; +disable_clks: + ahci_platform_disable_clks(hpriv); + disable_regulator: if (hpriv->target_pwr) regulator_disable(hpriv->target_pwr); @@ -142,6 +158,11 @@ EXPORT_SYMBOL_GPL(ahci_platform_enable_resources); void ahci_platform_disable_resources(struct ahci_host_priv *hpriv) { + if (hpriv->phy) { + phy_power_off(hpriv->phy); + phy_exit(hpriv->phy); + } + ahci_platform_disable_clks(hpriv); if (hpriv->target_pwr) @@ -194,6 +215,25 @@ struct ahci_host_priv *ahci_platform_get_resources( hpriv->clks[i] = clk; } + 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 free_clk; + + default: + dev_err(dev, "couldn't get sata-phy\n"); + goto free_clk; + } + } + return hpriv; free_clk: diff --git a/include/linux/ahci.h b/include/linux/ahci.h index ac69cdc..8fbe3d7 100644 --- a/include/linux/ahci.h +++ b/include/linux/ahci.h @@ -23,6 +23,7 @@ #include #include +#include #define AHCI_MAX_CLKS 3 @@ -42,6 +43,7 @@ struct ahci_host_priv { u32 em_msg_type; /* EM message type */ struct clk *clks[AHCI_MAX_CLKS]; /* Optional */ struct regulator *target_pwr; /* Optional */ + struct phy *phy; /* If platform uses phy */ void *plat_data; /* Other platform data */ /* Optional ahci_start_engine override */ void (*start_engine)(struct ata_port *ap);