Skip to content

Commit

Permalink
altera: updated max10_mem_t with check_addr0, done_bit_addr & pgm_suc…
Browse files Browse the repository at this point in the history
…cess_addr (differs between MAX10 models). Updated both max10_dsm_program_success and max10_flow_program_donebit to uses these addresses
  • Loading branch information
trabucayre committed Jan 26, 2025
1 parent 1388f7b commit a17cea2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
20 changes: 13 additions & 7 deletions src/altera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,19 +303,25 @@ uint32_t Altera::idCode()
#define MAX10_BYPASS {0xFF, 0x03}

typedef struct {
uint32_t check_addr0; // something to check before sequence
uint32_t dsm_addr;
uint32_t dsm_len; // 32bits
uint32_t ufm_addr; // UFM1 addr
uint32_t ufm_len[2];
uint32_t cfm_addr; // CFM2 addr
uint32_t cfm_len[3];
uint32_t done_bit_addr;
uint32_t pgm_success_addr;
} max10_mem_t;

static const std::map<uint32_t, max10_mem_t> max10_memory_map = {
{0x031820dd, {
0x80005, // check_addr0
0x0000, 512, // DSM
0x0200, {4096, 4096}, // UFM
0x2200, {35840, 14848, 20992}} // CFM
0x2200, {35840, 14848, 20992}, // CFM
0x0009, // done bit
0x000b} // program success addr
},
};

Expand Down Expand Up @@ -413,9 +419,9 @@ void Altera::max10_program()
max10_dsm_program(dsm_data, dsm_len);
max10_dsm_verify();

max10_flow_program_donebit();
max10_flow_program_donebit(mem.done_bit_addr);
max10_dsm_verify();
max10_dsm_program_success();
max10_dsm_program_success(mem.pgm_success_addr);
max10_dsm_verify();

/* disable ISC flow */
Expand Down Expand Up @@ -628,7 +634,7 @@ void Altera::max10_addr_shift(uint32_t addr)
_jtag->shiftDR(addr_arr, NULL, 23, Jtag::RUN_TEST_IDLE);
}

void Altera::max10_dsm_program_success()
void Altera::max10_dsm_program_success(const uint32_t pgm_success_addr)
{
const uint32_t prog_len = 5120 / _clk_period; // ??
const uint32_t prog2_len = 320000 / _clk_period; // ??
Expand All @@ -638,7 +644,7 @@ void Altera::max10_dsm_program_success()
uint8_t magic[4];
word_to_array(0x6C48A50F, magic); // FIXME: uses define instead

max10_addr_shift(0x00000b);
max10_addr_shift(pgm_success_addr);

/* Send 'Magic' code */
_jtag->shiftIR((unsigned char *)cmd, NULL, IRLENGTH, Jtag::PAUSE_IR);
Expand All @@ -648,7 +654,7 @@ void Altera::max10_dsm_program_success()
_jtag->toggleClk(prog2_len); // must wait 305.0e-6
}

void Altera::max10_flow_program_donebit()
void Altera::max10_flow_program_donebit(const uint32_t done_bit_addr)
{
const uint32_t addr_shift_delay = 5120 / _clk_period; // ??
const uint32_t icb_program_delay = 320000 / _clk_period; // ??
Expand All @@ -659,7 +665,7 @@ void Altera::max10_flow_program_donebit()
word_to_array(0x6C48A50F, magic); // FIXME: uses define instead

/* Send target address */
max10_addr_shift(0x000009);
max10_addr_shift(done_bit_addr);

/* Send 'Magic' code */
_jtag->shiftIR(cmd, NULL, IRLENGTH, Jtag::PAUSE_IR);
Expand Down
4 changes: 2 additions & 2 deletions src/altera.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ class Altera: public Device, SPIInterface {
void writeXFM(const uint8_t *cfg_data, uint32_t base_addr, uint32_t offset, uint32_t len);
uint32_t verifyxFM(const uint8_t *cfg_data, uint32_t base_addr, uint32_t offset,
uint32_t len);
void max10_dsm_program_success();
void max10_flow_program_donebit();
void max10_dsm_program_success(const uint32_t pgm_success_addr);
void max10_flow_program_donebit(const uint32_t done_bit_addr);
void max10_addr_shift(uint32_t addr);
void max_10_flow_enable();
void max_10_flow_disable();
Expand Down

0 comments on commit a17cea2

Please sign in to comment.