static int ath10k_download_board_data(struct ath10k *ar) { u32 board_data_size = QCA988X_BOARD_DATA_SZ; u32 address; int ret; ret = ath10k_push_board_ext_data(ar); if (ret) { ath10k_err(ar, "could not push board ext data (%d)\n", ret); goto exit; } ret = ath10k_bmi_read32(ar, hi_board_data, &address); if (ret) { ath10k_err(ar, "could not read board data addr (%d)\n", ret); goto exit; } ret = ath10k_bmi_write_memory(ar, address, ar->board_data, min_t(u32, board_data_size, ar->board_len)); if (ret) { ath10k_err(ar, "could not write board data (%d)\n", ret); goto exit; } ret = ath10k_bmi_write32(ar, hi_board_data_initialized, 1); if (ret) { ath10k_err(ar, "could not write board data bit (%d)\n", ret); goto exit; } exit: return ret; }
int ath10k_swap_code_seg_configure(struct ath10k *ar, enum ath10k_swap_code_seg_bin_type type) { int ret; struct ath10k_swap_code_seg_info *seg_info = NULL; switch (type) { case ATH10K_SWAP_CODE_SEG_BIN_TYPE_FW: if (!ar->swap.firmware_swap_code_seg_info) return 0; ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot found firmware code swap binary\n"); seg_info = ar->swap.firmware_swap_code_seg_info; break; default: case ATH10K_SWAP_CODE_SEG_BIN_TYPE_OTP: case ATH10K_SWAP_CODE_SEG_BIN_TYPE_UTF: ath10k_warn(ar, "ignoring unknown code swap binary type %d\n", type); return 0; } ret = ath10k_bmi_write_memory(ar, seg_info->target_addr, &seg_info->seg_hw_info, sizeof(seg_info->seg_hw_info)); if (ret) { ath10k_err(ar, "failed to write Code swap segment information (%d)\n", ret); return ret; } return 0; }
static int ath10k_push_board_ext_data(struct ath10k *ar, const void *data, size_t data_len) { u32 board_data_size = ar->hw_params.fw.board_size; u32 board_ext_data_size = ar->hw_params.fw.board_ext_size; u32 board_ext_data_addr; int ret; ret = ath10k_bmi_read32(ar, hi_board_ext_data, &board_ext_data_addr); if (ret) { ath10k_err(ar, "could not read board ext data addr (%d)\n", ret); return ret; } ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot push board extended data addr 0x%x\n", board_ext_data_addr); if (board_ext_data_addr == 0) return 0; if (data_len != (board_data_size + board_ext_data_size)) { ath10k_err(ar, "invalid board (ext) data sizes %zu != %d+%d\n", data_len, board_data_size, board_ext_data_size); return -EINVAL; } ret = ath10k_bmi_write_memory(ar, board_ext_data_addr, data + board_data_size, board_ext_data_size); if (ret) { ath10k_err(ar, "could not write board ext data (%d)\n", ret); return ret; } ret = ath10k_bmi_write32(ar, hi_board_ext_data_config, (board_ext_data_size << 16) | 1); if (ret) { ath10k_err(ar, "could not write board ext data bit (%d)\n", ret); return ret; } return 0; }
static int ath10k_push_board_ext_data(struct ath10k *ar) { u32 board_data_size = QCA988X_BOARD_DATA_SZ; u32 board_ext_data_size = QCA988X_BOARD_EXT_DATA_SZ; u32 board_ext_data_addr; int ret; ret = ath10k_bmi_read32(ar, hi_board_ext_data, &board_ext_data_addr); if (ret) { ath10k_err(ar, "could not read board ext data addr (%d)\n", ret); return ret; } ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot push board extended data addr 0x%x\n", board_ext_data_addr); if (board_ext_data_addr == 0) return 0; if (ar->board_len != (board_data_size + board_ext_data_size)) { ath10k_err(ar, "invalid board (ext) data sizes %zu != %d+%d\n", ar->board_len, board_data_size, board_ext_data_size); return -EINVAL; } ret = ath10k_bmi_write_memory(ar, board_ext_data_addr, ar->board_data + board_data_size, board_ext_data_size); if (ret) { ath10k_err(ar, "could not write board ext data (%d)\n", ret); return ret; } ret = ath10k_bmi_write32(ar, hi_board_ext_data_config, (board_ext_data_size << 16) | 1); if (ret) { ath10k_err(ar, "could not write board ext data bit (%d)\n", ret); return ret; } return 0; }
static int ath10k_download_board_data(struct ath10k *ar) { u32 board_data_size = QCA988X_BOARD_DATA_SZ; u32 address; const struct firmware *fw; int ret; fw = ath10k_fetch_fw_file(ar, ar->hw_params.fw.dir, ar->hw_params.fw.board); if (IS_ERR(fw)) { ath10k_err("could not fetch board data fw file (%ld)\n", PTR_ERR(fw)); return PTR_ERR(fw); } ret = ath10k_push_board_ext_data(ar, fw); if (ret) { ath10k_err("could not push board ext data (%d)\n", ret); goto exit; } ret = ath10k_bmi_read32(ar, hi_board_data, &address); if (ret) { ath10k_err("could not read board data addr (%d)\n", ret); goto exit; } ret = ath10k_bmi_write_memory(ar, address, fw->data, min_t(u32, board_data_size, fw->size)); if (ret) { ath10k_err("could not write board data (%d)\n", ret); goto exit; } ret = ath10k_bmi_write32(ar, hi_board_data_initialized, 1); if (ret) { ath10k_err("could not write board data bit (%d)\n", ret); goto exit; } exit: release_firmware(fw); return ret; }
static int ath10k_push_board_ext_data(struct ath10k *ar, const struct firmware *fw) { u32 board_data_size = QCA988X_BOARD_DATA_SZ; u32 board_ext_data_size = QCA988X_BOARD_EXT_DATA_SZ; u32 board_ext_data_addr; int ret; ret = ath10k_bmi_read32(ar, hi_board_ext_data, &board_ext_data_addr); if (ret) { ath10k_err("could not read board ext data addr (%d)\n", ret); return ret; } ath10k_dbg(ATH10K_DBG_CORE, "ath10k: Board extended Data download addr: 0x%x\n", board_ext_data_addr); if (board_ext_data_addr == 0) return 0; if (fw->size != (board_data_size + board_ext_data_size)) { ath10k_err("invalid board (ext) data sizes %zu != %d+%d\n", fw->size, board_data_size, board_ext_data_size); return -EINVAL; } ret = ath10k_bmi_write_memory(ar, board_ext_data_addr, fw->data + board_data_size, board_ext_data_size); if (ret) { ath10k_err("could not write board ext data (%d)\n", ret); return ret; } ret = ath10k_bmi_write32(ar, hi_board_ext_data_config, (board_ext_data_size << 16) | 1); if (ret) { ath10k_err("could not write board ext data bit (%d)\n", ret); return ret; } return 0; }
static int ath10k_download_board_data(struct ath10k *ar, const void *data, size_t data_len) { u32 board_data_size = ar->hw_params.fw.board_size; u32 address; int ret; ret = ath10k_push_board_ext_data(ar, data, data_len); if (ret) { ath10k_err(ar, "could not push board ext data (%d)\n", ret); goto exit; } ret = ath10k_bmi_read32(ar, hi_board_data, &address); if (ret) { ath10k_err(ar, "could not read board data addr (%d)\n", ret); goto exit; } ret = ath10k_bmi_write_memory(ar, address, data, min_t(u32, board_data_size, data_len)); if (ret) { ath10k_err(ar, "could not write board data (%d)\n", ret); goto exit; } ret = ath10k_bmi_write32(ar, hi_board_data_initialized, 1); if (ret) { ath10k_err(ar, "could not write board data bit (%d)\n", ret); goto exit; } exit: return ret; }
int ath10k_swap_code_seg_configure(struct ath10k *ar, const struct ath10k_fw_file *fw_file) { int ret; struct ath10k_swap_code_seg_info *seg_info = NULL; if (!fw_file->firmware_swap_code_seg_info) return 0; ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot found firmware code swap binary\n"); seg_info = fw_file->firmware_swap_code_seg_info; ret = ath10k_bmi_write_memory(ar, seg_info->target_addr, &seg_info->seg_hw_info, sizeof(seg_info->seg_hw_info)); if (ret) { ath10k_err(ar, "failed to write Code swap segment information (%d)\n", ret); return ret; } return 0; }
/** * ath10k_hw_qca6174_enable_pll_clock() - enable the qca6174 hw pll clock * @ar: the ath10k blob * * This function is very hardware specific, the clock initialization * steps is very sensitive and could lead to unknown crash, so they * should be done in sequence. * * *** Be aware if you planned to refactor them. *** * * Return: 0 if successfully enable the pll, otherwise EINVAL */ static int ath10k_hw_qca6174_enable_pll_clock(struct ath10k *ar) { int ret, wait_limit; u32 clk_div_addr, pll_init_addr, speed_addr; u32 addr, reg_val, mem_val; struct ath10k_hw_params *hw; const struct ath10k_hw_clk_params *hw_clk; hw = &ar->hw_params; if (ar->regs->core_clk_div_address == 0 || ar->regs->cpu_pll_init_address == 0 || ar->regs->cpu_speed_address == 0) return -EINVAL; clk_div_addr = ar->regs->core_clk_div_address; pll_init_addr = ar->regs->cpu_pll_init_address; speed_addr = ar->regs->cpu_speed_address; /* Read efuse register to find out the right hw clock configuration */ addr = (RTC_SOC_BASE_ADDRESS | EFUSE_OFFSET); ret = ath10k_bmi_read_soc_reg(ar, addr, ®_val); if (ret) return -EINVAL; /* sanitize if the hw refclk index is out of the boundary */ if (MS(reg_val, EFUSE_XTAL_SEL) > ATH10K_HW_REFCLK_COUNT) return -EINVAL; hw_clk = &hw->hw_clk[MS(reg_val, EFUSE_XTAL_SEL)]; /* Set the rnfrac and outdiv params to bb_pll register */ addr = (RTC_SOC_BASE_ADDRESS | BB_PLL_CONFIG_OFFSET); ret = ath10k_bmi_read_soc_reg(ar, addr, ®_val); if (ret) return -EINVAL; reg_val &= ~(BB_PLL_CONFIG_FRAC_MASK | BB_PLL_CONFIG_OUTDIV_MASK); reg_val |= (SM(hw_clk->rnfrac, BB_PLL_CONFIG_FRAC) | SM(hw_clk->outdiv, BB_PLL_CONFIG_OUTDIV)); ret = ath10k_bmi_write_soc_reg(ar, addr, reg_val); if (ret) return -EINVAL; /* Set the correct settle time value to pll_settle register */ addr = (RTC_WMAC_BASE_ADDRESS | WLAN_PLL_SETTLE_OFFSET); ret = ath10k_bmi_read_soc_reg(ar, addr, ®_val); if (ret) return -EINVAL; reg_val &= ~WLAN_PLL_SETTLE_TIME_MASK; reg_val |= SM(hw_clk->settle_time, WLAN_PLL_SETTLE_TIME); ret = ath10k_bmi_write_soc_reg(ar, addr, reg_val); if (ret) return -EINVAL; /* Set the clock_ctrl div to core_clk_ctrl register */ addr = (RTC_SOC_BASE_ADDRESS | SOC_CORE_CLK_CTRL_OFFSET); ret = ath10k_bmi_read_soc_reg(ar, addr, ®_val); if (ret) return -EINVAL; reg_val &= ~SOC_CORE_CLK_CTRL_DIV_MASK; reg_val |= SM(1, SOC_CORE_CLK_CTRL_DIV); ret = ath10k_bmi_write_soc_reg(ar, addr, reg_val); if (ret) return -EINVAL; /* Set the clock_div register */ mem_val = 1; ret = ath10k_bmi_write_memory(ar, clk_div_addr, &mem_val, sizeof(mem_val)); if (ret) return -EINVAL; /* Configure the pll_control register */ addr = (RTC_WMAC_BASE_ADDRESS | WLAN_PLL_CONTROL_OFFSET); ret = ath10k_bmi_read_soc_reg(ar, addr, ®_val); if (ret) return -EINVAL; reg_val |= (SM(hw_clk->refdiv, WLAN_PLL_CONTROL_REFDIV) | SM(hw_clk->div, WLAN_PLL_CONTROL_DIV) | SM(1, WLAN_PLL_CONTROL_NOPWD)); ret = ath10k_bmi_write_soc_reg(ar, addr, reg_val); if (ret) return -EINVAL; /* busy wait (max 1s) the rtc_sync status register indicate ready */ wait_limit = 100000; addr = (RTC_WMAC_BASE_ADDRESS | RTC_SYNC_STATUS_OFFSET); do { ret = ath10k_bmi_read_soc_reg(ar, addr, ®_val); if (ret) return -EINVAL; if (!MS(reg_val, RTC_SYNC_STATUS_PLL_CHANGING)) break; wait_limit--; udelay(10); } while (wait_limit > 0); if (MS(reg_val, RTC_SYNC_STATUS_PLL_CHANGING)) return -EINVAL; /* Unset the pll_bypass in pll_control register */ addr = (RTC_WMAC_BASE_ADDRESS | WLAN_PLL_CONTROL_OFFSET); ret = ath10k_bmi_read_soc_reg(ar, addr, ®_val); if (ret) return -EINVAL; reg_val &= ~WLAN_PLL_CONTROL_BYPASS_MASK; reg_val |= SM(0, WLAN_PLL_CONTROL_BYPASS); ret = ath10k_bmi_write_soc_reg(ar, addr, reg_val); if (ret) return -EINVAL; /* busy wait (max 1s) the rtc_sync status register indicate ready */ wait_limit = 100000; addr = (RTC_WMAC_BASE_ADDRESS | RTC_SYNC_STATUS_OFFSET); do { ret = ath10k_bmi_read_soc_reg(ar, addr, ®_val); if (ret) return -EINVAL; if (!MS(reg_val, RTC_SYNC_STATUS_PLL_CHANGING)) break; wait_limit--; udelay(10); } while (wait_limit > 0); if (MS(reg_val, RTC_SYNC_STATUS_PLL_CHANGING)) return -EINVAL; /* Enable the hardware cpu clock register */ addr = (RTC_SOC_BASE_ADDRESS | SOC_CPU_CLOCK_OFFSET); ret = ath10k_bmi_read_soc_reg(ar, addr, ®_val); if (ret) return -EINVAL; reg_val &= ~SOC_CPU_CLOCK_STANDARD_MASK; reg_val |= SM(1, SOC_CPU_CLOCK_STANDARD); ret = ath10k_bmi_write_soc_reg(ar, addr, reg_val); if (ret) return -EINVAL; /* unset the nopwd from pll_control register */ addr = (RTC_WMAC_BASE_ADDRESS | WLAN_PLL_CONTROL_OFFSET); ret = ath10k_bmi_read_soc_reg(ar, addr, ®_val); if (ret) return -EINVAL; reg_val &= ~WLAN_PLL_CONTROL_NOPWD_MASK; ret = ath10k_bmi_write_soc_reg(ar, addr, reg_val); if (ret) return -EINVAL; /* enable the pll_init register */ mem_val = 1; ret = ath10k_bmi_write_memory(ar, pll_init_addr, &mem_val, sizeof(mem_val)); if (ret) return -EINVAL; /* set the target clock frequency to speed register */ ret = ath10k_bmi_write_memory(ar, speed_addr, &hw->target_cpu_freq, sizeof(hw->target_cpu_freq)); if (ret) return -EINVAL; return 0; }