Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp222843ybh; Fri, 13 Mar 2020 20:46:12 -0700 (PDT) X-Google-Smtp-Source: ADFU+vu1PaGWg2PIjYo8W9+c1M27CxCJOvw0+B9h0O9nrGlCeXCEj0pTJIT8TZjz3uGjLiVhJDsq X-Received: by 2002:a9d:53cc:: with SMTP id i12mr14000960oth.11.1584157572467; Fri, 13 Mar 2020 20:46:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584157572; cv=none; d=google.com; s=arc-20160816; b=rpj2753oSY4oFUOcRdPBkPHlkk54SEn1vSby4RJ4CpY5S/NdPzbuF5BxDmwAcSXYKW sliylTZUgBlh5herIidVliGi8FXRMa3Lz7Qxpj4YFVXpnKQG24TRlgxmtkxnABzTQAzK dA2MZrEEm7DSWjIYOlLzR/2NQegs+CuNBU3kTkcjh8UXR26tJ45rrBiXDPjcTYtG9+Ut o4iX+ra1GBzphP34/W4DGVf/tCT3EUfSFBmmWAtNLfodLDMBxdb9awqHbx4wNvB+feci /rHQTdlkORbyYu2TMrJ9yDJRdOP/1DHovjm1hIsP0wZNYAFIRIc/IlCVFWHnaniG2QdV llAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=AWSbJlQRcvuhLdFfdvXm7wo9VCoyiEVof78UKyRA/fQ=; b=moJfkMhuZnJY9rd1wCDiyUEJSKyIfsKR5aMD0601uvEgYwviDhJ1AWxHFpGqcoreu5 bneYaKwD6zYSoyCc+YS04SEzC2fGL2BqDlPOZiBXGcbs4vN+xJMK+Z3ctJ2T245mBx96 hzbPfBHQgydY7tZ0/CgcMQgRinrfTEf07NeiD0sTek0YZQwDENAtg8CNDjGKH0BHB1un aQbb/Hiujv5UVRbs00JwSQDjLBYIwXhpowvOg9s/jObhXgfW6U52go+239PZmqRZU6Fu cHlYD227PPyNZNnzMhKAYnPopj7VBHrMfSUFCwaDeCjJImiRF4Wzr2jeAY3XIuLLJRdx 8BmA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y2si6046440oto.123.2020.03.13.20.46.00; Fri, 13 Mar 2020 20:46:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726837AbgCNDox (ORCPT + 99 others); Fri, 13 Mar 2020 23:44:53 -0400 Received: from inva021.nxp.com ([92.121.34.21]:59952 "EHLO inva021.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726399AbgCNDov (ORCPT ); Fri, 13 Mar 2020 23:44:51 -0400 Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 52316200131; Sat, 14 Mar 2020 04:44:49 +0100 (CET) Received: from invc005.ap-rdc01.nxp.com (invc005.ap-rdc01.nxp.com [165.114.16.14]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 49C662014E0; Sat, 14 Mar 2020 04:44:39 +0100 (CET) Received: from titan.ap.freescale.net (titan.ap.freescale.net [10.192.208.233]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id BAB77402FC; Sat, 14 Mar 2020 11:44:27 +0800 (SGT) From: Xiaowei Bao To: Zhiqiang.Hou@nxp.com, Minghuan.Lian@nxp.com, mingkai.hu@nxp.com, bhelgaas@google.com, robh+dt@kernel.org, shawnguo@kernel.org, leoyang.li@nxp.com, kishon@ti.com, lorenzo.pieralisi@arm.com, roy.zang@nxp.com, amurray@thegoodpenguin.co.uk, jingoohan1@gmail.com, gustavo.pimentel@synopsys.com, andrew.murray@arm.com, linux-pci@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org Cc: Xiaowei Bao Subject: [PATCH v6 07/11] PCI: layerscape: Modify the way of getting capability with different PEX Date: Sat, 14 Mar 2020 11:30:34 +0800 Message-Id: <20200314033038.24844-8-xiaowei.bao@nxp.com> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20200314033038.24844-1-xiaowei.bao@nxp.com> References: <20200314033038.24844-1-xiaowei.bao@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The different PCIe controller in one board may be have different capability of MSI or MSIX, so change the way of getting the MSI capability, make it more flexible. Signed-off-by: Xiaowei Bao --- v2: - Remove the repeated assignment code. v3: - Use ep_func msi_cap and msix_cap to decide the msi_capable and msix_capable of pci_epc_features struct. v4: - No change. v5: - No change. v6: - No change. drivers/pci/controller/dwc/pci-layerscape-ep.c | 31 +++++++++++++++++++------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/drivers/pci/controller/dwc/pci-layerscape-ep.c b/drivers/pci/controller/dwc/pci-layerscape-ep.c index 0691d9a..9601f9c 100644 --- a/drivers/pci/controller/dwc/pci-layerscape-ep.c +++ b/drivers/pci/controller/dwc/pci-layerscape-ep.c @@ -22,6 +22,7 @@ struct ls_pcie_ep { struct dw_pcie *pci; + struct pci_epc_features *ls_epc; }; #define to_ls_pcie_ep(x) dev_get_drvdata((x)->dev) @@ -40,26 +41,31 @@ static const struct of_device_id ls_pcie_ep_of_match[] = { { }, }; -static const struct pci_epc_features ls_pcie_epc_features = { - .linkup_notifier = false, - .msi_capable = true, - .msix_capable = false, - .bar_fixed_64bit = (1 << BAR_2) | (1 << BAR_4), -}; - static const struct pci_epc_features* ls_pcie_ep_get_features(struct dw_pcie_ep *ep) { - return &ls_pcie_epc_features; + struct dw_pcie *pci = to_dw_pcie_from_ep(ep); + struct ls_pcie_ep *pcie = to_ls_pcie_ep(pci); + + return pcie->ls_epc; } static void ls_pcie_ep_init(struct dw_pcie_ep *ep) { struct dw_pcie *pci = to_dw_pcie_from_ep(ep); + struct ls_pcie_ep *pcie = to_ls_pcie_ep(pci); + struct dw_pcie_ep_func *ep_func; enum pci_barno bar; + ep_func = dw_pcie_ep_get_func_from_ep(ep, 0); + if (!ep_func) + return; + for (bar = 0; bar < PCI_STD_NUM_BARS; bar++) dw_pcie_ep_reset_bar(pci, bar); + + pcie->ls_epc->msi_capable = ep_func->msi_cap ? true : false; + pcie->ls_epc->msix_capable = ep_func->msix_cap ? true : false; } static int ls_pcie_ep_raise_irq(struct dw_pcie_ep *ep, u8 func_no, @@ -119,6 +125,7 @@ static int __init ls_pcie_ep_probe(struct platform_device *pdev) struct device *dev = &pdev->dev; struct dw_pcie *pci; struct ls_pcie_ep *pcie; + struct pci_epc_features *ls_epc; struct resource *dbi_base; int ret; @@ -130,6 +137,10 @@ static int __init ls_pcie_ep_probe(struct platform_device *pdev) if (!pci) return -ENOMEM; + ls_epc = devm_kzalloc(dev, sizeof(*ls_epc), GFP_KERNEL); + if (!ls_epc) + return -ENOMEM; + dbi_base = platform_get_resource_byname(pdev, IORESOURCE_MEM, "regs"); pci->dbi_base = devm_pci_remap_cfg_resource(dev, dbi_base); if (IS_ERR(pci->dbi_base)) @@ -140,6 +151,10 @@ static int __init ls_pcie_ep_probe(struct platform_device *pdev) pci->ops = &ls_pcie_ep_ops; pcie->pci = pci; + ls_epc->bar_fixed_64bit = (1 << BAR_2) | (1 << BAR_4), + + pcie->ls_epc = ls_epc; + platform_set_drvdata(pdev, pcie); ret = ls_add_pcie_ep(pcie, pdev); -- 2.9.5