diff options
author | Rafaël Carré <rafael.carre@gmail.com> | 2010-02-05 15:12:08 +0000 |
---|---|---|
committer | Rafaël Carré <rafael.carre@gmail.com> | 2010-02-05 15:12:08 +0000 |
commit | c8ea43f0957ff75664a03332c602dee241717435 (patch) | |
tree | 3edf6c21b014e8933fd88c107bdac9e4ea87486c /firmware/target/arm/as3525 | |
parent | 507d7bdb0e915504f8d60ee7c2ff1047a6d977c2 (diff) | |
download | rockbox-c8ea43f0957ff75664a03332c602dee241717435.tar.gz rockbox-c8ea43f0957ff75664a03332c602dee241717435.zip |
Untested attempt at a Clip+ LCD driver using SSP (PrimeCell PL022)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@24523 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/arm/as3525')
-rw-r--r-- | firmware/target/arm/as3525/sansa-clip/lcd-ssd1303.c | 62 |
1 files changed, 55 insertions, 7 deletions
diff --git a/firmware/target/arm/as3525/sansa-clip/lcd-ssd1303.c b/firmware/target/arm/as3525/sansa-clip/lcd-ssd1303.c index b379808060..b1aeee93ba 100644 --- a/firmware/target/arm/as3525/sansa-clip/lcd-ssd1303.c +++ b/firmware/target/arm/as3525/sansa-clip/lcd-ssd1303.c | |||
@@ -73,10 +73,11 @@ | |||
73 | #define LCD_CNTL_HIGHCOL 0x10 /* Upper column address */ | 73 | #define LCD_CNTL_HIGHCOL 0x10 /* Upper column address */ |
74 | #define LCD_CNTL_LOWCOL 0x00 /* Lower column address */ | 74 | #define LCD_CNTL_LOWCOL 0x00 /* Lower column address */ |
75 | 75 | ||
76 | /* DBOP initialisation, do what OF does */ | 76 | |
77 | static void ams3525_dbop_init(void) | 77 | static void lcd_hw_init(void) |
78 | { | 78 | { |
79 | #ifdef SANSA_CLIP | 79 | #if defined(SANSA_CLIP) |
80 | /* DBOP initialisation, do what OF does */ | ||
80 | CGU_DBOP = (1<<3) | AS3525_DBOP_DIV; | 81 | CGU_DBOP = (1<<3) | AS3525_DBOP_DIV; |
81 | 82 | ||
82 | GPIOB_AFSEL = 0x08; /* DBOP on pin 3 */ | 83 | GPIOB_AFSEL = 0x08; /* DBOP on pin 3 */ |
@@ -85,13 +86,21 @@ static void ams3525_dbop_init(void) | |||
85 | DBOP_CTRL = 0x51008; | 86 | DBOP_CTRL = 0x51008; |
86 | DBOP_TIMPOL_01 = 0x6E167; | 87 | DBOP_TIMPOL_01 = 0x6E167; |
87 | DBOP_TIMPOL_23 = 0xA167E06F; | 88 | DBOP_TIMPOL_23 = 0xA167E06F; |
88 | #else /* SANSA_CLIPV2 */ | 89 | #elif defined(SANSA_CLIPV2) |
90 | /* DBOP initialisation, do what OF does */ | ||
89 | CCU_IO |= (1<<12); /* ?? */ | 91 | CCU_IO |= (1<<12); /* ?? */ |
90 | CGU_DBOP |= /*(1<<3)*/ 0x18 | AS3525_DBOP_DIV; | 92 | CGU_DBOP |= /*(1<<3)*/ 0x18 | AS3525_DBOP_DIV; |
91 | 93 | ||
92 | DBOP_CTRL = 0x51004; | 94 | DBOP_CTRL = 0x51004; |
93 | DBOP_TIMPOL_01 = 0x36A12F; | 95 | DBOP_TIMPOL_01 = 0x36A12F; |
94 | DBOP_TIMPOL_23 = 0xE037E037; | 96 | DBOP_TIMPOL_23 = 0xE037E037; |
97 | #elif defined(SANSA_CLIPPLUS) | ||
98 | CGU_PERI |= CGU_SSP_CLOCK_ENABLE; | ||
99 | |||
100 | SSP_CPSR; /* No clock prescale */ | ||
101 | SSP_CR0 = 0 | 7; /* Motorola SPI frame format, 8 bits */ | ||
102 | SSP_CR1 = 1<<1; /* SSP Operation enabled */ | ||
103 | SSP_IMSC = 0; /* No interrupts */ | ||
95 | #endif | 104 | #endif |
96 | } | 105 | } |
97 | 106 | ||
@@ -101,6 +110,7 @@ static void ams3525_dbop_init(void) | |||
101 | #define LCD_DELAY 10 | 110 | #define LCD_DELAY 10 |
102 | #endif | 111 | #endif |
103 | 112 | ||
113 | #if defined(SANSA_CLIP) || defined(SANSA_CLIPV2) | ||
104 | void lcd_write_command(int byte) | 114 | void lcd_write_command(int byte) |
105 | { | 115 | { |
106 | volatile int i = 0; | 116 | volatile int i = 0; |
@@ -126,7 +136,21 @@ void lcd_write_command(int byte) | |||
126 | DBOP_TIMPOL_23 = 0xE037E037; | 136 | DBOP_TIMPOL_23 = 0xE037E037; |
127 | #endif | 137 | #endif |
128 | } | 138 | } |
139 | #elif defined(SANSA_CLIPPLUS) | ||
140 | void lcd_write_command(int byte) | ||
141 | { | ||
142 | while(SSP_SR & (1<<4)) /* BSY flag */ | ||
143 | ; | ||
144 | |||
145 | GPIOB_PIN(2) = 0; | ||
146 | SSP_DATA = byte; | ||
147 | |||
148 | while(SSP_SR & (1<<4)) /* BSY flag */ | ||
149 | ; | ||
150 | } | ||
151 | #endif | ||
129 | 152 | ||
153 | #if defined(SANSA_CLIP) || defined(SANSA_CLIPV2) | ||
130 | void lcd_write_data(const fb_data* p_bytes, int count) | 154 | void lcd_write_data(const fb_data* p_bytes, int count) |
131 | { | 155 | { |
132 | volatile int i = 0; | 156 | volatile int i = 0; |
@@ -152,6 +176,23 @@ void lcd_write_data(const fb_data* p_bytes, int count) | |||
152 | /* While push fifo is not empty */ | 176 | /* While push fifo is not empty */ |
153 | while ((DBOP_STAT & (1<<10)) == 0); | 177 | while ((DBOP_STAT & (1<<10)) == 0); |
154 | } | 178 | } |
179 | #elif defined(SANSA_CLIPPLUS) | ||
180 | void lcd_write_data(const fb_data* p_bytes, int count) | ||
181 | { | ||
182 | GPIOB_PIN(2) = (1<<2); | ||
183 | |||
184 | SSP_CR0 = 0 | 15; /* Motorola SPI frame format, 16 bits */ | ||
185 | while (count--) | ||
186 | { | ||
187 | while(SSP_SR & (1<<1)) /* Transmit FIFO is not full */ | ||
188 | SSP_DATA = *p_bytes++; | ||
189 | |||
190 | while(!(SSP_SR & (1<<0))) /* Transmit FIFO is not empty */ | ||
191 | ; | ||
192 | } | ||
193 | SSP_CR0 = 0 | 7; /* Motorola SPI frame format, 8 bits */ | ||
194 | } | ||
195 | #endif | ||
155 | 196 | ||
156 | 197 | ||
157 | /** globals **/ | 198 | /** globals **/ |
@@ -234,9 +275,9 @@ void lcd_init_device(void) | |||
234 | #define LCD_FULLSCREEN (128+4) | 275 | #define LCD_FULLSCREEN (128+4) |
235 | fb_data p_bytes[LCD_FULLSCREEN]; /* framebuffer used to clear the screen */ | 276 | fb_data p_bytes[LCD_FULLSCREEN]; /* framebuffer used to clear the screen */ |
236 | 277 | ||
237 | ams3525_dbop_init(); | 278 | lcd_hw_init(); |
238 | 279 | ||
239 | #ifdef SANSA_CLIP | 280 | #if defined(SANSA_CLIP) |
240 | GPIOA_DIR |= 0x33; /* pins 5:4 and 1:0 out */ | 281 | GPIOA_DIR |= 0x33; /* pins 5:4 and 1:0 out */ |
241 | GPIOB_DIR |= 0x40; /* pin 6 out */ | 282 | GPIOB_DIR |= 0x40; /* pin 6 out */ |
242 | 283 | ||
@@ -244,9 +285,16 @@ void lcd_init_device(void) | |||
244 | GPIOA_PIN(0) = (1<<0); | 285 | GPIOA_PIN(0) = (1<<0); |
245 | GPIOA_PIN(4) = 0; | 286 | GPIOA_PIN(4) = 0; |
246 | GPIOB_PIN(6) = (1<<6); | 287 | GPIOB_PIN(6) = (1<<6); |
247 | #else /* SANSA_CLIPV2 */ | 288 | #elif defined(SANSA_CLIPV2) |
248 | GPIOB_DIR |= (1<<2)|(1<<5); | 289 | GPIOB_DIR |= (1<<2)|(1<<5); |
249 | GPIOB_PIN(5) = (1<<5); | 290 | GPIOB_PIN(5) = (1<<5); |
291 | #elif defined(SANSA_CLIPPLUS) | ||
292 | GPIOA_DIR |= (1<<5); | ||
293 | GPIOB_DIR |= (1<<2) | (1<<7); | ||
294 | GPIOA_PIN(5) = 0; | ||
295 | GPIOA_DIR &= (1<<0); | ||
296 | GPIOA_PIN(0) = (1<<0); | ||
297 | GPIOB_PIN(7) = (1<<7); | ||
250 | #endif | 298 | #endif |
251 | 299 | ||
252 | /* Set display clock (divide ratio = 1) and oscillator frequency (1) */ | 300 | /* Set display clock (divide ratio = 1) and oscillator frequency (1) */ |