فهرست منبع

* Patch by Steven Scholz, 18 Oct 2003:
Fix AT91RM9200 ethernet driver

* Patch by Nye Liu, 17 Oct 2003:
Fix typo in include/mpc8xx.h

* Patch by Richard Woodruff, 16 Oct 03:
Fixes for cpu/arm925/interrupt.c
- Initialize timestamp & lastdec vars.
- fix timestamp overflows.
- fix lastdec overflow.
- smarter normalization to allow udelay() below 1ms to work.

* Patch by Scott McNutt, 16 Oct
add networking support for the Altera Nios Development Kit,
Cyclone Edition (DK-1C20)

* Patch by Jon Diekema, 14 Oct 2003:
add hint about doc/README.silent to README file

wdenk 21 سال پیش
والد
کامیت
a3ad8e26a4
10فایلهای تغییر یافته به همراه119 افزوده شده و 38 حذف شده
  1. 20 0
      CHANGELOG
  2. 5 0
      README
  3. 46 23
      cpu/arm925t/interrupts.c
  4. 3 3
      cpu/at91rm9200/at91rm9200_ether.c
  5. 5 2
      doc/README.dk1c20
  6. 1 3
      doc/README.nios
  7. 25 0
      drivers/smc91111.h
  8. 3 6
      include/configs/DK1C20.h
  9. 1 1
      include/mpc8xx.h
  10. 10 0
      lib_nios/board.c

+ 20 - 0
CHANGELOG

@@ -2,6 +2,26 @@
 Changes for U-Boot 1.0.0:
 Changes for U-Boot 1.0.0:
 ======================================================================
 ======================================================================
 
 
+* Patch by Steven Scholz, 18 Oct 2003:
+  Fix AT91RM9200 ethernet driver
+
+* Patch by Nye Liu, 17 Oct 2003:
+  Fix typo in include/mpc8xx.h
+
+* Patch by Richard Woodruff, 16 Oct 03:
+  Fixes for cpu/arm925/interrupt.c
+  - Initialize timestamp & lastdec vars.
+  - fix timestamp overflows.
+  - fix lastdec overflow.
+  - smarter normalization to allow udelay() below 1ms to work.
+
+* Patch by Scott McNutt, 16 Oct
+  add networking support for the Altera Nios Development Kit,
+  Cyclone Edition (DK-1C20)
+
+* Patch by Jon Diekema, 14 Oct 2003:
+  add hint about doc/README.silent to README file
+
 * Add CompactFlash support for NSCU
 * Add CompactFlash support for NSCU
 
 
 * Fix PCI problems on PPChameleonEVB
 * Fix PCI problems on PPChameleonEVB

+ 5 - 0
README

@@ -487,6 +487,11 @@ The following options need to be configured:
 		default i/o. Serial console can be forced with
 		default i/o. Serial console can be forced with
 		environment 'console=serial'.
 		environment 'console=serial'.
 
 
+                When CONFIG_SILENT_CONSOLE is defined, all console
+                messages (by U-Boot and Linux!) can be silenced with
+                the "silent" environment variable. See
+                doc/README.silent for more information.
+
 - Console Baudrate:
 - Console Baudrate:
 		CONFIG_BAUDRATE - in bps
 		CONFIG_BAUDRATE - in bps
 		Select one of the baudrates listed in
 		Select one of the baudrates listed in

+ 46 - 23
cpu/arm925t/interrupts.c

@@ -185,9 +185,14 @@ int interrupt_init (void)
 {
 {
 	int32_t val;
 	int32_t val;
 
 
+	/* Start the decrementer ticking down from 0xffffffff */
 	*((int32_t *) (CFG_TIMERBASE + LOAD_TIM)) = TIMER_LOAD_VAL;
 	*((int32_t *) (CFG_TIMERBASE + LOAD_TIM)) = TIMER_LOAD_VAL;
 	val = MPUTIM_ST | MPUTIM_AR | MPUTIM_CLOCK_ENABLE | (CFG_PVT << MPUTIM_PTV_BIT);
 	val = MPUTIM_ST | MPUTIM_AR | MPUTIM_CLOCK_ENABLE | (CFG_PVT << MPUTIM_PTV_BIT);
 	*((int32_t *) (CFG_TIMERBASE + CNTL_TIMER)) = val;
 	*((int32_t *) (CFG_TIMERBASE + CNTL_TIMER)) = val;
+
+	/* init the timestamp and lastdec value */
+	reset_timer_masked();
+
 	return (0);
 	return (0);
 }
 }
 
 
@@ -210,7 +215,7 @@ void set_timer (ulong t)
 	timestamp = t;
 	timestamp = t;
 }
 }
 
 
-/* very rough timer... */
+/* delay x useconds AND perserve advance timstamp value */
 void udelay (unsigned long usec)
 void udelay (unsigned long usec)
 {
 {
 #ifdef CONFIG_INNOVATOROMAP1510
 #ifdef CONFIG_INNOVATOROMAP1510
@@ -220,16 +225,24 @@ void udelay (unsigned long usec)
 	for (i = time_remaining; i > 0; i--) {
 	for (i = time_remaining; i > 0; i--) {
 	}
 	}
 #else
 #else
+	ulong tmo, tmp;
+
+	if(usec >= 1000){               /* if "big" number, spread normalization to seconds */
+		tmo = usec / 1000;      /* start to normalize for usec to ticks per sec */
+		tmo *= CFG_HZ;          /* find number of "ticks" to wait to achieve target */
+		tmo /= 1000;            /* finish normalize. */
+	}else{                          /* else small number, don't kill it prior to HZ multiply */
+		tmo = usec * CFG_HZ;
+		tmo /= (1000*1000);
+	}
 
 
-	ulong tmo;
-
-	tmo = usec / 1000;
-	tmo *= CFG_HZ;
-	tmo /= 1000;
-
-	tmo += get_timer (0);
+	tmp = get_timer (0);		/* get current timestamp */
+	if( (tmo + tmp) < tmp ) 	/* if setting this fordward will roll time stamp */
+		reset_timer_masked ();	/* reset "advancing" timestamp to 0, set lastdec value */
+	else
+		tmo += tmp;		/* else, set advancing stamp wake up time */
 
 
-	while (get_timer_masked () < tmo)
+	while (get_timer_masked () < tmo)/* loop till event */
 		/*NOP*/;
 		/*NOP*/;
 #endif
 #endif
 }
 }
@@ -237,19 +250,23 @@ void udelay (unsigned long usec)
 void reset_timer_masked (void)
 void reset_timer_masked (void)
 {
 {
 	/* reset time */
 	/* reset time */
-	lastdec = READ_TIMER;
-	timestamp = 0;
+	lastdec = READ_TIMER;  /* capure current decrementer value time */
+	timestamp = 0;         /* start "advancing" time stamp from 0 */
 }
 }
 
 
 ulong get_timer_masked (void)
 ulong get_timer_masked (void)
 {
 {
-	ulong now = READ_TIMER;           /* current tick value */
+	ulong now = READ_TIMER;		/* current tick value */
 
 
-	if (lastdec >= now) {             /* did I roll (rem decrementer) */
+	if (lastdec >= now) {		/* normal mode (non roll) */
 		/* normal mode */
 		/* normal mode */
-		timestamp += lastdec - now;   /* record amount of time since last check */
-	} else {
-		/* we have an overflow ... */
+		timestamp += lastdec - now; /* move stamp fordward with absoulte diff ticks */
+	} else {			/* we have overflow of the count down timer */
+		/* nts = ts + ld + (TLV - now)
+		 * ts=old stamp, ld=time that passed before passing through -1
+		 * (TLV-now) amount of time after passing though -1
+		 * nts = new "advancing time stamp"...it could also roll and cause problems.
+		 */
 		timestamp += lastdec + TIMER_LOAD_VAL - now;
 		timestamp += lastdec + TIMER_LOAD_VAL - now;
 	}
 	}
 	lastdec = now;
 	lastdec = now;
@@ -257,6 +274,7 @@ ulong get_timer_masked (void)
 	return timestamp;
 	return timestamp;
 }
 }
 
 
+/* waits specified delay value and resets timestamp */
 void udelay_masked (unsigned long usec)
 void udelay_masked (unsigned long usec)
 {
 {
 #ifdef CONFIG_INNOVATOROMAP1510
 #ifdef CONFIG_INNOVATOROMAP1510
@@ -265,15 +283,20 @@ void udelay_masked (unsigned long usec)
     for (i=time_remaining; i>0; i--) { }
     for (i=time_remaining; i>0; i--) { }
 #else
 #else
 
 
-	ulong tmo;
+	ulong tmo, tmp;
 
 
-	tmo = usec / 1000;
-	tmo *= CFG_HZ;
-	tmo /= 1000;
+	if(usec >= 1000){               /* if "big" number, spread normalization to seconds */
+		tmo = usec / 1000;      /* start to normalize for usec to ticks per sec */
+		tmo *= CFG_HZ;          /* find number of "ticks" to wait to achieve target */
+		tmo /= 1000;            /* finish normalize. */
+	}else{                          /* else small number, don't kill it prior to HZ multiply */
+		tmo = usec * CFG_HZ;
+		tmo /= (1000*1000);
+	}
 
 
-	reset_timer_masked ();
+	reset_timer_masked ();	/* set "advancing" timestamp to 0, set lastdec vaule */
 
 
-	while (get_timer_masked () < tmo)
+	while (get_timer_masked () < tmo) /* wait for time stamp to overtake tick number.*/
 		/*NOP*/;
 		/*NOP*/;
 #endif
 #endif
 }
 }
@@ -292,7 +315,7 @@ unsigned long long get_ticks(void)
  * On ARM it returns the number of timer ticks per second.
  * On ARM it returns the number of timer ticks per second.
  */
  */
 ulong get_tbclk (void)
 ulong get_tbclk (void)
-{	/* poor timer, may need to improve especiall for bootp. */
+{
 	ulong tbclk;
 	ulong tbclk;
 
 
 	tbclk = CFG_HZ;
 	tbclk = CFG_HZ;

+ 3 - 3
cpu/at91rm9200/at91rm9200_ether.c

@@ -334,12 +334,12 @@ static UCHAR at91rm9200_EmacReadPhy (AT91PS_EMAC p_mac,
  *	TRUE - if data read successfully
  *	TRUE - if data read successfully
  */
  */
 static UCHAR at91rm9200_EmacWritePhy (AT91PS_EMAC p_mac,
 static UCHAR at91rm9200_EmacWritePhy (AT91PS_EMAC p_mac,
-									  unsigned char RegisterAddress,
-									  unsigned short *pOutput)
+				      unsigned char RegisterAddress,
+				      unsigned short *pOutput)
 {
 {
 	p_mac->EMAC_MAN = (AT91C_EMAC_HIGH & ~AT91C_EMAC_LOW) |
 	p_mac->EMAC_MAN = (AT91C_EMAC_HIGH & ~AT91C_EMAC_LOW) |
 			AT91C_EMAC_CODE_802_3 | AT91C_EMAC_RW_W |
 			AT91C_EMAC_CODE_802_3 | AT91C_EMAC_RW_W |
-			(RegisterAddress << 18);
+			(RegisterAddress << 18) | *pOutput;
 
 
 	udelay (10000);
 	udelay (10000);
 
 

+ 5 - 2
doc/README.dk1c20

@@ -2,7 +2,7 @@
 			 Nios Development Kit
 			 Nios Development Kit
 			   Cyclone Editions
 			   Cyclone Editions
 
 
-		    Last Update: October 4, 2003
+		    Last Update: October 15, 2003
 ====================================================================
 ====================================================================
 
 
 This file contains information regarding U-Boot and the Altera
 This file contains information regarding U-Boot and the Altera
@@ -34,7 +34,10 @@ The hello_world example works fine.
 Programming U-Boot into FLASH with GERMS
 Programming U-Boot into FLASH with GERMS
 -----------------------------------------
 -----------------------------------------
 The current version of the DK-1C20 port occupies less than
 The current version of the DK-1C20 port occupies less than
-60 KByte. So everything will fit into a single Flash sector.
+60 KByte with network support disabled. So everything will fit
+into a single flash sector. With network support (e.g. bootp,
+tftpboot, ping, etc) the flash footprint is about 77K.
+
 To program U-Boot into the DK-1C20 flash using GERMS do the
 To program U-Boot into the DK-1C20 flash using GERMS do the
 following:
 following:
 
 

+ 1 - 3
doc/README.nios

@@ -1,7 +1,7 @@
 
 
 			   U-Boot for Nios-32
 			   U-Boot for Nios-32
 
 
-		    Last Update: October 4, 2003
+		    Last Update: October 15, 2003
 ====================================================================
 ====================================================================
 
 
 This file contains information regarding U-Boot and the Altera
 This file contains information regarding U-Boot and the Altera
@@ -173,8 +173,6 @@ BTW, thats a 'zero' ... not the letter 'O'.
 There are plenty of areas where help is needed. Here's are some ideas
 There are plenty of areas where help is needed. Here's are some ideas
 for those interested in contributing:
 for those interested in contributing:
 
 
--SMC 91C111 support. E.g. add in tftpboot, etc.
-
 -CompactFlash. Port & test CF/FAT.
 -CompactFlash. Port & test CF/FAT.
 
 
 -ASMI support. Use ASMI for environment, etc.
 -ASMI support. Use ASMI for environment, etc.

+ 25 - 0
drivers/smc91111.h

@@ -178,6 +178,31 @@ typedef unsigned long int 		dword;
 				})
 				})
 #endif
 #endif
 
 
+#if defined(CONFIG_SMC_USE_32_BIT)
+
+#define	SMC_inl(r) 	(*((volatile dword *)(SMC_BASE_ADDRESS+(r))))
+
+#define SMC_insl(r,b,l) 	({	int __i ;  \
+					dword *__b2;  \
+			    		__b2 = (dword *) b;  \
+			    		for (__i = 0; __i < l; __i++) {  \
+					  *(__b2 + __i) = SMC_inl(r);  \
+					  SMC_inl(0);  \
+					};  \
+				})
+
+#define	SMC_outl(d,r)	(*((volatile dword *)(SMC_BASE_ADDRESS+(r))) = d)
+
+#define SMC_outsl(r,b,l)	({	int __i; \
+					dword *__b2; \
+					__b2 = (dword *) b; \
+					for (__i = 0; __i < l; __i++) { \
+					    SMC_outl( *(__b2 + __i), r); \
+					} \
+				})
+
+#endif /* CONFIG_SMC_USE_32_BIT */
+
 #endif
 #endif
 
 
 /*---------------------------------------------------------------
 /*---------------------------------------------------------------

+ 3 - 6
include/configs/DK1C20.h

@@ -96,12 +96,10 @@
 /*------------------------------------------------------------------------
 /*------------------------------------------------------------------------
  * Ethernet -- needs work!
  * Ethernet -- needs work!
  *----------------------------------------------------------------------*/
  *----------------------------------------------------------------------*/
-#if 0
 #define CONFIG_DRIVER_SMC91111			/* Using SMC91c111	*/
 #define CONFIG_DRIVER_SMC91111			/* Using SMC91c111	*/
-#define CONFIG_SMC91111_BASE	0x00910000	/* Base address		*/
-#undef  CONFIG_SMC91111_EXT_PHY			/* No external PHY	*/
-#define CONFIG_SMC_USE_32_BIT	1		/* 32-bit i/f		*/
-#endif
+#define CONFIG_SMC91111_BASE	0x00910300	/* Base address		*/
+#undef  CONFIG_SMC91111_EXT_PHY			/* Internal PHY		*/
+#define CONFIG_SMC_USE_32_BIT			/* 32-bit data rd/wr	*/
 
 
 #define CONFIG_ETHADDR		08:00:3e:26:0a:5b
 #define CONFIG_ETHADDR		08:00:3e:26:0a:5b
 #define CONFIG_NETMASK		255.255.255.0
 #define CONFIG_NETMASK		255.255.255.0
@@ -131,7 +129,6 @@
 				 CFG_CMD_JFFS2	| \
 				 CFG_CMD_JFFS2	| \
 				 CFG_CMD_KGDB	| \
 				 CFG_CMD_KGDB	| \
 				 CFG_CMD_NAND	| \
 				 CFG_CMD_NAND	| \
-				 CFG_CMD_NET	| \
 				 CFG_CMD_MMC	| \
 				 CFG_CMD_MMC	| \
 				 CFG_CMD_MII	| \
 				 CFG_CMD_MII	| \
 				 CFG_CMD_PCI	| \
 				 CFG_CMD_PCI	| \

+ 1 - 1
include/mpc8xx.h

@@ -138,7 +138,7 @@
 #define PLPRCR_MF_MSK	0xffff001e	/* Multiplication factor + PDF bits	*/
 #define PLPRCR_MF_MSK	0xffff001e	/* Multiplication factor + PDF bits	*/
 #define PLPRCR_MFN_MSK	0xf8000000	/* Multiplication factor numerator bits */
 #define PLPRCR_MFN_MSK	0xf8000000	/* Multiplication factor numerator bits */
 #define PLPRCR_MFN_SHIFT 0x0000001b	/* Multiplication factor numerator shift*/
 #define PLPRCR_MFN_SHIFT 0x0000001b	/* Multiplication factor numerator shift*/
-#define PLPRCR_MFD_MSK	0x03c00000	/* Multiplication factor denominator bits */
+#define PLPRCR_MFD_MSK	0x07c00000	/* Multiplication factor denominator bits */
 #define PLPRCR_MFD_SHIFT 0x00000017	/* Multiplication factor denominator shift*/
 #define PLPRCR_MFD_SHIFT 0x00000017	/* Multiplication factor denominator shift*/
 #define PLPRCR_S_MSK	0x00300000	/* Multiplication factor integer bits	*/
 #define PLPRCR_S_MSK	0x00300000	/* Multiplication factor integer bits	*/
 #define PLPRCR_S_SHIFT	0x00000014	/* Multiplication factor integer shift	*/
 #define PLPRCR_S_SHIFT	0x00000014	/* Multiplication factor integer shift	*/

+ 10 - 0
lib_nios/board.c

@@ -27,6 +27,7 @@
 #include <common.h>
 #include <common.h>
 #include <devices.h>
 #include <devices.h>
 #include <watchdog.h>
 #include <watchdog.h>
+#include <net.h>
 
 
 
 
 /*
 /*
@@ -107,6 +108,8 @@ void board_init (void)
 
 
 	bd_t *bd;
 	bd_t *bd;
 	init_fnc_t **init_fnc_ptr;
 	init_fnc_t **init_fnc_ptr;
+	char *s, *e;
+	int i;
 
 
 	/* Pointer is writable since we allocated a register for it.
 	/* Pointer is writable since we allocated a register for it.
 	 * Nios treats CFG_GBL_DATA_OFFSET as an address.
 	 * Nios treats CFG_GBL_DATA_OFFSET as an address.
@@ -129,6 +132,12 @@ void board_init (void)
 	bd->bi_sramstart= CFG_SRAM_BASE;
 	bd->bi_sramstart= CFG_SRAM_BASE;
 	bd->bi_sramsize	= CFG_SRAM_SIZE;
 	bd->bi_sramsize	= CFG_SRAM_SIZE;
 	bd->bi_baudrate	= CONFIG_BAUDRATE;
 	bd->bi_baudrate	= CONFIG_BAUDRATE;
+	bd->bi_ip_addr = getenv_IPaddr ("ipaddr");
+	s = getenv ("ethaddr");
+	for (i = 0; i < 6; ++i) {
+		bd->bi_enetaddr[i] = s ? simple_strtoul (s, &e, 16) : 0;
+		if (s) s = (*e) ? e + 1 : e;
+	}
 
 
 	for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) {
 	for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) {
 		if ((*init_fnc_ptr) () != 0) {
 		if ((*init_fnc_ptr) () != 0) {
@@ -164,3 +173,4 @@ void hang (void)
 	puts("### ERROR ### Please reset board ###\n");
 	puts("### ERROR ### Please reset board ###\n");
 	for (;;);
 	for (;;);
 }
 }
+