Andrew Jeffery | 4fe996c | 2018-02-27 12:16:48 +1030 | [diff] [blame] | 1 | /* SPDX-License-Identifier: Apache-2.0 */ |
| 2 | /* Copyright (C) 2018 IBM Corp. */ |
Suraj Jitindar Singh | e39c916 | 2017-03-28 10:47:43 +1100 | [diff] [blame] | 3 | |
Andrew Jeffery | f2587b0 | 2018-08-08 16:39:55 +0930 | [diff] [blame] | 4 | #ifndef FLASH_H |
| 5 | #define FLASH_H |
Suraj Jitindar Singh | e39c916 | 2017-03-28 10:47:43 +1100 | [diff] [blame] | 6 | |
Andrew Jeffery | 26558db | 2018-08-10 00:22:38 +0930 | [diff] [blame] | 7 | #include <stdint.h> |
| 8 | |
Suraj Jitindar Singh | e39c916 | 2017-03-28 10:47:43 +1100 | [diff] [blame] | 9 | #define FLASH_DIRTY 0x00 |
| 10 | #define FLASH_ERASED 0x01 |
| 11 | |
Andrew Jeffery | c48d070 | 2018-08-09 14:04:27 +0930 | [diff] [blame] | 12 | /* Estimate as to how long (milliseconds) it takes to access a MB from flash */ |
| 13 | #define FLASH_ACCESS_MS_PER_MB 8000 |
| 14 | |
Andrew Jeffery | 26558db | 2018-08-10 00:22:38 +0930 | [diff] [blame] | 15 | struct mbox_context; |
Andrew Jeffery | 1a5f8b9 | 2017-04-11 11:58:55 +0930 | [diff] [blame] | 16 | |
Andrew Jeffery | d6b09bc | 2018-08-08 16:47:54 +0930 | [diff] [blame] | 17 | int flash_dev_init(struct mbox_context *context); |
Andrew Jeffery | dec6ca6 | 2018-08-08 16:49:43 +0930 | [diff] [blame] | 18 | void flash_dev_free(struct mbox_context *context); |
Andrew Jeffery | e0cdd3e | 2018-08-08 16:51:44 +0930 | [diff] [blame] | 19 | int64_t flash_copy(struct mbox_context *context, uint32_t offset, void *mem, |
Deepak Kodihalli | 7ee307c | 2017-07-12 03:41:08 -0500 | [diff] [blame] | 20 | uint32_t size); |
Andrew Jeffery | f953f79 | 2018-08-08 16:56:03 +0930 | [diff] [blame] | 21 | int flash_set_bytemap(struct mbox_context *context, uint32_t offset, |
Suraj Jitindar Singh | e39c916 | 2017-03-28 10:47:43 +1100 | [diff] [blame] | 22 | uint32_t count, uint8_t val); |
Andrew Jeffery | 4f5d29c | 2018-08-08 16:58:04 +0930 | [diff] [blame] | 23 | int flash_erase(struct mbox_context *context, uint32_t offset, uint32_t count); |
Andrew Jeffery | 0293f2f | 2018-08-08 16:59:45 +0930 | [diff] [blame] | 24 | int flash_write(struct mbox_context *context, uint32_t offset, void *buf, |
Suraj Jitindar Singh | e39c916 | 2017-03-28 10:47:43 +1100 | [diff] [blame] | 25 | uint32_t count); |
| 26 | |
Andrew Jeffery | f2587b0 | 2018-08-08 16:39:55 +0930 | [diff] [blame] | 27 | #endif /* FLASH_H */ |