pxa2x0_pcic.h revision 1.2 1 /* $NetBSD: pxa2x0_pcic.h,v 1.2 2007/07/10 13:55:20 nonaka Exp $ */
2 /* $OpenBSD: pxapcicvar.h,v 1.7 2005/12/14 15:08:51 uwe Exp $ */
3
4 /*
5 * Copyright (c) 2005 Dale Rahn <drahn (at) openbsd.org>
6 *
7 * Permission to use, copy, modify, and distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
10 *
11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 */
19
20 #ifndef _PXA2X0_PCIC_H_
21 #define _PXA2X0_PCIC_H_
22
23 struct pxapcic_socket {
24 struct pxapcic_softc *sc;
25 int socket; /* socket number */
26 struct device *pcmcia;
27 struct lwp *event_thread;
28
29 int flags;
30 int power_capability; /* PXAPCIC_POWER_3V | PXAPCIC_POWER_5V */
31
32 int irqpin;
33 void *irq;
34
35 void *pcictag_cookie; /* opaque data for pcictag functions */
36 struct pxapcic_tag *pcictag;
37 };
38
39 /* event */
40 #define PXAPCIC_EVENT_INSERTION 0
41 #define PXAPCIC_EVENT_REMOVAL 1
42
43 /* flags */
44 #define PXAPCIC_FLAG_CARDD 0
45 #define PXAPCIC_FLAG_CARDP 1
46
47 struct pxapcic_tag {
48 u_int (*read)(struct pxapcic_socket *, int);
49 void (*write)(struct pxapcic_socket *, int, u_int);
50 void (*set_power)(struct pxapcic_socket *, int);
51 void (*clear_intr)(struct pxapcic_socket *);
52 void *(*intr_establish)(struct pxapcic_socket *, int,
53 int (*)(void *), void *);
54 void (*intr_disestablish)(struct pxapcic_socket *, void *);
55 };
56
57 /* pcictag registers and their values */
58 #define PXAPCIC_CARD_STATUS 0
59 #define PXAPCIC_CARD_INVALID 0
60 #define PXAPCIC_CARD_VALID 1
61 #define PXAPCIC_CARD_READY 1
62 #define PXAPCIC_CARD_POWER 2
63 #define PXAPCIC_POWER_OFF 0
64 #define PXAPCIC_POWER_3V 1
65 #define PXAPCIC_POWER_5V 2
66 #define PXAPCIC_CARD_RESET 3
67
68 #define PXAPCIC_NSLOT 2
69
70 struct pxapcic_softc {
71 struct device sc_dev;
72 struct pxapcic_socket sc_socket[PXAPCIC_NSLOT];
73
74 bus_space_tag_t sc_iot;
75 bus_space_handle_t sc_memctl_ioh;
76
77 void *sc_irq;
78 int sc_shutdown;
79 int sc_nslots;
80 int sc_irqpin[PXAPCIC_NSLOT];
81 int sc_irqcfpin[PXAPCIC_NSLOT];
82
83 u_int sc_flags;
84 #define PPF_REVERSE_ORDER (1 << 0)
85 };
86
87 void pxapcic_attach_common(struct pxapcic_softc *,
88 void (*socket_setup_hook)(struct pxapcic_socket *));
89 int pxapcic_intr(void *);
90 void pxapcic_create_event_thread(void *);
91
92 #endif /* _PXA2X0_PCIC_H_ */
93