From patchwork Fri Apr 6 11:02:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergei Shtylyov X-Patchwork-Id: 10325843 X-Patchwork-Delegate: bhelgaas@google.com 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 50EFD60547 for ; Fri, 6 Apr 2018 11:02:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 42FC5291BD for ; Fri, 6 Apr 2018 11:02:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 37FB1291F3; Fri, 6 Apr 2018 11:02:58 +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.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=unavailable 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 DE02829243 for ; Fri, 6 Apr 2018 11:02:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751540AbeDFLC4 (ORCPT ); Fri, 6 Apr 2018 07:02:56 -0400 Received: from mail-wr0-f196.google.com ([209.85.128.196]:36574 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751434AbeDFLCz (ORCPT ); Fri, 6 Apr 2018 07:02:55 -0400 Received: by mail-wr0-f196.google.com with SMTP id y55so1370138wry.3 for ; Fri, 06 Apr 2018 04:02:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cogentembedded-com.20150623.gappssmtp.com; s=20150623; h=subject:from:to:references:organization:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=ygdli/k8tJLxpKP54kqOqddMHMRUIInLK1hz5F6f5Hc=; b=RbvO3RrqQaI1zqRkfax0bVItdpkjtzKk2PTnYC/TeWoXjogDbvW+TXwZTErmMjk7Cm OEER/+is6/bU0aNzFsOKjDotKqb0OMEPhyB/+7SgDaT/wVjyYzrTjkeZJfPwnJh+FcAI vgh+foC6gHu5I0uy0qNraYwaKn0Crfr3JM20syYs6X/RhPoC9dLluVN6MYJI9G8srDrh nOx5Gr5YRLmfsoPcN27/4Fc3m3JjCACIm3tPw8ka5zHu6P589hr9sGMvbIsSa/J81Oq0 zsu3apC4nKEs6DvveegrbuAnZHgW9+xAWpQhv5TjJ02VLIiK+/yD+RdR6eyr7SWLEVdl cUDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:references:organization :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=ygdli/k8tJLxpKP54kqOqddMHMRUIInLK1hz5F6f5Hc=; b=ddwd2rfekXYHyWSDUfJukbRcO5XHr6F03bwtXRrEUlCtT9FU0gtMEOPw7IClXJzdwe mzuDacKVMDCHo0iZcF3fQ6evvghCybPhBc/SA97l1nrnZ/kxvFAV7/n86AAb+xM2wajc 8Dp3G7aj4xuRDXC/KLif4dsCHq4GAobXWpnByy4X5cRHkhAmaYOxLqjEJr5skTGUOcXR 8ZzcP3IZdi0MctRXIhrPVl5zprNifF7aEMNWic52xaNlfm/L8rY3FOaGRWvRVM7X85TZ sANFD23roZGnGxBKB2WzNEQVg5FMKdpdPjHE26GLoarWdluYguHHe0gR4iMvo3phVehW gK9g== X-Gm-Message-State: ALQs6tBd3SiY7ovqW/Yc+cnynthjp81xK9KHtFkE74g7XlHuTlSIJFJ5 3uipPUu8iYH289Kt58HM4ZROGQ== X-Google-Smtp-Source: AIpwx4+s0XYEPwA3KU+usfL+iwFuXt4UNaNMfDRUpeAqv8HLKx2p5SKsvxjFs7tK9ZTNInqCPUgcvQ== X-Received: by 2002:a19:cc10:: with SMTP id c16-v6mr103623lfg.62.1523012574502; Fri, 06 Apr 2018 04:02:54 -0700 (PDT) Received: from wasted.cogentembedded.com ([31.173.80.60]) by smtp.gmail.com with ESMTPSA id l1sm847983ljj.30.2018.04.06.04.02.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 06 Apr 2018 04:02:53 -0700 (PDT) Subject: [PATCH 1/4] pcie-rcar: poll PHYRDY in rcar_pcie_hw_init() From: Sergei Shtylyov To: horms@verge.net.au, bhelgaas@google.com, linux-pci@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Lorenzo Pieralisi References: <23335d95-63ca-b107-e43d-f4c2621adc2c@cogentembedded.com> Organization: Cogent Embedded Message-ID: <35e8fb4a-4b43-dac9-7a6f-cc7083c06453@cogentembedded.com> Date: Fri, 6 Apr 2018 14:02:52 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <23335d95-63ca-b107-e43d-f4c2621adc2c@cogentembedded.com> Content-Language: en-MW Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In all the R-Car gen1/2/3 manuals, we are instructed to poll PCIEPHYSR for PHYRDY=1 at an early stage of the PCIEC initialization -- while the driver only does this on R-Car H1 (polling a PHY specific register). Add the PHYRDY polling to rcar_pcie_hw_init(). Note that without the special PHY driver on the R-Car V3H the PCIEC initialization just freezes the kernel -- adding the PHYRDY polling allows the init code to exit gracefully on timeout (PHY starts powered down after reset on this SoC). Signed-off-by: Sergei Shtylyov --- drivers/pci/host/pcie-rcar.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) Index: pci/drivers/pci/host/pcie-rcar.c =================================================================== --- pci.orig/drivers/pci/host/pcie-rcar.c +++ pci/drivers/pci/host/pcie-rcar.c @@ -36,6 +36,8 @@ #define PCIECDR 0x000020 #define PCIEMSR 0x000028 #define PCIEINTXR 0x000400 +#define PCIEPHYSR 0x0007f0 +#define PHYRDY 1 #define PCIEMSITXR 0x000840 /* Transfer control */ @@ -527,6 +529,20 @@ static void phy_write_reg(struct rcar_pc phy_wait_for_ack(pcie); } +static int rcar_pcie_wait_for_phyrdy(struct rcar_pcie *pcie) +{ + unsigned int timeout = 10; + + while (timeout--) { + if (rcar_pci_read_reg(pcie, PCIEPHYSR) & PHYRDY) + return 0; + + msleep(5); + } + + return -ETIMEDOUT; +} + static int rcar_pcie_wait_for_dl(struct rcar_pcie *pcie) { unsigned int timeout = 10; @@ -551,6 +567,10 @@ static int rcar_pcie_hw_init(struct rcar /* Set mode */ rcar_pci_write_reg(pcie, 1, PCIEMSR); + err = rcar_pcie_wait_for_phyrdy(pcie); + if (err) + return err; + /* * Initial header for port config space is type 1, set the device * class to match. Hardware takes care of propagating the IDSETR