Loading drivers/nfc/nfc-nci.c +65 −1 Original line number Diff line number Diff line Loading @@ -66,7 +66,7 @@ MODULE_DEVICE_TABLE(of, msm_match_table); #define CORE_RST_NTF_LENGTH (0x02) #define WAKE_TIMEOUT (10) #define WAKE_REG (0x10) #define EFUSE_REG (0xA0) struct qca199x_dev { wait_queue_head_t read_wq; Loading Loading @@ -707,6 +707,61 @@ int nfc_ioctl_nfcc_mode(struct file *filp, unsigned int cmd, unsigned long arg) return retval; } /* * Inside nfc_ioctl_nfcc_efuse * * @brief nfc_ioctl_nfcc_efuse * * */ int nfc_ioctl_nfcc_efuse(struct file *filp, unsigned int cmd, unsigned long arg) { int r = 0; unsigned short slave_addr = 0xE; unsigned short curr_addr; unsigned char efuse_addr = EFUSE_REG; unsigned char efuse_value = 0xFF; struct qca199x_dev *qca199x_dev = filp->private_data; curr_addr = qca199x_dev->client->addr; qca199x_dev->client->addr = slave_addr; r = nfc_i2c_write(qca199x_dev->client, &efuse_addr, 1); if (r < 0) { /* Restore original NFCC slave I2C address */ qca199x_dev->client->addr = curr_addr; dev_err(&qca199x_dev->client->dev, "ERROR_WRITE_FAIL : i2c write fail\n"); return -EIO; } /* * NFCC chip needs to be at least * 10usec high before make it low */ usleep_range(10, 15); r = i2c_master_recv(qca199x_dev->client, &efuse_value, sizeof(efuse_value)); if (r < 0) { /* Restore original NFCC slave I2C address */ qca199x_dev->client->addr = curr_addr; dev_err(&qca199x_dev->client->dev, "ERROR_I2C_RCV_FAIL : i2c recv fail\n"); return -EIO; } dev_dbg(&qca199x_dev->client->dev, "%s : EFUSE_VALUE %02x\n", __func__, efuse_value); /* Restore original NFCC slave I2C address */ qca199x_dev->client->addr = curr_addr; return efuse_value; } /* * Inside nfc_ioctl_nfcc_version * Loading Loading @@ -891,6 +946,7 @@ static long nfc_ioctl(struct file *pfile, unsigned int cmd, unsigned long arg) { int r = 0; struct qca199x_dev *qca199x_dev = pfile->private_data; switch (cmd) { case NFC_SET_PWR: nfc_ioctl_power_states(pfile, cmd, arg); Loading @@ -908,6 +964,14 @@ static long nfc_ioctl(struct file *pfile, unsigned int cmd, break; case SET_EMULATOR_TEST_POINT: break; case NFC_GET_EFUSE: r = nfc_ioctl_nfcc_efuse(pfile, cmd, arg); if (r < 0) { r = 0xFF; dev_err(&qca199x_dev->client->dev, "nfc_ioctl : FAILED TO READ EFUSE TYPE\n"); } break; default: r = -ENOIOCTLCMD; } Loading drivers/nfc/nfc-nci.h +1 −0 Original line number Diff line number Diff line Loading @@ -60,6 +60,7 @@ struct devicemode { #define SET_RX_BLOCK _IOW(0xE9, 0x04, unsigned int) #define SET_EMULATOR_TEST_POINT _IOW(0xE9, 0x05, unsigned int) #define NFCC_VERSION _IOW(0xE9, 0x08, unsigned int) #define NFC_GET_EFUSE _IOW(0xE9, 0x09, unsigned int) #define NFC_MAX_I2C_TRANSFER (0x0400) #define NFC_MSG_MAX_SIZE (0x21) Loading Loading
drivers/nfc/nfc-nci.c +65 −1 Original line number Diff line number Diff line Loading @@ -66,7 +66,7 @@ MODULE_DEVICE_TABLE(of, msm_match_table); #define CORE_RST_NTF_LENGTH (0x02) #define WAKE_TIMEOUT (10) #define WAKE_REG (0x10) #define EFUSE_REG (0xA0) struct qca199x_dev { wait_queue_head_t read_wq; Loading Loading @@ -707,6 +707,61 @@ int nfc_ioctl_nfcc_mode(struct file *filp, unsigned int cmd, unsigned long arg) return retval; } /* * Inside nfc_ioctl_nfcc_efuse * * @brief nfc_ioctl_nfcc_efuse * * */ int nfc_ioctl_nfcc_efuse(struct file *filp, unsigned int cmd, unsigned long arg) { int r = 0; unsigned short slave_addr = 0xE; unsigned short curr_addr; unsigned char efuse_addr = EFUSE_REG; unsigned char efuse_value = 0xFF; struct qca199x_dev *qca199x_dev = filp->private_data; curr_addr = qca199x_dev->client->addr; qca199x_dev->client->addr = slave_addr; r = nfc_i2c_write(qca199x_dev->client, &efuse_addr, 1); if (r < 0) { /* Restore original NFCC slave I2C address */ qca199x_dev->client->addr = curr_addr; dev_err(&qca199x_dev->client->dev, "ERROR_WRITE_FAIL : i2c write fail\n"); return -EIO; } /* * NFCC chip needs to be at least * 10usec high before make it low */ usleep_range(10, 15); r = i2c_master_recv(qca199x_dev->client, &efuse_value, sizeof(efuse_value)); if (r < 0) { /* Restore original NFCC slave I2C address */ qca199x_dev->client->addr = curr_addr; dev_err(&qca199x_dev->client->dev, "ERROR_I2C_RCV_FAIL : i2c recv fail\n"); return -EIO; } dev_dbg(&qca199x_dev->client->dev, "%s : EFUSE_VALUE %02x\n", __func__, efuse_value); /* Restore original NFCC slave I2C address */ qca199x_dev->client->addr = curr_addr; return efuse_value; } /* * Inside nfc_ioctl_nfcc_version * Loading Loading @@ -891,6 +946,7 @@ static long nfc_ioctl(struct file *pfile, unsigned int cmd, unsigned long arg) { int r = 0; struct qca199x_dev *qca199x_dev = pfile->private_data; switch (cmd) { case NFC_SET_PWR: nfc_ioctl_power_states(pfile, cmd, arg); Loading @@ -908,6 +964,14 @@ static long nfc_ioctl(struct file *pfile, unsigned int cmd, break; case SET_EMULATOR_TEST_POINT: break; case NFC_GET_EFUSE: r = nfc_ioctl_nfcc_efuse(pfile, cmd, arg); if (r < 0) { r = 0xFF; dev_err(&qca199x_dev->client->dev, "nfc_ioctl : FAILED TO READ EFUSE TYPE\n"); } break; default: r = -ENOIOCTLCMD; } Loading
drivers/nfc/nfc-nci.h +1 −0 Original line number Diff line number Diff line Loading @@ -60,6 +60,7 @@ struct devicemode { #define SET_RX_BLOCK _IOW(0xE9, 0x04, unsigned int) #define SET_EMULATOR_TEST_POINT _IOW(0xE9, 0x05, unsigned int) #define NFCC_VERSION _IOW(0xE9, 0x08, unsigned int) #define NFC_GET_EFUSE _IOW(0xE9, 0x09, unsigned int) #define NFC_MAX_I2C_TRANSFER (0x0400) #define NFC_MSG_MAX_SIZE (0x21) Loading