mirror of
https://github.com/enjoy-digital/litex.git
synced 2025-01-04 09:52:26 -05:00
software/liblitesata: update to multi-sector read, write
The LiteSATA gateware now supports multi-sector transfers, and expects a sector count register to be populated by the software before a DMA transfer is initiated. This patch also fixes checks for `done` and `error` during writes by using the correct `mem2sector` read function (instead of `sector2mem`, which is for use during read operations). Signed-off-by: Gabriel Somlo <gsomlo@gmail.com>
This commit is contained in:
parent
a9d6a0c6c9
commit
7d1e12c870
1 changed files with 18 additions and 25 deletions
|
@ -100,20 +100,16 @@ int sata_init(int show) {
|
|||
|
||||
void sata_read(uint32_t sector, uint32_t count, uint8_t* buf)
|
||||
{
|
||||
uint32_t i;
|
||||
uint8_t done = 0;
|
||||
|
||||
/* Write sectors */
|
||||
for (i=0; i<count; i++) {
|
||||
uint8_t done = 0;
|
||||
while (done == 0) {
|
||||
sata_sector2mem_base_write((uint64_t)(uintptr_t) buf);
|
||||
sata_sector2mem_sector_write(sector + i);
|
||||
sata_sector2mem_start_write(1);
|
||||
while ((sata_sector2mem_done_read() & 0x1) == 0);
|
||||
done = ((sata_sector2mem_error_read() & 0x1) == 0);
|
||||
busy_wait_us(10);
|
||||
}
|
||||
buf += 512;
|
||||
while (done == 0) {
|
||||
sata_sector2mem_base_write((uint64_t)(uintptr_t) buf);
|
||||
sata_sector2mem_sector_write(sector);
|
||||
sata_sector2mem_nsectors_write(count);
|
||||
sata_sector2mem_start_write(1);
|
||||
while ((sata_sector2mem_done_read() & 0x1) == 0);
|
||||
done = ((sata_sector2mem_error_read() & 0x1) == 0);
|
||||
busy_wait_us(10);
|
||||
}
|
||||
|
||||
#ifndef CONFIG_CPU_HAS_DMA_BUS
|
||||
|
@ -129,20 +125,17 @@ void sata_read(uint32_t sector, uint32_t count, uint8_t* buf)
|
|||
|
||||
void sata_write(uint32_t sector, uint32_t count, uint8_t* buf)
|
||||
{
|
||||
uint32_t i;
|
||||
uint8_t done = 0;
|
||||
|
||||
/* Write sectors */
|
||||
for (i=0; i<count; i++) {
|
||||
uint8_t done = 0;
|
||||
while (done == 0) {
|
||||
sata_mem2sector_base_write((uint64_t)(uintptr_t) buf);
|
||||
sata_mem2sector_sector_write(sector + i);
|
||||
sata_mem2sector_start_write(1);
|
||||
while ((sata_sector2mem_done_read() & 0x1) == 0);
|
||||
done = ((sata_sector2mem_error_read() & 0x1) == 0);
|
||||
busy_wait_us(10);
|
||||
}
|
||||
buf += 512;
|
||||
while (done == 0) {
|
||||
sata_mem2sector_base_write((uint64_t)(uintptr_t) buf);
|
||||
sata_mem2sector_sector_write(sector);
|
||||
sata_mem2sector_nsectors_write(count);
|
||||
sata_mem2sector_start_write(1);
|
||||
while ((sata_mem2sector_done_read() & 0x1) == 0);
|
||||
done = ((sata_mem2sector_error_read() & 0x1) == 0);
|
||||
busy_wait_us(10);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue