Skip to content

Commit

Permalink
Initial checkin
Browse files Browse the repository at this point in the history
Based on [1] rev#373ae9cf6e9cf7a3bbfedcda6a387d505045830b, moving
nrf_wifi to it's own repository. This simplies manifest updates in
Zephyr without conflicting with nrfx.

[1] - https://github.com/zephyrproject-rtos/hal_nordic

Signed-off-by: Chaitanya Tata <[email protected]>
  • Loading branch information
krish2718 committed Nov 23, 2024
1 parent 02c59a1 commit f9e2abd
Show file tree
Hide file tree
Showing 82 changed files with 33,511 additions and 0 deletions.
2,834 changes: 2,834 additions & 0 deletions Doxyfile

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.. _nrf_wifi_api:

nRF70 low-level API documentation
*********************************

The nRF70 Series Wi-Fi driver provides a low-level API for use cases where the application needs to access the nRF70 Series device directly.
This is typically intended for customers who want to use the nRF70 Series device on a different platform than Zephyr.

.. toctree::
:maxdepth: 1
:caption: Modules:
:glob:

doc/*
204 changes: 204 additions & 0 deletions bus_if/bal/inc/bal_api.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,204 @@
/*
* Copyright (c) 2024 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: BSD-3-Clause
*/

/**
* @brief Header containing the API declarations for the Bus Abstraction Layer
* (BAL) of the Wi-Fi driver.
*/

#ifndef __BAL_API_H__
#define __BAL_API_H__

#include "osal_api.h"
#include "bal_structs.h"

/**
* @brief Initialize the BAL layer.
*
* @param cfg_params Pointer to the configuration parameters for the BAL layer.
* @param intr_callbk_fn Pointer to the callback function which the user of this
* layer needs to implement to handle interrupts from the RPU.
*
* This API is used to initialize the BAL layer and is expected to be called
* before using the BAL layer. This API returns a pointer to the BAL context
* which might need to be passed to further API calls.
*
* @return Pointer to instance of BAL layer context.
*/
struct nrf_wifi_bal_priv *nrf_wifi_bal_init(struct nrf_wifi_bal_cfg_params *cfg_params,
enum nrf_wifi_status (*intr_callbk_fn)(void *hal_ctx));


/**
* @brief Deinitialize the BAL layer.
*
* This API is used to deinitialize the BAL layer and is expected to be called
* after done using the BAL layer.
*
* @param bpriv Pointer to the BAL layer context returned by the
* @ref nrf_wifi_bal_init API.
*/
void nrf_wifi_bal_deinit(struct nrf_wifi_bal_priv *bpriv);

/**
* @brief Add a device context to the BAL layer.
*
* @param bpriv Pointer to the BAL layer context returned by the
* @ref nrf_wifi_bal_init API.
* @param hal_dev_ctx Pointer to the HAL device context.
*
* @return Pointer to the added device context.
*/
struct nrf_wifi_bal_dev_ctx *nrf_wifi_bal_dev_add(struct nrf_wifi_bal_priv *bpriv,
void *hal_dev_ctx);

/**
* @brief Remove a device context from the BAL layer.
*
* @param bal_dev_ctx Pointer to the device context returned by the
* @ref nrf_wifi_bal_dev_add API.
*/
void nrf_wifi_bal_dev_rem(struct nrf_wifi_bal_dev_ctx *bal_dev_ctx);

/**
* @brief Initialize a device context in the BAL layer.
*
* @param bal_dev_ctx Pointer to the device context returned by the
* @ref nrf_wifi_bal_dev_add API.
*
* @return Status of the device initialization.
*/
enum nrf_wifi_status nrf_wifi_bal_dev_init(struct nrf_wifi_bal_dev_ctx *bal_dev_ctx);

/**
* @brief Deinitialize a device context in the BAL layer.
*
* @param bal_dev_ctx Pointer to the device context returned by the
* @ref nrf_wifi_bal_dev_add API.
*/
void nrf_wifi_bal_dev_deinit(struct nrf_wifi_bal_dev_ctx *bal_dev_ctx);

/**
* @brief Read a word from a specific address offset.
*
* @param ctx Pointer to the context.
* @param addr_offset Address offset to read from.
*
* @return The read word.
*/
unsigned int nrf_wifi_bal_read_word(void *ctx, unsigned long addr_offset);

/**
* @brief Write a word to a specific address offset.
*
* @param ctx Pointer to the context.
* @param addr_offset Address offset to write to.
* @param val Value to write.
*/
void nrf_wifi_bal_write_word(void *ctx,
unsigned long addr_offset,
unsigned int val);

/**
* @brief Read a block of data from a specific address offset.
*
* @param ctx Pointer to the context.
* @param dest_addr Pointer to the destination address.
* @param src_addr_offset Source address offset to read from.
* @param len Length of the data to read.
*/
void nrf_wifi_bal_read_block(void *ctx,
void *dest_addr,
unsigned long src_addr_offset,
size_t len);

/**
* @brief Write a block of data to a specific address offset.
*
* @param ctx Pointer to the context.
* @param dest_addr_offset Destination address offset to write to.
* @param src_addr Pointer to the source address.
* @param len Length of the data to write.
*/
void nrf_wifi_bal_write_block(void *ctx,
unsigned long dest_addr_offset,
const void *src_addr,
size_t len);

/**
* @brief Map a virtual address to a physical address for DMA transfer.
*
* @param ctx Pointer to the context.
* @param virt_addr Virtual address to map.
* @param len Length of the data to map.
* @param dma_dir DMA direction.
*
* @return The mapped physical address.
*/
unsigned long nrf_wifi_bal_dma_map(void *ctx,
unsigned long virt_addr,
size_t len,
enum nrf_wifi_osal_dma_dir dma_dir);

/**
* @brief Unmap a physical address for DMA transfer.
*
* @param ctx Pointer to the context.
* @param phy_addr Physical address to unmap.
* @param len Length of the data to unmap.
* @param dma_dir DMA direction.
*/
unsigned long nrf_wifi_bal_dma_unmap(void *ctx,
unsigned long phy_addr,
size_t len,
enum nrf_wifi_osal_dma_dir dma_dir);

/**
* @brief Enable bus access recording.
*
* @param ctx Pointer to the context.
*/
void nrf_wifi_bal_bus_access_rec_enab(void *ctx);

/**
* @brief Disable bus access recording.
*
* @param ctx Pointer to the context.
*/
void nrf_wifi_bal_bus_access_rec_disab(void *ctx);

/**
* @brief Print bus access count.
*
* @param ctx Pointer to the context.
*/
void nrf_wifi_bal_bus_access_cnt_print(void *ctx);

#if defined(NRF_WIFI_LOW_POWER) || defined(__DOXYGEN__)
/**
* @brief Put the RPU to sleep.
*
* @param ctx Pointer to the context.
*/
void nrf_wifi_bal_rpu_ps_sleep(void *ctx);

/**
* @brief Wake up the RPU from sleep.
*
* @param ctx Pointer to the context.
*/
void nrf_wifi_bal_rpu_ps_wake(void *ctx);

/**
* @brief Get the power-saving status of the RPU.
*
* @param ctx Pointer to the context.
*
* @return Power-saving status.
*/
int nrf_wifi_bal_rpu_ps_status(void *ctx);
#endif /* NRF_WIFI_LOW_POWER */
#endif /* __BAL_API_H__ */
177 changes: 177 additions & 0 deletions bus_if/bal/inc/bal_ops.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
/*
* Copyright (c) 2024 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: BSD-3-Clause
*/

/**
* @brief Header containing the OPs declarations for the Bus Abstraction Layer
* (BAL) of the Wi-Fi driver.
*/

#ifndef __BAL_OPS_H__
#define __BAL_OPS_H__

/**
* @brief Ops to be provided by a particular bus implementation.
*
* This structure defines the operations that need to be implemented
* by a specific bus implementation.
*/
struct nrf_wifi_bal_ops {
/**
* @brief Initialize the bus.
*
* @param cfg_params Pointer to the configuration parameters.
* @param intr_callbk_fn Pointer to the interrupt callback function.
* @return Pointer to the initialized instance of the bus.
*/
void * (*init)(void *cfg_params,
enum nrf_wifi_status (*intr_callbk_fn)(void *hal_ctx));

/**
* @brief Deinitialize the bus.
*
* @param bus_priv Pointer to the bus private data.
*/
void (*deinit)(void *bus_priv);

/**
* @brief Add a device to the bus.
*
* @param bus_priv Pointer to the bus private data.
* @param bal_dev_ctx Pointer to the BAL device context.
* @return Pointer to the added device context.
*/
void * (*dev_add)(void *bus_priv,
void *bal_dev_ctx);

/**
* @brief Remove a device from the bus.
*
* @param bus_dev_ctx Pointer to the bus device context.
*/
void (*dev_rem)(void *bus_dev_ctx);

/**
* @brief Initialize a device on the bus.
*
* @param bus_dev_ctx Pointer to the bus device context.
* @return Status of the device initialization.
*/
enum nrf_wifi_status (*dev_init)(void *bus_dev_ctx);

/**
* @brief Deinitialize a device on the bus.
*
* @param bus_dev_ctx Pointer to the bus device context.
*/
void (*dev_deinit)(void *bus_dev_ctx);

/**
* @brief Read a word from the bus.
*
* @param bus_dev_ctx Pointer to the bus device context.
* @param addr_offset Address offset.
* @return The read word.
*/
unsigned int (*read_word)(void *bus_dev_ctx,
unsigned long addr_offset);

/**
* @brief Write a word to the bus.
*
* @param bus_dev_ctx Pointer to the bus device context.
* @param addr_offset Address offset.
* @param val Value to write.
*/
void (*write_word)(void *bus_dev_ctx,
unsigned long addr_offset,
unsigned int val);

/**
* @brief Read a block of data from the bus.
*
* @param bus_dev_ctx Pointer to the bus device context.
* @param dest_addr Destination address.
* @param src_addr_offset Source address offset.
* @param len Length of the block to read.
*/
void (*read_block)(void *bus_dev_ctx,
void *dest_addr,
unsigned long src_addr_offset,
size_t len);

/**
* @brief Write a block of data to the bus.
*
* @param bus_dev_ctx Pointer to the bus device context.
* @param dest_addr_offset Destination address offset.
* @param src_addr Pointer to the source address.
* @param len Length of the block to write.
*/
void (*write_block)(void *bus_dev_ctx,
unsigned long dest_addr_offset,
const void *src_addr,
size_t len);

/**
* @brief Map a DMA buffer.
*
* @param bus_dev_ctx Pointer to the bus device context.
* @param virt_addr Virtual address of the buffer.
* @param len Length of the buffer.
* @param dma_dir DMA direction.
* @return Physical address of the mapped buffer.
*/
unsigned long (*dma_map)(void *bus_dev_ctx,
unsigned long virt_addr,
size_t len,
enum nrf_wifi_osal_dma_dir dma_dir);

/**
* @brief Unmap a DMA buffer.
*
* @param bus_dev_ctx Pointer to the bus device context.
* @param phy_addr Physical address of the buffer.
* @param len Length of the buffer.
* @param dma_dir DMA direction.
* @return Physical address of the unmapped buffer.
*/
unsigned long (*dma_unmap)(void *bus_dev_ctx,
unsigned long phy_addr,
size_t len,
enum nrf_wifi_osal_dma_dir dma_dir);

#if defined(NRF_WIFI_LOW_POWER) || defined(__DOXYGEN__)
/**
* @brief Put the device into power-saving sleep mode.
*
* @param bus_dev_ctx Pointer to the bus device context.
*/
void (*rpu_ps_sleep)(void *bus_dev_ctx);

/**
* @brief Wake the device from power-saving sleep mode.
*
* @param bus_dev_ctx Pointer to the bus device context.
*/
void (*rpu_ps_wake)(void *bus_dev_ctx);

/**
* @brief Get the power-saving status of the device.
*
* @param bus_dev_ctx Pointer to the bus device context.
* @return Power-saving status of the device.
*/
int (*rpu_ps_status)(void *bus_dev_ctx);
#endif /* NRF_WIFI_LOW_POWER */
};

/**
* @brief Get the bus operations.
*
* @return Pointer to the bus operations.
*/
struct nrf_wifi_bal_ops *get_bus_ops(void);
#endif /* __BAL_OPS_H__ */
Loading

0 comments on commit f9e2abd

Please sign in to comment.