a2kbbc.c revision 1.25
1/* $NetBSD: a2kbbc.c,v 1.25 2012/11/14 01:55:25 rkujawa Exp $ */ 2 3/* 4 * Copyright (c) 1988 University of Utah. 5 * Copyright (c) 1982, 1990 The Regents of the University of California. 6 * All rights reserved. 7 * 8 * This code is derived from software contributed to Berkeley by 9 * the Systems Programming Group of the University of Utah Computer 10 * Science Department. 11 * 12 * Redistribution and use in source and binary forms, with or without 13 * modification, are permitted provided that the following conditions 14 * are met: 15 * 1. Redistributions of source code must retain the above copyright 16 * notice, this list of conditions and the following disclaimer. 17 * 2. Redistributions in binary form must reproduce the above copyright 18 * notice, this list of conditions and the following disclaimer in the 19 * documentation and/or other materials provided with the distribution. 20 * 3. Neither the name of the University nor the names of its contributors 21 * may be used to endorse or promote products derived from this software 22 * without specific prior written permission. 23 * 24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34 * SUCH DAMAGE. 35 * 36 * from: Utah $Hdr: clock.c 1.18 91/01/21$ 37 * 38 * @(#)clock.c 7.6 (Berkeley) 5/7/91 39 */ 40 41#include <sys/cdefs.h> 42__KERNEL_RCSID(0, "$NetBSD: a2kbbc.c,v 1.25 2012/11/14 01:55:25 rkujawa Exp $"); 43 44#include <sys/param.h> 45#include <sys/kernel.h> 46#include <sys/device.h> 47#include <sys/systm.h> 48#include <sys/bus.h> 49#include <machine/psl.h> 50#include <machine/cpu.h> 51#include <amiga/amiga/device.h> 52#include <amiga/amiga/custom.h> 53#include <amiga/amiga/cia.h> 54#include <amiga/dev/zbusvar.h> 55 56#include <dev/clock_subr.h> 57 58#include <dev/ic/msm6242bvar.h> 59#include <dev/ic/msm6242breg.h> 60 61#define A2KBBC_ADDR 0xDC0000 /* XXX: possible D80000 on A2000 "A"? */ 62 63static int a2kbbc_match(device_t, cfdata_t, void *); 64static void a2kbbc_attach(device_t, device_t, void *); 65 66struct a2kbbc_softc { 67 struct msm6242b_softc sc_msm6242b; 68 struct bus_space_tag sc_bst; 69}; 70 71CFATTACH_DECL_NEW(a2kbbc, sizeof(struct a2kbbc_softc), 72 a2kbbc_match, a2kbbc_attach, NULL, NULL); 73 74static int 75a2kbbc_match(device_t parent, cfdata_t cf, void *aux) 76{ 77 //struct clock_ymdhms dt; 78 static int a2kbbc_matched = 0; 79 80 if (!matchname("a2kbbc", aux)) 81 return (0); 82 83 /* Allow only one instance. */ 84 if (a2kbbc_matched) 85 return (0); 86 87 if (/* is_a1200() || */ is_a3000() || is_a4000() 88#ifdef DRACO 89 || is_draco() 90#endif 91 ) 92 return (0); 93 94 a2kbbc_matched = 1; 95 return (1); 96} 97 98/* 99 * Attach us to the rtc function pointers. 100 */ 101void 102a2kbbc_attach(device_t parent, device_t self, void *aux) 103{ 104 struct a2kbbc_softc *sc; 105 struct msm6242b_softc *msc; 106 107 sc = device_private(self); 108 msc = &sc->sc_msm6242b; 109 msc->sc_dev = self; 110 111 sc->sc_bst.base = (bus_addr_t) __UNVOLATILE(ztwomap(A2KBBC_ADDR+1)); 112 sc->sc_bst.absm = &amiga_bus_stride_4; 113 114 msc->sc_iot = &sc->sc_bst; 115 116 if (bus_space_map(msc->sc_iot, 0, MSM6242B_SIZE, 0, &msc->sc_ioh)) { 117 aprint_error_dev(msc->sc_dev, "couldn't map registers\n"); 118 return; 119 } 120 121 msm6242b_attach(msc); 122} 123 124 125