X-Received: by 2002:a17:90b:4c50:b0:1b5:58fc:5f07 with SMTP id np16-20020a17090b4c5000b001b558fc5f07mr2278077pjb.94.1645504547265; Mon, 21 Feb 2022 20:35:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645504547; cv=none; d=google.com; s=arc-20160816; b=fyLDsRSEA3qAbX1h388ZUe2QZlq+uCgkLNH7aubqAjVtupdqsXWJimupocdoK2VVQu t+LI4zULEo8l8fzJfCzNrnb7hpl1zIqRgh7RvRCZ6dmREIdYKXddjhWtXVlb7BDqy+zq AhTq2yyR7eTEqnw1WdrwVecXXLrUxHxamkpStvJ2m4uBrJo3gQNyoVk5RubEaGb5Ni7y HoPsQShO+IXQSgMyOLtMpnynGmJixk92bSrD7VQ2lGpPgljVn71WbqyH53WPgafQ7NTo /07rqwaYxS5FtzJkUrpCbKXJs/9ljx0tI9mrFo3kxdnZFWssRWd03p/xdEwT1xSY2upR Eb2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=O+z4QPOczN9/wGswTzELt2PHSGEcQK+z4ZSzNntmhXU=; b=eAtcSEjjLPIr+7VEQFnDt0afVvZNeAjfvhUE+pFTdsUdJNlT3NBx/FpIDNkYSIwJWJ ++vvh6IdcxtB4GiANFLPYsfmmej8Ywf817TspCQsAEvL4s7KvA2q6QmiN0WyyRLLu0do eoGfCR4Ktjv1z+BGG02O/wnOjcDTKz1u7NH6j3XeFXMwb5ttIMWyLBuK+5/qI14L8kvi ABsG9znbGhbYMJNzoObbL+io6CDBXy2FyixstH7XoCFm9af9ieAfZC6n25v88IOTzQKP 7LlPT2VNnczme19R8xpc3f4lk+S93MddLgVjO3uQQ62z1fQsdgvPbu9j4hr3z1I0/pXy BqYA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=codethink.co.uk Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id q5si36635054plh.144.2022.02.21.20.35.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Feb 2022 20:35:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=codethink.co.uk Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 01810723D2; Mon, 21 Feb 2022 20:24:08 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233842AbiBUUii (ORCPT + 99 others); Mon, 21 Feb 2022 15:38:38 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:53940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233815AbiBUUih (ORCPT ); Mon, 21 Feb 2022 15:38:37 -0500 Received: from imap2.colo.codethink.co.uk (imap2.colo.codethink.co.uk [78.40.148.184]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 665A3237D2; Mon, 21 Feb 2022 12:38:13 -0800 (PST) Received: from cpc152649-stkp13-2-0-cust121.10-2.cable.virginm.net ([86.15.83.122] helo=rainbowdash) by imap2.colo.codethink.co.uk with esmtpsa (Exim 4.92 #3 (Debian)) id 1nMFRc-0001sl-R8; Mon, 21 Feb 2022 20:38:04 +0000 Received: from ben by rainbowdash with local (Exim 4.95) (envelope-from ) id 1nMFRc-005amP-8f; Mon, 21 Feb 2022 20:38:04 +0000 From: Ben Dooks To: paul.walmsley@sifive.com, greentime.hu@sifive.com Cc: lorenzo.pieralisi@arm.com, robh@kernel.org, kw@linux.com, bhelgaas@google.com, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, Ben Dooks Subject: [[PATCHv3]] PCI: fu740: Force gen1 for initial device probe Date: Mon, 21 Feb 2022 20:38:03 +0000 Message-Id: <20220221203803.1333012-1-ben.dooks@codethink.co.uk> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The fu740 PCIe core does not probe any devices on the SiFive Unmatched board without this fix from U-Boot (or having U-Boot explicitly start the PCIe via either boot-script or user command). The fix claims to set the link-speed to gen1 to get the probe to work. As this is a copy from U-Boot, the code is assumed to be correct and does fix the issue on the Unmatched. The code is at: https://source.denx.de/u-boot/u-boot/-/blob/master/drivers/pci/pcie_dw_sifive.c#L271 The code has been this way since the driver was commited in: https://source.denx.de/u-boot/u-boot/-/commit/416395c772018c6bf52aad36aca163115001793f Signed-off-by: Ben Dooks --- drivers/pci/controller/dwc/pcie-fu740.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/drivers/pci/controller/dwc/pcie-fu740.c b/drivers/pci/controller/dwc/pcie-fu740.c index 842b7202b96e..19501ec8c487 100644 --- a/drivers/pci/controller/dwc/pcie-fu740.c +++ b/drivers/pci/controller/dwc/pcie-fu740.c @@ -177,11 +177,30 @@ static void fu740_pcie_init_phy(struct fu740_pcie *afp) fu740_phyregwrite(1, PCIEX8MGMT_PHY_LANE3_BASE, PCIEX8MGMT_PHY_INIT_VAL, afp); } +/* This is copied from u-boot. Force system to gen1 otherwise nothing probes + * as found on the SiFive Unmatched board. + */ +static void fu740_pcie_force_gen1(struct dw_pcie *dw, struct fu740_pcie *afp ) +{ + unsigned val; + + dw_pcie_dbi_ro_wr_en(dw); + + val = dw_pcie_readl_dbi(dw, 0x70 + PCI_EXP_LNKCAP); + pr_info("%s: link-cap was %08x\n", __func__, val); + dw_pcie_writel_dbi(dw, 0x70 + PCI_EXP_LNKCAP, val | 0xf); + + dw_pcie_dbi_ro_wr_dis(dw); +} + static int fu740_pcie_start_link(struct dw_pcie *pci) { struct device *dev = pci->dev; struct fu740_pcie *afp = dev_get_drvdata(dev); + /* Force PCIe gen1 otherwise Unmatched board does not probe */ + fu740_pcie_force_gen1(pci, afp); + /* Enable LTSSM */ writel_relaxed(0x1, afp->mgmt_base + PCIEX8MGMT_APP_LTSSM_ENABLE); return 0; -- 2.34.1