^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0-only */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Copyright (C) 2014 NXP Semiconductors All rights reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Authors: Clément Perrochaud <clement.perrochaud@nxp.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * Derived from PN544 device driver:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * Copyright (C) 2012 Intel Corporation. All rights reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #ifndef __LOCAL_NXP_NCI_H_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #define __LOCAL_NXP_NCI_H_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/completion.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <linux/firmware.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <linux/nfc.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <net/nfc/nci_core.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #define NXP_NCI_FW_HDR_LEN 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #define NXP_NCI_FW_CRC_LEN 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #define NXP_NCI_FW_FRAME_LEN_MASK 0x03FF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) enum nxp_nci_mode {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) NXP_NCI_MODE_COLD,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) NXP_NCI_MODE_NCI,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) NXP_NCI_MODE_FW
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) struct nxp_nci_phy_ops {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) int (*set_mode)(void *id, enum nxp_nci_mode mode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) int (*write)(void *id, struct sk_buff *skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) struct nxp_nci_fw_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) char name[NFC_FIRMWARE_NAME_MAXSIZE + 1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) const struct firmware *fw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) size_t size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) size_t written;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) const u8 *data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) size_t frame_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) struct work_struct work;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) struct completion cmd_completion;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) int cmd_result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) struct nxp_nci_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) struct nci_dev *ndev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) void *phy_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) struct device *pdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) enum nxp_nci_mode mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) const struct nxp_nci_phy_ops *phy_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) unsigned int max_payload;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) struct mutex info_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) struct nxp_nci_fw_info fw_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) int nxp_nci_fw_download(struct nci_dev *ndev, const char *firmware_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) void nxp_nci_fw_work(struct work_struct *work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) void nxp_nci_fw_recv_frame(struct nci_dev *ndev, struct sk_buff *skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) void nxp_nci_fw_work_complete(struct nxp_nci_info *info, int result);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) int nxp_nci_probe(void *phy_id, struct device *pdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) const struct nxp_nci_phy_ops *phy_ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) unsigned int max_payload,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) struct nci_dev **ndev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) void nxp_nci_remove(struct nci_dev *ndev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) #endif /* __LOCAL_NXP_NCI_H_ */