From patchwork Wed Jan 18 13:19:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 91769 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp1010260qgi; Wed, 18 Jan 2017 05:20:36 -0800 (PST) X-Received: by 10.99.95.151 with SMTP id t145mr3887907pgb.75.1484745636337; Wed, 18 Jan 2017 05:20:36 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t25si204672pge.272.2017.01.18.05.20.36; Wed, 18 Jan 2017 05:20:36 -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; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752832AbdARNU2 (ORCPT + 25 others); Wed, 18 Jan 2017 08:20:28 -0500 Received: from mail-wm0-f50.google.com ([74.125.82.50]:38620 "EHLO mail-wm0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752747AbdARNUW (ORCPT ); Wed, 18 Jan 2017 08:20:22 -0500 Received: by mail-wm0-f50.google.com with SMTP id r144so24693722wme.1 for ; Wed, 18 Jan 2017 05:20:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=dd3oaffUvdNALpCuH4cA+p+i9l+V6/HOJQHNkF+ruQc=; b=o7p/c2CsiNyFltxj2yFn8uutcitqyh0b8f1cQPtRe++yR+kv/L6dcq8Vw1ZM23x3d/ Gubxv62Pc767ZUVeG+wPQcL/mbKIBQ01NzNd9hTNIuTW+EA4JOzHIn/mBwzNujLUYUu1 yE4jdGsZOVFeurIsuafzd5KoZFPJ3ShkcrtiEZMRInrpSAIwdsbQHPT5leVL1vSq+k8Y RUlL6AE7uIClj5zwHZK1YoWPQwCApTwnPMC63QAP8zSZicupdfDR29OSp2fLEklKJUAi EPQCTQASHpZFUOECNiPhyxwUuxZ7trMjEuIPdV2V/ZlzPtALipRZT9nX1etq6qU8zgsO BY2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=dd3oaffUvdNALpCuH4cA+p+i9l+V6/HOJQHNkF+ruQc=; b=AqYJlyxERou51rzxS3dE+6FfWr0adkPdyfL75giK//U9/I8gnJvfhx6VFNmWER6khF P4m/wtqBAc+UXirZgXt22Q0xAU1LOakBAyFZGig8eqhQCYE0IR8b77u9fEtNsYNLAuUo dppJ3p/IP8RD2T2/TBxBNr7wHrAMKkm8ueuyYZV/5NzuTU24EwnqVvRJFy25LW6zGyDi lM74OxmZszGv4/CZhjtAZIqlA8iRftbC3qGcyosl7hH0O97p16qiHpghA9sjI5hS+Yj8 UjhvmWhPMbRbBdg+hUDMgmV65wyweuRrg6zadLwQGCYItPQMUjfEwuJCMiut+4ScVObG p9ZA== X-Gm-Message-State: AIkVDXK4Iv//RBsC5UdfIIJ6oT63YnbQCjJIt3h88Q18imuw3euRr2F9iGKq6xlXmxFZM7eW X-Received: by 10.223.134.151 with SMTP id 23mr3449505wrx.0.1484745620946; Wed, 18 Jan 2017 05:20:20 -0800 (PST) Received: from localhost.localdomain ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id w79sm4899569wmw.0.2017.01.18.05.20.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 18 Jan 2017 05:20:20 -0800 (PST) From: Bartosz Golaszewski To: Kevin Hilman , Sekhar Nori , Patrick Titiano , Michael Turquette , Tejun Heo , Rob Herring , Mark Rutland , Russell King , David Lechner Cc: linux-ide@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Bartosz Golaszewski Subject: [PATCH v3 04/13] sata: ahci-da850: get the sata clock using a connection id Date: Wed, 18 Jan 2017 14:19:52 +0100 Message-Id: <1484745601-4769-5-git-send-email-bgolaszewski@baylibre.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1484745601-4769-1-git-send-email-bgolaszewski@baylibre.com> References: <1484745601-4769-1-git-send-email-bgolaszewski@baylibre.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In preparation for using two clocks in the driver (the sysclk2-based clock and the external REFCLK), check if we got a functional clock after calling ahci_platform_get_resources(). If not, retry calling clk_get() with con_id specified. Signed-off-by: Bartosz Golaszewski --- drivers/ata/ahci_da850.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) -- 2.9.3 diff --git a/drivers/ata/ahci_da850.c b/drivers/ata/ahci_da850.c index 267a3d3..8cfdc86 100644 --- a/drivers/ata/ahci_da850.c +++ b/drivers/ata/ahci_da850.c @@ -71,12 +71,28 @@ static int ahci_da850_probe(struct platform_device *pdev) struct ahci_host_priv *hpriv; struct resource *res; void __iomem *pwrdn_reg; + struct clk *clk; int rc; hpriv = ahci_platform_get_resources(pdev); if (IS_ERR(hpriv)) return PTR_ERR(hpriv); + /* + * Internally ahci_platform_get_resources() calls clk_get(dev, NULL) + * when trying to obtain the first clock. This SATA controller uses + * two clocks for which we specify two connection ids. If we don't + * have a clock at this point - call clk_get() again with + * con_id = "sata". + */ + if (!hpriv->clks[0]) { + clk = clk_get(dev, "sata"); + if (IS_ERR(clk)) + return PTR_ERR(clk); + + hpriv->clks[0] = clk; + } + rc = ahci_platform_enable_resources(hpriv); if (rc) return rc;