summaryrefslogtreecommitdiff
path: root/drivers/staging/android/ion/juno/juno_ion_dev.c
blob: cee6be3ce3f1150830b0b9532d9a649939f3ec24 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/*
 * drivers/gpu/ion/juno/juno_ion_dev.c
 *
 * Copyright (C) 2014 ARM, Inc.
 *
 * This software is licensed under the terms of the GNU General Public
 * License version 2, as published by the Free Software Foundation, and
 * may be copied, distributed, and modified under those terms.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 */

#include <linux/err.h>
#include <linux/platform_device.h>
#include <linux/dma-mapping.h>
#include "../ion.h"

u64 juno_dmamask = DMA_BIT_MASK(64);

struct platform_device juno_device_ion = {
        .name           = "ion-juno",
        .id             = -1,
};

struct ion_platform_heap juno_heaps[] = {
		{
			.id	= ION_HEAP_TYPE_SYSTEM,
			.type	= ION_HEAP_TYPE_SYSTEM,
			.name	= "system",
		},
		{
			.id	= ION_HEAP_TYPE_SYSTEM_CONTIG,
			.type	= ION_HEAP_TYPE_SYSTEM_CONTIG,
			.name	= "system contig",
		},
		{
			.id	= ION_HEAP_TYPE_DMA,
			.type 	= ION_HEAP_TYPE_DMA,
			.name	= "ion_dma_heap-3",
			.priv	= &juno_device_ion.dev,
		}
};

struct ion_platform_data juno_ion_pdata = {
	.nr = 3,
	.heaps = juno_heaps,
};

static int __init juno_ion_dev_init(void)
{
	int ret;

	ret = dma_declare_coherent_memory(&juno_device_ion.dev,
		0x60000000, 0x60000000, 0x08000000,
		DMA_MEMORY_MAP | DMA_MEMORY_EXCLUSIVE);
	if (ret < 0)
	{
		pr_err("%s: dma_declare_contiguous failed %d\n", __func__, ret);
		return ret;
	}

	juno_device_ion.dev.platform_data = &juno_ion_pdata;
	juno_device_ion.dev.coherent_dma_mask = juno_dmamask;
	juno_device_ion.dev.dma_mask = &juno_dmamask;

	return platform_device_register(&juno_device_ion);
}

static void __exit juno_ion_dev_exit(void)
{
	platform_device_unregister(&juno_device_ion);
}

module_init(juno_ion_dev_init);
module_exit(juno_ion_dev_exit);