From patchwork Mon Jan 23 17:00:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 9533131 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D33726046A for ; Mon, 23 Jan 2017 17:04:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C404626E82 for ; Mon, 23 Jan 2017 17:04:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B640628460; Mon, 23 Jan 2017 17:04:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_SORBS_SPAM,T_DKIM_INVALID autolearn=no version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7DA3C26E82 for ; Mon, 23 Jan 2017 17:04:02 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cVi2D-0003hH-89; Mon, 23 Jan 2017 17:04:01 +0000 Received: from mail-wm0-f49.google.com ([74.125.82.49]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cVi0h-0002aY-DO for linux-arm-kernel@lists.infradead.org; Mon, 23 Jan 2017 17:02:30 +0000 Received: by mail-wm0-f49.google.com with SMTP id r144so165495987wme.1 for ; Mon, 23 Jan 2017 09:02:06 -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=FZwZkqs4bj26ZKQMi1LuDiIVdTQgfgaLGvWGm8RF8ZA=; b=OJgbJipVcoezFdlfzM2CIrYF7TgHh3wwxFugQh/0+yxFri6bloTqj6Ezz1vhV8sTcz qMOwaJf24enozS5bcvBs/7goceT+ZWgDqM6xVkLOzjyrMaG2rEvM52xZdVx4CSFw6ktK DTFYIVkmYGXw0W/YTU0qfPvs1V6UysTpwMTDiIagqGrHLOcKvBaqCgoahx2Hf28J+FV9 Bl3JH3uEijHwtI3EutMRzpBWwE5FxvhOTRkMfKhWGxbOv8pjJ4dTEjXIxbChJjScp5AF uAk2kl8K1lQgarm15qgkgHFlypjz+MUsq9GpLeWpUW54QXOfbdWgxfAJRyljaBcjBEDg Hrvg== 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=FZwZkqs4bj26ZKQMi1LuDiIVdTQgfgaLGvWGm8RF8ZA=; b=kh44xQzpY2ZyywmOFU4T4LHfnYDQHbVvx8TDnbtA88/uJ7sDTRnXdZvu3D03ueYEWN 83rcNW2reK4KEK529dXBBPNtGcEcjmmEN8pWVsHoDZKachaLkCOLotp6+2naxTk5gWyl RKNLvDzwCfEOKGKnpEth5qoVkxHCmpNmuugYccQ+7hlw2UBFsf0tSwBdkszyzML/VXZn 1IL8Rc5uvbozYbi8DrOpr+Gf91uO9mSCHECZWOVkHOe46INxPEnaeSBHY0WOcWJjfiDf /RU7KN4MJc8WlnMcuWk+aXZaT2zmlMhaArlpOAf0GGYv3cVKjUb0oNJCoUHXPvi/9YPY WxAg== X-Gm-Message-State: AIkVDXI9jQn+6RQmzUQ+8c2Rt+mlQ6tZVrY5FWQEaYAz8wpd3+YZCSTfKvM2h+jzxz5SMn8F X-Received: by 10.223.155.140 with SMTP id d12mr23608555wrc.143.1485190865404; Mon, 23 Jan 2017 09:01:05 -0800 (PST) Received: from localhost.localdomain ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id l10sm12758910wrb.44.2017.01.23.09.01.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 23 Jan 2017 09:01:04 -0800 (PST) From: Bartosz Golaszewski To: Kevin Hilman , Sekhar Nori , Patrick Titiano , Michael Turquette , Tejun Heo , Rob Herring , Mark Rutland , Russell King , David Lechner Subject: [PATCH v6 04/14] sata: ahci-da850: get the sata clock using a connection id Date: Mon, 23 Jan 2017 18:00:46 +0100 Message-Id: <1485190856-4711-5-git-send-email-bgolaszewski@baylibre.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1485190856-4711-1-git-send-email-bgolaszewski@baylibre.com> References: <1485190856-4711-1-git-send-email-bgolaszewski@baylibre.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170123_090227_619417_BC74F913 X-CRM114-Status: GOOD ( 14.26 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-ide@vger.kernel.org, Bartosz Golaszewski , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Acked-by: Tejun Heo --- drivers/ata/ahci_da850.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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;