From patchwork Thu Aug 30 19:01:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin Labbe X-Patchwork-Id: 10582723 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6C9EF14BD for ; Thu, 30 Aug 2018 19:14:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5C18628726 for ; Thu, 30 Aug 2018 19:14:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4E11C2C453; Thu, 30 Aug 2018 19:14:11 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.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 EC4F428726 for ; Thu, 30 Aug 2018 19:14:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=TIP5RejUcvXXBSt3+PAt52Ykhoi1X4JBli+2a3xeEoM=; b=BFv1GuWuoGVRa2DbzoqRCUxWx5 OVM19LKh5+3PpfaXgMF199OetFfB70sVnJkaf2IUxTmxuffnY/DT4ajI3LnsrlOace/INf6n8n++F vOVxLNEKTFGBtmh9tSDwbrarRczCUvpLs+MuI2O2Fr889xQNwffaAiuDYhNTOdmMlY9zjH+D5Cyb+ 6UkTufIpIZo2TqW+MhzMzCrgYQgHEzk132wl3Aylf8uH1hJBBe5OkQ1A0ciqNjyBpSmCWHyKuTjK1 R6W+fBAVsNFuRrraAT3ZWOge5/N54AdgYNwu29Mcya4ouyvFiyVvijKfTP66S3mos+/K2v1NhA0yK BCyawJww==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fvSOH-0000z2-HF; Thu, 30 Aug 2018 19:14:01 +0000 Received: from casper.infradead.org ([85.118.1.10]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fvSKn-0006KM-GL for linux-arm-kernel@bombadil.infradead.org; Thu, 30 Aug 2018 19:10:25 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=t7Yy96h1CNLQsmpPB+gBtt+3MwMJX3o+4LyGaKYq94s=; b=BpZ2q8WLfAbe0NCXDqbC/TFq6 qIG3FGExZX/P7BlT2ZxZoFV1tlvMUr00w1CipvVZ/6q8xVSJ+F1okjZTxK5fPn4QiQ122zegeg1+N ofZI3GqB0NTHex+Qk2/MBAtUDNtKTkShwpcdxuscw3VzQWmAK7m9clEQCFkoAI2d5T6+pw2jwUZU0 IZH8oI19Bsd1wXvD1YzntwBbJSQzL1ITwaRaEOTtUhga1FPBohAd8/VeC/xxFu1p1VigYcrV8IWsH M8vjXJyqk5SwC5AeuKaqbYiY24rRitPWf/gZR3HR98OZC1qY6NAdARHkOoxMZm3h5IDMuSpFNMFq3 u06du8UEg==; Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]) by casper.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fvSCN-0000IX-P1 for linux-arm-kernel@lists.infradead.org; Thu, 30 Aug 2018 19:01:45 +0000 Received: by mail-wm0-x242.google.com with SMTP id o18-v6so3084849wmc.0 for ; Thu, 30 Aug 2018 12:01:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=t7Yy96h1CNLQsmpPB+gBtt+3MwMJX3o+4LyGaKYq94s=; b=Ovh2DSFQ3Cs6oLBB67ht6cSz4HYmGF8Wha89mOyuDPXkA1DktCSvtOe9hN5rJM0COS BqdbmOs3DP96TKpkimSVj+KN7d2D3YrtcPABUwXb7VS+YIshG7m0D0X9qlXfWUE5WPzQ fumVRD+JDD/7qTg9FPB+lWDdNyQSuT2/aERQEzH34edKn8K+oLj+6uX49dMym8abrtMS 5auJyHSU4SL8rfQCcfSL/B77phx64zqXzdkX+1ZlG5PSW+jGUVvUSOAiG9/QcA2gNIlQ 4cfntFdChWp7ZXQNx0uxZIJQoWDez6a8xLhtUG6/YweucdqC+/Gp+iLOg7i2Vr2fkqKp 7FCA== 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=t7Yy96h1CNLQsmpPB+gBtt+3MwMJX3o+4LyGaKYq94s=; b=dlEdcAxeSziZkpcvzF7JUyAoQEXNzvNVmOce58JdSRXkGnFMWW9Vnehbz8Q+A1kaos JxdOIZDE60jXONxaY58HWwDxLVf3d1OOoRSQeOG8mMZ5NTuTVC12UO+mH1u5GNJI23g+ 5R0u1rOTvP2mF+2jMPMqtWgGYERL6pyJsx/4I4z4akAxuVJ2zzw1oXBOL181+leT+WMp ehXdbgViXMFxAiGNR3fvskO7ff1ak9SXoKqt7SJvjLxuaYPzfNWmw7PKZeXc2OgtJSRH VmRlKcpUIRBMsQ57a3wvUjElUUPMNuXiGzdciHXRnLrhIP+8zwPhEuoodynB+dh+h9AZ TXZg== X-Gm-Message-State: APzg51DmTboQqsKqryec4wafquH6hajxGEHODac10bhJDEFsyghJ1dhY k3KFLrn9wML+vOwBAynLJKvQhShh X-Google-Smtp-Source: ANB0Vdb6vrLVv1tUQqsKvf3EK6v9rGI3K/xY72jlBe/Kj2psPEnGdHTISywO0PI3hRnsWYx3Asqzew== X-Received: by 2002:a1c:908b:: with SMTP id s133-v6mr2706797wmd.69.1535655691915; Thu, 30 Aug 2018 12:01:31 -0700 (PDT) Received: from Red.localdomain ([2a01:cb1d:147:7200:2e56:dcff:fed2:c6d6]) by smtp.googlemail.com with ESMTPSA id w17-v6sm2937095wmc.43.2018.08.30.12.01.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Aug 2018 12:01:30 -0700 (PDT) From: Corentin Labbe To: axboe@kernel.dk, hdegoede@redhat.com, kishon@ti.com, mark.rutland@arm.com, maxime.ripard@bootlin.com, robh+dt@kernel.org, wens@csie.org, clabbe.montjoie@gmail.com Subject: [PATCH v4 02/13] ata: ahci_platform: add support for AHCI controller regulator Date: Thu, 30 Aug 2018 21:01:09 +0200 Message-Id: <20180830190120.722-3-clabbe.montjoie@gmail.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20180830190120.722-1-clabbe.montjoie@gmail.com> References: <20180830190120.722-1-clabbe.montjoie@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180830_200143_812199_FCDC67B6 X-CRM114-Status: GOOD ( 24.22 ) 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: devicetree@vger.kernel.org, linux-sunxi@googlegroups.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-ide@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 The SoC R40 AHCI controller need a regulator to work. So this patch add a way to add an optional regulator on AHCI controller. Signed-off-by: Corentin Labbe --- drivers/ata/ahci.h | 1 + drivers/ata/libahci_platform.c | 26 ++++++++++++++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/drivers/ata/ahci.h b/drivers/ata/ahci.h index 6a1515f0da40..1415f1012de5 100644 --- a/drivers/ata/ahci.h +++ b/drivers/ata/ahci.h @@ -352,6 +352,7 @@ struct ahci_host_priv { struct clk *clks[AHCI_MAX_CLKS]; /* Optional */ struct reset_control *rsts; /* Optional */ struct regulator **target_pwrs; /* Optional */ + struct regulator *ahci_regulator;/* Optional */ /* * If platform uses PHYs. There is a 1:1 relation between the port number and * the PHY position in this array. diff --git a/drivers/ata/libahci_platform.c b/drivers/ata/libahci_platform.c index c92c10d55374..a886b61476a3 100644 --- a/drivers/ata/libahci_platform.c +++ b/drivers/ata/libahci_platform.c @@ -139,7 +139,7 @@ EXPORT_SYMBOL_GPL(ahci_platform_disable_clks); * ahci_platform_enable_regulators - Enable regulators * @hpriv: host private area to store config values * - * This function enables all the regulators found in + * This function enables all the regulators found in controller and * hpriv->target_pwrs, if any. If a regulator fails to be enabled, it * disables all the regulators already enabled in reverse order and * returns an error. @@ -151,6 +151,12 @@ int ahci_platform_enable_regulators(struct ahci_host_priv *hpriv) { int rc, i; + if (hpriv->ahci_regulator) { + rc = regulator_enable(hpriv->ahci_regulator); + if (rc) + return rc; + } + for (i = 0; i < hpriv->nports; i++) { if (!hpriv->target_pwrs[i]) continue; @@ -167,6 +173,8 @@ int ahci_platform_enable_regulators(struct ahci_host_priv *hpriv) if (hpriv->target_pwrs[i]) regulator_disable(hpriv->target_pwrs[i]); + if (hpriv->ahci_regulator) + regulator_disable(hpriv->ahci_regulator); return rc; } EXPORT_SYMBOL_GPL(ahci_platform_enable_regulators); @@ -175,7 +183,8 @@ EXPORT_SYMBOL_GPL(ahci_platform_enable_regulators); * ahci_platform_disable_regulators - Disable regulators * @hpriv: host private area to store config values * - * This function disables all regulators found in hpriv->target_pwrs. + * This function disables all regulators found in hpriv->target_pwrs and + * AHCI controller. */ void ahci_platform_disable_regulators(struct ahci_host_priv *hpriv) { @@ -186,6 +195,9 @@ void ahci_platform_disable_regulators(struct ahci_host_priv *hpriv) continue; regulator_disable(hpriv->target_pwrs[i]); } + + if (hpriv->ahci_regulator) + regulator_disable(hpriv->ahci_regulator); } EXPORT_SYMBOL_GPL(ahci_platform_disable_regulators); /** @@ -351,6 +363,7 @@ static int ahci_platform_get_regulator(struct ahci_host_priv *hpriv, u32 port, * * 1) mmio registers (IORESOURCE_MEM 0, mandatory) * 2) regulator for controlling the targets power (optional) + * regulator for controlling the AHCI controller (optional) * 3) 0 - AHCI_MAX_CLKS clocks, as specified in the devs devicetree node, * or for non devicetree enabled platforms a single clock * 4) resets, if flags has AHCI_PLATFORM_GET_RESETS (optional) @@ -408,6 +421,15 @@ struct ahci_host_priv *ahci_platform_get_resources(struct platform_device *pdev, hpriv->clks[i] = clk; } + hpriv->ahci_regulator = devm_regulator_get_optional(dev, "ahci"); + if (IS_ERR(hpriv->ahci_regulator)) { + rc = PTR_ERR(hpriv->ahci_regulator); + if (rc == -EPROBE_DEFER) + goto err_out; + rc = 0; + hpriv->ahci_regulator = NULL; + } + if (flags & AHCI_PLATFORM_GET_RESETS) { hpriv->rsts = devm_reset_control_array_get_optional_shared(dev); if (IS_ERR(hpriv->rsts)) {