From patchwork Thu Mar 27 22:46:36 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Herring X-Patchwork-Id: 3900121 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 6168E9F2E8 for ; Thu, 27 Mar 2014 22:47:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6E53B20274 for ; Thu, 27 Mar 2014 22:47:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 944CA20270 for ; Thu, 27 Mar 2014 22:47:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757090AbaC0WrH (ORCPT ); Thu, 27 Mar 2014 18:47:07 -0400 Received: from mail-ob0-f172.google.com ([209.85.214.172]:60766 "EHLO mail-ob0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756819AbaC0WrG (ORCPT ); Thu, 27 Mar 2014 18:47:06 -0400 Received: by mail-ob0-f172.google.com with SMTP id wm4so5064836obc.3 for ; Thu, 27 Mar 2014 15:47:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=XcPuPRcptq1Ahc4JlI9hDod2ox3b9Wgrgp4ia0T8icI=; b=Br3gW4tcxaOhe+98dgdphyRT2tX+hNhLj3zWVqoWl+vEUgtTW/Q9a/iVPHWCE9ePNK yloXW7b1ME22KgeluhkjP2W5fwzDfEsuujwoIU4isAgCNXL2bN83K/lDPhwOUDPgfk0/ 8eNWi+oEiw71pGCQ5IA8S99lhHIn4V+M8FZtP8z4bu1uV3rJPQYvCXez5FBJ54pYdZnx eiMEQFUmNeFcVpR5/ZnaY6NcHkn9YO/a/ubXalyy/O1KFBbiIup5N6r5LjFrbkrHk3Uw MGTSNiPyRdRC3Bn4EcHlObjMU5cKPekxAknqLqEYMs4eA7c5BBD4CKmnSP041zwCbA/g YO5Q== X-Received: by 10.182.40.37 with SMTP id u5mr3677942obk.41.1395960425778; Thu, 27 Mar 2014 15:47:05 -0700 (PDT) Received: from localhost.localdomain (72-48-77-163.dyn.grandenetworks.net. [72.48.77.163]) by mx.google.com with ESMTPSA id c9sm5620887obq.20.2014.03.27.15.47.04 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 27 Mar 2014 15:47:05 -0700 (PDT) From: Rob Herring To: Bjorn Helgaas , Russell King , Arnd Bergmann , liviu.dudau@arm.com Cc: linus.walleij@linaro.org, linux-arm-kernel@lists.infradead.org, linux-pci@vger.kernel.org, Rob Herring Subject: [PATCH 1/3] ARM: hackup pcibios support for commmon bridge code Date: Thu, 27 Mar 2014 17:46:36 -0500 Message-Id: <1395960398-4238-2-git-send-email-robherring2@gmail.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1395960398-4238-1-git-send-email-robherring2@gmail.com> References: <1395960398-4238-1-git-send-email-robherring2@gmail.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Rob Herring Signed-off-by: Rob Herring --- arch/arm/kernel/bios32.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/arch/arm/kernel/bios32.c b/arch/arm/kernel/bios32.c index 317da88..31ec14a 100644 --- a/arch/arm/kernel/bios32.c +++ b/arch/arm/kernel/bios32.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -337,6 +338,15 @@ void pcibios_fixup_bus(struct pci_bus *bus) list_for_each_entry(dev, &bus->devices, bus_list) { u16 cmd; + /* Ignore fully discovered devices */ + if (dev->is_added) + continue; + + set_dev_node(&dev->dev, pcibus_to_node(dev->bus)); + + /* Read default IRQs and fixup if necessary */ + dev->irq = of_irq_parse_and_map_pci(dev, 0, 0); + pci_read_config_word(dev, PCI_COMMAND, &cmd); cmd |= features; pci_write_config_word(dev, PCI_COMMAND, cmd); @@ -681,3 +691,56 @@ void __init pci_map_io_early(unsigned long pfn) pci_io_desc.pfn = pfn; iotable_init(&pci_io_desc, 1); } + +struct ioresource { + struct list_head list; + phys_addr_t start; + resource_size_t size; +}; + +static LIST_HEAD(io_list); + +int pci_register_io_range(phys_addr_t address, resource_size_t size) +{ + struct ioresource *res; + resource_size_t allocated_size = 0; + + /* find if the range has not been already allocated */ + list_for_each_entry(res, &io_list, list) { + if (address >= res->start && + address + size <= res->start + size) + return 0; + allocated_size += res->size; + } + + /* range not already registered, check for space */ + if (allocated_size + size > IO_SPACE_LIMIT) + return -E2BIG; + + /* add the range in the list */ + res = kzalloc(sizeof(*res), GFP_KERNEL); + if (!res) + return -ENOMEM; + res->start = address; + res->size = size; + + list_add_tail(&res->list, &io_list); + + return 0; +} +EXPORT_SYMBOL_GPL(pci_register_io_range); + +unsigned long pci_address_to_pio(phys_addr_t address) +{ + struct ioresource *res; + + list_for_each_entry(res, &io_list, list) { + if (address >= res->start && + address < res->start + res->size) { + return res->start - address; + } + } + + return (unsigned long)-1; +} +EXPORT_SYMBOL_GPL(pci_address_to_pio);