From 25c07526827197549e412fef063e8dacfae00201 Mon Sep 17 00:00:00 2001 From: Mahavir Jain Date: Thu, 21 Nov 2019 18:40:46 +0530 Subject: [PATCH] i2s: fix regression in retrieval of chip revision causing apll test to fail --- components/driver/CMakeLists.txt | 1 + components/driver/i2s.c | 11 +++++++---- components/soc/esp32/include/hal/i2s_ll.h | 15 +-------------- components/soc/esp32s2beta/include/hal/i2s_ll.h | 13 +------------ components/soc/include/hal/i2s_hal.h | 10 +--------- 5 files changed, 11 insertions(+), 39 deletions(-) diff --git a/components/driver/CMakeLists.txt b/components/driver/CMakeLists.txt index 4733d09d1a..3c1da5a67d 100644 --- a/components/driver/CMakeLists.txt +++ b/components/driver/CMakeLists.txt @@ -40,6 +40,7 @@ endif() idf_component_register(SRCS "${srcs}" INCLUDE_DIRS ${includes} PRIV_INCLUDE_DIRS "include/driver" + PRIV_REQUIRES efuse REQUIRES esp_ringbuf soc) #cannot totally hide soc headers, since there are a lot arguments in the driver are chip-dependent # uses C11 atomic feature diff --git a/components/driver/i2s.c b/components/driver/i2s.c index 129c810028..2592d273fd 100644 --- a/components/driver/i2s.c +++ b/components/driver/i2s.c @@ -31,6 +31,7 @@ #include "esp_err.h" #include "esp_log.h" #include "esp_pm.h" +#include "esp_efuse.h" static const char* I2S_TAG = "I2S"; @@ -180,12 +181,14 @@ static esp_err_t i2s_isr_register(i2s_port_t i2s_num, int intr_alloc_flags, void static float i2s_apll_get_fi2s(int bits_per_sample, int sdm0, int sdm1, int sdm2, int odir) { int f_xtal = (int)rtc_clk_xtal_freq_get() * 1000000; - uint32_t rev; - i2s_hal_get_rev(&(p_i2s_obj[0]->hal), &rev); // I2S hardware instance address will not be used - if (rev) { + +#if CONFIG_IDF_TARGET_ESP32 + /* ESP32 rev0 silicon issue for APLL range/accuracy, please see ESP32 ECO document for more information on this */ + if (esp_efuse_get_chip_ver() == 0) { sdm0 = 0; sdm1 = 0; } +#endif float fout = f_xtal * (sdm2 + sdm1 / 256.0f + sdm0 / 65536.0f + 4); if (fout < APLL_MIN_FREQ || fout > APLL_MAX_FREQ) { return APLL_MAX_FREQ; @@ -1149,4 +1152,4 @@ esp_err_t i2s_read(i2s_port_t i2s_num, void *dest, size_t size, size_t *bytes_re #endif xSemaphoreGive(p_i2s_obj[i2s_num]->rx->mux); return ESP_OK; -} \ No newline at end of file +} diff --git a/components/soc/esp32/include/hal/i2s_ll.h b/components/soc/esp32/include/hal/i2s_ll.h index 75c58d9ced..abf60be695 100644 --- a/components/soc/esp32/include/hal/i2s_ll.h +++ b/components/soc/esp32/include/hal/i2s_ll.h @@ -246,19 +246,6 @@ static inline void i2s_ll_enable_dma(i2s_dev_t *hw) hw->lc_conf.val = lc_conf.val; } -/** - * @brief Get I2S revision - * - * @param hw Peripheral I2S hardware instance address. - * @param val value to get revision - */ -static inline void i2s_ll_get_rev(i2s_dev_t *hw, uint32_t *val) -{ - if (GET_PERI_REG_BITS2(EFUSE_BLK0_RDATA3_REG, 1, 15) == 0) { - *val = 1; - } -} - /** * @brief Get I2S interrupt status * @@ -834,4 +821,4 @@ static inline void i2s_ll_set_sig_loopback(i2s_dev_t *hw, uint32_t val) #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/components/soc/esp32s2beta/include/hal/i2s_ll.h b/components/soc/esp32s2beta/include/hal/i2s_ll.h index fc760e35be..30df72a695 100644 --- a/components/soc/esp32s2beta/include/hal/i2s_ll.h +++ b/components/soc/esp32s2beta/include/hal/i2s_ll.h @@ -243,17 +243,6 @@ static inline void i2s_ll_enable_dma(i2s_dev_t *hw) hw->lc_conf.val = lc_conf.val; } -/** - * @brief Get I2S revision - * - * @param hw Peripheral I2S hardware instance address. - * @param val value to get revision - */ -static inline void i2s_ll_get_rev(i2s_dev_t *hw, uint32_t *val) -{ - *val = 1; -} - /** * @brief Get I2S interrupt status * @@ -828,4 +817,4 @@ static inline void i2s_ll_set_sig_loopback(i2s_dev_t *hw, uint32_t val) #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/components/soc/include/hal/i2s_hal.h b/components/soc/include/hal/i2s_hal.h index 24cab0d98a..75779c6ddf 100644 --- a/components/soc/include/hal/i2s_hal.h +++ b/components/soc/include/hal/i2s_hal.h @@ -47,14 +47,6 @@ typedef struct { */ void i2s_hal_reset_fifo(i2s_hal_context_t *hal); -/** - * @brief Get I2S revision - * - * @param hal Context of the HAL layer - * @param rev I2S revision - */ -#define i2s_hal_get_rev(hal, rev) i2s_ll_get_rev((hal)->dev, rev) - /** * @brief Get I2S interrupt status * @@ -301,4 +293,4 @@ void i2s_hal_init(i2s_hal_context_t *hal, int i2s_num); #ifdef __cplusplus } -#endif \ No newline at end of file +#endif