diff options
Diffstat (limited to 'firmware/target/arm/as3525/sansa-clip/lcd-ssd1303.c')
-rw-r--r-- | firmware/target/arm/as3525/sansa-clip/lcd-ssd1303.c | 55 |
1 files changed, 49 insertions, 6 deletions
diff --git a/firmware/target/arm/as3525/sansa-clip/lcd-ssd1303.c b/firmware/target/arm/as3525/sansa-clip/lcd-ssd1303.c index 1ca26dd1a1..45de3e80dc 100644 --- a/firmware/target/arm/as3525/sansa-clip/lcd-ssd1303.c +++ b/firmware/target/arm/as3525/sansa-clip/lcd-ssd1303.c | |||
@@ -9,7 +9,7 @@ | |||
9 | * | 9 | * |
10 | * Copyright (C) 2002 by Alan Korr | 10 | * Copyright (C) 2002 by Alan Korr |
11 | * Copyright (C) 2008 François Dinel | 11 | * Copyright (C) 2008 François Dinel |
12 | * Copyright (C) 2008 Rafaël Carré | 12 | * Copyright (C) 2008-2009 Rafaël Carré |
13 | * | 13 | * |
14 | * This program is free software; you can redistribute it and/or | 14 | * This program is free software; you can redistribute it and/or |
15 | * modify it under the terms of the GNU General Public License | 15 | * modify it under the terms of the GNU General Public License |
@@ -30,7 +30,12 @@ | |||
30 | #include "string.h" | 30 | #include "string.h" |
31 | 31 | ||
32 | /*** AS3525 specifics ***/ | 32 | /*** AS3525 specifics ***/ |
33 | #ifdef SANSA_CLIPV2 | ||
34 | #include "as3525v2.h" | ||
35 | #else | ||
33 | #include "as3525.h" | 36 | #include "as3525.h" |
37 | #endif | ||
38 | |||
34 | #include "ascodec.h" | 39 | #include "ascodec.h" |
35 | 40 | ||
36 | /*** definitions ***/ | 41 | /*** definitions ***/ |
@@ -71,6 +76,7 @@ | |||
71 | /* DBOP initialisation, do what OF does */ | 76 | /* DBOP initialisation, do what OF does */ |
72 | static void ams3525_dbop_init(void) | 77 | static void ams3525_dbop_init(void) |
73 | { | 78 | { |
79 | #ifdef SANSA_CLIP | ||
74 | CGU_DBOP = (1<<3) | AS3525_DBOP_DIV; | 80 | CGU_DBOP = (1<<3) | AS3525_DBOP_DIV; |
75 | 81 | ||
76 | GPIOB_AFSEL = 0x08; /* DBOP on pin 3 */ | 82 | GPIOB_AFSEL = 0x08; /* DBOP on pin 3 */ |
@@ -79,14 +85,34 @@ static void ams3525_dbop_init(void) | |||
79 | DBOP_CTRL = 0x51008; | 85 | DBOP_CTRL = 0x51008; |
80 | DBOP_TIMPOL_01 = 0x6E167; | 86 | DBOP_TIMPOL_01 = 0x6E167; |
81 | DBOP_TIMPOL_23 = 0xA167E06F; | 87 | DBOP_TIMPOL_23 = 0xA167E06F; |
88 | #else /* SANSA_CLIPV2 */ | ||
89 | CCU_IO |= (1<<12); /* ?? */ | ||
90 | CGU_DBOP |= /*(1<<3)*/ 0x18 | AS3525_DBOP_DIV; | ||
91 | |||
92 | DBOP_CTRL = 0x51004; | ||
93 | DBOP_TIMPOL_01 = 0x36A12F; | ||
94 | DBOP_TIMPOL_23 = 0xE037E037; | ||
95 | #endif | ||
82 | } | 96 | } |
83 | 97 | ||
98 | #ifdef SANSA_CLIP | ||
99 | #define LCD_DELAY 1 | ||
100 | #else /* SANSA_CLIPV2 */ | ||
101 | #define LCD_DELAY 10 | ||
102 | #endif | ||
103 | |||
84 | void lcd_write_command(int byte) | 104 | void lcd_write_command(int byte) |
85 | { | 105 | { |
86 | volatile int i = 0; | 106 | volatile int i = 0; |
87 | while(i<1) i++; | 107 | while(i<LCD_DELAY) i++; |
108 | |||
88 | /* unset D/C# (data or command) */ | 109 | /* unset D/C# (data or command) */ |
110 | #ifdef SANSA_CLIP | ||
89 | GPIOA_PIN(5) = 0; | 111 | GPIOA_PIN(5) = 0; |
112 | #else /* SANSA_CLIPV2 */ | ||
113 | GPIOB_PIN(2) = 0; | ||
114 | DBOP_TIMPOL_23 = 0xE0370036; | ||
115 | #endif | ||
90 | 116 | ||
91 | /* Write command */ | 117 | /* Write command */ |
92 | /* Only bits 15:12 and 3:0 of DBOP_DOUT are meaningful */ | 118 | /* Only bits 15:12 and 3:0 of DBOP_DOUT are meaningful */ |
@@ -95,14 +121,22 @@ void lcd_write_command(int byte) | |||
95 | /* While push fifo is not empty */ | 121 | /* While push fifo is not empty */ |
96 | while ((DBOP_STAT & (1<<10)) == 0) | 122 | while ((DBOP_STAT & (1<<10)) == 0) |
97 | ; | 123 | ; |
124 | |||
125 | #ifdef SANSA_CLIPV2 | ||
126 | DBOP_TIMPOL_23 = 0xE0370036; | ||
127 | #endif | ||
98 | } | 128 | } |
99 | 129 | ||
100 | void lcd_write_data(const fb_data* p_bytes, int count) | 130 | void lcd_write_data(const fb_data* p_bytes, int count) |
101 | { | 131 | { |
102 | volatile int i = 0; | 132 | volatile int i = 0; |
103 | while(i<1) i++; | 133 | while(i<LCD_DELAY) i++; |
104 | /* set D/C# (data or command) */ | 134 | /* set D/C# (data or command) */ |
135 | #ifdef SANSA_CLIP | ||
105 | GPIOA_PIN(5) = (1<<5); | 136 | GPIOA_PIN(5) = (1<<5); |
137 | #else /* SANSA_CLIPV2 */ | ||
138 | GPIOB_PIN(2) = (1<<2); | ||
139 | #endif | ||
106 | 140 | ||
107 | while (count--) | 141 | while (count--) |
108 | { | 142 | { |
@@ -139,9 +173,9 @@ void lcd_set_contrast(int val) | |||
139 | 173 | ||
140 | void lcd_set_invert_display(bool yesno) | 174 | void lcd_set_invert_display(bool yesno) |
141 | { | 175 | { |
142 | if (yesno) | 176 | if (yesno) |
143 | lcd_write_command(LCD_SET_REVERSE_DISPLAY); | 177 | lcd_write_command(LCD_SET_REVERSE_DISPLAY); |
144 | else | 178 | else |
145 | lcd_write_command(LCD_SET_NORMAL_DISPLAY); | 179 | lcd_write_command(LCD_SET_NORMAL_DISPLAY); |
146 | } | 180 | } |
147 | 181 | ||
@@ -168,8 +202,10 @@ void lcd_enable(bool enable) | |||
168 | 202 | ||
169 | if( (display_on = enable) ) /* simple '=' is not a typo ! */ | 203 | if( (display_on = enable) ) /* simple '=' is not a typo ! */ |
170 | { | 204 | { |
205 | #ifdef SANSA_CLIP | ||
171 | /* Enable DC-DC AS3525 for some Clip v1 that need it */ | 206 | /* Enable DC-DC AS3525 for some Clip v1 that need it */ |
172 | ascodec_write(AS3514_DCDC15, 1); | 207 | ascodec_write(AS3514_DCDC15, 1); |
208 | #endif | ||
173 | 209 | ||
174 | lcd_write_command(LCD_SET_DISPLAY_ON); | 210 | lcd_write_command(LCD_SET_DISPLAY_ON); |
175 | send_event(LCD_EVENT_ACTIVATION, NULL); | 211 | send_event(LCD_EVENT_ACTIVATION, NULL); |
@@ -177,8 +213,10 @@ void lcd_enable(bool enable) | |||
177 | else { | 213 | else { |
178 | lcd_write_command(LCD_SET_DISPLAY_OFF); | 214 | lcd_write_command(LCD_SET_DISPLAY_OFF); |
179 | 215 | ||
216 | #ifdef SANSA_CLIP | ||
180 | /* Disable DC-DC AS3525 */ | 217 | /* Disable DC-DC AS3525 */ |
181 | ascodec_write(AS3514_DCDC15, 0); | 218 | ascodec_write(AS3514_DCDC15, 0); |
219 | #endif | ||
182 | } | 220 | } |
183 | } | 221 | } |
184 | 222 | ||
@@ -198,6 +236,7 @@ void lcd_init_device(void) | |||
198 | 236 | ||
199 | ams3525_dbop_init(); | 237 | ams3525_dbop_init(); |
200 | 238 | ||
239 | #ifdef SANSA_CLIP | ||
201 | GPIOA_DIR |= 0x33; /* pins 5:4 and 1:0 out */ | 240 | GPIOA_DIR |= 0x33; /* pins 5:4 and 1:0 out */ |
202 | GPIOB_DIR |= 0x40; /* pin 6 out */ | 241 | GPIOB_DIR |= 0x40; /* pin 6 out */ |
203 | 242 | ||
@@ -205,6 +244,10 @@ void lcd_init_device(void) | |||
205 | GPIOA_PIN(0) = (1<<0); | 244 | GPIOA_PIN(0) = (1<<0); |
206 | GPIOA_PIN(4) = 0; | 245 | GPIOA_PIN(4) = 0; |
207 | GPIOB_PIN(6) = (1<<6); | 246 | GPIOB_PIN(6) = (1<<6); |
247 | #else /* SANSA_CLIPV2 */ | ||
248 | GPIOB_DIR |= (1<<2)|(1<<5); | ||
249 | GPIOB_PIN(5) = (1<<5); | ||
250 | #endif | ||
208 | 251 | ||
209 | /* Set display clock (divide ratio = 1) and oscillator frequency (1) */ | 252 | /* Set display clock (divide ratio = 1) and oscillator frequency (1) */ |
210 | lcd_write_command(LCD_SET_DISPLAY_CLOCK_AND_OSC_FREQ); | 253 | lcd_write_command(LCD_SET_DISPLAY_CLOCK_AND_OSC_FREQ); |
@@ -247,7 +290,7 @@ void lcd_init_device(void) | |||
247 | lcd_write_command (LCD_SET_HIGHER_COLUMN_ADDRESS /*| 0*/); | 290 | lcd_write_command (LCD_SET_HIGHER_COLUMN_ADDRESS /*| 0*/); |
248 | lcd_write_command (LCD_SET_LOWER_COLUMN_ADDRESS /*| 0*/); | 291 | lcd_write_command (LCD_SET_LOWER_COLUMN_ADDRESS /*| 0*/); |
249 | 292 | ||
250 | memset(p_bytes, 0, sizeof(p_bytes)); /* fills with 0 : pixel off */ | 293 | memset(p_bytes, 0, sizeof(p_bytes)); /* fills with 0 : pixel off */ |
251 | 294 | ||
252 | for(i = 0; i < 8; i++) | 295 | for(i = 0; i < 8; i++) |
253 | { | 296 | { |