|
14 | 14 | #include "hal/misc.h" |
15 | 15 | #include "hal/parlio_types.h" |
16 | 16 | #include "hal/hal_utils.h" |
| 17 | +#include "hal/config.h" |
17 | 18 | #include "soc/hp_sys_clkrst_struct.h" |
18 | 19 | #include "soc/lp_clkrst_struct.h" |
19 | 20 | #include "soc/parl_io_struct.h" |
|
33 | 34 | #define PARLIO_LL_EVENT_TX_MASK (PARLIO_LL_EVENT_TX_FIFO_EMPTY | PARLIO_LL_EVENT_TX_EOF) |
34 | 35 | #define PARLIO_LL_EVENT_RX_MASK (PARLIO_LL_EVENT_RX_FIFO_FULL) |
35 | 36 |
|
| 37 | + |
| 38 | +#if HAL_CONFIG(CHIP_SUPPORT_MIN_REV) < 300 |
36 | 39 | #define PARLIO_LL_TX_DATA_LINE_AS_VALID_SIG 15 // TXD[15] can be used a valid signal |
| 40 | +#endif |
| 41 | + |
37 | 42 | #define PARLIO_LL_TX_DATA_LINE_AS_CLK_GATE 15 // TXD[15] can be used as clock gate signal |
38 | 43 |
|
| 44 | +#if HAL_CONFIG(CHIP_SUPPORT_MIN_REV) >= 300 |
| 45 | +#define PARLIO_LL_TX_VALID_MAX_DELAY 32767 |
| 46 | +#endif |
| 47 | + |
39 | 48 | #ifdef __cplusplus |
40 | 49 | extern "C" { |
41 | 50 | #endif |
@@ -523,23 +532,6 @@ static inline void parlio_ll_tx_set_trans_bit_len(parl_io_dev_t *dev, uint32_t b |
523 | 532 | dev->tx_data_cfg.tx_bitlen = bitlen; |
524 | 533 | } |
525 | 534 |
|
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 | | - |
543 | 535 | /** |
544 | 536 | * @brief Check if tx size can be determined by DMA |
545 | 537 | * |
@@ -591,19 +583,6 @@ static inline void parlio_ll_tx_start(parl_io_dev_t *dev, bool en) |
591 | 583 | dev->tx_start_cfg.tx_start = en; |
592 | 584 | } |
593 | 585 |
|
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 | | - |
607 | 586 | /** |
608 | 587 | * @brief Set the sample clock edge |
609 | 588 | * |
@@ -764,6 +743,62 @@ static inline volatile void *parlio_ll_get_interrupt_status_reg(parl_io_dev_t *d |
764 | 743 | return &dev->int_st; |
765 | 744 | } |
766 | 745 |
|
| 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 | + |
767 | 802 | #ifdef __cplusplus |
768 | 803 | } |
769 | 804 | #endif |
0 commit comments