summaryrefslogtreecommitdiff
path: root/firmware/target/sh/archos/player
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/sh/archos/player')
-rw-r--r--firmware/target/sh/archos/player/adc-target.h35
-rw-r--r--firmware/target/sh/archos/player/backlight-target.h46
-rw-r--r--firmware/target/sh/archos/player/button-player.c76
-rw-r--r--firmware/target/sh/archos/player/button-target.h52
-rw-r--r--firmware/target/sh/archos/player/hwcompat-player.c28
-rw-r--r--firmware/target/sh/archos/player/lcd-as-player.S274
-rw-r--r--firmware/target/sh/archos/player/lcd-player.c213
-rw-r--r--firmware/target/sh/archos/player/power-player.c84
-rw-r--r--firmware/target/sh/archos/player/powermgmt-player.c64
-rw-r--r--firmware/target/sh/archos/player/usb-player.c44
10 files changed, 0 insertions, 916 deletions
diff --git a/firmware/target/sh/archos/player/adc-target.h b/firmware/target/sh/archos/player/adc-target.h
deleted file mode 100644
index a26f79de28..0000000000
--- a/firmware/target/sh/archos/player/adc-target.h
+++ /dev/null
@@ -1,35 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 by Linus Nielsen Feltzing
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21#ifndef _ADC_TARGET_H_
22#define _ADC_TARGET_H_
23
24#define NUM_ADC_CHANNELS 8
25
26#define ADC_BUTTON_LEFT 0
27#define ADC_BUTTON_MENU 1
28#define ADC_BUTTON_RIGHT 2
29#define ADC_BUTTON_PLAY 3
30#define ADC_UNREG_POWER 6 /* Battery voltage with a better scaling */
31#define ADC_EXT_POWER 7 /* The external power voltage, 0v or 2.7v */
32
33#define EXT_SCALE_FACTOR 14800
34
35#endif /* _ADC_TARGET_H_ */
diff --git a/firmware/target/sh/archos/player/backlight-target.h b/firmware/target/sh/archos/player/backlight-target.h
deleted file mode 100644
index b97d21a40f..0000000000
--- a/firmware/target/sh/archos/player/backlight-target.h
+++ /dev/null
@@ -1,46 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2007 by Jens Arnold
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21#ifndef BACKLIGHT_TARGET_H
22#define BACKLIGHT_TARGET_H
23
24#include "config.h"
25#include "cpu.h"
26
27static inline bool backlight_hw_init(void)
28{
29 PACR1 &= ~0x3000; /* Set PA14 (backlight control) to GPIO */
30 and_b(~0x40, &PADRH); /* drive and set low */
31 or_b(0x40, &PAIORH); /* ..and output */
32 return true;
33}
34
35static inline void backlight_hw_on(void)
36{
37 and_b(~0x40, &PADRH); /* drive and set low */
38 or_b(0x40, &PAIORH);
39}
40
41static inline void backlight_hw_off(void)
42{
43 and_b(~0x40, &PAIORH); /* let it float (up) */
44}
45
46#endif
diff --git a/firmware/target/sh/archos/player/button-player.c b/firmware/target/sh/archos/player/button-player.c
deleted file mode 100644
index 3cf634853e..0000000000
--- a/firmware/target/sh/archos/player/button-player.c
+++ /dev/null
@@ -1,76 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2006 by Jens Arnold
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#include "config.h"
23#include "system.h"
24#include "button.h"
25#include "backlight.h"
26#include "adc.h"
27
28/*
29 Player hardware button hookup
30 =============================
31
32 Player
33 ------
34 LEFT: AN0
35 MENU: AN1
36 RIGHT: AN2
37 PLAY: AN3
38
39 STOP: PA11
40 ON: PA5
41
42 All buttons are low active
43*/
44
45void button_init_device(void)
46{
47 /* set PA5 and PA11 as input pins */
48 PACR1 &= 0xff3f; /* PA11MD = 00 */
49 PACR2 &= 0xfbff; /* PA5MD = 0 */
50 PAIOR &= ~0x0820; /* Inputs */
51}
52
53int button_read_device(void)
54{
55 int btn = BUTTON_NONE;
56 int data;
57
58 /* buttons are active low */
59 if (adc_read(ADC_BUTTON_LEFT) < 0x180)
60 btn = BUTTON_LEFT;
61 if (adc_read(ADC_BUTTON_MENU) < 0x180)
62 btn |= BUTTON_MENU;
63 if (adc_read(ADC_BUTTON_RIGHT) < 0x180)
64 btn |= BUTTON_RIGHT;
65 if (adc_read(ADC_BUTTON_PLAY) < 0x180)
66 btn |= BUTTON_PLAY;
67
68 /* check port A pins for ON and STOP */
69 data = PADR;
70 if ( !(data & 0x0020) )
71 btn |= BUTTON_ON;
72 if ( !(data & 0x0800) )
73 btn |= BUTTON_STOP;
74
75 return btn;
76}
diff --git a/firmware/target/sh/archos/player/button-target.h b/firmware/target/sh/archos/player/button-target.h
deleted file mode 100644
index dd85d731be..0000000000
--- a/firmware/target/sh/archos/player/button-target.h
+++ /dev/null
@@ -1,52 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2006 by Jens Arnold
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#ifndef _BUTTON_TARGET_H_
23#define _BUTTON_TARGET_H_
24
25#define HAS_SERIAL_REMOTE
26
27 /* Main unit's buttons */
28#define BUTTON_ON 0x00000001
29#define BUTTON_STOP 0x00000002
30
31#define BUTTON_LEFT 0x00000004
32#define BUTTON_RIGHT 0x00000008
33#define BUTTON_PLAY 0x00000010
34#define BUTTON_MENU 0x00000020
35
36#define BUTTON_MAIN (BUTTON_ON|BUTTON_STOP|BUTTON_LEFT|BUTTON_RIGHT\
37 |BUTTON_PLAY|BUTTON_MENU)
38
39 /* Remote control's buttons */
40#define BUTTON_RC_PLAY 0x00100000
41#define BUTTON_RC_STOP 0x00080000
42
43#define BUTTON_RC_LEFT 0x00040000
44#define BUTTON_RC_RIGHT 0x00020000
45#define BUTTON_RC_VOL_UP 0x00010000
46#define BUTTON_RC_VOL_DOWN 0x00008000
47
48#define BUTTON_REMOTE (BUTTON_RC_PLAY|BUTTON_RC_STOP\
49 |BUTTON_RC_LEFT|BUTTON_RC_RIGHT\
50 |BUTTON_RC_VOL_UP|BUTTON_RC_VOL_DOWN)
51
52#endif /* _BUTTON_TARGET_H_ */
diff --git a/firmware/target/sh/archos/player/hwcompat-player.c b/firmware/target/sh/archos/player/hwcompat-player.c
deleted file mode 100644
index 49a333d708..0000000000
--- a/firmware/target/sh/archos/player/hwcompat-player.c
+++ /dev/null
@@ -1,28 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 by Linus Nielsen Feltzing
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#include <stdbool.h>
23#include "hwcompat.h"
24
25bool is_new_player(void)
26{
27 return (ROM_VERSION > 449) || (ROM_VERSION == 116);
28}
diff --git a/firmware/target/sh/archos/player/lcd-as-player.S b/firmware/target/sh/archos/player/lcd-as-player.S
deleted file mode 100644
index 19f812c1c7..0000000000
--- a/firmware/target/sh/archos/player/lcd-as-player.S
+++ /dev/null
@@ -1,274 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2004 by Jens Arnold
11 * Based on the work of Alan Korr and Jörg Hohensohn
12 *
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation; either version 2
16 * of the License, or (at your option) any later version.
17 *
18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 * KIND, either express or implied.
20 *
21 ****************************************************************************/
22
23#include "config.h"
24#include "cpu.h"
25
26#define LCDR (PBDR_ADDR+1)
27
28#define LCD_DS 1 /* PB0 = 1 --- 0001 --- LCD-DS */
29#define LCD_CS 2 /* PB1 = 1 --- 0010 --- /LCD-CS */
30#define LCD_SD 4 /* PB2 = 1 --- 0100 --- LCD-SD */
31#define LCD_SC 8 /* PB3 = 1 --- 1000 --- LCD-SC */
32
33/*
34 * About /CS,DS,SC,SD
35 * ------------------
36 *
37 * LCD on JBP and JBR uses a SPI protocol to receive orders (SDA and SCK lines)
38 *
39 * - /CS -> Chip Selection line :
40 * 0 : LCD chipset is activated.
41 * - DS -> Data Selection line, latched at the rising edge
42 * of the 8th serial clock (*) :
43 * 0 : instruction register,
44 * 1 : data register;
45 * - SC -> Serial Clock line (SDA).
46 * - SD -> Serial Data line (SCK), latched at the rising edge
47 * of each serial clock (*).
48 *
49 * _ _
50 * /CS \ /
51 * \______________________________________________________/
52 * _____ ____ ____ ____ ____ ____ ____ ____ ____ _____
53 * SD \/ D7 \/ D6 \/ D5 \/ D4 \/ D3 \/ D2 \/ D1 \/ D0 \/
54 * _____/\____/\____/\____/\____/\____/\____/\____/\____/\_____
55 *
56 * _____ _ _ _ _ _ _ _ ________
57 * SC \ * \ * \ * \ * \ * \ * \ * \ *
58 * \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/
59 * _ _________________________________________________________
60 * DS \/
61 * _/\_________________________________________________________
62 *
63 */
64
65 .section .icode,"ax",@progbits
66
67 .align 2
68 .global _lcd_write_command
69 .type _lcd_write_command,@function
70
71/* Write a command byte to the lcd controller
72 *
73 * Arguments:
74 * r4 - command byte (int)
75 *
76 * Register usage:
77 * r0 - scratch
78 * r1 - command byte (copied)
79 * r2 - precalculated port value (CS, DS and SC low, SD high)
80 * r3 - lcd port address
81 * r5 - 1 (byte count for reuse of the loop in _lcd_write_data)
82 */
83
84_lcd_write_command:
85 mov.l .lcdr, r3 /* put lcd data port address in r3 */
86 mov r4, r1 /* copy data byte to r1 */
87 mov #0, r5 /* fake end address - stop after first iteration */
88
89 /* This code will fail if an interrupt changes the contents of PBDRL.
90 * If so, we must disable the interrupt here. */
91
92 mov.b @r3, r0 /* r0 = PBDRL */
93 or #(LCD_SD), r0 /* r0 |= LCD_SD */
94 and #(~(LCD_CS|LCD_DS|LCD_SC)),r0 /* r0 &= ~(LCD_CS|LCD_DS|LCD_SC) */
95
96 bra .single_transfer /* jump into the transfer loop */
97 mov r0, r2
98
99
100 .align 2
101 .global _lcd_write_command_e
102 .type _lcd_write_command_e,@function
103
104/* Write a command byte and a data byte to the lcd controller
105 *
106 * Arguments:
107 * r4 - command byte
108 * r5 - data byte
109 *
110 * Register usage:
111 * r0 - scratch
112 * r1 - command/data byte (copied)
113 * r2 - precalculated port value (CS, DS and SC low, SD high)
114 * r3 - lcd port address
115 * r5 - fake end address
116 * r6 - data byte (saved)
117 * r7 - saved pr
118 */
119
120_lcd_write_command_e:
121 mov.l .lcdr, r3 /* put lcd data port address in r3 */
122 mov r4, r1 /* copy data byte to r1 */
123 mov r5, r6
124 mov #0, r5 /* fake end address - stop after first iteration */
125
126 /* This code will fail if an interrupt changes the contents of PBDRL.
127 * If so, we must disable the interrupt here. */
128
129 mov.b @r3, r0 /* r0 = PBDRL */
130 or #(LCD_SD), r0 /* r0 |= LCD_SD */
131 and #(~(LCD_CS|LCD_DS|LCD_SC)),r0 /* r0 &= ~(LCD_CS|LCD_DS|LCD_SC) */
132
133 sts pr, r7
134 bsr .single_transfer /* jump into the transfer loop */
135 mov r0, r2
136
137 lds r7, pr
138 mov r6, r1
139 or #(LCD_DS|LCD_SD), r0 /* r0 |= LCD_DS|LCD_SD */
140 and #(~(LCD_CS|LCD_SC)), r0 /* r0 &= ~(LCD_CS|LCD_SC) */
141 bra .single_transfer /* jump into the transfer loop */
142 mov r0, r2
143
144
145 .align 2
146 .global _lcd_write_data
147 .type _lcd_write_data,@function
148
149
150/* A high performance function to write data to the display,
151 * one or multiple bytes.
152 *
153 * Arguments:
154 * r4 - data address
155 * r5 - byte count
156 *
157 * Register usage:
158 * r0 - scratch
159 * r1 - current data byte
160 * r2 - precalculated port value (CS and SC low, DS and SD high)
161 * r3 - lcd port address
162 * r4 - current address
163 * r5 - end address
164 */
165
166_lcd_write_data:
167 mov.l .lcdr, r3 /* put lcd data port address in r3 */
168 add r4, r5 /* end address */
169
170 /* This code will fail if an interrupt changes the contents of PBDRL.
171 * If so, we must disable the interrupt here. If disabling interrupts
172 * for a long time (~9200 clks = ~830 µs for transferring 112 bytes on
173 * recorders)is undesirable, the loop has to be rewritten to
174 * disable/precalculate/transfer/enable for each iteration. However,
175 * this would significantly decrease performance. */
176
177 mov.b @r3, r0 /* r0 = PBDRL */
178 or #(LCD_DS|LCD_SD), r0 /* r0 |= LCD_DS|LCD_SD */
179 and #(~(LCD_CS|LCD_SC)), r0 /* r0 &= ~(LCD_CS|LCD_SC) */
180 mov r0, r2
181
182 .align 2
183.multi_transfer:
184 mov.b @r4+, r1 /* load data byte from memory */
185
186.single_transfer:
187 shll16 r1 /* shift data to most significant byte */
188 shll8 r1
189
190 shll r1 /* shift the msb into carry */
191 mov r2, r0 /* copy precalculated port value */
192 bt 1f /* data bit = 1? */
193 and #(~LCD_SD), r0 /* no: r0 &= ~LCD_SD */
1941:
195 shll r1 /* next shift here for alignment */
196 mov.b r0, @r3 /* set data to port */
197 or #(LCD_SC), r0 /* rise SC (independent of SD level) */
198 mov.b r0, @r3 /* set to port */
199
200 mov r2, r0
201 bt 1f
202 and #(~LCD_SD), r0
2031:
204 mov.b r0, @r3
205 or #(LCD_SC), r0
206 mov.b r0, @r3
207
208 shll r1
209 mov r2, r0
210 bt 1f
211 and #(~LCD_SD), r0
2121:
213 shll r1
214 mov.b r0, @r3
215 or #(LCD_SC), r0
216 mov.b r0, @r3
217
218 mov r2, r0
219 bt 1f
220 and #(~LCD_SD), r0
2211:
222 mov.b r0, @r3
223 or #(LCD_SC), r0
224 mov.b r0, @r3
225
226 shll r1
227 mov r2, r0
228 bt 1f
229 and #(~LCD_SD), r0
2301:
231 shll r1
232 mov.b r0, @r3
233 or #(LCD_SC), r0
234 mov.b r0, @r3
235
236 mov r2, r0
237 bt 1f
238 and #(~LCD_SD), r0
2391:
240 mov.b r0, @r3
241 or #(LCD_SC), r0
242 mov.b r0, @r3
243
244 shll r1
245 mov r2, r0
246 bt 1f
247 and #(~LCD_SD), r0
2481:
249 shll r1
250 mov.b r0, @r3
251 or #(LCD_SC), r0
252 mov.b r0, @r3
253
254 mov r2, r0
255 bt 1f
256 and #(~LCD_SD), r0
2571:
258 mov.b r0, @r3
259 or #(LCD_SC), r0
260 mov.b r0, @r3
261
262 cmp/hi r4, r5 /* some blocks left? */
263 bt .multi_transfer
264
265 or #(LCD_CS|LCD_DS|LCD_SD|LCD_SC),r0 /* restore port */
266 rts
267 mov.b r0, @r3
268
269 /* This is the place to reenable the interrupts, if we have disabled
270 * them. See above. */
271
272 .align 2
273.lcdr:
274 .long LCDR
diff --git a/firmware/target/sh/archos/player/lcd-player.c b/firmware/target/sh/archos/player/lcd-player.c
deleted file mode 100644
index 95b0164bf5..0000000000
--- a/firmware/target/sh/archos/player/lcd-player.c
+++ /dev/null
@@ -1,213 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2007 by Jens Arnold
11 * Based on the work of Alan Korr, Kjell Ericson and others
12 *
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation; either version 2
16 * of the License, or (at your option) any later version.
17 *
18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 * KIND, either express or implied.
20 *
21 ****************************************************************************/
22
23#include <string.h>
24#include "config.h"
25#include "system.h"
26#include "kernel.h"
27#include "hwcompat.h"
28#include "lcd.h"
29#include "lcd-charcell.h"
30
31#define OLD_LCD_DDRAM ((char)0xB0) /* Display data (characters) */
32#define OLD_LCD_CGRAM ((char)0x80) /* Character generator (patterns) */
33#define OLD_LCD_ICONRAM ((char)0xE0)
34#define OLD_LCD_CONTRAST_SET ((char)0xA8)
35#define OLD_LCD_NOP ((char)0x00)
36#define OLD_LCD_SYSTEM_SET ((char)0x60)
37#define OLD_LCD_SET_POWER_SAVE_OSC_CONTROL ((char)0x40)
38#define OLD_LCD_SET_POWER_CONTROL ((char)0x50)
39#define OLD_LCD_SET_DISPLAY_CONTROL ((char)0x30)
40
41#define NEW_LCD_DDRAM ((char)0x80) /* Display data (characters) */
42#define NEW_LCD_CGRAM ((char)0xC0) /* Character generator (patterns) */
43#define NEW_LCD_ICONRAM ((char)0x40)
44#define NEW_LCD_CONTRAST_SET ((char)0x50)
45#define NEW_LCD_NOP ((char)0x00)
46#define NEW_LCD_FUNCTION_SET ((char)0x10)
47#define NEW_LCD_SET_POWER_SAVE_OSC_CONTROL ((char)0x0c)
48#define NEW_LCD_SET_POWER_CONTROL_REG ((char)0x20)
49#define NEW_LCD_SET_DISPLAY_CONTROL ((char)0x28)
50#define NEW_LCD_SET_DOUBLE_HEIGHT ((char)0x08)
51
52#define LCD_CURSOR(x,y) ((char)(lcd_ddram+((y)*16+(x))))
53#define LCD_ICON(i) ((char)(lcd_iconram+i))
54
55static bool new_lcd;
56static char lcd_contrast_set;
57static char lcd_ddram;
58static char lcd_cgram;
59static char lcd_iconram;
60
61/* hardware configuration */
62
63int lcd_default_contrast(void)
64{
65 return 30;
66}
67
68void lcd_set_contrast(int val)
69{
70 lcd_write_command_e(lcd_contrast_set, 31 - val);
71}
72
73/* charcell specific */
74
75void lcd_double_height(bool on)
76{
77 if(new_lcd)
78 lcd_write_command(on ? (NEW_LCD_SET_DOUBLE_HEIGHT|1)
79 : NEW_LCD_SET_DOUBLE_HEIGHT);
80}
81
82void lcd_icon(int icon, bool enable)
83{
84 static const struct {
85 char pos;
86 char mask;
87 } icontab[] = {
88 { 0, 0x02}, { 0, 0x08}, { 0, 0x04}, { 0, 0x10}, /* Battery */
89 { 2, 0x04}, /* USB */
90 { 3, 0x10}, /* Play */
91 { 4, 0x10}, /* Record */
92 { 5, 0x02}, /* Pause */
93 { 5, 0x10}, /* Audio */
94 { 6, 0x02}, /* Repeat */
95 { 7, 0x01}, /* 1 */
96 { 9, 0x04}, /* Volume */
97 { 9, 0x02}, { 9, 0x01}, {10, 0x08}, {10, 0x04}, {10, 0x01}, /* Vol 1-5 */
98 {10, 0x10}, /* Param */
99 };
100 static char icon_mirror[11] = {0};
101
102 int pos, mask;
103
104 pos = icontab[icon].pos;
105 mask = icontab[icon].mask;
106
107 if (enable)
108 icon_mirror[pos] |= mask;
109 else
110 icon_mirror[pos] &= ~mask;
111
112 lcd_write_command_e(LCD_ICON(pos), icon_mirror[pos]);
113}
114
115/* device specific init */
116void lcd_init_device(void)
117{
118 unsigned char data_vector[64];
119
120 /* LCD init for cold start */
121 PBCR2 &= 0xff00; /* Set PB0..PB3 to GPIO */
122 or_b(0x0f, &PBDRL); /* ... high */
123 or_b(0x0f, &PBIORL); /* ... and output */
124
125 new_lcd = is_new_player();
126
127 if (new_lcd)
128 {
129 lcd_contrast_set = NEW_LCD_CONTRAST_SET;
130 lcd_ddram = NEW_LCD_DDRAM;
131 lcd_cgram = NEW_LCD_CGRAM;
132 lcd_iconram = NEW_LCD_ICONRAM;
133
134 lcd_write_command(NEW_LCD_FUNCTION_SET|1); /* CGRAM selected */
135 lcd_write_command_e(NEW_LCD_CONTRAST_SET, 0x08);
136 lcd_write_command(NEW_LCD_SET_POWER_SAVE_OSC_CONTROL|2);
137 /* oscillator on */
138 lcd_write_command(NEW_LCD_SET_POWER_CONTROL_REG|7);
139 /* opamp buffer + voltage booster on */
140
141 memset(data_vector, 0x20, 64);
142 lcd_write_command(NEW_LCD_DDRAM); /* Set DDRAM address */
143 lcd_write_data(data_vector, 64); /* all spaces */
144
145 memset(data_vector, 0, 64);
146 lcd_write_command(NEW_LCD_CGRAM); /* Set CGRAM address */
147 lcd_write_data(data_vector, 64); /* zero out */
148 lcd_write_command(NEW_LCD_ICONRAM); /* Set ICONRAM address */
149 lcd_write_data(data_vector, 16); /* zero out */
150
151 lcd_write_command(NEW_LCD_SET_DISPLAY_CONTROL|1); /* display on */
152 }
153 else
154 {
155 lcd_contrast_set = OLD_LCD_CONTRAST_SET;
156 lcd_ddram = OLD_LCD_DDRAM;
157 lcd_cgram = OLD_LCD_CGRAM;
158 lcd_iconram = OLD_LCD_ICONRAM;
159
160 lcd_write_command(OLD_LCD_NOP);
161 lcd_write_command(OLD_LCD_SYSTEM_SET|1); /* CGRAM selected */
162 lcd_write_command(OLD_LCD_SET_POWER_SAVE_OSC_CONTROL|2);
163 /* oscillator on */
164 lcd_write_command(OLD_LCD_SET_POWER_CONTROL|7);
165 /* voltage regulator, voltage follower and booster on */
166
167 memset(data_vector, 0x24, 13);
168 lcd_write_command(OLD_LCD_DDRAM); /* Set DDRAM address */
169 lcd_write_data(data_vector, 13); /* all spaces */
170 lcd_write_command(OLD_LCD_DDRAM + 0x10);
171 lcd_write_data(data_vector, 13);
172 lcd_write_command(OLD_LCD_DDRAM + 0x20);
173 lcd_write_data(data_vector, 13);
174
175 memset(data_vector, 0, 32);
176 lcd_write_command(OLD_LCD_CGRAM); /* Set CGRAM address */
177 lcd_write_data(data_vector, 32); /* zero out */
178 lcd_write_command(OLD_LCD_ICONRAM); /* Set ICONRAM address */
179 lcd_write_data(data_vector, 13); /* zero out */
180 lcd_write_command(OLD_LCD_ICONRAM + 0x10);
181 lcd_write_data(data_vector, 13);
182
183 sleep(HZ/10);
184 lcd_write_command(OLD_LCD_SET_DISPLAY_CONTROL|1); /* display on */
185 }
186 lcd_set_contrast(lcd_default_contrast());
187}
188
189/*** Update functions ***/
190
191void lcd_update(void)
192{
193 int y;
194
195 for (y = 0; y < lcd_pattern_count; y++)
196 {
197 if (lcd_patterns[y].count > 0)
198 {
199 lcd_write_command(lcd_cgram | (y << 3));
200 lcd_write_data(lcd_patterns[y].pattern, 7);
201 }
202 }
203 for (y = 0; y < LCD_HEIGHT; y++)
204 {
205 lcd_write_command(LCD_CURSOR(0, y));
206 lcd_write_data(lcd_charbuffer[y], LCD_WIDTH);
207 }
208 if (lcd_cursor.visible)
209 {
210 lcd_write_command_e(LCD_CURSOR(lcd_cursor.x, lcd_cursor.y),
211 lcd_cursor.hw_char);
212 }
213}
diff --git a/firmware/target/sh/archos/player/power-player.c b/firmware/target/sh/archos/player/power-player.c
deleted file mode 100644
index 33f5959021..0000000000
--- a/firmware/target/sh/archos/player/power-player.c
+++ /dev/null
@@ -1,84 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 by Linus Nielsen Feltzing
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21#include "config.h"
22#include "cpu.h"
23#include <stdbool.h>
24#include "kernel.h"
25#include "system.h"
26#include "power.h"
27#include "usb.h"
28
29void power_init(void)
30{
31}
32
33unsigned int power_input_status(void)
34{
35 /* Player */
36 return ((PADR & 1) == 0) ?
37 POWER_INPUT_MAIN_CHARGER : POWER_INPUT_NONE;
38}
39
40void ide_power_enable(bool on)
41{
42 bool touched = false;
43
44 if(on)
45 {
46 or_b(0x10, &PBDRL);
47 touched = true;
48 }
49#ifdef HAVE_ATA_POWER_OFF
50 if(!on)
51 {
52 and_b(~0x10, &PBDRL);
53 touched = true;
54 }
55#endif /* HAVE_ATA_POWER_OFF */
56
57/* late port preparation, else problems with read/modify/write
58 of other bits on same port, while input and floating high */
59 if (touched)
60 {
61 or_b(0x10, &PBIORL); /* PB4 is an output */
62 PBCR2 &= ~0x0300; /* GPIO for PB4 */
63 }
64}
65
66
67bool ide_powered(void)
68{
69 /* This is not correct for very old players, since these are unable to
70 * control hd power. However, driving the pin doesn't hurt, because it
71 * is not connected anywhere */
72 if ((PBCR2 & 0x0300) || !(PBIORL & 0x10)) /* not configured for output */
73 return false; /* would be floating low, disk off */
74 else
75 return (PBDRL & 0x10) != 0;
76}
77
78void power_off(void)
79{
80 disable_irq();
81 and_b(~0x08, &PADRH);
82 or_b(0x08, &PAIORH);
83 while(1);
84}
diff --git a/firmware/target/sh/archos/player/powermgmt-player.c b/firmware/target/sh/archos/player/powermgmt-player.c
deleted file mode 100644
index 8aa03d88a5..0000000000
--- a/firmware/target/sh/archos/player/powermgmt-player.c
+++ /dev/null
@@ -1,64 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 by Heikki Hannikainen, Uwe Freese
11 * Revisions copyright (C) 2005 by Gerald Van Baren
12 *
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation; either version 2
16 * of the License, or (at your option) any later version.
17 *
18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 * KIND, either express or implied.
20 *
21 ****************************************************************************/
22
23#include "config.h"
24#include "adc.h"
25#include "powermgmt.h"
26
27const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] =
28{
29 4750
30};
31
32const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] =
33{
34 4400
35};
36
37/* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */
38const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] =
39{
40 /* original values were taken directly after charging, but it should show
41 100% after turning off the device for some hours, too */
42 { 4500, 4810, 4910, 4970, 5030, 5070, 5120, 5140, 5170, 5250, 5400 }
43 /* orig. values: ...,5280,5600 */
44};
45
46/* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */
47const unsigned short percent_to_volt_charge[11] =
48{
49 /* values guessed, see
50 http://www.seattlerobotics.org/encoder/200210/LiIon2.pdf until someone
51 measures voltages over a charging cycle */
52 4760, 5440, 5510, 5560, 5610, 5640, 5660, 5760, 5820, 5840, 5850 /* NiMH */
53};
54
55#define BATTERY_SCALE_FACTOR 6703
56/* full-scale ADC readout (2^10) in millivolt */
57
58/* Returns battery voltage from ADC [millivolts] */
59int _battery_voltage(void)
60{
61 return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10;
62}
63
64
diff --git a/firmware/target/sh/archos/player/usb-player.c b/firmware/target/sh/archos/player/usb-player.c
deleted file mode 100644
index 76f2a2dcdd..0000000000
--- a/firmware/target/sh/archos/player/usb-player.c
+++ /dev/null
@@ -1,44 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2007 by Jens Arnold
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21#include "config.h"
22#include <stdbool.h>
23#include "cpu.h"
24#include "system.h"
25#include "usb.h"
26
27int usb_detect(void)
28{
29 return (PADR & 0x8000) ? USB_EXTRACTED : USB_INSERTED;
30}
31
32void usb_enable(bool on)
33{
34 if(on)
35 and_b(~0x04, &PADRH);
36 else
37 or_b(0x04, &PADRH);
38}
39
40void usb_init_device(void)
41{
42 or_b(0x04, &PADRH);
43 or_b(0x04, &PAIORH);
44}