![]() |
TT-System-Firmware APIs 19.15.99
Tenstorrent Firmware
|
#include "gddr_cal.h"#include <errno.h>#include <zephyr/device.h>#include <zephyr/drivers/flash.h>#include <zephyr/logging/log.h>#include <zephyr/storage/flash_map.h>#include <zephyr/sys/crc.h>#include <zephyr/sys/util.h>
Functions | |
| LOG_MODULE_REGISTER (gddr_cal, CONFIG_TT_APP_LOG_LEVEL) | |
| int | gddr_cal_read (gddr_cal_table_t *table) |
| Read and validate the CA calibration table from flash. | |
| int | gddr_cal_write (const gddr_cal_table_t *table) |
| Write the CA calibration table to flash. | |
| int gddr_cal_read | ( | gddr_cal_table_t * | table | ) |
Read and validate the CA calibration table from flash.
Reads both banks, prefers the one with the newer sequence number, and falls back to the other if it fails validation. Erased banks fail the magic check and are treated as absent, as are banks written by an older firmware whose table layout differed.
CONFIG_TT_BH_ARC_GDDR_CA_LATCH requires gddrcal_a and gddrcal_b in the devicetree; a build without those nodes is rejected at compile time.
| [out] | table | Destination table; only written on success. |
| 0 | on success. |
| -ENODEV | if the flash device is not ready. |
| -ENOENT | if neither bank holds a valid table. |
| -ENOSYS | if the latch Kconfig is off and the partitions are absent. |
| int gddr_cal_write | ( | const gddr_cal_table_t * | table | ) |
Write the CA calibration table to flash.
Writes to whichever bank is not currently active, with a sequence number one greater than the active bank's, then reads the bank back and verifies it. The active bank is never erased, so a power loss at any point leaves the previous table intact and readable.
| [in] | table | Table to store. |
| 0 | on success, negative error code on failure. |
| -ENOSYS | if the latch Kconfig is off and the partitions are absent. |
| LOG_MODULE_REGISTER | ( | gddr_cal | , |
| CONFIG_TT_APP_LOG_LEVEL | ) |