|
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 |
@@ -553,23 +562,6 @@ static inline void parlio_ll_tx_set_trans_bit_len(parl_io_dev_t *dev, uint32_t b |
553 | 562 | dev->tx_data_cfg.tx_bitlen = bitlen; |
554 | 563 | } |
555 | 564 |
|
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 | | - |
573 | 565 | /** |
574 | 566 | * @brief Check if tx size can be determined by DMA |
575 | 567 | * |
@@ -621,19 +613,6 @@ static inline void parlio_ll_tx_start(parl_io_dev_t *dev, bool en) |
621 | 613 | dev->tx_start_cfg.tx_start = en; |
622 | 614 | } |
623 | 615 |
|
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 | | - |
637 | 616 | /** |
638 | 617 | * @brief Set the sample clock edge |
639 | 618 | * |
@@ -794,6 +773,62 @@ static inline volatile void *parlio_ll_get_interrupt_status_reg(parl_io_dev_t *d |
794 | 773 | return &dev->int_st; |
795 | 774 | } |
796 | 775 |
|
| 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 | + |
797 | 832 | #ifdef __cplusplus |
798 | 833 | } |
799 | 834 | #endif |
0 commit comments