📄 gspx_bus.c
字号:
return pHC;
}
///////////////////////////////////////////////////////////////////////////////
// Function: gspx_deinit
// Description:
// Deinitializes the GSPI controller initialized by gspx_init(). This
// typically includes unmapping memories, unallocating interrupt, freeing
// critical sections, and other resources allocated by the DLL.
// Parameters:
// pHC - Pointer to the device context returned by gspx_init().
// Return:
// None
///////////////////////////////////////////////////////////////////////////////
VOID gspx_deinit(PVOID pHC)
{
EnterCriticalSection(&ioLock); //JKU
GspiBusDeinit(pHC);
LeaveCriticalSection(&ioLock);
DeleteCriticalSection(&ioLock);//gli++
}
///////////////////////////////////////////////////////////////////////////////
// Function: gspx_set_ist_callback
// Description:
// The WLAN calls this function to setup a callback to process the WLAN
// interrupts
// Parameters:
// pHC - Pointer to the device context returned by gspx_init().
// cb - Pointer to the callback function in the WLAN driver.
// data - The WLAN driver supplied context data which is passed back
// as the function parameter
// Return:
// The ID of the system interrupt allocated by gspx_init()
///////////////////////////////////////////////////////////////////////////////
BOOL gspx_set_ist_callback(PVOID pHC, PVOID cb, void *data)
{
PGSPI_GRV_DATA g_pDrvData = (PGSPI_GRV_DATA)pHC;
GSPIMSG(1, (TEXT("+GspiBusSetCallback()\n")));
if (cb != NULL)
{
wlan_isr_callback = cb;
g_pDrvData->CbData = data;
}
else
{
wlan_isr_callback = NULL;
g_pDrvData->CbData = NULL;
}
GSPIMSG(1, (TEXT("-GspiBusSetCallback()\n")));
return GSPI_OK;
}
///////////////////////////////////////////////////////////////////////////////
// Function: gspx_get_clock_rate
// Description:
// Gets the current GSPI host controller clock speed
// Parameters:
// pHC - Pointer to the device context returned by gspx_init().
// Return:
// The host controller clock speed in Hz
///////////////////////////////////////////////////////////////////////////////
UINT32 gspx_get_clock_rate(PVOID pHC)
{
return ((PGSPI_GRV_DATA)pHC)->dwBusClkRt;
}
///////////////////////////////////////////////////////////////////////////////
// Function: gspx_set_clock_rate
// Description:
// Sets the GSPI host controller's clock speed. If the controller does not
// support the exact speed requested, the speed shall be set to the next
// lower speed supported.
// Parameters:
// pHC - Pointer to the device context returned by gspx_init().
// rate - Clock rate to set to in Hz.
// Return:
// TRUE on success, and FALSE on failure.
///////////////////////////////////////////////////////////////////////////////
BOOL gspx_set_clock_rate(PVOID pHC, UINT32 rate)
{
BOOL ret = TRUE;
if(rate == GSPI_HIGH_CLK_RATE)
{
((PGSPI_GRV_DATA)pHC)->dwBusClkRt = GSPI_HIGH_CLK_RATE;
GspiBusRaiseBusClock();
}
else if (rate < GSPI_HIGH_CLK_RATE && rate >= GSPI_LOW_CLK_RATE )
{
((PGSPI_GRV_DATA)pHC)->dwBusClkRt = GSPI_LOW_CLK_RATE;
GspiBusLowerBusClock();
}
else
ret = FALSE;
return ret;
}
///////////////////////////////////////////////////////////////////////////////
// Function: gspx_set_clocking_edge
// Description:
// Sets the host to use rising or falling edge to clock data in.
// Parameters:
// pHC - Pointer to the device context returned by gspx_init().
// rise_fall - 1 for rising edge, and 0 for falling edge
// Return:
// TRUE on success, and FALSE on failure.
///////////////////////////////////////////////////////////////////////////////
BOOL gspx_set_clocking_edge(PVOID pHC, BOOL raise_fall)
{
return TRUE;
}
///////////////////////////////////////////////////////////////////////////////
// Function: gspx_set_read_delay
// Description:
// Sets register read delay in number of clocks
// Parameters:
// pHC - Pointer to the device context returned by gspx_init().
// reg - Read Register delay in multiple of 16 clocks.
// io - Port Register delay in multiple of 16 clocks.
// Return:
// TRUE on success, and FALSE on failure.
///////////////////////////////////////////////////////////////////////////////
BOOL gspx_set_read_delay(PVOID pHC, UINT16 reg,UINT16 io)
{
extern int g_spi_dummy_clk_reg;
extern int g_spi_dummy_clk_data;
g_spi_dummy_clk_reg = reg;
g_spi_dummy_clk_data = io;
return TRUE;
}
///////////////////////////////////////////////////////////////////////////////
// Function: gspx_reset_module
// Description:
// Resets the WLAN module by resting the RESET pin on the WLAN module.
// Parameters:
// pHC - Pointer to the device context returned by gspx_init().
// Return:
// None
///////////////////////////////////////////////////////////////////////////////
VOID gspx_reset_module(PVOID pHC)
{
extern void GspiHostSetRSTHigh();
extern void GspiHostSetRSTLow();
EnterCriticalSection(&ioLock);
GspiHostSetRSTHigh();
Sleep(1);
GspiHostSetRSTLow();
Sleep(5);
GspiHostSetRSTHigh();
Sleep(1);
LeaveCriticalSection(&ioLock);
}
///////////////////////////////////////////////////////////////////////////////
// Function: gspx_read_reg16
// Description:
// Reads a 16-bit value from a single register.
// Parameters:
// pHC - Pointer to the device context returned by gspx_init().
// reg - Register address to read from.
// data - A 16-bit value read from the register.
// Return:
// TRUE on success, and FALSE on failure.
///////////////////////////////////////////////////////////////////////////////
BOOL gspx_read_reg16(PVOID pbus, UINT16 reg, UINT16 *data)
{
UINT16 read_data[2];
int ret;
read_data[0] = BYTE_STREAM(reg);
if((ret = gspi_read_data_nodma(read_data, 1) != GSPI_OK))
{
return ret;
}
*data = BYTE_STREAM(read_data[0]);
return GSPI_OK;
}
///////////////////////////////////////////////////////////////////////////////
// Function: gspx_write_reg16
// Description:
// Writes to a single register a 16-bit value.
// Parameters:
// pHC - Pointer to the device context returned by gspx_init().
// reg - Register address to write to.
// data - A 16-bit value to write.
// Return:
// TRUE on success, and FALSE on failure.
///////////////////////////////////////////////////////////////////////////////
BOOL gspx_write_reg16(PVOID pbus, UINT16 reg, UINT16 data)
{
UINT16 write_data[2];
write_data[0] = BYTE_STREAM(reg);
write_data[1] = BYTE_STREAM(data);
return gspi_write_data_nodma(write_data, 2);
}
///////////////////////////////////////////////////////////////////////////////
// Function: gspx_read_reg32
// Description:
// Reads a 32-bit value from a single register.
// Parameters:
// pHC - Pointer to the device context returned by gspx_init().
// reg - Register address to read from.
// data - A 32-bit value read from the register.
// Return:
// TRUE on success, and FALSE on failure.
///////////////////////////////////////////////////////////////////////////////
//JKU: int gspx_read_reg32(PVOID pbus, UINT16 reg, UINT *data)
BOOL gspx_read_reg32(PVOID pbus, UINT16 reg, UINT32 *data)
{
UINT16 readdt[3];
readdt[0] = reg;
if(gspi_read_data_nodma(readdt, 2) < 0) {
return !GSPI_OK;
}
*data = readdt[1] << 16 | readdt[0];
return GSPI_OK;
}
///////////////////////////////////////////////////////////////////////////////
// Function: gspx_write_reg32
// Description:
// Writes to a single register a 32-bit value.
// Parameters:
// pHC - Pointer to the device context returned by gspx_init().
// reg - Register address to write to.
// data - A 32-bit value to write
// Return:
// TRUE on success, and FALSE on failure.
///////////////////////////////////////////////////////////////////////////////
BOOL gspx_write_reg32(PVOID pbus, UINT16 reg, UINT32 data)
{
UINT16 writedt[3];
writedt[0] = BYTE_STREAM(data & 0xffff);
writedt[1] = BYTE_STREAM(data >> 16);
if(gspi_write_data_direct_nodma((UCHAR *) writedt, reg, 2) < 0) {
return !GSPI_OK;
}
return GSPI_OK;
}
///////////////////////////////////////////////////////////////////////////////
// Function: gspx_read_mem
// Description:
// Reads a buffer from the port on the WLAN module.
// Parameters:
// pHC - Pointer to the device context returned by gspx_init().
// reg - Address to read from.
// nword - Number of 16-bit values to read.
// datPt - Caller supplied buffer for storing the data read.
// Return:
// TRUE on success, and FALSE on failure.
///////////////////////////////////////////////////////////////////////////////
BOOL gspx_read_mem(PVOID pbus, UINT16 reg, UINT16 size, UINT16 *data)
{
return (BOOL) gspi_read_data_direct_nodma((UCHAR*) data, BYTE_STREAM(reg), size);
}
///////////////////////////////////////////////////////////////////////////////
// Function: gspx_write_mem
// Description:
// Writes a buffer to the port on the WLAN module.
// Parameters:
// pHC - Pointer to the device context returned by gspx_init().
// reg - Address to write to.
// nword - Number of 16-bit values to write.
// datPt - Pointer to the data buffer to write.
// Return:
// TRUE on success, and FALSE on failure.
///////////////////////////////////////////////////////////////////////////////
BOOL gspx_write_mem(PVOID pHC, UINT16 reg, UINT16 size, UINT16 *data)
{
return (BOOL) gspi_write_data_direct_nodma((UCHAR*) data, BYTE_STREAM(reg), size);
}
///////////////////////////////////////////////////////////////////////////////
// Function: gspx_power_up
// Description:
// Power up the WLAN module.
// Parameters:
// pHC - Pointer to the device context returned by gspx_init().
// Return:
// TRUE on success, and FALSE on failure.
///////////////////////////////////////////////////////////////////////////////
BOOL gspx_power_up(PVOID pHC)
{
return TRUE;
}
///////////////////////////////////////////////////////////////////////////////
// Function: gspx_power_down
// Description:
// Power down the WLAN module.
// Parameters:
// pHC - Pointer to the device context returned by gspx_init().
// Return:
// TRUE on success, and FALSE on failure.
///////////////////////////////////////////////////////////////////////////////
BOOL gspx_power_down(PVOID pHC)
{
GSPIMSG(1, (TEXT("Entering gspx_power_down\n")));
GspiHostSetRSTLow(); // ksorada : fixed CR#798
return TRUE;
}
/*-------------------------------------------------------------------------
* END GSPX section:
*-------------------------------------------------------------------------*/
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -