Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
Software for White Rabbit PTP Core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
32
Issues
32
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
Software for White Rabbit PTP Core
Commits
b1ac9f9a
Commit
b1ac9f9a
authored
Jul 09, 2012
by
Wesley W. Terpstra
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added SDB support to the firmware: no more hard-coded addresses!
parent
9e1372b2
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
176 additions
and
16 deletions
+176
-16
dev.mk
dev/dev.mk
+2
-1
endpoint.c
dev/endpoint.c
+2
-1
ep_pfilter.c
dev/ep_pfilter.c
+1
-1
sdb.c
dev/sdb.c
+129
-0
syscon.c
dev/syscon.c
+4
-0
uart.c
dev/uart.c
+2
-1
memlayout.h
include/hw/memlayout.h
+12
-8
syscon.h
include/syscon.h
+1
-1
cmd_sdb.c
shell/cmd_sdb.c
+11
-0
shell.c
shell/shell.c
+1
-0
shell.h
shell/shell.h
+1
-0
shell.mk
shell/shell.mk
+1
-0
softpll_ng.c
softpll/softpll_ng.c
+5
-2
wrc_main.c
wrc_main.c
+4
-1
No files found.
dev/dev.mk
View file @
b1ac9f9a
...
...
@@ -7,4 +7,5 @@ OBJS_DEV = dev/eeprom.o \
dev/syscon.o \
dev/uart.o \
dev/sfp.o \
dev/persistent_mac.o
dev/persistent_mac.o \
dev/sdb.o
dev/endpoint.c
View file @
b1ac9f9a
...
...
@@ -27,7 +27,7 @@ LGPL 2.1
#define DMTD_AVG_SAMPLES 256
static
int
autoneg_enabled
;
static
volatile
struct
EP_WB
*
EP
=
(
volatile
struct
EP_WB
*
)
BASE_
EP
;
volatile
struct
EP_WB
*
EP
;
/* functions for accessing PCS (MDIO) registers */
uint16_t
pcs_read
(
int
location
)
...
...
@@ -72,6 +72,7 @@ void get_mac_addr(uint8_t dev_addr[])
/* Initializes the endpoint and sets its local MAC address */
void
ep_init
(
uint8_t
mac_addr
[])
{
EP
=
(
volatile
struct
EP_WB
*
)
BASE_EP
;
set_mac_addr
(
mac_addr
);
*
(
unsigned
int
*
)(
0x62000
)
=
0x2
;
// reset network stuff (cleanup required!)
...
...
dev/ep_pfilter.c
View file @
b1ac9f9a
...
...
@@ -81,7 +81,7 @@
#define pfilter_dbg
static
volatile
struct
EP_WB
*
EP
=
(
volatile
struct
EP_WB
*
)
BASE_
EP
;
extern
volatile
struct
EP_WB
*
EP
;
static
const
uint64_t
PF_MODE_LOGIC
=
(
1ULL
<<
34
);
static
const
uint64_t
PF_MODE_CMP
=
0ULL
;
...
...
dev/sdb.c
0 → 100644
View file @
b1ac9f9a
#include "hw/memlayout.h"
#define SDB_INTERCONNET 0x00
#define SDB_DEVICE 0x01
#define SDB_BRIDGE 0x02
#define SDB_EMPTY 0xFF
typedef
struct
pair64
{
uint32_t
high
;
uint32_t
low
;
}
pair64_t
;
struct
sdb_empty
{
int8_t
reserved
[
63
];
uint8_t
record_type
;
};
struct
sdb_product
{
pair64_t
vendor_id
;
uint32_t
device_id
;
uint32_t
version
;
uint32_t
date
;
int8_t
name
[
19
];
uint8_t
record_type
;
};
struct
sdb_component
{
pair64_t
addr_first
;
pair64_t
addr_last
;
struct
sdb_product
product
;
};
struct
sdb_device
{
uint16_t
abi_class
;
uint8_t
abi_ver_major
;
uint8_t
abi_ver_minor
;
uint32_t
bus_specific
;
struct
sdb_component
sdb_component
;
};
struct
sdb_bridge
{
pair64_t
sdb_child
;
struct
sdb_component
sdb_component
;
};
struct
sdb_interconnect
{
uint32_t
sdb_magic
;
uint16_t
sdb_records
;
uint8_t
sdb_version
;
uint8_t
sdb_bus_type
;
struct
sdb_component
sdb_component
;
};
typedef
union
sdb_record
{
struct
sdb_empty
empty
;
struct
sdb_device
device
;
struct
sdb_bridge
bridge
;
struct
sdb_interconnect
interconnect
;
}
sdb_record_t
;
static
unsigned
char
*
find_device_deep
(
unsigned
int
base
,
unsigned
int
sdb
,
unsigned
int
devid
)
{
sdb_record_t
*
record
=
(
sdb_record_t
*
)
sdb
;
int
records
=
record
->
interconnect
.
sdb_records
;
int
i
;
for
(
i
=
0
;
i
<
records
;
++
i
,
++
record
)
{
if
(
record
->
empty
.
record_type
==
SDB_BRIDGE
)
{
unsigned
char
*
out
=
find_device_deep
(
base
+
record
->
bridge
.
sdb_component
.
addr_first
.
low
,
record
->
bridge
.
sdb_child
.
low
,
devid
);
if
(
out
)
return
out
;
}
if
(
record
->
empty
.
record_type
==
SDB_DEVICE
&&
record
->
device
.
sdb_component
.
product
.
device_id
==
devid
)
{
break
;
}
}
if
(
i
==
records
)
return
0
;
return
(
unsigned
char
*
)(
base
+
record
->
device
.
sdb_component
.
addr_first
.
low
);
}
static
void
print_devices_deep
(
unsigned
int
base
,
unsigned
int
sdb
)
{
sdb_record_t
*
record
=
(
sdb_record_t
*
)
sdb
;
int
records
=
record
->
interconnect
.
sdb_records
;
int
i
;
char
buf
[
20
];
for
(
i
=
0
;
i
<
records
;
++
i
,
++
record
)
{
if
(
record
->
empty
.
record_type
==
SDB_BRIDGE
)
print_devices_deep
(
base
+
record
->
bridge
.
sdb_component
.
addr_first
.
low
,
record
->
bridge
.
sdb_child
.
low
);
if
(
record
->
empty
.
record_type
!=
SDB_DEVICE
)
continue
;
memcpy
(
buf
,
record
->
device
.
sdb_component
.
product
.
name
,
19
);
buf
[
19
]
=
0
;
mprintf
(
"%8x:%8x 0x%8x %s
\n
"
,
record
->
device
.
sdb_component
.
product
.
vendor_id
.
low
,
record
->
device
.
sdb_component
.
product
.
device_id
,
base
+
record
->
device
.
sdb_component
.
addr_first
.
low
,
buf
);
}
}
static
unsigned
char
*
find_device
(
unsigned
int
devid
)
{
find_device_deep
(
0
,
SDB_ADDRESS
,
devid
);
}
void
sdb_print_devices
(
void
)
{
mprintf
(
"SDB memory map:
\n
"
);
print_devices_deep
(
0
,
SDB_ADDRESS
);
mprintf
(
"---
\n
"
);
}
void
sdb_find_devices
(
void
)
{
BASE_MINIC
=
find_device
(
0xab28633a
);
BASE_EP
=
find_device
(
0x650c2d4f
);
BASE_SOFTPLL
=
find_device
(
0x65158dc0
);
BASE_PPS_GEN
=
find_device
(
0xde0d8ced
);
BASE_SYSCON
=
find_device
(
0xff07fc47
);
BASE_UART
=
find_device
(
0xe2d13d04
);
BASE_ONEWIRE
=
find_device
(
0x779c5443
);
BASE_ETHERBONE_CFG
=
(
unsigned
char
*
)
0x20700
;
/* !!! fixme -- needs HW change */
}
dev/syscon.c
View file @
b1ac9f9a
...
...
@@ -3,11 +3,15 @@
struct
s_i2c_if
i2c_if
[
2
]
=
{
{
SYSC_GPSR_FMC_SCL
,
SYSC_GPSR_FMC_SDA
},
{
SYSC_GPSR_SFP_SCL
,
SYSC_GPSR_SFP_SDA
}
};
volatile
struct
SYSCON_WB
*
syscon
;
/****************************
* TIMER
***************************/
void
timer_init
(
uint32_t
enable
)
{
syscon
=
(
volatile
struct
SYSCON_WB
*
)
BASE_SYSCON
;
if
(
enable
)
syscon
->
TCR
|=
SYSC_TCR_ENABLE
;
else
...
...
dev/uart.c
View file @
b1ac9f9a
...
...
@@ -9,10 +9,11 @@
( ((( (unsigned long long)baudrate * 8ULL) << (16 - 7)) + \
(CPU_CLOCK >> 8)) / (CPU_CLOCK >> 7) )
static
volatile
struct
UART_WB
*
uart
=
(
volatile
struct
UART_WB
*
)
BASE_UART
;
volatile
struct
UART_WB
*
uart
;
void
uart_init
()
{
uart
=
(
volatile
struct
UART_WB
*
)
BASE_UART
;
uart
->
BCR
=
CALC_BAUD
(
UART_BAUDRATE
);
}
...
...
include/hw/memlayout.h
View file @
b1ac9f9a
#ifndef __REGS_H
#define __REGS_H
#define BASE_MINIC 0x20000
#define BASE_EP 0x20100
#define BASE_SOFTPLL 0x20200
#define BASE_PPS_GEN 0x20300
#define BASE_SYSCON 0x20400
#define BASE_UART 0x20500
#define BASE_ONEWIRE 0x20600
#define BASE_ETHERBONE_CFG 0x20700
#define SDB_ADDRESS 0x30000
unsigned
char
*
BASE_MINIC
;
unsigned
char
*
BASE_EP
;
unsigned
char
*
BASE_SOFTPLL
;
unsigned
char
*
BASE_PPS_GEN
;
unsigned
char
*
BASE_SYSCON
;
unsigned
char
*
BASE_UART
;
unsigned
char
*
BASE_ONEWIRE
;
unsigned
char
*
BASE_ETHERBONE_CFG
;
#define FMC_EEPROM_ADR 0x50
void
sdb_find_devices
(
void
);
void
sdb_print_devices
(
void
);
#endif
include/syscon.h
View file @
b1ac9f9a
...
...
@@ -38,7 +38,7 @@ void timer_init(uint32_t enable);
uint32_t
timer_get_tics
();
void
timer_delay
(
uint32_t
how_long
);
static
volatile
struct
SYSCON_WB
*
syscon
=
(
volatile
struct
SYSCON_WB
*
)
BASE_SYSCON
;
extern
volatile
struct
SYSCON_WB
*
syscon
;
/****************************
* GPIO
...
...
shell/cmd_sdb.c
0 → 100644
View file @
b1ac9f9a
#include "shell.h"
#include "syscon.h"
#include "hw/memlayout.h"
extern
const
char
*
build_revision
,
*
build_date
;
int
cmd_sdb
(
const
char
*
args
[])
{
sdb_print_devices
();
return
0
;
}
\ No newline at end of file
shell/shell.c
View file @
b1ac9f9a
...
...
@@ -49,6 +49,7 @@ static const struct shell_cmd cmds_list[] = {
{
"ip"
,
cmd_ip
},
#endif
{
"mac"
,
cmd_mac
},
{
"sdb"
,
cmd_sdb
},
{
NULL
,
NULL
}
};
...
...
shell/shell.h
View file @
b1ac9f9a
...
...
@@ -15,6 +15,7 @@ int cmd_mode(const char *args[]);
int
cmd_measure_t24p
(
const
char
*
args
[]);
int
cmd_time
(
const
char
*
args
[]);
int
cmd_ip
(
const
char
*
args
[]);
int
cmd_sdb
(
const
char
*
args
[]);
int
cmd_mac
(
const
char
*
args
[]);
int
cmd_env
(
const
char
*
args
[]);
...
...
shell/shell.mk
View file @
b1ac9f9a
...
...
@@ -9,6 +9,7 @@ OBJS_SHELL = shell/shell.o \
shell/cmd_measure_t24p.o \
shell/cmd_time.o \
shell/cmd_gui.o \
shell/cmd_sdb.o \
shell/cmd_mac.o
ifneq ($(WITH_ETHERBONE), 0)
...
...
softpll/softpll_ng.c
View file @
b1ac9f9a
...
...
@@ -13,8 +13,8 @@
volatile
int
irq_count
=
0
;
static
volatile
struct
SPLL_WB
*
SPLL
=
(
volatile
struct
SPLL_WB
*
)
BASE_SOFTPLL
;
static
volatile
struct
PPSG_WB
*
PPSG
=
(
volatile
struct
PPSG_WB
*
)
BASE_PPS_GEN
;
static
volatile
struct
SPLL_WB
*
SPLL
;
static
volatile
struct
PPSG_WB
*
PPSG
;
#define TRACE(...) TRACE_DEV(__VA_ARGS__)
...
...
@@ -233,6 +233,9 @@ void spll_init(int mode, int slave_ref_channel, int align_pps)
char
mode_str
[
20
];
volatile
int
dummy
;
int
i
;
SPLL
=
(
volatile
struct
SPLL_WB
*
)
BASE_SOFTPLL
;
PPSG
=
(
volatile
struct
PPSG_WB
*
)
BASE_PPS_GEN
;
disable_irq
();
...
...
wrc_main.c
View file @
b1ac9f9a
...
...
@@ -34,9 +34,12 @@ void wrc_initialize()
int
ret
,
i
;
uint8_t
mac_addr
[
6
],
ds18_id
[
8
]
=
{
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
};
char
sfp_pn
[
17
];
sdb_find_devices
();
uart_init
();
mprintf
(
"WR Core: starting up...
\n
"
);
timer_init
(
1
);
owInit
();
...
...
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