Commit ad9656e3 authored by Tomasz Wlostowski's avatar Tomasz Wlostowski

initial support for multiple boards (SPEC/SVEC/etc.)

parent 5d3fc51a
# choose your board here.
BOARD = spec
# and don't touch the rest unless you know what you're doing.
CROSS_COMPILE = lm32-elf-
OBJS_WRC = wrc_main.o \
......@@ -50,7 +99,11 @@ OBJS=$(OBJS_PLATFORM) $(OBJS_WRC) $(OBJS_PTPD) $(OBJS_SHELL) $(OBJS_TESTS) $(OBJ
OUTPUT=wrc
REVISION=$(shell git rev-parse HEAD)
all: $(OBJS)
$(shell ln -sf ../boards/$(BOARD)/board.h include/board.h)
all: tools wrc
wrc: $(OBJS)
echo "const char *build_revision = \"$(REVISION)\";" > revision.c
echo "const char *build_date = __DATE__ \" \" __TIME__;" >> revision.c
$(CC) $(CFLAGS) -c revision.c
......@@ -67,13 +120,5 @@ clean:
%.o: %.c
${CC} $(CFLAGS) $(PTPD_CFLAGS) $(INCLUDE_DIR) $(LIB_DIR) -c $^ -o $@
load: #all
./tools/lm32-loader $(OUTPUT).bin
tools:
make -C tools
fpga:
- killall -9 vuart_console
../loadfile ../spec_top.bin
./tools/zpu-loader $(OUTPUT).bin
make -C tools
\ No newline at end of file
#ifndef __BOARD_H
#define __BOARD_H
#ifndef __REGS_H
#define __REGS_H
#define BASE_MINIC 0x20000
#define BASE_EP 0x20100
......@@ -11,15 +11,5 @@
#define FMC_EEPROM_ADR 0x50
#define CPU_CLOCK 62500000ULL
#define REF_CLOCK_PERIOD_PS 8000
#define REF_CLOCK_FREQ_HZ 125000000
#define UART_BAUDRATE 115200ULL /* not a real UART */
#define NET_MAX_SOCKETS 3
#define NET_SKBUF_SIZE 256
#endif
......@@ -27,136 +27,6 @@ int32_t sfp_alpha = 73622176; //default value if could not read EEPROM
int32_t sfp_deltaTx = 0;
int32_t sfp_deltaRx = 0;
uint32_t cal_phase_transition = 595; //7000;
///////////////////////////////////
#include "ptp-noposix/libptpnetif/ptpd_netif.h"
//void test_transition()
//{
// wr_socket_t *sock;
// wr_sockaddr_t bindaddr;
// const mac_addr_t PTP_MULTICAST_ADDR = {0x01, 0x1b, 0x19, 0, 0, 0};
//
// int phase = 0;
//
// softpll_enable();
//
// while(!softpll_check_lock()) timer_delay(1000);
//
//
// bindaddr.family = PTPD_SOCK_RAW_ETHERNET;// socket type
// bindaddr.ethertype = 0x88f7; // PTPv2
// memcpy(bindaddr.mac, PTP_MULTICAST_ADDR, sizeof(mac_addr_t));
//
// // Create one socket for event and general messages (WR lower level layer requires that
// sock = ptpd_netif_create_socket(PTPD_SOCK_RAW_ETHERNET, 0, &bindaddr);
//
// for(;;)
// { struct hw_timestamp hwts;
// wr_timestamp_t t_rx;
// uint8_t buf_hdr[18], buf[128];
// update_rx_queues();
//
// if(ptpd_netif_recvfrom(sock, &bindaddr, buf, 128, &t_rx) > 0)
//
//// if(minic_rx_frame(buf_hdr, buf, 128, &hwts) > 0)
// {
// printf("phase %d ahead %d TS %d:%d\n", phase,0,t_rx.nsec, t_rx.phase);
// phase+=100;
// softpll_set_phase(phase);
// timer_delay(10);
// }
//// mprintf(".");
// }
//}
//int last_btn0;
//int button_pressed()
//{
// int p;
// int btn0 = gpio_in(GPIO_BTN1);
// p=!btn0 && last_btn0;
// last_btn0 = btn0;
// return p;
//}
//void rx_test()
//{
// uint8_t mac[]= {0x1, 0x1b, 0x19, 0,0,0};
// uint16_t buf[100];
// wr_socket_t *sock;
// wr_sockaddr_t addr;
//
// memcpy(addr.mac, mac, 6);
// addr.ethertype = 0x88f7;
//
// ptpd_netif_init();
// sock = ptpd_netif_create_socket(PTPD_SOCK_RAW_ETHERNET, 0, &addr);
// mprintf("Sock @ %x\n", sock);
// wrc_extra_debug = 0;
// for(;;)
// {
// update_rx_queues();
// int n = ptpd_netif_recvfrom(sock, &addr, buf, sizeof(buf), NULL);
// if(n>0)
// {
// uint16_t sum = 0 ,i, rx;
// rx=n;
// n= buf[0];
// for(i=1;i<n;i++) sum+=buf[i];
// mprintf("%x %x\n", sum, buf[n]);
// if(sum != buf[n])
// {
// mprintf("****************** ERR: rxed %d size %d\n", rx, n);
// }
//
// }
// timer_delay(10);
// mprintf(".");
// }
//}
#if 1
int get_sfp_id(char *sfp_pn)
{
uint8_t data, sum=0;
uint8_t i;
// wait until SFP signalizes its presence
while( gpio_in(GPIO_SFP_DET) );
// mprintf("wr_core: SFP present\n");
mi2c_init(WRPC_SFP_I2C);
mi2c_start(WRPC_SFP_I2C);
mi2c_put_byte(WRPC_SFP_I2C, 0xA0);
mi2c_put_byte(WRPC_SFP_I2C, 0x00);
mi2c_repeat_start(WRPC_SFP_I2C);
mi2c_put_byte(WRPC_SFP_I2C, 0xA1);
mi2c_get_byte(WRPC_SFP_I2C, &data, 1);
mi2c_stop(WRPC_SFP_I2C);
sum = data;
mi2c_start(WRPC_SFP_I2C);
mi2c_put_byte(WRPC_SFP_I2C, 0xA1);
for(i=1; i<63; ++i)
{
mi2c_get_byte(WRPC_SFP_I2C, &data, 0);
sum = (uint8_t) ((uint16_t)sum + data) & 0xff;
if(i>=40 && i<=55) //Part Number
sfp_pn[i-40] = data;
}
mi2c_get_byte(WRPC_SFP_I2C, &data, 1); //final word, checksum
mi2c_stop(WRPC_SFP_I2C);
if(sum == data)
return 0;
return -1;
}
#endif
void wrc_initialize()
{
......@@ -169,23 +39,6 @@ void wrc_initialize()
mprintf("WR Core: starting up...\n");
timer_init(1);
//SFP
#if 0
if( get_sfp_id(sfp_pn) >= 0)
{
//mprintf("Found SFP transceiver ID: ");
for(i=0;i<16;i++)
mprintf("%c", sfp_pn[i]);
mprintf("\n");
if( !access_eeprom(sfp_pn, &sfp_alpha, &sfp_deltaTx, &sfp_deltaRx) )
{
mprintf("SFP: alpha=%d, deltaTx=%d, deltaRx=%d\n", sfp_alpha, sfp_deltaTx, sfp_deltaRx);
}
}
#endif
#if 1
//Generate MAC address
......@@ -206,12 +59,12 @@ void wrc_initialize()
mac_addr[5] = ds18_id[1]; // Creating Global Identifiers Using 1-Wire® Devices
TRACE_DEV("Local MAC address: %x:%x:%x:%x:%x:%x\n", mac_addr[0],mac_addr[1],mac_addr[2],mac_addr[3],mac_addr[4],mac_addr[5]);
ep_init(mac_addr);
ep_enable(1, 1);
minic_init();
pps_gen_init();
wrc_ptp_init();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment