/* Load code.bin file through boot (reset) interface. */ static int cycx_code_boot(void __iomem *addr, u8 *code, u32 len) { void __iomem *pt_boot_cmd = addr + CMD_OFFSET; u32 i; /* boot buffer lenght */ writew(CFM_LOAD_BUFSZ, pt_boot_cmd + sizeof(u16)); writew(GEN_DEFPAR, pt_boot_cmd); if (wait_cyc(addr) < 0) return -1; writew(0x0000, pt_boot_cmd + sizeof(u16)); writew(0xc400, pt_boot_cmd + 2 * sizeof(u16)); writew(GEN_SET_SEG, pt_boot_cmd); if (wait_cyc(addr) < 0) return -1; for (i = 0 ; i < len ; i += CFM_LOAD_BUFSZ) if (buffer_load(addr, code + i, min_t(u32, CFM_LOAD_BUFSZ, (len - i)))) { printk(KERN_ERR "%s: Error !!\n", modname); return -1; } return 0; }
/* Load data.bin file through boot (reset) interface. */ static int cycx_data_boot(u32 addr, u8 *code, u32 len) { u32 pt_boot_cmd = addr + CMD_OFFSET; u32 i; /* boot buffer lenght */ cyc2x_writew(CFM_LOAD_BUFSZ, pt_boot_cmd + sizeof(u16)); cyc2x_writew(GEN_DEFPAR, pt_boot_cmd); if (wait_cyc(addr) < 0) return -1; cyc2x_writew(0, pt_boot_cmd + sizeof(u16)); cyc2x_writew(0x4000, pt_boot_cmd + 2 * sizeof(u16)); cyc2x_writew(GEN_SET_SEG, pt_boot_cmd); if (wait_cyc(addr) < 0) return -1; for (i = 0 ; i < len ; i += CFM_LOAD_BUFSZ) if (buffer_load(addr, code + i, MIN(CFM_LOAD_BUFSZ, (len - i))) < 0) { printk(KERN_ERR "%s: Error !!\n", modname); return -1; } return 0; }
/* Load data.bin file through boot (reset) interface. */ static int cycx_data_boot(void __iomem *addr, u8 *code, u32 len) { void __iomem *pt_boot_cmd = addr + CMD_OFFSET; u32 i; /* boot buffer length */ writew(CFM_LOAD_BUFSZ, pt_boot_cmd + sizeof(u16)); writew(GEN_DEFPAR, pt_boot_cmd); if (wait_cyc(addr) < 0) return -1; writew(0, pt_boot_cmd + sizeof(u16)); writew(0x4000, pt_boot_cmd + 2 * sizeof(u16)); writew(GEN_SET_SEG, pt_boot_cmd); if (wait_cyc(addr) < 0) return -1; for (i = 0 ; i < len ; i += CFM_LOAD_BUFSZ) if (buffer_load(addr, code + i, min_t(u32, CFM_LOAD_BUFSZ, (len - i))) < 0) { pr_err("Error !!\n"); return -1; } return 0; }
/* Load buffer using boot interface. * o copy data from buffer to Cyclom-X memory * o wait for reset code to copy it to right portion of memory */ static int buffer_load(void __iomem *addr, u8 *buffer, u32 cnt) { memcpy_toio(addr + DATA_OFFSET, buffer, cnt); writew(GEN_BOOT_DAT, addr + CMD_OFFSET); return wait_cyc(addr); }
/* Load buffer using boot interface. * o copy data from buffer to Cyclom-X memory * o wait for reset code to copy it to right portion of memory */ static int buffer_load(u32 addr, u8 *buffer, u32 cnt) { cyc2x_memcpy_toio(addr + DATA_OFFSET, buffer, cnt); cyc2x_writew(GEN_BOOT_DAT, addr + CMD_OFFSET); return wait_cyc(addr); }