Skip to content

Commit 5423825

Browse files
committed
Merge branch 'refactor/improve_p4_psram_timing_tuning_point_selection' into 'master'
mspi: improve p4 psram timing tuning point selection See merge request espressif/esp-idf!38169
2 parents 72a5217 + d0e7834 commit 5423825

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

components/esp_hw_support/mspi_timing_tuning/mspi_timing_by_dqs.c

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -51,9 +51,9 @@ const static uint32_t s_test_data[MSPI_TIMING_TEST_DATA_LEN] = {0x7f786655, 0xa5
5151
0x80786655, 0x00a5ff5a, 0xc03c33aa, 0x00a55aff, 0xe01e9355, 0x00ff5aa5, 0xf00fccaa, 0x005affa5,
5252
0xf8876655, 0x5aa5ff00, 0xfcc333aa, 0x5affa500, 0xfee19955, 0x5a00a5ff, 0x11f0ccaa, 0x5a00ffa5};
5353
const static mspi_timing_config_t s_test_delayline_config = {
54-
.delayline_table = {{15, 0}, {14, 0}, {13, 0}, {12, 0}, {11, 0}, {10, 0}, {9, 0}, {8, 0}, {7, 0}, {6, 0}, {5, 0}, {4, 0}, {3, 0}, {2, 0}, {1, 0}, {0, 0},
55-
{0, 0}, {0, 1}, {0, 2}, {0, 3}, {0, 4}, {0, 5}, {0, 6}, {0, 7}, {0, 8}, {0, 9}, {0, 10}, {0, 11}, {0, 12}, {0, 13}, {0, 14}, {0, 15}},
56-
.available_config_num = 32,
54+
.delayline_table = {{0, 15}, {0, 14}, {0, 13}, {0, 12}, {0, 11}, {0, 10}, {0, 9}, {0, 8}, {0, 7}, {0, 6}, {0, 5}, {0, 4}, {0, 3}, {0, 2}, {0, 1},
55+
{0, 0}, {1, 0}, {2, 0}, {3, 0}, {4, 0}, {5, 0}, {6, 0}, {7, 0}, {8, 0}, {9, 0}, {10, 0}, {11, 0}, {12, 0}, {13, 0}, {14, 0}, {15, 0}},
56+
.available_config_num = 31,
5757
};
5858
static mspi_ll_dqs_phase_t s_psram_best_phase = MSPI_LL_DQS_PHASE_MAX;
5959
static delayline_config_t s_psram_best_delayline = {WRONG_DELAYLINE, WRONG_DELAYLINE};
@@ -134,12 +134,8 @@ uint32_t mspi_timing_psram_select_best_tuning_phase(const void *configs, uint32_
134134
if (consecutive_length == 0) {
135135
best_phase_id = 0;
136136
success = false;
137-
} else if (consecutive_length == 1) {
138-
best_phase_id = end;
139-
} else if (consecutive_length == 2 || consecutive_length == 3){
140-
best_phase_id = end - 1;
141137
} else {
142-
best_phase_id = end - 2;
138+
best_phase_id = (end - consecutive_length + 1);
143139
}
144140

145141
if (success) {

components/esp_hw_support/mspi_timing_tuning/mspi_timing_tuning.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2019-2024 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2019-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -270,8 +270,17 @@ static void s_find_max_consecutive_success_points(uint32_t *array, uint32_t size
270270
i++;
271271
}
272272

273-
*out_length = match_num > max ? match_num : max;
274-
*out_end_index = match_num == size ? size : end;
273+
/**
274+
* this is to deal with the case when the last points are consecutive 1, e.g.
275+
* {1, 0, 0, 1, 1, 1, 1, 1, 1}
276+
*/
277+
if (match_num > max) {
278+
max = match_num;
279+
end = i - 1;
280+
}
281+
282+
*out_length = max;
283+
*out_end_index = end;
275284
}
276285

277286
static void s_select_best_tuning_config(mspi_timing_config_t *config, uint32_t consecutive_length, uint32_t end, const uint8_t *reference_data, bool is_flash)

0 commit comments

Comments
 (0)