diff options
Diffstat (limited to 'drivers/nfc/pn544/i2c.c')
-rw-r--r-- | drivers/nfc/pn544/i2c.c | 42 |
1 files changed, 19 insertions, 23 deletions
diff --git a/drivers/nfc/pn544/i2c.c b/drivers/nfc/pn544/i2c.c index 01e27d4bdd0d..b158ee1c2ac6 100644 --- a/drivers/nfc/pn544/i2c.c +++ b/drivers/nfc/pn544/i2c.c | |||
@@ -18,6 +18,8 @@ | |||
18 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 18 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
22 | |||
21 | #include <linux/crc-ccitt.h> | 23 | #include <linux/crc-ccitt.h> |
22 | #include <linux/module.h> | 24 | #include <linux/module.h> |
23 | #include <linux/i2c.h> | 25 | #include <linux/i2c.h> |
@@ -151,8 +153,7 @@ static void pn544_hci_i2c_platform_init(struct pn544_i2c_phy *phy) | |||
151 | char rset_cmd[] = { 0x05, 0xF9, 0x04, 0x00, 0xC3, 0xE5 }; | 153 | char rset_cmd[] = { 0x05, 0xF9, 0x04, 0x00, 0xC3, 0xE5 }; |
152 | int count = sizeof(rset_cmd); | 154 | int count = sizeof(rset_cmd); |
153 | 155 | ||
154 | pr_info(DRIVER_DESC ": %s\n", __func__); | 156 | nfc_info(&phy->i2c_dev->dev, "Detecting nfc_en polarity\n"); |
155 | dev_info(&phy->i2c_dev->dev, "Detecting nfc_en polarity\n"); | ||
156 | 157 | ||
157 | /* Disable fw download */ | 158 | /* Disable fw download */ |
158 | gpio_set_value(phy->gpio_fw, 0); | 159 | gpio_set_value(phy->gpio_fw, 0); |
@@ -173,7 +174,7 @@ static void pn544_hci_i2c_platform_init(struct pn544_i2c_phy *phy) | |||
173 | dev_dbg(&phy->i2c_dev->dev, "Sending reset cmd\n"); | 174 | dev_dbg(&phy->i2c_dev->dev, "Sending reset cmd\n"); |
174 | ret = i2c_master_send(phy->i2c_dev, rset_cmd, count); | 175 | ret = i2c_master_send(phy->i2c_dev, rset_cmd, count); |
175 | if (ret == count) { | 176 | if (ret == count) { |
176 | dev_info(&phy->i2c_dev->dev, | 177 | nfc_info(&phy->i2c_dev->dev, |
177 | "nfc_en polarity : active %s\n", | 178 | "nfc_en polarity : active %s\n", |
178 | (polarity == 0 ? "low" : "high")); | 179 | (polarity == 0 ? "low" : "high")); |
179 | goto out; | 180 | goto out; |
@@ -181,7 +182,7 @@ static void pn544_hci_i2c_platform_init(struct pn544_i2c_phy *phy) | |||
181 | } | 182 | } |
182 | } | 183 | } |
183 | 184 | ||
184 | dev_err(&phy->i2c_dev->dev, | 185 | nfc_err(&phy->i2c_dev->dev, |
185 | "Could not detect nfc_en polarity, fallback to active high\n"); | 186 | "Could not detect nfc_en polarity, fallback to active high\n"); |
186 | 187 | ||
187 | out: | 188 | out: |
@@ -201,7 +202,7 @@ static int pn544_hci_i2c_enable(void *phy_id) | |||
201 | { | 202 | { |
202 | struct pn544_i2c_phy *phy = phy_id; | 203 | struct pn544_i2c_phy *phy = phy_id; |
203 | 204 | ||
204 | pr_info(DRIVER_DESC ": %s\n", __func__); | 205 | pr_info("%s\n", __func__); |
205 | 206 | ||
206 | pn544_hci_i2c_enable_mode(phy, PN544_HCI_MODE); | 207 | pn544_hci_i2c_enable_mode(phy, PN544_HCI_MODE); |
207 | 208 | ||
@@ -214,8 +215,6 @@ static void pn544_hci_i2c_disable(void *phy_id) | |||
214 | { | 215 | { |
215 | struct pn544_i2c_phy *phy = phy_id; | 216 | struct pn544_i2c_phy *phy = phy_id; |
216 | 217 | ||
217 | pr_info(DRIVER_DESC ": %s\n", __func__); | ||
218 | |||
219 | gpio_set_value(phy->gpio_fw, 0); | 218 | gpio_set_value(phy->gpio_fw, 0); |
220 | gpio_set_value(phy->gpio_en, !phy->en_polarity); | 219 | gpio_set_value(phy->gpio_en, !phy->en_polarity); |
221 | usleep_range(10000, 15000); | 220 | usleep_range(10000, 15000); |
@@ -298,11 +297,9 @@ static int check_crc(u8 *buf, int buflen) | |||
298 | crc = ~crc; | 297 | crc = ~crc; |
299 | 298 | ||
300 | if (buf[len - 2] != (crc & 0xff) || buf[len - 1] != (crc >> 8)) { | 299 | if (buf[len - 2] != (crc & 0xff) || buf[len - 1] != (crc >> 8)) { |
301 | pr_err(PN544_HCI_I2C_DRIVER_NAME | 300 | pr_err("CRC error 0x%x != 0x%x 0x%x\n", |
302 | ": CRC error 0x%x != 0x%x 0x%x\n", | ||
303 | crc, buf[len - 1], buf[len - 2]); | 301 | crc, buf[len - 1], buf[len - 2]); |
304 | 302 | pr_info("%s: BAD CRC\n", __func__); | |
305 | pr_info(DRIVER_DESC ": %s : BAD CRC\n", __func__); | ||
306 | print_hex_dump(KERN_DEBUG, "crc: ", DUMP_PREFIX_NONE, | 303 | print_hex_dump(KERN_DEBUG, "crc: ", DUMP_PREFIX_NONE, |
307 | 16, 2, buf, buflen, false); | 304 | 16, 2, buf, buflen, false); |
308 | return -EPERM; | 305 | return -EPERM; |
@@ -328,13 +325,13 @@ static int pn544_hci_i2c_read(struct pn544_i2c_phy *phy, struct sk_buff **skb) | |||
328 | 325 | ||
329 | r = i2c_master_recv(client, &len, 1); | 326 | r = i2c_master_recv(client, &len, 1); |
330 | if (r != 1) { | 327 | if (r != 1) { |
331 | dev_err(&client->dev, "cannot read len byte\n"); | 328 | nfc_err(&client->dev, "cannot read len byte\n"); |
332 | return -EREMOTEIO; | 329 | return -EREMOTEIO; |
333 | } | 330 | } |
334 | 331 | ||
335 | if ((len < (PN544_HCI_I2C_LLC_MIN_SIZE - 1)) || | 332 | if ((len < (PN544_HCI_I2C_LLC_MIN_SIZE - 1)) || |
336 | (len > (PN544_HCI_I2C_LLC_MAX_SIZE - 1))) { | 333 | (len > (PN544_HCI_I2C_LLC_MAX_SIZE - 1))) { |
337 | dev_err(&client->dev, "invalid len byte\n"); | 334 | nfc_err(&client->dev, "invalid len byte\n"); |
338 | r = -EBADMSG; | 335 | r = -EBADMSG; |
339 | goto flush; | 336 | goto flush; |
340 | } | 337 | } |
@@ -386,7 +383,7 @@ static int pn544_hci_i2c_fw_read_status(struct pn544_i2c_phy *phy) | |||
386 | 383 | ||
387 | r = i2c_master_recv(client, (char *) &response, sizeof(response)); | 384 | r = i2c_master_recv(client, (char *) &response, sizeof(response)); |
388 | if (r != sizeof(response)) { | 385 | if (r != sizeof(response)) { |
389 | dev_err(&client->dev, "cannot read fw status\n"); | 386 | nfc_err(&client->dev, "cannot read fw status\n"); |
390 | return -EIO; | 387 | return -EIO; |
391 | } | 388 | } |
392 | 389 | ||
@@ -478,8 +475,7 @@ static int pn544_hci_i2c_fw_download(void *phy_id, const char *firmware_name) | |||
478 | { | 475 | { |
479 | struct pn544_i2c_phy *phy = phy_id; | 476 | struct pn544_i2c_phy *phy = phy_id; |
480 | 477 | ||
481 | pr_info(DRIVER_DESC ": Starting Firmware Download (%s)\n", | 478 | pr_info("Starting Firmware Download (%s)\n", firmware_name); |
482 | firmware_name); | ||
483 | 479 | ||
484 | strcpy(phy->firmware_name, firmware_name); | 480 | strcpy(phy->firmware_name, firmware_name); |
485 | 481 | ||
@@ -493,7 +489,7 @@ static int pn544_hci_i2c_fw_download(void *phy_id, const char *firmware_name) | |||
493 | static void pn544_hci_i2c_fw_work_complete(struct pn544_i2c_phy *phy, | 489 | static void pn544_hci_i2c_fw_work_complete(struct pn544_i2c_phy *phy, |
494 | int result) | 490 | int result) |
495 | { | 491 | { |
496 | pr_info(DRIVER_DESC ": Firmware Download Complete, result=%d\n", result); | 492 | pr_info("Firmware Download Complete, result=%d\n", result); |
497 | 493 | ||
498 | pn544_hci_i2c_disable(phy); | 494 | pn544_hci_i2c_disable(phy); |
499 | 495 | ||
@@ -694,14 +690,14 @@ static int pn544_hci_i2c_probe(struct i2c_client *client, | |||
694 | dev_dbg(&client->dev, "IRQ: %d\n", client->irq); | 690 | dev_dbg(&client->dev, "IRQ: %d\n", client->irq); |
695 | 691 | ||
696 | if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { | 692 | if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { |
697 | dev_err(&client->dev, "Need I2C_FUNC_I2C\n"); | 693 | nfc_err(&client->dev, "Need I2C_FUNC_I2C\n"); |
698 | return -ENODEV; | 694 | return -ENODEV; |
699 | } | 695 | } |
700 | 696 | ||
701 | phy = devm_kzalloc(&client->dev, sizeof(struct pn544_i2c_phy), | 697 | phy = devm_kzalloc(&client->dev, sizeof(struct pn544_i2c_phy), |
702 | GFP_KERNEL); | 698 | GFP_KERNEL); |
703 | if (!phy) { | 699 | if (!phy) { |
704 | dev_err(&client->dev, | 700 | nfc_err(&client->dev, |
705 | "Cannot allocate memory for pn544 i2c phy.\n"); | 701 | "Cannot allocate memory for pn544 i2c phy.\n"); |
706 | return -ENOMEM; | 702 | return -ENOMEM; |
707 | } | 703 | } |
@@ -714,18 +710,18 @@ static int pn544_hci_i2c_probe(struct i2c_client *client, | |||
714 | 710 | ||
715 | pdata = client->dev.platform_data; | 711 | pdata = client->dev.platform_data; |
716 | if (pdata == NULL) { | 712 | if (pdata == NULL) { |
717 | dev_err(&client->dev, "No platform data\n"); | 713 | nfc_err(&client->dev, "No platform data\n"); |
718 | return -EINVAL; | 714 | return -EINVAL; |
719 | } | 715 | } |
720 | 716 | ||
721 | if (pdata->request_resources == NULL) { | 717 | if (pdata->request_resources == NULL) { |
722 | dev_err(&client->dev, "request_resources() missing\n"); | 718 | nfc_err(&client->dev, "request_resources() missing\n"); |
723 | return -EINVAL; | 719 | return -EINVAL; |
724 | } | 720 | } |
725 | 721 | ||
726 | r = pdata->request_resources(client); | 722 | r = pdata->request_resources(client); |
727 | if (r) { | 723 | if (r) { |
728 | dev_err(&client->dev, "Cannot get platform resources\n"); | 724 | nfc_err(&client->dev, "Cannot get platform resources\n"); |
729 | return r; | 725 | return r; |
730 | } | 726 | } |
731 | 727 | ||
@@ -739,7 +735,7 @@ static int pn544_hci_i2c_probe(struct i2c_client *client, | |||
739 | IRQF_TRIGGER_RISING | IRQF_ONESHOT, | 735 | IRQF_TRIGGER_RISING | IRQF_ONESHOT, |
740 | PN544_HCI_I2C_DRIVER_NAME, phy); | 736 | PN544_HCI_I2C_DRIVER_NAME, phy); |
741 | if (r < 0) { | 737 | if (r < 0) { |
742 | dev_err(&client->dev, "Unable to register IRQ handler\n"); | 738 | nfc_err(&client->dev, "Unable to register IRQ handler\n"); |
743 | goto err_rti; | 739 | goto err_rti; |
744 | } | 740 | } |
745 | 741 | ||