1 /* $NetBSD: gemini_lpcvar.h,v 1.2 2008/11/15 05:48:34 cliff Exp $ */ 2 3 #ifndef _ARM_GEMINI_LPCVAR_H 4 #define _ARM_GEMINI_LPCVAR_H 5 6 #include <sys/types.h> 7 #include <sys/device.h> 8 #include <machine/bus.h> 9 10 #define GEMINI_LPC_LDN_ALL -1 /* "global" LDN */ 11 12 typedef void * lpctag_t; 13 typedef void * lpcintrtag_t; 14 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; 24 25 /* la_flags */ 26 #define LPC_FL_ENABLED 0x01 /* device is enabled */ 27 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; 37 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; 48 49 50 static inline uint8_t 51 lpc_pnp_read(lpctag_t tag, int ldn, uint off) 52 { 53 gemini_lpc_softc_t *sc = tag; 54 return (*sc->sc_bus_ops->lpc_pnp_read)(tag, ldn, off); 55 } 56 57 static inline void 58 lpc_pnp_write(lpctag_t tag, int ldn, uint off, uint8_t val) 59 { 60 gemini_lpc_softc_t *sc = tag; 61 return (*sc->sc_bus_ops->lpc_pnp_write)(tag, ldn, off, val); 62 } 63 64 static inline void 65 lpc_pnp_enter(lpctag_t tag) 66 { 67 gemini_lpc_softc_t *sc = tag; 68 return (*sc->sc_bus_ops->lpc_pnp_enter)(tag); 69 } 70 71 static inline void 72 lpc_pnp_exit(lpctag_t tag) 73 { 74 gemini_lpc_softc_t *sc = tag; 75 return (*sc->sc_bus_ops->lpc_pnp_exit)(tag); 76 } 77 78 static inline void * 79 lpc_intr_establish(lpctag_t tag, uint intr, int ipl, int ist, 80 int (*func)(void *), void *arg) 81 { 82 gemini_lpc_softc_t *sc = tag; 83 void *ih; 84 85 ih = (*sc->sc_bus_ops->lpc_intr_establish) 86 (tag, intr, ipl, ist, func, arg); 87 88 return ih; 89 } 90 91 static inline void 92 lpc_intr_disestablish(lpctag_t tag, void *ih) 93 { 94 gemini_lpc_softc_t *sc = tag; 95 return (*sc->sc_bus_ops->lpc_intr_disestablish)(tag, ih); 96 } 97 98 99 100 101 102 #endif /* _ARM_GEMINI_LPCVAR_H */ 103