MALI: utgard: RK: reconstruct platform specific code for devfreq DVFS
[firefly-linux-kernel-4.4.55.git] / drivers / gpu / arm / mali400 / mali / linux / mali_ukk_core.c
index 1cd7293b134cd0ede38641f3b0fc1c8d3746cdd0..ba10ad21f3791cab6165d9e9e0e78ad5e00390c8 100755 (executable)
@@ -1,11 +1,11 @@
 /*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2008-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2010-2016 ARM Limited. All rights reserved.
+ * 
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
+ * 
+ * A copy of the licence is included with the program, and can also be obtained from Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 #include <linux/fs.h>       /* file system operations */
 #include <linux/slab.h>     /* memort allocation functions */
@@ -26,7 +26,7 @@ int get_api_version_wrapper(struct mali_session_data *session_data, _mali_uk_get
 
        if (0 != get_user(kargs.version, &uargs->version)) return -EFAULT;
 
-       kargs.ctx = session_data;
+       kargs.ctx = (uintptr_t)session_data;
        err = _mali_ukk_get_api_version(&kargs);
        if (_MALI_OSK_ERR_OK != err) return map_errcode(err);
 
@@ -35,16 +35,51 @@ int get_api_version_wrapper(struct mali_session_data *session_data, _mali_uk_get
 
        return 0;
 }
+
+int get_api_version_v2_wrapper(struct mali_session_data *session_data, _mali_uk_get_api_version_v2_s __user *uargs)
+{
+       _mali_uk_get_api_version_v2_s kargs;
+       _mali_osk_errcode_t err;
+
+       MALI_CHECK_NON_NULL(uargs, -EINVAL);
+
+       if (0 != get_user(kargs.version, &uargs->version)) return -EFAULT;
+
+       kargs.ctx = (uintptr_t)session_data;
+       err = _mali_ukk_get_api_version_v2(&kargs);
+       if (_MALI_OSK_ERR_OK != err) return map_errcode(err);
+
+       if (0 != put_user(kargs.version, &uargs->version)) return -EFAULT;
+       if (0 != put_user(kargs.compatible, &uargs->compatible)) return -EFAULT;
+
+       return 0;
+}
+
+/* rk_ext : 从对 r5p0-01rel0 集成开始, 不再使用. */
+#if 0
 #define mali400_in_rk30_version 0x01
 int get_mali_version_in_rk30_wrapper(struct mali_session_data *session_data, _mali_uk_get_mali_version_in_rk30_s __user *uargs)
 {
        _mali_uk_get_mali_version_in_rk30_s kargs;
        MALI_CHECK_NON_NULL(uargs, -EINVAL);
-       kargs.ctx = session_data;
+       kargs.ctx = (uintptr_t)session_data;
        kargs.version = mali400_in_rk30_version;
        if (0 != put_user(kargs.version, &uargs->version)) return -EFAULT;
        return 0;
 }
+#else
+#include "../platform/rk/rk_ext.h"
+int get_rk_ko_version_wrapper(struct mali_session_data *session_data, _mali_rk_ko_version_s __user *uargs)
+{
+       _mali_rk_ko_version_s kargs;
+       MALI_CHECK_NON_NULL(uargs, -EINVAL);
+       kargs.ctx = (uintptr_t)session_data;
+       kargs.version = RK_KO_VER;
+       if (0 != put_user(kargs.version, &uargs->version)) return -EFAULT;
+       return 0;
+}
+#endif
+
 int wait_for_notification_wrapper(struct mali_session_data *session_data, _mali_uk_wait_for_notification_s __user *uargs)
 {
        _mali_uk_wait_for_notification_s kargs;
@@ -52,12 +87,12 @@ int wait_for_notification_wrapper(struct mali_session_data *session_data, _mali_
 
        MALI_CHECK_NON_NULL(uargs, -EINVAL);
 
-       kargs.ctx = session_data;
+       kargs.ctx = (uintptr_t)session_data;
        err = _mali_ukk_wait_for_notification(&kargs);
        if (_MALI_OSK_ERR_OK != err) return map_errcode(err);
 
-       if(_MALI_NOTIFICATION_CORE_SHUTDOWN_IN_PROGRESS != kargs.type) {
-               kargs.ctx = NULL; /* prevent kernel address to be returned to user space */
+       if (_MALI_NOTIFICATION_CORE_SHUTDOWN_IN_PROGRESS != kargs.type) {
+               kargs.ctx = (uintptr_t)NULL; /* prevent kernel address to be returned to user space */
                if (0 != copy_to_user(uargs, &kargs, sizeof(_mali_uk_wait_for_notification_s))) return -EFAULT;
        } else {
                if (0 != put_user(kargs.type, &uargs->type)) return -EFAULT;
@@ -73,7 +108,7 @@ int post_notification_wrapper(struct mali_session_data *session_data, _mali_uk_p
 
        MALI_CHECK_NON_NULL(uargs, -EINVAL);
 
-       kargs.ctx = session_data;
+       kargs.ctx = (uintptr_t)session_data;
 
        if (0 != get_user(kargs.type, &uargs->type)) {
                return -EFAULT;
@@ -94,13 +129,13 @@ int get_user_settings_wrapper(struct mali_session_data *session_data, _mali_uk_g
 
        MALI_CHECK_NON_NULL(uargs, -EINVAL);
 
-       kargs.ctx = session_data;
+       kargs.ctx = (uintptr_t)session_data;
        err = _mali_ukk_get_user_settings(&kargs);
        if (_MALI_OSK_ERR_OK != err) {
                return map_errcode(err);
        }
 
-       kargs.ctx = NULL; /* prevent kernel address to be returned to user space */
+       kargs.ctx = 0; /* prevent kernel address to be returned to user space */
        if (0 != copy_to_user(uargs, &kargs, sizeof(_mali_uk_get_user_settings_s))) return -EFAULT;
 
        return 0;
@@ -113,10 +148,24 @@ int request_high_priority_wrapper(struct mali_session_data *session_data, _mali_
 
        MALI_CHECK_NON_NULL(uargs, -EINVAL);
 
-       kargs.ctx = session_data;
+       kargs.ctx = (uintptr_t)session_data;
        err = _mali_ukk_request_high_priority(&kargs);
 
-       kargs.ctx = NULL;
+       kargs.ctx = 0;
 
        return map_errcode(err);
 }
+
+int pending_submit_wrapper(struct mali_session_data *session_data, _mali_uk_pending_submit_s __user *uargs)
+{
+       _mali_uk_pending_submit_s kargs;
+       _mali_osk_errcode_t err;
+
+       MALI_CHECK_NON_NULL(uargs, -EINVAL);
+
+       kargs.ctx = (uintptr_t)session_data;
+       err = _mali_ukk_pending_submit(&kargs);
+       if (_MALI_OSK_ERR_OK != err) return map_errcode(err);
+
+       return 0;
+}