From patchwork Sun Feb 4 19:18:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshihiro Kaneko X-Patchwork-Id: 10199441 X-Patchwork-Delegate: geert@linux-m68k.org 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 6144A60318 for ; Sun, 4 Feb 2018 19:19:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 437AC2844B for ; Sun, 4 Feb 2018 19:19:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2391B285C8; Sun, 4 Feb 2018 19:19:31 +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=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DDFAE2844B for ; Sun, 4 Feb 2018 19:19:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752027AbeBDTT3 (ORCPT ); Sun, 4 Feb 2018 14:19:29 -0500 Received: from mail-pl0-f65.google.com ([209.85.160.65]:41898 "EHLO mail-pl0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751797AbeBDTT2 (ORCPT ); Sun, 4 Feb 2018 14:19:28 -0500 Received: by mail-pl0-f65.google.com with SMTP id k8so8090826pli.8; Sun, 04 Feb 2018 11:19:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=KcD8OLpVYeYsLy1qFfZUYpSNdDO1eHtlL/LJQ9+nRPU=; b=emxtg1dGUkup8uMR7IN+zyiW8DVBhZQ1qsIJ/pYrw6dPnfskbwRUssq3S2a3Qymo4S CR3cIkl2z87b+u+1IG5BfitPbXscXo3FWlROo9aWTgWmw5iV3AoHKH75g4q3sYkQY/wT 1rN5fWsMzxVLh/nUZfOBTIPy1att2g8auSfpOU+svQsId68YV46NekAGZIon5Bb4uArB OFjlI5mlycwj43mx4NEQz4f31GMq8rq5NYhdl/Cmdd1XcOQaL5VmpIPGfu4SqViODM0i MTX0tGtYymztO3hQZOy18GRVsemS+YIonG/oW7RG5Ot8IG60teQpdmovp6xfJWruPo4i ESbA== 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; bh=KcD8OLpVYeYsLy1qFfZUYpSNdDO1eHtlL/LJQ9+nRPU=; b=txMh2jRNMcspdX9jrSKztKohlUnIBGMBepKoxDlUusAScPxpptg3cvnv/OpHu2IeZu OVLtQQwofwNttb4z3aLvvGCZ9tv2r0hnsFe0qhJ55QaMyDbBZSJsiix+TvnemEoxBu5k MBhWfCC/t8ErpjlYhBHmxDt+1VUhiusg4qulTlSrAAxEaVcOuaP8pgy0qzjA2pJgmUOc 8uGmrS8UJ2t2vYnbNgV6bF8Z2TtKhMzVv1Eie+9+FcuwoQPfDosfrmv4P0pGUg4LCQC0 YjdDXlSkxQyNyAitwn4ewK9dMWCc8VaUfcNE0lvr4+8xoMZLBMmn1HMpupUd6pImanqo Fkuw== X-Gm-Message-State: AKwxytfm/n+ddkA01tgcmfnMWWISUZ/7OZHm2ZfyibahS67A71nkEasM /d56dSZpfrvtK9ReAjwZCMbf4g== X-Google-Smtp-Source: AH8x227FYrTZ0GjPwT1ONYyWbLg13w5xZ+kzagLc1Ih5JfYIN6OUtKIeYkHO+1na99hG0uwZLhLO0Q== X-Received: by 2002:a17:902:34f:: with SMTP id 73-v6mr41480491pld.122.1517771967882; Sun, 04 Feb 2018 11:19:27 -0800 (PST) Received: from localhost.localdomain (KD118152108246.ppp-bb.dion.ne.jp. [118.152.108.246]) by smtp.gmail.com with ESMTPSA id k7sm10355687pgo.31.2018.02.04.11.19.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 04 Feb 2018 11:19:27 -0800 (PST) From: Yoshihiro Kaneko To: linux-ide@vger.kernel.org Cc: Tejun Heo , Simon Horman , Magnus Damm , Geert Uytterhoeven , linux-renesas-soc@vger.kernel.org, Sergei Shtylyov Subject: [PATCH/RFT v3] sata_rcar: Reset SATA PHY when Salvator-X board resumes Date: Mon, 5 Feb 2018 04:18:51 +0900 Message-Id: <1517771931-17157-1-git-send-email-ykaneko0929@gmail.com> X-Mailer: git-send-email 1.9.1 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Khiem Nguyen Because power of Salvator-X board is cut off in suspend, it needs to reset SATA PHY state in resume. Otherwise, SATA partition could not be accessed anymore. Signed-off-by: Khiem Nguyen Signed-off-by: Hien Dang [reinit phy in sata_rcar_resume() function on R-Car Gen3 only] [factor out SATA module init sequence] [fixed the prefix for the subject] Signed-off-by: Yoshihiro Kaneko --- drivers/ata/sata_rcar.c | 63 +++++++++++++++++++++++++++++++------------------ 1 file changed, 40 insertions(+), 23 deletions(-) This patch is based on the for-next branch of libata tree. v2 [Yoshihiro Kaneko] * reinit phy on R-Car Gen3 only as suggested by Geert Uytterhoeven * use "sata_rcar" prefix for the subject as suggested by Sergei Shtylyov v3 [Yoshihiro Kaneko] * As suggested by Sergei Shtylyov - factored out the common part of the initialising SATA module - remove the redundant "sata:" prefix from the subject diff --git a/drivers/ata/sata_rcar.c b/drivers/ata/sata_rcar.c index 80ee2f2..6f47ca3 100644 --- a/drivers/ata/sata_rcar.c +++ b/drivers/ata/sata_rcar.c @@ -146,6 +146,7 @@ enum sata_rcar_type { RCAR_GEN1_SATA, RCAR_GEN2_SATA, + RCAR_GEN3_SATA, RCAR_R8A7790_ES1_SATA, }; @@ -784,26 +785,11 @@ static void sata_rcar_setup_port(struct ata_host *host) ioaddr->command_addr = ioaddr->cmd_addr + (ATA_REG_CMD << 2); } -static void sata_rcar_init_controller(struct ata_host *host) +static void sata_rcar_init_module(struct sata_rcar_priv *priv) { - struct sata_rcar_priv *priv = host->private_data; void __iomem *base = priv->base; u32 val; - /* reset and setup phy */ - switch (priv->type) { - case RCAR_GEN1_SATA: - sata_rcar_gen1_phy_init(priv); - break; - case RCAR_GEN2_SATA: - case RCAR_R8A7790_ES1_SATA: - sata_rcar_gen2_phy_init(priv); - break; - default: - dev_warn(host->dev, "SATA phy is not initialized\n"); - break; - } - /* SATA-IP reset state */ val = ioread32(base + ATAPI_CONTROL1_REG); val |= ATAPI_CONTROL1_RESET; @@ -824,10 +810,34 @@ static void sata_rcar_init_controller(struct ata_host *host) /* ack and mask */ iowrite32(0, base + SATAINTSTAT_REG); iowrite32(0x7ff, base + SATAINTMASK_REG); + /* enable interrupts */ iowrite32(ATAPI_INT_ENABLE_SATAINT, base + ATAPI_INT_ENABLE_REG); } +static void sata_rcar_init_controller(struct ata_host *host) +{ + struct sata_rcar_priv *priv = host->private_data; + void __iomem *base = priv->base; + + /* reset and setup phy */ + switch (priv->type) { + case RCAR_GEN1_SATA: + sata_rcar_gen1_phy_init(priv); + break; + case RCAR_GEN2_SATA: + case RCAR_GEN3_SATA: + case RCAR_R8A7790_ES1_SATA: + sata_rcar_gen2_phy_init(priv); + break; + default: + dev_warn(host->dev, "SATA phy is not initialized\n"); + break; + } + + sata_rcar_init_module(priv); +} + static const struct of_device_id sata_rcar_match[] = { { /* Deprecated by "renesas,sata-r8a7779" */ @@ -856,7 +866,7 @@ static void sata_rcar_init_controller(struct ata_host *host) }, { .compatible = "renesas,sata-r8a7795", - .data = (void *)RCAR_GEN2_SATA + .data = (void *)RCAR_GEN3_SATA }, { .compatible = "renesas,rcar-gen2-sata", @@ -864,7 +874,7 @@ static void sata_rcar_init_controller(struct ata_host *host) }, { .compatible = "renesas,rcar-gen3-sata", - .data = (void *)RCAR_GEN2_SATA + .data = (void *)RCAR_GEN3_SATA }, { }, }; @@ -982,11 +992,18 @@ static int sata_rcar_resume(struct device *dev) if (ret) return ret; - /* ack and mask */ - iowrite32(0, base + SATAINTSTAT_REG); - iowrite32(0x7ff, base + SATAINTMASK_REG); - /* enable interrupts */ - iowrite32(ATAPI_INT_ENABLE_SATAINT, base + ATAPI_INT_ENABLE_REG); + if (priv->type == RCAR_GEN3_SATA) { + sata_rcar_gen2_phy_init(priv); + sata_rcar_init_module(priv); + } else { + /* ack and mask */ + iowrite32(0, base + SATAINTSTAT_REG); + iowrite32(0x7ff, base + SATAINTMASK_REG); + + /* enable interrupts */ + iowrite32(ATAPI_INT_ENABLE_SATAINT, + base + ATAPI_INT_ENABLE_REG); + } ata_host_resume(host);