commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] r6530 - gnuradio/branches/developers/matt/u2f/firmware


From: eb
Subject: [Commit-gnuradio] r6530 - gnuradio/branches/developers/matt/u2f/firmware
Date: Mon, 24 Sep 2007 22:33:55 -0600 (MDT)

Author: eb
Date: 2007-09-24 22:33:55 -0600 (Mon, 24 Sep 2007)
New Revision: 6530

Added:
   gnuradio/branches/developers/matt/u2f/firmware/eth_mac.c
   gnuradio/branches/developers/matt/u2f/firmware/eth_mac.h
Modified:
   gnuradio/branches/developers/matt/u2f/firmware/Makefile
   gnuradio/branches/developers/matt/u2f/firmware/eth_mac_regs.h
Log:
ethernet mac/driver work-in-progress

Modified: gnuradio/branches/developers/matt/u2f/firmware/Makefile
===================================================================
--- gnuradio/branches/developers/matt/u2f/firmware/Makefile     2007-09-25 
03:54:03 UTC (rev 6529)
+++ gnuradio/branches/developers/matt/u2f/firmware/Makefile     2007-09-25 
04:33:55 UTC (rev 6530)
@@ -24,7 +24,7 @@
 test1.exe: test1_main.o u2_init.o spi.o buffer_pool.o sim_io.o
        $(CC) $(LDFLAGS) $^ -o $@
 
-eth_test.exe:  eth_test.o u2_init.o spi.o buffer_pool.o sim_io.o
+eth_test.exe:  eth_test.o u2_init.o spi.o buffer_pool.o sim_io.o eth_mac.o
        $(CC) $(LDFLAGS) $^ -o $@
 
 timer_test.exe:  timer_test.o u2_init.o spi.o sim_io.o
@@ -42,3 +42,4 @@
 test1_main.o: u2_init.h memory_map.h eth_mac_regs.h spi.h buffer_pool.h 
sim_io.h test1_main.c
 eth_test.o: u2_init.h memory_map.h eth_mac_regs.h spi.h buffer_pool.h sim_io.h 
eth_test.c
 eth.o: u2_init.h memory_map.h eth_mac_regs.h spi.h buffer_pool.h sim_io.h eth.c
+eth_mac.o: memory_map.h eth_mac_regs.h eth_mac.c

Added: gnuradio/branches/developers/matt/u2f/firmware/eth_mac.c
===================================================================
--- gnuradio/branches/developers/matt/u2f/firmware/eth_mac.c                    
        (rev 0)
+++ gnuradio/branches/developers/matt/u2f/firmware/eth_mac.c    2007-09-25 
04:33:55 UTC (rev 6530)
@@ -0,0 +1,79 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio 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 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio 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.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "eth_mac.h"
+#include "memory_map.h"
+
+void 
+eth_mac_init()
+{
+  // FIXME more to do
+
+  eth_mac->miimoder = 16;      // divider from CPU clock (33MHz / 16 ~= 2MHz)
+}
+
+int
+eth_mac_read_rmon(int addr)
+{
+  int t;
+  
+  eth_mac->rmon_rd_addr = addr;
+  eth_mac->rmon_rd_apply = 1;
+  while(eth_mac->rmon_rd_grant == 0)
+    ;
+
+  t = (eth_mac->rmon_rd_dout_hi << 16) | eth_mac->rmon_rd_dout_lo;
+  eth_mac->rmon_rd_apply = 0;
+  return t;
+}
+
+int
+eth_mac_miim_read(int addr)
+{
+  int phy_addr = 0;
+  eth_mac->miiaddress = (addr & 0x1f) << 8 | phy_addr;
+  eth_mac->miicommand = MIIC_RSTAT;
+
+  while((eth_mac->miistatus & MIIS_BUSY) != 0)
+    ;
+
+  return eth_mac->miirx_data;
+}
+
+void
+eth_mac_miim_write(int addr, int value)
+{
+  int phy_addr = 0;
+  eth_mac->miiaddress = (addr & 0x1f) << 8 | phy_addr;
+  eth_mac->miitx_data = value;
+  eth_mac->miicommand = MIIC_WCTRLDATA;
+
+  while((eth_mac->miistatus & MIIS_BUSY) != 0)
+    ;
+}
+
+int
+eth_mac_miim_read_status()
+{
+  return eth_mac->miistatus;
+}
+
+


Property changes on: gnuradio/branches/developers/matt/u2f/firmware/eth_mac.c
___________________________________________________________________
Name: svn:eol-style
   + native

Added: gnuradio/branches/developers/matt/u2f/firmware/eth_mac.h
===================================================================
--- gnuradio/branches/developers/matt/u2f/firmware/eth_mac.h                    
        (rev 0)
+++ gnuradio/branches/developers/matt/u2f/firmware/eth_mac.h    2007-09-25 
04:33:55 UTC (rev 6530)
@@ -0,0 +1,32 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio 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 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio 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.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef INCLUDED_ETH_MAC_H
+#define INCLUDED_ETH_MAC_H
+
+void eth_mac_init();
+int  eth_mac_read_rmon(int addr);
+int  eth_mac_miim_read(int addr);
+void eth_mac_miim_write(int addr, int value);
+int  eth_mac_miim_read_status();
+
+
+#endif /* INCLUDED_ETH_MAC_H */


Property changes on: gnuradio/branches/developers/matt/u2f/firmware/eth_mac.h
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: gnuradio/branches/developers/matt/u2f/firmware/eth_mac_regs.h
===================================================================
--- gnuradio/branches/developers/matt/u2f/firmware/eth_mac_regs.h       
2007-09-25 03:54:03 UTC (rev 6529)
+++ gnuradio/branches/developers/matt/u2f/firmware/eth_mac_regs.h       
2007-09-25 04:33:55 UTC (rev 6530)
@@ -23,6 +23,8 @@
 #define INCLUDED_ETH_MAC_REGS_H
 
 /*
+ * See opencores.org 10_100_1000 Mbps Tri-mode Ethernet MAC Specification
+ *
  * In reality, these are 16-bit regs, but are assigned
  * on 32-bit boundaries.  Because we're little endian,
  * declaring them "int" works.
@@ -56,11 +58,11 @@
   volatile int rx_ifg_set;
   volatile int rx_max_length;
   volatile int rx_min_length;
-  volatile int cpu_rd_addr;            // performance counter access
-  volatile int cpu_rd_apply;           
-  volatile int cpu_rd_grant;           // READONLY
-  volatile int cpu_rd_dout_lo;         // READONLY
-  volatile int cpu_rd_dout_hi;         // READONLY
+  volatile int rmon_rd_addr;           // performance counter access
+  volatile int rmon_rd_apply;          
+  volatile int rmon_rd_grant;          // READONLY
+  volatile int rmon_rd_dout_lo;        // READONLY
+  volatile int rmon_rd_dout_hi;        // READONLY
   volatile int line_loop_en;
   volatile int speed;
   volatile int miimoder;
@@ -71,4 +73,15 @@
   volatile int miistatus;
 } eth_mac_regs_t;
 
+// miicommand register
+#define MIIC_SCANSSTAT (1 << 0)        // Scan status
+#define MIIC_RSTAT      (1 << 1)       // Read status
+#define        MIIC_WCTRLDATA  (1 << 2)        // Write control data
+
+// miistatus register
+#define MIIS_LINKFAIL  (1 << 0)        // The link failed
+#define        MIIS_BUSY       (1 << 1)        // The MII is busy (operation 
in progress)
+#define        MIIS_NVALID     (1 << 2)        // The data in the status 
register is invalid
+                                       //   This it is only valid when the 
scan status is active.
+
 #endif /* INCLUDED_ETH_MAC_REGS_H */





reply via email to

[Prev in Thread] Current Thread [Next in Thread]