11.1Skiyohara/*	$NetBSD: epockbd_windermere.c,v 1.1 2013/04/28 12:11:25 kiyohara Exp $	*/
21.1Skiyohara/*
31.1Skiyohara * Copyright (c) 2013 KIYOHARA Takashi
41.1Skiyohara * All rights reserved.
51.1Skiyohara *
61.1Skiyohara * Redistribution and use in source and binary forms, with or without
71.1Skiyohara * modification, are permitted provided that the following conditions
81.1Skiyohara * are met:
91.1Skiyohara * 1. Redistributions of source code must retain the above copyright
101.1Skiyohara *    notice, this list of conditions and the following disclaimer.
111.1Skiyohara * 2. Redistributions in binary form must reproduce the above copyright
121.1Skiyohara *    notice, this list of conditions and the following disclaimer in the
131.1Skiyohara *    documentation and/or other materials provided with the distribution.
141.1Skiyohara *
151.1Skiyohara * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
161.1Skiyohara * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
171.1Skiyohara * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
181.1Skiyohara * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
191.1Skiyohara * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
201.1Skiyohara * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
211.1Skiyohara * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
221.1Skiyohara * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
231.1Skiyohara * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
241.1Skiyohara * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
251.1Skiyohara * POSSIBILITY OF SUCH DAMAGE.
261.1Skiyohara */
271.1Skiyohara#include <sys/cdefs.h>
281.1Skiyohara__KERNEL_RCSID(0, "$NetBSD: epockbd_windermere.c,v 1.1 2013/04/28 12:11:25 kiyohara Exp $");
291.1Skiyohara
301.1Skiyohara#include <sys/param.h>
311.1Skiyohara#include <sys/bus.h>
321.1Skiyohara#include <sys/device.h>
331.1Skiyohara#include <sys/errno.h>
341.1Skiyohara
351.1Skiyohara#include <epoc32/windermere/windermerereg.h>
361.1Skiyohara#include <epoc32/windermere/windermerevar.h>
371.1Skiyohara#include <epoc32/dev/epockbdvar.h>
381.1Skiyohara
391.1Skiyohara#include "locators.h"
401.1Skiyohara
411.1Skiyoharastatic int epockbd_windermere_match(device_t, cfdata_t, void *);
421.1Skiyoharastatic void epockbd_windermere_attach(device_t, device_t, void *);
431.1Skiyohara
441.1SkiyoharaCFATTACH_DECL_NEW(epockbd_windermere, sizeof(struct epockbd_softc),
451.1Skiyohara    epockbd_windermere_match, epockbd_windermere_attach, NULL, NULL);
461.1Skiyohara
471.1Skiyoharastatic int
481.1Skiyoharaepockbd_windermere_match(device_t parent, cfdata_t match, void *aux)
491.1Skiyohara{
501.1Skiyohara	struct windermere_attach_args *aa = aux;
511.1Skiyohara
521.1Skiyohara        /* Wildcard not accept */
531.1Skiyohara	if (aa->aa_offset == WINDERMERECF_OFFSET_DEFAULT)
541.1Skiyohara		return 0;
551.1Skiyohara
561.1Skiyohara	return 1;
571.1Skiyohara}
581.1Skiyohara
591.1Skiyoharastatic void
601.1Skiyoharaepockbd_windermere_attach(device_t parent, device_t self, void *aux)
611.1Skiyohara{
621.1Skiyohara	struct epockbd_softc *sc = device_private(self);
631.1Skiyohara	struct windermere_attach_args *aa = aux;
641.1Skiyohara	bus_space_tag_t iot = aa->aa_iot;
651.1Skiyohara	bus_space_handle_t ioh = *aa->aa_ioh;
661.1Skiyohara	bus_addr_t gpio_addr;
671.1Skiyohara
681.1Skiyohara	sc->sc_dev = self;
691.1Skiyohara	sc->sc_kbd_ncolumn = 8;
701.1Skiyohara	sc->sc_kbd_nrow = 7;
711.1Skiyohara	if (windermere_bus_space_subregion(iot, ioh, aa->aa_offset,
721.1Skiyohara					sizeof(uint32_t), &sc->sc_scanh) != 0) {
731.1Skiyohara		aprint_error_dev(self, "can't map scan registers\n");
741.1Skiyohara		return;
751.1Skiyohara	}
761.1Skiyohara	gpio_addr = aa->aa_offset & ~0xff;	/* XXXX */
771.1Skiyohara	if (windermere_bus_space_subregion(iot, ioh, gpio_addr,
781.1Skiyohara					sizeof(uint32_t), &sc->sc_datah) != 0) {
791.1Skiyohara		aprint_error_dev(self, "can't map data registers\n");
801.1Skiyohara		return;
811.1Skiyohara	}
821.1Skiyohara	sc->sc_scant = iot;
831.1Skiyohara	sc->sc_datat = iot;
841.1Skiyohara
851.1Skiyohara	epockbd_attach(sc);
861.1Skiyohara}
87