Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move Wi-Fi OS agnostic code from sdk-nrf #1101

Merged
merged 1 commit into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,6 @@ doc/* @b-gent
/nrf_dm/ @Tschet1 @eriksandgren
/lc3/ @koffes @alexsven
/nrf_fuel_gauge/ @nordic-auko @aasinclair
/nrf_wifi/ @krish2718 @sachinthegreen @rado17 @rlubos
/nrf_wifi/fw_if/umac_if/inc/fw/ @udaynordic @srkanordic
/nrf_wifi/hw_if/hal/inc/fw/ @udaynordic @srkanordic
1 change: 1 addition & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@ Refer to their respective documentation for more information.
nrf_dm/README
openthread/README
nrf_rpc/README
nrf_wifi/README
softdevice_controller/README
zboss/README
14 changes: 14 additions & 0 deletions nrf_wifi/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.. _nrf_wifi_api:

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/*
98 changes: 98 additions & 0 deletions nrf_wifi/bus_if/bal/inc/bal_api.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
/*
* Copyright (c) 2022 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"

/**
* nrf_wifi_bal_init() - Initialize the BAL layer.
*
* @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.
*
* Returns: Pointer to instance of BAL layer context.
*/
struct nrf_wifi_bal_priv *nrf_wifi_bal_init(struct nrf_wifi_osal_priv *opriv,
struct nrf_wifi_bal_cfg_params *cfg_params,
enum nrf_wifi_status (*intr_callbk_fn)(void *hal_ctx));


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


struct nrf_wifi_bal_dev_ctx *nrf_wifi_bal_dev_add(struct nrf_wifi_bal_priv *bpriv,
void *hal_dev_ctx);

void nrf_wifi_bal_dev_rem(struct nrf_wifi_bal_dev_ctx *bal_dev_ctx);

enum nrf_wifi_status nrf_wifi_bal_dev_init(struct nrf_wifi_bal_dev_ctx *bal_dev_ctx);

void nrf_wifi_bal_dev_deinit(struct nrf_wifi_bal_dev_ctx *bal_dev_ctx);

unsigned int nrf_wifi_bal_read_word(void *ctx,
unsigned long addr_offset);

void nrf_wifi_bal_write_word(void *ctx,
unsigned long addr_offset,
unsigned int val);

void nrf_wifi_bal_read_block(void *ctx,
void *dest_addr,
unsigned long src_addr_offset,
size_t len);

void nrf_wifi_bal_write_block(void *ctx,
unsigned long dest_addr_offset,
const void *src_addr,
size_t len);

unsigned long nrf_wifi_bal_dma_map(void *ctx,
unsigned long virt_addr,
size_t len,
enum nrf_wifi_osal_dma_dir dma_dir);

unsigned long nrf_wifi_bal_dma_unmap(void *ctx,
unsigned long phy_addr,
size_t len,
enum nrf_wifi_osal_dma_dir dma_dir);

void nrf_wifi_bal_bus_access_rec_enab(void *ctx);

void nrf_wifi_bal_bus_access_rec_disab(void *ctx);

void nrf_wifi_bal_bus_access_cnt_print(void *ctx);

#ifdef CONFIG_NRF_WIFI_LOW_POWER
void nrf_wifi_bal_rpu_ps_sleep(void *ctx);

void nrf_wifi_bal_rpu_ps_wake(void *ctx);

int nrf_wifi_bal_rpu_ps_status(void *ctx);
#endif /* CONFIG_NRF_WIFI_LOW_POWER */
#endif /* __BAL_API_H__ */
81 changes: 81 additions & 0 deletions nrf_wifi/bus_if/bal/inc/bal_ops.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/*
* Copyright (c) 2022 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__

#include <stdbool.h>

/**
* struct nrf_wifi_bal_ops - Ops to be provided by a particular bus
* implementation.
* @init:
* @deinit:
* @dev_init:
* @dev_deinit:
* @read_word:
* @write_word:
* @read_block:
* @write_block:
* @dma_map:
* @dma_unmap:
*/
struct nrf_wifi_bal_ops {
void * (*init)(struct nrf_wifi_osal_priv *opriv,
void *cfg_params,
enum nrf_wifi_status (*intr_callbk_fn)(void *hal_ctx));
void (*deinit)(void *bus_priv);
void * (*dev_add)(void *bus_priv,
void *bal_dev_ctx);
void (*dev_rem)(void *bus_dev_ctx);

enum nrf_wifi_status (*dev_init)(void *bus_dev_ctx);
void (*dev_deinit)(void *bus_dev_ctx);
unsigned int (*read_word)(void *bus_dev_ctx,
unsigned long addr_offset);
void (*write_word)(void *bus_dev_ctx,
unsigned long addr_offset,
unsigned int val);
void (*read_block)(void *bus_dev_ctx,
void *dest_addr,
unsigned long src_addr_offset,
size_t len);
void (*write_block)(void *bus_dev_ctx,
unsigned long dest_addr_offset,
const void *src_addr,
size_t len);
unsigned long (*dma_map)(void *bus_dev_ctx,
unsigned long virt_addr,
size_t len,
enum nrf_wifi_osal_dma_dir dma_dir);
unsigned long (*dma_unmap)(void *bus_dev_ctx,
unsigned long phy_addr,
size_t len,
enum nrf_wifi_osal_dma_dir dma_dir);
#ifdef CONFIG_NRF_WIFI_LOW_POWER
void (*rpu_ps_sleep)(void *bus_dev_ctx);
void (*rpu_ps_wake)(void *bus_dev_ctx);
int (*rpu_ps_status)(void *bus_dev_ctx);
#endif /* CONFIG_NRF_WIFI_LOW_POWER */
};


/**
* get_bus_ops() - The BAL layer expects this Op return a initialized instance
* of Bus specific Ops.
*
* This Op is expected to be implemented by a specific Bus shim and is expected
* to return a pointer to a initialized instance of struct nrf_wifi_bal_ops.
*
* Returns: Pointer to instance of Bus specific Ops.
*/
struct nrf_wifi_bal_ops *get_bus_ops(void);
#endif /* __BAL_OPS_H__ */
55 changes: 55 additions & 0 deletions nrf_wifi/bus_if/bal/inc/bal_structs.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* Copyright (c) 2022 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: BSD-3-Clause
*/

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

#ifndef __BAL_STRUCTS_H__
#define __BAL_STRUCTS_H__

#include "osal_ops.h"
#include "bal_ops.h"

struct nrf_wifi_bal_cfg_params {
unsigned long addr_pktram_base;
};

/**
* struct nrf_wifi_bal_priv - Structure to hold context information for the BAL
* @opriv: Pointer to the OSAL context.
* @bus_priv: Pointer to a specific bus context.
* @ops: Pointer to bus operations to be provided by a specific bus
* implementation.
*
* This structure maintains the context information necessary for the
* operation of the BAL. Some of the elements of the structure need to be
* initialized during the initialization of the BAL while others need to
* be kept updated over the duration of the BAL operation.
*/
struct nrf_wifi_bal_priv {
struct nrf_wifi_osal_priv *opriv;
void *bus_priv;
struct nrf_wifi_bal_ops *ops;

enum nrf_wifi_status (*init_dev_callbk_fn)(void *ctx);

void (*deinit_dev_callbk_fn)(void *ctx);

enum nrf_wifi_status (*intr_callbk_fn)(void *ctx);
};


struct nrf_wifi_bal_dev_ctx {
struct nrf_wifi_bal_priv *bpriv;
void *hal_dev_ctx;
void *bus_dev_ctx;
#ifdef CONFIG_NRF_WIFI_LOW_POWER
bool rpu_fw_booted;
#endif /* CONFIG_NRF_WIFI_LOW_POWER */
};
#endif /* __BAL_STRUCTS_H__ */
Loading
Loading