From patchwork Tue Jan 16 14:39:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshihiro Kaneko X-Patchwork-Id: 10167257 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 80CEB60325 for ; Tue, 16 Jan 2018 14:39:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 698E02851D for ; Tue, 16 Jan 2018 14:39:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5DEE12855A; Tue, 16 Jan 2018 14:39:29 +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 BEFC62851D for ; Tue, 16 Jan 2018 14:39:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750796AbeAPOjZ (ORCPT ); Tue, 16 Jan 2018 09:39:25 -0500 Received: from mail-pl0-f65.google.com ([209.85.160.65]:37746 "EHLO mail-pl0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750750AbeAPOjV (ORCPT ); Tue, 16 Jan 2018 09:39:21 -0500 Received: by mail-pl0-f65.google.com with SMTP id s3so6309193plp.4; Tue, 16 Jan 2018 06:39:21 -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=1eah4ASclgl1v/vS5fDlEuiDTlRSIjrdeEj2FnoB2S4=; b=q5VY5JjRw3/uHbj9hQwyTQZSJhNoaXQhMZ7Celspmc7SqZS3EGrdo4xm8IggY3Dwe3 GHvYfKordx3feELGs2Mg5NW95YVSoD2/zCAYJyakkJJFInGwb3WAsTYvzY2CUtwNM6KO FQPyT6NWWCZwpxKy03NoU99tk2NJwE3wvbROfZ1Y1UUDL1E+nEbklgvGeBWk4BKyDIqj OKsGFgAOR0P8aaqEc6u4UF9RfpUGduzo0LmTJ+gAwSrLXgqNKnfGJaDDTbp7c9DOWGb7 zNUB2CAETssH+qK8y0u28poohyRB/48SNMakPTjFEtklaiV7eMgjCuUMrg9Q67WDc8nH hy5A== 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=1eah4ASclgl1v/vS5fDlEuiDTlRSIjrdeEj2FnoB2S4=; b=doZ252cMxbpH4vMHmckVfSMNxVIb7Hsnk/1cGwbaEH/k3On63odRxN84TS1zRIKFTo 1lba3FMzemQk7CRnCO+f5uahC0H1p4ISUIvcNYdd2YEMBoppv3vXIlo6k69xvbJhdHVy 7hpu4WwC7sUar0WT7rtmtQtrxAaxls1n8z5gFLjXuDnhGVeJ4oSVBHPNlbjowqypq8kb 1CgE242X8d7F6gBhMt5JU+fXr2tB+rDm8U2xZDQsFUicdVEDnfEH+qOYKQJfP4hGAHex JRJDGsNtMmOX04HU00l0w3Z0XoyyK+IdLrmTuVUeAKIfEm+7ueme0w6Q7RWS52fg71Ue x6jA== X-Gm-Message-State: AKGB3mLqxfCEe0/w/vbz5rksQByv/Al58md7r0+cKfdo07wNNH8Z6fBQ LjLVg/FsL0Nthpzzwd50XZh1Xw== X-Google-Smtp-Source: ACJfBou6awY8vPhzOw7RicZ+J3LEEPFRe6lB1iXGVEn4LWPecWUEXsd7xgbT/lXzfFzUaXfqKPeVeQ== X-Received: by 10.84.211.39 with SMTP id b36mr39304196pli.217.1516113560978; Tue, 16 Jan 2018 06:39:20 -0800 (PST) Received: from macc.flets-east.jp (p8035-ipngn10101marunouchi.tokyo.ocn.ne.jp. [114.164.103.35]) by smtp.gmail.com with ESMTPSA id c184sm4198215pfc.60.2018.01.16.06.39.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 16 Jan 2018 06:39:20 -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 Subject: [PATCH v2] sata: sata_rcar: Reset SATA PHY when Salvator-X board resumes Date: Tue, 16 Jan 2018 23:39:12 +0900 Message-Id: <1516113552-27701-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] [fixed the prefix for the subject] Signed-off-by: Yoshihiro Kaneko --- 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 drivers/ata/sata_rcar.c | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/drivers/ata/sata_rcar.c b/drivers/ata/sata_rcar.c index 80ee2f2..4adc0d6 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, }; @@ -796,6 +797,7 @@ static void sata_rcar_init_controller(struct ata_host *host) 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; @@ -856,7 +858,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 +866,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 }, { }, }; @@ -977,11 +979,43 @@ static int sata_rcar_resume(struct device *dev) struct sata_rcar_priv *priv = host->private_data; void __iomem *base = priv->base; int ret; + u32 val; ret = clk_prepare_enable(priv->clk); if (ret) return ret; + /* reinit phy on R-Car Gen3 only */ + switch (priv->type) { + case RCAR_GEN1_SATA: + case RCAR_GEN2_SATA: + case RCAR_R8A7790_ES1_SATA: + break; + case RCAR_GEN3_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; + iowrite32(val, base + ATAPI_CONTROL1_REG); + + /* ISM mode, PRD mode, DTEND flag at bit 0 */ + val = ioread32(base + ATAPI_CONTROL1_REG); + val |= ATAPI_CONTROL1_ISM; + val |= ATAPI_CONTROL1_DESE; + val |= ATAPI_CONTROL1_DTA32M; + iowrite32(val, base + ATAPI_CONTROL1_REG); + + /* Release the SATA-IP from the reset state */ + val = ioread32(base + ATAPI_CONTROL1_REG); + val &= ~ATAPI_CONTROL1_RESET; + iowrite32(val, base + ATAPI_CONTROL1_REG); + /* ack and mask */ iowrite32(0, base + SATAINTSTAT_REG); iowrite32(0x7ff, base + SATAINTMASK_REG);