Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp1524110pxb; Sun, 22 Aug 2021 20:32:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyD5wdie8UdxV7OgHAAeSDhtbUuaBAyUDSBItJYEUQFfYFNpgT0ZuEBaYkUzRGCeEkuXMVN X-Received: by 2002:a17:907:101a:: with SMTP id ox26mr33569669ejb.282.1629689528279; Sun, 22 Aug 2021 20:32:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629689528; cv=none; d=google.com; s=arc-20160816; b=vEnbLqcvv4zrJrWUd1oeY/qYQRIMstLBuG22T80VLso/ImQxOJPp1ZUvI0FdZKR3Nd mDzMlrtezlVK93AziwCdx3MoMUReRLrtVV4fSo6vOq3OfuKWQMFkQSUaU/3JOAFYd9St KYgn60A2cuLxRSlcORqDa2VkFQ+kJ7i0U2LYpcHcBWN1cEVytycXgUt3uGAwPrbzWp7u Y10pX9UBkO5krZrjGsm54jdmFFxOO/ygPK8KXTjk4UvTf6hP2GBwcX8hqnX+m+vJXXzo JEHD4+myV4AyuaihlABXh/lxHnWaLWUZGjesH4c9c5pY9Y4A91DaUQC1PoYYMVl1RxUD F2sw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=GvmPfAPBDPc0i4UKwCNTKA2NUvPO2v9p/eRn05LJcw4=; b=dgF2pq4EYh2vAzlLN8OhlTUL073WC+dCjJGY6JK17fh/270Rmr99fKyQ0tw0EAbVn/ 40zqWUMhWd8y5rQm0UXJw7tx36p6BnQTNsuWXm1MfoWSxqgwbxa9ShUcSOsIE4kIKJe2 nCr0D6OFLzS2TesjFPTCGo04wp2oXC3jG+NRBdNgfinm/mp71oVVSTCWJIpg9RVqKi2D 4mvEmI9xY4wntYWz16IGE5317vB+5M8bfsGtll7zJHRqSkbe3658RNOCbRh4anwg80q8 BWJGJDZUI9MH89Sxj4YR6iF8OGip/7cikYJP5ivDZNMikVxvBiRbwcopcul8/iLCj295 S7Ew== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l15si12830327ejg.444.2021.08.22.20.31.45; Sun, 22 Aug 2021 20:32:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234421AbhHWD3o (ORCPT + 99 others); Sun, 22 Aug 2021 23:29:44 -0400 Received: from mailgw01.mediatek.com ([60.244.123.138]:36036 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S234427AbhHWD3n (ORCPT ); Sun, 22 Aug 2021 23:29:43 -0400 X-UUID: 3bc7393a40834d968507b134c914d571-20210823 X-UUID: 3bc7393a40834d968507b134c914d571-20210823 Received: from mtkcas07.mediatek.inc [(172.21.101.84)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 2099527350; Mon, 23 Aug 2021 11:28:58 +0800 Received: from mtkcas10.mediatek.inc (172.21.101.39) by mtkmbs02n2.mediatek.inc (172.21.101.101) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 23 Aug 2021 11:28:56 +0800 Received: from localhost.localdomain (10.17.3.153) by mtkcas10.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Mon, 23 Aug 2021 11:28:55 +0800 From: Chuanjia Liu To: , , , CC: , , , , , , , , Subject: [PATCH v12 4/6] PCI: mediatek: Get pci domain and decide how to parse node Date: Mon, 23 Aug 2021 11:27:58 +0800 Message-ID: <20210823032800.1660-5-chuanjia.liu@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20210823032800.1660-1-chuanjia.liu@mediatek.com> References: <20210823032800.1660-1-chuanjia.liu@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use of_get_pci_domain_nr() to get the pci domain. If the property of "linux,pci-domain" is defined in node, we assume that the PCIe bridge is an individual bridge, hence that we only need to parse one port. Signed-off-by: Chuanjia Liu Acked-by: Ryder Lee --- drivers/pci/controller/pcie-mediatek.c | 29 +++++++++++++++----------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/drivers/pci/controller/pcie-mediatek.c b/drivers/pci/controller/pcie-mediatek.c index 19e35ac62d43..928e0983a900 100644 --- a/drivers/pci/controller/pcie-mediatek.c +++ b/drivers/pci/controller/pcie-mediatek.c @@ -1048,22 +1048,27 @@ static int mtk_pcie_setup(struct mtk_pcie *pcie) struct device *dev = pcie->dev; struct device_node *node = dev->of_node, *child; struct mtk_pcie_port *port, *tmp; - int err; + int err, slot; + + slot = of_get_pci_domain_nr(dev->of_node); + if (slot < 0) { + for_each_available_child_of_node(node, child) { + err = of_pci_get_devfn(child); + if (err < 0) { + dev_err(dev, "failed to get devfn: %d\n", err); + goto error_put_node; + } - for_each_available_child_of_node(node, child) { - int slot; + slot = PCI_SLOT(err); - err = of_pci_get_devfn(child); - if (err < 0) { - dev_err(dev, "failed to parse devfn: %d\n", err); - goto error_put_node; + err = mtk_pcie_parse_port(pcie, child, slot); + if (err) + goto error_put_node; } - - slot = PCI_SLOT(err); - - err = mtk_pcie_parse_port(pcie, child, slot); + } else { + err = mtk_pcie_parse_port(pcie, node, slot); if (err) - goto error_put_node; + return err; } err = mtk_pcie_subsys_powerup(pcie); -- 2.18.0