No empty .Rs/.Re
[netbsd-mini2440.git] / sys / arch / evbarm / lubbock / lubbock_pcic.c
blob8ed0180a053ff52d547fba66ae1712719e7d4f35
1 /* $NetBSD: lubbock_pcic.c,v 1.4 2008/04/28 20:23:17 martin Exp $ */
3 /*-
4 * Copyright (c) 2001 The NetBSD Foundation, Inc.
5 * All rights reserved.
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by IWAMOTO Toshihiro.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
32 #include <sys/cdefs.h>
33 __KERNEL_RCSID(0, "$NetBSD: lubbock_pcic.c,v 1.4 2008/04/28 20:23:17 martin Exp $");
35 #include <sys/param.h>
36 #include <sys/systm.h>
37 #include <sys/types.h>
38 #include <sys/conf.h>
39 #include <sys/file.h>
40 #include <sys/device.h>
41 #include <sys/kernel.h>
42 #include <sys/kthread.h>
43 #include <sys/malloc.h>
45 #include <machine/bus.h>
47 #include <dev/pcmcia/pcmciachip.h>
48 #include <dev/pcmcia/pcmciavar.h>
49 #include <arm/sa11x0/sa11x0_reg.h>
50 #include <arm/sa11x0/sa11x0_var.h>
51 #include <arm/sa11x0/sa1111_reg.h>
52 #include <arm/sa11x0/sa1111_var.h>
53 #include <arm/sa11x0/sa11x1_pcicreg.h>
54 #include <arm/sa11x0/sa11xx_pcicvar.h>
55 #include <arm/sa11x0/sa11x1_pcicvar.h>
57 #include <evbarm/lubbock/lubbock_reg.h>
58 #include <evbarm/lubbock/lubbock_var.h>
60 static int sacpcic_match(device_t, cfdata_t, void *);
61 static void sacpcic_attach(device_t, device_t, void *);
62 static void lubbock_set_power(struct sapcic_socket *so, int arg);
63 static void lubbock_socket_setup(struct sapcic_socket *sp);
65 static struct sapcic_tag lubbock_sacpcic_functions = {
66 sacpcic_read,
67 sacpcic_write,
68 lubbock_set_power,
69 sacpcic_clear_intr,
70 sacpcic_intr_establish,
71 sacpcic_intr_disestablish
74 CFATTACH_DECL_NEW(sacpcic, sizeof(struct sacpcic_softc),
75 sacpcic_match, sacpcic_attach, NULL, NULL);
77 static int
78 sacpcic_match(device_t parent, cfdata_t cf, void *aux)
80 return (1);
83 static void
84 lubbock_socket_setup(struct sapcic_socket *sp)
86 sp->power_capability = SAPCIC_POWER_5V | SAPCIC_POWER_3V;
87 sp->pcictag = &lubbock_sacpcic_functions;
90 static void
91 sacpcic_attach(device_t parent, device_t self, void *aux)
93 sacpcic_attach_common(device_private(parent),
94 device_private(self), aux, lubbock_socket_setup);
98 static void
99 lubbock_set_power(struct sapcic_socket *so, int arg)
101 struct sacc_softc *sc = so->pcictag_cookie;
102 struct obio_softc *bsc = device_private(device_parent(sc->sc_dev));
103 int s;
104 uint16_t tmp;
106 static const uint8_t vval_socket0[] = {
107 /* for socket0 (pcmcia) */
108 0x00, /* OFF */
109 0x08, /* 3.3V */
110 0x05, /* 5V */
112 static const uint16_t vval_socket1[] = {
113 /* for socket1 (CF) */
114 0x0000, /* OFF */
115 0x8000, /* 3.3V */
116 0x4000, /* 5V */
119 if( arg < 0 || SAPCIC_POWER_5V < arg )
120 panic("sacpcic_set_power: bogus arg\n");
122 switch( so->socket ){
123 case 0:
124 bus_space_write_4(sc->sc_iot, sc->sc_ioh, SACCGPIOA_DVR,
125 vval_socket0[arg]);
126 break;
127 case 1:
128 s = splhigh();
129 tmp = bus_space_read_2(bsc->sc_iot, bsc->sc_obioreg_ioh,
130 LUBBOCK_MISCWR);
131 bus_space_write_2(bsc->sc_iot, bsc->sc_obioreg_ioh,
132 LUBBOCK_MISCWR, (tmp & 0x3fff) | vval_socket1[arg] );
133 splx(s);
134 break;
135 default:
136 aprint_normal("unknown socket number: %d\n", so->socket);