Commit 31858805 authored by Govind Singh's avatar Govind Singh Committed by Kalle Valo
Browse files

ath11k: Add support for multibus support



Current design supports only AHB interface for
11ax chipset. Refactor the code by adding hif layer
for bus level abstraction to support  PCI based device.

Signed-off-by: default avatarGovind Singh <govinds@codeaurora.org>
Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/20200506094400.4740-2-govinds@codeaurora.org
parent e47210f7
Loading
Loading
Loading
Loading
+39 −10
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@
#include <linux/dma-mapping.h>
#include "ahb.h"
#include "debug.h"
#include "hif.h"
#include <linux/remoteproc.h>

static const struct of_device_id ath11k_ahb_of_match[] = {
@@ -434,6 +435,16 @@ enum ext_irq_num {
	tcl2host_status_ring,
};

static inline u32 ath11k_ahb_read32(struct ath11k_base *ab, u32 offset)
{
	return ioread32(ab->mem + offset);
}

static inline void ath11k_ahb_write32(struct ath11k_base *ab, u32 offset, u32 value)
{
	iowrite32(value, ab->mem + offset);
}

static void ath11k_ahb_kill_tasklets(struct ath11k_base *ab)
{
	int i;
@@ -575,7 +586,7 @@ static void ath11k_ahb_ce_irqs_disable(struct ath11k_base *ab)
	}
}

int ath11k_ahb_start(struct ath11k_base *ab)
static int ath11k_ahb_start(struct ath11k_base *ab)
{
	ath11k_ahb_ce_irqs_enable(ab);
	ath11k_ce_rx_post_buf(ab);
@@ -583,7 +594,7 @@ int ath11k_ahb_start(struct ath11k_base *ab)
	return 0;
}

void ath11k_ahb_ext_irq_enable(struct ath11k_base *ab)
static void ath11k_ahb_ext_irq_enable(struct ath11k_base *ab)
{
	int i;

@@ -595,13 +606,13 @@ void ath11k_ahb_ext_irq_enable(struct ath11k_base *ab)
	}
}

void ath11k_ahb_ext_irq_disable(struct ath11k_base *ab)
static void ath11k_ahb_ext_irq_disable(struct ath11k_base *ab)
{
	__ath11k_ahb_ext_irq_disable(ab);
	ath11k_ahb_sync_ext_irqs(ab);
}

void ath11k_ahb_stop(struct ath11k_base *ab)
static void ath11k_ahb_stop(struct ath11k_base *ab)
{
	if (!test_bit(ATH11K_FLAG_CRASH_FLUSH, &ab->dev_flags))
		ath11k_ahb_ce_irqs_disable(ab);
@@ -611,7 +622,7 @@ void ath11k_ahb_stop(struct ath11k_base *ab)
	ath11k_ce_cleanup_pipes(ab);
}

int ath11k_ahb_power_up(struct ath11k_base *ab)
static int ath11k_ahb_power_up(struct ath11k_base *ab)
{
	int ret;

@@ -622,7 +633,7 @@ int ath11k_ahb_power_up(struct ath11k_base *ab)
	return ret;
}

void ath11k_ahb_power_down(struct ath11k_base *ab)
static void ath11k_ahb_power_down(struct ath11k_base *ab)
{
	rproc_shutdown(ab->tgt_rproc);
}
@@ -834,7 +845,7 @@ static int ath11k_ahb_config_irq(struct ath11k_base *ab)
	return ret;
}

int ath11k_ahb_map_service_to_pipe(struct ath11k_base *ab, u16 service_id,
static int ath11k_ahb_map_service_to_pipe(struct ath11k_base *ab, u16 service_id,
					  u8 *ul_pipe, u8 *dl_pipe)
{
	const struct service_to_pipe *entry;
@@ -877,6 +888,18 @@ int ath11k_ahb_map_service_to_pipe(struct ath11k_base *ab, u16 service_id,
	return 0;
}

static const struct ath11k_hif_ops ath11k_ahb_hif_ops = {
	.start = ath11k_ahb_start,
	.stop = ath11k_ahb_stop,
	.read32 = ath11k_ahb_read32,
	.write32 = ath11k_ahb_write32,
	.irq_enable = ath11k_ahb_ext_irq_enable,
	.irq_disable = ath11k_ahb_ext_irq_disable,
	.map_service_to_pipe = ath11k_ahb_map_service_to_pipe,
	.power_down = ath11k_ahb_power_down,
	.power_up = ath11k_ahb_power_up,
};

static int ath11k_ahb_probe(struct platform_device *pdev)
{
	struct ath11k_base *ab;
@@ -915,6 +938,7 @@ static int ath11k_ahb_probe(struct platform_device *pdev)
		return -ENOMEM;
	}

	ab->hif.ops = &ath11k_ahb_hif_ops;
	ab->pdev = pdev;
	ab->hw_rev = (enum ath11k_hw_rev)of_id->data;
	ab->mem = mem;
@@ -993,12 +1017,17 @@ static struct platform_driver ath11k_ahb_driver = {
	.remove = ath11k_ahb_remove,
};

int ath11k_ahb_init(void)
static int ath11k_ahb_init(void)
{
	return platform_driver_register(&ath11k_ahb_driver);
}
module_init(ath11k_ahb_init);

void ath11k_ahb_exit(void)
static void ath11k_ahb_exit(void)
{
	platform_driver_unregister(&ath11k_ahb_driver);
}
module_exit(ath11k_ahb_exit);

MODULE_DESCRIPTION("Driver support for Qualcomm Technologies 802.11ax wireless chip");
MODULE_LICENSE("Dual BSD/GPL");
+0 −22
Original line number Diff line number Diff line
@@ -10,26 +10,4 @@
#define ATH11K_AHB_RECOVERY_TIMEOUT (3 * HZ)
struct ath11k_base;

static inline u32 ath11k_ahb_read32(struct ath11k_base *ab, u32 offset)
{
	return ioread32(ab->mem + offset);
}

static inline void ath11k_ahb_write32(struct ath11k_base *ab, u32 offset, u32 value)
{
	iowrite32(value, ab->mem + offset);
}

void ath11k_ahb_ext_irq_enable(struct ath11k_base *ab);
void ath11k_ahb_ext_irq_disable(struct ath11k_base *ab);
int ath11k_ahb_start(struct ath11k_base *ab);
void ath11k_ahb_stop(struct ath11k_base *ab);
int ath11k_ahb_power_up(struct ath11k_base *ab);
void ath11k_ahb_power_down(struct ath11k_base *ab);
int ath11k_ahb_map_service_to_pipe(struct ath11k_base *ab, u16 service_id,
				   u8 *ul_pipe, u8 *dl_pipe);

int ath11k_ahb_init(void);
void ath11k_ahb_exit(void);

#endif
+11 −30
Original line number Diff line number Diff line
@@ -12,6 +12,7 @@
#include "dp_tx.h"
#include "dp_rx.h"
#include "debug.h"
#include "hif.h"

unsigned int ath11k_debug_mask;
module_param_named(debug_mask, ath11k_debug_mask, uint, 0644);
@@ -41,6 +42,7 @@ u8 ath11k_core_get_hw_mac_id(struct ath11k_base *ab, int pdev_idx)
		return ATH11K_INVALID_HW_MAC_ID;
	}
}
EXPORT_SYMBOL(ath11k_core_get_hw_mac_id);

static int ath11k_core_create_board_name(struct ath11k_base *ab, char *name,
					 size_t name_len)
@@ -324,7 +326,7 @@ static void ath11k_core_stop(struct ath11k_base *ab)
{
	if (!test_bit(ATH11K_FLAG_CRASH_FLUSH, &ab->dev_flags))
		ath11k_qmi_firmware_stop(ab);
	ath11k_ahb_stop(ab);
	ath11k_hif_stop(ab);
	ath11k_wmi_detach(ab);
	ath11k_dp_pdev_reo_cleanup(ab);

@@ -347,7 +349,7 @@ static int ath11k_core_soc_create(struct ath11k_base *ab)
		goto err_qmi_deinit;
	}

	ret = ath11k_ahb_power_up(ab);
	ret = ath11k_hif_power_up(ab);
	if (ret) {
		ath11k_err(ab, "failed to power up :%d\n", ret);
		goto err_debugfs_reg;
@@ -415,7 +417,7 @@ static void ath11k_core_pdev_destroy(struct ath11k_base *ab)
{
	ath11k_thermal_unregister(ab);
	ath11k_mac_unregister(ab);
	ath11k_ahb_ext_irq_disable(ab);
	ath11k_hif_irq_disable(ab);
	ath11k_dp_pdev_free(ab);
	ath11k_debug_pdev_destroy(ab);
}
@@ -443,7 +445,7 @@ static int ath11k_core_start(struct ath11k_base *ab,
		goto err_wmi_detach;
	}

	ret = ath11k_ahb_start(ab);
	ret = ath11k_hif_start(ab);
	if (ret) {
		ath11k_err(ab, "failed to start HIF: %d\n", ret);
		goto err_wmi_detach;
@@ -522,7 +524,7 @@ err_reo_cleanup:
err_mac_destroy:
	ath11k_mac_destroy(ab);
err_hif_stop:
	ath11k_ahb_stop(ab);
	ath11k_hif_stop(ab);
err_wmi_detach:
	ath11k_wmi_detach(ab);
err_firmware_stop:
@@ -559,7 +561,7 @@ int ath11k_core_qmi_firmware_ready(struct ath11k_base *ab)
		ath11k_err(ab, "failed to create pdev core: %d\n", ret);
		goto err_core_stop;
	}
	ath11k_ahb_ext_irq_enable(ab);
	ath11k_hif_irq_enable(ab);
	mutex_unlock(&ab->core_lock);

	return 0;
@@ -579,9 +581,9 @@ static int ath11k_core_reconfigure_on_crash(struct ath11k_base *ab)

	mutex_lock(&ab->core_lock);
	ath11k_thermal_unregister(ab);
	ath11k_ahb_ext_irq_disable(ab);
	ath11k_hif_irq_disable(ab);
	ath11k_dp_pdev_free(ab);
	ath11k_ahb_stop(ab);
	ath11k_hif_stop(ab);
	ath11k_wmi_detach(ab);
	ath11k_dp_pdev_reo_cleanup(ab);
	mutex_unlock(&ab->core_lock);
@@ -744,7 +746,7 @@ void ath11k_core_deinit(struct ath11k_base *ab)

	mutex_unlock(&ab->core_lock);

	ath11k_ahb_power_down(ab);
	ath11k_hif_power_down(ab);
	ath11k_mac_destroy(ab);
	ath11k_core_soc_destroy(ab);
}
@@ -784,24 +786,3 @@ err_sc_free:
	kfree(ab);
	return NULL;
}

static int __init ath11k_init(void)
{
	int ret;

	ret = ath11k_ahb_init();
	if (ret)
		printk(KERN_ERR "failed to register ath11k ahb driver: %d\n",
		       ret);
	return ret;
}
module_init(ath11k_init);

static void __exit ath11k_exit(void)
{
	ath11k_ahb_exit();
}
module_exit(ath11k_exit);

MODULE_DESCRIPTION("Driver support for Qualcomm Technologies 802.11ax wireless chip");
MODULE_LICENSE("Dual BSD/GPL");
+3 −1
Original line number Diff line number Diff line
@@ -607,7 +607,9 @@ struct ath11k_base {
	void __iomem *mem;
	unsigned long mem_len;

	const struct ath11k_hif_ops *hif_ops;
	struct {
		const struct ath11k_hif_ops *ops;
	} hif;

	struct ath11k_ce ce;
	struct timer_list rx_replenish_retry;
+1 −0
Original line number Diff line number Diff line
@@ -701,6 +701,7 @@ int ath11k_dp_service_srng(struct ath11k_base *ab,
done:
	return tot_work_done;
}
EXPORT_SYMBOL(ath11k_dp_service_srng);

void ath11k_dp_pdev_free(struct ath11k_base *ab)
{
Loading