aboutsummaryrefslogtreecommitdiff
path: root/include/uapi/linux/tsc.h
blob: ea6dde1bf48308c24e37eb2762a6fe37678d637d (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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#ifndef TSC_H_
#define TSC_H_

#include <linux/ioctl.h>
#include <linux/types.h>

/*
 * ENUMS
 */
/* TSC sources that can transfer the TS out */
enum tsc_source {
	TSC_SOURCE_EXTERNAL0,
	TSC_SOURCE_EXTERNAL1,
	TSC_SOURCE_INTERNAL,
	TSC_SOURCE_CICAM
};

/* TSC destinations that can receive TS */
enum tsc_dest {
	TSC_DEST_TSPP0,
	TSC_DEST_TSPP1,
	TSC_DEST_CICAM
};

/** TSIF parameters **/
/* TSC data type - can be serial of parallel */
enum tsc_data_type {
	TSC_DATA_TYPE_SERIAL = 0,
	TSC_DATA_TYPE_PARALLEL = 1
};

/* TSC receive mode - determine the usage of the VALID and START bits */
enum tsc_receive_mode {
	TSC_RECEIVE_MODE_START_VALID = 0,
	TSC_RECEIVE_MODE_START_ONLY = 1,
	TSC_RECEIVE_MODE_VALID_ONLY = 2
};

/* TSC polarity - can be normal or inversed */
enum tsc_polarity {
	TSC_POLARITY_NORMAL = 0,
	TSC_POLARITY_INVERSED = 1,
};

/* TSC data swap - whether LSB or MSB is sent first */
enum tsc_data_swap {
	TSC_DATA_NORMAL = 0,
	TSC_DATA_SWAP = 1
};

/* TSC set error bit in ts header if ts_fail is enable */
enum tsc_set_error_bit {
	TSC_SET_ERROR_BIT_DISABLE = 0,
	TSC_SET_ERROR_BIT_ENABLE = 1
};

/* TSC CAM personality type */
enum tsc_cam_personality {
	TSC_CICAM_PERSONALITY_DISABLE = 0,
	TSC_CICAM_PERSONALITY_CI = 1,
	TSC_CICAM_PERSONALITY_CIPLUS = 2,
};

/* TSC CAM card status */
enum tsc_card_status {
	TSC_CARD_STATUS_DETECTED,
	TSC_CARD_STATUS_NOT_DETECTED,
	TSC_CARD_STATUS_FAILURE
};

/* TSC transaction error types */
enum tsc_transcation_error {
	TSC_TRANSACTION_ERROR_ERR,
	TSC_TRANSACTION_ERROR_RETRY,
	TSC_TRANSACTION_ERROR_SPLIT
};


/*
 * STRUCTS
 */
/* TSC route - configure a TS transfer from source to dest */
struct tsc_route {
	enum tsc_source source;
	enum tsc_dest dest;
};

/* TSIF parameters to configure the source TSIF */
struct tsc_tsif_params {
	enum tsc_source source;
	enum tsc_receive_mode receive_mode;
	enum tsc_data_type data_type;
	enum tsc_polarity clock_polarity;
	enum tsc_polarity data_polarity;
	enum tsc_polarity start_polarity;
	enum tsc_polarity valid_polarity;
	enum tsc_polarity error_polarity;
	enum tsc_data_swap data_swap;
	enum tsc_set_error_bit set_error;
};


/* Parameters to perform single byte data transaction */
struct tsc_single_byte_mode {
	__u16 address;
	__u8 data;
	int timeout; /* in msec */
};

/* Parameters to perform buffer data transaction */
struct tsc_buffer_mode {
	int buffer_fd;
	__u16 buffer_size;
	int timeout; /* in msec */
};

/*
 * defines for IOCTL functions
 * read Documentation/ioctl-number.txt
 * some random number to avoid coinciding with other ioctl numbers
 */
#define TSC_IOCTL_BASE					0xBA

/* TSC Mux IOCTLs */
#define TSC_CONFIG_ROUTE			\
	_IOW(TSC_IOCTL_BASE, 0, struct tsc_route)
#define TSC_ENABLE_INPUT			\
	_IOW(TSC_IOCTL_BASE, 1, enum tsc_source)
#define TSC_DISABLE_INPUT			\
	_IOW(TSC_IOCTL_BASE, 2, enum tsc_source)
#define TSC_SET_TSIF_CONFIG			\
	_IOW(TSC_IOCTL_BASE, 3, struct tsc_tsif_params)
#define TSC_CLEAR_RATE_MISMATCH_IRQ		\
	_IO(TSC_IOCTL_BASE, 4)
#define TSC_CICAM_SET_CLOCK			\
	_IOW(TSC_IOCTL_BASE, 5, int)

/* TSC CI Card IOCTLs */
#define TSC_CAM_RESET				\
	_IO(TSC_IOCTL_BASE, 6)
#define TSC_CICAM_PERSONALITY_CHANGE\
	_IOW(TSC_IOCTL_BASE, 7, enum tsc_cam_personality)
#define TSC_GET_CARD_STATUS			\
	_IOR(TSC_IOCTL_BASE, 8, enum tsc_card_status)

/* TSC CI Data IOCTLs */
#define TSC_READ_CAM_MEMORY			\
	_IOWR(TSC_IOCTL_BASE, 9, struct tsc_single_byte_mode)
#define TSC_WRITE_CAM_MEMORY		\
	_IOW(TSC_IOCTL_BASE, 10, struct tsc_single_byte_mode)
#define TSC_READ_CAM_IO				\
	_IOWR(TSC_IOCTL_BASE, 11, struct tsc_single_byte_mode)
#define TSC_WRITE_CAM_IO			\
	_IOW(TSC_IOCTL_BASE, 12, struct tsc_single_byte_mode)
#define TSC_READ_CAM_BUFFER			\
	_IOWR(TSC_IOCTL_BASE, 13, struct tsc_buffer_mode)
#define TSC_WRITE_CAM_BUFFER		\
	_IOW(TSC_IOCTL_BASE, 14, struct tsc_buffer_mode)

#endif /* TSC_H_ */