Lines Matching +full:firmware +full:- +full:initialized
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /* -------------------------------------------------------------------------
3 * Copyright (C) 2014-2016, Intel Corporation
5 * -------------------------------------------------------------------------
12 #include <linux/firmware.h>
45 const struct firmware *otp_patch;
46 const struct firmware *ram_patch;
92 r = nci_core_conn_create(info->ndev, FDP_PATCH_CONN_DEST, 1, in fdp_nci_create_conn()
127 delta = 24 * fc - nd * clock_freq; in fdp_nci_set_clock()
148 info->setup_patch_sent = 1; in fdp_nci_send_patch_cb()
149 wake_up(&info->setup_wq); in fdp_nci_send_patch_cb()
155 * We have no other way of knowing when all firmware packets were sent out
163 struct device *dev = &info->phy->i2c_dev->dev; in fdp_nci_set_data_pkt_counter()
166 atomic_set(&info->data_pkt_counter, count); in fdp_nci_set_data_pkt_counter()
167 info->data_pkt_counter_cb = cb; in fdp_nci_set_data_pkt_counter()
172 * have the PBF flag set to 0x0 (last packet) even if the firmware
174 * whole firmware to nci_send_data it will segment it and it will set
177 * The firmware will be analyzed and applied when we send NCI_OP_PROP_PATCH_CMD
184 const struct firmware *fw; in fdp_nci_send_patch()
190 if ((type == NCI_PATCH_TYPE_OTP && !info->otp_patch) || in fdp_nci_send_patch()
191 (type == NCI_PATCH_TYPE_RAM && !info->ram_patch)) in fdp_nci_send_patch()
192 return -EINVAL; in fdp_nci_send_patch()
195 fw = info->otp_patch; in fdp_nci_send_patch()
197 fw = info->ram_patch; in fdp_nci_send_patch()
201 return -EINVAL; in fdp_nci_send_patch()
203 len = fw->size; in fdp_nci_send_patch()
206 DIV_ROUND_UP(fw->size, max_size)); in fdp_nci_send_patch()
216 return -ENOMEM; in fdp_nci_send_patch()
222 skb_put_data(skb, fw->data + (fw->size - len), payload_size); in fdp_nci_send_patch()
231 len -= payload_size; in fdp_nci_send_patch()
241 struct device *dev = &info->phy->i2c_dev->dev; in fdp_nci_open()
245 r = info->phy_ops->enable(info->phy); in fdp_nci_open()
253 struct device *dev = &info->phy->i2c_dev->dev; in fdp_nci_close()
262 struct device *dev = &info->phy->i2c_dev->dev; in fdp_nci_send()
266 if (atomic_dec_and_test(&info->data_pkt_counter)) in fdp_nci_send()
267 info->data_pkt_counter_cb(ndev); in fdp_nci_send()
269 return info->phy_ops->write(info->phy, skb); in fdp_nci_send()
275 struct device *dev = &info->phy->i2c_dev->dev; in fdp_nci_recv_frame()
285 struct device *dev = &info->phy->i2c_dev->dev; in fdp_nci_request_firmware()
289 r = request_firmware(&info->ram_patch, FDP_RAM_PATCH_NAME, dev); in fdp_nci_request_firmware()
295 data = (u8 *) info->ram_patch->data; in fdp_nci_request_firmware()
296 info->ram_patch_version = in fdp_nci_request_firmware()
303 info->ram_patch_version, (int) info->ram_patch->size); in fdp_nci_request_firmware()
306 r = request_firmware(&info->otp_patch, FDP_OTP_PATCH_NAME, dev); in fdp_nci_request_firmware()
312 data = (u8 *) info->otp_patch->data; in fdp_nci_request_firmware()
313 info->otp_patch_version = in fdp_nci_request_firmware()
320 info->otp_patch_version, (int) info->otp_patch->size); in fdp_nci_request_firmware()
331 if (info->otp_patch) { in fdp_nci_release_firmware()
332 release_firmware(info->otp_patch); in fdp_nci_release_firmware()
333 info->otp_patch = NULL; in fdp_nci_release_firmware()
336 if (info->ram_patch) { in fdp_nci_release_firmware()
337 release_firmware(info->ram_patch); in fdp_nci_release_firmware()
338 info->ram_patch = NULL; in fdp_nci_release_firmware()
345 struct device *dev = &info->phy->i2c_dev->dev; in fdp_nci_patch_otp()
349 if (info->otp_version >= info->otp_patch_version) in fdp_nci_patch_otp()
352 info->setup_patch_sent = 0; in fdp_nci_patch_otp()
353 info->setup_reset_ntf = 0; in fdp_nci_patch_otp()
354 info->setup_patch_ntf = 0; in fdp_nci_patch_otp()
374 wait_event_interruptible(info->setup_wq, in fdp_nci_patch_otp()
375 info->setup_patch_sent == 1); in fdp_nci_patch_otp()
381 r = nci_core_conn_close(info->ndev, conn_id); in fdp_nci_patch_otp()
388 r = -EINVAL; in fdp_nci_patch_otp()
393 wait_event_interruptible(info->setup_wq, info->setup_patch_ntf); in fdp_nci_patch_otp()
396 r = info->setup_patch_status; in fdp_nci_patch_otp()
399 r = -EINVAL; in fdp_nci_patch_otp()
407 wait_event_interruptible(info->setup_wq, info->setup_reset_ntf); in fdp_nci_patch_otp()
416 struct device *dev = &info->phy->i2c_dev->dev; in fdp_nci_patch_ram()
420 if (info->ram_version >= info->ram_patch_version) in fdp_nci_patch_ram()
423 info->setup_patch_sent = 0; in fdp_nci_patch_ram()
424 info->setup_reset_ntf = 0; in fdp_nci_patch_ram()
425 info->setup_patch_ntf = 0; in fdp_nci_patch_ram()
445 wait_event_interruptible(info->setup_wq, in fdp_nci_patch_ram()
446 info->setup_patch_sent == 1); in fdp_nci_patch_ram()
452 r = nci_core_conn_close(info->ndev, conn_id); in fdp_nci_patch_ram()
459 r = -EINVAL; in fdp_nci_patch_ram()
464 wait_event_interruptible(info->setup_wq, info->setup_patch_ntf); in fdp_nci_patch_ram()
467 r = info->setup_patch_status; in fdp_nci_patch_ram()
470 r = -EINVAL; in fdp_nci_patch_ram()
478 wait_event_interruptible(info->setup_wq, info->setup_reset_ntf); in fdp_nci_patch_ram()
488 struct device *dev = &info->phy->i2c_dev->dev; in fdp_nci_setup()
503 /* Load firmware from disk */ in fdp_nci_setup()
509 if (info->otp_version < info->otp_patch_version) { in fdp_nci_setup()
517 if (info->ram_version < info->ram_patch_version) { in fdp_nci_setup()
524 /* Release the firmware buffers */ in fdp_nci_setup()
537 if (info->otp_version != info->otp_patch_version || in fdp_nci_setup()
538 info->ram_version != info->ram_patch_version) { in fdp_nci_setup()
539 nfc_err(dev, "Firmware update failed"); in fdp_nci_setup()
540 r = -EINVAL; in fdp_nci_setup()
546 * We initialized the devices but the NFC subsystem expects in fdp_nci_setup()
547 * it to not be initialized. in fdp_nci_setup()
560 struct device *dev = &info->phy->i2c_dev->dev; in fdp_nci_post_setup()
564 if (info->fw_vsc_cfg && info->fw_vsc_cfg[0]) { in fdp_nci_post_setup()
567 r = fdp_nci_set_production_data(ndev, info->fw_vsc_cfg[3], in fdp_nci_post_setup()
568 &info->fw_vsc_cfg[4]); in fdp_nci_post_setup()
577 r = fdp_nci_set_clock(ndev, info->clock_type, info->clock_freq); in fdp_nci_post_setup()
591 * The nci core was initialized when post setup was called in fdp_nci_post_setup()
601 struct device *dev = &info->phy->i2c_dev->dev; in fdp_nci_core_reset_ntf_packet()
604 info->setup_reset_ntf = 1; in fdp_nci_core_reset_ntf_packet()
605 wake_up(&info->setup_wq); in fdp_nci_core_reset_ntf_packet()
614 struct device *dev = &info->phy->i2c_dev->dev; in fdp_nci_prop_patch_ntf_packet()
617 info->setup_patch_ntf = 1; in fdp_nci_prop_patch_ntf_packet()
618 info->setup_patch_status = skb->data[0]; in fdp_nci_prop_patch_ntf_packet()
619 wake_up(&info->setup_wq); in fdp_nci_prop_patch_ntf_packet()
628 struct device *dev = &info->phy->i2c_dev->dev; in fdp_nci_prop_patch_rsp_packet()
629 u8 status = skb->data[0]; in fdp_nci_prop_patch_rsp_packet()
641 struct device *dev = &info->phy->i2c_dev->dev; in fdp_nci_prop_set_production_data_rsp_packet()
642 u8 status = skb->data[0]; in fdp_nci_prop_set_production_data_rsp_packet()
654 struct device *dev = &info->phy->i2c_dev->dev; in fdp_nci_core_get_config_rsp_packet()
655 struct nci_core_get_config_rsp *rsp = (void *) skb->data; in fdp_nci_core_get_config_rsp_packet()
658 if (rsp->status == NCI_STATUS_OK) { in fdp_nci_core_get_config_rsp_packet()
660 p = rsp->data; in fdp_nci_core_get_config_rsp_packet()
666 info->ram_version = le32_to_cpup((__le32 *) p); in fdp_nci_core_get_config_rsp_packet()
671 info->otp_version = le32_to_cpup((__le32 *) p); in fdp_nci_core_get_config_rsp_packet()
676 info->otp_version = le32_to_cpup((__le32 *) p); in fdp_nci_core_get_config_rsp_packet()
681 info->key_index = *p++; in fdp_nci_core_get_config_rsp_packet()
686 dev_dbg(dev, "OTP version %d\n", info->otp_version); in fdp_nci_core_get_config_rsp_packet()
687 dev_dbg(dev, "RAM version %d\n", info->ram_version); in fdp_nci_core_get_config_rsp_packet()
688 dev_dbg(dev, "key index %d\n", info->key_index); in fdp_nci_core_get_config_rsp_packet()
689 dev_dbg(dev, "%s: status 0x%x\n", __func__, rsp->status); in fdp_nci_core_get_config_rsp_packet()
691 nci_req_complete(ndev, rsp->status); in fdp_nci_core_get_config_rsp_packet()
737 struct device *dev = &phy->i2c_dev->dev; in fdp_nci_probe()
745 return -ENOMEM; in fdp_nci_probe()
747 info->phy = phy; in fdp_nci_probe()
748 info->phy_ops = phy_ops; in fdp_nci_probe()
749 info->clock_type = clock_type; in fdp_nci_probe()
750 info->clock_freq = clock_freq; in fdp_nci_probe()
751 info->fw_vsc_cfg = fw_vsc_cfg; in fdp_nci_probe()
753 init_waitqueue_head(&info->setup_wq); in fdp_nci_probe()
767 return -ENOMEM; in fdp_nci_probe()
775 info->ndev = ndev; in fdp_nci_probe()
790 struct device *dev = &info->phy->i2c_dev->dev; in fdp_nci_remove()