PageRenderTime 18ms CodeModel.GetById 14ms app.highlight 3ms RepoModel.GetById 0ms app.codeStats 0ms

/drivers/gpu/mali/mali/linux/mali_osk_pm.c

https://bitbucket.org/ndreys/linux-sunxi
C | 83 lines | 59 code | 9 blank | 15 comment | 6 complexity | 2dffdcb2ea58e892d72e883025e85af5 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.0, AGPL-1.0
 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_pm.c
13 * Implementation of the callback functions from common power management
14 */
15
16#include <linux/sched.h>
17
18#ifdef CONFIG_PM_RUNTIME
19#include <linux/pm_runtime.h>
20#endif /* CONFIG_PM_RUNTIME */
21#include <linux/platform_device.h>
22#include "mali_platform.h"
23#include "mali_osk.h"
24#include "mali_uk_types.h"
25#include "mali_kernel_common.h"
26#include "mali_kernel_license.h"
27#include "mali_linux_pm.h"
28#include "mali_kernel_license.h"
29
30#if ! MALI_LICENSE_IS_GPL
31#undef CONFIG_PM_RUNTIME
32#endif
33
34extern struct platform_device mali_gpu_device;
35
36#ifdef CONFIG_PM_RUNTIME
37static mali_bool have_runtime_reference = MALI_FALSE;
38#endif
39
40void _mali_osk_pm_dev_enable(void)
41{
42#ifdef CONFIG_PM_RUNTIME
43	pm_runtime_enable(&(mali_gpu_device.dev));
44#endif
45}
46
47/* NB: Function is not thread safe */
48_mali_osk_errcode_t _mali_osk_pm_dev_idle(void)
49{
50#ifdef CONFIG_PM_RUNTIME
51	if (MALI_TRUE == have_runtime_reference)
52	{
53		int err;
54		err = pm_runtime_put_sync(&(mali_gpu_device.dev));	
55		if (0 > err)
56		{
57			MALI_PRINT_ERROR(("OSK PM: pm_runtime_put_sync() returned error code %d\n", err));	
58			return _MALI_OSK_ERR_FAULT;
59		}
60		have_runtime_reference = MALI_FALSE;
61	}
62#endif
63	return _MALI_OSK_ERR_OK;
64}
65
66/* NB: Function is not thread safe */
67_mali_osk_errcode_t _mali_osk_pm_dev_activate(void)
68{
69#ifdef CONFIG_PM_RUNTIME
70	if (MALI_TRUE != have_runtime_reference)
71	{
72		int err;
73		err = pm_runtime_get_sync(&(mali_gpu_device.dev));
74		if (0 > err)
75		{
76			MALI_PRINT_ERROR(("OSK PM: pm_runtime_get_sync() returned error code %d\n", err));	
77			return _MALI_OSK_ERR_FAULT;
78		}
79		have_runtime_reference = MALI_TRUE;
80	}
81#endif
82	return _MALI_OSK_ERR_OK;
83}