9
0
Fork 0

svn_rev_033

change to clocksource api
This commit is contained in:
Sascha Hauer 2007-07-05 18:01:15 +02:00 committed by Sascha Hauer
parent fecf0fd93e
commit 363266d818
14 changed files with 58 additions and 53 deletions

View File

@ -276,8 +276,6 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) {
/* arm simple, non interrupt dependent timer */
reset_timer_masked();
SF_NvmodeErase();
SF_NvmodeWrite();

View File

@ -57,17 +57,23 @@ uint32_t clocksource_hz2mult(uint32_t hz, uint32_t shift_constant)
int is_timeout(uint64_t start_ns, uint64_t time_offset_ns)
{
if (ctrlc ())
return -1;
if (start_ns + time_offset_ns < get_time_ns())
return 1;
else
return 0;
}
void udelay(unsigned long usecs)
int udelay(unsigned long usecs)
{
uint64_t start = get_time_ns();
while(!is_timeout(start, usecs * 1000));
while(!is_timeout(start, usecs * 1000))
if (ctrlc ())
return -1;
return 0;
}
void mdelay(unsigned long msecs)

View File

@ -26,12 +26,13 @@
*/
#include <common.h>
#include <command.h>
#include <clock.h>
#if (CONFIG_COMMANDS & CFG_CMD_MISC)
int do_sleep (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{
ulong start = get_timer(0);
uint64_t start;
ulong delay;
if (argc != 2) {
@ -41,12 +42,8 @@ int do_sleep (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
delay = simple_strtoul(argv[1], NULL, 10) * CFG_HZ;
while (get_timer(start) < delay) {
if (ctrlc ()) {
return (-1);
}
udelay (100);
}
start = get_time_ns();
while (!is_timeout(start, delay * 1000000));
return 0;
}

View File

@ -25,7 +25,7 @@ void jumptable_init (void)
gd->jt[XF_free] = (void *) free;
gd->jt[XF_getenv] = (void *) getenv;
gd->jt[XF_setenv] = (void *) setenv;
gd->jt[XF_get_timer] = (void *) get_timer;
// gd->jt[XF_get_timer] = (void *) get_timer;
gd->jt[XF_simple_strtoul] = (void *) simple_strtoul;
gd->jt[XF_udelay] = (void *) udelay;
#if defined(CONFIG_I386) || defined(CONFIG_PPC)

View File

@ -788,18 +788,18 @@ static int flash_is_busy (flash_info_t * info, flash_sect_t sect)
* This routine does not set the flash to read-array mode.
*/
static int flash_status_check (flash_info_t * info, flash_sect_t sector,
ulong tout, char *prompt)
uint64_t tout, char *prompt)
{
ulong start;
uint64_t start;
#if CFG_HZ != 1000
tout *= CFG_HZ/1000;
#endif
/* Wait for command completion */
start = get_timer (0);
start = get_time_ns();
while (flash_is_busy (info, sector)) {
if (get_timer (start) > tout) {
if (is_timeout(start, tout)) {
printf ("Flash %s timeout at address %lx data %lx\n",
prompt, info->start[sector],
flash_read_long (info, sector, 0));
@ -816,7 +816,7 @@ static int flash_status_check (flash_info_t * info, flash_sect_t sector,
* This routine sets the flash to read-array mode.
*/
static int flash_full_status_check (flash_info_t * info, flash_sect_t sector,
ulong tout, char *prompt)
uint64_t tout, char *prompt)
{
int retcode;
@ -1318,10 +1318,10 @@ ulong flash_get_size (ulong base, int banknum)
info->erase_blk_tout = (tmp * (1 << flash_read_uchar (info, FLASH_OFFSET_EMAX_TOUT)));
tmp = (1 << flash_read_uchar (info, FLASH_OFFSET_WBTOUT)) *
(1 << flash_read_uchar (info, FLASH_OFFSET_WBMAX_TOUT));
info->buffer_write_tout = tmp / 1000 + (tmp % 1000 ? 1 : 0); /* round up when converting to ms */
info->buffer_write_tout = tmp * 1000;
tmp = (1 << flash_read_uchar (info, FLASH_OFFSET_WTOUT)) *
(1 << flash_read_uchar (info, FLASH_OFFSET_WMAX_TOUT));
info->write_tout = tmp / 1000 + (tmp % 1000 ? 1 : 0); /* round up when converting to ms */
info->write_tout = tmp * 1000;
info->flash_id = FLASH_MAN_CFI;
if ((info->interface == FLASH_CFI_X8X16) && (info->chipwidth == FLASH_CFI_BY8)) {
info->portwidth >>= 1; /* XXX - Need to test on x8/x16 in parallel. */

View File

@ -40,6 +40,7 @@
#include <command.h>
#include "cs8900.h"
#include <net.h>
#include <clock.h>
#ifdef CONFIG_DRIVER_CS8900
@ -84,7 +85,7 @@ static void put_reg (int regno, unsigned short val)
static void eth_reset (void)
{
int tmo;
uint64_t start;
unsigned short us;
/* reset NIC */
@ -94,9 +95,9 @@ static void eth_reset (void)
udelay (200000);
/* Wait until the chip is reset */
tmo = get_timer (0) + 1 * CFG_HZ;
start = get_time_ns();
while ((((us = get_reg_init_bus (PP_SelfSTAT)) & PP_SelfSTAT_InitD) == 0)
&& tmo < get_timer (0))
&& !is_timeout(start, SECOND))
/*NOP*/;
}
@ -236,7 +237,7 @@ extern int eth_rx (void)
extern int eth_send (volatile void *packet, int length)
{
volatile unsigned short *addr;
int tmo;
uint64_t start;
unsigned short s;
retry:
@ -250,8 +251,9 @@ retry:
#ifdef DEBUG
printf ("cs: unable to send packet; retrying...\n");
#endif
for (tmo = get_timer (0) + 5 * CFG_HZ; get_timer (0) < tmo;)
/*NOP*/;
/* FIXME */
udelay(5000);
eth_reset ();
eth_reginit ();
goto retry;
@ -263,9 +265,9 @@ retry:
CS8900_RTDATA = *addr++;
/* wait for transfer to succeed */
tmo = get_timer (0) + 5 * CFG_HZ;
start = get_time_ns();
while ((s = get_reg (PP_TER) & ~0x1F) == 0) {
if (get_timer (0) >= tmo)
if (is_timeout(start, SECOND))
break;
}

View File

@ -54,8 +54,4 @@ void setup_revision_tag (struct tag **params);
/* common/cmd_nvedit.c */
void setenv (char *, char *);
/* cpu/.../interrupt.c */
void reset_timer_masked (void);
ulong get_timer_masked (void);
#endif /* _U_BOOT_ARM_H_ */

View File

@ -1,3 +1,5 @@
#ifndef CLOCK_H
#define CLOCK_H
struct clocksource {
uint32_t shift;
@ -8,7 +10,7 @@ struct clocksource {
};
inline uint32_t cyc2ns(struct clocksource *cs, uint64_t cycles)
static inline uint32_t cyc2ns(struct clocksource *cs, uint64_t cycles)
{
uint64_t ret = cycles;
ret = (ret * cs->mult) >> cs->shift;
@ -27,3 +29,8 @@ int is_timeout(uint64_t start_ns, uint64_t time_offset_ns);
void mdelay(unsigned long msecs);
#define SECOND ((uint64_t)(1000 * 1000 * 1000))
#define MSECOND ((uint64_t)(1000 * 1000))
#define USECOND ((uint64_t)(1000))
#endif /* CLOCK_H */

View File

@ -517,7 +517,6 @@ void external_interrupt (struct pt_regs *);
void irq_install_handler(int, interrupt_handler_t *, void *);
void irq_free_handler (int);
void reset_timer (void);
ulong get_timer (ulong base);
void set_timer (ulong t);
void enable_interrupts (void);
int disable_interrupts (void);
@ -555,7 +554,7 @@ unsigned long long get_ticks(void);
void wait_ticks (unsigned long);
/* lib_$(ARCH)/time.c */
void udelay (unsigned long);
int udelay (unsigned long);
ulong usec2ticks (unsigned long usec);
ulong ticks2usec (unsigned long ticks);
int init_timebase (void);

View File

@ -16,8 +16,7 @@ void install_hdlr(int, interrupt_handler_t*, void*);
void free_hdlr(int);
void *malloc(size_t);
void free(void*);
void udelay(unsigned long);
unsigned long get_timer(unsigned long);
int udelay(unsigned long);
void vprintf(const char *, va_list);
void do_reset (void);
unsigned long simple_strtoul(const char *cp,char **endp,unsigned int base);

View File

@ -374,7 +374,7 @@ extern uint NetCksum(uchar *, int); /* Calculate the checksum */
/* Set callbacks */
extern void NetSetHandler(rxhand_f *); /* Set RX packet handler */
extern void NetSetTimeout(ulong, thand_f *);/* Set timeout handler */
extern void NetSetTimeout(uint64_t, thand_f *);/* Set timeout handler */
/* Transmit "NetTxPacket" */
extern void NetSendPacket(volatile uchar *, int);

View File

@ -17,6 +17,7 @@
#include <common.h>
#include <command.h>
#include <clock.h>
#include <net.h>
#include "bootp.h"
#include "tftp.h"
@ -650,7 +651,8 @@ BootpRequest (void)
bp->bp_htype = HWT_ETHER;
bp->bp_hlen = HWL_ETHER;
bp->bp_hops = 0;
bp->bp_secs = htons(get_timer(0) / CFG_HZ);
/* FIXME what is this? */
// bp->bp_secs = htons(get_timer(0) / CFG_HZ);
NetWriteIP(&bp->bp_ciaddr, 0);
NetWriteIP(&bp->bp_yiaddr, 0);
NetWriteIP(&bp->bp_siaddr, 0);
@ -673,7 +675,7 @@ BootpRequest (void)
| ((ulong)NetOurEther[3] << 16)
| ((ulong)NetOurEther[4] << 8)
| (ulong)NetOurEther[5];
BootpID += get_timer(0);
BootpID += (uint32_t)get_time_ns();
BootpID = htonl(BootpID);
NetCopyLong(&bp->bp_id, &BootpID);
@ -828,7 +830,8 @@ static void DhcpSendRequestPkt(Bootp_t *bp_offer)
bp->bp_htype = HWT_ETHER;
bp->bp_hlen = HWL_ETHER;
bp->bp_hops = 0;
bp->bp_secs = htons(get_timer(0) / CFG_HZ);
/* FIXME what is this? */
// bp->bp_secs = htons(get_timer(0) / CFG_HZ);
NetCopyIP(&bp->bp_ciaddr, &bp_offer->bp_ciaddr); /* both in network byte order */
NetCopyIP(&bp->bp_yiaddr, &bp_offer->bp_yiaddr);
NetCopyIP(&bp->bp_siaddr, &bp_offer->bp_siaddr);

View File

@ -75,6 +75,7 @@
#include <common.h>
#include <clock.h>
#include <watchdog.h>
#include <command.h>
#include <net.h>
@ -94,7 +95,7 @@
DECLARE_GLOBAL_DATA_PTR;
#define ARP_TIMEOUT 5 /* Seconds before trying ARP again */
#define ARP_TIMEOUT (5 * SECOND) /* Seconds before trying ARP again */
#ifndef CONFIG_NET_RETRY_COUNT
# define ARP_TIMEOUT_COUNT 5 /* # of timeouts before giving up */
#else
@ -235,15 +236,11 @@ void ArpRequest (void)
void ArpTimeoutCheck(void)
{
ulong t;
if (!NetArpWaitPacketIP)
return;
t = get_timer(0);
/* check for arp timeout */
if ((t - NetArpWaitTimerStart) > ARP_TIMEOUT * CFG_HZ) {
if (is_timeout(NetArpWaitTimerStart, ARP_TIMEOUT)) {
NetArpWaitTry++;
if (NetArpWaitTry >= ARP_TIMEOUT_COUNT) {
@ -251,7 +248,7 @@ void ArpTimeoutCheck(void)
NetArpWaitTry = 0;
NetStartAgain();
} else {
NetArpWaitTimerStart = t;
NetArpWaitTimerStart = get_time_ns();
ArpRequest();
}
}
@ -501,7 +498,7 @@ restart:
* Check for a timeout, and run the timeout handler
* if we have one.
*/
if (timeHandler && ((get_timer(0) - timeStart) > timeDelta)) {
if (timeHandler && ((get_time_ns() - timeStart) > timeDelta)) {
thand_f *x;
#if defined(CONFIG_MII) || (CONFIG_COMMANDS & CFG_CMD_MII)
@ -615,13 +612,13 @@ NetSetHandler(rxhand_f * f)
void
NetSetTimeout(ulong iv, thand_f * f)
NetSetTimeout(uint64_t iv, thand_f * f)
{
if (iv == 0) {
timeHandler = (thand_f *)0;
} else {
timeHandler = f;
timeStart = get_timer(0);
timeStart = get_time_ns();
timeDelta = iv;
}
}
@ -666,7 +663,7 @@ NetSendUDPPacket(uchar *ether, IPaddr_t dest, int dport, int sport, int len)
/* and do the ARP request */
NetArpWaitTry = 1;
NetArpWaitTimerStart = get_timer(0);
NetArpWaitTimerStart = get_time_ns();
ArpRequest();
return 1; /* waiting */
}
@ -737,7 +734,7 @@ int PingSend(void)
/* and do the ARP request */
NetArpWaitTry = 1;
NetArpWaitTimerStart = get_timer(0);
NetArpWaitTimerStart = get_time_ns();
ArpRequest();
return 1; /* waiting */
}

View File

@ -7,6 +7,7 @@
#include <common.h>
#include <command.h>
#include <net.h>
#include <clock.h>
#include "tftp.h"
#include "bootp.h"
@ -369,7 +370,7 @@ TftpStart (void)
TftpTimeoutCount = 0;
TftpState = STATE_RRQ;
/* Use a pseudo-random port unless a specific port is set */
TftpOurPort = 1024 + (get_timer(0) % 3072);
TftpOurPort = 1024 + (get_time_ns() % 3072);
#ifdef CONFIG_TFTP_PORT
if ((ep = getenv("tftpdstp")) != NULL) {
TftpServerPort = simple_strtol(ep, NULL, 10);