From patchwork Tue Nov 22 12:08:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dongdong Liu X-Patchwork-Id: 9440871 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 BAF746075D for ; Tue, 22 Nov 2016 11:52:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B3BCA2843A for ; Tue, 22 Nov 2016 11:52:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 98DE728500; Tue, 22 Nov 2016 11:52: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=-6.9 required=2.0 tests=BAYES_00,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 445CA284FE for ; Tue, 22 Nov 2016 11:52:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754042AbcKVLwl (ORCPT ); Tue, 22 Nov 2016 06:52:41 -0500 Received: from szxga02-in.huawei.com ([119.145.14.65]:28197 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753274AbcKVLw0 (ORCPT ); Tue, 22 Nov 2016 06:52:26 -0500 Received: from 172.24.1.136 (EHLO SZXEML424-HUB.china.huawei.com) ([172.24.1.136]) by szxrg02-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id DRD10520; Tue, 22 Nov 2016 19:52:17 +0800 (CST) Received: from linux-ioko.site (10.71.200.31) by SZXEML424-HUB.china.huawei.com (10.82.67.153) with Microsoft SMTP Server id 14.3.235.1; Tue, 22 Nov 2016 19:52:07 +0800 From: Dongdong Liu To: , , , , , , CC: , , , , , , , , Subject: [PATCH V6 1/2] PCI/ACPI: Provide acpi_get_rc_resources() for ARM64 platform Date: Tue, 22 Nov 2016 20:08:48 +0800 Message-ID: <1479816529-97410-2-git-send-email-liudongdong3@huawei.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1479816529-97410-1-git-send-email-liudongdong3@huawei.com> References: <1479816529-97410-1-git-send-email-liudongdong3@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.71.200.31] X-CFilter-Loop: Reflected Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The acpi_get_rc_resources() is used to get the RC register address that can not be described in MCFG. It takes the _HID&segment to look for and returns the RC address resource. Use PNP0C02 devices to describe such RC address resource. Use _UID to match segment to tell which root bus the PNP0C02 resource belong to. Signed-off-by: Dongdong Liu Signed-off-by: Tomasz Nowicki --- drivers/pci/pci-acpi.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++ drivers/pci/pci.h | 4 +++ 2 files changed, 73 insertions(+) diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c index d966d47..76fd6f4 100644 --- a/drivers/pci/pci-acpi.c +++ b/drivers/pci/pci-acpi.c @@ -29,6 +29,75 @@ 0x91, 0x17, 0xea, 0x4d, 0x19, 0xc3, 0x43, 0x4d }; +#ifdef CONFIG_ARM64 +static struct resource *acpi_get_rc_addr(struct acpi_device *adev) +{ + struct resource_entry *entry; + struct list_head list; + unsigned long flags; + int ret; + struct resource *res; + + INIT_LIST_HEAD(&list); + flags = IORESOURCE_MEM; + ret = acpi_dev_get_resources(adev, &list, + acpi_dev_filter_resource_type_cb, + (void *) flags); + if (ret <= 0) + return NULL; + + entry = list_first_entry(&list, struct resource_entry, node); + res = entry->res; + acpi_dev_free_resource_list(&list); + return res; +} + +static acpi_status acpi_match_rc(acpi_handle handle, u32 lvl, void *context, + void **retval) +{ + u16 *segment = context; + unsigned long long uid; + acpi_status status; + + status = acpi_evaluate_integer(handle, "_UID", NULL, &uid); + if (ACPI_FAILURE(status) || uid != *segment) + return AE_CTRL_DEPTH; + + *(acpi_handle *)retval = handle; + return AE_CTRL_TERMINATE; +} + +/** + * acpi_get_rc_resources() - get the RC address resource. + * @hid: HID to search for. + * @segment: PCI Segment number. + * + * Get the RC address resource that can not be described in MCFG. It takes + * the _HID&segment to look for and returns the RC address resource. Use + * _CRS of PNP0C02 devices to describe such RC address resource. Use _UID + * to match segment to tell which root bus the PNP0C02 resource belong to. + * + * Return: RC address resource. + */ +struct resource *acpi_get_rc_resources(const char *hid, u16 segment) +{ + struct acpi_device *adev; + acpi_status status; + acpi_handle handle; + int ret; + + status = acpi_get_devices(hid, acpi_match_rc, &segment, &handle); + if (ACPI_FAILURE(status)) + return -ENODEV; + + ret = acpi_bus_get_device(handle, &adev); + if (ret) + return ret; + + return acpi_get_rc_addr(adev); +} +#endif + phys_addr_t acpi_pci_root_get_mcfg_addr(acpi_handle handle) { acpi_status status = AE_NOT_EXIST; diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index 4518562..bf1dbfe 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h @@ -356,4 +356,8 @@ static inline int pci_dev_specific_reset(struct pci_dev *dev, int probe) } #endif +#if defined(CONFIG_ARM64) && defined(CONFIG_ACPI) +struct resource *acpi_get_rc_resources(const char *hid, u16 segment); +#endif + #endif /* DRIVERS_PCI_H */