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
31
Issues
31
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
aa9161b7
Commit
aa9161b7
authored
Nov 28, 2017
by
Grzegorz Daniluk
Committed by
Adam Wujek
Nov 29, 2017
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make checkpatch happy
parent
91c69299
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
165 additions
and
133 deletions
+165
-133
flash.c
dev/flash.c
+56
-51
sdb-storage.c
dev/sdb-storage.c
+68
-49
syscon.c
dev/syscon.c
+11
-8
storage.h
include/storage.h
+7
-7
syscon.h
include/syscon.h
+2
-2
cmd_sdb.c
shell/cmd_sdb.c
+13
-8
wrc_main.c
wrc_main.c
+8
-8
No files found.
dev/flash.c
View file @
aa9161b7
...
...
@@ -20,6 +20,7 @@
static
void
delay
(
void
)
{
int
i
;
for
(
i
=
0
;
i
<
(
int
)(
CPU_CLOCK
/
10000000
);
i
++
)
asm
volatile
(
"nop"
);
}
...
...
@@ -55,7 +56,7 @@ static uint8_t bbspi_transfer(int cspin, uint8_t val)
/*
* Init function (just set the SPI pins for idle)
*/
void
flash_init
()
void
flash_init
(
void
)
{
gpio_out
(
GPIO_SPI_NCS
,
1
);
gpio_out
(
GPIO_SPI_SCLK
,
0
);
...
...
@@ -69,17 +70,17 @@ int flash_write(uint32_t addr, uint8_t *buf, int count)
{
int
i
;
bbspi_transfer
(
1
,
0
);
bbspi_transfer
(
0
,
0x06
);
bbspi_transfer
(
1
,
0
);
bbspi_transfer
(
0
,
0x02
);
bbspi_transfer
(
0
,(
addr
&
0xFF0000
)
>>
16
);
bbspi_transfer
(
0
,(
addr
&
0xFF00
)
>>
8
);
bbspi_transfer
(
0
,(
addr
&
0xFF
));
for
(
i
=
0
;
i
<
count
;
i
++
)
{
bbspi_transfer
(
0
,
buf
[
i
]);
bbspi_transfer
(
1
,
0
);
bbspi_transfer
(
0
,
0x06
);
bbspi_transfer
(
1
,
0
);
bbspi_transfer
(
0
,
0x02
);
bbspi_transfer
(
0
,
(
addr
&
0xFF0000
)
>>
16
);
bbspi_transfer
(
0
,
(
addr
&
0xFF00
)
>>
8
);
bbspi_transfer
(
0
,
(
addr
&
0xFF
));
for
(
i
=
0
;
i
<
count
;
i
++
)
{
bbspi_transfer
(
0
,
buf
[
i
]);
}
bbspi_transfer
(
1
,
0
);
bbspi_transfer
(
1
,
0
);
/* make sure the write is complete */
while
(
flash_rsr
()
&
0x01
)
{
...
...
@@ -95,16 +96,17 @@ int flash_write(uint32_t addr, uint8_t *buf, int count)
int
flash_read
(
uint32_t
addr
,
uint8_t
*
buf
,
int
count
)
{
int
i
;
bbspi_transfer
(
1
,
0
);
bbspi_transfer
(
0
,
0x0b
);
bbspi_transfer
(
0
,(
addr
&
0xFF0000
)
>>
16
);
bbspi_transfer
(
0
,(
addr
&
0xFF00
)
>>
8
);
bbspi_transfer
(
0
,(
addr
&
0xFF
));
bbspi_transfer
(
0
,
0
);
for
(
i
=
0
;
i
<
count
;
i
++
)
{
bbspi_transfer
(
1
,
0
);
bbspi_transfer
(
0
,
0x0b
);
bbspi_transfer
(
0
,
(
addr
&
0xFF0000
)
>>
16
);
bbspi_transfer
(
0
,
(
addr
&
0xFF00
)
>>
8
);
bbspi_transfer
(
0
,
(
addr
&
0xFF
));
bbspi_transfer
(
0
,
0
);
for
(
i
=
0
;
i
<
count
;
i
++
)
{
buf
[
i
]
=
bbspi_transfer
(
0
,
0
);
}
bbspi_transfer
(
1
,
0
);
bbspi_transfer
(
1
,
0
);
return
count
;
}
...
...
@@ -115,15 +117,16 @@ int flash_erase(uint32_t addr, int count)
int
sectors
;
/*calc number of sectors to be removed*/
if
(
count
%
storage_cfg
.
blocksize
>
0
)
if
(
count
%
storage_cfg
.
blocksize
>
0
)
sectors
=
1
;
else
sectors
=
0
;
sectors
+=
(
count
/
storage_cfg
.
blocksize
);
for
(
i
=
0
;
i
<
sectors
;
++
i
)
{
for
(
i
=
0
;
i
<
sectors
;
++
i
)
{
flash_serase
(
addr
+
i
*
storage_cfg
.
blocksize
);
while
(
flash_rsr
()
&
0x01
);
while
(
flash_rsr
()
&
0x01
)
;
}
return
count
;
...
...
@@ -134,45 +137,46 @@ int flash_erase(uint32_t addr, int count)
*/
void
flash_serase
(
uint32_t
addr
)
{
bbspi_transfer
(
1
,
0
);
bbspi_transfer
(
0
,
0x06
);
bbspi_transfer
(
1
,
0
);
bbspi_transfer
(
0
,
0xD8
);
bbspi_transfer
(
0
,(
addr
&
0xFF0000
)
>>
16
);
bbspi_transfer
(
0
,(
addr
&
0xFF00
)
>>
8
);
bbspi_transfer
(
0
,(
addr
&
0xFF
));
bbspi_transfer
(
1
,
0
);
bbspi_transfer
(
1
,
0
);
bbspi_transfer
(
0
,
0x06
);
bbspi_transfer
(
1
,
0
);
bbspi_transfer
(
0
,
0xD8
);
bbspi_transfer
(
0
,
(
addr
&
0xFF0000
)
>>
16
);
bbspi_transfer
(
0
,
(
addr
&
0xFF00
)
>>
8
);
bbspi_transfer
(
0
,
(
addr
&
0xFF
));
bbspi_transfer
(
1
,
0
);
}
/*
* Bulk erase
*/
void
flash_berase
()
flash_berase
(
void
)
{
bbspi_transfer
(
1
,
0
);
bbspi_transfer
(
0
,
0x06
);
bbspi_transfer
(
1
,
0
);
bbspi_transfer
(
0
,
0xc7
);
bbspi_transfer
(
1
,
0
);
bbspi_transfer
(
1
,
0
);
bbspi_transfer
(
0
,
0x06
);
bbspi_transfer
(
1
,
0
);
bbspi_transfer
(
0
,
0xc7
);
bbspi_transfer
(
1
,
0
);
}
/*
* Read status register
*/
uint8_t
flash_rsr
()
uint8_t
flash_rsr
(
void
)
{
uint8_t
retval
;
bbspi_transfer
(
1
,
0
);
bbspi_transfer
(
0
,
0x05
);
retval
=
bbspi_transfer
(
0
,
0
);
bbspi_transfer
(
1
,
0
);
bbspi_transfer
(
1
,
0
);
bbspi_transfer
(
0
,
0x05
);
retval
=
bbspi_transfer
(
0
,
0
);
bbspi_transfer
(
1
,
0
);
return
retval
;
}
/*****************************************************************************/
/*
SDB */
/* SDB */
/*****************************************************************************/
/* The sdb filesystem itself */
...
...
@@ -203,7 +207,8 @@ static void flash_sdb_list(struct sdbfs *fs)
{
struct
sdb_device
*
d
;
int
new
=
1
;
while
(
(
d
=
sdbfs_scan
(
fs
,
new
))
!=
NULL
)
{
while
((
d
=
sdbfs_scan
(
fs
,
new
))
!=
NULL
)
{
d
->
sdb_component
.
product
.
record_type
=
'\0'
;
pp_printf
(
"file 0x%08x @ %4i, name %19s
\n
"
,
(
int
)(
d
->
sdb_component
.
product
.
device_id
),
...
...
@@ -216,19 +221,19 @@ static void flash_sdb_list(struct sdbfs *fs)
/*
* Check for SDB presence on flash
*/
int
flash_sdb_check
()
int
flash_sdb_check
(
void
)
{
uint32_t
magic
=
0
;
int
i
;
uint32_t
entry_point
[]
=
{
0x000000
,
// flash base
0x100
,
// second page in flash
0x200
,
// IPMI with MultiRecord
0x300
,
// IPMI with larger MultiRecord
0x170000
,
// after first FPGA bitstream
0x2e0000
// after MultiBoot bitstream
};
0x000000
,
/* flash base */
0x100
,
/* second page in flash */
0x200
,
/* IPMI with MultiRecord */
0x300
,
/* IPMI with larger MultiRecord */
0x170000
,
/* after first FPGA bitstream */
0x2e0000
/* after MultiBoot bitstream */
};
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
entry_point
);
i
++
)
{
flash_read
(
entry_point
[
i
],
(
uint8_t
*
)
&
magic
,
4
);
...
...
dev/sdb-storage.c
View file @
aa9161b7
...
...
@@ -173,6 +173,7 @@ static void storage_sdb_list(struct sdbfs *fs)
{
struct
sdb_device
*
d
;
int
new
=
1
;
while
((
d
=
sdbfs_scan
(
fs
,
new
))
!=
NULL
)
{
d
->
sdb_component
.
product
.
record_type
=
'\0'
;
pp_printf
(
"file 0x%08x @ %4i, name %s
\n
"
,
...
...
@@ -263,7 +264,7 @@ void storage_init(int chosen_i2cif, int chosen_i2c_addr)
i2c_params
.
addr
=
EEPROM_START_ADR
;
while
(
i2c_params
.
addr
<=
EEPROM_STOP_ADR
)
{
/* First, we check if I2C EEPROM is there */
if
(
!
mi2c_devprobe
(
i2c_params
.
ifnum
,
i2c_params
.
addr
))
{
if
(
!
mi2c_devprobe
(
i2c_params
.
ifnum
,
i2c_params
.
addr
))
{
i2c_params
.
addr
++
;
continue
;
}
...
...
@@ -745,13 +746,13 @@ out:
int
storage_read_hdl_cfg
(
void
)
{
get_storage_info
(
&
storage_cfg
.
memtype
,
&
storage_cfg
.
baseadr
,
&
storage_cfg
.
blocksize
);
get_storage_info
(
&
storage_cfg
.
memtype
,
&
storage_cfg
.
baseadr
,
&
storage_cfg
.
blocksize
);
if
(
storage_cfg
.
memtype
==
MEM_FLASH
&&
storage_cfg
.
blocksize
==
0
)
{
storage_cfg
.
valid
=
0
;
/* keep default blocksize for backwards compatibility */
storage_cfg
.
blocksize
=
FLASH_BLOCKSIZE
;
}
else
}
else
storage_cfg
.
valid
=
1
;
return
0
;
}
...
...
@@ -763,10 +764,11 @@ extern uint32_t _binary_tools_sdbfs_default_bin_end[];
static
inline
unsigned
long
SDB_ALIGN
(
unsigned
long
x
,
int
blocksize
)
{
return
(
x
+
(
blocksize
-
1
))
&
~
(
blocksize
-
1
);
return
(
x
+
(
blocksize
-
1
))
&
~
(
blocksize
-
1
);
}
int
storage_sdbfs_erase
(
int
mem_type
,
uint32_t
base_adr
,
uint32_t
blocksize
,
uint8_t
i2c_adr
)
int
storage_sdbfs_erase
(
int
mem_type
,
uint32_t
base_adr
,
uint32_t
blocksize
,
uint8_t
i2c_adr
)
{
if
(
mem_type
==
MEM_FLASH
&&
blocksize
==
0
)
return
-
EINVAL
;
...
...
@@ -774,27 +776,30 @@ int storage_sdbfs_erase(int mem_type, uint32_t base_adr, uint32_t blocksize, uin
if
(
mem_type
==
MEM_FLASH
)
{
pp_printf
(
"Erasing Flash(0x%x)...
\n
"
,
base_adr
);
sdb_flash_erase
(
NULL
,
base_adr
,
SDBFS_REC
*
blocksize
);
}
else
if
(
mem_type
==
MEM_EEPROM
)
{
}
else
if
(
mem_type
==
MEM_EEPROM
)
{
pp_printf
(
"Erasing EEPROM %d (0x%x)...
\n
"
,
i2c_adr
,
base_adr
);
i2c_params
.
ifnum
=
WRPC_FMC_I2C
;
i2c_params
.
addr
=
i2c_adr
;
wrc_sdb
.
drvdata
=
&
i2c_params
;
sdb_i2c_erase
(
&
wrc_sdb
,
base_adr
,
SDBFS_REC
*
sizeof
(
struct
sdb_device
));
}
else
if
(
mem_type
==
MEM_1W_EEPROM
)
{
sdb_i2c_erase
(
&
wrc_sdb
,
base_adr
,
SDBFS_REC
*
sizeof
(
struct
sdb_device
));
}
else
if
(
mem_type
==
MEM_1W_EEPROM
)
{
pp_printf
(
"Erasing 1-W EEPROM (0x%x)...
\n
"
,
base_adr
);
wrc_sdb
.
drvdata
=
&
wrpc_w1_bus
;
sdb_w1_erase
(
&
wrc_sdb
,
base_adr
,
SDBFS_REC
*
sizeof
(
struct
sdb_device
));
sdb_w1_erase
(
&
wrc_sdb
,
base_adr
,
SDBFS_REC
*
sizeof
(
struct
sdb_device
));
}
return
0
;
}
int
storage_gensdbfs
(
int
mem_type
,
uint32_t
base_adr
,
uint32_t
blocksize
,
uint8_t
i2c_adr
)
int
storage_gensdbfs
(
int
mem_type
,
uint32_t
base_adr
,
uint32_t
blocksize
,
uint8_t
i2c_adr
)
{
struct
sdb_device
*
sdbfs
=
(
struct
sdb_device
*
)
_binary_tools_sdbfs_default_bin_start
;
struct
sdb_interconnect
*
sdbfs_dir
=
(
struct
sdb_interconnect
*
)
_binary_tools_sdbfs_default_bin_start
;
//struct sdb_device sdbfs_buf[SDBFS_REC];
struct
sdb_device
*
sdbfs
=
(
struct
sdb_device
*
)
_binary_tools_sdbfs_default_bin_start
;
struct
sdb_interconnect
*
sdbfs_dir
=
(
struct
sdb_interconnect
*
)
_binary_tools_sdbfs_default_bin_start
;
/* struct sdb_device sdbfs_buf[SDBFS_REC]; */
int
i
;
char
buf
[
19
]
=
{
0
};
int
cur_adr
,
size
;
...
...
@@ -807,20 +812,23 @@ int storage_gensdbfs(int mem_type, uint32_t base_adr, uint32_t blocksize, uint8_
return
-
EINVAL
;
/* first file starts after the SDBFS description */
cur_adr
=
base_adr
+
SDB_ALIGN
(
SDBFS_REC
*
sizeof
(
struct
sdb_device
),
blocksize
);
cur_adr
=
base_adr
+
SDB_ALIGN
(
SDBFS_REC
*
sizeof
(
struct
sdb_device
),
blocksize
);
/* scan through files */
for
(
i
=
1
;
i
<
SDBFS_REC
;
++
i
)
{
/* relocate each file depending on base address and block size */
size
=
sdbfs
[
i
].
sdb_component
.
addr_last
-
sdbfs
[
i
].
sdb_component
.
addr_first
;
for
(
i
=
1
;
i
<
SDBFS_REC
;
++
i
)
{
/* relocate each file depending on base address and block size*/
size
=
sdbfs
[
i
].
sdb_component
.
addr_last
-
sdbfs
[
i
].
sdb_component
.
addr_first
;
sdbfs
[
i
].
sdb_component
.
addr_first
=
cur_adr
;
sdbfs
[
i
].
sdb_component
.
addr_last
=
cur_adr
+
size
;
cur_adr
=
SDB_ALIGN
(
cur_adr
+
(
size
+
1
),
blocksize
);
}
/* update the directory */
sdbfs_dir
->
sdb_component
.
addr_first
=
base_adr
;
sdbfs_dir
->
sdb_component
.
addr_last
=
sdbfs
[
SDBFS_REC
-
1
].
sdb_component
.
addr_last
;
sdbfs_dir
->
sdb_component
.
addr_last
=
sdbfs
[
SDBFS_REC
-
1
].
sdb_component
.
addr_last
;
for
(
i
=
0
;
i
<
SDBFS_REC
;
++
i
)
{
for
(
i
=
0
;
i
<
SDBFS_REC
;
++
i
)
{
strncpy
(
buf
,
(
char
*
)
sdbfs
[
i
].
sdb_component
.
product
.
name
,
18
);
pp_printf
(
"filename: %s; first: %x; last: %x
\n
"
,
buf
,
(
int
)
sdbfs
[
i
].
sdb_component
.
addr_first
,
...
...
@@ -833,48 +841,59 @@ int storage_gensdbfs(int mem_type, uint32_t base_adr, uint32_t blocksize, uint8_
/* each file is in a separate block, therefore erase SDBFS_REC
* number of blocks */
sdb_flash_erase
(
NULL
,
base_adr
,
SDBFS_REC
*
blocksize
);
for
(
i
=
0
;
i
<
SDBFS_REC
;
++
i
)
{
sdb_flash_write
(
NULL
,
base_adr
+
i
*
size
,
&
sdbfs
[
i
],
size
);
for
(
i
=
0
;
i
<
SDBFS_REC
;
++
i
)
{
sdb_flash_write
(
NULL
,
base_adr
+
i
*
size
,
&
sdbfs
[
i
],
size
);
}
//pp_printf("Verification...");
//sdb_flash_read(NULL, base_adr, sdbfs_buf, SDBFS_REC * sizeof(struct sdb_device));
//if(memcmp(sdbfs, sdbfs_buf, SDBFS_REC * sizeof(struct sdb_device)))
// pp_printf("Error.\n");
//else
// pp_printf("OK.\n");
}
else
if
(
mem_type
==
MEM_EEPROM
)
{
/*
pp_printf("Verification...");
sdb_flash_read(NULL, base_adr, sdbfs_buf, SDBFS_REC *
sizeof(struct sdb_device));
if(memcmp(sdbfs, sdbfs_buf, SDBFS_REC *
sizeof(struct sdb_device)))
pp_printf("Error.\n");
else
pp_printf("OK.\n");
*/
}
else
if
(
mem_type
==
MEM_EEPROM
)
{
/* First, check if EEPROM is really there */
if
(
!
mi2c_devprobe
(
WRPC_FMC_I2C
,
i2c_adr
))
{
if
(
!
mi2c_devprobe
(
WRPC_FMC_I2C
,
i2c_adr
))
{
pp_printf
(
"I2C EEPROM not found
\n
"
);
return
-
EINVAL
;
}
i2c_params
.
ifnum
=
WRPC_FMC_I2C
;
i2c_params
.
addr
=
i2c_adr
;
pp_printf
(
"Formatting SDBFS in I2C EEPROM %d (0x%x)...
\n
"
,
i2c_params
.
addr
,
base_adr
);
pp_printf
(
"Formatting SDBFS in I2C EEPROM %d (0x%x)...
\n
"
,
i2c_params
.
addr
,
base_adr
);
wrc_sdb
.
drvdata
=
&
i2c_params
;
sdb_i2c_erase
(
&
wrc_sdb
,
base_adr
,
SDBFS_REC
*
size
);
for
(
i
=
0
;
i
<
SDBFS_REC
;
++
i
)
{
sdb_i2c_write
(
&
wrc_sdb
,
base_adr
+
i
*
size
,
&
sdbfs
[
i
],
size
);
for
(
i
=
0
;
i
<
SDBFS_REC
;
++
i
)
{
sdb_i2c_write
(
&
wrc_sdb
,
base_adr
+
i
*
size
,
&
sdbfs
[
i
],
size
);
}
//pp_printf("Verification...");
//sdb_i2c_read(&wrc_sdb, base_adr, sdbfs_buf, SDBFS_REC * sizeof(struct sdb_device));
//if(memcmp(sdbfs, sdbfs_buf, SDBFS_REC * sizeof(struct sdb_device)))
// pp_printf("Error.\n");
//else
// pp_printf("OK.\n");
}
else
if
(
mem_type
==
MEM_1W_EEPROM
)
{
/*
pp_printf("Verification...");
sdb_i2c_read(&wrc_sdb, base_adr, sdbfs_buf, SDBFS_REC *
sizeof(struct sdb_device));
if(memcmp(sdbfs, sdbfs_buf, SDBFS_REC *
sizeof(struct sdb_device)))
pp_printf("Error.\n");
else
pp_printf("OK.\n");
*/
}
else
if
(
mem_type
==
MEM_1W_EEPROM
)
{
wrc_sdb
.
drvdata
=
&
wrpc_w1_bus
;
if
(
sdb_w1_read
(
&
wrc_sdb
,
0
,
&
val
,
sizeof
(
val
))
!=
sizeof
(
val
))
{
if
(
sdb_w1_read
(
&
wrc_sdb
,
0
,
&
val
,
sizeof
(
val
))
!=
sizeof
(
val
))
{
pp_printf
(
"1-Wire EEPROM not found
\n
"
);
return
-
EINVAL
;
}
pp_printf
(
"Formatting SDBFS in 1-W EEPROM (0x%x)...
\n
"
,
base_adr
);
pp_printf
(
"Formatting SDBFS in 1-W EEPROM (0x%x)...
\n
"
,
base_adr
);
sdb_w1_erase
(
&
wrc_sdb
,
base_adr
,
SDBFS_REC
*
size
);
for
(
i
=
0
;
i
<
SDBFS_REC
;
++
i
)
{
sdb_w1_write
(
&
wrc_sdb
,
base_adr
+
i
*
size
,
&
sdbfs
[
i
],
size
);
for
(
i
=
0
;
i
<
SDBFS_REC
;
++
i
)
{
sdb_w1_write
(
&
wrc_sdb
,
base_adr
+
i
*
size
,
&
sdbfs
[
i
],
size
);
}
}
...
...
dev/syscon.c
View file @
aa9161b7
...
...
@@ -61,7 +61,9 @@ void timer_delay(uint32_t tics)
{
uint32_t
t_end
;
// timer_init(1);
/*
timer_init(1);
*/
t_end
=
timer_get_tics
()
+
tics
;
while
(
time_before
(
timer_get_tics
(),
t_end
))
...
...
@@ -135,16 +137,16 @@ void net_rst(void)
int
wdiag_set_valid
(
int
enable
)
{
if
(
enable
)
if
(
enable
)
syscon
->
WDIAG_CTRL
|=
SYSC_WDIAG_CTRL_DATA_VALID
;
if
(
!
enable
)
if
(
!
enable
)
syscon
->
WDIAG_CTRL
&=
~
SYSC_WDIAG_CTRL_DATA_VALID
;
return
(
int
)(
syscon
->
WDIAG_CTRL
&
SYSC_WDIAG_CTRL_DATA_VALID
);
}
int
wdiag_get_valid
(
void
)
{
if
(
syscon
->
WDIAG_CTRL
&
SYSC_WDIAG_CTRL_DATA_VALID
)
if
(
syscon
->
WDIAG_CTRL
&
SYSC_WDIAG_CTRL_DATA_VALID
)
return
1
;
else
return
0
;
...
...
@@ -152,15 +154,15 @@ int wdiag_get_valid(void)
int
wdiag_get_snapshot
(
void
)
{
if
(
syscon
->
WDIAG_CTRL
&
SYSC_WDIAG_CTRL_DATA_SNAPSHOT
)
if
(
syscon
->
WDIAG_CTRL
&
SYSC_WDIAG_CTRL_DATA_SNAPSHOT
)
return
1
;
else
return
0
;
}
void
wdiags_write_servo_state
(
int
wr_mode
,
uint8_t
servostate
,
uint64_t
mu
,
uint64_t
dms
,
int32_t
asym
,
int32_t
cko
,
int32_t
setp
,
int32_t
ucnt
)
uint64_t
dms
,
int32_t
asym
,
int32_t
cko
,
int32_t
setp
,
int32_t
ucnt
)
{
syscon
->
WDIAG_SSTAT
=
wr_mode
?
SYSC_WDIAG_SSTAT_WR_MODE
:
0
;
syscon
->
WDIAG_SSTAT
|=
SYSC_WDIAG_SSTAT_SERVOSTATE_W
(
servostate
);
...
...
@@ -177,6 +179,7 @@ void wdiags_write_servo_state(int wr_mode, uint8_t servostate, uint64_t mu,
void
wdiags_write_port_state
(
int
link
,
int
locked
)
{
uint32_t
val
=
0
;
val
=
link
?
SYSC_WDIAG_PSTAT_LINK
:
0
;
val
|=
locked
?
SYSC_WDIAG_PSTAT_LOCKED
:
0
;
syscon
->
WDIAG_PSTAT
=
val
;
...
...
@@ -207,5 +210,5 @@ void wdiags_write_time(uint64_t sec, uint32_t nsec)
void
wdiags_write_temp
(
uint32_t
temp
)
{
syscon
->
WDIAG_TEMP
=
temp
;
syscon
->
WDIAG_TEMP
=
temp
;
}
include/storage.h
View file @
aa9161b7
...
...
@@ -61,18 +61,16 @@ void storage_init(int i2cif, int i2c_addr);
int
storage_sfpdb_erase
(
void
);
int
storage_match_sfp
(
struct
s_sfpinfo
*
sfp
);
int
storage_get_sfp
(
struct
s_sfpinfo
*
sfp
,
uint8_t
add
,
uint8_t
pos
);
int
storage_get_sfp
(
struct
s_sfpinfo
*
sfp
,
uint8_t
add
,
uint8_t
pos
);
int
storage_phtrans
(
uint32_t
*
val
,
uint8_t
write
);
int
storage_phtrans
(
uint32_t
*
val
,
uint8_t
write
);
int
storage_init_erase
(
void
);
int
storage_init_add
(
const
char
*
args
[]);
int
storage_init_show
(
void
);
int
storage_init_readcmd
(
uint8_t
*
buf
,
uint8_t
bufsize
,
uint8_t
next
);
struct
storage_config
{
struct
storage_config
{
int
memtype
;
int
valid
;
uint32_t
blocksize
;
...
...
@@ -89,8 +87,10 @@ extern struct storage_config storage_cfg;
int
storage_read_hdl_cfg
(
void
);
#ifdef CONFIG_GENSDBFS
int
storage_sdbfs_erase
(
int
mem_type
,
uint32_t
base_adr
,
uint32_t
blocksize
,
uint8_t
i2c_adr
);
int
storage_gensdbfs
(
int
mem_type
,
uint32_t
base_adr
,
uint32_t
blocksize
,
uint8_t
i2c_adr
);
int
storage_sdbfs_erase
(
int
mem_type
,
uint32_t
base_adr
,
uint32_t
blocksize
,
uint8_t
i2c_adr
);
int
storage_gensdbfs
(
int
mem_type
,
uint32_t
base_adr
,
uint32_t
blocksize
,
uint8_t
i2c_adr
);
#endif
#endif
include/syscon.h
View file @
aa9161b7
...
...
@@ -142,8 +142,8 @@ int wdiag_set_valid(int enable);
int
wdiag_get_valid
(
void
);
int
wdiag_get_snapshot
(
void
);
void
wdiags_write_servo_state
(
int
wr_mode
,
uint8_t
servostate
,
uint64_t
mu
,
uint64_t
dms
,
int32_t
asym
,
int32_t
cko
,
int32_t
setp
,
int32_t
ucnt
);
uint64_t
dms
,
int32_t
asym
,
int32_t
cko
,
int32_t
setp
,
int32_t
ucnt
);
void
wdiags_write_port_state
(
int
link
,
int
locked
);
void
wdiags_write_ptp_state
(
uint8_t
ptpstate
);
void
wdiags_write_aux_state
(
uint32_t
aux_states
);
...
...
shell/cmd_sdb.c
View file @
aa9161b7
...
...
@@ -12,7 +12,8 @@
#include "storage.h"
/*
* args[1] - where to write sdbfs image (0 - Flash, 1 - I2C EEPROM, 2 - 1Wire EEPROM)
* args[1] - where to write sdbfs image (0 - Flash, 1 - I2C EEPROM,
* 2 - 1Wire EEPROM)
* args[2] - base address for sdbfs image in Flash/EEPROM
* args[3] - i2c address of EEPROM or blocksize of Flash
*/
...
...
@@ -21,7 +22,7 @@ static int cmd_sdb(const char *args[])
{
#ifdef CONFIG_GENSDBFS
uint8_t
i2c_adr
=
FMC_EEPROM_ADR
;
int
blocksize
=
1
;
int
blocksize
=
1
;
#endif
if
(
!
args
[
0
])
{
...
...
@@ -42,24 +43,28 @@ static int cmd_sdb(const char *args[])
if
(
!
strcasecmp
(
args
[
0
],
"fs"
)
&&
args
[
2
])
{
/* if all the parameters were specified from the cmd line, we
* use these */
storage_gensdbfs
(
atoi
(
args
[
1
]),
atoi
(
args
[
2
]),
blocksize
,
i2c_adr
);
storage_gensdbfs
(
atoi
(
args
[
1
]),
atoi
(
args
[
2
]),
blocksize
,
i2c_adr
);
return
0
;
}
if
(
!
strcasecmp
(
args
[
0
],
"fs"
)
&&
storage_cfg
.
valid
&&
atoi
(
args
[
1
])
==
MEM_FLASH
)
{
atoi
(
args
[
1
])
==
MEM_FLASH
)
{
/* if available, we can also use Flash parameters specified with
* HDL generics */
storage_gensdbfs
(
MEM_FLASH
,
storage_cfg
.
baseadr
,
storage_cfg
.
blocksize
,
0
);
storage_gensdbfs
(
MEM_FLASH
,
storage_cfg
.
baseadr
,
storage_cfg
.
blocksize
,
0
);
return
0
;
}
/* Erasing SDBFS image */
if
(
!
strcasecmp
(
args
[
0
],
"fse"
)
&&
args
[
2
])
{
storage_sdbfs_erase
(
atoi
(
args
[
1
]),
atoi
(
args
[
2
]),
blocksize
,
i2c_adr
);
storage_sdbfs_erase
(
atoi
(
args
[
1
]),
atoi
(
args
[
2
]),
blocksize
,
i2c_adr
);
return
0
;
}
if
(
!
strcasecmp
(
args
[
0
],
"fse"
)
&&
storage_cfg
.
valid
&&
atoi
(
args
[
1
])
==
MEM_FLASH
)
{
storage_sdbfs_erase
(
MEM_FLASH
,
storage_cfg
.
baseadr
,
storage_cfg
.
blocksize
,
0
);
atoi
(
args
[
1
])
==
MEM_FLASH
)
{
storage_sdbfs_erase
(
MEM_FLASH
,
storage_cfg
.
baseadr
,
storage_cfg
.
blocksize
,
0
);
return
0
;
}
#endif
...
...
wrc_main.c
View file @
aa9161b7
...
...
@@ -70,12 +70,12 @@ static void wrc_initialize(void)
if
(
get_persistent_mac
(
ONEWIRE_PORT
,
mac_addr
)
==
-
1
)
{
pp_printf
(
"Unable to determine MAC address
\n
"
);
mac_addr
[
0
]
=
0x22
;
/
/
mac_addr
[
1
]
=
0x33
;
//
mac_addr
[
2
]
=
0x44
;
//
fallback MAC if get_persistent_mac fails
mac_addr
[
3
]
=
0x55
;
//
mac_addr
[
4
]
=
0x66
;
//
mac_addr
[
5
]
=
0x77
;
/
/
mac_addr
[
0
]
=
0x22
;
/
*
mac_addr[1] = 0x33;
*
mac_addr[2] = 0x44;
*
fallback MAC if get_persistent_mac fails
mac_addr[3] = 0x55;
*
mac_addr[4] = 0x66;
*
mac_addr[5] = 0x77;
*
/
}
pp_printf
(
"Local MAC address: %02x:%02x:%02x:%02x:%02x:%02x
\n
"
,
...
...
@@ -92,7 +92,7 @@ static void wrc_initialize(void)
minic_init
();
shw_pps_gen_init
();
wrc_ptp_init
();
/
/try reading t24 phase transition from EEPROM
/
* try reading t24 phase transition from EEPROM */
calib_t24p
(
WRC_MODE_MASTER
,
&
cal_phase_transition
);
spll_very_init
();
usleep_init
();
...
...
@@ -228,7 +228,7 @@ static void account_task(struct wrc_task *t, int done_sth)
delta
+=
1000
*
1000
*
1000
;
t
->
nanos
+=
delta
;
if
(
t
->
nanos
>
1000
*
1000
*
1000
)
{
if
(
t
->
nanos
>
1000
*
1000
*
1000
)
{
t
->
nanos
-=
1000
*
1000
*
1000
;
t
->
seconds
++
;
}
...
...
Adam Wujek
💬
@awujek
mentioned in commit
49adc9d0
·
Mar 19, 2019
mentioned in commit
49adc9d0
mentioned in commit 49adc9d00e9373bab55f6f02c3db16213dcf44e4
Toggle commit list
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