else
echo "OK"
fi
+echo -n " Networking library..."
+cd $BASEDIR/software/libnet && make >> $LOGFILE 2>&1
+if [ "$?" != 0 ] ; then
+ echo "FAILED"
+ exit 1
+else
+ echo "OK"
+fi
echo -n " Demonstration firmware..."
cd $BASEDIR/software/demo && make >> $LOGFILE 2>&1
if [ "$?" != 0 ] ; then
cd $BASEDIR/software/libbase && make clean
cd $BASEDIR/software/libmath && make clean
cd $BASEDIR/software/libhal && make clean
+cd $BASEDIR/software/libnet && make clean
cd $BASEDIR/software/bios && make clean
cd $BASEDIR/software/demo && make clean
.irq_rx(irq_rx),
.irq_tx(irq_tx),
+ .speed10(),
+ .promisc(),
+ .macaddr(),
+
+ .rx_valid(),
+ .rx_adr(),
+ .rx_incrcount(),
+ .rx_endframe(),
+
+ .tx_valid(),
+ .tx_adr(),
+ .tx_bytecount(),
+ .tx_next(),
+
.phy_mii_clk(phy_mii_clk),
.phy_mii_data(phy_mii_data)
);
+assign phy_tx_data = 4'h0;
+assign phy_tx_en = 1'b0;
+assign phy_tx_er = 1'b0;
+
endmodule
input [13:0] csr_a,
input csr_we,
input [31:0] csr_di,
- output [31:0] csr_do,
+ output reg [31:0] csr_do,
output reg irq_rx,
output reg irq_tx,
mii_data_oe <= 1'b0;
mii_data_do <= 1'b0;
+ phy_mii_clk <= 1'b0;
slot0_state <= 2'b00;
slot0_adr <= 30'd0;
5'd2 : macaddr[23:0] <= csr_di[23:0];
5'd3 : begin
+ phy_mii_clk <= csr_di[3];
mii_data_oe <= csr_di[2];
mii_data_do <= csr_di[0];
end
5'd1 : csr_do <= macaddr[47:24];
5'd2 : csr_do <= macaddr[23:0];
- 5'd3 : csr_do <= {mii_data_oe, mii_data_di, mii_data_do};
+ 5'd3 : csr_do <= {phy_mii_clk, mii_data_oe, mii_data_di, mii_data_do};
5'd4 : csr_do <= slot0_state;
5'd5 : csr_do <= slot0_adr;
chmod -x $@
$(MMDIR)/tools/crc32 $@
-boot.elf: linker.ld $(OBJECTS) $(MMDIR)/software/libbase/libbase.a $(MMDIR)/software/libmath/libmath.a $(MMDIR)/software/libhal/libhal.a
- $(LD) $(LDFLAGS) -T linker.ld -N -o $@ -L$(MMDIR)/software/libbase -L$(MMDIR)/software/libmath -L$(MMDIR)/software/libhal --start-group $(OBJECTS) -lbase -lmath -lhal --end-group
+boot.elf: linker.ld $(OBJECTS) $(MMDIR)/software/libbase/libbase.a $(MMDIR)/software/libmath/libmath.a $(MMDIR)/software/libhal/libhal.a $(MMDIR)/software/libnet/libnet.a
+ $(LD) $(LDFLAGS) -T linker.ld -N -o $@ -L$(MMDIR)/software/libbase -L$(MMDIR)/software/libmath -L$(MMDIR)/software/libhal -L$(MMDIR)/software/libnet --start-group $(OBJECTS) -lbase -lmath -lhal -lnet --end-group
chmod -x $@
.PHONY: clean depend
shell.o: ../../software/include/hal/vga.h ../../software/include/hal/snd.h
shell.o: ../../software/include/hw/ac97.h ../../software/include/hal/tmu.h
shell.o: ../../software/include/hal/time.h ../../software/include/hal/brd.h
-shell.o: line.h wave.h rpipe.h cpustats.h shell.h ui.h
+shell.o: ../../software/include/net/mdio.h line.h wave.h rpipe.h cpustats.h
+shell.o: shell.h ui.h
tick.o: ../../software/include/hal/time.h rpipe.h
tick.o: ../../software/include/hal/tmu.h ../../software/include/hw/tmu.h
tick.o: ../../software/include/hw/common.h cpustats.h ui.h
cpustats_init();
time_init();
mem_init();
- vga_init();
- snd_init();
- pfpu_init();
- tmu_init();
- renderer_init();
- apipe_init();
- rpipe_init();
- slowout_init();
- hdlcd_init();
- ui_init();
+ //vga_init();
+ //snd_init();
+ //pfpu_init();
+ //tmu_init();
+ //renderer_init();
+ //apipe_init();
+ //rpipe_init();
+ //slowout_init();
+ //hdlcd_init();
+ //ui_init();
shell_init();
while(1) {
if(readchar_nonblock())
shell_input(readchar());
- apipe_service();
- rpipe_service();
+ //apipe_service();
+ //rpipe_service();
}
return 0;
#include <hal/time.h>
#include <hal/brd.h>
+#include <net/mdio.h>
+
#include "line.h"
#include "wave.h"
#include "rpipe.h"
puts("spam - start/stop advertising");
puts("stats - print system stats");
puts("reboot - system reset");
+ puts("mdior - read MDIO register");
+ puts("mdiow - write MDIO register");
+}
+
+static void mdior(char *reg)
+{
+ char *c;
+ int reg2;
+
+ if(*reg == 0) {
+ printf("mdior <register>\n");
+ return;
+ }
+ reg2 = strtoul(reg, &c, 0);
+ if(*c != 0) {
+ printf("incorrect register\n");
+ return;
+ }
+
+ printf("%02x\n", mdio_read(0, reg2));
}
+static void mdiow(char *reg, char *value)
+{
+ char *c;
+ int reg2;
+ int value2;
+
+ if((*reg == 0) || (*value == 0)) {
+ printf("mdiow <register> <value>\n");
+ return;
+ }
+ reg2 = strtoul(reg, &c, 0);
+ if(*c != 0) {
+ printf("incorrect address\n");
+ return;
+ }
+ value2 = strtoul(value, &c, 0);
+ if(*c != 0) {
+ printf("incorrect value\n");
+ return;
+ }
+
+ mdio_write(0, reg2, value2);
+}
+
+
static void loadpic(const char *filename)
{
int size;
else if(strcmp(command, "reboot") == 0) reboot();
else if(strcmp(command, "help") == 0) help();
+ /* Networking */
+ else if(strcmp(command, "mdior") == 0) mdior(param1);
+ else if(strcmp(command, "mdiow") == 0) mdiow(param1, param2);
+
/* Test functions and hacks */
else if(strcmp(command, "loadpic") == 0) loadpic(param1);
else if(strcmp(command, "checker") == 0) checker();
--- /dev/null
+/*
+ * Milkymist VJ SoC (Software)
+ * Copyright (C) 2007, 2008, 2009, 2010 Sebastien Bourdeauducq
+ *
+ * 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, version 3 of the License.
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __HW_MINIMAC_H
+#define __HW_MINIMAC_H
+
+#include <hw/common.h>
+
+#define CSR_MINIMAC_SETUP MMPTR(0x80009000)
+
+#define MINIMAC_SETUP_SPEED10 (0x1)
+#define MINIMAC_SETUP_PROMISC (0x2)
+
+#define CSR_MINIMAC_ADDRHI MMPTR(0x80009004)
+#define CSR_MINIMAC_ADDRLO MMPTR(0x80009008)
+
+#define CSR_MINIMAC_MDIO MMPTR(0x8000900C)
+
+#define MINIMAC_MDIO_DO (0x1)
+#define MINIMAC_MDIO_DI (0x2)
+#define MINIMAC_MDIO_OE (0x4)
+#define MINIMAC_MDIO_CLK (0x8)
+
+#define CSR_MINIMAC_STATE0 MMPTR(0x80009010)
+#define CSR_MINIMAC_ADDR0 MMPTR(0x80009014)
+#define CSR_MINIMAC_COUNT0 MMPTR(0x80009018)
+#define CSR_MINIMAC_STATE1 MMPTR(0x8000901C)
+#define CSR_MINIMAC_ADDR1 MMPTR(0x80009020)
+#define CSR_MINIMAC_COUNT1 MMPTR(0x80009024)
+#define CSR_MINIMAC_STATE2 MMPTR(0x80009028)
+#define CSR_MINIMAC_ADDR2 MMPTR(0x8000902C)
+#define CSR_MINIMAC_COUNT2 MMPTR(0x80009030)
+#define CSR_MINIMAC_STATE3 MMPTR(0x80009034)
+#define CSR_MINIMAC_ADDR3 MMPTR(0x80009038)
+#define CSR_MINIMAC_COUNT3 MMPTR(0x8000903C)
+
+#define MINIMAC_STATE_EMPTY (0x0)
+#define MINIMAC_STATE_LOADED (0x1)
+#define MINIMAC_STATE_PENDING (0x2)
+
+#define CSR_MINIMAC_TXADR MMPTR(0x80009040)
+#define CSR_MINIMAC_TXREMAINING MMPTR(0x80009044)
+
+#endif /* __HW_MINIMAC_H */
--- /dev/null
+/*
+ * Milkymist VJ SoC (Software)
+ * Copyright (C) 2007, 2008, 2009, 2010 Sebastien Bourdeauducq
+ *
+ * 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, version 3 of the License.
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __NET_MDIO_H
+#define __NET_MDIO_H
+
+void mdio_write(int phyadr, int reg, int val);
+int mdio_read(int phyadr, int reg);
+
+#endif /* __NET_MDIO_H */
#ifndef __VERSION_H
#define __VERSION_H
-#define VERSION "0.3"
+#define VERSION "0.4"
#endif /* __VERSION_H */
--- /dev/null
+MMDIR=../..
+include $(MMDIR)/software/include.mak
+
+OBJECTS=mdio.o
+
+all: libnet.a
+
+libnet.a: $(OBJECTS)
+ $(AR) clr libnet.a $(OBJECTS)
+ $(RANLIB) libnet.a
+
+.PHONY: clean depend
+
+depend:
+ makedepend -Y -- $(CFLAGS) -- *.c
+
+clean:
+ rm -f *.o libnet.a .*~ *~ Makefile.bak
+# DO NOT DELETE
+
+mdio.o: ../../software/include/hw/minimac.h
+mdio.o: ../../software/include/hw/common.h ../../software/include/net/mdio.h
--- /dev/null
+/*
+ * Milkymist VJ SoC (Software)
+ * Copyright (C) 2007, 2008, 2009, 2010 Sebastien Bourdeauducq
+ *
+ * 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, version 3 of the License.
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <hw/minimac.h>
+#include <net/mdio.h>
+
+static void delay()
+{
+ volatile int i;
+ for(i=0;i<1000;i++);
+}
+
+static void raw_write(unsigned int word, int bitcount)
+{
+ word <<= 32 - bitcount;
+ while(bitcount > 0) {
+ if(word & 0x80000000) {
+ CSR_MINIMAC_MDIO = MINIMAC_MDIO_CLK|MINIMAC_MDIO_DO|MINIMAC_MDIO_OE;
+ delay();
+ CSR_MINIMAC_MDIO = MINIMAC_MDIO_DO|MINIMAC_MDIO_OE;
+ delay();
+ } else {
+ CSR_MINIMAC_MDIO = MINIMAC_MDIO_CLK|MINIMAC_MDIO_OE;
+ delay();
+ CSR_MINIMAC_MDIO = MINIMAC_MDIO_OE;
+ delay();
+ }
+ word <<= 1;
+ bitcount--;
+ }
+}
+
+static unsigned int raw_read()
+{
+ unsigned int word;
+ unsigned int i;
+
+ word = 0;
+ for(i=0;i<16;i++) {
+ word <<= 1;
+ CSR_MINIMAC_MDIO = MINIMAC_MDIO_CLK;
+ delay();
+ CSR_MINIMAC_MDIO = 0;
+ delay();
+ if(CSR_MINIMAC_MDIO & MINIMAC_MDIO_DI)
+ word |= 1;
+ }
+ return word;
+}
+
+static void raw_turnaround()
+{
+ CSR_MINIMAC_MDIO = MINIMAC_MDIO_CLK;
+ delay();
+ CSR_MINIMAC_MDIO = 0;
+ delay();
+ CSR_MINIMAC_MDIO = MINIMAC_MDIO_CLK;
+ delay();
+ CSR_MINIMAC_MDIO = 0;
+ delay();
+}
+
+void mdio_write(int phyadr, int reg, int val)
+{
+ CSR_MINIMAC_MDIO = MINIMAC_MDIO_OE;
+ raw_write(0xffffffff, 32); /* < sync */
+ raw_write(0x05, 4); /* < start + write */
+ raw_write(phyadr, 5);
+ raw_write(reg, 5);
+ raw_write(0x02, 2); /* < turnaround */
+ raw_write(val, 16);
+ raw_turnaround();
+}
+
+int mdio_read(int phyadr, int reg)
+{
+ int r;
+
+ CSR_MINIMAC_MDIO = MINIMAC_MDIO_OE;
+ raw_write(0xffffffff, 32); /* < sync */
+ raw_write(0x06, 4); /* < start + read */
+ raw_write(phyadr, 5);
+ raw_write(reg, 5);
+ raw_turnaround();
+ r = raw_read();
+ raw_turnaround();
+
+ return r;
+}
+
make -C libbase depend
make -C libmath depend
make -C libhal depend
+make -C libnet depend
make -C bios depend
make -C demo depend