?? rtusb_io.c
字號:
/*
***************************************************************************
* Ralink Tech Inc.
* 4F, No. 2 Technology 5th Rd.
* Science-based Industrial Park
* Hsin-chu, Taiwan, R.O.C.
*
* (c) Copyright 2002-2004, Ralink Technology, Inc.
*
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
************************************************************************
Module Name:
rtusb_io.c
Abstract:
Revision History:
Who When What
-------- ---------- ----------------------------------------------
Name Date Modification logs
Jan Lee 2005-06-01 Release
*/
#include "rt_config.h"
/*
========================================================================
Routine Description:
Arguments:
Return Value:
IRQL =
Note:
========================================================================
*/
NTSTATUS RTUSBSingleRead(
IN PRT2570ADAPTER pAdapter,
IN USHORT Offset,
OUT PUSHORT pValue)
{
NTSTATUS Status;
Status = RTUSB_VendorRequest(
pAdapter,
0,
DEVICE_VENDOR_REQUEST_IN,
0x3,
0,
Offset,
pValue,
2);
return Status;
}
/*
========================================================================
Routine Description:
Arguments:
Return Value:
IRQL =
Note:
========================================================================
*/
NTSTATUS RTUSBSingleWrite(
IN PRT2570ADAPTER pAdapter,
IN USHORT Offset,
IN USHORT Value)
{
NTSTATUS Status;
Status = RTUSB_VendorRequest(
pAdapter,
0,
DEVICE_VENDOR_REQUEST_OUT,
0x2,
Value,
Offset,
NULL,
0);
return Status;
}
/*
========================================================================
Routine Description:
Arguments:
Return Value:
IRQL =
Note:
========================================================================
*/
NTSTATUS RTUSBMultiRead(
IN PRT2570ADAPTER pAdapter,
IN USHORT Offset,
OUT PUCHAR pData,
IN USHORT length)
{
NTSTATUS Status;
Status = RTUSB_VendorRequest(
pAdapter,
0,
DEVICE_VENDOR_REQUEST_IN,
0x7,
0,
Offset,
pData,
length);
return Status;
}
/*
========================================================================
Routine Description:
Arguments:
Return Value:
IRQL =
Note:
========================================================================
*/
NTSTATUS RTUSBMultiWrite(
IN PRT2570ADAPTER pAdapter,
IN USHORT Offset,
IN PUCHAR pData,
IN USHORT length)
{
NTSTATUS Status;
Status = RTUSB_VendorRequest(
pAdapter,
0,
DEVICE_VENDOR_REQUEST_OUT,
0x6,
0,
Offset,
pData,
length);
return Status;
}
/*
========================================================================
Routine Description:
Arguments:
Return Value:
IRQL =
Note:
========================================================================
*/
NTSTATUS RTUSBReadMACRegister(
IN PRT2570ADAPTER pAdapter,
IN USHORT Offset,
OUT PUSHORT pValue)
{
NTSTATUS Status;
Status = RTUSB_VendorRequest(
pAdapter,
0,
DEVICE_VENDOR_REQUEST_IN,
0x3,
0,
Offset + 0x400,
pValue,
2);
return Status;
}
/*
========================================================================
Routine Description:
Arguments:
Return Value:
IRQL =
Note:
========================================================================
*/
NTSTATUS RTUSBWriteMACRegister(
IN PRT2570ADAPTER pAdapter,
IN USHORT Offset,
IN USHORT Value)
{
NTSTATUS Status;
if (Offset == TXRX_CSR2)
DBGPRINT(RT_DEBUG_ERROR, " !!!!!set Rx control = %x\n", Value);
Status = RTUSB_VendorRequest(
pAdapter,
0,
DEVICE_VENDOR_REQUEST_OUT,
0x2,
Value,
Offset + 0x400,
NULL,
0);
return Status;
}
/*
========================================================================
Routine Description:
Arguments:
Return Value:
IRQL =
Note:
========================================================================
*/
NTSTATUS RTUSBMultiReadMAC(
IN PRT2570ADAPTER pAdapter,
IN USHORT Offset,
OUT PUCHAR pData,
IN USHORT length)
{
NTSTATUS Status;
Status = RTUSB_VendorRequest(
pAdapter,
0,
DEVICE_VENDOR_REQUEST_IN,
0x7,
0,
Offset + 0x400,
pData,
length);
return Status;
}
/*
========================================================================
Routine Description:
Arguments:
Return Value:
IRQL =
Note:
========================================================================
*/
NTSTATUS RTUSBMultiWriteMAC(
IN PRT2570ADAPTER pAdapter,
IN USHORT Offset,
IN PUCHAR pData,
IN USHORT length)
{
NTSTATUS Status;
Status = RTUSB_VendorRequest(
pAdapter,
0,
DEVICE_VENDOR_REQUEST_OUT,
0x6,
0,
Offset + 0x400,
pData,
length);
return Status;
}
/*
========================================================================
Routine Description:
Arguments:
Return Value:
IRQL =
Note:
========================================================================
*/
NTSTATUS RTUSBReadBBPRegister(
IN PRT2570ADAPTER pAdapter,
IN UCHAR Id,
IN PUCHAR pValue)
{
PHY_CSR7_STRUC PhyCsr7;
USHORT temp;
UINT i = 0;
if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_REMOVE_IN_PROGRESS))
{
DBGPRINT(RT_DEBUG_ERROR,"device connected\n");
return -1;
}
PhyCsr7.value = 0;
PhyCsr7.field.WriteControl = 1;
PhyCsr7.field.RegID = Id;
RTUSBWriteMACRegister(pAdapter, PHY_CSR7, PhyCsr7.value);
do
{
RTUSBReadMACRegister(pAdapter, PHY_CSR8, &temp);
if (!(temp & BUSY))
break;
i++;
}
while ((i < RETRY_LIMIT) && (!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_REMOVE_IN_PROGRESS)));
if ((i == RETRY_LIMIT) || (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_REMOVE_IN_PROGRESS)))
{
DBGPRINT_RAW(RT_DEBUG_ERROR, "Retry count exhausted or device removed!!!\n");
return STATUS_UNSUCCESSFUL;
}
RTUSBReadMACRegister(pAdapter, PHY_CSR7, (PUSHORT)&PhyCsr7);
*pValue = (UCHAR)PhyCsr7.field.Data;
return STATUS_SUCCESS;
}
/*
========================================================================
Routine Description:
Arguments:
Return Value:
IRQL =
Note:
========================================================================
*/
NTSTATUS RTUSBWriteBBPRegister(
IN PRT2570ADAPTER pAdapter,
IN UCHAR Id,
IN UCHAR Value)
{
PHY_CSR7_STRUC PhyCsr7;
USHORT temp;
UINT i = 0;
if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_REMOVE_IN_PROGRESS))
{
DBGPRINT(RT_DEBUG_ERROR,"device connected\n");
return -1;
}
do
{
RTUSBReadMACRegister(pAdapter, PHY_CSR8, &temp);
if (!(temp & BUSY))
break;
i++;
}
while ((i < RETRY_LIMIT) && (!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_REMOVE_IN_PROGRESS)));
if ((i == RETRY_LIMIT) || (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_REMOVE_IN_PROGRESS)))
{
DBGPRINT_RAW(RT_DEBUG_ERROR, "Retry count exhausted or device removed!!!\n");
return STATUS_UNSUCCESSFUL;
}
PhyCsr7.value = 0;
PhyCsr7.field.WriteControl = 0;
PhyCsr7.field.RegID = Id;
PhyCsr7.field.Data = Value;
RTUSBWriteMACRegister(pAdapter, PHY_CSR7, PhyCsr7.value);
pAdapter->PortCfg.BbpWriteLatch[Id] = Value;
return STATUS_SUCCESS;
}
/*
========================================================================
Routine Description:
Arguments:
Return Value:
IRQL =
Note:
========================================================================
*/
NTSTATUS RTUSBWriteRFRegister(
IN PRT2570ADAPTER pAdapter,
IN ULONG Value)
{
PHY_CSR10_STRUC PhyCsr10;
UINT i = 0;
do
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -