xref: /openbmc/linux/arch/arm/mach-omap2/fb.c (revision b830f94f)
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  * Framebuffer device registration for TI OMAP platforms
4  *
5  * Copyright (C) 2006 Nokia Corporation
6  * Author: Imre Deak <imre.deak@nokia.com>
7  */
8 
9 #include <linux/module.h>
10 #include <linux/kernel.h>
11 #include <linux/mm.h>
12 #include <linux/init.h>
13 #include <linux/platform_device.h>
14 #include <linux/memblock.h>
15 #include <linux/io.h>
16 #include <linux/omapfb.h>
17 #include <linux/dma-mapping.h>
18 
19 #include <asm/mach/map.h>
20 
21 #include "soc.h"
22 #include "display.h"
23 
24 #ifdef CONFIG_OMAP2_VRFB
25 
26 /*
27  * The first memory resource is the register region for VRFB,
28  * the rest are VRFB virtual memory areas for each VRFB context.
29  */
30 
31 static const struct resource omap2_vrfb_resources[] = {
32 	DEFINE_RES_MEM_NAMED(0x68008000u, 0x40, "vrfb-regs"),
33 	DEFINE_RES_MEM_NAMED(0x70000000u, 0x4000000, "vrfb-area-0"),
34 	DEFINE_RES_MEM_NAMED(0x74000000u, 0x4000000, "vrfb-area-1"),
35 	DEFINE_RES_MEM_NAMED(0x78000000u, 0x4000000, "vrfb-area-2"),
36 	DEFINE_RES_MEM_NAMED(0x7c000000u, 0x4000000, "vrfb-area-3"),
37 };
38 
39 static const struct resource omap3_vrfb_resources[] = {
40 	DEFINE_RES_MEM_NAMED(0x6C000180u, 0xc0, "vrfb-regs"),
41 	DEFINE_RES_MEM_NAMED(0x70000000u, 0x4000000, "vrfb-area-0"),
42 	DEFINE_RES_MEM_NAMED(0x74000000u, 0x4000000, "vrfb-area-1"),
43 	DEFINE_RES_MEM_NAMED(0x78000000u, 0x4000000, "vrfb-area-2"),
44 	DEFINE_RES_MEM_NAMED(0x7c000000u, 0x4000000, "vrfb-area-3"),
45 	DEFINE_RES_MEM_NAMED(0xe0000000u, 0x4000000, "vrfb-area-4"),
46 	DEFINE_RES_MEM_NAMED(0xe4000000u, 0x4000000, "vrfb-area-5"),
47 	DEFINE_RES_MEM_NAMED(0xe8000000u, 0x4000000, "vrfb-area-6"),
48 	DEFINE_RES_MEM_NAMED(0xec000000u, 0x4000000, "vrfb-area-7"),
49 	DEFINE_RES_MEM_NAMED(0xf0000000u, 0x4000000, "vrfb-area-8"),
50 	DEFINE_RES_MEM_NAMED(0xf4000000u, 0x4000000, "vrfb-area-9"),
51 	DEFINE_RES_MEM_NAMED(0xf8000000u, 0x4000000, "vrfb-area-10"),
52 	DEFINE_RES_MEM_NAMED(0xfc000000u, 0x4000000, "vrfb-area-11"),
53 };
54 
55 int __init omap_init_vrfb(void)
56 {
57 	struct platform_device *pdev;
58 	const struct resource *res;
59 	unsigned int num_res;
60 
61 	if (cpu_is_omap24xx()) {
62 		res = omap2_vrfb_resources;
63 		num_res = ARRAY_SIZE(omap2_vrfb_resources);
64 	} else if (cpu_is_omap34xx()) {
65 		res = omap3_vrfb_resources;
66 		num_res = ARRAY_SIZE(omap3_vrfb_resources);
67 	} else {
68 		return 0;
69 	}
70 
71 	pdev = platform_device_register_resndata(NULL, "omapvrfb", -1,
72 			res, num_res, NULL, 0);
73 
74 	return PTR_ERR_OR_ZERO(pdev);
75 }
76 #else
77 int __init omap_init_vrfb(void) { return 0; }
78 #endif
79 
80 #if IS_ENABLED(CONFIG_FB_OMAP2)
81 
82 static u64 omap_fb_dma_mask = ~(u32)0;
83 static struct omapfb_platform_data omapfb_config;
84 
85 static struct platform_device omap_fb_device = {
86 	.name		= "omapfb",
87 	.id		= -1,
88 	.dev = {
89 		.dma_mask		= &omap_fb_dma_mask,
90 		.coherent_dma_mask	= DMA_BIT_MASK(32),
91 		.platform_data		= &omapfb_config,
92 	},
93 	.num_resources = 0,
94 };
95 
96 int __init omap_init_fb(void)
97 {
98 	return platform_device_register(&omap_fb_device);
99 }
100 #else
101 int __init omap_init_fb(void) { return 0; }
102 #endif
103