]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - drivers/nfc/st-nci/st-nci.h
NFC: netlink: Add missing NFC_ATTR comments
[mirror_ubuntu-bionic-kernel.git] / drivers / nfc / st-nci / st-nci.h
CommitLineData
35630df6
CR
1/*
2 * NCI based Driver for STMicroelectronics NFC Chip
3 *
4 * Copyright (C) 2014 STMicroelectronics SAS. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, see <http://www.gnu.org/licenses/>.
17 */
18
ed06aeef
CR
19#ifndef __LOCAL_ST_NCI_H_
20#define __LOCAL_ST_NCI_H_
35630df6 21
35630df6
CR
22#include "ndlc.h"
23
24/* Define private flags: */
ed06aeef 25#define ST_NCI_RUNNING 1
35630df6 26
ed06aeef
CR
27#define ST_NCI_CORE_PROP 0x01
28#define ST_NCI_SET_NFC_MODE 0x02
41fc2f50 29
f5876627
CR
30/*
31 * ref ISO7816-3 chap 8.1. the initial character TS is followed by a
32 * sequence of at most 32 characters.
33 */
34#define ST_NCI_ESE_MAX_LENGTH 33
35#define ST_NCI_HCI_HOST_ID_ESE 0xc0
36
b1fa4dc4
CR
37#define ST_NCI_DEVICE_MGNT_GATE 0x01
38
39#define ST_NCI_VENDOR_OUI 0x0080E1 /* STMicroelectronics */
40#define ST_NCI_FACTORY_MODE 2
41
41fc2f50
CR
42struct nci_mode_set_cmd {
43 u8 cmd_type;
44 u8 mode;
45} __packed;
dbd70b40
CR
46
47struct nci_mode_set_rsp {
48 u8 status;
49} __packed;
50
f5876627
CR
51struct st_nci_se_info {
52 u8 atr[ST_NCI_ESE_MAX_LENGTH];
53 struct completion req_completion;
54
55 struct timer_list bwi_timer;
56 int wt_timeout; /* in msecs */
57 bool bwi_active;
58
59 struct timer_list se_active_timer;
60 bool se_active;
61
62 bool xch_error;
63
64 se_io_cb_t cb;
65 void *cb_context;
66};
67
b1fa4dc4
CR
68/**
69 * enum nfc_vendor_cmds - supported nfc vendor commands
70 *
71 * @FACTORY_MODE: Allow to set the driver into a mode where no secure element
72 * are activated. It does not consider any NFC_ATTR_VENDOR_DATA.
73 * @HCI_CLEAR_ALL_PIPES: Allow to execute a HCI clear all pipes command.
74 * It does not consider any NFC_ATTR_VENDOR_DATA.
75 * @HCI_DM_PUT_DATA: Allow to configure specific CLF registry as for example
76 * RF trimmings or low level drivers configurations (I2C, SPI, SWP).
77 * @HCI_DM_UPDATE_AID: Allow to configure an AID routing into the CLF routing
78 * table following RF technology, CLF mode or protocol.
79 * @HCI_DM_GET_INFO: Allow to retrieve CLF information.
80 * @HCI_DM_GET_DATA: Allow to retrieve CLF configurable data such as low
81 * level drivers configurations or RF trimmings.
82 * @HCI_DM_DIRECT_LOAD: Allow to load a firmware into the CLF. A complete
83 * packet can be more than 8KB.
84 * @HCI_DM_RESET: Allow to run a CLF reset in order to "commit" CLF
85 * configuration changes without CLF power off.
86 * @HCI_GET_PARAM: Allow to retrieve an HCI CLF parameter (for example the
87 * white list).
88 * @HCI_DM_FIELD_GENERATOR: Allow to generate different kind of RF
89 * technology. When using this command to anti-collision is done.
90 * @HCI_LOOPBACK: Allow to echo a command and test the Dh to CLF
91 * connectivity.
92 * @HCI_DM_VDC_MEASUREMENT_VALUE: Allow to measure the field applied on the
93 * CLF antenna. A value between 0 and 0x0f is returned. 0 is maximum.
94 * @HCI_DM_FWUPD_START: Allow to put CLF into firmware update mode. It is a
95 * specific CLF command as there is no GPIO for this.
96 * @HCI_DM_FWUPD_END: Allow to complete firmware update.
97 * @HCI_DM_VDC_VALUE_COMPARISON: Allow to compare the field applied on the
98 * CLF antenna to a reference value.
99 * @MANUFACTURER_SPECIFIC: Allow to retrieve manufacturer specific data
100 * received during a NCI_CORE_INIT_CMD.
101 */
102enum nfc_vendor_cmds {
103 FACTORY_MODE,
104 HCI_CLEAR_ALL_PIPES,
105 HCI_DM_PUT_DATA,
106 HCI_DM_UPDATE_AID,
107 HCI_DM_GET_INFO,
108 HCI_DM_GET_DATA,
109 HCI_DM_DIRECT_LOAD,
110 HCI_DM_RESET,
111 HCI_GET_PARAM,
112 HCI_DM_FIELD_GENERATOR,
113 HCI_LOOPBACK,
114 HCI_DM_FWUPD_START,
115 HCI_DM_FWUPD_END,
116 HCI_DM_VDC_MEASUREMENT_VALUE,
117 HCI_DM_VDC_VALUE_COMPARISON,
118 MANUFACTURER_SPECIFIC,
119};
120
121struct st_nci_vendor_info {
122 struct completion req_completion;
123 struct sk_buff *rx_skb;
124};
125
ed06aeef 126struct st_nci_info {
35630df6
CR
127 struct llt_ndlc *ndlc;
128 unsigned long flags;
ed06aeef 129 struct st_nci_se_info se_info;
b1fa4dc4 130 struct st_nci_vendor_info vendor_info;
35630df6
CR
131};
132
ed06aeef
CR
133void st_nci_remove(struct nci_dev *ndev);
134int st_nci_probe(struct llt_ndlc *ndlc, int phy_headroom,
35630df6
CR
135 int phy_tailroom);
136
f5876627
CR
137int st_nci_se_init(struct nci_dev *ndev);
138void st_nci_se_deinit(struct nci_dev *ndev);
139
140int st_nci_discover_se(struct nci_dev *ndev);
141int st_nci_enable_se(struct nci_dev *ndev, u32 se_idx);
142int st_nci_disable_se(struct nci_dev *ndev, u32 se_idx);
143int st_nci_se_io(struct nci_dev *ndev, u32 se_idx,
144 u8 *apdu, size_t apdu_length,
145 se_io_cb_t cb, void *cb_context);
146int st_nci_hci_load_session(struct nci_dev *ndev);
147void st_nci_hci_event_received(struct nci_dev *ndev, u8 pipe,
148 u8 event, struct sk_buff *skb);
149void st_nci_hci_cmd_received(struct nci_dev *ndev, u8 pipe, u8 cmd,
150 struct sk_buff *skb);
151
b1fa4dc4
CR
152void st_nci_hci_loopback_event_received(struct nci_dev *ndev, u8 event,
153 struct sk_buff *skb);
154int st_nci_vendor_cmds_init(struct nci_dev *ndev);
155
ed06aeef 156#endif /* __LOCAL_ST_NCI_H_ */