Commit eab10b71 authored by Eric Lapuyade's avatar Eric Lapuyade Committed by Samuel Ortiz

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: default avatarEric Lapuyade <eric.lapuyade@intel.com>
Signed-off-by: default avatarSamuel Ortiz <sameo@linux.intel.com>
parent ef04158e
...@@ -65,6 +65,7 @@ struct pn544_i2c_phy { ...@@ -65,6 +65,7 @@ struct pn544_i2c_phy {
unsigned int en_polarity; unsigned int en_polarity;
int powered; int powered;
int run_mode;
int hard_fault; /* int hard_fault; /*
* < 0 if hardware error occured (e.g. i2c err) * < 0 if hardware error occured (e.g. i2c err)
...@@ -122,15 +123,22 @@ static void pn544_hci_i2c_platform_init(struct pn544_i2c_phy *phy) ...@@ -122,15 +123,22 @@ static void pn544_hci_i2c_platform_init(struct pn544_i2c_phy *phy)
gpio_set_value(phy->gpio_en, !phy->en_polarity); gpio_set_value(phy->gpio_en, !phy->en_polarity);
} }
static void pn544_hci_i2c_enable_mode(struct pn544_i2c_phy *phy, int run_mode)
{
gpio_set_value(phy->gpio_fw, run_mode == PN544_FW_MODE ? 1 : 0);
gpio_set_value(phy->gpio_en, phy->en_polarity);
usleep_range(10000, 15000);
phy->run_mode = run_mode;
}
static int pn544_hci_i2c_enable(void *phy_id) static int pn544_hci_i2c_enable(void *phy_id)
{ {
struct pn544_i2c_phy *phy = phy_id; struct pn544_i2c_phy *phy = phy_id;
pr_info(DRIVER_DESC ": %s\n", __func__); pr_info(DRIVER_DESC ": %s\n", __func__);
gpio_set_value(phy->gpio_fw, 0); pn544_hci_i2c_enable_mode(phy, PN544_HCI_MODE);
gpio_set_value(phy->gpio_en, phy->en_polarity);
usleep_range(10000, 15000);
phy->powered = 1; phy->powered = 1;
......
...@@ -31,9 +31,6 @@ ...@@ -31,9 +31,6 @@
/* Timing restrictions (ms) */ /* Timing restrictions (ms) */
#define PN544_HCI_RESETVEN_TIME 30 #define PN544_HCI_RESETVEN_TIME 30
#define HCI_MODE 0
#define FW_MODE 1
enum pn544_state { enum pn544_state {
PN544_ST_COLD, PN544_ST_COLD,
PN544_ST_FW_READY, PN544_ST_FW_READY,
......
...@@ -24,6 +24,9 @@ ...@@ -24,6 +24,9 @@
#define DRIVER_DESC "HCI NFC driver for PN544" #define DRIVER_DESC "HCI NFC driver for PN544"
#define PN544_HCI_MODE 0
#define PN544_FW_MODE 1
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); struct nfc_hci_dev **hdev);
......
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