Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
W
wrpc-sw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
hdl-core-lib
wr-cores
wrpc-sw
Commits
b65aa1dd
Commit
b65aa1dd
authored
Sep 17, 2018
by
Maciej Lipinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[vxs support] FRAM working as flash
parent
acd1e17c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
61 additions
and
25 deletions
+61
-25
flash.c
dev/flash.c
+28
-24
sdb-storage.c
dev/sdb-storage.c
+1
-0
cmd_sdb.c
shell/cmd_sdb.c
+32
-1
No files found.
dev/flash.c
View file @
b65aa1dd
...
...
@@ -70,11 +70,11 @@ 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
(
1
,
0
);
// idle (possibly not needed)
bbspi_transfer
(
0
,
0x06
);
// WREN (set write enable latch)
bbspi_transfer
(
1
,
0
);
// idle (possibly not needed)
bbspi_transfer
(
0
,
0x02
);
// optcode for writing
// bbspi_transfer(0, (addr & 0xFF0000) >> 16);// VXS FRAM has only 16 bits
bbspi_transfer
(
0
,
(
addr
&
0xFF00
)
>>
8
);
bbspi_transfer
(
0
,
(
addr
&
0xFF
));
for
(
i
=
0
;
i
<
count
;
i
++
)
{
...
...
@@ -83,7 +83,7 @@ int flash_write(uint32_t addr, uint8_t *buf, int count)
bbspi_transfer
(
1
,
0
);
/* make sure the write is complete */
while
(
flash_rsr
()
&
0x01
)
{
while
(
flash_rsr
()
&
0x01
)
{
// not needed in VXS, but no harm
/* do nothing */
}
...
...
@@ -98,11 +98,12 @@ 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, 0x0b);
bbspi_transfer
(
0
,
0x03
);
// optcode for VXS is 0x02
// bbspi_transfer(0, (addr & 0xFF0000) >> 16);// VXS FRAM has only 16 bits
bbspi_transfer
(
0
,
(
addr
&
0xFF00
)
>>
8
);
bbspi_transfer
(
0
,
(
addr
&
0xFF
));
bbspi_transfer
(
0
,
0
);
// bbspi_transfer(0, 0); // not in VXS FRAM
for
(
i
=
0
;
i
<
count
;
i
++
)
{
buf
[
i
]
=
bbspi_transfer
(
0
,
0
);
}
...
...
@@ -115,19 +116,22 @@ int flash_erase(uint32_t addr, int count)
{
int
i
;
int
sectors
;
/*calc number of sectors to be removed*/
if
(
count
%
storage_cfg
.
blocksize
>
0
)
sectors
=
1
;
else
sectors
=
0
;
sectors
+=
(
count
/
storage_cfg
.
blocksize
);
for
(
i
=
0
;
i
<
sectors
;
++
i
)
{
flash_serase
(
addr
+
i
*
storage_cfg
.
blocksize
);
while
(
flash_rsr
()
&
0x01
)
;
}
uint8_t
buf
[
1
]
=
{
0xff
};
for
(
i
=
0
;
i
<
count
;
i
++
)
flash_write
(
addr
+
i
,
buf
,
1
);
// /*calc number of sectors to be removed*/
// if (count % storage_cfg.blocksize > 0)
// sectors = 1;
// else
// sectors = 0;
// sectors += (count / storage_cfg.blocksize);
//
// for (i = 0; i < sectors; ++i) {
// flash_serase(addr + i*storage_cfg.blocksize);
// while (flash_rsr() & 0x01)
// ;
// }
return
count
;
}
...
...
@@ -231,8 +235,8 @@ int flash_sdb_check(void)
0x100
,
/* second page in flash */
0x200
,
/* IPMI with MultiRecord */
0x300
,
/* IPMI with larger MultiRecord */
0x1700
00
,
/* after first FPGA bitstream */
0x2e00
00
/* after MultiBoot bitstream */
0x1700
,
/* after first FPGA bitstream */
0x2e00
/* after MultiBoot bitstream */
};
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
entry_point
);
i
++
)
{
...
...
dev/sdb-storage.c
View file @
b65aa1dd
...
...
@@ -208,6 +208,7 @@ void storage_init(int chosen_i2cif, int chosen_i2c_addr)
0x100
,
/* second page in flash */
0x200
,
/* IPMI with MultiRecord */
0x300
,
/* IPMI with larger MultiRecord */
0x6000
,
/* for VXS */
0x170000
,
/* after first FPGA bitstream */
0x2e0000
,
/* after MultiBoot bitstream */
0x600000
};
/* after SVEC AFPGA bitstream */
...
...
shell/cmd_sdb.c
View file @
b65aa1dd
...
...
@@ -10,6 +10,7 @@
#include "syscon.h"
#include "hw/memlayout.h"
#include "storage.h"
#include <flash.h>
/*
* args[1] - where to write sdbfs image (0 - Flash, 1 - I2C EEPROM,
...
...
@@ -22,6 +23,10 @@ static int cmd_sdb(const char *args[])
{
uint8_t
i2c_adr
=
FMC_EEPROM_ADR
;
int
blocksize
=
1
;
uint8_t
buf
[
1
]
=
{
0
};
uint32_t
addr
=
0
;
int
count
=
0
;
int
i
=
0
;
if
(
!
args
[
0
])
{
sdb_print_devices
();
...
...
@@ -64,7 +69,33 @@ static int cmd_sdb(const char *args[])
storage_cfg
.
blocksize
,
0
);
return
0
;
}
if
(
!
strcasecmp
(
args
[
0
],
"wr"
)
&&
atoi
(
args
[
1
])
==
MEM_FLASH
)
{
addr
=
atoi
(
args
[
2
]);
buf
[
0
]
=
atoi
(
args
[
3
]);
flash_write
(
addr
,
buf
,
1
);
pp_printf
(
"written 0x%x at addr = 0x%x
\n
"
,
buf
[
0
],
addr
);
flash_read
(
addr
,
buf
,
1
);
pp_printf
(
"read 0x%x from addr = 0x%x
\n
"
,
buf
[
0
],
addr
);
return
0
;
}
if
(
!
strcasecmp
(
args
[
0
],
"fls"
)
&&
atoi
(
args
[
1
])
==
MEM_FLASH
)
{
buf
[
0
]
=
flash_rsr
();
pp_printf
(
"value of status reg 0x%x
\n
"
,
buf
[
0
]);
return
0
;
}
if
(
!
strcasecmp
(
args
[
0
],
"rd"
)
&&
atoi
(
args
[
1
])
==
MEM_FLASH
)
{
addr
=
atoi
(
args
[
2
]);
count
=
atoi
(
args
[
3
]);
for
(
i
=
0
;
i
<
count
;
i
++
)
{
flash_read
(
addr
+
i
,
buf
,
1
);
pp_printf
(
"0x%x: 0x%x
\n
"
,
addr
+
i
,
buf
[
0
]);
}
return
0
;
}
if
(
!
strcasecmp
(
args
[
0
],
"erase"
)
&&
atoi
(
args
[
1
])
==
MEM_FLASH
)
{
flash_erase
(
0
,
0x7FFF
);
return
0
;
}
return
-
EINVAL
;
}
...
...
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