From patchwork Sun Apr 8 17:59:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergei Shtylyov X-Patchwork-Id: 10328449 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 993986053C for ; Sun, 8 Apr 2018 17:59:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 86FD328862 for ; Sun, 8 Apr 2018 17:59:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7335228AA7; Sun, 8 Apr 2018 17:59:42 +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 2518228887 for ; Sun, 8 Apr 2018 17:59:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752077AbeDHR7l (ORCPT ); Sun, 8 Apr 2018 13:59:41 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:54548 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751775AbeDHR7k (ORCPT ); Sun, 8 Apr 2018 13:59:40 -0400 Received: by mail-wm0-f66.google.com with SMTP id r191so13332334wmg.4 for ; Sun, 08 Apr 2018 10:59:39 -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=nopDySNFV0NEOamYn/DvQTNQPlCSMlbuO9WFtD4YsvaUMZLzx/kaQsAyi8ZPkS+H2z Il/47YCq6lexRpM67dobPZRSFkRwNK5GlvHdj4tEz4rF4AaE967mJmsriH36mB363g0s pZLidPKdHtaiGeF+Zt+ZAuXiTS9n/3gLhUSiKbA1UUGKv7SCIZaET6JccZBbiL1ND4xz fMUyHBxdCkk7p2+cBCDkJzxEvz9ieZW5iPv71aXCrbO5q0IGa2RsB8vIlnt3ugyVIXyh 9/8xcNwprxuyt/EhdFCXpUFALajl8bu2d0O5PUjQQa3moXtYMR+jX8ZYbE8f6DWEVc/a /lLA== 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=LQpzfHZlF2qYR7k6xzcbboV3zWsH9A0BF2Xg3hb7zmCpuPA2CKyTDK/RCdGkueWwWe eupa8vfZ1CB5OVm7ffsuCqf4SReKQtdOSckvZ6ZoXxTktWb5zMMywDT5q9e4kZ4h2h3l BARej3fz2lBf9LAOcmXDFEUKvETBDVTB6zbmXfJkn+eQFV3RM0Ua1O+XiVQ9jGeHG9FH dCnlj1W27eSO9AR18PSfJ76Ma+7FGwF8oUJkaRD0UYf/3gcXxXKpVZHBjV8ckLcSMxV+ FAL5350OWZNHK6cPPXal8FsdpxZCW+a0PKNTwxMNBTsgtf1eved9+AaTD54KvMtntPsl SMRw== X-Gm-Message-State: AElRT7G+MpqrJ25odt6cNnRO4kjTUAWlZf0SMIzsy1avUESAtHLziSJ8 H0nLtUQj1kPa3v4P9FGipCcP0A== X-Google-Smtp-Source: AIpwx49Gw9C+aCMfQB4MUajufOHnWWDUDEHrwjxiwcpe635uo7ZCiYcn2xTQ/af91Tllg39mhwq+Xg== X-Received: by 10.46.151.149 with SMTP id y21mr21299702lji.64.1523210379143; Sun, 08 Apr 2018 10:59:39 -0700 (PDT) Received: from wasted.cogentembedded.com ([31.173.81.34]) by smtp.gmail.com with ESMTPSA id 1sm2538975lje.38.2018.04.08.10.59.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 08 Apr 2018 10:59:38 -0700 (PDT) Subject: [PATCH v2 1/5] 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: <26e803ca-06b6-28c5-b87c-fc639b322d6f@cogentembedded.com> Organization: Cogent Embedded Message-ID: <7fc00e4d-68ee-3092-a705-292140d4e6df@cogentembedded.com> Date: Sun, 8 Apr 2018 20:59:37 +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: <26e803ca-06b6-28c5-b87c-fc639b322d6f@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