Skip to contentSkip to conversation

GRETH: Added support for selecting PHY address from config, PHY address was always set to zero before.

PATCH New Daniel Hellstrom 2 participants 21 messages May 18, 2010 – May 26, 2010

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 2/17 GRETH: Added support for selecting PHY address from config, PHY address was always set to zero before.

---
 drivers/net/greth.c |   69 +++++++++++++++++++++++++++++++-------------------
 1 files changed, 43 insertions(+), 26 deletions(-)
drivers/net/greth.c +43 -26
index 79bc4d9..a1a88f9 100644
@@ -45,7 +45,7 @@
 /* ByPass Cache when reading regs */
 #define GRETH_REGLOAD(addr)		SPARC_NOCACHE_READ(addr)
 /* Write-through cache ==> no bypassing needed on writes */
-#define GRETH_REGSAVE(addr,data)	(*(unsigned int *)(addr) = (data))
+#define GRETH_REGSAVE(addr,data) (*(volatile unsigned int *)(addr) = (data))
 #define GRETH_REGORIN(addr,data) GRETH_REGSAVE(addr,GRETH_REGLOAD(addr)|data)
 #define GRETH_REGANDIN(addr,data) GRETH_REGSAVE(addr,GRETH_REGLOAD(addr)&data)
 
@@ -102,12 +102,12 @@ typedef struct {
 } greth_priv;
 
 /* Read MII register 'addr' from core 'regs' */
-static int read_mii(int addr, volatile greth_regs * regs)
+static int read_mii(int phyaddr, int regaddr, volatile greth_regs * regs)
 {
 	while (GRETH_REGLOAD(&regs->mdio) & GRETH_MII_BUSY) {
 	}
 
-	GRETH_REGSAVE(&regs->mdio, (0 << 11) | ((addr & 0x1F) << 6) | 2);
+	GRETH_REGSAVE(&regs->mdio, ((phyaddr & 0x1F) << 11) | ((regaddr & 0x1F) << 6) | 2);
 
 	while (GRETH_REGLOAD(&regs->mdio) & GRETH_MII_BUSY) {
 	}
@@ -119,14 +119,14 @@ static int read_mii(int addr, volatile greth_regs * regs)
 	}
 }
 
-static void write_mii(int addr, int data, volatile greth_regs * regs)
+static void write_mii(int phyaddr, int regaddr, int data, volatile greth_regs * regs)
 {
 	while (GRETH_REGLOAD(&regs->mdio) & GRETH_MII_BUSY) {
 	}
 
 	GRETH_REGSAVE(&regs->mdio,
-		      ((data & 0xFFFF) << 16) | (0 << 11) | ((addr & 0x1F) << 6)
-		      | 1);
+		      ((data & 0xFFFF) << 16) | ((phyaddr & 0x1F) << 11) |
+		      ((regaddr & 0x1F) << 6) | 1);
 
 	while (GRETH_REGLOAD(&regs->mdio) & GRETH_MII_BUSY) {
 	}
@@ -146,8 +146,6 @@ int greth_init(struct eth_device *dev, bd_t * bis)
 	printf("greth_init\n");
 #endif
 
-	GRETH_REGSAVE(&regs->control, 0);
-
 	if (!greth->rxbd_base) {
 
 		/* allocate descriptors */
@@ -161,6 +159,7 @@ int greth_init(struct eth_device *dev, bd_t * bis)
 		    malloc(GRETH_RXBUF_EFF_SIZE * GRETH_RXBD_CNT);
 	}
 
+	memset(greth->rxbuf_base, 0, GRETH_RXBUF_EFF_SIZE * GRETH_RXBD_CNT);
 	/* initate rx decriptors */
 	for (i = 0; i < GRETH_RXBD_CNT; i++) {
 		greth->rxbd_base[i].addr = (unsigned int)
@@ -219,6 +218,11 @@ int greth_init_phy(greth_priv * dev, bd_t * bis)
 	greth_regs *regs = dev->regs;
 	int tmp, tmp1, tmp2, i;
 	unsigned int start, timeout;
+#ifdef CONFIG_SYS_GRLIB_GRETH_PHYADDR
+	int phyaddr = CONFIG_SYS_GRLIB_GRETH_PHYADDR;
+#else
+	int phyaddr = 0;
+#endif
 
 	/* X msecs to ticks */
 	timeout = usec2ticks(GRETH_PHY_TIMEOUT_MS * 1000);
@@ -230,17 +234,25 @@ int greth_init_phy(greth_priv * dev, bd_t * bis)
 
 	/* get phy control register default values */
 
-	while ((tmp = read_mii(0, regs)) & 0x8000) {
-		if (get_timer(start) > timeout)
+	while ((tmp = read_mii(phyaddr, 0, regs)) & 0x8000) {
+		if (get_timer(start) > timeout) {
+#ifdef DEBUG
+			printf("greth_init_phy: PHY read 1 failed\n");
+#endif
 			return 1;	/* Fail */
+		}
 	}
 
 	/* reset PHY and wait for completion */
-	write_mii(0, 0x8000 | tmp, regs);
+	write_mii(phyaddr, 0, 0x8000 | tmp, regs);
 
-	while (((tmp = read_mii(0, regs))) & 0x8000) {
-		if (get_timer(start) > timeout)
+	while (((tmp = read_mii(phyaddr, 0, regs))) & 0x8000) {
+		if (get_timer(start) > timeout) {
+#ifdef DEBUG
+			printf("greth_init_phy: PHY read 2 failed\n");
+#endif
 			return 1;	/* Fail */
+		}
 	}
 
 	/* Check if PHY is autoneg capable and then determine operating
@@ -251,16 +263,16 @@ int greth_init_phy(greth_priv * dev, bd_t * bis)
 	dev->sp = 0;
 	dev->auto_neg = 0;
 	if (!((tmp >> 12) & 1)) {
-		write_mii(0, 0, regs);
+		write_mii(phyaddr, 0, 0, regs);
 	} else {
 		/* wait for auto negotiation to complete and then check operating mode */
 		dev->auto_neg = 1;
 		i = 0;
-		while (!(((tmp = read_mii(1, regs)) >> 5) & 1)) {
+		while (!(((tmp = read_mii(phyaddr, 1, regs)) >> 5) & 1)) {
 			if (get_timer(start) > timeout) {
 				printf("Auto negotiation timed out. "
 				       "Selecting default config\n");
-				tmp = read_mii(0, regs);
+				tmp = read_mii(phyaddr, 0, regs);
 				dev->gb = ((tmp >> 6) & 1)
 				    && !((tmp >> 13) & 1);
 				dev->sp = !((tmp >> 6) & 1)
@@ -270,8 +282,8 @@ int greth_init_phy(greth_priv * dev, bd_t * bis)
 			}
 		}
 		if ((tmp >> 8) & 1) {
-			tmp1 = read_mii(9, regs);
-			tmp2 = read_mii(10, regs);
+			tmp1 = read_mii(phyaddr, 9, regs);
+			tmp2 = read_mii(phyaddr, 10, regs);
 			if ((tmp1 & GRETH_MII_EXTADV_1000FD) &&
 			    (tmp2 & GRETH_MII_EXTPRT_1000FD)) {
 				dev->gb = 1;
@@ -284,8 +296,8 @@ int greth_init_phy(greth_priv * dev, bd_t * bis)
 			}
 		}
 		if ((dev->gb == 0) || ((dev->gb == 1) && (dev->gbit_mac == 0))) {
-			tmp1 = read_mii(4, regs);
-			tmp2 = read_mii(5, regs);
+			tmp1 = read_mii(phyaddr, 4, regs);
+			tmp2 = read_mii(phyaddr, 5, regs);
 			if ((tmp1 & GRETH_MII_100TXFD) &&
 			    (tmp2 & GRETH_MII_100TXFD)) {
 				dev->sp = 1;
@@ -302,7 +314,7 @@ int greth_init_phy(greth_priv * dev, bd_t * bis)
 			if ((dev->gb == 1) && (dev->gbit_mac == 0)) {
 				dev->gb = 0;
 				dev->fd = 0;
-				write_mii(0, dev->sp << 13, regs);
+				write_mii(phyaddr, 0, dev->sp << 13, regs);
 			}
 		}
 
@@ -314,8 +326,8 @@ int greth_init_phy(greth_priv * dev, bd_t * bis)
 #endif
 	/* Read out PHY info if extended registers are available */
 	if (tmp & 1) {
-		tmp1 = read_mii(2, regs);
-		tmp2 = read_mii(3, regs);
+		tmp1 = read_mii(phyaddr, 2, regs);
+		tmp2 = read_mii(phyaddr, 3, regs);
 		tmp1 = (tmp1 << 6) | ((tmp2 >> 10) & 0x3F);
 		tmp = tmp2 & 0xF;
 
@@ -542,10 +554,9 @@ int greth_recv(struct eth_device *dev)
 		/* increase index */
 		greth->rxbd_curr =
 		    ((unsigned int)greth->rxbd_curr >=
-		     (unsigned int)greth->rxbd_max) ? greth->
-		    rxbd_base : (greth->rxbd_curr + 1);
+		     (unsigned int)greth->rxbd_max) ? greth->rxbd_base : (greth->rxbd_curr + 1);
 
-	};
+	}
 
 	if (enable) {
 		GRETH_REGORIN(&regs->control, GRETH_RXEN);
@@ -630,6 +641,9 @@ int greth_initialize(bd_t * bis)
 	/* initiate PHY, select speed/duplex depending on connected PHY */
 	if (greth_init_phy(greth, bis)) {
 		/* Failed to init PHY (timedout) */
+#ifdef DEBUG
+		printf("GRETH[0x%08x]: Failed to init PHY\n", greth->regs);
+#endif
 		return -1;
 	}
 
@@ -658,5 +672,8 @@ int greth_initialize(bd_t * bis)
 	/* set and remember MAC address */
 	greth_set_hwaddr(greth, addr);
 
+#ifdef DEBUG
+	printf("GRETH[0x%08x]: Initialized successfully\n", greth->regs);
+#endif
 	return 0;
 }
Signature · 1 line
1.5.4
#1 lore raw

PATCH 3/17 GRETH: Added extra RESET, this is needed if GRETH was stopped during an ethernet frame reception.

---
 drivers/net/greth.c |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)
drivers/net/greth.c +12 -2
index a1a88f9..143c773 100644
@@ -146,13 +146,23 @@ int greth_init(struct eth_device *dev, bd_t * bis)
 	printf("greth_init\n");
 #endif
 
+	/* Reset core */
+	GRETH_REGSAVE(&regs->control, (GRETH_RESET | (greth->gb << 8) |
+		(greth->sp << 7) | (greth->fd << 4)));
+
+	/* Wait for Reset to complete */
+	while ( GRETH_REGLOAD(&regs->control) & GRETH_RESET) ;
+
+	GRETH_REGSAVE(&regs->control,
+		((greth->gb << 8) | (greth->sp << 7) | (greth->fd << 4)));
+
 	if (!greth->rxbd_base) {
 
 		/* allocate descriptors */
 		greth->rxbd_base = (greth_bd *)
 		    memalign(0x1000, GRETH_RXBD_CNT * sizeof(greth_bd));
 		greth->txbd_base = (greth_bd *)
-		    memalign(0x1000, GRETH_RXBD_CNT * sizeof(greth_bd));
+		    memalign(0x1000, GRETH_TXBD_CNT * sizeof(greth_bd));
 
 		/* allocate buffers to all descriptors  */
 		greth->rxbuf_base =
@@ -185,7 +195,7 @@ int greth_init(struct eth_device *dev, bd_t * bis)
 	for (i = 0; i < GRETH_TXBD_CNT; i++) {
 		greth->txbd_base[i].addr = 0;
 		/* enable desciptor & set wrap bit if last descriptor */
-		if (i >= (GRETH_RXBD_CNT - 1)) {
+		if (i >= (GRETH_TXBD_CNT - 1)) {
 			greth->txbd_base[i].stat = GRETH_BD_WR;
 		} else {
 			greth->txbd_base[i].stat = 0;
Signature · 1 line
1.5.4
#2 lore raw

PATCH 3/17 GRETH: Added extra RESET, this is needed if GRETH was stopped during an ethernet frame reception.

Dear Daniel Hellstrom,

Quoted 21 lines · In message <[email protected]> you wrote:
---
 drivers/net/greth.c |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)
drivers/net/greth.c +8 -0
index a1a88f9..143c773 100644
@@ -146,13 +146,23 @@ int greth_init(struct eth_device *dev, bd_t * bis)
 	printf("greth_init\n");
 #endif
 
+	/* Reset core */
+	GRETH_REGSAVE(&regs->control, (GRETH_RESET | (greth->gb << 8) |
+		(greth->sp << 7) | (greth->fd << 4)));
+
+	/* Wait for Reset to complete */
+	while ( GRETH_REGLOAD(&regs->control) & GRETH_RESET) ;
+
+	GRETH_REGSAVE(&regs->control,

drivers/net/greth.c int greth_init(struct eth_device *dev, bd_t * bis) · line 165

Quoted 10 lines
drivers/net/greth.c +3 -1
+		((greth->gb << 8) | (greth->sp << 7) | (greth->fd << 4)));
+
 	if (!greth->rxbd_base) {
 
 		/* allocate descriptors */
 		greth->rxbd_base = (greth_bd *)
 		    memalign(0x1000, GRETH_RXBD_CNT * sizeof(greth_bd));
 		greth->txbd_base = (greth_bd *)
-		    memalign(0x1000, GRETH_RXBD_CNT * sizeof(greth_bd));
+		    memalign(0x1000, GRETH_TXBD_CNT * sizeof(greth_bd));

This...

drivers/net/greth.c int greth_init(struct eth_device *dev, bd_t * bis) · line 198

Quoted 8 lines
drivers/net/greth.c +1 -1
 		/* allocate buffers to all descriptors  */
 		greth->rxbuf_base =
@@ -185,7 +195,7 @@ int greth_init(struct eth_device *dev, bd_t * bis)
 	for (i = 0; i < GRETH_TXBD_CNT; i++) {
 		greth->txbd_base[i].addr = 0;
 		/* enable desciptor & set wrap bit if last descriptor */
-		if (i >= (GRETH_RXBD_CNT - 1)) {
+		if (i >= (GRETH_TXBD_CNT - 1)) {

... and these seem to be unrelated bug fixes. These should go into a separate commit.

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
A failure will not appear until a unit has passed final inspection.
#3 lore raw

PATCH 4/17 LEON3: reimplemented AMBA Plug&Play scanning routines.

In reply to Daniel Hellstrom
---
 arch/sparc/cpu/leon3/Makefile       |    2 +-
 arch/sparc/cpu/leon3/ambapp.c       |  581 +++++++++++++-------------
 arch/sparc/cpu/leon3/ambapp_low.S   |  798 +++++++++++++++++++++++++++++++++++
 arch/sparc/cpu/leon3/ambapp_low_c.S |  133 ++++++
 arch/sparc/cpu/leon3/cpu_init.c     |  182 +++------
 arch/sparc/cpu/leon3/serial.c       |    8 +-
 arch/sparc/cpu/leon3/usb_uhci.c     |    4 +-
 common/cmd_ambapp.c                 |  564 +++++++++++++++++++------
 drivers/net/greth.c                 |   15 +-
 include/ambapp.h                    |  365 ++++++++---------
 include/ambapp_ids.h                |  256 +++++++++++
 11 files changed, 2179 insertions(+), 729 deletions(-)
 create mode 100644 arch/sparc/cpu/leon3/ambapp_low.S
 create mode 100644 arch/sparc/cpu/leon3/ambapp_low_c.S
 create mode 100644 include/ambapp_ids.h
arch/sparc/cpu/leon3/Makefile +1 -1
index 182543d..d8f89bc 100644
@@ -26,7 +26,7 @@ include $(TOPDIR)/config.mk
 LIB	= $(obj)lib$(CPU).a
 
 START	= start.o
-SOBJS	=
+SOBJS	= ambapp_low.o ambapp_low_c.o
 COBJS	= cpu_init.o serial.o cpu.o ambapp.o interrupts.o prom.o usb_uhci.o
 
 SRCS	:= $(START:.o=.S) $(SOBJS:.o=.S) $(COBJS:.o=.c)
arch/sparc/cpu/leon3/ambapp.c +295 -286

642 lines not on this page · raw message

arch/sparc/cpu/leon3/ambapp_low.S new file +798 -0

798 lines not on this page · raw message

arch/sparc/cpu/leon3/ambapp_low_c.S new file +133 -0

133 lines not on this page · raw message

arch/sparc/cpu/leon3/cpu_init.c +58 -124

223 lines not on this page · raw message

arch/sparc/cpu/leon3/serial.c +7 -1
index 4b2fcb8..15c380e 100644
@@ -30,6 +30,11 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
+/* Select which UART that will become u-boot console */
+#ifndef CONFIG_SYS_GRLIB_APBUART_INDEX
+#define CONFIG_SYS_GRLIB_APBUART_INDEX 0
+#endif
+
 /* Force cache miss each time a serial controller reg is read */
 #define CACHE_BYPASS 1
 
@@ -48,7 +53,8 @@ int serial_init(void)
 	unsigned int tmp;
 
 	/* find UART */
-	if (ambapp_apb_first(VENDOR_GAISLER, GAISLER_APBUART, &apbdev) == 1) {
+	if (ambapp_apb_find(&ambapp_plb, VENDOR_GAISLER, GAISLER_APBUART,
+		CONFIG_SYS_GRLIB_APBUART_INDEX, &apbdev) == 1) {
 
 		leon3_apbuart = (ambapp_dev_apbuart *) apbdev.address;
 
arch/sparc/cpu/leon3/usb_uhci.c +2 -2
index 8f99e1d..01310e2 100644
@@ -708,11 +708,11 @@ void handle_usb_interrupt(void)
  */
 int usb_lowlevel_init(void)
 {
-	unsigned char temp;
 	ambapp_ahbdev ahbdev;
 
 	/* Find GRUSB core using AMBA Plug&Play information */
-	if (ambapp_ahbslv_first(VENDOR_GAISLER, GAISLER_UHCI, &ahbdev) != 1) {
+	if (ambapp_ahbslv_find(&ambapp_plb, VENDOR_GAISLER, GAISLER_UHCI,
+		CONFIG_SYS_GRLIB_GRUSB_INDEX, &ahbdev) != 1 ) {
 		printf("USB UHCI: Failed to find GRUSB controller\n");
 		return -1;
 	}
common/cmd_ambapp.c +441 -123

660 lines not on this page · raw message

drivers/net/greth.c +13 -2
index 143c773..fcccb99 100644
@@ -42,6 +42,13 @@
 #define GRETH_PHY_TIMEOUT_MS 3000
 #endif
 
+/* Let board select which GRETH to use as network interface, set
+ * this to zero if only one GRETH is available.
+ */
+#ifndef CONFIG_SYS_GRLIB_GRETH_INDEX
+#define CONFIG_SYS_GRLIB_GRETH_INDEX 0
+#endif
+
 /* ByPass Cache when reading regs */
 #define GRETH_REGLOAD(addr)		SPARC_NOCACHE_READ(addr)
 /* Write-through cache ==> no bypassing needed on writes */
@@ -605,8 +612,12 @@ int greth_initialize(bd_t * bis)
 #ifdef DEBUG
 	printf("Scanning for GRETH\n");
 #endif
-	/* Find Device & IRQ via AMBA Plug&Play information */
-	if (ambapp_apb_first(VENDOR_GAISLER, GAISLER_ETHMAC, &apbdev) != 1) {
+	/* Find Device & IRQ via AMBA Plug&Play information,
+	 * CONFIG_SYS_GRLIB_GRETH_INDEX select which GRETH if multiple
+	 * GRETHs in system.
+	 */
+	if (ambapp_apb_find(&ambapp_plb, VENDOR_GAISLER, GAISLER_ETHMAC,
+			CONFIG_SYS_GRLIB_GRETH_INDEX, &apbdev) != 1) {
 		return -1;	/* GRETH not found */
 	}
 
include/ambapp.h +175 -190

414 lines not on this page · raw message

include/ambapp_ids.h new file +256 -0

62 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
1.5.4

Part of the diff is not shown here. View the raw message.

#4 lore raw

PATCH 4/17 LEON3: reimplemented AMBA Plug&Play scanning routines.

Dear Daniel Hellstrom,

Quoted 1 line · In message <[email protected]> you wrote:

...

Quoted 4 lines

- * (C) Copyright 2007
- * Daniel Hellstrom, Gaisler Research, daniel at gaisler.com
+ * (C) Copyright 2010
+ * Daniel Hellstrom, Aeroflex Gaisler, daniel at gaisler.com.

Thsi cannot be. Make this "Copyright 2007, 2010" or "Copyright 2007-2010".

Quoted 3 lines

* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
+ *

Please drop this empty line.

Review

Quoted 2 lines
(quoted diff) +2 -0
+/* #define DEBUG */
+

Please do not add dead code.

...

arch/sparc/cpu/leon3/ambapp.c line 83

Quoted 6 lines
arch/sparc/cpu/leon3/ambapp.c +6 -0
+	int i;
+
+	ambapp_find_buses(ioarea, abus);
+	for(i=0; i<6; i++)
+		if ( abus->ioareas[i] == 0 )
+			break;

Multiline if's require braces. Please also fix white space:

	for (i=0; i<6; i++) {
		if (abus->ioareas[i] == 0)
			break;
	}

arch/sparc/cpu/leon3/ambapp.c line 124

Quoted 1 line
arch/sparc/cpu/leon3/ambapp.c +1 -0
+		if ( type == AMBA_TYPE_AHBIO ) {

Please fix white spaces as above. Please fix this globally.

arch/sparc/cpu/leon3/ambapp.c line 153

Quoted 3 lines
arch/sparc/cpu/leon3/ambapp.c +3 -0
+	if ( found == 1 ) {
+		ambapp_apb_parse(&apbdev, dev);
+	}

No braces for one liners. And fix the white space.

...

arch/sparc/cpu/leon3/ambapp.c line 222

Quoted 6 lines
arch/sparc/cpu/leon3/ambapp.c +5 -0
+	found = ambapp_find_ahb(abus, devid, 63, type, &ahbdev);
+	if ( found == 1 ) {
+		return 64;
+	} else {
+		return 63 - ahbdev.dec_index;
 	}

Seems I have seen semi-identical code above. Factor out as function?

Quoted 7 lines

+/* The define CONFIG_SYS_GRLIB_SINGLE_BUS may be defined on GRLIB systems
+ * where only one AHB Bus is available - no bridges are present. This option
+ * is available only to reduce the footprint.
+ *
+ * Defining this on a multi-bus GRLIB system may also work depending on the
+ * design.
+ */

Incorrect multiline comment style.

Quoted 3 lines

+/* Get Parent bus frequency. Note that since we go from a "child" bus
+ * to a parent bus, the frequency factor direction is inverted.
+ */

Incorrect multiline comment style. Please fix globally.

arch/sparc/cpu/leon3/ambapp.c line 271

Quoted 5 lines
arch/sparc/cpu/leon3/ambapp.c +5 -0
+		if ( dir ) {
+			freq = freq * ffact;
+		} else {
+			freq = freq / ffact;
+		}

No braces for oneliners. Please fix globally.

arch/sparc/cpu/leon3/ambapp.c line 281

Quoted 6 lines
arch/sparc/cpu/leon3/ambapp.c +3 -2
+unsigned int gaisler_ahb2ahb_v2_freq(ambapp_ahbdev *ahb, unsigned int freq)
 {
-	/* find first device of this */
-	return ambapp_ahb_scan(vendor, driver, dev, index, 1, AHB_SCAN_SLAVE);
+	printf("gaisler_ahb2ahb_v2_freq: AHB2AHB ver 2 not supported\n");
+	while(1) ;

Consider calling hang() instead ? [globally]

...

arch/sparc/cpu/leon3/ambapp.c line 319

Quoted 4 lines
arch/sparc/cpu/leon3/ambapp.c +4 -0
+		/* Get parent bus */
+		parent = (ioarea & 0x7);
+		if ( parent == 0 ) {
+			printf("ambapp_bus_freq: parent=0 indicates no parent! Stopping.\n");

Line too long. Please fix globally.

...

arch/sparc/cpu/leon3/ambapp_low.S line 111

Quoted 8 lines
arch/sparc/cpu/leon3/ambapp_low.S new file +8 -0
+init_ahb_bridges:
+	mov	%g0, %i0
+	mov	%g0, %i1
+	mov	%g0, %i2
+	mov	%g0, %i3
+	mov	%g0, %i4
+	retl
+	 mov	%g0, %i5

Incorrect indentation. Please fix globally.

...

Quoted 35 lines

void cpu_init_f(void)
{

arch/sparc/cpu/leon3/cpu_init.c +0 -32
-	/* these varaiable must not be initialized */
-	ambapp_dev_irqmp *irqmp;
-	ambapp_apbdev apbdev;
-	register unsigned int apbmst;
-
-	/* find AMBA APB Master */
-	apbmst = (unsigned int)
-	    ambapp_ahb_next_nomem(VENDOR_GAISLER, GAISLER_APBMST, 1, 0);
-	if (!apbmst) {
-		/*
-		 * no AHB/APB bridge, something is wrong
-		 * ==> jump to start (or hang)
-		 */
-		while (1) ;
-	}
-	/* Init memory controller */
-	if (init_memory_ctrl()) {
-		while (1) ;
-	}
-
-	/****************************************************
-	 * From here we can use the main memory and the stack.
-	 */
 
-	/* Find AMBA APB IRQMP Controller */
-	if (ambapp_apb_first(VENDOR_GAISLER, GAISLER_IRQMP, &apbdev) != 1) {
-		/* no IRQ controller, something is wrong
-		 * ==> jump to start (or hang)
-		 */
-		while (1) ;
-	}
-	irqmp = (ambapp_dev_irqmp *) apbdev.address;
-

arch/sparc/cpu/leon3/cpu_init.c struct { · line 69

Quoted 10 lines
arch/sparc/cpu/leon3/cpu_init.c +0 -9
-	/* initialize the IRQMP */
-	irqmp->ilevel = 0xf;	/* all IRQ off */
-	irqmp->iforce = 0;
-	irqmp->ipend = 0;
-	irqmp->iclear = 0xfffe;	/* clear all old pending interrupts */
-	irqmp->cpu_mask[0] = 0;	/* mask all IRQs on CPU 0 */
-	irqmp->cpu_force[0] = 0;	/* no force IRQ on CPU 0 */
-
-	/* cache */
 }

Seems this becomes an empty function? Drop it, then!

Quoted 5 lines
arch/sparc/cpu/leon3/cpu_init.c +5 -0
+/* Routine called from start.S,
+ *
+ * Run from FLASH/PROM:
+ *  - memory controller has already been setup up, stack can be used
+ *  - global variables available for read/writing

arch/sparc/cpu/leon3/cpu_init.c struct { · line 84

Quoted 10 lines
arch/sparc/cpu/leon3/cpu_init.c +6 -1
+ *  - constants avaiable
+ */
 void cpu_init_f2(void)
 {
-
+	/* Initialize the AMBA Plug & Play bus structure, the bus
+	 * structure represents the AMBA bus that the CPU is located at.
+	 */
+	ambapp_bus_init(CONFIG_AMBAPP_IOAREA, CONFIG_SYS_CLK_FREQ, &ambapp_plb);
 }

Or rename this into cpu_init_f() ?

common/cmd_ambapp.c line 53

Quoted 7 lines
common/cmd_ambapp.c +7 -0
+/** Vendor GAISLER devices */
+static ambapp_device_name GAISLER_devices[] =
+{
+  {GAISLER_LEON2DSU, "LEON2DSU", "Leon2 Debug Support Unit"},
+  {GAISLER_LEON3, "LEON3", "Leon3 SPARC V8 Processor"},
+  {GAISLER_LEON3DSU, "LEON3DSU", "Leon3 Debug Support Unit"},
+  {GAISLER_ETHAHB, "ETHAHB", "OC ethernet AHB interface"},

...

Please use TABs for indentation - fix globally, please.

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
I haven't lost my mind -- it's backed up on tape somewhere.
#5 lore raw

PATCH 5/17 LEON3: added memory controller initialization using the new AMBA PnP routines.

In reply to Daniel Hellstrom
---
 arch/sparc/cpu/leon3/Makefile     |    5 +-
 arch/sparc/cpu/leon3/memcfg.c     |  276 +++++++++++++++++++++++++++++++++++++
 arch/sparc/cpu/leon3/memcfg.h     |  106 ++++++++++++++
 arch/sparc/cpu/leon3/memcfg_low.S |  270 ++++++++++++++++++++++++++++++++++++
 arch/sparc/cpu/leon3/start.S      |   36 +++++
 include/configs/gr_cpci_ax2000.h  |   27 ++--
 include/configs/gr_ep2s60.h       |   32 +++--
 include/configs/gr_xc3s_1500.h    |   23 ++--
 include/configs/grsim.h           |   27 ++--
 9 files changed, 754 insertions(+), 48 deletions(-)
 create mode 100644 arch/sparc/cpu/leon3/memcfg.c
 create mode 100644 arch/sparc/cpu/leon3/memcfg.h
 create mode 100644 arch/sparc/cpu/leon3/memcfg_low.S
arch/sparc/cpu/leon3/Makefile +3 -2
index d8f89bc..f1bb808 100644
@@ -26,8 +26,9 @@ include $(TOPDIR)/config.mk
 LIB	= $(obj)lib$(CPU).a
 
 START	= start.o
-SOBJS	= ambapp_low.o ambapp_low_c.o
-COBJS	= cpu_init.o serial.o cpu.o ambapp.o interrupts.o prom.o usb_uhci.o
+SOBJS	= ambapp_low.o ambapp_low_c.o memcfg_low.o
+COBJS	= cpu_init.o serial.o cpu.o ambapp.o interrupts.o prom.o usb_uhci.o \
+	memcfg.o
 
 SRCS	:= $(START:.o=.S) $(SOBJS:.o=.S) $(COBJS:.o=.c)
 OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
arch/sparc/cpu/leon3/memcfg.c new file +276 -0

276 lines not on this page · raw message

arch/sparc/cpu/leon3/memcfg.h new file +106 -0

106 lines not on this page · raw message

arch/sparc/cpu/leon3/memcfg_low.S new file +270 -0

270 lines not on this page · raw message

arch/sparc/cpu/leon3/start.S +36 -0
index bd634bd..a9c49d9 100644
@@ -29,6 +29,12 @@
 #include <asm/leon.h>
 #include <timestamp.h>
 #include <version.h>
+#include <ambapp.h>
+
+/* Default Plug&Play I/O area */
+#ifndef CONFIG_AMBAPP_IOAREA
+#define CONFIG_AMBAPP_IOAREA AMBA_DEFAULT_IOAREA
+#endif
 
 /* Entry for traps which jump to a programmer-specified trap handler.  */
 #define TRAPR(H)  \
@@ -205,6 +211,7 @@ version_string:
 	.ascii CONFIG_IDENT_STRING, "\0"
 
 	.section	".text"
+	.extern	_nomem_amba_init, _nomem_memory_ctrl_init
 	.align 4
 
 _hardreset:
@@ -256,6 +263,34 @@ stackp:
 	andn	%fp, 0x0f, %fp
 	sub	%fp, 64, %sp
 
+/* Scan AMBA Bus for AMBA buses using PnP information. All found
+ * AMBA buses I/O area will be located in i0-i5 upon return.
+ * The i0-i5 registers are later used by _nomem_amba_init2
+ */
+ambainit:
+	call	_nomem_amba_init
+	 sethi	%hi(CONFIG_AMBAPP_IOAREA), %o0
+
+/* Scan AMBA Buses for memory controllers, then initialize the
+ * memory controllers. Note that before setting up the memory controller
+ * the stack can not be used.
+ */
+memory_ctrl_init:
+	sethi	%hi(grlib_mctrl_handlers), %o0
+	call	_nomem_memory_ctrl_init
+	 or	%o0, %lo(grlib_mctrl_handlers), %o0
+
+/* The return valu indicate how many memory controllers where found and
+ * initialized, if no memory controller was initialized, we can not continue
+ * because from here on we expect memory to be working.
+ */
+	cmp	%o0, 0
+memory_ctrl_init_failed:
+	beq	memory_ctrl_init_failed
+	 nop
+
+/*** From now on the stack can be used. ***/
+
 cpu_init_unreloc:
 	call	cpu_init_f
 	nop
@@ -385,6 +420,7 @@ jump:
 
 	set	board_init_f,%o1
 	set	CONFIG_SYS_RELOC_MONITOR_BASE,%o2
+	set	TEXT_START, %g1
 	add	%o1,%o2,%o1
 	sub	%o1,%g1,%o1
 	call	%o1
include/configs/gr_cpci_ax2000.h +15 -12
index d188439..b9d45dd 100644
@@ -340,33 +340,36 @@
 /* AMBA Plug & Play info display on startup */
 /*#define CONFIG_SYS_AMBAPP_PRINT_ON_STARTUP*/
 
-#define CONFIG_SYS_GRLIB_SDRAM    0
+/* No SDRAM Configuration */
+#undef CONFIG_SYS_GRLIB_GAISLER_SDCTRL1
 
 /* See, GRLIB Docs (grip.pdf) on how to set up
  * These the memory controller registers.
  */
-#define CONFIG_SYS_GRLIB_MEMCFG1   (0x10f800ff | (1<<11))
+#define CONFIG_SYS_GRLIB_ESA_MCTRL1
+#define CONFIG_SYS_GRLIB_ESA_MCTRL1_CFG1   (0x10f800ff | (1<<11))
 #if CONFIG_LEON_RAM_SELECT == CONFIG_LEON_RAM_SDRAM_NOSRAM
-#define CONFIG_SYS_GRLIB_MEMCFG2   0x82206000
+#define CONFIG_SYS_GRLIB_ESA_MCTRL1_CFG2   0x82206000
 #else
-#define CONFIG_SYS_GRLIB_MEMCFG2   0x82205260
+#define CONFIG_SYS_GRLIB_ESA_MCTRL1_CFG2   0x82205260
 #endif
-#define CONFIG_SYS_GRLIB_MEMCFG3   0x0809a000
+#define CONFIG_SYS_GRLIB_ESA_MCTRL1_CFG3   0x0809a000
 
-#define CONFIG_SYS_GRLIB_FT_MEMCFG1   (0x10f800ff | (1<<11))
+/* GRLIB FT-MCTRL configuration */
+#define CONFIG_SYS_GRLIB_GAISLER_FTMCTRL1
+#define CONFIG_SYS_GRLIB_GAISLER_FTMCTRL1_CFG1   (0x10f800ff | (1<<11))
 #if CONFIG_LEON_RAM_SELECT == CONFIG_LEON_RAM_SDRAM_NOSRAM
-#define CONFIG_SYS_GRLIB_FT_MEMCFG2   0x82206000
+#define CONFIG_SYS_GRLIB_GAISLER_FTMCTRL1_CFG2   0x82206000
 #else
-#define CONFIG_SYS_GRLIB_FT_MEMCFG2   0x82205260
+#define CONFIG_SYS_GRLIB_GAISLER_FTMCTRL1_CFG2   0x82205260
 #endif
-#define CONFIG_SYS_GRLIB_FT_MEMCFG3   0x0809a000
+#define CONFIG_SYS_GRLIB_GAISLER_FTMCTRL1_CFG3   0x0809a000
 
 /* no DDR controller */
-#define CONFIG_SYS_GRLIB_DDR_CFG   0x00000000
+#undef CONFIG_SYS_GRLIB_GAISLER_DDRSPA1
 
 /* no DDR2 Controller */
-#define CONFIG_SYS_GRLIB_DDR2_CFG1 0x00000000
-#define CONFIG_SYS_GRLIB_DDR2_CFG3 0x00000000
+#undef CONFIG_SYS_GRLIB_GAISLER_DDR2SPA1
 
 /* Calculate scaler register value from default baudrate */
 #define CONFIG_SYS_GRLIB_APBUART_SCALER \
include/configs/gr_ep2s60.h +19 -13
index 3a568ff..6edb92c 100644
@@ -326,23 +326,29 @@
 /* AMBA Plug & Play info display on startup */
 /*#define CONFIG_SYS_AMBAPP_PRINT_ON_STARTUP*/
 
-#define CONFIG_SYS_GRLIB_SDRAM    0
+/* No SDRAM Configuration */
+#undef CONFIG_SYS_GRLIB_GAISLER_SDCTRL1
 
 /* See, GRLIB Docs (grip.pdf) on how to set up
  * These the memory controller registers.
  */
-#define CONFIG_SYS_GRLIB_MEMCFG1  (0x10f800ff | (1<<11))
-#define CONFIG_SYS_GRLIB_MEMCFG2  0x00000000
-#define CONFIG_SYS_GRLIB_MEMCFG3  0x00000000
-
-#define CONFIG_SYS_GRLIB_FT_MEMCFG1  (0x10f800ff | (1<<11))
-#define CONFIG_SYS_GRLIB_FT_MEMCFG2  0x00000000
-#define CONFIG_SYS_GRLIB_FT_MEMCFG3  0x00000000
-
-#define CONFIG_SYS_GRLIB_DDR_CFG  0xa900830a
-
-#define CONFIG_SYS_GRLIB_DDR2_CFG1 0x00000000
-#define CONFIG_SYS_GRLIB_DDR2_CFG3 0x00000000
+#define CONFIG_SYS_GRLIB_ESA_MCTRL1
+#define CONFIG_SYS_GRLIB_ESA_MCTRL1_CFG1  (0x10f800ff | (1<<11))
+#define CONFIG_SYS_GRLIB_ESA_MCTRL1_CFG2  0x00000000
+#define CONFIG_SYS_GRLIB_ESA_MCTRL1_CFG3  0x00000000
+
+/* GRLIB FT-MCTRL configuration */
+#define CONFIG_SYS_GRLIB_GAISLER_FTMCTRL1
+#define CONFIG_SYS_GRLIB_GAISLER_FTMCTRL1_CFG1  (0x10f800ff | (1<<11))
+#define CONFIG_SYS_GRLIB_GAISLER_FTMCTRL1_CFG2  0x00000000
+#define CONFIG_SYS_GRLIB_GAISLER_FTMCTRL1_CFG3  0x00000000
+
+/* DDR controller */
+#define CONFIG_SYS_GRLIB_GAISLER_DDRSPA1
+#define CONFIG_SYS_GRLIB_GAISLER_DDRSPA1_CTRL  0xa900830a
+
+/* no DDR2 Controller */
+#undef CONFIG_SYS_GRLIB_GAISLER_DDR2SPA1
 
 /* Calculate scaler register value from default baudrate */
 #define CONFIG_SYS_GRLIB_APBUART_SCALER \
include/configs/gr_xc3s_1500.h +13 -10
index 4dd9a0f..1f9dd4a 100644
@@ -288,25 +288,28 @@
 /* AMBA Plug & Play info display on startup */
 /*#define CONFIG_SYS_AMBAPP_PRINT_ON_STARTUP*/
 
-#define CONFIG_SYS_GRLIB_SDRAM    0
+/* No SDRAM Configuration */
+#undef CONFIG_SYS_GRLIB_GAISLER_SDCTRL1
 
 /* See, GRLIB Docs (grip.pdf) on how to set up
  * These the memory controller registers.
  */
-#define CONFIG_SYS_GRLIB_MEMCFG1   (0x000000ff | (1<<11))
-#define CONFIG_SYS_GRLIB_MEMCFG2   0x82206000
-#define CONFIG_SYS_GRLIB_MEMCFG3   0x00136000
+#define CONFIG_SYS_GRLIB_ESA_MCTRL1
+#define CONFIG_SYS_GRLIB_ESA_MCTRL1_CFG1   (0x000000ff | (1<<11))
+#define CONFIG_SYS_GRLIB_ESA_MCTRL1_CFG2   0x82206000
+#define CONFIG_SYS_GRLIB_ESA_MCTRL1_CFG3   0x00136000
 
-#define CONFIG_SYS_GRLIB_FT_MEMCFG1   (0x000000ff | (1<<11))
-#define CONFIG_SYS_GRLIB_FT_MEMCFG2   0x82206000
-#define CONFIG_SYS_GRLIB_FT_MEMCFG3   0x00136000
+/* GRLIB FT-MCTRL configuration */
+#define CONFIG_SYS_GRLIB_GAISLER_FTMCTRL1
+#define CONFIG_SYS_GRLIB_GAISLER_FTMCTRL1_CFG1   (0x000000ff | (1<<11))
+#define CONFIG_SYS_GRLIB_GAISLER_FTMCTRL1_CFG2   0x82206000
+#define CONFIG_SYS_GRLIB_GAISLER_FTMCTRL1_CFG3   0x00136000
 
 /* no DDR controller */
-#define CONFIG_SYS_GRLIB_DDR_CFG   0x00000000
+#undef CONFIG_SYS_GRLIB_GAISLER_DDRSPA1
 
 /* no DDR2 Controller */
-#define CONFIG_SYS_GRLIB_DDR2_CFG1 0x00000000
-#define CONFIG_SYS_GRLIB_DDR2_CFG3 0x00000000
+#undef CONFIG_SYS_GRLIB_GAISLER_DDR2SPA1
 
 /* Calculate scaler register value from default baudrate */
 #define CONFIG_SYS_GRLIB_APBUART_SCALER \
include/configs/grsim.h +16 -11
index c3f1a31..f815672 100644
@@ -307,27 +307,32 @@
 /* AMBA Plug & Play info display on startup */
 /*#define CONFIG_SYS_AMBAPP_PRINT_ON_STARTUP*/
 
-#define CONFIG_SYS_GRLIB_SDRAM     0
-#define CONFIG_SYS_GRLIB_MEMCFG1   (0x000000ff | (1<<11))
+/* No SDRAM Configuration */
+#undef CONFIG_SYS_GRLIB_GAISLER_SDCTRL1
+
+/* LEON2 MCTRL configuration */
+#define CONFIG_SYS_GRLIB_ESA_MCTRL1
+#define CONFIG_SYS_GRLIB_ESA_MCTRL1_CFG1   (0x000000ff | (1<<11))
 #if CONFIG_GRSIM
 /* GRSIM configuration */
-#define CONFIG_SYS_GRLIB_MEMCFG2   0x82206000
+#define CONFIG_SYS_GRLIB_ESA_MCTRL1_CFG2   0x82206000
 #else
 /* TSIM configuration */
-#define CONFIG_SYS_GRLIB_MEMCFG2   0x00001820
+#define CONFIG_SYS_GRLIB_ESA_MCTRL1_CFG2   0x00001820
 #endif
-#define CONFIG_SYS_GRLIB_MEMCFG3   0x00136000
+#define CONFIG_SYS_GRLIB_ESA_MCTRL1_CFG3   0x00136000
 
-#define CONFIG_SYS_GRLIB_FT_MEMCFG1   (0x000000ff | (1<<11))
-#define CONFIG_SYS_GRLIB_FT_MEMCFG2   0x82206000
-#define CONFIG_SYS_GRLIB_FT_MEMCFG3   0x00136000
+/* GRLIB FT-MCTRL configuration */
+#define CONFIG_SYS_GRLIB_GAISLER_FTMCTRL1
+#define CONFIG_SYS_GRLIB_GAISLER_FTMCTRL1_CFG1   (0x000000ff | (1<<11))
+#define CONFIG_SYS_GRLIB_GAISLER_FTMCTRL1_CFG2   0x82206000
+#define CONFIG_SYS_GRLIB_GAISLER_FTMCTRL1_CFG3   0x00136000
 
 /* no DDR controller */
-#define CONFIG_SYS_GRLIB_DDR_CFG   0x00000000
+#undef CONFIG_SYS_GRLIB_GAISLER_DDRSPA1
 
 /* no DDR2 Controller */
-#define CONFIG_SYS_GRLIB_DDR2_CFG1 0x00000000
-#define CONFIG_SYS_GRLIB_DDR2_CFG3 0x00000000
+#undef CONFIG_SYS_GRLIB_GAISLER_DDR2SPA1
 
 #define CONFIG_SYS_GRLIB_APBUART_SCALER \
  ((((CONFIG_SYS_CLK_FREQ*10)/(CONFIG_BAUDRATE*8))-5)/10)
Signature · 1 line
1.5.4
#6 lore raw

PATCH 5/17 LEON3: added memory controller initialization using the new AMBA PnP routines.

Dear Daniel Hellstrom,

Quoted 21 lines · In message <[email protected]> you wrote:
---
 arch/sparc/cpu/leon3/Makefile     |    5 +-
 arch/sparc/cpu/leon3/memcfg.c     |  276 +++++++++++++++++++++++++++++++++++++
 arch/sparc/cpu/leon3/memcfg.h     |  106 ++++++++++++++
 arch/sparc/cpu/leon3/memcfg_low.S |  270 ++++++++++++++++++++++++++++++++++++
 arch/sparc/cpu/leon3/start.S      |   36 +++++
 include/configs/gr_cpci_ax2000.h  |   27 ++--
 include/configs/gr_ep2s60.h       |   32 +++--
 include/configs/gr_xc3s_1500.h    |   23 ++--
 include/configs/grsim.h           |   27 ++--
 9 files changed, 754 insertions(+), 48 deletions(-)
 create mode 100644 arch/sparc/cpu/leon3/memcfg.c
 create mode 100644 arch/sparc/cpu/leon3/memcfg.h
 create mode 100644 arch/sparc/cpu/leon3/memcfg_low.S
arch/sparc/cpu/leon3/Makefile +0 -0
index d8f89bc..f1bb808 100644

arch/sparc/cpu/leon3/Makefile include $(TOPDIR)/config.mk · line 31

Quoted 8 lines
arch/sparc/cpu/leon3/Makefile +3 -2
@@ -26,8 +26,9 @@ include $(TOPDIR)/config.mk
 LIB	= $(obj)lib$(CPU).a
 
 START	= start.o
-SOBJS	= ambapp_low.o ambapp_low_c.o
-COBJS	= cpu_init.o serial.o cpu.o ambapp.o interrupts.o prom.o usb_uhci.o
+SOBJS	= ambapp_low.o ambapp_low_c.o memcfg_low.o
+COBJS	= cpu_init.o serial.o cpu.o ambapp.o interrupts.o prom.o usb_uhci.o \
+	memcfg.o

Please sort lists.

arch/sparc/cpu/leon3/memcfg.c line 3

Quoted 11 lines
arch/sparc/cpu/leon3/Makefile +0 -0
 SRCS	:= $(START:.o=.S) $(SOBJS:.o=.S) $(COBJS:.o=.c)
 OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
arch/sparc/cpu/leon3/memcfg.c new file +3 -0
new file mode 100644
index 0000000..4a9bded
@@ -0,0 +1,276 @@
+/* GRLIB Memory controller setup. The register values are used
+ * from the associated low level assembler routine implemented
+ * in memcfg_low.S.

Please apply all review comments to the previous patch here, too (white space, multiline comment style, brace style, etc.) Ditto for your other patches.

Best regards,

Wolfgang Denk

Signature · 5 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
Vor allem kein Gedanke! Nichts ist kompromittierender als ein  Gedan-
ke!            - Friedrich Wilhelm Nietzsche _Der Fall Wagner_ (1888)
#7 lore raw

PATCH 6/17 LEON3: Moved GRLIB core header files to common include/grlib directory

In reply to Daniel Hellstrom
---
 arch/sparc/cpu/leon3/cpu_init.c   |   10 +--
 arch/sparc/cpu/leon3/interrupts.c |    7 +-
 arch/sparc/cpu/leon3/memcfg.h     |    1 -
 arch/sparc/cpu/leon3/prom.c       |    7 ++-
 arch/sparc/cpu/leon3/serial.c     |   16 ++--
 drivers/net/greth.c               |    2 +-
 include/ambapp.h                  |  137 -------------------------------------
 include/grlib/apbuart.h           |   63 +++++++++++++++++
 include/grlib/gptimer.h           |   50 +++++++++++++
 include/grlib/greth.h             |  103 ++++++++++++++++++++++++++++
 include/grlib/irqmp.h             |   39 +++++++++++
 11 files changed, 277 insertions(+), 158 deletions(-)
 create mode 100644 include/grlib/apbuart.h
 create mode 100644 include/grlib/gptimer.h
 create mode 100644 include/grlib/greth.h
 create mode 100644 include/grlib/irqmp.h
arch/sparc/cpu/leon3/cpu_init.c +4 -6
index bc7e493..fd3e757 100644
@@ -28,6 +28,8 @@
 #include <asm/asi.h>
 #include <asm/leon.h>
 #include <ambapp.h>
+#include <grlib/irqmp.h>
+#include <grlib/gptimer.h>
 
 #include <config.h>
 
@@ -41,11 +43,7 @@ DECLARE_GLOBAL_DATA_PTR;
 /* reset CPU (jump to 0, without reset) */
 void start(void);
 
-/* find & initialize the memory controller */
-int init_memory_ctrl(void);
-
 ambapp_dev_irqmp *irqmp = NULL;
-ambapp_dev_mctrl memctrl;
 ambapp_dev_gptimer *gptimer = NULL;
 unsigned int gptimer_irq = 0;
 int leon3_snooping_avail = 0;
@@ -164,8 +162,8 @@ int timer_interrupt_init_cpu(void)
 	gptimer->e[0].val = 0;
 	gptimer->e[0].rld = 999;	/* (((1000000 / 100) - 1)) */
 	gptimer->e[0].ctrl =
-	    (LEON3_GPTIMER_EN |
-	     LEON3_GPTIMER_RL | LEON3_GPTIMER_LD | LEON3_GPTIMER_IRQEN);
+	    (GPTIMER_CTRL_EN | GPTIMER_CTRL_RS |
+	     GPTIMER_CTRL_LD | GPTIMER_CTRL_IE);
 
 	return gptimer_irq;
 }
arch/sparc/cpu/leon3/interrupts.c +4 -3
index ac6aca5..d927de1 100644
@@ -39,6 +39,8 @@
 
 #include <asm/leon.h>
 #include <ambapp.h>
+#include <grlib/irqmp.h>
+#include <grlib/gptimer.h>
 
 /* 15 normal irqs and a non maskable interrupt */
 #define NR_IRQS 15
@@ -141,9 +143,8 @@ int interrupt_init_cpu(void)
 /* Handle Timer 0 IRQ */
 void timer_interrupt_cpu(void *arg)
 {
-	gptimer->e[0].ctrl = (LEON3_GPTIMER_EN |
-			      LEON3_GPTIMER_RL |
-			      LEON3_GPTIMER_LD | LEON3_GPTIMER_IRQEN);
+	gptimer->e[0].ctrl = (GPTIMER_CTRL_EN | GPTIMER_CTRL_RS |
+			      GPTIMER_CTRL_LD | GPTIMER_CTRL_IE);
 	/* nothing to do here */
 	return;
 }
arch/sparc/cpu/leon3/memcfg.h +0 -1
index 0b4738e..02086ce 100644
@@ -54,7 +54,6 @@ extern struct grlib_mctrl_handler grlib_mctrl_handlers[];
 #define MH_STRUCT_SIZE		(4*4)
 #define MH_TYPE			0x00
 #define MH_INDEX		0x01
-#define MH_UNUSED		0x02
 #define MH_VENDOR_DEVICE	0x04
 #define MH_FUNC			0x08
 #define MH_PRIV			0x0c
arch/sparc/cpu/leon3/prom.c +5 -2
index 18d2fb2..86376bb 100644
@@ -32,6 +32,9 @@
 #include <asm/irq.h>
 #include <asm/leon.h>
 #include <ambapp.h>
+#include <grlib/apbuart.h>
+#include <grlib/irqmp.h>
+#include <grlib/gptimer.h>
 
 #include <config.h>
 /*
@@ -757,14 +760,14 @@ static int PROM_TEXT leon_nbputchar(int c)
 
 	/* Wait for last character to go. */
 	while (!(SPARC_BYPASS_READ(&uart->status)
-		 & LEON_REG_UART_STATUS_THE)) ;
+		 & APBUART_STATUS_THE)) ;
 
 	/* Send data */
 	SPARC_BYPASS_WRITE(&uart->data, c);
 
 	/* Wait for data to be sent */
 	while (!(SPARC_BYPASS_READ(&uart->status)
-		 & LEON_REG_UART_STATUS_TSE)) ;
+		 & APBUART_STATUS_TSE)) ;
 
 	return 0;
 }
arch/sparc/cpu/leon3/serial.c +8 -8
index 15c380e..8964310 100644
@@ -27,6 +27,7 @@
 #include <asm/processor.h>
 #include <asm/leon.h>
 #include <ambapp.h>
+#include <grlib/apbuart.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -69,9 +70,9 @@ int serial_init(void)
 		/* Let bit 11 be unchanged (debug bit for GRMON) */
 		tmp = READ_WORD(leon3_apbuart->ctrl);
 
-		leon3_apbuart->ctrl = ((tmp & LEON_REG_UART_CTRL_DBG) |
-				       LEON_REG_UART_CTRL_RE |
-				       LEON_REG_UART_CTRL_TE);
+		leon3_apbuart->ctrl = ((tmp & APBUART_CTRL_DBG) |
+				       APBUART_CTRL_RE |
+				       APBUART_CTRL_TE);
 
 		return 0;
 	}
@@ -92,14 +93,14 @@ void serial_putc_raw(const char c)
 		return;
 
 	/* Wait for last character to go. */
-	while (!(READ_WORD(leon3_apbuart->status) & LEON_REG_UART_STATUS_THE)) ;
+	while (!(READ_WORD(leon3_apbuart->status) & APBUART_STATUS_THE)) ;
 
 	/* Send data */
 	leon3_apbuart->data = c;
 
 #ifdef LEON_DEBUG
 	/* Wait for data to be sent */
-	while (!(READ_WORD(leon3_apbuart->status) & LEON_REG_UART_STATUS_TSE)) ;
+	while (!(READ_WORD(leon3_apbuart->status) & APBUART_STATUS_TSE)) ;
 #endif
 }
 
@@ -116,7 +117,7 @@ int serial_getc(void)
 		return 0;
 
 	/* Wait for a character to arrive. */
-	while (!(READ_WORD(leon3_apbuart->status) & LEON_REG_UART_STATUS_DR)) ;
+	while (!(READ_WORD(leon3_apbuart->status) & APBUART_STATUS_DR)) ;
 
 	/* read data */
 	return READ_WORD(leon3_apbuart->data);
@@ -125,8 +126,7 @@ int serial_getc(void)
 int serial_tstc(void)
 {
 	if (leon3_apbuart)
-		return (READ_WORD(leon3_apbuart->status) &
-			LEON_REG_UART_STATUS_DR);
+		return (READ_WORD(leon3_apbuart->status) & APBUART_STATUS_DR);
 	return 0;
 }
 
drivers/net/greth.c +1 -1
index fcccb99..4bbfe68 100644
@@ -35,7 +35,7 @@
 
 /* #define DEBUG */
 
-#include "greth.h"
+#include <grlib/greth.h>
 
 /* Default to 3s timeout on autonegotiation */
 #ifndef GRETH_PHY_TIMEOUT_MS
include/ambapp.h +0 -137

141 lines not on this page · raw message

include/grlib/apbuart.h new file +63 -0

63 lines not on this page · raw message

include/grlib/gptimer.h new file +50 -0

50 lines not on this page · raw message

include/grlib/greth.h new file +103 -0

103 lines not on this page · raw message

include/grlib/irqmp.h new file +39 -0
new file mode 100644
index 0000000..1cf45ee
@@ -0,0 +1,39 @@
+/* GRLIB IRQMP (IRQ Multi-processor controller) definitions
+ *
+ * (C) Copyright 2010
+ * Daniel Hellstrom, Aeroflex Gaisler, [email protected]
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * 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
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#ifndef __GRLIB_IRQMP_H__
+#define __GRLIB_IRQMP_H__
+
+typedef struct {
+	volatile unsigned int ilevel;
+	volatile unsigned int ipend;
+	volatile unsigned int iforce;
+	volatile unsigned int iclear;
+	volatile unsigned int mstatus;
+	volatile unsigned int notused[11];
+	volatile unsigned int cpu_mask[16];
+	volatile unsigned int cpu_force[16];
+} ambapp_dev_irqmp;
+
+#endif
Signature · 1 line
1.5.4
#8 lore raw

PATCH 6/17 LEON3: Moved GRLIB core header files to common include/grlib directory

Dear Daniel Hellstrom,

Quoted 18 lines · In message <[email protected]> you wrote:
---
 arch/sparc/cpu/leon3/cpu_init.c   |   10 +--
 arch/sparc/cpu/leon3/interrupts.c |    7 +-
 arch/sparc/cpu/leon3/memcfg.h     |    1 -
 arch/sparc/cpu/leon3/prom.c       |    7 ++-
 arch/sparc/cpu/leon3/serial.c     |   16 ++--
 drivers/net/greth.c               |    2 +-
 include/ambapp.h                  |  137 -------------------------------------
 include/grlib/apbuart.h           |   63 +++++++++++++++++
 include/grlib/gptimer.h           |   50 +++++++++++++
 include/grlib/greth.h             |  103 ++++++++++++++++++++++++++++
 include/grlib/irqmp.h             |   39 +++++++++++
 11 files changed, 277 insertions(+), 158 deletions(-)
 create mode 100644 include/grlib/apbuart.h
 create mode 100644 include/grlib/gptimer.h
 create mode 100644 include/grlib/greth.h
 create mode 100644 include/grlib/irqmp.h

...

include/grlib/apbuart.h line 4

Quoted 7 lines
include/grlib/apbuart.h new file +4 -0
@@ -0,0 +1,63 @@
+/* GRLIB APBUART definitions
+ *
+ * (C) Copyright 2010
+ * Daniel Hellstrom, Aeroflex Gaisler, daniel at gaisler.com

...

Incorrect multiline comment style.

OK, I give up review on this patch series now. Please apply all previously made review comments globally, to all patches in this series.

Then resubmit.

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
Drawing on my fine command of language, I said nothing.
#9 lore raw

PATCH 7/17 LEON3: serial baud rate register support multiple buses with different frequency.

In reply to Daniel Hellstrom
---
 arch/sparc/cpu/leon3/serial.c |   17 ++++++++++++++---
 1 files changed, 14 insertions(+), 3 deletions(-)
arch/sparc/cpu/leon3/serial.c +14 -3
index 8964310..1f17ede 100644
@@ -47,11 +47,18 @@ DECLARE_GLOBAL_DATA_PTR;
 #endif
 
 ambapp_dev_apbuart *leon3_apbuart = NULL;
+unsigned int apbuart_freq = CONFIG_SYS_CLK_FREQ;
+
+unsigned int apbuart_calc_scaler(unsigned int apbuart_freq, unsigned int baud)
+{
+	return ((((apbuart_freq*10)/(baud*8))-5)/10);
+}
 
 int serial_init(void)
 {
 	ambapp_apbdev apbdev;
 	unsigned int tmp;
+	unsigned int freq;
 
 	/* find UART */
 	if (ambapp_apb_find(&ambapp_plb, VENDOR_GAISLER, GAISLER_APBUART,
@@ -65,7 +72,13 @@ int serial_init(void)
 		 *
 		 * Receiver & transmitter enable
 		 */
+#ifdef CONFIG_SYS_GRLIB_APBUART_SCALER
 		leon3_apbuart->scaler = CONFIG_SYS_GRLIB_APBUART_SCALER;
+#else
+		/* APBUART Frequency is equal to bus frequency */
+		freq = ambapp_bus_freq(&ambapp_plb, apbdev.ahb_bus_index);
+		leon3_apbuart->scaler = apbuart_calc_scaler(freq, CONFIG_BAUDRATE);
+#endif
 
 		/* Let bit 11 be unchanged (debug bit for GRMON) */
 		tmp = READ_WORD(leon3_apbuart->ctrl);
@@ -136,9 +149,7 @@ void serial_setbrg(void)
 	/* update baud rate settings, read it from gd->baudrate */
 	unsigned int scaler;
 	if (leon3_apbuart && (gd->baudrate > 0)) {
-		scaler =
-		    (((CONFIG_SYS_CLK_FREQ * 10) / (gd->baudrate * 8)) -
-		     5) / 10;
+		scaler = apbuart_calc_scaler(apbuart_freq, gd->baudrate);
 		leon3_apbuart->scaler = scaler;
 	}
 	return;
Signature · 1 line
1.5.4
#10 lore raw

PATCH 8/17 SPARC: added function that checks if IRQ is on or off.

In reply to Daniel Hellstrom
---
 arch/sparc/include/asm/irq.h |    3 +++
 arch/sparc/lib/interrupts.c  |    7 +++++++
 2 files changed, 10 insertions(+), 0 deletions(-)
arch/sparc/include/asm/irq.h +3 -0
index c5538c0..ce78169 100644
@@ -46,4 +46,7 @@ extern int intLock(void);
 /* Sets the PIL to oldLevel */
 extern void intUnlock(int oldLevel);
 
+/* Return non-zero if interrupts are currently enabled */
+extern int interrupt_is_enabled(void);
+
 #endif
arch/sparc/lib/interrupts.c +7 -0
index 4c73b82..4d53e8c 100644
@@ -63,6 +63,13 @@ int disable_interrupts(void)
 	return intLock();
 }
 
+int interrupt_is_enabled(void)
+{
+	if ( get_pil() == 15 )
+		return 0;
+	return 1;
+}
+
 int interrupt_init(void)
 {
 	int ret;
Signature · 1 line
1.5.4
#11 lore raw

PATCH 9/17 LEON3: added busy wait function, made wait_ms() work when IRQ is disabled.

In reply to Daniel Hellstrom
---
 arch/sparc/cpu/leon3/cpu_init.c |   30 ++++++++++++++++++++++++++++--
 1 files changed, 28 insertions(+), 2 deletions(-)
arch/sparc/cpu/leon3/cpu_init.c +28 -2
index fd3e757..1829a08 100644
@@ -142,14 +142,40 @@ int cpu_init_r(void)
 	return (0);
 }
 
+/* Busy wait a number of ms */
+void cpu_wait_ms_busy(unsigned long ms)
+{
+	unsigned int ms_delay;
+	volatile unsigned int tmp;
+
+	/* ~10-20 cycles per decrement */
+	ms_delay = leon_cpu_freq / (1000 * 10);
+	do {
+		/* Wait ~1ms */
+		tmp = ms_delay;
+		while ( tmp-- > 0 )
+			;
+	} while ( --ms > 0 );
+}
+
 /* Uses Timer 0 to get accurate
  * pauses. Max 2 raised to 32 ticks
  *
  */
 void cpu_wait_ticks(unsigned long ticks)
 {
-	unsigned long start = get_timer(0);
-	while (get_timer(start) < ticks) ;
+	unsigned long start;
+
+	if ( interrupt_is_enabled() ) {
+		start = get_timer(0);
+		while (get_timer(start) < ticks) ;
+	} else {
+		/* Interrupts disabled, this means that we cannot
+		 * use get_timer(), it relies on IRQ. Instead the
+		 * CPU frequency is used.
+		 */
+		cpu_wait_ms_busy( ticks2usec(ticks) / 1000 );
+	}
 }
 
 /* initiate and setup timer0 interrupt to 1MHz
Signature · 1 line
1.5.4
#12 lore raw

PATCH 10/17 LEON3: added CPU count and frequency detection.

In reply to Daniel Hellstrom
---
 arch/sparc/cpu/leon3/cpu.c     |   42 +++++++++++++++++++++++++++++++++++++++-
 arch/sparc/include/asm/leon3.h |   13 ++++++++++++
 2 files changed, 54 insertions(+), 1 deletions(-)
arch/sparc/cpu/leon3/cpu.c +41 -1
index 976f311..5cc9513 100644
@@ -29,15 +29,55 @@
 
 #include <asm/io.h>
 #include <asm/processor.h>
+#include <ambapp.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
 extern void _reset_reloc(void);
 
+int leon_cpu_cnt = 1;
+int leon_ver = 3;
+unsigned int leon_cpu_freq = CONFIG_SYS_CLK_FREQ;
+
+int cpu_freq(void)
+{
+	ambapp_ahbdev dev;
+
+	if ( leon_ver == 3 ) {
+		ambapp_ahbmst_find(&ambapp_plb, VENDOR_GAISLER,
+			GAISLER_LEON3, 0, &dev);
+	} else {
+		ambapp_ahbmst_find(&ambapp_plb, VENDOR_GAISLER,
+			GAISLER_LEON4, 0, &dev);
+	}
+
+	leon_cpu_freq = ambapp_bus_freq(&ambapp_plb, dev.ahb_bus_index);
+}
+
 int checkcpu(void)
 {
+	int cnt;
+	char str[4];
+
 	/* check LEON version here */
-	printf("CPU: LEON3\n");
+	cnt = ambapp_ahbmst_count(&ambapp_plb, VENDOR_GAISLER, GAISLER_LEON3);
+	if ( cnt <= 0 ) {
+		cnt = ambapp_ahbmst_count(&ambapp_plb, VENDOR_GAISLER, GAISLER_LEON4);
+		if ( cnt > 0 )
+			leon_ver = 4;
+	}
+
+	cpu_freq();
+
+	str[0] = '\0';
+	if ( cnt > 1 ) {
+		leon_cpu_cnt = cnt;
+		str[0] = '0' + cnt;
+		str[1] = 'x';
+		str[2] = '\0';
+	}
+	printf("CPU: %sLEON%d @ %dMHz\n", str, leon_ver, leon_cpu_freq / 1000000);
+
 	return 0;
 }
 
arch/sparc/include/asm/leon3.h +13 -0
index b90d35b..60396c4 100644
@@ -33,4 +33,17 @@
  * ctrl, memory controllers etc.
  */
 
+
+#ifndef __ASSEMBLER__
+/* The frequency of the CPU */
+extern unsigned int leon_cpu_freq;
+
+/* Number of LEON processors in system */
+extern int leon_cpu_cnt;
+
+/* Ver/subversion of CPU */
+extern int leon_ver;
+
+#endif /* __ASSEMBLER__ */
+
 #endif
Signature · 1 line
1.5.4
#13 lore raw

PATCH 11/17 SPARC: removed USB stop from linux bootm, arch-independent bootm stop USB.

In reply to Daniel Hellstrom
---
 arch/sparc/lib/bootm.c |    8 --------
 1 files changed, 0 insertions(+), 8 deletions(-)
arch/sparc/lib/bootm.c +0 -8
index c62cf57..f517325 100644
@@ -35,10 +35,6 @@ extern image_header_t header;
 extern void srmmu_init_cpu(unsigned int entry);
 extern void prepare_bootargs(char *bootargs);
 
-#ifdef CONFIG_USB_UHCI
-extern int usb_lowlevel_stop(void);
-#endif
-
 /* sparc kernel argument (the ROM vector) */
 struct linux_romvec *kernel_arg_promvec;
 
@@ -125,10 +121,6 @@ int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t * images)
 	       linux_hdr->linuxver_minor, linux_hdr->linuxver_revision);
 #endif
 
-#ifdef CONFIG_USB_UHCI
-	usb_lowlevel_stop();
-#endif
-
 	/* set basic boot params in kernel header now that it has been
 	 * extracted and is writeable.
 	 */
Signature · 1 line
1.5.4
#14 lore raw

PATCH 12/17 SPARC: added optional cpu_late_init routine.

In reply to Daniel Hellstrom
---
 arch/sparc/lib/board.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
arch/sparc/lib/board.c +5 -0
index 11eea60..d829af0 100644
@@ -65,6 +65,7 @@ extern void timer_interrupt_init(void);
 extern void malloc_bin_reloc(void);
 extern int do_ambapp_print(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]);
 extern int prom_init(void);
+extern void cpu_late_init(void);
 
 #if defined(CONFIG__CMD_DOC)
 void doc_init(void);
@@ -353,6 +354,10 @@ void board_init_f(ulong bootflag)
 	/* relocate environment function pointers etc. */
 	env_relocate();
 
+#if defined(CONFIG_CPU_LATE_INIT)
+	cpu_late_init();
+#endif
+
 #if defined(CONFIG_BOARD_LATE_INIT)
 	board_late_init();
 #endif
Signature · 1 line
1.5.4
#15 lore raw

PATCH 13/17 LEON3: Added GRETH EDCL debug link IP address initialization.

In reply to Daniel Hellstrom
---
 arch/sparc/cpu/leon3/cpu_init.c |   14 ++++
 arch/sparc/cpu/leon3/greth.c    |  152 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 166 insertions(+), 0 deletions(-)
 create mode 100644 arch/sparc/cpu/leon3/greth.c
arch/sparc/cpu/leon3/cpu_init.c +14 -0
index 1829a08..bb394a1 100644
@@ -43,6 +43,9 @@ DECLARE_GLOBAL_DATA_PTR;
 /* reset CPU (jump to 0, without reset) */
 void start(void);
 
+/* Initialize GRETH EDCL on startup */
+extern void greth_edcl_init(void);
+
 ambapp_dev_irqmp *irqmp = NULL;
 ambapp_dev_gptimer *gptimer = NULL;
 unsigned int gptimer_irq = 0;
@@ -142,6 +145,17 @@ int cpu_init_r(void)
 	return (0);
 }
 
+/* Late CPU initialization
+ *
+ * At this point environment variables is available.
+ */
+void cpu_late_init(void)
+{
+#ifdef CONFIG_SYS_GRETH_EDCL_IP
+	greth_edcl_init();
+#endif
+}
+
 /* Busy wait a number of ms */
 void cpu_wait_ms_busy(unsigned long ms)
 {
arch/sparc/cpu/leon3/greth.c new file +152 -0

152 lines not on this page · raw message

Signature · 1 line
1.5.4
#16 lore raw

PATCH 14/17 LEON: added support for GRLIB SPI Memory controller, spi command interface.

In reply to Daniel Hellstrom
---
 arch/sparc/lib/board.c     |   14 +++
 drivers/spi/Makefile       |    1 +
 drivers/spi/spimctrl_spi.c |  263 ++++++++++++++++++++++++++++++++++++++++++++
 include/grlib/spimctrl.h   |   69 ++++++++++++
 4 files changed, 347 insertions(+), 0 deletions(-)
 create mode 100644 drivers/spi/spimctrl_spi.c
 create mode 100644 include/grlib/spimctrl.h
arch/sparc/lib/board.c +14 -0
index d829af0..3362f39 100644
@@ -97,6 +97,16 @@ static int init_baudrate(void)
 	return (0);
 }
 
+#if defined(CONFIG_HARD_SPI)
+static int init_func_spi (void)
+{
+        puts ("SPI:   ");
+        spi_init ();
+        puts ("ready\n");
+        return (0);
+}
+#endif
+
 /***********************************************************************/
 
 /*
@@ -304,6 +314,10 @@ void board_init_f(ulong bootflag)
 			CONFIG_SYS_MALLOC_END - CONFIG_SYS_MALLOC_BASE);
 	malloc_bin_reloc();
 
+#if defined(CONFIG_HARD_SPI)
+	init_func_spi();
+#endif
+
 #if !defined(CONFIG_SYS_NO_FLASH)
 	puts("FLASH: ");
 
drivers/spi/Makefile +1 -0
index f112ed0..9f7d81d 100644
@@ -35,6 +35,7 @@ COBJS-$(CONFIG_MPC52XX_SPI) += mpc52xx_spi.o
 COBJS-$(CONFIG_MPC8XXX_SPI) += mpc8xxx_spi.o
 COBJS-$(CONFIG_MXC_SPI) += mxc_spi.o
 COBJS-$(CONFIG_SOFT_SPI) += soft_spi.o
+COBJS-$(CONFIG_SPIMCTRL_SPI) += spimctrl_spi.o
 
 COBJS	:= $(COBJS-y)
 SRCS	:= $(COBJS:.o=.c)
drivers/spi/spimctrl_spi.c new file +263 -0

263 lines not on this page · raw message

include/grlib/spimctrl.h new file +69 -0

69 lines not on this page · raw message

Signature · 1 line
1.5.4
#17 lore raw

PATCH 15/17 LEON3: fixed MMU table for systems with larger memory than 128MB.

In reply to Daniel Hellstrom
---
 arch/sparc/cpu/leon3/prom.c |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)
arch/sparc/cpu/leon3/prom.c +16 -0
index 86376bb..e0a69af 100644
@@ -1059,6 +1059,22 @@ void srmmu_init_cpu(unsigned int entry)
 	    ((CONFIG_SYS_SDRAM_BASE + 0x6000000) >> 4) | ACC_SU_ALL | PTE;
 	psrmmu_tables->pgd_table[0xf7] =
 	    ((CONFIG_SYS_SDRAM_BASE + 0x7000000) >> 4) | ACC_SU_ALL | PTE;
+	psrmmu_tables->pgd_table[0xf8] =
+	    ((CONFIG_SYS_SDRAM_BASE + 0x8000000) >> 4) | ACC_SU_ALL | PTE;
+	psrmmu_tables->pgd_table[0xf9] =
+	    ((CONFIG_SYS_SDRAM_BASE + 0x9000000) >> 4) | ACC_SU_ALL | PTE;
+	psrmmu_tables->pgd_table[0xfa] =
+	    ((CONFIG_SYS_SDRAM_BASE + 0xa000000) >> 4) | ACC_SU_ALL | PTE;
+	psrmmu_tables->pgd_table[0xfb] =
+	    ((CONFIG_SYS_SDRAM_BASE + 0xb000000) >> 4) | ACC_SU_ALL | PTE;
+	psrmmu_tables->pgd_table[0xfc] =
+	    ((CONFIG_SYS_SDRAM_BASE + 0xc000000) >> 4) | ACC_SU_ALL | PTE;
+	psrmmu_tables->pgd_table[0xfd] =
+	    ((CONFIG_SYS_SDRAM_BASE + 0xd000000) >> 4) | ACC_SU_ALL | PTE;
+	psrmmu_tables->pgd_table[0xfe] =
+	    ((CONFIG_SYS_SDRAM_BASE + 0xe000000) >> 4) | ACC_SU_ALL | PTE;
+	psrmmu_tables->pgd_table[0xff] =
+	    ((CONFIG_SYS_SDRAM_BASE + 0xf000000) >> 4) | ACC_SU_ALL | PTE;
 
 	/* convert rom vec pointer to virtual address */
 	kernel_arg_promvec = (struct linux_romvec *)
Signature · 1 line
1.5.4
#18 lore raw

PATCH 16/17 bootm command: added argument to arch_preboot_os, function may depend on OS type.

In reply to Daniel Hellstrom
---
 arch/powerpc/cpu/mpc85xx/cpu_init.c |    2 +-
 common/cmd_bootm.c                  |    8 ++++----
 2 files changed, 5 insertions(+), 5 deletions(-)
arch/powerpc/cpu/mpc85xx/cpu_init.c +1 -1
index e578b29..61dd7ad 100644
@@ -403,7 +403,7 @@ int cpu_init_r(void)
 
 extern void setup_ivors(void);
 
-void arch_preboot_os(void)
+void arch_preboot_os(int os)
 {
 	u32 msr;
 
common/cmd_bootm.c +4 -4
index da06009..f5ca5c9 100644
@@ -154,11 +154,11 @@ ulong load_addr = CONFIG_SYS_LOAD_ADDR;	/* Default Load Address */
 static bootm_headers_t images;		/* pointers to os/initrd/fdt images */
 
 /* Allow for arch specific config before we boot */
-void __arch_preboot_os(void)
+void __arch_preboot_os(int os)
 {
 	/* please define platform specific arch_preboot_os() */
 }
-void arch_preboot_os(void) __attribute__((weak, alias("__arch_preboot_os")));
+void arch_preboot_os(int os) __attribute__((weak, alias("__arch_preboot_os")));
 
 #if defined(__ARM__)
   #define IH_INITRD_ARCH IH_ARCH_ARM
@@ -566,7 +566,7 @@ int do_bootm_subcommand (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 			break;
 		case BOOTM_STATE_OS_GO:
 			disable_interrupts();
-			arch_preboot_os();
+			arch_preboot_os(images.os.os);
 			boot_fn(BOOTM_STATE_OS_GO, argc, argv, &images);
 			break;
 	}
@@ -699,7 +699,7 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 		return 1;
 	}
 
-	arch_preboot_os();
+	arch_preboot_os(images.os.os);
 
 	boot_fn(0, argc, argv, &images);
 
Signature · 1 line
1.5.4
#19 lore raw

PATCH 17/17 SPARC, LEON3: added support for multiprocessing, tested Linux 2.6.21.1 SMP and RTEMS-4.10 AMP.

In reply to Daniel Hellstrom
---
 arch/sparc/cpu/leon3/Makefile           |    2 +-
 arch/sparc/cpu/leon3/cpu.c              |   10 ++-
 arch/sparc/cpu/leon3/cpu_mp.c           |   87 +++++++++++++++
 arch/sparc/cpu/leon3/prom.c             |   32 +++---
 arch/sparc/cpu/leon3/start.S            |   70 ++++++++++++
 arch/sparc/include/asm/boot_mp.h        |   70 ++++++++++++
 arch/sparc/lib/Makefile                 |    2 +-
 arch/sparc/lib/boot_mp.c                |  177 +++++++++++++++++++++++++++++++
 arch/sparc/lib/bootm.c                  |   57 ++++++++--
 board/gaisler/gr_cpci_ax2000/u-boot.lds |    7 ++
 board/gaisler/gr_ep2s60/u-boot.lds      |    7 ++
 board/gaisler/gr_xc3s_1500/u-boot.lds   |    7 ++
 board/gaisler/grsim/u-boot.lds          |    7 ++
 include/configs/gr_cpci_ax2000.h        |   12 ++-
 include/configs/gr_ep2s60.h             |   12 ++-
 include/configs/gr_xc3s_1500.h          |   14 ++-
 include/configs/grsim.h                 |   12 ++-
 17 files changed, 547 insertions(+), 38 deletions(-)
 create mode 100644 arch/sparc/cpu/leon3/cpu_mp.c
 create mode 100644 arch/sparc/include/asm/boot_mp.h
 create mode 100644 arch/sparc/lib/boot_mp.c
arch/sparc/cpu/leon3/Makefile +1 -1
index f1bb808..4d36061 100644
@@ -28,7 +28,7 @@ LIB	= $(obj)lib$(CPU).a
 START	= start.o
 SOBJS	= ambapp_low.o ambapp_low_c.o memcfg_low.o
 COBJS	= cpu_init.o serial.o cpu.o ambapp.o interrupts.o prom.o usb_uhci.o \
-	memcfg.o
+	memcfg.o cpu_mp.o
 
 SRCS	:= $(START:.o=.S) $(SOBJS:.o=.S) $(COBJS:.o=.c)
 OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
arch/sparc/cpu/leon3/cpu.c +8 -2
index 5cc9513..13d3dd7 100644
@@ -83,8 +83,14 @@ int checkcpu(void)
 
 /* ------------------------------------------------------------------------- */
 
-void cpu_reset(void)
+int cpu_reset(int nr)
 {
+	if ( nr > 0 ) {
+		puts(" CPU[N] RESET NOT SUPPORTED BY ARCHITECTURE (N>0), "
+		     "SYSTEM RESET IS POSSIBLE.");
+		return -1;
+	}
+
 	/* Interrupts off */
 	disable_interrupts();
 
@@ -94,7 +100,7 @@ void cpu_reset(void)
 
 int do_reset(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
 {
-	cpu_reset();
+	cpu_reset(0);
 
 	return 1;
 
arch/sparc/cpu/leon3/cpu_mp.c new file +87 -0

87 lines not on this page · raw message

arch/sparc/cpu/leon3/prom.c +17 -15
index e0a69af..eb7350b 100644
@@ -31,6 +31,7 @@
 #include <asm/processor.h>
 #include <asm/irq.h>
 #include <asm/leon.h>
+#include <asm/boot_mp.h>
 #include <ambapp.h>
 #include <grlib/apbuart.h>
 #include <grlib/irqmp.h>
@@ -931,21 +932,9 @@ void leon_prom_init(struct leon_prom_info *pspi)
 	/* Set the pointer to the Console UART in romvec */
 	pspi->reloc_funcs.leon3_apbuart = leon3_apbuart;
 
-	{
-		int j = 1;
-#ifdef CONFIG_SMP
-		ambapp_dev_irqmp *b;
-		b = (ambapp_dev_irqmp *) leon3_getapbbase(VENDOR_GAISLER,
-							  GAISLER_IRQMP);
-		if (b) {
-			j = 1 + ((LEON3_BYPASS_LOAD_PA(&(b->mpstatus))
-				  >> LEON3_IRQMPSTATUS_CPUNR) & 0xf);
-		}
-#endif
 #undef nodes
-		pspi->nodes[2 + j].level = -1;
-		pspi->nodes[2 + j].properties = __va(spi.root_properties + 3);
-	}
+	pspi->nodes[2 + leon_cpu_cnt].level = -1;
+	pspi->nodes[2 + leon_cpu_cnt].properties = __va(spi.root_properties + 3);
 
 	/* Set Ethernet MAC address from environment */
 	if ((addr_str = getenv("ethaddr")) != NULL) {
@@ -1024,7 +1013,7 @@ void prepare_bootargs(char *bootargs)
 	}
 }
 
-void srmmu_init_cpu(unsigned int entry)
+void srmmu_init(unsigned int entry)
 {
 	sparc_srmmu_setup *psrmmu_tables = (void *)
 	    ((((unsigned int)&srmmu_tables) & PROM_SIZE_MASK) +
@@ -1079,6 +1068,19 @@ void srmmu_init_cpu(unsigned int entry)
 	/* convert rom vec pointer to virtual address */
 	kernel_arg_promvec = (struct linux_romvec *)
 	    (((unsigned int)kernel_arg_promvec & 0x0fffffff) | 0xf0000000);
+}
+
+#ifdef CONFIG_MP
+/* This function must be located in the MP or PROM part of the application because
+ * it will be called from CPU1, CPU2 ...  after CPU0 has made it into the kernel
+ * and started the other CPUs
+ */
+void MP_TEXT boot_mp_linux_cpu_preinit(int cpu)
+#else
+void boot_mp_linux_cpu_preinit(int cpu)
+#endif
+{
+	sparc_srmmu_setup *psrmmu_tables = (void *)CONFIG_SYS_PROM_OFFSET;
 
 	/* Set Context pointer to point to context table
 	 * 256 contexts supported.
arch/sparc/cpu/leon3/start.S +70 -0

91 lines not on this page · raw message

arch/sparc/include/asm/boot_mp.h new file +70 -0

70 lines not on this page · raw message

arch/sparc/lib/Makefile +1 -1
index 040ca10..3860fdc 100644
@@ -27,7 +27,7 @@ LIB	= $(obj)lib$(ARCH).a
 
 SOBJS	=
 
-COBJS	= board.o cache.o interrupts.o time.o bootm.o
+COBJS	= board.o cache.o interrupts.o time.o bootm.o boot_mp.o
 
 SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
 OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
arch/sparc/lib/boot_mp.c new file +177 -0

177 lines not on this page · raw message

arch/sparc/lib/bootm.c +46 -11

102 lines not on this page · raw message

board/gaisler/gr_cpci_ax2000/u-boot.lds +7 -0
index 2282682..4f116a1 100644
@@ -72,6 +72,13 @@ SECTIONS
 		*(.prom.text)
 		. = ALIGN(16);
 		__prom_end = .;
+		/* Align MP section to the same as the MAX size of the MP section */
+		. = ALIGN(512);
+		__mp_start = .;
+		*(.mp.data)
+		*(.mp.text)
+		. = ALIGN(16);
+		__mp_end = .;
 		*(.text)
 		*(.fixup)
 		*(.gnu.warning)
board/gaisler/gr_ep2s60/u-boot.lds +7 -0
index 0ca2651..7c2d82c 100644
@@ -72,6 +72,13 @@ SECTIONS
 		*(.prom.text)
 		. = ALIGN(16);
 		__prom_end = .;
+		/* Align MP section to the same as the MAX size of the MP section */
+		. = ALIGN(512);
+		__mp_start = .;
+		*(.mp.data)
+		*(.mp.text)
+		. = ALIGN(16);
+		__mp_end = .;
 		*(.text)
 		*(.fixup)
 		*(.gnu.warning)
board/gaisler/gr_xc3s_1500/u-boot.lds +7 -0
index 67222ac..769df44 100644
@@ -72,6 +72,13 @@ SECTIONS
 		*(.prom.text)
 		. = ALIGN(16);
 		__prom_end = .;
+		/* Align MP section to the same as the MAX size of the MP section */
+		. = ALIGN(512);
+		__mp_start = .;
+		*(.mp.data)
+		*(.mp.text)
+		. = ALIGN(16);
+		__mp_end = .;
 		*(.text)
 		*(.fixup)
 		*(.gnu.warning)
board/gaisler/grsim/u-boot.lds +7 -0
index 681fd8d..c25d533 100644
@@ -71,6 +71,13 @@ SECTIONS
 		*(.prom.text)
 		. = ALIGN(16);
 		__prom_end = .;
+		/* Align MP section to the same as the MAX size of the MP section */
+		. = ALIGN(512);
+		__mp_start = .;
+		*(.mp.data)
+		*(.mp.text)
+		. = ALIGN(16);
+		__mp_end = .;
 		*(.text)
 		*(.fixup)
 		*(.gnu.warning)
include/configs/gr_cpci_ax2000.h +10 -2
index b9d45dd..a6d669d 100644
@@ -264,8 +264,16 @@
 #define CONFIG_SYS_GBL_DATA_SIZE	128	/* size in bytes reserved for initial data */
 #define CONFIG_SYS_GBL_DATA_OFFSET	(CONFIG_SYS_RAM_END - CONFIG_SYS_GBL_DATA_SIZE)
 
-#define CONFIG_SYS_PROM_SIZE		(8192-CONFIG_SYS_GBL_DATA_SIZE)
-#define CONFIG_SYS_PROM_OFFSET		(CONFIG_SYS_GBL_DATA_OFFSET-CONFIG_SYS_PROM_SIZE)
+#ifdef CONFIG_MP
+#define CONFIG_SYS_MP_SIZE		512
+#define CONFIG_SYS_MP_OFFSET		(CONFIG_SYS_GBL_DATA_OFFSET-CONFIG_SYS_MP_SIZE)
+#else
+#define CONFIG_SYS_MP_SIZE		0
+#define CONFIG_SYS_MP_OFFSET		CONFIG_SYS_GBL_DATA_OFFSET
+#endif
+
+#define CONFIG_SYS_PROM_SIZE		(8192-CONFIG_SYS_MP_SIZE-CONFIG_SYS_GBL_DATA_SIZE)
+#define CONFIG_SYS_PROM_OFFSET		(CONFIG_SYS_MP_OFFSET-CONFIG_SYS_PROM_SIZE)
 
 #define CONFIG_SYS_INIT_SP_OFFSET	(CONFIG_SYS_PROM_OFFSET-32)
 #define CONFIG_SYS_STACK_SIZE		(0x10000-32)
include/configs/gr_ep2s60.h +10 -2
index 6edb92c..10afca2 100644
@@ -232,8 +232,16 @@
 #define CONFIG_SYS_GBL_DATA_SIZE	128	/* size in bytes reserved for initial data */
 #define CONFIG_SYS_GBL_DATA_OFFSET	(CONFIG_SYS_SDRAM_END - CONFIG_SYS_GBL_DATA_SIZE)
 
-#define CONFIG_SYS_PROM_SIZE		(8192-CONFIG_SYS_GBL_DATA_SIZE)
-#define CONFIG_SYS_PROM_OFFSET		(CONFIG_SYS_GBL_DATA_OFFSET-CONFIG_SYS_PROM_SIZE)
+#ifdef CONFIG_MP
+#define CONFIG_SYS_MP_SIZE		512
+#define CONFIG_SYS_MP_OFFSET		(CONFIG_SYS_GBL_DATA_OFFSET-CONFIG_SYS_MP_SIZE)
+#else
+#define CONFIG_SYS_MP_SIZE		0
+#define CONFIG_SYS_MP_OFFSET		CONFIG_SYS_GBL_DATA_OFFSET
+#endif
+
+#define CONFIG_SYS_PROM_SIZE		(8192-CONFIG_SYS_MP_SIZE-CONFIG_SYS_GBL_DATA_SIZE)
+#define CONFIG_SYS_PROM_OFFSET		(CONFIG_SYS_MP_OFFSET-CONFIG_SYS_PROM_SIZE)
 
 #define CONFIG_SYS_INIT_SP_OFFSET	(CONFIG_SYS_PROM_OFFSET-32)
 #define CONFIG_SYS_STACK_SIZE		(0x10000-32)
include/configs/gr_xc3s_1500.h +12 -2
index 1f9dd4a..b57640a 100644
@@ -54,6 +54,8 @@
 #define CONFIG_DOS_PARTITION
 #define CONFIG_MAC_PARTITION
 #define CONFIG_ISO_PARTITION
+#define CONFIG_MP
+#define CONFIG_MP_MAX_CPUS 4
 
 /*
  * Supported commands
@@ -209,8 +211,16 @@
 #define CONFIG_SYS_GBL_DATA_SIZE	128	/* size in bytes reserved for initial data */
 #define CONFIG_SYS_GBL_DATA_OFFSET	(CONFIG_SYS_RAM_END - CONFIG_SYS_GBL_DATA_SIZE)
 
-#define CONFIG_SYS_PROM_SIZE		(8192-CONFIG_SYS_GBL_DATA_SIZE)
-#define CONFIG_SYS_PROM_OFFSET		(CONFIG_SYS_GBL_DATA_OFFSET-CONFIG_SYS_PROM_SIZE)
+#ifdef CONFIG_MP
+#define CONFIG_SYS_MP_SIZE		512
+#define CONFIG_SYS_MP_OFFSET		(CONFIG_SYS_GBL_DATA_OFFSET-CONFIG_SYS_MP_SIZE)
+#else
+#define CONFIG_SYS_MP_SIZE		0
+#define CONFIG_SYS_MP_OFFSET		CONFIG_SYS_GBL_DATA_OFFSET
+#endif
+
+#define CONFIG_SYS_PROM_SIZE		(8192-CONFIG_SYS_MP_SIZE-CONFIG_SYS_GBL_DATA_SIZE)
+#define CONFIG_SYS_PROM_OFFSET		(CONFIG_SYS_MP_OFFSET-CONFIG_SYS_PROM_SIZE)
 
 #define CONFIG_SYS_INIT_SP_OFFSET	(CONFIG_SYS_PROM_OFFSET-32)
 #define CONFIG_SYS_STACK_SIZE		(0x10000-32)
include/configs/grsim.h +10 -2
index f815672..9e177e6 100644
@@ -234,8 +234,16 @@
 #define CONFIG_SYS_GBL_DATA_SIZE	128	/* size in bytes reserved for initial data */
 #define CONFIG_SYS_GBL_DATA_OFFSET	(CONFIG_SYS_RAM_END - CONFIG_SYS_GBL_DATA_SIZE)
 
-#define CONFIG_SYS_PROM_SIZE		(8192-CONFIG_SYS_GBL_DATA_SIZE)
-#define CONFIG_SYS_PROM_OFFSET		(CONFIG_SYS_GBL_DATA_OFFSET-CONFIG_SYS_PROM_SIZE)
+#ifdef CONFIG_MP
+#define CONFIG_SYS_MP_SIZE		512
+#define CONFIG_SYS_MP_OFFSET		(CONFIG_SYS_GBL_DATA_OFFSET-CONFIG_SYS_MP_SIZE)
+#else
+#define CONFIG_SYS_MP_SIZE		0
+#define CONFIG_SYS_MP_OFFSET		CONFIG_SYS_GBL_DATA_OFFSET
+#endif
+
+#define CONFIG_SYS_PROM_SIZE		(8192-CONFIG_SYS_MP_SIZE-CONFIG_SYS_GBL_DATA_SIZE)
+#define CONFIG_SYS_PROM_OFFSET		(CONFIG_SYS_MP_OFFSET-CONFIG_SYS_PROM_SIZE)
 
 #define CONFIG_SYS_INIT_SP_OFFSET	(CONFIG_SYS_PROM_OFFSET-32)
 #define CONFIG_SYS_STACK_SIZE		(0x10000-32)
Signature · 1 line
1.5.4
#20 lore raw

PATCH 2/17 GRETH: Added support for selecting PHY address from config, PHY address was always set to zero before.

In reply to Daniel Hellstrom

Dear Daniel Hellstrom,

Quoted 4 lines · In message <[email protected]> you wrote:
---
 drivers/net/greth.c |   69 +++++++++++++++++++++++++++++++-------------------
 1 files changed, 43 insertions(+), 26 deletions(-)

Sorry for the late review...

drivers/net/greth.c int greth_init_phy(greth_priv * dev, bd_t * bis) · line 225

Quoted 5 lines
drivers/net/greth.c +5 -0
+#ifdef CONFIG_SYS_GRLIB_GRETH_PHYADDR
+	int phyaddr = CONFIG_SYS_GRLIB_GRETH_PHYADDR;
+#else
+	int phyaddr = 0;
+#endif

Please make this:

#ifndef CONFIG_SYS_GRLIB_GRETH_PHYADDR
#define CONFIG_SYS_GRLIB_GRETH_PHYADDR 0
#endif
int phyaddr = CONFIG_SYS_GRLIB_GRETH_PHYADDR;

Quoted 3 lines
drivers/net/greth.c +3 -0
+#ifdef DEBUG
+			printf("greth_init_phy: PHY read 1 failed\n");
+#endif

...

drivers/net/greth.c int greth_init_phy(greth_priv * dev, bd_t * bis) · line 253

Quoted 3 lines
drivers/net/greth.c +3 -0
+#ifdef DEBUG
+			printf("greth_init_phy: PHY read 2 failed\n");
+#endif

Please change all these into debug() calls and drop the #ifdef's.

Also, this patch needs to go through Ben's networking repository.

Best regards,

Wolfgang Denk

Signature · 5 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
Do you suppose the reason the ends of the `Intel Inside'  logo  don't
match up is that it was drawn on a Pentium?