Home | History | Annotate | Line # | Download | only in gemini
      1 /*	$NetBSD: gemini_lpcvar.h,v 1.4 2012/10/27 17:17:38 chs 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 <sys/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 	bus_addr_t			sc_addr;
     40 	bus_size_t			sc_size;
     41 	int				sc_intr;
     42 	bus_space_tag_t			sc_iot;
     43 	bus_space_handle_t		sc_ioh;
     44 	void			       *sc_lpchctag;
     45 	struct gemini_lpc_bus_ops      *sc_bus_ops;
     46 } gemini_lpc_softc_t;
     47 
     48 
     49 static inline uint8_t
     50 lpc_pnp_read(lpctag_t tag, int ldn, uint off)
     51 {
     52 	gemini_lpc_softc_t *sc = tag;
     53 	return (*sc->sc_bus_ops->lpc_pnp_read)(tag, ldn, off);
     54 }
     55 
     56 static inline void
     57 lpc_pnp_write(lpctag_t tag, int ldn, uint off, uint8_t val)
     58 {
     59 	gemini_lpc_softc_t *sc = tag;
     60 	return (*sc->sc_bus_ops->lpc_pnp_write)(tag, ldn, off, val);
     61 }
     62 
     63 static inline void
     64 lpc_pnp_enter(lpctag_t tag)
     65 {
     66 	gemini_lpc_softc_t *sc = tag;
     67 	return (*sc->sc_bus_ops->lpc_pnp_enter)(tag);
     68 }
     69 
     70 static inline void
     71 lpc_pnp_exit(lpctag_t tag)
     72 {
     73 	gemini_lpc_softc_t *sc = tag;
     74 	return (*sc->sc_bus_ops->lpc_pnp_exit)(tag);
     75 }
     76 
     77 static inline void *
     78 lpc_intr_establish(lpctag_t tag, uint intr, int ipl, int ist,
     79 	int (*func)(void *), void *arg)
     80 {
     81 	gemini_lpc_softc_t *sc = tag;
     82 	void *ih;
     83 
     84 	ih = (*sc->sc_bus_ops->lpc_intr_establish)
     85 		(tag, intr, ipl, ist, func, arg);
     86 
     87 	return ih;
     88 }
     89 
     90 static inline void
     91 lpc_intr_disestablish(lpctag_t tag, void *ih)
     92 {
     93 	gemini_lpc_softc_t *sc = tag;
     94 	return (*sc->sc_bus_ops->lpc_intr_disestablish)(tag, ih);
     95 }
     96 
     97 
     98 
     99 
    100 
    101 #endif	/* _ARM_GEMINI_LPCVAR_H */
    102