mac80211: add preliminary support for the AR913x SoCs
[openwrt/openwrt.git] / package / mac80211 / patches / 402-ath9k-introduce-bus-specific-register-access-routin.patch
1 From 0ef95ef08ca82a87c85a1656f434a03a98bfab5b Mon Sep 17 00:00:00 2001
2 From: Gabor Juhos <juhosg@openwrt.org>
3 Date: Fri, 2 Jan 2009 16:07:50 +0100
4 Subject: [RFC 02/12] ath9k: introduce bus specific register access routines
5
6 The AHB bus will require different code for register access, so we make
7 them replaceable as well.
8
9 Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
10 Signed-off-by: Imre Kaloz <kaloz@openwrt.org>
11 ---
12 drivers/net/wireless/ath9k/ath9k.h | 4 ++--
13 drivers/net/wireless/ath9k/core.h | 17 +++++++++++++++++
14 drivers/net/wireless/ath9k/main.c | 13 +++++++++++++
15 3 files changed, 32 insertions(+), 2 deletions(-)
16
17 --- a/drivers/net/wireless/ath9k/ath9k.h
18 +++ b/drivers/net/wireless/ath9k/ath9k.h
19 @@ -587,8 +587,8 @@ struct ath9k_country_entry {
20 u8 iso[3];
21 };
22
23 -#define REG_WRITE(_ah, _reg, _val) iowrite32(_val, _ah->ah_sh + _reg)
24 -#define REG_READ(_ah, _reg) ioread32(_ah->ah_sh + _reg)
25 +#define REG_WRITE(_ah, _reg, _val) ath_reg_write(_ah, _reg, _val)
26 +#define REG_READ(_ah, _reg) ath_reg_read(_ah, _reg)
27
28 #define SM(_v, _f) (((_v) << _f##_S) & _f)
29 #define MS(_v, _f) (((_v) & _f) >> _f##_S)
30 --- a/drivers/net/wireless/ath9k/core.h
31 +++ b/drivers/net/wireless/ath9k/core.h
32 @@ -718,6 +718,9 @@ struct ath_bus_ops {
33 size_t size,
34 void *p,
35 dma_addr_t da);
36 +
37 + u32 (*reg_read)(struct ath_hal *ah, unsigned reg);
38 + void (*reg_write)(struct ath_hal *ah, unsigned reg, u32 val);
39 };
40
41 struct ath_softc {
42 @@ -826,4 +829,18 @@ static inline void ath_dma_free(struct a
43 sc->bus_ops->dma_free(sc, size, p, da);
44 }
45
46 +static inline u32 ath_reg_read(struct ath_hal *ah, unsigned reg)
47 +{
48 + struct ath_softc *sc = ah->ah_sc;
49 +
50 + return sc->bus_ops->reg_read(ah, reg);
51 +}
52 +
53 +static inline void ath_reg_write(struct ath_hal *ah, unsigned reg, u32 val)
54 +{
55 + struct ath_softc *sc = ah->ah_sc;
56 +
57 + sc->bus_ops->reg_write(ah, reg, val);
58 +}
59 +
60 #endif /* CORE_H */
61 --- a/drivers/net/wireless/ath9k/main.c
62 +++ b/drivers/net/wireless/ath9k/main.c
63 @@ -2595,6 +2595,16 @@ static void ath_pci_dma_free(struct ath_
64 pci_free_consistent(sc->pdev, size, p, da);
65 }
66
67 +static u32 ath_pci_reg_read(struct ath_hal *ah, unsigned reg)
68 +{
69 + return ioread32(ah->ah_sh + reg);
70 +}
71 +
72 +static void ath_pci_reg_write(struct ath_hal *ah, unsigned reg, u32 val)
73 +{
74 + iowrite32(val, ah->ah_sh + reg);
75 +}
76 +
77 static struct ath_bus_ops ath_pci_bus_ops = {
78 .dma_map_single_to_device = ath_pci_map_single_to_device,
79 .dma_unmap_single_to_device = ath_pci_unmap_single_to_device,
80 @@ -2605,6 +2615,9 @@ static struct ath_bus_ops ath_pci_bus_op
81 .dma_sync_single_for_cpu = ath_pci_sync_single_for_cpu,
82 .dma_alloc = ath_pci_dma_alloc,
83 .dma_free = ath_pci_dma_free,
84 +
85 + .reg_read = ath_pci_reg_read,
86 + .reg_write = ath_pci_reg_write,
87 };
88
89 static int ath_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)