1 /* 2 * MCA bus driver code 3 * 4 * Abstracted from 3c509.c. 5 * 6 */ 7 8 FILE_LICENCE ( GPL2_OR_LATER ); 9 10 #ifndef MCA_H 11 #define MCA_H 12 13 #include <gpxe/isa_ids.h> 14 #include <gpxe/device.h> 15 #include <gpxe/tables.h> 16 17 /* 18 * MCA constants 19 * 20 */ 21 #define MCA_MOTHERBOARD_SETUP_REG 0x94 22 #define MCA_ADAPTER_SETUP_REG 0x96 23 #define MCA_MAX_SLOT_NR 0x07 /* Must be 2^n - 1 */ 24 #define MCA_POS_REG(n) (0x100+(n)) 25 26 /* Is there a standard that would define this? */ 27 #define GENERIC_MCA_VENDOR ISA_VENDOR ( 'M', 'C', 'A' ) 28 29 /** An MCA device ID list entry */ 30 struct mca_device_id { 31 /** Name */ 32 const char *name; 33 /** Device ID */ 34 uint16_t id; 35 }; 36 37 /** An MCA device */ 38 struct mca_device { 39 /** Generic device */ 40 struct device dev; 41 /** Slot number */ 42 unsigned int slot; 43 /** POS register values */ 44 unsigned char pos[8]; 45 /** Driver for this device */ 46 struct mca_driver *driver; 47 /** Driver-private data 48 * 49 * Use mca_set_drvdata() and mca_get_drvdata() to access 50 * this field. 51 */ 52 void *priv; 53 /** Driver name */ 54 const char *driver_name; 55 }; 56 57 #define MCA_ID(mca) ( ( (mca)->pos[1] << 8 ) + (mca)->pos[0] ) 58 59 /** An MCA driver */ 60 struct mca_driver { 61 /** MCA ID table */ 62 struct mca_device_id *ids; 63 /** Number of entries in MCA ID table */ 64 unsigned int id_count; 65 /** 66 * Probe device 67 * 68 * @v mca MCA device 69 * @v id Matching entry in ID table 70 * @ret rc Return status code 71 */ 72 int ( * probe ) ( struct mca_device *mca, 73 const struct mca_device_id *id ); 74 /** 75 * Remove device 76 * 77 * @v mca MCA device 78 */ 79 void ( * remove ) ( struct mca_device *mca ); 80 }; 81 82 /** MCA driver table */ 83 #define MCA_DRIVERS __table ( struct mca_driver, "mca_drivers" ) 84 85 /** Declare an MCA driver */ 86 #define __mca_driver __table_entry ( MCA_DRIVERS, 01 ) 87 88 /** 89 * Set MCA driver-private data 90 * 91 * @v mca MCA device 92 * @v priv Private data 93 */ mca_set_drvdata(struct mca_device * mca,void * priv)94static inline void mca_set_drvdata ( struct mca_device *mca, void *priv ) { 95 mca->priv = priv; 96 } 97 98 /** 99 * Get MCA driver-private data 100 * 101 * @v mca MCA device 102 * @ret priv Private data 103 */ mca_get_drvdata(struct mca_device * mca)104static inline void * mca_get_drvdata ( struct mca_device *mca ) { 105 return mca->priv; 106 } 107 108 #endif 109