Lines Matching refs:trans

97 static int iwl_eeprom_acquire_semaphore(struct iwl_trans *trans)  in iwl_eeprom_acquire_semaphore()  argument
104 iwl_set_bit(trans, CSR_HW_IF_CONFIG_REG, in iwl_eeprom_acquire_semaphore()
108 ret = iwl_poll_bit(trans, CSR_HW_IF_CONFIG_REG, in iwl_eeprom_acquire_semaphore()
113 IWL_DEBUG_EEPROM(trans->dev, in iwl_eeprom_acquire_semaphore()
123 static void iwl_eeprom_release_semaphore(struct iwl_trans *trans) in iwl_eeprom_release_semaphore() argument
125 iwl_clear_bit(trans, CSR_HW_IF_CONFIG_REG, in iwl_eeprom_release_semaphore()
129 static int iwl_eeprom_verify_signature(struct iwl_trans *trans, bool nvm_is_otp) in iwl_eeprom_verify_signature() argument
131 u32 gp = iwl_read32(trans, CSR_EEPROM_GP) & CSR_EEPROM_GP_VALID_MSK; in iwl_eeprom_verify_signature()
133 IWL_DEBUG_EEPROM(trans->dev, "EEPROM signature=0x%08x\n", gp); in iwl_eeprom_verify_signature()
138 IWL_ERR(trans, "EEPROM with bad signature: 0x%08x\n", in iwl_eeprom_verify_signature()
146 IWL_ERR(trans, "OTP with bad signature: 0x%08x\n", gp); in iwl_eeprom_verify_signature()
152 IWL_ERR(trans, in iwl_eeprom_verify_signature()
165 static void iwl_set_otp_access_absolute(struct iwl_trans *trans) in iwl_set_otp_access_absolute() argument
167 iwl_read32(trans, CSR_OTP_GP_REG); in iwl_set_otp_access_absolute()
169 iwl_clear_bit(trans, CSR_OTP_GP_REG, in iwl_set_otp_access_absolute()
173 static int iwl_nvm_is_otp(struct iwl_trans *trans) in iwl_nvm_is_otp() argument
178 switch (trans->hw_rev & CSR_HW_REV_TYPE_MSK) { in iwl_nvm_is_otp()
180 IWL_ERR(trans, "Unknown hardware type\n"); in iwl_nvm_is_otp()
188 otpgp = iwl_read32(trans, CSR_OTP_GP_REG); in iwl_nvm_is_otp()
195 static int iwl_init_otp_access(struct iwl_trans *trans) in iwl_init_otp_access() argument
200 iwl_write32(trans, CSR_GP_CNTRL, in iwl_init_otp_access()
201 iwl_read32(trans, CSR_GP_CNTRL) | in iwl_init_otp_access()
205 ret = iwl_poll_bit(trans, CSR_GP_CNTRL, in iwl_init_otp_access()
210 IWL_ERR(trans, "Time out access OTP\n"); in iwl_init_otp_access()
212 iwl_set_bits_prph(trans, APMG_PS_CTRL_REG, in iwl_init_otp_access()
215 iwl_clear_bits_prph(trans, APMG_PS_CTRL_REG, in iwl_init_otp_access()
222 if (trans->cfg->base_params->shadow_ram_support) in iwl_init_otp_access()
223 iwl_set_bit(trans, CSR_DBG_LINK_PWR_MGMT_REG, in iwl_init_otp_access()
229 static int iwl_read_otp_word(struct iwl_trans *trans, u16 addr, in iwl_read_otp_word() argument
236 iwl_write32(trans, CSR_EEPROM_REG, in iwl_read_otp_word()
238 ret = iwl_poll_bit(trans, CSR_EEPROM_REG, in iwl_read_otp_word()
243 IWL_ERR(trans, "Time out reading OTP[%d]\n", addr); in iwl_read_otp_word()
246 r = iwl_read32(trans, CSR_EEPROM_REG); in iwl_read_otp_word()
248 otpgp = iwl_read32(trans, CSR_OTP_GP_REG); in iwl_read_otp_word()
252 iwl_set_bit(trans, CSR_OTP_GP_REG, in iwl_read_otp_word()
254 IWL_ERR(trans, "Uncorrectable OTP ECC error, abort OTP read\n"); in iwl_read_otp_word()
260 iwl_set_bit(trans, CSR_OTP_GP_REG, in iwl_read_otp_word()
262 IWL_ERR(trans, "Correctable OTP ECC error, continue read\n"); in iwl_read_otp_word()
271 static bool iwl_is_otp_empty(struct iwl_trans *trans) in iwl_is_otp_empty() argument
278 if (!iwl_read_otp_word(trans, next_link_addr, &link_value)) { in iwl_is_otp_empty()
280 IWL_ERR(trans, "OTP is empty\n"); in iwl_is_otp_empty()
284 IWL_ERR(trans, "Unable to read first block of OTP list.\n"); in iwl_is_otp_empty()
301 static int iwl_find_otp_image(struct iwl_trans *trans, in iwl_find_otp_image() argument
309 iwl_set_otp_access_absolute(trans); in iwl_find_otp_image()
312 if (iwl_is_otp_empty(trans)) in iwl_find_otp_image()
326 IWL_DEBUG_EEPROM(trans->dev, "OTP blocks %d addr 0x%x\n", in iwl_find_otp_image()
328 if (iwl_read_otp_word(trans, next_link_addr, &link_value)) in iwl_find_otp_image()
343 } while (usedblocks <= trans->cfg->base_params->max_ll_items); in iwl_find_otp_image()
346 IWL_DEBUG_EEPROM(trans->dev, "OTP has no valid blocks\n"); in iwl_find_otp_image()
358 int iwl_read_eeprom(struct iwl_trans *trans, u8 **eeprom, size_t *eeprom_size) in iwl_read_eeprom() argument
361 u32 gp = iwl_read32(trans, CSR_EEPROM_GP); in iwl_read_eeprom()
372 nvm_is_otp = iwl_nvm_is_otp(trans); in iwl_read_eeprom()
376 sz = trans->cfg->base_params->eeprom_size; in iwl_read_eeprom()
377 IWL_DEBUG_EEPROM(trans->dev, "NVM size = %d\n", sz); in iwl_read_eeprom()
383 ret = iwl_eeprom_verify_signature(trans, nvm_is_otp); in iwl_read_eeprom()
385 IWL_ERR(trans, "EEPROM not found, EEPROM_GP=0x%08x\n", gp); in iwl_read_eeprom()
390 ret = iwl_eeprom_acquire_semaphore(trans); in iwl_read_eeprom()
392 IWL_ERR(trans, "Failed to acquire EEPROM semaphore.\n"); in iwl_read_eeprom()
397 ret = iwl_init_otp_access(trans); in iwl_read_eeprom()
399 IWL_ERR(trans, "Failed to initialize OTP access.\n"); in iwl_read_eeprom()
403 iwl_write32(trans, CSR_EEPROM_GP, in iwl_read_eeprom()
404 iwl_read32(trans, CSR_EEPROM_GP) & in iwl_read_eeprom()
407 iwl_set_bit(trans, CSR_OTP_GP_REG, in iwl_read_eeprom()
411 if (!trans->cfg->base_params->shadow_ram_support) { in iwl_read_eeprom()
412 ret = iwl_find_otp_image(trans, &validblockaddr); in iwl_read_eeprom()
420 ret = iwl_read_otp_word(trans, addr, &eeprom_data); in iwl_read_eeprom()
431 iwl_write32(trans, CSR_EEPROM_REG, in iwl_read_eeprom()
434 ret = iwl_poll_bit(trans, CSR_EEPROM_REG, in iwl_read_eeprom()
439 IWL_ERR(trans, in iwl_read_eeprom()
443 r = iwl_read32(trans, CSR_EEPROM_REG); in iwl_read_eeprom()
448 IWL_DEBUG_EEPROM(trans->dev, "NVM Type: %s\n", in iwl_read_eeprom()
451 iwl_eeprom_release_semaphore(trans); in iwl_read_eeprom()
458 iwl_eeprom_release_semaphore(trans); in iwl_read_eeprom()