summaryrefslogtreecommitdiff
path: root/firmware/target/coldfire/mpio/hd200
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/coldfire/mpio/hd200')
-rw-r--r--firmware/target/coldfire/mpio/hd200/adc-hd200.c97
-rw-r--r--firmware/target/coldfire/mpio/hd200/adc-target.h41
-rw-r--r--firmware/target/coldfire/mpio/hd200/backlight-hd200.c94
-rw-r--r--firmware/target/coldfire/mpio/hd200/backlight-target.h35
-rw-r--r--firmware/target/coldfire/mpio/hd200/button-target.h68
-rw-r--r--firmware/target/coldfire/mpio/hd200/power-hd200.c130
-rw-r--r--firmware/target/coldfire/mpio/hd200/system-hd200.c125
-rw-r--r--firmware/target/coldfire/mpio/hd200/usb-hd200.c75
8 files changed, 68 insertions, 597 deletions
diff --git a/firmware/target/coldfire/mpio/hd200/adc-hd200.c b/firmware/target/coldfire/mpio/hd200/adc-hd200.c
deleted file mode 100644
index 92b9479279..0000000000
--- a/firmware/target/coldfire/mpio/hd200/adc-hd200.c
+++ /dev/null
@@ -1,97 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2010 Marcin Bukat
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 "cpu.h"
24#include "system.h"
25#include "kernel.h"
26#include "thread.h"
27#include "adc.h"
28
29volatile unsigned short adc_data[NUM_ADC_CHANNELS] IBSS_ATTR;
30
31/* Reading takes 4096 adclk ticks
32 * 1) tick task is created that enables ADC interrupt
33 * 2) On interrupt single channel is readed and
34 * ADC is prepared for next channel
35 * 3) When all 4 channels are scanned ADC interrupt is disabled
36 */
37
38void ADC(void) __attribute__ ((interrupt_handler,section(".icode")));
39void ADC(void)
40{
41 static unsigned char channel IBSS_ATTR;
42 /* read current value */
43 adc_data[(channel&0x03)] = ADVALUE;
44
45 /* switch channel
46 *
47 * set source remark
48 * ADCONFIG is 16bit wide so we have to shift data by 16bits left
49 * thats why we shift <<24 instead of <<8
50 */
51
52 channel++;
53
54 and_l(~(0x03<<24),&ADCONFIG);
55 or_l( (((channel&0x03) << 8 )|(1<<7))<<16, &ADCONFIG);
56
57 if ( (channel & 0x03) == 0 )
58 /* disable ADC interrupt */
59 and_l((~(1<<6))<<16,&ADCONFIG);
60}
61
62unsigned short adc_scan(int channel)
63{
64 /* maybe we can drop &0x03 part */
65 return adc_data[(channel&0x03)];
66}
67
68void adc_tick(void)
69{
70 /* enable ADC interrupt */
71 or_l( ((1<<6))<<16, &ADCONFIG);
72}
73
74void adc_init(void)
75{
76 /* GPIO38 GPIO39 */
77 and_l(~((1<<6)|(1<<7)), &GPIO1_FUNCTION);
78
79 /* ADOUT_SEL = 01
80 * SOURCE SELECT = 000
81 * CLEAR INTERRUPT FLAG
82 * ENABLE INTERRUPT = 0
83 * ADOUT_DRIVE = 00
84 * ADCLK_SEL = 011 (busclk/8)
85 */
86
87 ADCONFIG = (1<<10)|(1<<8)|(1<<7)|0x03;
88
89 /* ADC interrupt level 4.0 */
90 or_l((4<<28), &INTPRI8);
91
92 /* create tick task which enables ADC interrupt */
93 tick_add_task(adc_tick);
94
95 /* let the interrupt handler fill readout array */
96 sleep(2);
97}
diff --git a/firmware/target/coldfire/mpio/hd200/adc-target.h b/firmware/target/coldfire/mpio/hd200/adc-target.h
deleted file mode 100644
index fb541833cf..0000000000
--- a/firmware/target/coldfire/mpio/hd200/adc-target.h
+++ /dev/null
@@ -1,41 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2010 Marcin Bukat
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 _ADC_TARGET_H_
23#define _ADC_TARGET_H_
24
25#define NUM_ADC_CHANNELS 4
26
27#define ADC_BUTTONS 1
28#define ADC_REMOTE 0
29#define ADC_BATTERY 2
30#define ADC_REMOTEDETECT 3
31#define ADC_UNREG_POWER ADC_BATTERY /* For compatibility */
32
33/* Force a scan now */
34unsigned short adc_scan(int channel);
35
36static inline unsigned short adc_read(int channel)
37{
38 return adc_scan(channel);
39}
40
41#endif /* _ADC_TARGET_H_ */
diff --git a/firmware/target/coldfire/mpio/hd200/backlight-hd200.c b/firmware/target/coldfire/mpio/hd200/backlight-hd200.c
deleted file mode 100644
index 1e40e9bb88..0000000000
--- a/firmware/target/coldfire/mpio/hd200/backlight-hd200.c
+++ /dev/null
@@ -1,94 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2010 Marcin Bukat
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 "cpu.h"
24#include "kernel.h"
25#include "system.h"
26#include "backlight.h"
27#include "backlight-target.h"
28#include "lcd.h"
29
30static bool _backlight_on = true;
31static int _brightness = DEFAULT_BRIGHTNESS_SETTING;
32
33/* Returns the current state of the backlight (true=ON, false=OFF). */
34bool _backlight_init(void)
35{
36#ifdef BOOTLOADER
37 and_l(~(1<<28),&GPIO_OUT);
38#endif
39 or_l((1<<28),&GPIO_FUNCTION);
40 or_l((1<<28),&GPIO_ENABLE);
41 return true;
42}
43
44void _backlight_hw_on(void)
45{
46#ifndef BOOTLOADER
47 if (_backlight_on)
48 return;
49#endif
50
51 _backlight_set_brightness(_brightness);
52 _backlight_on = true;
53
54}
55
56void _backlight_hw_off(void)
57{
58 /* GPIO28 low */
59 and_l(~(1<<28),&GPIO_OUT);
60 _backlight_on = false;
61}
62
63void _backlight_set_brightness(int val)
64{
65 unsigned char i;
66
67#ifndef BOOTLOADER
68 if( _brightness == val && _backlight_on == true )
69 return;
70#endif
71
72 and_l(~(1<<28),&GPIO_OUT);
73 sleep(4);
74
75 for (i=0;i<val;i++)
76 {
77 or_l((1<<28),&GPIO_OUT);
78 and_l(~(1<<28),&GPIO_OUT);
79 }
80
81 or_l((1<<28),&GPIO_OUT);
82
83 _brightness = val;
84}
85
86void _remote_backlight_on(void)
87{
88 /* I don't have remote to play with */
89}
90
91void _remote_backlight_off(void)
92{
93 /* I don't have remote to play with */
94}
diff --git a/firmware/target/coldfire/mpio/hd200/backlight-target.h b/firmware/target/coldfire/mpio/hd200/backlight-target.h
deleted file mode 100644
index 93b1f309fb..0000000000
--- a/firmware/target/coldfire/mpio/hd200/backlight-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) 2010 Marcin Bukat
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
24bool _backlight_init(void); /* Returns backlight current state (true=ON). */
25void _backlight_hw_on(void);
26void _backlight_hw_off(void);
27void _backlight_set_brightness(int val);
28
29#define _backlight_on() _backlight_hw_on()
30#define _backlight_off() _backlight_hw_off()
31#define _backlight_on_isr() _backlight_hw_on()
32#define _backlight_off_isr() _backlight_hw_off()
33#define _backlight_on_normal() _backlight_hw_on()
34#define _backlight_off_normal() _backlight_hw_off()
35#endif
diff --git a/firmware/target/coldfire/mpio/hd200/button-target.h b/firmware/target/coldfire/mpio/hd200/button-target.h
new file mode 100644
index 0000000000..b7c31f8c59
--- /dev/null
+++ b/firmware/target/coldfire/mpio/hd200/button-target.h
@@ -0,0 +1,68 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2010 Marcin Bukat
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 _BUTTON_TARGET_H_
22#define _BUTTON_TARGET_H_
23
24#include <stdbool.h>
25#include "config.h"
26
27#define HAS_BUTTON_HOLD
28#define HAS_REMOTE_BUTTON_HOLD
29
30bool button_hold(void);
31bool remote_button_hold(void);
32void button_init_device(void);
33int button_read_device(void);
34
35/* HD200 specific button codes */
36/* Main unit's buttons - flags as in original firmware*/
37#define BUTTON_PLAY 0x00000001
38
39#define BUTTON_REW 0x00000004
40#define BUTTON_FF 0x00000002
41#define BUTTON_VOL_UP 0x00000008
42#define BUTTON_VOL_DOWN 0x00000010
43#define BUTTON_REC 0x00000020
44#define BUTTON_FUNC 0x00002000
45
46#define BUTTON_RC_PLAY 0x00010000
47
48#define BUTTON_RC_REW 0x00040000
49#define BUTTON_RC_FF 0x00020000
50#define BUTTON_RC_VOL_UP 0x00080000
51#define BUTTON_RC_VOL_DOWN 0x00100000
52#define BUTTON_RC_FUNC 0x20000000
53
54#define BUTTON_LEFT BUTTON_REW
55#define BUTTON_RIGHT BUTTON_FF
56#define BUTTON_ON BUTTON_PLAY
57
58#define BUTTON_MAIN (BUTTON_PLAY|BUTTON_REW|BUTTON_FF|BUTTON_VOL_UP|\
59 BUTTON_VOL_DOWN|BUTTON_REC|BUTTON_FUNC)
60
61#define BUTTON_REMOTE (BUTTON_RC_PLAY|BUTTON_RC_REW|BUTTON_RC_FF|\
62 BUTTON_RC_VOL_UP|BUTTON_RC_VOL_DOWN|BUTTON_RC_FUNC)
63
64#define POWEROFF_BUTTON BUTTON_PLAY
65#define RC_POWEROFF_BUTTON BUTTON_RC_PLAY
66#define POWEROFF_COUNT 30
67
68#endif /* _BUTTON_TARGET_H_ */
diff --git a/firmware/target/coldfire/mpio/hd200/power-hd200.c b/firmware/target/coldfire/mpio/hd200/power-hd200.c
deleted file mode 100644
index 3034bab82d..0000000000
--- a/firmware/target/coldfire/mpio/hd200/power-hd200.c
+++ /dev/null
@@ -1,130 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2010 Marcin Bukat
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 "cpu.h"
24#include <stdbool.h>
25#include "kernel.h"
26#include "system.h"
27#include "lcd.h"
28#include "power.h"
29
30#if CONFIG_TUNER
31bool tuner_power(bool status)
32{
33 if (status)
34 and_l(~(1<<17), &GPIO1_OUT);
35 else
36 or_l((1<<17), &GPIO1_OUT);
37
38 return status;
39}
40#endif /* #if CONFIG_TUNER */
41
42void power_init(void)
43{
44 /* GPIO53 has to be high - low resets device
45 * it is setup in crt0.S
46 */
47
48 /* GPIO50 is ATA power (default OFF) */
49 or_l((1<<18), &GPIO1_OUT);
50 or_l((1<<18), &GPIO1_ENABLE);
51 or_l((1<<18), &GPIO1_FUNCTION);
52
53 /* GPIO49 is FM power (default OFF) */
54 or_l((1<<17), &GPIO1_OUT);
55 or_l((1<<17), &GPIO1_ENABLE);
56 or_l((1<<17), &GPIO1_FUNCTION);
57
58 /* GPIO46 is wall charger detect (input) */
59 and_l(~(1<<14), &GPIO1_ENABLE);
60 or_l((1<<14), &GPIO1_FUNCTION);
61
62 /* GPIO31 needs to be low */
63 and_l(~(1<<31), &GPIO_OUT);
64 or_l((1<<31),&GPIO_ENABLE);
65 or_l((1<<31),&GPIO_FUNCTION);
66
67 /* turn off charger by default*/
68 or_l((1<<23), &GPIO_OUT);
69 or_l((1<<23), &GPIO_ENABLE);
70 or_l((1<<23), &GPIO_FUNCTION);
71
72 /* high current charge mode */
73 or_l((1<<15), &GPIO_OUT);
74 or_l((1<<15),&GPIO_ENABLE);
75 or_l((1<<15),&GPIO_FUNCTION);
76
77#ifndef BOOTLOADER
78 /* The boot loader controls the power */
79 ide_power_enable(true);
80#endif
81}
82
83unsigned int power_input_status(void)
84{
85 unsigned int status = POWER_INPUT_NONE;
86/* GPIO46 is AC plug detect (low = AC plugged) */
87 if (!(GPIO1_READ & (1<<14)))
88 {
89 status |= POWER_INPUT_MAIN_CHARGER;
90 /* tristate GPIO23 to start charging cycle */
91 and_l(~(1<<23), &GPIO_ENABLE);
92 }
93 else
94 {
95 /* drive GPIO23 high to enter LTC1733 shutdown mode */
96 or_l((1<<23), &GPIO_ENABLE);
97 }
98 return status;
99}
100
101/* Returns true if the unit is charging the batteries. */
102bool charging_state(void)
103{
104 if (!(GPIO1_READ & (1<<14)))
105 return (GPIO_READ & (1<<30) )?false:true;
106 else
107 return false;
108}
109
110void ide_power_enable(bool on)
111{
112 if (on)
113 and_l(~(1<<18),&GPIO1_OUT);
114 else
115 or_l((1<<18),&GPIO1_OUT);
116}
117
118bool ide_powered(void)
119{
120 return (GPIO1_OUT & (1<<18))?false:true;
121}
122
123void power_off(void)
124{
125 lcd_shutdown();
126 set_irq_level(DISABLE_INTERRUPTS);
127 and_l(~(1<<21), &GPIO1_OUT); /* pull KEEPACT low */
128 asm("halt");
129 while(1);
130}
diff --git a/firmware/target/coldfire/mpio/hd200/system-hd200.c b/firmware/target/coldfire/mpio/hd200/system-hd200.c
deleted file mode 100644
index 0bd0e07386..0000000000
--- a/firmware/target/coldfire/mpio/hd200/system-hd200.c
+++ /dev/null
@@ -1,125 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2010 by Marcin Bukat
11 * Copyright (C) 2006 by Linus Nielsen Feltzing
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#include "config.h"
23#include "cpu.h"
24#include "kernel.h"
25#include "system.h"
26#include "power.h"
27#include "timer.h"
28
29/* Settings for all possible clock frequencies (with properly working timers)
30 * NOTE: Some 5249 chips don't like having PLLDIV set to 0. We must avoid that!
31 *
32 * xxx_REFRESH_TIMER below
33 * system.h, CPUFREQ_xxx_MULT |
34 * | |
35 * V V
36 * PLLCR & Refreshtim. IDECONFIG1/IDECONFIG2
37 * CPUCLK/Hz MULT ~0x70400000 16MB 32MB CSCR0 CSCR1 CSCR3 CS2Pre CS2Post CS2Wait
38 * ---------------------------------------------------------------------------------------
39 * 11289600 1 0x00800200 4 1 0x0180 0x0180 0x0180 1 1 0
40 * 22579200 2 0x0589e025 10 4 0x0180 0x0180 0x0180 1 1 0
41 * 33868800 3 0x0388e025 15 7 0x0180 0x0180 0x0180 1 1 0
42 * 45158400 4 0x0589e021 21 10 0x0580 0x0180 0x0580 1 1 0
43 * 56448000 5 0x0289e025 26 12 0x0580 0x0580 0x0980 2 1 0
44 * 67737600 6 0x0388e021 32 15 0x0980 0x0980 0x0d80 2 1 0
45 * 79027200 7 0x038a6021 37 18 0x0980 0x0d80 0x1180 2 1 0
46 * 90316800 8 0x038be021 43 21 0x0d80 0x0d80 0x1580 2 1 0
47 * 101606400 9 0x01892025 48 23 0x0d80 0x1180 0x1980 2 1 0
48 * 112896000 10 0x0189e025 54 26 0x1180 0x1580 0x1d80 3 1 0
49 * 124185600 11 0x018ae025 59 29 0x1180 0x1580 0x2180 3 1 1
50 */
51
52#define MAX_REFRESH_TIMER 59
53#define NORMAL_REFRESH_TIMER 21
54#define DEFAULT_REFRESH_TIMER 4
55
56#ifdef HAVE_ADJUSTABLE_CPU_FREQ
57void set_cpu_frequency (long) __attribute__ ((section (".icode")));
58void set_cpu_frequency(long frequency)
59#else
60void cf_set_cpu_frequency (long) __attribute__ ((section (".icode")));
61void cf_set_cpu_frequency(long frequency)
62#endif
63{
64 switch(frequency)
65 {
66 case CPUFREQ_MAX:
67 DCR = (0x8200 | DEFAULT_REFRESH_TIMER);
68 /* Refresh timer for bypass frequency */
69 PLLCR &= ~1; /* Bypass mode */
70 timers_adjust_prescale(CPUFREQ_DEFAULT_MULT, false);
71 PLLCR = 0x018ae025 | (PLLCR & 0x70400000);
72 CSCR0 = 0x00001180; /* Flash: 4 wait states */
73 CSCR3 = 0x00000980; /* LCD: 2 wait states */
74 while(!(PLLCR & 0x80000000)) {}; /* Wait until the PLL has locked.
75 This may take up to 10ms! */
76 timers_adjust_prescale(CPUFREQ_MAX_MULT, true);
77 DCR = (0x8200 | MAX_REFRESH_TIMER); /* Refresh timer */
78 cpu_frequency = CPUFREQ_MAX;
79 IDECONFIG1 = (1<<28)|(1<<20)|(1<<18)|(1<<13)|(3<<10);
80 /* BUFEN2 enable on /CS2 | CS2Post 1 clock| CS2Pre 3 clocks*/
81 IDECONFIG2 = (1<<18)|(1<<16)|(1<<8)|(1<<0); /* TA /CS2 enable + CS2wait */
82
83 and_l(~(0x07<<16), &ADCONFIG);
84 or_l((0x05)<<16, &ADCONFIG); /* adclk = busclk/32 */
85 break;
86
87 case CPUFREQ_NORMAL:
88 DCR = (DCR & ~0x01ff) | DEFAULT_REFRESH_TIMER;
89 /* Refresh timer for bypass frequency */
90 PLLCR &= ~1; /* Bypass mode */
91 timers_adjust_prescale(CPUFREQ_DEFAULT_MULT, false);
92 PLLCR = 0x0589e021 | (PLLCR & 0x70400000);
93 CSCR0 = 0x00000580; /* Flash: 1 wait state */
94 CSCR3 = 0x00000580; /* LCD: 1 wait state */
95 while(!(PLLCR & 0x80000000)) {}; /* Wait until the PLL has locked.
96 This may take up to 10ms! */
97 timers_adjust_prescale(CPUFREQ_NORMAL_MULT, true);
98 DCR = (0x8000 | NORMAL_REFRESH_TIMER); /* Refresh timer */
99 cpu_frequency = CPUFREQ_NORMAL;
100 IDECONFIG1 = (1<<28)|(1<<20)|(1<<18)|(1<<13)|(1<<10);
101 IDECONFIG2 = (1<<18)|(1<<16);
102
103 and_l(~(0x07<<16), &ADCONFIG);
104 or_l((0x03)<<16, &ADCONFIG); /* adclk = busclk/8 */
105 break;
106
107 default:
108 DCR = (DCR & ~0x01ff) | DEFAULT_REFRESH_TIMER;
109 /* Refresh timer for bypass frequency */
110 PLLCR &= ~1; /* Bypass mode */
111 timers_adjust_prescale(CPUFREQ_DEFAULT_MULT, true);
112 /* Power down PLL, but keep CLSEL and CRSEL */
113 PLLCR = 0x00800200 | (PLLCR & 0x70400000);
114 CSCR0 = 0x00000180; /* Flash: 0 wait states */
115 CSCR3 = 0x00000180; /* LCD: 0 wait states */
116 DCR = (0x8000 | DEFAULT_REFRESH_TIMER); /* Refresh timer */
117 cpu_frequency = CPUFREQ_DEFAULT;
118 IDECONFIG1 = (1<<28)|(1<<20)|(1<<18)|(1<<13)|(1<<10);
119 IDECONFIG2 = (1<<18)|(1<<16);
120
121 and_l(~(0x07<<16), &ADCONFIG);
122 or_l((0x01)<<16, &ADCONFIG); /* adclk = busclk/2 */
123 break;
124 }
125}
diff --git a/firmware/target/coldfire/mpio/hd200/usb-hd200.c b/firmware/target/coldfire/mpio/hd200/usb-hd200.c
deleted file mode 100644
index a8c3db85bd..0000000000
--- a/firmware/target/coldfire/mpio/hd200/usb-hd200.c
+++ /dev/null
@@ -1,75 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2010 Marcin Bukat
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 "kernel.h"
26#include "usb.h"
27
28void usb_init_device(void)
29{
30 /* GPIO42 is USB detect input
31 * but it also serves as MCLK2 for DAC
32 */
33 and_l(~(1<<4), &GPIO1_OUT); /* GPIO36 low */
34 or_l((1<<4), &GPIO1_ENABLE); /* GPIO36 */
35 or_l((1<<4)|(1<<5), &GPIO1_FUNCTION); /* GPIO36 GPIO37 */
36
37 /* GPIO22 GPIO30 high */
38 or_l((1<<22)|(1<<30), &GPIO_OUT);
39 or_l((1<<22)|(1<<30), &GPIO_ENABLE);
40 or_l((1<<22)|(1<<30), &GPIO_FUNCTION);
41}
42
43int usb_detect(void)
44{
45 /* GPIO42 active low*/
46 return (GPIO1_READ & (1<<10)) ? USB_EXTRACTED : USB_INSERTED;
47}
48
49void usb_enable(bool on)
50{
51 /* one second timeout */
52 unsigned char timeout = 10;
53
54 if(on)
55 {
56 and_l(~(1<<30),&GPIO_OUT); /* GPIO30 low */
57 and_l(~(1<<22),&GPIO_OUT); /* GPIO22 low */
58
59 or_l((1<<4),&GPIO1_OUT); /* GPIO36 high */
60
61 }
62 else
63 {
64 or_l((1<<22),&GPIO_OUT); /* GPIO22 high */
65 or_l((1<<30),&GPIO_OUT); /* GPIO30 high */
66
67 and_l(~(1<<4),&GPIO1_OUT); /* GPIO36 low */
68
69 while ( !(GPIO1_READ & (1<<5)) && timeout--)
70 {
71 sleep(HZ/10);
72 }
73 sleep(HZ);
74 }
75}