Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 14 Jun 2006 02:05:06 GMT
From:      Kevin Lo <kevlo@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 99188 for review
Message-ID:  <200606140205.k5E255Ri024201@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=99188

Change 99188 by kevlo@kevlo_rtsl on 2006/06/14 02:04:27

	Sync my tree. I'm sure I lost something...

Affected files ...

.. //depot/projects/arm/src/sys/arm/s3c2xx0/fs2410_machdep.c#4 edit
.. //depot/projects/arm/src/sys/arm/s3c2xx0/s3c2410.c#5 edit
.. //depot/projects/arm/src/sys/arm/s3c2xx0/s3c24x0_clk.c#2 edit
.. //depot/projects/arm/src/sys/arm/s3c2xx0/uart_bus_s3c2410.c#2 edit

Differences ...

==== //depot/projects/arm/src/sys/arm/s3c2xx0/fs2410_machdep.c#4 (text+ko) ====

@@ -325,7 +325,7 @@
 
 	int i = 0;
 	uint32_t fake_preload[35];
-	uint32_t memsize = 32 * 1024 * 1024;
+	uint32_t memsize = 64 * 1024 * 1024;
 
 	i = 0;
 
@@ -394,7 +394,6 @@
 			kernel_pt_table[loop].pv_va =
 			    kernel_pt_table[loop].pv_pa + 0x20000000;
 		}
-		i++;
 	}
 	freemem_pt = freemempos;
 	freemempos = 0x30100000;

==== //depot/projects/arm/src/sys/arm/s3c2xx0/s3c2410.c#5 (text+ko) ====


==== //depot/projects/arm/src/sys/arm/s3c2xx0/s3c24x0_clk.c#2 (text+ko) ====

@@ -1,4 +1,4 @@
-/*	$NetBSD: s3c24x0_clk.c,v 1.3 2003/08/27 03:57:05 bsh Exp $ */
+/*	$NetBSD: s3c24x0_clk.c,v 1.6 2005/12/24 20:06:52 perry Exp $ */
 
 /*
  * Copyright (c) 2003  Genetec corporation.  All rights reserved.
@@ -30,24 +30,79 @@
  */
 
 #include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
 
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/kernel.h>
+#include <sys/module.h>
 #include <sys/time.h>
 #include <sys/bus.h>
+#include <sys/resource.h>
+#include <sys/rman.h>
+#include <sys/timetc.h>
 
 #include <machine/bus.h>
+#include <machine/cpu.h>
+#include <machine/cpufunc.h>
+#include <machine/frame.h>
+#include <machine/resource.h>
 #include <machine/intr.h>
-#include <machine/cpufunc.h>
 #include <arm/s3c2xx0/s3c24x0reg.h>
 #include <arm/s3c2xx0/s3c24x0var.h>
 
+struct s3c24x0_timer_softc {
+	device_t	dev;
+} timer_softc;
+
+static unsigned s3c24x0_timer_get_timecount(struct timecounter *tc);
+
+static struct timecounter s3c24x0_timer_timecounter = {
+	s3c24x0_timer_get_timecount,	/* get_timecount */
+	NULL,				/* no poll_pps */
+	~0u,				/* counter_mask */
+	3686400,			/* frequency */
+	"s3c24x0 timer",		/* name */
+	1000				/* quality */
+};
+
+static int
+s3c24x0_timer_probe(device_t dev)
+{
 
+	device_set_desc(dev, "s3c24x0 timer");
+	return (0);
+}
+
+static int
+s3c24x0_timer_attach(device_t dev)
+{
+	timer_softc.dev = dev;
+	return (0);
+}
+
+static device_method_t s3c24x0_timer_methods[] = {
+	DEVMETHOD(device_probe, s3c24x0_timer_probe),
+	DEVMETHOD(device_attach, s3c24x0_timer_attach),
+	{0, 0},
+};
+
+static driver_t s3c24x0_timer_driver = {
+	"timer",
+	s3c24x0_timer_methods,
+	sizeof(struct s3c24x0_timer_softc),
+};
+static devclass_t s3c24x0_timer_devclass;
+
+DRIVER_MODULE(s3c24x0timer, s3c2410, s3c24x0_timer_driver, s3c24x0_timer_devclass, 0, 0);
+
 #ifndef STATHZ
 #define STATHZ	64
 #endif
 
+#define hardintr	(void *)hardclock
+#define statintr	(void *)statclock
+
 #define TIMER_FREQUENCY(pclk) ((pclk)/16) /* divider=1/16 */
 
 static unsigned int timer4_reload_value;
@@ -60,116 +115,7 @@
 #define counter_to_usec(c,pclk)	\
 	(((c)*timer4_prescaler*1000)/(TIMER_FREQUENCY(pclk)/1000))
 
-
-/*
- * microtime:
- *
- *	Fill in the specified timeval struct with the current time
- *	accurate to the microsecond.
- */
-#if 0
-void
-microtime(struct timeval *tvp)
-{
-	struct s3c24x0_softc *sc = (struct s3c24x0_softc *) s3c2xx0_softc;
-	int save, int_pend0, int_pend1, count, delta;
-	static struct timeval last;
-	int pclk = s3c2xx0_softc->sc_pclk;
-
-	if( timer4_reload_value == 0 ){
-		/* not initialized yet */
-		tvp->tv_sec = 0;
-		tvp->tv_usec = 0;
-		return;
-	}
-
-	save = disable_interrupts(I32_bit);
-
- again:
-	int_pend0 = S3C24X0_INT_TIMER4 &
-	    bus_space_read_4(sc->sc_sx.sc_iot, sc->sc_sx.sc_intctl_ioh,
-		INTCTL_SRCPND);
-	count = bus_space_read_2(sc->sc_sx.sc_iot, sc->sc_timer_ioh,
-	    TIMER_TCNTO(4));
-	
-	for (;;){
-
-		int_pend1 = S3C24X0_INT_TIMER4 &
-		    bus_space_read_4(sc->sc_sx.sc_iot, sc->sc_sx.sc_intctl_ioh,
-			INTCTL_SRCPND);
-		if( int_pend0 == int_pend1 )
-			break;
-
-		/*
-		 * Down counter reached to zero while we were reading
-		 * timer values. do it again to get consistent values.
-		 */
-		int_pend0 = int_pend1;
-		count = bus_space_read_2(sc->sc_sx.sc_iot, sc->sc_timer_ioh,
-		    TIMER_TCNTO(4));
-	}
-
-	if( __predict_false(count > timer4_reload_value) ){
-		/* 
-		 * Buggy Hardware Warning --- sometimes timer counter
-		 * reads bogus value like 0xffff.  I guess it happens when
-		 * the timer is reloaded.
-		 */
-		printf( "Bogus value from timer counter: %d\n", count );
-		goto again;
-	}
-
-	/* copy system time */
-	*tvp = time;
-
-	restore_interrupts(save);
-
-	delta = timer4_reload_value - count;
-
-	if( int_pend1 ){
-		/*
-		 * down counter underflow, but
-		 * clock interrupt have not serviced yet
-		 */
-		tvp->tv_usec += tick;
-	}
-
-	tvp->tv_usec += counter_to_usec(delta, pclk);
-
-	/* Make sure microseconds doesn't overflow. */
-	tvp->tv_sec += tvp->tv_usec / 1000000;
-	tvp->tv_usec = tvp->tv_usec % 1000000;
-
-	if (last.tv_sec &&
-	    (tvp->tv_sec < last.tv_sec ||
-		(tvp->tv_sec == last.tv_sec && 
-		    tvp->tv_usec < last.tv_usec) ) ){
-
-		/* XXX: This happens very often when the kernel runs
-		   under Multi-ICE */
-#if 0
-		printf("time reversal: %ld.%06ld(%d,%d) -> %ld.%06ld(%d,%d)\n",
-		    last.tv_sec, last.tv_usec,
-		    last_count, last_pend,
-		    tvp->tv_sec, tvp->tv_usec,
-		    count, int_pend1 );
-#endif
-			    
-		/* make sure the time has advanced. */
-		*tvp = last;
-		tvp->tv_usec++;
-		if( tvp->tv_usec >= 1000000 ){
-			tvp->tv_usec -= 1000000;
-			tvp->tv_sec++;
-		}
-	}
-
-	last = *tvp;
-
-}
-#endif
-
-static __inline int
+static inline int
 read_timer(struct s3c24x0_softc *sc)
 {
 	int count;
@@ -182,98 +128,29 @@
 	return count;
 }
 
-/*
- * delay:
- *
- *	Delay for at least N microseconds.
- */
-void
-DELAY(int n)
+static unsigned
+s3c24x0_timer_get_timecount(struct timecounter *tc)
 {
-	struct s3c24x0_softc *sc = (struct s3c24x0_softc *) s3c2xx0_softc;
-	int v0, v1, delta;
-	u_int ucnt;
+	struct s3c24x0_softc *sc = (struct s3c24x0_softc *)s3c2xx0_softc;
 
-	if ( timer4_reload_value == 0 ){
-		/* not initialized yet */
-		while ( n-- > 0 ){
-			int m;
-
-			for (m=0; m<100; ++m )
-				;
-		}
-		return;
-	}
-
-	/* read down counter */
-	v0 = read_timer(sc);
-
-	ucnt = usec_to_counter(n);
-
-	while( ucnt > 0 ) {
-		v1 = read_timer(sc);
-		delta = v0 - v1;
-		if ( delta < 0 )
-			delta += timer4_reload_value;
-#ifdef DEBUG
-		if (delta < 0 || delta > timer4_reload_value)
-			panic("wrong value from timer counter");
-#endif
-
-		if((u_int)delta < ucnt){
-			ucnt -= (u_int)delta;
-			v0 = v1;
-		}
-		else {
-			ucnt = 0;
-		}
-	}
-	/*NOTREACHED*/
+	return (bus_space_read_4(sc->sc_sx.sc_iot, sc->sc_timer_ioh,
+		    TIMER_TCON));
 }
 
-/*
- * inittodr:
- *
- *	Initialize time from the time-of-day register.
- */
-#if 0
 void
-inittodr(time_t base)
-{
-
-	time.tv_sec = base;
-	time.tv_usec = 0;
-}
-
-/*
- * resettodr:
- *
- *	Reset the time-of-day register with the current time.
- */
-void
-resettodr(void)
-{
-}
-
-void
-setstatclockrate(hz)
-	int hz;
-{
-}
-#endif
-#define hardintr	(int (*)(void *))hardclock
-#define statintr	(int (*)(void *))statclock
-
-void
 cpu_initclocks(void)
 {
 	struct s3c24x0_softc *sc = (struct s3c24x0_softc *)s3c2xx0_softc;
 	long tc;
+	struct resource *irq;
+	int rid = 0;
+	void *ihl;
 	int prescaler, h;
 	int pclk = s3c2xx0_softc->sc_pclk;
 	bus_space_tag_t iot = sc->sc_sx.sc_iot;
 	bus_space_handle_t ioh = sc->sc_timer_ioh;
 	uint32_t  reg;
+	device_t dev = timer_softc.dev;
 
 	stathz = STATHZ;
 	profhz = stathz;
@@ -311,12 +188,14 @@
 	bus_space_write_4(iot, ioh, TIMER_TCNTB(3),
 	    ((prescaler - 1) << 16) | (time_constant(stathz) - 1));
 
-#if 0
-	s3c24x0_intr_establish(S3C24X0_INT_TIMER4, IPL_CLOCK, 
-			       IST_NONE, hardintr, 0);
-	s3c24x0_intr_establish(S3C24X0_INT_TIMER3, IPL_STATCLOCK,
-			       IST_NONE, statintr, 0);
-#endif
+	irq = bus_alloc_resource(dev, SYS_RES_IRQ, &rid, S3C24X0_INT_TIMER4,
+		S3C24X0_INT_TIMER4, 1, RF_ACTIVE);
+	if (!irq)
+		panic("Unable to setup the clock irq handler.\n");
+	else
+		bus_setup_intr(dev, irq, INTR_TYPE_CLK | INTR_FAST,
+		    hardintr, NULL, &ihl);
+
 	/* set prescaler1 */
 	reg = bus_space_read_4(iot, ioh, TIMER_TCFG0);
 	bus_space_write_4(iot, ioh, TIMER_TCFG0,
@@ -341,35 +220,54 @@
 	bus_space_write_4(iot, ioh, TIMER_TCON, reg |
 	    TCON_AUTORELOAD(3) | TCON_START(3) |
 	    TCON_AUTORELOAD(4) | TCON_START(4) );
+
+	tc_init(&s3c24x0_timer_timecounter);
 }
 
+/*
+ * DELAY:
+ *
+ *	Delay for at least N microseconds.
+ */
+void
+DELAY(int n)
+{
+	struct s3c24x0_softc *sc = (struct s3c24x0_softc *) s3c2xx0_softc;
+	int v0, v1, delta;
+	u_int ucnt;
+
+	if (timer4_reload_value == 0) {
+		/* not initialized yet */
+		while ( n-- > 0 ){
+			int m;
+
+			for (m = 0; m < 100; ++m )
+				;
+		}
+		return;
+	}
 
-#if 0
-/* test routine for delay() */
+	/* read down counter */
+	v0 = read_timer(sc);
 
-void delay_test(void);
-void
-delay_test(void)
-{
-	struct s3c2xx0_softc *sc = s3c2xx0_softc;
-	volatile int *pdatc = (volatile int *)
-		((char *)bus_space_vaddr(sc->sc_iot, sc->sc_gpio_ioh) + GPIO_PDATC);
-	static const int d[] = {0, 1, 5, 10, 50, 100, 500, 1000, -1};
-	int i;
-	int v = *pdatc & ~0x07;
+	ucnt = usec_to_counter(n);
 
-	for (;;) {
-		*pdatc = v | 2;
+	while( ucnt > 0 ) {
+		v1 = read_timer(sc);
+		delta = v0 - v1;
+		if ( delta < 0 )
+			delta += timer4_reload_value;
 
-		for (i=0; d[i] >= 0; ++i) {
-			*pdatc = v | 3;
-			delay(d[i]);
-			*pdatc = v | 2;
+		if((u_int)delta < ucnt){
+			ucnt -= (u_int)delta;
+			v0 = v1;
+		}
+		else {
+			ucnt = 0;
 		}
-		*pdatc = v;
 	}
+	/*NOTREACHED*/
 }
-#endif
 
 void
 cpu_startprofclock(void)

==== //depot/projects/arm/src/sys/arm/s3c2xx0/uart_bus_s3c2410.c#2 (text+ko) ====

@@ -1,3 +1,6 @@
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/bus.h>
@@ -17,10 +20,7 @@
 #include "uart_if.h"
 
 static int uart_s3c2410_probe(device_t dev);
-#if 0
-static int uart_sa1110_attach(device_t dev);
-static int uart_sa1110_detach(device_t dev);
-#endif
+
 static device_method_t uart_s3c2410_methods[] = {
 	/* Device interface */
 	DEVMETHOD(device_probe,		uart_s3c2410_probe),
@@ -50,18 +50,4 @@
 	return (0);
 }
 
-
-#if 0
-static int
-uart_sa1110_attach(device_t dev)
-{
-	return (0);
-}
-
-static int
-uart_sa1110_detach(device_t dev)
-{
-	return (0);
-}
-#endif
-DRIVER_MODULE(uart, ssio, uart_s3c2410_driver, uart_devclass, 0, 0);
+DRIVER_MODULE(uart, s3c2410, uart_s3c2410_driver, uart_devclass, 0, 0);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200606140205.k5E255Ri024201>