summaryrefslogtreecommitdiff
path: root/driver/product/kernel/drivers/gpu/drm/pl111/pl111_drm_platform.c
blob: 9d5ec0cb1751caadc0cf291c1349e276dddba116 (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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
/*
 *
 * (C) COPYRIGHT 2012-2013 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.
 *
 */



/**
 * pl111_drm_platform.c
 * Implementation of the Linux platform device entrypoints for PL111 DRM
 */
#include <linux/amba/bus.h>
#include <linux/amba/clcd.h>
#include <linux/version.h>
#include <linux/shmem_fs.h>
#include <linux/dma-buf.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/platform_device.h>
#include <drm/drmP.h>
#include <drm/drm_crtc_helper.h>
#include "pl111_drm.h"

static int pl111_platform_drm_suspend(struct platform_device *dev,
					pm_message_t state)
{
	pr_info("DRM %s\n", __func__);
	return 0;
}

static int pl111_platform_drm_resume(struct platform_device *dev)
{
	pr_info("DRM %s\n", __func__);
	return 0;
}

int pl111_platform_drm_probe(struct platform_device *dev)
{
	pr_info("DRM %s\n", __func__);
	return pl111_drm_init(dev);
}

static int pl111_platform_drm_remove(struct platform_device *dev)
{
	pr_info("DRM %s\n", __func__);
	pl111_drm_exit(dev);

	return 0;
}

static struct amba_id pl111_id_table[] = {
	{
	.id = 0x00041110,
	.mask = 0x000ffffe,
	},
	{0, 0},
};

static struct amba_driver pl111_amba_driver = {
	.drv = {
		.name = "clcd-pl11x",
		},
	.probe = pl111_amba_probe,
	.remove = pl111_amba_remove,
	.id_table = pl111_id_table,
};

static struct platform_driver platform_drm_driver = {
	.probe = pl111_platform_drm_probe,
	.remove = pl111_platform_drm_remove,
	.suspend = pl111_platform_drm_suspend,
	.resume = pl111_platform_drm_resume,
	.driver = {
			.owner = THIS_MODULE,
			.name = DRIVER_NAME,
		},
};

static const struct platform_device_info pl111_drm_pdevinfo = {
	.name = DRIVER_NAME,
	.id = -1,
	.dma_mask = ~0UL
};

static struct platform_device *pl111_drm_device;

static int __init pl111_platform_drm_init(void)
{
	int ret;

	pr_info("DRM %s\n", __func__);

	pl111_drm_device = platform_device_register_full(&pl111_drm_pdevinfo);
	if (pl111_drm_device == NULL) {
		pr_err("DRM platform_device_register_full() failed\n");
		return -ENOMEM;
	}

	ret = amba_driver_register(&pl111_amba_driver);
	if (ret != 0) {
		pr_err("DRM amba_driver_register() failed %d\n", ret);
		goto err_amba_reg;
	}

	ret = platform_driver_register(&platform_drm_driver);
	if (ret != 0) {
		pr_err("DRM platform_driver_register() failed %d\n", ret);
		goto err_pdrv_reg;
	}

	return 0;

err_pdrv_reg:
	amba_driver_unregister(&pl111_amba_driver);
err_amba_reg:
	platform_device_unregister(pl111_drm_device);

	return ret;
}

static void __exit pl111_platform_drm_exit(void)
{
	pr_info("DRM %s\n", __func__);

	platform_device_unregister(pl111_drm_device);
	amba_driver_unregister(&pl111_amba_driver);
	platform_driver_unregister(&platform_drm_driver);
}

#ifdef MODULE
module_init(pl111_platform_drm_init);
#else
late_initcall(pl111_platform_drm_init);
#endif
module_exit(pl111_platform_drm_exit);

MODULE_DESCRIPTION(DRIVER_DESC);
MODULE_VERSION(DRIVER_VERSION);
MODULE_AUTHOR(DRIVER_AUTHOR);
MODULE_LICENSE(DRIVER_LICENCE);
MODULE_ALIAS(DRIVER_ALIAS);