summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
Diffstat (limited to 'firmware')
-rw-r--r--firmware/target/arm/ipod/lcd-gray.c84
1 files changed, 74 insertions, 10 deletions
diff --git a/firmware/target/arm/ipod/lcd-gray.c b/firmware/target/arm/ipod/lcd-gray.c
index 9a229a4725..265cc447d7 100644
--- a/firmware/target/arm/ipod/lcd-gray.c
+++ b/firmware/target/arm/ipod/lcd-gray.c
@@ -28,6 +28,7 @@
28#include "lcd.h" 28#include "lcd.h"
29#include "kernel.h" 29#include "kernel.h"
30#include "system.h" 30#include "system.h"
31#include "hwcompat.h"
31 32
32 33
33/*** hardware configuration ***/ 34/*** hardware configuration ***/
@@ -68,6 +69,20 @@ static bool lcd_backlit = false;
68static void invert_display(void); 69static void invert_display(void);
69#endif 70#endif
70 71
72#if defined(IPOD_1G2G) || defined(IPOD_3G)
73static unsigned short power_reg_h;
74#define POWER_REG_H power_reg_h
75#else
76#define POWER_REG_H 0x1200
77#endif
78
79#ifdef IPOD_1G2G
80static unsigned short contrast_reg_h;
81#define CONTRAST_REG_H contrast_reg_h
82#else
83#define CONTRAST_REG_H 0x400
84#endif
85
71/* needed for flip */ 86/* needed for flip */
72static int addr_offset; 87static int addr_offset;
73#if defined(IPOD_MINI) || defined(IPOD_MINI2G) 88#if defined(IPOD_MINI) || defined(IPOD_MINI2G)
@@ -82,19 +97,18 @@ static const unsigned char dibits[16] ICONST_ATTR = {
82/* wait for LCD with timeout */ 97/* wait for LCD with timeout */
83static inline void lcd_wait_write(void) 98static inline void lcd_wait_write(void)
84{ 99{
85 long timeout = USEC_TIMER + 1000; /* 1 ms */ 100 while (inl(IPOD_LCD_BASE) & LCD_BUSY_MASK);
86
87 while ((inl(IPOD_LCD_BASE) & LCD_BUSY_MASK)
88 && TIME_BEFORE(USEC_TIMER, timeout));
89} 101}
90 102
91
92/* send LCD data */ 103/* send LCD data */
104#if CONFIG_CPU == PP5002
105STATICIRAM void ICODE_ATTR lcd_send_data(unsigned data)
106#else
93static void lcd_send_data(unsigned data) 107static void lcd_send_data(unsigned data)
108#endif
94{ 109{
95 lcd_wait_write(); 110 lcd_wait_write();
96#ifdef IPOD_MINI2G 111#ifdef IPOD_MINI2G
97 outl((inl(IPOD_LCD_BASE) & ~0x1f00000) | 0x1700000, IPOD_LCD_BASE);
98 outl(data | 0x760000, IPOD_LCD_BASE+8); 112 outl(data | 0x760000, IPOD_LCD_BASE+8);
99#else 113#else
100 outl(data >> 8, IPOD_LCD_BASE + LCD_DATA); 114 outl(data >> 8, IPOD_LCD_BASE + LCD_DATA);
@@ -108,7 +122,6 @@ static void lcd_prepare_cmd(unsigned cmd)
108{ 122{
109 lcd_wait_write(); 123 lcd_wait_write();
110#ifdef IPOD_MINI2G 124#ifdef IPOD_MINI2G
111 outl((inl(IPOD_LCD_BASE) & ~0x1f00000) | 0x1700000, IPOD_LCD_BASE);
112 outl(cmd | 0x740000, IPOD_LCD_BASE+8); 125 outl(cmd | 0x740000, IPOD_LCD_BASE+8);
113#else 126#else
114 outl(0x0, IPOD_LCD_BASE + LCD_CMD); 127 outl(0x0, IPOD_LCD_BASE + LCD_CMD);
@@ -127,6 +140,38 @@ static void lcd_cmd_and_data(unsigned cmd, unsigned data)
127/* LCD init */ 140/* LCD init */
128void lcd_init_device(void) 141void lcd_init_device(void)
129{ 142{
143#ifdef IPOD_1G2G
144 if ((IPOD_HW_REVISION >> 16) == 1)
145 {
146 power_reg_h = 0x1500;
147 contrast_reg_h = 0x700;
148 }
149 else /* 2nd gen */
150 {
151 if (inl(0xcf00404c) & 0x01) /* check bit 0 */
152 {
153 power_reg_h = 0x1520; /* Set step-up frequency to f/8 instead of
154 * f/32, for better blacklevel stability */
155 contrast_reg_h = 0x400;
156 }
157 else
158 {
159 power_reg_h = 0x1100;
160 contrast_reg_h = 0x300;
161 }
162 }
163#elif defined IPOD_3G
164 if (inl(0xcf00404c) & 0x01) /* check bit 0 */
165 power_reg_h = 0x1520; /* Set step-up frequency to f/8 instead of
166 * f/32, for better blacklevel stability */
167 else
168 power_reg_h = 0x1100;
169#elif defined IPOD_MINI2G
170 lcd_wait_write();
171 outl((inl(IPOD_LCD_BASE) & ~0x1f00000) | 0x1700000, IPOD_LCD_BASE);
172#endif
173
174 lcd_cmd_and_data(R_POWER_CONTROL, POWER_REG_H | 0xc);
130#ifdef HAVE_BACKLIGHT_INVERSION 175#ifdef HAVE_BACKLIGHT_INVERSION
131 invert_display(); 176 invert_display();
132#else 177#else
@@ -150,10 +195,10 @@ void lcd_init_device(void)
150int lcd_default_contrast(void) 195int lcd_default_contrast(void)
151{ 196{
152#ifdef IPOD_1G2G 197#ifdef IPOD_1G2G
153 return 30; 198 return 28;
154#elif defined(IPOD_MINI) || defined(IPOD_MINI2G) || defined(IPOD_3G) 199#elif defined(IPOD_MINI) || defined(IPOD_MINI2G) || defined(IPOD_3G)
155 return 42; 200 return 42;
156#else 201#elif defined(IPOD_4G)
157 return 35; 202 return 35;
158#endif 203#endif
159} 204}
@@ -164,7 +209,7 @@ void lcd_set_contrast(int val)
164 if (val < 0) val = 0; 209 if (val < 0) val = 0;
165 else if (val > 63) val = 63; 210 else if (val > 63) val = 63;
166 211
167 lcd_cmd_and_data(R_CONTRAST_CONTROL, 0x400 | (val + 64)); 212 lcd_cmd_and_data(R_CONTRAST_CONTROL, CONTRAST_REG_H | (val + 64));
168} 213}
169 214
170#ifdef HAVE_BACKLIGHT_INVERSION 215#ifdef HAVE_BACKLIGHT_INVERSION
@@ -229,6 +274,25 @@ void lcd_set_flip(bool yesno)
229#endif 274#endif
230} 275}
231 276
277void lcd_enable(bool on)
278{
279 if (on)
280 {
281 lcd_cmd_and_data(R_START_OSC, 1); /* start oscillation */
282 sleep(HZ/10); /* wait 10ms */
283 lcd_cmd_and_data(R_POWER_CONTROL, POWER_REG_H); /*clear standby mode */
284 lcd_cmd_and_data(R_POWER_CONTROL, POWER_REG_H | 0xc);
285 /* enable opamp & booster */
286 }
287 else
288 {
289 lcd_cmd_and_data(R_POWER_CONTROL, POWER_REG_H);
290 /* switch off opamp & booster */
291 lcd_cmd_and_data(R_POWER_CONTROL, POWER_REG_H | 0x1);
292 /* enter standby mode */
293 }
294}
295
232/*** update functions ***/ 296/*** update functions ***/
233 297
234/* Performance function that works with an external buffer 298/* Performance function that works with an external buffer