summaryrefslogtreecommitdiffstats
path: root/src/target/firmware/calypso/dsp.c
diff options
context:
space:
mode:
authorSylvain Munaut2010-09-29 20:13:26 +0200
committerSylvain Munaut2010-11-07 21:36:32 +0100
commit59bc439886ca96c841a3dfaea0f31d0c5e0e7500 (patch)
treee59935608f171999dd790128944d054c487e0ea7 /src/target/firmware/calypso/dsp.c
parenttarget/fw/dsp: Create a common function to start running code (diff)
downloadosmocom-59bc439886ca96c841a3dfaea0f31d0c5e0e7500.tar.gz
osmocom-59bc439886ca96c841a3dfaea0f31d0c5e0e7500.tar.xz
osmocom-59bc439886ca96c841a3dfaea0f31d0c5e0e7500.zip
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 <tnt@246tNt.com>
Diffstat (limited to 'src/target/firmware/calypso/dsp.c')
-rw-r--r--src/target/firmware/calypso/dsp.c35
1 files changed, 35 insertions, 0 deletions
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; i<sec->size; 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++) {