Skip to content

Commit 5ab2e6e

Browse files
committed
Merge branch 'feat/support_parlio_cs_on_p4_eco5_v5.5' into 'release/v5.5'
feat(parlio_tx): support cs signal on esp32p4 eco5 (v5.5) See merge request espressif/esp-idf!42781
2 parents e113ecd + 1597f60 commit 5ab2e6e

File tree

5 files changed

+102
-46
lines changed

5 files changed

+102
-46
lines changed

components/esp_driver_parlio/test_apps/parlio/main/test_board.h

Lines changed: 9 additions & 1 deletion
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
*/
@@ -68,6 +68,14 @@ extern "C" {
6868
#define TEST_DATA5_GPIO 29
6969
#define TEST_DATA6_GPIO 30
7070
#define TEST_DATA7_GPIO 31
71+
#define TEST_DATA8_GPIO 35
72+
#define TEST_DATA9_GPIO 36
73+
#define TEST_DATA10_GPIO 39
74+
#define TEST_DATA11_GPIO 40
75+
#define TEST_DATA12_GPIO 41
76+
#define TEST_DATA13_GPIO 42
77+
#define TEST_DATA14_GPIO 43
78+
#define TEST_DATA15_GPIO 44
7179
#else
7280
#error "Unsupported target"
7381
#endif

components/esp_driver_parlio/test_apps/parlio/main/test_parlio_tx.c

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -294,18 +294,10 @@ TEST_CASE("parallel_tx_clock_gating", "[paralio_tx]")
294294
#if !PARLIO_LL_TX_DATA_LINE_AS_VALID_SIG
295295
TEST_CASE("parallel_tx_clock_gating_and_msb_coexist", "[paralio_tx]")
296296
{
297-
printf("init a gpio to read parlio_tx clk output\r\n");
298-
gpio_config_t test_gpio_conf = {
299-
.mode = GPIO_MODE_INPUT,
300-
.pin_bit_mask = BIT64(TEST_CLK_GPIO) | BIT64(TEST_DATA7_GPIO),
301-
};
302-
TEST_ESP_OK(gpio_config(&test_gpio_conf));
303-
304-
printf("install parlio tx unit\r\n");
305297
parlio_tx_unit_handle_t tx_unit = NULL;
306298
parlio_tx_unit_config_t config = {
307299
.clk_src = PARLIO_CLK_SRC_DEFAULT,
308-
.data_width = 8,
300+
.data_width = PARLIO_TX_UNIT_MAX_DATA_WIDTH,
309301
.clk_in_gpio_num = -1, // use internal clock source
310302
.valid_gpio_num = TEST_VALID_GPIO, // generate the valid signal
311303
.clk_out_gpio_num = TEST_CLK_GPIO,
@@ -318,6 +310,16 @@ TEST_CASE("parallel_tx_clock_gating_and_msb_coexist", "[paralio_tx]")
318310
TEST_DATA5_GPIO,
319311
TEST_DATA6_GPIO,
320312
TEST_DATA7_GPIO,
313+
#if PARLIO_TX_UNIT_MAX_DATA_WIDTH > 8
314+
TEST_DATA8_GPIO,
315+
TEST_DATA9_GPIO,
316+
TEST_DATA10_GPIO,
317+
TEST_DATA11_GPIO,
318+
TEST_DATA12_GPIO,
319+
TEST_DATA13_GPIO,
320+
TEST_DATA14_GPIO,
321+
TEST_DATA15_GPIO,
322+
#endif
321323
},
322324
.output_clk_freq_hz = 1 * 1000 * 1000,
323325
.trans_queue_depth = 4,
@@ -328,13 +330,23 @@ TEST_CASE("parallel_tx_clock_gating_and_msb_coexist", "[paralio_tx]")
328330
.valid_stop_delay = 5,
329331
.flags.clk_gate_en = true, // enable clock gating, controlled by the CS signal
330332
};
333+
334+
printf("init a gpio to read parlio_tx clk output\r\n");
335+
gpio_num_t msb_gpio_num = config.data_gpio_nums[PARLIO_TX_UNIT_MAX_DATA_WIDTH - 1];
336+
gpio_config_t test_gpio_conf = {
337+
.mode = GPIO_MODE_INPUT,
338+
.pin_bit_mask = BIT64(TEST_CLK_GPIO) | BIT64(msb_gpio_num),
339+
};
340+
TEST_ESP_OK(gpio_config(&test_gpio_conf));
341+
342+
printf("install parlio tx unit\r\n");
331343
TEST_ESP_OK(parlio_new_tx_unit(&config, &tx_unit));
332344
TEST_ESP_OK(parlio_tx_unit_enable(tx_unit));
333345

334346
printf("send packets and see if the clock is gated when there's no transaction on line\r\n");
335347
parlio_transmit_config_t transmit_config = {
336-
// set the idle value to 0x80, so that the MSB is high when there's no transaction
337-
.idle_value = 0x80,
348+
// set the idle value to 1 << (PARLIO_TX_UNIT_MAX_DATA_WIDTH - 1), so that the MSB is high when there's no transaction
349+
.idle_value = 1 << (PARLIO_TX_UNIT_MAX_DATA_WIDTH - 1),
338350
};
339351
uint32_t size = 256;
340352
__attribute__((aligned(64))) uint8_t payload[size];
@@ -345,16 +357,17 @@ TEST_CASE("parallel_tx_clock_gating_and_msb_coexist", "[paralio_tx]")
345357
TEST_ESP_OK(parlio_tx_unit_wait_all_done(tx_unit, -1));
346358
// check if the level on the clock line is low
347359
TEST_ASSERT_EQUAL(0, gpio_get_level(TEST_CLK_GPIO));
348-
TEST_ASSERT_EQUAL(1, gpio_get_level(TEST_DATA7_GPIO));
360+
TEST_ASSERT_EQUAL(1, gpio_get_level(msb_gpio_num));
349361
TEST_ESP_OK(parlio_tx_unit_transmit(tx_unit, payload, size * sizeof(uint8_t) * 8, &transmit_config));
350362
TEST_ESP_OK(parlio_tx_unit_wait_all_done(tx_unit, -1));
351363
TEST_ASSERT_EQUAL(0, gpio_get_level(TEST_CLK_GPIO));
352364
TEST_ASSERT_EQUAL(0, gpio_get_level(TEST_CLK_GPIO));
353-
TEST_ASSERT_EQUAL(1, gpio_get_level(TEST_DATA7_GPIO));
365+
TEST_ASSERT_EQUAL(1, gpio_get_level(msb_gpio_num));
354366

355367
TEST_ESP_OK(parlio_tx_unit_disable(tx_unit));
356368
TEST_ESP_OK(parlio_del_tx_unit(tx_unit));
357369
TEST_ESP_OK(gpio_reset_pin(TEST_CLK_GPIO));
370+
TEST_ESP_OK(gpio_reset_pin(msb_gpio_num));
358371
}
359372
#endif // !PARLIO_LL_TX_DATA_LINE_AS_VALID_SIG
360373
#endif // SOC_PARLIO_TX_CLK_SUPPORT_GATING

components/hal/esp32p4/include/hal/parlio_ll.h

Lines changed: 65 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "hal/misc.h"
1515
#include "hal/parlio_types.h"
1616
#include "hal/hal_utils.h"
17+
#include "hal/config.h"
1718
#include "soc/hp_sys_clkrst_struct.h"
1819
#include "soc/lp_clkrst_struct.h"
1920
#include "soc/parl_io_struct.h"
@@ -33,9 +34,17 @@
3334
#define PARLIO_LL_EVENT_TX_MASK (PARLIO_LL_EVENT_TX_FIFO_EMPTY | PARLIO_LL_EVENT_TX_EOF)
3435
#define PARLIO_LL_EVENT_RX_MASK (PARLIO_LL_EVENT_RX_FIFO_FULL)
3536

37+
38+
#if HAL_CONFIG(CHIP_SUPPORT_MIN_REV) < 300
3639
#define PARLIO_LL_TX_DATA_LINE_AS_VALID_SIG 15 // TXD[15] can be used a valid signal
40+
#endif
41+
3742
#define PARLIO_LL_TX_DATA_LINE_AS_CLK_GATE 15 // TXD[15] can be used as clock gate signal
3843

44+
#if HAL_CONFIG(CHIP_SUPPORT_MIN_REV) >= 300
45+
#define PARLIO_LL_TX_VALID_MAX_DELAY 32767
46+
#endif
47+
3948
#ifdef __cplusplus
4049
extern "C" {
4150
#endif
@@ -523,23 +532,6 @@ static inline void parlio_ll_tx_set_trans_bit_len(parl_io_dev_t *dev, uint32_t b
523532
dev->tx_data_cfg.tx_bitlen = bitlen;
524533
}
525534

526-
/**
527-
* @brief Set TX valid signal delay
528-
*
529-
* @param dev Parallel IO register base address
530-
* @param start_delay Number of clock cycles to delay
531-
* @param stop_delay Number of clock cycles to delay
532-
* @return true: success, false: valid delay is not supported
533-
*/
534-
static inline bool parlio_ll_tx_set_valid_delay(parl_io_dev_t *dev, uint32_t start_delay, uint32_t stop_delay)
535-
{
536-
(void)dev;
537-
if (start_delay == 0 && stop_delay == 0) {
538-
return true;
539-
}
540-
return false;
541-
}
542-
543535
/**
544536
* @brief Check if tx size can be determined by DMA
545537
*
@@ -591,19 +583,6 @@ static inline void parlio_ll_tx_start(parl_io_dev_t *dev, bool en)
591583
dev->tx_start_cfg.tx_start = en;
592584
}
593585

594-
/**
595-
* @brief Whether to treat the MSB of TXD as the valid signal
596-
*
597-
* @note If enabled, TXD[15] will work as valid signal, which stay high during data transmission.
598-
*
599-
* @param dev Parallel IO register base address
600-
* @param en True to enable, False to disable
601-
*/
602-
static inline void parlio_ll_tx_treat_msb_as_valid(parl_io_dev_t *dev, bool en)
603-
{
604-
dev->tx_genrl_cfg.tx_valid_output_en = en;
605-
}
606-
607586
/**
608587
* @brief Set the sample clock edge
609588
*
@@ -764,6 +743,62 @@ static inline volatile void *parlio_ll_get_interrupt_status_reg(parl_io_dev_t *d
764743
return &dev->int_st;
765744
}
766745

746+
/**********************************************************************************************************************/
747+
/************************ The following functions behave differently based on the chip revision ***********************/
748+
/**********************************************************************************************************************/
749+
750+
#if HAL_CONFIG(CHIP_SUPPORT_MIN_REV) >= 300
751+
/**
752+
* @brief Set the clock gating from the valid signal
753+
*
754+
* @param dev Parallel IO register base address
755+
* @param en If set to true, the clock is gated by the valid signal, otherwise it is gated by the MSB of the data line.
756+
*/
757+
static inline void parlio_ll_tx_clock_gating_from_valid(parl_io_dev_t *dev, bool en)
758+
{
759+
dev->tx_genrl_cfg.tx_valid_output_en = en;
760+
}
761+
#else
762+
/**
763+
* @brief Whether to treat the MSB of TXD as the valid signal
764+
*
765+
* @note If enabled, TXD[15] will work as valid signal, which stay high during data transmission.
766+
*
767+
* @param dev Parallel IO register base address
768+
* @param en True to enable, False to disable
769+
*/
770+
static inline void parlio_ll_tx_treat_msb_as_valid(parl_io_dev_t *dev, bool en)
771+
{
772+
dev->tx_genrl_cfg.tx_valid_output_en = en;
773+
}
774+
#endif
775+
776+
/**
777+
* @brief Set TX valid signal delay
778+
*
779+
* @param dev Parallel IO register base address
780+
* @param start_delay Number of clock cycles to delay
781+
* @param stop_delay Number of clock cycles to delay
782+
* @return true: success, false: valid delay is not supported
783+
*/
784+
static inline bool parlio_ll_tx_set_valid_delay(parl_io_dev_t *dev, uint32_t start_delay, uint32_t stop_delay)
785+
{
786+
#if HAL_CONFIG(CHIP_SUPPORT_MIN_REV) >= 300
787+
if (start_delay > PARLIO_LL_TX_VALID_MAX_DELAY || stop_delay > PARLIO_LL_TX_VALID_MAX_DELAY) {
788+
return false;
789+
}
790+
HAL_FORCE_MODIFY_U32_REG_FIELD(dev->tx_cs_cfg, tx_cs_start_delay, start_delay);
791+
HAL_FORCE_MODIFY_U32_REG_FIELD(dev->tx_cs_cfg, tx_cs_stop_delay, stop_delay);
792+
return true;
793+
#else
794+
(void)dev;
795+
if (start_delay == 0 && stop_delay == 0) {
796+
return true;
797+
}
798+
return false;
799+
#endif
800+
}
801+
767802
#ifdef __cplusplus
768803
}
769804
#endif

components/soc/esp32p4/include/soc/gpio_sig_map.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@
458458
#define CORE_GPIO_IN_PAD_IN27_IDX 241
459459
#define CORE_GPIO_OUT_PAD_OUT27_IDX 241
460460
#define CORE_GPIO_IN_PAD_IN28_IDX 242
461-
#define CORE_GPIO_OUT_PAD_OUT28_IDX 242
461+
#define PARLIO_TX_CS_PAD_OUT_IDX 242 // only exists on ESP32P4 Rev. 3.0 and later
462462
#define CORE_GPIO_IN_PAD_IN29_IDX 243
463463
#define CORE_GPIO_OUT_PAD_OUT29_IDX 243
464464
#define CORE_GPIO_IN_PAD_IN30_IDX 244

components/soc/esp32p4/parlio_periph.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const parlio_signal_conn_t parlio_periph_signals = {
3535
},
3636
.clk_out_sig = PARLIO_TX_CLK_PAD_OUT_IDX,
3737
.clk_in_sig = PARLIO_TX_CLK_PAD_IN_IDX,
38-
.cs_sig = -1,
38+
.cs_sig = PARLIO_TX_CS_PAD_OUT_IDX,
3939
}
4040
},
4141
.rx_units = {

0 commit comments

Comments
 (0)