osi: common: Add API to check if MAC is enabled

Issue: RFE to check MAC enable status.

Fix: Export osi_is_mac_enabled API to check
for MAC status.

Bug 200646286
Bug 200671362

Change-Id: I26575c7c26095de3598197f5b800d3f1610a8bc9
Signed-off-by: Gaurav Asati <gasati@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/kernel/nvethernetrm/+/2397918
(cherry picked from commit a1b24b2524150aa4b3f60cdd00c08f97de875f1c)
Reviewed-on: https://git-master.nvidia.com/r/c/kernel/nvethernetrm/+/2405293
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
Nagarjuna Kristam
2020-08-12 17:17:07 +05:30
committed by Bhadram Varka
parent c7ad3e0e9f
commit 6407375044
8 changed files with 85 additions and 1 deletions

View File

@@ -333,7 +333,7 @@ struct osi_ptp_config {
/** /**
* @brief Max num of MAC core registers to backup. It should be max of or >= * @brief Max num of MAC core registers to backup. It should be max of or >=
* (EQOS_MAX_BAK_IDX=380, MGBE_MAX_BAK_IDX, coreX,...etc) backup registers. * (EQOS_MAX_BAK_IDX=380, coreX,...etc) backup registers.
*/ */
#define CORE_MAX_BAK_IDX 700U #define CORE_MAX_BAK_IDX 700U

View File

@@ -940,4 +940,17 @@ int osi_dma_get_systime_from_mac(
unsigned int *sec, unsigned int *sec,
unsigned int *nsec); unsigned int *nsec);
/**
* @brief osi_is_mac_enabled - Checks if MAC is enabled.
*
* Algorithm: Reads MAC MCR register for Tx and Rx enabled bits.
*
* @param[in] osi_dma: OSI DMA private data structure.
*
* @note MAC should be init and started. see osi_start_mac()
*
* @retval OSI_ENABLE if MAC enabled.
* @retval OSI_DISABLE otherwise.
*/
unsigned int osi_is_mac_enabled(struct osi_dma_priv_data *const osi_dma);
#endif /* OSI_DMA_H */ #endif /* OSI_DMA_H */

View File

@@ -56,3 +56,17 @@ unsigned long long eqos_get_systime_from_mac(void *addr)
return ns; return ns;
} }
unsigned int eqos_is_mac_enabled(void *addr)
{
unsigned int enable = OSI_DISABLE;
unsigned int reg;
reg = osi_readl((unsigned char *)addr + EQOS_MAC_MCR);
if ((reg & (EQOS_MCR_TE | EQOS_MCR_RE)) ==
(EQOS_MCR_TE | EQOS_MCR_RE)) {
enable = OSI_ENABLE;
}
return enable;
}

View File

@@ -34,6 +34,15 @@
#define EQOS_MAC_STNSR_TSSS_MASK 0x7FFFFFFFU #define EQOS_MAC_STNSR_TSSS_MASK 0x7FFFFFFFU
/** @} */ /** @} */
/**
* @brief Common MAC MCR register and its bits
* @{
*/
#define EQOS_MAC_MCR 0x0000
#define EQOS_MCR_TE OSI_BIT(0)
#define EQOS_MCR_RE OSI_BIT(1)
/** @} */
/** /**
* @brief eqos_get_systime - Get system time from MAC * @brief eqos_get_systime - Get system time from MAC
* *
@@ -49,4 +58,18 @@
*/ */
unsigned long long eqos_get_systime_from_mac(void *addr); unsigned long long eqos_get_systime_from_mac(void *addr);
/**
* @brief eqos_is_mac_enabled - Checks if MAC is enabled or not.
*
* Algorithm: Reads MAC MCR register for Tx and Rx enabled bits.
*
* @param[in] addr: Base address indicating the start of
* memory mapped IO region of the MAC.
*
* @note MAC should be init and started. see osi_start_mac()
*
* @retval OSI_ENABLE if MAC enabled.
* @retval OSI_DISABLE otherwise.
*/
unsigned int eqos_is_mac_enabled(void *addr);
#endif /* EQOS_COMMON_H */ #endif /* EQOS_COMMON_H */

View File

@@ -43,4 +43,18 @@
void common_get_systime_from_mac(void *addr, unsigned int mac, void common_get_systime_from_mac(void *addr, unsigned int mac,
unsigned int *sec, unsigned int *nsec); unsigned int *sec, unsigned int *nsec);
/**
* @brief common_is_mac_enabled - Checks if MAC is enabled or not.
*
* Algorithm: Reads MAC register for Tx and Rx enabled bits.
*
* @param[in] addr: Address of base register.
* @param[in] mac: MAC HW type.
*
* @note MAC should be init and started. see osi_start_mac()
*
* @retval OSI_ENABLE if MAC enabled.
* @retval OSI_DISABLE otherwise.
*/
unsigned int common_is_mac_enabled(void *addr, unsigned int mac);
#endif /* LOCAL_COMMON_H */ #endif /* LOCAL_COMMON_H */

View File

@@ -191,3 +191,13 @@ void common_get_systime_from_mac(void *addr, unsigned int mac,
/* do nothing here */ /* do nothing here */
} }
} }
unsigned int common_is_mac_enabled(void *addr, unsigned int mac)
{
if (mac == OSI_MAC_HW_EQOS) {
return eqos_is_mac_enabled(addr);
} else {
/* Non EQOS HW is supported yet */
return OSI_DISABLE;
}
}

View File

@@ -42,3 +42,4 @@ osi_validate_dma_regs
osi_config_slot_function osi_config_slot_function
osi_clear_tx_pkt_err_stats osi_clear_tx_pkt_err_stats
osi_dma_get_systime_from_mac osi_dma_get_systime_from_mac
osi_is_mac_enabled

View File

@@ -426,3 +426,12 @@ int osi_dma_get_systime_from_mac(struct osi_dma_priv_data *const osi_dma,
return 0; return 0;
} }
unsigned int osi_is_mac_enabled(struct osi_dma_priv_data *const osi_dma)
{
if ((osi_dma != OSI_NULL) && (osi_dma->base != OSI_NULL)) {
return common_is_mac_enabled(osi_dma->base, osi_dma->mac);
} else {
return OSI_DISABLE;
}
}