svn commit: r230147 - in head/sys/dev/ath/ath_hal: . ar9001 ar9002
Adrian Chadd
adrian at FreeBSD.org
Sun Jan 15 19:22:35 UTC 2012
Author: adrian
Date: Sun Jan 15 19:22:34 2012
New Revision: 230147
URL: http://svn.freebsd.org/changeset/base/230147
Log:
Break out the "memory" EEPROM data read method from being AR9130 specific
to being more generic.
Other embedded SoCs also throw the configuration/PCI register
info into flash.
For now I'm just hard-coding the AR9280 option (for on-board AR9220's on
AP94 and commercial designs (eg D-Link DIR-825.))
TODO:
* Figure out how to support it for all 11n SoC NICs by doing it in
ar5416InitState();
* Don't hard-code the EEPROM size - add another field which is set
by the relevant chip initialisation code.
* 'owl_eep_start_loc' may need to be overridden in some cases to 0x0.
I need to do some further digging.
Modified:
head/sys/dev/ath/ath_hal/ah.c
head/sys/dev/ath/ath_hal/ah.h
head/sys/dev/ath/ath_hal/ar9001/ar9130_attach.c
head/sys/dev/ath/ath_hal/ar9001/ar9130_eeprom.c
head/sys/dev/ath/ath_hal/ar9001/ar9130_eeprom.h
head/sys/dev/ath/ath_hal/ar9002/ar9280_attach.c
Modified: head/sys/dev/ath/ath_hal/ah.c
==============================================================================
--- head/sys/dev/ath/ath_hal/ah.c Sun Jan 15 18:51:07 2012 (r230146)
+++ head/sys/dev/ath/ath_hal/ah.c Sun Jan 15 19:22:34 2012 (r230147)
@@ -1266,3 +1266,27 @@ ath_hal_getcca(struct ath_hal *ah)
return 1;
return ((diag & 0x500000) == 0);
}
+
+/*
+ * This routine is only needed when supporting EEPROM-in-RAM setups
+ * (eg embedded SoCs and on-board PCI/PCIe devices.)
+ */
+/* NB: This is in 16 bit words; not bytes */
+/* XXX This doesn't belong here! */
+#define ATH_DATA_EEPROM_SIZE 2048
+
+HAL_BOOL
+ath_hal_EepromDataRead(struct ath_hal *ah, u_int off, uint16_t *data)
+{
+ if (ah->ah_eepromdata == AH_NULL) {
+ HALDEBUG(ah, HAL_DEBUG_ANY, "%s: no eeprom data!\n", __func__);
+ return AH_FALSE;
+ }
+ if (off > ATH_DATA_EEPROM_SIZE) {
+ HALDEBUG(ah, HAL_DEBUG_ANY, "%s: offset %x > %x\n",
+ __func__, off, ATH_DATA_EEPROM_SIZE);
+ return AH_FALSE;
+ }
+ (*data) = ah->ah_eepromdata[off];
+ return AH_TRUE;
+}
Modified: head/sys/dev/ath/ath_hal/ah.h
==============================================================================
--- head/sys/dev/ath/ath_hal/ah.h Sun Jan 15 18:51:07 2012 (r230146)
+++ head/sys/dev/ath/ath_hal/ah.h Sun Jan 15 19:22:34 2012 (r230147)
@@ -1169,4 +1169,10 @@ void __ahdecl ath_hal_setcca(struct ath_
*/
int __ahdecl ath_hal_getcca(struct ath_hal *ah);
+/*
+ * Read EEPROM data from ah_eepromdata
+ */
+HAL_BOOL __ahdecl ath_hal_EepromDataRead(struct ath_hal *ah,
+ u_int off, uint16_t *data);
+
#endif /* _ATH_AH_H_ */
Modified: head/sys/dev/ath/ath_hal/ar9001/ar9130_attach.c
==============================================================================
--- head/sys/dev/ath/ath_hal/ar9001/ar9130_attach.c Sun Jan 15 18:51:07 2012 (r230146)
+++ head/sys/dev/ath/ath_hal/ar9001/ar9130_attach.c Sun Jan 15 19:22:34 2012 (r230147)
@@ -119,11 +119,11 @@ ar9130Attach(uint16_t devid, HAL_SOFTC s
/*
* Use the "local" EEPROM data given to us by the higher layers.
- * This is a private copy out of system flash. The Linux ath9k
- * commit for the initial AR9130 support mentions MMIO flash
- * access is "unreliable." -adrian
+ * This is a private copy out of system flash.
+ * By this stage the SoC SPI flash may have disabled the memory-
+ * mapping and rely purely on port-based SPI IO.
*/
- AH_PRIVATE((ah))->ah_eepromRead = ar9130EepromRead;
+ AH_PRIVATE((ah))->ah_eepromRead = ath_hal_EepromDataRead;
AH_PRIVATE((ah))->ah_eepromWrite = NULL;
ah->ah_eepromdata = eepromdata;
Modified: head/sys/dev/ath/ath_hal/ar9001/ar9130_eeprom.c
==============================================================================
--- head/sys/dev/ath/ath_hal/ar9001/ar9130_eeprom.c Sun Jan 15 18:51:07 2012 (r230146)
+++ head/sys/dev/ath/ath_hal/ar9001/ar9130_eeprom.c Sun Jan 15 19:22:34 2012 (r230147)
@@ -16,28 +16,3 @@
*
* $FreeBSD$
*/
-#include "opt_ah.h"
-
-#include "ah.h"
-#include "ah_internal.h"
-
-#include "ar9001/ar9130_eeprom.h"
-
-/* XXX this shouldn't be done here */
-/* This is in 16 bit words; not bytes -adrian */
-#define ATH_DATA_EEPROM_SIZE 2048
-
-HAL_BOOL
-ar9130EepromRead(struct ath_hal *ah, u_int off, uint16_t *data)
-{
- if (ah->ah_eepromdata == AH_NULL) {
- HALDEBUG(ah, HAL_DEBUG_ANY, "%s: no eeprom data!\n", __func__);
- return AH_FALSE;
- }
- if (off > ATH_DATA_EEPROM_SIZE) {
- HALDEBUG(ah, HAL_DEBUG_ANY, "ar9130EepromRead: offset %x > %x\n", off, ATH_DATA_EEPROM_SIZE);
- return AH_FALSE;
- }
- (*data) = ah->ah_eepromdata[off];
- return AH_TRUE;
-}
Modified: head/sys/dev/ath/ath_hal/ar9001/ar9130_eeprom.h
==============================================================================
--- head/sys/dev/ath/ath_hal/ar9001/ar9130_eeprom.h Sun Jan 15 18:51:07 2012 (r230146)
+++ head/sys/dev/ath/ath_hal/ar9001/ar9130_eeprom.h Sun Jan 15 19:22:34 2012 (r230147)
@@ -19,6 +19,4 @@
#ifndef __AR9130_EEPROM_H__
#define __AR9130_EEPROM_H__
-extern HAL_BOOL ar9130EepromRead(struct ath_hal *ah, u_int off, uint16_t *data);
-
#endif
Modified: head/sys/dev/ath/ath_hal/ar9002/ar9280_attach.c
==============================================================================
--- head/sys/dev/ath/ath_hal/ar9002/ar9280_attach.c Sun Jan 15 18:51:07 2012 (r230146)
+++ head/sys/dev/ath/ath_hal/ar9002/ar9280_attach.c Sun Jan 15 19:22:34 2012 (r230147)
@@ -169,6 +169,19 @@ ar9280Attach(uint16_t devid, HAL_SOFTC s
ar5416InitState(AH5416(ah), devid, sc, st, sh, status);
+
+ /*
+ * Use the "local" EEPROM data given to us by the higher layers.
+ * This is a private copy out of system flash. The Linux ath9k
+ * commit for the initial AR9130 support mentions MMIO flash
+ * access is "unreliable." -adrian
+ */
+ if (eepromdata != AH_NULL) {
+ AH_PRIVATE((ah))->ah_eepromRead = ath_hal_EepromDataRead;
+ AH_PRIVATE((ah))->ah_eepromWrite = NULL;
+ ah->ah_eepromdata = eepromdata;
+ }
+
/* XXX override with 9280 specific state */
/* override 5416 methods for our needs */
AH5416(ah)->ah_initPLL = ar9280InitPLL;
More information about the svn-src-all
mailing list