blob: a302d9194f572f6f93d5e38c555817fac92e5aeb [file] [log] [blame]
Tony Lindgrenc40fae952006-12-07 13:58:10 -08001/*
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
Tony Lindgren0dc5e772006-04-02 17:46:26 +010024#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
41static struct omapfb_platform_data omapfb_config;
42
43static u64 omap_fb_dma_mask = ~(u32)0;
44
45static 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 */
57void omapfb_reserve_mem(void)
58{
59 const struct omap_fbmem_config *fbmem_conf;
Tony Lindgrenc40fae952006-12-07 13:58:10 -080060 unsigned long total_size;
61 int i;
Tony Lindgren0dc5e772006-04-02 17:46:26 +010062
Tony Lindgrenc40fae952006-12-07 13:58:10 -080063 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;
Tony Lindgren0dc5e772006-04-02 17:46:26 +010068 }
Tony Lindgrenc40fae952006-12-07 13:58:10 -080069
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
Tony Lindgren0dc5e772006-04-02 17:46:26 +010096}
97
Imre Deak771af222006-12-06 17:13:50 -080098void omapfb_set_ctrl_platform_data(void *data)
99{
100 omapfb_config.ctrl_platform_data = data;
101}
102
Tony Lindgren0dc5e772006-04-02 17:46:26 +0100103static 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
116arch_initcall(omap_init_fb);
117
118#else
119
120void omapfb_reserve_mem(void) {}
121
122#endif
123
124