Skip to content

Commit 15d1717

Browse files
cricard13Samuel Ortiz
authored andcommitted
NFC: st21nfca: Add support for proprietary commands
Add support for proprietary commands useful mainly for factory testings. Here is a list: - FACTORY_MODE: Allow to set the driver into a mode where no secure element are activated. It does not consider any NFC_ATTR_VENDOR_DATA. - HCI_CLEAR_ALL_PIPES: Allow to execute a HCI clear all pipes command. It does not consider any NFC_ATTR_VENDOR_DATA. - HCI_DM_PUT_DATA: Allow to configure specific CLF registry as for example RF trimmings or low level drivers configurations (I2C, SPI, SWP). - HCI_DM_UPDATE_AID: Allow to configure an AID routing into the CLF routing table following RF technology, CLF mode or protocol. - HCI_DM_GET_INFO: Allow to retrieve CLF information. - HCI_DM_GET_DATA: Allow to retrieve CLF configurable data such as low level drivers configurations or RF trimmings. - HCI_DM_LOAD: Allow to load a firmware into the CLF. A complete packet can be more than 8KB. - HCI_DM_RESET: Allow to run a CLF reset in order to "commit" CLF configuration changes without CLF power off. - HCI_GET_PARAM: Allow to retrieve an HCI CLF parameter (for example the white list). - HCI_DM_FIELD_GENERATOR: Allow to generate different kind of RF technology. When using this command to anti-collision is done. - HCI_LOOPBACK: Allow to echo a command and test the Dh to CLF connectivity. Signed-off-by: Christophe Ricard <[email protected]> Signed-off-by: Samuel Ortiz <[email protected]>
1 parent 2b6e5bf commit 15d1717

File tree

6 files changed

+437
-3
lines changed

6 files changed

+437
-3
lines changed

drivers/nfc/st21nfca/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Makefile for ST21NFCA HCI based NFC driver
33
#
44

5-
st21nfca_hci-objs = core.o dep.o se.o
5+
st21nfca_hci-objs = core.o dep.o se.o vendor_cmds.o
66
obj-$(CONFIG_NFC_ST21NFCA) += st21nfca_hci.o
77

88
st21nfca_i2c-objs = i2c.o

drivers/nfc/st21nfca/core.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -923,6 +923,8 @@ static int st21nfca_hci_event_received(struct nfc_hci_dev *hdev, u8 pipe,
923923
event, skb);
924924
case ST21NFCA_APDU_READER_GATE:
925925
return st21nfca_apdu_reader_event_received(hdev, event, skb);
926+
case NFC_HCI_LOOPBACK_GATE:
927+
return st21nfca_hci_loopback_event_received(hdev, event, skb);
926928
default:
927929
return 1;
928930
}
@@ -1024,6 +1026,7 @@ int st21nfca_hci_probe(void *phy_id, struct nfc_phy_ops *phy_ops,
10241026
*hdev = info->hdev;
10251027
st21nfca_dep_init(info->hdev);
10261028
st21nfca_se_init(info->hdev);
1029+
st21nfca_vendor_cmds_init(info->hdev);
10271030

10281031
return 0;
10291032

drivers/nfc/st21nfca/se.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,9 @@ int st21nfca_hci_discover_se(struct nfc_hci_dev *hdev)
167167
struct st21nfca_hci_info *info = nfc_hci_get_clientdata(hdev);
168168
int se_count = 0;
169169

170+
if (test_bit(ST21NFCA_FACTORY_MODE, &hdev->quirks))
171+
return 0;
172+
170173
if (info->se_status->is_uicc_present) {
171174
nfc_add_se(hdev->ndev, NFC_HCI_UICC_HOST_ID, NFC_SE_UICC);
172175
se_count++;
@@ -191,7 +194,6 @@ int st21nfca_hci_enable_se(struct nfc_hci_dev *hdev, u32 se_idx)
191194
* Same for eSE.
192195
*/
193196
r = st21nfca_hci_control_se(hdev, se_idx, ST21NFCA_SE_MODE_ON);
194-
195197
if (r == ST21NFCA_ESE_HOST_ID) {
196198
st21nfca_se_get_atr(hdev);
197199
r = nfc_hci_send_event(hdev, ST21NFCA_APDU_READER_GATE,

drivers/nfc/st21nfca/st21nfca.h

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@
6666
#define ST21NFCA_HCI_MODE 0
6767
#define ST21NFCA_NUM_DEVICES 256
6868

69+
#define ST21NFCA_VENDOR_OUI 0x0080E1 /* STMicroelectronics */
70+
#define ST21NFCA_FACTORY_MODE 2
71+
6972
struct st21nfca_se_status {
7073
bool is_ese_present;
7174
bool is_uicc_present;
@@ -76,6 +79,50 @@ enum st21nfca_state {
7679
ST21NFCA_ST_READY,
7780
};
7881

82+
/**
83+
* enum nfc_vendor_cmds - supported nfc vendor commands
84+
*
85+
* @FACTORY_MODE: Allow to set the driver into a mode where no secure element
86+
* are activated. It does not consider any NFC_ATTR_VENDOR_DATA.
87+
* @HCI_CLEAR_ALL_PIPES: Allow to execute a HCI clear all pipes command.
88+
* It does not consider any NFC_ATTR_VENDOR_DATA.
89+
* @HCI_DM_PUT_DATA: Allow to configure specific CLF registry as for example
90+
* RF trimmings or low level drivers configurations (I2C, SPI, SWP).
91+
* @HCI_DM_UPDATE_AID: Allow to configure an AID routing into the CLF routing
92+
* table following RF technology, CLF mode or protocol.
93+
* @HCI_DM_GET_INFO: Allow to retrieve CLF information.
94+
* @HCI_DM_GET_DATA: Allow to retrieve CLF configurable data such as low
95+
* level drivers configurations or RF trimmings.
96+
* @HCI_DM_LOAD: Allow to load a firmware into the CLF. A complete
97+
* packet can be more than 8KB.
98+
* @HCI_DM_RESET: Allow to run a CLF reset in order to "commit" CLF
99+
* configuration changes without CLF power off.
100+
* @HCI_GET_PARAM: Allow to retrieve an HCI CLF parameter (for example the
101+
* white list).
102+
* @HCI_DM_FIELD_GENERATOR: Allow to generate different kind of RF
103+
* technology. When using this command to anti-collision is done.
104+
* @HCI_LOOPBACK: Allow to echo a command and test the Dh to CLF
105+
* connectivity.
106+
*/
107+
enum nfc_vendor_cmds {
108+
FACTORY_MODE,
109+
HCI_CLEAR_ALL_PIPES,
110+
HCI_DM_PUT_DATA,
111+
HCI_DM_UPDATE_AID,
112+
HCI_DM_GET_INFO,
113+
HCI_DM_GET_DATA,
114+
HCI_DM_LOAD,
115+
HCI_DM_RESET,
116+
HCI_GET_PARAM,
117+
HCI_DM_FIELD_GENERATOR,
118+
HCI_LOOPBACK,
119+
};
120+
121+
struct st21nfca_vendor_info {
122+
struct completion req_completion;
123+
struct sk_buff *rx_skb;
124+
};
125+
79126
struct st21nfca_dep_info {
80127
struct sk_buff *tx_pending;
81128
struct work_struct tx_work;
@@ -124,12 +171,13 @@ struct st21nfca_hci_info {
124171

125172
struct st21nfca_dep_info dep_info;
126173
struct st21nfca_se_info se_info;
174+
struct st21nfca_vendor_info vendor_info;
127175
};
128176

129177
int st21nfca_hci_probe(void *phy_id, struct nfc_phy_ops *phy_ops,
130178
char *llc_name, int phy_headroom, int phy_tailroom,
131179
int phy_payload, struct nfc_hci_dev **hdev,
132-
struct st21nfca_se_status *se_status);
180+
struct st21nfca_se_status *se_status);
133181
void st21nfca_hci_remove(struct nfc_hci_dev *hdev);
134182

135183
int st21nfca_dep_event_received(struct nfc_hci_dev *hdev,
@@ -156,4 +204,8 @@ int st21nfca_hci_se_io(struct nfc_hci_dev *hdev, u32 se_idx,
156204
void st21nfca_se_init(struct nfc_hci_dev *hdev);
157205
void st21nfca_se_deinit(struct nfc_hci_dev *hdev);
158206

207+
int st21nfca_hci_loopback_event_received(struct nfc_hci_dev *ndev, u8 event,
208+
struct sk_buff *skb);
209+
int st21nfca_vendor_cmds_init(struct nfc_hci_dev *ndev);
210+
159211
#endif /* __LOCAL_ST21NFCA_H_ */

0 commit comments

Comments
 (0)