summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Philippe Bernardy <jeanphilippe.bernardy@gmail.com>2005-02-19 17:49:58 +0000
committerJean-Philippe Bernardy <jeanphilippe.bernardy@gmail.com>2005-02-19 17:49:58 +0000
commit8ec05779e3cb42654fd774906561d586b4f1095e (patch)
tree0a6ef2f3600ddfe4da0098c84990cd56c9ff9998
parentce51bc4b81f45424357ef8defe94fa43eb963823 (diff)
downloadrockbox-8ec05779e3cb42654fd774906561d586b4f1095e.zip
rockbox-8ec05779e3cb42654fd774906561d586b4f1095e.tar.gz
rockbox-8ec05779e3cb42654fd774906561d586b4f1095e.tar.bz2
rockbox-8ec05779e3cb42654fd774906561d586b4f1095e.tar.xz
Gmini work:
* Better USB * Better comments * Better coding style git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6022 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/export/system.h4
-rw-r--r--firmware/kernel.c11
-rw-r--r--firmware/system.c62
-rw-r--r--firmware/thread.c7
-rw-r--r--firmware/usb.c30
5 files changed, 87 insertions, 27 deletions
diff --git a/firmware/export/system.h b/firmware/export/system.h
index f9da0d2..626cdfa 100644
--- a/firmware/export/system.h
+++ b/firmware/export/system.h
@@ -190,6 +190,10 @@ static inline void invalidate_icache(void)
#elif CONFIG_CPU == TCC730
+extern int smsc_version(void);
+
+extern void smsc_delay(void);
+
extern void set_pll_freq(int pll_index, long freq_out);
diff --git a/firmware/kernel.c b/firmware/kernel.c
index 71daac1..ca0dcf5 100644
--- a/firmware/kernel.c
+++ b/firmware/kernel.c
@@ -258,7 +258,16 @@ void TIMER0(void)
{
int i;
- /* Keep alive (?) */
+ /* Mess with smsc chip. No idea what for.
+ */
+ if (smsc_version() < 4) {
+ P6 |= 0x08;
+ P10 |= 0x20;
+ }
+
+ /* Keep alive (?)
+ * If this is not done, power goes down when DC is unplugged.
+ */
if (current_tick % 2 == 0)
P8 |= 1;
else
diff --git a/firmware/system.c b/firmware/system.c
index eb6c6ee..3ead7c6 100644
--- a/firmware/system.c
+++ b/firmware/system.c
@@ -106,6 +106,57 @@ void set_pll_freq(int pll_index, long freq_out) {
} while ((*pllcon & 0x2) == 0); /* wait for stabilization */
}
+int smsc_version(void) {
+ int v;
+ int* smsc_ver_addr = (int*)0x4C20;
+ __asm__ ("ldc %0, @%1" : "=r"(v) : "a"(smsc_ver_addr));
+ v &= 0xFF;
+ if (v < 4 || v == 0xFF) {
+ return 3;
+ }
+ return v;
+}
+
+
+
+void smsc_delay() {
+ int i;
+ /* FIXME: tune the delay.
+ !!! Delay should depend on CPU speed !!!
+ */
+ for (i = 0; i < 100; i++) {
+
+ }
+}
+
+static void extra_init(void) {
+ /* Power on
+ P1 |= 0x01;
+ P1CON |= 0x01;
+ */
+
+ /* SMSC chip config (?) */
+ P6CON |= 0x08;
+ P10CON |= 0x20;
+ P6 &= 0xF7;
+ P10 &= 0x20;
+ smsc_delay();
+ if (smsc_version() < 4) {
+ P6 |= 0x80;
+ P10 |= 0x20;
+ }
+
+ /* P5 conf
+ * line 2 & 4 are digital, other analog. : P5CON = 0xec;
+ */
+
+ /* P7 conf
+ nothing to do: all are inputs
+ (reset value of the register is good)
+ */
+
+}
+
/* called by crt0 */
void system_init(void)
{
@@ -119,7 +170,14 @@ void system_init(void)
/* keep alive (?) -- clear the bit to prevent crash at start (??) */
P8 = 0x00;
P8CON = 0x01;
-
+
+ /* smsc chip init (?) */
+ P10 = 0x20;
+ P6 = 0x08;
+
+ P10CON = 0x20;
+ P6CON = 0x08;
+
/********
* CPU
*/
@@ -170,6 +228,8 @@ void system_init(void)
/* IRQ13 IIS0 INT */
/* IRQ14 IIS1 INT */
/* IRQ15 ­ */
+
+ extra_init();
}
#elif CONFIG_CPU == MCF5249
diff --git a/firmware/thread.c b/firmware/thread.c
index d59c05e..d79c538 100644
--- a/firmware/thread.c
+++ b/firmware/thread.c
@@ -188,8 +188,11 @@ void switch_thread(void)
#if CONFIG_CPU == MCF5249
asm volatile ("stop #0x2000");
#elif CONFIG_CPU == TCC730
- /* No sleep instr on the CalmRisc. (?)
- * TODO: investigate the SYS instruction
+ /* Sleep mode is triggered by the SYS instr on CalmRisc16.
+ * Unfortunately, the manual doesn't specify which arg to use.
+ __asm__ volatile ("sys #0x0f");
+ 0x1f seems to trigger a reset;
+ 0x0f is the only one other argument used by Archos.
*/
#else
SBYCR &= 0x7F;
diff --git a/firmware/usb.c b/firmware/usb.c
index 8bb320c..1400805 100644
--- a/firmware/usb.c
+++ b/firmware/usb.c
@@ -80,19 +80,6 @@ static struct event_queue usb_queue;
static bool last_usb_status;
static bool usb_monitor_enabled;
-#ifdef USB_GMINISTYLE
-static int getSMSCVer(void) {
- int v;
- int* smscVerAddr = (int*)0x4C20;
- __asm__ ("ldc %0, @%1" : "=r"(v) : "a"(smscVerAddr));
- v &= 0xFF;
- if (v < 4 || v == 0xFF) {
- return 3;
- }
- return v;
-}
-
-#endif
static void usb_enable(bool on)
{
@@ -118,26 +105,23 @@ static void usb_enable(bool on)
or_b(0x28, &PAIORL); /* output for USB enable and card detect */
#elif defined(USB_GMINISTYLE)
{
- int i;
- int smscVer = getSMSCVer();
+ int smsc_ver = smsc_version();
if (on) {
- if (smscVer < 4) {
+ if (smsc_ver < 4) {
P6 &= ~0x04;
P10 &= ~0x20;
- for (i=0; i < 20; i++)
- ;
+ smsc_delay();
P6 |= 0x08;
P10 |= 0x20;
-
- for (i=0; i < 20; i++)
- ;
+
+ smsc_delay();
}
P6 |= 0x10;
} else {
P6 &= ~0x10;
- if (smscVer < 4) {
+ if (smsc_ver < 4) {
P6 &= ~0x04;
P10 &= ~0x20;
}
@@ -355,7 +339,7 @@ bool usb_detect(void)
current_status = (GPIO1_READ & 0x80)?true:false;
#endif
#ifdef USB_GMINISTYLE
- current_status = (P5 & 0x80)?true:false;
+ current_status = (P5 & 0x10)?true:false;
#endif
return current_status;
}