]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
NFC: pn544: Pass hardware variant information when downloading firmware
authorArron Wang <arron.wang@intel.com>
Wed, 11 Dec 2013 09:25:23 +0000 (17:25 +0800)
committerSamuel Ortiz <sameo@linux.intel.com>
Sun, 16 Feb 2014 22:49:54 +0000 (23:49 +0100)
Different pn544 hardware variant may use different commands to download
new firmwares. The C2 does a regular firmware download while the C3 uses
a more secure protocol.
As a consequence we need to pass the hardware variant from the HCI SW
version command reply down to the pn544 i2c layer, in order to use the
right protocol at run time.

Signed-off-by: Arron Wang <arron.wang@intel.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
drivers/nfc/pn544/i2c.c
drivers/nfc/pn544/pn544.c
drivers/nfc/pn544/pn544.h

index d6185ff2f87b0aa80aba29a55a806057301e39d4..c7e277cddb48ea8e04b802a1d0e7eb6098873723 100644 (file)
@@ -58,6 +58,14 @@ MODULE_DEVICE_TABLE(i2c, pn544_hci_i2c_id_table);
 
 #define PN544_HCI_I2C_DRIVER_NAME "pn544_hci_i2c"
 
+/*
+ * Exposed through the 4 most significant bytes
+ * from the HCI SW_VERSION first byte, a.k.a.
+ * SW RomLib.
+ */
+#define PN544_HW_VARIANT_C2 0xa
+#define PN544_HW_VARIANT_C3 0xb
+
 #define PN544_FW_CMD_WRITE 0x08
 #define PN544_FW_CMD_CHECK 0x06
 
@@ -119,6 +127,8 @@ struct pn544_i2c_phy {
        unsigned int gpio_fw;
        unsigned int en_polarity;
 
+       u8 hw_variant;
+
        struct work_struct fw_work;
        int fw_work_state;
        char firmware_name[NFC_FIRMWARE_NAME_MAXSIZE + 1];
@@ -469,7 +479,8 @@ static struct nfc_phy_ops i2c_phy_ops = {
        .disable = pn544_hci_i2c_disable,
 };
 
-static int pn544_hci_i2c_fw_download(void *phy_id, const char *firmware_name)
+static int pn544_hci_i2c_fw_download(void *phy_id, const char *firmware_name,
+                                       u8 hw_variant)
 {
        struct pn544_i2c_phy *phy = phy_id;
 
@@ -477,6 +488,7 @@ static int pn544_hci_i2c_fw_download(void *phy_id, const char *firmware_name)
 
        strcpy(phy->firmware_name, firmware_name);
 
+       phy->hw_variant = hw_variant;
        phy->fw_work_state = FW_WORK_STATE_START;
 
        schedule_work(&phy->fw_work);
index 3df4a109cfadfb36a5ccd08e788feef43da0048e..9c8051d20cea98fa4377edb79167ddef2b14cf24 100644 (file)
@@ -786,7 +786,7 @@ static int pn544_hci_fw_download(struct nfc_hci_dev *hdev,
        if (info->fw_download == NULL)
                return -ENOTSUPP;
 
-       return info->fw_download(info->phy_id, firmware_name);
+       return info->fw_download(info->phy_id, firmware_name, hdev->sw_romlib);
 }
 
 static int pn544_hci_discover_se(struct nfc_hci_dev *hdev)
index 491bf45da35822f706401bd25bbf9b9eaaa78e99..2aa9233e808647d9e7581aa9326b313696d85380 100644 (file)
@@ -25,7 +25,8 @@
 #define PN544_HCI_MODE 0
 #define PN544_FW_MODE 1
 
-typedef int (*fw_download_t)(void *context, const char *firmware_name);
+typedef int (*fw_download_t)(void *context, const char *firmware_name,
+                               u8 hw_variant);
 
 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,