mcclock_jensenio.c revision 1.4
11.4Sthorpej/* $NetBSD: mcclock_jensenio.c,v 1.4 2002/10/02 04:06:38 thorpej Exp $ */ 21.1Sthorpej 31.1Sthorpej/*- 41.1Sthorpej * Copyright (c) 1999 The NetBSD Foundation, Inc. 51.1Sthorpej * All rights reserved. 61.1Sthorpej * 71.1Sthorpej * This code is derived from software contributed to The NetBSD Foundation 81.1Sthorpej * by Jason R. Thorpe. 91.1Sthorpej * 101.1Sthorpej * Redistribution and use in source and binary forms, with or without 111.1Sthorpej * modification, are permitted provided that the following conditions 121.1Sthorpej * are met: 131.1Sthorpej * 1. Redistributions of source code must retain the above copyright 141.1Sthorpej * notice, this list of conditions and the following disclaimer. 151.1Sthorpej * 2. Redistributions in binary form must reproduce the above copyright 161.1Sthorpej * notice, this list of conditions and the following disclaimer in the 171.1Sthorpej * documentation and/or other materials provided with the distribution. 181.1Sthorpej * 3. All advertising materials mentioning features or use of this software 191.1Sthorpej * must display the following acknowledgement: 201.1Sthorpej * This product includes software developed by the NetBSD 211.1Sthorpej * Foundation, Inc. and its contributors. 221.1Sthorpej * 4. Neither the name of The NetBSD Foundation nor the names of its 231.1Sthorpej * contributors may be used to endorse or promote products derived 241.1Sthorpej * from this software without specific prior written permission. 251.1Sthorpej * 261.1Sthorpej * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 271.1Sthorpej * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 281.1Sthorpej * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 291.1Sthorpej * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 301.1Sthorpej * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 311.1Sthorpej * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 321.1Sthorpej * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 331.1Sthorpej * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 341.1Sthorpej * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 351.1Sthorpej * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 361.1Sthorpej * POSSIBILITY OF SUCH DAMAGE. 371.1Sthorpej */ 381.1Sthorpej 391.1Sthorpej/* 401.1Sthorpej * Copyright (c) 1995, 1996 Carnegie-Mellon University. 411.1Sthorpej * All rights reserved. 421.1Sthorpej * 431.1Sthorpej * Author: Chris G. Demetriou 441.1Sthorpej * 451.1Sthorpej * Permission to use, copy, modify and distribute this software and 461.1Sthorpej * its documentation is hereby granted, provided that both the copyright 471.1Sthorpej * notice and this permission notice appear in all copies of the 481.1Sthorpej * software, derivative works or modified versions, and any portions 491.1Sthorpej * thereof, and that both notices appear in supporting documentation. 501.1Sthorpej * 511.1Sthorpej * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 521.1Sthorpej * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND 531.1Sthorpej * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 541.1Sthorpej * 551.1Sthorpej * Carnegie Mellon requests users of this software to return to 561.1Sthorpej * 571.1Sthorpej * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU 581.1Sthorpej * School of Computer Science 591.1Sthorpej * Carnegie Mellon University 601.1Sthorpej * Pittsburgh PA 15213-3890 611.1Sthorpej * 621.1Sthorpej * any improvements or extensions that they make and grant Carnegie the 631.1Sthorpej * rights to redistribute these changes. 641.1Sthorpej */ 651.1Sthorpej 661.1Sthorpej#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */ 671.1Sthorpej 681.4Sthorpej__KERNEL_RCSID(0, "$NetBSD: mcclock_jensenio.c,v 1.4 2002/10/02 04:06:38 thorpej Exp $"); 691.1Sthorpej 701.1Sthorpej#include <sys/param.h> 711.1Sthorpej#include <sys/kernel.h> 721.1Sthorpej#include <sys/systm.h> 731.1Sthorpej#include <sys/device.h> 741.1Sthorpej 751.1Sthorpej#include <machine/bus.h> 761.1Sthorpej 771.1Sthorpej#include <dev/dec/clockvar.h> 781.1Sthorpej#include <dev/dec/mcclockvar.h> 791.1Sthorpej#include <dev/ic/mc146818reg.h> 801.1Sthorpej#include <dev/eisa/eisavar.h> 811.1Sthorpej#include <dev/isa/isavar.h> 821.1Sthorpej#include <alpha/jensenio/jenseniovar.h> 831.1Sthorpej 841.1Sthorpejstruct mcclock_jensenio_softc { 851.1Sthorpej struct mcclock_softc sc_mcclock; 861.1Sthorpej 871.1Sthorpej bus_space_tag_t sc_iot; 881.1Sthorpej bus_space_handle_t sc_ioh; 891.1Sthorpej 901.1Sthorpej bus_space_handle_t sc_std_rtc_ioh; 911.1Sthorpej}; 921.1Sthorpej 931.1Sthorpejint mcclock_jensenio_match(struct device *, struct cfdata *, void *); 941.1Sthorpejvoid mcclock_jensenio_attach(struct device *, struct device *, void *); 951.1Sthorpej 961.4SthorpejCFATTACH_DECL(mcclock_jensenio, sizeof (struct mcclock_jensenio_softc), 971.4Sthorpej mcclock_jensenio_match, mcclock_jensenio_attach, NULL, NULL); 981.1Sthorpej 991.1Sthorpejvoid mcclock_jensenio_write(struct mcclock_softc *, u_int, u_int); 1001.1Sthorpeju_int mcclock_jensenio_read(struct mcclock_softc *, u_int); 1011.1Sthorpej 1021.1Sthorpejconst struct mcclock_busfns mcclock_jensenio_busfns = { 1031.1Sthorpej mcclock_jensenio_write, mcclock_jensenio_read, 1041.1Sthorpej}; 1051.1Sthorpej 1061.1Sthorpejint 1071.1Sthorpejmcclock_jensenio_match(struct device *parent, struct cfdata *match, void *aux) 1081.1Sthorpej{ 1091.1Sthorpej struct jensenio_attach_args *ja = aux; 1101.1Sthorpej 1111.1Sthorpej /* Always present. */ 1121.2Sthorpej if (strcmp(ja->ja_name, match->cf_name) == 0) 1131.1Sthorpej return (1); 1141.1Sthorpej 1151.1Sthorpej return (0); 1161.1Sthorpej} 1171.1Sthorpej 1181.1Sthorpejvoid 1191.1Sthorpejmcclock_jensenio_attach(struct device *parent, struct device *self, void *aux) 1201.1Sthorpej{ 1211.1Sthorpej struct jensenio_attach_args *ja = aux; 1221.1Sthorpej struct mcclock_jensenio_softc *sc = (void *) self; 1231.1Sthorpej 1241.1Sthorpej sc->sc_iot = ja->ja_iot; 1251.1Sthorpej if (bus_space_map(sc->sc_iot, ja->ja_ioaddr, 0x02, 0, 1261.1Sthorpej &sc->sc_ioh)) 1271.1Sthorpej panic("mcclock_jensenio_attach: couldn't map clock I/O space"); 1281.1Sthorpej 1291.1Sthorpej /* 1301.1Sthorpej * Map the I/O space normally used by the ISA RTC (port 0x70) so 1311.1Sthorpej * as to avoid a false match at that address, as well. 1321.1Sthorpej */ 1331.1Sthorpej (void) bus_space_map(sc->sc_iot, 0x70, 0x02, 0, 1341.1Sthorpej &sc->sc_std_rtc_ioh); 1351.1Sthorpej 1361.1Sthorpej mcclock_attach(&sc->sc_mcclock, &mcclock_jensenio_busfns); 1371.1Sthorpej} 1381.1Sthorpej 1391.1Sthorpejvoid 1401.1Sthorpejmcclock_jensenio_write(struct mcclock_softc *mcsc, u_int reg, u_int datum) 1411.1Sthorpej{ 1421.1Sthorpej struct mcclock_jensenio_softc *sc = (void *) mcsc; 1431.1Sthorpej bus_space_tag_t iot = sc->sc_iot; 1441.1Sthorpej bus_space_handle_t ioh = sc->sc_ioh; 1451.1Sthorpej 1461.1Sthorpej bus_space_write_1(iot, ioh, 0, reg); 1471.1Sthorpej bus_space_write_1(iot, ioh, 1, datum); 1481.1Sthorpej} 1491.1Sthorpej 1501.1Sthorpeju_int 1511.1Sthorpejmcclock_jensenio_read(struct mcclock_softc *mcsc, u_int reg) 1521.1Sthorpej{ 1531.1Sthorpej struct mcclock_jensenio_softc *sc = (void *) mcsc; 1541.1Sthorpej bus_space_tag_t iot = sc->sc_iot; 1551.1Sthorpej bus_space_handle_t ioh = sc->sc_ioh; 1561.1Sthorpej 1571.1Sthorpej bus_space_write_1(iot, ioh, 0, reg); 1581.1Sthorpej return bus_space_read_1(iot, ioh, 1); 1591.1Sthorpej} 160