⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 if_cf.h

📁 marvell cf wifi driver source code CF-8385-linux-x86-5.0.4.p0-132-src.rar
💻 H
字号:
/**************************************************************************
 * Module:  if_cf.h
 * Description: Header file for the compact flash interface.
 *    Contains data definitions and prototypes that define 
 *    one instance of the  compact flash interface.
 * Copyright(c) 2003, Marvell Semiconductor Inc. All rights reserved.
 *************************************************************************/

#ifndef _IF_CF_H_
#define _IF_CF_H_

#include  "cfio_io.h"

#include "if_cfmacreg.h"
#include "if_ixstatus.h"

#if NOT_REQUIRED
//-----------------------------------------------------------------------------
// This structure defines a compact flash interface object. An instance of
// this structure will be passed to all calls in the CF interace.
//-----------------------------------------------------------------------------
typedef struct {
  u32 ulSignatureTop; // CF object top signature.
  // Nothing above this data.
  u16 base_addr;
  u16 cfHostIntMask;  // Current device interrupt mask.

  //----------------------------------------------------
  // Transmit related members
  //----------------------------------------------------
  BOOLEAN bTxPacketOpen;  // Set if TX packet is open.
  u32 ulTxPacketSize; // size in bytes of current packet.
  u32 ulTxPacketByteCount;  // number of bytes transmitted in
  // current tx packet.

  //----------------------------------------------------
  // Receive related members
  //----------------------------------------------------
  BOOLEAN bRxPacketOpen;  // Set if RX packet is open.
  u32 ulRxPacketSize; // size of current receive packet.
  u32 ulRxPacketByteCount;  // number of bytes transmitted in
  // current RX packet.
  u32 ulSignatureBottom;  // CF object bottom signature.
  // Nothing below this.
} CF_OBJECT, *PCF_OBJECT;

#endif  //NOT_REQUIRED

/**************************************************************************
 * Function:  cf_UshortRegSetBits
 * Description: Sets bits set in mask passed in the u16 register
 *    specified by offset passed in.
 * Returns: IX_STATUS_SUCCESS if device is ready.
 *    IX_STATUS_DEVICE_BUSY if not.
 *************************************************************************/
static inline void cf_UshortRegSetBits(wlan_private *priv,
          u16 regOffset, u16 mask)
{
  ENTER();

  /* Set the bit in host status to indicate cmd download is complete */
  if (((struct cf_card_rec *)(priv->wlan_dev.card))->do_read_modify_write == 0)
  {
    outw(mask,
      priv->wlan_dev.netdev->base_addr + regOffset);
  }
  else
  {
    outw(inw(priv->wlan_dev.netdev->base_addr + regOffset) | mask,
      priv->wlan_dev.netdev->base_addr + regOffset);
  }

  LEAVE();
}

/**************************************************************************
 * Function:    cf_IsRxUploadReady
 * Description:   Polls device to see if RxUpLdRdy bit is set.
 * Returns:   SUCCESS if device is ready for a receive data transfer. 
 *                     DEVICE_BUSY if not.
 *************************************************************************/
static inline IX_STATUS cf_IsRxUploadReady(wlan_private *priv)
{
  u16 usval;

  usval = inw(priv->wlan_dev.netdev->base_addr+CF_CCR_CARD_STATUS);
  return (usval & CF_HCR_HIM_RxUpLdRdy) ?
        IX_STATUS_SUCCESS : IX_STATUS_NO_DATA;
}

/**************************************************************************
 * Function:    cf_IsCmdReady
 * Description:   Polls cmd ready bit to see if device is ready.
 * Returns:   IX_STATUS_SUCCESS if device is ready.
 *      IX_STATUS_DEVICE_BUSY if not.
 *************************************************************************/
static inline IX_STATUS cf_IsCmdReady(wlan_private *priv)
{
  u16 usval;

  usval = inw(priv->wlan_dev.netdev->base_addr+CF_CCR_CARD_STATUS);
  return (usval & CF_HCR_HIM_CmdDnLdRdy) ? IX_STATUS_SUCCESS :
            IX_STATUS_DEVICE_BUSY;
}

/*************************************************************************
 * Function:    cf_IsRespReady
 * Description:   Polls device to see if the device has a cmd response
 *      waiting.
 * Returns:   IX_STATUS_SUCCESS if device has response ready. 
 *      IX_STATUS_NO_RESP if not.
 *************************************************************************/
static inline IX_STATUS cf_IsRespReady(wlan_private *priv)
{
  u16 usval;

  usval = inw(priv->wlan_dev.netdev->base_addr+CF_CCR_CARD_STATUS);
  return (usval & CF_HCR_HIM_CmdRspRdy) ? IX_STATUS_SUCCESS :
      IX_STATUS_NO_RESP;
}

/*************************************************************************
 * Function:    cf_RxStartPacket
 * Description:   Checks if packet is available, if so reads and
 *      returns packet length.
 * Returns:   DEVICE_BUSY if device busy, SUCCESS otherwise
 *************************************************************************/
static inline IX_STATUS cf_RxStartPacket(wlan_private *priv,
           u16 * rxPacketLength)
{
  ENTER();
#if 0
  /* not convinced with this check need more clarifications
   * to uncommnet MPS
   */
  // First check if there is data available. 
  // If not then return status indicating so.
  if (cf_IsRxUploadReady(priv) != IX_STATUS_SUCCESS) {
    PRINTK("ERROR: Device has no data waiting\n");
    return IX_STATUS_NO_DATA;
  }
#endif

  // Read the receive packet length: This tells device we are getting
  // ready to read the current packet.
  *rxPacketLength = inw(priv->wlan_dev.netdev->base_addr + 
            CF_CCR_IO_READ_LEN);

  PRINTK("Rx Packet Length = %d bytes\n", *rxPacketLength);

  return IX_STATUS_SUCCESS;
}

/*************************************************************************
 * Function:  cf_RxEndPacket
 * Description: Ends download of current packet by setting the host status 
 *    RxUpLdOver bit and and setting the card interrupt cause 
 *    for RxUpLdOver so card can generate internal interrupt.
 * NOTE:  This routine can be called at anytime on an open packet to 
 *    either end a packet whose data has been read, or to discard 
 *    packet data without actually reading in any or all of the 
 *    receive packet.
 * Returns: void
 *************************************************************************/
static inline void cf_RxEndPacket(wlan_private *priv)
{
  static u32 rxPacketCnt = 0;

  rxPacketCnt++;

  // Set the CF_HCR_HS_RxUpLdOvr bit in the host status register.
  cf_UshortRegSetBits(priv, CF_HCR_HOST_STATUS,
          CF_HCR_HS_RxUpLdOvr);

  // Set CF_HCR_CIC_TxDnLdOvr bit in the interrupt cause register.
  // This triggers an interrupt in the card FW.
  cf_UshortRegSetBits(priv, CF_HCR_CARD_INT_CAUSE,
          CF_HCR_CIC_RxUpLdOvr);
}

/**************************************************************************
 * Function:  cf_KickstartRX
 * Description: Fire off bogus int to start up RX in firmware
 * Returns: void
 *************************************************************************/
static inline void cf_KickstartRX(wlan_private *priv)
{
  // Set the CF_HCR_HS_RxUpLdOvr bit in the host status register.
  cf_UshortRegSetBits(priv, CF_HCR_HOST_STATUS,
          CF_HCR_HS_RxUpLdOvr);

  // Set CF_HCR_CIC_RxUpLdOvr bit in interrupt cause register.
  // This triggers an interrupt in the card FW.
  cf_UshortRegSetBits(priv, CF_HCR_CARD_INT_CAUSE,
          CF_HCR_CIC_RxUpLdOvr);
}

/**************************************************************************
 * Function:  cf_IsTxDownloadReady
 * Description: Polls device to see if TxDnLdRdy is set.
 * Returns: IX_STATUS_SUCCESS if device is ready for tx download. 
 *    IX_STATUS_DEVICE_BUSY if not.
 *************************************************************************/
static inline IX_STATUS cf_IsTxDownloadReady(wlan_private *priv)
{
  u16 usval;

  usval = inw(priv->wlan_dev.netdev->base_addr+CF_CCR_CARD_STATUS);
  
  if (usval & CF_CCR_CS_TxDnLdRdy) {
    PRINTK("Card Status indicates TxDnLdRdy\n");
    return IX_STATUS_SUCCESS;
  } else {
    PRINTK("Tx Download not ready, CSR = %x\n", usval);
    // Retrigger the send, FW may have missed the interrupt
    // Set the CF_HCR_HS_TxDnLdOvr bit in the host
    // status register.
    cf_UshortRegSetBits(priv, CF_HCR_HOST_STATUS,
                CF_HCR_HS_TxDnLdOvr);

    // Set the CF_HCR_CIC_TxDnLdOvr bit in the
    // interrupt cause register.This triggers an interrupt
    // in the card FW.
    cf_UshortRegSetBits(priv, CF_HCR_CARD_INT_CAUSE,
                CF_HCR_CIC_TxDnLdOvr);
  }
  
  return IX_STATUS_DEVICE_BUSY;
}

#endif  /* _IF_CF_H_ */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -