Skip to contentSkip to conversation

Make MPC8641's PCI/PCI-E driver a common driver for many FSL parts.

PATCH New Jon Loeliger 1 participant 2 messages Jul 18, 2007 – Aug 2, 2007

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Make MPC8641's PCI/PCI-E driver a common driver for many FSL parts.

From: Ed Swarthout <[email protected]>

All of the PCI/PCI-Express driver and initialization code that was in the MPC8641HPCN port has now been moved into the common drivers/fsl_pci_init.c. In a subsequent patch, this will be utilized by the 85xx ports as well.

Common PCI-E IMMAP register blocks for FSL 85xx/86xx are added.

Also enable the second PCI-Express controller on 8641 by getting its BATS and CFG_ setup right.

---

Wolfgang,

Please apply this to the testing repository as it depends on my previous PCI/PCI-E changes already applied there. I have built and tested this on the 8641 from u-boot-testing.

Thanks,
jdl

 board/mpc8641hpcn/mpc8641hpcn.c |  161 ++++++++++++++++++++++++-------
 board/mpc8641hpcn/u-boot.lds    |    1 -
 cpu/mpc86xx/Makefile            |    3 +-
 cpu/mpc86xx/pci.c               |  146 ----------------------------
 cpu/mpc86xx/pcie_indirect.c     |  199 ---------------------------------------
 drivers/Makefile                |    2 +-
 drivers/fsl_pci_init.c          |  176 ++++++++++++++++++++++++++++++++++
 include/asm-ppc/immap_fsl_pci.h |  150 +++++++++++++++++++++++++++++
 include/configs/MPC8641HPCN.h   |   41 +++++----
 include/pci.h                   |    6 +
 10 files changed, 482 insertions(+), 403 deletions(-)
 delete mode 100644 cpu/mpc86xx/pci.c
 delete mode 100644 cpu/mpc86xx/pcie_indirect.c
 create mode 100644 drivers/fsl_pci_init.c
 create mode 100644 include/asm-ppc/immap_fsl_pci.h
board/mpc8641hpcn/mpc8641hpcn.c +124 -37
index 7d7e2af..d8a4b1f 100644
@@ -11,7 +11,7 @@
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
@@ -24,6 +24,7 @@
 #include <pci.h>
 #include <asm/processor.h>
 #include <asm/immap_86xx.h>
+#include <asm/immap_fsl_pci.h>
 #include <spd.h>
 #include <asm/io.h>
 
@@ -55,35 +56,6 @@ int checkboard(void)
 {
 	puts("Board: MPC8641HPCN\n");
 
-#ifdef CONFIG_PCI
-
-	volatile immap_t *immap = (immap_t *) CFG_CCSRBAR;
-	volatile ccsr_gur_t *gur = &immap->im_gur;
-	volatile ccsr_pex_t *pex1 = &immap->im_pex1;
-
-	uint devdisr = gur->devdisr;
-	uint io_sel = (gur->pordevsr & MPC86xx_PORDEVSR_IO_SEL) >> 16;
-	uint host1_agent = (gur->porbmsr & MPC86xx_PORBMSR_HA) >> 17;
-	uint pex1_agent = (host1_agent == 0) || (host1_agent == 1);
-
-	if ((io_sel == 2 || io_sel == 3 || io_sel == 5
-	     || io_sel == 6 || io_sel == 7 || io_sel == 0xF)
-	    && !(devdisr & MPC86xx_DEVDISR_PCIEX1)) {
-		debug("PCI-EXPRESS 1: %s \n", pex1_agent ? "Agent" : "Host");
-		debug("0x%08x=0x%08x ", &pex1->pme_msg_det, pex1->pme_msg_det);
-		if (pex1->pme_msg_det) {
-			pex1->pme_msg_det = 0xffffffff;
-			debug(" with errors.  Clearing.  Now 0x%08x",
-			      pex1->pme_msg_det);
-		}
-		debug("\n");
-	} else {
-		puts("PCI-EXPRESS 1: Disabled\n");
-	}
-
-#else
-	puts("PCI-EXPRESS1: Disabled\n");
-#endif
 
 	return 0;
 }
@@ -219,21 +191,136 @@ static struct pci_config_table pci_fsl86xxads_config_table[] = {
 #endif
 
 
-static struct pci_controller hose = {
+static struct pci_controller pci1_hose = {
 #ifndef CONFIG_PCI_PNP
-      config_table:pci_mpc86xxcts_config_table,
+	config_table:pci_mpc86xxcts_config_table
 #endif
 };
-
 #endif /* CONFIG_PCI */
 
+#ifdef CONFIG_PCI2
+static struct pci_controller pci2_hose;
+#endif	/* CONFIG_PCI2 */
+
+int first_free_busno = 0;
+
+
 void pci_init_board(void)
 {
-#ifdef CONFIG_PCI
-	extern void pci_mpc86xx_init(struct pci_controller *hose);
+	volatile immap_t *immap = (immap_t *) CFG_CCSRBAR;
+	volatile ccsr_gur_t *gur = &immap->im_gur;
+	uint devdisr = gur->devdisr;
+	uint io_sel = (gur->pordevsr & MPC86xx_PORDEVSR_IO_SEL) >> 16;
+
+#ifdef CONFIG_PCI1
+{
+	volatile ccsr_fsl_pci_t *pci = (ccsr_fsl_pci_t *) CFG_PCI1_ADDR;
+	extern void fsl_pci_init(struct pci_controller *hose);
+	struct pci_controller *hose = &pci1_hose;
+	uint host1_agent = (gur->porbmsr & MPC86xx_PORBMSR_HA) >> 17;
+	uint pex1_agent = (host1_agent == 0) || (host1_agent == 1);
+
+	if ((io_sel == 2 || io_sel == 3 || io_sel == 5
+	     || io_sel == 6 || io_sel == 7 || io_sel == 0xF)
+	    && !(devdisr & MPC86xx_DEVDISR_PCIEX1)) {
+		debug("PCI-EXPRESS 1: %s \n", pex1_agent ? "Agent" : "Host");
+		debug("0x%08x=0x%08x ", &pci->pme_msg_det, pci->pme_msg_det);
+		if (pci->pme_msg_det) {
+			pci->pme_msg_det = 0xffffffff;
+			debug(" with errors.  Clearing.  Now 0x%08x",
+			      pci->pme_msg_det);
+		}
+		debug("\n");
+
+		/* inbound */
+		pci_set_region(hose->regions + 0,
+			       CFG_PCI_MEMORY_BUS,
+			       CFG_PCI_MEMORY_PHYS,
+			       CFG_PCI_MEMORY_SIZE,
+			       PCI_REGION_MEM | PCI_REGION_MEMORY);
+
+		/* outbound memory */
+		pci_set_region(hose->regions + 1,
+			       CFG_PCI1_MEM_BASE,
+			       CFG_PCI1_MEM_PHYS,
+			       CFG_PCI1_MEM_SIZE,
+			       PCI_REGION_MEM);
+
+		/* outbound io */
+		pci_set_region(hose->regions + 2,
+			       CFG_PCI1_IO_BASE,
+			       CFG_PCI1_IO_PHYS,
+			       CFG_PCI1_IO_SIZE,
+			       PCI_REGION_IO);
+
+		hose->region_count = 3;
+
+		hose->first_busno=first_free_busno;
+		pci_setup_indirect(hose, (int) &pci->cfg_addr, (int) &pci->cfg_data);
+
+		fsl_pci_init(hose);
+
+		first_free_busno=hose->last_busno+1;
+		printf ("    PCI-EXPRESS 1 on bus %02x - %02x\n",
+			hose->first_busno,hose->last_busno);
+
+		/*
+		 * Activate ULI1575 legacy chip by performing a fake
+		 * memory access.  Needed to make ULI RTC work.
+		 */
+		in_be32(CFG_PCI1_MEM_BASE + CFG_PCI1_MEM_SIZE - 0x1000000);
+
+	} else {
+		puts("PCI-EXPRESS 1: Disabled\n");
+	}
+}
+#else
+	puts("PCI-EXPRESS1: Disabled\n");
+#endif /* CONFIG_PCI1 */
+
+#ifdef CONFIG_PCI2
+{
+	volatile ccsr_fsl_pci_t *pci = (ccsr_fsl_pci_t *) CFG_PCI2_ADDR;
+	extern void fsl_pci_init(struct pci_controller *hose);
+	struct pci_controller *hose = &pci2_hose;
+
+
+	/* inbound */
+	pci_set_region(hose->regions + 0,
+		       CFG_PCI_MEMORY_BUS,
+		       CFG_PCI_MEMORY_PHYS,
+		       CFG_PCI_MEMORY_SIZE,
+		       PCI_REGION_MEM | PCI_REGION_MEMORY);
+
+	/* outbound memory */
+	pci_set_region(hose->regions + 1,
+		       CFG_PCI2_MEM_BASE,
+		       CFG_PCI2_MEM_PHYS,
+		       CFG_PCI2_MEM_SIZE,
+		       PCI_REGION_MEM);
+
+	/* outbound io */
+	pci_set_region(hose->regions + 2,
+		       CFG_PCI2_IO_BASE,
+		       CFG_PCI2_IO_PHYS,
+		       CFG_PCI2_IO_SIZE,
+		       PCI_REGION_IO);
+
+	hose->region_count = 3;
+
+	hose->first_busno=first_free_busno;
+	pci_setup_indirect(hose, (int) &pci->cfg_addr, (int) &pci->cfg_data);
+
+	fsl_pci_init(hose);
+
+	first_free_busno=hose->last_busno+1;
+	printf ("    PCI-EXPRESS 2 on bus %02x - %02x\n",
+		hose->first_busno,hose->last_busno);
+}
+#else
+	puts("PCI-EXPRESS 2: Disabled\n");
+#endif /* CONFIG_PCI2 */
 
-	pci_mpc86xx_init(&hose);
-#endif /* CONFIG_PCI */
 }
 
 #if defined(CONFIG_OF_FLAT_TREE) && defined(CONFIG_OF_BOARD_SETUP)
board/mpc8641hpcn/u-boot.lds +0 -1
index 34b50e4..e4792ef 100644
@@ -57,7 +57,6 @@ SECTIONS
     cpu/mpc86xx/cpu_init.o (.text)
     cpu/mpc86xx/cpu.o (.text)
     cpu/mpc86xx/speed.o (.text)
-    cpu/mpc86xx/pci.o (.text)
     common/dlmalloc.o (.text)
     lib_generic/crc32.o (.text)
     lib_ppc/extable.o (.text)
cpu/mpc86xx/Makefile +2 -1
index fffcfd2..6d9300e 100644
@@ -1,4 +1,5 @@
 #
+# Copyright 2007 Freescale Semiconductor, Inc.
 # (C) Copyright 2002,2003 Motorola Inc.
 # Xianghua Xiao,X.Xiao at motorola.com
 #
@@ -30,7 +31,7 @@ LIB	= $(obj)lib$(CPU).a
 START	= start.o #resetvec.o
 SOBJS	= cache.o
 COBJS	= traps.o cpu.o cpu_init.o speed.o interrupts.o \
-	  pci.o pcie_indirect.o spd_sdram.o
+	  spd_sdram.o
 
 SRCS	:= $(START:.o=.S) $(SOBJS:.o=.S) $(COBJS:.o=.c)
 OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
cpu/mpc86xx/pci.c deleted +0 -146

146 lines not on this page · raw message

cpu/mpc86xx/pcie_indirect.c deleted +0 -199

199 lines not on this page · raw message

drivers/Makefile +1 -1
index 48fd4ea..fa2e86f 100644
@@ -52,7 +52,7 @@ COBJS	= 3c589.o 5701rls.o ali512x.o ata_piix.o atmel_usart.o \
 	  ks8695eth.o \
 	  pxa_pcmcia.o mpc8xx_pcmcia.o tqm8xx_pcmcia.o	\
 	  rpx_pcmcia.o \
-	  fsl_i2c.o
+	  fsl_i2c.o fsl_pci_init.o
 
 SRCS	:= $(COBJS:.o=.c)
 OBJS	:= $(addprefix $(obj),$(COBJS))
drivers/fsl_pci_init.c new file +176 -0

176 lines not on this page · raw message

include/asm-ppc/immap_fsl_pci.h new file +150 -0

150 lines not on this page · raw message

include/configs/MPC8641HPCN.h +23 -18

86 lines not on this page · raw message

include/pci.h +6 -0
index 7c9a0e3..8e5dacc 100644
@@ -302,6 +302,12 @@
 #define PCI_MAX_PCI_DEVICES	32
 #define PCI_MAX_PCI_FUNCTIONS	8
 
+#define PCI_DCR		0x54    /* PCIe Device Control Register */
+#define PCI_DSR		0x56    /* PCIe Device Status Register */
+#define PCI_LSR		0x5e    /* PCIe Link Status Register */
+#define PCI_LTSSM	0x404   /* PCIe Link Training, Status State Machine */
+#define  PCI_LTSSM_L0	0x16    /* L0 state */
+
 /* Include the ID list */
 
 #include <pci_ids.h>
Signature · 1 line
1.5.0.3
#1 lore raw

PATCH 1/1 Make MPC8641's PCI/PCI-E driver a common driver for many FSL parts.

Quoted 27 lines · Jon Loeliger

From: Ed Swarthout <[email protected]>

All of the PCI/PCI-Express driver and initialization code that was in the MPC8641HPCN port has now been moved into the common drivers/fsl_pci_init.c. In a subsequent patch, this will be utilized by the 85xx ports as well.

Common PCI-E IMMAP register blocks for FSL 85xx/86xx are added.

Also enable the second PCI-Express controller on 8641 by getting its BATS and CFG_ setup right.

---

Wolfgang,

Please apply this to the testing repository as it depends on my previous PCI/PCI-E changes already applied there. I have built and tested this on the 8641 from u-boot-testing.

Thanks,
jdl

Quoted 15 lines
 board/mpc8641hpcn/mpc8641hpcn.c |  161 ++++++++++++++++++++++++-------
 board/mpc8641hpcn/u-boot.lds    |    1 -
 cpu/mpc86xx/Makefile            |    3 +-
 cpu/mpc86xx/pci.c               |  146 ----------------------------
 cpu/mpc86xx/pcie_indirect.c     |  199 ---------------------------------------
 drivers/Makefile                |    2 +-
 drivers/fsl_pci_init.c          |  176 ++++++++++++++++++++++++++++++++++
 include/asm-ppc/immap_fsl_pci.h |  150 +++++++++++++++++++++++++++++
 include/configs/MPC8641HPCN.h   |   41 +++++----
 include/pci.h                   |    6 +
 10 files changed, 482 insertions(+), 403 deletions(-)
 delete mode 100644 cpu/mpc86xx/pci.c
 delete mode 100644 cpu/mpc86xx/pcie_indirect.c
 create mode 100644 drivers/fsl_pci_init.c
 create mode 100644 include/asm-ppc/immap_fsl_pci.h

Wolfgang,

I will rebase this patch to current top of u-boot-testing.git and repost it for you. It will take into account the minor cleanups that you recently posted for the 8641 HPCN board. I would send these via the -mpc86xx repo, except that they are dependent upon the patches already in the -testing repository!

There is a follow-up 85xx PCI patch series that I will press Andy Fleming into posting as well has his followup TSEC cleanup patches!

Thanks,
jdl