Sync usage with man page.
[netbsd-mini2440.git] / sys / arch / arm / gemini / gemini_lpcvar.h
blob3d2c039796a68c751bab64891cf3b5a3f76dc9e8
1 /* $NetBSD: gemini_lpcvar.h,v 1.1 2008/11/09 09:15:42 cliff Exp $ */
3 #ifndef _ARM_GEMINI_LPCVAR_H
4 #define _ARM_GEMINI_LPCVAR_H
6 #include <sys/types.h>
7 #include <sys/device.h>
8 #include <machine/bus.h>
10 #define GEMINI_LPC_LDN_ALL -1 /* "global" LDN */
12 typedef void * lpctag_t;
13 typedef void * lpcintrtag_t;
15 typedef struct gemini_lpc_attach_args {
16 lpctag_t lpc_tag;
17 uint lpc_ldn;
18 bus_addr_t lpc_base;
19 bus_addr_t lpc_addr;
20 bus_size_t lpc_size;
21 uint lpc_intr;
22 bus_space_tag_t lpc_iot;
23 } gemini_lpc_attach_args_t;
25 /* la_flags */
26 #define LPC_FL_ENABLED 0x01 /* device is enabled */
28 typedef struct gemini_lpc_bus_ops {
29 uint8_t (*lpc_pnp_read)(lpctag_t, int, uint);
30 void (*lpc_pnp_write)(lpctag_t, int, uint, uint8_t);
31 void (*lpc_pnp_enter)(lpctag_t);
32 void (*lpc_pnp_exit)(lpctag_t);
33 void *(*lpc_intr_establish)(lpctag_t, uint, int, int,
34 int (*)(void *), void *);
35 void (*lpc_intr_disestablish)(lpctag_t, void *);
36 } gemini_lpc_bus_ops_t;
38 typedef struct gemini_lpc_softc {
39 struct device sc_dev;
40 bus_addr_t sc_addr;
41 bus_size_t sc_size;
42 int sc_intr;
43 bus_space_tag_t sc_iot;
44 bus_space_handle_t sc_ioh;
45 void *sc_lpchctag;
46 struct gemini_lpc_bus_ops *sc_bus_ops;
47 } gemini_lpc_softc_t;
50 static inline uint8_t
51 lpc_pnp_read(lpctag_t tag, int ldn, uint off)
53 gemini_lpc_softc_t *sc = tag;
54 return (*sc->sc_bus_ops->lpc_pnp_read)(tag, ldn, off);
57 static inline void
58 lpc_pnp_write(lpctag_t tag, int ldn, uint off, uint8_t val)
60 gemini_lpc_softc_t *sc = tag;
61 return (*sc->sc_bus_ops->lpc_pnp_write)(tag, ldn, off, val);
64 static inline void
65 lpc_pnp_enter(lpctag_t tag)
67 gemini_lpc_softc_t *sc = tag;
68 return (*sc->sc_bus_ops->lpc_pnp_enter)(tag);
71 static inline void
72 lpc_pnp_exit(lpctag_t tag)
74 gemini_lpc_softc_t *sc = tag;
75 return (*sc->sc_bus_ops->lpc_pnp_exit)(tag);
78 static inline void *
79 lpc_intr_establish(lpctag_t tag, uint intr, int ipl, int ist,
80 int (*func)(void *), void *arg)
82 gemini_lpc_softc_t *sc = tag;
83 void *ih;
85 ih = (*sc->sc_bus_ops->lpc_intr_establish)
86 (tag, intr, ipl, ist, func, arg);
88 return ih;
91 static inline void
92 lpc_intr_disestablish(lpctag_t tag, void *ih)
94 gemini_lpc_softc_t *sc = tag;
95 return (*sc->sc_bus_ops->lpc_intr_disestablish)(tag, ih);
102 #endif /* _ARM_GEMINI_LPCVAR_H */