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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
|
/*
* @file mstdrv.h
* @brief Header file for MST driver
* Copyright (c) 2015~2019, Samsung Electronics Corporation. 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 MST_DRV_H
#define MST_DRV_H
#if defined(CONFIG_ARCH_QCOM)
#include <linux/msm-bus.h>
#include <linux/msm_pcie.h>
#include <linux/sched/core_ctl.h>
#include <linux/qseecom.h>
#endif
#if defined(CONFIG_ARCH_EXYNOS)
#if defined(CONFIG_MST_LPM_CONTROL) && defined(CONFIG_PCI_EXYNOS)
#include <linux/exynos-pci-ctrl.h>
#endif
#include <linux/smc.h>
#if defined(CONFIG_MST_TEEGRIS)
#include "../../drivers/misc/tzdev/include/tzdev/tee_client_api.h"
#endif
#endif
/* defines */
#define MST_DRV_DEV "mst_drv"
#define TAG "[sec_mst]"
#if defined(CONFIG_ARCH_QCOM)
#define SVC_MST_ID 0x000A0000 // need to check ID
#define MST_CREATE_CMD(x) (SVC_MST_ID | x) // Create MST commands
#define MST_TA "mst"
DEFINE_MUTEX(mst_mutex);
DEFINE_MUTEX(transmit_mutex);
#endif
#if defined(CONFIG_MST_V2)
#define MFC_MST_LDO_CONFIG_1 0x7400
#define MFC_MST_LDO_CONFIG_2 0x7409
#define MFC_MST_LDO_CONFIG_3 0x7418
#define MFC_MST_LDO_CONFIG_4 0x3014
#define MFC_MST_LDO_CONFIG_5 0x3405
#define MFC_MST_LDO_CONFIG_6 0x3010
#define MFC_MST_LDO_TURN_ON 0x301c
#define MFC_MST_LDO_CONFIG_8 0x343c
#define MFC_MST_OVER_TEMP_INT 0x0024
#endif
#define MFC_CHIP_ID_L_REG 0x00
#define MFC_CHIP_ID_P9320 0x20
#define MFC_CHIP_ID_S2MIW04 0x04
/* for logging */
#include <linux/printk.h>
void mst_printk(int level, const char *fmt, ...);
#define DEV_ERR (1)
#define DEV_WARN (2)
#define DEV_NOTI (3)
#define DEV_INFO (4)
#define DEV_DEBUG (5)
#define MST_LOG_LEVEL DEV_INFO
#define mst_err(fmt, ...) mst_printk(DEV_ERR, fmt, ## __VA_ARGS__);
#define mst_warn(fmt, ...) mst_printk(DEV_WARN, fmt, ## __VA_ARGS__);
#define mst_noti(fmt, ...) mst_printk(DEV_NOTI, fmt, ## __VA_ARGS__);
#define mst_info(fmt, ...) mst_printk(DEV_INFO, fmt, ## __VA_ARGS__);
#define mst_debug(fmt, ...) mst_printk(DEV_DEBUG, fmt, ## __VA_ARGS__);
struct workqueue_struct *cluster_freq_ctrl_wq;
struct delayed_work dwork;
static uint32_t mode_set_wait = 40;
static uint32_t idt_i2c_command = 0;
typedef enum {
MFC_CHIP_ID_IDT = 1,
MFC_CHIP_ID_LSI,
} mfc_chip_vendor;
#if defined(CONFIG_ARCH_QCOM)
/* global variables */
uint32_t ss_mst_bus_hdl;
/* enum definitions */
typedef enum {
MST_CMD_TRACK1_TEST = MST_CREATE_CMD(0x00000000),
MST_CMD_TRACK2_TEST = MST_CREATE_CMD(0x00000001),
MST_CMD_UNKNOWN = MST_CREATE_CMD(0x7FFFFFFF)
} mst_cmd_type;
/* struct definitions */
struct qseecom_handle {
void *dev; /* in/out */
unsigned char *sbuf; /* in/out */
uint32_t sbuf_len; /* in/out */
};
static struct qseecom_handle *qhandle;
typedef struct mst_req_s {
mst_cmd_type cmd_id;
uint32_t data;
} __attribute__ ((packed)) mst_req_t;
typedef struct mst_rsp_s {
uint32_t data;
uint32_t status;
} __attribute__ ((packed)) mst_rsp_t;
/* extern function declarations */
extern int qseecom_start_app(struct qseecom_handle **handle, char *app_name,
uint32_t size);
extern int qseecom_shutdown_app(struct qseecom_handle **handle);
extern int qseecom_send_command(struct qseecom_handle *handle, void *send_buf,
uint32_t sbuf_len, void *resp_buf,
uint32_t rbuf_len);
static struct msm_bus_paths ss_mst_usecases[] = {
{
.vectors = (struct msm_bus_vectors[]){
{
.src = 1,
.dst = 512,
.ab = 0,
.ib = 0,
},
},
.num_paths = 1,
},
{
.vectors = (struct msm_bus_vectors[]){
{
.src = 1,
.dst = 512,
.ab = 4068000000,
.ib = 4068000000,
},
},
.num_paths = 1,
},
};
static struct msm_bus_scale_pdata ss_mst_bus_client_pdata = {
.usecase = ss_mst_usecases,
.num_usecases = ARRAY_SIZE(ss_mst_usecases),
.name = "ss_mst",
};
#endif
#if defined(CONFIG_ARCH_EXYNOS)
#if defined(CONFIG_MST_TEEGRIS)
/* enum definitions */
enum cmd_drv_client
{
/* ta cmd */
CMD_OPEN,
CMD_CLOSE,
CMD_IOCTL,
CMD_TRACK1,
CMD_TRACK2,
CMD_MAX
};
/* ta uuid definition */
static TEEC_UUID uuid_ta = {
0,0,0,{0,0,0x6d,0x73,0x74,0x5f,0x54,0x41}
};
#endif
#endif
#endif /* MST_DRV_H */
|