Skip to contentSkip to conversation

ath9k: add preliminary support for the AR913x SoCs

RFC New Gabor Juhos 3 participants 22 messages Jan 3, 2009 – Jan 6, 2009 Networking drivers (wireless)

lore
Share & tools
lore
#0 lore raw

cover ath9k: add preliminary support for the AR913x SoCs

This patch set introduces preliminary support for the Atheros' AR9130/AR9132 SoCs built-in WMAC device. Tested with compat-wireless-2008-12-29 on 2.6.2{7,8} kernels.

12 patches will follow as replies:

Gabor Juhos (12):
ath9k: introduce bus specific DMA routines
ath9k: introduce bus specific register access routines
ath9k: introduce bus specific cache size routine
ath9k: introduce bus specific cleanup routine
ath9k: move PCI code into separate file
ath9k: convert to struct device
ath9k: introduce platform driver for AHB bus support
ath9k: get EEPROM contents from platform data on AHB bus
ath9k: enable support for AR9100
ath9k: remove (u16) casts from rtc register access
ath9k: fix ar5416Addac_9100 values
ath9k: fix null pointer dereference in ani monitor code

 drivers/net/wireless/ath9k/Makefile   |    2 
 drivers/net/wireless/ath9k/ahb.c      |  285 +++++++++++++++++++++++++
 drivers/net/wireless/ath9k/ani.c      |    6 -
 drivers/net/wireless/ath9k/ath9k.h    |    4 
 drivers/net/wireless/ath9k/beacon.c   |   29 +--
 drivers/net/wireless/ath9k/core.h     |  137 ++++++++++++
 drivers/net/wireless/ath9k/eeprom.c   |   51 ----
 drivers/net/wireless/ath9k/hw.c       |   17 +
 drivers/net/wireless/ath9k/initvals.h |    2 
 drivers/net/wireless/ath9k/main.c     |  315 +++------------------------
 drivers/net/wireless/ath9k/pci.c      |  381 +++++++++++++++++++++++++++++++++
 drivers/net/wireless/ath9k/recv.c     |   30 +--
 drivers/net/wireless/ath9k/xmit.c     |   12 -
 include/linux/ath9k_platform.h        |   28 ++
 14 files changed, 913 insertions(+), 386 deletions(-)
 create mode 100644 drivers/net/wireless/ath9k/ahb.c
 create mode 100644 drivers/net/wireless/ath9k/pci.c
 create mode 100644 include/linux/ath9k_platform.h
#1 lore raw

RFC 1/12 ath9k: introduce bus specific DMA routines

In the AR913x SoCs, the WMAC devices are connected to the CPU through the internal AHB bus instead of PCI. We first patch ath9k driver to use replaceable DMA routines, so we can use different code for the AHB bus.

---
 drivers/net/wireless/ath9k/beacon.c |   29 +++++---------
 drivers/net/wireless/ath9k/core.h   |   75 +++++++++++++++++++++++++++++++++++
 drivers/net/wireless/ath9k/main.c   |   71 +++++++++++++++++++++++++++++---
 drivers/net/wireless/ath9k/recv.c   |   30 ++++++--------
 drivers/net/wireless/ath9k/xmit.c   |   12 ++----
 5 files changed, 166 insertions(+), 51 deletions(-)
drivers/net/wireless/ath9k/beacon.c +10 -19
index 3ab0b43..05cdbc8 100644
@@ -164,9 +164,7 @@ static struct ath_buf *ath_beacon_generate(struct ath_softc *sc, int if_id)
 	bf = avp->av_bcbuf;
 	skb = (struct sk_buff *)bf->bf_mpdu;
 	if (skb) {
-		pci_unmap_single(sc->pdev, bf->bf_dmacontext,
-				 skb->len,
-				 PCI_DMA_TODEVICE);
+		ath_unmap_single_to_device(sc, bf->bf_dmacontext, skb->len);
 		dev_kfree_skb_any(skb);
 	}
 
@@ -188,14 +186,12 @@ static struct ath_buf *ath_beacon_generate(struct ath_softc *sc, int if_id)
 	}
 
 	bf->bf_buf_addr = bf->bf_dmacontext =
-		pci_map_single(sc->pdev, skb->data,
-			       skb->len,
-			       PCI_DMA_TODEVICE);
-	if (unlikely(pci_dma_mapping_error(sc->pdev, bf->bf_buf_addr))) {
+		ath_map_single_to_device(sc, skb->data, skb->len);
+	if (unlikely(ath_dma_mapping_error(sc, bf->bf_buf_addr))) {
 		dev_kfree_skb_any(skb);
 		bf->bf_mpdu = NULL;
 		DPRINTF(sc, ATH_DBG_CONFIG,
-			"pci_dma_mapping_error() on beaconing\n");
+			"dma_mapping_error() on beaconing\n");
 		return NULL;
 	}
 
@@ -343,9 +339,7 @@ int ath_beacon_alloc(struct ath_softc *sc, int if_id)
 	bf = avp->av_bcbuf;
 	if (bf->bf_mpdu != NULL) {
 		skb = (struct sk_buff *)bf->bf_mpdu;
-		pci_unmap_single(sc->pdev, bf->bf_dmacontext,
-				 skb->len,
-				 PCI_DMA_TODEVICE);
+		ath_unmap_single_to_device(sc, bf->bf_dmacontext, skb->len);
 		dev_kfree_skb_any(skb);
 		bf->bf_mpdu = NULL;
 	}
@@ -402,14 +396,12 @@ int ath_beacon_alloc(struct ath_softc *sc, int if_id)
 
 	bf->bf_mpdu = skb;
 	bf->bf_buf_addr = bf->bf_dmacontext =
-		pci_map_single(sc->pdev, skb->data,
-			       skb->len,
-			       PCI_DMA_TODEVICE);
-	if (unlikely(pci_dma_mapping_error(sc->pdev, bf->bf_buf_addr))) {
+		ath_map_single_to_device(sc, skb->data, skb->len);
+	if (unlikely(ath_dma_mapping_error(sc, bf->bf_buf_addr))) {
 		dev_kfree_skb_any(skb);
 		bf->bf_mpdu = NULL;
 		DPRINTF(sc, ATH_DBG_CONFIG,
-			"pci_dma_mapping_error() on beacon alloc\n");
+			"dma_mapping_error() on beacon alloc\n");
 		return -ENOMEM;
 	}
 
@@ -429,9 +421,8 @@ void ath_beacon_return(struct ath_softc *sc, struct ath_vap *avp)
 		bf = avp->av_bcbuf;
 		if (bf->bf_mpdu != NULL) {
 			struct sk_buff *skb = (struct sk_buff *)bf->bf_mpdu;
-			pci_unmap_single(sc->pdev, bf->bf_dmacontext,
-					 skb->len,
-					 PCI_DMA_TODEVICE);
+			ath_unmap_single_to_device(sc, bf->bf_dmacontext,
+						   skb->len);
 			dev_kfree_skb_any(skb);
 			bf->bf_mpdu = NULL;
 		}
drivers/net/wireless/ath9k/core.h +75 -0

91 lines not on this page · raw message

drivers/net/wireless/ath9k/main.c +64 -7

101 lines not on this page · raw message

drivers/net/wireless/ath9k/recv.c +13 -17
index 462e08c..e135038 100644
@@ -291,15 +291,14 @@ int ath_rx_init(struct ath_softc *sc, int nbufs)
 			}
 
 			bf->bf_mpdu = skb;
-			bf->bf_buf_addr = pci_map_single(sc->pdev, skb->data,
-							 sc->rx.bufsize,
-							 PCI_DMA_FROMDEVICE);
-			if (unlikely(pci_dma_mapping_error(sc->pdev,
-				  bf->bf_buf_addr))) {
+			bf->bf_buf_addr = ath_map_single_from_device(sc,
+						skb->data, sc->rx.bufsize);
+			if (unlikely(ath_dma_mapping_error(sc,
+						bf->bf_buf_addr))) {
 				dev_kfree_skb_any(skb);
 				bf->bf_mpdu = NULL;
 				DPRINTF(sc, ATH_DBG_CONFIG,
-					"pci_dma_mapping_error() on RX init\n");
+					"dma_mapping_error() on RX init\n");
 				error = -ENOMEM;
 				break;
 			}
@@ -524,9 +523,7 @@ int ath_rx_tasklet(struct ath_softc *sc, int flush)
 		 * 1. accessing the frame
 		 * 2. requeueing the same buffer to h/w
 		 */
-		pci_dma_sync_single_for_cpu(sc->pdev, bf->bf_buf_addr,
-				sc->rx.bufsize,
-				PCI_DMA_FROMDEVICE);
+		ath_sync_single_for_cpu(sc, bf->bf_buf_addr, sc->rx.bufsize);
 
 		/*
 		 * If we're asked to flush receive queue, directly
@@ -557,9 +554,8 @@ int ath_rx_tasklet(struct ath_softc *sc, int flush)
 			goto requeue;
 
 		/* Unmap the frame */
-		pci_unmap_single(sc->pdev, bf->bf_buf_addr,
-				 sc->rx.bufsize,
-				 PCI_DMA_FROMDEVICE);
+		ath_unmap_single_from_device(sc, bf->bf_buf_addr,
+					     sc->rx.bufsize);
 
 		skb_put(skb, ds->ds_rxstat.rs_datalen);
 		skb->protocol = cpu_to_be16(ETH_P_CONTROL);
@@ -599,15 +595,15 @@ int ath_rx_tasklet(struct ath_softc *sc, int flush)
 
 		/* We will now give hardware our shiny new allocated skb */
 		bf->bf_mpdu = requeue_skb;
-		bf->bf_buf_addr = pci_map_single(sc->pdev, requeue_skb->data,
-					 sc->rx.bufsize,
-					 PCI_DMA_FROMDEVICE);
-		if (unlikely(pci_dma_mapping_error(sc->pdev,
+		bf->bf_buf_addr = ath_map_single_from_device(sc,
+						requeue_skb->data,
+						sc->rx.bufsize);
+		if (unlikely(ath_dma_mapping_error(sc,
 			  bf->bf_buf_addr))) {
 			dev_kfree_skb_any(requeue_skb);
 			bf->bf_mpdu = NULL;
 			DPRINTF(sc, ATH_DBG_CONFIG,
-				"pci_dma_mapping_error() on RX\n");
+				"dma_mapping_error() on RX\n");
 			break;
 		}
 		bf->bf_dmacontext = bf->bf_buf_addr;
drivers/net/wireless/ath9k/xmit.c +4 -8
index c92f0c6..d238b02 100644
@@ -340,10 +340,7 @@ static void ath_tx_complete_buf(struct ath_softc *sc,
 	}
 
 	/* Unmap this frame */
-	pci_unmap_single(sc->pdev,
-			 bf->bf_dmacontext,
-			 skb->len,
-			 PCI_DMA_TODEVICE);
+	ath_unmap_single_to_device(sc, bf->bf_dmacontext, skb->len);
 	/* complete this frame */
 	ath_tx_complete(sc, skb, &tx_status);
 
@@ -1713,12 +1710,11 @@ static int ath_tx_setup_buffer(struct ath_softc *sc, struct ath_buf *bf,
 	/* DMA setup */
 	bf->bf_mpdu = skb;
 
-	bf->bf_dmacontext = pci_map_single(sc->pdev, skb->data,
-					   skb->len, PCI_DMA_TODEVICE);
-	if (unlikely(pci_dma_mapping_error(sc->pdev, bf->bf_dmacontext))) {
+	bf->bf_dmacontext = ath_map_single_to_device(sc, skb->data, skb->len);
+	if (unlikely(ath_dma_mapping_error(sc, bf->bf_dmacontext))) {
 		bf->bf_mpdu = NULL;
 		DPRINTF(sc, ATH_DBG_CONFIG,
-			"pci_dma_mapping_error() on TX\n");
+			"dma_mapping_error() on TX\n");
 		return -ENOMEM;
 	}
 
Signature · 1 line
1.5.3.2
#2 lore raw

RFC 1/12 ath9k: introduce bus specific DMA routines

drivers/net/wireless/ath9k/beacon.c static struct ath_buf *ath_beacon_generate(struct ath_softc *sc, int if_id) · line 167

Quoted 8 lines · Gabor Juhos

In the AR913x SoCs, the WMAC devices are connected to the CPU through the internal AHB bus instead of PCI. We first patch ath9k driver to use replaceable DMA routines, so we can use different code for the AHB bus.

drivers/net/wireless/ath9k/beacon.c +1 -3
-		pci_unmap_single(sc->pdev, bf->bf_dmacontext,
-				 skb->len,
-				 PCI_DMA_TODEVICE);
+		ath_unmap_single_to_device(sc, bf->bf_dmacontext, skb->len);

Just use the dma_* routines, as they are bus-agnostic and make sure the implementation on your mips SOC works for the ahb bus.

#3 lore raw

RFC 1/12 ath9k: introduce bus specific DMA routines

Christoph Hellwig ?rta:

Quoted 5 lines · Gabor Juhos
Quoted 3 lines

In the AR913x SoCs, the WMAC devices are connected to the CPU through the internal AHB bus instead of PCI. We first patch ath9k driver to use replaceable DMA routines, so we can use different code for the AHB bus.

Quoted 9 lines

drivers/net/wireless/ath9k/beacon.c static struct ath_buf *ath_beacon_generate(struct ath_softc *sc, int if_id) · line 167

Quoted 4 lines
drivers/net/wireless/ath9k/beacon.c +1 -3
-		pci_unmap_single(sc->pdev, bf->bf_dmacontext,
-				 skb->len,
-				 PCI_DMA_TODEVICE);
+		ath_unmap_single_to_device(sc, bf->bf_dmacontext, skb->len);

Just use the dma_* routines, as they are bus-agnostic and make sure the implementation on your mips SOC works for the ahb bus.

Ok, i will try it.

#4 lore raw

RFC 2/12 ath9k: introduce bus specific register access routines

In reply to Gabor Juhos

The AHB bus will require different code for register access, so we make them replaceable as well.

---
 drivers/net/wireless/ath9k/ath9k.h |    4 ++--
 drivers/net/wireless/ath9k/core.h  |   17 +++++++++++++++++
 drivers/net/wireless/ath9k/main.c  |   13 +++++++++++++
 3 files changed, 32 insertions(+), 2 deletions(-)
drivers/net/wireless/ath9k/ath9k.h +2 -2
index d278135..dc9b260 100644
@@ -587,8 +587,8 @@ struct ath9k_country_entry {
 	u8 iso[3];
 };
 
-#define REG_WRITE(_ah, _reg, _val) iowrite32(_val, _ah->ah_sh + _reg)
-#define REG_READ(_ah, _reg) ioread32(_ah->ah_sh + _reg)
+#define REG_WRITE(_ah, _reg, _val) 	ath_reg_write(_ah, _reg, _val)
+#define REG_READ(_ah, _reg) 		ath_reg_read(_ah, _reg)
 
 #define SM(_v, _f)  (((_v) << _f##_S) & _f)
 #define MS(_v, _f)  (((_v) & _f) >> _f##_S)
drivers/net/wireless/ath9k/core.h +17 -0
index de50e47..db7ae4e 100644
@@ -718,6 +718,9 @@ struct ath_bus_ops {
 				    size_t size,
 				    void *p,
 				    dma_addr_t da);
+
+	u32		(*reg_read)(struct ath_hal *ah, unsigned reg);
+	void		(*reg_write)(struct ath_hal *ah, unsigned reg, u32 val);
 };
 
 struct ath_softc {
@@ -826,4 +829,18 @@ static inline void ath_dma_free(struct ath_softc *sc, size_t size,
 	sc->bus_ops->dma_free(sc, size, p, da);
 }
 
+static inline u32 ath_reg_read(struct ath_hal *ah, unsigned reg)
+{
+	struct ath_softc *sc = ah->ah_sc;
+
+	return sc->bus_ops->reg_read(ah, reg);
+}
+
+static inline void ath_reg_write(struct ath_hal *ah, unsigned reg, u32 val)
+{
+	struct ath_softc *sc = ah->ah_sc;
+
+	sc->bus_ops->reg_write(ah, reg, val);
+}
+
 #endif /* CORE_H */
drivers/net/wireless/ath9k/main.c +13 -0
index 62a0a5b..9ce89b4 100644
@@ -2595,6 +2595,16 @@ static void ath_pci_dma_free(struct ath_softc *sc, size_t size,
 	pci_free_consistent(sc->pdev, size, p, da);
 }
 
+static u32 ath_pci_reg_read(struct ath_hal *ah, unsigned reg)
+{
+	return ioread32(ah->ah_sh + reg);
+}
+
+static void ath_pci_reg_write(struct ath_hal *ah, unsigned reg, u32 val)
+{
+	iowrite32(val, ah->ah_sh + reg);
+}
+
 static struct ath_bus_ops ath_pci_bus_ops  = {
 	.dma_map_single_to_device = ath_pci_map_single_to_device,
 	.dma_unmap_single_to_device = ath_pci_unmap_single_to_device,
@@ -2605,6 +2615,9 @@ static struct ath_bus_ops ath_pci_bus_ops  = {
 	.dma_sync_single_for_cpu = ath_pci_sync_single_for_cpu,
 	.dma_alloc = ath_pci_dma_alloc,
 	.dma_free = ath_pci_dma_free,
+
+	.reg_read = ath_pci_reg_read,
+	.reg_write = ath_pci_reg_write,
 };
 
 static int ath_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
Signature · 1 line
1.5.3.2
#5 lore raw

RFC 2/12 ath9k: introduce bus specific register access routines

Quoted 2 lines · Gabor Juhos

The AHB bus will require different code for register access, so we make them replaceable as well.

What kind of different code? ioread*/iowrite* are supposed to be bus-agnostic.

#6 lore raw

RFC 2/12 ath9k: introduce bus specific register access routines

Christoph Hellwig ?rta:

Quoted 7 lines · Gabor Juhos
Quoted 2 lines

The AHB bus will require different code for register access, so we make them replaceable as well.

What kind of different code? ioread*/iowrite* are supposed to be bus-agnostic.

I have used __raw_{read,write}*. You are right, I have tried it right now and it works with io{read,write}* as well. I will remove them.

#7 lore raw

RFC 3/12 ath9k: introduce bus specific cache size routine

In reply to Gabor Juhos

The PCI specific bus_read_cachesize routine won't work on the AHB bus, we have to replace it with a suitable one later.

---
 drivers/net/wireless/ath9k/core.h |    7 +++++++
 drivers/net/wireless/ath9k/main.c |    8 +++++---
 2 files changed, 12 insertions(+), 3 deletions(-)
drivers/net/wireless/ath9k/core.h +7 -0
index db7ae4e..0c8064e 100644
@@ -721,6 +721,8 @@ struct ath_bus_ops {
 
 	u32		(*reg_read)(struct ath_hal *ah, unsigned reg);
 	void		(*reg_write)(struct ath_hal *ah, unsigned reg, u32 val);
+
+	void		(*read_cachesize)(struct ath_softc *sc, int *csz);
 };
 
 struct ath_softc {
@@ -843,4 +845,9 @@ static inline void ath_reg_write(struct ath_hal *ah, unsigned reg, u32 val)
 	sc->bus_ops->reg_write(ah, reg, val);
 }
 
+static inline void ath_read_cachesize(struct ath_softc *sc, int *csz)
+{
+	sc->bus_ops->read_cachesize(sc, csz);
+}
+
 #endif /* CORE_H */
drivers/net/wireless/ath9k/main.c +5 -3
index 9ce89b4..f1da1ac 100644
@@ -41,8 +41,7 @@ static struct pci_device_id ath_pci_id_table[] __devinitdata = {
 static void ath_detach(struct ath_softc *sc);
 
 /* return bus cachesize in 4B word units */
-
-static void bus_read_cachesize(struct ath_softc *sc, int *csz)
+static void ath_pci_read_cachesize(struct ath_softc *sc, int *csz)
 {
 	u8 u8tmp;
 
@@ -59,6 +58,7 @@ static void bus_read_cachesize(struct ath_softc *sc, int *csz)
 		*csz = DEFAULT_CACHELINE >> 2;   /* Use the default size */
 }
 
+
 static void ath_setcurmode(struct ath_softc *sc, enum wireless_mode mode)
 {
 	sc->cur_rate_table = sc->hw_rate_table[mode];
@@ -1347,7 +1347,7 @@ static int ath_init(u16 devid, struct ath_softc *sc)
 	 * Cache line size is used to size and align various
 	 * structures used to communicate with the hardware.
 	 */
-	bus_read_cachesize(sc, &csz);
+	ath_read_cachesize(sc, &csz);
 	/* XXX assert csz is non-zero */
 	sc->sc_cachelsz = csz << 2;	/* convert to bytes */
 
@@ -2618,6 +2618,8 @@ static struct ath_bus_ops ath_pci_bus_ops  = {
 
 	.reg_read = ath_pci_reg_read,
 	.reg_write = ath_pci_reg_write,
+
+	.read_cachesize = ath_pci_read_cachesize,
 };
 
 static int ath_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
Signature · 1 line
1.5.3.2
#8 lore raw

RFC 4/12 ath9k: introduce bus specific cleanup routine

In reply to Gabor Juhos

We have left only some PCI specific cleanup code. We have to convert them as well.

---
 drivers/net/wireless/ath9k/core.h |    7 +++++++
 drivers/net/wireless/ath9k/main.c |   29 +++++++++++++++--------------
 2 files changed, 22 insertions(+), 14 deletions(-)
drivers/net/wireless/ath9k/core.h +7 -0
index 0c8064e..4833598 100644
@@ -723,6 +723,8 @@ struct ath_bus_ops {
 	void		(*reg_write)(struct ath_hal *ah, unsigned reg, u32 val);
 
 	void		(*read_cachesize)(struct ath_softc *sc, int *csz);
+
+	void		(*cleanup)(struct ath_softc *sc);
 };
 
 struct ath_softc {
@@ -850,4 +852,9 @@ static inline void ath_read_cachesize(struct ath_softc *sc, int *csz)
 	sc->bus_ops->read_cachesize(sc, csz);
 }
 
+static inline void ath_bus_cleanup(struct ath_softc *sc)
+{
+	sc->bus_ops->cleanup(sc);
+}
+
 #endif /* CORE_H */
drivers/net/wireless/ath9k/main.c +15 -14
index f1da1ac..e126b65 100644
@@ -1276,13 +1276,7 @@ static int ath_start_rfkill_poll(struct ath_softc *sc)
 			rfkill_free(sc->rf_kill.rfkill);
 
 			/* Deinitialize the device */
-			ath_detach(sc);
-			if (sc->pdev->irq)
-				free_irq(sc->pdev->irq, sc);
-			pci_iounmap(sc->pdev, sc->mem);
-			pci_release_region(sc->pdev, 0);
-			pci_disable_device(sc->pdev);
-			ieee80211_free_hw(sc->hw);
+			ath_bus_cleanup(sc);
 			return -EIO;
 		} else {
 			sc->sc_flags |= SC_OP_RFKILL_REGISTERED;
@@ -2605,6 +2599,17 @@ static void ath_pci_reg_write(struct ath_hal *ah, unsigned reg, u32 val)
 	iowrite32(val, ah->ah_sh + reg);
 }
 
+static void ath_pci_cleanup(struct ath_softc *sc)
+{
+	ath_detach(sc);
+	if (sc->pdev->irq)
+		free_irq(sc->pdev->irq, sc);
+	pci_iounmap(sc->pdev, sc->mem);
+	pci_release_region(sc->pdev, 0);
+	pci_disable_device(sc->pdev);
+	ieee80211_free_hw(sc->hw);
+}
+
 static struct ath_bus_ops ath_pci_bus_ops  = {
 	.dma_map_single_to_device = ath_pci_map_single_to_device,
 	.dma_unmap_single_to_device = ath_pci_unmap_single_to_device,
@@ -2620,6 +2625,8 @@ static struct ath_bus_ops ath_pci_bus_ops  = {
 	.reg_write = ath_pci_reg_write,
 
 	.read_cachesize = ath_pci_read_cachesize,
+
+	.cleanup = ath_pci_cleanup,
 };
 
 static int ath_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
@@ -2756,13 +2763,7 @@ static void ath_pci_remove(struct pci_dev *pdev)
 	struct ieee80211_hw *hw = pci_get_drvdata(pdev);
 	struct ath_softc *sc = hw->priv;
 
-	ath_detach(sc);
-	if (pdev->irq)
-		free_irq(pdev->irq, sc);
-	pci_iounmap(pdev, sc->mem);
-	pci_release_region(pdev, 0);
-	pci_disable_device(pdev);
-	ieee80211_free_hw(hw);
+	ath_pci_cleanup(sc);
 }
 
 #ifdef CONFIG_PM
Signature · 1 line
1.5.3.2
#9 lore raw

RFC 5/12 ath9k: move PCI code into separate file

In reply to Gabor Juhos

Convert 'struct pci_dev' to 'struct device' to make it usable on the AHB bus as well.

---
 drivers/net/wireless/ath9k/Makefile |    1 +
 drivers/net/wireless/ath9k/core.h   |   16 ++
 drivers/net/wireless/ath9k/main.c   |  368 ++---------------------------------
 drivers/net/wireless/ath9k/pci.c    |  357 +++++++++++++++++++++++++++++++++
 4 files changed, 395 insertions(+), 347 deletions(-)
drivers/net/wireless/ath9k/Makefile +1 -0
index 1209d14..af3f39b 100644
@@ -11,6 +11,7 @@ ath9k-y +=	hw.o \
 		xmit.o \
 		rc.o
 
+ath9k-$(CONFIG_PCI) += pci.o
 ath9k-$(CONFIG_ATH9K_DEBUG) += debug.o
 
 obj-$(CONFIG_ATH9K) += ath9k.o
drivers/net/wireless/ath9k/core.h +16 -0
index 4833598..73a409b 100644
@@ -857,4 +857,20 @@ static inline void ath_bus_cleanup(struct ath_softc *sc)
 	sc->bus_ops->cleanup(sc);
 }
 
+extern struct ieee80211_ops ath9k_ops;
+
+irqreturn_t ath_isr(int irq, void *dev);
+int ath_attach(u16 devid, struct ath_softc *sc);
+void ath_detach(struct ath_softc *sc);
+const char *ath_mac_bb_name(u32 mac_bb_version);
+const char *ath_rf_name(u16 rf_version);
+
+#ifdef CONFIG_PCI
+int ath_pci_init(void);
+void ath_pci_exit(void);
+#else
+static inline int ath_pci_init(void) { return 0; };
+static inline void ath_pci_exit(void) {};
+#endif
+
 #endif /* CORE_H */
drivers/net/wireless/ath9k/main.c +21 -347

432 lines not on this page · raw message

drivers/net/wireless/ath9k/pci.c new file +357 -0

357 lines not on this page · raw message

Signature · 1 line
1.5.3.2
#10 lore raw

RFC 6/12 ath9k: convert to struct device

In reply to Gabor Juhos

Now that we have converted all bus specific routines to replaceable, we can move the PCI specific codes into a separate file.

---
 drivers/net/wireless/ath9k/core.h |    5 +++--
 drivers/net/wireless/ath9k/pci.c  |   35 ++++++++++++++++++++---------------
 2 files changed, 23 insertions(+), 17 deletions(-)
drivers/net/wireless/ath9k/core.h +3 -2
index 73a409b..6889df7 100644
@@ -18,7 +18,8 @@
 #define CORE_H
 
 #include <linux/etherdevice.h>
-#include <linux/pci.h>
+#include <linux/device.h>
+#include <linux/types.h>
 #include <net/mac80211.h>
 #include <linux/leds.h>
 #include <linux/rfkill.h>
@@ -729,7 +730,7 @@ struct ath_bus_ops {
 
 struct ath_softc {
 	struct ieee80211_hw *hw;
-	struct pci_dev *pdev;
+	struct device *dev;
 	struct tasklet_struct intr_tq;
 	struct tasklet_struct bcon_tasklet;
 	struct ath_hal *sc_ah;
drivers/net/wireless/ath9k/pci.c +20 -15
index 1bb4787..314bf9d 100644
@@ -15,6 +15,8 @@
  */
 
 #include <linux/nl80211.h>
+#include <linux/pci.h>
+
 #include "core.h"
 #include "reg.h"
 #include "hw.h"
@@ -34,7 +36,8 @@ static void ath_pci_read_cachesize(struct ath_softc *sc, int *csz)
 {
 	u8 u8tmp;
 
-	pci_read_config_byte(sc->pdev, PCI_CACHE_LINE_SIZE, (u8 *)&u8tmp);
+	pci_read_config_byte(to_pci_dev(sc->dev), PCI_CACHE_LINE_SIZE,
+			     (u8 *)&u8tmp);
 	*csz = (int)u8tmp;
 
 	/*
@@ -50,49 +53,49 @@ static void ath_pci_read_cachesize(struct ath_softc *sc, int *csz)
 static dma_addr_t ath_pci_map_single_to_device(struct ath_softc *sc,
 					       void *p, size_t size)
 {
-	return pci_map_single(sc->pdev, p, size, PCI_DMA_TODEVICE);
+	return pci_map_single(to_pci_dev(sc->dev), p, size, PCI_DMA_TODEVICE);
 }
 
 static void ath_pci_unmap_single_to_device(struct ath_softc *sc,
 					   dma_addr_t da, size_t size)
 {
-	pci_unmap_single(sc->pdev, da, size, PCI_DMA_TODEVICE);
+	pci_unmap_single(to_pci_dev(sc->dev), da, size, PCI_DMA_TODEVICE);
 }
 
 static dma_addr_t ath_pci_map_single_from_device(struct ath_softc *sc,
 						 void *p, size_t size)
 {
-	return pci_map_single(sc->pdev, p, size, PCI_DMA_FROMDEVICE);
+	return pci_map_single(to_pci_dev(sc->dev), p, size, PCI_DMA_FROMDEVICE);
 }
 
 static void ath_pci_unmap_single_from_device(struct ath_softc *sc,
 					     dma_addr_t da, size_t size)
 {
-	pci_unmap_single(sc->pdev, da, size, PCI_DMA_FROMDEVICE);
+	pci_unmap_single(to_pci_dev(sc->dev), da, size, PCI_DMA_FROMDEVICE);
 }
 
 static int ath_pci_dma_mapping_error(struct ath_softc *sc, dma_addr_t da)
 {
-	return pci_dma_mapping_error(sc->pdev, da);
+	return pci_dma_mapping_error(to_pci_dev(sc->dev), da);
 }
 
 static void ath_pci_sync_single_for_cpu(struct ath_softc *sc, dma_addr_t da,
 				       size_t size)
 {
-	pci_dma_sync_single_for_cpu(sc->pdev, da, size,
+	pci_dma_sync_single_for_cpu(to_pci_dev(sc->dev), da, size,
 				    PCI_DMA_FROMDEVICE);
 }
 
 static void *ath_pci_dma_alloc(struct ath_softc *sc, size_t size,
 				       dma_addr_t *pda)
 {
-	return pci_alloc_consistent(sc->pdev, size, pda);
+	return pci_alloc_consistent(to_pci_dev(sc->dev), size, pda);
 }
 
 static void ath_pci_dma_free(struct ath_softc *sc, size_t size,
 				    void *p, dma_addr_t da)
 {
-	pci_free_consistent(sc->pdev, size, p, da);
+	pci_free_consistent(to_pci_dev(sc->dev), size, p, da);
 }
 
 static u32 ath_pci_reg_read(struct ath_hal *ah, unsigned reg)
@@ -107,12 +110,14 @@ static void ath_pci_reg_write(struct ath_hal *ah, unsigned reg, u32 val)
 
 static void ath_pci_cleanup(struct ath_softc *sc)
 {
+	struct pci_dev *pdev = to_pci_dev(sc->dev);
+
 	ath_detach(sc);
-	if (sc->pdev->irq)
-		free_irq(sc->pdev->irq, sc);
-	pci_iounmap(sc->pdev, sc->mem);
-	pci_release_region(sc->pdev, 0);
-	pci_disable_device(sc->pdev);
+	if (pdev->irq)
+		free_irq(pdev->irq, sc);
+	pci_iounmap(pdev, sc->mem);
+	pci_release_region(pdev, 0);
+	pci_disable_device(pdev);
 	ieee80211_free_hw(sc->hw);
 }
 
@@ -221,7 +226,7 @@ static int ath_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 
 	sc = hw->priv;
 	sc->hw = hw;
-	sc->pdev = pdev;
+	sc->dev = &pdev->dev;
 	sc->mem = mem;
 	sc->bus_ops = &ath_pci_bus_ops;
 
Signature · 1 line
1.5.3.2
#11 lore raw

RFC 7/12 ath9k: introduce platform driver for AHB bus support

In reply to Gabor Juhos

This patch adds the platform_driver itself, and modifies the main driver to register it.

---
 drivers/net/wireless/ath9k/Makefile |    1 +
 drivers/net/wireless/ath9k/ahb.c    |  258 +++++++++++++++++++++++++++++++++++
 drivers/net/wireless/ath9k/core.h   |    8 +
 drivers/net/wireless/ath9k/main.c   |   10 ++
 4 files changed, 277 insertions(+), 0 deletions(-)
drivers/net/wireless/ath9k/Makefile +1 -0
index af3f39b..0062958 100644
@@ -12,6 +12,7 @@ ath9k-y +=	hw.o \
 		rc.o
 
 ath9k-$(CONFIG_PCI) += pci.o
+ath9k-$(CONFIG_ATHEROS_AR71XX) += ahb.o
 ath9k-$(CONFIG_ATH9K_DEBUG) += debug.o
 
 obj-$(CONFIG_ATH9K) += ath9k.o
drivers/net/wireless/ath9k/ahb.c new file +258 -0

258 lines not on this page · raw message

drivers/net/wireless/ath9k/core.h +8 -0
index 6889df7..bb8b45b 100644
@@ -874,4 +874,12 @@ static inline int ath_pci_init(void) { return 0; };
 static inline void ath_pci_exit(void) {};
 #endif
 
+#ifdef CONFIG_ATHEROS_AR71XX
+int ath_ahb_init(void);
+void ath_ahb_exit(void);
+#else
+static inline int ath_ahb_init(void) { return 0; };
+static inline void ath_ahb_exit(void) {};
+#endif
+
 #endif /* CORE_H */
drivers/net/wireless/ath9k/main.c +10 -0
index 423cf3b..b4aee16 100644
@@ -2533,8 +2533,17 @@ static int __init ath9k_init(void)
 		goto err_rate_unregister;
 	}
 
+	error = ath_ahb_init();
+	if (error < 0) {
+		error = -ENODEV;
+		goto err_pci_exit;
+	}
+
 	return 0;
 
+ err_pci_exit:
+	ath_pci_exit();
+
  err_rate_unregister:
 	ath_rate_control_unregister();
  err_out:
@@ -2544,6 +2553,7 @@ module_init(ath9k_init);
 
 static void __exit ath9k_exit(void)
 {
+	ath_ahb_exit();
 	ath_pci_exit();
 	ath_rate_control_unregister();
 	printk(KERN_INFO "%s: Driver unloaded\n", dev_info);
Signature · 1 line
1.5.3.2
#12 lore raw

RFC 7/12 ath9k: introduce platform driver for AHB bus support

drivers/net/wireless/ath9k/ahb.c line 29

Quoted 5 lines · Gabor Juhos
drivers/net/wireless/ath9k/ahb.c new file +5 -0
+static dma_addr_t ath_ahb_map_single_to_device(struct ath_softc *sc,
+					       void *p, size_t size)
+{
+	return dma_map_single(NULL, p, size, DMA_TO_DEVICE);
+}

As said before you should just use dma_* directly. And please make sure to always pass a struct device to the dma_* routines, even if your platform might currently not required it the API does.

drivers/net/wireless/ath9k/ahb.c line 96

Quoted 9 lines
drivers/net/wireless/ath9k/ahb.c new file +9 -0
+static void ath_ahb_cleanup(struct ath_softc *sc)
+{
+	struct platform_device *pdev = to_platform_device(sc->dev);
+	struct ieee80211_hw *hw = sc->hw;
+	struct resource *res;
+
+	res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
+	if (res)
+		free_irq(res->start, sc);

If you stored the irq value directly in the softc this whole thing might be able to be done in a generic way..

#13 lore raw

RFC 7/12 ath9k: introduce platform driver for AHB bus support

Christoph Hellwig ?rta:

Quoted 11 lines · Gabor Juhos

drivers/net/wireless/ath9k/ahb.c line 29

Quoted 5 lines
drivers/net/wireless/ath9k/ahb.c new file +5 -0
+static dma_addr_t ath_ahb_map_single_to_device(struct ath_softc *sc,
+					       void *p, size_t size)
+{
+	return dma_map_single(NULL, p, size, DMA_TO_DEVICE);
+}

As said before you should just use dma_* directly. And please make sure to always pass a struct device to the dma_* routines, even if your platform might currently not required it the API does.

Quoted 14 lines

drivers/net/wireless/ath9k/ahb.c line 96

Quoted 9 lines
drivers/net/wireless/ath9k/ahb.c new file +9 -0
+static void ath_ahb_cleanup(struct ath_softc *sc)
+{
+	struct platform_device *pdev = to_platform_device(sc->dev);
+	struct ieee80211_hw *hw = sc->hw;
+	struct resource *res;
+
+	res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
+	if (res)
+		free_irq(res->start, sc);

If you stored the irq value directly in the softc this whole thing might be able to be done in a generic way..

I did not want to store it in the softc, because 'struct pci_dev' has it already and we will duplicate it. However the code will be simpler, so i can add it of course.

#14 lore raw

RFC 8/12 ath9k: get EEPROM contents from platform data on AHB bus

In reply to Gabor Juhos

On the AR913x SOCs we have to provide EEPROM contents via platform_data, because accessing the flash via MMIO is not safe. Additionally different boards may store the radio calibration data at different locations.

---
 drivers/net/wireless/ath9k/ahb.c    |   27 ++++++++++++++++++
 drivers/net/wireless/ath9k/core.h   |    2 +
 drivers/net/wireless/ath9k/eeprom.c |   51 ++--------------------------------
 drivers/net/wireless/ath9k/pci.c    |   19 +++++++++++++
 include/linux/ath9k_platform.h      |   28 +++++++++++++++++++
 5 files changed, 79 insertions(+), 48 deletions(-)
drivers/net/wireless/ath9k/ahb.c +27 -0
index bf37a9e..7fece47 100644
@@ -18,6 +18,7 @@
 
 #include <linux/nl80211.h>
 #include <linux/platform_device.h>
+#include <linux/ath9k_platform.h>
 #include "core.h"
 #include "reg.h"
 #include "hw.h"
@@ -101,6 +102,24 @@ static void ath_ahb_cleanup(struct ath_softc *sc)
 	platform_set_drvdata(pdev, NULL);
 }
 
+static bool ath_ahb_eeprom_read(struct ath_hal *ah, u32 off, u16 *data)
+{
+	struct ath_softc *sc = ah->ah_sc;
+	struct platform_device *pdev = to_platform_device(sc->dev);
+	struct ath9k_platform_data *pdata;
+
+	pdata = (struct ath9k_platform_data *) pdev->dev.platform_data;
+	if (off >= (ARRAY_SIZE(pdata->eeprom_data))) {
+		DPRINTF(ah->ah_sc, ATH_DBG_FATAL,
+			"%s: flash read failed, offset %08x is out of range\n",
+				__func__, off);
+		return false;
+	}
+
+	*data = pdata->eeprom_data[off];
+	return true;
+}
+
 static struct ath_bus_ops ath_ahb_bus_ops  = {
 	.dma_map_single_to_device = ath_ahb_map_single_to_device,
 	.dma_unmap_single_to_device = ath_ahb_unmap_single_to_device,
@@ -118,6 +137,8 @@ static struct ath_bus_ops ath_ahb_bus_ops  = {
 	.read_cachesize = ath_ahb_read_cachesize,
 
 	.cleanup = ath_ahb_cleanup,
+
+	.eeprom_read = ath_ahb_eeprom_read,
 };
 
 static int ath_ahb_probe(struct platform_device *pdev)
@@ -130,6 +151,12 @@ static int ath_ahb_probe(struct platform_device *pdev)
 	int ret = 0;
 	struct ath_hal *ah;
 
+	if (!pdev->dev.platform_data) {
+		dev_err(&pdev->dev, "no platform data specified\n");
+		ret = -EINVAL;
+		goto err_out;
+	}
+
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	if (res == NULL) {
 		dev_err(&pdev->dev, "no memory resource found\n");
drivers/net/wireless/ath9k/core.h +2 -0
index bb8b45b..4f915d8 100644
@@ -726,6 +726,8 @@ struct ath_bus_ops {
 	void		(*read_cachesize)(struct ath_softc *sc, int *csz);
 
 	void		(*cleanup)(struct ath_softc *sc);
+
+	bool		(*eeprom_read)(struct ath_hal *ah, u32 off, u16 *data);
 };
 
 struct ath_softc {
drivers/net/wireless/ath9k/eeprom.c +3 -48

65 lines not on this page · raw message

drivers/net/wireless/ath9k/pci.c +19 -0
index 314bf9d..68b2ea1 100644
@@ -121,6 +121,23 @@ static void ath_pci_cleanup(struct ath_softc *sc)
 	ieee80211_free_hw(sc->hw);
 }
 
+static bool ath_pci_eeprom_read(struct ath_hal *ah, u32 off, u16 *data)
+{
+	(void)REG_READ(ah, AR5416_EEPROM_OFFSET + (off << AR5416_EEPROM_S));
+
+	if (!ath9k_hw_wait(ah,
+			   AR_EEPROM_STATUS_DATA,
+			   AR_EEPROM_STATUS_DATA_BUSY |
+			   AR_EEPROM_STATUS_DATA_PROT_ACCESS, 0)) {
+		return false;
+	}
+
+	*data = MS(REG_READ(ah, AR_EEPROM_STATUS_DATA),
+		   AR_EEPROM_STATUS_DATA_VAL);
+
+	return true;
+}
+
 static struct ath_bus_ops ath_pci_bus_ops  = {
 	.dma_map_single_to_device = ath_pci_map_single_to_device,
 	.dma_unmap_single_to_device = ath_pci_unmap_single_to_device,
@@ -138,6 +155,8 @@ static struct ath_bus_ops ath_pci_bus_ops  = {
 	.read_cachesize = ath_pci_read_cachesize,
 
 	.cleanup = ath_pci_cleanup,
+
+	.eeprom_read = ath_pci_eeprom_read,
 };
 
 static int ath_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
include/linux/ath9k_platform.h new file +28 -0
new file mode 100644
index 0000000..06b7461
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2008 Atheros Communications Inc.
+ * Copyright (c) 2009 Gabor Juhos <[email protected]>
+ * Copyright (c) 2009 Imre Kaloz <[email protected]>
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifndef _LINUX_ATH9K_PLATFORM_H
+#define _LINUX_ATH9L_PLATFORM_H
+
+#define ATH9K_PLAT_EEP_MAX_WORDS	2048
+
+struct ath9k_platform_data {
+	u16 eeprom_data[ATH9K_PLAT_EEP_MAX_WORDS];
+};
+
+#endif /* _LINUX_ATH9K_PLATFORM_H */
Signature · 1 line
1.5.3.2
#15 lore raw

RFC 8/12 ath9k: get EEPROM contents from platform data on AHB bus

include/linux/ath9k_platform.h line 20

Quoted 2 lines · Gabor Juhos
include/linux/ath9k_platform.h new file +2 -0
+#ifndef _LINUX_ATH9K_PLATFORM_H
+#define _LINUX_ATH9L_PLATFORM_H

Typo ?

Also, after addressing Christopher's comments, I don't think too many bus specific routines would remain. In that case would it be reasonable to just have a single file (bus.c, with appropriate ifdefs), instead of pci.c and ahb.c ?

Sujith

#16 lore raw

RFC 8/12 ath9k: get EEPROM contents from platform data on AHB bus

Sujith ?rta:

Quoted 5 lines

include/linux/ath9k_platform.h line 20

Quoted 2 lines · Gabor Juhos
include/linux/ath9k_platform.h new file +2 -0
+#ifndef _LINUX_ATH9K_PLATFORM_H
+#define _LINUX_ATH9L_PLATFORM_H

Typo ?

Oops, yes.

Quoted 4 lines

Also, after addressing Christopher's comments, I don't think too many bus specific routines would remain. In that case would it be reasonable to just have a single file (bus.c, with appropriate ifdefs), instead of pci.c and ahb.c ?

We will have 3 of them actually (read_cachesize, read_eeprom, cleanup), but here is the whole {pci,platform}_driver specific stuff. Of course we can move all of this into one file, but i would like to avoid the unnecessary ifdefs where it is possible. Apart from this, if we will put the PCI and AHB stuff into one file, we could put it into main.c simply.

-Gabor

#17 lore raw

RFC 8/12 ath9k: get EEPROM contents from platform data on AHB bus

Quoted 10 lines · Gabor Juhos
Quoted 4 lines

Also, after addressing Christopher's comments, I don't think too many bus specific routines would remain. In that case would it be reasonable to just have a single file (bus.c, with appropriate ifdefs), instead of pci.c and ahb.c ?

We will have 3 of them actually (read_cachesize, read_eeprom, cleanup), but here is the whole {pci,platform}_driver specific stuff. Of course we can move all of this into one file, but i would like to avoid the unnecessary ifdefs where it is possible. Apart from this, if we will put the PCI and AHB stuff into one file, we could put it into main.c simply.

Your choice really, it doesn't matter much anyway. :)

Sujith

#18 lore raw

RFC 9/12 ath9k: enable support for AR9100

In reply to Gabor Juhos

Because we have support for the AR9100 devices now, we can enable them.

---
 drivers/net/wireless/ath9k/hw.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
drivers/net/wireless/ath9k/hw.c +3 -0
index d2b0ecf..ca0fc53 100644
@@ -389,6 +389,8 @@ static const char *ath9k_hw_devname(u16 devid)
 		return "Atheros 5418";
 	case AR9160_DEVID_PCI:
 		return "Atheros 9160";
+	case AR5416_AR9100_DEVID:
+		return "Atheros 9100";
 	case AR9280_DEVID_PCI:
 	case AR9280_DEVID_PCIE:
 		return "Atheros 9280";
@@ -1192,6 +1194,7 @@ struct ath_hal *ath9k_hw_attach(u16 devid, struct ath_softc *sc,
 	switch (devid) {
 	case AR5416_DEVID_PCI:
 	case AR5416_DEVID_PCIE:
+	case AR5416_AR9100_DEVID:
 	case AR9160_DEVID_PCI:
 	case AR9280_DEVID_PCI:
 	case AR9280_DEVID_PCIE:
Signature · 1 line
1.5.3.2
#19 lore raw

RFC 10/12 ath9k: remove (u16) casts from rtc register access

In reply to Gabor Juhos

The RTC register offsets don't fit into 'u16' on the AR913x, so we have to remove the existing casts.

---
 drivers/net/wireless/ath9k/hw.c |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)
drivers/net/wireless/ath9k/hw.c +7 -7
index ca0fc53..68f97ca 100644
@@ -1026,7 +1026,7 @@ static void ath9k_hw_init_pll(struct ath_hal *ah,
 				pll |= SM(0xb, AR_RTC_PLL_DIV);
 		}
 	}
-	REG_WRITE(ah, (u16) (AR_RTC_PLL_CONTROL), pll);
+	REG_WRITE(ah, (AR_RTC_PLL_CONTROL), pll);
 
 	udelay(RTC_PLL_SETTLE_DELAY);
 
@@ -1566,11 +1566,11 @@ static bool ath9k_hw_set_reset(struct ath_hal *ah, int type)
 			rst_flags |= AR_RTC_RC_MAC_COLD;
 	}
 
-	REG_WRITE(ah, (u16) (AR_RTC_RC), rst_flags);
+	REG_WRITE(ah, (AR_RTC_RC), rst_flags);
 	udelay(50);
 
-	REG_WRITE(ah, (u16) (AR_RTC_RC), 0);
-	if (!ath9k_hw_wait(ah, (u16) (AR_RTC_RC), AR_RTC_RC_M, 0)) {
+	REG_WRITE(ah, (AR_RTC_RC), 0);
+	if (!ath9k_hw_wait(ah, (AR_RTC_RC), AR_RTC_RC_M, 0)) {
 		DPRINTF(ah->ah_sc, ATH_DBG_RESET,
 			"RTC stuck in MAC reset\n");
 		return false;
@@ -1592,8 +1592,8 @@ static bool ath9k_hw_set_reset_power_on(struct ath_hal *ah)
 	REG_WRITE(ah, AR_RTC_FORCE_WAKE, AR_RTC_FORCE_WAKE_EN |
 		  AR_RTC_FORCE_WAKE_ON_INT);
 
-	REG_WRITE(ah, (u16) (AR_RTC_RESET), 0);
-	REG_WRITE(ah, (u16) (AR_RTC_RESET), 1);
+	REG_WRITE(ah, (AR_RTC_RESET), 0);
+	REG_WRITE(ah, (AR_RTC_RESET), 1);
 
 	if (!ath9k_hw_wait(ah,
 			   AR_RTC_STATUS,
@@ -2662,7 +2662,7 @@ static void ath9k_set_power_sleep(struct ath_hal *ah, int setChip)
 		if (!AR_SREV_9100(ah))
 			REG_WRITE(ah, AR_RC, AR_RC_AHB | AR_RC_HOSTIF);
 
-		REG_CLR_BIT(ah, (u16) (AR_RTC_RESET),
+		REG_CLR_BIT(ah, (AR_RTC_RESET),
 			    AR_RTC_RESET_EN);
 	}
 }
Signature · 1 line
1.5.3.2
#20 lore raw

RFC 11/12 ath9k: fix ar5416Addac_9100 values

In reply to Gabor Juhos

Writing the register at offset 0x98c4 causes a deadlock on the AR913x SoCs. Although i don't have detailed knowledge about these registers, but if i change the register offset according to the 'ar5416Addac' table, it works. Additionally there is no reference to the 0x98c4 elsewhere.

---
 drivers/net/wireless/ath9k/initvals.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/net/wireless/ath9k/initvals.h +1 -1
index f3cfa16..80a5d85 100644
@@ -659,7 +659,7 @@ static const u32 ar5416Addac_9100[][2] = {
     {0x0000989c,  0x00000000 },
     {0x0000989c,  0x00000000 },
     {0x0000989c,  0x00000000 },
-    {0x000098c4,  0x00000000 },
+    {0x000098cc,  0x00000000 },
 };
 
 /* ar5416 - howl ar5416_howl.ini */
Signature · 1 line
1.5.3.2
#21 lore raw

RFC 12/12 ath9k: fix null pointer dereference in ani monitor code

In reply to Gabor Juhos

In 'ath9k_ani_reset' the 'ahp->ah_curani' will be initialized only if 'DO_ANI(ah)' true. In 'ath9k_hw_ani_monitor' we are using 'ahp->ah_curani' unconditionally, and it will cause a NULL pointer dereference on AR9100.

---
 drivers/net/wireless/ath9k/ani.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
drivers/net/wireless/ath9k/ani.c +3 -3
index 251e2d9..ffa6a93 100644
@@ -555,6 +555,9 @@ void ath9k_hw_ani_monitor(struct ath_hal *ah,
 	struct ar5416AniState *aniState;
 	int32_t listenTime;
 
+	if (!DO_ANI(ah))
+		return;
+
 	aniState = ahp->ah_curani;
 	ahp->ah_stats.ast_nodestats = *stats;
 
@@ -614,9 +617,6 @@ void ath9k_hw_ani_monitor(struct ath_hal *ah,
 		aniState->cckPhyErrCount = cckPhyErrCnt;
 	}
 
-	if (!DO_ANI(ah))
-		return;
-
 	if (aniState->listenTime > 5 * ahp->ah_aniPeriod) {
 		if (aniState->ofdmPhyErrCount <= aniState->listenTime *
 		    aniState->ofdmTrigLow / 1000 &&
Signature · 1 line
1.5.3.2