Home | History | Annotate | Line # | Download | only in dev
epockbd_clpssoc.c revision 1.1.12.2
      1  1.1.12.2  yamt /*	$NetBSD: epockbd_clpssoc.c,v 1.1.12.2 2014/05/22 11:39:38 yamt Exp $	*/
      2  1.1.12.2  yamt /*
      3  1.1.12.2  yamt  * Copyright (c) 2013 KIYOHARA Takashi
      4  1.1.12.2  yamt  * All rights reserved.
      5  1.1.12.2  yamt  *
      6  1.1.12.2  yamt  * Redistribution and use in source and binary forms, with or without
      7  1.1.12.2  yamt  * modification, are permitted provided that the following conditions
      8  1.1.12.2  yamt  * are met:
      9  1.1.12.2  yamt  * 1. Redistributions of source code must retain the above copyright
     10  1.1.12.2  yamt  *    notice, this list of conditions and the following disclaimer.
     11  1.1.12.2  yamt  * 2. Redistributions in binary form must reproduce the above copyright
     12  1.1.12.2  yamt  *    notice, this list of conditions and the following disclaimer in the
     13  1.1.12.2  yamt  *    documentation and/or other materials provided with the distribution.
     14  1.1.12.2  yamt  *
     15  1.1.12.2  yamt  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     16  1.1.12.2  yamt  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
     17  1.1.12.2  yamt  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
     18  1.1.12.2  yamt  * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
     19  1.1.12.2  yamt  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     20  1.1.12.2  yamt  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
     21  1.1.12.2  yamt  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     22  1.1.12.2  yamt  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     23  1.1.12.2  yamt  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
     24  1.1.12.2  yamt  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     25  1.1.12.2  yamt  * POSSIBILITY OF SUCH DAMAGE.
     26  1.1.12.2  yamt  */
     27  1.1.12.2  yamt #include <sys/cdefs.h>
     28  1.1.12.2  yamt __KERNEL_RCSID(0, "$NetBSD: epockbd_clpssoc.c,v 1.1.12.2 2014/05/22 11:39:38 yamt Exp $");
     29  1.1.12.2  yamt 
     30  1.1.12.2  yamt #include <sys/param.h>
     31  1.1.12.2  yamt #include <sys/bus.h>
     32  1.1.12.2  yamt #include <sys/device.h>
     33  1.1.12.2  yamt #include <sys/errno.h>
     34  1.1.12.2  yamt 
     35  1.1.12.2  yamt #include <arm/clps711x/clps711xreg.h>
     36  1.1.12.2  yamt #include <arm/clps711x/clpssocvar.h>
     37  1.1.12.2  yamt #include <epoc32/dev/epockbdvar.h>
     38  1.1.12.2  yamt 
     39  1.1.12.2  yamt #include "locators.h"
     40  1.1.12.2  yamt 
     41  1.1.12.2  yamt static int epockbd_clpssoc_match(device_t, cfdata_t, void *);
     42  1.1.12.2  yamt static void epockbd_clpssoc_attach(device_t, device_t, void *);
     43  1.1.12.2  yamt 
     44  1.1.12.2  yamt CFATTACH_DECL_NEW(epockbd_clpssoc, sizeof(struct epockbd_softc),
     45  1.1.12.2  yamt     epockbd_clpssoc_match, epockbd_clpssoc_attach, NULL, NULL);
     46  1.1.12.2  yamt 
     47  1.1.12.2  yamt static int
     48  1.1.12.2  yamt epockbd_clpssoc_match(device_t parent, cfdata_t match, void *aux)
     49  1.1.12.2  yamt {
     50  1.1.12.2  yamt 
     51  1.1.12.2  yamt 	return 1;
     52  1.1.12.2  yamt }
     53  1.1.12.2  yamt 
     54  1.1.12.2  yamt static void
     55  1.1.12.2  yamt epockbd_clpssoc_attach(device_t parent, device_t self, void *aux)
     56  1.1.12.2  yamt {
     57  1.1.12.2  yamt 	struct epockbd_softc *sc = device_private(self);
     58  1.1.12.2  yamt 	struct clpssoc_attach_args *aa = aux;
     59  1.1.12.2  yamt 	bus_space_tag_t iot = aa->aa_iot;
     60  1.1.12.2  yamt 	bus_space_handle_t ioh = *aa->aa_ioh;
     61  1.1.12.2  yamt 
     62  1.1.12.2  yamt 	sc->sc_dev = self;
     63  1.1.12.2  yamt 	sc->sc_kbd_ncolumn = 8;
     64  1.1.12.2  yamt 	sc->sc_kbd_nrow = 7;
     65  1.1.12.2  yamt 	if (bus_space_subregion(iot, ioh, PS711X_SYSCON, sizeof(uint32_t),
     66  1.1.12.2  yamt 							&sc->sc_scanh) != 0) {
     67  1.1.12.2  yamt 		aprint_error_dev(self, "can't map scan registers\n");
     68  1.1.12.2  yamt 		return;
     69  1.1.12.2  yamt 	}
     70  1.1.12.2  yamt 	if (bus_space_subregion(iot, ioh, PS711X_PADR, sizeof(uint32_t),
     71  1.1.12.2  yamt 							&sc->sc_datah) != 0) {
     72  1.1.12.2  yamt 		aprint_error_dev(self, "can't map data registers\n");
     73  1.1.12.2  yamt 		return;
     74  1.1.12.2  yamt 	}
     75  1.1.12.2  yamt 	sc->sc_scant = iot;
     76  1.1.12.2  yamt 	sc->sc_datat = iot;
     77  1.1.12.2  yamt 
     78  1.1.12.2  yamt 	epockbd_attach(sc);
     79  1.1.12.2  yamt }
     80