// SPDX-License-Identifier: GPL-2.0 #include "softmac_core.h" #include "hal_common.h" int _rpu_umac_if_init(struct proc_dir_entry **main_dir_entry) { int error=0; error = proc_init(&main_dir_entry); if (error) return error; error = rpu_init(); return error; } void _rpu_umac_if_exit(void) { rpu_exit(); proc_exit(); } int rpu_core_init(struct img_priv *priv, unsigned int ftm) { int ret = 0; unsigned int reset_type = LMAC_ENABLE; rpu_if_init(priv, priv->name); /* Enable the LMAC, set defaults and initialize TX */ priv->reset_complete = 0; pr_info("%s-UMAC: Reset (ENABLE)\n", priv->name); if (hal_ops.start()) { ret = -1; pr_err("%s:%d hal_ops.start failed\n", __FUNCTION__, __LINE__); goto rpu_if_deinit; } if (ftm) CALL_RPU(rpu_prog_reset, reset_type, LMAC_MODE_FTM); else CALL_RPU(rpu_prog_reset, reset_type, LMAC_MODE_NORMAL); if (wait_for_reset_complete(priv) < 0) { ret = -1; pr_err("%s:%d wait_for_reset_complete failed\n", __FUNCTION__, __LINE__); goto hal_deinit_bufs; } CALL_RPU(rpu_prog_txpower, priv->txpower); CALL_RPU(rpu_prog_mcast_filter_control, MCAST_FILTER_DISABLE); rpu_tx_init(priv); return 0; hal_deinit_bufs: hal_ops.deinit_bufs(); prog_rpu_fail: rpu_if_deinit: rpu_if_deinit(); return ret; } void rpu_core_deinit(struct img_priv *priv, unsigned int ftm) { int ret = 0; /* De initialize tx and disable LMAC*/ rpu_tx_deinit(priv); /* Disable the LMAC */ priv->reset_complete = 0; pr_info("%s-UMAC: Reset (DISABLE)\n", priv->name); if (ftm) CALL_RPU(rpu_prog_reset, LMAC_DISABLE, LMAC_MODE_FTM); else CALL_RPU(rpu_prog_reset, LMAC_DISABLE, LMAC_MODE_NORMAL); wait_for_reset_complete(priv); hal_ops.deinit_bufs(); prog_rpu_fail: rpu_if_free_outstnding(); rpu_if_deinit(); } void rpu_reset_complete(unsigned int lmac_version, void *context) { struct img_priv *priv = (struct img_priv *)context; priv->reset_complete = 1; mutex_unlock_timedout(&priv->reset_complete_sem,1); } void rpu_store_stats(struct lmac_event_stats *prod_stats) { if ((prod_stats->type == STATS_TYPE_PHY)) { wifi->stats.ofdm_crc32_pass_cnt = prod_stats->stats.phy_stats.ofdm_crc32_pass_cnt; wifi->stats.ofdm_crc32_fail_cnt = prod_stats->stats.phy_stats.ofdm_crc32_fail_cnt; wifi->stats.dsss_crc32_pass_cnt = prod_stats->stats.phy_stats.dsss_crc32_pass_cnt; wifi->stats.dsss_crc32_fail_cnt = prod_stats->stats.phy_stats.dsss_crc32_fail_cnt; wifi->params.rssi_average = prod_stats->stats.phy_stats.averageRSSI; } return; } void rpu_ch_prog_complete(int event, struct lmac_event_ch_prog_complete *prog_ch, void *context) { (void)event; (void)prog_ch; struct img_priv *priv = (struct img_priv *)context; priv->chan_prog_done = 1; mutex_unlock_timedout(&priv->reset_complete_sem,1); }