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