and added files (forgot git commit -a again)
authorDobrica Pavlinusic <dpavlin@brr.lan>
Wed, 25 Jul 2007 08:08:29 +0000 (03:08 -0500)
committerDobrica Pavlinusic <dpavlin@brr.lan>
Wed, 25 Jul 2007 08:08:29 +0000 (03:08 -0500)
21 files changed:
MAKEALL
Makefile
common/cmd_bootm.c
common/cmd_ext2.c
common/console.c
common/main.c
cpu/mpc824x/cpu.c
cpu/mpc824x/start.S
drivers/dc2114x.c
drivers/netconsole.c
drivers/rtl8169.c
fs/ext2/ext2fs.c
include/devices.h
include/flash.h
include/pci_ids.h
include/version.h
lib_ppc/board.c
lib_ppc/interrupts.c
net/net.c
net/nfs.c
tools/Makefile

diff --git a/MAKEALL b/MAKEALL
index fcbab47..5c6a1ea 100755 (executable)
--- a/MAKEALL
+++ b/MAKEALL
@@ -92,9 +92,9 @@ LIST_8220="   \
 LIST_824x="    \
        A3000           barco           BMW             CPC45           \
        CU824           debris          eXalion         HIDDEN_DRAGON   \
-       MOUSSE          MUSENKI         MVBLUE          OXC             \
-       PN62            Sandpoint8240   Sandpoint8245   sbc8240         \
-       SL8245          utx8245                                         \
+       linkstation     linkstationhg   MOUSSE          MUSENKI         \
+       MVBLUE          OXC             PN62            Sandpoint8240   \
+       Sandpoint8245   sbc8240         SL8245          utx8245         \
 "
 
 #########################################################################
index 9305cab..daa6f04 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -54,7 +54,7 @@ ifeq ($(HOSTARCH),ppc)
 CROSS_COMPILE =
 else
 ifeq ($(ARCH),ppc)
-CROSS_COMPILE = powerpc-linux-
+CROSS_COMPILE = ppc_6xx-
 endif
 ifeq ($(ARCH),arm)
 CROSS_COMPILE = arm-linux-
@@ -142,6 +142,40 @@ ALL = u-boot.srec u-boot.bin System.map
 
 all:           $(ALL)
 
+LSMODEL := $(shell head -n 1 include/config.h)
+
+linkstation_HGLAN_RAM: include/config.h
+       @[ -n "$(findstring HGLAN_RAM, $(LSMODEL))" ] || \
+               { echo "Bad configuration: $(LSMODEL)" ; \
+                 exit 1 ; \
+               }
+       @make all
+       @mv u-boot.bin u-boot-hg.ram.bin
+
+linkstation_HGLAN: include/config.h
+       @[ -n "$(findstring HGLAN_ROM, $(LSMODEL))" ] || \
+               { echo "Bad configuration: $(LSMODEL)" ; \
+                 exit 1 ; \
+               }
+       @make all
+       @mv u-boot.bin u-boot-hg.flash.bin
+
+linkstation_HDLAN_RAM: include/config.h
+       @[ -n "$(findstring HDLAN_RAM, $(LSMODEL))" ] || \
+               { echo "Bad configuration: $(LSMODEL)" ; \
+                 exit 1 ; \
+               }
+       @make all
+       @mv u-boot.bin u-boot-hd.ram.bin
+
+linkstation_HDLAN: include/config.h
+       @[ -n "$(findstring HDLAN_ROM, $(LSMODEL))" ] || \
+               { echo "Bad configuration: $(LSMODEL)" ; \
+                 exit 1 ; \
+               }
+       @make all
+       @mv u-boot.bin u-boot-hd.flash.bin
+
 u-boot.hex:    u-boot
                $(OBJCOPY) ${OBJCFLAGS} -O ihex $< $@
 
@@ -200,6 +234,10 @@ System.map:        u-boot
 
 #########################################################################
 else
+linkstation_HGLAN_RAM  \
+linkstation_HGLAN      \
+linkstation_HDLAN_RAM  \
+linkstation_HDLAN      \
 all install u-boot u-boot.srec depend dep:
        @echo "System not configured - see README" >&2
        @ exit 1
@@ -972,6 +1010,38 @@ eXalion_config: unconfig
 HIDDEN_DRAGON_config: unconfig
        @./mkconfig $(@:_config=) ppc mpc824x hidden_dragon
 
+linkstation_HGLAN_RAM_config: mrproper
+       @>include/config.h ; \
+       echo "/* HGLAN_RAM */" >>include/config.h ; \
+       echo "#define CONFIG_HGLAN 1" >>include/config.h ; \
+       echo "TEXT_BASE = 0x07F00000" >board/linkstation/config.tmp ; \
+       ./mkconfig -a linkstation ppc mpc824x linkstation ; \
+       echo "LinkStation HGLAN -- RAM BUILD ..."
+
+linkstation_HGLAN_config: mrproper
+       @>include/config.h ; \
+       echo "/* HGLAN_ROM */" >>include/config.h ; \
+       echo "#define CONFIG_HGLAN 1" >>include/config.h ; \
+       echo "TEXT_BASE = 0xFFF00000" >board/linkstation/config.tmp ; \
+       ./mkconfig -a linkstation ppc mpc824x linkstation ; \
+       echo "LinkStation HGLAN -- ROM BUILD ..."
+
+linkstation_HDLAN_RAM_config: mrproper
+       @>include/config.h ; \
+       echo "/* HDLAN_RAM */" >>include/config.h ; \
+       echo "#define CONFIG_HLAN 1" >>include/config.h ; \
+       echo "TEXT_BASE = 0x03F00000" >board/linkstation/config.tmp ; \
+       ./mkconfig -a linkstation ppc mpc824x linkstation ; \
+       echo "LinkStation HDLAN -- RAM BUILD ..."
+
+linkstation_HDLAN_config: mrproper
+       @>include/config.h ; \
+       echo "/* HDLAN_ROM */" >>include/config.h ; \
+       echo "#define CONFIG_HLAN 1" >>include/config.h ; \
+       echo "TEXT_BASE = 0xFFF00000" >board/linkstation/config.tmp ; \
+       ./mkconfig -a linkstation ppc mpc824x linkstation ; \
+       echo "LinkStation HDLAN -- ROM BUILD ..."
+
 MOUSSE_config: unconfig
        @./mkconfig $(@:_config=) ppc mpc824x mousse
 
index 8599a49..2c7cdef 100644 (file)
@@ -187,6 +187,12 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
                        verify = 0;
                } else
 #endif /* __I386__ */
+#ifdef CONFIG_LINKSTATION
+               extern boot_os_Fcn do_boot_lskernel;
+               do_boot_lskernel(cmdtp, flag, argc, argv,
+                               addr, NULL, verify);
+               return 1; /* Only returns on error */
+#endif
            {
                puts ("Bad Magic Number\n");
                SHOW_BOOT_PROGRESS (-1);
index 5db42f2..257de45 100644 (file)
@@ -283,7 +283,8 @@ int do_ext2load (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
        sprintf(buf, "%lX", filelen);
        setenv("filesize", buf);
 
-       return(filelen);
+//     return(filelen);
+       return(0);
 }
 
 U_BOOT_CMD(
index 3c535d2..4ff2429 100644 (file)
@@ -46,7 +46,7 @@ extern int overwrite_console (void);
 
 #endif /* CFG_CONSOLE_IS_IN_ENV */
 
-static int console_setfile (int file, device_t * dev)
+int console_setfile (int file, device_t * dev)
 {
        DECLARE_GLOBAL_DATA_PTR;
        int error = 0;
@@ -456,22 +456,27 @@ int console_init_r (void)
        gd->flags |= GD_FLG_DEVINIT;    /* device initialization completed */
 
 #ifndef CFG_CONSOLE_INFO_QUIET
+       if (strcmp(stdio_devices[stdout]->name, "serial")) {
+               extern char version_string[];
+               printf ("\n%s\n", version_string);
+       }
+
        /* Print information */
-       puts ("In:    ");
+       puts ("stdin :   ");
        if (stdio_devices[stdin] == NULL) {
                puts ("No input devices available!\n");
        } else {
                printf ("%s\n", stdio_devices[stdin]->name);
        }
 
-       puts ("Out:   ");
+       puts ("stdout:   ");
        if (stdio_devices[stdout] == NULL) {
                puts ("No output devices available!\n");
        } else {
                printf ("%s\n", stdio_devices[stdout]->name);
        }
 
-       puts ("Err:   ");
+       puts ("stderr:   ");
        if (stdio_devices[stderr] == NULL) {
                puts ("No error devices available!\n");
        } else {
index f042f3a..97a0cee 100644 (file)
@@ -74,6 +74,11 @@ int do_mdm_init = 0;
 extern void mdm_init(void); /* defined in board.c */
 #endif
 
+#ifdef CONFIG_LINKSTATION
+extern int avr_input(void);
+extern void avr_StopBoot(void);
+#endif
+
 /***************************************************************************
  * Watch for 'delay' seconds for autoboot stop or autoboot delay string.
  * returns: 0 -  no key string, allow autoboot
@@ -156,7 +161,14 @@ static __inline__ int abortboot(int bootdelay)
        /* In order to keep up with incoming data, check timeout only
         * when catch up.
         */
+       uint64_t onesec = endtick(1);
+       int bootremain = bootdelay;
        while (!abort && get_ticks() <= etime) {
+               if (get_ticks() >= onesec) {
+                       onesec = endtick(1);
+                       putc('\r');
+                       printf (CONFIG_AUTOBOOT_PROMPT, --bootremain);
+               }
                for (i = 0; i < sizeof(delaykey) / sizeof(delaykey[0]); i ++) {
                        if (delaykey[i].len > 0 &&
                            presskey_len >= delaykey[i].len &&
@@ -177,6 +189,20 @@ static __inline__ int abortboot(int bootdelay)
                        }
                }
 
+#ifdef CONFIG_LINKSTATION
+               int avr_action = avr_input();
+               if (avr_action == -3)
+                       /* Abort boot */
+                       abort = 1;
+               else if (avr_action == -2) {
+                       /* Restart boot */
+                       putc('\r');
+                       printf (CONFIG_AUTOBOOT_PROMPT, bootdelay);
+                       etime = endtick(bootdelay);
+                       onesec = endtick(1);
+                       bootremain = bootdelay;
+               }
+#endif
                if (tstc()) {
                        if (presskey_len < presskey_max) {
                                presskey [presskey_len ++] = getc();
@@ -189,6 +215,7 @@ static __inline__ int abortboot(int bootdelay)
                        }
                }
        }
+       putc('\n');
 #  if DEBUG_BOOTKEYS
        if (!abort)
                puts ("key timeout\n");
@@ -417,6 +444,10 @@ void main_loop (void)
                int prev = disable_ctrlc(1);    /* disable Control C checking */
 # endif
 
+#ifdef CONFIG_LINKSTATION
+               s = getenv("bootcmd");  /* bootcmd can change (see avr.c) */
+#endif
+
 # ifndef CFG_HUSH_PARSER
                run_command (s, 0);
 # else
@@ -451,6 +482,10 @@ void main_loop (void)
        }
 #endif
 
+#ifdef CONFIG_LINKSTATION
+               avr_StopBoot();
+#endif
+
        /*
         * Main Loop for Monitor Command Processing
         */
@@ -475,6 +510,10 @@ void main_loop (void)
                        strcpy (lastcommand, console_buffer);
                else if (len == 0)
                        flag |= CMD_FLAG_REPEAT;
+#ifdef CONFIG_LINKSTATION
+               else if (len == -2)
+                       return;
+#endif
 #ifdef CONFIG_BOOT_RETRY_TIME
                else if (len == -2) {
                        /* -2 means timed out, retry autoboot
@@ -567,6 +606,15 @@ int readline (const char *const prompt)
                        extern void show_activity(int arg);
                        show_activity(0);
                }
+#endif
+#ifdef CONFIG_LINKSTATION
+               while (!tstc()) {
+                       int avr_ret = avr_input();
+                       if (avr_ret == -2)
+                               return (-2);
+                       else if (avr_ret > 0)
+                               return avr_ret;
+               }
 #endif
                c = getc();
 
index 312dfe2..4effb12 100644 (file)
@@ -92,6 +92,7 @@ int checkdcache (void)
 
 /*------------------------------------------------------------------- */
 
+#ifndef CONFIG_LINKSTATION
 int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 {
        ulong msr, addr;
@@ -125,6 +126,7 @@ int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
        return 1;
 
 }
+#endif
 
 /* ------------------------------------------------------------------------- */
 
index 9ff052c..a6afc58 100644 (file)
@@ -130,7 +130,7 @@ boot_warm:
 
 
 in_flash:
-#if defined(CONFIG_BMW)
+#if defined(CONFIG_BMW) || defined(CONFIG_LINKSTATION)
        bl early_init_f /* Must be ASM: no stack yet! */
 #endif
        /*
@@ -155,6 +155,7 @@ in_flash:
        mtspr   HID0, r2
        sync
 
+#if !defined(CONFIG_LINKSTATION)
        /* Allocate Initial RAM in data cache.
         */
        lis     r3, CFG_INIT_RAM_ADDR@h
@@ -175,6 +176,7 @@ in_flash:
        ori     r3, r3, 0x0080
        sync
        mtspr   1011, r3
+#endif /* !CONFIG_LINKSTATION */
 #endif /* !CONFIG_BMW */
        /*
         * Thisk the stack pointer *somewhere* sensible. Doesnt
@@ -195,7 +197,9 @@ in_flash:
        GET_GOT                 /* initialize GOT access                        */
 
        /* r3: IMMR */
+#if !defined(CONFIG_LINKSTATION)
        bl      cpu_init_f      /* run low-level CPU init code     (from Flash) */
+#endif
 
        mr      r3, r21
        /* r3: BOOTFLAG */
@@ -475,7 +479,7 @@ relocate_code:
        mr      r10, r5         /* Save copy of Destination Address     */
 
        mr      r3,  r5                         /* Destination Address  */
-#ifdef CFG_RAMBOOT
+#if defined(CFG_RAMBOOT) && !defined(CONFIG_LINKSTATION)
        lis     r4, CFG_SDRAM_BASE@h            /* Source      Address  */
        ori     r4, r4, CFG_SDRAM_BASE@l
 #else
@@ -689,6 +693,14 @@ trap_init:
        cmplw   0, r7, r8
        blt     4b
 
+       mfmsr   r7                      /* Exception prefix 0x000 */
+       li      r8,0
+       ori     r8,r8,MSR_IP
+       andc    r7,r7,r8
+       SYNC
+       mtmsr   r7
+       SYNC
+
        mtlr    r4                      /* restore link register        */
        blr
 
index c43cd5e..84b3076 100644 (file)
 #include <net.h>
 #include <pci.h>
 
+#if 0
+#define DEBUG_TRACE
+#define DEBUG_TULIP
+#endif
+
 #undef DEBUG_SROM
 #undef DEBUG_SROM2
 
 #undef UPDATE_SROM
 
-/* PCI Registers.
+/*
+ *  PCI Registers.
  */
-#define PCI_CFDA_PSM           0x43
+#define PCI_CFDA_PSM   0x43
 
 #define CFRV_RN                0x000000f0      /* Revision Number */
 
 
 #define DC2114x_BRK    0x0020          /* CFRV break between DC21142 & DC21143 */
 
-/* Ethernet chip registers.
+/*
+ * Ethernet chip registers.
  */
 #define DE4X5_BMR      0x000           /* Bus Mode Register */
 #define DE4X5_TPD      0x008           /* Transmit Poll Demand Reg */
+#define DE4X5_RPD      0x010           /* Receive Poll Demand Reg */
 #define DE4X5_RRBA     0x018           /* RX Ring Base Address Reg */
 #define DE4X5_TRBA     0x020           /* TX Ring Base Address Reg */
 #define DE4X5_STS      0x028           /* Status Register */
@@ -54,7 +62,8 @@
 #define DE4X5_SICR     0x068           /* SIA Connectivity Register */
 #define DE4X5_APROM    0x048           /* Ethernet Address PROM */
 
-/* Register bits.
+/*
+ * Register bits.
  */
 #define BMR_SWR                0x00000001      /* Software Reset */
 #define STS_TS         0x00700000      /* Transmit Process State */
 #define OMR_PS         0x00040000      /* Port Select */
 #define OMR_SDP                0x02000000      /* SD Polarity - MUST BE ASSERTED */
 #define OMR_PM         0x00000080      /* Pass All Multicast */
+#define OMR_PMS                0x00000040      /* Promiscuous */
 
-/* Descriptor bits.
+/*
+ * Descriptor bits.
  */
 #define R_OWN          0x80000000      /* Own Bit */
 #define RD_RER         0x02000000      /* Receive End Of Ring */
 
 #define SROM_HWADD         0x0014      /* Hardware Address offset in SROM */
 #define SROM_RD                0x00004000      /* Read from Boot ROM */
-#define EE_DATA_WRITE        0x04      /* EEPROM chip data in. */
+#define EE_DATA_WRITE     0x04 /* EEPROM chip data in. */
 #define EE_WRITE_0         0x4801
 #define EE_WRITE_1         0x4805
-#define EE_DATA_READ         0x08      /* EEPROM chip data out. */
+#define EE_DATA_READ     0x08  /* EEPROM chip data out. */
 #define SROM_SR                0x00000800      /* Select Serial ROM when set */
 
 #define DT_IN          0x00000004      /* Serial Data In */
 
 #define POLL_DEMAND    1
 
+#ifndef PCI_VENDOR_ID_ADMTEK
+#  define PCI_VENDOR_ID_ADMTEK 0x1317
+#endif
+#ifndef PCI_DEVICE_ID_ADMTEK_AN983B
+#  define PCI_DEVICE_ID_ADMTEK_AN983B 0x985
+#endif
+
+/* The chip types have been taken from linux-2.4.31
+ * drivers/net/tulip/tulip.h
+ * Only COMET is used for now
+ */
+enum chips {
+       DC21040 = 0,
+       DC21041 = 1,
+       DC21140 = 2,
+       DC21142 = 3, DC21143 = 3,
+       LC82C168,
+       MX98713,
+       MX98715,
+       MX98725,
+       AX88140,
+       PNIC2,
+       COMET,
+       COMPEX9881,
+       I21145,
+       DM910X,
+       CONEXANT,
+};
+static int chip_idx = DC21143;
+
 #ifdef CONFIG_TULIP_FIX_DAVICOM
 #define RESET_DM9102(dev) {\
     unsigned long i;\
 #else
 #define RESET_DE4X5(dev) {\
     int i;\
-    i=INL(dev, DE4X5_BMR);\
-    udelay(1000);\
+    i=0x01A04000;\
     OUTL(dev, i | BMR_SWR, DE4X5_BMR);\
     udelay(1000);\
     OUTL(dev, i, DE4X5_BMR);\
     udelay(1000);\
-    for (i=0;i<5;i++) {INL(dev, DE4X5_BMR); udelay(10000);}\
-    udelay(1000);\
 }
 #endif
 
 #define START_DE4X5(dev) {\
-    s32 omr; \
+    u32 omr; \
     omr = INL(dev, DE4X5_OMR);\
     omr |= OMR_ST | OMR_SR;\
     OUTL(dev, omr, DE4X5_OMR);         /* Enable the TX and/or RX */\
 }
 
 #define STOP_DE4X5(dev) {\
-    s32 omr; \
+    u32 omr; \
     omr = INL(dev, DE4X5_OMR);\
     omr &= ~(OMR_ST|OMR_SR);\
     OUTL(dev, omr, DE4X5_OMR);         /* Disable the TX and/or RX */ \
 }
 
-#define NUM_RX_DESC PKTBUFSRX
+#define NUM_RX_DESC            4
 #ifndef CONFIG_TULIP_FIX_DAVICOM
-       #define NUM_TX_DESC 1                   /* Number of TX descriptors   */
+       #define NUM_TX_DESC     2                       /* Number of TX descriptors   */
 #else
        #define NUM_TX_DESC 4
 #endif
-#define RX_BUFF_SZ  PKTSIZE_ALIGN
+#define BUFLEN  1536
 
 #define TOUT_LOOP   1000000
 
 #define SETUP_FRAME_LEN 192
 #define ETH_ALEN       6
+#define ETH_ZLEN       60
 
 struct de4x5_desc {
-       volatile s32 status;
+       volatile u32 status;
        u32 des1;
        u32 buf;
        u32 next;
 };
 
-static struct de4x5_desc rx_ring[NUM_RX_DESC] __attribute__ ((aligned(32))); /* RX descriptor ring         */
-static struct de4x5_desc tx_ring[NUM_TX_DESC] __attribute__ ((aligned(32))); /* TX descriptor ring         */
-static int rx_new;                             /* RX descriptor ring pointer */
-static int tx_new;                             /* TX descriptor ring pointer */
+/* Note: transmit and receive buffers must be longword aligned and
+   longword divisable */
 
-static char rxRingSize;
-static char txRingSize;
+/* TX descriptor ring */
+static struct de4x5_desc tx_ring[NUM_TX_DESC] __attribute__ ((aligned(4)));
+/* TX buffer */
+static unsigned char txb[BUFLEN] __attribute__ ((aligned(32)));
+
+/* RX descriptor ring */
+static struct de4x5_desc rx_ring[NUM_RX_DESC] __attribute__ ((aligned(4)));
+/* RX buffers */
+static unsigned char rxb[NUM_RX_DESC * BUFLEN] __attribute__ ((aligned(32)));
+
+static int rx_new;             /* RX descriptor ring pointer */
 
 #if defined(UPDATE_SROM) || !defined(CONFIG_TULIP_FIX_DAVICOM)
 static void  sendto_srom(struct eth_device* dev, u_int command, u_long addr);
@@ -204,6 +250,7 @@ static void OUTL(struct eth_device* dev, int command, u_long addr)
 static struct pci_device_id supported[] = {
        { PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_TULIP_FAST },
        { PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_21142 },
+       { PCI_VENDOR_ID_ADMTEK, PCI_DEVICE_ID_ADMTEK_AN983B },
 #ifdef CONFIG_TULIP_FIX_DAVICOM
        { PCI_VENDOR_ID_DAVICOM, PCI_DEVICE_ID_DAVICOM_DM9102A },
 #endif
@@ -214,29 +261,44 @@ int dc21x4x_initialize(bd_t *bis)
 {
        int                     idx=0;
        int                     card_number = 0;
-       unsigned int            cfrv;
+       unsigned int        cfrv;
        unsigned char           timer;
-       pci_dev_t               devbusfn;
+       pci_dev_t                       devbusfn;
        unsigned int            iobase;
        unsigned short          status;
        struct eth_device*      dev;
+       u16                                     vendor;
+       u16                                     device;
 
+#ifdef DEBUG_TULIP
+       printf("%s\n", __FUNCTION__);
+#endif
        while(1) {
                devbusfn =  pci_find_devices(supported, idx++);
                if (devbusfn == -1) {
                        break;
                }
+               pci_read_config_word(devbusfn, PCI_VENDOR_ID, &vendor);
+               pci_read_config_word(devbusfn, PCI_DEVICE_ID, &device);
+
+               debug("dc21x4x: devbusfn: %08lX, VID: %08lX, DID: %08lX\n",
+                       devbusfn, vendor, device);
 
-               /* Get the chip configuration revision register. */
-               pci_read_config_dword(devbusfn, PCI_REVISION_ID, &cfrv);
+               if (vendor == PCI_VENDOR_ID_ADMTEK && \
+                   device == PCI_DEVICE_ID_ADMTEK_AN983B) {
+                       chip_idx = COMET;
+               } else {
+                       /* Get the chip configuration revision register. */
+                       pci_read_config_dword(devbusfn, PCI_REVISION_ID, &cfrv);
 
 #ifndef CONFIG_TULIP_FIX_DAVICOM
-               if ((cfrv & CFRV_RN) < DC2114x_BRK ) {
-                       printf("Error: The chip is not DC21143.\n");
-                       continue;
-               }
+                       if ((cfrv & CFRV_RN) < DC2114x_BRK ) {
+                               printf("Error: The chip is not DC21143.\n");
+                               idx++;
+                               continue;
+                       }
 #endif
-
+               }
                pci_read_config_word(devbusfn, PCI_COMMAND, &status);
                status |=
 #ifdef CONFIG_TULIP_USE_IO
@@ -286,7 +348,10 @@ int dc21x4x_initialize(bd_t *bis)
 #ifdef CONFIG_TULIP_FIX_DAVICOM
                sprintf(dev->name, "Davicom#%d", card_number);
 #else
-               sprintf(dev->name, "dc21x4x#%d", card_number);
+               if (chip_idx == COMET)
+                       sprintf(dev->name, "COMET#%d", card_number);
+               else
+                       sprintf(dev->name, "dc21x4x#%d", card_number);
 #endif
 
 #ifdef CONFIG_TULIP_USE_IO
@@ -303,8 +368,6 @@ int dc21x4x_initialize(bd_t *bis)
                /* Ensure we're not sleeping. */
                pci_write_config_byte(devbusfn, PCI_CFDA_PSM, WAKEUP);
 
-               udelay(10 * 1000);
-
 #ifndef CONFIG_TULIP_FIX_DAVICOM
                read_hw_addr(dev, bis);
 #endif
@@ -321,8 +384,9 @@ static int dc21x4x_init(struct eth_device* dev, bd_t* bis)
        int             i;
        int             devbusfn = (int) dev->priv;
 
-       /* Ensure we're not sleeping. */
-       pci_write_config_byte(devbusfn, PCI_CFDA_PSM, WAKEUP);
+#if defined(DEBUG_TULIP) || defined(DEBUG_TRACE)
+       serial_printf("%0lu %s\n", get_timer(0), __FUNCTION__);
+#endif
 
 #ifdef CONFIG_TULIP_FIX_DAVICOM
        RESET_DM9102(dev);
@@ -330,57 +394,71 @@ static int dc21x4x_init(struct eth_device* dev, bd_t* bis)
        RESET_DE4X5(dev);
 #endif
 
-       if ((INL(dev, DE4X5_STS) & (STS_TS | STS_RS)) != 0) {
-               printf("Error: Cannot reset ethernet controller.\n");
-               return 0;
-       }
-
 #ifdef CONFIG_TULIP_SELECT_MEDIA
        dc21x4x_select_media(dev);
 #else
-       OUTL(dev, OMR_SDP | OMR_PS | OMR_PM, DE4X5_OMR);
+       if (chip_idx == COMET) {
+               /* No multicast */
+               OUTL(dev, 0, 0xAC);
+               OUTL(dev, 0, 0xB0);
+       } else {
+               OUTL(dev, OMR_SDP | OMR_PS | OMR_PM, DE4X5_OMR);
+       }
 #endif
 
        for (i = 0; i < NUM_RX_DESC; i++) {
                rx_ring[i].status = cpu_to_le32(R_OWN);
-               rx_ring[i].des1 = cpu_to_le32(RX_BUFF_SZ);
-               rx_ring[i].buf = cpu_to_le32(phys_to_bus((u32) NetRxPackets[i]));
-#ifdef CONFIG_TULIP_FIX_DAVICOM
-               rx_ring[i].next = cpu_to_le32(phys_to_bus((u32) &rx_ring[(i+1) % NUM_RX_DESC]));
-#else
-               rx_ring[i].next = 0;
-#endif
+               rx_ring[i].des1 = cpu_to_le32(BUFLEN);
+               rx_ring[i].buf = cpu_to_le32(phys_to_bus((u32)&rxb[i * BUFLEN]));
+               rx_ring[i].next = cpu_to_le32(phys_to_bus((u32)&rx_ring[i+1]));
        }
+       /* Write the end of list marker to the descriptor lists. */
+       rx_ring[NUM_RX_DESC - 1].des1 |= cpu_to_le32(RD_RER);
+       rx_ring[NUM_RX_DESC - 1].next = cpu_to_le32(phys_to_bus((u32)&rx_ring[0]));
 
-       for (i=0; i < NUM_TX_DESC; i++) {
-               tx_ring[i].status = 0;
-               tx_ring[i].des1 = 0;
-               tx_ring[i].buf = 0;
+       /* Point to the first descriptor */
+       rx_new = 0;
 
-#ifdef CONFIG_TULIP_FIX_DAVICOM
-       tx_ring[i].next = cpu_to_le32(phys_to_bus((u32) &tx_ring[(i+1) % NUM_TX_DESC]));
-#else
-               tx_ring[i].next = 0;
-#endif
-       }
+       /* We only use 1 transmit buffer, but we use 2 descriptors so
+          transmit engines have somewhere to point to if they feel the need */
+
+       tx_ring[0].status = 0;
+       tx_ring[0].des1 = 0;
+       tx_ring[0].buf = cpu_to_le32(phys_to_bus((u32)&txb[0]));
+       tx_ring[0].next = cpu_to_le32(phys_to_bus((u32)&tx_ring[1]));
 
-       rxRingSize = NUM_RX_DESC;
-       txRingSize = NUM_TX_DESC;
+       /* this descriptor should never get used, since it will never be owned
+          by the machine (status will always == 0) */
+
+       tx_ring[1].status = 0;
+       tx_ring[1].des1 = 0;
+       tx_ring[1].buf = cpu_to_le32(phys_to_bus((u32)&txb[0]));
+       tx_ring[1].next = cpu_to_le32(phys_to_bus((u32)&tx_ring[0]));
 
        /* Write the end of list marker to the descriptor lists. */
-       rx_ring[rxRingSize - 1].des1 |= cpu_to_le32(RD_RER);
-       tx_ring[txRingSize - 1].des1 |= cpu_to_le32(TD_TER);
+       tx_ring[1].des1 |= cpu_to_le32(TD_TER);
 
        /* Tell the adapter where the TX/RX rings are located. */
-       OUTL(dev, phys_to_bus((u32) &rx_ring), DE4X5_RRBA);
-       OUTL(dev, phys_to_bus((u32) &tx_ring), DE4X5_TRBA);
+       OUTL(dev, phys_to_bus((u32) &rx_ring[0]), DE4X5_RRBA);
+       OUTL(dev, phys_to_bus((u32) &tx_ring[0]), DE4X5_TRBA);
+
+       if (chip_idx == COMET) {
+               /* Bit 18 (0x00040000) is reserved in the AN983B */
+               /* datasheet, but it is used by the tulip driver */
+               OUTL(dev, (INL(dev, (DE4X5_OMR)) & ~(OMR_PMS | OMR_PM)) | OMR_PS, DE4X5_OMR);
+               /* Enable automatic Tx underrun recovery */
+               OUTL(dev, INL(dev, 0x88) | 1, 0x88);
+//             OUTL(dev, INL(dev, 0x88) | 0x19, 0x88);
+       }
 
        START_DE4X5(dev);
 
-       tx_new = 0;
-       rx_new = 0;
+       /* Start receiving */
+       OUTL(dev, POLL_DEMAND, DE4X5_RPD);
 
-       send_setup_frame(dev, bis);
+       if (chip_idx != COMET) {        /* No setup frame needed by COMET */
+               send_setup_frame(dev, bis);
+       }
 
        return 1;
 }
@@ -389,90 +467,117 @@ static int dc21x4x_send(struct eth_device* dev, volatile void *packet, int lengt
 {
        int             status = -1;
        int             i;
+       u32             len = length;
 
        if (length <= 0) {
                printf("%s: bad packet size: %d\n", dev->name, length);
                goto Done;
        }
 
-       for(i = 0; tx_ring[tx_new].status & cpu_to_le32(T_OWN); i++) {
+       for(i = 0; tx_ring[0].status & cpu_to_le32(T_OWN); i++) {
                if (i >= TOUT_LOOP) {
-                       printf("%s: tx error buffer not ready\n", dev->name);
+                       printf(".%s: Tx not ready\n", dev->name);
                        goto Done;
                }
        }
 
-       tx_ring[tx_new].buf    = cpu_to_le32(phys_to_bus((u32) packet));
-       tx_ring[tx_new].des1   = cpu_to_le32(TD_TER | TD_LS | TD_FS | length);
-       tx_ring[tx_new].status = cpu_to_le32(T_OWN);
+       /* Disable the TX */
+       OUTL(dev, INL(dev, DE4X5_OMR) & ~OMR_ST, DE4X5_OMR);
+
+       memcpy(txb, (char*)packet, length);
 
+       /* setup the transmit descriptor */
+       tx_ring[0].des1 = cpu_to_le32(TD_LS | TD_FS | length);
+       tx_ring[0].status = cpu_to_le32(T_OWN);
+
+       /* Point to transmit descriptor */
+       OUTL(dev, phys_to_bus((u32) &tx_ring[0]), DE4X5_TRBA);
+
+       /* Enable the TX */
+       OUTL(dev, INL(dev, DE4X5_OMR) | OMR_ST, DE4X5_OMR);
+
+       /* Immediate transmit demand */
        OUTL(dev, POLL_DEMAND, DE4X5_TPD);
 
-       for(i = 0; tx_ring[tx_new].status & cpu_to_le32(T_OWN); i++) {
+       for(i = 0; tx_ring[0].status & cpu_to_le32(T_OWN); i++) {
                if (i >= TOUT_LOOP) {
-                       printf(".%s: tx buffer not ready\n", dev->name);
+                       printf(".%s: Tx Timeout\n", dev->name);
                        goto Done;
                }
        }
 
-       if (le32_to_cpu(tx_ring[tx_new].status) & TD_ES) {
-#if 0 /* test-only */
+#ifdef DEBUG_TRACE
+       serial_printf("%0lu Tx L2: %d P: %04X IP: %08X\n",
+                                       get_timer(0), i, *((u16 *)(packet+0xC)),
+                                       *((u32 *)(packet+0x1E)));
+#endif
+
+       if (le32_to_cpu(tx_ring[0].status) & TD_ES) {
+#if 1 /* test-only */
                printf("TX error status = 0x%08X\n",
-                       le32_to_cpu(tx_ring[tx_new].status));
+                       le32_to_cpu(tx_ring[0].status));
 #endif
-               tx_ring[tx_new].status = 0x0;
+               tx_ring[0].status = 0x0;
                goto Done;
        }
 
        status = length;
 
  Done:
-    tx_new = (tx_new+1) % NUM_TX_DESC;
        return status;
 }
 
 static int dc21x4x_recv(struct eth_device* dev)
 {
-       s32             status;
+       u32             status;
+       int             rx_prv;
        int             length    = 0;
 
-       for ( ; ; ) {
-               status = (s32)le32_to_cpu(rx_ring[rx_new].status);
+#ifdef DEBUG_TULIP
+       u32 csr5 = INL(dev, DE4X5_STS);
+       if ((csr5 & STS_RS) != 0x00060000) {
+               OUTL(dev, 0x0001ffff, DE4X5_STS);
+               printf("Receive status: 0x%08X\n", csr5);
+       }
+#endif
 
-               if (status & R_OWN) {
-                       break;
-               }
+       status = (u32)le32_to_cpu(rx_ring[rx_new].status);
+       if (status & R_OWN)
+               return 0;
 
-               if (status & RD_LS) {
-                       /* Valid frame status.
-                        */
-                       if (status & RD_ES) {
-
-                               /* There was an error.
-                                */
-                               printf("RX error status = 0x%08X\n", status);
-                       } else {
-                               /* A valid frame received.
-                                */
-                               length = (le32_to_cpu(rx_ring[rx_new].status) >> 16);
-
-                               /* Pass the packet up to the protocol
-                                * layers.
-                                */
-                               NetReceive(NetRxPackets[rx_new], length - 4);
-                       }
+#ifdef DEBUG_TULIP
+       printf("recv status: 0x%08X\n", status);
+#endif
 
-                       /* Change buffer ownership for this frame, back
-                        * to the adapter.
-                        */
+       if (status & RD_LS) {
+#ifdef DEBUG_TRACE
+               serial_printf("rx: %d status: %08X\n", rx_new, status);
+#endif
+               /* Valid frame status */
+               if (status & RD_ES) {
+                       /* There was an error */
+                       printf("RX error status = 0x%08X\n", status);
                        rx_ring[rx_new].status = cpu_to_le32(R_OWN);
-               }
+               } else {
+                       /* Received valid frame */
+                       length = (int)(le32_to_cpu(rx_ring[rx_new].status) >> 16);
 
-               /* Update entry information.
-                */
-               rx_new = (rx_new + 1) % rxRingSize;
+                       /* Pass the packet up to the protocol layers. */
+                       unsigned char rxdata[BUFLEN];
+                       memcpy(rxdata, rxb + rx_new * BUFLEN, length - 4);
+
+                       /* Give buffer ownership for this
+                        * frame back to the adapter */
+                       rx_ring[rx_new].status = cpu_to_le32(R_OWN);
+
+                       /* Pass the received packet to the upper layer */
+                       NetReceive(rxdata, length - 4);
+               }
        }
 
+       /* Update current descriptor index */
+       rx_new = (rx_new + 1) % NUM_RX_DESC;
+
        return length;
 }
 
@@ -480,10 +585,12 @@ static void dc21x4x_halt(struct eth_device* dev)
 {
        int             devbusfn = (int) dev->priv;
 
+#ifdef DEBUG_TULIP
+       printf("%s\n", __FUNCTION__);
+#endif
        STOP_DE4X5(dev);
        OUTL(dev, 0, DE4X5_SICR);
 
-       pci_write_config_byte(devbusfn, PCI_CFDA_PSM, SLEEP);
 }
 
 static void send_setup_frame(struct eth_device* dev, bd_t *bis)
@@ -501,30 +608,29 @@ static void send_setup_frame(struct eth_device* dev, bd_t *bis)
                }
        }
 
-       for(i = 0; tx_ring[tx_new].status & cpu_to_le32(T_OWN); i++) {
+       for(i = 0; tx_ring[0].status & cpu_to_le32(T_OWN); i++) {
                if (i >= TOUT_LOOP) {
                        printf("%s: tx error buffer not ready\n", dev->name);
                        goto Done;
                }
        }
 
-       tx_ring[tx_new].buf = cpu_to_le32(phys_to_bus((u32) &setup_frame[0]));
-       tx_ring[tx_new].des1 = cpu_to_le32(TD_TER | TD_SET| SETUP_FRAME_LEN);
-       tx_ring[tx_new].status = cpu_to_le32(T_OWN);
+       tx_ring[0].buf = cpu_to_le32(phys_to_bus((u32) &setup_frame[0]));
+       tx_ring[0].des1 = cpu_to_le32(TD_TER | TD_SET| SETUP_FRAME_LEN);
+       tx_ring[0].status = cpu_to_le32(T_OWN);
 
        OUTL(dev, POLL_DEMAND, DE4X5_TPD);
 
-       for(i = 0; tx_ring[tx_new].status & cpu_to_le32(T_OWN); i++) {
+       for(i = 0; tx_ring[0].status & cpu_to_le32(T_OWN); i++) {
                if (i >= TOUT_LOOP) {
                        printf("%s: tx buffer not ready\n", dev->name);
                        goto Done;
                }
        }
 
-       if (le32_to_cpu(tx_ring[tx_new].status) != 0x7FFFFFFF) {
-               printf("TX error status2 = 0x%08X\n", le32_to_cpu(tx_ring[tx_new].status));
+       if (le32_to_cpu(tx_ring[0].status) != 0x7FFFFFFF) {
+               printf("TX error status2 = 0x%08X\n", le32_to_cpu(tx_ring[0].status));
        }
-       tx_new = (tx_new+1) % NUM_TX_DESC;
 
 Done:
        return;
@@ -543,7 +649,7 @@ sendto_srom(struct eth_device* dev, u_int command, u_long addr)
 static int
 getfrom_srom(struct eth_device* dev, u_long addr)
 {
-       s32 tmp;
+       u32 tmp;
 
        tmp = INL(dev, addr);
        udelay(1);
@@ -708,19 +814,27 @@ static int write_srom(struct eth_device *dev, u_long ioaddr, int index, int new_
 #ifndef CONFIG_TULIP_FIX_DAVICOM
 static void read_hw_addr(struct eth_device *dev, bd_t *bis)
 {
-       u_short tmp, *p = (u_short *)(&dev->enetaddr[0]);
-       int i, j = 0;
-
-       for (i = 0; i < (ETH_ALEN >> 1); i++) {
-               tmp = read_srom(dev, DE4X5_APROM, ((SROM_HWADD >> 1) + i));
-               *p = le16_to_cpu(tmp);
-               j += *p++;
-       }
+       if (chip_idx == COMET) {
+               /* COMET reads the ehernet address directly from the EEPROM */
+               *(u32 *)dev->enetaddr = cpu_to_le32(INL(dev, 0xA4));
+               *(u16 *)(dev->enetaddr+4) = cpu_to_le16(INL(dev, 0xA8));
+               *(u32 *)bis->bi_enetaddr = *(u32 *)dev->enetaddr;
+               *(u16 *)(bis->bi_enetaddr+4) = *(u16 *)(dev->enetaddr+4);
+       } else {
+               u_short tmp, *p = (u_short *)(&dev->enetaddr[0]);
+               int i, j = 0;
+
+               for (i = 0; i < (ETH_ALEN >> 1); i++) {
+                       tmp=read_srom(dev, DE4X5_APROM, ((SROM_HWADD >> 1)+i));
+                       *p = le16_to_cpu(tmp);
+                       j += *p++;
+               }
 
-       if ((j == 0) || (j == 0x2fffd)) {
-               memset (dev->enetaddr, 0, ETH_ALEN);
-               debug ("Warning: can't read HW address from SROM.\n");
-               goto Done;
+               if ((j == 0) || (j == 0x2fffd)) {
+                       memset (dev->enetaddr, 0, ETH_ALEN);
+                       debug ("Warning: can't read HW address from SROM.\n");
+                       goto Done;
+               }
        }
 
        return;
@@ -769,3 +883,5 @@ static void update_srom(struct eth_device *dev, bd_t *bis)
 #endif /* UPDATE_SROM */
 
 #endif /* CFG_CMD_NET && CONFIG_NET_MULTI && CONFIG_TULIP */
+
+/* vim: set ts=4: */
index 9a0a24f..2de5220 100644 (file)
@@ -27,6 +27,7 @@
 
 #include <command.h>
 #include <devices.h>
+#include <console.h>
 #include <net.h>
 
 static char input_buffer[512];
@@ -124,6 +125,26 @@ static void nc_send_packet (const char *buf, int len)
                output_packet_len = len;
                NetLoop (NETCONS);      /* wait for arp reply and send packet */
                output_packet_len = 0;
+#if defined(CFG_CONSOLE_IS_IN_ENV) || defined(CONFIG_SILENT_CONSOLE)
+               if (NetState == NETLOOP_FAIL) {
+                       /* ARP failed, fail back to serial console */
+                       device_t *idev;
+                       device_t *odev;
+
+                       idev = search_device(DEV_FLAGS_INPUT,  "serial");
+                       odev = search_device(DEV_FLAGS_OUTPUT, "serial");
+
+                       console_setfile (stdin,  idev);
+                       console_setfile (stdout, odev);
+                       console_setfile (stderr, odev);
+
+#if defined(CONFIG_LINKSTATION)
+                       void next_cons_choice(int console);
+                       /* Console 0 is the serial console */
+                       next_cons_choice(0);
+#endif
+               }
+#endif
                return;
        }
 
@@ -236,7 +257,8 @@ int nc_tstc (void)
 
        input_recursion = 1;
 
-       net_timeout = 1;
+//     net_timeout = 1;
+       net_timeout = 50;
        NetLoop (NETCONS);      /* kind of poll */
 
        input_recursion = 0;
index 3393ba8..af483bb 100644 (file)
 *
 *    Indent Options: indent -kr -i8
 ***************************************************************************/
-
+/*
+ * 26 August 2006 Mihai Georgian <u-boot@linuxnotincluded.org.uk>
+ * Modified to use le32_to_cpu and cpu_to_le32 properly
+ */
 #include <common.h>
 #include <malloc.h>
 #include <net.h>
@@ -68,6 +71,7 @@
 static u32 ioaddr;
 
 /* Condensed operations for readability. */
+#define virt_to_bus(addr)      cpu_to_le32(addr)
 #define virt_to_le32desc(addr) cpu_to_le32(virt_to_bus(addr))
 #define le32desc_to_virt(addr) bus_to_virt(le32_to_cpu(addr))
 
@@ -413,23 +417,23 @@ static int rtl_recv(struct eth_device *dev)
        ioaddr = dev->iobase;
 
        cur_rx = tpc->cur_rx;
-       if ((tpc->RxDescArray[cur_rx].status & OWNbit) == 0) {
-               if (!(tpc->RxDescArray[cur_rx].status & RxRES)) {
+       if ((le32_to_cpu(tpc->RxDescArray[cur_rx].status) & OWNbit) == 0) {
+               if (!(le32_to_cpu(tpc->RxDescArray[cur_rx].status) & RxRES)) {
                        unsigned char rxdata[RX_BUF_LEN];
-                       length = (int) (tpc->RxDescArray[cur_rx].
-                                               status & 0x00001FFF) - 4;
+                       length = (int) (le32_to_cpu(tpc->RxDescArray[cur_rx].
+                                               status) & 0x00001FFF) - 4;
 
                        memcpy(rxdata, tpc->RxBufferRing[cur_rx], length);
                        NetReceive(rxdata, length);
 
                        if (cur_rx == NUM_RX_DESC - 1)
                                tpc->RxDescArray[cur_rx].status =
-                                   (OWNbit | EORbit) + RX_BUF_SIZE;
+                               cpu_to_le32((OWNbit | EORbit) + RX_BUF_SIZE);
                        else
                                tpc->RxDescArray[cur_rx].status =
-                                   OWNbit + RX_BUF_SIZE;
+                               cpu_to_le32(OWNbit + RX_BUF_SIZE);
                        tpc->RxDescArray[cur_rx].buf_addr =
-                           virt_to_bus(tpc->RxBufferRing[cur_rx]);
+                           cpu_to_le32(tpc->RxBufferRing[cur_rx]);
                } else {
                        puts("Error Rx");
                }
@@ -454,6 +458,7 @@ static int rtl_send(struct eth_device *dev, volatile void *packet, int length)
        u8 *ptxb;
        int entry = tpc->cur_tx % NUM_TX_DESC;
        u32 len = length;
+       int ret;
 
 #ifdef DEBUG_RTL8169_TX
        int stime = currticks();
@@ -465,39 +470,46 @@ static int rtl_send(struct eth_device *dev, volatile void *packet, int length)
 
        /* point to the current txb incase multiple tx_rings are used */
        ptxb = tpc->Tx_skbuff[entry * MAX_ETH_FRAME_SIZE];
+#ifdef DEBUG_RTL8169_TX
+       printf("ptxb: %08X, length: %d\n", ptxb, (int)length);
+#endif
        memcpy(ptxb, (char *)packet, (int)length);
 
        while (len < ETH_ZLEN)
                ptxb[len++] = '\0';
 
-       tpc->TxDescArray[entry].buf_addr = virt_to_bus(ptxb);
+       tpc->TxDescArray[entry].buf_addr = cpu_to_le32(ptxb);
        if (entry != (NUM_TX_DESC - 1)) {
                tpc->TxDescArray[entry].status =
-                   (OWNbit | FSbit | LSbit) | ((len > ETH_ZLEN) ?
-                                               len : ETH_ZLEN);
+                   cpu_to_le32((OWNbit | FSbit | LSbit) |
+                               ((len > ETH_ZLEN) ? len : ETH_ZLEN));
        } else {
                tpc->TxDescArray[entry].status =
-                   (OWNbit | EORbit | FSbit | LSbit) |
-                   ((len > ETH_ZLEN) ? length : ETH_ZLEN);
+                   cpu_to_le32((OWNbit | EORbit | FSbit | LSbit) |
+                               ((len > ETH_ZLEN) ? len : ETH_ZLEN));
        }
        RTL_W8(TxPoll, 0x40);   /* set polling bit */
 
        tpc->cur_tx++;
        to = currticks() + TX_TIMEOUT;
-       while ((tpc->TxDescArray[entry].status & OWNbit) && (currticks() < to));        /* wait */
+       while ((le32_to_cpu(tpc->TxDescArray[entry].status) & OWNbit)
+                               && (currticks() < to)); /* wait */
 
        if (currticks() >= to) {
 #ifdef DEBUG_RTL8169_TX
                puts ("tx timeout/error\n");
                printf ("%s elapsed time : %d\n", __FUNCTION__, currticks()-stime);
 #endif
-               return 0;
+               ret = 0;
        } else {
 #ifdef DEBUG_RTL8169_TX
                puts("tx done\n");
 #endif
-               return length;
+               ret = length;
        }
+       /* Delay to make net console (nc) work properly */
+       udelay(20);
+       return ret;
 }
 
 static void rtl8169_set_rx_mode(struct eth_device *dev)
@@ -603,13 +615,14 @@ static void rtl8169_init_ring(struct eth_device *dev)
        for (i = 0; i < NUM_RX_DESC; i++) {
                if (i == (NUM_RX_DESC - 1))
                        tpc->RxDescArray[i].status =
-                           (OWNbit | EORbit) + RX_BUF_SIZE;
+                       cpu_to_le32((OWNbit | EORbit) + RX_BUF_SIZE);
                else
-                       tpc->RxDescArray[i].status = OWNbit + RX_BUF_SIZE;
+                       tpc->RxDescArray[i].status =
+                       cpu_to_le32(OWNbit + RX_BUF_SIZE);
 
                tpc->RxBufferRing[i] = &rxb[i * RX_BUF_SIZE];
                tpc->RxDescArray[i].buf_addr =
-                   virt_to_bus(tpc->RxBufferRing[i]);
+                   cpu_to_le32(tpc->RxBufferRing[i]);
        }
 
 #ifdef DEBUG_RTL8169
@@ -635,17 +648,23 @@ static void rtl_reset(struct eth_device *dev, bd_t *bis)
        if (tpc->TxDescArrays == 0)
                puts("Allot Error");
        /* Tx Desscriptor needs 256 bytes alignment; */
-       TxPhyAddr = virt_to_bus(tpc->TxDescArrays);
+       TxPhyAddr = tpc->TxDescArrays;
        diff = 256 - (TxPhyAddr - ((TxPhyAddr >> 8) << 8));
        TxPhyAddr += diff;
        tpc->TxDescArray = (struct TxDesc *) (tpc->TxDescArrays + diff);
+#ifdef DEBUG_RTL8169
+       printf("tpc->TxDescArray: %08X\n", tpc->TxDescArray);
+#endif
 
        tpc->RxDescArrays = rx_ring;
        /* Rx Desscriptor needs 256 bytes alignment; */
-       RxPhyAddr = virt_to_bus(tpc->RxDescArrays);
+       RxPhyAddr = tpc->RxDescArrays;
        diff = 256 - (RxPhyAddr - ((RxPhyAddr >> 8) << 8));
        RxPhyAddr += diff;
        tpc->RxDescArray = (struct RxDesc *) (tpc->RxDescArrays + diff);
+#ifdef DEBUG_RTL8169
+       printf("tpc->RxDescArray: %08X\n", tpc->RxDescArray);
+#endif
 
        if (tpc->TxDescArrays == NULL || tpc->RxDescArrays == NULL) {
                puts("Allocate RxDescArray or TxDescArray failed\n");
@@ -733,7 +752,7 @@ static int rtl_init(struct eth_device *dev, bd_t *bis)
 
        /* Get MAC address.  FIXME: read EEPROM */
        for (i = 0; i < MAC_ADDR_LEN; i++)
-               dev->enetaddr[i] = RTL_R8(MAC0 + i);
+               bis->bi_enetaddr[i] = dev->enetaddr[i] = RTL_R8(MAC0 + i);
 
 #ifdef DEBUG_RTL8169
        printf("MAC Address");
@@ -805,33 +824,68 @@ static int rtl_init(struct eth_device *dev, bd_t *bis)
                           PHY_Enable_Auto_Nego | PHY_Restart_Auto_Nego);
                udelay(100);
 
+#ifdef CONFIG_LINKSTATION
+void miconCntl_FanLow(void);
+void miconCntl_FanHigh(void);
+void miconCntl_Eth1000M(int up);
+void miconCntl_Eth100M(int up);
+void miconCntl_Eth10M(int up);
+void miconCntl_5f(void);
+
+               miconCntl_FanLow();
+#endif
+
                /* wait for auto-negotiation process */
                for (i = 10000; i > 0; i--) {
                        /* check if auto-negotiation complete */
                        if (mdio_read(PHY_STAT_REG) & PHY_Auto_Neco_Comp) {
                                udelay(100);
                                option = RTL_R8(PHYstatus);
+#if defined(CONFIG_LINKSTATION) && defined(CONFIG_HTGL)
                                if (option & _1000bpsF) {
 #ifdef DEBUG_RTL8169
                                        printf("%s: 1000Mbps Full-duplex operation.\n",
                                             dev->name);
 #endif
-                               } else {
+                                       miconCntl_Eth1000M(1);
+                               } else if (option & _100bps) {
+#ifdef DEBUG_RTL8169
+                                       printf("%s: 100Mbps %s-duplexoperation.\n",
+                                               dev->name,
+                                               (option & FullDup) ? "Full" : "Half");
+#endif
+                                       miconCntl_Eth100M(1);
+                               } else if (option & _10bps) {
 #ifdef DEBUG_RTL8169
                                        printf
-                                           ("%s: %sMbps %s-duplex operation.\n",
+                                           ("%s: 10Mbps %s-duplex operation.\n",
                                             dev->name,
-                                            (option & _100bps) ? "100" :
-                                            "10",
-                                            (option & FullDup) ? "Full" :
-                                            "Half");
+                                            (option & FullDup) ? "Full" : "Half");
 #endif
+                                       miconCntl_Eth100M(1);
                                }
+                               miconCntl_5f();
+#else /* !defined(CONFIG_LINKSTATION) || !defined(CONFIG_HTGL) */
+                               if (option & _1000bpsF) {
+#ifdef DEBUG_RTL8169
+                                       printf("%s: 1000Mbps Full-duplex operation.\n",
+                                               dev->name);
+#endif
+                                       miconCntl_FanHigh();
+                               } else {
+#ifdef DEBUG_RTL8169
+                                       printk("%s: %sMbps %s-duplex operation.\n",
+                                               dev->name,
+                                               (option & _100bps) ? "100" : "10",
+                                               (option & FullDup) ? "Full" : "Half");
+#endif
+                               }
+#endif
                                break;
                        } else {
                                udelay(100);
                        }
-               }               /* end for-loop to wait for auto-negotiation process */
+               }       /* end for-loop to wait for auto-negotiation process */
 
        } else {
                udelay(100);
@@ -886,3 +940,5 @@ int rtl8169_initialize(bd_t *bis)
 }
 
 #endif
+
+/* vim: set ts=4: */
index c21d2d6..a6f9999 100644 (file)
@@ -35,6 +35,8 @@ extern int ext2fs_devread (int sector, int byte_offset, int byte_len,
 
 /* Magic value used to identify an ext2 filesystem.  */
 #define        EXT2_MAGIC              0xEF53
+/* Magic value used to identify Buffalo's idea of ext2 */
+#define LINKSTATION_MAGIC      0xEF54
 /* Amount of indirect blocks in an inode.  */
 #define INDIRECT_BLOCKS                12
 /* Maximum lenght of a pathname.  */
@@ -851,7 +853,8 @@ int ext2fs_mount (unsigned part_length) {
                goto fail;
        }
        /* Make sure this is an ext2 filesystem.  */
-       if (__le16_to_cpu (data->sblock.magic) != EXT2_MAGIC) {
+       if ((__le16_to_cpu (data->sblock.magic) != EXT2_MAGIC) &&
+           (__le16_to_cpu (data->sblock.magic) != LINKSTATION_MAGIC)) {
                goto fail;
        }
        data->diropen.data = data;
index 2d9e282..8fd51f8 100644 (file)
@@ -93,6 +93,7 @@ int   device_register (device_t * dev);
 int    devices_init (void);
 int    devices_done (void);
 int    device_deregister(char *devname);
+int    console_setfile (int file, device_t * dev);
 #ifdef CONFIG_LCD
 int    drv_lcd_init (void);
 #endif
@@ -111,5 +112,8 @@ int drv_usbtty_init (void);
 #ifdef CONFIG_NETCONSOLE
 int    drv_nc_init (void);
 #endif
+#if defined(CFG_CONSOLE_IS_IN_ENV) || defined(CONFIG_SPLASH_SCREEN) || defined(CONFIG_SILENT_CONSOLE)
+device_t *search_device (int flags, char *name);
+#endif
 
 #endif /* _DEVICES_H_ */
index decb046..5624b8b 100644 (file)
@@ -211,6 +211,8 @@ extern void flash_read_factory_serial(flash_info_t * info, void * buffer, int of
 
 #define AMD_ID_LV320B_2 0x221A221A     /* 2d ID word for AM29LV320MB at 0x38 */
 #define AMD_ID_LV320B_3 0x22002200     /* 3d ID word for AM29LV320MB at 0x3c */
+#define AMD_ID_LV320T_2 0x221A221A     /* 2d ID word for AM29LV320MT at 0x38 */
+#define AMD_ID_LV320T_3 0x22012201     /* 3d ID word for AM29LV320MT at 0x3c */
 
 #define AMD_ID_LV640U  0x22D722D7      /* 29LV640U ID (64 M, uniform sectors)  */
 #define AMD_ID_LV650U  0x22D722D7      /* 29LV650U ID (64 M, uniform sectors)  */
@@ -241,6 +243,8 @@ extern void flash_read_factory_serial(flash_info_t * info, void * buffer, int of
 #define STM_ID_x800AB  0x005B005B      /* M29W800AB ID (8M = 512K x 16 )       */
 #define STM_ID_29W320DT 0x22CA22CA     /* M29W320DT ID (32 M, top boot sector) */
 #define STM_ID_29W320DB 0x22CB22CB     /* M29W320DB ID (32 M, bottom boot sect)        */
+#define STM_ID_29W324DT 0x225C225C     /* M29W324DT ID (32 M, top boot sector) */
+#define STM_ID_29W324DB 0x225D225D     /* M29W324DB ID (32 M, bottom boot sect)        */
 #define STM_ID_29W040B 0x00E300E3      /* M29W040B ID (4M = 512K x 8)  */
 
 #define INTEL_ID_28F016S    0x66a066a0 /* 28F016S[VS] ID (16M = 512k x 16)     */
@@ -339,6 +343,8 @@ extern void flash_read_factory_serial(flash_info_t * info, void * buffer, int of
 #define FLASH_STM800AB 0x0051          /* STM M29WF800AB  (  8M = 512K x 16 )  */
 #define FLASH_STMW320DT 0x0052         /* STM M29W320DT   (32 M, top boot sector)      */
 #define FLASH_STMW320DB 0x0053         /* STM M29W320DB   (32 M, bottom boot sect)*/
+#define FLASH_STMW324DT 0x005C         /* STM M29W320DT   (32 M, top boot sector)      */
+#define FLASH_STMW324DB 0x005D         /* STM M29W320DB   (32 M, bottom boot sect)*/
 #define FLASH_STM320DB 0x00CB          /* STM M29W320DB (4M = 64K x 64, bottom)*/
 #define FLASH_STM800DT 0x00D7          /* STM M29W800DT (1M = 64K x 16, top)   */
 #define FLASH_STM800DB 0x005B          /* STM M29W800DB (1M = 64K x 16, bottom)*/
index 7dec378..a1305f2 100644 (file)
 #define PCI_DEVICE_ID_ITE_IT8172G_AUDIO 0x0801
 #define PCI_DEVICE_ID_ITE_IT8181       0x8181
 #define PCI_DEVICE_ID_ITE_8872         0x8872
+#define PCI_DEVICE_ID_ITE_8211         0x8211
+#define PCI_DEVICE_ID_ITE_8212         0x8212
 
 #define PCI_DEVICE_ID_ITE_IT8330G_0    0xe886
 
index 4f8b498..389831e 100644 (file)
@@ -24,6 +24,6 @@
 #ifndef        __VERSION_H__
 #define        __VERSION_H__
 
-#define        U_BOOT_VERSION  "U-Boot 1.1.4"
+#define        U_BOOT_VERSION  "U-Boot 1.1.4 LiSt 2.1.0"
 
 #endif /* __VERSION_H__ */
index f40bb25..251d62e 100644 (file)
@@ -437,6 +437,10 @@ void board_init_f (ulong bootflag)
         */
        addr -= len;
        addr &= ~(4096 - 1);
+#ifdef CONFIG_LINKSTATION
+       /* U-Boot code at 1 MB boundary to make it easier to debug */
+       addr &= ~(1048576 - 1);
+#endif
 #ifdef CONFIG_E500
        /* round down to next 64 kB limit so that IVPR stays aligned */
        addr &= ~(65536 - 1);
@@ -883,8 +887,10 @@ void board_init_r (gd_t *id, ulong dest_addr)
        /* Initialize the jump table for applications */
        jumptable_init ();
 
+#if !defined(CONFIG_LINKSTATION)
        /* Initialize the console (after the relocation and devices init) */
        console_init_r ();
+#endif
 
 #if defined(CONFIG_CCM)                || \
     defined(CONFIG_COGENT)     || \
@@ -937,6 +943,7 @@ void board_init_r (gd_t *id, ulong dest_addr)
        if ((s = getenv ("loadaddr")) != NULL) {
                load_addr = simple_strtoul (s, NULL, 16);
        }
+       debug("load_addr: %08lx\n", load_addr);
 #if (CONFIG_COMMANDS & CFG_CMD_NET)
        if ((s = getenv ("bootfile")) != NULL) {
                copy_filename (BootFile, s, sizeof (BootFile));
@@ -992,6 +999,11 @@ void board_init_r (gd_t *id, ulong dest_addr)
        reset_phy ();
 #endif
 
+#if defined(CONFIG_LINKSTATION)
+       /* The LinkStation uses the net console by default */
+       console_init_r ();
+#endif
+
 #ifdef CONFIG_POST
        post_run (NULL, POST_RAM | post_bootmode_get(0));
 #endif
index b803952..abad0ca 100644 (file)
@@ -40,7 +40,7 @@
 #endif
 
 extern int interrupt_init_cpu (unsigned *);
-extern void timer_interrupt_cpu (struct pt_regs *);
+extern void timer_interrupt_cpu (struct pt_regs *, ulong timestamp);
 
 static unsigned decrementer_count; /* count value for 1e6/HZ microseconds */
 
@@ -111,7 +111,7 @@ static volatile ulong timestamp = 0;
 void timer_interrupt (struct pt_regs *regs)
 {
        /* call cpu specific function from $(CPU)/interrupts.c */
-       timer_interrupt_cpu (regs);
+       timer_interrupt_cpu (regs, timestamp);
 
        /* Restore Decrementer Count */
        set_dec (decrementer_count);
index 37c5fb6..1ec8b8f 100644 (file)
--- a/net/net.c
+++ b/net/net.c
@@ -642,6 +642,11 @@ NetSendUDPPacket(uchar *ether, IPaddr_t dest, int dport, int sport, int len)
 {
        uchar *pkt;
 
+#ifdef ET_DEBUG
+        printf("%s dest: %08lx, dport: %d, sport: %d, len: %d\n",
+               __FUNCTION__, dest, dport, sport, len);
+#endif
+
        /* convert to new style broadcast */
        if (dest == 0)
                dest = 0xFFFFFFFF;
@@ -759,6 +764,8 @@ PingHandler (uchar * pkt, unsigned dest, unsigned src, unsigned len)
        IPaddr_t tmp;
        volatile IP_t *ip = (volatile IP_t *)pkt;
 
+       if (!pkt && !dest && !src && !len) /* ARP packet */
+               return;
        tmp = NetReadIP((void *)&ip->ip_src);
        if (tmp != NetPingIP)
                return;
@@ -1147,7 +1154,7 @@ NetReceive(volatile uchar * inpkt, int len)
        ushort cti = 0, vlanid = VLAN_NONE, myvlanid, mynvlanid;
 
 #ifdef ET_DEBUG
-       printf("packet received\n");
+       printf("%s: packet received\n", __FUNCTION__);
 #endif
 
        NetRxPkt = inpkt;
@@ -1172,10 +1179,6 @@ NetReceive(volatile uchar * inpkt, int len)
 
        x = ntohs(et->et_protlen);
 
-#ifdef ET_DEBUG
-       printf("packet received\n");
-#endif
-
        if (x < 1514) {
                /*
                 *      Got a 802 packet.  Check the other protocol field.
@@ -1306,13 +1309,16 @@ NetReceive(volatile uchar * inpkt, int len)
                        /* matched waiting packet's address */
                        if (tmp == NetArpWaitReplyIP) {
 #ifdef ET_DEBUG
-                               puts ("Got it\n");
+                               puts ("ARP reply IP matches original pkt IP\n");
 #endif
                                /* save address for later use */
                                memcpy(NetArpWaitPacketMAC, &arp->ar_data[0], 6);
 
 #ifdef CONFIG_NETCONSOLE
-                               (*packetHandler)(0,0,0,0);
+                               if (packetHandler)
+                                       (*packetHandler)(0,0,0,0);
+                               else
+                                       printf("ARP: NULL packetHandler\n");
 #endif
                                /* modify header, and transmit it */
                                memcpy(((Ethernet_t *)NetArpWaitTxPacket)->et_dest, NetArpWaitPacketMAC, 6);
@@ -1355,7 +1361,10 @@ NetReceive(volatile uchar * inpkt, int len)
                                NetCopyIP(&NetServerIP, &arp->ar_data[ 6]);
                        memcpy (NetServerEther, &arp->ar_data[ 0], 6);
 
-                       (*packetHandler)(0,0,0,0);
+                       if (packetHandler)
+                               (*packetHandler)(0,0,0,0);
+                       else
+                               printf("ARP: NULL packetHandler\n");
                }
                break;
 
index de789e1..3eaad5c 100644 (file)
--- a/net/nfs.c
+++ b/net/nfs.c
@@ -29,7 +29,7 @@
 #include "nfs.h"
 #include "bootp.h"
 
-/*#define NFS_DEBUG*/
+#undef NFS_DEBUG
 
 #if ((CONFIG_COMMANDS & CFG_CMD_NET) && (CONFIG_COMMANDS & CFG_CMD_NFS))
 
@@ -180,6 +180,9 @@ rpc_req (int rpc_prog, int rpc_proc, uint32_t *data, int datalen)
        int sport;
 
        id = ++rpc_id;
+#ifdef NFS_DEBUG
+        printf ("%s xid: %d, rpc_id: %d\n", __FUNCTION__, id, rpc_id);
+#endif
        pkt.u.call.id = htonl(id);
        pkt.u.call.type = htonl(MSG_CALL);
        pkt.u.call.rpcvers = htonl(2);  /* use RPC version 2 */
@@ -213,6 +216,10 @@ rpc_lookup_req (int prog, int ver)
 {
        uint32_t data[16];
 
+#ifdef NFS_DEBUG
+        printf ("%s\n", __FUNCTION__);
+#endif
+
        data[0] = 0; data[1] = 0;       /* auth credential */
        data[2] = 0; data[3] = 0;       /* auth verifier */
        data[4] = htonl(prog);
@@ -234,6 +241,10 @@ nfs_mount_req (char *path)
        int len;
        int pathlen;
 
+#ifdef NFS_DEBUG
+        printf ("%s\n", __FUNCTION__);
+#endif
+
        pathlen = strlen (path);
 
        p = &(data[0]);
@@ -259,6 +270,10 @@ nfs_umountall_req (void)
        uint32_t *p;
        int len;
 
+#ifdef NFS_DEBUG
+        printf ("%s\n", __FUNCTION__);
+#endif
+
        if ((NfsSrvMountPort == -1) || (!fs_mounted)) {
                /* Nothing mounted, nothing to umount */
                return;
@@ -286,6 +301,10 @@ nfs_readlink_req (void)
        uint32_t *p;
        int len;
 
+#ifdef NFS_DEBUG
+        printf ("%s\n", __FUNCTION__);
+#endif
+
        p = &(data[0]);
        p = (uint32_t *)rpc_add_credentials ((long *)p);
 
@@ -308,6 +327,10 @@ nfs_lookup_req (char *fname)
        int len;
        int fnamelen;
 
+#ifdef NFS_DEBUG
+        printf ("%s\n", __FUNCTION__);
+#endif
+
        fnamelen = strlen (fname);
 
        p = &(data[0]);
@@ -335,6 +358,10 @@ nfs_read_req (int offset, int readlen)
        uint32_t *p;
        int len;
 
+#ifdef NFS_DEBUG
+        printf ("%s\n", __FUNCTION__);
+#endif
+
        p = &(data[0]);
        p = (uint32_t *)rpc_add_credentials ((long *)p);
 
@@ -405,8 +432,13 @@ rpc_lookup_reply (int prog, uchar *pkt, unsigned len)
 
        if (rpc_pkt.u.reply.rstatus  ||
            rpc_pkt.u.reply.verifier ||
-           rpc_pkt.u.reply.astatus  ||
            rpc_pkt.u.reply.astatus) {
+#ifdef NFS_DEBUG
+               printf ("rstatus: %d\n", rpc_pkt.u.reply.rstatus);
+               printf ("verifier: %08lx\n", rpc_pkt.u.reply.verifier);
+               printf ("v2: %08lx\n", rpc_pkt.u.reply.v2);
+               printf ("astatus: %d\n", rpc_pkt.u.reply.astatus);
+#endif
                return -1;
        }
 
@@ -433,13 +465,24 @@ nfs_mount_reply (uchar *pkt, unsigned len)
 
        memcpy ((unsigned char *)&rpc_pkt, pkt, len);
 
-       if (ntohl(rpc_pkt.u.reply.id) != rpc_id)
+       if (ntohl(rpc_pkt.u.reply.id) != rpc_id) {
+#ifdef NFS_DEBUG
+               printf ("rpc_id error. expected: %d, got: %d\n", \
+                       rpc_id, ntohl(rpc_pkt.u.reply.id));
+#endif
                return -1;
+       }
 
        if (rpc_pkt.u.reply.rstatus  ||
            rpc_pkt.u.reply.verifier ||
            rpc_pkt.u.reply.astatus  ||
            rpc_pkt.u.reply.data[0]) {
+#ifdef NFS_DEBUG
+               printf ("rstatus: %d\n", rpc_pkt.u.reply.rstatus);
+               printf ("verifier: %08lx\n", rpc_pkt.u.reply.verifier);
+               printf ("astatus: %d\n", rpc_pkt.u.reply.astatus);
+               printf ("data[0]: %08lx\n", rpc_pkt.u.reply.data[0]);
+#endif
                return -1;
        }
 
@@ -544,7 +587,7 @@ nfs_read_reply (uchar *pkt, unsigned len)
        struct rpc_t rpc_pkt;
        int rlen;
 
-#ifdef NFS_DEBUG_nop
+#ifdef NFS_DEBUG
        printf ("%s\n", __FUNCTION__);
 #endif
 
@@ -601,6 +644,8 @@ NfsHandler (uchar *pkt, unsigned dest, unsigned src, unsigned len)
        printf ("%s\n", __FUNCTION__);
 #endif
 
+       if (!pkt && !dest && !src && !len) /* ARP packet */
+               return;
        if (dest != NfsOurPort) return;
 
        switch (NfsState) {
index d3dcc7d..03351a9 100644 (file)
@@ -21,9 +21,9 @@
 # MA 02111-1307 USA
 #
 
-BINS   = img2srec$(SFX) mkimage$(SFX) envcrc$(SFX) gen_eth_addr$(SFX) bmp_logo$(SFX)
+BINS   = img2srec$(SFX) mkimage$(SFX) envcrc$(SFX) gen_eth_addr$(SFX) bmp_logo$(SFX) ncb$(SFX)
 
-OBJS   = environment.o img2srec.o mkimage.o crc32.o envcrc.o gen_eth_addr.o bmp_logo.o
+OBJS   = environment.o img2srec.o mkimage.o crc32.o envcrc.o gen_eth_addr.o bmp_logo.o ncb.o
 
 ifeq ($(ARCH),mips)
 BINS   += inca-swap-bytes$(SFX)