Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
W
White Rabbit Switch - Software
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
86
Issues
86
List
Board
Labels
Milestones
Merge Requests
4
Merge Requests
4
CI / CD
CI / CD
Pipelines
Schedules
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
White Rabbit Switch - Software
Commits
76939652
Commit
76939652
authored
Nov 20, 2014
by
Alessandro Rubini
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'libwr-headers'
parents
121fd855
e56732ec
Hide whitespace changes
Inline
Side-by-side
Showing
58 changed files
with
196 additions
and
183 deletions
+196
-183
fpga_io.h
userspace/include/fpga_io.h
+1
-1
Makefile
userspace/libwr/Makefile
+3
-2
README
userspace/libwr/README
+1
-1
fan.c
userspace/libwr/fan.c
+8
-8
fpga_io.c
userspace/libwr/fpga_io.c
+1
-1
hal_client.c
userspace/libwr/hal_client.c
+4
-4
hwiu.c
userspace/libwr/hwiu.c
+2
-2
i2c.c
userspace/libwr/i2c.c
+8
-8
i2c_bitbang.c
userspace/libwr/i2c_bitbang.c
+23
-23
i2c_bitbang.h
userspace/libwr/i2c_bitbang.h
+2
-2
i2c_fpga_reg.c
userspace/libwr/i2c_fpga_reg.c
+4
-4
i2c_fpga_reg.h
userspace/libwr/i2c_fpga_reg.h
+1
-1
i2c_io.c
userspace/libwr/i2c_io.c
+2
-2
i2c_sfp.c
userspace/libwr/i2c_sfp.c
+14
-14
i2c_sfp.h
userspace/libwr/i2c_sfp.h
+1
-1
fan.h
userspace/libwr/include/libwr/fan.h
+3
-3
hal_client.h
userspace/libwr/include/libwr/hal_client.h
+11
-0
hwiu.h
userspace/libwr/include/libwr/hwiu.h
+3
-3
pio.h
userspace/libwr/include/libwr/pio.h
+3
-3
pps_gen.h
userspace/libwr/include/libwr/pps_gen.h
+3
-3
ptpd_netif.h
userspace/libwr/include/libwr/ptpd_netif.h
+3
-3
sfp_lib.h
userspace/libwr/include/libwr/sfp_lib.h
+3
-3
shw_io.h
userspace/libwr/include/libwr/shw_io.h
+5
-4
switch_hw.h
userspace/libwr/include/libwr/switch_hw.h
+7
-7
trace.h
userspace/libwr/include/libwr/trace.h
+3
-3
util.h
userspace/libwr/include/libwr/util.h
+3
-3
init.c
userspace/libwr/init.c
+2
-2
libshw_i2c.c
userspace/libwr/libshw_i2c.c
+5
-5
pio.c
userspace/libwr/pio.c
+9
-9
pps_gen.c
userspace/libwr/pps_gen.c
+5
-5
ptpd_netif.c
userspace/libwr/ptpd_netif.c
+2
-2
shw_io.c
userspace/libwr/shw_io.c
+3
-3
trace.c
userspace/libwr/trace.c
+1
-1
util.c
userspace/libwr/util.c
+2
-2
Makefile
userspace/tools/Makefile
+2
-2
lm32-vuart.c
userspace/tools/lm32-vuart.c
+2
-2
rtu_stat.c
userspace/tools/rtu_stat.c
+2
-2
spll_dbg_proxy.c
userspace/tools/spll_dbg_proxy.c
+1
-1
wr_management.c
userspace/tools/wr_management.c
+1
-1
wr_mon.c
userspace/tools/wr_mon.c
+1
-1
wr_phytool.c
userspace/tools/wr_phytool.c
+3
-3
wrs_pstats.c
userspace/tools/wrs_pstats.c
+2
-2
wrs_version.c
userspace/tools/wrs_version.c
+3
-3
wrs_vlans.c
userspace/tools/wrs_vlans.c
+1
-1
Makefile
userspace/wrsw_hal/Makefile
+1
-1
gps_resync.c
userspace/wrsw_hal/gps_resync/gps_resync.c
+1
-1
hal_config.c
userspace/wrsw_hal/hal_config.c
+1
-1
hal_exports.c
userspace/wrsw_hal/hal_exports.c
+2
-2
hal_main.c
userspace/wrsw_hal/hal_main.c
+3
-3
hal_ports.c
userspace/wrsw_hal/hal_ports.c
+4
-4
hal_timing.c
userspace/wrsw_hal/hal_timing.c
+1
-1
wrsw_hal.h
userspace/wrsw_hal/wrsw_hal.h
+1
-2
Makefile
userspace/wrsw_rtud/Makefile
+3
-2
rtu_drv.c
userspace/wrsw_rtud/rtu_drv.c
+2
-2
rtu_ext_drv.c
userspace/wrsw_rtud/rtu_ext_drv.c
+2
-2
rtu_fd.c
userspace/wrsw_rtud/rtu_fd.c
+1
-1
rtud.c
userspace/wrsw_rtud/rtud.c
+3
-3
rtud_exports.c
userspace/wrsw_rtud/rtud_exports.c
+2
-2
No files found.
userspace/include/fpga_io.h
View file @
76939652
...
...
@@ -28,7 +28,7 @@
#define FPGA_BASE_PSTATS 0x58000
/* HardWare Debugging Unit */
#define FPGA_BASE_HWDU 0x59000
#define FPGA_BASE_HWDU 0x59000
/* Endpoint */
#define FPGA_BASE_EP0 0x30000
...
...
userspace/libwr/Makefile
View file @
76939652
CC
=
$(CROSS_COMPILE)
gcc
AR
=
$(CROSS_COMPILE)
ar
CFLAGS
=
-Wall
-I
.
-O2
-DDEBUG
-ggdb
-I
../include
-I
../wrsw_hal
-I
../mini-rpc
CFLAGS
=
-Wall
-I
.
-O2
-DDEBUG
-ggdb
-I
./include
-I
../include
\
-I
../wrsw_hal
-I
../mini-rpc
OBJS
=
trace.o init.o fpga_io.o util.o pps_gen.o i2c.o shw_io.o i2c_bitbang.o
\
i2c_fpga_reg.o pio.o libshw_i2c.o i2c_sfp.o fan.o i2c_io.o hwiu.o
\
...
...
@@ -8,7 +9,7 @@ OBJS = trace.o init.o fpga_io.o util.o pps_gen.o i2c.o shw_io.o i2c_bitbang.o \
LIB
=
libwr.a
all
:
$(LIB)
all
:
$(LIB)
$(LIB)
:
$(OBJS)
$(AR)
rc
$@
$^
...
...
userspace/libwr/README
View file @
76939652
Switch V3 Hardware Library (libwr)
-------------------------------
Libwr is a collection of low-level userspace drivers for various
Libwr is a collection of low-level userspace drivers for various
peripherals in the switch, which do not need kernel modules. These are:
- Main FPGA (fpga_io.c) and CPU GPIO ports (pio.c), pin definitions (shw_io.c)
- PPS generator (pps_gen.c, adjustment of time)
...
...
userspace/libwr/fan.c
View file @
76939652
...
...
@@ -24,10 +24,10 @@
#include <sys/ioctl.h>
#include <fcntl.h>
#include <unistd.h>
#include <trace.h>
#include <
libwr/
trace.h>
#include <pio.h>
#include <fan.h>
#include <
libwr/
pio.h>
#include <
libwr/
fan.h>
#include <at91_softpwm.h>
...
...
@@ -35,9 +35,9 @@
#include "i2c_io.h"
#include "i2c_fpga_reg.h"
#include "fpga_io.h"
#include
"shw_io.h"
#include
<libwr/shw_io.h>
#include "spwm-regs.h"
#include
"util.h"
#include
<libwr/util.h>
#define FAN_TEMP_SENSOR_ADDR 0x4c
...
...
@@ -169,8 +169,8 @@ static uint32_t tmp100_read_reg(int dev_addr, uint8_t reg_addr, int n_bytes)
uint32_t
rv
=
0
,
i
;
data
[
0
]
=
reg_addr
;
i2c_write
(
&
fpga_sensors_i2c
,
dev_addr
,
1
,
data
);
i2c_read
(
&
fpga_sensors_i2c
,
dev_addr
,
n_bytes
,
data
);
i2c_write
(
&
fpga_sensors_i2c
,
dev_addr
,
1
,
data
);
i2c_read
(
&
fpga_sensors_i2c
,
dev_addr
,
n_bytes
,
data
);
for
(
i
=
0
;
i
<
n_bytes
;
i
++
)
{
...
...
@@ -189,7 +189,7 @@ static void tmp100_write_reg(int dev_addr, uint8_t reg_addr, uint8_t value)
data
[
0
]
=
reg_addr
;
data
[
1
]
=
value
;
i2c_write
(
&
fpga_sensors_i2c
,
dev_addr
,
2
,
data
);
i2c_write
(
&
fpga_sensors_i2c
,
dev_addr
,
2
,
data
);
}
...
...
userspace/libwr/fpga_io.c
View file @
76939652
...
...
@@ -9,7 +9,7 @@
#include <fcntl.h>
#include <poll.h>
#include <switch_hw.h>
#include <
libwr/
switch_hw.h>
#include <fpga_io.h>
...
...
userspace/libwr/hal_client.c
View file @
76939652
...
...
@@ -62,17 +62,17 @@ int halexp_get_timing_state(hexp_timing_state_t *tstate)
int
halexp_client_try_connect
(
int
retries
,
int
timeout
)
{
for
(;;)
{
hal_ch
=
minipc_client_create
(
WRSW_HAL_SERVER_ADDR
,
MINIPC_FLAG_VERBOSE
);
if
(
hal_ch
==
0
)
retries
--
;
else
else
return
0
;
if
(
!
retries
)
return
-
1
;
usleep
(
timeout
);
}
...
...
userspace/libwr/hwiu.c
View file @
76939652
...
...
@@ -3,7 +3,7 @@
#include <stddef.h>
#include <fpga_io.h>
#include <regs/hwiu-regs.h>
#include <hwiu.h>
#include <
libwr/
hwiu.h>
#define hwiu_write(reg, val) \
_fpga_writel(FPGA_BASE_HWIU + offsetof(struct HWIU_WB, reg), val)
...
...
@@ -46,7 +46,7 @@ int shw_hwiu_gwver(struct gw_info *info)
printf
(
"nwords: sw=%u, hw=%u, ver=%u, data=%x
\n
"
,
info
->
nwords
,
HWIU_INFO_WORDS
,
info
->
struct_ver
,
data
[
0
]);
return
-
1
;
}
//now read info words
for
(
i
=
0
;
i
<
info
->
nwords
;
++
i
)
{
if
(
hwiu_read_word
(
HWIU_INFO_WORDS_START
+
i
,
data
+
i
+
1
)
<
0
)
...
...
userspace/libwr/i2c.c
View file @
76939652
...
...
@@ -6,8 +6,8 @@
#include "i2c_bitbang.h"
#include "i2c_fpga_reg.h"
#include
"trace.h"
#include
"util.h"
#include
<libwr/trace.h>
#include
<libwr/util.h>
int
i2c_init_bus
(
struct
i2c_bus
*
bus
)
{
...
...
@@ -33,7 +33,7 @@ void i2c_free(struct i2c_bus* bus)
{
if
(
!
bus
)
return
;
if
(
bus
->
type_specific
)
shw_free
(
bus
->
type_specific
);
...
...
@@ -59,18 +59,18 @@ int32_t i2c_scan(struct i2c_bus* bus, uint8_t* data)
{
if
(
!
bus
)
return
I2C_NULL_PARAM
;
// const int devices = 128;
int
address
;
const
int
first_valid_address
=
0
;
const
int
last_valid_address
=
0x7f
;
memset
((
void
*
)
data
,
0
,
16
);
//16 bytes * 8 addresses per byte == 128 addresses
int
found
=
0
;
for
(
address
=
first_valid_address
;
address
<=
last_valid_address
;
address
++
)
{
int
res
=
bus
->
scan
(
bus
,
address
);
...
...
userspace/libwr/i2c_bitbang.c
View file @
76939652
...
...
@@ -4,11 +4,11 @@
#include <stdlib.h>
#include <string.h>
#include <util.h>
#include <
libwr/
util.h>
#include "i2c_bitbang.h"
#include
"trace.h"
#include
<libwr/trace.h>
static
int32_t
i2c_bitbang_transfer
(
struct
i2c_bus
*
bus
,
uint32_t
address
,
uint32_t
to_write
,
uint32_t
to_read
,
uint8_t
*
data
);
static
int32_t
i2c_bitbang_scan
(
struct
i2c_bus
*
bus
,
uint32_t
address
);
...
...
@@ -30,7 +30,7 @@ int i2c_bitbang_init_bus(struct i2c_bus *bus)
shw_pio_setdir
(
priv
->
sda
,
0
);
priv
->
udelay
=
50
;
priv
->
timeout
=
100
;
//assign functions
bus
->
transfer
=
i2c_bitbang_transfer
;
bus
->
scan
=
i2c_bitbang_scan
;
...
...
@@ -52,7 +52,7 @@ static void mi2c_start(struct i2c_bitbang* bus)
mi2c_pin_out
(
bus
->
scl
,
0
);
}
/* not used right now
/* not used right now
static void mi2c_restart(struct i2c_bitbang* bus)
{
mi2c_pin_out(bus->sda, 1);
...
...
@@ -74,7 +74,7 @@ static int mi2c_write_byte(struct i2c_bitbang* bus, uint8_t data)
{
int
ack
=
0
;
int
b
;
for
(
b
=
0
;
b
<
8
;
b
++
)
{
mi2c_pin_out
(
bus
->
sda
,
data
&
0x80
);
//set MSB to SDA
...
...
@@ -82,18 +82,18 @@ static int mi2c_write_byte(struct i2c_bitbang* bus, uint8_t data)
mi2c_pin_out
(
bus
->
scl
,
0
);
data
<<=
1
;
}
mi2c_pin_out
(
bus
->
sda
,
1
);
//go high
mi2c_pin_out
(
bus
->
scl
,
1
);
//toggle clock
shw_pio_setdir
(
bus
->
sda
,
PIO_IN
);
//let SDA float
shw_udelay
(
I2C_DELAY
);
ack
=
shw_pio_get
(
bus
->
sda
);
mi2c_pin_out
(
bus
->
scl
,
0
);
// shw_pio_setdir(bus->sda, PIO_OUT_1); //turn on output
shw_udelay
(
I2C_DELAY
);
return
(
ack
==
0
)
?
1
:
0
;
}
...
...
@@ -106,7 +106,7 @@ static uint8_t mi2c_get_byte(struct i2c_bitbang *bus, int ack)
mi2c_pin_out
(
bus
->
scl
,
0
);
shw_pio_setdir
(
bus
->
sda
,
PIO_IN
);
//let SDA float so we can read it
for
(
i
=
0
;
i
<
8
;
i
++
)
{
mi2c_pin_out
(
bus
->
scl
,
1
);
...
...
@@ -117,12 +117,12 @@ static uint8_t mi2c_get_byte(struct i2c_bitbang *bus, int ack)
}
//send ACK or NAK
mi2c_pin_out
(
bus
->
sda
,
ack
?
0
:
1
);
mi2c_pin_out
(
bus
->
sda
,
ack
?
0
:
1
);
shw_udelay
(
I2C_DELAY
);
mi2c_pin_out
(
bus
->
scl
,
1
);
//generate SCL pulse for slave to read ACK/NACK
mi2c_pin_out
(
bus
->
scl
,
0
);
return
result
;
}
...
...
@@ -157,25 +157,25 @@ static int32_t i2c_bitbang_scan(struct i2c_bus* bus, uint32_t address)
return
state
?
1
:
0
;
}
static
int
i2c_bitbang_transfer
(
i2c_bus_t
*
bus
,
uint32_t
address
,
uint32_t
to_write
,
uint32_t
to_read
,
uint8_t
*
data
)
{
if
(
!
bus
)
return
I2C_NULL_PARAM
;
if
(
bus
->
type
!=
I2C_TYPE_BITBANG
)
return
I2C_BUS_MISMATCH
;
//TRACE(TRACE_INFO,"%s (0x%x) @ 0x%x: w=%d/r=%d; cmd=%d d=%d (0b%s)",bus->name,bus,address,to_write,to_read,data[0],data[1],shw_2binary(data[1]));
struct
i2c_bitbang
*
ts
=
(
struct
i2c_bitbang
*
)
bus
->
type_specific
;
int
sent
=
0
;
int
rcvd
=
0
;
int
ack
=
0
;
uint32_t
i
;
if
(
to_write
>
0
)
{
mi2c_start
(
ts
);
...
...
@@ -184,7 +184,7 @@ static int i2c_bitbang_transfer(i2c_bus_t* bus, uint32_t address, uint32_t to_wr
{
mi2c_stop
(
ts
);
return
I2C_DEV_NOT_FOUND
;
//the device did not ack it's address
}
}
for
(
i
=
0
;
i
<
to_write
;
i
++
)
{
ack
=
mi2c_write_byte
(
ts
,
data
[
i
]);
//write data
...
...
@@ -197,7 +197,7 @@ static int i2c_bitbang_transfer(i2c_bus_t* bus, uint32_t address, uint32_t to_wr
}
mi2c_stop
(
ts
);
}
if
(
to_read
)
{
mi2c_start
(
ts
);
...
...
@@ -209,7 +209,7 @@ static int i2c_bitbang_transfer(i2c_bus_t* bus, uint32_t address, uint32_t to_wr
}
uint32_t
last_byte
=
to_read
-
1
;
for
(
i
=
0
;
i
<
to_read
;
i
++
)
{
data
[
i
]
=
mi2c_get_byte
(
ts
,
i
!=
last_byte
);
//read data, ack until the last byte
...
...
@@ -217,7 +217,7 @@ static int i2c_bitbang_transfer(i2c_bus_t* bus, uint32_t address, uint32_t to_wr
}
mi2c_stop
(
ts
);
}
return
sent
+
rcvd
;
}
userspace/libwr/i2c_bitbang.h
View file @
76939652
/*
i2c_bitbang.h
2012 CERN B.Bielawski
2012 CERN B.Bielawski
*/
#ifndef I2C_CPU_BB_H
#define I2C_CPU_BB_H
#include <pio.h>
#include <
libwr/
pio.h>
#include "i2c.h"
struct
i2c_bitbang
{
...
...
userspace/libwr/i2c_fpga_reg.c
View file @
76939652
...
...
@@ -4,7 +4,7 @@
#include <stdlib.h>
#include <string.h>
#include <util.h> //for shw_udelay();
#include <
libwr/
util.h> //for shw_udelay();
#include "i2c_fpga_reg.h"
...
...
@@ -143,7 +143,7 @@ static int32_t i2c_fpga_reg_transfer(struct i2c_bus* bus, uint32_t i2c_address,
return
I2C_NULL_PARAM
;
if
(
bus
->
type
!=
I2C_BUS_TYPE_FPGA_REG
)
return
I2C_BUS_MISMATCH
;
i2c_fpga_reg_t
*
ts
=
(
i2c_fpga_reg_t
*
)
bus
->
type_specific
;
uint32_t
fpga_address
=
ts
->
base_address
;
...
...
@@ -168,10 +168,10 @@ static int32_t i2c_fpga_reg_transfer(struct i2c_bus* bus, uint32_t i2c_address,
mi2c_sel_if
(
fpga_address
,
ts
->
if_num
,
0
);
return
I2C_NO_ACK_RCVD
;
}
sent
++
;
sent
++
;
}
}
if
(
to_read
)
{
ack
=
mi2c_start
(
fpga_address
,
i2c_address
,
I2C_READ
);
if
(
!
ack
)
{
//NAK
...
...
userspace/libwr/i2c_fpga_reg.h
View file @
76939652
/*
i2c_fpga_reg.h
2012 CERN B.Bielawski
2012 CERN B.Bielawski
*/
#ifndef I2C_FPGA_REG_H
...
...
userspace/libwr/i2c_io.c
View file @
76939652
...
...
@@ -25,8 +25,8 @@
#include <unistd.h>
#include <errno.h>
#include <pio.h>
#include <trace.h>
#include <
libwr/
pio.h>
#include <
libwr/
trace.h>
#include "i2c.h"
#include "i2c_io.h"
...
...
userspace/libwr/i2c_sfp.c
View file @
76939652
...
...
@@ -13,9 +13,9 @@
#include <lauxlib.h>
#include <lualib.h>
#include
"pio.h"
#include
"trace.h"
#include
"util.h"
#include
<libwr/pio.h>
#include
<libwr/trace.h>
#include
<libwr/util.h>
#include "i2c.h"
#include "i2c_sfp.h"
...
...
@@ -396,15 +396,15 @@ void shw_sfp_gpio_init(void)
struct
i2c_bus
*
bus
=
&
i2c_buses
[
WR_FPGA_BUS0
];
/* configure the pins as outputs */
i2c_transfer
(
bus
,
addr
,
2
,
0
,
conf_output
);
i2c_transfer
(
bus
,
addr
,
2
,
0
,
set_output
);
i2c_transfer
(
bus
,
addr
,
2
,
0
,
conf_output
);
i2c_transfer
(
bus
,
addr
,
2
,
0
,
set_output
);
bus
=
&
i2c_buses
[
WR_FPGA_BUS1
];
for
(
i
=
0
;
i
<
8
;
i
++
)
{
i2c_transfer
(
bus
,
addr
+
i
,
2
,
0
,
conf_output
);
i2c_transfer
(
bus
,
addr
+
i
,
2
,
0
,
set_output
);
i2c_transfer
(
bus
,
addr
+
i
,
2
,
0
,
conf_output
);
i2c_transfer
(
bus
,
addr
+
i
,
2
,
0
,
set_output
);
}
for
(
i
=
0
;
i
<
18
;
i
++
)
{
shw_sfp_set_led_synced
(
i
,
1
);
...
...
@@ -420,7 +420,7 @@ void shw_sfp_gpio_init(void)
shw_udelay
(
7000
);
}
}
void
shw_sfp_gpio_set
(
int
num
,
uint8_t
state
)
...
...
@@ -448,8 +448,8 @@ void shw_sfp_gpio_set(int num, uint8_t state)
/* Read current state of pins */
i2c_transfer
(
bus
,
addr
,
1
,
0
,
send
);
i2c_transfer
(
bus
,
addr
,
0
,
1
,
&
curr
);
i2c_transfer
(
bus
,
addr
,
1
,
0
,
send
);
i2c_transfer
(
bus
,
addr
,
0
,
1
,
&
curr
);
//TRACE(TRACE_INFO,"%d: 0x%x 0x%x s=%d, send=%d,%d c=%d, \n",num,bus,addr,state,send[0],send[1],&curr);
...
...
@@ -468,7 +468,7 @@ void shw_sfp_gpio_set(int num, uint8_t state)
curr
|=
SFP_TX_DISABLE_MASK
(
top
);
send
[
1
]
=
curr
;
i2c_transfer
(
bus
,
addr
,
2
,
0
,
send
);
i2c_transfer
(
bus
,
addr
,
2
,
0
,
send
);
//TRACE(TRACE_INFO,"%d: 0x%x 0x%x s=%d, send=%d,%d c=%d, \n",num,bus,addr,state,send[0],send[1],curr);
}
...
...
@@ -497,8 +497,8 @@ uint8_t shw_sfp_gpio_get(int num)
send
[
0
]
=
0x1
;
/* Read current state of pins */
i2c_transfer
(
bus
,
addr
,
1
,
0
,
send
);
i2c_transfer
(
bus
,
addr
,
0
,
1
,
&
curr
);
i2c_transfer
(
bus
,
addr
,
1
,
0
,
send
);
i2c_transfer
(
bus
,
addr
,
0
,
1
,
&
curr
);
if
(
curr
&
SFP_LED_LINK_MASK
(
top
))
out
|=
SFP_LED_LINK
;
...
...
userspace/libwr/i2c_sfp.h
View file @
76939652
...
...
@@ -3,7 +3,7 @@
#include "i2c.h"
#include <sfp_lib.h>
#include <
libwr/
sfp_lib.h>
//address from AT24C01 datasheet (1k, all address lines shorted to the ground)
#define I2C_SFP_ADDRESS 0x50
...
...
userspace/
include
/fan.h
→
userspace/
libwr/include/libwr
/fan.h
View file @
76939652
#ifndef __FAN_H
#define __FAN_H
#ifndef __
LIBWR_
FAN_H
#define __
LIBWR_
FAN_H
#define SHW_FAN_UPDATETO_DEFAULT 5
...
...
@@ -7,4 +7,4 @@
int
shw_init_fans
();
void
shw_update_fans
();
#endif
#endif
/* __LIBWR_FAN_H */
userspace/libwr/hal_client.h
→
userspace/libwr/
include/libwr/
hal_client.h
View file @
76939652
#ifndef __HAL_CLIENT_H
#define __HAL_CLIENT_H
#ifndef __
LIBWR_
HAL_CLIENT_H
#define __
LIBWR_
HAL_CLIENT_H
#include "hal_exports.h"
#include "
../wrsw_hal/
hal_exports.h"
int
halexp_client_init
();
int
halexp_client_try_connect
(
int
retries
,
int
timeout
);
#endif
#endif
/* __LIBWR_HAL_CLIENT_H */
userspace/
include
/hwiu.h
→
userspace/
libwr/include/libwr
/hwiu.h
View file @
76939652
#ifndef __HWIU_H__
#define __HWIU_H__
#ifndef __
LIBWR_
HWIU_H__
#define __
LIBWR_
HWIU_H__
#define HWIU_INFO_START 0
#define HWIU_INFO_WORDS_START 1
...
...
@@ -20,4 +20,4 @@ struct gw_info {
int
shw_hwiu_gwver
(
struct
gw_info
*
info
);
#endif
#endif
/* __LIBWR_HWIU_H__ */
userspace/
include
/pio.h
→
userspace/
libwr/include/libwr
/pio.h
View file @
76939652
#ifndef __CPU_IO_H
#define __CPU_IO_H
#ifndef __
LIBWR_
CPU_IO_H
#define __
LIBWR_
CPU_IO_H
#include <stdint.h>
...
...
@@ -96,4 +96,4 @@ static inline int shw_pio_setdir(const pio_pin_t *pin, int dir)
}
#endif /
/PIO_H
#endif
/
* __LIBWR_CPU_IO_H */
userspace/
include
/pps_gen.h
→
userspace/
libwr/include/libwr
/pps_gen.h
View file @
76939652
/* PPS Generator - a.k.a. WR Real-time clock driver */
#ifndef __PPS_GEN_H
#define __PPS_GEN_H
#ifndef __
LIBWR_
PPS_GEN_H
#define __
LIBWR_
PPS_GEN_H
#include <stdio.h>
#include <inttypes.h>
...
...
@@ -24,4 +24,4 @@ int shw_pps_gen_enable_output(int enable);
/* Reads the current time and stores at <seconds,nanoseconds>. */
void
shw_pps_gen_read_time
(
uint64_t
*
seconds
,
uint32_t
*
nanoseconds
);
#endif
#endif
/* __LIBWR_PPS_GEN_H */
userspace/libwr/ptpd_netif.h
→
userspace/libwr/
include/libwr/
ptpd_netif.h
View file @
76939652
// Network API for WR-PTPd
#ifndef __PTPD_NETIF_H
#define __PTPD_NETIF_H
#ifndef __
LIBWR_
PTPD_NETIF_H
#define __
LIBWR_
PTPD_NETIF_H
#include <stdio.h>
//#include <inttypes.h>
...
...
@@ -134,4 +134,4 @@ int ptpd_netif_adjust_counters(int64_t adjust_sec, int32_t adjust_nsec);
int
ptpd_netif_get_dmtd_phase
(
wr_socket_t
*
sock
,
int32_t
*
phase
);
void
ptpd_netif_linearize_rx_timestamp
(
wr_timestamp_t
*
ts
,
int32_t
dmtd_phase
,
int
cntr_ahead
,
int
transition_point
,
int
clock_period
);
#endif
#endif
/* __LIBWR_PTPD_NETIF_H */
userspace/
include
/sfp_lib.h
→
userspace/
libwr/include/libwr
/sfp_lib.h
View file @
76939652
#ifndef __SHW_SFPLIB_H
#define __SHW_SFPLIB_H
#ifndef __
LIBWR_
SHW_SFPLIB_H
#define __
LIBWR_
SHW_SFPLIB_H
#define SFP_LED_LINK (1 << 0)
#define SFP_LED_WRMODE (1 << 1)
...
...
@@ -100,4 +100,4 @@ struct shw_sfp_caldata *shw_sfp_get_cal_data(int num);
/* Read and verify the header all at once. returns -1 on failure */
int
shw_sfp_read_verify_header
(
int
num
,
struct
shw_sfp_header
*
head
);
#endif
// __SHW_SFPLIB_H
#endif
/* __LIBWR_SHW_SFPLIB_H */
userspace/
include
/shw_io.h
→
userspace/
libwr/include/libwr
/shw_io.h
View file @
76939652
...
...
@@ -20,12 +20,13 @@
* You should have received a copy of the GNU General Public License...
*/
#ifndef _SHW_IO_H_
#define _SHW_IO_H_
#ifndef _
LIBWR_
SHW_IO_H_
#define _
LIBWR_
SHW_IO_H_
#include <stdint.h>
#include "pio.h"
#include <libwr/shw_io.h>
#include <libwr/pio.h>
#define assert_init(proc) { int ret; if((ret = proc) < 0) return ret; }
...
...
@@ -116,5 +117,5 @@ const char* get_shw_info(const char cmd);
#endif
/* _SHW_IO_H_ */
#endif
/* _
LIBWR_
SHW_IO_H_ */
userspace/
include
/switch_hw.h
→
userspace/
libwr/include/libwr
/switch_hw.h
View file @
76939652
#ifndef __SWITCH_HW_H
#define __SWITCH_HW_H
#ifndef __
LIBWR_
SWITCH_HW_H
#define __
LIBWR_
SWITCH_HW_H
#include
"pio.h"
#include
"trace.h"
#include
"pps_gen.h"
#include
"fan.h"
#include
<libwr/pio.h>
#include
<libwr/trace.h>
#include
<libwr/pps_gen.h>
#include
<libwr/fan.h>
/* Some global, very important constants */
...
...
@@ -17,4 +17,4 @@
/* return 0 on success */
int
shw_init
(
void
);
int
shw_fpga_mmap_init
(
void
);
#endif
#endif
/* __LIBWR_SWITCH_HW_H */
userspace/
include
/trace.h
→
userspace/
libwr/include/libwr
/trace.h
View file @
76939652
#ifndef __TRACE_H
#define __TRACE_H
#ifndef __
LIBWR_
TRACE_H
#define __
LIBWR_
TRACE_H
#define TRACE_INFO 0x10
#define TRACE_INFO_L1 0x11
...
...
@@ -18,4 +18,4 @@ void trace_log_stderr();
void
trace_log_file
(
const
char
*
filename
);
void
trace_printf
(
const
char
*
fname
,
int
lineno
,
int
level
,
const
char
*
fmt
,
...);
#endif
#endif
/* __LIBWR_TRACE_H */
userspace/
include
/util.h
→
userspace/
libwr/include/libwr
/util.h
View file @
76939652
#ifndef __HW_UTIL_H
#define __HW_UTIL_H
#ifndef __
LIBWR_
HW_UTIL_H
#define __
LIBWR_
HW_UTIL_H
#include <stdio.h>
#include <inttypes.h>
...
...
@@ -12,4 +12,4 @@ void shw_free(void *ptr);
const
char
*
shw_2binary
(
uint8_t
x
);
uint64_t
shw_get_tics
();
#endif
#endif
/* __LIBWR_HW_UTIL_H */
userspace/libwr/init.c
View file @
76939652
...
...
@@ -3,9 +3,9 @@
#include <stdio.h>
#include <stdlib.h>
#include <switch_hw.h>
#include <
libwr/
switch_hw.h>
#include "i2c_sfp.h"
#include
"shw_io.h"
#include
<libwr/shw_io.h>
int
shw_init
()
...
...
userspace/libwr/libshw_i2c.c
View file @
76939652
...
...
@@ -22,7 +22,7 @@ int32_t wrswhw_pca9554_get_input(struct i2c_bus* bus, uint32_t address)
int
result
=
i2c_transfer
(
bus
,
address
,
1
,
0
,
&
r
);
if
(
result
<
0
)
return
result
;
//read one byte
result
=
i2c_transfer
(
bus
,
address
,
0
,
1
,
&
r
);
if
(
result
<
0
)
...
...
@@ -36,10 +36,10 @@ int wrswhw_pca9554_set_output_bits(struct i2c_bus* bus, uint32_t address, uint8_
int
result
=
wrswhw_pca9554_get_input
(
bus
,
address
);
if
(
result
<
0
)
return
result
;
result
|=
value
;
//or input bits
result
&=
0xFF
;
//leave only 8 LSBs
return
wrswhw_pca9554_set_output_reg
(
bus
,
address
,
result
);
}
...
...
@@ -48,10 +48,10 @@ int wrswhw_pca9554_clear_output_bits(struct i2c_bus* bus, uint32_t address, uint
int
result
=
wrswhw_pca9554_get_input
(
bus
,
address
);
if
(
result
<
0
)
return
result
;
result
&=
~
value
;
//remove bits we don't need
result
&=
0xFF
;
//leave only 8 LSBs
return
wrswhw_pca9554_set_output_reg
(
bus
,
address
,
result
);
}
userspace/libwr/pio.c
View file @
76939652
...
...
@@ -10,10 +10,10 @@
#include <at91/at91_pmc.h>
#include <at91/at91_pio.h>
#include
"pio.h"
#include
"trace.h"
#include
"shw_io.h"
#include
"util.h"
#include
<libwr/pio.h>
#include
<libwr/trace.h>
#include
<libwr/shw_io.h>
#include
<libwr/util.h>
volatile
uint8_t
*
_pio_base
[
4
][
NUM_PIO_BANKS
+
1
];
volatile
uint8_t
*
_sys_base
;
...
...
@@ -90,14 +90,14 @@ extern const pio_pin_t* _all_fpga_gpio_pins[];
void
shw_pio_toggle_pin
(
pio_pin_t
*
pin
,
uint32_t
udelay
)
{
while
(
1
)
{
{
shw_pio_set
(
pin
,
0
);
shw_udelay
(
udelay
);
shw_pio_set
(
pin
,
1
);
shw_udelay
(
udelay
);
}
}
void
shw_pio_configure
(
const
pio_pin_t
*
pin
)
{
uint32_t
mask
=
(
1
<<
pin
->
pin
);
...
...
@@ -148,8 +148,8 @@ void shw_pio_configure(const pio_pin_t *pin)
_writel
(
base
+
PIO_ODR
,
mask
);
// select input
}
break
;
case
PIO_FPGA
:
ddr
=
_readl
(
base
+
FPGA_PIO_REG_DDR
);
...
...
@@ -166,7 +166,7 @@ void shw_pio_configure(const pio_pin_t *pin)
_writel
(
base
+
FPGA_PIO_REG_DDR
,
ddr
);
break
;
}
//switch
}
...
...
userspace/libwr/pps_gen.c
View file @
76939652
...
...
@@ -13,8 +13,8 @@
#include <fpga_io.h>
#include <regs/ppsg-regs.h>
#include <switch_hw.h>
#include <trace.h>
#include <
libwr/
switch_hw.h>
#include <
libwr/
trace.h>
/* Default width (in 8ns units) of the pulses on the PPS output */
#define PPS_WIDTH 100000
...
...
@@ -47,7 +47,7 @@ int shw_pps_gen_init()
/* Adjusts the nanosecond (refclk cycle) counter by atomically adding (how_much) cycles. */
int
shw_pps_gen_adjust
(
int
counter
,
int64_t
how_much
)
{
TRACE
(
TRACE_INFO
,
"Adjust: counter = %s [%c%lld]"
,
TRACE
(
TRACE_INFO
,
"Adjust: counter = %s [%c%lld]"
,
counter
==
PPSG_ADJUST_SEC
?
"seconds"
:
"nanoseconds"
,
how_much
<
0
?
'-'
:
'+'
,
abs
(
how_much
));
if
(
counter
==
PPSG_ADJUST_NSEC
)
...
...
@@ -88,7 +88,7 @@ void shw_pps_gen_read_time(uint64_t *seconds, uint32_t *nanoseconds)
{
uint32_t
ns_cnt
;
uint64_t
sec1
,
sec2
;
do
{
sec1
=
(
uint64_t
)
ppsg_read
(
CNTR_UTCLO
)
|
(
uint64_t
)
ppsg_read
(
CNTR_UTCHI
)
<<
32
;
ns_cnt
=
ppsg_read
(
CNTR_NSEC
);
...
...
@@ -97,4 +97,4 @@ void shw_pps_gen_read_time(uint64_t *seconds, uint32_t *nanoseconds)
if
(
seconds
)
*
seconds
=
sec2
;
if
(
nanoseconds
)
*
nanoseconds
=
ns_cnt
;
}
\ No newline at end of file
}
userspace/libwr/ptpd_netif.c
View file @
76939652
...
...
@@ -23,8 +23,8 @@
#include <asm/socket.h>
#include
"ptpd_netif.h"
#include
"hal_client.h"
#include
<libwr/ptpd_netif.h>
#include
<libwr/hal_client.h>
#ifdef NETIF_VERBOSE
#define netif_dbg(...) printf(__VA_ARGS__)
...
...
userspace/libwr/shw_io.c
View file @
76939652
...
...
@@ -19,12 +19,12 @@
*
* You should have received a copy of the GNU General Public License...
*/
#include <pio.h>
#include <trace.h>
#include <
libwr/
pio.h>
#include <
libwr/
trace.h>
#include <string.h>
#include <stdio.h>
#include
"shw_io.h"
#include
<libwr/shw_io.h>
#include "i2c_io.h"
#include "libshw_i2c.h"
...
...
userspace/libwr/trace.c
View file @
76939652
...
...
@@ -3,7 +3,7 @@
#include <stdarg.h>
#include <string.h>
#include <trace.h>
#include <
libwr/
trace.h>
static
FILE
*
trace_file
=
NULL
;
static
int
trace_to_stderr
=
0
;
...
...
userspace/libwr/util.c
View file @
76939652
...
...
@@ -2,8 +2,8 @@
#include <stdlib.h>
#include <sys/time.h>
#include <trace.h>
#include <util.h>
#include <
libwr/
trace.h>
#include <
libwr/
util.h>
void
shw_udelay
(
uint32_t
microseconds
)
{
...
...
userspace/tools/Makefile
View file @
76939652
...
...
@@ -25,12 +25,12 @@ GIT_USR = $(shell git config --get-all user.name)
CFLAGS
=
-O2
-g
-Wall
\
-I
$(LINUX)
/include
\
-I
$(LINUX)
/arch/arm/mach-at91/include
\
-I
../libwr
\
-I
../wrsw_hal
\
-I
../wrsw_rtud
\
-I
../mini-rpc
\
-I
../libsdb
\
-I
../include
-I
../include
\
-I
../libwr/include
ifdef
WRS_TOOLS_DEBUG
CFLAGS
+=
-DDEBUG
...
...
userspace/tools/lm32-vuart.c
View file @
76939652
...
...
@@ -4,9 +4,9 @@
#include <unistd.h>
#include <stdlib.h>
#include
"shw_io.h"
#include
<libwr/shw_io.h>
#include "fpga_io.h"
#include
"switch_hw.h"
#include
<libwr/switch_hw.h>
#define VUART_BASE 0x10000
#define VUART_TDR 0x10
...
...
userspace/tools/rtu_stat.c
View file @
76939652
...
...
@@ -24,9 +24,9 @@
#include <stdlib.h>
#include <string.h>
#include <util.h>
#include <
libwr/
util.h>
#include <hal_client.h>
#include <
libwr/
hal_client.h>
#include <minipc.h>
#include <rtud_exports.h>
#include <mac.h>
...
...
userspace/tools/spll_dbg_proxy.c
View file @
76939652
...
...
@@ -25,7 +25,7 @@
#include <fpga_io.h>
#include <regs/softpll-regs.h>
#include
"switch_hw.h"
#include
<libwr/switch_hw.h>
/* TCP Port to listen on */
#define MY_PORT 12345
...
...
userspace/tools/wr_management.c
View file @
76939652
...
...
@@ -30,7 +30,7 @@
#define PTP_EXPORT_STRUCTURES
#include "ptpd_exports.h"
#include
"hal_client.h"
#include
<libwr/hal_client.h>
hexp_port_list_t
port_list
;
...
...
userspace/tools/wr_mon.c
View file @
76939652
...
...
@@ -9,7 +9,7 @@
#define PTP_EXPORT_STRUCTURES
#include "ptpd_exports.h"
#include
"hal_client.h"
#include
<libwr/hal_client.h>
#define SHOW_GUI 0
#define SHOW_STATS 1
...
...
userspace/tools/wr_phytool.c
View file @
76939652
...
...
@@ -26,11 +26,11 @@
#include <regs/endpoint-regs.h>
#undef PACKED
#include
"ptpd_netif.h"
#include
<libwr/ptpd_netif.h>
#include "rt_ipc.h"
#include
"hal_client.h"
#include
"switch_hw.h"
#include
<libwr/hal_client.h>
#include
<libwr/switch_hw.h>
#define WRS3_FPGA_BASE 0x10000000
#define WRS3_FPGA_SIZE 0x100000
...
...
userspace/tools/wrs_pstats.c
View file @
76939652
...
...
@@ -11,8 +11,8 @@
#include <fcntl.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <switch_hw.h>
#include <hal_client.h>
#include <
libwr/
switch_hw.h>
#include <
libwr/
hal_client.h>
static
void
parse_sysfs
(
int
init
);
...
...
userspace/tools/wrs_version.c
View file @
76939652
...
...
@@ -23,9 +23,9 @@
#include <stdio.h>
#include <string.h>
#include <shw_io.h>
#include <hwiu.h>
#include
"switch_hw.h"
#include <
libwr/
shw_io.h>
#include <
libwr/
hwiu.h>
#include
<libwr/switch_hw.h>
#include "libsdbfs.h"
#define SDBFS_NAME "/dev/mtd5ro"
...
...
userspace/tools/wrs_vlans.c
View file @
76939652
...
...
@@ -30,7 +30,7 @@
#include <rtud_exports.h>
#include "regs/endpoint-regs.h"
#include
"switch_hw.h"
#include
<libwr/switch_hw.h>
#include "fpga_io.h"
#include "wrs_vlans.h"
...
...
userspace/wrsw_hal/Makefile
View file @
76939652
...
...
@@ -12,7 +12,7 @@ WR_INCLUDE = $(WR_INSTALL_ROOT)/include
WR_LIB
=
$(WR_INSTALL_ROOT)
/lib
CFLAGS
=
-g
-Wall
-DRT_CLIENT
\
-I
../include
-I
../mini-rpc
-I
$(WR_INCLUDE)
-I
../include
-I
../
libwr/include
-I
../
mini-rpc
-I
$(WR_INCLUDE)
ifdef
WRS_HAL_DEBUG
CFLAGS
+=
-DDEBUG
...
...
userspace/wrsw_hal/gps_resync/gps_resync.c
View file @
76939652
...
...
@@ -8,7 +8,7 @@
#include "serial.h"
#include "nmea.h"
#include <switch_hw.h>
#include <
libwr/
switch_hw.h>
void
read_nmea_msg
(
char
*
msgbuf
,
int
len
)
{
...
...
userspace/wrsw_hal/hal_config.c
View file @
76939652
...
...
@@ -8,7 +8,7 @@
#include <lauxlib.h>
#include <lualib.h>
#include <trace.h>
#include <
libwr/
trace.h>
#define HAL_CONFIG_FILE "/wr/etc/wrsw_hal.conf"
...
...
userspace/wrsw_hal/hal_exports.c
View file @
76939652
...
...
@@ -3,8 +3,8 @@
#include <stdio.h>
#include <stdlib.h>
#include <trace.h>
#include <pps_gen.h>
/* for direct access to DMPLL and PPS generator */
#include <
libwr/
trace.h>
#include <
libwr/
pps_gen.h>
/* for direct access to DMPLL and PPS generator */
#include "wrsw_hal.h"
#include "rt_ipc.h"
...
...
userspace/wrsw_hal/hal_main.c
View file @
76939652
...
...
@@ -10,9 +10,9 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <trace.h>
#include <switch_hw.h>
#include <shw_io.h>
#include <
libwr/
trace.h>
#include <
libwr/
switch_hw.h>
#include <
libwr/
shw_io.h>
#include "wrsw_hal.h"
#include "rt_ipc.h"
...
...
userspace/wrsw_hal/hal_ports.c
View file @
76939652
...
...
@@ -16,10 +16,10 @@
#include <linux/if.h>
/* LOTs of hardware includes */
#include <switch_hw.h>
#include <trace.h>
#include <pio.h>
#include <sfp_lib.h>
#include <
libwr/
switch_hw.h>
#include <
libwr/
trace.h>
#include <
libwr/
pio.h>
#include <
libwr/
sfp_lib.h>
#include <fpga_io.h>
#include <regs/endpoint-regs.h>
...
...
userspace/wrsw_hal/hal_timing.c
View file @
76939652
...
...
@@ -6,7 +6,7 @@
#include <stdint.h>
#include <unistd.h>
#include <switch_hw.h>
#include <
libwr/
switch_hw.h>
#include "wrsw_hal.h"
#include "timeout.h"
...
...
userspace/wrsw_hal/wrsw_hal.h
View file @
76939652
...
...
@@ -2,8 +2,7 @@
#define __WRSW_HAL_H
#include <inttypes.h>
#include <sfp_lib.h>
#include <libwr/sfp_lib.h>
typedef
void
(
*
hal_cleanup_callback_t
)();
...
...
userspace/wrsw_rtud/Makefile
View file @
76939652
...
...
@@ -13,8 +13,9 @@ WR_INCLUDE = $(WR_INSTALL_ROOT)/include
WR_LIB
=
$(WR_INSTALL_ROOT)
/lib
CFLAGS
=
-O2
-Wall
-ggdb
\
-I
../libwr
-I
../wrsw_hal
\
-I
../mini-rpc
-I
../include
-I
$(WR_INCLUDE)
-I
$(LINUX)
/include
-I
../wrsw_hal
\
-I
../mini-rpc
-I
../include
-I
../libwr/include
\
-I
$(WR_INCLUDE)
-I
$(LINUX)
/include
# -I$(CROSS_COMPILE_ARM_PATH)/../include
ifdef
WRS_RTUD_DEBUG
...
...
userspace/wrsw_rtud/rtu_drv.c
View file @
76939652
...
...
@@ -42,8 +42,8 @@
#include <stdlib.h>
#include <sys/ioctl.h>
#include <switch_hw.h>
#include <hal_client.h>
#include <
libwr/
switch_hw.h>
#include <
libwr/
hal_client.h>
#include <fpga_io.h>
#include <regs/rtu-regs.h>
...
...
userspace/wrsw_rtud/rtu_ext_drv.c
View file @
76939652
...
...
@@ -30,8 +30,8 @@
#include <stdlib.h>
#include <sys/ioctl.h>
#include <switch_hw.h>
#include <hal_client.h>
#include <
libwr/
switch_hw.h>
#include <
libwr/
hal_client.h>
#include <fpga_io.h>
#include <regs/rtu-regs.h>
...
...
userspace/wrsw_rtud/rtu_fd.c
View file @
76939652
...
...
@@ -38,7 +38,7 @@
#include <fpga_io.h>
#include <regs/rtu-regs.h>
#include <trace.h>
#include <
libwr/
trace.h>
#include "rtu_fd.h"
#include "rtu_drv.h"
...
...
userspace/wrsw_rtud/rtud.c
View file @
76939652
...
...
@@ -38,9 +38,9 @@
#include <sys/ioctl.h>
#include <linux/if.h>
#include <trace.h>
#include <switch_hw.h>
#include <hal_client.h>
#include <
libwr/
trace.h>
#include <
libwr/
switch_hw.h>
#include <
libwr/
hal_client.h>
#include "rtu.h"
#include "mac.h"
...
...
userspace/wrsw_rtud/rtud_exports.c
View file @
76939652
...
...
@@ -31,7 +31,7 @@
#include <stdint.h>
#include <errno.h>
#include <trace.h>
#include <
libwr/
trace.h>
#include "minipc.h"
#include "rtu.h"
...
...
@@ -39,7 +39,7 @@
#include "rtud_exports.h"
#include "mac.h"
#include <hal_client.h>
#include <
libwr/
hal_client.h>
/* The channel */
static
struct
minipc_ch
*
rtud_ch
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment