PERFORCE change 176673 for review

Rafal Jaworowski raj at FreeBSD.org
Thu Apr 8 16:48:29 UTC 2010


http://p4web.freebsd.org/@@176673?ac=10

Change 176673 by raj at raj_fdt on 2010/04/08 16:48:26

	Improve handling of USB decode windows.

Affected files ...

.. //depot/projects/fdt/sys/arm/mv/common.c#11 edit
.. //depot/projects/fdt/sys/arm/mv/mvwin.h#6 edit

Differences ...

==== //depot/projects/fdt/sys/arm/mv/common.c#11 (text+ko) ====

@@ -100,6 +100,7 @@
 static uint32_t dev_mask = 0;
 static int cpu_wins_no = 0;
 static int eth_port = 0;
+static int usb_port = 0;
 
 static struct decode_win cpu_win_tbl[MAX_CPU_WIN];
 
@@ -416,6 +417,7 @@
 		soc_dump_decode_win();
 
 	eth_port = 0;
+	usb_port = 0;
 	if ((err = fdt_win_setup()) != 0)
 		return (err);
 
@@ -437,10 +439,10 @@
 WIN_REG_IDX_RD(ddr, br, MV_WIN_DDR_BASE, MV_DDR_CADR_BASE)
 WIN_REG_IDX_RD(ddr, sz, MV_WIN_DDR_SIZE, MV_DDR_CADR_BASE)
 
-WIN_REG_BASE_IDX_RD2(win_usb, cr, MV_WIN_USB_CTRL)
-WIN_REG_BASE_IDX_RD2(win_usb, br, MV_WIN_USB_BASE)
-WIN_REG_BASE_IDX_WR2(win_usb, cr, MV_WIN_USB_CTRL)
-WIN_REG_BASE_IDX_WR2(win_usb, br, MV_WIN_USB_BASE)
+WIN_REG_BASE_IDX_RD(win_usb, cr, MV_WIN_USB_CTRL)
+WIN_REG_BASE_IDX_RD(win_usb, br, MV_WIN_USB_BASE)
+WIN_REG_BASE_IDX_WR(win_usb, cr, MV_WIN_USB_CTRL)
+WIN_REG_BASE_IDX_WR(win_usb, br, MV_WIN_USB_BASE)
 
 WIN_REG_BASE_IDX_RD(win_cesa, cr, MV_WIN_CESA_CTRL)
 WIN_REG_BASE_IDX_RD(win_cesa, br, MV_WIN_CESA_BASE)
@@ -762,29 +764,17 @@
 	return (decode_win_can_cover_ddr(MV_WIN_USB_MAX));
 }
 
-static __inline int
-usb_max_ports(void)
-{
-	uint32_t dev, rev;
-
-	soc_id(&dev, &rev);
-	return ((dev == MV_DEV_MV78100 || dev == MV_DEV_MV78100_Z0) ? 3 : 1);
-}
-
 static void
 decode_win_usb_dump(u_long base)
 {
-	int i, p, m;
+	int i;
 
-	m = usb_max_ports();
-	for (p = 0; p < m; p++) {
-		if (pm_is_disabled(CPU_PM_CTRL_USB(p)))
-			continue;
+	if (pm_is_disabled(CPU_PM_CTRL_USB(usb_port - 1)))
+		return;
 
-		for (i = 0; i < MV_WIN_USB_MAX; i++)
-			printf("USB window#%d: c 0x%08x, b 0x%08x\n", i,
-			    win_usb_cr_read(base, i, p), win_usb_br_read(base, i, p));
-	}
+	for (i = 0; i < MV_WIN_USB_MAX; i++)
+		printf("USB window#%d: c 0x%08x, b 0x%08x\n", i,
+		    win_usb_cr_read(base, i), win_usb_br_read(base, i));
 }
 
 /*
@@ -794,42 +784,39 @@
 decode_win_usb_setup(u_long base)
 {
 	uint32_t br, cr;
-	int i, j, p, m;
+	int i, j;
 
-	/* Disable and clear all USB windows for all ports */
-	m = usb_max_ports();
 
-	for (p = 0; p < m; p++) {
+	if (pm_is_disabled(CPU_PM_CTRL_USB(usb_port)))
+		return;
 
-		if (pm_is_disabled(CPU_PM_CTRL_USB(p)))
-			continue;
+	usb_port++;
 
-		for (i = 0; i < MV_WIN_USB_MAX; i++) {
-			win_usb_cr_write(base, i, p, 0);
-			win_usb_br_write(base, i, p, 0);
-		}
+	for (i = 0; i < MV_WIN_USB_MAX; i++) {
+		win_usb_cr_write(base, i, 0);
+		win_usb_br_write(base, i, 0);
+	}
 
-		/* Only access to active DRAM banks is required */
-		for (i = 0; i < MV_WIN_DDR_MAX; i++) {
-			if (ddr_is_active(i)) {
-				br = ddr_base(i);
-				/*
-				 * XXX for 6281 we should handle Mbus write
-				 * burst limit field in the ctrl reg
-				 */
-				cr = (((ddr_size(i) - 1) & 0xffff0000) |
-				    (ddr_attr(i) << 8) |
-				    (ddr_target(i) << 4) | 1);
+	/* Only access to active DRAM banks is required */
+	for (i = 0; i < MV_WIN_DDR_MAX; i++) {
+		if (ddr_is_active(i)) {
+			br = ddr_base(i);
+			/*
+			 * XXX for 6281 we should handle Mbus write
+			 * burst limit field in the ctrl reg
+			 */
+			cr = (((ddr_size(i) - 1) & 0xffff0000) |
+			    (ddr_attr(i) << 8) |
+			    (ddr_target(i) << 4) | 1);
 
-				/* Set the first free USB window */
-				for (j = 0; j < MV_WIN_USB_MAX; j++) {
-					if (win_usb_cr_read(base, j, p) & 0x1)
-						continue;
+			/* Set the first free USB window */
+			for (j = 0; j < MV_WIN_USB_MAX; j++) {
+				if (win_usb_cr_read(base, j) & 0x1)
+					continue;
 
-					win_usb_br_write(base, j, p, br);
-					win_usb_cr_write(base, j, p, cr);
-					break;
-				}
+				win_usb_br_write(base, j, br);
+				win_usb_cr_write(base, j, cr);
+				break;
 			}
 		}
 	}

==== //depot/projects/fdt/sys/arm/mv/mvwin.h#6 (text+ko) ====

@@ -138,8 +138,8 @@
 #define MV_WIN_CESA_ATTR		0
 #endif
 
-#define MV_WIN_USB_CTRL(n, m)		(0x10 * (n) + (m) * 0x1000 + 0x0)
-#define MV_WIN_USB_BASE(n, m)		(0x10 * (n) + (m) * 0x1000 + 0x4)
+#define MV_WIN_USB_CTRL(n)		(0x10 * (n) + 0x0)
+#define MV_WIN_USB_BASE(n)		(0x10 * (n) + 0x4)
 #define MV_WIN_USB_MAX			4
 
 #define MV_WIN_ETH_BASE(n)		(0x8 * (n) + 0x200)


More information about the p4-projects mailing list