diff --git a/nfc/common.c b/nfc/common.c index 6e03a97918..cc6185ed8c 100644 --- a/nfc/common.c +++ b/nfc/common.c @@ -80,6 +80,12 @@ int nfc_parse_dt(struct device *dev, struct platform_configs *nfc_configs, nfc_configs->clk_pin_voting = true; } + /* Read DTS_SZONE_STR to check secure zone support */ + if (of_property_read_string(np, DTS_SZONE_STR, &nfc_configs->szone)) { + nfc_configs->CNSS_NFC_HW_SECURE_ENABLE = false; + }else + nfc_configs->CNSS_NFC_HW_SECURE_ENABLE = true; + pr_info("%s: irq %d, ven %d, dwl %d, clkreq %d, clk_pin_voting %d \n", __func__, nfc_gpio->irq, nfc_gpio->ven, nfc_gpio->dwl_req, nfc_gpio->clkreq, nfc_configs->clk_pin_voting); @@ -450,7 +456,9 @@ int nfc_post_init(struct nfc_dev *nfc_dev) } /*Initialising sempahore to disbale NFC Ven GPIO only after eSE is power off flag is set */ - sema_init(&sem_eSE_pwr_off,0); + if (nfc_dev->configs.CNSS_NFC_HW_SECURE_ENABLE == true) { + sema_init(&sem_eSE_pwr_off,0); + } post_init_success = 1; pr_info("%s success\n", __func__); @@ -477,7 +485,6 @@ int nfc_post_init(struct nfc_dev *nfc_dev) int ret; bool retstat = 1; u8 state = 0; - /* get rootObj */ ret = get_client_env_object(&client_env); if (ret) { @@ -545,7 +552,6 @@ int nfc_dynamic_protection_ioctl(struct nfc_dev *nfc_dev, unsigned long sec_zone static int init_flag=1; struct platform_gpio *nfc_gpio = &nfc_dev->configs.gpio; - if(sec_zone_trans == 1) { /*check NFC is disabled, only then set Ven GPIO low*/ if(nfc_dev->cold_reset.is_nfc_enabled == false) { @@ -590,6 +596,7 @@ int nfc_dynamic_protection_ioctl(struct nfc_dev *nfc_dev, unsigned long sec_zone return ret; } + /** * nfc_dev_ioctl - used to set or get data from upper layer. * @pfile file node for opened device. @@ -610,13 +617,14 @@ long nfc_dev_ioctl(struct file *pfile, unsigned int cmd, unsigned long arg) if (!nfc_dev) return -ENODEV; - - /*Avoiding ioctl call in secure zone*/ - if(nfc_dev->secure_zone) { - if(cmd!=NFC_SECURE_ZONE) { - pr_debug("nfc_dev_ioctl failed\n"); - return -1; - } + if( nfc_dev->configs.CNSS_NFC_HW_SECURE_ENABLE == true) { + /*Avoiding ioctl call in secure zone*/ + if(nfc_dev->secure_zone) { + if(cmd!=NFC_SECURE_ZONE) { + pr_debug("nfc_dev_ioctl failed\n"); + return -1; + } + } } pr_debug("%s: cmd = %x arg = %zx\n", __func__, cmd, arg); @@ -638,7 +646,9 @@ long nfc_dev_ioctl(struct file *pfile, unsigned int cmd, unsigned long arg) ret = ese_cold_reset_ioctl(nfc_dev, arg); break; case NFC_SECURE_ZONE: - ret = nfc_dynamic_protection_ioctl(nfc_dev, arg); + if( nfc_dev->configs.CNSS_NFC_HW_SECURE_ENABLE == true) { + ret = nfc_dynamic_protection_ioctl(nfc_dev, arg); + } break; default: pr_err("%s: bad cmd %lu\n", __func__, arg); diff --git a/nfc/common.h b/nfc/common.h index 404333f120..d5c4a58ec3 100644 --- a/nfc/common.h +++ b/nfc/common.h @@ -110,6 +110,7 @@ #define DTS_FWDN_GPIO_STR "qcom,sn-firm" #define DTS_CLKREQ_GPIO_STR "qcom,sn-clkreq" #define DTS_CLKSRC_GPIO_STR "qcom,clk-src" +#define DTS_SZONE_STR "qcom,sn-szone" #define NFC_LDO_SUPPLY_DT_NAME "qcom,sn-vdd-1p8" #define NFC_LDO_SUPPLY_NAME "qcom,sn-vdd-1p8-supply" #define NFC_LDO_VOL_DT_NAME "qcom,sn-vdd-1p8-voltage" @@ -127,7 +128,6 @@ #define FEATURE_NOT_SUPPORTED 12 #define PERIPHERAL_NOT_FOUND 10 - #define NUM_OF_IPC_LOG_PAGES (2) #define PKT_MAX_LEN (4) // no of max bytes to print for cmd/resp @@ -147,7 +147,6 @@ do { \ static struct semaphore sem_eSE_pwr_off; static chk_eSE_pwr_off; - enum ese_ioctl_request { /* eSE POWER ON */ ESE_POWER_ON = 0, @@ -235,6 +234,8 @@ struct platform_configs { const char *clk_src_name; /* NFC_CLK pin voting state */ bool clk_pin_voting; + const char *szone; + bool CNSS_NFC_HW_SECURE_ENABLE; }; @@ -274,7 +275,6 @@ struct nfc_dev { u8 *kbuf; union nqx_uinfo nqx_info; - /*secure zone state*/ bool secure_zone; diff --git a/nfc/ese_cold_reset.c b/nfc/ese_cold_reset.c index c96675d00f..e6dd80a3d6 100644 --- a/nfc/ese_cold_reset.c +++ b/nfc/ese_cold_reset.c @@ -47,8 +47,11 @@ int nfc_ese_pwr(struct nfc_dev *nfc_dev, unsigned long arg) pr_debug("keep ven high as NFC is enabled\n"); } nfc_dev->is_ese_session_active = false; - if(chk_eSE_pwr_off) - up(&sem_eSE_pwr_off); + if (nfc_dev->configs.CNSS_NFC_HW_SECURE_ENABLE == true) { + if(chk_eSE_pwr_off) + up(&sem_eSE_pwr_off); + } + } else if (arg == ESE_POWER_STATE) { /* get VEN gpio state for eSE, as eSE also enabled through same GPIO */ ret = gpio_get_value(nfc_dev->configs.gpio.ven); diff --git a/nfc/i2c_drv.c b/nfc/i2c_drv.c index 54a008b149..55ebc62aa2 100644 --- a/nfc/i2c_drv.c +++ b/nfc/i2c_drv.c @@ -418,27 +418,31 @@ int nfc_i2c_dev_probe(struct i2c_client *client, const struct i2c_device_id *id) goto err_ldo_config_failed; } - /*Check NFC Secure Zone status*/ - if(!nfc_hw_secure_check()) { + if( nfc_dev->configs.CNSS_NFC_HW_SECURE_ENABLE == true) { + /*Check NFC Secure Zone status*/ + if(!nfc_hw_secure_check()) { + nfc_post_init(nfc_dev); + nfc_dev->secure_zone = false; + } + else { + nfc_dev->secure_zone = true; + } + pr_info("%s:nfc_dev->secure_zone = %s", __func__, nfc_dev->secure_zone ? "true" : "false"); + }else { nfc_post_init(nfc_dev); - nfc_dev->secure_zone = false; } - else - nfc_dev->secure_zone = true; - pr_info("%s:nfc_dev->secure_zone = %s", __func__, nfc_dev->secure_zone ? "true" : "false"); if(nfc_dev->configs.clk_pin_voting) nfc_dev->clk_run = false; else nfc_dev->clk_run = true; - device_init_wakeup(&client->dev, true); i2c_set_clientdata(client, nfc_dev); i2c_dev->irq_wake_up = false; nfc_dev->is_ese_session_active = false; - pr_info("%s: probing nfc i2c successfully\n", __func__); + pr_info("%s: probing nfc i2c success\n", __func__); return 0;