2 * Copyright (C) 2011-2012 ARM Limited. All rights reserved.
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.
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.
12 * @file mali_osk_mali.c
13 * Implementation of the OS abstraction layer which is specific for the Mali kernel device driver
15 #include <linux/kernel.h>
16 #include <asm/uaccess.h>
17 #include <linux/platform_device.h>
18 #include <linux/mali/mali_utgard.h>
20 #include "mali_osk_mali.h"
21 #include "mali_kernel_common.h" /* MALI_xxx macros */
22 #include "mali_osk.h" /* kernel side OS functions */
23 #include "mali_uk_types.h"
24 #include "mali_kernel_linux.h"
26 _mali_osk_errcode_t _mali_osk_resource_find(u32 addr, _mali_osk_resource_t *res)
30 if (NULL == mali_platform_device)
32 /* Not connected to a device */
33 return _MALI_OSK_ERR_ITEM_NOT_FOUND;
36 for (i = 0; i < mali_platform_device->num_resources; i++)
38 if (IORESOURCE_MEM == resource_type(&(mali_platform_device->resource[i])) &&
39 mali_platform_device->resource[i].start == addr)
44 res->description = mali_platform_device->resource[i].name;
46 /* Any (optional) IRQ resource belonging to this resource will follow */
47 if ((i + 1) < mali_platform_device->num_resources &&
48 IORESOURCE_IRQ == resource_type(&(mali_platform_device->resource[i+1])))
50 res->irq = mali_platform_device->resource[i+1].start;
57 return _MALI_OSK_ERR_OK;
61 return _MALI_OSK_ERR_ITEM_NOT_FOUND;
64 u32 _mali_osk_resource_base_address(void)
66 u32 lowest_addr = 0xFFFFFFFF;
69 if (NULL != mali_platform_device)
72 for (i = 0; i < mali_platform_device->num_resources; i++)
74 if (mali_platform_device->resource[i].flags & IORESOURCE_MEM &&
75 mali_platform_device->resource[i].start < lowest_addr)
77 lowest_addr = mali_platform_device->resource[i].start;
86 _mali_osk_errcode_t _mali_osk_device_data_get(struct _mali_osk_device_data *data)
88 MALI_DEBUG_ASSERT_POINTER(data);
90 if (NULL != mali_platform_device)
92 struct mali_gpu_device_data* os_data = NULL;
94 os_data = (struct mali_gpu_device_data*)mali_platform_device->dev.platform_data;
97 /* Copy data from OS dependant struct to Mali neutral struct (identical!) */
98 data->dedicated_mem_start = os_data->dedicated_mem_start;
99 data->dedicated_mem_size = os_data->dedicated_mem_size;
100 data->shared_mem_size = os_data->shared_mem_size;
101 data->fb_start = os_data->fb_start;
102 data->fb_size = os_data->fb_size;
103 data->utilization_interval = os_data->utilization_interval;
104 data->utilization_handler = os_data->utilization_handler;
105 return _MALI_OSK_ERR_OK;
109 return _MALI_OSK_ERR_ITEM_NOT_FOUND;