linux/drivers/platform/x86/amd/wbrf.c

// SPDX-License-Identifier: GPL-2.0
/*
 * Wifi Frequency Band Manage Interface
 * Copyright (C) 2023 Advanced Micro Devices
 */

#include <linux/acpi.h>
#include <linux/acpi_amd_wbrf.h>

/*
 * Functions bit vector for WBRF method
 *
 * Bit 0: WBRF supported.
 * Bit 1: Function 1 (Add / Remove frequency) is supported.
 * Bit 2: Function 2 (Get frequency list) is supported.
 */
#define WBRF_ENABLED
#define WBRF_RECORD
#define WBRF_RETRIEVE

#define WBRF_REVISION

/*
 * The data structure used for WBRF_RETRIEVE is not naturally aligned.
 * And unfortunately the design has been settled down.
 */
struct amd_wbrf_ranges_out {} __packed;

static const guid_t wifi_acpi_dsm_guid =;

/*
 * Used to notify consumer (amdgpu driver currently) about
 * the wifi frequency is change.
 */
static BLOCKING_NOTIFIER_HEAD(wbrf_chain_head);

static int wbrf_record(struct acpi_device *adev, uint8_t action, struct wbrf_ranges_in_out *in)
{}

/**
 * acpi_amd_wbrf_add_remove - add or remove the frequency band the device is using
 *
 * @dev: device pointer
 * @action: remove or add the frequency band into bios
 * @in: input structure containing the frequency band the device is using
 *
 * Broadcast to other consumers the frequency band the device starts
 * to use. Underneath the surface the information is cached into an
 * internal buffer first. Then a notification is sent to all those
 * registered consumers. So then they can retrieve that buffer to
 * know the latest active frequency bands. Consumers that haven't
 * yet been registered can retrieve the information from the cache
 * when they register.
 *
 * Return:
 * 0 for success add/remove wifi frequency band.
 * Returns a negative error code for failure.
 */
int acpi_amd_wbrf_add_remove(struct device *dev, uint8_t action, struct wbrf_ranges_in_out *in)
{}
EXPORT_SYMBOL_GPL();

/**
 * acpi_amd_wbrf_supported_producer - determine if the WBRF can be enabled
 *                                    for the device as a producer
 *
 * @dev: device pointer
 *
 * Check if the platform equipped with necessary implementations to
 * support WBRF for the device as a producer.
 *
 * Return:
 * true if WBRF is supported, otherwise returns false
 */
bool acpi_amd_wbrf_supported_producer(struct device *dev)
{}
EXPORT_SYMBOL_GPL();

/**
 * acpi_amd_wbrf_supported_consumer - determine if the WBRF can be enabled
 *                                    for the device as a consumer
 *
 * @dev: device pointer
 *
 * Determine if the platform equipped with necessary implementations to
 * support WBRF for the device as a consumer.
 *
 * Return:
 * true if WBRF is supported, otherwise returns false.
 */
bool acpi_amd_wbrf_supported_consumer(struct device *dev)
{}
EXPORT_SYMBOL_GPL();

/**
 * amd_wbrf_retrieve_freq_band - retrieve current active frequency bands
 *
 * @dev: device pointer
 * @out: output structure containing all the active frequency bands
 *
 * Retrieve the current active frequency bands which were broadcasted
 * by other producers. The consumer who calls this API should take
 * proper actions if any of the frequency band may cause RFI with its
 * own frequency band used.
 *
 * Return:
 * 0 for getting wifi freq band successfully.
 * Returns a negative error code for failure.
 */
int amd_wbrf_retrieve_freq_band(struct device *dev, struct wbrf_ranges_in_out *out)
{}
EXPORT_SYMBOL_GPL();

/**
 * amd_wbrf_register_notifier - register for notifications of frequency
 *                                   band update
 *
 * @nb: driver notifier block
 *
 * The consumer should register itself via this API so that it can get
 * notified on the frequency band updates from other producers.
 *
 * Return:
 * 0 for registering a consumer driver successfully.
 * Returns a negative error code for failure.
 */
int amd_wbrf_register_notifier(struct notifier_block *nb)
{}
EXPORT_SYMBOL_GPL();

/**
 * amd_wbrf_unregister_notifier - unregister for notifications of
 *                                     frequency band update
 *
 * @nb: driver notifier block
 *
 * The consumer should call this API when it is longer interested with
 * the frequency band updates from other producers. Usually, this should
 * be performed during driver cleanup.
 *
 * Return:
 * 0 for unregistering a consumer driver.
 * Returns a negative error code for failure.
 */
int amd_wbrf_unregister_notifier(struct notifier_block *nb)
{}
EXPORT_SYMBOL_GPL();