ich8lan.c 61 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225
  1. /*******************************************************************************
  2. Intel PRO/1000 Linux driver
  3. Copyright(c) 1999 - 2007 Intel Corporation.
  4. This program is free software; you can redistribute it and/or modify it
  5. under the terms and conditions of the GNU General Public License,
  6. version 2, as published by the Free Software Foundation.
  7. This program is distributed in the hope it will be useful, but WITHOUT
  8. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  9. FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  10. more details.
  11. You should have received a copy of the GNU General Public License along with
  12. this program; if not, write to the Free Software Foundation, Inc.,
  13. 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
  14. The full GNU General Public License is included in this distribution in
  15. the file called "COPYING".
  16. Contact Information:
  17. Linux NICS <linux.nics@intel.com>
  18. e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
  19. Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  20. *******************************************************************************/
  21. /*
  22. * 82562G-2 10/100 Network Connection
  23. * 82562GT 10/100 Network Connection
  24. * 82562GT-2 10/100 Network Connection
  25. * 82562V 10/100 Network Connection
  26. * 82562V-2 10/100 Network Connection
  27. * 82566DC-2 Gigabit Network Connection
  28. * 82566DC Gigabit Network Connection
  29. * 82566DM-2 Gigabit Network Connection
  30. * 82566DM Gigabit Network Connection
  31. * 82566MC Gigabit Network Connection
  32. * 82566MM Gigabit Network Connection
  33. */
  34. #include <linux/netdevice.h>
  35. #include <linux/ethtool.h>
  36. #include <linux/delay.h>
  37. #include <linux/pci.h>
  38. #include "e1000.h"
  39. #define ICH_FLASH_GFPREG 0x0000
  40. #define ICH_FLASH_HSFSTS 0x0004
  41. #define ICH_FLASH_HSFCTL 0x0006
  42. #define ICH_FLASH_FADDR 0x0008
  43. #define ICH_FLASH_FDATA0 0x0010
  44. #define ICH_FLASH_READ_COMMAND_TIMEOUT 500
  45. #define ICH_FLASH_WRITE_COMMAND_TIMEOUT 500
  46. #define ICH_FLASH_ERASE_COMMAND_TIMEOUT 3000000
  47. #define ICH_FLASH_LINEAR_ADDR_MASK 0x00FFFFFF
  48. #define ICH_FLASH_CYCLE_REPEAT_COUNT 10
  49. #define ICH_CYCLE_READ 0
  50. #define ICH_CYCLE_WRITE 2
  51. #define ICH_CYCLE_ERASE 3
  52. #define FLASH_GFPREG_BASE_MASK 0x1FFF
  53. #define FLASH_SECTOR_ADDR_SHIFT 12
  54. #define ICH_FLASH_SEG_SIZE_256 256
  55. #define ICH_FLASH_SEG_SIZE_4K 4096
  56. #define ICH_FLASH_SEG_SIZE_8K 8192
  57. #define ICH_FLASH_SEG_SIZE_64K 65536
  58. #define E1000_ICH_FWSM_RSPCIPHY 0x00000040 /* Reset PHY on PCI Reset */
  59. #define E1000_ICH_MNG_IAMT_MODE 0x2
  60. #define ID_LED_DEFAULT_ICH8LAN ((ID_LED_DEF1_DEF2 << 12) | \
  61. (ID_LED_DEF1_OFF2 << 8) | \
  62. (ID_LED_DEF1_ON2 << 4) | \
  63. (ID_LED_DEF1_DEF2))
  64. #define E1000_ICH_NVM_SIG_WORD 0x13
  65. #define E1000_ICH_NVM_SIG_MASK 0xC000
  66. #define E1000_ICH8_LAN_INIT_TIMEOUT 1500
  67. #define E1000_FEXTNVM_SW_CONFIG 1
  68. #define E1000_FEXTNVM_SW_CONFIG_ICH8M (1 << 27) /* Bit redefined for ICH8M :/ */
  69. #define PCIE_ICH8_SNOOP_ALL PCIE_NO_SNOOP_ALL
  70. #define E1000_ICH_RAR_ENTRIES 7
  71. #define PHY_PAGE_SHIFT 5
  72. #define PHY_REG(page, reg) (((page) << PHY_PAGE_SHIFT) | \
  73. ((reg) & MAX_PHY_REG_ADDRESS))
  74. #define IGP3_KMRN_DIAG PHY_REG(770, 19) /* KMRN Diagnostic */
  75. #define IGP3_VR_CTRL PHY_REG(776, 18) /* Voltage Regulator Control */
  76. #define IGP3_KMRN_DIAG_PCS_LOCK_LOSS 0x0002
  77. #define IGP3_VR_CTRL_DEV_POWERDOWN_MODE_MASK 0x0300
  78. #define IGP3_VR_CTRL_MODE_SHUTDOWN 0x0200
  79. /* ICH GbE Flash Hardware Sequencing Flash Status Register bit breakdown */
  80. /* Offset 04h HSFSTS */
  81. union ich8_hws_flash_status {
  82. struct ich8_hsfsts {
  83. u16 flcdone :1; /* bit 0 Flash Cycle Done */
  84. u16 flcerr :1; /* bit 1 Flash Cycle Error */
  85. u16 dael :1; /* bit 2 Direct Access error Log */
  86. u16 berasesz :2; /* bit 4:3 Sector Erase Size */
  87. u16 flcinprog :1; /* bit 5 flash cycle in Progress */
  88. u16 reserved1 :2; /* bit 13:6 Reserved */
  89. u16 reserved2 :6; /* bit 13:6 Reserved */
  90. u16 fldesvalid :1; /* bit 14 Flash Descriptor Valid */
  91. u16 flockdn :1; /* bit 15 Flash Config Lock-Down */
  92. } hsf_status;
  93. u16 regval;
  94. };
  95. /* ICH GbE Flash Hardware Sequencing Flash control Register bit breakdown */
  96. /* Offset 06h FLCTL */
  97. union ich8_hws_flash_ctrl {
  98. struct ich8_hsflctl {
  99. u16 flcgo :1; /* 0 Flash Cycle Go */
  100. u16 flcycle :2; /* 2:1 Flash Cycle */
  101. u16 reserved :5; /* 7:3 Reserved */
  102. u16 fldbcount :2; /* 9:8 Flash Data Byte Count */
  103. u16 flockdn :6; /* 15:10 Reserved */
  104. } hsf_ctrl;
  105. u16 regval;
  106. };
  107. /* ICH Flash Region Access Permissions */
  108. union ich8_hws_flash_regacc {
  109. struct ich8_flracc {
  110. u32 grra :8; /* 0:7 GbE region Read Access */
  111. u32 grwa :8; /* 8:15 GbE region Write Access */
  112. u32 gmrag :8; /* 23:16 GbE Master Read Access Grant */
  113. u32 gmwag :8; /* 31:24 GbE Master Write Access Grant */
  114. } hsf_flregacc;
  115. u16 regval;
  116. };
  117. static s32 e1000_setup_link_ich8lan(struct e1000_hw *hw);
  118. static void e1000_clear_hw_cntrs_ich8lan(struct e1000_hw *hw);
  119. static void e1000_initialize_hw_bits_ich8lan(struct e1000_hw *hw);
  120. static s32 e1000_check_polarity_ife_ich8lan(struct e1000_hw *hw);
  121. static s32 e1000_erase_flash_bank_ich8lan(struct e1000_hw *hw, u32 bank);
  122. static s32 e1000_retry_write_flash_byte_ich8lan(struct e1000_hw *hw,
  123. u32 offset, u8 byte);
  124. static s32 e1000_read_flash_word_ich8lan(struct e1000_hw *hw, u32 offset,
  125. u16 *data);
  126. static s32 e1000_read_flash_data_ich8lan(struct e1000_hw *hw, u32 offset,
  127. u8 size, u16 *data);
  128. static s32 e1000_setup_copper_link_ich8lan(struct e1000_hw *hw);
  129. static s32 e1000_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw *hw);
  130. static inline u16 __er16flash(struct e1000_hw *hw, unsigned long reg)
  131. {
  132. return readw(hw->flash_address + reg);
  133. }
  134. static inline u32 __er32flash(struct e1000_hw *hw, unsigned long reg)
  135. {
  136. return readl(hw->flash_address + reg);
  137. }
  138. static inline void __ew16flash(struct e1000_hw *hw, unsigned long reg, u16 val)
  139. {
  140. writew(val, hw->flash_address + reg);
  141. }
  142. static inline void __ew32flash(struct e1000_hw *hw, unsigned long reg, u32 val)
  143. {
  144. writel(val, hw->flash_address + reg);
  145. }
  146. #define er16flash(reg) __er16flash(hw, (reg))
  147. #define er32flash(reg) __er32flash(hw, (reg))
  148. #define ew16flash(reg,val) __ew16flash(hw, (reg), (val))
  149. #define ew32flash(reg,val) __ew32flash(hw, (reg), (val))
  150. /**
  151. * e1000_init_phy_params_ich8lan - Initialize PHY function pointers
  152. * @hw: pointer to the HW structure
  153. *
  154. * Initialize family-specific PHY parameters and function pointers.
  155. **/
  156. static s32 e1000_init_phy_params_ich8lan(struct e1000_hw *hw)
  157. {
  158. struct e1000_phy_info *phy = &hw->phy;
  159. s32 ret_val;
  160. u16 i = 0;
  161. phy->addr = 1;
  162. phy->reset_delay_us = 100;
  163. phy->id = 0;
  164. while ((e1000_phy_unknown == e1000e_get_phy_type_from_id(phy->id)) &&
  165. (i++ < 100)) {
  166. msleep(1);
  167. ret_val = e1000e_get_phy_id(hw);
  168. if (ret_val)
  169. return ret_val;
  170. }
  171. /* Verify phy id */
  172. switch (phy->id) {
  173. case IGP03E1000_E_PHY_ID:
  174. phy->type = e1000_phy_igp_3;
  175. phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT;
  176. break;
  177. case IFE_E_PHY_ID:
  178. case IFE_PLUS_E_PHY_ID:
  179. case IFE_C_E_PHY_ID:
  180. phy->type = e1000_phy_ife;
  181. phy->autoneg_mask = E1000_ALL_NOT_GIG;
  182. break;
  183. default:
  184. return -E1000_ERR_PHY;
  185. break;
  186. }
  187. return 0;
  188. }
  189. /**
  190. * e1000_init_nvm_params_ich8lan - Initialize NVM function pointers
  191. * @hw: pointer to the HW structure
  192. *
  193. * Initialize family-specific NVM parameters and function
  194. * pointers.
  195. **/
  196. static s32 e1000_init_nvm_params_ich8lan(struct e1000_hw *hw)
  197. {
  198. struct e1000_nvm_info *nvm = &hw->nvm;
  199. struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
  200. u32 gfpreg;
  201. u32 sector_base_addr;
  202. u32 sector_end_addr;
  203. u16 i;
  204. /* Can't read flash registers if the register set isn't mapped.
  205. */
  206. if (!hw->flash_address) {
  207. hw_dbg(hw, "ERROR: Flash registers not mapped\n");
  208. return -E1000_ERR_CONFIG;
  209. }
  210. nvm->type = e1000_nvm_flash_sw;
  211. gfpreg = er32flash(ICH_FLASH_GFPREG);
  212. /* sector_X_addr is a "sector"-aligned address (4096 bytes)
  213. * Add 1 to sector_end_addr since this sector is included in
  214. * the overall size. */
  215. sector_base_addr = gfpreg & FLASH_GFPREG_BASE_MASK;
  216. sector_end_addr = ((gfpreg >> 16) & FLASH_GFPREG_BASE_MASK) + 1;
  217. /* flash_base_addr is byte-aligned */
  218. nvm->flash_base_addr = sector_base_addr << FLASH_SECTOR_ADDR_SHIFT;
  219. /* find total size of the NVM, then cut in half since the total
  220. * size represents two separate NVM banks. */
  221. nvm->flash_bank_size = (sector_end_addr - sector_base_addr)
  222. << FLASH_SECTOR_ADDR_SHIFT;
  223. nvm->flash_bank_size /= 2;
  224. /* Adjust to word count */
  225. nvm->flash_bank_size /= sizeof(u16);
  226. nvm->word_size = E1000_ICH8_SHADOW_RAM_WORDS;
  227. /* Clear shadow ram */
  228. for (i = 0; i < nvm->word_size; i++) {
  229. dev_spec->shadow_ram[i].modified = 0;
  230. dev_spec->shadow_ram[i].value = 0xFFFF;
  231. }
  232. return 0;
  233. }
  234. /**
  235. * e1000_init_mac_params_ich8lan - Initialize MAC function pointers
  236. * @hw: pointer to the HW structure
  237. *
  238. * Initialize family-specific MAC parameters and function
  239. * pointers.
  240. **/
  241. static s32 e1000_init_mac_params_ich8lan(struct e1000_adapter *adapter)
  242. {
  243. struct e1000_hw *hw = &adapter->hw;
  244. struct e1000_mac_info *mac = &hw->mac;
  245. /* Set media type function pointer */
  246. hw->media_type = e1000_media_type_copper;
  247. /* Set mta register count */
  248. mac->mta_reg_count = 32;
  249. /* Set rar entry count */
  250. mac->rar_entry_count = E1000_ICH_RAR_ENTRIES;
  251. if (mac->type == e1000_ich8lan)
  252. mac->rar_entry_count--;
  253. /* Set if manageability features are enabled. */
  254. mac->arc_subsystem_valid = 1;
  255. /* Enable PCS Lock-loss workaround for ICH8 */
  256. if (mac->type == e1000_ich8lan)
  257. e1000e_set_kmrn_lock_loss_workaround_ich8lan(hw, 1);
  258. return 0;
  259. }
  260. static s32 e1000_get_invariants_ich8lan(struct e1000_adapter *adapter)
  261. {
  262. struct e1000_hw *hw = &adapter->hw;
  263. s32 rc;
  264. rc = e1000_init_mac_params_ich8lan(adapter);
  265. if (rc)
  266. return rc;
  267. rc = e1000_init_nvm_params_ich8lan(hw);
  268. if (rc)
  269. return rc;
  270. rc = e1000_init_phy_params_ich8lan(hw);
  271. if (rc)
  272. return rc;
  273. if ((adapter->hw.mac.type == e1000_ich8lan) &&
  274. (adapter->hw.phy.type == e1000_phy_igp_3))
  275. adapter->flags |= FLAG_LSC_GIG_SPEED_DROP;
  276. return 0;
  277. }
  278. /**
  279. * e1000_acquire_swflag_ich8lan - Acquire software control flag
  280. * @hw: pointer to the HW structure
  281. *
  282. * Acquires the software control flag for performing NVM and PHY
  283. * operations. This is a function pointer entry point only called by
  284. * read/write routines for the PHY and NVM parts.
  285. **/
  286. static s32 e1000_acquire_swflag_ich8lan(struct e1000_hw *hw)
  287. {
  288. u32 extcnf_ctrl;
  289. u32 timeout = PHY_CFG_TIMEOUT;
  290. while (timeout) {
  291. extcnf_ctrl = er32(EXTCNF_CTRL);
  292. extcnf_ctrl |= E1000_EXTCNF_CTRL_SWFLAG;
  293. ew32(EXTCNF_CTRL, extcnf_ctrl);
  294. extcnf_ctrl = er32(EXTCNF_CTRL);
  295. if (extcnf_ctrl & E1000_EXTCNF_CTRL_SWFLAG)
  296. break;
  297. mdelay(1);
  298. timeout--;
  299. }
  300. if (!timeout) {
  301. hw_dbg(hw, "FW or HW has locked the resource for too long.\n");
  302. return -E1000_ERR_CONFIG;
  303. }
  304. return 0;
  305. }
  306. /**
  307. * e1000_release_swflag_ich8lan - Release software control flag
  308. * @hw: pointer to the HW structure
  309. *
  310. * Releases the software control flag for performing NVM and PHY operations.
  311. * This is a function pointer entry point only called by read/write
  312. * routines for the PHY and NVM parts.
  313. **/
  314. static void e1000_release_swflag_ich8lan(struct e1000_hw *hw)
  315. {
  316. u32 extcnf_ctrl;
  317. extcnf_ctrl = er32(EXTCNF_CTRL);
  318. extcnf_ctrl &= ~E1000_EXTCNF_CTRL_SWFLAG;
  319. ew32(EXTCNF_CTRL, extcnf_ctrl);
  320. }
  321. /**
  322. * e1000_check_reset_block_ich8lan - Check if PHY reset is blocked
  323. * @hw: pointer to the HW structure
  324. *
  325. * Checks if firmware is blocking the reset of the PHY.
  326. * This is a function pointer entry point only called by
  327. * reset routines.
  328. **/
  329. static s32 e1000_check_reset_block_ich8lan(struct e1000_hw *hw)
  330. {
  331. u32 fwsm;
  332. fwsm = er32(FWSM);
  333. return (fwsm & E1000_ICH_FWSM_RSPCIPHY) ? 0 : E1000_BLK_PHY_RESET;
  334. }
  335. /**
  336. * e1000_phy_force_speed_duplex_ich8lan - Force PHY speed & duplex
  337. * @hw: pointer to the HW structure
  338. *
  339. * Forces the speed and duplex settings of the PHY.
  340. * This is a function pointer entry point only called by
  341. * PHY setup routines.
  342. **/
  343. static s32 e1000_phy_force_speed_duplex_ich8lan(struct e1000_hw *hw)
  344. {
  345. struct e1000_phy_info *phy = &hw->phy;
  346. s32 ret_val;
  347. u16 data;
  348. bool link;
  349. if (phy->type != e1000_phy_ife) {
  350. ret_val = e1000e_phy_force_speed_duplex_igp(hw);
  351. return ret_val;
  352. }
  353. ret_val = e1e_rphy(hw, PHY_CONTROL, &data);
  354. if (ret_val)
  355. return ret_val;
  356. e1000e_phy_force_speed_duplex_setup(hw, &data);
  357. ret_val = e1e_wphy(hw, PHY_CONTROL, data);
  358. if (ret_val)
  359. return ret_val;
  360. /* Disable MDI-X support for 10/100 */
  361. ret_val = e1e_rphy(hw, IFE_PHY_MDIX_CONTROL, &data);
  362. if (ret_val)
  363. return ret_val;
  364. data &= ~IFE_PMC_AUTO_MDIX;
  365. data &= ~IFE_PMC_FORCE_MDIX;
  366. ret_val = e1e_wphy(hw, IFE_PHY_MDIX_CONTROL, data);
  367. if (ret_val)
  368. return ret_val;
  369. hw_dbg(hw, "IFE PMC: %X\n", data);
  370. udelay(1);
  371. if (phy->wait_for_link) {
  372. hw_dbg(hw, "Waiting for forced speed/duplex link on IFE phy.\n");
  373. ret_val = e1000e_phy_has_link_generic(hw,
  374. PHY_FORCE_LIMIT,
  375. 100000,
  376. &link);
  377. if (ret_val)
  378. return ret_val;
  379. if (!link)
  380. hw_dbg(hw, "Link taking longer than expected.\n");
  381. /* Try once more */
  382. ret_val = e1000e_phy_has_link_generic(hw,
  383. PHY_FORCE_LIMIT,
  384. 100000,
  385. &link);
  386. if (ret_val)
  387. return ret_val;
  388. }
  389. return 0;
  390. }
  391. /**
  392. * e1000_phy_hw_reset_ich8lan - Performs a PHY reset
  393. * @hw: pointer to the HW structure
  394. *
  395. * Resets the PHY
  396. * This is a function pointer entry point called by drivers
  397. * or other shared routines.
  398. **/
  399. static s32 e1000_phy_hw_reset_ich8lan(struct e1000_hw *hw)
  400. {
  401. struct e1000_phy_info *phy = &hw->phy;
  402. u32 i;
  403. u32 data, cnf_size, cnf_base_addr, sw_cfg_mask;
  404. s32 ret_val;
  405. u16 loop = E1000_ICH8_LAN_INIT_TIMEOUT;
  406. u16 word_addr, reg_data, reg_addr, phy_page = 0;
  407. ret_val = e1000e_phy_hw_reset_generic(hw);
  408. if (ret_val)
  409. return ret_val;
  410. /* Initialize the PHY from the NVM on ICH platforms. This
  411. * is needed due to an issue where the NVM configuration is
  412. * not properly autoloaded after power transitions.
  413. * Therefore, after each PHY reset, we will load the
  414. * configuration data out of the NVM manually.
  415. */
  416. if (hw->mac.type == e1000_ich8lan && phy->type == e1000_phy_igp_3) {
  417. struct e1000_adapter *adapter = hw->adapter;
  418. /* Check if SW needs configure the PHY */
  419. if ((adapter->pdev->device == E1000_DEV_ID_ICH8_IGP_M_AMT) ||
  420. (adapter->pdev->device == E1000_DEV_ID_ICH8_IGP_M))
  421. sw_cfg_mask = E1000_FEXTNVM_SW_CONFIG_ICH8M;
  422. else
  423. sw_cfg_mask = E1000_FEXTNVM_SW_CONFIG;
  424. data = er32(FEXTNVM);
  425. if (!(data & sw_cfg_mask))
  426. return 0;
  427. /* Wait for basic configuration completes before proceeding*/
  428. do {
  429. data = er32(STATUS);
  430. data &= E1000_STATUS_LAN_INIT_DONE;
  431. udelay(100);
  432. } while ((!data) && --loop);
  433. /* If basic configuration is incomplete before the above loop
  434. * count reaches 0, loading the configuration from NVM will
  435. * leave the PHY in a bad state possibly resulting in no link.
  436. */
  437. if (loop == 0) {
  438. hw_dbg(hw, "LAN_INIT_DONE not set, increase timeout\n");
  439. }
  440. /* Clear the Init Done bit for the next init event */
  441. data = er32(STATUS);
  442. data &= ~E1000_STATUS_LAN_INIT_DONE;
  443. ew32(STATUS, data);
  444. /* Make sure HW does not configure LCD from PHY
  445. * extended configuration before SW configuration */
  446. data = er32(EXTCNF_CTRL);
  447. if (data & E1000_EXTCNF_CTRL_LCD_WRITE_ENABLE)
  448. return 0;
  449. cnf_size = er32(EXTCNF_SIZE);
  450. cnf_size &= E1000_EXTCNF_SIZE_EXT_PCIE_LENGTH_MASK;
  451. cnf_size >>= E1000_EXTCNF_SIZE_EXT_PCIE_LENGTH_SHIFT;
  452. if (!cnf_size)
  453. return 0;
  454. cnf_base_addr = data & E1000_EXTCNF_CTRL_EXT_CNF_POINTER_MASK;
  455. cnf_base_addr >>= E1000_EXTCNF_CTRL_EXT_CNF_POINTER_SHIFT;
  456. /* Configure LCD from extended configuration
  457. * region. */
  458. /* cnf_base_addr is in DWORD */
  459. word_addr = (u16)(cnf_base_addr << 1);
  460. for (i = 0; i < cnf_size; i++) {
  461. ret_val = e1000_read_nvm(hw,
  462. (word_addr + i * 2),
  463. 1,
  464. &reg_data);
  465. if (ret_val)
  466. return ret_val;
  467. ret_val = e1000_read_nvm(hw,
  468. (word_addr + i * 2 + 1),
  469. 1,
  470. &reg_addr);
  471. if (ret_val)
  472. return ret_val;
  473. /* Save off the PHY page for future writes. */
  474. if (reg_addr == IGP01E1000_PHY_PAGE_SELECT) {
  475. phy_page = reg_data;
  476. continue;
  477. }
  478. reg_addr |= phy_page;
  479. ret_val = e1e_wphy(hw, (u32)reg_addr, reg_data);
  480. if (ret_val)
  481. return ret_val;
  482. }
  483. }
  484. return 0;
  485. }
  486. /**
  487. * e1000_get_phy_info_ife_ich8lan - Retrieves various IFE PHY states
  488. * @hw: pointer to the HW structure
  489. *
  490. * Populates "phy" structure with various feature states.
  491. * This function is only called by other family-specific
  492. * routines.
  493. **/
  494. static s32 e1000_get_phy_info_ife_ich8lan(struct e1000_hw *hw)
  495. {
  496. struct e1000_phy_info *phy = &hw->phy;
  497. s32 ret_val;
  498. u16 data;
  499. bool link;
  500. ret_val = e1000e_phy_has_link_generic(hw, 1, 0, &link);
  501. if (ret_val)
  502. return ret_val;
  503. if (!link) {
  504. hw_dbg(hw, "Phy info is only valid if link is up\n");
  505. return -E1000_ERR_CONFIG;
  506. }
  507. ret_val = e1e_rphy(hw, IFE_PHY_SPECIAL_CONTROL, &data);
  508. if (ret_val)
  509. return ret_val;
  510. phy->polarity_correction = (!(data & IFE_PSC_AUTO_POLARITY_DISABLE));
  511. if (phy->polarity_correction) {
  512. ret_val = e1000_check_polarity_ife_ich8lan(hw);
  513. if (ret_val)
  514. return ret_val;
  515. } else {
  516. /* Polarity is forced */
  517. phy->cable_polarity = (data & IFE_PSC_FORCE_POLARITY)
  518. ? e1000_rev_polarity_reversed
  519. : e1000_rev_polarity_normal;
  520. }
  521. ret_val = e1e_rphy(hw, IFE_PHY_MDIX_CONTROL, &data);
  522. if (ret_val)
  523. return ret_val;
  524. phy->is_mdix = (data & IFE_PMC_MDIX_STATUS);
  525. /* The following parameters are undefined for 10/100 operation. */
  526. phy->cable_length = E1000_CABLE_LENGTH_UNDEFINED;
  527. phy->local_rx = e1000_1000t_rx_status_undefined;
  528. phy->remote_rx = e1000_1000t_rx_status_undefined;
  529. return 0;
  530. }
  531. /**
  532. * e1000_get_phy_info_ich8lan - Calls appropriate PHY type get_phy_info
  533. * @hw: pointer to the HW structure
  534. *
  535. * Wrapper for calling the get_phy_info routines for the appropriate phy type.
  536. * This is a function pointer entry point called by drivers
  537. * or other shared routines.
  538. **/
  539. static s32 e1000_get_phy_info_ich8lan(struct e1000_hw *hw)
  540. {
  541. switch (hw->phy.type) {
  542. case e1000_phy_ife:
  543. return e1000_get_phy_info_ife_ich8lan(hw);
  544. break;
  545. case e1000_phy_igp_3:
  546. return e1000e_get_phy_info_igp(hw);
  547. break;
  548. default:
  549. break;
  550. }
  551. return -E1000_ERR_PHY_TYPE;
  552. }
  553. /**
  554. * e1000_check_polarity_ife_ich8lan - Check cable polarity for IFE PHY
  555. * @hw: pointer to the HW structure
  556. *
  557. * Polarity is determined on the polarity reveral feature being enabled.
  558. * This function is only called by other family-specific
  559. * routines.
  560. **/
  561. static s32 e1000_check_polarity_ife_ich8lan(struct e1000_hw *hw)
  562. {
  563. struct e1000_phy_info *phy = &hw->phy;
  564. s32 ret_val;
  565. u16 phy_data, offset, mask;
  566. /* Polarity is determined based on the reversal feature
  567. * being enabled.
  568. */
  569. if (phy->polarity_correction) {
  570. offset = IFE_PHY_EXTENDED_STATUS_CONTROL;
  571. mask = IFE_PESC_POLARITY_REVERSED;
  572. } else {
  573. offset = IFE_PHY_SPECIAL_CONTROL;
  574. mask = IFE_PSC_FORCE_POLARITY;
  575. }
  576. ret_val = e1e_rphy(hw, offset, &phy_data);
  577. if (!ret_val)
  578. phy->cable_polarity = (phy_data & mask)
  579. ? e1000_rev_polarity_reversed
  580. : e1000_rev_polarity_normal;
  581. return ret_val;
  582. }
  583. /**
  584. * e1000_set_d0_lplu_state_ich8lan - Set Low Power Linkup D0 state
  585. * @hw: pointer to the HW structure
  586. * @active: TRUE to enable LPLU, FALSE to disable
  587. *
  588. * Sets the LPLU D0 state according to the active flag. When
  589. * activating LPLU this function also disables smart speed
  590. * and vice versa. LPLU will not be activated unless the
  591. * device autonegotiation advertisement meets standards of
  592. * either 10 or 10/100 or 10/100/1000 at all duplexes.
  593. * This is a function pointer entry point only called by
  594. * PHY setup routines.
  595. **/
  596. static s32 e1000_set_d0_lplu_state_ich8lan(struct e1000_hw *hw, bool active)
  597. {
  598. struct e1000_phy_info *phy = &hw->phy;
  599. u32 phy_ctrl;
  600. s32 ret_val = 0;
  601. u16 data;
  602. if (phy->type != e1000_phy_igp_3)
  603. return ret_val;
  604. phy_ctrl = er32(PHY_CTRL);
  605. if (active) {
  606. phy_ctrl |= E1000_PHY_CTRL_D0A_LPLU;
  607. ew32(PHY_CTRL, phy_ctrl);
  608. /* Call gig speed drop workaround on LPLU before accessing
  609. * any PHY registers */
  610. if ((hw->mac.type == e1000_ich8lan) &&
  611. (hw->phy.type == e1000_phy_igp_3))
  612. e1000e_gig_downshift_workaround_ich8lan(hw);
  613. /* When LPLU is enabled, we should disable SmartSpeed */
  614. ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG, &data);
  615. data &= ~IGP01E1000_PSCFR_SMART_SPEED;
  616. ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG, data);
  617. if (ret_val)
  618. return ret_val;
  619. } else {
  620. phy_ctrl &= ~E1000_PHY_CTRL_D0A_LPLU;
  621. ew32(PHY_CTRL, phy_ctrl);
  622. /* LPLU and SmartSpeed are mutually exclusive. LPLU is used
  623. * during Dx states where the power conservation is most
  624. * important. During driver activity we should enable
  625. * SmartSpeed, so performance is maintained. */
  626. if (phy->smart_speed == e1000_smart_speed_on) {
  627. ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG,
  628. &data);
  629. if (ret_val)
  630. return ret_val;
  631. data |= IGP01E1000_PSCFR_SMART_SPEED;
  632. ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG,
  633. data);
  634. if (ret_val)
  635. return ret_val;
  636. } else if (phy->smart_speed == e1000_smart_speed_off) {
  637. ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG,
  638. &data);
  639. if (ret_val)
  640. return ret_val;
  641. data &= ~IGP01E1000_PSCFR_SMART_SPEED;
  642. ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG,
  643. data);
  644. if (ret_val)
  645. return ret_val;
  646. }
  647. }
  648. return 0;
  649. }
  650. /**
  651. * e1000_set_d3_lplu_state_ich8lan - Set Low Power Linkup D3 state
  652. * @hw: pointer to the HW structure
  653. * @active: TRUE to enable LPLU, FALSE to disable
  654. *
  655. * Sets the LPLU D3 state according to the active flag. When
  656. * activating LPLU this function also disables smart speed
  657. * and vice versa. LPLU will not be activated unless the
  658. * device autonegotiation advertisement meets standards of
  659. * either 10 or 10/100 or 10/100/1000 at all duplexes.
  660. * This is a function pointer entry point only called by
  661. * PHY setup routines.
  662. **/
  663. static s32 e1000_set_d3_lplu_state_ich8lan(struct e1000_hw *hw, bool active)
  664. {
  665. struct e1000_phy_info *phy = &hw->phy;
  666. u32 phy_ctrl;
  667. s32 ret_val;
  668. u16 data;
  669. phy_ctrl = er32(PHY_CTRL);
  670. if (!active) {
  671. phy_ctrl &= ~E1000_PHY_CTRL_NOND0A_LPLU;
  672. ew32(PHY_CTRL, phy_ctrl);
  673. /* LPLU and SmartSpeed are mutually exclusive. LPLU is used
  674. * during Dx states where the power conservation is most
  675. * important. During driver activity we should enable
  676. * SmartSpeed, so performance is maintained. */
  677. if (phy->smart_speed == e1000_smart_speed_on) {
  678. ret_val = e1e_rphy(hw,
  679. IGP01E1000_PHY_PORT_CONFIG,
  680. &data);
  681. if (ret_val)
  682. return ret_val;
  683. data |= IGP01E1000_PSCFR_SMART_SPEED;
  684. ret_val = e1e_wphy(hw,
  685. IGP01E1000_PHY_PORT_CONFIG,
  686. data);
  687. if (ret_val)
  688. return ret_val;
  689. } else if (phy->smart_speed == e1000_smart_speed_off) {
  690. ret_val = e1e_rphy(hw,
  691. IGP01E1000_PHY_PORT_CONFIG,
  692. &data);
  693. if (ret_val)
  694. return ret_val;
  695. data &= ~IGP01E1000_PSCFR_SMART_SPEED;
  696. ret_val = e1e_wphy(hw,
  697. IGP01E1000_PHY_PORT_CONFIG,
  698. data);
  699. if (ret_val)
  700. return ret_val;
  701. }
  702. } else if ((phy->autoneg_advertised == E1000_ALL_SPEED_DUPLEX) ||
  703. (phy->autoneg_advertised == E1000_ALL_NOT_GIG) ||
  704. (phy->autoneg_advertised == E1000_ALL_10_SPEED)) {
  705. phy_ctrl |= E1000_PHY_CTRL_NOND0A_LPLU;
  706. ew32(PHY_CTRL, phy_ctrl);
  707. /* Call gig speed drop workaround on LPLU before accessing
  708. * any PHY registers */
  709. if ((hw->mac.type == e1000_ich8lan) &&
  710. (hw->phy.type == e1000_phy_igp_3))
  711. e1000e_gig_downshift_workaround_ich8lan(hw);
  712. /* When LPLU is enabled, we should disable SmartSpeed */
  713. ret_val = e1e_rphy(hw,
  714. IGP01E1000_PHY_PORT_CONFIG,
  715. &data);
  716. if (ret_val)
  717. return ret_val;
  718. data &= ~IGP01E1000_PSCFR_SMART_SPEED;
  719. ret_val = e1e_wphy(hw,
  720. IGP01E1000_PHY_PORT_CONFIG,
  721. data);
  722. }
  723. return 0;
  724. }
  725. /**
  726. * e1000_read_nvm_ich8lan - Read word(s) from the NVM
  727. * @hw: pointer to the HW structure
  728. * @offset: The offset (in bytes) of the word(s) to read.
  729. * @words: Size of data to read in words
  730. * @data: Pointer to the word(s) to read at offset.
  731. *
  732. * Reads a word(s) from the NVM using the flash access registers.
  733. **/
  734. static s32 e1000_read_nvm_ich8lan(struct e1000_hw *hw, u16 offset, u16 words,
  735. u16 *data)
  736. {
  737. struct e1000_nvm_info *nvm = &hw->nvm;
  738. struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
  739. u32 act_offset;
  740. s32 ret_val;
  741. u16 i, word;
  742. if ((offset >= nvm->word_size) || (words > nvm->word_size - offset) ||
  743. (words == 0)) {
  744. hw_dbg(hw, "nvm parameter(s) out of bounds\n");
  745. return -E1000_ERR_NVM;
  746. }
  747. ret_val = e1000_acquire_swflag_ich8lan(hw);
  748. if (ret_val)
  749. return ret_val;
  750. /* Start with the bank offset, then add the relative offset. */
  751. act_offset = (er32(EECD) & E1000_EECD_SEC1VAL)
  752. ? nvm->flash_bank_size
  753. : 0;
  754. act_offset += offset;
  755. for (i = 0; i < words; i++) {
  756. if ((dev_spec->shadow_ram) &&
  757. (dev_spec->shadow_ram[offset+i].modified)) {
  758. data[i] = dev_spec->shadow_ram[offset+i].value;
  759. } else {
  760. ret_val = e1000_read_flash_word_ich8lan(hw,
  761. act_offset + i,
  762. &word);
  763. if (ret_val)
  764. break;
  765. data[i] = word;
  766. }
  767. }
  768. e1000_release_swflag_ich8lan(hw);
  769. return ret_val;
  770. }
  771. /**
  772. * e1000_flash_cycle_init_ich8lan - Initialize flash
  773. * @hw: pointer to the HW structure
  774. *
  775. * This function does initial flash setup so that a new read/write/erase cycle
  776. * can be started.
  777. **/
  778. static s32 e1000_flash_cycle_init_ich8lan(struct e1000_hw *hw)
  779. {
  780. union ich8_hws_flash_status hsfsts;
  781. s32 ret_val = -E1000_ERR_NVM;
  782. s32 i = 0;
  783. hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
  784. /* Check if the flash descriptor is valid */
  785. if (hsfsts.hsf_status.fldesvalid == 0) {
  786. hw_dbg(hw, "Flash descriptor invalid. "
  787. "SW Sequencing must be used.");
  788. return -E1000_ERR_NVM;
  789. }
  790. /* Clear FCERR and DAEL in hw status by writing 1 */
  791. hsfsts.hsf_status.flcerr = 1;
  792. hsfsts.hsf_status.dael = 1;
  793. ew16flash(ICH_FLASH_HSFSTS, hsfsts.regval);
  794. /* Either we should have a hardware SPI cycle in progress
  795. * bit to check against, in order to start a new cycle or
  796. * FDONE bit should be changed in the hardware so that it
  797. * is 1 after harware reset, which can then be used as an
  798. * indication whether a cycle is in progress or has been
  799. * completed.
  800. */
  801. if (hsfsts.hsf_status.flcinprog == 0) {
  802. /* There is no cycle running at present,
  803. * so we can start a cycle */
  804. /* Begin by setting Flash Cycle Done. */
  805. hsfsts.hsf_status.flcdone = 1;
  806. ew16flash(ICH_FLASH_HSFSTS, hsfsts.regval);
  807. ret_val = 0;
  808. } else {
  809. /* otherwise poll for sometime so the current
  810. * cycle has a chance to end before giving up. */
  811. for (i = 0; i < ICH_FLASH_READ_COMMAND_TIMEOUT; i++) {
  812. hsfsts.regval = __er16flash(hw, ICH_FLASH_HSFSTS);
  813. if (hsfsts.hsf_status.flcinprog == 0) {
  814. ret_val = 0;
  815. break;
  816. }
  817. udelay(1);
  818. }
  819. if (ret_val == 0) {
  820. /* Successful in waiting for previous cycle to timeout,
  821. * now set the Flash Cycle Done. */
  822. hsfsts.hsf_status.flcdone = 1;
  823. ew16flash(ICH_FLASH_HSFSTS, hsfsts.regval);
  824. } else {
  825. hw_dbg(hw, "Flash controller busy, cannot get access");
  826. }
  827. }
  828. return ret_val;
  829. }
  830. /**
  831. * e1000_flash_cycle_ich8lan - Starts flash cycle (read/write/erase)
  832. * @hw: pointer to the HW structure
  833. * @timeout: maximum time to wait for completion
  834. *
  835. * This function starts a flash cycle and waits for its completion.
  836. **/
  837. static s32 e1000_flash_cycle_ich8lan(struct e1000_hw *hw, u32 timeout)
  838. {
  839. union ich8_hws_flash_ctrl hsflctl;
  840. union ich8_hws_flash_status hsfsts;
  841. s32 ret_val = -E1000_ERR_NVM;
  842. u32 i = 0;
  843. /* Start a cycle by writing 1 in Flash Cycle Go in Hw Flash Control */
  844. hsflctl.regval = er16flash(ICH_FLASH_HSFCTL);
  845. hsflctl.hsf_ctrl.flcgo = 1;
  846. ew16flash(ICH_FLASH_HSFCTL, hsflctl.regval);
  847. /* wait till FDONE bit is set to 1 */
  848. do {
  849. hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
  850. if (hsfsts.hsf_status.flcdone == 1)
  851. break;
  852. udelay(1);
  853. } while (i++ < timeout);
  854. if (hsfsts.hsf_status.flcdone == 1 && hsfsts.hsf_status.flcerr == 0)
  855. return 0;
  856. return ret_val;
  857. }
  858. /**
  859. * e1000_read_flash_word_ich8lan - Read word from flash
  860. * @hw: pointer to the HW structure
  861. * @offset: offset to data location
  862. * @data: pointer to the location for storing the data
  863. *
  864. * Reads the flash word at offset into data. Offset is converted
  865. * to bytes before read.
  866. **/
  867. static s32 e1000_read_flash_word_ich8lan(struct e1000_hw *hw, u32 offset,
  868. u16 *data)
  869. {
  870. /* Must convert offset into bytes. */
  871. offset <<= 1;
  872. return e1000_read_flash_data_ich8lan(hw, offset, 2, data);
  873. }
  874. /**
  875. * e1000_read_flash_data_ich8lan - Read byte or word from NVM
  876. * @hw: pointer to the HW structure
  877. * @offset: The offset (in bytes) of the byte or word to read.
  878. * @size: Size of data to read, 1=byte 2=word
  879. * @data: Pointer to the word to store the value read.
  880. *
  881. * Reads a byte or word from the NVM using the flash access registers.
  882. **/
  883. static s32 e1000_read_flash_data_ich8lan(struct e1000_hw *hw, u32 offset,
  884. u8 size, u16 *data)
  885. {
  886. union ich8_hws_flash_status hsfsts;
  887. union ich8_hws_flash_ctrl hsflctl;
  888. u32 flash_linear_addr;
  889. u32 flash_data = 0;
  890. s32 ret_val = -E1000_ERR_NVM;
  891. u8 count = 0;
  892. if (size < 1 || size > 2 || offset > ICH_FLASH_LINEAR_ADDR_MASK)
  893. return -E1000_ERR_NVM;
  894. flash_linear_addr = (ICH_FLASH_LINEAR_ADDR_MASK & offset) +
  895. hw->nvm.flash_base_addr;
  896. do {
  897. udelay(1);
  898. /* Steps */
  899. ret_val = e1000_flash_cycle_init_ich8lan(hw);
  900. if (ret_val != 0)
  901. break;
  902. hsflctl.regval = er16flash(ICH_FLASH_HSFCTL);
  903. /* 0b/1b corresponds to 1 or 2 byte size, respectively. */
  904. hsflctl.hsf_ctrl.fldbcount = size - 1;
  905. hsflctl.hsf_ctrl.flcycle = ICH_CYCLE_READ;
  906. ew16flash(ICH_FLASH_HSFCTL, hsflctl.regval);
  907. ew32flash(ICH_FLASH_FADDR, flash_linear_addr);
  908. ret_val = e1000_flash_cycle_ich8lan(hw,
  909. ICH_FLASH_READ_COMMAND_TIMEOUT);
  910. /* Check if FCERR is set to 1, if set to 1, clear it
  911. * and try the whole sequence a few more times, else
  912. * read in (shift in) the Flash Data0, the order is
  913. * least significant byte first msb to lsb */
  914. if (ret_val == 0) {
  915. flash_data = er32flash(ICH_FLASH_FDATA0);
  916. if (size == 1) {
  917. *data = (u8)(flash_data & 0x000000FF);
  918. } else if (size == 2) {
  919. *data = (u16)(flash_data & 0x0000FFFF);
  920. }
  921. break;
  922. } else {
  923. /* If we've gotten here, then things are probably
  924. * completely hosed, but if the error condition is
  925. * detected, it won't hurt to give it another try...
  926. * ICH_FLASH_CYCLE_REPEAT_COUNT times.
  927. */
  928. hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
  929. if (hsfsts.hsf_status.flcerr == 1) {
  930. /* Repeat for some time before giving up. */
  931. continue;
  932. } else if (hsfsts.hsf_status.flcdone == 0) {
  933. hw_dbg(hw, "Timeout error - flash cycle "
  934. "did not complete.");
  935. break;
  936. }
  937. }
  938. } while (count++ < ICH_FLASH_CYCLE_REPEAT_COUNT);
  939. return ret_val;
  940. }
  941. /**
  942. * e1000_write_nvm_ich8lan - Write word(s) to the NVM
  943. * @hw: pointer to the HW structure
  944. * @offset: The offset (in bytes) of the word(s) to write.
  945. * @words: Size of data to write in words
  946. * @data: Pointer to the word(s) to write at offset.
  947. *
  948. * Writes a byte or word to the NVM using the flash access registers.
  949. **/
  950. static s32 e1000_write_nvm_ich8lan(struct e1000_hw *hw, u16 offset, u16 words,
  951. u16 *data)
  952. {
  953. struct e1000_nvm_info *nvm = &hw->nvm;
  954. struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
  955. s32 ret_val;
  956. u16 i;
  957. if ((offset >= nvm->word_size) || (words > nvm->word_size - offset) ||
  958. (words == 0)) {
  959. hw_dbg(hw, "nvm parameter(s) out of bounds\n");
  960. return -E1000_ERR_NVM;
  961. }
  962. ret_val = e1000_acquire_swflag_ich8lan(hw);
  963. if (ret_val)
  964. return ret_val;
  965. for (i = 0; i < words; i++) {
  966. dev_spec->shadow_ram[offset+i].modified = 1;
  967. dev_spec->shadow_ram[offset+i].value = data[i];
  968. }
  969. e1000_release_swflag_ich8lan(hw);
  970. return 0;
  971. }
  972. /**
  973. * e1000_update_nvm_checksum_ich8lan - Update the checksum for NVM
  974. * @hw: pointer to the HW structure
  975. *
  976. * The NVM checksum is updated by calling the generic update_nvm_checksum,
  977. * which writes the checksum to the shadow ram. The changes in the shadow
  978. * ram are then committed to the EEPROM by processing each bank at a time
  979. * checking for the modified bit and writing only the pending changes.
  980. * After a succesful commit, the shadow ram is cleared and is ready for
  981. * future writes.
  982. **/
  983. static s32 e1000_update_nvm_checksum_ich8lan(struct e1000_hw *hw)
  984. {
  985. struct e1000_nvm_info *nvm = &hw->nvm;
  986. struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
  987. u32 i, act_offset, new_bank_offset, old_bank_offset;
  988. s32 ret_val;
  989. u16 data;
  990. ret_val = e1000e_update_nvm_checksum_generic(hw);
  991. if (ret_val)
  992. return ret_val;;
  993. if (nvm->type != e1000_nvm_flash_sw)
  994. return ret_val;;
  995. ret_val = e1000_acquire_swflag_ich8lan(hw);
  996. if (ret_val)
  997. return ret_val;;
  998. /* We're writing to the opposite bank so if we're on bank 1,
  999. * write to bank 0 etc. We also need to erase the segment that
  1000. * is going to be written */
  1001. if (!(er32(EECD) & E1000_EECD_SEC1VAL)) {
  1002. new_bank_offset = nvm->flash_bank_size;
  1003. old_bank_offset = 0;
  1004. e1000_erase_flash_bank_ich8lan(hw, 1);
  1005. } else {
  1006. old_bank_offset = nvm->flash_bank_size;
  1007. new_bank_offset = 0;
  1008. e1000_erase_flash_bank_ich8lan(hw, 0);
  1009. }
  1010. for (i = 0; i < E1000_ICH8_SHADOW_RAM_WORDS; i++) {
  1011. /* Determine whether to write the value stored
  1012. * in the other NVM bank or a modified value stored
  1013. * in the shadow RAM */
  1014. if (dev_spec->shadow_ram[i].modified) {
  1015. data = dev_spec->shadow_ram[i].value;
  1016. } else {
  1017. e1000_read_flash_word_ich8lan(hw,
  1018. i + old_bank_offset,
  1019. &data);
  1020. }
  1021. /* If the word is 0x13, then make sure the signature bits
  1022. * (15:14) are 11b until the commit has completed.
  1023. * This will allow us to write 10b which indicates the
  1024. * signature is valid. We want to do this after the write
  1025. * has completed so that we don't mark the segment valid
  1026. * while the write is still in progress */
  1027. if (i == E1000_ICH_NVM_SIG_WORD)
  1028. data |= E1000_ICH_NVM_SIG_MASK;
  1029. /* Convert offset to bytes. */
  1030. act_offset = (i + new_bank_offset) << 1;
  1031. udelay(100);
  1032. /* Write the bytes to the new bank. */
  1033. ret_val = e1000_retry_write_flash_byte_ich8lan(hw,
  1034. act_offset,
  1035. (u8)data);
  1036. if (ret_val)
  1037. break;
  1038. udelay(100);
  1039. ret_val = e1000_retry_write_flash_byte_ich8lan(hw,
  1040. act_offset + 1,
  1041. (u8)(data >> 8));
  1042. if (ret_val)
  1043. break;
  1044. }
  1045. /* Don't bother writing the segment valid bits if sector
  1046. * programming failed. */
  1047. if (ret_val) {
  1048. hw_dbg(hw, "Flash commit failed.\n");
  1049. e1000_release_swflag_ich8lan(hw);
  1050. return ret_val;
  1051. }
  1052. /* Finally validate the new segment by setting bit 15:14
  1053. * to 10b in word 0x13 , this can be done without an
  1054. * erase as well since these bits are 11 to start with
  1055. * and we need to change bit 14 to 0b */
  1056. act_offset = new_bank_offset + E1000_ICH_NVM_SIG_WORD;
  1057. e1000_read_flash_word_ich8lan(hw, act_offset, &data);
  1058. data &= 0xBFFF;
  1059. ret_val = e1000_retry_write_flash_byte_ich8lan(hw,
  1060. act_offset * 2 + 1,
  1061. (u8)(data >> 8));
  1062. if (ret_val) {
  1063. e1000_release_swflag_ich8lan(hw);
  1064. return ret_val;
  1065. }
  1066. /* And invalidate the previously valid segment by setting
  1067. * its signature word (0x13) high_byte to 0b. This can be
  1068. * done without an erase because flash erase sets all bits
  1069. * to 1's. We can write 1's to 0's without an erase */
  1070. act_offset = (old_bank_offset + E1000_ICH_NVM_SIG_WORD) * 2 + 1;
  1071. ret_val = e1000_retry_write_flash_byte_ich8lan(hw, act_offset, 0);
  1072. if (ret_val) {
  1073. e1000_release_swflag_ich8lan(hw);
  1074. return ret_val;
  1075. }
  1076. /* Great! Everything worked, we can now clear the cached entries. */
  1077. for (i = 0; i < E1000_ICH8_SHADOW_RAM_WORDS; i++) {
  1078. dev_spec->shadow_ram[i].modified = 0;
  1079. dev_spec->shadow_ram[i].value = 0xFFFF;
  1080. }
  1081. e1000_release_swflag_ich8lan(hw);
  1082. /* Reload the EEPROM, or else modifications will not appear
  1083. * until after the next adapter reset.
  1084. */
  1085. e1000e_reload_nvm(hw);
  1086. msleep(10);
  1087. return ret_val;
  1088. }
  1089. /**
  1090. * e1000_validate_nvm_checksum_ich8lan - Validate EEPROM checksum
  1091. * @hw: pointer to the HW structure
  1092. *
  1093. * Check to see if checksum needs to be fixed by reading bit 6 in word 0x19.
  1094. * If the bit is 0, that the EEPROM had been modified, but the checksum was not
  1095. * calculated, in which case we need to calculate the checksum and set bit 6.
  1096. **/
  1097. static s32 e1000_validate_nvm_checksum_ich8lan(struct e1000_hw *hw)
  1098. {
  1099. s32 ret_val;
  1100. u16 data;
  1101. /* Read 0x19 and check bit 6. If this bit is 0, the checksum
  1102. * needs to be fixed. This bit is an indication that the NVM
  1103. * was prepared by OEM software and did not calculate the
  1104. * checksum...a likely scenario.
  1105. */
  1106. ret_val = e1000_read_nvm(hw, 0x19, 1, &data);
  1107. if (ret_val)
  1108. return ret_val;
  1109. if ((data & 0x40) == 0) {
  1110. data |= 0x40;
  1111. ret_val = e1000_write_nvm(hw, 0x19, 1, &data);
  1112. if (ret_val)
  1113. return ret_val;
  1114. ret_val = e1000e_update_nvm_checksum(hw);
  1115. if (ret_val)
  1116. return ret_val;
  1117. }
  1118. return e1000e_validate_nvm_checksum_generic(hw);
  1119. }
  1120. /**
  1121. * e1000_write_flash_data_ich8lan - Writes bytes to the NVM
  1122. * @hw: pointer to the HW structure
  1123. * @offset: The offset (in bytes) of the byte/word to read.
  1124. * @size: Size of data to read, 1=byte 2=word
  1125. * @data: The byte(s) to write to the NVM.
  1126. *
  1127. * Writes one/two bytes to the NVM using the flash access registers.
  1128. **/
  1129. static s32 e1000_write_flash_data_ich8lan(struct e1000_hw *hw, u32 offset,
  1130. u8 size, u16 data)
  1131. {
  1132. union ich8_hws_flash_status hsfsts;
  1133. union ich8_hws_flash_ctrl hsflctl;
  1134. u32 flash_linear_addr;
  1135. u32 flash_data = 0;
  1136. s32 ret_val;
  1137. u8 count = 0;
  1138. if (size < 1 || size > 2 || data > size * 0xff ||
  1139. offset > ICH_FLASH_LINEAR_ADDR_MASK)
  1140. return -E1000_ERR_NVM;
  1141. flash_linear_addr = (ICH_FLASH_LINEAR_ADDR_MASK & offset) +
  1142. hw->nvm.flash_base_addr;
  1143. do {
  1144. udelay(1);
  1145. /* Steps */
  1146. ret_val = e1000_flash_cycle_init_ich8lan(hw);
  1147. if (ret_val)
  1148. break;
  1149. hsflctl.regval = er16flash(ICH_FLASH_HSFCTL);
  1150. /* 0b/1b corresponds to 1 or 2 byte size, respectively. */
  1151. hsflctl.hsf_ctrl.fldbcount = size -1;
  1152. hsflctl.hsf_ctrl.flcycle = ICH_CYCLE_WRITE;
  1153. ew16flash(ICH_FLASH_HSFCTL, hsflctl.regval);
  1154. ew32flash(ICH_FLASH_FADDR, flash_linear_addr);
  1155. if (size == 1)
  1156. flash_data = (u32)data & 0x00FF;
  1157. else
  1158. flash_data = (u32)data;
  1159. ew32flash(ICH_FLASH_FDATA0, flash_data);
  1160. /* check if FCERR is set to 1 , if set to 1, clear it
  1161. * and try the whole sequence a few more times else done */
  1162. ret_val = e1000_flash_cycle_ich8lan(hw,
  1163. ICH_FLASH_WRITE_COMMAND_TIMEOUT);
  1164. if (!ret_val)
  1165. break;
  1166. /* If we're here, then things are most likely
  1167. * completely hosed, but if the error condition
  1168. * is detected, it won't hurt to give it another
  1169. * try...ICH_FLASH_CYCLE_REPEAT_COUNT times.
  1170. */
  1171. hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
  1172. if (hsfsts.hsf_status.flcerr == 1)
  1173. /* Repeat for some time before giving up. */
  1174. continue;
  1175. if (hsfsts.hsf_status.flcdone == 0) {
  1176. hw_dbg(hw, "Timeout error - flash cycle "
  1177. "did not complete.");
  1178. break;
  1179. }
  1180. } while (count++ < ICH_FLASH_CYCLE_REPEAT_COUNT);
  1181. return ret_val;
  1182. }
  1183. /**
  1184. * e1000_write_flash_byte_ich8lan - Write a single byte to NVM
  1185. * @hw: pointer to the HW structure
  1186. * @offset: The index of the byte to read.
  1187. * @data: The byte to write to the NVM.
  1188. *
  1189. * Writes a single byte to the NVM using the flash access registers.
  1190. **/
  1191. static s32 e1000_write_flash_byte_ich8lan(struct e1000_hw *hw, u32 offset,
  1192. u8 data)
  1193. {
  1194. u16 word = (u16)data;
  1195. return e1000_write_flash_data_ich8lan(hw, offset, 1, word);
  1196. }
  1197. /**
  1198. * e1000_retry_write_flash_byte_ich8lan - Writes a single byte to NVM
  1199. * @hw: pointer to the HW structure
  1200. * @offset: The offset of the byte to write.
  1201. * @byte: The byte to write to the NVM.
  1202. *
  1203. * Writes a single byte to the NVM using the flash access registers.
  1204. * Goes through a retry algorithm before giving up.
  1205. **/
  1206. static s32 e1000_retry_write_flash_byte_ich8lan(struct e1000_hw *hw,
  1207. u32 offset, u8 byte)
  1208. {
  1209. s32 ret_val;
  1210. u16 program_retries;
  1211. ret_val = e1000_write_flash_byte_ich8lan(hw, offset, byte);
  1212. if (!ret_val)
  1213. return ret_val;
  1214. for (program_retries = 0; program_retries < 100; program_retries++) {
  1215. hw_dbg(hw, "Retrying Byte %2.2X at offset %u\n", byte, offset);
  1216. udelay(100);
  1217. ret_val = e1000_write_flash_byte_ich8lan(hw, offset, byte);
  1218. if (!ret_val)
  1219. break;
  1220. }
  1221. if (program_retries == 100)
  1222. return -E1000_ERR_NVM;
  1223. return 0;
  1224. }
  1225. /**
  1226. * e1000_erase_flash_bank_ich8lan - Erase a bank (4k) from NVM
  1227. * @hw: pointer to the HW structure
  1228. * @bank: 0 for first bank, 1 for second bank, etc.
  1229. *
  1230. * Erases the bank specified. Each bank is a 4k block. Banks are 0 based.
  1231. * bank N is 4096 * N + flash_reg_addr.
  1232. **/
  1233. static s32 e1000_erase_flash_bank_ich8lan(struct e1000_hw *hw, u32 bank)
  1234. {
  1235. struct e1000_nvm_info *nvm = &hw->nvm;
  1236. union ich8_hws_flash_status hsfsts;
  1237. union ich8_hws_flash_ctrl hsflctl;
  1238. u32 flash_linear_addr;
  1239. /* bank size is in 16bit words - adjust to bytes */
  1240. u32 flash_bank_size = nvm->flash_bank_size * 2;
  1241. s32 ret_val;
  1242. s32 count = 0;
  1243. s32 iteration;
  1244. s32 sector_size;
  1245. s32 j;
  1246. hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
  1247. /* Determine HW Sector size: Read BERASE bits of hw flash status
  1248. * register */
  1249. /* 00: The Hw sector is 256 bytes, hence we need to erase 16
  1250. * consecutive sectors. The start index for the nth Hw sector
  1251. * can be calculated as = bank * 4096 + n * 256
  1252. * 01: The Hw sector is 4K bytes, hence we need to erase 1 sector.
  1253. * The start index for the nth Hw sector can be calculated
  1254. * as = bank * 4096
  1255. * 10: The Hw sector is 8K bytes, nth sector = bank * 8192
  1256. * (ich9 only, otherwise error condition)
  1257. * 11: The Hw sector is 64K bytes, nth sector = bank * 65536
  1258. */
  1259. switch (hsfsts.hsf_status.berasesz) {
  1260. case 0:
  1261. /* Hw sector size 256 */
  1262. sector_size = ICH_FLASH_SEG_SIZE_256;
  1263. iteration = flash_bank_size / ICH_FLASH_SEG_SIZE_256;
  1264. break;
  1265. case 1:
  1266. sector_size = ICH_FLASH_SEG_SIZE_4K;
  1267. iteration = flash_bank_size / ICH_FLASH_SEG_SIZE_4K;
  1268. break;
  1269. case 2:
  1270. if (hw->mac.type == e1000_ich9lan) {
  1271. sector_size = ICH_FLASH_SEG_SIZE_8K;
  1272. iteration = flash_bank_size / ICH_FLASH_SEG_SIZE_8K;
  1273. } else {
  1274. return -E1000_ERR_NVM;
  1275. }
  1276. break;
  1277. case 3:
  1278. sector_size = ICH_FLASH_SEG_SIZE_64K;
  1279. iteration = flash_bank_size / ICH_FLASH_SEG_SIZE_64K;
  1280. break;
  1281. default:
  1282. return -E1000_ERR_NVM;
  1283. }
  1284. /* Start with the base address, then add the sector offset. */
  1285. flash_linear_addr = hw->nvm.flash_base_addr;
  1286. flash_linear_addr += (bank) ? (sector_size * iteration) : 0;
  1287. for (j = 0; j < iteration ; j++) {
  1288. do {
  1289. /* Steps */
  1290. ret_val = e1000_flash_cycle_init_ich8lan(hw);
  1291. if (ret_val)
  1292. return ret_val;
  1293. /* Write a value 11 (block Erase) in Flash
  1294. * Cycle field in hw flash control */
  1295. hsflctl.regval = er16flash(ICH_FLASH_HSFCTL);
  1296. hsflctl.hsf_ctrl.flcycle = ICH_CYCLE_ERASE;
  1297. ew16flash(ICH_FLASH_HSFCTL, hsflctl.regval);
  1298. /* Write the last 24 bits of an index within the
  1299. * block into Flash Linear address field in Flash
  1300. * Address.
  1301. */
  1302. flash_linear_addr += (j * sector_size);
  1303. ew32flash(ICH_FLASH_FADDR, flash_linear_addr);
  1304. ret_val = e1000_flash_cycle_ich8lan(hw,
  1305. ICH_FLASH_ERASE_COMMAND_TIMEOUT);
  1306. if (ret_val == 0)
  1307. break;
  1308. /* Check if FCERR is set to 1. If 1,
  1309. * clear it and try the whole sequence
  1310. * a few more times else Done */
  1311. hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
  1312. if (hsfsts.hsf_status.flcerr == 1)
  1313. /* repeat for some time before
  1314. * giving up */
  1315. continue;
  1316. else if (hsfsts.hsf_status.flcdone == 0)
  1317. return ret_val;
  1318. } while (++count < ICH_FLASH_CYCLE_REPEAT_COUNT);
  1319. }
  1320. return 0;
  1321. }
  1322. /**
  1323. * e1000_valid_led_default_ich8lan - Set the default LED settings
  1324. * @hw: pointer to the HW structure
  1325. * @data: Pointer to the LED settings
  1326. *
  1327. * Reads the LED default settings from the NVM to data. If the NVM LED
  1328. * settings is all 0's or F's, set the LED default to a valid LED default
  1329. * setting.
  1330. **/
  1331. static s32 e1000_valid_led_default_ich8lan(struct e1000_hw *hw, u16 *data)
  1332. {
  1333. s32 ret_val;
  1334. ret_val = e1000_read_nvm(hw, NVM_ID_LED_SETTINGS, 1, data);
  1335. if (ret_val) {
  1336. hw_dbg(hw, "NVM Read Error\n");
  1337. return ret_val;
  1338. }
  1339. if (*data == ID_LED_RESERVED_0000 ||
  1340. *data == ID_LED_RESERVED_FFFF)
  1341. *data = ID_LED_DEFAULT_ICH8LAN;
  1342. return 0;
  1343. }
  1344. /**
  1345. * e1000_get_bus_info_ich8lan - Get/Set the bus type and width
  1346. * @hw: pointer to the HW structure
  1347. *
  1348. * ICH8 use the PCI Express bus, but does not contain a PCI Express Capability
  1349. * register, so the the bus width is hard coded.
  1350. **/
  1351. static s32 e1000_get_bus_info_ich8lan(struct e1000_hw *hw)
  1352. {
  1353. struct e1000_bus_info *bus = &hw->bus;
  1354. s32 ret_val;
  1355. ret_val = e1000e_get_bus_info_pcie(hw);
  1356. /* ICH devices are "PCI Express"-ish. They have
  1357. * a configuration space, but do not contain
  1358. * PCI Express Capability registers, so bus width
  1359. * must be hardcoded.
  1360. */
  1361. if (bus->width == e1000_bus_width_unknown)
  1362. bus->width = e1000_bus_width_pcie_x1;
  1363. return ret_val;
  1364. }
  1365. /**
  1366. * e1000_reset_hw_ich8lan - Reset the hardware
  1367. * @hw: pointer to the HW structure
  1368. *
  1369. * Does a full reset of the hardware which includes a reset of the PHY and
  1370. * MAC.
  1371. **/
  1372. static s32 e1000_reset_hw_ich8lan(struct e1000_hw *hw)
  1373. {
  1374. u32 ctrl, icr, kab;
  1375. s32 ret_val;
  1376. /* Prevent the PCI-E bus from sticking if there is no TLP connection
  1377. * on the last TLP read/write transaction when MAC is reset.
  1378. */
  1379. ret_val = e1000e_disable_pcie_master(hw);
  1380. if (ret_val) {
  1381. hw_dbg(hw, "PCI-E Master disable polling has failed.\n");
  1382. }
  1383. hw_dbg(hw, "Masking off all interrupts\n");
  1384. ew32(IMC, 0xffffffff);
  1385. /* Disable the Transmit and Receive units. Then delay to allow
  1386. * any pending transactions to complete before we hit the MAC
  1387. * with the global reset.
  1388. */
  1389. ew32(RCTL, 0);
  1390. ew32(TCTL, E1000_TCTL_PSP);
  1391. e1e_flush();
  1392. msleep(10);
  1393. /* Workaround for ICH8 bit corruption issue in FIFO memory */
  1394. if (hw->mac.type == e1000_ich8lan) {
  1395. /* Set Tx and Rx buffer allocation to 8k apiece. */
  1396. ew32(PBA, E1000_PBA_8K);
  1397. /* Set Packet Buffer Size to 16k. */
  1398. ew32(PBS, E1000_PBS_16K);
  1399. }
  1400. ctrl = er32(CTRL);
  1401. if (!e1000_check_reset_block(hw)) {
  1402. /* PHY HW reset requires MAC CORE reset at the same
  1403. * time to make sure the interface between MAC and the
  1404. * external PHY is reset.
  1405. */
  1406. ctrl |= E1000_CTRL_PHY_RST;
  1407. }
  1408. ret_val = e1000_acquire_swflag_ich8lan(hw);
  1409. hw_dbg(hw, "Issuing a global reset to ich8lan");
  1410. ew32(CTRL, (ctrl | E1000_CTRL_RST));
  1411. msleep(20);
  1412. ret_val = e1000e_get_auto_rd_done(hw);
  1413. if (ret_val) {
  1414. /*
  1415. * When auto config read does not complete, do not
  1416. * return with an error. This can happen in situations
  1417. * where there is no eeprom and prevents getting link.
  1418. */
  1419. hw_dbg(hw, "Auto Read Done did not complete\n");
  1420. }
  1421. ew32(IMC, 0xffffffff);
  1422. icr = er32(ICR);
  1423. kab = er32(KABGTXD);
  1424. kab |= E1000_KABGTXD_BGSQLBIAS;
  1425. ew32(KABGTXD, kab);
  1426. return ret_val;
  1427. }
  1428. /**
  1429. * e1000_init_hw_ich8lan - Initialize the hardware
  1430. * @hw: pointer to the HW structure
  1431. *
  1432. * Prepares the hardware for transmit and receive by doing the following:
  1433. * - initialize hardware bits
  1434. * - initialize LED identification
  1435. * - setup receive address registers
  1436. * - setup flow control
  1437. * - setup transmit discriptors
  1438. * - clear statistics
  1439. **/
  1440. static s32 e1000_init_hw_ich8lan(struct e1000_hw *hw)
  1441. {
  1442. struct e1000_mac_info *mac = &hw->mac;
  1443. u32 ctrl_ext, txdctl, snoop;
  1444. s32 ret_val;
  1445. u16 i;
  1446. e1000_initialize_hw_bits_ich8lan(hw);
  1447. /* Initialize identification LED */
  1448. ret_val = e1000e_id_led_init(hw);
  1449. if (ret_val) {
  1450. hw_dbg(hw, "Error initializing identification LED\n");
  1451. return ret_val;
  1452. }
  1453. /* Setup the receive address. */
  1454. e1000e_init_rx_addrs(hw, mac->rar_entry_count);
  1455. /* Zero out the Multicast HASH table */
  1456. hw_dbg(hw, "Zeroing the MTA\n");
  1457. for (i = 0; i < mac->mta_reg_count; i++)
  1458. E1000_WRITE_REG_ARRAY(hw, E1000_MTA, i, 0);
  1459. /* Setup link and flow control */
  1460. ret_val = e1000_setup_link_ich8lan(hw);
  1461. /* Set the transmit descriptor write-back policy for both queues */
  1462. txdctl = er32(TXDCTL);
  1463. txdctl = (txdctl & ~E1000_TXDCTL_WTHRESH) |
  1464. E1000_TXDCTL_FULL_TX_DESC_WB;
  1465. txdctl = (txdctl & ~E1000_TXDCTL_PTHRESH) |
  1466. E1000_TXDCTL_MAX_TX_DESC_PREFETCH;
  1467. ew32(TXDCTL, txdctl);
  1468. txdctl = er32(TXDCTL1);
  1469. txdctl = (txdctl & ~E1000_TXDCTL_WTHRESH) |
  1470. E1000_TXDCTL_FULL_TX_DESC_WB;
  1471. txdctl = (txdctl & ~E1000_TXDCTL_PTHRESH) |
  1472. E1000_TXDCTL_MAX_TX_DESC_PREFETCH;
  1473. ew32(TXDCTL1, txdctl);
  1474. /* ICH8 has opposite polarity of no_snoop bits.
  1475. * By default, we should use snoop behavior. */
  1476. if (mac->type == e1000_ich8lan)
  1477. snoop = PCIE_ICH8_SNOOP_ALL;
  1478. else
  1479. snoop = (u32) ~(PCIE_NO_SNOOP_ALL);
  1480. e1000e_set_pcie_no_snoop(hw, snoop);
  1481. ctrl_ext = er32(CTRL_EXT);
  1482. ctrl_ext |= E1000_CTRL_EXT_RO_DIS;
  1483. ew32(CTRL_EXT, ctrl_ext);
  1484. /* Clear all of the statistics registers (clear on read). It is
  1485. * important that we do this after we have tried to establish link
  1486. * because the symbol error count will increment wildly if there
  1487. * is no link.
  1488. */
  1489. e1000_clear_hw_cntrs_ich8lan(hw);
  1490. return 0;
  1491. }
  1492. /**
  1493. * e1000_initialize_hw_bits_ich8lan - Initialize required hardware bits
  1494. * @hw: pointer to the HW structure
  1495. *
  1496. * Sets/Clears required hardware bits necessary for correctly setting up the
  1497. * hardware for transmit and receive.
  1498. **/
  1499. static void e1000_initialize_hw_bits_ich8lan(struct e1000_hw *hw)
  1500. {
  1501. u32 reg;
  1502. /* Extended Device Control */
  1503. reg = er32(CTRL_EXT);
  1504. reg |= (1 << 22);
  1505. ew32(CTRL_EXT, reg);
  1506. /* Transmit Descriptor Control 0 */
  1507. reg = er32(TXDCTL);
  1508. reg |= (1 << 22);
  1509. ew32(TXDCTL, reg);
  1510. /* Transmit Descriptor Control 1 */
  1511. reg = er32(TXDCTL1);
  1512. reg |= (1 << 22);
  1513. ew32(TXDCTL1, reg);
  1514. /* Transmit Arbitration Control 0 */
  1515. reg = er32(TARC0);
  1516. if (hw->mac.type == e1000_ich8lan)
  1517. reg |= (1 << 28) | (1 << 29);
  1518. reg |= (1 << 23) | (1 << 24) | (1 << 26) | (1 << 27);
  1519. ew32(TARC0, reg);
  1520. /* Transmit Arbitration Control 1 */
  1521. reg = er32(TARC1);
  1522. if (er32(TCTL) & E1000_TCTL_MULR)
  1523. reg &= ~(1 << 28);
  1524. else
  1525. reg |= (1 << 28);
  1526. reg |= (1 << 24) | (1 << 26) | (1 << 30);
  1527. ew32(TARC1, reg);
  1528. /* Device Status */
  1529. if (hw->mac.type == e1000_ich8lan) {
  1530. reg = er32(STATUS);
  1531. reg &= ~(1 << 31);
  1532. ew32(STATUS, reg);
  1533. }
  1534. }
  1535. /**
  1536. * e1000_setup_link_ich8lan - Setup flow control and link settings
  1537. * @hw: pointer to the HW structure
  1538. *
  1539. * Determines which flow control settings to use, then configures flow
  1540. * control. Calls the appropriate media-specific link configuration
  1541. * function. Assuming the adapter has a valid link partner, a valid link
  1542. * should be established. Assumes the hardware has previously been reset
  1543. * and the transmitter and receiver are not enabled.
  1544. **/
  1545. static s32 e1000_setup_link_ich8lan(struct e1000_hw *hw)
  1546. {
  1547. struct e1000_mac_info *mac = &hw->mac;
  1548. s32 ret_val;
  1549. if (e1000_check_reset_block(hw))
  1550. return 0;
  1551. /* ICH parts do not have a word in the NVM to determine
  1552. * the default flow control setting, so we explicitly
  1553. * set it to full.
  1554. */
  1555. if (mac->fc == e1000_fc_default)
  1556. mac->fc = e1000_fc_full;
  1557. mac->original_fc = mac->fc;
  1558. hw_dbg(hw, "After fix-ups FlowControl is now = %x\n", mac->fc);
  1559. /* Continue to configure the copper link. */
  1560. ret_val = e1000_setup_copper_link_ich8lan(hw);
  1561. if (ret_val)
  1562. return ret_val;
  1563. ew32(FCTTV, mac->fc_pause_time);
  1564. return e1000e_set_fc_watermarks(hw);
  1565. }
  1566. /**
  1567. * e1000_setup_copper_link_ich8lan - Configure MAC/PHY interface
  1568. * @hw: pointer to the HW structure
  1569. *
  1570. * Configures the kumeran interface to the PHY to wait the appropriate time
  1571. * when polling the PHY, then call the generic setup_copper_link to finish
  1572. * configuring the copper link.
  1573. **/
  1574. static s32 e1000_setup_copper_link_ich8lan(struct e1000_hw *hw)
  1575. {
  1576. u32 ctrl;
  1577. s32 ret_val;
  1578. u16 reg_data;
  1579. ctrl = er32(CTRL);
  1580. ctrl |= E1000_CTRL_SLU;
  1581. ctrl &= ~(E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX);
  1582. ew32(CTRL, ctrl);
  1583. /* Set the mac to wait the maximum time between each iteration
  1584. * and increase the max iterations when polling the phy;
  1585. * this fixes erroneous timeouts at 10Mbps. */
  1586. ret_val = e1000e_write_kmrn_reg(hw, GG82563_REG(0x34, 4), 0xFFFF);
  1587. if (ret_val)
  1588. return ret_val;
  1589. ret_val = e1000e_read_kmrn_reg(hw, GG82563_REG(0x34, 9), &reg_data);
  1590. if (ret_val)
  1591. return ret_val;
  1592. reg_data |= 0x3F;
  1593. ret_val = e1000e_write_kmrn_reg(hw, GG82563_REG(0x34, 9), reg_data);
  1594. if (ret_val)
  1595. return ret_val;
  1596. if (hw->phy.type == e1000_phy_igp_3) {
  1597. ret_val = e1000e_copper_link_setup_igp(hw);
  1598. if (ret_val)
  1599. return ret_val;
  1600. }
  1601. return e1000e_setup_copper_link(hw);
  1602. }
  1603. /**
  1604. * e1000_get_link_up_info_ich8lan - Get current link speed and duplex
  1605. * @hw: pointer to the HW structure
  1606. * @speed: pointer to store current link speed
  1607. * @duplex: pointer to store the current link duplex
  1608. *
  1609. * Calls the generic get_speed_and_duplex to retreive the current link
  1610. * information and then calls the Kumeran lock loss workaround for links at
  1611. * gigabit speeds.
  1612. **/
  1613. static s32 e1000_get_link_up_info_ich8lan(struct e1000_hw *hw, u16 *speed,
  1614. u16 *duplex)
  1615. {
  1616. s32 ret_val;
  1617. ret_val = e1000e_get_speed_and_duplex_copper(hw, speed, duplex);
  1618. if (ret_val)
  1619. return ret_val;
  1620. if ((hw->mac.type == e1000_ich8lan) &&
  1621. (hw->phy.type == e1000_phy_igp_3) &&
  1622. (*speed == SPEED_1000)) {
  1623. ret_val = e1000_kmrn_lock_loss_workaround_ich8lan(hw);
  1624. }
  1625. return ret_val;
  1626. }
  1627. /**
  1628. * e1000_kmrn_lock_loss_workaround_ich8lan - Kumeran workaround
  1629. * @hw: pointer to the HW structure
  1630. *
  1631. * Work-around for 82566 Kumeran PCS lock loss:
  1632. * On link status change (i.e. PCI reset, speed change) and link is up and
  1633. * speed is gigabit-
  1634. * 0) if workaround is optionally disabled do nothing
  1635. * 1) wait 1ms for Kumeran link to come up
  1636. * 2) check Kumeran Diagnostic register PCS lock loss bit
  1637. * 3) if not set the link is locked (all is good), otherwise...
  1638. * 4) reset the PHY
  1639. * 5) repeat up to 10 times
  1640. * Note: this is only called for IGP3 copper when speed is 1gb.
  1641. **/
  1642. static s32 e1000_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw *hw)
  1643. {
  1644. struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
  1645. u32 phy_ctrl;
  1646. s32 ret_val;
  1647. u16 i, data;
  1648. bool link;
  1649. if (!dev_spec->kmrn_lock_loss_workaround_enabled)
  1650. return 0;
  1651. /* Make sure link is up before proceeding. If not just return.
  1652. * Attempting this while link is negotiating fouled up link
  1653. * stability */
  1654. ret_val = e1000e_phy_has_link_generic(hw, 1, 0, &link);
  1655. if (!link)
  1656. return 0;
  1657. for (i = 0; i < 10; i++) {
  1658. /* read once to clear */
  1659. ret_val = e1e_rphy(hw, IGP3_KMRN_DIAG, &data);
  1660. if (ret_val)
  1661. return ret_val;
  1662. /* and again to get new status */
  1663. ret_val = e1e_rphy(hw, IGP3_KMRN_DIAG, &data);
  1664. if (ret_val)
  1665. return ret_val;
  1666. /* check for PCS lock */
  1667. if (!(data & IGP3_KMRN_DIAG_PCS_LOCK_LOSS))
  1668. return 0;
  1669. /* Issue PHY reset */
  1670. e1000_phy_hw_reset(hw);
  1671. mdelay(5);
  1672. }
  1673. /* Disable GigE link negotiation */
  1674. phy_ctrl = er32(PHY_CTRL);
  1675. phy_ctrl |= (E1000_PHY_CTRL_GBE_DISABLE |
  1676. E1000_PHY_CTRL_NOND0A_GBE_DISABLE);
  1677. ew32(PHY_CTRL, phy_ctrl);
  1678. /* Call gig speed drop workaround on Giga disable before accessing
  1679. * any PHY registers */
  1680. e1000e_gig_downshift_workaround_ich8lan(hw);
  1681. /* unable to acquire PCS lock */
  1682. return -E1000_ERR_PHY;
  1683. }
  1684. /**
  1685. * e1000_set_kmrn_lock_loss_workaound_ich8lan - Set Kumeran workaround state
  1686. * @hw: pointer to the HW structure
  1687. * @state: boolean value used to set the current Kumaran workaround state
  1688. *
  1689. * If ICH8, set the current Kumeran workaround state (enabled - TRUE
  1690. * /disabled - FALSE).
  1691. **/
  1692. void e1000e_set_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw *hw,
  1693. bool state)
  1694. {
  1695. struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
  1696. if (hw->mac.type != e1000_ich8lan) {
  1697. hw_dbg(hw, "Workaround applies to ICH8 only.\n");
  1698. return;
  1699. }
  1700. dev_spec->kmrn_lock_loss_workaround_enabled = state;
  1701. }
  1702. /**
  1703. * e1000_ipg3_phy_powerdown_workaround_ich8lan - Power down workaround on D3
  1704. * @hw: pointer to the HW structure
  1705. *
  1706. * Workaround for 82566 power-down on D3 entry:
  1707. * 1) disable gigabit link
  1708. * 2) write VR power-down enable
  1709. * 3) read it back
  1710. * Continue if successful, else issue LCD reset and repeat
  1711. **/
  1712. void e1000e_igp3_phy_powerdown_workaround_ich8lan(struct e1000_hw *hw)
  1713. {
  1714. u32 reg;
  1715. u16 data;
  1716. u8 retry = 0;
  1717. if (hw->phy.type != e1000_phy_igp_3)
  1718. return;
  1719. /* Try the workaround twice (if needed) */
  1720. do {
  1721. /* Disable link */
  1722. reg = er32(PHY_CTRL);
  1723. reg |= (E1000_PHY_CTRL_GBE_DISABLE |
  1724. E1000_PHY_CTRL_NOND0A_GBE_DISABLE);
  1725. ew32(PHY_CTRL, reg);
  1726. /* Call gig speed drop workaround on Giga disable before
  1727. * accessing any PHY registers */
  1728. if (hw->mac.type == e1000_ich8lan)
  1729. e1000e_gig_downshift_workaround_ich8lan(hw);
  1730. /* Write VR power-down enable */
  1731. e1e_rphy(hw, IGP3_VR_CTRL, &data);
  1732. data &= ~IGP3_VR_CTRL_DEV_POWERDOWN_MODE_MASK;
  1733. e1e_wphy(hw, IGP3_VR_CTRL, data | IGP3_VR_CTRL_MODE_SHUTDOWN);
  1734. /* Read it back and test */
  1735. e1e_rphy(hw, IGP3_VR_CTRL, &data);
  1736. data &= IGP3_VR_CTRL_DEV_POWERDOWN_MODE_MASK;
  1737. if ((data == IGP3_VR_CTRL_MODE_SHUTDOWN) || retry)
  1738. break;
  1739. /* Issue PHY reset and repeat at most one more time */
  1740. reg = er32(CTRL);
  1741. ew32(CTRL, reg | E1000_CTRL_PHY_RST);
  1742. retry++;
  1743. } while (retry);
  1744. }
  1745. /**
  1746. * e1000e_gig_downshift_workaround_ich8lan - WoL from S5 stops working
  1747. * @hw: pointer to the HW structure
  1748. *
  1749. * Steps to take when dropping from 1Gb/s (eg. link cable removal (LSC),
  1750. * LPLU, Giga disable, MDIC PHY reset):
  1751. * 1) Set Kumeran Near-end loopback
  1752. * 2) Clear Kumeran Near-end loopback
  1753. * Should only be called for ICH8[m] devices with IGP_3 Phy.
  1754. **/
  1755. void e1000e_gig_downshift_workaround_ich8lan(struct e1000_hw *hw)
  1756. {
  1757. s32 ret_val;
  1758. u16 reg_data;
  1759. if ((hw->mac.type != e1000_ich8lan) ||
  1760. (hw->phy.type != e1000_phy_igp_3))
  1761. return;
  1762. ret_val = e1000e_read_kmrn_reg(hw, E1000_KMRNCTRLSTA_DIAG_OFFSET,
  1763. &reg_data);
  1764. if (ret_val)
  1765. return;
  1766. reg_data |= E1000_KMRNCTRLSTA_DIAG_NELPBK;
  1767. ret_val = e1000e_write_kmrn_reg(hw, E1000_KMRNCTRLSTA_DIAG_OFFSET,
  1768. reg_data);
  1769. if (ret_val)
  1770. return;
  1771. reg_data &= ~E1000_KMRNCTRLSTA_DIAG_NELPBK;
  1772. ret_val = e1000e_write_kmrn_reg(hw, E1000_KMRNCTRLSTA_DIAG_OFFSET,
  1773. reg_data);
  1774. }
  1775. /**
  1776. * e1000_cleanup_led_ich8lan - Restore the default LED operation
  1777. * @hw: pointer to the HW structure
  1778. *
  1779. * Return the LED back to the default configuration.
  1780. **/
  1781. static s32 e1000_cleanup_led_ich8lan(struct e1000_hw *hw)
  1782. {
  1783. if (hw->phy.type == e1000_phy_ife)
  1784. return e1e_wphy(hw, IFE_PHY_SPECIAL_CONTROL_LED, 0);
  1785. ew32(LEDCTL, hw->mac.ledctl_default);
  1786. return 0;
  1787. }
  1788. /**
  1789. * e1000_led_on_ich8lan - Turn LED's on
  1790. * @hw: pointer to the HW structure
  1791. *
  1792. * Turn on the LED's.
  1793. **/
  1794. static s32 e1000_led_on_ich8lan(struct e1000_hw *hw)
  1795. {
  1796. if (hw->phy.type == e1000_phy_ife)
  1797. return e1e_wphy(hw, IFE_PHY_SPECIAL_CONTROL_LED,
  1798. (IFE_PSCL_PROBE_MODE | IFE_PSCL_PROBE_LEDS_ON));
  1799. ew32(LEDCTL, hw->mac.ledctl_mode2);
  1800. return 0;
  1801. }
  1802. /**
  1803. * e1000_led_off_ich8lan - Turn LED's off
  1804. * @hw: pointer to the HW structure
  1805. *
  1806. * Turn off the LED's.
  1807. **/
  1808. static s32 e1000_led_off_ich8lan(struct e1000_hw *hw)
  1809. {
  1810. if (hw->phy.type == e1000_phy_ife)
  1811. return e1e_wphy(hw, IFE_PHY_SPECIAL_CONTROL_LED,
  1812. (IFE_PSCL_PROBE_MODE | IFE_PSCL_PROBE_LEDS_OFF));
  1813. ew32(LEDCTL, hw->mac.ledctl_mode1);
  1814. return 0;
  1815. }
  1816. /**
  1817. * e1000_clear_hw_cntrs_ich8lan - Clear statistical counters
  1818. * @hw: pointer to the HW structure
  1819. *
  1820. * Clears hardware counters specific to the silicon family and calls
  1821. * clear_hw_cntrs_generic to clear all general purpose counters.
  1822. **/
  1823. static void e1000_clear_hw_cntrs_ich8lan(struct e1000_hw *hw)
  1824. {
  1825. u32 temp;
  1826. e1000e_clear_hw_cntrs_base(hw);
  1827. temp = er32(ALGNERRC);
  1828. temp = er32(RXERRC);
  1829. temp = er32(TNCRS);
  1830. temp = er32(CEXTERR);
  1831. temp = er32(TSCTC);
  1832. temp = er32(TSCTFC);
  1833. temp = er32(MGTPRC);
  1834. temp = er32(MGTPDC);
  1835. temp = er32(MGTPTC);
  1836. temp = er32(IAC);
  1837. temp = er32(ICRXOC);
  1838. }
  1839. static struct e1000_mac_operations ich8_mac_ops = {
  1840. .mng_mode_enab = E1000_ICH_MNG_IAMT_MODE << E1000_FWSM_MODE_SHIFT,
  1841. .check_for_link = e1000e_check_for_copper_link,
  1842. .cleanup_led = e1000_cleanup_led_ich8lan,
  1843. .clear_hw_cntrs = e1000_clear_hw_cntrs_ich8lan,
  1844. .get_bus_info = e1000_get_bus_info_ich8lan,
  1845. .get_link_up_info = e1000_get_link_up_info_ich8lan,
  1846. .led_on = e1000_led_on_ich8lan,
  1847. .led_off = e1000_led_off_ich8lan,
  1848. .mc_addr_list_update = e1000e_mc_addr_list_update_generic,
  1849. .reset_hw = e1000_reset_hw_ich8lan,
  1850. .init_hw = e1000_init_hw_ich8lan,
  1851. .setup_link = e1000_setup_link_ich8lan,
  1852. .setup_physical_interface= e1000_setup_copper_link_ich8lan,
  1853. };
  1854. static struct e1000_phy_operations ich8_phy_ops = {
  1855. .acquire_phy = e1000_acquire_swflag_ich8lan,
  1856. .check_reset_block = e1000_check_reset_block_ich8lan,
  1857. .commit_phy = NULL,
  1858. .force_speed_duplex = e1000_phy_force_speed_duplex_ich8lan,
  1859. .get_cfg_done = e1000e_get_cfg_done,
  1860. .get_cable_length = e1000e_get_cable_length_igp_2,
  1861. .get_phy_info = e1000_get_phy_info_ich8lan,
  1862. .read_phy_reg = e1000e_read_phy_reg_igp,
  1863. .release_phy = e1000_release_swflag_ich8lan,
  1864. .reset_phy = e1000_phy_hw_reset_ich8lan,
  1865. .set_d0_lplu_state = e1000_set_d0_lplu_state_ich8lan,
  1866. .set_d3_lplu_state = e1000_set_d3_lplu_state_ich8lan,
  1867. .write_phy_reg = e1000e_write_phy_reg_igp,
  1868. };
  1869. static struct e1000_nvm_operations ich8_nvm_ops = {
  1870. .acquire_nvm = e1000_acquire_swflag_ich8lan,
  1871. .read_nvm = e1000_read_nvm_ich8lan,
  1872. .release_nvm = e1000_release_swflag_ich8lan,
  1873. .update_nvm = e1000_update_nvm_checksum_ich8lan,
  1874. .valid_led_default = e1000_valid_led_default_ich8lan,
  1875. .validate_nvm = e1000_validate_nvm_checksum_ich8lan,
  1876. .write_nvm = e1000_write_nvm_ich8lan,
  1877. };
  1878. struct e1000_info e1000_ich8_info = {
  1879. .mac = e1000_ich8lan,
  1880. .flags = FLAG_HAS_WOL
  1881. | FLAG_RX_CSUM_ENABLED
  1882. | FLAG_HAS_CTRLEXT_ON_LOAD
  1883. | FLAG_HAS_AMT
  1884. | FLAG_HAS_FLASH
  1885. | FLAG_APME_IN_WUC,
  1886. .pba = 8,
  1887. .get_invariants = e1000_get_invariants_ich8lan,
  1888. .mac_ops = &ich8_mac_ops,
  1889. .phy_ops = &ich8_phy_ops,
  1890. .nvm_ops = &ich8_nvm_ops,
  1891. };
  1892. struct e1000_info e1000_ich9_info = {
  1893. .mac = e1000_ich9lan,
  1894. .flags = FLAG_HAS_JUMBO_FRAMES
  1895. | FLAG_HAS_WOL
  1896. | FLAG_RX_CSUM_ENABLED
  1897. | FLAG_HAS_CTRLEXT_ON_LOAD
  1898. | FLAG_HAS_AMT
  1899. | FLAG_HAS_ERT
  1900. | FLAG_HAS_FLASH
  1901. | FLAG_APME_IN_WUC,
  1902. .pba = 10,
  1903. .get_invariants = e1000_get_invariants_ich8lan,
  1904. .mac_ops = &ich8_mac_ops,
  1905. .phy_ops = &ich8_phy_ops,
  1906. .nvm_ops = &ich8_nvm_ops,
  1907. };