11.26Srkujawa/* $NetBSD: a2kbbc.c,v 1.26 2013/01/27 19:58:04 rkujawa Exp $ */ 21.1Sis 31.1Sis/* 41.22Srmind * Copyright (c) 1988 University of Utah. 51.1Sis * Copyright (c) 1982, 1990 The Regents of the University of California. 61.1Sis * All rights reserved. 71.1Sis * 81.1Sis * This code is derived from software contributed to Berkeley by 91.1Sis * the Systems Programming Group of the University of Utah Computer 101.1Sis * Science Department. 111.1Sis * 121.1Sis * Redistribution and use in source and binary forms, with or without 131.1Sis * modification, are permitted provided that the following conditions 141.1Sis * are met: 151.1Sis * 1. Redistributions of source code must retain the above copyright 161.1Sis * notice, this list of conditions and the following disclaimer. 171.1Sis * 2. Redistributions in binary form must reproduce the above copyright 181.1Sis * notice, this list of conditions and the following disclaimer in the 191.1Sis * documentation and/or other materials provided with the distribution. 201.15Sagc * 3. Neither the name of the University nor the names of its contributors 211.15Sagc * may be used to endorse or promote products derived from this software 221.15Sagc * without specific prior written permission. 231.15Sagc * 241.15Sagc * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 251.15Sagc * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 261.15Sagc * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 271.15Sagc * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 281.15Sagc * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 291.15Sagc * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 301.15Sagc * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 311.15Sagc * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 321.15Sagc * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 331.15Sagc * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 341.15Sagc * SUCH DAMAGE. 351.15Sagc * 361.15Sagc * from: Utah $Hdr: clock.c 1.18 91/01/21$ 371.15Sagc * 381.15Sagc * @(#)clock.c 7.6 (Berkeley) 5/7/91 391.15Sagc */ 401.15Sagc 411.12Saymeric#include <sys/cdefs.h> 421.26Srkujawa__KERNEL_RCSID(0, "$NetBSD: a2kbbc.c,v 1.26 2013/01/27 19:58:04 rkujawa Exp $"); 431.1Sis 441.1Sis#include <sys/param.h> 451.1Sis#include <sys/kernel.h> 461.1Sis#include <sys/device.h> 471.1Sis#include <sys/systm.h> 481.25Srkujawa#include <sys/bus.h> 491.1Sis#include <machine/psl.h> 501.1Sis#include <machine/cpu.h> 511.1Sis#include <amiga/amiga/device.h> 521.1Sis#include <amiga/amiga/custom.h> 531.1Sis#include <amiga/amiga/cia.h> 541.1Sis#include <amiga/dev/zbusvar.h> 551.1Sis 561.1Sis#include <dev/clock_subr.h> 571.1Sis 581.25Srkujawa#include <dev/ic/msm6242bvar.h> 591.25Srkujawa#include <dev/ic/msm6242breg.h> 601.1Sis 611.25Srkujawa#define A2KBBC_ADDR 0xDC0000 /* XXX: possible D80000 on A2000 "A"? */ 621.25Srkujawa 631.25Srkujawastatic int a2kbbc_match(device_t, cfdata_t, void *); 641.25Srkujawastatic void a2kbbc_attach(device_t, device_t, void *); 651.25Srkujawa 661.25Srkujawastruct a2kbbc_softc { 671.25Srkujawa struct msm6242b_softc sc_msm6242b; 681.25Srkujawa struct bus_space_tag sc_bst; 691.25Srkujawa}; 701.25Srkujawa 711.25SrkujawaCFATTACH_DECL_NEW(a2kbbc, sizeof(struct a2kbbc_softc), 721.14Sthorpej a2kbbc_match, a2kbbc_attach, NULL, NULL); 731.1Sis 741.25Srkujawastatic int 751.24Schsa2kbbc_match(device_t parent, cfdata_t cf, void *aux) 761.1Sis{ 771.10Skleink static int a2kbbc_matched = 0; 781.10Skleink 791.24Schs if (!matchname("a2kbbc", aux)) 801.2Skleink return (0); 811.1Sis 821.10Skleink /* Allow only one instance. */ 831.10Skleink if (a2kbbc_matched) 841.10Skleink return (0); 851.1Sis 861.11Saymeric if (/* is_a1200() || */ is_a3000() || is_a4000() 871.3Sis#ifdef DRACO 881.3Sis || is_draco() 891.3Sis#endif 901.3Sis ) 911.2Skleink return (0); 921.1Sis 931.10Skleink a2kbbc_matched = 1; 941.2Skleink return (1); 951.1Sis} 961.1Sis 971.1Sis/* 981.1Sis * Attach us to the rtc function pointers. 991.1Sis */ 1001.1Sisvoid 1011.24Schsa2kbbc_attach(device_t parent, device_t self, void *aux) 1021.1Sis{ 1031.25Srkujawa struct a2kbbc_softc *sc; 1041.25Srkujawa struct msm6242b_softc *msc; 1051.1Sis 1061.25Srkujawa sc = device_private(self); 1071.25Srkujawa msc = &sc->sc_msm6242b; 1081.25Srkujawa msc->sc_dev = self; 1091.1Sis 1101.25Srkujawa sc->sc_bst.base = (bus_addr_t) __UNVOLATILE(ztwomap(A2KBBC_ADDR+1)); 1111.25Srkujawa sc->sc_bst.absm = &amiga_bus_stride_4; 1121.1Sis 1131.25Srkujawa msc->sc_iot = &sc->sc_bst; 1141.1Sis 1151.25Srkujawa if (bus_space_map(msc->sc_iot, 0, MSM6242B_SIZE, 0, &msc->sc_ioh)) { 1161.25Srkujawa aprint_error_dev(msc->sc_dev, "couldn't map registers\n"); 1171.25Srkujawa return; 1181.1Sis } 1191.1Sis 1201.25Srkujawa msm6242b_attach(msc); 1211.1Sis} 1221.1Sis 1231.1Sis 124