as3525v2-usb: major code renaming
[kugel-rb.git] / firmware / target / arm / as3525 / sansa-clip / lcd-clip.c
blob29d9259b52066aa9f57f1cd2966d7708bbb12030
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2008 François Dinel
11 * Copyright (C) 2008-2009 Rafaël Carré
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation; either version 2
16 * of the License, or (at your option) any later version.
18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 * KIND, either express or implied.
21 ****************************************************************************/
22 #include "config.h"
24 #include "lcd.h"
25 #include "lcd-clip.h"
26 #include "system.h"
27 #include "cpu.h"
29 void lcd_hw_init(void)
31 /* DBOP initialisation, do what OF does */
32 CGU_DBOP = (1<<3) | AS3525_DBOP_DIV;
34 GPIOB_AFSEL = 0x08; /* DBOP on pin 3 */
35 GPIOC_AFSEL = 0x0f; /* DBOP on pins 3:0 */
37 DBOP_CTRL = 0x51008;
38 DBOP_TIMPOL_01 = 0x6E167;
39 DBOP_TIMPOL_23 = 0xA167E06F;
41 GPIOA_DIR |= 0x33; /* pins 5:4 and 1:0 out */
42 GPIOB_DIR |= 0x40; /* pin 6 out */
44 GPIOA_PIN(1) = (1<<1);
45 GPIOA_PIN(0) = (1<<0);
46 GPIOA_PIN(4) = 0;
47 GPIOB_PIN(6) = (1<<6);
50 #define LCD_DELAY 1
52 void lcd_write_command(int byte)
54 volatile int i = 0;
55 while(i<LCD_DELAY) i++;
57 /* unset D/C# (data or command) */
58 GPIOA_PIN(5) = 0;
60 /* Write command */
61 /* Only bits 15:12 and 3:0 of DBOP_DOUT are meaningful */
62 DBOP_DOUT = (byte << 8) | byte;
64 /* While push fifo is not empty */
65 while ((DBOP_STAT & (1<<10)) == 0)
69 void lcd_write_data(const fb_data* p_bytes, int count)
71 volatile int i = 0;
72 while(i<LCD_DELAY) i++;
74 /* set D/C# (data or command) */
75 GPIOA_PIN(5) = (1<<5);
77 while (count--)
79 /* Write pixels */
80 /* Only bits 15:12 and 3:0 of DBOP_DOUT are meaningful */
81 DBOP_DOUT = (*p_bytes << 8) | *p_bytes;
83 p_bytes++; /* next packed pixels */
85 /* Wait if push fifo is full */
86 while ((DBOP_STAT & (1<<6)) != 0);
88 /* While push fifo is not empty */
89 while ((DBOP_STAT & (1<<10)) == 0);