qcacmn: Use wrappers for bus-oriented OS API's

Use appropriate wrappers for bus and platform related
OS API's.

Change-Id: I2b6d16f698816ef4851594717810bda6f167de32
CRs-Fixed: 2297169
This commit is contained in:
Debasis Das
2018-07-19 20:39:08 +05:30
committed by nshrivas
parent faadbb6cd0
commit 0c88e0f704
4 changed files with 99 additions and 43 deletions

View File

@@ -20,6 +20,7 @@
#include <ce_main.h>
#include <hif_irq_affinity.h>
#include "qdf_module.h"
#include "qdf_net_if.h"
/* mapping NAPI budget 0 to internal budget 0
* NAPI budget 1 to internal budget [1,scaler -1]
@@ -197,7 +198,7 @@ static struct hif_exec_context *hif_exec_napi_create(uint32_t scale)
ctx->exec_ctx.sched_ops = &napi_sched_ops;
ctx->exec_ctx.inited = true;
ctx->exec_ctx.scale_bin_shift = scale;
init_dummy_netdev(&(ctx->netdev));
qdf_net_if_create_dummy_if((struct qdf_net_if *)&ctx->netdev);
netif_napi_add(&(ctx->netdev), &(ctx->napi), hif_exec_poll,
QCA_NAPI_BUDGET);
napi_enable(&ctx->napi);

View File

@@ -46,6 +46,8 @@
#include <hif_irq_affinity.h>
#include "qdf_cpuhp.h"
#include "qdf_module.h"
#include "qdf_net_if.h"
#include "qdf_dev.h"
enum napi_decision_vector {
HIF_NAPI_NOEVENT = 0,
@@ -692,7 +694,8 @@ int hif_napi_event(struct hif_opaque_softc *hif_ctx, enum qca_napi_event event,
__func__, i);
napi_disable(napi);
/* in case it is affined, remove it */
irq_set_affinity_hint(napii->irq, NULL);
qdf_dev_set_irq_affinity(napii->irq,
NULL);
}
}
}
@@ -814,6 +817,7 @@ bool hif_napi_correct_cpu(struct qca_napi_info *napi_info)
cpumask_t cpumask;
int cpu;
struct qca_napi_data *napid;
QDF_STATUS ret;
napid = hif_napi_get_all(GET_HIF_OPAQUE_HDL(napi_info->hif_ctx));
@@ -829,8 +833,10 @@ bool hif_napi_correct_cpu(struct qca_napi_info *napi_info)
cpumask.bits[0] = (0x01 << napi_info->cpu);
irq_modify_status(napi_info->irq, IRQ_NO_BALANCING, 0);
rc = irq_set_affinity_hint(napi_info->irq,
&cpumask);
ret = qdf_dev_set_irq_affinity(napi_info->irq,
(struct qdf_cpu_mask *)
&cpumask);
rc = qdf_status_to_os_return(ret);
irq_modify_status(napi_info->irq, 0, IRQ_NO_BALANCING);
if (rc)
@@ -1463,6 +1469,7 @@ static int hncm_migrate_to(struct qca_napi_data *napid,
{
int rc = 0;
cpumask_t cpumask;
QDF_STATUS status;
NAPI_DEBUG("-->%s(napi_cd=%d, didx=%d)", __func__, napi_ce, didx);
@@ -1471,7 +1478,9 @@ static int hncm_migrate_to(struct qca_napi_data *napid,
return -EINVAL;
irq_modify_status(napid->napis[napi_ce]->irq, IRQ_NO_BALANCING, 0);
rc = irq_set_affinity_hint(napid->napis[napi_ce]->irq, &cpumask);
status = qdf_dev_set_irq_affinity(napid->napis[napi_ce]->irq,
(struct qdf_cpu_mask *)&cpumask);
rc = qdf_status_to_os_return(status);
/* unmark the napis bitmap in the cpu table */
napid->napi_cpu[napid->napis[napi_ce]->cpu].napis &= ~(0x01 << napi_ce);

View File

@@ -35,6 +35,7 @@
#include "ahb_api.h"
#include "pci_api.h"
#include "hif_napi.h"
#include "qal_vbus_dev.h"
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1, 0)
#define IRQF_DISABLED 0x00000020
@@ -218,7 +219,7 @@ int hif_ahb_configure_legacy_irq(struct hif_pci_softc *sc)
/* do not support MSI or MSI IRQ failed */
tasklet_init(&sc->intr_tq, wlan_tasklet, (unsigned long)sc);
irq = platform_get_irq_byname(pdev, "legacy");
qal_vbus_get_irq((struct qdf_pfm_hndl *)pdev, "legacy", &irq);
if (irq < 0) {
dev_err(&pdev->dev, "Unable to get irq\n");
ret = -1;
@@ -259,7 +260,8 @@ int hif_ahb_configure_irq(struct hif_pci_softc *sc)
for (i = 0; i < scn->ce_count; i++) {
if (host_ce_conf[i].flags & CE_ATTR_DISABLE_INTR)
continue;
irq = platform_get_irq_byname(pdev, ic_irqname[HIF_IC_CE0_IRQ_OFFSET + i]);
qal_vbus_get_irq((struct qdf_pfm_hndl *)pdev,
ic_irqname[HIF_IC_CE0_IRQ_OFFSET + i], &irq);
ic_irqnum[HIF_IC_CE0_IRQ_OFFSET + i] = irq;
ret = request_irq(irq ,
hif_ahb_interrupt_handler,
@@ -284,7 +286,6 @@ int hif_ahb_configure_grp_irq(struct hif_softc *scn,
struct hif_pci_softc *sc = HIF_GET_PCI_SOFTC(scn);
struct platform_device *pdev = (struct platform_device *)sc->pdev;
int irq = 0;
const char *irq_name;
int j;
/* configure external interrupts */
@@ -295,8 +296,8 @@ int hif_ahb_configure_grp_irq(struct hif_softc *scn,
qdf_spin_lock_irqsave(&hif_ext_group->irq_lock);
for (j = 0; j < hif_ext_group->numirq; j++) {
irq_name = ic_irqname[hif_ext_group->irq[j]];
irq = platform_get_irq_byname(pdev, irq_name);
qal_vbus_get_irq((struct qdf_pfm_hndl *)pdev,
ic_irqname[hif_ext_group->irq[j]], &irq);
ic_irqnum[hif_ext_group->irq[j]] = irq;
irq_set_status_flags(irq, IRQ_DISABLE_UNLAZY);
@@ -426,11 +427,14 @@ void hif_ahb_disable_bus(struct hif_softc *scn)
struct resource *memres = NULL;
int mem_pa_size = 0;
struct hif_target_info *tgt_info = NULL;
struct qdf_vbus_resource *vmres = NULL;
tgt_info = &scn->target_info;
/*Disable WIFI clock input*/
if (sc->mem) {
memres = platform_get_resource(pdev, IORESOURCE_MEM, 0);
qal_vbus_get_resource((struct qdf_pfm_hndl *)pdev, &vmres,
IORESOURCE_MEM, 0);
memres = (struct resource *)vmres;
if (!memres) {
HIF_INFO("%s: Failed to get IORESOURCE_MEM\n",
__func__);

View File

@@ -31,6 +31,7 @@
#include "ce_tasklet.h"
#include "ahb_api.h"
#include "if_ahb.h"
#include "qal_vbus_dev.h"
#include <linux/clk.h>
#include <linux/of_address.h>
@@ -60,6 +61,7 @@ static int clk_enable_disable(struct device *dev, const char *str, int enable)
{
struct clk *clk_t = NULL;
int ret;
QDF_STATUS status;
clk_t = clk_get(dev, str);
if (IS_ERR(clk_t)) {
@@ -69,17 +71,18 @@ static int clk_enable_disable(struct device *dev, const char *str, int enable)
}
if (true == enable) {
/* Prepare and Enable clk */
ret = clk_prepare_enable(clk_t);
status = qal_vbus_enable_devclk((struct qdf_dev_clk *)clk_t);
ret = qdf_status_to_os_return(status);
if (ret) {
HIF_INFO("%s: err enabling clk %s , error:%d\n",
__func__, str, ret);
return ret;
}
} else {
/* Disable and unprepare clk */
clk_disable_unprepare(clk_t);
status = qal_vbus_disable_devclk((struct qdf_dev_clk *)clk_t);
ret = qdf_status_to_os_return(status);
}
return 0;
return ret;
}
@@ -129,6 +132,7 @@ int hif_ahb_enable_radio(struct hif_pci_softc *sc,
struct device_node *dev_node = pdev->dev.of_node;
bool msienable = false;
int ret = 0;
struct qdf_vbus_rstctl *vrstctl = NULL;
ret = of_property_read_u32(dev_node, "qca,msi_addr", &msi_addr);
if (ret) {
@@ -198,47 +202,63 @@ int hif_ahb_enable_radio(struct hif_pci_softc *sc,
}
/* De-assert radio cold reset */
reset_ctl = reset_control_get(&pdev->dev, "wifi_radio_cold");
qal_vbus_get_dev_rstctl((struct qdf_pfm_hndl *)&pdev->dev,
"wifi_radio_cold", &vrstctl);
reset_ctl = (struct reset_control *)vrstctl;
if (IS_ERR(reset_ctl)) {
HIF_INFO("%s: Failed to get radio cold reset control\n",
__func__);
ret = PTR_ERR(reset_ctl);
goto err_reset;
}
reset_control_deassert(reset_ctl);
reset_control_put(reset_ctl);
qal_vbus_deactivate_dev_rstctl((struct qdf_pfm_hndl *)&pdev->dev,
(struct qdf_vbus_rstctl *)reset_ctl);
qal_vbus_release_dev_rstctl((struct qdf_pfm_hndl *)&pdev->dev,
(struct qdf_vbus_rstctl *)reset_ctl);
/* De-assert radio warm reset */
reset_ctl = reset_control_get(&pdev->dev, "wifi_radio_warm");
qal_vbus_get_dev_rstctl((struct qdf_pfm_hndl *)&pdev->dev,
"wifi_radio_warm", &vrstctl);
reset_ctl = (struct reset_control *)vrstctl;
if (IS_ERR(reset_ctl)) {
HIF_INFO("%s: Failed to get radio warm reset control\n",
__func__);
ret = PTR_ERR(reset_ctl);
goto err_reset;
}
reset_control_deassert(reset_ctl);
reset_control_put(reset_ctl);
qal_vbus_deactivate_dev_rstctl((struct qdf_pfm_hndl *)&pdev->dev,
(struct qdf_vbus_rstctl *)reset_ctl);
qal_vbus_release_dev_rstctl((struct qdf_pfm_hndl *)&pdev->dev,
(struct qdf_vbus_rstctl *)reset_ctl);
/* De-assert radio srif reset */
reset_ctl = reset_control_get(&pdev->dev, "wifi_radio_srif");
qal_vbus_get_dev_rstctl((struct qdf_pfm_hndl *)&pdev->dev,
"wifi_radio_srif", &vrstctl);
reset_ctl = (struct reset_control *)vrstctl;
if (IS_ERR(reset_ctl)) {
HIF_INFO("%s: Failed to get radio srif reset control\n",
__func__);
ret = PTR_ERR(reset_ctl);
goto err_reset;
}
reset_control_deassert(reset_ctl);
reset_control_put(reset_ctl);
qal_vbus_deactivate_dev_rstctl((struct qdf_pfm_hndl *)&pdev->dev,
(struct qdf_vbus_rstctl *)reset_ctl);
qal_vbus_release_dev_rstctl((struct qdf_pfm_hndl *)&pdev->dev,
(struct qdf_vbus_rstctl *)reset_ctl);
/* De-assert target CPU reset */
reset_ctl = reset_control_get(&pdev->dev, "wifi_cpu_init");
qal_vbus_get_dev_rstctl((struct qdf_pfm_hndl *)&pdev->dev,
"wifi_cpu_init", &vrstctl);
reset_ctl = (struct reset_control *)vrstctl;
if (IS_ERR(reset_ctl)) {
HIF_INFO("%s: Failed to get cpu init reset control", __func__);
ret = PTR_ERR(reset_ctl);
goto err_reset;
}
reset_control_deassert(reset_ctl);
reset_control_put(reset_ctl);
qal_vbus_activate_dev_rstctl((struct qdf_pfm_hndl *)&pdev->dev,
(struct qdf_vbus_rstctl *)reset_ctl);
qal_vbus_deactivate_dev_rstctl((struct qdf_pfm_hndl *)&pdev->dev,
(struct qdf_vbus_rstctl *)reset_ctl);
return 0;
@@ -282,6 +302,7 @@ void hif_ahb_device_reset(struct hif_softc *scn)
uint32_t wifi_core_id = 0XFFFFFFFF;
uint32_t reg_value;
int wait_limit = ATH_AHB_RESET_WAIT_MAX;
struct qdf_vbus_rstctl *vrstctl = NULL;
wifi_core_id = hif_read32_mb(sc, sc->mem +
@@ -313,14 +334,17 @@ void hif_ahb_device_reset(struct hif_softc *scn)
reg_value = hif_read32_mb(sc, mem_tcsr + glb_cfg_offset);
hif_write32_mb(sc, mem_tcsr + glb_cfg_offset, reg_value | (1 << 25));
core_resetctl = reset_control_get(&pdev->dev, AHB_RESET_TYPE);
qal_vbus_get_dev_rstctl((struct qdf_pfm_hndl *)&pdev->dev,
AHB_RESET_TYPE, &vrstctl);
core_resetctl = (struct reset_control *)vrstctl;
if (IS_ERR(core_resetctl)) {
HIF_INFO("Failed to get wifi core cold reset control\n");
return;
}
/* Reset wifi core */
reset_control_assert(core_resetctl);
qal_vbus_activate_dev_rstctl((struct qdf_pfm_hndl *)&pdev->dev,
(struct qdf_vbus_rstctl *)core_resetctl);
/* TBD: Check if we should also assert other bits (radio_cold, radio_
* warm, radio_srif, cpu_ini)
@@ -328,47 +352,63 @@ void hif_ahb_device_reset(struct hif_softc *scn)
qdf_mdelay(1); /* TBD: Get reqd delay from HW team */
/* Assert radio cold reset */
resetctl = reset_control_get(&pdev->dev, "wifi_radio_cold");
qal_vbus_get_dev_rstctl((struct qdf_pfm_hndl *)&pdev->dev,
"wifi_radio_cold", &vrstctl);
resetctl = (struct reset_control *)vrstctl;
if (IS_ERR(resetctl)) {
HIF_INFO("%s: Failed to get radio cold reset control\n",
__func__);
return;
}
reset_control_assert(resetctl);
qal_vbus_activate_dev_rstctl((struct qdf_pfm_hndl *)&pdev->dev,
(struct qdf_vbus_rstctl *)resetctl);
qdf_mdelay(1); /* TBD: Get reqd delay from HW team */
reset_control_put(resetctl);
qal_vbus_release_dev_rstctl((struct qdf_pfm_hndl *)&pdev->dev,
(struct qdf_vbus_rstctl *)resetctl);
/* Assert radio warm reset */
resetctl = reset_control_get(&pdev->dev, "wifi_radio_warm");
qal_vbus_get_dev_rstctl((struct qdf_pfm_hndl *)&pdev->dev,
"wifi_radio_warm", &vrstctl);
resetctl = (struct reset_control *)vrstctl;
if (IS_ERR(resetctl)) {
HIF_INFO("%s: Failed to get radio warm reset control\n",
__func__);
return;
}
reset_control_assert(resetctl);
qal_vbus_activate_dev_rstctl((struct qdf_pfm_hndl *)&pdev->dev,
(struct qdf_vbus_rstctl *)resetctl);
qdf_mdelay(1); /* TBD: Get reqd delay from HW team */
reset_control_put(resetctl);
qal_vbus_release_dev_rstctl((struct qdf_pfm_hndl *)&pdev->dev,
(struct qdf_vbus_rstctl *)resetctl);
/* Assert radio srif reset */
resetctl = reset_control_get(&pdev->dev, "wifi_radio_srif");
qal_vbus_get_dev_rstctl((struct qdf_pfm_hndl *)&pdev->dev,
"wifi_radio_srif", &vrstctl);
resetctl = (struct reset_control *)vrstctl;
if (IS_ERR(resetctl)) {
HIF_INFO("%s: Failed to get radio srif reset control\n",
__func__);
return;
}
reset_control_assert(resetctl);
qal_vbus_activate_dev_rstctl((struct qdf_pfm_hndl *)&pdev->dev,
(struct qdf_vbus_rstctl *)resetctl);
qdf_mdelay(1); /* TBD: Get reqd delay from HW team */
reset_control_put(resetctl);
qal_vbus_release_dev_rstctl((struct qdf_pfm_hndl *)&pdev->dev,
(struct qdf_vbus_rstctl *)resetctl);
/* Assert target CPU reset */
resetctl = reset_control_get(&pdev->dev, "wifi_cpu_init");
qal_vbus_get_dev_rstctl((struct qdf_pfm_hndl *)&pdev->dev,
"wifi_cpu_init", &vrstctl);
resetctl = (struct reset_control *)vrstctl;
if (IS_ERR(resetctl)) {
HIF_INFO("%s: Failed to get cpu init reset control", __func__);
return;
}
reset_control_assert(resetctl);
qal_vbus_activate_dev_rstctl((struct qdf_pfm_hndl *)&pdev->dev,
(struct qdf_vbus_rstctl *)resetctl);
qdf_mdelay(10); /* TBD: Get reqd delay from HW team */
reset_control_put(resetctl);
qal_vbus_release_dev_rstctl((struct qdf_pfm_hndl *)&pdev->dev,
(struct qdf_vbus_rstctl *)resetctl);
/* Clear gbl_cfg and haltreq before clearing Wifi core reset */
reg_value = hif_read32_mb(sc, mem_tcsr + haltreq_offset);
@@ -377,12 +417,14 @@ void hif_ahb_device_reset(struct hif_softc *scn)
hif_write32_mb(sc, mem_tcsr + glb_cfg_offset, reg_value & ~(1 << 25));
/* de-assert wifi core reset */
reset_control_deassert(core_resetctl);
qal_vbus_deactivate_dev_rstctl((struct qdf_pfm_hndl *)&pdev->dev,
(struct qdf_vbus_rstctl *)core_resetctl);
qdf_mdelay(1); /* TBD: Get reqd delay from HW team */
/* TBD: Check if we should de-assert other bits here */
reset_control_put(core_resetctl);
qal_vbus_release_dev_rstctl((struct qdf_pfm_hndl *)&pdev->dev,
(struct qdf_vbus_rstctl *)core_resetctl);
iounmap(mem_tcsr);
HIF_INFO("Reset complete for wifi core id : %d\n", wifi_core_id);
}