1
0
Fork 0
forked from len0rd/rockbox

Gmini work:

* Better USB
* Better comments
* Better coding style


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6022 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Jean-Philippe Bernardy 2005-02-19 17:49:58 +00:00
parent ce51bc4b81
commit 8ec05779e3
5 changed files with 87 additions and 27 deletions

View file

@ -190,6 +190,10 @@ static inline void invalidate_icache(void)
#elif CONFIG_CPU == TCC730 #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); extern void set_pll_freq(int pll_index, long freq_out);

View file

@ -258,7 +258,16 @@ void TIMER0(void)
{ {
int i; 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) if (current_tick % 2 == 0)
P8 |= 1; P8 |= 1;
else else

View file

@ -106,6 +106,57 @@ void set_pll_freq(int pll_index, long freq_out) {
} while ((*pllcon & 0x2) == 0); /* wait for stabilization */ } 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 */ /* called by crt0 */
void system_init(void) void system_init(void)
{ {
@ -119,7 +170,14 @@ void system_init(void)
/* keep alive (?) -- clear the bit to prevent crash at start (??) */ /* keep alive (?) -- clear the bit to prevent crash at start (??) */
P8 = 0x00; P8 = 0x00;
P8CON = 0x01; P8CON = 0x01;
/* smsc chip init (?) */
P10 = 0x20;
P6 = 0x08;
P10CON = 0x20;
P6CON = 0x08;
/******** /********
* CPU * CPU
*/ */
@ -170,6 +228,8 @@ void system_init(void)
/* IRQ13 IIS0 INT */ /* IRQ13 IIS0 INT */
/* IRQ14 IIS1 INT */ /* IRQ14 IIS1 INT */
/* IRQ15 ­ */ /* IRQ15 ­ */
extra_init();
} }
#elif CONFIG_CPU == MCF5249 #elif CONFIG_CPU == MCF5249

View file

@ -188,8 +188,11 @@ void switch_thread(void)
#if CONFIG_CPU == MCF5249 #if CONFIG_CPU == MCF5249
asm volatile ("stop #0x2000"); asm volatile ("stop #0x2000");
#elif CONFIG_CPU == TCC730 #elif CONFIG_CPU == TCC730
/* No sleep instr on the CalmRisc. (?) /* Sleep mode is triggered by the SYS instr on CalmRisc16.
* TODO: investigate the SYS instruction * 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 #else
SBYCR &= 0x7F; SBYCR &= 0x7F;

View file

@ -80,19 +80,6 @@ static struct event_queue usb_queue;
static bool last_usb_status; static bool last_usb_status;
static bool usb_monitor_enabled; 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) 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 */ or_b(0x28, &PAIORL); /* output for USB enable and card detect */
#elif defined(USB_GMINISTYLE) #elif defined(USB_GMINISTYLE)
{ {
int i; int smsc_ver = smsc_version();
int smscVer = getSMSCVer();
if (on) { if (on) {
if (smscVer < 4) { if (smsc_ver < 4) {
P6 &= ~0x04; P6 &= ~0x04;
P10 &= ~0x20; P10 &= ~0x20;
for (i=0; i < 20; i++) smsc_delay();
;
P6 |= 0x08; P6 |= 0x08;
P10 |= 0x20; P10 |= 0x20;
for (i=0; i < 20; i++) smsc_delay();
;
} }
P6 |= 0x10; P6 |= 0x10;
} else { } else {
P6 &= ~0x10; P6 &= ~0x10;
if (smscVer < 4) { if (smsc_ver < 4) {
P6 &= ~0x04; P6 &= ~0x04;
P10 &= ~0x20; P10 &= ~0x20;
} }
@ -355,7 +339,7 @@ bool usb_detect(void)
current_status = (GPIO1_READ & 0x80)?true:false; current_status = (GPIO1_READ & 0x80)?true:false;
#endif #endif
#ifdef USB_GMINISTYLE #ifdef USB_GMINISTYLE
current_status = (P5 & 0x80)?true:false; current_status = (P5 & 0x10)?true:false;
#endif #endif
return current_status; return current_status;
} }