xref: /linux/arch/arm/mach-omap1/fb.c (revision 4f2c0a4acffbec01079c28f839422e64ddeff004)
11a59d1b8SThomas Gleixner // SPDX-License-Identifier: GPL-2.0-or-later
216d60bb8STony Lindgren /*
316d60bb8STony Lindgren  * File: arch/arm/plat-omap/fb.c
416d60bb8STony Lindgren  *
516d60bb8STony Lindgren  * Framebuffer device registration for TI OMAP platforms
616d60bb8STony Lindgren  *
716d60bb8STony Lindgren  * Copyright (C) 2006 Nokia Corporation
816d60bb8STony Lindgren  * Author: Imre Deak <imre.deak@nokia.com>
916d60bb8STony Lindgren  */
1016d60bb8STony Lindgren 
1116d60bb8STony Lindgren #include <linux/module.h>
1216d60bb8STony Lindgren #include <linux/kernel.h>
1316d60bb8STony Lindgren #include <linux/mm.h>
1416d60bb8STony Lindgren #include <linux/init.h>
1516d60bb8STony Lindgren #include <linux/platform_device.h>
1616d60bb8STony Lindgren #include <linux/memblock.h>
1716d60bb8STony Lindgren #include <linux/io.h>
1816d60bb8STony Lindgren #include <linux/omapfb.h>
1916d60bb8STony Lindgren #include <linux/dma-mapping.h>
2081ad0f5bSArnd Bergmann #include <linux/irq.h>
2116d60bb8STony Lindgren 
2216d60bb8STony Lindgren #include <asm/mach/map.h>
2316d60bb8STony Lindgren 
247e0a9e62SArnd Bergmann #include "irqs.h"
2581ad0f5bSArnd Bergmann 
26fcebddb9SJavier Martinez Canillas #if IS_ENABLED(CONFIG_FB_OMAP)
2716d60bb8STony Lindgren 
2816d60bb8STony Lindgren static bool omapfb_lcd_configured;
2916d60bb8STony Lindgren static struct omapfb_platform_data omapfb_config;
3016d60bb8STony Lindgren 
3116d60bb8STony Lindgren static u64 omap_fb_dma_mask = ~(u32)0;
3216d60bb8STony Lindgren 
33*e514f1fdSArnd Bergmann static struct resource omap_fb_resources[] = {
3481ad0f5bSArnd Bergmann 	{
3581ad0f5bSArnd Bergmann 		.name  = "irq",
3681ad0f5bSArnd Bergmann 		.start = INT_LCD_CTRL,
3781ad0f5bSArnd Bergmann 		.flags = IORESOURCE_IRQ,
3881ad0f5bSArnd Bergmann 	},
3981ad0f5bSArnd Bergmann 	{
4081ad0f5bSArnd Bergmann 		.name  = "irq",
4181ad0f5bSArnd Bergmann 		.start = INT_SOSSI_MATCH,
4281ad0f5bSArnd Bergmann 		.flags = IORESOURCE_IRQ,
4381ad0f5bSArnd Bergmann 	},
4481ad0f5bSArnd Bergmann };
4581ad0f5bSArnd Bergmann 
4616d60bb8STony Lindgren static struct platform_device omap_fb_device = {
4716d60bb8STony Lindgren 	.name		= "omapfb",
4816d60bb8STony Lindgren 	.id		= -1,
4916d60bb8STony Lindgren 	.dev = {
5016d60bb8STony Lindgren 		.dma_mask		= &omap_fb_dma_mask,
5116d60bb8STony Lindgren 		.coherent_dma_mask	= DMA_BIT_MASK(32),
5216d60bb8STony Lindgren 		.platform_data		= &omapfb_config,
5316d60bb8STony Lindgren 	},
5481ad0f5bSArnd Bergmann 	.num_resources = ARRAY_SIZE(omap_fb_resources),
5581ad0f5bSArnd Bergmann 	.resource = omap_fb_resources,
5616d60bb8STony Lindgren };
5716d60bb8STony Lindgren 
omapfb_set_lcd_config(const struct omap_lcd_config * config)5816d60bb8STony Lindgren void __init omapfb_set_lcd_config(const struct omap_lcd_config *config)
5916d60bb8STony Lindgren {
6016d60bb8STony Lindgren 	omapfb_config.lcd = *config;
6116d60bb8STony Lindgren 	omapfb_lcd_configured = true;
6216d60bb8STony Lindgren }
6316d60bb8STony Lindgren 
omap_init_fb(void)6416d60bb8STony Lindgren static int __init omap_init_fb(void)
6516d60bb8STony Lindgren {
6616d60bb8STony Lindgren 	/*
6716d60bb8STony Lindgren 	 * If the board file has not set the lcd config with
6816d60bb8STony Lindgren 	 * omapfb_set_lcd_config(), don't bother registering the omapfb device
6916d60bb8STony Lindgren 	 */
7016d60bb8STony Lindgren 	if (!omapfb_lcd_configured)
7116d60bb8STony Lindgren 		return 0;
7216d60bb8STony Lindgren 
7316d60bb8STony Lindgren 	return platform_device_register(&omap_fb_device);
7416d60bb8STony Lindgren }
7516d60bb8STony Lindgren 
7616d60bb8STony Lindgren arch_initcall(omap_init_fb);
7716d60bb8STony Lindgren 
7816d60bb8STony Lindgren #else
7916d60bb8STony Lindgren 
omapfb_set_lcd_config(const struct omap_lcd_config * config)8016d60bb8STony Lindgren void __init omapfb_set_lcd_config(const struct omap_lcd_config *config)
8116d60bb8STony Lindgren {
8216d60bb8STony Lindgren }
8316d60bb8STony Lindgren 
8416d60bb8STony Lindgren #endif
85