Home | History | Annotate | Line # | Download | only in armadillo
armadillo9_pcic.c revision 1.1.118.1
      1  1.1.118.1      yamt /*	$NetBSD: armadillo9_pcic.c,v 1.1.118.1 2012/10/30 17:19:18 yamt Exp $	*/
      2        1.1  hamajima 
      3        1.1  hamajima /*
      4        1.1  hamajima  * Copyright (c) 2005 HAMAJIMA Katsuomi. All rights reserved.
      5        1.1  hamajima  *
      6        1.1  hamajima  * Redistribution and use in source and binary forms, with or without
      7        1.1  hamajima  * modification, are permitted provided that the following conditions
      8        1.1  hamajima  * are met:
      9        1.1  hamajima  * 1. Redistributions of source code must retain the above copyright
     10        1.1  hamajima  *    notice, this list of conditions and the following disclaimer.
     11        1.1  hamajima  * 2. Redistributions in binary form must reproduce the above copyright
     12        1.1  hamajima  *    notice, this list of conditions and the following disclaimer in the
     13        1.1  hamajima  *    documentation and/or other materials provided with the distribution.
     14        1.1  hamajima  *
     15        1.1  hamajima  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
     16        1.1  hamajima  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     17        1.1  hamajima  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     18        1.1  hamajima  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
     19        1.1  hamajima  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     20        1.1  hamajima  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     21        1.1  hamajima  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     22        1.1  hamajima  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     23        1.1  hamajima  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     24        1.1  hamajima  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     25        1.1  hamajima  * SUCH DAMAGE.
     26        1.1  hamajima  */
     27        1.1  hamajima 
     28        1.1  hamajima #include <sys/cdefs.h>
     29  1.1.118.1      yamt __KERNEL_RCSID(0, "$NetBSD: armadillo9_pcic.c,v 1.1.118.1 2012/10/30 17:19:18 yamt Exp $");
     30        1.1  hamajima 
     31        1.1  hamajima #include <sys/param.h>
     32        1.1  hamajima #include <sys/systm.h>
     33        1.1  hamajima #include <sys/kernel.h>
     34        1.1  hamajima #include <sys/device.h>
     35        1.1  hamajima #include <arm/ep93xx/epsocvar.h>
     36        1.1  hamajima #include <arm/ep93xx/epgpiovar.h>
     37        1.1  hamajima #include <arm/ep93xx/eppcicvar.h>
     38        1.1  hamajima 
     39        1.1  hamajima #ifdef A9PCIC_DEBUG
     40        1.1  hamajima int armadillo9pcic_debug = A9PCIC_DEBUG;
     41        1.1  hamajima #define DPRINTFN(n,x)	if (armadillo9pcic_debug>(n)) printf x;
     42        1.1  hamajima #else
     43        1.1  hamajima #define DPRINTFN(n,x)
     44        1.1  hamajima #endif
     45        1.1  hamajima 
     46  1.1.118.1      yamt static int armadillo9pcic_match(device_t, cfdata_t, void *);
     47  1.1.118.1      yamt static void armadillo9pcic_attach(device_t, device_t, void *);
     48        1.1  hamajima 
     49  1.1.118.1      yamt CFATTACH_DECL_NEW(armadillo9pcic, 0,
     50  1.1.118.1      yamt     armadillo9pcic_match, armadillo9pcic_attach, NULL, NULL);
     51        1.1  hamajima 
     52        1.1  hamajima static int armadillo9pcic_card_mode(void *, int);
     53        1.1  hamajima static int armadillo9pcic_power_capability(void *, int);
     54        1.1  hamajima static int armadillo9pcic_power_ctl(void *, int, int);
     55        1.1  hamajima 
     56        1.1  hamajima struct eppcic_chipset_tag armadillo9pcic_tag = {
     57        1.1  hamajima 	armadillo9pcic_card_mode,
     58        1.1  hamajima 	armadillo9pcic_power_capability,
     59        1.1  hamajima 	armadillo9pcic_power_ctl
     60        1.1  hamajima };
     61        1.1  hamajima 
     62        1.1  hamajima static int
     63  1.1.118.1      yamt armadillo9pcic_match(device_t parent, cfdata_t match, void *aux)
     64        1.1  hamajima {
     65        1.1  hamajima 	return 1;
     66        1.1  hamajima }
     67        1.1  hamajima 
     68        1.1  hamajima static void
     69  1.1.118.1      yamt armadillo9pcic_attach(device_t parent, device_t self, void *aux)
     70        1.1  hamajima {
     71        1.1  hamajima 	struct epsoc_attach_args *sa = aux;
     72        1.1  hamajima 
     73        1.1  hamajima 	epgpio_out(sa->sa_gpio, PORT_A, 3);
     74        1.1  hamajima 	eppcic_attach_common(parent, self, aux, &armadillo9pcic_tag);
     75        1.1  hamajima }
     76        1.1  hamajima 
     77        1.1  hamajima static int
     78        1.1  hamajima armadillo9pcic_card_mode(void *self, int socket)
     79        1.1  hamajima {
     80        1.1  hamajima 	if (socket == 0)
     81        1.1  hamajima 		return CF_MODE;
     82        1.1  hamajima 	else
     83        1.1  hamajima 		return SLOT_DISABLE;
     84        1.1  hamajima }
     85        1.1  hamajima 
     86        1.1  hamajima static int
     87        1.1  hamajima armadillo9pcic_power_capability(void *self, int socket)
     88        1.1  hamajima {
     89        1.1  hamajima 	int vcc = 0;
     90        1.1  hamajima 
     91        1.1  hamajima 	if (socket == 0)
     92        1.1  hamajima 		vcc |= VCC_3V;
     93        1.1  hamajima 	return vcc;
     94        1.1  hamajima }
     95        1.1  hamajima 
     96        1.1  hamajima static int
     97        1.1  hamajima armadillo9pcic_power_ctl(void *self, int socket, int onoff)
     98        1.1  hamajima {
     99  1.1.118.1      yamt 	struct eppcic_softc *sc = device_private(self);
    100        1.1  hamajima 
    101        1.1  hamajima 	DPRINTFN(1, ("armadillo9pcic_power_ctl: %s\n",onoff?"on":"off"));
    102        1.1  hamajima 
    103        1.1  hamajima 	if (onoff)
    104        1.1  hamajima 		epgpio_clear(sc->sc_gpio, PORT_A, 3);
    105        1.1  hamajima 	else
    106        1.1  hamajima 		epgpio_set(sc->sc_gpio, PORT_A, 3);
    107        1.1  hamajima 	return (300 * 1000);
    108        1.1  hamajima }
    109