Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e00fe467 authored by Lukas0610's avatar Lukas0610 Committed by Usaamah Patel
Browse files

sec-nfc: update driver to A8 Oreo Sources (A810SKSU2CRG3)

Change-Id: I5fdfc68ce780d8029a02012c10ee84760e09e487
parent 91ff4b34
Loading
Loading
Loading
Loading
+53 −4
Original line number Diff line number Diff line
@@ -74,12 +74,16 @@ struct sec_nfc_i2c_info {};
#include <linux/poll.h>
#include <linux/sched.h>
#include <linux/i2c.h>
#ifdef CONFIG_ESE_SECURE
#include <linux/smc.h>
#endif

#define SEC_NFC_GET_INFO(dev) i2c_get_clientdata(to_i2c_client(dev))
enum sec_nfc_irq {
	SEC_NFC_SKIP = -1,
	SEC_NFC_NONE,
	SEC_NFC_INT,
	SEC_NFC_SKIP,
	SEC_NFC_READ_TIMES,
};

struct sec_nfc_i2c_info {
@@ -142,7 +146,7 @@ static irqreturn_t sec_nfc_irq_thread_fn(int irq, void *dev_id)
		return IRQ_HANDLED;
	}

	info->i2c_info.read_irq = SEC_NFC_INT;
	info->i2c_info.read_irq += SEC_NFC_READ_TIMES;
	mutex_unlock(&info->i2c_info.read_mutex);

	wake_up_interruptible(&info->i2c_info.read_wait);
@@ -176,6 +180,14 @@ static ssize_t sec_nfc_read(struct file *file, char __user *buf,
	}

	mutex_lock(&info->i2c_info.read_mutex);
	if(count == 0)
	{
		if (info->i2c_info.read_irq >= SEC_NFC_INT)
			info->i2c_info.read_irq--;
		mutex_unlock(&info->i2c_info.read_mutex);
		goto out;
	}

	irq = info->i2c_info.read_irq;
	mutex_unlock(&info->i2c_info.read_mutex);
	if (irq == SEC_NFC_NONE) {
@@ -211,7 +223,12 @@ static ssize_t sec_nfc_read(struct file *file, char __user *buf,
		goto read_error;
	}

	info->i2c_info.read_irq = SEC_NFC_NONE;
	if (info->i2c_info.read_irq >= SEC_NFC_INT)
		info->i2c_info.read_irq--;

	if(info->i2c_info.read_irq == SEC_NFC_READ_TIMES)
		wake_up_interruptible(&info->i2c_info.read_wait);

	mutex_unlock(&info->i2c_info.read_mutex);

	if (copy_to_user(buf, info->i2c_info.buf, ret)) {
@@ -317,7 +334,7 @@ static unsigned int sec_nfc_poll(struct file *file, poll_table *wait)

	mutex_lock(&info->i2c_info.read_mutex);
	irq = info->i2c_info.read_irq;
	if (irq == SEC_NFC_INT)
	if (irq == SEC_NFC_READ_TIMES)
		ret = (POLLIN | POLLRDNORM);
	mutex_unlock(&info->i2c_info.read_mutex);

@@ -610,6 +627,31 @@ static long sec_nfc_ioctl(struct file *file, unsigned int cmd,
		}
		break;
#endif
	case SEC_NFC_SET_NPT_MODE:
		if(SEC_NFC_NPT_CMD_ON == new) {
			pr_info("%s: NFC OFF mode NPT - Turn on VEN.\n", __func__);
			info->mode = SEC_NFC_MODE_FIRMWARE;
			mutex_lock(&info->i2c_info.read_mutex);
			info->i2c_info.read_irq = SEC_NFC_SKIP;
			mutex_unlock(&info->i2c_info.read_mutex);
			gpio_set_value(pdata->ven, SEC_NFC_PW_ON);
#ifdef  CONFIG_SEC_NFC_CLK_REQ
			sec_nfc_clk_ctl_enable(info);
#endif
			msleep(20);
			if (pdata->firm) gpio_set_value(pdata->firm, SEC_NFC_FW_ON);
			enable_irq_wake(info->i2c_info.i2c_dev->irq);
		} else if(SEC_NFC_NPT_CMD_OFF == new) {
			pr_info("%s: NFC OFF mode NPT - Turn off VEN.\n", __func__);
			info->mode = SEC_NFC_MODE_OFF;
			if (pdata->firm) gpio_set_value(pdata->firm, SEC_NFC_FW_OFF);
			gpio_set_value(pdata->ven, SEC_NFC_PW_OFF);
#ifdef  CONFIG_SEC_NFC_CLK_REQ
			sec_nfc_clk_ctl_disable(info);
#endif
			disable_irq_wake(info->i2c_info.i2c_dev->irq);
		}
		break;

	default:
		pr_info("%s Unknow ioctl 0x%x\n", __func__, cmd);
@@ -1098,6 +1140,13 @@ static int __devinit sec_nfc_probe(struct i2c_client *client,
{
	int ret = 0;

#ifdef CONFIG_ESE_SECURE
	ret = exynos_smc(0x83000032, 0 , 0, 0);
	if (ret == EBUSY) { 
		pr_err("[NFC] eSE spi secure fail!\n");
		return -EBUSY;
	}
#endif
	ret = __sec_nfc_probe(&client->dev);
	if (ret)
		return ret;
+8 −0
Original line number Diff line number Diff line
@@ -133,6 +133,7 @@ enum readable_state {
#define SEC_NFC_SET_MODE		_IOW(SEC_NFC_MAGIC, 1, unsigned int)
#define SEC_NFC_SLEEP			_IOW(SEC_NFC_MAGIC, 2, unsigned int)
#define SEC_NFC_WAKEUP			_IOW(SEC_NFC_MAGIC, 3, unsigned int)
#define SEC_NFC_SET_NPT_MODE	_IOW(SEC_NFC_MAGIC, 4, unsigned int)

/* size */
#define SEC_NFC_MSG_MAX_SIZE	(256 + 4)
@@ -211,6 +212,13 @@ enum sec_nfc_wake {
	SEC_NFC_WAKE_SLEEP = 0,
	SEC_NFC_WAKE_UP,
};
enum sec_nfc_npt_mode {
	SEC_NFC_NPT_OFF = 0,
	SEC_NFC_NPT_ON,
	SEC_NFC_NPT_CMD_ON = 0x7E,
	SEC_NFC_NPT_CMD_OFF,
};

#endif /* CONFIG_SEC_NFC_SENN3AB */

#if defined(CONFIG_SEC_NFC_LDO_CONTROL) || defined(CONFIG_SEC_NFC_LDO_JPN_CONTROL)