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: 3900161 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id D47E2BF540 for ; Thu, 27 Mar 2014 22:49:15 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 10E7C201B4 for ; Thu, 27 Mar 2014 22:49:15 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1272620149 for ; Thu, 27 Mar 2014 22:49:14 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WTJ5q-0003js-RP; Thu, 27 Mar 2014 22:48:15 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WTJ5c-000485-Bz; Thu, 27 Mar 2014 22:48:00 +0000 Received: from mail-oa0-x22d.google.com ([2607:f8b0:4003:c02::22d]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WTJ57-00044n-1G for linux-arm-kernel@lists.infradead.org; Thu, 27 Mar 2014 22:47:31 +0000 Received: by mail-oa0-f45.google.com with SMTP id eb12so5183656oac.18 for ; Thu, 27 Mar 2014 15:47:07 -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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140327_184729_176826_FC1302BC X-CRM114-Status: GOOD ( 16.29 ) X-Spam-Score: -1.8 (-) Cc: linux-pci@vger.kernel.org, linus.walleij@linaro.org, linux-arm-kernel@lists.infradead.org, Rob Herring X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, 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);