diff options
author | Sujith Manoharan <Sujith.Manoharan@atheros.com> | 2011-01-04 02:47:28 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2011-01-19 11:36:06 -0500 |
commit | 04cf53f465049c7c509aac7b776f75d38ef68e69 (patch) | |
tree | ab748e229f7bd35f131a1f4091f1f422168a9fed /drivers/net/wireless/ath | |
parent | 09a525d33870e8a16076ec0200cc5002f6bef35d (diff) |
ath9k_hw: Offload USB eeprom reading to target
For USB devices, reading the EEPROM data can be offloaded
to the target. Use multiple register reads to take advantage
of this feature to reduce initialization time.
Signed-off-by: Sujith Manoharan <Sujith.Manoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/ath')
-rw-r--r-- | drivers/net/wireless/ath/ath9k/eeprom.c | 32 | ||||
-rw-r--r-- | drivers/net/wireless/ath/ath9k/eeprom.h | 2 | ||||
-rw-r--r-- | drivers/net/wireless/ath/ath9k/eeprom_4k.c | 41 | ||||
-rw-r--r-- | drivers/net/wireless/ath/ath9k/eeprom_9287.c | 45 | ||||
-rw-r--r-- | drivers/net/wireless/ath/ath9k/eeprom_def.c | 32 |
5 files changed, 123 insertions, 29 deletions
diff --git a/drivers/net/wireless/ath/ath9k/eeprom.c b/drivers/net/wireless/ath/ath9k/eeprom.c index d05163159572..8c18bed3a558 100644 --- a/drivers/net/wireless/ath/ath9k/eeprom.c +++ b/drivers/net/wireless/ath/ath9k/eeprom.c | |||
@@ -89,6 +89,38 @@ bool ath9k_hw_get_lower_upper_index(u8 target, u8 *pList, u16 listSize, | |||
89 | return false; | 89 | return false; |
90 | } | 90 | } |
91 | 91 | ||
92 | void ath9k_hw_usb_gen_fill_eeprom(struct ath_hw *ah, u16 *eep_data, | ||
93 | int eep_start_loc, int size) | ||
94 | { | ||
95 | int i = 0, j, addr; | ||
96 | u32 addrdata[8]; | ||
97 | u32 data[8]; | ||
98 | |||
99 | for (addr = 0; addr < size; addr++) { | ||
100 | addrdata[i] = AR5416_EEPROM_OFFSET + | ||
101 | ((addr + eep_start_loc) << AR5416_EEPROM_S); | ||
102 | i++; | ||
103 | if (i == 8) { | ||
104 | REG_READ_MULTI(ah, addrdata, data, i); | ||
105 | |||
106 | for (j = 0; j < i; j++) { | ||
107 | *eep_data = data[j]; | ||
108 | eep_data++; | ||
109 | } | ||
110 | i = 0; | ||
111 | } | ||
112 | } | ||
113 | |||
114 | if (i != 0) { | ||
115 | REG_READ_MULTI(ah, addrdata, data, i); | ||
116 | |||
117 | for (j = 0; j < i; j++) { | ||
118 | *eep_data = data[j]; | ||
119 | eep_data++; | ||
120 | } | ||
121 | } | ||
122 | } | ||
123 | |||
92 | bool ath9k_hw_nvram_read(struct ath_common *common, u32 off, u16 *data) | 124 | bool ath9k_hw_nvram_read(struct ath_common *common, u32 off, u16 *data) |
93 | { | 125 | { |
94 | return common->bus_ops->eeprom_read(common, off, data); | 126 | return common->bus_ops->eeprom_read(common, off, data); |
diff --git a/drivers/net/wireless/ath/ath9k/eeprom.h b/drivers/net/wireless/ath/ath9k/eeprom.h index 58e2ddc927a9..bd82447f5b78 100644 --- a/drivers/net/wireless/ath/ath9k/eeprom.h +++ b/drivers/net/wireless/ath/ath9k/eeprom.h | |||
@@ -665,6 +665,8 @@ int16_t ath9k_hw_interpolate(u16 target, u16 srcLeft, u16 srcRight, | |||
665 | bool ath9k_hw_get_lower_upper_index(u8 target, u8 *pList, u16 listSize, | 665 | bool ath9k_hw_get_lower_upper_index(u8 target, u8 *pList, u16 listSize, |
666 | u16 *indexL, u16 *indexR); | 666 | u16 *indexL, u16 *indexR); |
667 | bool ath9k_hw_nvram_read(struct ath_common *common, u32 off, u16 *data); | 667 | bool ath9k_hw_nvram_read(struct ath_common *common, u32 off, u16 *data); |
668 | void ath9k_hw_usb_gen_fill_eeprom(struct ath_hw *ah, u16 *eep_data, | ||
669 | int eep_start_loc, int size); | ||
668 | void ath9k_hw_fill_vpd_table(u8 pwrMin, u8 pwrMax, u8 *pPwrList, | 670 | void ath9k_hw_fill_vpd_table(u8 pwrMin, u8 pwrMax, u8 *pPwrList, |
669 | u8 *pVpdList, u16 numIntercepts, | 671 | u8 *pVpdList, u16 numIntercepts, |
670 | u8 *pRetVpdList); | 672 | u8 *pRetVpdList); |
diff --git a/drivers/net/wireless/ath/ath9k/eeprom_4k.c b/drivers/net/wireless/ath/ath9k/eeprom_4k.c index fbdff7e47952..bc77a308c901 100644 --- a/drivers/net/wireless/ath/ath9k/eeprom_4k.c +++ b/drivers/net/wireless/ath/ath9k/eeprom_4k.c | |||
@@ -27,19 +27,13 @@ static int ath9k_hw_4k_get_eeprom_rev(struct ath_hw *ah) | |||
27 | return ((ah->eeprom.map4k.baseEepHeader.version) & 0xFFF); | 27 | return ((ah->eeprom.map4k.baseEepHeader.version) & 0xFFF); |
28 | } | 28 | } |
29 | 29 | ||
30 | static bool ath9k_hw_4k_fill_eeprom(struct ath_hw *ah) | ||
31 | { | ||
32 | #define SIZE_EEPROM_4K (sizeof(struct ar5416_eeprom_4k) / sizeof(u16)) | 30 | #define SIZE_EEPROM_4K (sizeof(struct ar5416_eeprom_4k) / sizeof(u16)) |
31 | |||
32 | static bool __ath9k_hw_4k_fill_eeprom(struct ath_hw *ah) | ||
33 | { | ||
33 | struct ath_common *common = ath9k_hw_common(ah); | 34 | struct ath_common *common = ath9k_hw_common(ah); |
34 | u16 *eep_data = (u16 *)&ah->eeprom.map4k; | 35 | u16 *eep_data = (u16 *)&ah->eeprom.map4k; |
35 | int addr, eep_start_loc = 0; | 36 | int addr, eep_start_loc = 64; |
36 | |||
37 | eep_start_loc = 64; | ||
38 | |||
39 | if (!ath9k_hw_use_flash(ah)) { | ||
40 | ath_dbg(common, ATH_DBG_EEPROM, | ||
41 | "Reading from EEPROM, not flash\n"); | ||
42 | } | ||
43 | 37 | ||
44 | for (addr = 0; addr < SIZE_EEPROM_4K; addr++) { | 38 | for (addr = 0; addr < SIZE_EEPROM_4K; addr++) { |
45 | if (!ath9k_hw_nvram_read(common, addr + eep_start_loc, eep_data)) { | 39 | if (!ath9k_hw_nvram_read(common, addr + eep_start_loc, eep_data)) { |
@@ -51,9 +45,34 @@ static bool ath9k_hw_4k_fill_eeprom(struct ath_hw *ah) | |||
51 | } | 45 | } |
52 | 46 | ||
53 | return true; | 47 | return true; |
54 | #undef SIZE_EEPROM_4K | ||
55 | } | 48 | } |
56 | 49 | ||
50 | static bool __ath9k_hw_usb_4k_fill_eeprom(struct ath_hw *ah) | ||
51 | { | ||
52 | u16 *eep_data = (u16 *)&ah->eeprom.map4k; | ||
53 | |||
54 | ath9k_hw_usb_gen_fill_eeprom(ah, eep_data, 64, SIZE_EEPROM_4K); | ||
55 | |||
56 | return true; | ||
57 | } | ||
58 | |||
59 | static bool ath9k_hw_4k_fill_eeprom(struct ath_hw *ah) | ||
60 | { | ||
61 | struct ath_common *common = ath9k_hw_common(ah); | ||
62 | |||
63 | if (!ath9k_hw_use_flash(ah)) { | ||
64 | ath_dbg(common, ATH_DBG_EEPROM, | ||
65 | "Reading from EEPROM, not flash\n"); | ||
66 | } | ||
67 | |||
68 | if (common->bus_ops->ath_bus_type == ATH_USB) | ||
69 | return __ath9k_hw_usb_4k_fill_eeprom(ah); | ||
70 | else | ||
71 | return __ath9k_hw_4k_fill_eeprom(ah); | ||
72 | } | ||
73 | |||
74 | #undef SIZE_EEPROM_4K | ||
75 | |||
57 | static int ath9k_hw_4k_check_eeprom(struct ath_hw *ah) | 76 | static int ath9k_hw_4k_check_eeprom(struct ath_hw *ah) |
58 | { | 77 | { |
59 | #define EEPROM_4K_SIZE (sizeof(struct ar5416_eeprom_4k) / sizeof(u16)) | 78 | #define EEPROM_4K_SIZE (sizeof(struct ar5416_eeprom_4k) / sizeof(u16)) |
diff --git a/drivers/net/wireless/ath/ath9k/eeprom_9287.c b/drivers/net/wireless/ath/ath9k/eeprom_9287.c index 9b6bc8a953bc..8cd8333cc086 100644 --- a/drivers/net/wireless/ath/ath9k/eeprom_9287.c +++ b/drivers/net/wireless/ath/ath9k/eeprom_9287.c | |||
@@ -17,7 +17,7 @@ | |||
17 | #include "hw.h" | 17 | #include "hw.h" |
18 | #include "ar9002_phy.h" | 18 | #include "ar9002_phy.h" |
19 | 19 | ||
20 | #define NUM_EEP_WORDS (sizeof(struct ar9287_eeprom) / sizeof(u16)) | 20 | #define SIZE_EEPROM_AR9287 (sizeof(struct ar9287_eeprom) / sizeof(u16)) |
21 | 21 | ||
22 | static int ath9k_hw_ar9287_get_eeprom_ver(struct ath_hw *ah) | 22 | static int ath9k_hw_ar9287_get_eeprom_ver(struct ath_hw *ah) |
23 | { | 23 | { |
@@ -29,25 +29,15 @@ static int ath9k_hw_ar9287_get_eeprom_rev(struct ath_hw *ah) | |||
29 | return (ah->eeprom.map9287.baseEepHeader.version) & 0xFFF; | 29 | return (ah->eeprom.map9287.baseEepHeader.version) & 0xFFF; |
30 | } | 30 | } |
31 | 31 | ||
32 | static bool ath9k_hw_ar9287_fill_eeprom(struct ath_hw *ah) | 32 | static bool __ath9k_hw_ar9287_fill_eeprom(struct ath_hw *ah) |
33 | { | 33 | { |
34 | struct ar9287_eeprom *eep = &ah->eeprom.map9287; | 34 | struct ar9287_eeprom *eep = &ah->eeprom.map9287; |
35 | struct ath_common *common = ath9k_hw_common(ah); | 35 | struct ath_common *common = ath9k_hw_common(ah); |
36 | u16 *eep_data; | 36 | u16 *eep_data; |
37 | int addr, eep_start_loc; | 37 | int addr, eep_start_loc = AR9287_EEP_START_LOC; |
38 | eep_data = (u16 *)eep; | 38 | eep_data = (u16 *)eep; |
39 | 39 | ||
40 | if (common->bus_ops->ath_bus_type == ATH_USB) | 40 | for (addr = 0; addr < SIZE_EEPROM_AR9287; addr++) { |
41 | eep_start_loc = AR9287_HTC_EEP_START_LOC; | ||
42 | else | ||
43 | eep_start_loc = AR9287_EEP_START_LOC; | ||
44 | |||
45 | if (!ath9k_hw_use_flash(ah)) { | ||
46 | ath_dbg(common, ATH_DBG_EEPROM, | ||
47 | "Reading from EEPROM, not flash\n"); | ||
48 | } | ||
49 | |||
50 | for (addr = 0; addr < NUM_EEP_WORDS; addr++) { | ||
51 | if (!ath9k_hw_nvram_read(common, addr + eep_start_loc, | 41 | if (!ath9k_hw_nvram_read(common, addr + eep_start_loc, |
52 | eep_data)) { | 42 | eep_data)) { |
53 | ath_dbg(common, ATH_DBG_EEPROM, | 43 | ath_dbg(common, ATH_DBG_EEPROM, |
@@ -60,6 +50,31 @@ static bool ath9k_hw_ar9287_fill_eeprom(struct ath_hw *ah) | |||
60 | return true; | 50 | return true; |
61 | } | 51 | } |
62 | 52 | ||
53 | static bool __ath9k_hw_usb_ar9287_fill_eeprom(struct ath_hw *ah) | ||
54 | { | ||
55 | u16 *eep_data = (u16 *)&ah->eeprom.map9287; | ||
56 | |||
57 | ath9k_hw_usb_gen_fill_eeprom(ah, eep_data, | ||
58 | AR9287_HTC_EEP_START_LOC, | ||
59 | SIZE_EEPROM_AR9287); | ||
60 | return true; | ||
61 | } | ||
62 | |||
63 | static bool ath9k_hw_ar9287_fill_eeprom(struct ath_hw *ah) | ||
64 | { | ||
65 | struct ath_common *common = ath9k_hw_common(ah); | ||
66 | |||
67 | if (!ath9k_hw_use_flash(ah)) { | ||
68 | ath_dbg(common, ATH_DBG_EEPROM, | ||
69 | "Reading from EEPROM, not flash\n"); | ||
70 | } | ||
71 | |||
72 | if (common->bus_ops->ath_bus_type == ATH_USB) | ||
73 | return __ath9k_hw_usb_ar9287_fill_eeprom(ah); | ||
74 | else | ||
75 | return __ath9k_hw_ar9287_fill_eeprom(ah); | ||
76 | } | ||
77 | |||
63 | static int ath9k_hw_ar9287_check_eeprom(struct ath_hw *ah) | 78 | static int ath9k_hw_ar9287_check_eeprom(struct ath_hw *ah) |
64 | { | 79 | { |
65 | u32 sum = 0, el, integer; | 80 | u32 sum = 0, el, integer; |
@@ -86,7 +101,7 @@ static int ath9k_hw_ar9287_check_eeprom(struct ath_hw *ah) | |||
86 | need_swap = true; | 101 | need_swap = true; |
87 | eepdata = (u16 *)(&ah->eeprom); | 102 | eepdata = (u16 *)(&ah->eeprom); |
88 | 103 | ||
89 | for (addr = 0; addr < NUM_EEP_WORDS; addr++) { | 104 | for (addr = 0; addr < SIZE_EEPROM_AR9287; addr++) { |
90 | temp = swab16(*eepdata); | 105 | temp = swab16(*eepdata); |
91 | *eepdata = temp; | 106 | *eepdata = temp; |
92 | eepdata++; | 107 | eepdata++; |
diff --git a/drivers/net/wireless/ath/ath9k/eeprom_def.c b/drivers/net/wireless/ath/ath9k/eeprom_def.c index 749a93608664..c9318ff40964 100644 --- a/drivers/net/wireless/ath/ath9k/eeprom_def.c +++ b/drivers/net/wireless/ath/ath9k/eeprom_def.c | |||
@@ -86,9 +86,10 @@ static int ath9k_hw_def_get_eeprom_rev(struct ath_hw *ah) | |||
86 | return ((ah->eeprom.def.baseEepHeader.version) & 0xFFF); | 86 | return ((ah->eeprom.def.baseEepHeader.version) & 0xFFF); |
87 | } | 87 | } |
88 | 88 | ||
89 | static bool ath9k_hw_def_fill_eeprom(struct ath_hw *ah) | ||
90 | { | ||
91 | #define SIZE_EEPROM_DEF (sizeof(struct ar5416_eeprom_def) / sizeof(u16)) | 89 | #define SIZE_EEPROM_DEF (sizeof(struct ar5416_eeprom_def) / sizeof(u16)) |
90 | |||
91 | static bool __ath9k_hw_def_fill_eeprom(struct ath_hw *ah) | ||
92 | { | ||
92 | struct ath_common *common = ath9k_hw_common(ah); | 93 | struct ath_common *common = ath9k_hw_common(ah); |
93 | u16 *eep_data = (u16 *)&ah->eeprom.def; | 94 | u16 *eep_data = (u16 *)&ah->eeprom.def; |
94 | int addr, ar5416_eep_start_loc = 0x100; | 95 | int addr, ar5416_eep_start_loc = 0x100; |
@@ -103,9 +104,34 @@ static bool ath9k_hw_def_fill_eeprom(struct ath_hw *ah) | |||
103 | eep_data++; | 104 | eep_data++; |
104 | } | 105 | } |
105 | return true; | 106 | return true; |
106 | #undef SIZE_EEPROM_DEF | ||
107 | } | 107 | } |
108 | 108 | ||
109 | static bool __ath9k_hw_usb_def_fill_eeprom(struct ath_hw *ah) | ||
110 | { | ||
111 | u16 *eep_data = (u16 *)&ah->eeprom.def; | ||
112 | |||
113 | ath9k_hw_usb_gen_fill_eeprom(ah, eep_data, | ||
114 | 0x100, SIZE_EEPROM_DEF); | ||
115 | return true; | ||
116 | } | ||
117 | |||
118 | static bool ath9k_hw_def_fill_eeprom(struct ath_hw *ah) | ||
119 | { | ||
120 | struct ath_common *common = ath9k_hw_common(ah); | ||
121 | |||
122 | if (!ath9k_hw_use_flash(ah)) { | ||
123 | ath_dbg(common, ATH_DBG_EEPROM, | ||
124 | "Reading from EEPROM, not flash\n"); | ||
125 | } | ||
126 | |||
127 | if (common->bus_ops->ath_bus_type == ATH_USB) | ||
128 | return __ath9k_hw_usb_def_fill_eeprom(ah); | ||
129 | else | ||
130 | return __ath9k_hw_def_fill_eeprom(ah); | ||
131 | } | ||
132 | |||
133 | #undef SIZE_EEPROM_DEF | ||
134 | |||
109 | static int ath9k_hw_def_check_eeprom(struct ath_hw *ah) | 135 | static int ath9k_hw_def_check_eeprom(struct ath_hw *ah) |
110 | { | 136 | { |
111 | struct ar5416_eeprom_def *eep = | 137 | struct ar5416_eeprom_def *eep = |