Home | History | Annotate | Line # | Download | only in dev
mkclock_hb.c revision 1.2.4.4
      1  1.2.4.4  skrll /*	$NetBSD: mkclock_hb.c,v 1.2.4.4 2004/09/21 13:19:32 skrll Exp $	*/
      2  1.2.4.2  skrll 
      3  1.2.4.2  skrll /*-
      4  1.2.4.2  skrll  * Copyright (c) 1996 The NetBSD Foundation, Inc.
      5  1.2.4.2  skrll  * All rights reserved.
      6  1.2.4.2  skrll  *
      7  1.2.4.2  skrll  * This code is derived from software contributed to The NetBSD Foundation
      8  1.2.4.2  skrll  * by Jason R. Thorpe.
      9  1.2.4.2  skrll  *
     10  1.2.4.2  skrll  * Redistribution and use in source and binary forms, with or without
     11  1.2.4.2  skrll  * modification, are permitted provided that the following conditions
     12  1.2.4.2  skrll  * are met:
     13  1.2.4.2  skrll  * 1. Redistributions of source code must retain the above copyright
     14  1.2.4.2  skrll  *    notice, this list of conditions and the following disclaimer.
     15  1.2.4.2  skrll  * 2. Redistributions in binary form must reproduce the above copyright
     16  1.2.4.2  skrll  *    notice, this list of conditions and the following disclaimer in the
     17  1.2.4.2  skrll  *    documentation and/or other materials provided with the distribution.
     18  1.2.4.2  skrll  * 3. All advertising materials mentioning features or use of this software
     19  1.2.4.2  skrll  *    must display the following acknowledgement:
     20  1.2.4.2  skrll  *        This product includes software developed by the NetBSD
     21  1.2.4.2  skrll  *        Foundation, Inc. and its contributors.
     22  1.2.4.2  skrll  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23  1.2.4.2  skrll  *    contributors may be used to endorse or promote products derived
     24  1.2.4.2  skrll  *    from this software without specific prior written permission.
     25  1.2.4.2  skrll  *
     26  1.2.4.2  skrll  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27  1.2.4.2  skrll  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28  1.2.4.2  skrll  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29  1.2.4.2  skrll  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30  1.2.4.2  skrll  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31  1.2.4.2  skrll  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32  1.2.4.2  skrll  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33  1.2.4.2  skrll  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34  1.2.4.2  skrll  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35  1.2.4.2  skrll  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36  1.2.4.2  skrll  * POSSIBILITY OF SUCH DAMAGE.
     37  1.2.4.2  skrll  */
     38  1.2.4.2  skrll 
     39  1.2.4.2  skrll #include <sys/cdefs.h>
     40  1.2.4.4  skrll __KERNEL_RCSID(0, "$NetBSD: mkclock_hb.c,v 1.2.4.4 2004/09/21 13:19:32 skrll Exp $");
     41  1.2.4.2  skrll 
     42  1.2.4.2  skrll #include <sys/param.h>
     43  1.2.4.2  skrll #include <sys/kernel.h>
     44  1.2.4.2  skrll #include <sys/systm.h>
     45  1.2.4.2  skrll #include <sys/device.h>
     46  1.2.4.2  skrll 
     47  1.2.4.2  skrll #include <machine/cpu.h>
     48  1.2.4.2  skrll #include <machine/bus.h>
     49  1.2.4.2  skrll 
     50  1.2.4.2  skrll #include <dev/clock_subr.h>
     51  1.2.4.2  skrll #include <dev/ic/mk48txxreg.h>
     52  1.2.4.2  skrll #include <dev/ic/mk48txxvar.h>
     53  1.2.4.2  skrll 
     54  1.2.4.2  skrll #include <newsmips/dev/hbvar.h>
     55  1.2.4.2  skrll 
     56  1.2.4.2  skrll int  mkclock_hb_match(struct device *, struct cfdata  *, void *);
     57  1.2.4.2  skrll void mkclock_hb_attach(struct device *, struct device *, void *);
     58  1.2.4.2  skrll 
     59  1.2.4.2  skrll CFATTACH_DECL(mkclock_hb, sizeof(struct mk48txx_softc),
     60  1.2.4.2  skrll     mkclock_hb_match, mkclock_hb_attach, NULL, NULL);
     61  1.2.4.2  skrll 
     62  1.2.4.2  skrll extern struct cfdriver mkclock_cd;
     63  1.2.4.2  skrll 
     64  1.2.4.2  skrll int
     65  1.2.4.2  skrll mkclock_hb_match(parent, cf, aux)
     66  1.2.4.2  skrll 	struct device *parent;
     67  1.2.4.2  skrll 	struct cfdata *cf;
     68  1.2.4.2  skrll 	void *aux;
     69  1.2.4.2  skrll {
     70  1.2.4.2  skrll 	struct hb_attach_args *ha = aux;
     71  1.2.4.2  skrll 	static int mkclock_hb_matched;
     72  1.2.4.2  skrll 
     73  1.2.4.2  skrll 	/* Only one clock, please. */
     74  1.2.4.2  skrll 	if (mkclock_hb_matched)
     75  1.2.4.2  skrll 		return (0);
     76  1.2.4.2  skrll 
     77  1.2.4.2  skrll 	if (strcmp(ha->ha_name, mkclock_cd.cd_name))
     78  1.2.4.2  skrll 		return (0);
     79  1.2.4.2  skrll 
     80  1.2.4.2  skrll 	mkclock_hb_matched = 1;
     81  1.2.4.2  skrll 
     82  1.2.4.2  skrll 	return 1;
     83  1.2.4.2  skrll }
     84  1.2.4.2  skrll 
     85  1.2.4.2  skrll void
     86  1.2.4.2  skrll mkclock_hb_attach(parent, self, aux)
     87  1.2.4.2  skrll 	struct device *parent, *self;
     88  1.2.4.2  skrll 	void *aux;
     89  1.2.4.2  skrll {
     90  1.2.4.2  skrll 	struct mk48txx_softc *sc = (void *)self;
     91  1.2.4.2  skrll 	struct hb_attach_args *ha = aux;
     92  1.2.4.2  skrll 
     93  1.2.4.2  skrll 	if (bus_space_map(sc->sc_bst, (bus_addr_t)ha->ha_addr, MK48T02_CLKSZ,
     94  1.2.4.2  skrll 	    0, &sc->sc_bsh) != 0)
     95  1.2.4.2  skrll 		printf("can't map device space\n");
     96  1.2.4.2  skrll 
     97  1.2.4.2  skrll 	sc->sc_model = "mk48t02";
     98  1.2.4.2  skrll 	sc->sc_year0 = 1900;
     99  1.2.4.2  skrll 	mk48txx_attach(sc);
    100  1.2.4.2  skrll 
    101  1.2.4.2  skrll 	printf("\n");
    102  1.2.4.2  skrll 
    103  1.2.4.2  skrll 	todr_attach(&sc->sc_handle);
    104  1.2.4.2  skrll }
    105