Skip to content

Commit 0da7604

Browse files
committed
Merge branch 'feat/support_weight_arbitration_on_c61' into 'master'
feat(gdma): support gdma weighted arbitration on c61 v1.0 Closes IDF-12882, IDF-9310, and IDF-12090 See merge request espressif/esp-idf!39710
2 parents 974f571 + f3f6bc9 commit 0da7604

File tree

5 files changed

+112
-89
lines changed

5 files changed

+112
-89
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
CONFIG_SPIRAM=y
2+
CONFIG_SPIRAM_SPEED_80M=y

components/hal/esp32c61/include/hal/ahb_dma_ll.h

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -22,6 +22,7 @@ extern "C" {
2222
#define AHB_DMA_LL_GET_HW(id) (((id) == 0) ? (&AHB_DMA) : NULL)
2323

2424
#define GDMA_LL_CHANNEL_MAX_PRIORITY 5 // supported priority levels: [0,5]
25+
#define GDMA_LL_CHANNEL_MAX_WEIGHT 15 // supported weight levels: [0,15]
2526

2627
#define GDMA_LL_RX_EVENT_MASK (0x7F)
2728
#define GDMA_LL_TX_EVENT_MASK (0x3F)
@@ -130,6 +131,25 @@ static inline void ahb_dma_ll_set_default_memory_range(ahb_dma_dev_t *dev)
130131
dev->intr_mem_end_addr.val = 0x44000000;
131132
}
132133

134+
/**
135+
* @brief Enable the weighted arbitration for AHB-DMA
136+
*/
137+
static inline void ahb_dma_ll_enable_weighted_arb(ahb_dma_dev_t *dev, bool enable)
138+
{
139+
dev->weight_en.weight_en = enable;
140+
}
141+
142+
/**
143+
* @brief Set the weighted arbitration timeout for AHB-DMA
144+
*
145+
* @param timeout AHB bus clock cycle
146+
*/
147+
static inline void ahb_dma_ll_set_weighted_arb_timeout(ahb_dma_dev_t *dev, uint32_t timeout)
148+
{
149+
HAL_ASSERT(timeout != 0 && timeout <= 65535);
150+
dev->arb_timeout.arb_timeout_num = timeout;
151+
}
152+
133153
///////////////////////////////////// RX /////////////////////////////////////////
134154
/**
135155
* @brief Get DMA RX channel interrupt status word
@@ -212,6 +232,9 @@ static inline void ahb_dma_ll_rx_set_burst_size(ahb_dma_dev_t *dev, uint32_t cha
212232
case 32:
213233
burst_mode = 2; // incr8
214234
break;
235+
case 64:
236+
burst_mode = 3; // incr16
237+
break;
215238
default:
216239
HAL_ASSERT(false);
217240
break;
@@ -380,6 +403,22 @@ static inline void ahb_dma_ll_rx_enable_etm_task(ahb_dma_dev_t *dev, uint32_t ch
380403
dev->channel[channel].in.in_conf0.in_etm_en_chn = enable;
381404
}
382405

406+
/**
407+
* @brief Enable the weighted arbitration optimize for DMA RX channel
408+
*/
409+
static inline void ahb_dma_ll_rx_enable_weighted_arb_opt(ahb_dma_dev_t *dev, uint32_t channel, bool enable)
410+
{
411+
dev->in_crc_arb[channel].arb_weight_opt.rx_arb_weight_opt_dis_chn = !enable;
412+
}
413+
414+
/**
415+
* @brief Set the weight for DMA RX channel
416+
*/
417+
static inline void ahb_dma_ll_rx_set_weight(ahb_dma_dev_t *dev, uint32_t channel, uint32_t weight)
418+
{
419+
dev->in_crc_arb[channel].ch_arb_weight.rx_arb_weight_value_chn = weight;
420+
}
421+
383422
///////////////////////////////////// TX /////////////////////////////////////////
384423
/**
385424
* @brief Get DMA TX channel interrupt status word
@@ -462,6 +501,9 @@ static inline void ahb_dma_ll_tx_set_burst_size(ahb_dma_dev_t *dev, uint32_t cha
462501
case 32:
463502
burst_mode = 2; // incr8
464503
break;
504+
case 64:
505+
burst_mode = 3; // incr16
506+
break;
465507
default:
466508
HAL_ASSERT(false);
467509
break;
@@ -628,6 +670,22 @@ static inline void ahb_dma_ll_tx_enable_etm_task(ahb_dma_dev_t *dev, uint32_t ch
628670
dev->channel[channel].out.out_conf0.out_etm_en_chn = enable;
629671
}
630672

673+
/**
674+
* @brief Enable the weighted arbitration optimize for DMA TX channel
675+
*/
676+
static inline void ahb_dma_ll_tx_enable_weighted_arb_opt(ahb_dma_dev_t *dev, uint32_t channel, bool enable)
677+
{
678+
dev->out_crc_arb[channel].arb_weight_opt.tx_arb_weight_opt_dis_chn = !enable;
679+
}
680+
681+
/**
682+
* @brief Set the weight for DMA TX channel
683+
*/
684+
static inline void ahb_dma_ll_tx_set_weight(ahb_dma_dev_t *dev, uint32_t channel, uint32_t weight)
685+
{
686+
dev->out_crc_arb[channel].ch_arb_weight.tx_arb_weight_value_chn = weight;
687+
}
688+
631689
#ifdef __cplusplus
632690
}
633691
#endif

components/soc/esp32c61/include/soc/Kconfig.soc_caps.in

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,14 @@ config SOC_GDMA_SUPPORT_SLEEP_RETENTION
367367
bool
368368
default y
369369

370+
config SOC_AHB_GDMA_SUPPORT_PSRAM
371+
bool
372+
default y
373+
374+
config SOC_GDMA_SUPPORT_WEIGHTED_ARBITRATION
375+
bool
376+
default y
377+
370378
config SOC_ETM_GROUPS
371379
int
372380
default 1
@@ -779,6 +787,10 @@ config SOC_SPIRAM_XIP_SUPPORTED
779787
bool
780788
default y
781789

790+
config SOC_PSRAM_DMA_CAPABLE
791+
bool
792+
default y
793+
782794
config SOC_SPI_MEM_SUPPORT_AUTO_WAIT_IDLE
783795
bool
784796
default y

components/soc/esp32c61/include/soc/soc_caps.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,8 @@
152152
#define SOC_GDMA_PAIRS_PER_GROUP_MAX 2
153153
#define SOC_GDMA_SUPPORT_ETM 1 // Support ETM submodule
154154
#define SOC_GDMA_SUPPORT_SLEEP_RETENTION 1
155+
#define SOC_AHB_GDMA_SUPPORT_PSRAM 1
156+
#define SOC_GDMA_SUPPORT_WEIGHTED_ARBITRATION 1
155157

156158
/*-------------------------- ETM CAPS --------------------------------------*/
157159
#define SOC_ETM_GROUPS 1U // Number of ETM groups
@@ -335,6 +337,7 @@
335337

336338
/*-------------------------- SPIRAM CAPS ----------------------------------------*/
337339
#define SOC_SPIRAM_XIP_SUPPORTED 1
340+
#define SOC_PSRAM_DMA_CAPABLE 1
338341

339342
/*-------------------------- SPI MEM CAPS ---------------------------------------*/
340343
#define SOC_SPI_MEM_SUPPORT_AUTO_WAIT_IDLE (1)

components/soc/esp32c61/register/soc/ahb_dma_struct.h

Lines changed: 36 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -1050,117 +1050,61 @@ typedef union {
10501050
uint32_t val;
10511051
} ahb_dma_out_done_des_addr_ch1_reg_t;
10521052

1053-
/** Type of tx_ch_arb_weight_ch0 register
1054-
* TX channel 0 arbitration weight configuration register
1053+
/** Type of tx_ch_arb_weight_chn register
1054+
* TX channel n arbitration weight configuration register
10551055
*/
10561056
typedef union {
10571057
struct {
1058-
/** tx_arb_weight_value_ch0 : R/W; bitpos: [3:0]; default: 0;
1058+
/** tx_arb_weight_value_chn : R/W; bitpos: [3:0]; default: 0;
10591059
* Configures the weight(i.e the number of tokens) of TX channel0
10601060
*/
1061-
uint32_t tx_arb_weight_value_ch0:4;
1061+
uint32_t tx_arb_weight_value_chn:4;
10621062
uint32_t reserved_4:28;
10631063
};
10641064
uint32_t val;
1065-
} ahb_dma_tx_ch_arb_weight_ch0_reg_t;
1065+
} ahb_dma_tx_ch_arb_weight_chn_reg_t;
10661066

1067-
/** Type of tx_arb_weight_opt_dir_ch0 register
1068-
* TX channel 0 weight arbitration optimization enable register
1067+
/** Type of tx_arb_weight_opt_dir_chn register
1068+
* TX channel n weight arbitration optimization enable register
10691069
*/
10701070
typedef union {
10711071
struct {
1072-
/** tx_arb_weight_opt_dis_ch0 : R/W; bitpos: [0]; default: 0;
1072+
/** tx_arb_weight_opt_dis_chn : R/W; bitpos: [0]; default: 0;
10731073
* reserved
10741074
*/
1075-
uint32_t tx_arb_weight_opt_dis_ch0:1;
1075+
uint32_t tx_arb_weight_opt_dis_chn:1;
10761076
uint32_t reserved_1:31;
10771077
};
10781078
uint32_t val;
1079-
} ahb_dma_tx_arb_weight_opt_dir_ch0_reg_t;
1079+
} ahb_dma_tx_arb_weight_opt_dir_chn_reg_t;
10801080

1081-
/** Type of tx_ch_arb_weight_ch1 register
1082-
* TX channel 1 arbitration weight configuration register
1081+
/** Type of rx_ch_arb_weight_chn register
1082+
* RX channel n arbitration weight configuration register
10831083
*/
10841084
typedef union {
10851085
struct {
1086-
/** tx_arb_weight_value_ch1 : R/W; bitpos: [3:0]; default: 0;
1087-
* Configures the weight(i.e the number of tokens) of TX channel1
1088-
*/
1089-
uint32_t tx_arb_weight_value_ch1:4;
1090-
uint32_t reserved_4:28;
1091-
};
1092-
uint32_t val;
1093-
} ahb_dma_tx_ch_arb_weight_ch1_reg_t;
1094-
1095-
/** Type of tx_arb_weight_opt_dir_ch1 register
1096-
* TX channel 1 weight arbitration optimization enable register
1097-
*/
1098-
typedef union {
1099-
struct {
1100-
/** tx_arb_weight_opt_dis_ch1 : R/W; bitpos: [0]; default: 0;
1101-
* reserved
1102-
*/
1103-
uint32_t tx_arb_weight_opt_dis_ch1:1;
1104-
uint32_t reserved_1:31;
1105-
};
1106-
uint32_t val;
1107-
} ahb_dma_tx_arb_weight_opt_dir_ch1_reg_t;
1108-
1109-
/** Type of rx_ch_arb_weight_ch0 register
1110-
* RX channel 0 arbitration weight configuration register
1111-
*/
1112-
typedef union {
1113-
struct {
1114-
/** rx_arb_weight_value_ch0 : R/W; bitpos: [3:0]; default: 0;
1086+
/** rx_arb_weight_value_chn : R/W; bitpos: [3:0]; default: 0;
11151087
* Configures the weight(i.e the number of tokens) of RX channel0
11161088
*/
1117-
uint32_t rx_arb_weight_value_ch0:4;
1118-
uint32_t reserved_4:28;
1119-
};
1120-
uint32_t val;
1121-
} ahb_dma_rx_ch_arb_weight_ch0_reg_t;
1122-
1123-
/** Type of rx_arb_weight_opt_dir_ch0 register
1124-
* RX channel 0 weight arbitration optimization enable register
1125-
*/
1126-
typedef union {
1127-
struct {
1128-
/** rx_arb_weight_opt_dis_ch0 : R/W; bitpos: [0]; default: 0;
1129-
* reserved
1130-
*/
1131-
uint32_t rx_arb_weight_opt_dis_ch0:1;
1132-
uint32_t reserved_1:31;
1133-
};
1134-
uint32_t val;
1135-
} ahb_dma_rx_arb_weight_opt_dir_ch0_reg_t;
1136-
1137-
/** Type of rx_ch_arb_weight_ch1 register
1138-
* RX channel 1 arbitration weight configuration register
1139-
*/
1140-
typedef union {
1141-
struct {
1142-
/** rx_arb_weight_value_ch1 : R/W; bitpos: [3:0]; default: 0;
1143-
* Configures the weight(i.e the number of tokens) of RX channel1
1144-
*/
1145-
uint32_t rx_arb_weight_value_ch1:4;
1089+
uint32_t rx_arb_weight_value_chn:4;
11461090
uint32_t reserved_4:28;
11471091
};
11481092
uint32_t val;
1149-
} ahb_dma_rx_ch_arb_weight_ch1_reg_t;
1093+
} ahb_dma_rx_ch_arb_weight_chn_reg_t;
11501094

1151-
/** Type of rx_arb_weight_opt_dir_ch1 register
1152-
* RX channel 1 weight arbitration optimization enable register
1095+
/** Type of rx_arb_weight_opt_dir_chn register
1096+
* RX channel n weight arbitration optimization enable register
11531097
*/
11541098
typedef union {
11551099
struct {
1156-
/** rx_arb_weight_opt_dis_ch1 : R/W; bitpos: [0]; default: 0;
1100+
/** rx_arb_weight_opt_dis_chn : R/W; bitpos: [0]; default: 0;
11571101
* reserved
11581102
*/
1159-
uint32_t rx_arb_weight_opt_dis_ch1:1;
1103+
uint32_t rx_arb_weight_opt_dis_chn:1;
11601104
uint32_t reserved_1:31;
11611105
};
11621106
uint32_t val;
1163-
} ahb_dma_rx_arb_weight_opt_dir_ch1_reg_t;
1107+
} ahb_dma_rx_arb_weight_opt_dir_chn_reg_t;
11641108

11651109
/** Type of in_link_addr_chn register
11661110
* Link list descriptor address configuration of RX channel 0
@@ -1453,6 +1397,18 @@ typedef struct {
14531397
uint32_t reserved_out[7];
14541398
} ahb_dma_chn_reg_t;
14551399

1400+
typedef struct {
1401+
uint32_t reserved[8];
1402+
ahb_dma_tx_ch_arb_weight_chn_reg_t ch_arb_weight;
1403+
ahb_dma_tx_arb_weight_opt_dir_chn_reg_t arb_weight_opt;
1404+
} ahb_dma_out_crc_arb_chn_reg_t;
1405+
1406+
typedef struct {
1407+
uint32_t reserved[8];
1408+
ahb_dma_rx_ch_arb_weight_chn_reg_t ch_arb_weight;
1409+
ahb_dma_rx_arb_weight_opt_dir_chn_reg_t arb_weight_opt;
1410+
} ahb_dma_in_crc_arb_chn_reg_t;
1411+
14561412
typedef struct {
14571413
volatile ahb_dma_in_int_chn_reg_t in_intr[2];
14581414
uint32_t reserved_020[4];
@@ -1463,18 +1419,10 @@ typedef struct {
14631419
volatile ahb_dma_date_reg_t date;
14641420
uint32_t reserved_06c;
14651421
volatile ahb_dma_chn_reg_t channel[2];
1466-
uint32_t reserved_1db[59];
1467-
volatile ahb_dma_tx_ch_arb_weight_ch0_reg_t tx_ch_arb_weight_ch0;
1468-
volatile ahb_dma_tx_arb_weight_opt_dir_ch0_reg_t tx_arb_weight_opt_dir_ch0;
1469-
uint32_t reserved_2e4[8];
1470-
volatile ahb_dma_tx_ch_arb_weight_ch1_reg_t tx_ch_arb_weight_ch1;
1471-
volatile ahb_dma_tx_arb_weight_opt_dir_ch1_reg_t tx_arb_weight_opt_dir_ch1;
1472-
uint32_t reserved_30c[18];
1473-
volatile ahb_dma_rx_ch_arb_weight_ch0_reg_t rx_ch_arb_weight_ch0;
1474-
volatile ahb_dma_rx_arb_weight_opt_dir_ch0_reg_t rx_arb_weight_opt_dir_ch0;
1475-
uint32_t reserved_35c[8];
1476-
volatile ahb_dma_rx_ch_arb_weight_ch1_reg_t rx_ch_arb_weight_ch1;
1477-
volatile ahb_dma_rx_arb_weight_opt_dir_ch1_reg_t rx_arb_weight_opt_dir_ch1;
1422+
uint32_t reserved_1db[51];
1423+
volatile ahb_dma_out_crc_arb_chn_reg_t out_crc_arb[2];
1424+
uint32_t reserved_30c[10];
1425+
volatile ahb_dma_in_crc_arb_chn_reg_t in_crc_arb[2];
14781426
uint32_t reserved_384[10];
14791427
volatile ahb_dma_in_link_addr_chn_reg_t in_link_addr[2];
14801428
uint32_t reserved_3b4;

0 commit comments

Comments
 (0)