Skip to content

Commit a1f765b

Browse files
committed
Merge branch 'feat/support_parlio_cs_on_p4_eco5' into 'master'
feat(parlio_tx): support cs signal on esp32p4 eco5 Closes IDF-13519 and IDF-12219 See merge request espressif/esp-idf!41787
2 parents 03dd5e3 + dde8fac commit a1f765b

File tree

21 files changed

+125
-10323
lines changed

21 files changed

+125
-10323
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/esp32/register/soc/io_mux_reg.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -84,12 +84,6 @@
8484

8585
#define PIN_FUNC_GPIO 2
8686

87-
#define SPI_CLK_GPIO_NUM 6
88-
#define SPI_CS0_GPIO_NUM 11
89-
#define SPI_Q_GPIO_NUM 7
90-
#define SPI_D_GPIO_NUM 8
91-
#define SPI_WP_GPIO_NUM 10
92-
#define SPI_HD_GPIO_NUM 9
9387
#define XTAL32K_P_GPIO_NUM 32
9488
#define XTAL32K_N_GPIO_NUM 33
9589

components/soc/esp32c2/register/soc/io_mux_reg.h

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2017-2022 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2017-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -122,13 +122,6 @@
122122
#define GPIO_PAD_PULLDOWN(num) do{PIN_PULLUP_DIS(IOMUX_REG_GPIO##num);PIN_PULLDWN_EN(IOMUX_REG_GPIO##num);}while(0)
123123
#define GPIO_PAD_SET_DRV(num, drv) PIN_SET_DRV(IOMUX_REG_GPIO##num, drv)
124124

125-
#define SPI_HD_GPIO_NUM 12
126-
#define SPI_WP_GPIO_NUM 13
127-
#define SPI_CS0_GPIO_NUM 14
128-
#define SPI_CLK_GPIO_NUM 15
129-
#define SPI_D_GPIO_NUM 16
130-
#define SPI_Q_GPIO_NUM 17
131-
132125
#define MAX_RTC_GPIO_NUM 5
133126
#define MAX_PAD_GPIO_NUM 20
134127
#define MAX_GPIO_NUM 24

components/soc/esp32c3/register/soc/io_mux_reg.h

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -123,13 +123,6 @@
123123
#define GPIO_PAD_PULLDOWN(num) do{PIN_PULLUP_DIS(IOMUX_REG_GPIO##num);PIN_PULLDWN_EN(IOMUX_REG_GPIO##num);}while(0)
124124
#define GPIO_PAD_SET_DRV(num, drv) PIN_SET_DRV(IOMUX_REG_GPIO##num, drv)
125125

126-
#define SPI_HD_GPIO_NUM 12
127-
#define SPI_WP_GPIO_NUM 13
128-
#define SPI_CS0_GPIO_NUM 14
129-
#define SPI_CLK_GPIO_NUM 15
130-
#define SPI_D_GPIO_NUM 16
131-
#define SPI_Q_GPIO_NUM 17
132-
133126
#define SD_CLK_GPIO_NUM 12
134127
#define SD_CMD_GPIO_NUM 11
135128
#define SD_DATA0_GPIO_NUM 13

components/soc/esp32c5/register/soc/io_mux_reg.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -130,14 +130,6 @@ extern "C" {
130130
#define GPIO_PAD_PULLUP(num) do{PIN_PULLDWN_DIS(IOMUX_REG_GPIO##num);PIN_PULLUP_EN(IOMUX_REG_GPIO##num);}while(0)
131131
#define GPIO_PAD_PULLDOWN(num) do{PIN_PULLUP_DIS(IOMUX_REG_GPIO##num);PIN_PULLDWN_EN(IOMUX_REG_GPIO##num);}while(0)
132132

133-
#define SPI_HD_GPIO_NUM 20
134-
#define SPI_WP_GPIO_NUM 18
135-
#define SPI_CS0_GPIO_NUM 16
136-
#define SPI_CLK_GPIO_NUM 21
137-
#define SPI_D_GPIO_NUM 22
138-
#define SPI_Q_GPIO_NUM 17
139-
#define SPI_CS1_GPIO_NUM 15
140-
141133
#define USB_INT_PHY0_DM_GPIO_NUM 13
142134
#define USB_INT_PHY0_DP_GPIO_NUM 14
143135

components/soc/esp32c6/register/soc/io_mux_reg.h

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -129,13 +129,6 @@
129129
#define GPIO_PAD_PULLDOWN(num) do{PIN_PULLUP_DIS(IOMUX_REG_GPIO##num);PIN_PULLDWN_EN(IOMUX_REG_GPIO##num);}while(0)
130130
#define GPIO_PAD_SET_DRV(num, drv) PIN_SET_DRV(IOMUX_REG_GPIO##num, drv)
131131

132-
#define SPI_HD_GPIO_NUM 28
133-
#define SPI_WP_GPIO_NUM 26
134-
#define SPI_CS0_GPIO_NUM 24
135-
#define SPI_CLK_GPIO_NUM 29
136-
#define SPI_D_GPIO_NUM 30
137-
#define SPI_Q_GPIO_NUM 25
138-
139132
#define SD_CLK_GPIO_NUM 19
140133
#define SD_CMD_GPIO_NUM 18
141134
#define SD_DATA0_GPIO_NUM 20

components/soc/esp32h2/register/soc/io_mux_reg.h

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -148,13 +148,6 @@
148148
#define GPIO_PAD_PULLDOWN(num) do{PIN_PULLUP_DIS(IOMUX_REG_GPIO##num);PIN_PULLDWN_EN(IOMUX_REG_GPIO##num);}while(0)
149149
#define GPIO_PAD_SET_DRV(num, drv) PIN_SET_DRV(IOMUX_REG_GPIO##num, drv)
150150

151-
#define SPI_HD_GPIO_NUM 18
152-
#define SPI_WP_GPIO_NUM 17
153-
#define SPI_CS0_GPIO_NUM 15
154-
#define SPI_CLK_GPIO_NUM 19
155-
#define SPI_D_GPIO_NUM 20
156-
#define SPI_Q_GPIO_NUM 16
157-
158151
#define USB_INT_PHY0_DM_GPIO_NUM 26
159152
#define USB_INT_PHY0_DP_GPIO_NUM 27
160153

components/soc/esp32p4/emac_periph.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ const emac_io_info_t emac_io_idx = {
1616
.mii_tx_clk_i_idx = EMAC_TX_CLK_PAD_IN_IDX,
1717
.mii_tx_en_o_idx = EMAC_PHY_TXEN_PAD_OUT_IDX,
1818
.mii_txd0_o_idx = EMAC_PHY_TXD0_PAD_OUT_IDX,
19-
.mii_txd1_o_idx = EMAC_PHY_TXD0_PAD_OUT_IDX,
20-
.mii_txd2_o_idx = EMAC_PHY_TXD0_PAD_OUT_IDX,
21-
.mii_txd3_o_idx = EMAC_PHY_TXD0_PAD_OUT_IDX,
19+
.mii_txd1_o_idx = EMAC_PHY_TXD1_PAD_OUT_IDX,
20+
.mii_txd2_o_idx = EMAC_PHY_TXD2_PAD_OUT_IDX,
21+
.mii_txd3_o_idx = EMAC_PHY_TXD3_PAD_OUT_IDX,
2222
.mii_rx_clk_i_idx = EMAC_RX_CLK_PAD_IN_IDX,
2323
.mii_rx_dv_i_idx = EMAC_PHY_RXDV_PAD_IN_IDX,
2424
.mii_rxd0_i_idx = EMAC_PHY_RXD0_PAD_IN_IDX,

0 commit comments

Comments
 (0)