source: G950FXXS5DSI1
[GitHub/exynos8895/android_kernel_samsung_universal8895.git] / include / linux / sti / abc_common.h
1 /* abc_common.h
2 *
3 * Abnormal Behavior Catcher Common Driver
4 *
5 * Copyright (C) 2017 Samsung Electronics
6 *
7 * Hyeokseon Yu <hyeokseon.yu@samsung.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 */
20
21 #ifndef SEC_ABC_H
22 #define SEC_ABC_H
23
24 #include <linux/kernel.h>
25 #include <linux/module.h>
26 #include <linux/sec_sysfs.h>
27 #include <linux/device.h>
28 #include <linux/platform_device.h>
29 #include <linux/of.h>
30 #include <linux/of_device.h>
31 #include <linux/err.h>
32 #include <linux/kthread.h>
33 #include <linux/delay.h>
34 #include <linux/io.h>
35 #include <linux/slab.h>
36 #include <linux/suspend.h>
37 #include <linux/workqueue.h>
38 #include <linux/rtc.h>
39
40 #define ABC_UEVENT_MAX 20
41 #define ABC_BUFFER_MAX 256
42 #define ABC_LOG_STR_LEN 50
43 #define ABC_LOG_MAX 80
44
45 #define ABC_WAIT_ENABLE_TIMEOUT 10000
46
47 enum {
48 ABC_DISABLED,
49 /* TYPE1 : ABC Driver - ABC Daemon is not used. ABC Driver manage ABC Error */
50 ABC_TYPE1_ENABLED,
51 /* TYPE2 : Common Driver - ABC Daemon is used. ABC Daemon manage ABC Error. Common Driver send uevent bypass */
52 ABC_TYPE2_ENABLED,
53 };
54
55 enum {
56 ABC_EVENT_I2C = 1,
57 ABC_EVENT_UNDERRUN,
58 ABC_EVENT_GPU_FAULT,
59 };
60
61 struct abc_fault_info {
62 unsigned long cur_time;
63 int cur_cnt;
64 };
65
66 struct abc_buffer {
67 int size;
68 int rear;
69 int front;
70
71 struct abc_fault_info *abc_element;
72 };
73
74 struct abc_qdata {
75 const char *desc;
76 int queue_size;
77 int threshold_cnt;
78 int threshold_time;
79 int fail_cnt;
80
81 struct abc_buffer buffer;
82 };
83
84 struct abc_platform_data {
85 struct abc_qdata *gpu_items;
86 struct abc_qdata *aicl_items;
87
88 unsigned int nItem;
89 unsigned int nGpu;
90 unsigned int nAicl;
91 };
92
93 struct abc_log_entry {
94 struct list_head node;
95 char abc_log_str[ABC_LOG_STR_LEN];
96 };
97
98 struct abc_info {
99 struct device *dev;
100 struct workqueue_struct *workqueue;
101 struct work_struct work;
102 struct list_head log_list;
103 struct completion enable_done;
104 int log_list_cnt;
105 char abc_str[ABC_BUFFER_MAX];
106 struct abc_platform_data *pdata;
107 struct mutex log_mutex;
108 };
109
110 extern void sec_abc_send_event(char *str);
111 extern int sec_abc_get_enabled(void);
112 extern int sec_abc_wait_enabled(void);
113 #endif