tizen 2.4 release
[kernel/linux-3.0.git] / drivers / gpu / arm / mali400 / r4p0_rel0 / linux / mali_osk_specific.h
1 /*
2  * Copyright (C) 2010, 2012 ARM Limited. All rights reserved.
3  * 
4  * This program is free software and is provided to you under the terms of the GNU General Public License version 2
5  * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
6  * 
7  * A copy of the licence is included with the program, and can also be obtained from Free Software
8  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
9  */
10
11 /**
12  * @file mali_osk_specific.h
13  * Defines per-OS Kernel level specifics, such as unusual workarounds for
14  * certain OSs.
15  */
16
17 #ifndef __MALI_OSK_SPECIFIC_H__
18 #define __MALI_OSK_SPECIFIC_H__
19
20 #include <asm/uaccess.h>
21 #include <linux/platform_device.h>
22 #include <linux/dmapool.h>
23 #include <linux/gfp.h>
24 #include <linux/hardirq.h>
25
26 #include "mali_osk_types.h"
27 #include "mali_kernel_linux.h"
28
29 #define MALI_STATIC_INLINE static inline
30 #define MALI_NON_STATIC_INLINE inline
31
32 typedef struct dma_pool * mali_dma_pool;
33
34
35 MALI_STATIC_INLINE mali_dma_pool mali_dma_pool_create(u32 size, u32 alignment, u32 boundary)
36 {
37         return dma_pool_create("mali-dma", &mali_platform_device->dev, size, alignment, boundary);
38 }
39
40 MALI_STATIC_INLINE void mali_dma_pool_destroy(mali_dma_pool pool)
41 {
42         dma_pool_destroy(pool);
43 }
44
45 MALI_STATIC_INLINE mali_io_address mali_dma_pool_alloc(mali_dma_pool pool, u32 *phys_addr)
46 {
47         return dma_pool_alloc(pool, GFP_KERNEL, phys_addr);
48 }
49
50 MALI_STATIC_INLINE void mali_dma_pool_free(mali_dma_pool pool, void* virt_addr, u32 phys_addr)
51 {
52         dma_pool_free(pool, virt_addr, phys_addr);
53 }
54
55
56 #if MALI_ENABLE_CPU_CYCLES
57 /* Reads out the clock cycle performance counter of the current cpu.
58    It is useful for cost-free (2 cycle) measuring of the time spent
59    in a code path. Sample before and after, the diff number of cycles.
60    When the CPU is idle it will not increase this clock counter.
61    It means that the counter is accurate if only spin-locks are used,
62    but mutexes may lead to too low values since the cpu might "idle"
63    waiting for the mutex to become available.
64    The clock source is configured on the CPU during mali module load,
65    but will not give useful output after a CPU has been power cycled.
66    It is therefore important to configure the system to not turn of
67    the cpu cores when using this functionallity.*/
68 static inline unsigned int mali_get_cpu_cyclecount(void)
69 {
70         unsigned int value;
71         /* Reading the CCNT Register - CPU clock counter */
72         asm volatile ("MRC p15, 0, %0, c9, c13, 0\t\n": "=r"(value));
73         return value;
74 }
75
76 void mali_init_cpu_time_counters(int reset, int enable_divide_by_64);
77 #endif
78
79
80 MALI_STATIC_INLINE u32 _mali_osk_copy_from_user(void *to, void *from, u32 n)
81 {
82         return (u32)copy_from_user(to, from, (unsigned long)n);
83 }
84
85 MALI_STATIC_INLINE mali_bool _mali_osk_in_atomic(void)
86 {
87         return in_atomic();
88 }
89
90 #define _mali_osk_put_user(x, ptr) put_user(x, ptr)
91
92 #endif /* __MALI_OSK_SPECIFIC_H__ */