summaryrefslogtreecommitdiff
path: root/firmware/target/arm/iriver/h10/lcd-h10_20gb.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm/iriver/h10/lcd-h10_20gb.c')
-rw-r--r--firmware/target/arm/iriver/h10/lcd-h10_20gb.c48
1 files changed, 17 insertions, 31 deletions
diff --git a/firmware/target/arm/iriver/h10/lcd-h10_20gb.c b/firmware/target/arm/iriver/h10/lcd-h10_20gb.c
index f6ea87c1d0..a52e98f364 100644
--- a/firmware/target/arm/iriver/h10/lcd-h10_20gb.c
+++ b/firmware/target/arm/iriver/h10/lcd-h10_20gb.c
@@ -22,12 +22,6 @@
22#include "kernel.h" 22#include "kernel.h"
23#include "system.h" 23#include "system.h"
24 24
25/* check if number of useconds has past */
26static inline bool timer_check(int clock_start, int usecs)
27{
28 return ((int)(USEC_TIMER - clock_start)) >= usecs;
29}
30
31/** Initialized in lcd_init_device() **/ 25/** Initialized in lcd_init_device() **/
32/* Is the power turned on? */ 26/* Is the power turned on? */
33static bool power_on; 27static bool power_on;
@@ -43,17 +37,6 @@ static int lcd_contrast;
43/* Forward declarations */ 37/* Forward declarations */
44static void lcd_display_off(void); 38static void lcd_display_off(void);
45 39
46/* Hardware address of LCD. Bits are:
47 * 31 - set to write, poll for completion.
48 * 24 - 0 for command, 1 for data
49 * 7..0 - command/data to send
50 * Commands/Data are always sent in 16-bits, msb first.
51 */
52#define LCD_BASE *(volatile unsigned int *)0x70008a0c
53#define LCD_BUSY_MASK 0x80000000
54#define LCD_CMD 0x80000000
55#define LCD_DATA 0x81000000
56
57/* register defines for the Renesas HD66773R */ 40/* register defines for the Renesas HD66773R */
58#define R_START_OSC 0x00 41#define R_START_OSC 0x00
59#define R_DEVICE_CODE_READ 0x00 42#define R_DEVICE_CODE_READ 0x00
@@ -91,31 +74,34 @@ static void lcd_display_off(void);
91 74
92static inline void lcd_wait_write(void) 75static inline void lcd_wait_write(void)
93{ 76{
94 if ((LCD_BASE & LCD_BUSY_MASK) != 0) { 77 while (LCD2_PORT & LCD2_BUSY_MASK);
95 int start = USEC_TIMER;
96
97 do {
98 if ((LCD_BASE & LCD_BUSY_MASK) == 0) break;
99 } while (timer_check(start, 1000) == 0);
100 }
101} 78}
102 79
103/* Send command */ 80/* Send command */
104static inline void lcd_send_cmd(int v) 81static inline void lcd_send_cmd(unsigned v)
105{ 82{
106 lcd_wait_write(); 83 lcd_wait_write();
107 LCD_BASE = 0x00000000 | LCD_CMD; 84 LCD2_PORT = LCD2_CMD_MASK;
108 LCD_BASE = v | LCD_CMD; 85 LCD2_PORT = LCD2_CMD_MASK | v;
109} 86}
110 87
111/* Send 16-bit data */ 88/* Send 16-bit data */
112static inline void lcd_send_data(int v) 89static inline void lcd_send_data(unsigned v)
113{ 90{
114 lcd_wait_write(); 91 lcd_wait_write();
115 LCD_BASE = ((v>>8) & 0xff) | LCD_DATA; /* Send MSB first */ 92 LCD2_PORT = LCD2_DATA_MASK | (v >> 8); /* Send MSB first */
116 LCD_BASE = ( v & 0xff) | LCD_DATA; 93 LCD2_PORT = LCD2_DATA_MASK | (v & 0xff);
117} 94}
118 95
96/* Send 16-bit data byte-swapped. Only needed until we can use block transfer. */
97static inline void lcd_send_data_swapped(unsigned v)
98{
99 lcd_wait_write();
100 LCD2_PORT = LCD2_DATA_MASK | (v & 0xff); /* Send LSB first */
101 LCD2_PORT = LCD2_DATA_MASK | (v >> 8);
102}
103
104
119/* Write value to register */ 105/* Write value to register */
120static inline void lcd_write_reg(int reg, int val) 106static inline void lcd_write_reg(int reg, int val)
121{ 107{
@@ -635,7 +621,7 @@ void lcd_update_rect(int x0, int y0, int width, int height)
635 /* for each column */ 621 /* for each column */
636 for (c = 0; c < width; c++) { 622 for (c = 0; c < width; c++) {
637 /* output 1 pixel */ 623 /* output 1 pixel */
638 lcd_send_data(*(addr++)); 624 lcd_send_data_swapped(*addr++);
639 } 625 }
640 626
641 addr += LCD_WIDTH - width; 627 addr += LCD_WIDTH - width;