Skip to contentSkip to conversation

74xx_7xx: Add CPCI adapter/target support for the CPCI750

PATCH New Stefan Roese 2 participants 2 messages Jun 4, 2009

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 74xx_7xx: Add CPCI adapter/target support for the CPCI750

The CPCI750 can be built as CPCI host or adapter/target board. This patch adds support for runtime detection of those variants.

Changes in more detail are:

- On CPCI adapter some things have to be done differently:
- Different PCI setup
- Skip (PCI) video inititialization
- No PCI IDE configuration
- Addition of a boardspecific command (loadpci) for OS-image loading/booting on the CPCI adapter via the CPCI host.
- Minor coding style fixes
- PCI related fixes
- Add command line editing (history) and completion

---
Changes in v2:
- Commit text describes changes in more detail now
- Minor coding style fixes (whitespace fixup of v1 patch)

 board/esd/cpci750/cpci750.c |  108 +++++++++++++++++++++++++++++++++++++++----
 board/esd/cpci750/ide.c     |    4 +-
 board/esd/cpci750/pci.c     |   57 ++++++++++++++++------
 include/configs/CPCI750.h   |    5 ++-
 4 files changed, 147 insertions(+), 27 deletions(-)
board/esd/cpci750/cpci750.c +99 -9
index 4826633..1e76bc6 100644
@@ -122,6 +122,9 @@ static char show_config_tab[][15] = {{"PCI0DLL_2     "},  /* 31 */
 
 extern flash_info_t flash_info[];
 
+extern int do_bootm (cmd_tbl_t *, int, int, char *[]);
+extern int do_bootvx (cmd_tbl_t *, int, int, char *[]);
+
 /* ------------------------------------------------------------------------- */
 
 /* this is the current GT register space location */
@@ -137,6 +140,15 @@ void board_prebootm_init (void);
 unsigned int INTERNAL_REG_BASE_ADDR = CONFIG_SYS_GT_REGS;
 int display_mem_map (void);
 
+/*
+ * Skip video initialization on slave variant.
+ * This function will overwrite the weak default in cfb_console.c
+ */
+int board_video_skip(void)
+{
+	return CPCI750_SLAVE_TEST;
+}
+
 /* ------------------------------------------------------------------------- */
 
 /*
@@ -184,6 +196,7 @@ original ppcboot 1.1.6 source end */
 static void gt_pci_config (void)
 {
 	unsigned int stat;
+	unsigned int data;
 	unsigned int val = 0x00fff864;	/* DINK32: BusNum 23:16,  DevNum 15:11, FuncNum 10:8, RegNum 7:2 */
 
 	/* In PCIX mode devices provide their own bus and device numbers. We query the Discovery II's
@@ -251,10 +264,11 @@ static void gt_pci_config (void)
 
 /*ronen update the pci internal registers base address.*/
 #ifdef MAP_PCI
-	for (stat = 0; stat <= PCI_HOST1; stat++)
-		pciWriteConfigReg (stat,
-				   PCI_INTERNAL_REGISTERS_MEMORY_MAPPED_BASE_ADDRESS,
-				   SELF, CONFIG_SYS_GT_REGS);
+	for (stat = 0; stat <= PCI_HOST1; stat++) {
+		data = pciReadConfigReg(stat, PCI_INTERNAL_REGISTERS_MEMORY_MAPPED_BASE_ADDRESS, SELF);
+		data = (data & 0x0f) | CONFIG_SYS_GT_REGS;
+		pciWriteConfigReg (stat, PCI_INTERNAL_REGISTERS_MEMORY_MAPPED_BASE_ADDRESS, SELF, data);
+	}
 #endif
 
 }
@@ -448,13 +462,16 @@ int misc_init_r ()
 
 void after_reloc (ulong dest_addr, gd_t * gd)
 {
+	memoryMapDeviceSpace (BOOT_DEVICE, CONFIG_SYS_BOOT_SPACE,
+			      CONFIG_SYS_BOOT_SIZE);
 
-  memoryMapDeviceSpace (BOOT_DEVICE, CONFIG_SYS_BOOT_SPACE, CONFIG_SYS_BOOT_SIZE);
+	display_mem_map ();
+	GT_REG_WRITE (PCI_0BASE_ADDRESS_REGISTERS_ENABLE, 0xfffffdfe);
+	GT_REG_WRITE (PCI_1BASE_ADDRESS_REGISTERS_ENABLE, 0xfffffdfe);
 
-  display_mem_map ();
-  /* now, jump to the main ppcboot board init code */
-  board_init_r (gd, dest_addr);
-  /* NOTREACHED */
+	/* now, jump to the main ppcboot board init code */
+	board_init_r (gd, dest_addr);
+	/* NOTREACHED */
 }
 
 /* ------------------------------------------------------------------------- */
@@ -538,6 +555,79 @@ int display_mem_map (void)
 	return (0);
 }
 
+/*
+ * Command loadpci: wait for signal from host and boot image.
+ */
+int do_loadpci(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
+{
+	volatile unsigned int *ptr;
+	int count = 0;
+	int count2 = 0;
+	int status;
+	char addr[16];
+	char str[] = "\\|/-";
+	char *local_args[2];
+
+	/*
+	 * Mark sync address
+	 */
+	ptr = 0;
+	ptr[0] = 0xffffffff;
+	ptr[1] = 0xffffffff;
+	puts("\nWaiting for image from pci host -");
+
+	/*
+	 * Wait for host to write the start address
+	 */
+	while (*ptr == 0xffffffff) {
+		count++;
+		if (!(count % 100)) {
+			count2++;
+			putc(0x08); /* backspace */
+			putc(str[count2 % 4]);
+		}
+
+		/* Abort if ctrl-c was pressed */
+		if (ctrlc()) {
+			puts("\nAbort\n");
+			return 0;
+		}
+
+		udelay(1000);
+	}
+
+	sprintf(addr, "%08x", *ptr);
+	printf("\nBooting Image@addr 0x%s ...\n", addr);
+	setenv("loadaddr", addr);
+
+	switch (ptr[1] == 0) {
+	case 0:
+		/*
+		 * Boot image via bootm
+		 */
+		local_args[0] = argv[0];
+		local_args[1] = NULL;
+		status = do_bootm (cmdtp, 0, 1, local_args);
+		break;
+	case 1:
+		/*
+		 * Boot image via bootvx
+		 */
+		local_args[0] = argv[0];
+		local_args[1] = NULL;
+		status = do_bootvx (cmdtp, 0, 1, local_args);
+		break;
+	}
+
+	return 0;
+}
+
+U_BOOT_CMD(
+	loadpci,	1,	1,	do_loadpci,
+	"loadpci - Wait for pci-image and boot it\n",
+	NULL
+	);
+
 /* DRAM check routines copied from gw8260 */
 
 #if defined (CONFIG_SYS_DRAM_TEST)
board/esd/cpci750/ide.c +3 -1
index 9bdc523..638219f 100644
@@ -39,6 +39,8 @@ int ide_preinit (void)
 	int l;
 
 	status = 1;
+	if (CPCI750_SLAVE_TEST != 0)
+		return status;
 	for (l = 0; l < CONFIG_SYS_IDE_MAXBUS; l++) {
 		ide_bus_offset[l] = -ATA_STATUS;
 	}
@@ -57,7 +59,7 @@ int ide_preinit (void)
 		ide_bus_offset[1] &= 0xfffffffe;
 		ide_bus_offset[1] += CONFIG_SYS_PCI0_IO_SPACE;
 	}
-	return (status);
+	return status;
 }
 
 void ide_set_reset (int flag) {
board/esd/cpci750/pci.c +41 -16

110 lines not on this page · raw message

include/configs/CPCI750.h +4 -1
index 8494faa..d516c3c 100644
@@ -76,7 +76,8 @@
 
 #define CONFIG_SYS_PROMPT_HUSH_PS2	"> "
 
-#define CONFIG_AUTO_COMPLETE 1
+#define CONFIG_CMDLINE_EDITING		/* add command line history	*/
+#define CONFIG_AUTO_COMPLETE		/* add autocompletion support	*/
 
 /* Define which ETH port will be used for connecting the network */
 #define CONFIG_SYS_ETH_PORT		ETH_0
@@ -626,4 +627,6 @@
 
 #define CONFIG_SYS_BOARD_ASM_INIT	1
 
+#define CPCI750_SLAVE_TEST	(((in8(0xf0300000) & 0x80) == 0) ? 0 : 1)
+
 #endif	/* __CONFIG_H */
Signature · 1 line
1.6.2.5
#1 lore raw

PATCH v2 1/1 74xx_7xx: Add CPCI adapter/target support for the CPCI750

Dear Stefan Roese,

Quoted 5 lines · In message <[email protected]> you wrote:

The CPCI750 can be built as CPCI host or adapter/target board. This patch adds support for runtime detection of those variants.

Changes in more detail are:

Quoted 9 lines

- On CPCI adapter some things have to be done differently:
- Different PCI setup
- Skip (PCI) video inititialization
- No PCI IDE configuration
- Addition of a boardspecific command (loadpci) for OS-image loading/booting on the CPCI adapter via the CPCI host.
- Minor coding style fixes
- PCI related fixes
- Add command line editing (history) and completion

These are at least 3 unrelated topics handled in this patch:
- PCI related changes
- new command
- configuration changes (and cleanup)

I still think this needs to be split up into separate commits.

Best regards,

Wolfgang Denk

Signature · 4 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"This isn't brain surgery; it's just television."   - David Letterman