From owner-svn-src-projects@FreeBSD.ORG Sat Jun 30 23:29:35 2012 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7773A106566B; Sat, 30 Jun 2012 23:29:35 +0000 (UTC) (envelope-from marcel@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 4A0D08FC14; Sat, 30 Jun 2012 23:29:35 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5UNTZ0L047734; Sat, 30 Jun 2012 23:29:35 GMT (envelope-from marcel@svn.freebsd.org) Received: (from marcel@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5UNTZxh047732; Sat, 30 Jun 2012 23:29:35 GMT (envelope-from marcel@svn.freebsd.org) Message-Id: <201206302329.q5UNTZxh047732@svn.freebsd.org> From: Marcel Moolenaar Date: Sat, 30 Jun 2012 23:29:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237858 - projects/altix2/sys/ia64/sgisn X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 30 Jun 2012 23:29:35 -0000 Author: marcel Date: Sat Jun 30 23:29:34 2012 New Revision: 237858 URL: http://svn.freebsd.org/changeset/base/237858 Log: Register a timecounter based on the SHub's RTC. As it happens the mandatory ACPI PM Timer isn't there on the SGI Altix. Modified: projects/altix2/sys/ia64/sgisn/sgisn_shub.c Modified: projects/altix2/sys/ia64/sgisn/sgisn_shub.c ============================================================================== --- projects/altix2/sys/ia64/sgisn/sgisn_shub.c Sat Jun 30 22:18:43 2012 (r237857) +++ projects/altix2/sys/ia64/sgisn/sgisn_shub.c Sat Jun 30 23:29:34 2012 (r237858) @@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -62,6 +63,7 @@ struct sgisn_shub_softc { bus_addr_t sc_mmraddr; bus_space_tag_t sc_tag; bus_space_handle_t sc_hndl; + struct timecounter sc_rtc; u_int sc_domain; u_int sc_hubtype; /* SHub type (0=SHub1, 1=SHub2) */ u_int sc_nasid_mask; @@ -130,6 +132,17 @@ static driver_t sgisn_shub_driver = { DRIVER_MODULE(shub, nexus, sgisn_shub_driver, sgisn_shub_devclass, 0, 0); +static u_int +sgisn_shub_get_rtc(struct timecounter *tc) +{ + struct sgisn_shub_softc *sc; + u_int rtc; + + sc = tc->tc_priv; + rtc = bus_space_read_8(sc->sc_tag, sc->sc_hndl, SHUB_MMR_RTC); + return (rtc); +} + static int sgisn_shub_activate_resource(device_t dev, device_t child, int type, int rid, struct resource *res) @@ -429,6 +442,18 @@ sgisn_shub_attach(device_t dev) device_set_ivars(child, (void *)(uintptr_t)~0UL); } + /* Use the SHub's RTC as a time counter. */ + r = ia64_sal_entry(SAL_FREQ_BASE, 2, 0, 0, 0, 0, 0, 0); + if (r.sal_status == 0) { + sc->sc_rtc.tc_get_timecount = sgisn_shub_get_rtc; + sc->sc_rtc.tc_counter_mask = ~0U; + sc->sc_rtc.tc_frequency = r.sal_result[0]; + sc->sc_rtc.tc_name = "SHub RTC"; + sc->sc_rtc.tc_quality = (r.sal_result[0]) ? 1200 : 950; + sc->sc_rtc.tc_priv = sc; + tc_init(&sc->sc_rtc); + } + for (seg = 0; seg <= sc->sc_fwhub->hub_pci_maxseg; seg++) { for (bus = 0; bus <= sc->sc_fwhub->hub_pci_maxbus; bus++) { r = ia64_sal_entry(SAL_SGISN_IOBUS_INFO, seg, bus,