diff options
Diffstat (limited to 'firmware/target/arm/as3525/sansa-clip/lcd-clip.c')
-rw-r--r-- | firmware/target/arm/as3525/sansa-clip/lcd-clip.c | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/firmware/target/arm/as3525/sansa-clip/lcd-clip.c b/firmware/target/arm/as3525/sansa-clip/lcd-clip.c new file mode 100644 index 0000000000..9df006ac69 --- /dev/null +++ b/firmware/target/arm/as3525/sansa-clip/lcd-clip.c | |||
@@ -0,0 +1,89 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2008 François Dinel | ||
11 | * Copyright (C) 2008-2009 Rafaël Carré | ||
12 | * | ||
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. | ||
17 | * | ||
18 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
19 | * KIND, either express or implied. | ||
20 | * | ||
21 | ****************************************************************************/ | ||
22 | #include "config.h" | ||
23 | |||
24 | #include "lcd.h" | ||
25 | #include "system.h" | ||
26 | #include "cpu.h" | ||
27 | |||
28 | void lcd_hw_init(void) | ||
29 | { | ||
30 | /* DBOP initialisation, do what OF does */ | ||
31 | CGU_DBOP = (1<<3) | AS3525_DBOP_DIV; | ||
32 | |||
33 | GPIOB_AFSEL = 0x08; /* DBOP on pin 3 */ | ||
34 | GPIOC_AFSEL = 0x0f; /* DBOP on pins 3:0 */ | ||
35 | |||
36 | DBOP_CTRL = 0x51008; | ||
37 | DBOP_TIMPOL_01 = 0x6E167; | ||
38 | DBOP_TIMPOL_23 = 0xA167E06F; | ||
39 | |||
40 | GPIOA_DIR |= 0x33; /* pins 5:4 and 1:0 out */ | ||
41 | GPIOB_DIR |= 0x40; /* pin 6 out */ | ||
42 | |||
43 | GPIOA_PIN(1) = (1<<1); | ||
44 | GPIOA_PIN(0) = (1<<0); | ||
45 | GPIOA_PIN(4) = 0; | ||
46 | GPIOB_PIN(6) = (1<<6); | ||
47 | } | ||
48 | |||
49 | #define LCD_DELAY 1 | ||
50 | |||
51 | void lcd_write_command(int byte) | ||
52 | { | ||
53 | volatile int i = 0; | ||
54 | while(i<LCD_DELAY) i++; | ||
55 | |||
56 | /* unset D/C# (data or command) */ | ||
57 | GPIOA_PIN(5) = 0; | ||
58 | |||
59 | /* Write command */ | ||
60 | /* Only bits 15:12 and 3:0 of DBOP_DOUT are meaningful */ | ||
61 | DBOP_DOUT = (byte << 8) | byte; | ||
62 | |||
63 | /* While push fifo is not empty */ | ||
64 | while ((DBOP_STAT & (1<<10)) == 0) | ||
65 | ; | ||
66 | } | ||
67 | |||
68 | void lcd_write_data(const fb_data* p_bytes, int count) | ||
69 | { | ||
70 | volatile int i = 0; | ||
71 | while(i<LCD_DELAY) i++; | ||
72 | |||
73 | /* set D/C# (data or command) */ | ||
74 | GPIOA_PIN(5) = (1<<5); | ||
75 | |||
76 | while (count--) | ||
77 | { | ||
78 | /* Write pixels */ | ||
79 | /* Only bits 15:12 and 3:0 of DBOP_DOUT are meaningful */ | ||
80 | DBOP_DOUT = (*p_bytes << 8) | *p_bytes; | ||
81 | |||
82 | p_bytes++; /* next packed pixels */ | ||
83 | |||
84 | /* Wait if push fifo is full */ | ||
85 | while ((DBOP_STAT & (1<<6)) != 0); | ||
86 | } | ||
87 | /* While push fifo is not empty */ | ||
88 | while ((DBOP_STAT & (1<<10)) == 0); | ||
89 | } | ||