Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
127 commits
Select commit Hold shift + click to select a range
4c4de6b
wifi: ath12k: Restructure PCI code to common and Wi-Fi 7 specific logic
Aug 12, 2025
7e46ef4
wifi: ath12k: Move Copy Engine configuration to Wi-Fi 7 specific file
Aug 12, 2025
92f6746
wifi: ath12k: Move Wi-Fi 7 WMI configuration to dedicated file
Aug 12, 2025
c9c3d70
wifi: ath12k: Move Wi-Fi 7 MHI configuration to dedicated file
Aug 12, 2025
d96c059
wifi: ath12k: Rename hw.c to Wi-Fi 7 specific implementation file
Aug 12, 2025
e8ced1b
wifi: ath12k: Rename ahb_hif_ops to reflect generic usage
Aug 12, 2025
fadcfec
wifi: ath12k: Restructure ahb.c into common and Wi-Fi 7 specific modules
Aug 12, 2025
524b48c
wifi: ath12k: Move Wi-Fi 7 specific init routines to dedicated file
Aug 12, 2025
2438986
wifi: ath12k: Move hw_init invocation to target-specific probe
Aug 12, 2025
8111e39
wifi: ath12k: Modularize driver into common and Wi-Fi 7 specific comp…
Aug 12, 2025
7cbeee0
wifi: ath12k: Rename ath12k_* symbols to ath12k_wifi7_* for clarity
Aug 12, 2025
bb22f1d
wifi: ath12k: Remove HAL defines from shared PCI code
Aug 12, 2025
7d67fe8
wifi: ath12k: Remove HAL define dependencies from shared AHB code
Aug 12, 2025
154d9fe
wifi: ath12k: Move hal_tx and hal_rx to wifi7 directory
Aug 28, 2025
d679d69
wifi: ath12k: Move hal_tx.h file to wifi7 directory
Aug 28, 2025
cc50b28
wifi: ath12k: Move hal_rx.h file to wifi7 directory
Aug 28, 2025
562f3f3
wifi: ath12k: Move HAL Rx wrapper APIs to dp_rx.h
Aug 28, 2025
0770a98
wifi: ath12k: Move Rx error related functions to wifi7 directory
Aug 28, 2025
0c46761
wifi: ath12k: Move hal_desc.h file to wifi7 directory
Aug 28, 2025
5718a6e
wifi: ath12k: Move rx_desc.h file to wifi7 directory
Aug 28, 2025
9fffd65
wifi: ath12k: Move rxdma ring config functions to wifi7 directory
Aug 28, 2025
bfecdf3
wifi: ath12k: Move rx error and defrag functions to wifi7 directory
Aug 28, 2025
2828984
wifi: ath12k: Move regular msdu processing functions to wifi7 directory
Aug 28, 2025
b6605bd
wifi: ath12k: Move srng processing to wifi7 directory
Aug 28, 2025
e9b68e8
wifi: ath12k: Separate arch specific part of RX APIs
Aug 28, 2025
e08a09a
wifi: ath12k: Move arch specific REO functions to wifi7 directory
Aug 28, 2025
df9e0eb
wifi: ath12k: Move arch specific rx tid and related functions to wifi…
Aug 28, 2025
ff00034
wifi: ath12k: Move arch specific tx APIs to wifi7 directory
Aug 28, 2025
fc9c76f
wifi: ath12k: Move ath12k_dp_tx and related APIs to wifi7 directory
Aug 28, 2025
98e50fd
wifi: ath12k: Move HTT code in dp.h to newly introduced files
Aug 28, 2025
8d4bbf8
wifi: ath12k: Move HTT Rx specific code to newly introduced files
Aug 28, 2025
857fa76
wifi: ath12k: Move HTT Tx specific code to newly introduced files
Aug 28, 2025
eb89b68
wifi: ath12k: Move HTT specific code from dp.c to newly introduced files
Aug 28, 2025
23f934e
wifi: ath12k: Remove non-compact TLV support from QCN
Sep 10, 2025
457eb1e
wifi: ath12k: Move the hal APIs to hardware specific files
Sep 10, 2025
de3b977
wifi: ath12k: unify HAL ops naming across chips
Sep 10, 2025
4111e71
wifi: ath12k: Replace ops with direct calls for rxdma ring mask
Sep 10, 2025
b0888b8
wifi: ath12k: Move hal_rx_ops callbacks to hal_ops
Sep 10, 2025
6b0c0a8
wifi: ath12k: Add new infra for the rx path
Sep 10, 2025
717f631
wifi: ath12k: Remove hal_rx_ops and merge into hal_ops
Sep 10, 2025
f9c10d7
wifi: ath12k: Change the API prefixes to ath12k_wifi7 in tx/rx
Sep 10, 2025
55d96c1
wifi: ath12k: Convert ath12k_dp member in ath12k_base to pointer
Sep 30, 2025
4ab651f
wifi: ath12k: Support arch-specific DP device allocation
Sep 30, 2025
93196f6
wifi: ath12k: Rearrange DP fields in ath12k_hw_group struct
Sep 30, 2025
bbb6e6f
wifi: ath12k: Add framework for hardware specific ieee80211_ops regis…
Sep 30, 2025
75b5af8
wifi: ath12k: Add framework for hardware specific DP interrupt handler
Sep 30, 2025
dc65af2
wifi: ath12k: Refactor ath12k_vif structure
Sep 30, 2025
e539276
wifi: ath12k: Refactor data path pdev struct
Oct 7, 2025
96cb951
wifi: ath12k: Rearrange PPDU radio stats
Oct 7, 2025
894778f
wifi: ath12k: Move srng config and hal_ops to hw specific hal files
Oct 9, 2025
bf47889
wifi: ath12k: Initialize desc_size through hal_init
Oct 9, 2025
b002296
wifi: ath12k: Initialize hal_ops through hal_init
Oct 9, 2025
90d686a
wifi: ath12k: Move wbm_rbm_map to hw specific hal files
Oct 9, 2025
e95d2b0
wifi: ath12k: Move hal_params and regs to hal from hw
Oct 9, 2025
cabfd11
wifi: ath12k: Add direct HAL pointer in ath12k_dp
Oct 9, 2025
a9cf2fc
wifi: ath12k: Use hal handle instead of ab handle
Oct 9, 2025
4fff08a
wifi: ath12k: Move HAL CE setup and SRNG related APIs to wifi7 directory
Oct 9, 2025
2cc407a
wifi: ath12k: Move HAL SRNG shadow config and get ring id APIs to wif…
Oct 9, 2025
148776b
wifi: ath12k: Move HAL CE desc related APIs to wifi7 directory
Oct 9, 2025
2619fe7
wifi: ath12k: Move HAL CE status and set link desc addr APIs to wifi7…
Oct 9, 2025
07a9681
wifi: ath12k: Move HAL Tx, REO and link idle setup related APIs to wi…
Oct 9, 2025
45550a8
wifi: ath12k: Move HAL REO and Rx buf related APIs to wifi7 directory
Oct 9, 2025
60a95b6
wifi: ath12k: Move HAL Cookie Conversion and RBM related APIs to wifi…
Oct 9, 2025
66c0995
wifi: ath12k: Segregate the common and wifi7 specific structures
Oct 9, 2025
6ea6e14
wifi: ath12k: Remove the unused ring inits in wcn
Oct 9, 2025
f44889d
wifi: ath12k: Rename hal_ops to ops
Oct 9, 2025
b128322
wifi: ath12k: Drop hal_ prefix from hardware register names
Oct 9, 2025
cdb2dc2
wifi: ath12k: Move DP related functions from peer.c to dp_peer.c file
Oct 24, 2025
cbc67d1
wifi: ath12k: Rename ath12k_peer to ath12k_dp_link_peer
Oct 24, 2025
09a4576
wifi: ath12k: Add hash table for ath12k_link_sta in ath12k_base
Oct 24, 2025
7fd46dd
wifi: ath12k: Move ath12k_dp_link_peer list from ath12k_base to ath12…
Oct 24, 2025
ba32693
wifi: ath12k: Add hash table for ath12k_dp_link_peer
Oct 24, 2025
792db2b
wifi: ath12k: Define ath12k_dp_peer structure & APIs for create & delete
Oct 24, 2025
31bd4d2
wifi: ath12k: Attach and detach ath12k_dp_link_peer to ath12k_dp_peer
Oct 24, 2025
4e3522f
wifi: ath12k: Use ath12k_dp_peer in per packet Tx & Rx paths
Oct 24, 2025
481b64b
wifi: ath12k: Add lockdep warn for RCU
Oct 24, 2025
813be84
wifi: ath12k: Add callbacks in arch_ops for rx APIs
Nov 3, 2025
6d225f2
wifi: ath12k: Move DP device stats to ath12k_dp
Nov 3, 2025
a0fc298
wifi: ath12k: Move DP specific link stats to DP link peer
Nov 3, 2025
d77d9a4
wifi: ath12k: Add helper to free DP link peer
Nov 3, 2025
51f5212
wifi: ath12k: Move ieee80211_ops callback to the arch specific module
Nov 3, 2025
6ad2492
wifi: ath12k: Remove the wifi7 header inclusions in common code
Nov 3, 2025
b755668
wifi: ath12k: Move ath12k_dp_rx_frags_cleanup API to Wi-Fi 7
Nov 3, 2025
81ada21
wifi: ath12k: Move ath12k_dp_rx_get_peer_id API to Wi-Fi 7
Nov 3, 2025
83401f4
wifi: ath12k: Remove arch-specific HAL dependencies from common DP
Nov 3, 2025
b83b978
wifi: ath12k: Build all the files in wifi7 directory into ath12k_wifi…
Nov 3, 2025
ce24ba2
wifi: ath12k: Use dp objects in performance critical paths
Nov 3, 2025
ad69148
wifi: ath12k: Replace lock/unlock with guard()
Nov 3, 2025
068073d
wifi: ath12k: Move monitor ring processing to Wi-Fi 7 module
Nov 10, 2025
100b17a
wifi: ath12k: Move monitor status processing to Wi-Fi 7 module
Nov 10, 2025
d3f5c47
wifi: ath12k: Move MPDU pop functionality to Wi-Fi 7 module
Nov 10, 2025
9ee2b3d
wifi: ath12k: Move RX status TLV parsing to Wi-Fi 7 module
Nov 10, 2025
b02f5d5
wifi: ath12k: Move TX monitor functionality to Wi-Fi 7 module
Nov 10, 2025
37b6afb
wifi: ath12k: Move HT/VHT SIG processing to Wi-Fi 7 module
Nov 10, 2025
b363d61
wifi: ath12k: Move HE SIG processing to Wi-Fi 7 module
Nov 10, 2025
5bb0a85
wifi: ath12k: Move EHT SIG processing to Wi-Fi 7 module
Nov 10, 2025
d4a952f
wifi: ath12k: Move remaining SIG TLV parsing to Wi-Fi 7 module
Nov 10, 2025
f3733f8
wifi: ath12k: Move MU user processing to Wi-Fi 7 module
Nov 10, 2025
978b603
wifi: ath12k: Move MSDU END TLV processing to Wi-Fi 7 module
Nov 10, 2025
0b54323
wifi: ath12k: Remove Wi-Fi 7 header dependencies from common ath12k m…
Nov 10, 2025
2fd02ae
wifi: ath12k: add the missing RCU lock in ath12k_dp_tx_free_txbuf()
Nov 19, 2025
f3a1997
wifi: ath12k: move firmware stats request outside of atomic context
Nov 19, 2025
10961dc
wifi: ath12k: Skip DP peer creation for scan vdev
Dec 7, 2025
07206fd
Merge branch 'ath12k-ng' into ath-next
jeff-t-johnson Jan 30, 2026
a1ed83f
wifi: ath12k: remove redundant pci_set_drvdata() call
adminchev Nov 27, 2025
244b9f5
wifi: ath12k: clean up on error in ath12k_dp_setup()
Dec 18, 2025
cc57e57
wifi: ath12k: do WoW offloads only on primary link
Nov 3, 2025
acc3ad6
wifi: ath12k: refactor PCI window register access
Jan 12, 2026
3404a72
wifi: ath12k: refactor REO CMD ring handling
Jan 12, 2026
8b7a382
wifi: ath12k: refactor REO status ring handling
Jan 12, 2026
2c93735
wifi: ath12k: fix preferred hardware mode calculation
Jan 12, 2026
21caedd
wifi: ath12k: refactor 320 MHz bandwidth support parsing
Jan 12, 2026
df027f8
wifi: ath12k: fix mac phy capability parsing
Jan 12, 2026
579798d
wifi: ath12k: add hardware registers for QCC2072
Jan 12, 2026
4cbbcd9
wifi: ath12k: add hardware parameters for QCC2072
Jan 12, 2026
9eae6f0
wifi: ath12k: support LPASS_SHARED target memory type
Jan 12, 2026
fbe202d
wifi: ath12k: support downloading auxiliary ucode image for QCC2072
Jan 12, 2026
1e2e54f
wifi: ath12k: add HAL descriptor and ops for QCC2072
Jan 12, 2026
c0fc5ec
wifi: ath12k: add hardware ops support for QCC2072
Jan 12, 2026
5fd524b
wifi: ath12k: handle REO CMD ring for QCC2072
Jan 12, 2026
1b3ec34
wifi: ath12k: handle REO status ring for QCC2072
Jan 12, 2026
182f827
wifi: ath12k: limit number of channels per WMI command
Jan 12, 2026
b6ae599
wifi: ath12k: send peer meta data version to firmware
Jan 12, 2026
18ac499
wifi: ath12k: fix PCIE_LOCAL_REG_QRTR_NODE_ID definition for QCC2072
miaoqing-quic Jan 12, 2026
6e4630d
wifi: ath12k: enable QCC2072 support
Jan 12, 2026
0938d35
wifi: ath12k: Fix wrong P2P device link id issue
MilanoPipo Jan 8, 2026
b73b913
mhi: host: Add support for loading dual ELF image format
qianyu-qcom Dec 24, 2025
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
10 changes: 10 additions & 0 deletions drivers/bus/mhi/host/boot.c
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,16 @@ void mhi_fw_load_handler(struct mhi_controller *mhi_cntrl)
* device transitioning into MHI READY state
*/
if (fw_load_type == MHI_FW_LOAD_FBC) {
/*
* Some FW combine two separate ELF images (SBL + WLAN FW) in a single
* file. Hence, check for the existence of the second ELF header after
* SBL. If present, load the second image separately.
*/
if (!memcmp(fw_data + mhi_cntrl->sbl_size, ELFMAG, SELFMAG)) {
fw_data += mhi_cntrl->sbl_size;
fw_sz -= mhi_cntrl->sbl_size;
}

ret = mhi_alloc_bhie_table(mhi_cntrl, &mhi_cntrl->fbc_image, fw_sz);
if (ret) {
release_firmware(firmware);
Expand Down
8 changes: 5 additions & 3 deletions drivers/net/wireless/ath/ath12k/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
obj-$(CONFIG_ATH12K) += ath12k.o
ath12k-y += core.o \
hal.o \
hal_tx.o \
hal_rx.o \
wmi.o \
mac.o \
reg.o \
Expand All @@ -12,18 +10,22 @@ ath12k-y += core.o \
dp.o \
dp_tx.o \
dp_rx.o \
dp_htt.o \
dp_peer.o \
debug.o \
ce.o \
peer.o \
dbring.o \
hw.o \
mhi.o \
pci.o \
dp_mon.o \
fw.o \
p2p.o

ath12k-$(CONFIG_ATH12K_AHB) += ahb.o

obj-$(CONFIG_ATH12K) += wifi7/

ath12k-$(CONFIG_ATH12K_DEBUGFS) += debugfs.o debugfs_htt_stats.o debugfs_sta.o
ath12k-$(CONFIG_ACPI) += acpi.o
ath12k-$(CONFIG_ATH12K_TRACING) += trace.o
Expand Down
165 changes: 113 additions & 52 deletions drivers/net/wireless/ath/ath12k/ahb.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: BSD-3-Clause-Clear
/*
* Copyright (c) 2018-2019 The Linux Foundation. All rights reserved.
* Copyright (c) 2022-2025 Qualcomm Innovation Center, Inc. All rights reserved.
* Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
*/

#include <linux/dma-mapping.h>
Expand All @@ -16,18 +16,11 @@
#include "debug.h"
#include "hif.h"

static const struct of_device_id ath12k_ahb_of_match[] = {
{ .compatible = "qcom,ipq5332-wifi",
.data = (void *)ATH12K_HW_IPQ5332_HW10,
},
{ }
};

MODULE_DEVICE_TABLE(of, ath12k_ahb_of_match);

#define ATH12K_IRQ_CE0_OFFSET 4
#define ATH12K_MAX_UPDS 1
#define ATH12K_UPD_IRQ_WRD_LEN 18

static struct ath12k_ahb_driver *ath12k_ahb_family_drivers[ATH12K_DEVICE_FAMILY_MAX];
static const char ath12k_userpd_irq[][9] = {"spawn",
"ready",
"stop-ack"};
Expand Down Expand Up @@ -130,15 +123,15 @@ enum ext_irq_num {

static u32 ath12k_ahb_read32(struct ath12k_base *ab, u32 offset)
{
if (ab->ce_remap && offset < HAL_SEQ_WCSS_CMEM_OFFSET)
if (ab->ce_remap && offset < ab->cmem_offset)
return ioread32(ab->mem_ce + offset);
return ioread32(ab->mem + offset);
}

static void ath12k_ahb_write32(struct ath12k_base *ab, u32 offset,
u32 value)
{
if (ab->ce_remap && offset < HAL_SEQ_WCSS_CMEM_OFFSET)
if (ab->ce_remap && offset < ab->cmem_offset)
iowrite32(value, ab->mem_ce + offset);
else
iowrite32(value, ab->mem + offset);
Expand Down Expand Up @@ -531,9 +524,10 @@ static int ath12k_ahb_ext_grp_napi_poll(struct napi_struct *napi, int budget)
struct ath12k_ext_irq_grp,
napi);
struct ath12k_base *ab = irq_grp->ab;
struct ath12k_dp *dp = ath12k_ab_to_dp(ab);
int work_done;

work_done = ath12k_dp_service_srng(ab, irq_grp, budget);
work_done = ath12k_dp_service_srng(dp, irq_grp, budget);
if (work_done < budget) {
napi_complete_done(napi, work_done);
ath12k_ahb_ext_grp_enable(irq_grp);
Expand Down Expand Up @@ -563,12 +557,10 @@ static int ath12k_ahb_config_ext_irq(struct ath12k_base *ab)
{
const struct ath12k_hw_ring_mask *ring_mask;
struct ath12k_ext_irq_grp *irq_grp;
const struct hal_ops *hal_ops;
int i, j, irq, irq_idx, ret;
u32 num_irq;

ring_mask = ab->hw_params->ring_mask;
hal_ops = ab->hw_params->hal_ops;
for (i = 0; i < ATH12K_EXT_IRQ_GRP_NUM_MAX; i++) {
irq_grp = &ab->ext_irq_grp[i];
num_irq = 0;
Expand All @@ -588,7 +580,7 @@ static int ath12k_ahb_config_ext_irq(struct ath12k_base *ab)
* tcl_to_wbm_rbm_map point to the same ring number.
*/
if (ring_mask->tx[i] &
BIT(hal_ops->tcl_to_wbm_rbm_map[j].wbm_ring_num)) {
BIT(ab->hal.tcl_to_wbm_rbm_map[j].wbm_ring_num)) {
irq_grp->irqs[num_irq++] =
wbm2host_tx_completions_ring1 - j;
}
Expand Down Expand Up @@ -698,7 +690,7 @@ static int ath12k_ahb_map_service_to_pipe(struct ath12k_base *ab, u16 service_id
return 0;
}

static const struct ath12k_hif_ops ath12k_ahb_hif_ops_ipq5332 = {
static const struct ath12k_hif_ops ath12k_ahb_hif_ops = {
.start = ath12k_ahb_start,
.stop = ath12k_ahb_stop,
.read32 = ath12k_ahb_read32,
Expand Down Expand Up @@ -935,7 +927,8 @@ static int ath12k_ahb_resource_init(struct ath12k_base *ab)
goto err_mem_unmap;
}
ab->ce_remap = true;
ab->ce_remap_base_addr = HAL_IPQ5332_CE_WFSS_REG_BASE;
ab->cmem_offset = ce_remap->cmem_offset;
ab->ce_remap_base_addr = ce_remap->base;
}

ab_ahb->xo_clk = devm_clk_get(ab->dev, "xo");
Expand Down Expand Up @@ -988,13 +981,34 @@ static void ath12k_ahb_resource_deinit(struct ath12k_base *ab)
ab_ahb->xo_clk = NULL;
}

static enum ath12k_device_family
ath12k_ahb_get_device_family(const struct platform_device *pdev)
{
enum ath12k_device_family device_family_id;
struct ath12k_ahb_driver *driver;
const struct of_device_id *of_id;

for (device_family_id = ATH12K_DEVICE_FAMILY_START;
device_family_id < ATH12K_DEVICE_FAMILY_MAX; device_family_id++) {
driver = ath12k_ahb_family_drivers[device_family_id];
if (driver) {
of_id = of_match_device(driver->id_table, &pdev->dev);
if (of_id) {
/* Found the driver */
return device_family_id;
}
}
}

return ATH12K_DEVICE_FAMILY_MAX;
}

static int ath12k_ahb_probe(struct platform_device *pdev)
{
struct ath12k_base *ab;
const struct ath12k_hif_ops *hif_ops;
enum ath12k_device_family device_id;
struct ath12k_ahb *ab_ahb;
enum ath12k_hw_rev hw_rev;
u32 addr, userpd_id;
struct ath12k_base *ab;
u32 addr;
int ret;

ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
Expand All @@ -1008,25 +1022,32 @@ static int ath12k_ahb_probe(struct platform_device *pdev)
if (!ab)
return -ENOMEM;

hw_rev = (enum ath12k_hw_rev)(kernel_ulong_t)of_device_get_match_data(&pdev->dev);
switch (hw_rev) {
case ATH12K_HW_IPQ5332_HW10:
hif_ops = &ath12k_ahb_hif_ops_ipq5332;
userpd_id = ATH12K_IPQ5332_USERPD_ID;
break;
default:
ret = -EOPNOTSUPP;
ab_ahb = ath12k_ab_to_ahb(ab);
ab_ahb->ab = ab;
ab->hif.ops = &ath12k_ahb_hif_ops;
ab->pdev = pdev;
platform_set_drvdata(pdev, ab);

device_id = ath12k_ahb_get_device_family(pdev);
if (device_id >= ATH12K_DEVICE_FAMILY_MAX) {
ath12k_err(ab, "failed to get device family: %d\n", device_id);
ret = -EINVAL;
goto err_core_free;
}

ab->hif.ops = hif_ops;
ab->pdev = pdev;
ab->hw_rev = hw_rev;
ab->target_mem_mode = ATH12K_QMI_MEMORY_MODE_DEFAULT;
platform_set_drvdata(pdev, ab);
ab_ahb = ath12k_ab_to_ahb(ab);
ab_ahb->ab = ab;
ab_ahb->userpd_id = userpd_id;
ath12k_dbg(ab, ATH12K_DBG_AHB, "AHB device family id: %d\n", device_id);

ab_ahb->device_family_ops = &ath12k_ahb_family_drivers[device_id]->ops;

/* Call device specific probe. This is the callback that can
* be used to override any ops in future
* probe is validated for NULL during registration.
*/
ret = ab_ahb->device_family_ops->probe(pdev);
if (ret) {
ath12k_err(ab, "failed to probe device: %d\n", ret);
goto err_core_free;
}

/* Set fixed_mem_region to true for platforms that support fixed memory
* reservation from DT. If memory is reserved from DT for FW, ath12k driver
Expand Down Expand Up @@ -1065,14 +1086,26 @@ static int ath12k_ahb_probe(struct platform_device *pdev)
goto err_rproc_deconfigure;
}

/* Invoke arch_init here so that arch-specific init operations
* can utilize already initialized ab fields, such as HAL SRNGs.
*/
ret = ab_ahb->device_family_ops->arch_init(ab);
if (ret) {
ath12k_err(ab, "AHB arch_init failed %d\n", ret);
goto err_rproc_deconfigure;
}

ret = ath12k_core_init(ab);
if (ret) {
ath12k_err(ab, "failed to init core: %d\n", ret);
goto err_rproc_deconfigure;
goto err_deinit_arch;
}

return 0;

err_deinit_arch:
ab_ahb->device_family_ops->arch_deinit(ab);

err_rproc_deconfigure:
ath12k_ahb_deconfigure_rproc(ab);

Expand Down Expand Up @@ -1111,11 +1144,13 @@ static void ath12k_ahb_remove_prepare(struct ath12k_base *ab)
static void ath12k_ahb_free_resources(struct ath12k_base *ab)
{
struct platform_device *pdev = ab->pdev;
struct ath12k_ahb *ab_ahb = ath12k_ab_to_ahb(ab);

ath12k_hal_srng_deinit(ab);
ath12k_ce_free_pipes(ab);
ath12k_ahb_resource_deinit(ab);
ath12k_ahb_deconfigure_rproc(ab);
ab_ahb->device_family_ops->arch_deinit(ab);
ath12k_core_free(ab);
platform_set_drvdata(pdev, NULL);
}
Expand All @@ -1136,21 +1171,47 @@ static void ath12k_ahb_remove(struct platform_device *pdev)
ath12k_ahb_free_resources(ab);
}

static struct platform_driver ath12k_ahb_driver = {
.driver = {
.name = "ath12k_ahb",
.of_match_table = ath12k_ahb_of_match,
},
.probe = ath12k_ahb_probe,
.remove = ath12k_ahb_remove,
};

int ath12k_ahb_init(void)
int ath12k_ahb_register_driver(const enum ath12k_device_family device_id,
struct ath12k_ahb_driver *driver)
{
return platform_driver_register(&ath12k_ahb_driver);
struct platform_driver *ahb_driver;

if (device_id >= ATH12K_DEVICE_FAMILY_MAX)
return -EINVAL;

if (!driver || !driver->ops.probe ||
!driver->ops.arch_init || !driver->ops.arch_deinit)
return -EINVAL;

if (ath12k_ahb_family_drivers[device_id]) {
pr_err("Driver already registered for id %d\n", device_id);
return -EALREADY;
}

ath12k_ahb_family_drivers[device_id] = driver;

ahb_driver = &ath12k_ahb_family_drivers[device_id]->driver;
ahb_driver->driver.name = driver->name;
ahb_driver->driver.of_match_table = driver->id_table;
ahb_driver->probe = ath12k_ahb_probe;
ahb_driver->remove = ath12k_ahb_remove;

return platform_driver_register(ahb_driver);
}
EXPORT_SYMBOL(ath12k_ahb_register_driver);

void ath12k_ahb_exit(void)
void ath12k_ahb_unregister_driver(const enum ath12k_device_family device_id)
{
platform_driver_unregister(&ath12k_ahb_driver);
struct platform_driver *ahb_driver;

if (device_id >= ATH12K_DEVICE_FAMILY_MAX)
return;

if (!ath12k_ahb_family_drivers[device_id])
return;

ahb_driver = &ath12k_ahb_family_drivers[device_id]->driver;
platform_driver_unregister(ahb_driver);
ath12k_ahb_family_drivers[device_id] = NULL;
}
EXPORT_SYMBOL(ath12k_ahb_unregister_driver);
Loading