From edbd2aaad62572187fc2b244981cdc4980326fa8 Mon Sep 17 00:00:00 2001 From: nxf24591 Date: Tue, 1 Feb 2022 17:31:42 +0530 Subject: [PATCH 1/2] Updated corresponding to - NFC_AR_00_E800_13.02.01_OpnSrc --- nfc/Kbuild | 8 ++++---- nfc/common.h | 8 ++++---- nfc/i2c_drv.c | 25 ++++++++++--------------- nfc/i2c_drv.h | 4 ++-- 4 files changed, 20 insertions(+), 25 deletions(-) diff --git a/nfc/Kbuild b/nfc/Kbuild index 198d574a94..9a4e9a23da 100644 --- a/nfc/Kbuild +++ b/nfc/Kbuild @@ -1,6 +1,6 @@ -obj-$(CONFIG_NXP_NFC_I2C) := pn553_i2c.o +obj-$(CONFIG_NXP_NFC_I2C) := nfc_i2c.o -pn553_i2c-y := common.o \ - common_ese.o \ - i2c_drv.o +nfc_i2c-y := common.o \ + common_ese.o \ + i2c_drv.o diff --git a/nfc/common.h b/nfc/common.h index bcdd26dd33..675e06ccd4 100644 --- a/nfc/common.h +++ b/nfc/common.h @@ -30,7 +30,7 @@ #define CLASS_NAME "nfc" /* NFC character device name, this will be in /dev/ */ -#define NFC_CHAR_DEV_NAME "pn553" +#define NFC_CHAR_DEV_NAME "nxp-nci" /* NCI packet details */ #define NCI_CMD (0x20) @@ -78,9 +78,9 @@ #define ESE_SET_PWR _IOW(NFC_MAGIC, 0x02, uint32_t) #define ESE_GET_PWR _IOR(NFC_MAGIC, 0x03, uint32_t) -#define DTS_IRQ_GPIO_STR "nxp,pn544-irq" -#define DTS_VEN_GPIO_STR "nxp,pn544-ven" -#define DTS_FWDN_GPIO_STR "nxp,pn544-fw-dwnld" +#define DTS_IRQ_GPIO_STR "nxp,sn-irq" +#define DTS_VEN_GPIO_STR "nxp,sn-ven-rstn" +#define DTS_FWDN_GPIO_STR "nxp,sn-dwl-req" enum nfcc_ioctl_request { /* NFC disable request with VEN LOW */ diff --git a/nfc/i2c_drv.c b/nfc/i2c_drv.c index 2792484263..32cfc43a4c 100644 --- a/nfc/i2c_drv.c +++ b/nfc/i2c_drv.c @@ -323,27 +323,27 @@ int nfc_i2c_dev_probe(struct i2c_client *client, const struct i2c_device_id *id) int ret = 0; struct nfc_dev *nfc_dev = NULL; struct i2c_dev *i2c_dev = NULL; - struct platform_configs nfc_configs; - struct platform_gpio *nfc_gpio = &nfc_configs.gpio; - + struct platform_configs *nfc_configs = NULL; + struct platform_gpio *nfc_gpio = NULL; pr_debug("%s: enter\n", __func__); + nfc_dev = kzalloc(sizeof(struct nfc_dev), GFP_KERNEL); + if (nfc_dev == NULL) { + ret = -ENOMEM; + goto err; + } + nfc_configs = &nfc_dev->configs; + nfc_gpio = &nfc_configs->gpio; /* retrieve details of gpios from dt */ - ret = nfc_parse_dt(&client->dev, &nfc_configs, PLATFORM_IF_I2C); + ret = nfc_parse_dt(&client->dev,nfc_configs, PLATFORM_IF_I2C); if (ret) { pr_err("%s: failed to parse dt\n", __func__); goto err; } - if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { pr_err("%s: need I2C_FUNC_I2C\n", __func__); ret = -ENODEV; goto err; } - nfc_dev = kzalloc(sizeof(struct nfc_dev), GFP_KERNEL); - if (nfc_dev == NULL) { - ret = -ENOMEM; - goto err; - } nfc_dev->read_kbuf = kzalloc(MAX_NCI_BUFFER_SIZE, GFP_DMA | GFP_KERNEL); if (!nfc_dev->read_kbuf) { ret = -ENOMEM; @@ -380,11 +380,6 @@ int nfc_i2c_dev_probe(struct i2c_client *client, const struct i2c_device_id *id) pr_err("%s: unable to request nfc firm downl gpio [%d]\n", __func__, nfc_gpio->dwl_req); } - - /* copy the retrieved gpio details from DT */ - memcpy(&nfc_dev->configs, &nfc_configs, - sizeof(struct platform_configs)); - /* init mutex and queues */ init_waitqueue_head(&nfc_dev->read_wq); mutex_init(&nfc_dev->read_mutex); diff --git a/nfc/i2c_drv.h b/nfc/i2c_drv.h index 1508fd4163..628ca0862d 100644 --- a/nfc/i2c_drv.h +++ b/nfc/i2c_drv.h @@ -23,8 +23,8 @@ #include /* kept same as dts */ -#define NFC_I2C_DRV_STR "nxp,pn544" -#define NFC_I2C_DEV_ID "pn553" +#define NFC_I2C_DRV_STR "nxp,sn-nci" +#define NFC_I2C_DEV_ID "sn-i2c" /* Interface specific parameters */ struct i2c_dev { From 71fa3f1d6bda19888c900244da173a0ee0a142d2 Mon Sep 17 00:00:00 2001 From: nxf24591 Date: Tue, 1 Mar 2022 15:12:06 +0530 Subject: [PATCH 2/2] Updated corresponding to - NFC_AR_00_E800_13.03.00_OpnSrc --- nfc/common.h | 8 +++----- nfc/i2c_drv.c | 10 +++++----- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/nfc/common.h b/nfc/common.h index 675e06ccd4..4899c0d92c 100644 --- a/nfc/common.h +++ b/nfc/common.h @@ -1,6 +1,6 @@ /****************************************************************************** * Copyright (C) 2015, The Linux Foundation. All rights reserved. - * Copyright (C) 2019-2021 NXP + * Copyright (C) 2019-2022 NXP * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -64,10 +64,8 @@ #define NCI_CMD_RSP_TIMEOUT_MS (2000) /* Time to wait for NFCC to be ready again after any change in the GPIO */ #define NFC_GPIO_SET_WAIT_TIME_US (10000) -/* Time to wait for IRQ low during write 5*3ms */ -#define NFC_WRITE_IRQ_WAIT_TIME_US (3000) -/* Time to wait before retrying i2c/I3C writes */ -#define WRITE_RETRY_WAIT_TIME_US (1000) +/* Time to wait before retrying writes */ +#define WRITE_RETRY_WAIT_TIME_US (3000) /* Time to wait before retrying read for some specific usecases */ #define READ_RETRY_WAIT_TIME_US (3500) #define NFC_MAGIC (0xE9) diff --git a/nfc/i2c_drv.c b/nfc/i2c_drv.c index 32cfc43a4c..f335386e6d 100644 --- a/nfc/i2c_drv.c +++ b/nfc/i2c_drv.c @@ -1,6 +1,6 @@ /****************************************************************************** * Copyright (C) 2015, The Linux Foundation. All rights reserved. - * Copyright (C) 2013-2021 NXP + * Copyright (C) 2013-2022 NXP * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -225,8 +225,8 @@ int i2c_write(struct nfc_dev *nfc_dev, const char *buf, size_t count, for (retry_cnt = 1; retry_cnt <= MAX_WRITE_IRQ_COUNT; retry_cnt++) { if (gpio_get_value(nfc_gpio->irq)) { pr_warn("%s: irq high during write, wait\n", __func__); - usleep_range(NFC_WRITE_IRQ_WAIT_TIME_US, - NFC_WRITE_IRQ_WAIT_TIME_US + 100); + usleep_range(WRITE_RETRY_WAIT_TIME_US, + WRITE_RETRY_WAIT_TIME_US + 100); } else { break; } @@ -337,12 +337,12 @@ int nfc_i2c_dev_probe(struct i2c_client *client, const struct i2c_device_id *id) ret = nfc_parse_dt(&client->dev,nfc_configs, PLATFORM_IF_I2C); if (ret) { pr_err("%s: failed to parse dt\n", __func__); - goto err; + goto err_free_nfc_dev; } if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { pr_err("%s: need I2C_FUNC_I2C\n", __func__); ret = -ENODEV; - goto err; + goto err_free_nfc_dev; } nfc_dev->read_kbuf = kzalloc(MAX_NCI_BUFFER_SIZE, GFP_DMA | GFP_KERNEL); if (!nfc_dev->read_kbuf) {