]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - drivers/video/amba.c
common/lcd.c: cleanup use of global variables
[karo-tx-uboot.git] / drivers / video / amba.c
1 /*
2  * Driver for AMBA PrimeCell CLCD
3  *
4  * Copyright (C) 2009 Alessandro Rubini
5  *
6  * See file CREDITS for list of people who contributed to this
7  * project.
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License as
11  * published by the Free Software Foundation; either version 2 of
12  * the License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
22  * MA 02111-1307 USA
23  */
24
25 #include <common.h>
26 #include <asm/io.h>
27 #include <lcd.h>
28 #include <amba_clcd.h>
29
30 /* These variables are required by lcd.c -- although it sets them by itself */
31 int lcd_line_length;
32 void *lcd_base;
33 void *lcd_console_address;
34 short console_col;
35 short console_row;
36
37 /*
38  * To use this driver you need to provide the following in board files:
39  *      a panel_info definition
40  *      an lcd_enable function (can't define a weak default with current code)
41  */
42
43 /* There is nothing to do with color registers, we use true color */
44 void lcd_setcolreg(ushort regno, ushort red, ushort green, ushort blue)
45 {
46         return;
47 }
48
49 /* Low level initialization of the logic cell: depends on panel_info */
50 void lcd_ctrl_init(void *lcdbase)
51 {
52         struct clcd_config *config;
53         struct clcd_registers *regs;
54         u32 cntl;
55
56         config = panel_info.priv;
57         regs = config->address;
58         cntl = config->cntl & ~CNTL_LCDEN;
59
60         /* Lazily, just copy the registers over: first control with disable */
61         writel(cntl, &regs->cntl);
62
63         writel(config->tim0, &regs->tim0);
64         writel(config->tim1, &regs->tim1);
65         writel(config->tim2, &regs->tim2);
66         writel(config->tim3, &regs->tim3);
67         writel((u32)lcdbase, &regs->ubas);
68         /* finally, enable */
69         writel(cntl | CNTL_LCDEN, &regs->cntl);
70 }
71
72 /* This is trivial, and copied from atmel_lcdfb.c */
73 ulong calc_fbsize(void)
74 {
75         return ((panel_info.vl_col * panel_info.vl_row *
76                 NBITS(panel_info.vl_bpix)) / 8) + PAGE_SIZE;
77 }