// SPDX-License-Identifier: GPL-2.0+ /* * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. * All rights reserved. * * Purpose: MAC routines * * Author: Tevin Chen * * Date: May 21, 1996 * * Functions: * vt6655_mac_is_reg_bits_off - Test if All test Bits Off * vt6655_mac_set_short_retry_limit - Set 802.11 Short Retry limit * MACvSetLongRetryLimit - Set 802.11 Long Retry limit * vt6655_mac_set_loopback_mode - Set MAC Loopback Mode * vt6655_mac_save_context - Save Context of MAC Registers * vt6655_mac_restore_context - Restore Context of MAC Registers * MACbSoftwareReset - Software Reset MAC * vt6655_mac_safe_rx_off - Turn Off MAC Rx * vt6655_mac_safe_tx_off - Turn Off MAC Tx * vt6655_mac_safe_stop - Stop MAC function * MACbShutdown - Shut down MAC * MACvInitialize - Initialize MAC * MACvSetCurrRxDescAddr - Set Rx Descriptors Address * MACvSetCurrTx0DescAddr - Set Tx0 Descriptors Address * MACvSetCurrTx1DescAddr - Set Tx1 Descriptors Address * MACvTimer0MicroSDelay - Micro Second Delay Loop by MAC * * Revision History: * 08-22-2003 Kyle Hsu : Porting MAC functions from sim53 * 09-03-2003 Bryan YC Fan : Add MACvClearBusSusInd()& * MACvEnableBusSusEn() * 09-18-2003 Jerry Chen : Add MACvSetKeyEntry & MACvDisableKeyEntry * */ #include "mac.h" void vt6655_mac_reg_bits_on(void __iomem *iobase, const u8 reg_offset, const u8 bit_mask) { … } void vt6655_mac_word_reg_bits_on(void __iomem *iobase, const u8 reg_offset, const u16 bit_mask) { … } void vt6655_mac_reg_bits_off(void __iomem *iobase, const u8 reg_offset, const u8 bit_mask) { … } void vt6655_mac_word_reg_bits_off(void __iomem *iobase, const u8 reg_offset, const u16 bit_mask) { … } static void vt6655_mac_clear_stck_ds(void __iomem *iobase) { … } /* * Description: * Test if all test bits off * * Parameters: * In: * io_base - Base Address for MAC * reg_offset - Offset of MAC Register * mask - Test bits * Out: * none * * Return Value: true if all test bits Off; otherwise false * */ static bool vt6655_mac_is_reg_bits_off(struct vnt_private *priv, unsigned char reg_offset, unsigned char mask) { … } /* * Description: * Set 802.11 Short Retry Limit * * Parameters: * In: * io_base - Base Address for MAC * retry_limit - Retry Limit * Out: * none * * Return Value: none * */ void vt6655_mac_set_short_retry_limit(struct vnt_private *priv, unsigned char retry_limit) { … } /* * Description: * Set 802.11 Long Retry Limit * * Parameters: * In: * io_base - Base Address for MAC * byRetryLimit- Retry Limit * Out: * none * * Return Value: none * */ void MACvSetLongRetryLimit(struct vnt_private *priv, unsigned char byRetryLimit) { … } /* * Description: * Set MAC Loopback mode * * Parameters: * In: * io_base - Base Address for MAC * loopback_mode - Loopback Mode * Out: * none * * Return Value: none * */ static void vt6655_mac_set_loopback_mode(struct vnt_private *priv, u8 loopback_mode) { … } /* * Description: * Save MAC registers to context buffer * * Parameters: * In: * io_base - Base Address for MAC * Out: * cxt_buf - Context buffer * * Return Value: none * */ static void vt6655_mac_save_context(struct vnt_private *priv, u8 *cxt_buf) { … } /* * Description: * Restore MAC registers from context buffer * * Parameters: * In: * io_base - Base Address for MAC * cxt_buf - Context buffer * Out: * none * * Return Value: none * */ static void vt6655_mac_restore_context(struct vnt_private *priv, u8 *cxt_buf) { … } /* * Description: * Software Reset MAC * * Parameters: * In: * io_base - Base Address for MAC * Out: * none * * Return Value: true if Reset Success; otherwise false * */ bool MACbSoftwareReset(struct vnt_private *priv) { … } /* * Description: * save some important register's value, then do reset, then restore * register's value * * Parameters: * In: * io_base - Base Address for MAC * Out: * none * * Return Value: true if success; otherwise false * */ static void vt6655_mac_save_soft_reset(struct vnt_private *priv) { … } /* * Description: * Turn Off MAC Rx * * Parameters: * In: * io_base - Base Address for MAC * Out: * none * * Return Value: true if success; otherwise false * */ static bool vt6655_mac_safe_rx_off(struct vnt_private *priv) { … } /* * Description: * Turn Off MAC Tx * * Parameters: * In: * io_base - Base Address for MAC * Out: * none * * Return Value: true if success; otherwise false * */ static bool vt6655_mac_safe_tx_off(struct vnt_private *priv) { … } /* * Description: * Stop MAC function * * Parameters: * In: * io_base - Base Address for MAC * Out: * none * * Return Value: true if success; otherwise false * */ static bool vt6655_mac_safe_stop(struct vnt_private *priv) { … } /* * Description: * Shut Down MAC * * Parameters: * In: * io_base - Base Address for MAC * Out: * none * * Return Value: true if success; otherwise false * */ bool MACbShutdown(struct vnt_private *priv) { … } /* * Description: * Initialize MAC * * Parameters: * In: * io_base - Base Address for MAC * Out: * none * * Return Value: none * */ void MACvInitialize(struct vnt_private *priv) { … } /* * Description: * Set the chip with current rx descriptor address * * Parameters: * In: * io_base - Base Address for MAC * curr_desc_addr - Descriptor Address * Out: * none * * Return Value: none * */ void vt6655_mac_set_curr_rx_0_desc_addr(struct vnt_private *priv, u32 curr_desc_addr) { … } /* * Description: * Set the chip with current rx descriptor address * * Parameters: * In: * io_base - Base Address for MAC * curr_desc_addr - Descriptor Address * Out: * none * * Return Value: none * */ void vt6655_mac_set_curr_rx_1_desc_addr(struct vnt_private *priv, u32 curr_desc_addr) { … } /* * Description: * Set the chip with current tx0 descriptor address * * Parameters: * In: * io_base - Base Address for MAC * curr_desc_addr - Descriptor Address * Out: * none * * Return Value: none * */ static void vt6655_mac_set_curr_tx_0_desc_addr_ex(struct vnt_private *priv, u32 curr_desc_addr) { … } /* * Description: * Set the chip with current AC0 descriptor address * * Parameters: * In: * io_base - Base Address for MAC * curr_desc_addr - Descriptor Address * Out: * none * * Return Value: none * */ /* TxDMA1 = AC0DMA */ static void vt6655_mac_set_curr_ac_0_desc_addr_ex(struct vnt_private *priv, u32 curr_desc_addr) { … } void vt6655_mac_set_curr_tx_desc_addr(int tx_type, struct vnt_private *priv, u32 curr_desc_addr) { … } /* * Description: * Micro Second Delay via MAC * * Parameters: * In: * io_base - Base Address for MAC * uDelay - Delay time (timer resolution is 4 us) * Out: * none * * Return Value: none * */ void MACvTimer0MicroSDelay(struct vnt_private *priv, unsigned int uDelay) { … } /* * Description: * Micro Second One shot timer via MAC * * Parameters: * In: * io_base - Base Address for MAC * uDelay - Delay time * Out: * none * * Return Value: none * */ void MACvOneShotTimer1MicroSec(struct vnt_private *priv, unsigned int uDelayTime) { … } void MACvSetMISCFifo(struct vnt_private *priv, unsigned short offset, u32 data) { … } bool MACbPSWakeup(struct vnt_private *priv) { … } /* * Description: * Set the Key by MISCFIFO * * Parameters: * In: * io_base - Base Address for MAC * * Out: * none * * Return Value: none * */ void MACvSetKeyEntry(struct vnt_private *priv, unsigned short wKeyCtl, unsigned int uEntryIdx, unsigned int uKeyIdx, unsigned char *pbyAddr, u32 *pdwKey, unsigned char local_id) { … } /* * Description: * Disable the Key Entry by MISCFIFO * * Parameters: * In: * io_base - Base Address for MAC * * Out: * none * * Return Value: none * */ void MACvDisableKeyEntry(struct vnt_private *priv, unsigned int uEntryIdx) { … }