Răsfoiți Sursa

NFC: driver: Add compilation flag for secure module lib dependencies

Implemented compilation flag for secure module libraries dependencies
nfc driver.

Change-Id: I63d5feb1bf5c8e84748529b55e8b9b6832ae27e4
Mallikarjun S T 2 ani în urmă
părinte
comite
215e40c3bc
6 a modificat fișierele cu 42 adăugiri și 13 ștergeri
  1. 8 5
      Android.mk
  2. 16 4
      nfc/common.c
  3. 10 0
      nfc/common.h
  4. 2 1
      nfc/ese_cold_reset.c
  5. 5 2
      nfc/i2c_drv.c
  6. 1 1
      nfc_kernel_dlkm_vendor_board.mk

+ 8 - 5
Android.mk

@@ -5,13 +5,16 @@ DLKM_DIR          :=  $(TOP)/device/qcom/common/dlkm
 
 LOCAL_PATH        := $(call my-dir)
 
-KBUILD_OPTIONS += KBUILD_EXTRA_SYMBOLS=$(PWD)/$(call intermediates-dir-for,DLKM,sec-module-symvers)/Module.symvers
-
 include $(CLEAR_VARS)
-ifeq ($(TARGET_KERNEL_DLKM_SECURE_MSM_OVERRIDE), true)
-LOCAL_REQUIRED_MODULES := sec-module-symvers
-LOCAL_ADDITIONAL_DEPENDENCIES += $(call intermediates-dir-for,DLKM,sec-module-symvers)/Module.symvers
+ifeq ($(TARGET_ENABLE_PERIPHERAL_CONTROL), true)
+  LOCAL_CFLAGS := -DNFC_SECURE_PERIPHERAL_ENABLED
+  KBUILD_OPTIONS += KBUILD_EXTRA_SYMBOLS=$(PWD)/$(call intermediates-dir-for,DLKM,sec-module-symvers)/Module.symvers
+  ifeq ($(TARGET_KERNEL_DLKM_SECURE_MSM_OVERRIDE), true)
+    LOCAL_REQUIRED_MODULES := sec-module-symvers
+    LOCAL_ADDITIONAL_DEPENDENCIES += $(call intermediates-dir-for,DLKM,sec-module-symvers)/Module.symvers
+  endif
 endif
+
 LOCAL_MODULE      := nxp-nci.ko
 LOCAL_MODULE_PATH := $(KERNEL_MODULES_OUT)
 LOCAL_SRC_FILES   := $(wildcard $(LOCAL_PATH)/**/*) $(wildcard $(LOCAL_PATH)/*)

+ 16 - 4
nfc/common.c

@@ -76,12 +76,13 @@ int nfc_parse_dt(struct device *dev, struct platform_configs *nfc_configs,
 		   return -EINVAL;
         }
 
+#ifdef NFC_SECURE_PERIPHERAL_ENABLED
 	/* 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;
-
+#endif
 	pr_info("NxpDrv: %s: irq %d, ven %d, dwl %d, clkreq %d \n", __func__, nfc_gpio->irq, nfc_gpio->ven,
 		nfc_gpio->dwl_req, nfc_gpio->clkreq);
 
@@ -134,6 +135,7 @@ void gpio_set_ven(struct nfc_dev *nfc_dev, int value)
 	struct platform_gpio *nfc_gpio = &nfc_dev->configs.gpio;
 	if (gpio_get_value(nfc_gpio->ven) != value) {
 		pr_debug("NxpDrv: %s: value %d\n", __func__, value);
+#ifdef NFC_SECURE_PERIPHERAL_ENABLED
 		if(secure_peripheral_not_found)
 		{
 			/*secure peripheral feature is not enabled*/
@@ -145,6 +147,10 @@ void gpio_set_ven(struct nfc_dev *nfc_dev, int value)
 			if(!nfc_hw_secure_check())
 				gpio_set_value(nfc_gpio->ven, value);
 		}
+#else
+		gpio_set_value(nfc_gpio->ven, value);
+#endif
+
 		/* hardware dependent delay */
 		usleep_range(NFC_GPIO_SET_WAIT_TIME_US,
 				NFC_GPIO_SET_WAIT_TIME_US + 100);
@@ -495,11 +501,12 @@ int nfc_post_init(struct nfc_dev *nfc_dev)
 		return ret;
 	}
 
+#ifdef NFC_SECURE_PERIPHERAL_ENABLED
 	/*Initialising sempahore to disbale NFC Ven GPIO only after eSE is power off flag is set */
 	if (nfc_dev->configs.CNSS_NFC_HW_SECURE_ENABLE == true) {
 		sema_init(&sem_eSE_pwr_off,0);
 	}
-
+#endif
 	post_init_success = 1;
 	pr_info("NxpDrv: %s success\n", __func__);
 	return 0;
@@ -507,6 +514,7 @@ int nfc_post_init(struct nfc_dev *nfc_dev)
 
 }
 
+#ifdef NFC_SECURE_PERIPHERAL_ENABLED
 /**
  * nfc_hw_secure_check() - Checks the NFC secure zone status
  *
@@ -638,7 +646,7 @@ int nfc_dynamic_protection_ioctl(struct nfc_dev *nfc_dev, unsigned long sec_zone
 
 	return ret;
 }
-
+#endif
 
 /**
  * nfc_dev_ioctl - used to set or get data from upper layer.
@@ -660,6 +668,8 @@ long nfc_dev_ioctl(struct file *pfile, unsigned int cmd, unsigned long arg)
 
 	if (!nfc_dev)
 		return -ENODEV;
+
+#ifdef NFC_SECURE_PERIPHERAL_ENABLED
 	if( nfc_dev->configs.CNSS_NFC_HW_SECURE_ENABLE == true) {
 	    /*Avoiding ioctl call in secure zone*/
 	    if(nfc_dev->secure_zone) {
@@ -669,7 +679,7 @@ long nfc_dev_ioctl(struct file *pfile, unsigned int cmd, unsigned long arg)
 		    }
 	    }
 	}
-
+#endif
 	pr_debug("NxpDrv: %s: cmd = %x arg = %zx\n", __func__, cmd, arg);
 	switch (cmd) {
 	case NFC_SET_PWR:
@@ -702,11 +712,13 @@ long nfc_dev_ioctl(struct file *pfile, unsigned int cmd, unsigned long arg)
 		pr_debug("NxpDrv: nfc ese cold reset ioctl\n");
 		ret = ese_cold_reset_ioctl(nfc_dev, arg);
 		break;
+#ifdef NFC_SECURE_PERIPHERAL_ENABLED
 	case NFC_SECURE_ZONE:
 		if( nfc_dev->configs.CNSS_NFC_HW_SECURE_ENABLE == true) {
 		  ret = nfc_dynamic_protection_ioctl(nfc_dev, arg);
 		}
 		break;
+#endif
 	default:
 		pr_err("NxpDrv: %s: bad cmd %lu\n", __func__, arg);
 		ret = -ENOIOCTLCMD;

+ 10 - 0
nfc/common.h

@@ -33,10 +33,12 @@
 #include "i2c_drv.h"
 #include "ese_cold_reset.h"
 
+#ifdef NFC_SECURE_PERIPHERAL_ENABLED
 /*secure library headers*/
 #include "smcinvoke.h"
 #include "smcinvoke_object.h"
 #include "IClientEnv.h"
+#endif
 
 /* Max device count for this driver */
 #define DEV_COUNT			1
@@ -106,7 +108,9 @@
 #define ESE_GET_PWR                   _IOR(NFC_MAGIC, 0x03, uint32_t)
 #define NFC_SET_RESET_READ_PENDING    _IOW(NFC_MAGIC, 0x04, uint32_t)
 #define NFC_GET_GPIO_STATUS	      _IOR(NFC_MAGIC, 0x05, uint32_t)
+#ifdef NFC_SECURE_PERIPHERAL_ENABLED
 #define NFC_SECURE_ZONE               _IOW(NFC_MAGIC, 0x0A, uint32_t)
+#endif
 
 #define DTS_IRQ_GPIO_STR	"qcom,sn-irq"
 #define DTS_VEN_GPIO_STR	"qcom,sn-ven"
@@ -128,12 +132,14 @@
 /* Two bits to indicate GPIO status (Invalid(-2), Set(1) or Reset(0)) */
 #define GPIO_STATUS_MASK_BITS 3
 
+#ifdef NFC_SECURE_PERIPHERAL_ENABLED
 //NFC ID for registration with secure libraries
 #define HW_STATE_UID		0x108
 #define HW_OP_GET_STATE		1
 #define HW_NFC_UID			0x506
 #define FEATURE_NOT_SUPPORTED	12
 #define PERIPHERAL_NOT_FOUND	10
+#endif
 
 #define NUM_OF_IPC_LOG_PAGES	(2)
 #define PKT_MAX_LEN		(4) // no of max bytes to print for cmd/resp
@@ -151,8 +157,10 @@ do { \
 	} \
 } while (0)
 
+#ifdef NFC_SECURE_PERIPHERAL_ENABLED
 static struct semaphore sem_eSE_pwr_off;
 static bool chk_eSE_pwr_off;
+#endif
 
 enum ese_ioctl_request {
 	/* eSE POWER ON */
@@ -244,7 +252,9 @@ struct platform_configs {
 	struct platform_gpio gpio;
 	struct platform_ldo ldo;
 	const char *szone;
+#ifdef NFC_SECURE_PERIPHERAL_ENABLED
 	bool CNSS_NFC_HW_SECURE_ENABLE;
+#endif
 };
 
 

+ 2 - 1
nfc/ese_cold_reset.c

@@ -47,11 +47,12 @@ 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;
+#ifdef NFC_SECURE_PERIPHERAL_ENABLED
 		if (nfc_dev->configs.CNSS_NFC_HW_SECURE_ENABLE == true) {
 			if(chk_eSE_pwr_off)
 			  up(&sem_eSE_pwr_off);
 		}
-
+#endif
 	} 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);

+ 5 - 2
nfc/i2c_drv.c

@@ -417,7 +417,7 @@ int nfc_i2c_dev_probe(struct i2c_client *client, const struct i2c_device_id *id)
 		pr_err("NxpDrv: LDO config failed\n");
 		goto err_ldo_config_failed;
 	}
-
+#ifdef NFC_SECURE_PERIPHERAL_ENABLED
 	if( nfc_dev->configs.CNSS_NFC_HW_SECURE_ENABLE == true) {
 	    /*Check NFC Secure Zone status*/
 	    if(!nfc_hw_secure_check()) {
@@ -431,7 +431,10 @@ int nfc_i2c_dev_probe(struct i2c_client *client, const struct i2c_device_id *id)
 	}else {
 		nfc_post_init(nfc_dev);
 	}
-
+#else
+	nfc_dev->secure_zone = false;
+	nfc_post_init(nfc_dev);
+#endif
 	device_init_wakeup(&client->dev, true);
 	i2c_set_clientdata(client, nfc_dev);
 	i2c_dev->irq_wake_up = false;

+ 1 - 1
nfc_kernel_dlkm_vendor_board.mk

@@ -1,5 +1,5 @@
 # Build NFC kernel driver
-ifeq ($(call is-board-platform-in-list, pineapple),true)
+ifeq ($(call is-board-platform-in-list, pineapple blair),true)
 BOARD_VENDOR_KERNEL_MODULES += $(KERNEL_MODULES_OUT)/nxp-nci.ko
 endif