Start of public OpenTitan development history

Code contributors:
Alex Bradbury <asb@lowrisc.org>
Cindy Chen <chencindy@google.com>
Eunchan Kim <eunchan@google.com>
Gaurang Chitroda <gaurangg@google.com>
Mark Hayter <mark.hayter@gmail.com>
Michael Schaffner <msf@google.com>
Miguel Osorio <miguelosorio@google.com>
Nils Graf <nilsg@google.com>
Philipp Wagner <phw@lowrisc.org>
Pirmin Vogel <vogelpi@lowrisc.org>
Ram Babu Penugonda <rampenugonda@google.com>
Scott Johnson <scottdj@google.com>
Shail Kushwah <kushwahs@google.com>
Srikrishna Iyer <sriyer@google.com>
Steve Nelson <Steve.Nelson@wdc.com>
Tao Liu <taliu@google.com>
Timothy Chen <timothytim@google.com>
Tobias Wölfel <tobias.woelfel@mailbox.org>
Weicai Yang <weicai@google.com>
diff --git a/sw/lib/flash_ctrl.h b/sw/lib/flash_ctrl.h
new file mode 100644
index 0000000..21e90a1
--- /dev/null
+++ b/sw/lib/flash_ctrl.h
@@ -0,0 +1,43 @@
+// Copyright lowRISC contributors.
+// Licensed under the Apache License, Version 2.0, see LICENSE for details.
+// SPDX-License-Identifier: Apache-2.0
+
+#ifndef _FLASH_H_
+#define _FLASH_H_
+
+#include <stdint.h>
+
+#include "flash_ctrl_regs.h"
+
+#define FLASH_CTRL0_BASE_ADDR 0x40030000
+#define WORDS_PER_PAGE 256
+#define ERASE_CHECK_WORDS 16
+#define BYTES_PER_WORD 4
+
+typedef enum flash_op {
+  FlashRead = 0,
+  FlashProg = 1,
+  FlashErase = 2
+} flash_op_t;
+
+typedef enum erase_type { PageErase = 0, BankErase = 1 } erase_type_t;
+
+typedef struct mp_region {
+  uint32_t num;  // which region to program
+  uint32_t base;
+  uint32_t size;
+  uint32_t rd_en;
+  uint32_t prog_en;
+  uint32_t erase_en;
+} mp_region_t;
+
+void wait_flash_init(void);
+void wait_done_and_ack(void);
+void setup_flash_prog(uint32_t addr, uint32_t num);
+uint32_t prog_flash(uint32_t addr, uint32_t num, uint32_t *data);
+uint32_t read_flash(uint32_t addr, uint32_t num, uint32_t *data);
+uint32_t page_erase(uint32_t addr);
+void flash_default_region(uint32_t rd_en, uint32_t prog_en, uint32_t erase_en);
+void flash_cfg_region(mp_region_t region_cfg);
+
+#endif