From: Kumar Gala <galak@kernel.crashing.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 07/10] pci/fsl_pci_init: Add a common PCI inbound setup function
Date: Thu, 23 Oct 2008 01:26:45 -0500 [thread overview]
Message-ID: <1224743208-11160-8-git-send-email-galak@kernel.crashing.org> (raw)
In-Reply-To: <1224743208-11160-7-git-send-email-galak@kernel.crashing.org>
Add a common setup function that determines the pci_region(s) based
on how much memory we have in the system.
Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
---
drivers/pci/fsl_pci_init.c | 81 ++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 81 insertions(+), 0 deletions(-)
diff --git a/drivers/pci/fsl_pci_init.c b/drivers/pci/fsl_pci_init.c
index f41c8aa..564459c 100644
--- a/drivers/pci/fsl_pci_init.c
+++ b/drivers/pci/fsl_pci_init.c
@@ -18,6 +18,8 @@
#include <common.h>
+DECLARE_GLOBAL_DATA_PTR;
+
/*
* PCI/PCIE Controller initialization for mpc85xx/mpc86xx soc's
*
@@ -41,6 +43,85 @@ void pciauto_postscan_setup_bridge(struct pci_controller *hose,
pci_dev_t dev, int sub_bus);
void pciauto_config_init(struct pci_controller *hose);
+#ifndef CONFIG_SYS_PCI_MEMORY_BUS
+#define CONFIG_SYS_PCI_MEMORY_BUS 0
+#endif
+
+#ifndef CONFIG_SYS_PCI_MEMORY_PHYS
+#define CONFIG_SYS_PCI_MEMORY_PHYS 0
+#endif
+
+#if defined(CONFIG_SYS_PCI_64BIT) && !defined(CONFIG_SYS_PCI64_MEMORY_BUS)
+#define CONFIG_SYS_PCI64_MEMORY_BUS (64ull*1024*1024*1024)
+#endif
+
+int fsl_pci_setup_inbound_windows(struct pci_region *r)
+{
+ struct pci_region *rgn_base = r;
+ u64 sz = min((u64)gd->ram_size, 1ull << 32);
+
+ phys_addr_t phys_start = CONFIG_SYS_PCI_MEMORY_PHYS;
+ pci_addr_t bus_start = CONFIG_SYS_PCI_MEMORY_BUS;
+ pci_size_t pci_sz = 1ull << __ilog2_u64(sz);
+
+ debug ("R0 bus_start: %llx phys_start: %llx size: %llx\n",
+ (u64)bus_start, (u64)phys_start, (u64)pci_sz);
+ pci_set_region(r++, bus_start, phys_start, pci_sz,
+ PCI_REGION_MEM | PCI_REGION_MEMORY | \
+ PCI_REGION_PREFETCH);
+
+ sz -= pci_sz;
+ bus_start += pci_sz;
+ phys_start += pci_sz;
+
+ pci_sz = 1ull << __ilog2_u64(sz);
+ if (sz) {
+ debug ("R1 bus_start: %llx phys_start: %llx size: %llx\n",
+ (u64)bus_start, (u64)phys_start, (u64)pci_sz);
+ pci_set_region(r++, bus_start, phys_start, pci_sz,
+ PCI_REGION_MEM | PCI_REGION_MEMORY | \
+ PCI_REGION_PREFETCH);
+ sz -= pci_sz;
+ bus_start += pci_sz;
+ phys_start += pci_sz;
+ }
+
+#if defined(CONFIG_PHYS_64BIT) && defined(CONFIG_SYS_PCI_64BIT)
+ pci_sz = 1ull << __ilog2_u64(gd->ram_size);
+ /* round up to the next largest power of two */
+ if (gd->ram_size > pci_sz)
+ sz = 1ull << (__ilog2_u64(gd->ram_size) + 1);
+ debug ("R64 bus_start: %llx phys_start: %llx size: %llx\n",
+ (u64)CONFIG_SYS_PCI_MEMORY_BUS,
+ (u64)CONFIG_SYS_PCI_MEMORY_PHYS,
+ (u64)pci_sz);
+ pci_set_region(r++,
+ CONFIG_SYS_PCI_MEMORY_BUS,
+ CONFIG_SYS_PCI_MEMORY_PHYS,
+ pci_sz,
+ PCI_REGION_MEM | PCI_REGION_MEMORY | \
+ PCI_REGION_PREFETCH);
+#else
+ pci_sz = 1ull << __ilog2_u64(sz);
+ if (sz) {
+ debug ("R2 bus_start: %llx phys_start: %llx size: %llx\n",
+ (u64)bus_start, (u64)phys_start, (u64)pci_sz);
+ pci_set_region(r++, bus_start, phys_start, pci_sz,
+ PCI_REGION_MEM | PCI_REGION_MEMORY | \
+ PCI_REGION_PREFETCH);
+ sz -= pci_sz;
+ bus_start += pci_sz;
+ phys_start += pci_sz;
+ }
+#endif
+
+ if (sz && (((u64)gd->ram_size) < (1ull << 32)))
+ printf("Was not able to map all of memory via "
+ "inbound windows -- %lld remaining\n", sz);
+
+ return r - rgn_base;
+}
+
void fsl_pci_init(struct pci_controller *hose)
{
u16 temp16;
--
1.5.5.1
next prev parent reply other threads:[~2008-10-23 6:26 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-23 6:26 [U-Boot] [PATCH 00/10] 85xx/85xx pci cleanup Kumar Gala
2008-10-23 6:26 ` [U-Boot] [PATCH 01/10] pci: Allow for PCI addresses to be 64-bit Kumar Gala
2008-10-23 6:26 ` [U-Boot] [PATCH 02/10] 85xx: Enable 64-bit PCI resources on all Freescale boards Kumar Gala
2008-10-23 6:26 ` [U-Boot] [PATCH 03/10] 86xx: " Kumar Gala
2008-10-23 6:26 ` [U-Boot] [PATCH 04/10] fdt: Add fdt_sizecell & fdt_addrcell helpers Kumar Gala
2008-10-23 6:26 ` [U-Boot] [PATCH 05/10] fdt: Added helper to set PCI dma-ranges property Kumar Gala
2008-10-23 6:26 ` [U-Boot] [PATCH 06/10] pci/fsl_pci_init: Enable larger address and setting inbound windows properly Kumar Gala
2008-10-23 6:26 ` Kumar Gala [this message]
2008-10-23 6:26 ` [U-Boot] [PATCH 08/10] pci/fsl_pci_init: Added fdt helper for setting up bus-ranges & dma-ranges Kumar Gala
2008-10-23 6:26 ` [U-Boot] [PATCH 09/10] 85xx: Convert all fsl_pci_init users to new APIs Kumar Gala
2008-10-23 6:26 ` [U-Boot] [PATCH 10/10] 86xx: " Kumar Gala
2008-10-24 0:41 ` Jon Loeliger
2008-10-23 11:55 ` [U-Boot] [PATCH 04/10] fdt: Add fdt_sizecell & fdt_addrcell helpers Jerry Van Baren
2008-10-23 12:04 ` Kumar Gala
2008-10-23 12:26 ` Jerry Van Baren
2008-10-23 12:59 ` Kumar Gala
2008-10-24 13:12 ` [U-Boot] [PATCH 01/10] pci: Allow for PCI addresses to be 64-bit Wolfgang Denk
2008-10-23 8:35 ` [U-Boot] [PATCH 00/10] 85xx/85xx pci cleanup Wolfgang Denk
2008-10-23 11:58 ` Kumar Gala
2008-10-24 22:48 ` Andy Fleming
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1224743208-11160-8-git-send-email-galak@kernel.crashing.org \
--to=galak@kernel.crashing.org \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox