1 /* $NetBSD: lubbock_pcic.c,v 1.4 2008/04/28 20:23:17 martin Exp $ */
4 * Copyright (c) 2001 The NetBSD Foundation, Inc.
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
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>
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
= {
70 sacpcic_intr_establish
,
71 sacpcic_intr_disestablish
74 CFATTACH_DECL_NEW(sacpcic
, sizeof(struct sacpcic_softc
),
75 sacpcic_match
, sacpcic_attach
, NULL
, NULL
);
78 sacpcic_match(device_t parent
, cfdata_t cf
, void *aux
)
84 lubbock_socket_setup(struct sapcic_socket
*sp
)
86 sp
->power_capability
= SAPCIC_POWER_5V
| SAPCIC_POWER_3V
;
87 sp
->pcictag
= &lubbock_sacpcic_functions
;
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
);
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
));
106 static const uint8_t vval_socket0
[] = {
107 /* for socket0 (pcmcia) */
112 static const uint16_t vval_socket1
[] = {
113 /* for socket1 (CF) */
119 if( arg
< 0 || SAPCIC_POWER_5V
< arg
)
120 panic("sacpcic_set_power: bogus arg\n");
122 switch( so
->socket
){
124 bus_space_write_4(sc
->sc_iot
, sc
->sc_ioh
, SACCGPIOA_DVR
,
129 tmp
= bus_space_read_2(bsc
->sc_iot
, bsc
->sc_obioreg_ioh
,
131 bus_space_write_2(bsc
->sc_iot
, bsc
->sc_obioreg_ioh
,
132 LUBBOCK_MISCWR
, (tmp
& 0x3fff) | vval_socket1
[arg
] );
136 aprint_normal("unknown socket number: %d\n", so
->socket
);