From owner-svn-src-all@FreeBSD.ORG Tue May 24 02:19:45 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A68171065674; Tue, 24 May 2011 02:19:45 +0000 (UTC) (envelope-from nwhitehorn@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 7CA868FC14; Tue, 24 May 2011 02:19:45 +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 p4O2JjtX047490; Tue, 24 May 2011 02:19:45 GMT (envelope-from nwhitehorn@svn.freebsd.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p4O2Jj4Y047488; Tue, 24 May 2011 02:19:45 GMT (envelope-from nwhitehorn@svn.freebsd.org) Message-Id: <201105240219.p4O2Jj4Y047488@svn.freebsd.org> From: Nathan Whitehorn Date: Tue, 24 May 2011 02:19:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r222239 - head/sys/powerpc/ps3 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 May 2011 02:19:45 -0000 Author: nwhitehorn Date: Tue May 24 02:19:45 2011 New Revision: 222239 URL: http://svn.freebsd.org/changeset/base/222239 Log: Add RTC support for the LV1 clock on the PS3. The hypervisor won't let us set it, but it's better than nothing. Modified: head/sys/powerpc/ps3/ps3bus.c Modified: head/sys/powerpc/ps3/ps3bus.c ============================================================================== --- head/sys/powerpc/ps3/ps3bus.c Tue May 24 01:08:53 2011 (r222238) +++ head/sys/powerpc/ps3/ps3bus.c Tue May 24 02:19:45 2011 (r222239) @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -46,6 +47,7 @@ #include "ps3bus.h" #include "ps3-hvcall.h" #include "iommu_if.h" +#include "clock_if.h" static void ps3bus_identify(driver_t *, device_t); static int ps3bus_probe(device_t); @@ -63,6 +65,8 @@ static int ps3_iommu_map(device_t dev, b bus_size_t boundary, void *cookie); static int ps3_iommu_unmap(device_t dev, bus_dma_segment_t *segs, int nsegs, void *cookie); +static int ps3_gettime(device_t dev, struct timespec *ts); +static int ps3_settime(device_t dev, struct timespec *ts); struct ps3bus_devinfo { int bus; @@ -106,6 +110,10 @@ static device_method_t ps3bus_methods[] DEVMETHOD(iommu_map, ps3_iommu_map), DEVMETHOD(iommu_unmap, ps3_iommu_unmap), + /* Clock interface */ + DEVMETHOD(clock_gettime, ps3_gettime), + DEVMETHOD(clock_settime, ps3_settime), + { 0, 0 } }; @@ -312,6 +320,8 @@ ps3bus_attach(device_t self) device_set_ivars(cdev, dinfo); } } + + clock_register(self, 1000); return (bus_generic_attach(self)); } @@ -551,7 +561,6 @@ ps3_iommu_map(device_t dev, bus_dma_segm return (0); } - static int ps3_iommu_unmap(device_t dev, bus_dma_segment_t *segs, int nsegs, void *cookie) { @@ -559,3 +568,26 @@ ps3_iommu_unmap(device_t dev, bus_dma_se return (0); } +#define Y2K 946684800 + +static int +ps3_gettime(device_t dev, struct timespec *ts) +{ + uint64_t rtc, tb; + int result; + + result = lv1_get_rtc(&rtc, &tb); + if (result) + return (result); + + ts->tv_sec = rtc + Y2K; + ts->tv_nsec = 0; + return (0); +} + +static int +ps3_settime(device_t dev, struct timespec *ts) +{ + return (-1); +} +