summaryrefslogtreecommitdiff
path: root/drivers/usb/gadget/function/f_ccid.h
blob: 935308cff0bc2109fe5df4923e663467fed051d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/*
 * Copyright (c) 2011, 2017 The Linux Foundation. All rights reserved.

 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
 * only version 2 as published by the Free Software Foundation.

 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details
 */

#ifndef __F_CCID_H
#define __F_CCID_H

#define PROTOCOL_TO 0x01
#define PROTOCOL_T1 0x02
#define ABDATA_SIZE 512

/* define for dwFeatures for Smart Card Device Class Descriptors */
/* No special characteristics */
#define CCID_FEATURES_NADA       0x00000000
/* Automatic parameter configuration based on ATR data */
#define CCID_FEATURES_AUTO_PCONF 0x00000002
/* Automatic activation of ICC on inserting */
#define CCID_FEATURES_AUTO_ACTIV 0x00000004
/* Automatic ICC voltage selection */
#define CCID_FEATURES_AUTO_VOLT  0x00000008
/* Automatic ICC clock frequency change */
#define CCID_FEATURES_AUTO_CLOCK 0x00000010
/* Automatic baud rate change */
#define CCID_FEATURES_AUTO_BAUD  0x00000020
/*Automatic parameters negotiation made by the CCID */
#define CCID_FEATURES_AUTO_PNEGO 0x00000040
/* Automatic PPS made by the CCID according to the active parameters */
#define CCID_FEATURES_AUTO_PPS   0x00000080
/* CCID can set ICC in clock stop mode */
#define CCID_FEATURES_ICCSTOP    0x00000100
/* NAD value other than 00 accepted (T=1 protocol in use) */
#define CCID_FEATURES_NAD        0x00000200
/* Automatic IFSD exchange as first exchange (T=1 protocol in use) */
#define CCID_FEATURES_AUTO_IFSD  0x00000400
/* TPDU level exchanges with CCID */
#define CCID_FEATURES_EXC_TPDU   0x00010000
/* Short APDU level exchange with CCID */
#define CCID_FEATURES_EXC_SAPDU  0x00020000
/* Short and Extended APDU level exchange with CCID */
#define CCID_FEATURES_EXC_APDU   0x00040000
/* USB Wake up signaling supported on card insertion and removal */
#define CCID_FEATURES_WAKEUP     0x00100000

#define CCID_NOTIFY_CARD	_IOW('C', 1, struct usb_ccid_notification)
#define CCID_NOTIFY_HWERROR	_IOW('C', 2, struct usb_ccid_notification)
#define CCID_READ_DTR		_IOR('C', 3, int)

struct usb_ccid_notification {
	__u8 buf[4];
} __packed;

struct ccid_bulk_in_header {
	__u8 bMessageType;
	__u32 wLength;
	__u8 bSlot;
	__u8 bSeq;
	__u8 bStatus;
	__u8 bError;
	__u8 bSpecific;
	__u8 abData[ABDATA_SIZE];
	__u8 bSizeToSend;
} __packed;

struct ccid_bulk_out_header {
	__u8 bMessageType;
	__u32 wLength;
	__u8 bSlot;
	__u8 bSeq;
	__u8 bSpecific_0;
	__u8 bSpecific_1;
	__u8 bSpecific_2;
	__u8 APDU[ABDATA_SIZE];
} __packed;
#endif