import PULS_20160108
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / misc / mediatek / gpu / mt8127 / mali / mali / linux / mali_osk_misc.c
1 /*
2 * This confidential and proprietary software may be used only as
3 * authorised by a licensing agreement from ARM Limited
4 * (C) COPYRIGHT 2008-2013 ARM Limited
5 * ALL RIGHTS RESERVED
6 * The entire notice above must be reproduced on all authorised
7 * copies and copies may only be made to the extent permitted
8 * by a licensing agreement from ARM Limited.
9 */
10
11 /**
12 * @file mali_osk_misc.c
13 * Implementation of the OS abstraction layer for the kernel device driver
14 */
15 #include <linux/kernel.h>
16 #include <asm/uaccess.h>
17 #include <asm/cacheflush.h>
18 #include <linux/sched.h>
19 #include <linux/module.h>
20 #include "mali_osk.h"
21 #include "mt_reg_base.h"
22
23 extern void smi_dumpDebugMsg(void);
24 extern int m4u_dump_debug_registers(void);;
25
26 void _mali_osk_dbgmsg( const char *fmt, ... )
27 {
28 va_list args;
29 va_start(args, fmt);
30 vprintk(fmt, args);
31 va_end(args);
32 }
33
34 u32 _mali_osk_snprintf( char *buf, u32 size, const char *fmt, ... )
35 {
36 int res;
37 va_list args;
38 va_start(args, fmt);
39
40 res = vscnprintf(buf, (size_t)size, fmt, args);
41
42 va_end(args);
43 return res;
44 }
45
46 #define CLK_CFG_0 (INFRA_BASE + 0x0040)
47 #define VENCPLL_CON0 (DDRPHY_BASE+0x800)
48 #define MMPLL_CON0 (APMIXEDSYS_BASE + 0x0230)
49
50 void _mali_osk_abort(void)
51 {
52 int index;
53
54 /* make a simple fault by dereferencing a NULL pointer */
55 dump_stack();
56
57 for (index = 0; index < 5; index++)
58 {
59 MALI_DEBUG_PRINT(2, ("=== [MALI] PLL Dump %d ===\n", index));
60 MALI_DEBUG_PRINT(2, ("CLK_CFG_0: 0x%08x\n", *((volatile unsigned int*)CLK_CFG_0)));
61 MALI_DEBUG_PRINT(2, ("VENCPLL_CON0: 0x%08x\n", *((volatile unsigned int*)VENCPLL_CON0)));
62 MALI_DEBUG_PRINT(2, ("MMPLL_CON0: 0x%08x\n", *((volatile unsigned int*)MMPLL_CON0)));
63
64 MALI_DEBUG_PRINT(2, ("=== [MALI] SMI Dump %d ===\n", index));
65 smi_dumpDebugMsg();
66
67 MALI_DEBUG_PRINT(2, ("=== [MALI] 8127 m4u not provide API? M4U Dump %d ===\n", index));
68 /*m4u_dump_debug_registers();*/
69 }
70
71 *(int *)0 = 0;
72 }
73
74 void _mali_osk_break(void)
75 {
76 _mali_osk_abort();
77 }
78
79 u32 _mali_osk_get_pid(void)
80 {
81 /* Thread group ID is the process ID on Linux */
82 return (u32)current->tgid;
83 }
84
85 u32 _mali_osk_get_tid(void)
86 {
87 /* pid is actually identifying the thread on Linux */
88 u32 tid = current->pid;
89
90 /* If the pid is 0 the core was idle. Instead of returning 0 we return a special number
91 * identifying which core we are on. */
92 if (0 == tid) {
93 tid = -(1 + raw_smp_processor_id());
94 }
95
96 return tid;
97 }