summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
Diffstat (limited to 'firmware')
-rw-r--r--firmware/backlight.c20
-rw-r--r--firmware/drivers/lcd-h100-remote.c34
-rw-r--r--firmware/export/system.h37
3 files changed, 57 insertions, 34 deletions
diff --git a/firmware/backlight.c b/firmware/backlight.c
index 98b2d9a40d..d40f00f163 100644
--- a/firmware/backlight.c
+++ b/firmware/backlight.c
@@ -114,7 +114,7 @@ void TIMER1(void)
114 114
115 if (bl_dim_current > 0 && bl_dim_current < BL_PWM_COUNT) 115 if (bl_dim_current > 0 && bl_dim_current < BL_PWM_COUNT)
116 { 116 {
117 GPIO1_OUT &= ~0x00020000; 117 and_l(~0x00020000, &GPIO1_OUT);
118 bl_pwm_counter = bl_dim_current; 118 bl_pwm_counter = bl_dim_current;
119 timer_period = timer_period * bl_pwm_counter / BL_PWM_COUNT; 119 timer_period = timer_period * bl_pwm_counter / BL_PWM_COUNT;
120 bl_dim_state = DIM_STATE_MAIN; 120 bl_dim_state = DIM_STATE_MAIN;
@@ -122,9 +122,9 @@ void TIMER1(void)
122 else 122 else
123 { 123 {
124 if (bl_dim_current) 124 if (bl_dim_current)
125 GPIO1_OUT &= ~0x00020000; 125 and_l(~0x00020000, &GPIO1_OUT);
126 else 126 else
127 GPIO1_OUT |= 0x00020000; 127 or_l(0x00020000, &GPIO1_OUT);
128 if (bl_dim_current == bl_dim_target) 128 if (bl_dim_current == bl_dim_target)
129 idle = true; 129 idle = true;
130 } 130 }
@@ -133,7 +133,7 @@ void TIMER1(void)
133 133
134 /* Dim main screen */ 134 /* Dim main screen */
135 case DIM_STATE_MAIN: 135 case DIM_STATE_MAIN:
136 GPIO1_OUT |= 0x00020000; 136 or_l(0x00020000, &GPIO1_OUT);
137 bl_dim_state = DIM_STATE_START; 137 bl_dim_state = DIM_STATE_START;
138 timer_period = timer_period * (BL_PWM_COUNT - bl_pwm_counter) / BL_PWM_COUNT; 138 timer_period = timer_period * (BL_PWM_COUNT - bl_pwm_counter) / BL_PWM_COUNT;
139 break ; 139 break ;
@@ -182,9 +182,9 @@ void backlight_allow_timer(bool on)
182 TMR1 = 0; 182 TMR1 = 0;
183 183
184 if (bl_dim_current) 184 if (bl_dim_current)
185 GPIO1_OUT &= ~0x00020000; 185 and_l(~0x00020000, &GPIO1_OUT);
186 else 186 else
187 GPIO1_OUT |= 0x00020000; 187 or_l(0x00020000, &GPIO1_OUT);
188 } 188 }
189} 189}
190 190
@@ -207,7 +207,7 @@ static void __backlight_off(void)
207 else 207 else
208 { 208 {
209 bl_dim_target = bl_dim_current = 0; 209 bl_dim_target = bl_dim_current = 0;
210 GPIO1_OUT |= 0x00020000; 210 or_l(0x00020000, &GPIO1_OUT);
211 } 211 }
212#elif CONFIG_BACKLIGHT == BL_RTC 212#elif CONFIG_BACKLIGHT == BL_RTC
213 /* Disable square wave */ 213 /* Disable square wave */
@@ -229,7 +229,7 @@ static void __backlight_on(void)
229 else 229 else
230 { 230 {
231 bl_dim_target = bl_dim_current = BL_PWM_COUNT; 231 bl_dim_target = bl_dim_current = BL_PWM_COUNT;
232 GPIO1_OUT &= ~0x00020000; 232 and_l(~0x00020000, &GPIO1_OUT);
233 } 233 }
234#elif CONFIG_BACKLIGHT == BL_RTC 234#elif CONFIG_BACKLIGHT == BL_RTC
235 /* Enable square wave */ 235 /* Enable square wave */
@@ -409,8 +409,8 @@ void backlight_init(void)
409 sizeof(backlight_stack), backlight_thread_name); 409 sizeof(backlight_stack), backlight_thread_name);
410 410
411#if CONFIG_BACKLIGHT == BL_IRIVER 411#if CONFIG_BACKLIGHT == BL_IRIVER
412 GPIO1_ENABLE |= 0x00020000; 412 or_l(0x00020000, &GPIO1_ENABLE);
413 GPIO1_FUNCTION |= 0x00020000; 413 or_l(0x00020000, &GPIO1_FUNCTION);
414#elif CONFIG_BACKLIGHT == BL_PA14_LO || CONFIG_BACKLIGHT == BL_PA14_HI 414#elif CONFIG_BACKLIGHT == BL_PA14_LO || CONFIG_BACKLIGHT == BL_PA14_HI
415 PACR1 &= ~0x3000; /* Set PA14 (backlight control) to GPIO */ 415 PACR1 &= ~0x3000; /* Set PA14 (backlight control) to GPIO */
416 or_b(0x40, &PAIORH); /* ..and output */ 416 or_b(0x40, &PAIORH); /* ..and output */
diff --git a/firmware/drivers/lcd-h100-remote.c b/firmware/drivers/lcd-h100-remote.c
index af6a45c2c0..eaf61260cb 100644
--- a/firmware/drivers/lcd-h100-remote.c
+++ b/firmware/drivers/lcd-h100-remote.c
@@ -50,14 +50,14 @@
50#define LCD_REMOTE_CNTL_HIGHCOL 0x10 /* Upper column address */ 50#define LCD_REMOTE_CNTL_HIGHCOL 0x10 /* Upper column address */
51#define LCD_REMOTE_CNTL_LOWCOL 0x00 /* Lower column address */ 51#define LCD_REMOTE_CNTL_LOWCOL 0x00 /* Lower column address */
52 52
53#define CS_LO GPIO1_OUT &= ~0x00000004 53#define CS_LO and_l(~0x00000004, &GPIO1_OUT)
54#define CS_HI GPIO1_OUT |= 0x00000004 54#define CS_HI or_l(0x00000004, &GPIO1_OUT)
55#define CLK_LO GPIO_OUT &= ~0x10000000 55#define CLK_LO and_l(~0x10000000, &GPIO_OUT)
56#define CLK_HI GPIO_OUT |= 0x10000000 56#define CLK_HI or_l(0x10000000, &GPIO_OUT)
57#define DATA_LO GPIO1_OUT &= ~0x00040000 57#define DATA_LO and_l(~0x00040000, &GPIO1_OUT)
58#define DATA_HI GPIO1_OUT |= 0x00040000 58#define DATA_HI or_l(0x00040000, &GPIO1_OUT)
59#define RS_LO GPIO_OUT &= ~0x00010000 59#define RS_LO and_l(~0x00010000, &GPIO_OUT)
60#define RS_HI GPIO_OUT |= 0x00010000 60#define RS_HI or_l(0x00010000, &GPIO_OUT)
61 61
62/* delay loop */ 62/* delay loop */
63#define DELAY do { int _x; for(_x=0;_x<3;_x++);} while (0) 63#define DELAY do { int _x; for(_x=0;_x<3;_x++);} while (0)
@@ -115,12 +115,12 @@ static const char scroll_tick_table[16] = {
115#ifndef SIMULATOR 115#ifndef SIMULATOR
116void lcd_remote_backlight_on(void) 116void lcd_remote_backlight_on(void)
117{ 117{
118 GPIO_OUT &= ~0x00000800; 118 and_l(~0x00000800, &GPIO_OUT);
119} 119}
120 120
121void lcd_remote_backlight_off(void) 121void lcd_remote_backlight_off(void)
122{ 122{
123 GPIO_OUT |= 0x00000800; 123 or_l(0x00000800, &GPIO_OUT);
124} 124}
125 125
126void lcd_remote_write_command(int cmd) 126void lcd_remote_write_command(int cmd)
@@ -363,14 +363,14 @@ static void remote_tick(void)
363/* Initialise ports and kick off monitor */ 363/* Initialise ports and kick off monitor */
364void lcd_remote_init(void) 364void lcd_remote_init(void)
365{ 365{
366 GPIO_FUNCTION |= 0x10010800; /* GPIO11: Backlight 366 or_l(0x10010800, &GPIO_FUNCTION); /* GPIO11: Backlight
367 GPIO16: RS 367 GPIO16: RS
368 GPIO28: CLK */ 368 GPIO28: CLK */
369 369
370 GPIO1_FUNCTION |= 0x00040004; /* GPIO34: CS 370 or_l(0x00040004, &GPIO1_FUNCTION); /* GPIO34: CS
371 GPIO50: Data */ 371 GPIO50: Data */
372 GPIO_ENABLE |= 0x10010800; 372 or_l(0x10010800, &GPIO_ENABLE);
373 GPIO1_ENABLE |= 0x00040004; 373 or_l(0x00040004, &GPIO1_ENABLE);
374 374
375 lcd_remote_clear_display(); 375 lcd_remote_clear_display();
376 376
diff --git a/firmware/export/system.h b/firmware/export/system.h
index e98c362a8c..56fee6bdab 100644
--- a/firmware/export/system.h
+++ b/firmware/export/system.h
@@ -81,25 +81,48 @@ enum {
81 81
82#if CONFIG_CPU == SH7034 82#if CONFIG_CPU == SH7034
83#define or_b(mask, address) \ 83#define or_b(mask, address) \
84 asm \ 84 asm \
85 ("or.b\t%0,@(r0,gbr)" \ 85 ("or.b %0,@(r0,gbr)" \
86 : \ 86 : \
87 : /* %0 */ I_CONSTRAINT((char)(mask)), \ 87 : /* %0 */ I_CONSTRAINT((char)(mask)), \
88 /* %1 */ "z"(address-GBR)) 88 /* %1 */ "z"(address-GBR))
89 89
90#define and_b(mask, address) \ 90#define and_b(mask, address) \
91 asm \ 91 asm \
92 ("and.b\t%0,@(r0,gbr)" \ 92 ("and.b %0,@(r0,gbr)" \
93 : \ 93 : \
94 : /* %0 */ I_CONSTRAINT((char)(mask)), \ 94 : /* %0 */ I_CONSTRAINT((char)(mask)), \
95 /* %1 */ "z"(address-GBR)) 95 /* %1 */ "z"(address-GBR))
96 96
97#define xor_b(mask, address) \ 97#define xor_b(mask, address) \
98 asm \ 98 asm \
99 ("xor.b\t%0,@(r0,gbr)" \ 99 ("xor.b %0,@(r0,gbr)" \
100 : \ 100 : \
101 : /* %0 */ I_CONSTRAINT((char)(mask)), \ 101 : /* %0 */ I_CONSTRAINT((char)(mask)), \
102 /* %1 */ "z"(address-GBR)) 102 /* %1 */ "z"(address-GBR))
103
104#elif CONFIG_CPU == MCF5249
105#define or_l(mask, address) \
106 asm \
107 ("or.l %0,(%1)" \
108 : \
109 : /* %0 */ "d"(mask), \
110 /* %1 */ "a"(address))
111
112#define and_l(mask, address) \
113 asm \
114 ("and.l %0,(%1)" \
115 : \
116 : /* %0 */ "d"(mask), \
117 /* %1 */ "a"(address))
118
119#define eor_l(mask, address) \
120 asm \
121 ("eor.l %0,(%1)" \
122 : \
123 : /* %0 */ "d"(mask), \
124 /* %1 */ "a"(address))
125
103#endif 126#endif
104 127
105#ifndef SIMULATOR 128#ifndef SIMULATOR