diff options
author | Emmanuel Grumbach <emmanuel.grumbach@intel.com> | 2012-01-03 06:48:07 -0500 |
---|---|---|
committer | Wey-Yi Guy <wey-yi.w.guy@intel.com> | 2012-02-02 17:35:38 -0500 |
commit | 0390549571cb614ac5cd3327b63f95155a75c673 (patch) | |
tree | 071b5eb231ba835f3b4da2b1347f1d0673bd3deb /drivers/net | |
parent | a42a184458ae95937893cb873c988385637c5e14 (diff) |
iwlwifi: the read / write register ops move to transport
Most of the accesses to the registers are done from the transport layer.
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Diffstat (limited to 'drivers/net')
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-bus.h | 21 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-io.h | 11 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-pci.c | 22 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-trans-pcie.c | 37 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-trans.h | 21 |
5 files changed, 48 insertions, 64 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-bus.h b/drivers/net/wireless/iwlwifi/iwl-bus.h index 37ed7b60aaf6..981f7b79d395 100644 --- a/drivers/net/wireless/iwlwifi/iwl-bus.h +++ b/drivers/net/wireless/iwlwifi/iwl-bus.h | |||
@@ -124,18 +124,12 @@ struct iwl_bus; | |||
124 | * @apm_config: will be called during the config of the APM | 124 | * @apm_config: will be called during the config of the APM |
125 | * @get_hw_id_string: prints the hw_id in the provided buffer | 125 | * @get_hw_id_string: prints the hw_id in the provided buffer |
126 | * @get_hw_id: get hw_id in u32 | 126 | * @get_hw_id: get hw_id in u32 |
127 | * @write8: write a byte to register at offset ofs | ||
128 | * @write32: write a dword to register at offset ofs | ||
129 | * @wread32: read a dword at register at offset ofs | ||
130 | */ | 127 | */ |
131 | struct iwl_bus_ops { | 128 | struct iwl_bus_ops { |
132 | bool (*get_pm_support)(struct iwl_bus *bus); | 129 | bool (*get_pm_support)(struct iwl_bus *bus); |
133 | void (*apm_config)(struct iwl_bus *bus); | 130 | void (*apm_config)(struct iwl_bus *bus); |
134 | void (*get_hw_id_string)(struct iwl_bus *bus, char buf[], int buf_len); | 131 | void (*get_hw_id_string)(struct iwl_bus *bus, char buf[], int buf_len); |
135 | u32 (*get_hw_id)(struct iwl_bus *bus); | 132 | u32 (*get_hw_id)(struct iwl_bus *bus); |
136 | void (*write8)(struct iwl_bus *bus, u32 ofs, u8 val); | ||
137 | void (*write32)(struct iwl_bus *bus, u32 ofs, u32 val); | ||
138 | u32 (*read32)(struct iwl_bus *bus, u32 ofs); | ||
139 | }; | 133 | }; |
140 | 134 | ||
141 | /** | 135 | /** |
@@ -183,21 +177,6 @@ static inline u32 bus_get_hw_id(struct iwl_bus *bus) | |||
183 | return bus->ops->get_hw_id(bus); | 177 | return bus->ops->get_hw_id(bus); |
184 | } | 178 | } |
185 | 179 | ||
186 | static inline void bus_write8(struct iwl_bus *bus, u32 ofs, u8 val) | ||
187 | { | ||
188 | bus->ops->write8(bus, ofs, val); | ||
189 | } | ||
190 | |||
191 | static inline void bus_write32(struct iwl_bus *bus, u32 ofs, u32 val) | ||
192 | { | ||
193 | bus->ops->write32(bus, ofs, val); | ||
194 | } | ||
195 | |||
196 | static inline u32 bus_read32(struct iwl_bus *bus, u32 ofs) | ||
197 | { | ||
198 | return bus->ops->read32(bus, ofs); | ||
199 | } | ||
200 | |||
201 | /***************************************************** | 180 | /***************************************************** |
202 | * Bus layer registration functions | 181 | * Bus layer registration functions |
203 | ******************************************************/ | 182 | ******************************************************/ |
diff --git a/drivers/net/wireless/iwlwifi/iwl-io.h b/drivers/net/wireless/iwlwifi/iwl-io.h index 427d065435c8..b8e00cd7b1f7 100644 --- a/drivers/net/wireless/iwlwifi/iwl-io.h +++ b/drivers/net/wireless/iwlwifi/iwl-io.h | |||
@@ -31,23 +31,28 @@ | |||
31 | 31 | ||
32 | #include "iwl-devtrace.h" | 32 | #include "iwl-devtrace.h" |
33 | #include "iwl-shared.h" | 33 | #include "iwl-shared.h" |
34 | /* TODO: remove when not needed any more */ | ||
34 | #include "iwl-bus.h" | 35 | #include "iwl-bus.h" |
36 | #include "iwl-trans.h" | ||
35 | 37 | ||
36 | static inline void iwl_write8(struct iwl_bus *bus, u32 ofs, u8 val) | 38 | static inline void iwl_write8(struct iwl_bus *bus, u32 ofs, u8 val) |
37 | { | 39 | { |
40 | /* TODO: get trans instead of bus */ | ||
38 | trace_iwlwifi_dev_iowrite8(priv(bus), ofs, val); | 41 | trace_iwlwifi_dev_iowrite8(priv(bus), ofs, val); |
39 | bus_write8(bus, ofs, val); | 42 | iwl_trans_write8(trans(bus), ofs, val); |
40 | } | 43 | } |
41 | 44 | ||
42 | static inline void iwl_write32(struct iwl_bus *bus, u32 ofs, u32 val) | 45 | static inline void iwl_write32(struct iwl_bus *bus, u32 ofs, u32 val) |
43 | { | 46 | { |
47 | /* TODO: get trans instead of bus */ | ||
44 | trace_iwlwifi_dev_iowrite32(priv(bus), ofs, val); | 48 | trace_iwlwifi_dev_iowrite32(priv(bus), ofs, val); |
45 | bus_write32(bus, ofs, val); | 49 | iwl_trans_write32(trans(bus), ofs, val); |
46 | } | 50 | } |
47 | 51 | ||
48 | static inline u32 iwl_read32(struct iwl_bus *bus, u32 ofs) | 52 | static inline u32 iwl_read32(struct iwl_bus *bus, u32 ofs) |
49 | { | 53 | { |
50 | u32 val = bus_read32(bus, ofs); | 54 | /* TODO: get trans instead of bus */ |
55 | u32 val = iwl_trans_read32(trans(bus), ofs); | ||
51 | trace_iwlwifi_dev_ioread32(priv(bus), ofs, val); | 56 | trace_iwlwifi_dev_ioread32(priv(bus), ofs, val); |
52 | return val; | 57 | return val; |
53 | } | 58 | } |
diff --git a/drivers/net/wireless/iwlwifi/iwl-pci.c b/drivers/net/wireless/iwlwifi/iwl-pci.c index 631b67ca2b6b..ab462337d7a7 100644 --- a/drivers/net/wireless/iwlwifi/iwl-pci.c +++ b/drivers/net/wireless/iwlwifi/iwl-pci.c | |||
@@ -79,9 +79,6 @@ | |||
79 | struct iwl_pci_bus { | 79 | struct iwl_pci_bus { |
80 | /* basic pci-network driver stuff */ | 80 | /* basic pci-network driver stuff */ |
81 | struct pci_dev *pci_dev; | 81 | struct pci_dev *pci_dev; |
82 | |||
83 | /* pci hardware address support */ | ||
84 | void __iomem *hw_base; | ||
85 | }; | 82 | }; |
86 | 83 | ||
87 | #define IWL_BUS_GET_PCI_BUS(_iwl_bus) \ | 84 | #define IWL_BUS_GET_PCI_BUS(_iwl_bus) \ |
@@ -151,30 +148,11 @@ static u32 iwl_pci_get_hw_id(struct iwl_bus *bus) | |||
151 | return (pci_dev->device << 16) + pci_dev->subsystem_device; | 148 | return (pci_dev->device << 16) + pci_dev->subsystem_device; |
152 | } | 149 | } |
153 | 150 | ||
154 | static void iwl_pci_write8(struct iwl_bus *bus, u32 ofs, u8 val) | ||
155 | { | ||
156 | iowrite8(val, IWL_BUS_GET_PCI_BUS(bus)->hw_base + ofs); | ||
157 | } | ||
158 | |||
159 | static void iwl_pci_write32(struct iwl_bus *bus, u32 ofs, u32 val) | ||
160 | { | ||
161 | iowrite32(val, IWL_BUS_GET_PCI_BUS(bus)->hw_base + ofs); | ||
162 | } | ||
163 | |||
164 | static u32 iwl_pci_read32(struct iwl_bus *bus, u32 ofs) | ||
165 | { | ||
166 | u32 val = ioread32(IWL_BUS_GET_PCI_BUS(bus)->hw_base + ofs); | ||
167 | return val; | ||
168 | } | ||
169 | |||
170 | static const struct iwl_bus_ops bus_ops_pci = { | 151 | static const struct iwl_bus_ops bus_ops_pci = { |
171 | .get_pm_support = iwl_pci_is_pm_supported, | 152 | .get_pm_support = iwl_pci_is_pm_supported, |
172 | .apm_config = iwl_pci_apm_config, | 153 | .apm_config = iwl_pci_apm_config, |
173 | .get_hw_id_string = iwl_pci_get_hw_id_string, | 154 | .get_hw_id_string = iwl_pci_get_hw_id_string, |
174 | .get_hw_id = iwl_pci_get_hw_id, | 155 | .get_hw_id = iwl_pci_get_hw_id, |
175 | .write8 = iwl_pci_write8, | ||
176 | .write32 = iwl_pci_write32, | ||
177 | .read32 = iwl_pci_read32, | ||
178 | }; | 156 | }; |
179 | 157 | ||
180 | #define IWL_PCI_DEVICE(dev, subdev, cfg) \ | 158 | #define IWL_PCI_DEVICE(dev, subdev, cfg) \ |
diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c index 5d0cfe033407..80f531844f3e 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c | |||
@@ -1299,6 +1299,22 @@ static int iwl_trans_pcie_reclaim(struct iwl_trans *trans, int sta_id, int tid, | |||
1299 | return 0; | 1299 | return 0; |
1300 | } | 1300 | } |
1301 | 1301 | ||
1302 | static void iwl_trans_pcie_write8(struct iwl_trans *trans, u32 ofs, u8 val) | ||
1303 | { | ||
1304 | iowrite8(val, IWL_TRANS_GET_PCIE_TRANS(trans)->hw_base + ofs); | ||
1305 | } | ||
1306 | |||
1307 | static void iwl_trans_pcie_write32(struct iwl_trans *trans, u32 ofs, u32 val) | ||
1308 | { | ||
1309 | iowrite32(val, IWL_TRANS_GET_PCIE_TRANS(trans)->hw_base + ofs); | ||
1310 | } | ||
1311 | |||
1312 | static u32 iwl_trans_pcie_read32(struct iwl_trans *trans, u32 ofs) | ||
1313 | { | ||
1314 | u32 val = ioread32(IWL_TRANS_GET_PCIE_TRANS(trans)->hw_base + ofs); | ||
1315 | return val; | ||
1316 | } | ||
1317 | |||
1302 | static void iwl_trans_pcie_free(struct iwl_trans *trans) | 1318 | static void iwl_trans_pcie_free(struct iwl_trans *trans) |
1303 | { | 1319 | { |
1304 | struct iwl_trans_pcie *trans_pcie = | 1320 | struct iwl_trans_pcie *trans_pcie = |
@@ -1935,22 +1951,11 @@ const struct iwl_trans_ops trans_ops_pcie = { | |||
1935 | .suspend = iwl_trans_pcie_suspend, | 1951 | .suspend = iwl_trans_pcie_suspend, |
1936 | .resume = iwl_trans_pcie_resume, | 1952 | .resume = iwl_trans_pcie_resume, |
1937 | #endif | 1953 | #endif |
1954 | .write8 = iwl_trans_pcie_write8, | ||
1955 | .write32 = iwl_trans_pcie_write32, | ||
1956 | .read32 = iwl_trans_pcie_read32, | ||
1938 | }; | 1957 | }; |
1939 | 1958 | ||
1940 | /* TODO: remove this hack - will be possible when all the io{write/read} ops | ||
1941 | * will be done through the transport | ||
1942 | */ | ||
1943 | struct iwl_pci_bus { | ||
1944 | /* basic pci-network driver stuff */ | ||
1945 | struct pci_dev *pci_dev; | ||
1946 | |||
1947 | /* pci hardware address support */ | ||
1948 | void __iomem *hw_base; | ||
1949 | }; | ||
1950 | |||
1951 | #define IWL_BUS_GET_PCI_BUS(_iwl_bus) \ | ||
1952 | ((struct iwl_pci_bus *) ((_iwl_bus)->bus_specific)) | ||
1953 | |||
1954 | /* PCI registers */ | 1959 | /* PCI registers */ |
1955 | #define PCI_CFG_RETRY_TIMEOUT 0x041 | 1960 | #define PCI_CFG_RETRY_TIMEOUT 0x041 |
1956 | 1961 | ||
@@ -1958,7 +1963,6 @@ struct iwl_trans *iwl_trans_pcie_alloc(struct iwl_shared *shrd, | |||
1958 | struct pci_dev *pdev, | 1963 | struct pci_dev *pdev, |
1959 | const struct pci_device_id *ent) | 1964 | const struct pci_device_id *ent) |
1960 | { | 1965 | { |
1961 | struct iwl_pci_bus *iwl_pci_bus = IWL_BUS_GET_PCI_BUS(shrd->bus); | ||
1962 | struct iwl_trans_pcie *trans_pcie; | 1966 | struct iwl_trans_pcie *trans_pcie; |
1963 | struct iwl_trans *trans; | 1967 | struct iwl_trans *trans; |
1964 | u16 pci_cmd; | 1968 | u16 pci_cmd; |
@@ -2018,9 +2022,6 @@ struct iwl_trans *iwl_trans_pcie_alloc(struct iwl_shared *shrd, | |||
2018 | goto out_pci_release_regions; | 2022 | goto out_pci_release_regions; |
2019 | } | 2023 | } |
2020 | 2024 | ||
2021 | /* TODO: remove this hack */ | ||
2022 | iwl_pci_bus->hw_base = trans_pcie->hw_base; | ||
2023 | |||
2024 | dev_printk(KERN_INFO, &pdev->dev, | 2025 | dev_printk(KERN_INFO, &pdev->dev, |
2025 | "pci_resource_len = 0x%08llx\n", | 2026 | "pci_resource_len = 0x%08llx\n", |
2026 | (unsigned long long) pci_resource_len(pdev, 0)); | 2027 | (unsigned long long) pci_resource_len(pdev, 0)); |
diff --git a/drivers/net/wireless/iwlwifi/iwl-trans.h b/drivers/net/wireless/iwlwifi/iwl-trans.h index 9a8076194868..0a3727dac6ac 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans.h +++ b/drivers/net/wireless/iwlwifi/iwl-trans.h | |||
@@ -158,6 +158,9 @@ struct iwl_host_cmd { | |||
158 | * automatically deleted. | 158 | * automatically deleted. |
159 | * @suspend: stop the device unless WoWLAN is configured | 159 | * @suspend: stop the device unless WoWLAN is configured |
160 | * @resume: resume activity of the device | 160 | * @resume: resume activity of the device |
161 | * @write8: write a u8 to a register at offset ofs from the BAR | ||
162 | * @write32: write a u32 to a register at offset ofs from the BAR | ||
163 | * @read32: read a u32 register at offset ofs from the BAR | ||
161 | */ | 164 | */ |
162 | struct iwl_trans_ops { | 165 | struct iwl_trans_ops { |
163 | 166 | ||
@@ -201,6 +204,9 @@ struct iwl_trans_ops { | |||
201 | int (*suspend)(struct iwl_trans *trans); | 204 | int (*suspend)(struct iwl_trans *trans); |
202 | int (*resume)(struct iwl_trans *trans); | 205 | int (*resume)(struct iwl_trans *trans); |
203 | #endif | 206 | #endif |
207 | void (*write8)(struct iwl_trans *trans, u32 ofs, u8 val); | ||
208 | void (*write32)(struct iwl_trans *trans, u32 ofs, u32 val); | ||
209 | u32 (*read32)(struct iwl_trans *trans, u32 ofs); | ||
204 | }; | 210 | }; |
205 | 211 | ||
206 | /* one for each uCode image (inst/data, boot/init/runtime) */ | 212 | /* one for each uCode image (inst/data, boot/init/runtime) */ |
@@ -382,6 +388,21 @@ static inline int iwl_trans_resume(struct iwl_trans *trans) | |||
382 | } | 388 | } |
383 | #endif | 389 | #endif |
384 | 390 | ||
391 | static inline void iwl_trans_write8(struct iwl_trans *trans, u32 ofs, u8 val) | ||
392 | { | ||
393 | trans->ops->write8(trans, ofs, val); | ||
394 | } | ||
395 | |||
396 | static inline void iwl_trans_write32(struct iwl_trans *trans, u32 ofs, u32 val) | ||
397 | { | ||
398 | trans->ops->write32(trans, ofs, val); | ||
399 | } | ||
400 | |||
401 | static inline u32 iwl_trans_read32(struct iwl_trans *trans, u32 ofs) | ||
402 | { | ||
403 | return trans->ops->read32(trans, ofs); | ||
404 | } | ||
405 | |||
385 | /***************************************************** | 406 | /***************************************************** |
386 | * Utils functions | 407 | * Utils functions |
387 | ******************************************************/ | 408 | ******************************************************/ |