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