Alessandro Rubini | 3e446cb | 2009-12-05 13:39:31 +0100 | [diff] [blame^] | 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 | int lcd_color_fg; |
| 33 | int lcd_color_bg; |
| 34 | void *lcd_base; |
| 35 | void *lcd_console_address; |
| 36 | short console_col; |
| 37 | short console_row; |
| 38 | |
| 39 | /* |
| 40 | * To use this driver you need to provide the following in board files: |
| 41 | * a panel_info definition |
| 42 | * an lcd_enable function (can't define a weak default with current code) |
| 43 | */ |
| 44 | |
| 45 | /* There is nothing to do with color registers, we use true color */ |
| 46 | void lcd_setcolreg(ushort regno, ushort red, ushort green, ushort blue) |
| 47 | { |
| 48 | return; |
| 49 | } |
| 50 | |
| 51 | /* Low level initialization of the logic cell: depends on panel_info */ |
| 52 | void lcd_ctrl_init(void *lcdbase) |
| 53 | { |
| 54 | struct clcd_config *config; |
| 55 | struct clcd_registers *regs; |
| 56 | u32 cntl; |
| 57 | |
| 58 | config = panel_info.priv; |
| 59 | regs = config->address; |
| 60 | cntl = config->cntl & ~CNTL_LCDEN; |
| 61 | |
| 62 | /* Lazily, just copy the registers over: first control with disable */ |
| 63 | writel(cntl, ®s->cntl); |
| 64 | |
| 65 | writel(config->tim0, ®s->tim0); |
| 66 | writel(config->tim1, ®s->tim1); |
| 67 | writel(config->tim2, ®s->tim2); |
| 68 | writel(config->tim3, ®s->tim3); |
| 69 | writel((u32)lcdbase, ®s->ubas); |
| 70 | /* finally, enable */ |
| 71 | writel(cntl | CNTL_LCDEN, ®s->cntl); |
| 72 | } |
| 73 | |
| 74 | /* This is trivial, and copied from atmel_lcdfb.c */ |
| 75 | ulong calc_fbsize(void) |
| 76 | { |
| 77 | return ((panel_info.vl_col * panel_info.vl_row * |
| 78 | NBITS(panel_info.vl_bpix)) / 8) + PAGE_SIZE; |
| 79 | } |