summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cpu/pxa/interrupts.c46
-rw-r--r--drivers/net/mpc5xxx_fec.c23
2 files changed, 40 insertions, 29 deletions
diff --git a/cpu/pxa/interrupts.c b/cpu/pxa/interrupts.c
index 40d8bf2..2bc5c50 100644
--- a/cpu/pxa/interrupts.c
+++ b/cpu/pxa/interrupts.c
@@ -28,6 +28,7 @@
#include <common.h>
#include <asm/arch/pxa-regs.h>
+#include <div64.h>
#ifdef CONFIG_USE_IRQ
#error: interrupts not implemented yet
@@ -41,6 +42,20 @@
#error "Timer frequency unknown - please config PXA CPU type"
#endif
+static inline unsigned long long tick_to_time(unsigned long long tick)
+{
+ tick *= CONFIG_SYS_HZ;
+ do_div(tick, TIMER_FREQ_HZ);
+ return tick;
+}
+
+static inline unsigned long long us_to_tick(unsigned long long us)
+{
+ us = us * TIMER_FREQ_HZ + 999999;
+ do_div(us, 1000000);
+ return us;
+}
+
int interrupt_init (void)
{
/* nothing happens here - we don't setup any IRQs */
@@ -75,33 +90,20 @@ void reset_timer_masked (void)
ulong get_timer_masked (void)
{
- unsigned long long ticks = get_ticks();
-
- return (((ticks / TIMER_FREQ_HZ) * 1000) +
- ((ticks % TIMER_FREQ_HZ) * 1000) / TIMER_FREQ_HZ);
+ return tick_to_time(get_ticks());
}
void udelay_masked (unsigned long usec)
{
+ unsigned long long tmp;
ulong tmo;
- ulong endtime;
- signed long diff;
-
- if (usec >= 1000) {
- tmo = usec / 1000;
- tmo *= TIMER_FREQ_HZ;
- tmo /= 1000;
- } else {
- tmo = usec * TIMER_FREQ_HZ;
- tmo /= (1000*1000);
- }
-
- endtime = get_ticks() + tmo;
-
- do {
- ulong now = get_ticks();
- diff = endtime - now;
- } while (diff >= 0);
+
+ tmo = us_to_tick(usec);
+ tmp = get_ticks() + tmo; /* get current timestamp */
+
+ while (get_ticks() < tmp) /* loop till event */
+ /*NOP*/;
+
}
/*
diff --git a/drivers/net/mpc5xxx_fec.c b/drivers/net/mpc5xxx_fec.c
index 2bf901e..0f1d1af 100644
--- a/drivers/net/mpc5xxx_fec.c
+++ b/drivers/net/mpc5xxx_fec.c
@@ -281,13 +281,6 @@ static int mpc5xxx_fec_init(struct eth_device *dev, bd_t * bis)
}
fec->eth->x_cntrl = 0x00000000; /* half-duplex, heartbeat disabled */
- if (fec->xcv_type != SEVENWIRE) {
- /*
- * Set MII_SPEED = (1/(mii_speed * 2)) * System Clock
- * and do not drop the Preamble.
- */
- fec->eth->mii_speed = (((gd->ipb_clk >> 20) / 5) << 1); /* No MII for 7-wire mode */
- }
/*
* Set Opcode/Pause Duration Register
@@ -640,6 +633,15 @@ static void mpc5xxx_fec_halt(struct eth_device *dev)
*/
udelay(10);
+ /* don't leave the MII speed set to zero */
+ if (fec->xcv_type != SEVENWIRE) {
+ /*
+ * Set MII_SPEED = (1/(mii_speed * 2)) * System Clock
+ * and do not drop the Preamble.
+ */
+ fec->eth->mii_speed = (((gd->ipb_clk >> 20) / 5) << 1); /* No MII for 7-wire mode */
+ }
+
#if (DEBUG & 0x3)
printf("Ethernet task stopped\n");
#endif
@@ -897,6 +899,13 @@ int mpc5xxx_fec_initialize(bd_t * bis)
#else
#error fec->xcv_type not initialized.
#endif
+ if (fec->xcv_type != SEVENWIRE) {
+ /*
+ * Set MII_SPEED = (1/(mii_speed * 2)) * System Clock
+ * and do not drop the Preamble.
+ */
+ fec->eth->mii_speed = (((gd->ipb_clk >> 20) / 5) << 1); /* No MII for 7-wire mode */
+ }
dev->priv = (void *)fec;
dev->iobase = MPC5XXX_FEC;