iaudio7: Implement udelay, mostly based on D2 port, except Z-clock initialization

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22620 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Vitja Makarov 2009-09-04 09:36:53 +00:00
parent 4b4e5e9265
commit b5e39c15a5
3 changed files with 17 additions and 7 deletions

View file

@ -82,13 +82,6 @@ static int fd_log = -1;
#define FM_CLOCK_PIN 5
#define FM_DATA_PIN 6
#define FM_NRW_PIN 7
/* Remove hack when i7 has udelay */
static void udelay(int usecs)
{
while (usecs--)
asm("nop;nop;");
}
#elif defined(COWON_D2)
#define TUNER_GPIO_OUTPUT_EN GPIOC_DIR
#define TUNER_GPIO_OUTPUT_VAL GPIOC

View file

@ -34,4 +34,13 @@
#define inw(a) (*(volatile unsigned short *) (a))
#define outw(a,b) (*(volatile unsigned short *) (b) = (a))
/* TC32 is configured to 1MHz in clock_init() */
#define USEC_TIMER TC32MCNT
static inline void udelay(unsigned usecs)
{
unsigned stop = USEC_TIMER + usecs;
while (TIME_BEFORE(USEC_TIMER, stop));
}
#endif /* SYSTEM_TARGET_H */

View file

@ -187,6 +187,14 @@ static void clock_init(void)
"nop \n\t"
"nop \n\t"
);
/* Enable Z-Clock */
PCLKCFG5 |= (1<<31) | (4<<28); /* Timer Z-Clock enable, XIN direct*/
/* Set TC32 timer to be our USEC_TIMER (Xin divided by 12 = 1MHz) */
TC32MCNT = 0;
TC32LDV = 0;
TC32EN = (1<<24) | 11;
}
static void cpu_init(void)