Tapas Dey | 367bf99 | 2019-01-17 16:54:23 +0530 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | /* |
Gaurav Singhal | 29efe77 | 2020-04-17 18:17:13 +0530 | [diff] [blame] | 3 | * Copyright (c) 2015-2020, The Linux Foundation. All rights reserved. |
Tapas Dey | 367bf99 | 2019-01-17 16:54:23 +0530 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #ifndef __NQ_NCI_H |
| 7 | #define __NQ_NCI_H |
| 8 | |
| 9 | #include <linux/i2c.h> |
| 10 | #include <linux/types.h> |
| 11 | #include <linux/version.h> |
| 12 | |
| 13 | #include <linux/semaphore.h> |
| 14 | #include <linux/completion.h> |
| 15 | |
| 16 | #include <linux/ioctl.h> |
| 17 | #include <linux/cdev.h> |
| 18 | #include <linux/nfcinfo.h> |
| 19 | |
| 20 | #define NFC_SET_PWR _IOW(0xE9, 0x01, unsigned int) |
| 21 | #define ESE_SET_PWR _IOW(0xE9, 0x02, unsigned int) |
| 22 | #define ESE_GET_PWR _IOR(0xE9, 0x03, unsigned int) |
| 23 | #define SET_RX_BLOCK _IOW(0xE9, 0x04, unsigned int) |
| 24 | #define SET_EMULATOR_TEST_POINT _IOW(0xE9, 0x05, unsigned int) |
| 25 | #define NFCC_INITIAL_CORE_RESET_NTF _IOW(0xE9, 0x10, unsigned int) |
| 26 | |
Bhuvan Varshney | dea45e3 | 2019-09-03 11:15:22 +0530 | [diff] [blame] | 27 | #define DEV_COUNT 1 |
| 28 | #define DEVICE_NAME "nq-nci" |
| 29 | #define CLASS_NAME "nqx" |
| 30 | #define MAX_BUFFER_SIZE (320) |
| 31 | #define WAKEUP_SRC_TIMEOUT (2000) |
| 32 | #define NCI_HEADER_LEN 3 |
| 33 | #define NCI_PAYLOAD_IDX 3 |
| 34 | #define MAX_RETRY_COUNT 3 |
| 35 | #define NCI_RESET_CMD_LEN 4 |
| 36 | #define NCI_RESET_RSP_LEN 4 |
| 37 | #define NCI_RESET_NTF_LEN 13 |
| 38 | #define NCI_GET_VERSION_CMD_LEN 8 |
| 39 | #define NCI_GET_VERSION_RSP_LEN 12 |
| 40 | #define MAX_IRQ_WAIT_TIME (90) //in ms |
| 41 | #define COLD_RESET_CMD_LEN 3 |
| 42 | #define COLD_RESET_RSP_LEN 4 |
| 43 | #define COLD_RESET_CMD_GID 0x2F |
| 44 | #define COLD_RESET_CMD_PAYLOAD_LEN 0x00 |
| 45 | #define COLD_RESET_RSP_GID 0x4F |
| 46 | #define COLD_RESET_OID 0x1E |
| 47 | |
Tapas Dey | 367bf99 | 2019-01-17 16:54:23 +0530 | [diff] [blame] | 48 | #define NFC_RX_BUFFER_CNT_START (0x0) |
| 49 | #define PAYLOAD_HEADER_LENGTH (0x3) |
| 50 | #define PAYLOAD_LENGTH_MAX (256) |
| 51 | #define BYTE (0x8) |
| 52 | #define NCI_IDENTIFIER (0x10) |
Gaurav Singhal | 29efe77 | 2020-04-17 18:17:13 +0530 | [diff] [blame] | 53 | #define NFC_LDO_SUPPLY_DT_NAME "qcom,nq-vdd-1p8" |
| 54 | #define NFC_LDO_SUPPLY_NAME "qcom,nq-vdd-1p8-supply" |
| 55 | #define NFC_LDO_VOL_DT_NAME "qcom,nq-vdd-1p8-voltage" |
| 56 | #define NFC_LDO_CUR_DT_NAME "qcom,nq-vdd-1p8-current" |
| 57 | |
| 58 | //as per SN1x0 datasheet |
| 59 | #define NFC_VDDIO_MIN 1650000 //in uV |
| 60 | #define NFC_VDDIO_MAX 1950000 //in uV |
| 61 | #define NFC_CURRENT_MAX 157000 //in uA |
Tapas Dey | 367bf99 | 2019-01-17 16:54:23 +0530 | [diff] [blame] | 62 | |
Bhuvan Varshney | dea45e3 | 2019-09-03 11:15:22 +0530 | [diff] [blame] | 63 | enum ese_ioctl_request { |
| 64 | /* eSE POWER ON */ |
| 65 | ESE_POWER_ON = 0, |
| 66 | /* eSE POWER OFF */ |
| 67 | ESE_POWER_OFF, |
| 68 | /* eSE COLD RESET */ |
| 69 | ESE_COLD_RESET, |
| 70 | /* eSE POWER STATE */ |
| 71 | ESE_POWER_STATE |
| 72 | }; |
| 73 | |
| 74 | enum nfcc_ioctl_request { |
| 75 | /* NFC disable request with VEN LOW */ |
| 76 | NFC_POWER_OFF = 0, |
| 77 | /* NFC enable request with VEN Toggle */ |
| 78 | NFC_POWER_ON, |
| 79 | /* firmware download request with VEN Toggle */ |
| 80 | NFC_FW_DWL_VEN_TOGGLE, |
| 81 | /* ISO reset request */ |
| 82 | NFC_ISO_RESET, |
| 83 | /* request for firmware download gpio HIGH */ |
| 84 | NFC_FW_DWL_HIGH, |
| 85 | /* hard reset request */ |
| 86 | NFC_HARD_RESET, |
| 87 | /* request for firmware download gpio LOW */ |
| 88 | NFC_FW_DWL_LOW, |
| 89 | /* NFC enable without VEN gpio modification */ |
| 90 | NFC_ENABLE, |
| 91 | /* NFC disable without VEN gpio modification */ |
| 92 | NFC_DISABLE |
| 93 | }; |
| 94 | |
Tapas Dey | 367bf99 | 2019-01-17 16:54:23 +0530 | [diff] [blame] | 95 | enum nfcc_initial_core_reset_ntf { |
| 96 | TIMEDOUT_INITIAL_CORE_RESET_NTF = 0, /* 0*/ |
| 97 | ARRIVED_INITIAL_CORE_RESET_NTF, /* 1 */ |
| 98 | DEFAULT_INITIAL_CORE_RESET_NTF, /*2*/ |
| 99 | }; |
| 100 | |
| 101 | enum nfcc_chip_variant { |
| 102 | NFCC_NQ_210 = 0x48, /**< NFCC NQ210 */ |
| 103 | NFCC_NQ_220 = 0x58, /**< NFCC NQ220 */ |
| 104 | NFCC_NQ_310 = 0x40, /**< NFCC NQ310 */ |
| 105 | NFCC_NQ_330 = 0x51, /**< NFCC NQ330 */ |
Bhuvan Varshney | f1684bb | 2019-01-03 21:17:45 +0530 | [diff] [blame] | 106 | NFCC_SN100_A = 0xa3, /**< NFCC SN100_A */ |
| 107 | NFCC_SN100_B = 0xa4, /**< NFCC SN100_B */ |
Tapas Dey | 367bf99 | 2019-01-17 16:54:23 +0530 | [diff] [blame] | 108 | NFCC_PN66T = 0x18, /**< NFCC PN66T */ |
| 109 | NFCC_NOT_SUPPORTED = 0xFF /**< NFCC is not supported */ |
| 110 | }; |
| 111 | #endif |