ich8lan.c 64 KB

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