]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - arch/arm/plat-omap/fb.c
ARM: OMAP: Sync core code with linux-omap
[linux-2.6-omap-h63xx.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/init.h>
27 #include <linux/platform_device.h>
28 #include <linux/bootmem.h>
29
30 #include <asm/hardware.h>
31 #include <asm/io.h>
32 #include <asm/mach-types.h>
33 #include <asm/mach/map.h>
34
35 #include <asm/arch/board.h>
36 #include <asm/arch/sram.h>
37 #include <asm/arch/omapfb.h>
38
39 #if defined(CONFIG_FB_OMAP) || defined(CONFIG_FB_OMAP_MODULE)
40
41 static struct omapfb_platform_data omapfb_config;
42
43 static u64 omap_fb_dma_mask = ~(u32)0;
44
45 static struct platform_device omap_fb_device = {
46         .name           = "omapfb",
47         .id             = -1,
48         .dev = {
49                 .dma_mask               = &omap_fb_dma_mask,
50                 .coherent_dma_mask      = ~(u32)0,
51                 .platform_data          = &omapfb_config,
52         },
53         .num_resources = 0,
54 };
55
56 /* called from map_io */
57 void omapfb_reserve_mem(void)
58 {
59         const struct omap_fbmem_config *fbmem_conf;
60         unsigned long total_size;
61         int i;
62
63         if (!omap_fb_sram_valid) {
64                 /* FBMEM SRAM configuration was already found to be invalid.
65                  * Ignore the whole configuration block. */
66                 omapfb_config.mem_desc.region_cnt = 0;
67                 return;
68         }
69
70         i = 0;
71         total_size = 0;
72         while ((fbmem_conf = omap_get_nr_config(OMAP_TAG_FBMEM,
73                                 struct omap_fbmem_config, i)) != NULL) {
74                 unsigned long start;
75                 unsigned long size;
76
77                 if (i == OMAPFB_PLANE_NUM) {
78                         printk(KERN_ERR "ignoring extra plane info\n");
79                         break;
80                 }
81                 start = fbmem_conf->start;
82                 size  = fbmem_conf->size;
83                 omapfb_config.mem_desc.region[i].paddr = start;
84                 omapfb_config.mem_desc.region[i].size = size;
85                 if (omap_fb_sram_plane != i && start) {
86                         reserve_bootmem(start, size);
87                         total_size += size;
88                 }
89                 i++;
90         }
91         omapfb_config.mem_desc.region_cnt = i;
92         if (total_size)
93                 pr_info("Reserving %lu bytes SDRAM for frame buffer\n",
94                          total_size);
95
96 }
97
98 void omapfb_set_ctrl_platform_data(void *data)
99 {
100         omapfb_config.ctrl_platform_data = data;
101 }
102
103 static inline int omap_init_fb(void)
104 {
105         const struct omap_lcd_config *conf;
106
107         conf = omap_get_config(OMAP_TAG_LCD, struct omap_lcd_config);
108         if (conf == NULL)
109                 return 0;
110
111         omapfb_config.lcd = *conf;
112
113         return platform_device_register(&omap_fb_device);
114 }
115
116 arch_initcall(omap_init_fb);
117
118 #else
119
120 void omapfb_reserve_mem(void) {}
121
122 #endif
123
124