diff options
author | Scott Wood <scottwood@freescale.com> | 2014-04-07 23:49:35 (GMT) |
---|---|---|
committer | Scott Wood <scottwood@freescale.com> | 2014-04-07 23:49:35 (GMT) |
commit | 62b8c978ee6b8d135d9e7953221de58000dba986 (patch) | |
tree | 683b04b2e627f6710c22c151b23c8cc9a165315e /drivers/nfc/pn544 | |
parent | 78fd82238d0e5716578c326404184a27ba67fd6e (diff) | |
download | linux-fsl-qoriq-62b8c978ee6b8d135d9e7953221de58000dba986.tar.xz |
Rewind v3.13-rc3+ (78fd82238d0e5716) to v3.12
Diffstat (limited to 'drivers/nfc/pn544')
-rw-r--r-- | drivers/nfc/pn544/i2c.c | 42 | ||||
-rw-r--r-- | drivers/nfc/pn544/pn544.c | 129 |
2 files changed, 36 insertions, 135 deletions
diff --git a/drivers/nfc/pn544/i2c.c b/drivers/nfc/pn544/i2c.c index b158ee1..01e27d4 100644 --- a/drivers/nfc/pn544/i2c.c +++ b/drivers/nfc/pn544/i2c.c @@ -18,8 +18,6 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - #include <linux/crc-ccitt.h> #include <linux/module.h> #include <linux/i2c.h> @@ -153,7 +151,8 @@ static void pn544_hci_i2c_platform_init(struct pn544_i2c_phy *phy) char rset_cmd[] = { 0x05, 0xF9, 0x04, 0x00, 0xC3, 0xE5 }; int count = sizeof(rset_cmd); - nfc_info(&phy->i2c_dev->dev, "Detecting nfc_en polarity\n"); + pr_info(DRIVER_DESC ": %s\n", __func__); + dev_info(&phy->i2c_dev->dev, "Detecting nfc_en polarity\n"); /* Disable fw download */ gpio_set_value(phy->gpio_fw, 0); @@ -174,7 +173,7 @@ static void pn544_hci_i2c_platform_init(struct pn544_i2c_phy *phy) dev_dbg(&phy->i2c_dev->dev, "Sending reset cmd\n"); ret = i2c_master_send(phy->i2c_dev, rset_cmd, count); if (ret == count) { - nfc_info(&phy->i2c_dev->dev, + dev_info(&phy->i2c_dev->dev, "nfc_en polarity : active %s\n", (polarity == 0 ? "low" : "high")); goto out; @@ -182,7 +181,7 @@ static void pn544_hci_i2c_platform_init(struct pn544_i2c_phy *phy) } } - nfc_err(&phy->i2c_dev->dev, + dev_err(&phy->i2c_dev->dev, "Could not detect nfc_en polarity, fallback to active high\n"); out: @@ -202,7 +201,7 @@ static int pn544_hci_i2c_enable(void *phy_id) { struct pn544_i2c_phy *phy = phy_id; - pr_info("%s\n", __func__); + pr_info(DRIVER_DESC ": %s\n", __func__); pn544_hci_i2c_enable_mode(phy, PN544_HCI_MODE); @@ -215,6 +214,8 @@ static void pn544_hci_i2c_disable(void *phy_id) { struct pn544_i2c_phy *phy = phy_id; + pr_info(DRIVER_DESC ": %s\n", __func__); + gpio_set_value(phy->gpio_fw, 0); gpio_set_value(phy->gpio_en, !phy->en_polarity); usleep_range(10000, 15000); @@ -297,9 +298,11 @@ static int check_crc(u8 *buf, int buflen) crc = ~crc; if (buf[len - 2] != (crc & 0xff) || buf[len - 1] != (crc >> 8)) { - pr_err("CRC error 0x%x != 0x%x 0x%x\n", + pr_err(PN544_HCI_I2C_DRIVER_NAME + ": CRC error 0x%x != 0x%x 0x%x\n", crc, buf[len - 1], buf[len - 2]); - pr_info("%s: BAD CRC\n", __func__); + + pr_info(DRIVER_DESC ": %s : BAD CRC\n", __func__); print_hex_dump(KERN_DEBUG, "crc: ", DUMP_PREFIX_NONE, 16, 2, buf, buflen, false); return -EPERM; @@ -325,13 +328,13 @@ static int pn544_hci_i2c_read(struct pn544_i2c_phy *phy, struct sk_buff **skb) r = i2c_master_recv(client, &len, 1); if (r != 1) { - nfc_err(&client->dev, "cannot read len byte\n"); + dev_err(&client->dev, "cannot read len byte\n"); return -EREMOTEIO; } if ((len < (PN544_HCI_I2C_LLC_MIN_SIZE - 1)) || (len > (PN544_HCI_I2C_LLC_MAX_SIZE - 1))) { - nfc_err(&client->dev, "invalid len byte\n"); + dev_err(&client->dev, "invalid len byte\n"); r = -EBADMSG; goto flush; } @@ -383,7 +386,7 @@ static int pn544_hci_i2c_fw_read_status(struct pn544_i2c_phy *phy) r = i2c_master_recv(client, (char *) &response, sizeof(response)); if (r != sizeof(response)) { - nfc_err(&client->dev, "cannot read fw status\n"); + dev_err(&client->dev, "cannot read fw status\n"); return -EIO; } @@ -475,7 +478,8 @@ static int pn544_hci_i2c_fw_download(void *phy_id, const char *firmware_name) { struct pn544_i2c_phy *phy = phy_id; - pr_info("Starting Firmware Download (%s)\n", firmware_name); + pr_info(DRIVER_DESC ": Starting Firmware Download (%s)\n", + firmware_name); strcpy(phy->firmware_name, firmware_name); @@ -489,7 +493,7 @@ static int pn544_hci_i2c_fw_download(void *phy_id, const char *firmware_name) static void pn544_hci_i2c_fw_work_complete(struct pn544_i2c_phy *phy, int result) { - pr_info("Firmware Download Complete, result=%d\n", result); + pr_info(DRIVER_DESC ": Firmware Download Complete, result=%d\n", result); pn544_hci_i2c_disable(phy); @@ -690,14 +694,14 @@ static int pn544_hci_i2c_probe(struct i2c_client *client, dev_dbg(&client->dev, "IRQ: %d\n", client->irq); if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { - nfc_err(&client->dev, "Need I2C_FUNC_I2C\n"); + dev_err(&client->dev, "Need I2C_FUNC_I2C\n"); return -ENODEV; } phy = devm_kzalloc(&client->dev, sizeof(struct pn544_i2c_phy), GFP_KERNEL); if (!phy) { - nfc_err(&client->dev, + dev_err(&client->dev, "Cannot allocate memory for pn544 i2c phy.\n"); return -ENOMEM; } @@ -710,18 +714,18 @@ static int pn544_hci_i2c_probe(struct i2c_client *client, pdata = client->dev.platform_data; if (pdata == NULL) { - nfc_err(&client->dev, "No platform data\n"); + dev_err(&client->dev, "No platform data\n"); return -EINVAL; } if (pdata->request_resources == NULL) { - nfc_err(&client->dev, "request_resources() missing\n"); + dev_err(&client->dev, "request_resources() missing\n"); return -EINVAL; } r = pdata->request_resources(client); if (r) { - nfc_err(&client->dev, "Cannot get platform resources\n"); + dev_err(&client->dev, "Cannot get platform resources\n"); return r; } @@ -735,7 +739,7 @@ static int pn544_hci_i2c_probe(struct i2c_client *client, IRQF_TRIGGER_RISING | IRQF_ONESHOT, PN544_HCI_I2C_DRIVER_NAME, phy); if (r < 0) { - nfc_err(&client->dev, "Unable to register IRQ handler\n"); + dev_err(&client->dev, "Unable to register IRQ handler\n"); goto err_rti; } diff --git a/drivers/nfc/pn544/pn544.c b/drivers/nfc/pn544/pn544.c index 74cfa0a..078e62f 100644 --- a/drivers/nfc/pn544/pn544.c +++ b/drivers/nfc/pn544/pn544.c @@ -18,8 +18,6 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - #include <linux/delay.h> #include <linux/slab.h> #include <linux/module.h> @@ -43,7 +41,6 @@ enum pn544_state { /* Proprietary commands */ #define PN544_WRITE 0x3f -#define PN544_TEST_SWP 0x21 /* Proprietary gates, events, commands and registers */ @@ -84,17 +81,14 @@ enum pn544_state { #define PN544_PL_NFCT_DEACTIVATED 0x09 #define PN544_SWP_MGMT_GATE 0xA0 -#define PN544_SWP_DEFAULT_MODE 0x01 #define PN544_NFC_WI_MGMT_GATE 0xA1 -#define PN544_NFC_ESE_DEFAULT_MODE 0x01 #define PN544_HCI_EVT_SND_DATA 0x01 #define PN544_HCI_EVT_ACTIVATED 0x02 #define PN544_HCI_EVT_DEACTIVATED 0x03 #define PN544_HCI_EVT_RCV_DATA 0x04 #define PN544_HCI_EVT_CONTINUE_MI 0x05 -#define PN544_HCI_EVT_SWITCH_MODE 0x03 #define PN544_HCI_CMD_ATTREQUEST 0x12 #define PN544_HCI_CMD_CONTINUE_ACTIVATION 0x13 @@ -193,6 +187,13 @@ static int pn544_hci_ready(struct nfc_hci_dev *hdev) {{0x9e, 0xb4}, 0x00}, + {{0x9e, 0xd9}, 0xff}, + {{0x9e, 0xda}, 0xff}, + {{0x9e, 0xdb}, 0x23}, + {{0x9e, 0xdc}, 0x21}, + {{0x9e, 0xdd}, 0x22}, + {{0x9e, 0xde}, 0x24}, + {{0x9c, 0x01}, 0x08}, {{0x9e, 0xaa}, 0x01}, @@ -393,7 +394,7 @@ static int pn544_hci_start_poll(struct nfc_hci_dev *hdev, if ((im_protocols | tm_protocols) & NFC_PROTO_NFC_DEP_MASK) { hdev->gb = nfc_get_local_general_bytes(hdev->ndev, &hdev->gb_len); - pr_debug("generate local bytes %p\n", hdev->gb); + pr_debug("generate local bytes %p", hdev->gb); if (hdev->gb == NULL || hdev->gb_len == 0) { im_protocols &= ~NFC_PROTO_NFC_DEP_MASK; tm_protocols &= ~NFC_PROTO_NFC_DEP_MASK; @@ -695,7 +696,7 @@ static int pn544_hci_tm_send(struct nfc_hci_dev *hdev, struct sk_buff *skb) static int pn544_hci_check_presence(struct nfc_hci_dev *hdev, struct nfc_target *target) { - pr_debug("supported protocol %d\b", target->supported_protocols); + pr_debug("supported protocol %d", target->supported_protocols); if (target->supported_protocols & (NFC_PROTO_ISO14443_MASK | NFC_PROTO_ISO14443_B_MASK)) { return nfc_hci_send_cmd(hdev, target->hci_reader_gate, @@ -732,7 +733,7 @@ static int pn544_hci_event_received(struct nfc_hci_dev *hdev, u8 gate, u8 event, struct sk_buff *rgb_skb = NULL; int r; - pr_debug("hci event %d\n", event); + pr_debug("hci event %d", event); switch (event) { case PN544_HCI_EVT_ACTIVATED: if (gate == PN544_RF_READER_NFCIP1_INITIATOR_GATE) { @@ -763,7 +764,7 @@ static int pn544_hci_event_received(struct nfc_hci_dev *hdev, u8 gate, u8 event, } if (skb->data[0] != 0) { - pr_debug("data0 %d\n", skb->data[0]); + pr_debug("data0 %d", skb->data[0]); r = -EPROTO; goto exit; } @@ -791,108 +792,6 @@ static int pn544_hci_fw_download(struct nfc_hci_dev *hdev, return info->fw_download(info->phy_id, firmware_name); } -static int pn544_hci_discover_se(struct nfc_hci_dev *hdev) -{ - u32 se_idx = 0; - u8 ese_mode = 0x01; /* Default mode */ - struct sk_buff *res_skb; - int r; - - r = nfc_hci_send_cmd(hdev, PN544_SYS_MGMT_GATE, PN544_TEST_SWP, - NULL, 0, &res_skb); - - if (r == 0) { - if (res_skb->len == 2 && res_skb->data[0] == 0x00) - nfc_add_se(hdev->ndev, se_idx++, NFC_SE_UICC); - - kfree_skb(res_skb); - } - - r = nfc_hci_send_event(hdev, PN544_NFC_WI_MGMT_GATE, - PN544_HCI_EVT_SWITCH_MODE, - &ese_mode, 1); - if (r == 0) - nfc_add_se(hdev->ndev, se_idx++, NFC_SE_EMBEDDED); - - return !se_idx; -} - -#define PN544_SE_MODE_OFF 0x00 -#define PN544_SE_MODE_ON 0x01 -static int pn544_hci_enable_se(struct nfc_hci_dev *hdev, u32 se_idx) -{ - struct nfc_se *se; - u8 enable = PN544_SE_MODE_ON; - static struct uicc_gatelist { - u8 head; - u8 adr[2]; - u8 value; - } uicc_gatelist[] = { - {0x00, {0x9e, 0xd9}, 0x23}, - {0x00, {0x9e, 0xda}, 0x21}, - {0x00, {0x9e, 0xdb}, 0x22}, - {0x00, {0x9e, 0xdc}, 0x24}, - }; - struct uicc_gatelist *p = uicc_gatelist; - int count = ARRAY_SIZE(uicc_gatelist); - struct sk_buff *res_skb; - int r; - - se = nfc_find_se(hdev->ndev, se_idx); - - switch (se->type) { - case NFC_SE_UICC: - while (count--) { - r = nfc_hci_send_cmd(hdev, PN544_SYS_MGMT_GATE, - PN544_WRITE, (u8 *)p, 4, &res_skb); - if (r < 0) - return r; - - if (res_skb->len != 1) { - kfree_skb(res_skb); - return -EPROTO; - } - - if (res_skb->data[0] != p->value) { - kfree_skb(res_skb); - return -EIO; - } - - kfree_skb(res_skb); - - p++; - } - - return nfc_hci_set_param(hdev, PN544_SWP_MGMT_GATE, - PN544_SWP_DEFAULT_MODE, &enable, 1); - case NFC_SE_EMBEDDED: - return nfc_hci_set_param(hdev, PN544_NFC_WI_MGMT_GATE, - PN544_NFC_ESE_DEFAULT_MODE, &enable, 1); - - default: - return -EINVAL; - } -} - -static int pn544_hci_disable_se(struct nfc_hci_dev *hdev, u32 se_idx) -{ - struct nfc_se *se; - u8 disable = PN544_SE_MODE_OFF; - - se = nfc_find_se(hdev->ndev, se_idx); - - switch (se->type) { - case NFC_SE_UICC: - return nfc_hci_set_param(hdev, PN544_SWP_MGMT_GATE, - PN544_SWP_DEFAULT_MODE, &disable, 1); - case NFC_SE_EMBEDDED: - return nfc_hci_set_param(hdev, PN544_NFC_WI_MGMT_GATE, - PN544_NFC_ESE_DEFAULT_MODE, &disable, 1); - default: - return -EINVAL; - } -} - static struct nfc_hci_ops pn544_hci_ops = { .open = pn544_hci_open, .close = pn544_hci_close, @@ -908,9 +807,6 @@ static struct nfc_hci_ops pn544_hci_ops = { .check_presence = pn544_hci_check_presence, .event_received = pn544_hci_event_received, .fw_download = pn544_hci_fw_download, - .discover_se = pn544_hci_discover_se, - .enable_se = pn544_hci_enable_se, - .disable_se = pn544_hci_disable_se, }; int pn544_hci_probe(void *phy_id, struct nfc_phy_ops *phy_ops, char *llc_name, @@ -924,6 +820,7 @@ int pn544_hci_probe(void *phy_id, struct nfc_phy_ops *phy_ops, char *llc_name, info = kzalloc(sizeof(struct pn544_hci_info), GFP_KERNEL); if (!info) { + pr_err("Cannot allocate memory for pn544_hci_info.\n"); r = -ENOMEM; goto err_info_alloc; } @@ -956,7 +853,7 @@ int pn544_hci_probe(void *phy_id, struct nfc_phy_ops *phy_ops, char *llc_name, phy_headroom + PN544_CMDS_HEADROOM, phy_tailroom, phy_payload); if (!info->hdev) { - pr_err("Cannot allocate nfc hdev\n"); + pr_err("Cannot allocate nfc hdev.\n"); r = -ENOMEM; goto err_alloc_hdev; } |