summaryrefslogtreecommitdiffstats
path: root/drivers/nfc/pn544
diff options
context:
space:
mode:
authorEric Lapuyade <eric.lapuyade@linux.intel.com>2013-07-19 08:57:13 -0400
committerSamuel Ortiz <sameo@linux.intel.com>2013-08-13 19:08:12 -0400
commiteab10b71a7d62d7cc6db631dba448f1d84df9b53 (patch)
tree96c4c697aaab1da7cce768945365e07bcf3fe63d /drivers/nfc/pn544
parentef04158e13e827315680cf8449d9af3bd8dc6280 (diff)
NFC: pn544: i2c: Add firmware download mode power-on support
This is in preparation for pn544-i2c firmware download feature, where we need to know if we're in regular or firmware upload mode. Signed-off-by: Eric Lapuyade <eric.lapuyade@intel.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/nfc/pn544')
-rw-r--r--drivers/nfc/pn544/i2c.c14
-rw-r--r--drivers/nfc/pn544/pn544.c3
-rw-r--r--drivers/nfc/pn544/pn544.h3
3 files changed, 14 insertions, 6 deletions
diff --git a/drivers/nfc/pn544/i2c.c b/drivers/nfc/pn544/i2c.c
index 8cf64c19f022..e09c8982596c 100644
--- a/drivers/nfc/pn544/i2c.c
+++ b/drivers/nfc/pn544/i2c.c
@@ -65,6 +65,7 @@ struct pn544_i2c_phy {
65 unsigned int en_polarity; 65 unsigned int en_polarity;
66 66
67 int powered; 67 int powered;
68 int run_mode;
68 69
69 int hard_fault; /* 70 int hard_fault; /*
70 * < 0 if hardware error occured (e.g. i2c err) 71 * < 0 if hardware error occured (e.g. i2c err)
@@ -122,15 +123,22 @@ out:
122 gpio_set_value(phy->gpio_en, !phy->en_polarity); 123 gpio_set_value(phy->gpio_en, !phy->en_polarity);
123} 124}
124 125
126static void pn544_hci_i2c_enable_mode(struct pn544_i2c_phy *phy, int run_mode)
127{
128 gpio_set_value(phy->gpio_fw, run_mode == PN544_FW_MODE ? 1 : 0);
129 gpio_set_value(phy->gpio_en, phy->en_polarity);
130 usleep_range(10000, 15000);
131
132 phy->run_mode = run_mode;
133}
134
125static int pn544_hci_i2c_enable(void *phy_id) 135static int pn544_hci_i2c_enable(void *phy_id)
126{ 136{
127 struct pn544_i2c_phy *phy = phy_id; 137 struct pn544_i2c_phy *phy = phy_id;
128 138
129 pr_info(DRIVER_DESC ": %s\n", __func__); 139 pr_info(DRIVER_DESC ": %s\n", __func__);
130 140
131 gpio_set_value(phy->gpio_fw, 0); 141 pn544_hci_i2c_enable_mode(phy, PN544_HCI_MODE);
132 gpio_set_value(phy->gpio_en, phy->en_polarity);
133 usleep_range(10000, 15000);
134 142
135 phy->powered = 1; 143 phy->powered = 1;
136 144
diff --git a/drivers/nfc/pn544/pn544.c b/drivers/nfc/pn544/pn544.c
index 0d17da7675b7..1d4b38c036fb 100644
--- a/drivers/nfc/pn544/pn544.c
+++ b/drivers/nfc/pn544/pn544.c
@@ -31,9 +31,6 @@
31/* Timing restrictions (ms) */ 31/* Timing restrictions (ms) */
32#define PN544_HCI_RESETVEN_TIME 30 32#define PN544_HCI_RESETVEN_TIME 30
33 33
34#define HCI_MODE 0
35#define FW_MODE 1
36
37enum pn544_state { 34enum pn544_state {
38 PN544_ST_COLD, 35 PN544_ST_COLD,
39 PN544_ST_FW_READY, 36 PN544_ST_FW_READY,
diff --git a/drivers/nfc/pn544/pn544.h b/drivers/nfc/pn544/pn544.h
index f47c6454914b..d689f0ac64aa 100644
--- a/drivers/nfc/pn544/pn544.h
+++ b/drivers/nfc/pn544/pn544.h
@@ -24,6 +24,9 @@
24 24
25#define DRIVER_DESC "HCI NFC driver for PN544" 25#define DRIVER_DESC "HCI NFC driver for PN544"
26 26
27#define PN544_HCI_MODE 0
28#define PN544_FW_MODE 1
29
27int pn544_hci_probe(void *phy_id, struct nfc_phy_ops *phy_ops, char *llc_name, 30int pn544_hci_probe(void *phy_id, struct nfc_phy_ops *phy_ops, char *llc_name,
28 int phy_headroom, int phy_tailroom, int phy_payload, 31 int phy_headroom, int phy_tailroom, int phy_payload,
29 struct nfc_hci_dev **hdev); 32 struct nfc_hci_dev **hdev);