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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
|
/*
* Copyright (c) 2018 Samsung Electronics Co., Ltd.
* http://www.samsung.com
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License Version 2 as publised
* by the Free Software Foundation.
*
* Header for BTS Bus Traffic Shaper
*
* Includes Data structure for BTS device driver and pre-defined offsets
* For offset values used in register setting, please refer regs-bts.h
*
*/
#ifndef __BTS_H__
#define __BTS_H__
#include <linux/types.h>
#include <linux/module.h>
#include <linux/platform_device.h>
#include <dt-bindings/soc/samsung/exynos-bts.h>
#include <soc/samsung/exynos-pd.h>
#include <soc/samsung/bts.h>
#define NUM_CHANNEL 4
#define BUS_WIDTH 16
#define MIF_UTIL 65
#define INT_UTIL 70
#define DEFAULT_QOS 0x4
#define MAX_QOS 0xF
#define SCIMAX_QOS 0x3
#define MAX_MO 0xFFFF
#define MAX_QUTH 0xFF
struct bts_scen;
struct bts_stat;
struct bts_info;
/**
* struct bts - Device BTS structure
* @lock: a spin-lock to protect accessing bts
* @mutex_lock: mutex-lock to protect accessing setting DVFS
*
* @num_bts: number of bts hardware
* @num_scen: number of scenario be used
* @top_scen: current top scenario
*
* @bts_list: struct bts_info * - contains start address pointer for BTS devices
* @scen_list: struct bts_scen * - contains start address pointer for BTS scenarios
* @scen_node: list node - contains structure about scenario
*
* @bts_bw: struct bts_bw * - struct for saving bandwidth information
* @peak_bw: currently max bandwidth
* @total_bw: current total bandwidth
* @calc_dis: boolean value whether using calc API
*
* This structure stores basic BTS information for QoS control
*
* Note that it contains only basic information of BTS device driver
*
*/
struct bts_device {
struct device *dev;
spinlock_t lock;
struct mutex mutex_lock;
unsigned int num_bts;
unsigned int num_scen;
unsigned int top_scen;
struct bts_info *bts_list;
struct bts_scen *scen_list;
struct list_head scen_node;
struct bts_bw *bts_bw;
unsigned int peak_bw;
unsigned int total_bw;
int calc_dis_cnt;
};
/**
* struct bts_ops - operation functions for BTS setting
* @init_bts: function for initialize.
* It will be run only on initial time and after system resume
* @set_bts: operation function to set bts.
* @get_bts: operation function to get bts.
* @set_qos: operation function to set axqos of bts.
* @get_qos: operation function to get axqos of bts.
* @set_mo: operation function to set xmo of bts.
* @get_mo: operation function to get xmo of bts.
* @set_urgent: operation function to set urgent timeout of bts.
* @get_urgent: operation function to get urgent timeout of bts.
* @set_blocking: operation function to set blocking threshold of bts.
* @get_blocking: operation function to get blocking threshold of bts.
*
*/
struct bts_ops {
void (*init_bts)(void __iomem *va);
int (*set_bts)(void __iomem *va, struct bts_stat *stat);
int (*get_bts)(void __iomem *va, struct bts_stat *stat);
int (*set_qos)(void __iomem *va, struct bts_stat *stat);
int (*get_qos)(void __iomem *va, struct bts_stat *stat);
int (*set_mo)(void __iomem *va, struct bts_stat *stat);
int (*get_mo)(void __iomem *va, struct bts_stat *stat);
int (*set_urgent)(void __iomem *va, struct bts_stat *stat);
int (*get_urgent)(void __iomem *va, struct bts_stat *stat);
int (*set_blocking)(void __iomem *va, struct bts_stat *stat);
int (*get_blocking)(void __iomem *va, struct bts_stat *stat);
};
/**
* struct bts_scen - BTS scenario
* @node
* @index: scenario index
* @status: scenario status (0 means scenario is off / 1 means on)
* @name: scenario name
*
* BTS scenario is defined in Device Tree and parsed in probe function
* index will be used as priority order of scenarios
*/
struct bts_scen {
struct list_head node;
unsigned int index;
bool status;
int usage_count;
const char *name;
};
/**
* struct bts_stat - BTS status
* @stat_on: shows current set of config can be used or not
* @bypass: when BTS must bypass master request, set as true
*
* @arqos: ArQoS value for master IP (0x0~0xF)
* @awqos: AwQoS value for master IP (0x0~0xF)
* @rmo: Multiple Outstanding value for Read
* @wmo: Multiple Outstanding value for Write
* @qurgent: Signal from Master which accelerates delayed requests
* @qurgent_th_r/w: Threshold for Qurgent. Read/Write is seperated
* @blocking: Signal from Slave which limits master requests
* @qmax_limit_r/w: Limitation criteria when QMAX is enabled
* @qfull_limit_r/w: Limitation criteria when QFULL is enabled
* @qbusy_limit_r/w: Limitation criteria when QBUSY is enabled
*
* This structure stores data to control BTS
*
*/
struct bts_stat {
bool stat_on;
bool bypass;
unsigned int arqos;
unsigned int awqos;
unsigned int rmo;
unsigned int wmo;
bool qurgent_on;
unsigned int qurgent_th_r;
unsigned int qurgent_th_w;
bool blocking_on;
unsigned int qfull_limit_r;
unsigned int qfull_limit_w;
unsigned int qbusy_limit_r;
unsigned int qbusy_limit_w;
unsigned int qmax0_limit_r;
unsigned int qmax0_limit_w;
unsigned int qmax1_limit_r;
unsigned int qmax1_limit_w;
int qos_num;
};
/**
* struct bts_info - BTS information
* @name: name of BTS
* @pa_base: Physical Address data of BTS
* @va_base: Virtual Address data of BTS
* @status: boolean value whether BTS is on/off
* @type: type of bts
* @pd_name: name of power domain
* @pd_on: whether related power domain is on/off
* @stat: list of array that contains BTS status data for QoS control
* @ops: operation function classified according to bts type
*
*/
struct bts_info {
const char *name;
unsigned int pa_base;
void __iomem *va_base;
bool status;
unsigned int type;
unsigned int pd_id;
bool pd_on;
struct bts_stat *stat;
struct bts_ops *ops;
};
extern int register_btsops(struct bts_info *info);
extern int exynos_bts_debugfs_init(void);
#endif
|