1 /* $NetBSD: j720pcic.c,v 1.5 2008/04/28 20:23:21 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 /* Jornada 720 PCMCIA support. */
34 #include <sys/cdefs.h>
35 __KERNEL_RCSID(0, "$NetBSD: j720pcic.c,v 1.5 2008/04/28 20:23:21 martin Exp $");
37 #include <sys/param.h>
38 #include <sys/systm.h>
39 #include <sys/types.h>
42 #include <sys/device.h>
43 #include <sys/kernel.h>
44 #include <sys/kthread.h>
45 #include <sys/malloc.h>
47 #include <machine/bus.h>
48 #include <machine/platid.h>
49 #include <machine/platid_mask.h>
51 #include <dev/pcmcia/pcmciachip.h>
52 #include <dev/pcmcia/pcmciavar.h>
54 #include <arm/sa11x0/sa11x0_reg.h>
55 #include <arm/sa11x0/sa11x0_var.h>
56 #include <arm/sa11x0/sa1111_reg.h>
57 #include <arm/sa11x0/sa1111_var.h>
58 #include <arm/sa11x0/sa11x1_pcicreg.h>
59 #include <arm/sa11x0/sa11xx_pcicvar.h>
60 #include <arm/sa11x0/sa11x1_pcicvar.h>
64 static int sacpcic_match(device_t
, cfdata_t
, void *);
65 static void sacpcic_attach(device_t
, device_t
, void *);
67 static void j720_socket_setup(struct sapcic_socket
*);
68 static void j720_set_power(struct sapcic_socket
*, int);
70 static struct sapcic_tag j720_sacpcic_functions
= {
75 sacpcic_intr_establish
,
76 sacpcic_intr_disestablish
79 static int j720_power_capability
[] = {
80 SAPCIC_POWER_5V
| SAPCIC_POWER_3V
, SAPCIC_POWER_3V
83 static struct platid_data sacpcic_platid_table
[] = {
84 { &platid_mask_MACH_HP_JORNADA_7XX
, j720_power_capability
},
88 CFATTACH_DECL_NEW(sacpcic
, sizeof(struct sacpcic_softc
),
89 sacpcic_match
, sacpcic_attach
, NULL
, NULL
);
93 sacpcic_match(device_t parent
, cfdata_t cf
, void *aux
)
100 sacpcic_attach(device_t parent
, device_t self
, void *aux
)
103 sacpcic_attach_common(device_private(parent
),
104 device_private(self
), aux
, j720_socket_setup
);
108 j720_socket_setup(struct sapcic_socket
*sp
)
111 struct platid_data
*p
;
112 int socket
= sp
->socket
;
114 p
= platid_search_data(&platid
, sacpcic_platid_table
);
117 sp
->power_capability
= SAPCIC_POWER_5V
;
120 sp
->power_capability
= ip
[socket
];
123 sp
->pcictag
= &j720_sacpcic_functions
;
127 j720_set_power(struct sapcic_socket
*so
, int arg
)
129 int newval
, oldval
, s
;
130 struct sacc_softc
*sc
= so
->pcictag_cookie
;
132 /* XXX this isn't well confirmed. DANGER DANGER */
134 case SAPCIC_POWER_OFF
:
137 case SAPCIC_POWER_3V
:
140 case SAPCIC_POWER_5V
:
144 panic("j720_set_power: bogus arg (%d)", arg
);
148 oldval
= bus_space_read_4(sc
->sc_iot
, sc
->sc_ioh
, SACCGPIOA_DVR
);
150 switch (so
->socket
) {
152 newval
= newval
| (oldval
& 0xc);
155 newval
= (newval
<< 2) | (oldval
& 3);
159 panic("j720_set_power: bogus socket (%d)", so
->socket
);
161 bus_space_write_4(sc
->sc_iot
, sc
->sc_ioh
, SACCGPIOA_DVR
, newval
);