summaryrefslogtreecommitdiff
path: root/firmware/target/arm/tcc77x/iaudio7
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm/tcc77x/iaudio7')
-rw-r--r--firmware/target/arm/tcc77x/iaudio7/adc-target.h28
-rw-r--r--firmware/target/arm/tcc77x/iaudio7/ata2501.c110
-rw-r--r--firmware/target/arm/tcc77x/iaudio7/ata2501.h27
-rw-r--r--firmware/target/arm/tcc77x/iaudio7/audio-iaudio7.c94
-rw-r--r--firmware/target/arm/tcc77x/iaudio7/backlight-target.h48
-rw-r--r--firmware/target/arm/tcc77x/iaudio7/button-iaudio7.c93
-rw-r--r--firmware/target/arm/tcc77x/iaudio7/button-target.h47
-rw-r--r--firmware/target/arm/tcc77x/iaudio7/lcd-iaudio7.c260
-rw-r--r--firmware/target/arm/tcc77x/iaudio7/power-iaudio7.c149
-rw-r--r--firmware/target/arm/tcc77x/iaudio7/powermgmt-iaudio7.c84
10 files changed, 0 insertions, 940 deletions
diff --git a/firmware/target/arm/tcc77x/iaudio7/adc-target.h b/firmware/target/arm/tcc77x/iaudio7/adc-target.h
deleted file mode 100644
index 1916d93598..0000000000
--- a/firmware/target/arm/tcc77x/iaudio7/adc-target.h
+++ /dev/null
@@ -1,28 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2007 Dave Chapman
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_BUTTONS 0
27
28#endif /* _ADC_TARGET_H_ */
diff --git a/firmware/target/arm/tcc77x/iaudio7/ata2501.c b/firmware/target/arm/tcc77x/iaudio7/ata2501.c
deleted file mode 100644
index f7526b2b9a..0000000000
--- a/firmware/target/arm/tcc77x/iaudio7/ata2501.c
+++ /dev/null
@@ -1,110 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2008 Vitja Makarov
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 "cpu.h"
25#include "button.h"
26
27#include "ata2501.h"
28
29#define STB (1<<5)
30#define SDATA (1<<4)
31#define RESET (1<<6)
32#define SIFMD (1<<7)
33#define STB_DELAY 200
34
35static inline void ndelay(unsigned long nsecs)
36{
37 nsecs /= 8;
38 while (nsecs)
39 nsecs--;
40}
41
42/*
43 TODO: sensitivity
44*/
45void ata2501_init(void)
46{
47 GPIOD_DIR |= (RESET | STB | SIFMD | (1 << 8) | (1 << 9));
48 GPIOD_DIR &= ~SDATA;
49
50 GPIOD &= ~STB;
51 GPIOD |= (1 << 8) | SIFMD | (1 << 9);
52
53 GPIOD &= ~RESET;
54 ndelay(1000);
55 GPIOD |= RESET;
56}
57
58unsigned short ata2501_read(void)
59{
60 unsigned short ret = 0;
61 int i;
62
63 for (i = 0; i < 12; i++) {
64 GPIOD |= STB;
65 ndelay(100);
66 ret <<= 1;
67 if (GPIOD & SDATA)
68 ret |= 1;
69 GPIOD &= ~STB;
70 ndelay(100);
71 }
72
73 return ret;
74}
75
76//#define ATA2501_TEST
77#ifdef ATA2501_TEST
78#include "lcd.h"
79
80static
81void bits(char *str, unsigned short val)
82{
83 int i;
84
85 for (i = 0; i < 12; i++)
86 str[i] = (val & (1 << i)) ? '1' : '0';
87 str[i] = 0;
88}
89
90void ata2501_test(void)
91{
92 char buf[100];
93 ata2501_init();
94
95 while (1) {
96 unsigned short data;
97 int line = 0;
98
99 data = ata2501_read();
100 lcd_clear_display();
101 lcd_puts(0, line++, "ATA2501 test");
102
103 bits(buf, data);
104 lcd_puts(0, line++, buf);
105
106 lcd_update();
107 sleep(HZ/10);
108 }
109}
110#endif
diff --git a/firmware/target/arm/tcc77x/iaudio7/ata2501.h b/firmware/target/arm/tcc77x/iaudio7/ata2501.h
deleted file mode 100644
index 465d0b199c..0000000000
--- a/firmware/target/arm/tcc77x/iaudio7/ata2501.h
+++ /dev/null
@@ -1,27 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2008 Vitja Makarov
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 _ATA2501_H_
22#define _ATA2501_H_
23
24void ata2501_init(void);
25unsigned short ata2501_read(void);
26
27#endif /* _ATA2501_H_ */
diff --git a/firmware/target/arm/tcc77x/iaudio7/audio-iaudio7.c b/firmware/target/arm/tcc77x/iaudio7/audio-iaudio7.c
deleted file mode 100644
index bcb6843286..0000000000
--- a/firmware/target/arm/tcc77x/iaudio7/audio-iaudio7.c
+++ /dev/null
@@ -1,94 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2007 by Michael Sevakis
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 "system.h"
22#include "cpu.h"
23#include "audio.h"
24#include "sound.h"
25
26int audio_channels = 2;
27int audio_output_source = AUDIO_SRC_PLAYBACK;
28
29void audio_set_output_source(int source)
30{
31 int oldmode = set_fiq_status(FIQ_DISABLED);
32
33 if ((unsigned)source >= AUDIO_NUM_SOURCES)
34 source = AUDIO_SRC_PLAYBACK;
35
36 audio_output_source = source;
37 set_fiq_status(oldmode);
38}
39
40void audio_input_mux(int source, unsigned flags)
41{
42 static int last_source = AUDIO_SRC_PLAYBACK;
43 static bool last_recording = false;
44 bool recording = flags & SRCF_RECORDING;
45
46 switch (source)
47 {
48 default: /* playback - no recording */
49 source = AUDIO_SRC_PLAYBACK;
50 case AUDIO_SRC_PLAYBACK:
51 audio_channels = 2;
52 if (source != last_source)
53 {
54 audiohw_set_monitor(false);
55 /* audiohw_disable_recording();*/
56 }
57 break;
58
59 case AUDIO_SRC_MIC: /* recording only */
60 GPIOD |= 0x1;
61
62 audio_channels = 1;
63 if (source != last_source)
64 {
65 /*audiohw_set_monitor(false);
66 audiohw_enable_recording(true); /. source mic */
67 }
68 break;
69
70 case AUDIO_SRC_FMRADIO: /* recording and playback */
71 GPIOD &= ~0x1;
72
73 audio_channels = 2;
74
75 if (source == last_source && recording == last_recording)
76 break;
77
78 last_recording = recording;
79
80 if (recording)
81 {
82 /*audiohw_set_monitor(false);
83 audiohw_enable_recording(false);*/
84 }
85 else
86 {
87 /*audiohw_disable_recording(); */
88 audiohw_set_monitor(true); /* line 1 analog audio path */
89 }
90 break;
91 } /* end switch */
92
93 last_source = source;
94} /* audio_input_mux */
diff --git a/firmware/target/arm/tcc77x/iaudio7/backlight-target.h b/firmware/target/arm/tcc77x/iaudio7/backlight-target.h
deleted file mode 100644
index 0b227cd11c..0000000000
--- a/firmware/target/arm/tcc77x/iaudio7/backlight-target.h
+++ /dev/null
@@ -1,48 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2008 Vitja Makarov
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 <stdbool.h>
25#include "tcc77x.h"
26
27void power_touch_panel(bool on);
28
29static inline bool backlight_hw_init(void)
30{
31 GPIOD_DIR |= 0x2;
32 /* set backlight on by default, since the screen is unreadable without it */
33 GPIOD |= 0x2;
34 return true;
35}
36
37static inline void backlight_hw_on(void)
38{
39 GPIOD |= 0x2;
40 power_touch_panel(true);
41}
42
43static inline void backlight_hw_off(void)
44{
45 GPIOD &= ~0x2;
46 power_touch_panel(false);
47}
48#endif /* BACKLIGHT_TARGET_H */
diff --git a/firmware/target/arm/tcc77x/iaudio7/button-iaudio7.c b/firmware/target/arm/tcc77x/iaudio7/button-iaudio7.c
deleted file mode 100644
index abf31b4feb..0000000000
--- a/firmware/target/arm/tcc77x/iaudio7/button-iaudio7.c
+++ /dev/null
@@ -1,93 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2008 Vitja Makarov
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 "button.h"
24#include "backlight.h"
25#include "adc.h"
26
27#include "button-target.h"
28#include "ata2501.h"
29
30void button_init_device(void)
31{
32 ata2501_init();
33}
34
35/*
36 touchpad:
37 0: stop
38 1-8: between next & prev
39 9: play
40 10: next
41 11: prev
42*/
43
44int button_read_device(void)
45{
46 static bool hold_button = false;
47 bool hold_button_old;
48
49 int btn = BUTTON_NONE;
50 int adc;
51 int sensor;
52
53 hold_button_old = hold_button;
54 hold_button = button_hold();
55
56#ifndef BOOTLOADER
57 if (hold_button != hold_button_old)
58 backlight_hold_changed(hold_button);
59#endif
60
61 if (button_hold())
62 return BUTTON_NONE;
63
64 adc = adc_read(0);
65 sensor = ata2501_read();
66
67 if (0 == (GPIOA & 4))
68 btn |= BUTTON_POWER;
69
70 /* seems they can't be hold together */
71 if (adc < 0x120)
72 btn |= BUTTON_VOLUP;
73 else if (adc < 0x270)
74 btn |= BUTTON_VOLDOWN;
75 else if (adc < 0x300)
76 btn |= BUTTON_MENU;
77
78 if (sensor & (1 << 0))
79 btn |= BUTTON_STOP;
80 if (sensor & (1 << 9))
81 btn |= BUTTON_PLAY;
82 if (sensor & ((1 << 10) | 0x1c0))
83 btn |= BUTTON_RIGHT;
84 if (sensor & ((1 << 11) | 0xe))
85 btn |= BUTTON_LEFT;
86
87 return btn;
88}
89
90bool button_hold(void)
91{
92 return !(GPIOA & 0x2);
93}
diff --git a/firmware/target/arm/tcc77x/iaudio7/button-target.h b/firmware/target/arm/tcc77x/iaudio7/button-target.h
deleted file mode 100644
index 9d232d9ae8..0000000000
--- a/firmware/target/arm/tcc77x/iaudio7/button-target.h
+++ /dev/null
@@ -1,47 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2008 Vitja Makarov
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 _IAUDIO7_BUTTON_TARGET_H_
22#define _IAUDIO7_BUTTON_TARGET_H_
23
24#define HAS_BUTTON_HOLD
25
26/* Main unit's buttons */
27#define BUTTON_POWER 0x00000001
28#define BUTTON_VOLUP 0x00000002
29#define BUTTON_VOLDOWN 0x00000004
30#define BUTTON_MENU 0x00000008
31
32#define BUTTON_LEFT 0x00000010
33#define BUTTON_RIGHT 0x00000020
34#define BUTTON_PLAY 0x00000040
35#define BUTTON_STOP 0x00000080
36
37#define BUTTON_ON BUTTON_POWER
38
39#define BUTTON_MAIN (BUTTON_POWER|BUTTON_VOLUP|BUTTON_VOLDOWN| \
40 BUTTON_MENU|BUTTON_LEFT|BUTTON_RIGHT| \
41 BUTTON_PLAY|BUTTON_STOP)
42
43/* Software power-off */
44#define POWEROFF_BUTTON BUTTON_POWER
45#define POWEROFF_COUNT 10
46
47#endif /* _IAUDIO7_BUTTON_TARGET_H_ */
diff --git a/firmware/target/arm/tcc77x/iaudio7/lcd-iaudio7.c b/firmware/target/arm/tcc77x/iaudio7/lcd-iaudio7.c
deleted file mode 100644
index e681e1eff7..0000000000
--- a/firmware/target/arm/tcc77x/iaudio7/lcd-iaudio7.c
+++ /dev/null
@@ -1,260 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2004 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/*
23 Thanks Hein-Pieter van Braam for initial work.
24
25 Mostly based on lcd-h300.c, adapted for the iaudio 7 by Vitja Makarov
26 */
27
28#include <config.h>
29
30#include <kernel.h>
31#include <cpu.h>
32#include <lcd.h>
33#include <system-target.h>
34#include <panic.h>
35
36#include "hd66789r.h"
37
38static bool display_on = false; /* is the display turned on? */
39
40static inline void lcd_write_reg(int reg, int data)
41{
42 GPIOA &= ~0x400;
43 outw(0, 0x50010000);
44 outw(reg << 1, 0x50010000);
45 GPIOA |= 0x400;
46
47 outw((data & 0xff00) >> 7, 0x50010008);
48 outw((data << 24) >> 23, 0x50010008);
49}
50
51static void lcd_write_cmd(int reg)
52{
53 GPIOA &= ~0x400;
54 outw(0, 0x50010000);
55 outw(reg << 1, 0x50010000);
56 GPIOA |= 0x400;
57}
58
59/* Do what OF do */
60static void lcd_delay(int x)
61{
62 int i;
63
64 x *= 0xc35;
65 for (i = 0; i < x * 8; i++) {
66 }
67}
68
69
70static void _display_on(void)
71{
72 GPIOA_DIR |= 0x8000 | 0x400;
73 GPIOA |= 0x8000;
74
75 /* power setup */
76 lcd_write_reg(R_START_OSC, 0x0001);
77 lcd_delay(0xf);
78 lcd_write_reg(R_DISP_CONTROL1, 0x000);
79 lcd_delay(0xa);
80 lcd_write_reg(R_POWER_CONTROL2, 0x0002);
81 lcd_write_reg(R_POWER_CONTROL3, 0x000a);
82 lcd_write_reg(R_POWER_CONTROL4, 0xc5a);
83 lcd_write_reg(R_POWER_CONTROL1, 0x0004);
84 lcd_write_reg(R_POWER_CONTROL1, 0x0134);
85 lcd_write_reg(R_POWER_CONTROL2, 0x0111);
86 lcd_write_reg(R_POWER_CONTROL3, 0x001c);
87 lcd_delay(0x28);
88 lcd_write_reg(R_POWER_CONTROL4, 0x2c40);
89 lcd_write_reg(R_POWER_CONTROL1, 0x0510);
90 lcd_delay(0x3c);
91
92 /* lcd init 2 */
93 lcd_write_reg(R_DRV_OUTPUT_CONTROL, 0x0113);
94 lcd_write_reg(R_DRV_WAVEFORM_CONTROL, 0x0700);
95 lcd_write_reg(R_ENTRY_MODE, 0x1038);
96 lcd_write_reg(R_DISP_CONTROL2, 0x0508); // 0x3c8, TMM
97 lcd_write_reg(R_DISP_CONTROL3, 0x0000);
98 lcd_write_reg(R_FRAME_CYCLE_CONTROL, 0x0003);
99 lcd_write_reg(R_RAM_ADDR_SET, 0x0000);
100 lcd_write_reg(R_GAMMA_FINE_ADJ_POS1, 0x0406);
101 lcd_write_reg(R_GAMMA_FINE_ADJ_POS2, 0x0303);
102 lcd_write_reg(R_GAMMA_FINE_ADJ_POS3, 0x0000);
103 lcd_write_reg(R_GAMMA_GRAD_ADJ_POS, 0x0305);
104 lcd_write_reg(R_GAMMA_FINE_ADJ_NEG1, 0x0404);
105 lcd_write_reg(R_GAMMA_FINE_ADJ_NEG2, 0x0000);
106 lcd_write_reg(R_GAMMA_FINE_ADJ_NEG3, 0x0000);
107 lcd_write_reg(R_GAMMA_GRAD_ADJ_NEG, 0x0503);
108 lcd_write_reg(R_GAMMA_AMP_ADJ_RES_POS, 0x1d05);
109 lcd_write_reg(R_GAMMA_AMP_AVG_ADJ_RES_NEG, 0x1d05);
110 lcd_write_reg(R_VERT_SCROLL_CONTROL, 0x0000);
111 lcd_write_reg(R_1ST_SCR_DRV_POS, 0x9f00);
112 lcd_write_reg(R_2ND_SCR_DRV_POS, 0x9f00);
113 lcd_write_reg(R_HORIZ_RAM_ADDR_POS, 0x7f00);
114 lcd_write_reg(R_VERT_RAM_ADDR_POS, 0x9f00);
115
116 /* lcd init 3 */
117 lcd_write_reg(R_POWER_CONTROL1, 0x4510);
118 lcd_write_reg(R_DISP_CONTROL1, 0x0005);
119 lcd_delay(0x28);
120 lcd_write_reg(R_DISP_CONTROL1, 0x0025);
121 lcd_write_reg(R_DISP_CONTROL1, 0x0027);
122 lcd_delay(0x28);
123 lcd_write_reg(R_DISP_CONTROL1, 0x0037);
124
125 display_on = true;
126}
127
128void lcd_init_device(void)
129{
130 /* Configure external memory banks */
131 CSCFG1 = 0x0d500023 | tcc77x_cscfg_bw(TCC77X_CSCFG_BW16);
132
133 /* may be reset */
134 GPIOA |= 0x8000;
135
136 _display_on();
137}
138
139void lcd_enable(bool on)
140{
141 if (display_on == on)
142 return;
143
144 if (on) {
145 _display_on();
146 send_event(LCD_EVENT_ACTIVATION, NULL);
147 } else {
148 /** Off sequence according to datasheet, p. 130 **/
149 lcd_write_reg(R_FRAME_CYCLE_CONTROL, 0x0002); /* EQ=0, 18 clks/line */
150 lcd_write_reg(R_DISP_CONTROL1, 0x0036); /* GON=1, DTE=1, REV=1, D1-0=10 */
151 sleep(2);
152
153 lcd_write_reg(R_DISP_CONTROL1, 0x0026); /* GON=1, DTE=0, REV=1, D1-0=10 */
154 sleep(2);
155
156 lcd_write_reg(R_DISP_CONTROL1, 0x0000); /* GON=0, DTE=0, D1-0=00 */
157
158 lcd_write_reg(R_POWER_CONTROL1, 0x0000); /* SAP2-0=000, AP2-0=000 */
159 lcd_write_reg(R_POWER_CONTROL3, 0x0000); /* PON=0 */
160 lcd_write_reg(R_POWER_CONTROL4, 0x0000); /* VCOMG=0 */
161
162 /* datasheet p. 131 */
163 lcd_write_reg(R_POWER_CONTROL1, 0x0001); /* STB=1: standby mode */
164
165 display_on = false;
166 }
167}
168
169bool lcd_active(void)
170{
171 return display_on;
172}
173
174
175#define RGB(r,g,b) ((((r)&0x3f) << 12)|(((g)&0x3f) << 6)|(((b)&0x3f)))
176
177
178void lcd_update(void)
179{
180 lcd_update_rect(0, 0, LCD_WIDTH, LCD_HEIGHT);
181}
182
183/* todo: need tests */
184void lcd_update_rect(int sx, int sy, int width, int height)
185{
186 int x, y;
187
188 if (!display_on)
189 return;
190
191 if (width <= 0 || height <= 0) /* nothing to do */
192 return;
193
194 width += sx;
195 height += sy;
196
197 if (width > LCD_WIDTH)
198 width = LCD_WIDTH;
199 if (height > LCD_HEIGHT)
200 height = LCD_HEIGHT;
201
202 lcd_write_reg(R_ENTRY_MODE, 0x1028);
203 /* set update window */
204 lcd_write_reg(R_HORIZ_RAM_ADDR_POS, (LCD_HEIGHT - 1) << 8);
205 lcd_write_reg(R_VERT_RAM_ADDR_POS, ((width - 1) << 8) | sx);
206 lcd_write_reg(R_RAM_ADDR_SET, (sx << 8) | (LCD_HEIGHT - sy - 1));
207 lcd_write_cmd(R_WRITE_DATA_2_GRAM);
208
209 for (y = sy; y < height; y++) {
210 for (x = sx; x < width; x++) {
211 fb_data c;
212 unsigned long color;
213
214 c = *FBADDR(x,y);
215 color =
216 ((c & 0x1f) << 1) | ((c & 0x7e0) << 1) | ((c & 0xf800) <<
217 2);
218
219 /* TODO: our color is 18-bit */
220 outw((color >> 9) & 0x1ff, 0x50010008);
221 outw((color) & 0x1ff, 0x50010008);
222 }
223 }
224}
225
226void lcd_set_contrast(int val)
227{
228 (void) val;
229}
230
231void lcd_set_invert_display(bool yesno)
232{
233 (void) yesno;
234}
235
236void lcd_set_flip(bool yesno)
237{
238 (void) yesno;
239}
240
241/* TODO: implement me */
242void lcd_blit_yuv(unsigned char *const src[3],
243 int src_x, int src_y, int stride,
244 int x, int y, int width, int height)
245{
246 (void) src;
247 (void) src_x;
248 (void) src_y;
249 (void) stride;
250 (void) x;
251 (void) y;
252
253 if (!display_on)
254 return;
255
256 width &= ~1; /* stay on the safe side */
257 height &= ~1;
258
259 panicf("%s", __func__);
260}
diff --git a/firmware/target/arm/tcc77x/iaudio7/power-iaudio7.c b/firmware/target/arm/tcc77x/iaudio7/power-iaudio7.c
deleted file mode 100644
index baf93b73aa..0000000000
--- a/firmware/target/arm/tcc77x/iaudio7/power-iaudio7.c
+++ /dev/null
@@ -1,149 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2008 Vitja Makarov
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 <stdbool.h>
22
23#include "config.h"
24#include "cpu.h"
25#include "kernel.h"
26#include "system.h"
27#include "power.h"
28#include "backlight-target.h"
29
30#include "pcf50606.h"
31
32void power_init(void)
33{
34 pcf50606_write(PCF5060X_DCDC1, 0x90);
35 pcf50606_write(PCF5060X_DCDC2, 0x48);
36 pcf50606_write(PCF5060X_DCDC3, 0xfc);
37 pcf50606_write(PCF5060X_DCDC4, 0xb1);
38
39 pcf50606_write(PCF5060X_IOREGC, 0xe9);
40 /* 3.3V, touch-panel */
41 pcf50606_write(PCF5060X_D1REGC1, 0xf8);
42 pcf50606_write(PCF5060X_D2REGC1, 0xf2);
43 pcf50606_write(PCF5060X_D3REGC1, 0xf5);
44
45 pcf50606_write(PCF5060X_LPREGC1, 0x00);
46 pcf50606_write(PCF5060X_LPREGC2, 0x02);
47
48 pcf50606_write(PCF5060X_DCUDC1, 0xe6);
49 pcf50606_write(PCF5060X_DCUDC2, 0x30);
50
51 pcf50606_write(PCF5060X_DCDEC1, 0xe7);
52 pcf50606_write(PCF5060X_DCDEC2, 0x02);
53
54 pcf50606_write(PCF5060X_INT1M, 0x5b);
55 pcf50606_write(PCF5060X_INT1M, 0xaf);
56 pcf50606_write(PCF5060X_INT1M, 0x8f);
57
58 pcf50606_write(PCF5060X_OOCC1, 0x40);
59 pcf50606_write(PCF5060X_OOCC2, 0x05);
60
61 pcf50606_write(PCF5060X_MBCC3, 0x3a);
62 pcf50606_write(PCF5060X_GPOC1, 0x00);
63 pcf50606_write(PCF5060X_BBCC, 0xf8);
64}
65
66/* Control leds on ata2501 board */
67void power_touch_panel(bool on)
68{
69 if (on)
70 pcf50606_write(PCF5060X_D1REGC1, 0xf8);
71 else
72 pcf50606_write(PCF5060X_D1REGC1, 0x00);
73}
74
75void ide_power_enable(bool on)
76{
77 (void) on;
78}
79
80bool ide_powered(void)
81{
82 return true;
83}
84
85void power_off(void)
86{
87 /* Forcibly cut power to SoC & peripherals by putting the PCF to sleep */
88 pcf50606_write(PCF5060X_OOCC1, GOSTDBY | CHGWAK | EXTONWAK);
89}
90
91#if CONFIG_TUNER
92#include "tuner.h"
93
94/** Tuner **/
95static bool powered = false;
96
97#define TUNNER_CLK (1 << 5)
98#define TUNNER_DATA (1 << 6)
99#define TUNNER_NR_W (1 << 7)
100
101bool tuner_power(bool status)
102{
103 bool old_status;
104 lv24020lp_lock();
105
106 old_status = powered;
107
108 if (status != old_status)
109 {
110 if (status)
111 {
112 /* When power up, host should initialize the 3-wire bus
113 in host read mode: */
114
115 /* 1. Set direction of the DATA-line to input-mode. */
116 GPIOA_DIR &= ~TUNNER_DATA;
117
118 /* 2. Drive NR_W low */
119 GPIOA &= ~TUNNER_NR_W;
120 GPIOA_DIR |= TUNNER_NR_W;
121
122 /* 3. Drive CLOCK high */
123 GPIOA |= TUNNER_CLK;
124 GPIOA_DIR |= TUNNER_CLK;
125
126 lv24020lp_power(true);
127 }
128 else
129 {
130 lv24020lp_power(false);
131
132 /* set all as inputs */
133 GPIOC_DIR &= ~(TUNNER_CLK | TUNNER_DATA | TUNNER_NR_W);
134 }
135
136 powered = status;
137 }
138
139 lv24020lp_unlock();
140 return old_status;
141}
142
143#endif /* CONFIG_TUNER */
144
145unsigned int power_input_status(void)
146{
147 return (GPIOA & 0x1) ?
148 POWER_INPUT_MAIN_CHARGER : POWER_INPUT_NONE;
149}
diff --git a/firmware/target/arm/tcc77x/iaudio7/powermgmt-iaudio7.c b/firmware/target/arm/tcc77x/iaudio7/powermgmt-iaudio7.c
deleted file mode 100644
index bc7ead61f0..0000000000
--- a/firmware/target/arm/tcc77x/iaudio7/powermgmt-iaudio7.c
+++ /dev/null
@@ -1,84 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id: powermgmt-cowond2.c 17847 2008-06-28 18:10:04Z bagder $
9 *
10 * Copyright (C) 2007 by Karl Kurbjun
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 "adc.h"
24#include "powermgmt.h"
25#include "kernel.h"
26#include "pcf50606.h"
27
28unsigned short current_voltage = 5150;
29
30const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] =
31{
32 /* FIXME: calibrate value */
33 4400
34};
35
36const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] =
37{
38 /* FIXME: calibrate value */
39 4600
40};
41
42/* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */
43const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] =
44{
45 /* FIXME: calibrate values. Table is "inherited" from iPod-PCF / H100 */
46 { 4500, 4810, 4910, 4970, 5030, 5070, 5120, 5140, 5170, 5250, 5400 }
47};
48
49#if CONFIG_CHARGING
50/* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */
51const unsigned short percent_to_volt_charge[11] =
52{
53 /* FIXME: calibrate values. Table is "inherited" from iPod-PCF / H100 */
54 4760, 5440, 5510, 5560, 5610, 5640, 5660, 5760, 5820, 5840, 5850 /* NiMH */
55};
56#endif /* CONFIG_CHARGING */
57
58#define BATTERY_SCALE_FACTOR 6000
59/* full-scale ADC readout (2^10) in millivolt */
60
61/* Returns battery voltage from ADC [millivolts] */
62int _battery_voltage(void)
63{
64 static unsigned last_tick = 0;
65
66 if (0 == last_tick || TIME_BEFORE(last_tick+HZ, current_tick))
67 {
68 int adc_val, irq_status;
69 unsigned char buf[2];
70
71 irq_status = disable_irq_save();
72 pcf50606_write(PCF5060X_ADCC2, 0x1);
73 pcf50606_read_multiple(PCF5060X_ADCS1, buf, 2);
74 restore_interrupt(irq_status);
75
76 adc_val = (buf[0]<<2) | (buf[1] & 3); //ADCDAT1H+ADCDAT1L
77 current_voltage = (adc_val * BATTERY_SCALE_FACTOR) >> 10;
78
79 last_tick = current_tick;
80 }
81
82 return current_voltage;
83}
84