From patchwork Tue Jun 25 23:05:51 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 2781421 Return-Path: X-Original-To: patchwork-linux-arm@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 A8F309F968 for ; Tue, 25 Jun 2013 23:07:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BDDA32022B for ; Tue, 25 Jun 2013 23:07:07 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A148220226 for ; Tue, 25 Jun 2013 23:07:06 +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 1UrcJn-0005Tq-9A; Tue, 25 Jun 2013 23:06:35 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UrcJf-0007Hw-2e; Tue, 25 Jun 2013 23:06:27 +0000 Received: from mail-la0-x231.google.com ([2a00:1450:4010:c03::231]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UrcJW-0007GB-Fc for linux-arm-kernel@lists.infradead.org; Tue, 25 Jun 2013 23:06:20 +0000 Received: by mail-la0-f49.google.com with SMTP id ea20so12801743lab.36 for ; Tue, 25 Jun 2013 16:05:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:x-gm-message-state; bh=amiKoGAq2rB7T7vroHAWGxxa1rUyOyJ7TDfK5I7fVLk=; b=FXv0UZD1ieOZ7ClRUBXTh5hFSNfFoEOJIxjOknr7OPFUWin+QllEqP5lUwX/2wMuHa +CJPIZgYz/hXFY7ktayXRTk1rw1ICJtC76mCZkLiSP3ORJIcIdN9ri7Bllm6lGNMyymG XwyYDGbeb0zJNbBAaiLPLQlYn98rJZvEqmQNZVo9wqV31CKf12czlinhyGzYJmlDhqhk z5VNtiNWgyt+Nu9boeuCJycEGJSFRIlaTDnxISRQZtI1Mt3L02/DM/v7sa/znydrS1nT JSXWRHmLR0ZXIw9M3jqPeiC1wzXi6lfD4xid99N9nDHnh3GUcxhO3Ks8lMqBiDpx/HI1 QOCg== X-Received: by 10.112.189.101 with SMTP id gh5mr843036lbc.73.1372201556183; Tue, 25 Jun 2013 16:05:56 -0700 (PDT) Received: from localhost.localdomain (c83-249-208-144.bredband.comhem.se. [83.249.208.144]) by mx.google.com with ESMTPSA id et10sm9533669lbc.6.2013.06.25.16.05.54 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 25 Jun 2013 16:05:55 -0700 (PDT) From: Linus Walleij To: arm@kernel.org Subject: [PATCH 2/3] ARM: integrator: let pciv3 use mem/premem from device tree Date: Wed, 26 Jun 2013 01:05:51 +0200 Message-Id: <1372201551-25984-1-git-send-email-linus.walleij@linaro.org> X-Mailer: git-send-email 1.8.1.4 X-Gm-Message-State: ALoCoQlvKhdVYam8SqcKd5tQ4rmcXHlx1BP47b1t7xbDEAK3NO1+YZ6Ibjsfhi+odhum5AdJntMc X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130625_190618_881231_0D744760 X-CRM114-Status: GOOD ( 11.97 ) X-Spam-Score: -1.9 (-) Cc: Linus Walleij , linux-arm-kernel@lists.infradead.org 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=-5.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, 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 Instead of relying on the hard-coded mem/premem bases for the PCI side, read in these from the device tree in the DT probe path. Hard-code the old values on the non-DT probe path. Introduce some static locals to hold these addresses instead of the earlier static #defines. Reported-by: Arnd Bergmann Signed-off-by: Linus Walleij --- arch/arm/mach-integrator/pci_v3.c | 46 +++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/arch/arm/mach-integrator/pci_v3.c b/arch/arm/mach-integrator/pci_v3.c index a0e069d..bef1005 100644 --- a/arch/arm/mach-integrator/pci_v3.c +++ b/arch/arm/mach-integrator/pci_v3.c @@ -52,7 +52,8 @@ * the V3 only has two windows (therefore we need to map stuff on the fly), * we maintain the same addresses, even if they're not mapped. */ -#define PHYS_PCI_MEM_BASE 0x40000000 /* 512M */ +#define PHYS_PCI_MEM_BASE 0x40000000 /* 256M */ +#define PHYS_PCI_PRE_BASE 0x50000000 /* 256M */ #define PHYS_PCI_IO_BASE 0x60000000 /* 16M */ #define PHYS_PCI_CONFIG_BASE 0x61000000 /* 16M */ #define PHYS_PCI_V3_BASE 0x62000000 /* 64K */ @@ -285,10 +286,16 @@ /* Filled in by probe */ static void __iomem *pci_v3_base; +/* CPU side memory ranges */ static struct resource conf_mem; /* FIXME: remap this instead of static map */ static struct resource io_mem; static struct resource non_mem; static struct resource pre_mem; +/* PCI side memory ranges */ +static u64 non_mem_pci; +static u64 non_mem_pci_sz; +static u64 pre_mem_pci; +static u64 pre_mem_pci_sz; // V3 access routines #define v3_writeb(o,v) __raw_writeb(v, pci_v3_base + (unsigned int)(o)) @@ -354,19 +361,6 @@ static struct resource pre_mem; */ static DEFINE_RAW_SPINLOCK(v3_lock); -#define PCI_BUS_NONMEM_START 0x00000000 -#define PCI_BUS_NONMEM_SIZE SZ_256M - -#define PCI_BUS_PREMEM_START PCI_BUS_NONMEM_START + PCI_BUS_NONMEM_SIZE -#define PCI_BUS_PREMEM_SIZE SZ_256M - -#if PCI_BUS_NONMEM_START & 0x000fffff -#error PCI_BUS_NONMEM_START must be megabyte aligned -#endif -#if PCI_BUS_PREMEM_START & 0x000fffff -#error PCI_BUS_PREMEM_START must be megabyte aligned -#endif - #undef V3_LB_BASE_PREFETCH #define V3_LB_BASE_PREFETCH 0 @@ -453,7 +447,7 @@ static void v3_close_config_window(void) v3_writel(V3_LB_BASE1, v3_addr_to_lb_base(pre_mem.start) | V3_LB_BASE_ADR_SIZE_256MB | V3_LB_BASE_PREFETCH | V3_LB_BASE_ENABLE); - v3_writew(V3_LB_MAP1, v3_addr_to_lb_map(PCI_BUS_PREMEM_START) | + v3_writew(V3_LB_MAP1, v3_addr_to_lb_map(pre_mem_pci) | V3_LB_MAP_TYPE_MEM_MULTIPLE); /* @@ -694,7 +688,7 @@ static void __init pci_v3_preinit(void) */ v3_writel(V3_LB_BASE0, v3_addr_to_lb_base(non_mem.start) | V3_LB_BASE_ADR_SIZE_256MB | V3_LB_BASE_ENABLE); - v3_writew(V3_LB_MAP0, v3_addr_to_lb_map(PCI_BUS_NONMEM_START) | + v3_writew(V3_LB_MAP0, v3_addr_to_lb_map(non_mem_pci) | V3_LB_MAP_TYPE_MEM); /* @@ -704,7 +698,7 @@ static void __init pci_v3_preinit(void) v3_writel(V3_LB_BASE1, v3_addr_to_lb_base(pre_mem.start) | V3_LB_BASE_ADR_SIZE_256MB | V3_LB_BASE_PREFETCH | V3_LB_BASE_ENABLE); - v3_writew(V3_LB_MAP1, v3_addr_to_lb_map(PCI_BUS_PREMEM_START) | + v3_writew(V3_LB_MAP1, v3_addr_to_lb_map(pre_mem_pci) | V3_LB_MAP_TYPE_MEM_MULTIPLE); /* @@ -905,11 +899,15 @@ static int __init pci_v3_dtprobe(struct platform_device *pdev, } if ((range.flags & IORESOURCE_MEM) && !(range.flags & IORESOURCE_PREFETCH)) { + non_mem_pci = range.pci_addr; + non_mem_pci_sz = range.size; of_pci_range_to_resource(&range, np, &non_mem); non_mem.name = "PCIv3 non-prefetched mem"; } if ((range.flags & IORESOURCE_MEM) && (range.flags & IORESOURCE_PREFETCH)) { + pre_mem_pci = range.pci_addr; + pre_mem_pci_sz = range.size; of_pci_range_to_resource(&range, np, &pre_mem); pre_mem.name = "PCIv3 prefetched mem"; } @@ -976,16 +974,18 @@ static int __init pci_v3_probe(struct platform_device *pdev) io_mem.end = PHYS_PCI_IO_BASE + SZ_16M - 1; io_mem.flags = IORESOURCE_MEM; + non_mem_pci = 0x00000000; + non_mem_pci_sz = SZ_256M; non_mem.name = "PCIv3 non-prefetched mem"; - non_mem.start = PHYS_PCI_MEM_BASE + PCI_BUS_NONMEM_START; - non_mem.end = PHYS_PCI_MEM_BASE + PCI_BUS_NONMEM_START + - PCI_BUS_NONMEM_SIZE - 1; + non_mem.start = PHYS_PCI_MEM_BASE; + non_mem.end = PHYS_PCI_MEM_BASE + SZ_256M - 1; non_mem.flags = IORESOURCE_MEM; + pre_mem_pci = 0x10000000; + pre_mem_pci_sz = SZ_256M; pre_mem.name = "PCIv3 prefetched mem"; - pre_mem.start = PHYS_PCI_MEM_BASE + PCI_BUS_PREMEM_START; - pre_mem.end = PHYS_PCI_MEM_BASE + PCI_BUS_PREMEM_START + - PCI_BUS_PREMEM_SIZE - 1; + pre_mem.start = PHYS_PCI_PRE_BASE + SZ_256M; + pre_mem.end = PHYS_PCI_PRE_BASE + SZ_256M - 1; pre_mem.flags = IORESOURCE_MEM | IORESOURCE_PREFETCH; pci_v3.map_irq = pci_v3_map_irq;