diff options
author | Emmanuel Grumbach <emmanuel.grumbach@intel.com> | 2011-09-15 14:46:33 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2011-09-19 15:58:27 -0400 |
commit | eeb7f8cb93966250e5768ea9f8fec8830567c02a (patch) | |
tree | a2070a55b1240d9da4747e631481dc994bd1d5c1 /drivers/net/wireless/iwlwifi/iwl-bus.h | |
parent | 14991a9d8469ccac12c5d243e975d3ab78c8238a (diff) |
iwlagn: document the bus layer API
Add documentation to the bus layer API - iwl-bus.h
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/iwlwifi/iwl-bus.h')
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-bus.h | 62 |
1 files changed, 57 insertions, 5 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-bus.h b/drivers/net/wireless/iwlwifi/iwl-bus.h index 83aed46673e1..98535dfd29e7 100644 --- a/drivers/net/wireless/iwlwifi/iwl-bus.h +++ b/drivers/net/wireless/iwlwifi/iwl-bus.h | |||
@@ -63,18 +63,65 @@ | |||
63 | #ifndef __iwl_bus_h__ | 63 | #ifndef __iwl_bus_h__ |
64 | #define __iwl_bus_h__ | 64 | #define __iwl_bus_h__ |
65 | 65 | ||
66 | /*This file includes the declaration that are exported from the bus layer */ | ||
67 | |||
68 | #include <linux/types.h> | 66 | #include <linux/types.h> |
69 | #include <linux/spinlock.h> | 67 | #include <linux/spinlock.h> |
70 | 68 | ||
69 | /** | ||
70 | * DOC: Bus layer - role and goal | ||
71 | * | ||
72 | * iwl-bus.h defines the API to the bus layer of the iwlwifi driver. | ||
73 | * The bus layer is responsible for doing very basic bus operations that are | ||
74 | * listed in the iwl_bus_ops structure. | ||
75 | * The bus layer registers to the bus driver, advertises the supported HW and | ||
76 | * gets notifications about enumeration, suspend, resume. | ||
77 | * For the moment, the bus layer is not a linux kernel module as itself, and | ||
78 | * the module_init function of the driver must call the bus specific | ||
79 | * registration functions. These functions are listed at the end of this file. | ||
80 | * For the moment, there is only one implementation of this interface: PCI-e. | ||
81 | * This implementation is iwl-pci.c | ||
82 | */ | ||
83 | |||
84 | /** | ||
85 | * DOC: encapsulation and type safety | ||
86 | * | ||
87 | * The iwl_bus describes the data that is shared amongst all the bus layer | ||
88 | * implementations. This data is visible to other layers. Data in the bus | ||
89 | * specific area is not visible outside the bus specific implementation. | ||
90 | * iwl_bus holds a pointer to iwl_shared which holds pointer to all the other | ||
91 | * layers of the driver (iwl_priv, iwl_trans). In fact, this is the way to go | ||
92 | * when the transport layer needs to call a function of another layer. | ||
93 | * | ||
94 | * In order to achieve encapsulation, iwl_priv cannot be dereferenced from the | ||
95 | * bus layer. Type safety is still kept since functions that gets iwl_priv gets | ||
96 | * a typed pointer (as opposed to void *). | ||
97 | */ | ||
98 | |||
99 | /** | ||
100 | * DOC: probe flow | ||
101 | * | ||
102 | * The module_init calls the bus specific registration function. The | ||
103 | * registration to the bus layer will trigger an enumeration of the bus which | ||
104 | * will call the bus specific probe function. | ||
105 | * The first thing this function must do is to allocate the memory needed by | ||
106 | * iwl_bus + the bus_specific data. | ||
107 | * Once the bus specific probe function has configured the hardware, it | ||
108 | * chooses the appropriate transport layer and calls iwl_probe that will run | ||
109 | * the bus independent probe flow. | ||
110 | * | ||
111 | * Note: The bus specific code must set the following data in iwl_bus before it | ||
112 | * calls iwl_probe: | ||
113 | * * bus->dev | ||
114 | * * bus->irq | ||
115 | * * bus->ops | ||
116 | */ | ||
117 | |||
71 | struct iwl_shared; | 118 | struct iwl_shared; |
72 | struct iwl_bus; | 119 | struct iwl_bus; |
73 | 120 | ||
74 | /** | 121 | /** |
75 | * struct iwl_bus_ops - bus specific operations | 122 | * struct iwl_bus_ops - bus specific operations |
76 | * @get_pm_support: must returns true if the bus can go to sleep | 123 | * @get_pm_support: must returns true if the bus can go to sleep |
77 | * @apm_config: will be called during the config of the APM configuration | 124 | * @apm_config: will be called during the config of the APM |
78 | * @set_drv_data: set the shared data pointer to the bus layer | 125 | * @set_drv_data: set the shared data pointer to the bus layer |
79 | * @get_hw_id: prints the hw_id in the provided buffer | 126 | * @get_hw_id: prints the hw_id in the provided buffer |
80 | * @write8: write a byte to register at offset ofs | 127 | * @write8: write a byte to register at offset ofs |
@@ -93,14 +140,16 @@ struct iwl_bus_ops { | |||
93 | 140 | ||
94 | /** | 141 | /** |
95 | * struct iwl_bus - bus common data | 142 | * struct iwl_bus - bus common data |
96 | * @dev - pointer to struct device * that represent the device | 143 | * |
144 | * This data is common to all bus layer implementations. | ||
145 | * | ||
146 | * @dev - pointer to struct device * that represents the device | ||
97 | * @ops - pointer to iwl_bus_ops | 147 | * @ops - pointer to iwl_bus_ops |
98 | * @shrd - pointer to iwl_shared which holds shared data from the upper layer | 148 | * @shrd - pointer to iwl_shared which holds shared data from the upper layer |
99 | * @irq - the irq number for the device | 149 | * @irq - the irq number for the device |
100 | * @reg_lock - protect hw register access | 150 | * @reg_lock - protect hw register access |
101 | */ | 151 | */ |
102 | struct iwl_bus { | 152 | struct iwl_bus { |
103 | /* Common data to all buses */ | ||
104 | struct device *dev; | 153 | struct device *dev; |
105 | const struct iwl_bus_ops *ops; | 154 | const struct iwl_bus_ops *ops; |
106 | struct iwl_shared *shrd; | 155 | struct iwl_shared *shrd; |
@@ -149,6 +198,9 @@ static inline u32 bus_read32(struct iwl_bus *bus, u32 ofs) | |||
149 | return bus->ops->read32(bus, ofs); | 198 | return bus->ops->read32(bus, ofs); |
150 | } | 199 | } |
151 | 200 | ||
201 | /***************************************************** | ||
202 | * Bus layer registration functions | ||
203 | ******************************************************/ | ||
152 | int __must_check iwl_pci_register_driver(void); | 204 | int __must_check iwl_pci_register_driver(void); |
153 | void iwl_pci_unregister_driver(void); | 205 | void iwl_pci_unregister_driver(void); |
154 | 206 | ||