blob: 27605635059c757b339aaf115bf899193bfc0c9c [file] [log] [blame]
Andrew Jeffery4fe996c2018-02-27 12:16:48 +10301/* SPDX-License-Identifier: Apache-2.0 */
2/* Copyright (C) 2018 IBM Corp. */
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +11003
Andrew Jefferyf2587b02018-08-08 16:39:55 +09304#ifndef FLASH_H
5#define FLASH_H
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +11006
Andrew Jefferycb935042019-03-15 09:54:33 +10307#include <stdbool.h>
Andrew Jeffery26558db2018-08-10 00:22:38 +09308#include <stdint.h>
9
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +110010#define FLASH_DIRTY 0x00
11#define FLASH_ERASED 0x01
12
Andrew Jefferyc48d0702018-08-09 14:04:27 +093013/* Estimate as to how long (milliseconds) it takes to access a MB from flash */
14#define FLASH_ACCESS_MS_PER_MB 8000
15
Andrew Jeffery26558db2018-08-10 00:22:38 +093016struct mbox_context;
Andrew Jeffery1a5f8b92017-04-11 11:58:55 +093017
Andrew Jefferyd6b09bc2018-08-08 16:47:54 +093018int flash_dev_init(struct mbox_context *context);
Andrew Jefferydec6ca62018-08-08 16:49:43 +093019void flash_dev_free(struct mbox_context *context);
Andrew Jefferycb935042019-03-15 09:54:33 +103020int flash_validate(struct mbox_context *context, uint32_t offset,
21 uint32_t size, bool ro);
Andrew Jefferye0cdd3e2018-08-08 16:51:44 +093022int64_t flash_copy(struct mbox_context *context, uint32_t offset, void *mem,
Deepak Kodihalli7ee307c2017-07-12 03:41:08 -050023 uint32_t size);
Andrew Jefferyf953f792018-08-08 16:56:03 +093024int flash_set_bytemap(struct mbox_context *context, uint32_t offset,
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +110025 uint32_t count, uint8_t val);
Andrew Jeffery4f5d29c2018-08-08 16:58:04 +093026int flash_erase(struct mbox_context *context, uint32_t offset, uint32_t count);
Andrew Jeffery0293f2f2018-08-08 16:59:45 +093027int flash_write(struct mbox_context *context, uint32_t offset, void *buf,
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +110028 uint32_t count);
29
Andrew Jefferyf2587b02018-08-08 16:39:55 +093030#endif /* FLASH_H */