2013-01-30 01:37:40 +09:00
|
|
|
/*
|
|
|
|
* (C) Copyright 2012 Stephen Warren
|
|
|
|
*
|
2013-07-08 16:37:19 +09:00
|
|
|
* SPDX-License-Identifier: GPL-2.0+
|
2013-01-30 01:37:40 +09:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <lcd.h>
|
2015-09-03 08:24:58 +09:00
|
|
|
#include <memalign.h>
|
2016-02-07 02:42:43 +09:00
|
|
|
#include <phys2bus.h>
|
2013-01-30 01:37:40 +09:00
|
|
|
#include <asm/arch/mbox.h>
|
2017-04-06 07:23:40 +09:00
|
|
|
#include <asm/arch/msg.h>
|
2013-01-30 01:37:40 +09:00
|
|
|
#include <asm/global_data.h>
|
|
|
|
|
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
|
|
|
|
|
|
|
/* Global variables that lcd.c expects to exist */
|
|
|
|
vidinfo_t panel_info;
|
|
|
|
|
2017-04-06 07:23:41 +09:00
|
|
|
static int bcm2835_pitch;
|
2013-01-30 01:37:40 +09:00
|
|
|
|
|
|
|
void lcd_ctrl_init(void *lcdbase)
|
|
|
|
{
|
|
|
|
int ret;
|
2017-04-06 07:23:40 +09:00
|
|
|
int w, h;
|
2017-04-06 07:23:41 +09:00
|
|
|
ulong fb_base, fb_size, fb_start, fb_end;
|
2013-01-30 01:37:40 +09:00
|
|
|
|
|
|
|
debug("bcm2835: Query resolution...\n");
|
2017-04-06 07:23:40 +09:00
|
|
|
ret = bcm2835_get_video_size(&w, &h);
|
2013-01-30 01:37:40 +09:00
|
|
|
if (ret) {
|
|
|
|
/* FIXME: How to disable the LCD to prevent errors? hang()? */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
debug("bcm2835: Setting up display for %d x %d\n", w, h);
|
2017-04-06 07:23:41 +09:00
|
|
|
ret = bcm2835_set_video_params(&w, &h, 32, BCM2835_MBOX_PIXEL_ORDER_RGB,
|
|
|
|
BCM2835_MBOX_ALPHA_MODE_IGNORED,
|
|
|
|
&fb_base, &fb_size, &bcm2835_pitch);
|
2013-01-30 01:37:40 +09:00
|
|
|
|
|
|
|
debug("bcm2835: Final resolution is %d x %d\n", w, h);
|
|
|
|
|
|
|
|
panel_info.vl_col = w;
|
|
|
|
panel_info.vl_row = h;
|
2016-11-02 18:36:19 +09:00
|
|
|
panel_info.vl_bpix = LCD_COLOR32;
|
2013-01-30 01:37:40 +09:00
|
|
|
|
2017-04-06 07:23:41 +09:00
|
|
|
gd->fb_base = fb_base;
|
2016-03-24 18:31:11 +09:00
|
|
|
|
|
|
|
/* Enable dcache for the frame buffer */
|
2017-04-06 07:23:41 +09:00
|
|
|
fb_start = fb_base & ~(MMU_SECTION_SIZE - 1);
|
|
|
|
fb_end = fb_base + fb_size;
|
2016-03-24 18:31:11 +09:00
|
|
|
fb_end = ALIGN(fb_end, 1 << MMU_SECTION_SHIFT);
|
|
|
|
mmu_set_region_dcache_behaviour(fb_start, fb_end - fb_start,
|
2017-04-06 07:23:41 +09:00
|
|
|
DCACHE_WRITEBACK);
|
2016-03-24 18:31:11 +09:00
|
|
|
lcd_set_flush_dcache(1);
|
2013-01-30 01:37:40 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
void lcd_enable(void)
|
|
|
|
{
|
|
|
|
}
|
2013-11-09 19:07:53 +09:00
|
|
|
|
|
|
|
int lcd_get_size(int *line_length)
|
|
|
|
{
|
|
|
|
*line_length = bcm2835_pitch;
|
2017-04-06 07:23:41 +09:00
|
|
|
|
2013-11-09 19:07:53 +09:00
|
|
|
return *line_length * panel_info.vl_row;
|
|
|
|
}
|