1 /*
2  * SPDX-FileCopyrightText: 2019-2022 Espressif Systems (Shanghai) CO LTD
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #include "soc/soc.h"
8 #include "soc/efuse_reg.h"
9 
10 #if CONFIG_IDF_TARGET_ESP32S3
11 /**
12  * Since rom of esp32s3 does not export function ets_efuse_get_opiconfig,
13  * patch this function here.
14  */
esp_rom_efuse_get_opiconfig(void)15 uint32_t esp_rom_efuse_get_opiconfig(void)
16 {
17     uint64_t spiconfig1 = REG_GET_FIELD(EFUSE_RD_MAC_SPI_SYS_2_REG, EFUSE_SPI_PAD_CONF_1);
18     uint64_t spiconfig2 = REG_GET_FIELD(EFUSE_RD_MAC_SPI_SYS_3_REG, EFUSE_SPI_PAD_CONF_2);
19     uint64_t opiconfig = (spiconfig2 << 12) | (spiconfig1 >> 20);
20     if (opiconfig == 0 || opiconfig == 0x3fffffffllu) {
21         return 0;
22     }
23     // (MSB)EFUSE_SPI_PAD_CONF_2(18bit) + EFUSE_SPI_PAD_CONF_1(32bit) + EFUSE_SPI_PAD_CONF_0(16bit) (LSB)
24     // [36:41] -- DQS
25     // [42:47] -- D4
26     // [48:53] -- D5
27     // [54:59] -- D6
28     // [60:65] -- D7
29     return opiconfig & 0x3fffffff;
30 }
31 #endif
32