blob: a3367b783fc7f84c973a2dea20526dd7fc9d0a66 [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>
Andrea Righi27ac7922008-07-23 21:28:13 -070026#include <linux/mm.h>
Tony Lindgren0dc5e772006-04-02 17:46:26 +010027#include <linux/init.h>
28#include <linux/platform_device.h>
Russell King98864ff2010-05-22 23:59:11 +010029#include <linux/memblock.h>
Russell Kingfced80c2008-09-06 12:10:45 +010030#include <linux/io.h>
Tomi Valkeinen91773a02009-08-03 15:06:36 +030031#include <linux/omapfb.h>
Tomi Valkeinen3f5ba552012-11-09 15:41:21 +020032#include <linux/dma-mapping.h>
Tony Lindgren0dc5e772006-04-02 17:46:26 +010033
Tony Lindgren0dc5e772006-04-02 17:46:26 +010034#include <asm/mach/map.h>
35
Tomi Valkeinen406c8562012-10-08 14:35:44 +030036#include <plat/cpu.h>
37
38#ifdef CONFIG_OMAP2_VRFB
39
40/*
41 * The first memory resource is the register region for VRFB,
42 * the rest are VRFB virtual memory areas for each VRFB context.
43 */
44
45static const struct resource omap2_vrfb_resources[] = {
46 DEFINE_RES_MEM_NAMED(0x68008000u, 0x40, "vrfb-regs"),
47 DEFINE_RES_MEM_NAMED(0x70000000u, 0x4000000, "vrfb-area-0"),
48 DEFINE_RES_MEM_NAMED(0x74000000u, 0x4000000, "vrfb-area-1"),
49 DEFINE_RES_MEM_NAMED(0x78000000u, 0x4000000, "vrfb-area-2"),
50 DEFINE_RES_MEM_NAMED(0x7c000000u, 0x4000000, "vrfb-area-3"),
51};
52
53static const struct resource omap3_vrfb_resources[] = {
54 DEFINE_RES_MEM_NAMED(0x6C000180u, 0xc0, "vrfb-regs"),
55 DEFINE_RES_MEM_NAMED(0x70000000u, 0x4000000, "vrfb-area-0"),
56 DEFINE_RES_MEM_NAMED(0x74000000u, 0x4000000, "vrfb-area-1"),
57 DEFINE_RES_MEM_NAMED(0x78000000u, 0x4000000, "vrfb-area-2"),
58 DEFINE_RES_MEM_NAMED(0x7c000000u, 0x4000000, "vrfb-area-3"),
59 DEFINE_RES_MEM_NAMED(0xe0000000u, 0x4000000, "vrfb-area-4"),
60 DEFINE_RES_MEM_NAMED(0xe4000000u, 0x4000000, "vrfb-area-5"),
61 DEFINE_RES_MEM_NAMED(0xe8000000u, 0x4000000, "vrfb-area-6"),
62 DEFINE_RES_MEM_NAMED(0xec000000u, 0x4000000, "vrfb-area-7"),
63 DEFINE_RES_MEM_NAMED(0xf0000000u, 0x4000000, "vrfb-area-8"),
64 DEFINE_RES_MEM_NAMED(0xf4000000u, 0x4000000, "vrfb-area-9"),
65 DEFINE_RES_MEM_NAMED(0xf8000000u, 0x4000000, "vrfb-area-10"),
66 DEFINE_RES_MEM_NAMED(0xfc000000u, 0x4000000, "vrfb-area-11"),
67};
68
69static int __init omap_init_vrfb(void)
70{
71 struct platform_device *pdev;
72 const struct resource *res;
73 unsigned int num_res;
74
75 if (cpu_is_omap24xx()) {
76 res = omap2_vrfb_resources;
77 num_res = ARRAY_SIZE(omap2_vrfb_resources);
78 } else if (cpu_is_omap34xx()) {
79 res = omap3_vrfb_resources;
80 num_res = ARRAY_SIZE(omap3_vrfb_resources);
81 } else {
82 return 0;
83 }
84
85 pdev = platform_device_register_resndata(NULL, "omapvrfb", -1,
86 res, num_res, NULL, 0);
87
88 if (IS_ERR(pdev))
89 return PTR_ERR(pdev);
90 else
91 return 0;
92}
93
94arch_initcall(omap_init_vrfb);
95#endif
96
Tony Lindgren0dc5e772006-04-02 17:46:26 +010097#if defined(CONFIG_FB_OMAP) || defined(CONFIG_FB_OMAP_MODULE)
98
Tomi Valkeinenddba6c72011-09-20 15:23:13 +030099static bool omapfb_lcd_configured;
Tony Lindgren0dc5e772006-04-02 17:46:26 +0100100static struct omapfb_platform_data omapfb_config;
101
102static u64 omap_fb_dma_mask = ~(u32)0;
103
104static struct platform_device omap_fb_device = {
105 .name = "omapfb",
106 .id = -1,
107 .dev = {
108 .dma_mask = &omap_fb_dma_mask,
Tomi Valkeinen3f5ba552012-11-09 15:41:21 +0200109 .coherent_dma_mask = DMA_BIT_MASK(32),
Tony Lindgren0dc5e772006-04-02 17:46:26 +0100110 .platform_data = &omapfb_config,
111 },
112 .num_resources = 0,
113};
114
Tomi Valkeinenddba6c72011-09-20 15:23:13 +0300115void __init omapfb_set_lcd_config(const struct omap_lcd_config *config)
116{
117 omapfb_config.lcd = *config;
118 omapfb_lcd_configured = true;
119}
120
Uwe Kleine-König375c3242010-09-02 10:03:38 +0200121static int __init omap_init_fb(void)
Tony Lindgren0dc5e772006-04-02 17:46:26 +0100122{
Tomi Valkeinenddba6c72011-09-20 15:23:13 +0300123 /*
124 * If the board file has not set the lcd config with
125 * omapfb_set_lcd_config(), don't bother registering the omapfb device
126 */
127 if (!omapfb_lcd_configured)
Imre Deakb7cc6d42007-03-06 03:16:36 -0800128 return 0;
Tomi Valkeinen1e434f92011-09-20 14:12:43 +0300129
Tony Lindgren0dc5e772006-04-02 17:46:26 +0100130 return platform_device_register(&omap_fb_device);
131}
132
133arch_initcall(omap_init_fb);
134
Tomi Valkeinenb39a982d2009-08-04 16:12:50 +0300135#elif defined(CONFIG_FB_OMAP2) || defined(CONFIG_FB_OMAP2_MODULE)
136
137static u64 omap_fb_dma_mask = ~(u32)0;
138static struct omapfb_platform_data omapfb_config;
139
140static struct platform_device omap_fb_device = {
141 .name = "omapfb",
142 .id = -1,
143 .dev = {
144 .dma_mask = &omap_fb_dma_mask,
Tomi Valkeinen3f5ba552012-11-09 15:41:21 +0200145 .coherent_dma_mask = DMA_BIT_MASK(32),
Tomi Valkeinenb39a982d2009-08-04 16:12:50 +0300146 .platform_data = &omapfb_config,
147 },
148 .num_resources = 0,
149};
150
Uwe Kleine-König375c3242010-09-02 10:03:38 +0200151static int __init omap_init_fb(void)
Tomi Valkeinenb39a982d2009-08-04 16:12:50 +0300152{
153 return platform_device_register(&omap_fb_device);
154}
155
156arch_initcall(omap_init_fb);
Tony Lindgren0dc5e772006-04-02 17:46:26 +0100157
Tomi Valkeinenddba6c72011-09-20 15:23:13 +0300158#else
159
Tony Lindgren001b7f32012-03-08 12:43:28 -0800160void __init omapfb_set_lcd_config(const struct omap_lcd_config *config)
161{
162}
Tomi Valkeinenddba6c72011-09-20 15:23:13 +0300163
Tony Lindgren0dc5e772006-04-02 17:46:26 +0100164#endif