diff options
Diffstat (limited to 'firmware/target/arm/ipod/lcd-color_nano.c')
-rw-r--r-- | firmware/target/arm/ipod/lcd-color_nano.c | 63 |
1 files changed, 45 insertions, 18 deletions
diff --git a/firmware/target/arm/ipod/lcd-color_nano.c b/firmware/target/arm/ipod/lcd-color_nano.c index 0b62666c81..a331b98c88 100644 --- a/firmware/target/arm/ipod/lcd-color_nano.c +++ b/firmware/target/arm/ipod/lcd-color_nano.c | |||
@@ -31,6 +31,7 @@ | |||
31 | #include "kernel.h" | 31 | #include "kernel.h" |
32 | #include "system.h" | 32 | #include "system.h" |
33 | #include "hwcompat.h" | 33 | #include "hwcompat.h" |
34 | #include "backlight-target.h" | ||
34 | 35 | ||
35 | /* LCD command codes for HD66789R */ | 36 | /* LCD command codes for HD66789R */ |
36 | #define LCD_CNTL_RAM_ADDR_SET 0x21 | 37 | #define LCD_CNTL_RAM_ADDR_SET 0x21 |
@@ -39,7 +40,7 @@ | |||
39 | #define LCD_CNTL_VERT_RAM_ADDR_POS 0x45 | 40 | #define LCD_CNTL_VERT_RAM_ADDR_POS 0x45 |
40 | 41 | ||
41 | /*** globals ***/ | 42 | /*** globals ***/ |
42 | int lcd_type = 1; /* 0 = "old" Color/Photo, 1 = "new" Color & Nano */ | 43 | int lcd_type = 1; /* 0,2 = "old" Color/Photo; 1,3 = similar to HD66789R */ |
43 | 44 | ||
44 | static inline void lcd_wait_write(void) | 45 | static inline void lcd_wait_write(void) |
45 | { | 46 | { |
@@ -48,7 +49,7 @@ static inline void lcd_wait_write(void) | |||
48 | 49 | ||
49 | static void lcd_cmd_data(unsigned cmd, unsigned data) | 50 | static void lcd_cmd_data(unsigned cmd, unsigned data) |
50 | { | 51 | { |
51 | if (lcd_type == 0) { /* 16 bit transfers */ | 52 | if ((lcd_type&1) == 0) { /* 16 bit transfers */ |
52 | lcd_wait_write(); | 53 | lcd_wait_write(); |
53 | LCD2_PORT = LCD2_CMD_MASK | cmd; | 54 | LCD2_PORT = LCD2_CMD_MASK | cmd; |
54 | lcd_wait_write(); | 55 | lcd_wait_write(); |
@@ -91,22 +92,11 @@ void lcd_init_device(void) | |||
91 | if (IPOD_HW_REVISION == 0x60000) { | 92 | if (IPOD_HW_REVISION == 0x60000) { |
92 | lcd_type = 0; | 93 | lcd_type = 0; |
93 | } else { | 94 | } else { |
94 | int gpio_a01, gpio_a04; | 95 | lcd_type = (GPIOA_INPUT_VAL & 0x2) | ((GPIOA_INPUT_VAL & 0x10) >> 4); |
95 | |||
96 | /* A01 */ | ||
97 | gpio_a01 = (GPIOA_INPUT_VAL & 0x2) >> 1; | ||
98 | /* A04 */ | ||
99 | gpio_a04 = (GPIOA_INPUT_VAL & 0x10) >> 4; | ||
100 | |||
101 | if (((gpio_a01 << 1) | gpio_a04) == 0 || ((gpio_a01 << 1) | gpio_a04) == 2) { | ||
102 | lcd_type = 0; | ||
103 | } else { | ||
104 | lcd_type = 1; | ||
105 | } | ||
106 | } | 96 | } |
107 | if (lcd_type == 0) { | 97 | if ((lcd_type&1) == 0) { |
108 | lcd_cmd_data(0xef, 0x0); | 98 | lcd_cmd_data(0xef, 0x0); |
109 | lcd_cmd_data(0x1, 0x0); | 99 | lcd_cmd_data(0x01, 0x0); |
110 | lcd_cmd_data(0x80, 0x1); | 100 | lcd_cmd_data(0x80, 0x1); |
111 | lcd_cmd_data(0x10, 0xc); | 101 | lcd_cmd_data(0x10, 0xc); |
112 | lcd_cmd_data(0x18, 0x6); | 102 | lcd_cmd_data(0x18, 0x6); |
@@ -114,12 +104,49 @@ void lcd_init_device(void) | |||
114 | lcd_cmd_data(0x7e, 0x5); | 104 | lcd_cmd_data(0x7e, 0x5); |
115 | lcd_cmd_data(0x7f, 0x1); | 105 | lcd_cmd_data(0x7f, 0x1); |
116 | } | 106 | } |
117 | |||
118 | #elif CONFIG_LCD == LCD_IPODNANO | 107 | #elif CONFIG_LCD == LCD_IPODNANO |
119 | /* iPodLinux doesn't appear have any LCD init code for the Nano */ | 108 | /* iPodLinux doesn't appear have any LCD init code for the Nano */ |
120 | #endif | 109 | #endif |
121 | } | 110 | } |
122 | 111 | ||
112 | #ifdef HAVE_LCD_SHUTDOWN | ||
113 | void lcd_shutdown(void) { | ||
114 | /* Immediately switch off the backlight to avoid flashing. */ | ||
115 | #if defined(IPOD_NANO) | ||
116 | _backlight_hw_enable(false); | ||
117 | #elif defined(IPOD_COLOR) | ||
118 | _backlight_off(); | ||
119 | #endif | ||
120 | |||
121 | if ((lcd_type&1) == 0) { | ||
122 | /* lcd_type 0 and 2 */ | ||
123 | lcd_cmd_data(0x00EF, 0x0000); | ||
124 | lcd_cmd_data(0x0080, 0x0000); udelay(1000); | ||
125 | lcd_cmd_data(0x0001, 0x0001); | ||
126 | } else if (lcd_type == 1) { | ||
127 | /* lcd_type 1 */ | ||
128 | lcd_cmd_data(0x0007, 0x0236); sleep( 40*HZ/1000); | ||
129 | lcd_cmd_data(0x0007, 0x0226); sleep( 40*HZ/1000); | ||
130 | lcd_cmd_data(0x0007, 0x0204); | ||
131 | lcd_cmd_data(0x0010, 0x7574); sleep(200*HZ/1000); | ||
132 | lcd_cmd_data(0x0010, 0x7504); sleep( 50*HZ/1000); | ||
133 | lcd_cmd_data(0x0010, 0x0501); | ||
134 | } else { | ||
135 | /* lcd_type 3 */ | ||
136 | lcd_cmd_data(0x0007, 0x4016); sleep( 20*HZ/1000); | ||
137 | lcd_cmd_data(0x0059, 0x0011); sleep( 20*HZ/1000); | ||
138 | lcd_cmd_data(0x0059, 0x0003); sleep( 20*HZ/1000); | ||
139 | lcd_cmd_data(0x0059, 0x0002); sleep( 20*HZ/1000); | ||
140 | lcd_cmd_data(0x0010, 0x6360); sleep(200*HZ/1000); | ||
141 | lcd_cmd_data(0x0010, 0x6300); sleep( 50*HZ/1000); | ||
142 | lcd_cmd_data(0x0010, 0x0300); | ||
143 | lcd_cmd_data(0x0059, 0x0000); | ||
144 | lcd_cmd_data(0x0007, 0x4004); | ||
145 | lcd_cmd_data(0x0010, 0x0301); | ||
146 | } | ||
147 | } | ||
148 | #endif | ||
149 | |||
123 | /* Helper function to set up drawing region and start drawing */ | 150 | /* Helper function to set up drawing region and start drawing */ |
124 | static void lcd_setup_drawing_region(int x, int y, int width, int height) | 151 | static void lcd_setup_drawing_region(int x, int y, int width, int height) |
125 | { | 152 | { |
@@ -139,7 +166,7 @@ static void lcd_setup_drawing_region(int x, int y, int width, int height) | |||
139 | #endif | 166 | #endif |
140 | 167 | ||
141 | /* setup the drawing region */ | 168 | /* setup the drawing region */ |
142 | if (lcd_type == 0) { | 169 | if ((lcd_type&1) == 0) { |
143 | lcd_cmd_data(0x12, y0); /* start vert */ | 170 | lcd_cmd_data(0x12, y0); /* start vert */ |
144 | lcd_cmd_data(0x13, x0); /* start horiz */ | 171 | lcd_cmd_data(0x13, x0); /* start horiz */ |
145 | lcd_cmd_data(0x15, y1); /* end vert */ | 172 | lcd_cmd_data(0x15, y1); /* end vert */ |