From owner-svn-src-head@freebsd.org Sat Jun 3 15:48:05 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 64DF4BF45A9; Sat, 3 Jun 2017 15:48:05 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 395EB74F34; Sat, 3 Jun 2017 15:48:05 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v53Fm3IJ092555; Sat, 3 Jun 2017 15:48:03 GMT (envelope-from andrew@FreeBSD.org) Received: (from andrew@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v53Fm3tG092554; Sat, 3 Jun 2017 15:48:03 GMT (envelope-from andrew@FreeBSD.org) Message-Id: <201706031548.v53Fm3tG092554@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: andrew set sender to andrew@FreeBSD.org using -f From: Andrew Turner Date: Sat, 3 Jun 2017 15:48:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r319537 - head/sys/arm/versatile X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 03 Jun 2017 15:48:05 -0000 Author: andrew Date: Sat Jun 3 15:48:03 2017 New Revision: 319537 URL: https://svnweb.freebsd.org/changeset/base/319537 Log: Add MULTIDELAY support to the sp804 driver. Modified: head/sys/arm/versatile/sp804.c Modified: head/sys/arm/versatile/sp804.c ============================================================================== --- head/sys/arm/versatile/sp804.c Sat Jun 3 15:40:34 2017 (r319536) +++ head/sys/arm/versatile/sp804.c Sat Jun 3 15:48:03 2017 (r319537) @@ -42,6 +42,10 @@ __FBSDID("$FreeBSD$"); #include #include +#ifdef MULTIDELAY +#include /* For arm_set_delay */ +#endif + #include #include #include @@ -109,6 +113,7 @@ struct sp804_timer_softc { bus_space_write_4(sc->bst, sc->bsh, reg, val) static unsigned sp804_timer_tc_get_timecount(struct timecounter *); +static void sp804_timer_delay(int, void *); static unsigned sp804_timer_tc_get_timecount(struct timecounter *tc) @@ -287,6 +292,10 @@ sp804_timer_attach(device_t dev) (sp804_timer_tc_read_4(SP804_PRIMECELL_ID0 + i*4) & 0xff); } +#ifdef MULTIDELAY + arm_set_delay(sp804_timer_delay, sc); +#endif + device_printf(dev, "PrimeCell ID: %08x\n", id); sc->timer_initialized = 1; @@ -310,11 +319,36 @@ static devclass_t sp804_timer_devclass; DRIVER_MODULE(sp804_timer, simplebus, sp804_timer_driver, sp804_timer_devclass, 0, 0); +static void +sp804_timer_delay(int usec, void *arg) +{ + struct sp804_timer_softc *sc = arg; + int32_t counts; + uint32_t first, last; + + /* Get the number of times to count */ + counts = usec * ((sc->tc.tc_frequency / 1000000) + 1); + + first = sp804_timer_tc_get_timecount(&sc->tc); + + while (counts > 0) { + last = sp804_timer_tc_get_timecount(&sc->tc); + if (last == first) + continue; + if (last > first) { + counts -= (int32_t)(last - first); + } else { + counts -= (int32_t)((0xFFFFFFFF - first) + last); + } + first = last; + } +} + +#ifndef MULTIDELAY void DELAY(int usec) { int32_t counts; - uint32_t first, last; device_t timer_dev; struct sp804_timer_softc *sc; int timer_initialized = 0; @@ -336,23 +370,8 @@ DELAY(int usec) for (counts = 200; counts > 0; counts--) /* Prevent gcc from optimizing out the loop */ cpufunc_nullop(); - return; + } else { + sp804_timer_delay(usec, sc); } - - /* Get the number of times to count */ - counts = usec * ((sc->tc.tc_frequency / 1000000) + 1); - - first = sp804_timer_tc_get_timecount(&sc->tc); - - while (counts > 0) { - last = sp804_timer_tc_get_timecount(&sc->tc); - if (last == first) - continue; - if (last>first) { - counts -= (int32_t)(last - first); - } else { - counts -= (int32_t)((0xFFFFFFFF - first) + last); - } - first = last; - } } +#endif