• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef EISA_H
2 #define EISA_H
3 
4 FILE_LICENCE ( GPL2_OR_LATER );
5 
6 #include <stdint.h>
7 #include <gpxe/isa_ids.h>
8 #include <gpxe/device.h>
9 #include <gpxe/tables.h>
10 
11 /*
12  * EISA constants
13  *
14  */
15 
16 #define EISA_MIN_SLOT (0x1)
17 #define EISA_MAX_SLOT (0xf)	/* Must be 2^n - 1 */
18 #define EISA_SLOT_BASE( n ) ( 0x1000 * (n) )
19 
20 #define EISA_VENDOR_ID ( 0xc80 )
21 #define EISA_PROD_ID ( 0xc82 )
22 #define EISA_GLOBAL_CONFIG ( 0xc84 )
23 
24 #define EISA_CMD_RESET ( 1 << 2 )
25 #define EISA_CMD_ENABLE ( 1 << 0 )
26 
27 /** An EISA device ID list entry */
28 struct eisa_device_id {
29 	/** Name */
30         const char *name;
31 	/** Manufacturer ID */
32 	uint16_t vendor_id;
33 	/** Product ID */
34 	uint16_t prod_id;
35 };
36 
37 /** An EISA device */
38 struct eisa_device {
39 	/** Generic device */
40 	struct device dev;
41 	/** Slot number */
42 	unsigned int slot;
43 	/** I/O address */
44 	uint16_t ioaddr;
45 	/** Manufacturer ID */
46 	uint16_t vendor_id;
47 	/** Product ID */
48 	uint16_t prod_id;
49 	/** Driver for this device */
50 	struct eisa_driver *driver;
51 	/** Driver-private data
52 	 *
53 	 * Use eisa_set_drvdata() and eisa_get_drvdata() to access
54 	 * this field.
55 	 */
56 	void *priv;
57 	/** Driver name */
58 	const char *driver_name;
59 };
60 
61 /** An EISA driver */
62 struct eisa_driver {
63 	/** EISA ID table */
64 	struct eisa_device_id *ids;
65 	/** Number of entries in EISA ID table */
66 	unsigned int id_count;
67 	/**
68 	 * Probe device
69 	 *
70 	 * @v eisa	EISA device
71 	 * @v id	Matching entry in ID table
72 	 * @ret rc	Return status code
73 	 */
74 	int ( * probe ) ( struct eisa_device *eisa,
75 			  const struct eisa_device_id *id );
76 	/**
77 	 * Remove device
78 	 *
79 	 * @v eisa	EISA device
80 	 */
81 	void ( * remove ) ( struct eisa_device *eisa );
82 };
83 
84 /** EISA driver table */
85 #define EISA_DRIVERS __table ( struct eisa_driver, "eisa_drivers" )
86 
87 /** Declare an EISA driver */
88 #define __eisa_driver __table_entry ( EISA_DRIVERS, 01 )
89 
90 extern void eisa_device_enabled ( struct eisa_device *eisa, int enabled );
91 
92 /**
93  * Enable EISA device
94  *
95  * @v eisa		EISA device
96  */
enable_eisa_device(struct eisa_device * eisa)97 static inline void enable_eisa_device ( struct eisa_device *eisa ) {
98 	eisa_device_enabled ( eisa, 1 );
99 }
100 
101 /**
102  * Disable EISA device
103  *
104  * @v eisa		EISA device
105  */
disable_eisa_device(struct eisa_device * eisa)106 static inline void disable_eisa_device ( struct eisa_device *eisa ) {
107 	eisa_device_enabled ( eisa, 0 );
108 }
109 
110 /**
111  * Set EISA driver-private data
112  *
113  * @v eisa		EISA device
114  * @v priv		Private data
115  */
eisa_set_drvdata(struct eisa_device * eisa,void * priv)116 static inline void eisa_set_drvdata ( struct eisa_device *eisa, void *priv ) {
117 	eisa->priv = priv;
118 }
119 
120 /**
121  * Get EISA driver-private data
122  *
123  * @v eisa		EISA device
124  * @ret priv		Private data
125  */
eisa_get_drvdata(struct eisa_device * eisa)126 static inline void * eisa_get_drvdata ( struct eisa_device *eisa ) {
127 	return eisa->priv;
128 }
129 
130 #endif /* EISA_H */
131