Commit 8bd7fc89958c2f23a5c5d0113ff65713683041ea

Authored by Eric Lapuyade
Committed by Samuel Ortiz
1 parent 352a5f5fb3

NFC: pn544: Add firmware operations hci ops

The firmware operation callback is passed by the physical layer to the
hci driver during probe. All the driver does is to store it and call it
when the fw_upload hci ops is invoked.

Signed-off-by: Eric Lapuyade <eric.lapuyade@intel.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>

Showing 4 changed files with 21 additions and 4 deletions Side-by-side Diff

drivers/nfc/pn544/i2c.c
... ... @@ -428,7 +428,7 @@
428 428  
429 429 r = pn544_hci_probe(phy, &i2c_phy_ops, LLC_SHDLC_NAME,
430 430 PN544_I2C_FRAME_HEADROOM, PN544_I2C_FRAME_TAILROOM,
431   - PN544_HCI_I2C_LLC_MAX_PAYLOAD, &phy->hdev);
  431 + PN544_HCI_I2C_LLC_MAX_PAYLOAD, NULL, &phy->hdev);
432 432 if (r < 0)
433 433 goto err_hci;
434 434  
drivers/nfc/pn544/mei.c
... ... @@ -45,7 +45,7 @@
45 45  
46 46 r = pn544_hci_probe(phy, &mei_phy_ops, LLC_NOP_NAME,
47 47 MEI_NFC_HEADER_SIZE, 0, MEI_NFC_MAX_HCI_PAYLOAD,
48   - &phy->hdev);
  48 + NULL, &phy->hdev);
49 49 if (r < 0) {
50 50 nfc_mei_phy_free(phy);
51 51  
drivers/nfc/pn544/pn544.c
... ... @@ -127,6 +127,8 @@
127 127 int async_cb_type;
128 128 data_exchange_cb_t async_cb;
129 129 void *async_cb_context;
  130 +
  131 + fw_download_t fw_download;
130 132 };
131 133  
132 134 static int pn544_hci_open(struct nfc_hci_dev *hdev)
... ... @@ -779,6 +781,17 @@
779 781 return r;
780 782 }
781 783  
  784 +static int pn544_hci_fw_download(struct nfc_hci_dev *hdev,
  785 + const char *firmware_name)
  786 +{
  787 + struct pn544_hci_info *info = nfc_hci_get_clientdata(hdev);
  788 +
  789 + if (info->fw_download == NULL)
  790 + return -ENOTSUPP;
  791 +
  792 + return info->fw_download(info->phy_id, firmware_name);
  793 +}
  794 +
782 795 static struct nfc_hci_ops pn544_hci_ops = {
783 796 .open = pn544_hci_open,
784 797 .close = pn544_hci_close,
785 798  
... ... @@ -793,11 +806,12 @@
793 806 .tm_send = pn544_hci_tm_send,
794 807 .check_presence = pn544_hci_check_presence,
795 808 .event_received = pn544_hci_event_received,
  809 + .fw_download = pn544_hci_fw_download,
796 810 };
797 811  
798 812 int pn544_hci_probe(void *phy_id, struct nfc_phy_ops *phy_ops, char *llc_name,
799 813 int phy_headroom, int phy_tailroom, int phy_payload,
800   - struct nfc_hci_dev **hdev)
  814 + fw_download_t fw_download, struct nfc_hci_dev **hdev)
801 815 {
802 816 struct pn544_hci_info *info;
803 817 u32 protocols;
... ... @@ -813,6 +827,7 @@
813 827  
814 828 info->phy_ops = phy_ops;
815 829 info->phy_id = phy_id;
  830 + info->fw_download = fw_download;
816 831 info->state = PN544_ST_COLD;
817 832 mutex_init(&info->info_lock);
818 833  
drivers/nfc/pn544/pn544.h
... ... @@ -27,9 +27,11 @@
27 27 #define PN544_HCI_MODE 0
28 28 #define PN544_FW_MODE 1
29 29  
  30 +typedef int (*fw_download_t)(void *context, const char *firmware_name);
  31 +
30 32 int pn544_hci_probe(void *phy_id, struct nfc_phy_ops *phy_ops, char *llc_name,
31 33 int phy_headroom, int phy_tailroom, int phy_payload,
32   - struct nfc_hci_dev **hdev);
  34 + fw_download_t fw_download, struct nfc_hci_dev **hdev);
33 35 void pn544_hci_remove(struct nfc_hci_dev *hdev);
34 36  
35 37 #endif /* __LOCAL_PN544_H_ */