DSWifi
Loading...
Searching...
No Matches
Functions
dsiwifi7_bmi.h File Reference

BMI utilities for DSi Wifi. More...

#include <nds/ndstypes.h>
#include <dswifi_version.h>

Functions

u32 ath6k_bmi_execute (u32 addr, u32 arg)
 Call an Xtensa subroutine from BMI mode.
 
u32 ath6k_bmi_get_version (void)
 Reads the wifi module version.
 
void ath6k_bmi_lz_upload (u32 addr, const u8 *data, u32 len)
 Upload LZ-compressed data to the Xtensa-internal address space. The BMI bootloader decompresses it.
 
void ath6k_bmi_read_memory (u32 addr, u32 len, u8 *data)
 Read a block of Xtensa-internal memory via BMI.
 
u32 ath6k_bmi_read_register (u32 addr)
 Reads an Xtensa-internal I/O register.
 
void ath6k_bmi_set_entrypoint (u32 addr)
 Set the runtime Xtensa firmware entrypoint.
 
void ath6k_bmi_start_firmware (void)
 Start the firmware at the address specified by wifi_card_bmi_set_entrypoint()
 
void ath6k_bmi_wait_count4 (void)
 Perform a busywait until it is possible to send more data via BMI.
 
void ath6k_bmi_write_memory (u32 addr, const u8 *data, u32 len)
 Writes a block of data into Xtensa-internal memory via BMI.
 
void ath6k_bmi_write_register (u32 addr, u32 val)
 Writes an Xtensa-internal I/O register.
 
void ath6k_deinit_hw (void)
 Deinitializes the Wifi SDIO card.
 
int ath6k_init_hw_to_bmi (void)
 Initializes the Wifi SDIO card into BMI (bootloader) mode.
 
bool ath6k_mbox0_read_u32_timeout (u32 *retv, u32 timeout_max)
 Read a 32-bit word from the MBOX0 FIFO, with timeout.
 
u16 ath6k_mbox0_readbytes (u8 *dat, u32 sz_buf, u32 len_read)
 Read a block of data from the MBOX0 FIFO.
 
void ath6k_mbox0_sendbytes (const u8 *dat, u32 len)
 Send a block of data to the MBOX0 FIFO.
 
void ath6k_mbox0_write_u32 (u32 val, bool send_irq)
 Write a 32-bit word to the MBOX0 FIFO.
 
u32 ath6k_read_intern_word (u32 addr)
 Read a 32-bit word from the Xtensa internal address space.
 
void ath6k_write_intern_word (u32 addr, u32 data)
 Writes a 32-bit word into the Xtensa internal address space.
 
void SDIO_enable_cardirq (bool en)
 Sets whether the SDIO card interrupt is enabled.
 
u8 SDIO_func0_read_u8 (u32 addr)
 Read a byte from the SDIO Function 0 address space.
 
int SDIO_func0_write_u8 (u32 addr, u8 val)
 Write a byte to the SDIO Function 0 address space.
 
u32 SDIO_func1_read_u32 (u32 addr)
 Read a 32-bit word from the SDIO Function 1 address space.
 
u8 SDIO_func1_read_u8 (u32 addr)
 Read a byte from the SDIO Function 1 address space.
 
void SDIO_func1_write_u32 (u32 addr, u32 val)
 Write a 32-bit word to the SDIO Function 1 address space.
 
int SDIO_func1_write_u8 (u32 addr, u8 v)
 Write a byte to the SDIO Function 1 address space.
 
u16 SDIO_get_cardirq_stat (void)
 Gets whether the SDIO card interrupt is pending.
 

Detailed Description

BMI utilities for DSi Wifi.

This header defines EXPERIMENTAL functions for low-level access to the WiFi card hardware, including functions for uploading code to the Xtensa CPU in the WiFi card.

Please do not assume this API is stable, it might still change in the- future.

Function Documentation

◆ ath6k_bmi_execute()

u32 ath6k_bmi_execute ( u32  addr,
u32  arg 
)

Call an Xtensa subroutine from BMI mode.

Parameters
addrFunction address to call
argArgument to pass to thre function
Returns
Function call return value

◆ ath6k_bmi_get_version()

u32 ath6k_bmi_get_version ( void  )

Reads the wifi module version.

Returns
module version

DWM-W015 = 0x20000188 DWM-W024 = 0x23000024 DWM-W028 = 0x2300006F

◆ ath6k_bmi_lz_upload()

void ath6k_bmi_lz_upload ( u32  addr,
const u8 *  data,
u32  len 
)

Upload LZ-compressed data to the Xtensa-internal address space. The BMI bootloader decompresses it.

Parameters
addrXtensa-internal address to decompress the data to
dataLZ-compressed data to transfer and decompress
lensize of compressed data

◆ ath6k_bmi_read_memory()

void ath6k_bmi_read_memory ( u32  addr,
u32  len,
u8 *  data 
)

Read a block of Xtensa-internal memory via BMI.

Parameters
addraddress to read from
lennumber of bytes to read
databuffer to return read data into

◆ ath6k_bmi_read_register()

u32 ath6k_bmi_read_register ( u32  addr)

Reads an Xtensa-internal I/O register.

Parameters
addrI/O register address
Returns
I/O register value

◆ ath6k_bmi_set_entrypoint()

void ath6k_bmi_set_entrypoint ( u32  addr)

Set the runtime Xtensa firmware entrypoint.

Parameters
addrfirmware entrypoint address

◆ ath6k_bmi_write_memory()

void ath6k_bmi_write_memory ( u32  addr,
const u8 *  data,
u32  len 
)

Writes a block of data into Xtensa-internal memory via BMI.

Parameters
addraddress to write to
datadata to write
lennumber of bytes to write

◆ ath6k_bmi_write_register()

void ath6k_bmi_write_register ( u32  addr,
u32  val 
)

Writes an Xtensa-internal I/O register.

Parameters
addrI/O register address
valI/O register value

◆ ath6k_init_hw_to_bmi()

int ath6k_init_hw_to_bmi ( void  )

Initializes the Wifi SDIO card into BMI (bootloader) mode.

Returns
nonzero on error

◆ ath6k_mbox0_read_u32_timeout()

bool ath6k_mbox0_read_u32_timeout ( u32 *  retv,
u32  timeout_max 
)

Read a 32-bit word from the MBOX0 FIFO, with timeout.

Parameters
retvpointer to write the return value to. only written to in case no timeout occurs.
timeout_maxmaximum tries before a timeout is signalled
Returns
true if the read succeeded, false if a timeout occurred

◆ ath6k_mbox0_readbytes()

u16 ath6k_mbox0_readbytes ( u8 *  dat,
u32  sz_buf,
u32  len_read 
)

Read a block of data from the MBOX0 FIFO.

Parameters
datbuffer to read into
sz_bufmaximum buffer size
len_readnumber of bytes to read, must not exceed 0x1800!
Returns
Number of bytes read

◆ ath6k_mbox0_sendbytes()

void ath6k_mbox0_sendbytes ( const u8 *  dat,
u32  len 
)

Send a block of data to the MBOX0 FIFO.

Parameters
datdata to send
lennumber of bytes to send, must not exceed 0x1800!

◆ ath6k_mbox0_write_u32()

void ath6k_mbox0_write_u32 ( u32  val,
bool  send_irq 
)

Write a 32-bit word to the MBOX0 FIFO.

Parameters
valvalue to write
send_irqwhether to interrupt the Xtensa core of the Wifi module

◆ ath6k_read_intern_word()

u32 ath6k_read_intern_word ( u32  addr)

Read a 32-bit word from the Xtensa internal address space.

Parameters
addraddress to read from
Returns
word read

◆ ath6k_write_intern_word()

void ath6k_write_intern_word ( u32  addr,
u32  data 
)

Writes a 32-bit word into the Xtensa internal address space.

Parameters
addraddress to write to
datavalue to write

◆ SDIO_enable_cardirq()

void SDIO_enable_cardirq ( bool  en)

Sets whether the SDIO card interrupt is enabled.

Note
You need to do more work than just calling this function to use IRQs from the Xtensa MBOX SDIO interface. Initialize things as follows:
irqSetAUX(IRQ_WIFI_SDIO_CARDIRQ, YOUR_ISR_HERE);
irqEnableAUX(IRQ_WIFI_SDIO_CARDIRQ);
SDIO_enable_cardirq(true);
SDIO_func1_write_u32(0x418, 0x010300D1);
SDIO_func0_write_u8(0x4, 0x3); // CCCR irq_enable, main+func1
Parameters
enTrue for enable the IRQ, false for disable

◆ SDIO_func0_read_u8()

u8 SDIO_func0_read_u8 ( u32  addr)

Read a byte from the SDIO Function 0 address space.

Parameters
addrFunction 0 address to read from
Returns
The byte value at the Function 0 address

◆ SDIO_func0_write_u8()

int SDIO_func0_write_u8 ( u32  addr,
u8  val 
)

Write a byte to the SDIO Function 0 address space.

Parameters
addrFunction 0 address to write to
vvalue to write
Returns
nonzero on error

◆ SDIO_func1_read_u32()

u32 SDIO_func1_read_u32 ( u32  addr)

Read a 32-bit word from the SDIO Function 1 address space.

Parameters
addrFunction 1 address to read from
Returns
The word at the Function 1 address

◆ SDIO_func1_read_u8()

u8 SDIO_func1_read_u8 ( u32  addr)

Read a byte from the SDIO Function 1 address space.

Parameters
addrFunction 1 address to read from
Returns
The byte value at the Function 1 address

◆ SDIO_func1_write_u32()

void SDIO_func1_write_u32 ( u32  addr,
u32  val 
)

Write a 32-bit word to the SDIO Function 1 address space.

Parameters
addrFunction 1 address to write to
vvalue to write

◆ SDIO_func1_write_u8()

int SDIO_func1_write_u8 ( u32  addr,
u8  v 
)

Write a byte to the SDIO Function 1 address space.

Parameters
addrFunction 1 address to write to
vvalue to write
Returns
nonzero on error

◆ SDIO_get_cardirq_stat()

u16 SDIO_get_cardirq_stat ( void  )

Gets whether the SDIO card interrupt is pending.

Returns
SDIO card IRQ status bits