blob: 758ae0bb5abf224521007670ada719b3c4bfeb13 [file] [log] [blame]
/*
* Copyright 2023 Google LLC
* Copyright lowRISC contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef SW_DEVICE_SILICON_CREATOR_ROM_BOOTSTRAP_H_
#define SW_DEVICE_SILICON_CREATOR_ROM_BOOTSTRAP_H_
#include "sw/device/lib/base/hardened.h"
#include "sw/device/lib/base/mmio.h"
#include "sw/device/silicon_creator/lib/error.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* Checks whether bootstrap is requested.
*
* The return value of this function also depends on the `ROM_BOOTSTRAP_EN` OTP
* item.
*
* @return Whether bootstrap is requested.
*/
hardened_bool_t bootstrap_requested(mmio_region_t otp_addr,
mmio_region_t gpio_addr);
/**
* Bootstraps the data partition of the embedded flash with data received by the
* spi_device.
*
* OpenTitan bootstrap uses the typical SPI flash EEPROM commands. A typical
* bootstrap session involves:
* - Asserting bootstrap pins to enter bootstrap mode,
* - Erasing the chip (WREN, CHIP_ERASE, busy loop ...),
* - Programming the chip (WREN, PAGE_PROGRAM, busy loop ...), and
* - Resetting the chip (RESET).
*
* This function only returns on error since a successful bootstrap ends with a
* chip reset.
*
* @return Result of the operation.
*/
rom_error_t bootstrap(mmio_region_t otp_addr, mmio_region_t gpio_addr,
mmio_region_t spi_device_addr);
#ifdef __cplusplus
}
#endif
#endif // SW_DEVICE_SILICON_CREATOR_ROM_BOOTSTRAP_H_