diff options
Diffstat (limited to 'firmware/target/arm/as3525/sansa-clipzip/lcd-clipzip.c')
-rw-r--r-- | firmware/target/arm/as3525/sansa-clipzip/lcd-clipzip.c | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/firmware/target/arm/as3525/sansa-clipzip/lcd-clipzip.c b/firmware/target/arm/as3525/sansa-clipzip/lcd-clipzip.c new file mode 100644 index 0000000000..8efbdf77b9 --- /dev/null +++ b/firmware/target/arm/as3525/sansa-clipzip/lcd-clipzip.c | |||
@@ -0,0 +1,103 @@ | |||
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 "lcd-clip.h" | ||
26 | #include "system.h" | ||
27 | #include "cpu.h" | ||
28 | |||
29 | static int display_type; | ||
30 | |||
31 | int lcd_hw_init(void) | ||
32 | { | ||
33 | bitset32(&CGU_PERI, CGU_SSP_CLOCK_ENABLE); | ||
34 | |||
35 | SSP_CPSR = AS3525_SSP_PRESCALER; /* OF = 0x10 */ | ||
36 | SSP_CR0 = (1<<7) | (1<<6) | 7; /* Motorola SPI frame format, 8 bits */ | ||
37 | SSP_CR1 = (1<<3) | (1<<1); /* SSP Operation enabled */ | ||
38 | SSP_IMSC = 0; /* No interrupts */ | ||
39 | |||
40 | /* configure GPIO B2 (display D/C#) as output */ | ||
41 | GPIOB_DIR |= (1<<2); | ||
42 | |||
43 | /* configure GPIO B3 (display type detect) as input */ | ||
44 | GPIOB_DIR &= ~(1<<3); | ||
45 | |||
46 | /* set GPIO A5 (display RESET# ?) */ | ||
47 | GPIOA_DIR |= (1<<5); | ||
48 | GPIOA_PIN(5) = (1<<5); | ||
49 | |||
50 | /* detect display type on GPIO B3 */ | ||
51 | return GPIOB_PIN(3) ? 1 : 0; | ||
52 | } | ||
53 | |||
54 | void lcd_write_command(int byte) | ||
55 | { | ||
56 | while(SSP_SR & (1<<4)) /* BSY flag */ | ||
57 | ; | ||
58 | |||
59 | /* LCD command mode */ | ||
60 | GPIOB_PIN(2) = 0; | ||
61 | |||
62 | SSP_DATA = byte; | ||
63 | while(SSP_SR & (1<<4)) /* BSY flag */ | ||
64 | ; | ||
65 | } | ||
66 | |||
67 | void lcd_write_data(const fb_data* p_bytes, int count) | ||
68 | { | ||
69 | /* LCD data mode */ | ||
70 | GPIOB_PIN(2) = (1<<2); | ||
71 | |||
72 | while (count--) | ||
73 | { | ||
74 | while(!(SSP_SR & (1<<1))) /* wait until transmit FIFO is not full */ | ||
75 | ; | ||
76 | |||
77 | SSP_DATA = *p_bytes++; | ||
78 | } | ||
79 | } | ||
80 | |||
81 | void lcd_update(void) | ||
82 | { | ||
83 | /* TODO */ | ||
84 | } | ||
85 | |||
86 | void lcd_init_device(void) | ||
87 | { | ||
88 | /* TODO */ | ||
89 | display_type = lcd_hw_init(); | ||
90 | } | ||
91 | |||
92 | /* Update a fraction of the display. */ | ||
93 | void lcd_update_rect(int x, int y, int width, int height) | ||
94 | { | ||
95 | (void) x; | ||
96 | (void) y; | ||
97 | (void) width; | ||
98 | (void) height; | ||
99 | |||
100 | /* TODO not implemented yet, do a full update instead */ | ||
101 | lcd_update(); | ||
102 | } | ||
103 | |||