Skip to content

Commit dde8fac

Browse files
committed
feat(parlio_tx): support cs signal on esp32p4 eco5
1 parent 9056974 commit dde8fac

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
@@ -553,23 +562,6 @@ static inline void parlio_ll_tx_set_trans_bit_len(parl_io_dev_t *dev, uint32_t b
553562
dev->tx_data_cfg.tx_bitlen = bitlen;
554563
}
555564

556-
/**
557-
* @brief Set TX valid signal delay
558-
*
559-
* @param dev Parallel IO register base address
560-
* @param start_delay Number of clock cycles to delay
561-
* @param stop_delay Number of clock cycles to delay
562-
* @return true: success, false: valid delay is not supported
563-
*/
564-
static inline bool parlio_ll_tx_set_valid_delay(parl_io_dev_t *dev, uint32_t start_delay, uint32_t stop_delay)
565-
{
566-
(void)dev;
567-
if (start_delay == 0 && stop_delay == 0) {
568-
return true;
569-
}
570-
return false;
571-
}
572-
573565
/**
574566
* @brief Check if tx size can be determined by DMA
575567
*
@@ -621,19 +613,6 @@ static inline void parlio_ll_tx_start(parl_io_dev_t *dev, bool en)
621613
dev->tx_start_cfg.tx_start = en;
622614
}
623615

624-
/**
625-
* @brief Whether to treat the MSB of TXD as the valid signal
626-
*
627-
* @note If enabled, TXD[15] will work as valid signal, which stay high during data transmission.
628-
*
629-
* @param dev Parallel IO register base address
630-
* @param en True to enable, False to disable
631-
*/
632-
static inline void parlio_ll_tx_treat_msb_as_valid(parl_io_dev_t *dev, bool en)
633-
{
634-
dev->tx_genrl_cfg.tx_valid_output_en = en;
635-
}
636-
637616
/**
638617
* @brief Set the sample clock edge
639618
*
@@ -794,6 +773,62 @@ static inline volatile void *parlio_ll_get_interrupt_status_reg(parl_io_dev_t *d
794773
return &dev->int_st;
795774
}
796775

776+
/**********************************************************************************************************************/
777+
/************************ The following functions behave differently based on the chip revision ***********************/
778+
/**********************************************************************************************************************/
779+
780+
#if HAL_CONFIG(CHIP_SUPPORT_MIN_REV) >= 300
781+
/**
782+
* @brief Set the clock gating from the valid signal
783+
*
784+
* @param dev Parallel IO register base address
785+
* @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.
786+
*/
787+
static inline void parlio_ll_tx_clock_gating_from_valid(parl_io_dev_t *dev, bool en)
788+
{
789+
dev->tx_genrl_cfg.tx_valid_output_en = en;
790+
}
791+
#else
792+
/**
793+
* @brief Whether to treat the MSB of TXD as the valid signal
794+
*
795+
* @note If enabled, TXD[15] will work as valid signal, which stay high during data transmission.
796+
*
797+
* @param dev Parallel IO register base address
798+
* @param en True to enable, False to disable
799+
*/
800+
static inline void parlio_ll_tx_treat_msb_as_valid(parl_io_dev_t *dev, bool en)
801+
{
802+
dev->tx_genrl_cfg.tx_valid_output_en = en;
803+
}
804+
#endif
805+
806+
/**
807+
* @brief Set TX valid signal delay
808+
*
809+
* @param dev Parallel IO register base address
810+
* @param start_delay Number of clock cycles to delay
811+
* @param stop_delay Number of clock cycles to delay
812+
* @return true: success, false: valid delay is not supported
813+
*/
814+
static inline bool parlio_ll_tx_set_valid_delay(parl_io_dev_t *dev, uint32_t start_delay, uint32_t stop_delay)
815+
{
816+
#if HAL_CONFIG(CHIP_SUPPORT_MIN_REV) >= 300
817+
if (start_delay > PARLIO_LL_TX_VALID_MAX_DELAY || stop_delay > PARLIO_LL_TX_VALID_MAX_DELAY) {
818+
return false;
819+
}
820+
HAL_FORCE_MODIFY_U32_REG_FIELD(dev->tx_cs_cfg, tx_cs_start_delay, start_delay);
821+
HAL_FORCE_MODIFY_U32_REG_FIELD(dev->tx_cs_cfg, tx_cs_stop_delay, stop_delay);
822+
return true;
823+
#else
824+
(void)dev;
825+
if (start_delay == 0 && stop_delay == 0) {
826+
return true;
827+
}
828+
return false;
829+
#endif
830+
}
831+
797832
#ifdef __cplusplus
798833
}
799834
#endif

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@
451451
#define CORE_GPIO_IN_PAD_IN27_IDX 241
452452
#define CORE_GPIO_OUT_PAD_OUT27_IDX 241
453453
#define CORE_GPIO_IN_PAD_IN28_IDX 242
454-
#define PARLIO_TX_CS_PAD_OUT_IDX 242
454+
#define PARLIO_TX_CS_PAD_OUT_IDX 242 // only exists on ESP32P4 Rev. 3.0 and later
455455
#define CORE_GPIO_IN_PAD_IN29_IDX 243
456456
#define EMAC_PTP_PPS_PAD_OUT_IDX 243
457457
#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)