xref: /linux/drivers/net/wireless/ath/ath12k/wifi7/ahb.c (revision 37a93dd5c49b5fda807fd204edf2547c3493319c)
1 // SPDX-License-Identifier: BSD-3-Clause-Clear
2 /*
3  * Copyright (c) 2018-2019 The Linux Foundation. All rights reserved.
4  * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
5  */
6 
7 #include <linux/of_device.h>
8 #include <linux/platform_device.h>
9 #include <linux/soc/qcom/mdt_loader.h>
10 #include "../ahb.h"
11 #include "ahb.h"
12 #include "../debug.h"
13 #include "../hif.h"
14 #include "hw.h"
15 #include "dp.h"
16 #include "core.h"
17 
18 static const struct of_device_id ath12k_wifi7_ahb_of_match[] = {
19 	{ .compatible = "qcom,ipq5332-wifi",
20 	  .data = (void *)ATH12K_HW_IPQ5332_HW10,
21 	},
22 	{ }
23 };
24 
25 MODULE_DEVICE_TABLE(of, ath12k_wifi7_ahb_of_match);
26 
27 static int ath12k_wifi7_ahb_probe(struct platform_device *pdev)
28 {
29 	struct ath12k_ahb *ab_ahb;
30 	enum ath12k_hw_rev hw_rev;
31 	struct ath12k_base *ab;
32 	int ret;
33 
34 	ab = platform_get_drvdata(pdev);
35 	ab_ahb = ath12k_ab_to_ahb(ab);
36 
37 	hw_rev = (enum ath12k_hw_rev)(kernel_ulong_t)of_device_get_match_data(&pdev->dev);
38 	switch (hw_rev) {
39 	case ATH12K_HW_IPQ5332_HW10:
40 		ab_ahb->userpd_id = ATH12K_IPQ5332_USERPD_ID;
41 		break;
42 	default:
43 		return -EOPNOTSUPP;
44 	}
45 
46 	ab->target_mem_mode = ATH12K_QMI_MEMORY_MODE_DEFAULT;
47 	ab->hw_rev = hw_rev;
48 
49 	ret = ath12k_wifi7_hw_init(ab);
50 	if (ret) {
51 		ath12k_err(ab, "WiFi-7 hw_init for AHB failed: %d\n", ret);
52 		return ret;
53 	}
54 
55 	return 0;
56 }
57 
58 static struct ath12k_ahb_driver ath12k_wifi7_ahb_driver = {
59 	.name = "ath12k_wifi7_ahb",
60 	.id_table = ath12k_wifi7_ahb_of_match,
61 	.ops.probe = ath12k_wifi7_ahb_probe,
62 	.ops.arch_init = ath12k_wifi7_arch_init,
63 	.ops.arch_deinit = ath12k_wifi7_arch_deinit,
64 };
65 
66 int ath12k_wifi7_ahb_init(void)
67 {
68 	return ath12k_ahb_register_driver(ATH12K_DEVICE_FAMILY_WIFI7,
69 					  &ath12k_wifi7_ahb_driver);
70 }
71 
72 void ath12k_wifi7_ahb_exit(void)
73 {
74 	ath12k_ahb_unregister_driver(ATH12K_DEVICE_FAMILY_WIFI7);
75 }
76