From 59bc439886ca96c841a3dfaea0f31d0c5e0e7500 Mon Sep 17 00:00:00 2001 From: Sylvain Munaut Date: Wed, 29 Sep 2010 20:13:26 +0200 Subject: [PATCH] target/fw/dsp: Implement section loading with bootloader This works for both the default ROM bootloader and for our custom one. This will allow to implement easy patch loading. Signed-off-by: Sylvain Munaut --- src/target/firmware/calypso/dsp.c | 35 +++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/target/firmware/calypso/dsp.c b/src/target/firmware/calypso/dsp.c index 2ce0bc7..0d9521f 100644 --- a/src/target/firmware/calypso/dsp.c +++ b/src/target/firmware/calypso/dsp.c @@ -116,6 +116,41 @@ static void dsp_bl_start_at(uint16_t addr) writew(BL_CMD_COPY_BLOCK, BL_CMD_STATUS); } +static int dsp_bl_upload_sections(const struct dsp_section *sec) +{ + /* Make sure the bootloader is ready */ + dsp_bl_wait_ready(); + + /* Set mode */ + writew(BL_MODE_DATA_WRITE, BASE_API_RAM); + writew(BL_CMD_COPY_MODE, BL_CMD_STATUS); + dsp_bl_wait_ready(); + + /* Scan all sections */ + for (; sec->data; sec++) { + volatile uint16_t *api = (volatile uint16_t *)BASE_API_RAM; + unsigned int i; + + if (sec->size > BL_MAX_BLOCK_SIZE) + return -1; /* not supported for now */ + + /* Copy data to API */ + for (i=0; isize; i++) + api[i] = sec->data[i]; + + /* Issue DRAM write */ + writew(sec->addr >> 16, BL_ADDR_HI); + writew(sec->addr & 0xffff, BL_ADDR_LO); + writew(sec->size, BL_SIZE); + writew(BL_CMD_COPY_BLOCK, BL_CMD_STATUS); + + /* Wait for completion */ + dsp_bl_wait_ready(); + } + + return 0; +} + static int dsp_upload_sections_api(const struct dsp_section *sec, uint16_t dsp_base_api) { for (; sec->data; sec++) { -- 2.20.1