summaryrefslogtreecommitdiffstats
path: root/drivers/video/amba.c
blob: ffa1c399e1418d797084012580f0d8c3e4dabea2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/*
 * Driver for AMBA PrimeCell CLCD
 *
 * Copyright (C) 2009 Alessandro Rubini
 *
 * See file CREDITS for list of people who contributed to this
 * project.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of
 * the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 * MA 02111-1307 USA
 */

#include <common.h>
#include <asm/io.h>
#include <lcd.h>
#include <amba_clcd.h>

/* These variables are required by lcd.c -- although it sets them by itself */
int lcd_line_length;
int lcd_color_fg;
int lcd_color_bg;
void *lcd_base;
void *lcd_console_address;
short console_col;
short console_row;

/*
 * To use this driver you need to provide the following in board files:
 *	a panel_info definition
 *	an lcd_enable function (can't define a weak default with current code)
 */

/* There is nothing to do with color registers, we use true color */
void lcd_setcolreg(ushort regno, ushort red, ushort green, ushort blue)
{
	return;
}

/* Low level initialization of the logic cell: depends on panel_info */
void lcd_ctrl_init(void *lcdbase)
{
	struct clcd_config *config;
	struct clcd_registers *regs;
	u32 cntl;

	config = panel_info.priv;
	regs = config->address;
	cntl = config->cntl & ~CNTL_LCDEN;

	/* Lazily, just copy the registers over: first control with disable */
	writel(cntl, &regs->cntl);

	writel(config->tim0, &regs->tim0);
	writel(config->tim1, &regs->tim1);
	writel(config->tim2, &regs->tim2);
	writel(config->tim3, &regs->tim3);
	writel((u32)lcdbase, &regs->ubas);
	/* finally, enable */
	writel(cntl | CNTL_LCDEN, &regs->cntl);
}

/* This is trivial, and copied from atmel_lcdfb.c */
ulong calc_fbsize(void)
{
	return ((panel_info.vl_col * panel_info.vl_row *
		NBITS(panel_info.vl_bpix)) / 8) + PAGE_SIZE;
}