aboutsummaryrefslogtreecommitdiff
path: root/src/include/lpc_common.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/lpc_common.h')
-rw-r--r--src/include/lpc_common.h91
1 files changed, 38 insertions, 53 deletions
diff --git a/src/include/lpc_common.h b/src/include/lpc_common.h
index 45d2964..4886156 100644
--- a/src/include/lpc_common.h
+++ b/src/include/lpc_common.h
@@ -20,64 +20,49 @@
#ifndef __LPC_COMMON_H
#define __LPC_COMMON_H
-#define IAP_CMD_INIT 49
-#define IAP_CMD_PREPARE 50
-#define IAP_CMD_PROGRAM 51
-#define IAP_CMD_ERASE 52
-#define IAP_CMD_BLANKCHECK 53
-#define IAP_CMD_SET_ACTIVE_BANK 60
+enum iap_cmd {
+ IAP_CMD_INIT = 49,
+ IAP_CMD_PREPARE = 50,
+ IAP_CMD_PROGRAM = 51,
+ IAP_CMD_ERASE = 52,
+ IAP_CMD_BLANKCHECK = 53,
+ IAP_CMD_SET_ACTIVE_BANK = 60,
+};
-#define IAP_STATUS_CMD_SUCCESS 0
-#define IAP_STATUS_INVALID_COMMAND 1
-#define IAP_STATUS_SRC_ADDR_ERROR 2
-#define IAP_STATUS_DST_ADDR_ERROR 3
-#define IAP_STATUS_SRC_ADDR_NOT_MAPPED 4
-#define IAP_STATUS_DST_ADDR_NOT_MAPPED 5
-#define IAP_STATUS_COUNT_ERROR 6
-#define IAP_STATUS_INVALID_SECTOR 7
-#define IAP_STATUS_SECTOR_NOT_BLANK 8
-#define IAP_STATUS_SECTOR_NOT_PREPARED 9
-#define IAP_STATUS_COMPARE_ERROR 10
-#define IAP_STATUS_BUSY 11
+enum iap_status {
+ IAP_STATUS_CMD_SUCCESS = 0,
+ IAP_STATUS_INVALID_COMMAND = 1,
+ IAP_STATUS_SRC_ADDR_ERROR = 2,
+ IAP_STATUS_DST_ADDR_ERROR = 3,
+ IAP_STATUS_SRC_ADDR_NOT_MAPPED = 4,
+ IAP_STATUS_DST_ADDR_NOT_MAPPED = 5,
+ IAP_STATUS_COUNT_ERROR = 6,
+ IAP_STATUS_INVALID_SECTOR = 7,
+ IAP_STATUS_SECTOR_NOT_BLANK = 8,
+ IAP_STATUS_SECTOR_NOT_PREPARED = 9,
+ IAP_STATUS_COMPARE_ERROR = 10,
+ IAP_STATUS_BUSY = 11,
+};
/* CPU Frequency */
#define CPU_CLK_KHZ 12000
-struct flash_param {
- uint16_t opcode;/* opcode to return to after calling the ROM */
- uint16_t pad0;
- uint32_t command;/* IAP command */
- union {
- uint32_t words[5];/* command parameters */
- struct {
- uint32_t start_sector;
- uint32_t end_sector;
- uint32_t flash_bank;
- } prepare;
- struct {
- uint32_t start_sector;
- uint32_t end_sector;
- uint32_t cpu_clk_khz;
- uint32_t flash_bank;
- } erase;
- struct {
- uint32_t dest;
- uint32_t source;
- uint32_t byte_count;
- uint32_t cpu_clk_khz;
- } program;
- struct {
- uint32_t start_sector;
- uint32_t end_sector;
- uint32_t flash_bank;
- } blank_check;
- struct {
- uint32_t flash_bank;
- uint32_t cpu_clk_khz;
- } make_active;
- };
- uint32_t result[5]; /* result data */
-} __attribute__((aligned(4)));
+struct lpc_flash {
+ struct target_flash f;
+ uint8_t base_sector;
+ uint8_t bank;
+ /* Info filled in by specific driver */
+ void (*wdt_kick)(target *t);
+ uint32_t iap_entry;
+ uint32_t iap_ram;
+ uint32_t iap_msp;
+};
+
+struct lpc_flash *lpc_add_flash(target *t, uint32_t addr, size_t length);
+enum iap_status lpc_iap_call(struct lpc_flash *f, enum iap_cmd cmd, ...);
+int lpc_flash_erase(struct target_flash *f, uint32_t addr, size_t len);
+int lpc_flash_write(struct target_flash *f,
+ uint32_t dest, const void *src, size_t len);
#endif