From patchwork Wed Dec 6 18:45:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshihiro Kaneko X-Patchwork-Id: 10096767 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 A5EF5602BF for ; Wed, 6 Dec 2017 18:46:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8D1AE29C3E for ; Wed, 6 Dec 2017 18:46:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7EDBA29DDB; Wed, 6 Dec 2017 18:46:59 +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 C204E29C3E for ; Wed, 6 Dec 2017 18:46:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751847AbdLFSq6 (ORCPT ); Wed, 6 Dec 2017 13:46:58 -0500 Received: from mail-pg0-f65.google.com ([74.125.83.65]:39316 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751711AbdLFSq5 (ORCPT ); Wed, 6 Dec 2017 13:46:57 -0500 Received: by mail-pg0-f65.google.com with SMTP id w7so2576520pgv.6; Wed, 06 Dec 2017 10:46:57 -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=qvRBuHK9jXuvTb1OIlJftedPwvOkLMi3UMbsi1b4jGk=; b=exYb6qkyWf2JvPiwBneU6x3qpD9qCMsypr6hC/aGBUDrCGH34ioDd55PHQrMNWL5Ek Ym8hlFnFssKhQhEm/ASCxV7jQRpKh1IQQ6e7TTJm1RHB+9C8ixOy2ye12D8OKRuxHlsY F5I6NkiKDGcmLafXFhovnS7+HSGmVqZGMNp4GbwY5/5/iyUYXI0J8qWTXHAzBFi+cgEt HIUB0mkof7D1TlLMyulWe+s3XsZHlNGefFuXb4t1+ZL5us8gfTbrI9RLQl/vuevGl7T8 o1oxrqFsFYIUvGAhmQ+JdmeBJAR84L4IC0KPgbzavC+SdYY5IaH5+dcEUVST9pJuSaBc ewjg== 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=qvRBuHK9jXuvTb1OIlJftedPwvOkLMi3UMbsi1b4jGk=; b=YRmVjCk8ENMiY2N4LS1FRUAD9UBrnSWEfkUb0F7KsoDQe5Cz3rmv8LtxsDB1KLrjjx J8Uho0FrZO42WxeYHZ2HDd+3EuwiCC07e1hYI1UQr+BbeaLWt63Bcn2AufclqeVGCBRa RvSB4CAUxpUg2tXwwCVkzvCyxVCIU44rm3do6ST0iLtw2WlLVNk8fRPxwR35DBQfSO2n +KCiX7FWN4VgUZSx1gxoCrVqfudmNE6eVvEbwnGVYEha/cw8Cve6NMGh1Zou5TnIvvLb Ll5JTrkC5qS/uW1fJ370jX0zd88RBRHyz70G3ww1uvdW87d0WUugaNUzqYpko2AAP1CL HxmA== X-Gm-Message-State: AJaThX48nExoUoQQO01YD10Shb+vGTjg3UXnc62Xn72a25XRxYRYVs/t JsNf8etGhWXj4JvCwC3iRSuAWw== X-Google-Smtp-Source: AGs4zMYsLobgK5L8gXUohuALME5lR5xtNpRliPNRMScRmOMbNDNUVXNpOCJ5LGxnvyhXx3+0aq1udw== X-Received: by 10.99.127.85 with SMTP id p21mr22332056pgn.425.1512586016807; Wed, 06 Dec 2017 10:46:56 -0800 (PST) Received: from localhost.localdomain (KD118152108246.ppp-bb.dion.ne.jp. [118.152.108.246]) by smtp.gmail.com with ESMTPSA id m21sm4950844pgn.66.2017.12.06.10.46.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 06 Dec 2017 10:46:56 -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] sata: rcar_sata: Reset SATA PHY when Salvator-X board resumes Date: Thu, 7 Dec 2017 03:45:25 +0900 Message-Id: <1512585925-4251-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 Signed-off-by: Yoshihiro Kaneko --- This patch is based on the for-next branch of libata tree. drivers/ata/sata_rcar.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/drivers/ata/sata_rcar.c b/drivers/ata/sata_rcar.c index 80ee2f2..aba6121 100644 --- a/drivers/ata/sata_rcar.c +++ b/drivers/ata/sata_rcar.c @@ -977,11 +977,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; + /* Re-use from sata_rcar_init_controller() */ + /* reset and setup phy */ + switch (priv->type) { + case RCAR_GEN1_SATA: + sata_rcar_gen1_phy_init(priv); + break; + case RCAR_GEN2_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);