Merge branch 'x86-ras-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
[firefly-linux-kernel-4.4.55.git] / arch / arm / plat-omap / fb.c
1 /*
2  * File: arch/arm/plat-omap/fb.c
3  *
4  * Framebuffer device registration for TI OMAP platforms
5  *
6  * Copyright (C) 2006 Nokia Corporation
7  * Author: Imre Deak <imre.deak@nokia.com>
8  *
9  * This program is free software; you can redistribute it and/or modify it
10  * under the terms of the GNU General Public License as published by the
11  * Free Software Foundation; either version 2 of the License, or (at your
12  * option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful, but
15  * WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License along
20  * with this program; if not, write to the Free Software Foundation, Inc.,
21  * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22  */
23
24 #include <linux/module.h>
25 #include <linux/kernel.h>
26 #include <linux/mm.h>
27 #include <linux/init.h>
28 #include <linux/platform_device.h>
29 #include <linux/memblock.h>
30 #include <linux/io.h>
31 #include <linux/omapfb.h>
32
33 #include <asm/mach/map.h>
34
35 #include <plat/cpu.h>
36
37 #ifdef CONFIG_OMAP2_VRFB
38
39 /*
40  * The first memory resource is the register region for VRFB,
41  * the rest are VRFB virtual memory areas for each VRFB context.
42  */
43
44 static const struct resource omap2_vrfb_resources[] = {
45         DEFINE_RES_MEM_NAMED(0x68008000u, 0x40, "vrfb-regs"),
46         DEFINE_RES_MEM_NAMED(0x70000000u, 0x4000000, "vrfb-area-0"),
47         DEFINE_RES_MEM_NAMED(0x74000000u, 0x4000000, "vrfb-area-1"),
48         DEFINE_RES_MEM_NAMED(0x78000000u, 0x4000000, "vrfb-area-2"),
49         DEFINE_RES_MEM_NAMED(0x7c000000u, 0x4000000, "vrfb-area-3"),
50 };
51
52 static const struct resource omap3_vrfb_resources[] = {
53         DEFINE_RES_MEM_NAMED(0x6C000180u, 0xc0, "vrfb-regs"),
54         DEFINE_RES_MEM_NAMED(0x70000000u, 0x4000000, "vrfb-area-0"),
55         DEFINE_RES_MEM_NAMED(0x74000000u, 0x4000000, "vrfb-area-1"),
56         DEFINE_RES_MEM_NAMED(0x78000000u, 0x4000000, "vrfb-area-2"),
57         DEFINE_RES_MEM_NAMED(0x7c000000u, 0x4000000, "vrfb-area-3"),
58         DEFINE_RES_MEM_NAMED(0xe0000000u, 0x4000000, "vrfb-area-4"),
59         DEFINE_RES_MEM_NAMED(0xe4000000u, 0x4000000, "vrfb-area-5"),
60         DEFINE_RES_MEM_NAMED(0xe8000000u, 0x4000000, "vrfb-area-6"),
61         DEFINE_RES_MEM_NAMED(0xec000000u, 0x4000000, "vrfb-area-7"),
62         DEFINE_RES_MEM_NAMED(0xf0000000u, 0x4000000, "vrfb-area-8"),
63         DEFINE_RES_MEM_NAMED(0xf4000000u, 0x4000000, "vrfb-area-9"),
64         DEFINE_RES_MEM_NAMED(0xf8000000u, 0x4000000, "vrfb-area-10"),
65         DEFINE_RES_MEM_NAMED(0xfc000000u, 0x4000000, "vrfb-area-11"),
66 };
67
68 static int __init omap_init_vrfb(void)
69 {
70         struct platform_device *pdev;
71         const struct resource *res;
72         unsigned int num_res;
73
74         if (cpu_is_omap24xx()) {
75                 res = omap2_vrfb_resources;
76                 num_res = ARRAY_SIZE(omap2_vrfb_resources);
77         } else if (cpu_is_omap34xx()) {
78                 res = omap3_vrfb_resources;
79                 num_res = ARRAY_SIZE(omap3_vrfb_resources);
80         } else {
81                 return 0;
82         }
83
84         pdev = platform_device_register_resndata(NULL, "omapvrfb", -1,
85                         res, num_res, NULL, 0);
86
87         if (IS_ERR(pdev))
88                 return PTR_ERR(pdev);
89         else
90                 return 0;
91 }
92
93 arch_initcall(omap_init_vrfb);
94 #endif
95
96 #if defined(CONFIG_FB_OMAP) || defined(CONFIG_FB_OMAP_MODULE)
97
98 static bool omapfb_lcd_configured;
99 static struct omapfb_platform_data omapfb_config;
100
101 static u64 omap_fb_dma_mask = ~(u32)0;
102
103 static struct platform_device omap_fb_device = {
104         .name           = "omapfb",
105         .id             = -1,
106         .dev = {
107                 .dma_mask               = &omap_fb_dma_mask,
108                 .coherent_dma_mask      = ~(u32)0,
109                 .platform_data          = &omapfb_config,
110         },
111         .num_resources = 0,
112 };
113
114 void __init omapfb_set_lcd_config(const struct omap_lcd_config *config)
115 {
116         omapfb_config.lcd = *config;
117         omapfb_lcd_configured = true;
118 }
119
120 static int __init omap_init_fb(void)
121 {
122         /*
123          * If the board file has not set the lcd config with
124          * omapfb_set_lcd_config(), don't bother registering the omapfb device
125          */
126         if (!omapfb_lcd_configured)
127                 return 0;
128
129         return platform_device_register(&omap_fb_device);
130 }
131
132 arch_initcall(omap_init_fb);
133
134 #elif defined(CONFIG_FB_OMAP2) || defined(CONFIG_FB_OMAP2_MODULE)
135
136 static u64 omap_fb_dma_mask = ~(u32)0;
137 static struct omapfb_platform_data omapfb_config;
138
139 static struct platform_device omap_fb_device = {
140         .name           = "omapfb",
141         .id             = -1,
142         .dev = {
143                 .dma_mask               = &omap_fb_dma_mask,
144                 .coherent_dma_mask      = ~(u32)0,
145                 .platform_data          = &omapfb_config,
146         },
147         .num_resources = 0,
148 };
149
150 static int __init omap_init_fb(void)
151 {
152         return platform_device_register(&omap_fb_device);
153 }
154
155 arch_initcall(omap_init_fb);
156
157 #else
158
159 void __init omapfb_set_lcd_config(const struct omap_lcd_config *config)
160 {
161 }
162
163 #endif