summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
Diffstat (limited to 'firmware')
-rw-r--r--firmware/drivers/lcd-ipod.c72
1 files changed, 21 insertions, 51 deletions
diff --git a/firmware/drivers/lcd-ipod.c b/firmware/drivers/lcd-ipod.c
index f7a21044bb..c17be0689d 100644
--- a/firmware/drivers/lcd-ipod.c
+++ b/firmware/drivers/lcd-ipod.c
@@ -27,56 +27,26 @@
27#include "system.h" 27#include "system.h"
28 28
29/*** definitions ***/ 29/*** definitions ***/
30#define IPOD_HW_REVISION (*((volatile unsigned long*)(0x00002084))) 30#define IPOD_HW_REVISION (*((volatile unsigned long*)0x00002084))
31 31#define IPOD_PP5020_RTC (*((volatile unsigned long*)0x60005010))
32/* LCD command codes */
33#define LCD_CNTL_POWER_CONTROL 0x25
34#define LCD_CNTL_VOLTAGE_SELECT 0x2b
35#define LCD_CNTL_LINE_INVERT_DRIVE 0x36
36#define LCD_CNTL_GRAY_SCALE_PATTERN 0x39
37#define LCD_CNTL_TEMP_GRADIENT_SELECT 0x4e
38#define LCD_CNTL_OSC_FREQUENCY 0x5f
39#define LCD_CNTL_ON_OFF 0xae
40#define LCD_CNTL_OSC_ON_OFF 0xaa
41#define LCD_CNTL_OFF_MODE 0xbe
42#define LCD_CNTL_REVERSE 0xa6
43#define LCD_CNTL_ALL_LIGHTING 0xa4
44#define LCD_CNTL_COMMON_OUTPUT_STATUS 0xc4
45#define LCD_CNTL_COLUMN_ADDRESS_DIR 0xa0
46#define LCD_CNTL_NLINE_ON_OFF 0xe4
47#define LCD_CNTL_DISPLAY_MODE 0x66
48#define LCD_CNTL_DUTY_SET 0x6d
49#define LCD_CNTL_ELECTRONIC_VOLUME 0x81
50#define LCD_CNTL_DATA_INPUT_DIR 0x84
51#define LCD_CNTL_DISPLAY_START_LINE 0x8a
52
53#define LCD_CNTL_PAGE 0xb1
54#define LCD_CNTL_COLUMN 0x13
55#define LCD_CNTL_DATA_WRITE 0x1d
56 32
57/*** globals ***/ 33#define IPOD_LCD_BASE 0x70008a0c
58static int lcd_type = 1; /* 0 = "old" Color/Photo, 1 = "new" Color & Nano */ 34#define IPOD_LCD_BUSY_MASK 0x80000000
59
60#define IPOD_PP5020_RTC 0x60005010
61 35
62#define LCD_DATA 0x10 36/* LCD command codes for HD66789R */
63#define LCD_CMD 0x08 37#define LCD_CNTL_RAM_ADDR_SET 0x21
38#define LCD_CNTL_WRITE_TO_GRAM 0x22
39#define LCD_CNTL_HORIZ_RAM_ADDR_POS 0x44
40#define LCD_CNTL_VERT_RAM_ADDR_POS 0x45
64 41
65#define IPOD_LCD_BASE 0x70008a0c 42/*** globals ***/
66#define IPOD_LCD_BUSY_MASK 0x80000000 43static int lcd_type = 1; /* 0 = "old" Color/Photo, 1 = "new" Color & Nano */
67 44
68static int timer_get_current(void)
69{
70 return inl(IPOD_PP5020_RTC);
71}
72 45
73/* check if number of useconds has past */ 46/* check if number of useconds has past */
74static int timer_check(unsigned long clock_start, unsigned long usecs) 47static inline int timer_check(unsigned long clock_start, unsigned long usecs)
75{ 48{
76 unsigned long clock; 49 if ( (IPOD_PP5020_RTC - clock_start) >= usecs ) {
77 clock = inl(IPOD_PP5020_RTC);
78
79 if ( (clock - clock_start) >= usecs ) {
80 return 1; 50 return 1;
81 } else { 51 } else {
82 return 0; 52 return 0;
@@ -86,7 +56,7 @@ static int timer_check(unsigned long clock_start, unsigned long usecs)
86static void lcd_wait_write(void) 56static void lcd_wait_write(void)
87{ 57{
88 if ((inl(IPOD_LCD_BASE) & IPOD_LCD_BUSY_MASK) != 0) { 58 if ((inl(IPOD_LCD_BASE) & IPOD_LCD_BUSY_MASK) != 0) {
89 int start = timer_get_current(); 59 int start = IPOD_PP5020_RTC;
90 60
91 do { 61 do {
92 if ((inl(IPOD_LCD_BASE) & IPOD_LCD_BUSY_MASK) == 0) break; 62 if ((inl(IPOD_LCD_BASE) & IPOD_LCD_BUSY_MASK) == 0) break;
@@ -97,13 +67,13 @@ static void lcd_wait_write(void)
97static void lcd_send_lo(int v) 67static void lcd_send_lo(int v)
98{ 68{
99 lcd_wait_write(); 69 lcd_wait_write();
100 outl(v | 0x80000000, 0x70008A0C); 70 outl(v | 0x80000000, IPOD_LCD_BASE);
101} 71}
102 72
103static void lcd_send_hi(int v) 73static void lcd_send_hi(int v)
104{ 74{
105 lcd_wait_write(); 75 lcd_wait_write();
106 outl(v | 0x81000000, 0x70008A0C); 76 outl(v | 0x81000000, IPOD_LCD_BASE);
107} 77}
108 78
109static void lcd_cmd_data(int cmd, int data) 79static void lcd_cmd_data(int cmd, int data)
@@ -258,9 +228,9 @@ void lcd_update_rect(int x, int y, int width, int height)
258 } 228 }
259 229
260 /* max horiz << 8 | start horiz */ 230 /* max horiz << 8 | start horiz */
261 lcd_cmd_data(0x44, (rect3 << 8) | rect1); 231 lcd_cmd_data(LCD_CNTL_HORIZ_RAM_ADDR_POS, (rect3 << 8) | rect1);
262 /* max vert << 8 | start vert */ 232 /* max vert << 8 | start vert */
263 lcd_cmd_data(0x45, (rect4 << 8) | rect2); 233 lcd_cmd_data(LCD_CNTL_VERT_RAM_ADDR_POS, (rect4 << 8) | rect2);
264 234
265 /* start vert = max vert */ 235 /* start vert = max vert */
266#if CONFIG_LCD == LCD_IPODCOLOR 236#if CONFIG_LCD == LCD_IPODCOLOR
@@ -269,11 +239,11 @@ void lcd_update_rect(int x, int y, int width, int height)
269 239
270 /* position cursor (set AD0-AD15) */ 240 /* position cursor (set AD0-AD15) */
271 /* start vert << 8 | start horiz */ 241 /* start vert << 8 | start horiz */
272 lcd_cmd_data(0x21, (rect2 << 8) | rect1); 242 lcd_cmd_data(LCD_CNTL_RAM_ADDR_SET, (rect2 << 8) | rect1);
273 243
274 /* start drawing */ 244 /* start drawing */
275 lcd_send_lo(0x0); 245 lcd_send_lo(0x0);
276 lcd_send_lo(0x22); 246 lcd_send_lo(LCD_CNTL_WRITE_TO_GRAM);
277 } 247 }
278 248
279 addr += x * LCD_WIDTH + y/2; 249 addr += x * LCD_WIDTH + y/2;
@@ -283,9 +253,9 @@ void lcd_update_rect(int x, int y, int width, int height)
283 int h, pixels_to_write; 253 int h, pixels_to_write;
284 254
285 pixels_to_write = (width * height) * 2; 255 pixels_to_write = (width * height) * 2;
256 h = height;
286 257
287 /* calculate how much we can do in one go */ 258 /* calculate how much we can do in one go */
288 h = height;
289 if (pixels_to_write > 64000) { 259 if (pixels_to_write > 64000) {
290 h = (64000/2) / width; 260 h = (64000/2) / width;
291 pixels_to_write = (width * h) * 2; 261 pixels_to_write = (width * h) * 2;