Introduce firmware download fail recovery mechanism
Root cause:
To avoid from recovery fail and then NFC always in download mode
How to fix:
To let NFC IRQ stay enabled while in download mode
Change-Id: Icbd45691e6b1aeebe2f694c04ae1573837913c3b
RiskArea: NFC
diff --git a/drivers/nfc/nq-nci.c b/drivers/nfc/nq-nci.c
index bae7f5b..cc90a36 100644
--- a/drivers/nfc/nq-nci.c
+++ b/drivers/nfc/nq-nci.c
@@ -29,6 +29,11 @@
#include <linux/compat.h>
#endif
+#define PFX "[NFC][NQ]"
+// 20181116 Michael Lin - Introduce firmware download fail recovery mechanism
+/* To avoid from recovery fail and then NFC always in download mode */
+#define NFC_FW_DOWNLOAD_MODE
+
struct nqx_platform_data {
unsigned int irq_gpio;
unsigned int en_gpio;
@@ -476,7 +481,11 @@
* interrupts to avoid spurious notifications to upper
* layers.
*/
+ //< 20181116 Michael Lin - Mask where firmware download fail recovery is used
+ #if !defined( NFC_FW_DOWNLOAD_MODE )
nqx_disable_irq(nqx_dev);
+ #endif
+ //> 20181116 Michael Lin - Mask where firmware download fail recovery is used
dev_dbg(&nqx_dev->client->dev,
"gpio_set_value disable: %s: info: %p\n",
__func__, nqx_dev);
@@ -533,6 +542,12 @@
return -EBUSY; /* Device or resource busy */
}
}
+ //< 20181116 Michael Lin - Add where firmware download fail recovery is used
+ #if defined( NFC_FW_DOWNLOAD_MODE )
+ /* Enable IRQ while upgrade FW. To avoid from recovery fail and then NFC always in download mode */
+ nqx_enable_irq( nqx_dev );
+ #endif
+ //< 20181116 Michael Lin - Add where firmware download fail recovery is used
gpio_set_value(nqx_dev->en_gpio, 1);
usleep_range(10000, 10100);
if (gpio_is_valid(nqx_dev->firm_gpio)) {
@@ -1187,8 +1202,14 @@
if (r) {
/* make sure NFCC is not enabled */
gpio_set_value(platform_data->en_gpio, 0);
+ //< 20181116 Michael Lin - Mask where firmware download fail recovery is used
+ #if !defined( NFC_FW_DOWNLOAD_MODE ) /* Qualcomm default */
/* We don't think there is hardware switch NFC OFF */
goto err_request_hw_check_failed;
+ #else
+ dev_err(&client->dev, "[%s]nfcc_hw_check() error !!\n", __func__ );
+ #endif
+ //> 20181116 Michael Lin - Mask where firmware download fail recovery is used
}
/* Register reboot notifier here */
@@ -1350,6 +1371,7 @@
*/
static int __init nqx_dev_init(void)
{
+ pr_info( PFX "[%s]Enter...\n", __func__ );
return i2c_add_driver(&nqx);
}
module_init(nqx_dev_init);