GNU Radio 3.3.0 C++ API
memory_map.h
Go to the documentation of this file.
00001 /* -*- c -*- */
00002 /*
00003  * Copyright 2007,2008,2009 Free Software Foundation, Inc.
00004  *
00005  * This program is free software: you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License as published by
00007  * the Free Software Foundation, either version 3 of the License, or
00008  * (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00017  */
00018 
00019 /* Overall Memory Map
00020  *   0000-7FFF  32K   RAM space (16K on 1500, 24K on 2000, 32K on DSP)
00021  *   8000-BFFF  16K   Buffer Pool
00022  *   C000-FFFF  16K   Peripherals
00023  */
00024 
00025 
00026 #ifndef INCLUDED_MEMORY_MAP_H
00027 #define INCLUDED_MEMORY_MAP_H
00028 
00029 #include <stdint.h>
00030 
00031 
00032 #define MASTER_CLK_RATE        100000000                // 100 MHz
00033 
00034 
00035 ////////////////////////////////////////////////////////////////
00036 //
00037 //         Memory map for embedded wishbone bus
00038 //
00039 ////////////////////////////////////////////////////////////////
00040 
00041 
00042 ////////////////////////////////////////////////////////////////
00043 // Main RAM, Slave 0
00044 
00045 #define RAM_BASE 0x0000
00046 
00047 ////////////////////////////////////////////////////////////////
00048 // Buffer Pool RAM, Slave 1
00049 //
00050 // The buffers themselves are located in Slave 1, Buffer Pool RAM.
00051 // The status registers are in Slave 5, Buffer Pool Status.
00052 // The control register is in Slave 7, Settings Bus.
00053 
00054 #define BUFFER_POOL_RAM_BASE 0x8000
00055 
00056 #define NBUFFERS                8
00057 #define BP_NLINES          0x0200       // number of 32-bit lines in a buffer
00058 #define BP_LAST_LINE    (BP_NLINES - 1) // last line in a buffer
00059 
00060 #define buffer_pool_ram \
00061   ((uint32_t *) BUFFER_POOL_RAM_BASE)
00062 
00063 #define buffer_ram(n) (&buffer_pool_ram[(n) * BP_NLINES])
00064 
00065 
00066 /////////////////////////////////////////////////////
00067 // SPI Core, Slave 2.  See core docs for more info
00068 #define SPI_BASE 0xC000   // Base address (16-bit)
00069 
00070 typedef struct {
00071   volatile uint32_t     txrx0;
00072   volatile uint32_t     txrx1;
00073   volatile uint32_t     txrx2;
00074   volatile uint32_t     txrx3;
00075   volatile uint32_t     ctrl;
00076   volatile uint32_t     div;
00077   volatile uint32_t     ss;
00078 } spi_regs_t;
00079 
00080 #define spi_regs ((spi_regs_t *) SPI_BASE)
00081 
00082 
00083 // Masks for controlling different peripherals
00084 #define SPI_SS_AD9510    1
00085 #define SPI_SS_AD9777    2
00086 #define SPI_SS_RX_DAC    4
00087 #define SPI_SS_RX_ADC    8
00088 #define SPI_SS_RX_DB    16
00089 #define SPI_SS_TX_DAC   32
00090 #define SPI_SS_TX_ADC   64
00091 #define SPI_SS_TX_DB   128
00092 
00093 // Masks for different parts of CTRL reg
00094 #define SPI_CTRL_ASS      (1<<13)
00095 #define SPI_CTRL_IE       (1<<12)
00096 #define SPI_CTRL_LSB      (1<<11)
00097 #define SPI_CTRL_TXNEG    (1<<10)
00098 #define SPI_CTRL_RXNEG    (1<< 9)
00099 #define SPI_CTRL_GO_BSY   (1<< 8)
00100 #define SPI_CTRL_CHAR_LEN_MASK 0x7F
00101 
00102 ////////////////////////////////////////////////
00103 // I2C, Slave 3
00104 // See Wishbone I2C-Master Core Specification.
00105 
00106 #define I2C_BASE 0xC400
00107 
00108 typedef struct {
00109   volatile uint32_t  prescaler_lo;      // r/w
00110   volatile uint32_t  prescaler_hi;      // r/w
00111   volatile uint32_t  ctrl;              // r/w
00112   volatile uint32_t  data;              // wr = transmit reg; rd = receive reg
00113   volatile uint32_t  cmd_status;        // wr = command reg;  rd = status reg
00114 } i2c_regs_t;
00115 
00116 #define i2c_regs ((i2c_regs_t *) I2C_BASE)
00117 
00118 #define I2C_CTRL_EN     (1 << 7)        // core enable
00119 #define I2C_CTRL_IE     (1 << 6)        // interrupt enable
00120 
00121 //
00122 // STA, STO, RD, WR, and IACK bits are cleared automatically
00123 //
00124 #define I2C_CMD_START   (1 << 7)        // generate (repeated) start condition
00125 #define I2C_CMD_STOP    (1 << 6)        // generate stop condition
00126 #define I2C_CMD_RD      (1 << 5)        // read from slave
00127 #define I2C_CMD_WR      (1 << 4)        // write to slave
00128 #define I2C_CMD_NACK    (1 << 3)        // when a rcvr, send ACK (ACK=0) or NACK (ACK=1)
00129 #define I2C_CMD_RSVD_2  (1 << 2)        // reserved
00130 #define I2C_CMD_RSVD_1  (1 << 1)        // reserved
00131 #define I2C_CMD_IACK    (1 << 0)        // set to clear pending interrupt
00132 
00133 #define I2C_ST_RXACK    (1 << 7)        // Received acknowledgement from slave (1 = NAK, 0 = ACK)
00134 #define I2C_ST_BUSY     (1 << 6)        // 1 after START signal detected; 0 after STOP signal detected
00135 #define I2C_ST_AL       (1 << 5)        // Arbitration lost.  1 when core lost arbitration
00136 #define I2C_ST_RSVD_4   (1 << 4)        // reserved
00137 #define I2C_ST_RSVD_3   (1 << 3)        // reserved
00138 #define I2C_ST_RSVD_2   (1 << 2)        // reserved
00139 #define I2C_ST_TIP      (1 << 1)        // Transfer-in-progress
00140 #define I2C_ST_IP       (1 << 0)        // Interrupt pending
00141 
00142 
00143 ////////////////////////////////////////////////
00144 // GPIO, Slave 4
00145 //
00146 // These go to the daughterboard i/o pins
00147 
00148 #define GPIO_BASE 0xC800
00149 
00150 typedef struct {
00151   volatile uint32_t     io;       // tx data in high 16, rx in low 16
00152   volatile uint32_t     ddr;      // 32 bits, 1 means output. tx in high 16, rx in low 16
00153   volatile uint32_t     tx_sel;   // 16 2-bit fields select which source goes to TX DB
00154   volatile uint32_t     rx_sel;   // 16 2-bit fields select which source goes to RX DB
00155 } gpio_regs_t;
00156 
00157 // each 2-bit sel field is layed out this way
00158 #define GPIO_SEL_SW        0 // if pin is an output, set by software in the io reg
00159 #define GPIO_SEL_ATR       1 // if pin is an output, set by ATR logic
00160 #define GPIO_SEL_DEBUG_0   2 // if pin is an output, debug lines from FPGA fabric
00161 #define GPIO_SEL_DEBUG_1   3 // if pin is an output, debug lines from FPGA fabric
00162 
00163 #define gpio_base ((gpio_regs_t *) GPIO_BASE)
00164 
00165 ///////////////////////////////////////////////////
00166 // Buffer Pool Status, Slave 5
00167 //
00168 // The buffers themselves are located in Slave 1, Buffer Pool RAM.
00169 // The status registers are in Slave 5, Buffer Pool Status.
00170 // The control register is in Slave 7, Settings Bus.
00171 
00172 #define BUFFER_POOL_STATUS_BASE 0xCC00
00173 
00174 typedef struct {
00175   volatile uint32_t last_line[NBUFFERS]; // last line xfer'd in buffer
00176   volatile uint32_t status;              // error and done flags
00177   volatile uint32_t hw_config;           // see below
00178   volatile uint32_t dummy[3];
00179   volatile uint32_t irqs;
00180   volatile uint32_t pri_enc_bp_status;
00181   volatile uint32_t cycle_count;
00182 } buffer_pool_status_t;
00183 
00184 #define buffer_pool_status ((buffer_pool_status_t *) BUFFER_POOL_STATUS_BASE)
00185 
00186 /*
00187  * Buffer n's xfer is done.
00188  * Clear this bit by issuing bp_clear_buf(n)
00189  */
00190 #define BPS_DONE(n)     (0x00000001 << (n))
00191 #define BPS_DONE_0      BPS_DONE(0)
00192 #define BPS_DONE_1      BPS_DONE(1)
00193 #define BPS_DONE_2      BPS_DONE(2)
00194 #define BPS_DONE_3      BPS_DONE(3)
00195 #define BPS_DONE_4      BPS_DONE(4)
00196 #define BPS_DONE_5      BPS_DONE(5)
00197 #define BPS_DONE_6      BPS_DONE(6)
00198 #define BPS_DONE_7      BPS_DONE(7)
00199 
00200 /*
00201  * Buffer n's xfer had an error.
00202  * Clear this bit by issuing bp_clear_buf(n)
00203  */
00204 #define BPS_ERROR(n)    (0x00000100 << (n))
00205 #define BPS_ERROR_0     BPS_ERROR(0)
00206 #define BPS_ERROR_1     BPS_ERROR(1)
00207 #define BPS_ERROR_2     BPS_ERROR(2)
00208 #define BPS_ERROR_3     BPS_ERROR(3)
00209 #define BPS_ERROR_4     BPS_ERROR(4)
00210 #define BPS_ERROR_5     BPS_ERROR(5)
00211 #define BPS_ERROR_6     BPS_ERROR(6)
00212 #define BPS_ERROR_7     BPS_ERROR(7)
00213 
00214 /*
00215  * Buffer n is idle.  A buffer is idle if it's not
00216  * DONE, ERROR, or processing a transaction.  If it's
00217  * IDLE, it's safe to start a new transaction.
00218  *
00219  * Clear this bit by starting a xfer with
00220  * bp_send_from_buf or bp_receive_to_buf.
00221  */
00222 #define BPS_IDLE(n)     (0x00010000 << (n))
00223 #define BPS_IDLE_0      BPS_IDLE(0)
00224 #define BPS_IDLE_1      BPS_IDLE(1)
00225 #define BPS_IDLE_2      BPS_IDLE(2)
00226 #define BPS_IDLE_3      BPS_IDLE(3)
00227 #define BPS_IDLE_4      BPS_IDLE(4)
00228 #define BPS_IDLE_5      BPS_IDLE(5)
00229 #define BPS_IDLE_6      BPS_IDLE(6)
00230 #define BPS_IDLE_7      BPS_IDLE(7)
00231 
00232 /*
00233  * Buffer n has a "slow path" packet in it.
00234  * This bit is orthogonal to the bits above and indicates that
00235  * the FPGA ethernet rx protocol engine has identified this packet
00236  * as one requiring firmware intervention.
00237  */
00238 #define BPS_SLOWPATH(n) (0x01000000 << (n))
00239 #define BPS_SLOWPATH_0  BPS_SLOWPATH(0)
00240 #define BPS_SLOWPATH_1  BPS_SLOWPATH(1)
00241 #define BPS_SLOWPATH_2  BPS_SLOWPATH(2)
00242 #define BPS_SLOWPATH_3  BPS_SLOWPATH(3)
00243 #define BPS_SLOWPATH_4  BPS_SLOWPATH(4)
00244 #define BPS_SLOWPATH_5  BPS_SLOWPATH(5)
00245 #define BPS_SLOWPATH_6  BPS_SLOWPATH(6)
00246 #define BPS_SLOWPATH_7  BPS_SLOWPATH(7)
00247 
00248 
00249 #define BPS_DONE_ALL      0x000000ff    // mask of all dones
00250 #define BPS_ERROR_ALL     0x0000ff00    // mask of all errors
00251 #define BPS_IDLE_ALL      0x00ff0000    // mask of all idles
00252 #define BPS_SLOWPATH_ALL  0xff000000    // mask of all slowpaths
00253 
00254 // The hw_config register
00255 
00256 #define HWC_SIMULATION          0x80000000
00257 #define HWC_WB_CLK_DIV_MASK     0x0000000f
00258 
00259 /*!
00260  * \brief return non-zero if we're running under the simulator
00261  */
00262 inline static int
00263 hwconfig_simulation_p(void)
00264 {
00265   return buffer_pool_status->hw_config & HWC_SIMULATION;
00266 }
00267 
00268 /*!
00269  * \brief Return Wishbone Clock divisor.
00270  * The processor runs at the Wishbone Clock rate which is MASTER_CLK_RATE / divisor.
00271  */
00272 inline static int
00273 hwconfig_wishbone_divisor(void)
00274 {
00275   return buffer_pool_status->hw_config & HWC_WB_CLK_DIV_MASK;
00276 }
00277 
00278 ///////////////////////////////////////////////////
00279 // Ethernet Core, Slave 6
00280 
00281 #define ETH_BASE 0xD000
00282 
00283 #include "eth_mac_regs.h"
00284 
00285 #define eth_mac ((eth_mac_regs_t *) ETH_BASE)
00286 
00287 ////////////////////////////////////////////////////
00288 // Settings Bus, Slave #7, Not Byte Addressable!
00289 //
00290 // Output-only from processor point-of-view.
00291 // 1KB of address space (== 256 32-bit write-only regs)
00292 
00293 
00294 #define MISC_OUTPUT_BASE        0xD400
00295 #define TX_PROTOCOL_ENGINE_BASE 0xD480
00296 #define RX_PROTOCOL_ENGINE_BASE 0xD4C0
00297 #define BUFFER_POOL_CTRL_BASE   0xD500
00298 #define DSP_TX_BASE             0xD600
00299 #define DSP_RX_BASE             0xD680
00300 
00301 #define LAST_SETTING_REG        0xD7FC  // last valid setting register
00302 
00303 // --- buffer pool control regs ---
00304 
00305 typedef struct {
00306   volatile uint32_t ctrl;
00307 } buffer_pool_ctrl_t;
00308 
00309 // buffer pool ports
00310 
00311 #define PORT_SERDES     0       // serial/deserializer
00312 #define PORT_DSP        1       // DSP tx or rx pipeline
00313 #define PORT_ETH        2       // ethernet tx or rx
00314 #define PORT_RAM        3       // RAM tx or rx
00315 
00316 // the buffer pool ctrl register fields
00317 
00318 #define BPC_BUFFER(n) (((n) & 0xf) << 28)
00319 #define   BPC_BUFFER_MASK      BPC_BUFFER(~0)
00320 #define   BPC_BUFFER_0         BPC_BUFFER(0)
00321 #define   BPC_BUFFER_1         BPC_BUFFER(1)
00322 #define   BPC_BUFFER_2         BPC_BUFFER(2)
00323 #define   BPC_BUFFER_3         BPC_BUFFER(3)
00324 #define   BPC_BUFFER_4         BPC_BUFFER(4)
00325 #define   BPC_BUFFER_5         BPC_BUFFER(5)
00326 #define   BPC_BUFFER_6         BPC_BUFFER(6)
00327 #define   BPC_BUFFER_7         BPC_BUFFER(7)
00328 #define   BPC_BUFFER_NIL       BPC_BUFFER(0x8)  // disable
00329 
00330 #define BPC_PORT(n) (((n) & 0x7) << 25)
00331 #define   BPC_PORT_MASK        BPC_PORT(~0)
00332 #define   BPC_PORT_SERDES      BPC_PORT(PORT_SERDES)
00333 #define   BPC_PORT_DSP         BPC_PORT(PORT_DSP)
00334 #define   BPC_PORT_ETH         BPC_PORT(PORT_ETH)
00335 #define   BPC_PORT_RAM         BPC_PORT(PORT_RAM)
00336 #define   BPC_PORT_NIL         BPC_PORT(0x4)    // disable
00337 
00338 #define BPC_CLR                (1 << 24)  // mutually excl commands
00339 #define BPC_READ               (1 << 23)
00340 #define BPC_WRITE              (1 << 22)
00341 
00342 #define BPC_STEP(step) (((step) & 0xf) << 18)
00343 #define   BPC_STEP_MASK        BPC_STEP(~0)
00344 #define BPC_LAST_LINE(line) (((line) & 0x1ff) << 9)
00345 #define   BPC_LAST_LINE_MASK   BPC_LAST_LINE(~0)
00346 #define BPC_FIRST_LINE(line) (((line) & 0x1ff) << 0)
00347 #define   BPC_FIRST_LINE_MASK  BPC_FIRST_LINE(~0)
00348 
00349 #define buffer_pool_ctrl ((buffer_pool_ctrl_t *) BUFFER_POOL_CTRL_BASE)
00350 
00351 // --- misc outputs ---
00352 
00353 typedef struct {
00354   volatile uint32_t     clk_ctrl;
00355   volatile uint32_t     serdes_ctrl;
00356   volatile uint32_t     adc_ctrl;
00357   volatile uint32_t     leds;
00358   volatile uint32_t     phy_ctrl;       // LSB is reset line to eth phy
00359   volatile uint32_t     debug_mux_ctrl;
00360   volatile uint32_t     ram_page;       // FIXME should go somewhere else...
00361   volatile uint32_t     flush_icache;   // Flush the icache
00362   volatile uint32_t     led_src;        // HW or SW control for LEDs
00363 } output_regs_t;
00364 
00365 #define SERDES_ENABLE 8
00366 #define SERDES_PRBSEN 4
00367 #define SERDES_LOOPEN 2
00368 #define SERDES_RXEN   1
00369 
00370 #define ADC_CTRL_ON     0x0F
00371 #define ADC_CTRL_OFF    0x00
00372 
00373 // crazy order that matches the labels on the case
00374 
00375 #define LED_A           (1 << 4)
00376 #define LED_B           (1 << 1)
00377 #define LED_C           (1 << 3)
00378 #define LED_D           (1 << 0)
00379 #define LED_E           (1 << 2)
00380 //      LED_F           // controlled by CPLD
00381 #define LED_RJ45        (1 << 5)
00382 
00383 #define output_regs ((output_regs_t *) MISC_OUTPUT_BASE)
00384 
00385 // --- dsp tx regs ---
00386 
00387 #define MIN_CIC_INTERP  1
00388 #define MAX_CIC_INTERP  128
00389 
00390 typedef struct {
00391   volatile int32_t      freq;
00392   volatile uint32_t     scale_iq;       // {scale_i,scale_q}
00393   volatile uint32_t     interp_rate;
00394   volatile uint32_t     clear_state;    // clears out state machine, fifos,
00395                                         //   NOT freq, scale, interp
00396   /*!
00397    * \brief output mux configuration.
00398    *
00399    * <pre>
00400    *     3                   2                   1                       
00401    *   1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
00402    *  +-------------------------------+-------+-------+-------+-------+
00403    *  |                                               | DAC1  |  DAC0 |
00404    *  +-------------------------------+-------+-------+-------+-------+
00405    * 
00406    *  There are N DUCs (1 now) with complex inputs and outputs.
00407    *  There are two DACs.
00408    * 
00409    *  Each 4-bit DACx field specifies the source for the DAC
00410    *  Each subfield is coded like this: 
00411    * 
00412    *     3 2 1 0
00413    *    +-------+
00414    *    |   N   |
00415    *    +-------+
00416    * 
00417    *  N specifies which DUC output is connected to this DAC.
00418    * 
00419    *   N   which interp output
00420    *  ---  -------------------
00421    *   0   DUC 0 I
00422    *   1   DUC 0 Q
00423    *   2   DUC 1 I
00424    *   3   DUC 1 Q
00425    *   F   All Zeros
00426    *   
00427    * The default value is 0x10
00428    * </pre>
00429    */
00430   volatile uint32_t     tx_mux;
00431 
00432 } dsp_tx_regs_t;
00433   
00434 #define dsp_tx_regs ((dsp_tx_regs_t *) DSP_TX_BASE)
00435 
00436 // --- dsp rx regs ---
00437 
00438 #define T_NOW (-1)
00439 
00440 #define MIN_CIC_DECIM   1
00441 #define MAX_CIC_DECIM   128
00442 
00443 typedef struct {
00444   volatile int32_t      freq;
00445   volatile uint32_t     scale_iq;       // {scale_i,scale_q}
00446   volatile uint32_t     decim_rate;
00447   volatile uint32_t     rx_time;        // when to begin reception
00448   volatile uint32_t     rx_command;     // {now, chain, num_lines(21), lines_per_frame(9)
00449   volatile uint32_t     clear_state;    // clears out state machine, fifos,
00450                                         //   cmd queue, NOT freq, scale, decim
00451   volatile uint32_t     dcoffset_i;     // Bit 31 high sets fixed offset mode, using lower 14 bits,
00452                                         // otherwise it is automatic 
00453   volatile uint32_t     dcoffset_q;     // Bit 31 high sets fixed offset mode, using lower 14 bits
00454 
00455   /*!
00456    * \brief input mux configuration.
00457    *
00458    * This determines which ADC (or constant zero) is connected to 
00459    * each DDC input.  There are N DDCs (1 now).  Each has two inputs.
00460    *
00461    * <pre>
00462    * Mux value:
00463    *
00464    *    3                   2                   1                       
00465    *  1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
00466    * +-------+-------+-------+-------+-------+-------+-------+-------+
00467    * |                                                       |Q0 |I0 |
00468    * +-------+-------+-------+-------+-------+-------+-------+-------+
00469    *
00470    * Each 2-bit I field is either 00 (A/D A), 01 (A/D B) or 1X (const zero)
00471    * Each 2-bit Q field is either 00 (A/D A), 01 (A/D B) or 1X (const zero)
00472    *
00473    * The default value is 0x4
00474    * </pre>
00475    */
00476   volatile uint32_t     rx_mux;        // called adc_mux in dsp_core_rx.v
00477 
00478   /*!
00479    * \brief Streaming GPIO configuration
00480    *
00481    * This determines whether the LSBs of I and Q samples come from the DSP
00482    * pipeline or from the io_rx GPIO pins.  To stream GPIO, one must first
00483    * set the GPIO data direction register to have io_rx[15] and/or io_rx[14]
00484    * configured as inputs.  The GPIO pins will be sampled at the time the
00485    * remainder of the DSP sample is strobed into the RX sample FIFO.  There
00486    * will be a decimation-dependent fixed time offset between the GPIO
00487    * sample stream and the associated RF samples.
00488    *
00489    *    3                   2                   1                       
00490    *  1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
00491    * +-------+-------+-------+-------+-------+-------+-------+-------+
00492    * |                           MBZ                             |Q|I|
00493    * +-------+-------+-------+-------+-------+-------+-------+-------+
00494    *
00495    * I         0=LSB comes from DSP pipeline (default)
00496    *           1=LSB comes from io_rx[15]
00497    * 
00498    * Q         0=LSB comes from DSP pipeline (default)
00499    *           1=LSB comes from io_rx[14]
00500    */
00501   volatile uint32_t gpio_stream_enable;
00502 
00503 } dsp_rx_regs_t;
00504   
00505 #define dsp_rx_regs ((dsp_rx_regs_t *) DSP_RX_BASE)
00506 
00507 #define MK_RX_CMD(num_lines, lines_per_frame, now, chain) \
00508   (((num_lines) << 9) | ((lines_per_frame) & 0x1ff) \
00509    | (((now) & 0x1) << 31) | (((chain) & 0x1) << 30))
00510 
00511 /* 
00512  * --- ethernet tx protocol engine regs (write only) ---
00513  *
00514  * These registers control the transmit portion of the ethernet
00515  * protocol engine (out of USRP2).  The protocol engine handles fifo
00516  * status and sequence number insertion in outgoing packets, and
00517  * automagically generates status packets when required to inform the
00518  * host of changes in fifo availability.
00519  *
00520  * All outgoing packets have their fifo_status field set to the number
00521  * of 32-bit lines of fifo available in the ethernet Rx fifo (see
00522  * usrp2_eth_packet.h).  Seqno's are set if FIXME, else 0.
00523  *
00524  * FIXME clean this up once we know how it's supposed to behave.
00525  */
00526 
00527 typedef struct {
00528   volatile uint32_t  flags;          // not yet fully defined (channel?)
00529   volatile uint32_t  mac_dst0123;    // 4 bytes of destination mac addr
00530   volatile uint32_t  mac_dst45src01; // 2 bytes of dest mac addr; 2 bytes of src mac addr
00531   volatile uint32_t  mac_src2345;    // 4 bytes of destination mac addr
00532   volatile uint32_t  seqno;          // Write to init seqno.  It autoincs on match
00533 } tx_proto_engine_regs_t;
00534 
00535 #define tx_proto_engine ((tx_proto_engine_regs_t *) TX_PROTOCOL_ENGINE_BASE)
00536 
00537 /*
00538  * --- ethernet rx protocol engine regs (write only) ---
00539  *
00540  * These registers control the receive portion of the ethernet
00541  * protocol engine (into USRP2).  The protocol engine offloads common
00542  * packet inspection operations so that firmware has less to do on
00543  * "fast path" packets.
00544  *
00545  * The registers define conditions which must be matched for a packet
00546  * to be considered a "fast path" packet.  If a received packet
00547  * matches the src and dst mac address, ethertype, flags field, and
00548  * expected seqno number it is considered a "fast path" packet, and
00549  * the expected seqno is updated.  If the packet fails to satisfy any
00550  * of the above conditions it's a "slow path" packet, and the
00551  * corresponding SLOWPATH flag will be set buffer_status register.
00552  */
00553 
00554 typedef struct {
00555   volatile uint32_t  flags;          // not yet fully defined (channel?)
00556   volatile uint32_t  mac_dst0123;    // 4 bytes of destination mac addr
00557   volatile uint32_t  mac_dst45src01; // 2 bytes of dest mac addr; 2 bytes of src mac addr
00558   volatile uint32_t  mac_src2345;    // 4 bytes of destination mac addr
00559   volatile uint32_t  ethertype_pad;  // ethertype in high 16-bits
00560 } rx_proto_engine_regs_t;
00561 
00562 #define rx_proto_engine ((rx_proto_engine_regs_t *) RX_PROTOCOL_ENGINE_BASE)
00563 
00564 
00565 
00566 ///////////////////////////////////////////////////
00567 // Simple Programmable Interrupt Controller, Slave 8
00568 
00569 #define PIC_BASE  0xD800
00570 
00571 // Interrupt request lines
00572 // Bit numbers (LSB == 0) that correpond to interrupts into PIC
00573 
00574 #define IRQ_BUFFER      0       // buffer manager
00575 #define IRQ_TIMER       1
00576 #define IRQ_SPI         2
00577 #define IRQ_I2C         3
00578 #define IRQ_PHY         4       // ethernet PHY
00579 #define IRQ_UNDERRUN    5
00580 #define IRQ_OVERRUN     6
00581 #define IRQ_PPS         7       // pulse per second
00582 #define IRQ_UART_RX     8
00583 #define IRQ_UART_TX     9
00584 #define IRQ_SERDES      10
00585 #define IRQ_CLKSTATUS   11
00586 
00587 #define IRQ_TO_MASK(x) (1 << (x))
00588 
00589 #define PIC_BUFFER_INT    IRQ_TO_MASK(IRQ_BUFFER)
00590 #define PIC_TIMER_INT     IRQ_TO_MASK(IRQ_TIMER)
00591 #define PIC_SPI_INT       IRQ_TO_MASK(IRQ_SPI)
00592 #define PIC_I2C_INT       IRQ_TO_MASK(IRQ_I2C)
00593 #define PIC_PHY_INT       IRQ_TO_MASK(IRQ_PHY)
00594 #define PIC_UNDERRUN_INT  IRQ_TO_MASK(IRQ_UNDERRUN)
00595 #define PIC_OVERRUN_INT   IRQ_TO_MASK(IRQ_OVERRUN)
00596 #define PIC_PPS_INT       IRQ_TO_MASK(IRQ_PPS)
00597 #define PIC_UART_RX_INT   IRQ_TO_MASK(IRQ_UART_RX)
00598 #define PIC_UART_TX_INT   IRQ_TO_MASK(IRQ_UART_TX)
00599 #define PIC_SERDES        IRQ_TO_MASK(IRQ_SERDES)
00600 #define PIC_CLKSTATUS     IRQ_TO_MASK(IRQ_CLKSTATUS)
00601 
00602 typedef struct {
00603   volatile uint32_t edge_enable; // mask: 1 -> edge triggered, 0 -> level
00604   volatile uint32_t polarity;    // mask: 1 -> rising edge
00605   volatile uint32_t mask;        // mask: 1 -> disabled
00606   volatile uint32_t pending;     // mask: 1 -> pending; write 1's to clear pending ints
00607 } pic_regs_t;
00608 
00609 #define pic_regs ((pic_regs_t *) PIC_BASE)
00610 
00611 ///////////////////////////////////////////////////
00612 // Timer, Slave 9
00613 
00614 #define TIMER_BASE  0xDC00
00615 
00616 typedef struct {
00617   volatile uint32_t time;       // R: current, W: set time to interrupt
00618 } timer_regs_t;
00619 
00620 #define timer_regs ((timer_regs_t *) TIMER_BASE)
00621 
00622 ///////////////////////////////////////////////////
00623 // UART, Slave 10
00624 
00625 #define UART_BASE  0xE000
00626 
00627 typedef struct {
00628   //  All elements are 8 bits except for clkdiv (16), but we use uint32 to make 
00629   //    the hardware for decoding easier
00630   volatile uint32_t clkdiv;  // Set to 50e6 divided by baud rate (no x16 factor)
00631   volatile uint32_t txlevel; // Number of spaces in the FIFO for writes
00632   volatile uint32_t rxlevel; // Number of available elements in the FIFO for reads
00633   volatile uint32_t txchar;  // Write characters to be sent here
00634   volatile uint32_t rxchar;  // Read received characters here
00635 } uart_regs_t;
00636 
00637 #define uart_regs ((uart_regs_t *) UART_BASE)
00638 
00639 ///////////////////////////////////////////////////
00640 // ATR Controller, Slave 11
00641 
00642 #define ATR_BASE  0xE400
00643 
00644 typedef struct {
00645   volatile uint32_t     v[16];
00646 } atr_regs_t;
00647 
00648 #define ATR_IDLE        0x0     // indicies into v
00649 #define ATR_TX          0x1
00650 #define ATR_RX          0x2
00651 #define ATR_FULL        0x3
00652 
00653 #define atr_regs ((atr_regs_t *) ATR_BASE)
00654 
00655 ///////////////////////////////////////////////////
00656 // Time Sync Controller, Slave 12
00657 #define TIMESYNC_BASE  0xE800
00658 
00659 typedef struct {
00660   /*!
00661    * \brief Time sync configuration.
00662    *
00663    * <pre>
00664    *
00665    *    3                   2                   1                       
00666    *  1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
00667    * +-----------------------------------------------------+-+-+-+-+-+
00668    * |                                                     |T|G|X|I|S|
00669    * +-----------------------------------------------------+-+-+-+-+-+
00670    *
00671    * S - Tick source (0 = free run, 1 = pps, default=0)
00672    * I - Tick interrupt enable (not implemented)
00673    * X - Use external sync source (default=1)
00674    * G - PPS edge selection (0=negedge, 1=posedge, default=0)
00675    * T - Trigger sync every pps edge (default=0)
00676    *
00677    * </pre>
00678    */
00679   volatile uint32_t tick_control;
00680   volatile uint32_t tick_interval;
00681   volatile uint32_t delta_time;
00682   volatile uint32_t sync_on_next_pps;
00683 } timesync_regs_t;
00684 
00685 #define timesync_regs ((timesync_regs_t *) TIMESYNC_BASE)
00686 
00687 #define TSC_SOURCE_PPS        (1 << 0)
00688 //#define TSC_SOURCE_FREE_RUN (0 << 0)
00689 #define TSC_IENABLE           (1 << 1)
00690 #define TSC_EXTSYNC           (1 << 2)
00691 #define TSC_PPSEDGE_POS       (1 << 3)
00692 //#define TSC_PPSEDGE_NEG     (0 << 3)
00693 #define TSC_TRIGGER_EVERYPPS  (1 << 4)
00694 //#define TSC_TRIGGER_ONCE    (0 << 4)
00695 
00696 ///////////////////////////////////////////////////
00697 // SD Card SPI interface, Slave 13
00698 //   All regs are 8 bits wide, but are accessed as if they are 32 bits
00699 
00700 #define SDSPI_BASE  0xEC00
00701 
00702 typedef struct {
00703   volatile uint32_t status;  // Write a 1 or 0 for controlling CS
00704   volatile uint32_t clkdiv;
00705   volatile uint32_t send_dat;
00706   volatile uint32_t receive_dat;
00707 } sdspi_regs_t;
00708 
00709 #define sdspi_regs ((sdspi_regs_t *) SDSPI_BASE)
00710 
00711 ///////////////////////////////////////////////////
00712 // External RAM interface, Slave 14
00713 //   Pages are 1K.  Page is 10 bits, set by a control register
00714 //    output_regs->ram_page
00715 
00716 #define EXTRAM_BASE 0xF000
00717 #define extram ((volatile uint32_t *) EXTRAM_BASE)
00718 
00719 
00720 ///////////////////////////////////////////////////
00721 
00722 #endif
00723