Commit 8bd7fc89 authored by Eric Lapuyade's avatar Eric Lapuyade Committed by Samuel Ortiz

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: default avatarEric Lapuyade <eric.lapuyade@intel.com>
Signed-off-by: default avatarSamuel Ortiz <sameo@linux.intel.com>
parent 352a5f5f
...@@ -428,7 +428,7 @@ static int pn544_hci_i2c_probe(struct i2c_client *client, ...@@ -428,7 +428,7 @@ static int pn544_hci_i2c_probe(struct i2c_client *client,
r = pn544_hci_probe(phy, &i2c_phy_ops, LLC_SHDLC_NAME, r = pn544_hci_probe(phy, &i2c_phy_ops, LLC_SHDLC_NAME,
PN544_I2C_FRAME_HEADROOM, PN544_I2C_FRAME_TAILROOM, PN544_I2C_FRAME_HEADROOM, PN544_I2C_FRAME_TAILROOM,
PN544_HCI_I2C_LLC_MAX_PAYLOAD, &phy->hdev); PN544_HCI_I2C_LLC_MAX_PAYLOAD, NULL, &phy->hdev);
if (r < 0) if (r < 0)
goto err_hci; goto err_hci;
......
...@@ -45,7 +45,7 @@ static int pn544_mei_probe(struct mei_cl_device *device, ...@@ -45,7 +45,7 @@ static int pn544_mei_probe(struct mei_cl_device *device,
r = pn544_hci_probe(phy, &mei_phy_ops, LLC_NOP_NAME, r = pn544_hci_probe(phy, &mei_phy_ops, LLC_NOP_NAME,
MEI_NFC_HEADER_SIZE, 0, MEI_NFC_MAX_HCI_PAYLOAD, MEI_NFC_HEADER_SIZE, 0, MEI_NFC_MAX_HCI_PAYLOAD,
&phy->hdev); NULL, &phy->hdev);
if (r < 0) { if (r < 0) {
nfc_mei_phy_free(phy); nfc_mei_phy_free(phy);
......
...@@ -127,6 +127,8 @@ struct pn544_hci_info { ...@@ -127,6 +127,8 @@ struct pn544_hci_info {
int async_cb_type; int async_cb_type;
data_exchange_cb_t async_cb; data_exchange_cb_t async_cb;
void *async_cb_context; void *async_cb_context;
fw_download_t fw_download;
}; };
static int pn544_hci_open(struct nfc_hci_dev *hdev) static int pn544_hci_open(struct nfc_hci_dev *hdev)
...@@ -779,6 +781,17 @@ static int pn544_hci_event_received(struct nfc_hci_dev *hdev, u8 gate, u8 event, ...@@ -779,6 +781,17 @@ static int pn544_hci_event_received(struct nfc_hci_dev *hdev, u8 gate, u8 event,
return r; return r;
} }
static int pn544_hci_fw_download(struct nfc_hci_dev *hdev,
const char *firmware_name)
{
struct pn544_hci_info *info = nfc_hci_get_clientdata(hdev);
if (info->fw_download == NULL)
return -ENOTSUPP;
return info->fw_download(info->phy_id, firmware_name);
}
static struct nfc_hci_ops pn544_hci_ops = { static struct nfc_hci_ops pn544_hci_ops = {
.open = pn544_hci_open, .open = pn544_hci_open,
.close = pn544_hci_close, .close = pn544_hci_close,
...@@ -793,11 +806,12 @@ static struct nfc_hci_ops pn544_hci_ops = { ...@@ -793,11 +806,12 @@ static struct nfc_hci_ops pn544_hci_ops = {
.tm_send = pn544_hci_tm_send, .tm_send = pn544_hci_tm_send,
.check_presence = pn544_hci_check_presence, .check_presence = pn544_hci_check_presence,
.event_received = pn544_hci_event_received, .event_received = pn544_hci_event_received,
.fw_download = pn544_hci_fw_download,
}; };
int pn544_hci_probe(void *phy_id, struct nfc_phy_ops *phy_ops, char *llc_name, int pn544_hci_probe(void *phy_id, struct nfc_phy_ops *phy_ops, char *llc_name,
int phy_headroom, int phy_tailroom, int phy_payload, int phy_headroom, int phy_tailroom, int phy_payload,
struct nfc_hci_dev **hdev) fw_download_t fw_download, struct nfc_hci_dev **hdev)
{ {
struct pn544_hci_info *info; struct pn544_hci_info *info;
u32 protocols; u32 protocols;
...@@ -813,6 +827,7 @@ int pn544_hci_probe(void *phy_id, struct nfc_phy_ops *phy_ops, char *llc_name, ...@@ -813,6 +827,7 @@ int pn544_hci_probe(void *phy_id, struct nfc_phy_ops *phy_ops, char *llc_name,
info->phy_ops = phy_ops; info->phy_ops = phy_ops;
info->phy_id = phy_id; info->phy_id = phy_id;
info->fw_download = fw_download;
info->state = PN544_ST_COLD; info->state = PN544_ST_COLD;
mutex_init(&info->info_lock); mutex_init(&info->info_lock);
......
...@@ -27,9 +27,11 @@ ...@@ -27,9 +27,11 @@
#define PN544_HCI_MODE 0 #define PN544_HCI_MODE 0
#define PN544_FW_MODE 1 #define PN544_FW_MODE 1
typedef int (*fw_download_t)(void *context, const char *firmware_name);
int pn544_hci_probe(void *phy_id, struct nfc_phy_ops *phy_ops, char *llc_name, int pn544_hci_probe(void *phy_id, struct nfc_phy_ops *phy_ops, char *llc_name,
int phy_headroom, int phy_tailroom, int phy_payload, int phy_headroom, int phy_tailroom, int phy_payload,
struct nfc_hci_dev **hdev); fw_download_t fw_download, struct nfc_hci_dev **hdev);
void pn544_hci_remove(struct nfc_hci_dev *hdev); void pn544_hci_remove(struct nfc_hci_dev *hdev);
#endif /* __LOCAL_PN544_H_ */ #endif /* __LOCAL_PN544_H_ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment