ich8lan.c 92 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412
  1. /*******************************************************************************
  2. Intel PRO/1000 Linux driver
  3. Copyright(c) 1999 - 2009 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 10/100 Network Connection
  23. * 82562G-2 10/100 Network Connection
  24. * 82562GT 10/100 Network Connection
  25. * 82562GT-2 10/100 Network Connection
  26. * 82562V 10/100 Network Connection
  27. * 82562V-2 10/100 Network Connection
  28. * 82566DC-2 Gigabit Network Connection
  29. * 82566DC Gigabit Network Connection
  30. * 82566DM-2 Gigabit Network Connection
  31. * 82566DM Gigabit Network Connection
  32. * 82566MC Gigabit Network Connection
  33. * 82566MM Gigabit Network Connection
  34. * 82567LM Gigabit Network Connection
  35. * 82567LF Gigabit Network Connection
  36. * 82567V Gigabit Network Connection
  37. * 82567LM-2 Gigabit Network Connection
  38. * 82567LF-2 Gigabit Network Connection
  39. * 82567V-2 Gigabit Network Connection
  40. * 82567LF-3 Gigabit Network Connection
  41. * 82567LM-3 Gigabit Network Connection
  42. * 82567LM-4 Gigabit Network Connection
  43. * 82577LM Gigabit Network Connection
  44. * 82577LC Gigabit Network Connection
  45. * 82578DM Gigabit Network Connection
  46. * 82578DC Gigabit Network Connection
  47. */
  48. #include "e1000.h"
  49. #define ICH_FLASH_GFPREG 0x0000
  50. #define ICH_FLASH_HSFSTS 0x0004
  51. #define ICH_FLASH_HSFCTL 0x0006
  52. #define ICH_FLASH_FADDR 0x0008
  53. #define ICH_FLASH_FDATA0 0x0010
  54. #define ICH_FLASH_PR0 0x0074
  55. #define ICH_FLASH_READ_COMMAND_TIMEOUT 500
  56. #define ICH_FLASH_WRITE_COMMAND_TIMEOUT 500
  57. #define ICH_FLASH_ERASE_COMMAND_TIMEOUT 3000000
  58. #define ICH_FLASH_LINEAR_ADDR_MASK 0x00FFFFFF
  59. #define ICH_FLASH_CYCLE_REPEAT_COUNT 10
  60. #define ICH_CYCLE_READ 0
  61. #define ICH_CYCLE_WRITE 2
  62. #define ICH_CYCLE_ERASE 3
  63. #define FLASH_GFPREG_BASE_MASK 0x1FFF
  64. #define FLASH_SECTOR_ADDR_SHIFT 12
  65. #define ICH_FLASH_SEG_SIZE_256 256
  66. #define ICH_FLASH_SEG_SIZE_4K 4096
  67. #define ICH_FLASH_SEG_SIZE_8K 8192
  68. #define ICH_FLASH_SEG_SIZE_64K 65536
  69. #define E1000_ICH_FWSM_RSPCIPHY 0x00000040 /* Reset PHY on PCI Reset */
  70. #define E1000_ICH_MNG_IAMT_MODE 0x2
  71. #define ID_LED_DEFAULT_ICH8LAN ((ID_LED_DEF1_DEF2 << 12) | \
  72. (ID_LED_DEF1_OFF2 << 8) | \
  73. (ID_LED_DEF1_ON2 << 4) | \
  74. (ID_LED_DEF1_DEF2))
  75. #define E1000_ICH_NVM_SIG_WORD 0x13
  76. #define E1000_ICH_NVM_SIG_MASK 0xC000
  77. #define E1000_ICH_NVM_VALID_SIG_MASK 0xC0
  78. #define E1000_ICH_NVM_SIG_VALUE 0x80
  79. #define E1000_ICH8_LAN_INIT_TIMEOUT 1500
  80. #define E1000_FEXTNVM_SW_CONFIG 1
  81. #define E1000_FEXTNVM_SW_CONFIG_ICH8M (1 << 27) /* Bit redefined for ICH8M :/ */
  82. #define PCIE_ICH8_SNOOP_ALL PCIE_NO_SNOOP_ALL
  83. #define E1000_ICH_RAR_ENTRIES 7
  84. #define PHY_PAGE_SHIFT 5
  85. #define PHY_REG(page, reg) (((page) << PHY_PAGE_SHIFT) | \
  86. ((reg) & MAX_PHY_REG_ADDRESS))
  87. #define IGP3_KMRN_DIAG PHY_REG(770, 19) /* KMRN Diagnostic */
  88. #define IGP3_VR_CTRL PHY_REG(776, 18) /* Voltage Regulator Control */
  89. #define IGP3_KMRN_DIAG_PCS_LOCK_LOSS 0x0002
  90. #define IGP3_VR_CTRL_DEV_POWERDOWN_MODE_MASK 0x0300
  91. #define IGP3_VR_CTRL_MODE_SHUTDOWN 0x0200
  92. #define HV_LED_CONFIG PHY_REG(768, 30) /* LED Configuration */
  93. #define SW_FLAG_TIMEOUT 1000 /* SW Semaphore flag timeout in milliseconds */
  94. /* SMBus Address Phy Register */
  95. #define HV_SMB_ADDR PHY_REG(768, 26)
  96. #define HV_SMB_ADDR_PEC_EN 0x0200
  97. #define HV_SMB_ADDR_VALID 0x0080
  98. /* Strapping Option Register - RO */
  99. #define E1000_STRAP 0x0000C
  100. #define E1000_STRAP_SMBUS_ADDRESS_MASK 0x00FE0000
  101. #define E1000_STRAP_SMBUS_ADDRESS_SHIFT 17
  102. /* OEM Bits Phy Register */
  103. #define HV_OEM_BITS PHY_REG(768, 25)
  104. #define HV_OEM_BITS_LPLU 0x0004 /* Low Power Link Up */
  105. #define HV_OEM_BITS_GBE_DIS 0x0040 /* Gigabit Disable */
  106. #define HV_OEM_BITS_RESTART_AN 0x0400 /* Restart Auto-negotiation */
  107. #define E1000_NVM_K1_CONFIG 0x1B /* NVM K1 Config Word */
  108. #define E1000_NVM_K1_ENABLE 0x1 /* NVM Enable K1 bit */
  109. /* ICH GbE Flash Hardware Sequencing Flash Status Register bit breakdown */
  110. /* Offset 04h HSFSTS */
  111. union ich8_hws_flash_status {
  112. struct ich8_hsfsts {
  113. u16 flcdone :1; /* bit 0 Flash Cycle Done */
  114. u16 flcerr :1; /* bit 1 Flash Cycle Error */
  115. u16 dael :1; /* bit 2 Direct Access error Log */
  116. u16 berasesz :2; /* bit 4:3 Sector Erase Size */
  117. u16 flcinprog :1; /* bit 5 flash cycle in Progress */
  118. u16 reserved1 :2; /* bit 13:6 Reserved */
  119. u16 reserved2 :6; /* bit 13:6 Reserved */
  120. u16 fldesvalid :1; /* bit 14 Flash Descriptor Valid */
  121. u16 flockdn :1; /* bit 15 Flash Config Lock-Down */
  122. } hsf_status;
  123. u16 regval;
  124. };
  125. /* ICH GbE Flash Hardware Sequencing Flash control Register bit breakdown */
  126. /* Offset 06h FLCTL */
  127. union ich8_hws_flash_ctrl {
  128. struct ich8_hsflctl {
  129. u16 flcgo :1; /* 0 Flash Cycle Go */
  130. u16 flcycle :2; /* 2:1 Flash Cycle */
  131. u16 reserved :5; /* 7:3 Reserved */
  132. u16 fldbcount :2; /* 9:8 Flash Data Byte Count */
  133. u16 flockdn :6; /* 15:10 Reserved */
  134. } hsf_ctrl;
  135. u16 regval;
  136. };
  137. /* ICH Flash Region Access Permissions */
  138. union ich8_hws_flash_regacc {
  139. struct ich8_flracc {
  140. u32 grra :8; /* 0:7 GbE region Read Access */
  141. u32 grwa :8; /* 8:15 GbE region Write Access */
  142. u32 gmrag :8; /* 23:16 GbE Master Read Access Grant */
  143. u32 gmwag :8; /* 31:24 GbE Master Write Access Grant */
  144. } hsf_flregacc;
  145. u16 regval;
  146. };
  147. /* ICH Flash Protected Region */
  148. union ich8_flash_protected_range {
  149. struct ich8_pr {
  150. u32 base:13; /* 0:12 Protected Range Base */
  151. u32 reserved1:2; /* 13:14 Reserved */
  152. u32 rpe:1; /* 15 Read Protection Enable */
  153. u32 limit:13; /* 16:28 Protected Range Limit */
  154. u32 reserved2:2; /* 29:30 Reserved */
  155. u32 wpe:1; /* 31 Write Protection Enable */
  156. } range;
  157. u32 regval;
  158. };
  159. static s32 e1000_setup_link_ich8lan(struct e1000_hw *hw);
  160. static void e1000_clear_hw_cntrs_ich8lan(struct e1000_hw *hw);
  161. static void e1000_initialize_hw_bits_ich8lan(struct e1000_hw *hw);
  162. static s32 e1000_erase_flash_bank_ich8lan(struct e1000_hw *hw, u32 bank);
  163. static s32 e1000_retry_write_flash_byte_ich8lan(struct e1000_hw *hw,
  164. u32 offset, u8 byte);
  165. static s32 e1000_read_flash_byte_ich8lan(struct e1000_hw *hw, u32 offset,
  166. u8 *data);
  167. static s32 e1000_read_flash_word_ich8lan(struct e1000_hw *hw, u32 offset,
  168. u16 *data);
  169. static s32 e1000_read_flash_data_ich8lan(struct e1000_hw *hw, u32 offset,
  170. u8 size, u16 *data);
  171. static s32 e1000_setup_copper_link_ich8lan(struct e1000_hw *hw);
  172. static s32 e1000_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw *hw);
  173. static s32 e1000_get_cfg_done_ich8lan(struct e1000_hw *hw);
  174. static s32 e1000_cleanup_led_ich8lan(struct e1000_hw *hw);
  175. static s32 e1000_led_on_ich8lan(struct e1000_hw *hw);
  176. static s32 e1000_led_off_ich8lan(struct e1000_hw *hw);
  177. static s32 e1000_id_led_init_pchlan(struct e1000_hw *hw);
  178. static s32 e1000_setup_led_pchlan(struct e1000_hw *hw);
  179. static s32 e1000_cleanup_led_pchlan(struct e1000_hw *hw);
  180. static s32 e1000_led_on_pchlan(struct e1000_hw *hw);
  181. static s32 e1000_led_off_pchlan(struct e1000_hw *hw);
  182. static s32 e1000_set_lplu_state_pchlan(struct e1000_hw *hw, bool active);
  183. static void e1000_power_down_phy_copper_ich8lan(struct e1000_hw *hw);
  184. static void e1000_lan_init_done_ich8lan(struct e1000_hw *hw);
  185. static s32 e1000_k1_gig_workaround_hv(struct e1000_hw *hw, bool link);
  186. static inline u16 __er16flash(struct e1000_hw *hw, unsigned long reg)
  187. {
  188. return readw(hw->flash_address + reg);
  189. }
  190. static inline u32 __er32flash(struct e1000_hw *hw, unsigned long reg)
  191. {
  192. return readl(hw->flash_address + reg);
  193. }
  194. static inline void __ew16flash(struct e1000_hw *hw, unsigned long reg, u16 val)
  195. {
  196. writew(val, hw->flash_address + reg);
  197. }
  198. static inline void __ew32flash(struct e1000_hw *hw, unsigned long reg, u32 val)
  199. {
  200. writel(val, hw->flash_address + reg);
  201. }
  202. #define er16flash(reg) __er16flash(hw, (reg))
  203. #define er32flash(reg) __er32flash(hw, (reg))
  204. #define ew16flash(reg,val) __ew16flash(hw, (reg), (val))
  205. #define ew32flash(reg,val) __ew32flash(hw, (reg), (val))
  206. /**
  207. * e1000_init_phy_params_pchlan - Initialize PHY function pointers
  208. * @hw: pointer to the HW structure
  209. *
  210. * Initialize family-specific PHY parameters and function pointers.
  211. **/
  212. static s32 e1000_init_phy_params_pchlan(struct e1000_hw *hw)
  213. {
  214. struct e1000_phy_info *phy = &hw->phy;
  215. s32 ret_val = 0;
  216. phy->addr = 1;
  217. phy->reset_delay_us = 100;
  218. phy->ops.read_reg = e1000_read_phy_reg_hv;
  219. phy->ops.read_reg_locked = e1000_read_phy_reg_hv_locked;
  220. phy->ops.set_d0_lplu_state = e1000_set_lplu_state_pchlan;
  221. phy->ops.set_d3_lplu_state = e1000_set_lplu_state_pchlan;
  222. phy->ops.write_reg = e1000_write_phy_reg_hv;
  223. phy->ops.write_reg_locked = e1000_write_phy_reg_hv_locked;
  224. phy->ops.power_up = e1000_power_up_phy_copper;
  225. phy->ops.power_down = e1000_power_down_phy_copper_ich8lan;
  226. phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT;
  227. phy->id = e1000_phy_unknown;
  228. e1000e_get_phy_id(hw);
  229. phy->type = e1000e_get_phy_type_from_id(phy->id);
  230. switch (phy->type) {
  231. case e1000_phy_82577:
  232. phy->ops.check_polarity = e1000_check_polarity_82577;
  233. phy->ops.force_speed_duplex =
  234. e1000_phy_force_speed_duplex_82577;
  235. phy->ops.get_cable_length = e1000_get_cable_length_82577;
  236. phy->ops.get_info = e1000_get_phy_info_82577;
  237. phy->ops.commit = e1000e_phy_sw_reset;
  238. case e1000_phy_82578:
  239. phy->ops.check_polarity = e1000_check_polarity_m88;
  240. phy->ops.force_speed_duplex = e1000e_phy_force_speed_duplex_m88;
  241. phy->ops.get_cable_length = e1000e_get_cable_length_m88;
  242. phy->ops.get_info = e1000e_get_phy_info_m88;
  243. break;
  244. default:
  245. ret_val = -E1000_ERR_PHY;
  246. break;
  247. }
  248. return ret_val;
  249. }
  250. /**
  251. * e1000_init_phy_params_ich8lan - Initialize PHY function pointers
  252. * @hw: pointer to the HW structure
  253. *
  254. * Initialize family-specific PHY parameters and function pointers.
  255. **/
  256. static s32 e1000_init_phy_params_ich8lan(struct e1000_hw *hw)
  257. {
  258. struct e1000_phy_info *phy = &hw->phy;
  259. s32 ret_val;
  260. u16 i = 0;
  261. phy->addr = 1;
  262. phy->reset_delay_us = 100;
  263. phy->ops.power_up = e1000_power_up_phy_copper;
  264. phy->ops.power_down = e1000_power_down_phy_copper_ich8lan;
  265. /*
  266. * We may need to do this twice - once for IGP and if that fails,
  267. * we'll set BM func pointers and try again
  268. */
  269. ret_val = e1000e_determine_phy_address(hw);
  270. if (ret_val) {
  271. phy->ops.write_reg = e1000e_write_phy_reg_bm;
  272. phy->ops.read_reg = e1000e_read_phy_reg_bm;
  273. ret_val = e1000e_determine_phy_address(hw);
  274. if (ret_val) {
  275. e_dbg("Cannot determine PHY addr. Erroring out\n");
  276. return ret_val;
  277. }
  278. }
  279. phy->id = 0;
  280. while ((e1000_phy_unknown == e1000e_get_phy_type_from_id(phy->id)) &&
  281. (i++ < 100)) {
  282. msleep(1);
  283. ret_val = e1000e_get_phy_id(hw);
  284. if (ret_val)
  285. return ret_val;
  286. }
  287. /* Verify phy id */
  288. switch (phy->id) {
  289. case IGP03E1000_E_PHY_ID:
  290. phy->type = e1000_phy_igp_3;
  291. phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT;
  292. phy->ops.read_reg_locked = e1000e_read_phy_reg_igp_locked;
  293. phy->ops.write_reg_locked = e1000e_write_phy_reg_igp_locked;
  294. phy->ops.get_info = e1000e_get_phy_info_igp;
  295. phy->ops.check_polarity = e1000_check_polarity_igp;
  296. phy->ops.force_speed_duplex = e1000e_phy_force_speed_duplex_igp;
  297. break;
  298. case IFE_E_PHY_ID:
  299. case IFE_PLUS_E_PHY_ID:
  300. case IFE_C_E_PHY_ID:
  301. phy->type = e1000_phy_ife;
  302. phy->autoneg_mask = E1000_ALL_NOT_GIG;
  303. phy->ops.get_info = e1000_get_phy_info_ife;
  304. phy->ops.check_polarity = e1000_check_polarity_ife;
  305. phy->ops.force_speed_duplex = e1000_phy_force_speed_duplex_ife;
  306. break;
  307. case BME1000_E_PHY_ID:
  308. phy->type = e1000_phy_bm;
  309. phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT;
  310. phy->ops.read_reg = e1000e_read_phy_reg_bm;
  311. phy->ops.write_reg = e1000e_write_phy_reg_bm;
  312. phy->ops.commit = e1000e_phy_sw_reset;
  313. phy->ops.get_info = e1000e_get_phy_info_m88;
  314. phy->ops.check_polarity = e1000_check_polarity_m88;
  315. phy->ops.force_speed_duplex = e1000e_phy_force_speed_duplex_m88;
  316. break;
  317. default:
  318. return -E1000_ERR_PHY;
  319. break;
  320. }
  321. return 0;
  322. }
  323. /**
  324. * e1000_init_nvm_params_ich8lan - Initialize NVM function pointers
  325. * @hw: pointer to the HW structure
  326. *
  327. * Initialize family-specific NVM parameters and function
  328. * pointers.
  329. **/
  330. static s32 e1000_init_nvm_params_ich8lan(struct e1000_hw *hw)
  331. {
  332. struct e1000_nvm_info *nvm = &hw->nvm;
  333. struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
  334. u32 gfpreg, sector_base_addr, sector_end_addr;
  335. u16 i;
  336. /* Can't read flash registers if the register set isn't mapped. */
  337. if (!hw->flash_address) {
  338. e_dbg("ERROR: Flash registers not mapped\n");
  339. return -E1000_ERR_CONFIG;
  340. }
  341. nvm->type = e1000_nvm_flash_sw;
  342. gfpreg = er32flash(ICH_FLASH_GFPREG);
  343. /*
  344. * sector_X_addr is a "sector"-aligned address (4096 bytes)
  345. * Add 1 to sector_end_addr since this sector is included in
  346. * the overall size.
  347. */
  348. sector_base_addr = gfpreg & FLASH_GFPREG_BASE_MASK;
  349. sector_end_addr = ((gfpreg >> 16) & FLASH_GFPREG_BASE_MASK) + 1;
  350. /* flash_base_addr is byte-aligned */
  351. nvm->flash_base_addr = sector_base_addr << FLASH_SECTOR_ADDR_SHIFT;
  352. /*
  353. * find total size of the NVM, then cut in half since the total
  354. * size represents two separate NVM banks.
  355. */
  356. nvm->flash_bank_size = (sector_end_addr - sector_base_addr)
  357. << FLASH_SECTOR_ADDR_SHIFT;
  358. nvm->flash_bank_size /= 2;
  359. /* Adjust to word count */
  360. nvm->flash_bank_size /= sizeof(u16);
  361. nvm->word_size = E1000_ICH8_SHADOW_RAM_WORDS;
  362. /* Clear shadow ram */
  363. for (i = 0; i < nvm->word_size; i++) {
  364. dev_spec->shadow_ram[i].modified = false;
  365. dev_spec->shadow_ram[i].value = 0xFFFF;
  366. }
  367. return 0;
  368. }
  369. /**
  370. * e1000_init_mac_params_ich8lan - Initialize MAC function pointers
  371. * @hw: pointer to the HW structure
  372. *
  373. * Initialize family-specific MAC parameters and function
  374. * pointers.
  375. **/
  376. static s32 e1000_init_mac_params_ich8lan(struct e1000_adapter *adapter)
  377. {
  378. struct e1000_hw *hw = &adapter->hw;
  379. struct e1000_mac_info *mac = &hw->mac;
  380. /* Set media type function pointer */
  381. hw->phy.media_type = e1000_media_type_copper;
  382. /* Set mta register count */
  383. mac->mta_reg_count = 32;
  384. /* Set rar entry count */
  385. mac->rar_entry_count = E1000_ICH_RAR_ENTRIES;
  386. if (mac->type == e1000_ich8lan)
  387. mac->rar_entry_count--;
  388. /* Set if manageability features are enabled. */
  389. mac->arc_subsystem_valid = true;
  390. /* Adaptive IFS supported */
  391. mac->adaptive_ifs = true;
  392. /* LED operations */
  393. switch (mac->type) {
  394. case e1000_ich8lan:
  395. case e1000_ich9lan:
  396. case e1000_ich10lan:
  397. /* ID LED init */
  398. mac->ops.id_led_init = e1000e_id_led_init;
  399. /* setup LED */
  400. mac->ops.setup_led = e1000e_setup_led_generic;
  401. /* cleanup LED */
  402. mac->ops.cleanup_led = e1000_cleanup_led_ich8lan;
  403. /* turn on/off LED */
  404. mac->ops.led_on = e1000_led_on_ich8lan;
  405. mac->ops.led_off = e1000_led_off_ich8lan;
  406. break;
  407. case e1000_pchlan:
  408. /* ID LED init */
  409. mac->ops.id_led_init = e1000_id_led_init_pchlan;
  410. /* setup LED */
  411. mac->ops.setup_led = e1000_setup_led_pchlan;
  412. /* cleanup LED */
  413. mac->ops.cleanup_led = e1000_cleanup_led_pchlan;
  414. /* turn on/off LED */
  415. mac->ops.led_on = e1000_led_on_pchlan;
  416. mac->ops.led_off = e1000_led_off_pchlan;
  417. break;
  418. default:
  419. break;
  420. }
  421. /* Enable PCS Lock-loss workaround for ICH8 */
  422. if (mac->type == e1000_ich8lan)
  423. e1000e_set_kmrn_lock_loss_workaround_ich8lan(hw, true);
  424. return 0;
  425. }
  426. /**
  427. * e1000_check_for_copper_link_ich8lan - Check for link (Copper)
  428. * @hw: pointer to the HW structure
  429. *
  430. * Checks to see of the link status of the hardware has changed. If a
  431. * change in link status has been detected, then we read the PHY registers
  432. * to get the current speed/duplex if link exists.
  433. **/
  434. static s32 e1000_check_for_copper_link_ich8lan(struct e1000_hw *hw)
  435. {
  436. struct e1000_mac_info *mac = &hw->mac;
  437. s32 ret_val;
  438. bool link;
  439. /*
  440. * We only want to go out to the PHY registers to see if Auto-Neg
  441. * has completed and/or if our link status has changed. The
  442. * get_link_status flag is set upon receiving a Link Status
  443. * Change or Rx Sequence Error interrupt.
  444. */
  445. if (!mac->get_link_status) {
  446. ret_val = 0;
  447. goto out;
  448. }
  449. /*
  450. * First we want to see if the MII Status Register reports
  451. * link. If so, then we want to get the current speed/duplex
  452. * of the PHY.
  453. */
  454. ret_val = e1000e_phy_has_link_generic(hw, 1, 0, &link);
  455. if (ret_val)
  456. goto out;
  457. if (hw->mac.type == e1000_pchlan) {
  458. ret_val = e1000_k1_gig_workaround_hv(hw, link);
  459. if (ret_val)
  460. goto out;
  461. }
  462. if (!link)
  463. goto out; /* No link detected */
  464. mac->get_link_status = false;
  465. if (hw->phy.type == e1000_phy_82578) {
  466. ret_val = e1000_link_stall_workaround_hv(hw);
  467. if (ret_val)
  468. goto out;
  469. }
  470. /*
  471. * Check if there was DownShift, must be checked
  472. * immediately after link-up
  473. */
  474. e1000e_check_downshift(hw);
  475. /*
  476. * If we are forcing speed/duplex, then we simply return since
  477. * we have already determined whether we have link or not.
  478. */
  479. if (!mac->autoneg) {
  480. ret_val = -E1000_ERR_CONFIG;
  481. goto out;
  482. }
  483. /*
  484. * Auto-Neg is enabled. Auto Speed Detection takes care
  485. * of MAC speed/duplex configuration. So we only need to
  486. * configure Collision Distance in the MAC.
  487. */
  488. e1000e_config_collision_dist(hw);
  489. /*
  490. * Configure Flow Control now that Auto-Neg has completed.
  491. * First, we need to restore the desired flow control
  492. * settings because we may have had to re-autoneg with a
  493. * different link partner.
  494. */
  495. ret_val = e1000e_config_fc_after_link_up(hw);
  496. if (ret_val)
  497. e_dbg("Error configuring flow control\n");
  498. out:
  499. return ret_val;
  500. }
  501. static s32 e1000_get_variants_ich8lan(struct e1000_adapter *adapter)
  502. {
  503. struct e1000_hw *hw = &adapter->hw;
  504. s32 rc;
  505. rc = e1000_init_mac_params_ich8lan(adapter);
  506. if (rc)
  507. return rc;
  508. rc = e1000_init_nvm_params_ich8lan(hw);
  509. if (rc)
  510. return rc;
  511. if (hw->mac.type == e1000_pchlan)
  512. rc = e1000_init_phy_params_pchlan(hw);
  513. else
  514. rc = e1000_init_phy_params_ich8lan(hw);
  515. if (rc)
  516. return rc;
  517. if (adapter->hw.phy.type == e1000_phy_ife) {
  518. adapter->flags &= ~FLAG_HAS_JUMBO_FRAMES;
  519. adapter->max_hw_frame_size = ETH_FRAME_LEN + ETH_FCS_LEN;
  520. }
  521. if ((adapter->hw.mac.type == e1000_ich8lan) &&
  522. (adapter->hw.phy.type == e1000_phy_igp_3))
  523. adapter->flags |= FLAG_LSC_GIG_SPEED_DROP;
  524. return 0;
  525. }
  526. static DEFINE_MUTEX(nvm_mutex);
  527. /**
  528. * e1000_acquire_nvm_ich8lan - Acquire NVM mutex
  529. * @hw: pointer to the HW structure
  530. *
  531. * Acquires the mutex for performing NVM operations.
  532. **/
  533. static s32 e1000_acquire_nvm_ich8lan(struct e1000_hw *hw)
  534. {
  535. mutex_lock(&nvm_mutex);
  536. return 0;
  537. }
  538. /**
  539. * e1000_release_nvm_ich8lan - Release NVM mutex
  540. * @hw: pointer to the HW structure
  541. *
  542. * Releases the mutex used while performing NVM operations.
  543. **/
  544. static void e1000_release_nvm_ich8lan(struct e1000_hw *hw)
  545. {
  546. mutex_unlock(&nvm_mutex);
  547. return;
  548. }
  549. static DEFINE_MUTEX(swflag_mutex);
  550. /**
  551. * e1000_acquire_swflag_ich8lan - Acquire software control flag
  552. * @hw: pointer to the HW structure
  553. *
  554. * Acquires the software control flag for performing PHY and select
  555. * MAC CSR accesses.
  556. **/
  557. static s32 e1000_acquire_swflag_ich8lan(struct e1000_hw *hw)
  558. {
  559. u32 extcnf_ctrl, timeout = PHY_CFG_TIMEOUT;
  560. s32 ret_val = 0;
  561. mutex_lock(&swflag_mutex);
  562. while (timeout) {
  563. extcnf_ctrl = er32(EXTCNF_CTRL);
  564. if (!(extcnf_ctrl & E1000_EXTCNF_CTRL_SWFLAG))
  565. break;
  566. mdelay(1);
  567. timeout--;
  568. }
  569. if (!timeout) {
  570. e_dbg("SW/FW/HW has locked the resource for too long.\n");
  571. ret_val = -E1000_ERR_CONFIG;
  572. goto out;
  573. }
  574. timeout = SW_FLAG_TIMEOUT;
  575. extcnf_ctrl |= E1000_EXTCNF_CTRL_SWFLAG;
  576. ew32(EXTCNF_CTRL, extcnf_ctrl);
  577. while (timeout) {
  578. extcnf_ctrl = er32(EXTCNF_CTRL);
  579. if (extcnf_ctrl & E1000_EXTCNF_CTRL_SWFLAG)
  580. break;
  581. mdelay(1);
  582. timeout--;
  583. }
  584. if (!timeout) {
  585. e_dbg("Failed to acquire the semaphore.\n");
  586. extcnf_ctrl &= ~E1000_EXTCNF_CTRL_SWFLAG;
  587. ew32(EXTCNF_CTRL, extcnf_ctrl);
  588. ret_val = -E1000_ERR_CONFIG;
  589. goto out;
  590. }
  591. out:
  592. if (ret_val)
  593. mutex_unlock(&swflag_mutex);
  594. return ret_val;
  595. }
  596. /**
  597. * e1000_release_swflag_ich8lan - Release software control flag
  598. * @hw: pointer to the HW structure
  599. *
  600. * Releases the software control flag for performing PHY and select
  601. * MAC CSR accesses.
  602. **/
  603. static void e1000_release_swflag_ich8lan(struct e1000_hw *hw)
  604. {
  605. u32 extcnf_ctrl;
  606. extcnf_ctrl = er32(EXTCNF_CTRL);
  607. extcnf_ctrl &= ~E1000_EXTCNF_CTRL_SWFLAG;
  608. ew32(EXTCNF_CTRL, extcnf_ctrl);
  609. mutex_unlock(&swflag_mutex);
  610. return;
  611. }
  612. /**
  613. * e1000_check_mng_mode_ich8lan - Checks management mode
  614. * @hw: pointer to the HW structure
  615. *
  616. * This checks if the adapter has manageability enabled.
  617. * This is a function pointer entry point only called by read/write
  618. * routines for the PHY and NVM parts.
  619. **/
  620. static bool e1000_check_mng_mode_ich8lan(struct e1000_hw *hw)
  621. {
  622. u32 fwsm;
  623. fwsm = er32(FWSM);
  624. return (fwsm & E1000_FWSM_MODE_MASK) ==
  625. (E1000_ICH_MNG_IAMT_MODE << E1000_FWSM_MODE_SHIFT);
  626. }
  627. /**
  628. * e1000_check_reset_block_ich8lan - Check if PHY reset is blocked
  629. * @hw: pointer to the HW structure
  630. *
  631. * Checks if firmware is blocking the reset of the PHY.
  632. * This is a function pointer entry point only called by
  633. * reset routines.
  634. **/
  635. static s32 e1000_check_reset_block_ich8lan(struct e1000_hw *hw)
  636. {
  637. u32 fwsm;
  638. fwsm = er32(FWSM);
  639. return (fwsm & E1000_ICH_FWSM_RSPCIPHY) ? 0 : E1000_BLK_PHY_RESET;
  640. }
  641. /**
  642. * e1000_sw_lcd_config_ich8lan - SW-based LCD Configuration
  643. * @hw: pointer to the HW structure
  644. *
  645. * SW should configure the LCD from the NVM extended configuration region
  646. * as a workaround for certain parts.
  647. **/
  648. static s32 e1000_sw_lcd_config_ich8lan(struct e1000_hw *hw)
  649. {
  650. struct e1000_phy_info *phy = &hw->phy;
  651. u32 i, data, cnf_size, cnf_base_addr, sw_cfg_mask;
  652. s32 ret_val;
  653. u16 word_addr, reg_data, reg_addr, phy_page = 0;
  654. ret_val = hw->phy.ops.acquire(hw);
  655. if (ret_val)
  656. return ret_val;
  657. /*
  658. * Initialize the PHY from the NVM on ICH platforms. This
  659. * is needed due to an issue where the NVM configuration is
  660. * not properly autoloaded after power transitions.
  661. * Therefore, after each PHY reset, we will load the
  662. * configuration data out of the NVM manually.
  663. */
  664. if ((hw->mac.type == e1000_ich8lan && phy->type == e1000_phy_igp_3) ||
  665. (hw->mac.type == e1000_pchlan)) {
  666. struct e1000_adapter *adapter = hw->adapter;
  667. /* Check if SW needs to configure the PHY */
  668. if ((adapter->pdev->device == E1000_DEV_ID_ICH8_IGP_M_AMT) ||
  669. (adapter->pdev->device == E1000_DEV_ID_ICH8_IGP_M) ||
  670. (hw->mac.type == e1000_pchlan))
  671. sw_cfg_mask = E1000_FEXTNVM_SW_CONFIG_ICH8M;
  672. else
  673. sw_cfg_mask = E1000_FEXTNVM_SW_CONFIG;
  674. data = er32(FEXTNVM);
  675. if (!(data & sw_cfg_mask))
  676. goto out;
  677. /* Wait for basic configuration completes before proceeding */
  678. e1000_lan_init_done_ich8lan(hw);
  679. /*
  680. * Make sure HW does not configure LCD from PHY
  681. * extended configuration before SW configuration
  682. */
  683. data = er32(EXTCNF_CTRL);
  684. if (data & E1000_EXTCNF_CTRL_LCD_WRITE_ENABLE)
  685. goto out;
  686. cnf_size = er32(EXTCNF_SIZE);
  687. cnf_size &= E1000_EXTCNF_SIZE_EXT_PCIE_LENGTH_MASK;
  688. cnf_size >>= E1000_EXTCNF_SIZE_EXT_PCIE_LENGTH_SHIFT;
  689. if (!cnf_size)
  690. goto out;
  691. cnf_base_addr = data & E1000_EXTCNF_CTRL_EXT_CNF_POINTER_MASK;
  692. cnf_base_addr >>= E1000_EXTCNF_CTRL_EXT_CNF_POINTER_SHIFT;
  693. if (!(data & E1000_EXTCNF_CTRL_OEM_WRITE_ENABLE) &&
  694. (hw->mac.type == e1000_pchlan)) {
  695. /*
  696. * HW configures the SMBus address and LEDs when the
  697. * OEM and LCD Write Enable bits are set in the NVM.
  698. * When both NVM bits are cleared, SW will configure
  699. * them instead.
  700. */
  701. data = er32(STRAP);
  702. data &= E1000_STRAP_SMBUS_ADDRESS_MASK;
  703. reg_data = data >> E1000_STRAP_SMBUS_ADDRESS_SHIFT;
  704. reg_data |= HV_SMB_ADDR_PEC_EN | HV_SMB_ADDR_VALID;
  705. ret_val = e1000_write_phy_reg_hv_locked(hw, HV_SMB_ADDR,
  706. reg_data);
  707. if (ret_val)
  708. goto out;
  709. data = er32(LEDCTL);
  710. ret_val = e1000_write_phy_reg_hv_locked(hw,
  711. HV_LED_CONFIG,
  712. (u16)data);
  713. if (ret_val)
  714. goto out;
  715. }
  716. /* Configure LCD from extended configuration region. */
  717. /* cnf_base_addr is in DWORD */
  718. word_addr = (u16)(cnf_base_addr << 1);
  719. for (i = 0; i < cnf_size; i++) {
  720. ret_val = e1000_read_nvm(hw, (word_addr + i * 2), 1,
  721. &reg_data);
  722. if (ret_val)
  723. goto out;
  724. ret_val = e1000_read_nvm(hw, (word_addr + i * 2 + 1),
  725. 1, &reg_addr);
  726. if (ret_val)
  727. goto out;
  728. /* Save off the PHY page for future writes. */
  729. if (reg_addr == IGP01E1000_PHY_PAGE_SELECT) {
  730. phy_page = reg_data;
  731. continue;
  732. }
  733. reg_addr &= PHY_REG_MASK;
  734. reg_addr |= phy_page;
  735. ret_val = phy->ops.write_reg_locked(hw,
  736. (u32)reg_addr,
  737. reg_data);
  738. if (ret_val)
  739. goto out;
  740. }
  741. }
  742. out:
  743. hw->phy.ops.release(hw);
  744. return ret_val;
  745. }
  746. /**
  747. * e1000_k1_gig_workaround_hv - K1 Si workaround
  748. * @hw: pointer to the HW structure
  749. * @link: link up bool flag
  750. *
  751. * If K1 is enabled for 1Gbps, the MAC might stall when transitioning
  752. * from a lower speed. This workaround disables K1 whenever link is at 1Gig
  753. * If link is down, the function will restore the default K1 setting located
  754. * in the NVM.
  755. **/
  756. static s32 e1000_k1_gig_workaround_hv(struct e1000_hw *hw, bool link)
  757. {
  758. s32 ret_val = 0;
  759. u16 status_reg = 0;
  760. bool k1_enable = hw->dev_spec.ich8lan.nvm_k1_enabled;
  761. if (hw->mac.type != e1000_pchlan)
  762. goto out;
  763. /* Wrap the whole flow with the sw flag */
  764. ret_val = hw->phy.ops.acquire(hw);
  765. if (ret_val)
  766. goto out;
  767. /* Disable K1 when link is 1Gbps, otherwise use the NVM setting */
  768. if (link) {
  769. if (hw->phy.type == e1000_phy_82578) {
  770. ret_val = hw->phy.ops.read_reg_locked(hw, BM_CS_STATUS,
  771. &status_reg);
  772. if (ret_val)
  773. goto release;
  774. status_reg &= BM_CS_STATUS_LINK_UP |
  775. BM_CS_STATUS_RESOLVED |
  776. BM_CS_STATUS_SPEED_MASK;
  777. if (status_reg == (BM_CS_STATUS_LINK_UP |
  778. BM_CS_STATUS_RESOLVED |
  779. BM_CS_STATUS_SPEED_1000))
  780. k1_enable = false;
  781. }
  782. if (hw->phy.type == e1000_phy_82577) {
  783. ret_val = hw->phy.ops.read_reg_locked(hw, HV_M_STATUS,
  784. &status_reg);
  785. if (ret_val)
  786. goto release;
  787. status_reg &= HV_M_STATUS_LINK_UP |
  788. HV_M_STATUS_AUTONEG_COMPLETE |
  789. HV_M_STATUS_SPEED_MASK;
  790. if (status_reg == (HV_M_STATUS_LINK_UP |
  791. HV_M_STATUS_AUTONEG_COMPLETE |
  792. HV_M_STATUS_SPEED_1000))
  793. k1_enable = false;
  794. }
  795. /* Link stall fix for link up */
  796. ret_val = hw->phy.ops.write_reg_locked(hw, PHY_REG(770, 19),
  797. 0x0100);
  798. if (ret_val)
  799. goto release;
  800. } else {
  801. /* Link stall fix for link down */
  802. ret_val = hw->phy.ops.write_reg_locked(hw, PHY_REG(770, 19),
  803. 0x4100);
  804. if (ret_val)
  805. goto release;
  806. }
  807. ret_val = e1000_configure_k1_ich8lan(hw, k1_enable);
  808. release:
  809. hw->phy.ops.release(hw);
  810. out:
  811. return ret_val;
  812. }
  813. /**
  814. * e1000_configure_k1_ich8lan - Configure K1 power state
  815. * @hw: pointer to the HW structure
  816. * @enable: K1 state to configure
  817. *
  818. * Configure the K1 power state based on the provided parameter.
  819. * Assumes semaphore already acquired.
  820. *
  821. * Success returns 0, Failure returns -E1000_ERR_PHY (-2)
  822. **/
  823. s32 e1000_configure_k1_ich8lan(struct e1000_hw *hw, bool k1_enable)
  824. {
  825. s32 ret_val = 0;
  826. u32 ctrl_reg = 0;
  827. u32 ctrl_ext = 0;
  828. u32 reg = 0;
  829. u16 kmrn_reg = 0;
  830. ret_val = e1000e_read_kmrn_reg_locked(hw,
  831. E1000_KMRNCTRLSTA_K1_CONFIG,
  832. &kmrn_reg);
  833. if (ret_val)
  834. goto out;
  835. if (k1_enable)
  836. kmrn_reg |= E1000_KMRNCTRLSTA_K1_ENABLE;
  837. else
  838. kmrn_reg &= ~E1000_KMRNCTRLSTA_K1_ENABLE;
  839. ret_val = e1000e_write_kmrn_reg_locked(hw,
  840. E1000_KMRNCTRLSTA_K1_CONFIG,
  841. kmrn_reg);
  842. if (ret_val)
  843. goto out;
  844. udelay(20);
  845. ctrl_ext = er32(CTRL_EXT);
  846. ctrl_reg = er32(CTRL);
  847. reg = ctrl_reg & ~(E1000_CTRL_SPD_1000 | E1000_CTRL_SPD_100);
  848. reg |= E1000_CTRL_FRCSPD;
  849. ew32(CTRL, reg);
  850. ew32(CTRL_EXT, ctrl_ext | E1000_CTRL_EXT_SPD_BYPS);
  851. udelay(20);
  852. ew32(CTRL, ctrl_reg);
  853. ew32(CTRL_EXT, ctrl_ext);
  854. udelay(20);
  855. out:
  856. return ret_val;
  857. }
  858. /**
  859. * e1000_oem_bits_config_ich8lan - SW-based LCD Configuration
  860. * @hw: pointer to the HW structure
  861. * @d0_state: boolean if entering d0 or d3 device state
  862. *
  863. * SW will configure Gbe Disable and LPLU based on the NVM. The four bits are
  864. * collectively called OEM bits. The OEM Write Enable bit and SW Config bit
  865. * in NVM determines whether HW should configure LPLU and Gbe Disable.
  866. **/
  867. static s32 e1000_oem_bits_config_ich8lan(struct e1000_hw *hw, bool d0_state)
  868. {
  869. s32 ret_val = 0;
  870. u32 mac_reg;
  871. u16 oem_reg;
  872. if (hw->mac.type != e1000_pchlan)
  873. return ret_val;
  874. ret_val = hw->phy.ops.acquire(hw);
  875. if (ret_val)
  876. return ret_val;
  877. mac_reg = er32(EXTCNF_CTRL);
  878. if (mac_reg & E1000_EXTCNF_CTRL_OEM_WRITE_ENABLE)
  879. goto out;
  880. mac_reg = er32(FEXTNVM);
  881. if (!(mac_reg & E1000_FEXTNVM_SW_CONFIG_ICH8M))
  882. goto out;
  883. mac_reg = er32(PHY_CTRL);
  884. ret_val = hw->phy.ops.read_reg_locked(hw, HV_OEM_BITS, &oem_reg);
  885. if (ret_val)
  886. goto out;
  887. oem_reg &= ~(HV_OEM_BITS_GBE_DIS | HV_OEM_BITS_LPLU);
  888. if (d0_state) {
  889. if (mac_reg & E1000_PHY_CTRL_GBE_DISABLE)
  890. oem_reg |= HV_OEM_BITS_GBE_DIS;
  891. if (mac_reg & E1000_PHY_CTRL_D0A_LPLU)
  892. oem_reg |= HV_OEM_BITS_LPLU;
  893. } else {
  894. if (mac_reg & E1000_PHY_CTRL_NOND0A_GBE_DISABLE)
  895. oem_reg |= HV_OEM_BITS_GBE_DIS;
  896. if (mac_reg & E1000_PHY_CTRL_NOND0A_LPLU)
  897. oem_reg |= HV_OEM_BITS_LPLU;
  898. }
  899. /* Restart auto-neg to activate the bits */
  900. if (!e1000_check_reset_block(hw))
  901. oem_reg |= HV_OEM_BITS_RESTART_AN;
  902. ret_val = hw->phy.ops.write_reg_locked(hw, HV_OEM_BITS, oem_reg);
  903. out:
  904. hw->phy.ops.release(hw);
  905. return ret_val;
  906. }
  907. /**
  908. * e1000_hv_phy_workarounds_ich8lan - A series of Phy workarounds to be
  909. * done after every PHY reset.
  910. **/
  911. static s32 e1000_hv_phy_workarounds_ich8lan(struct e1000_hw *hw)
  912. {
  913. s32 ret_val = 0;
  914. if (hw->mac.type != e1000_pchlan)
  915. return ret_val;
  916. if (((hw->phy.type == e1000_phy_82577) &&
  917. ((hw->phy.revision == 1) || (hw->phy.revision == 2))) ||
  918. ((hw->phy.type == e1000_phy_82578) && (hw->phy.revision == 1))) {
  919. /* Disable generation of early preamble */
  920. ret_val = e1e_wphy(hw, PHY_REG(769, 25), 0x4431);
  921. if (ret_val)
  922. return ret_val;
  923. /* Preamble tuning for SSC */
  924. ret_val = e1e_wphy(hw, PHY_REG(770, 16), 0xA204);
  925. if (ret_val)
  926. return ret_val;
  927. }
  928. if (hw->phy.type == e1000_phy_82578) {
  929. /*
  930. * Return registers to default by doing a soft reset then
  931. * writing 0x3140 to the control register.
  932. */
  933. if (hw->phy.revision < 2) {
  934. e1000e_phy_sw_reset(hw);
  935. ret_val = e1e_wphy(hw, PHY_CONTROL, 0x3140);
  936. }
  937. }
  938. /* Select page 0 */
  939. ret_val = hw->phy.ops.acquire(hw);
  940. if (ret_val)
  941. return ret_val;
  942. hw->phy.addr = 1;
  943. ret_val = e1000e_write_phy_reg_mdic(hw, IGP01E1000_PHY_PAGE_SELECT, 0);
  944. if (ret_val)
  945. goto out;
  946. hw->phy.ops.release(hw);
  947. /*
  948. * Configure the K1 Si workaround during phy reset assuming there is
  949. * link so that it disables K1 if link is in 1Gbps.
  950. */
  951. ret_val = e1000_k1_gig_workaround_hv(hw, true);
  952. out:
  953. return ret_val;
  954. }
  955. /**
  956. * e1000_lan_init_done_ich8lan - Check for PHY config completion
  957. * @hw: pointer to the HW structure
  958. *
  959. * Check the appropriate indication the MAC has finished configuring the
  960. * PHY after a software reset.
  961. **/
  962. static void e1000_lan_init_done_ich8lan(struct e1000_hw *hw)
  963. {
  964. u32 data, loop = E1000_ICH8_LAN_INIT_TIMEOUT;
  965. /* Wait for basic configuration completes before proceeding */
  966. do {
  967. data = er32(STATUS);
  968. data &= E1000_STATUS_LAN_INIT_DONE;
  969. udelay(100);
  970. } while ((!data) && --loop);
  971. /*
  972. * If basic configuration is incomplete before the above loop
  973. * count reaches 0, loading the configuration from NVM will
  974. * leave the PHY in a bad state possibly resulting in no link.
  975. */
  976. if (loop == 0)
  977. e_dbg("LAN_INIT_DONE not set, increase timeout\n");
  978. /* Clear the Init Done bit for the next init event */
  979. data = er32(STATUS);
  980. data &= ~E1000_STATUS_LAN_INIT_DONE;
  981. ew32(STATUS, data);
  982. }
  983. /**
  984. * e1000_phy_hw_reset_ich8lan - Performs a PHY reset
  985. * @hw: pointer to the HW structure
  986. *
  987. * Resets the PHY
  988. * This is a function pointer entry point called by drivers
  989. * or other shared routines.
  990. **/
  991. static s32 e1000_phy_hw_reset_ich8lan(struct e1000_hw *hw)
  992. {
  993. s32 ret_val = 0;
  994. u16 reg;
  995. ret_val = e1000e_phy_hw_reset_generic(hw);
  996. if (ret_val)
  997. return ret_val;
  998. /* Allow time for h/w to get to a quiescent state after reset */
  999. mdelay(10);
  1000. if (hw->mac.type == e1000_pchlan) {
  1001. ret_val = e1000_hv_phy_workarounds_ich8lan(hw);
  1002. if (ret_val)
  1003. return ret_val;
  1004. }
  1005. /* Dummy read to clear the phy wakeup bit after lcd reset */
  1006. if (hw->mac.type == e1000_pchlan)
  1007. e1e_rphy(hw, BM_WUC, &reg);
  1008. /* Configure the LCD with the extended configuration region in NVM */
  1009. ret_val = e1000_sw_lcd_config_ich8lan(hw);
  1010. if (ret_val)
  1011. goto out;
  1012. /* Configure the LCD with the OEM bits in NVM */
  1013. if (hw->mac.type == e1000_pchlan)
  1014. ret_val = e1000_oem_bits_config_ich8lan(hw, true);
  1015. out:
  1016. return 0;
  1017. }
  1018. /**
  1019. * e1000_set_lplu_state_pchlan - Set Low Power Link Up state
  1020. * @hw: pointer to the HW structure
  1021. * @active: true to enable LPLU, false to disable
  1022. *
  1023. * Sets the LPLU state according to the active flag. For PCH, if OEM write
  1024. * bit are disabled in the NVM, writing the LPLU bits in the MAC will not set
  1025. * the phy speed. This function will manually set the LPLU bit and restart
  1026. * auto-neg as hw would do. D3 and D0 LPLU will call the same function
  1027. * since it configures the same bit.
  1028. **/
  1029. static s32 e1000_set_lplu_state_pchlan(struct e1000_hw *hw, bool active)
  1030. {
  1031. s32 ret_val = 0;
  1032. u16 oem_reg;
  1033. ret_val = e1e_rphy(hw, HV_OEM_BITS, &oem_reg);
  1034. if (ret_val)
  1035. goto out;
  1036. if (active)
  1037. oem_reg |= HV_OEM_BITS_LPLU;
  1038. else
  1039. oem_reg &= ~HV_OEM_BITS_LPLU;
  1040. oem_reg |= HV_OEM_BITS_RESTART_AN;
  1041. ret_val = e1e_wphy(hw, HV_OEM_BITS, oem_reg);
  1042. out:
  1043. return ret_val;
  1044. }
  1045. /**
  1046. * e1000_set_d0_lplu_state_ich8lan - Set Low Power Linkup D0 state
  1047. * @hw: pointer to the HW structure
  1048. * @active: true to enable LPLU, false to disable
  1049. *
  1050. * Sets the LPLU D0 state according to the active flag. When
  1051. * activating LPLU this function also disables smart speed
  1052. * and vice versa. LPLU will not be activated unless the
  1053. * device autonegotiation advertisement meets standards of
  1054. * either 10 or 10/100 or 10/100/1000 at all duplexes.
  1055. * This is a function pointer entry point only called by
  1056. * PHY setup routines.
  1057. **/
  1058. static s32 e1000_set_d0_lplu_state_ich8lan(struct e1000_hw *hw, bool active)
  1059. {
  1060. struct e1000_phy_info *phy = &hw->phy;
  1061. u32 phy_ctrl;
  1062. s32 ret_val = 0;
  1063. u16 data;
  1064. if (phy->type == e1000_phy_ife)
  1065. return ret_val;
  1066. phy_ctrl = er32(PHY_CTRL);
  1067. if (active) {
  1068. phy_ctrl |= E1000_PHY_CTRL_D0A_LPLU;
  1069. ew32(PHY_CTRL, phy_ctrl);
  1070. if (phy->type != e1000_phy_igp_3)
  1071. return 0;
  1072. /*
  1073. * Call gig speed drop workaround on LPLU before accessing
  1074. * any PHY registers
  1075. */
  1076. if (hw->mac.type == e1000_ich8lan)
  1077. e1000e_gig_downshift_workaround_ich8lan(hw);
  1078. /* When LPLU is enabled, we should disable SmartSpeed */
  1079. ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG, &data);
  1080. data &= ~IGP01E1000_PSCFR_SMART_SPEED;
  1081. ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG, data);
  1082. if (ret_val)
  1083. return ret_val;
  1084. } else {
  1085. phy_ctrl &= ~E1000_PHY_CTRL_D0A_LPLU;
  1086. ew32(PHY_CTRL, phy_ctrl);
  1087. if (phy->type != e1000_phy_igp_3)
  1088. return 0;
  1089. /*
  1090. * LPLU and SmartSpeed are mutually exclusive. LPLU is used
  1091. * during Dx states where the power conservation is most
  1092. * important. During driver activity we should enable
  1093. * SmartSpeed, so performance is maintained.
  1094. */
  1095. if (phy->smart_speed == e1000_smart_speed_on) {
  1096. ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG,
  1097. &data);
  1098. if (ret_val)
  1099. return ret_val;
  1100. data |= IGP01E1000_PSCFR_SMART_SPEED;
  1101. ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG,
  1102. data);
  1103. if (ret_val)
  1104. return ret_val;
  1105. } else if (phy->smart_speed == e1000_smart_speed_off) {
  1106. ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG,
  1107. &data);
  1108. if (ret_val)
  1109. return ret_val;
  1110. data &= ~IGP01E1000_PSCFR_SMART_SPEED;
  1111. ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG,
  1112. data);
  1113. if (ret_val)
  1114. return ret_val;
  1115. }
  1116. }
  1117. return 0;
  1118. }
  1119. /**
  1120. * e1000_set_d3_lplu_state_ich8lan - Set Low Power Linkup D3 state
  1121. * @hw: pointer to the HW structure
  1122. * @active: true to enable LPLU, false to disable
  1123. *
  1124. * Sets the LPLU D3 state according to the active flag. When
  1125. * activating LPLU this function also disables smart speed
  1126. * and vice versa. LPLU will not be activated unless the
  1127. * device autonegotiation advertisement meets standards of
  1128. * either 10 or 10/100 or 10/100/1000 at all duplexes.
  1129. * This is a function pointer entry point only called by
  1130. * PHY setup routines.
  1131. **/
  1132. static s32 e1000_set_d3_lplu_state_ich8lan(struct e1000_hw *hw, bool active)
  1133. {
  1134. struct e1000_phy_info *phy = &hw->phy;
  1135. u32 phy_ctrl;
  1136. s32 ret_val;
  1137. u16 data;
  1138. phy_ctrl = er32(PHY_CTRL);
  1139. if (!active) {
  1140. phy_ctrl &= ~E1000_PHY_CTRL_NOND0A_LPLU;
  1141. ew32(PHY_CTRL, phy_ctrl);
  1142. if (phy->type != e1000_phy_igp_3)
  1143. return 0;
  1144. /*
  1145. * LPLU and SmartSpeed are mutually exclusive. LPLU is used
  1146. * during Dx states where the power conservation is most
  1147. * important. During driver activity we should enable
  1148. * SmartSpeed, so performance is maintained.
  1149. */
  1150. if (phy->smart_speed == e1000_smart_speed_on) {
  1151. ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG,
  1152. &data);
  1153. if (ret_val)
  1154. return ret_val;
  1155. data |= IGP01E1000_PSCFR_SMART_SPEED;
  1156. ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG,
  1157. data);
  1158. if (ret_val)
  1159. return ret_val;
  1160. } else if (phy->smart_speed == e1000_smart_speed_off) {
  1161. ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG,
  1162. &data);
  1163. if (ret_val)
  1164. return ret_val;
  1165. data &= ~IGP01E1000_PSCFR_SMART_SPEED;
  1166. ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG,
  1167. data);
  1168. if (ret_val)
  1169. return ret_val;
  1170. }
  1171. } else if ((phy->autoneg_advertised == E1000_ALL_SPEED_DUPLEX) ||
  1172. (phy->autoneg_advertised == E1000_ALL_NOT_GIG) ||
  1173. (phy->autoneg_advertised == E1000_ALL_10_SPEED)) {
  1174. phy_ctrl |= E1000_PHY_CTRL_NOND0A_LPLU;
  1175. ew32(PHY_CTRL, phy_ctrl);
  1176. if (phy->type != e1000_phy_igp_3)
  1177. return 0;
  1178. /*
  1179. * Call gig speed drop workaround on LPLU before accessing
  1180. * any PHY registers
  1181. */
  1182. if (hw->mac.type == e1000_ich8lan)
  1183. e1000e_gig_downshift_workaround_ich8lan(hw);
  1184. /* When LPLU is enabled, we should disable SmartSpeed */
  1185. ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG, &data);
  1186. if (ret_val)
  1187. return ret_val;
  1188. data &= ~IGP01E1000_PSCFR_SMART_SPEED;
  1189. ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG, data);
  1190. }
  1191. return 0;
  1192. }
  1193. /**
  1194. * e1000_valid_nvm_bank_detect_ich8lan - finds out the valid bank 0 or 1
  1195. * @hw: pointer to the HW structure
  1196. * @bank: pointer to the variable that returns the active bank
  1197. *
  1198. * Reads signature byte from the NVM using the flash access registers.
  1199. * Word 0x13 bits 15:14 = 10b indicate a valid signature for that bank.
  1200. **/
  1201. static s32 e1000_valid_nvm_bank_detect_ich8lan(struct e1000_hw *hw, u32 *bank)
  1202. {
  1203. u32 eecd;
  1204. struct e1000_nvm_info *nvm = &hw->nvm;
  1205. u32 bank1_offset = nvm->flash_bank_size * sizeof(u16);
  1206. u32 act_offset = E1000_ICH_NVM_SIG_WORD * 2 + 1;
  1207. u8 sig_byte = 0;
  1208. s32 ret_val = 0;
  1209. switch (hw->mac.type) {
  1210. case e1000_ich8lan:
  1211. case e1000_ich9lan:
  1212. eecd = er32(EECD);
  1213. if ((eecd & E1000_EECD_SEC1VAL_VALID_MASK) ==
  1214. E1000_EECD_SEC1VAL_VALID_MASK) {
  1215. if (eecd & E1000_EECD_SEC1VAL)
  1216. *bank = 1;
  1217. else
  1218. *bank = 0;
  1219. return 0;
  1220. }
  1221. e_dbg("Unable to determine valid NVM bank via EEC - "
  1222. "reading flash signature\n");
  1223. /* fall-thru */
  1224. default:
  1225. /* set bank to 0 in case flash read fails */
  1226. *bank = 0;
  1227. /* Check bank 0 */
  1228. ret_val = e1000_read_flash_byte_ich8lan(hw, act_offset,
  1229. &sig_byte);
  1230. if (ret_val)
  1231. return ret_val;
  1232. if ((sig_byte & E1000_ICH_NVM_VALID_SIG_MASK) ==
  1233. E1000_ICH_NVM_SIG_VALUE) {
  1234. *bank = 0;
  1235. return 0;
  1236. }
  1237. /* Check bank 1 */
  1238. ret_val = e1000_read_flash_byte_ich8lan(hw, act_offset +
  1239. bank1_offset,
  1240. &sig_byte);
  1241. if (ret_val)
  1242. return ret_val;
  1243. if ((sig_byte & E1000_ICH_NVM_VALID_SIG_MASK) ==
  1244. E1000_ICH_NVM_SIG_VALUE) {
  1245. *bank = 1;
  1246. return 0;
  1247. }
  1248. e_dbg("ERROR: No valid NVM bank present\n");
  1249. return -E1000_ERR_NVM;
  1250. }
  1251. return 0;
  1252. }
  1253. /**
  1254. * e1000_read_nvm_ich8lan - Read word(s) from the NVM
  1255. * @hw: pointer to the HW structure
  1256. * @offset: The offset (in bytes) of the word(s) to read.
  1257. * @words: Size of data to read in words
  1258. * @data: Pointer to the word(s) to read at offset.
  1259. *
  1260. * Reads a word(s) from the NVM using the flash access registers.
  1261. **/
  1262. static s32 e1000_read_nvm_ich8lan(struct e1000_hw *hw, u16 offset, u16 words,
  1263. u16 *data)
  1264. {
  1265. struct e1000_nvm_info *nvm = &hw->nvm;
  1266. struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
  1267. u32 act_offset;
  1268. s32 ret_val = 0;
  1269. u32 bank = 0;
  1270. u16 i, word;
  1271. if ((offset >= nvm->word_size) || (words > nvm->word_size - offset) ||
  1272. (words == 0)) {
  1273. e_dbg("nvm parameter(s) out of bounds\n");
  1274. ret_val = -E1000_ERR_NVM;
  1275. goto out;
  1276. }
  1277. nvm->ops.acquire(hw);
  1278. ret_val = e1000_valid_nvm_bank_detect_ich8lan(hw, &bank);
  1279. if (ret_val) {
  1280. e_dbg("Could not detect valid bank, assuming bank 0\n");
  1281. bank = 0;
  1282. }
  1283. act_offset = (bank) ? nvm->flash_bank_size : 0;
  1284. act_offset += offset;
  1285. ret_val = 0;
  1286. for (i = 0; i < words; i++) {
  1287. if ((dev_spec->shadow_ram) &&
  1288. (dev_spec->shadow_ram[offset+i].modified)) {
  1289. data[i] = dev_spec->shadow_ram[offset+i].value;
  1290. } else {
  1291. ret_val = e1000_read_flash_word_ich8lan(hw,
  1292. act_offset + i,
  1293. &word);
  1294. if (ret_val)
  1295. break;
  1296. data[i] = word;
  1297. }
  1298. }
  1299. nvm->ops.release(hw);
  1300. out:
  1301. if (ret_val)
  1302. e_dbg("NVM read error: %d\n", ret_val);
  1303. return ret_val;
  1304. }
  1305. /**
  1306. * e1000_flash_cycle_init_ich8lan - Initialize flash
  1307. * @hw: pointer to the HW structure
  1308. *
  1309. * This function does initial flash setup so that a new read/write/erase cycle
  1310. * can be started.
  1311. **/
  1312. static s32 e1000_flash_cycle_init_ich8lan(struct e1000_hw *hw)
  1313. {
  1314. union ich8_hws_flash_status hsfsts;
  1315. s32 ret_val = -E1000_ERR_NVM;
  1316. s32 i = 0;
  1317. hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
  1318. /* Check if the flash descriptor is valid */
  1319. if (hsfsts.hsf_status.fldesvalid == 0) {
  1320. e_dbg("Flash descriptor invalid. "
  1321. "SW Sequencing must be used.");
  1322. return -E1000_ERR_NVM;
  1323. }
  1324. /* Clear FCERR and DAEL in hw status by writing 1 */
  1325. hsfsts.hsf_status.flcerr = 1;
  1326. hsfsts.hsf_status.dael = 1;
  1327. ew16flash(ICH_FLASH_HSFSTS, hsfsts.regval);
  1328. /*
  1329. * Either we should have a hardware SPI cycle in progress
  1330. * bit to check against, in order to start a new cycle or
  1331. * FDONE bit should be changed in the hardware so that it
  1332. * is 1 after hardware reset, which can then be used as an
  1333. * indication whether a cycle is in progress or has been
  1334. * completed.
  1335. */
  1336. if (hsfsts.hsf_status.flcinprog == 0) {
  1337. /*
  1338. * There is no cycle running at present,
  1339. * so we can start a cycle.
  1340. * Begin by setting Flash Cycle Done.
  1341. */
  1342. hsfsts.hsf_status.flcdone = 1;
  1343. ew16flash(ICH_FLASH_HSFSTS, hsfsts.regval);
  1344. ret_val = 0;
  1345. } else {
  1346. /*
  1347. * Otherwise poll for sometime so the current
  1348. * cycle has a chance to end before giving up.
  1349. */
  1350. for (i = 0; i < ICH_FLASH_READ_COMMAND_TIMEOUT; i++) {
  1351. hsfsts.regval = __er16flash(hw, ICH_FLASH_HSFSTS);
  1352. if (hsfsts.hsf_status.flcinprog == 0) {
  1353. ret_val = 0;
  1354. break;
  1355. }
  1356. udelay(1);
  1357. }
  1358. if (ret_val == 0) {
  1359. /*
  1360. * Successful in waiting for previous cycle to timeout,
  1361. * now set the Flash Cycle Done.
  1362. */
  1363. hsfsts.hsf_status.flcdone = 1;
  1364. ew16flash(ICH_FLASH_HSFSTS, hsfsts.regval);
  1365. } else {
  1366. e_dbg("Flash controller busy, cannot get access");
  1367. }
  1368. }
  1369. return ret_val;
  1370. }
  1371. /**
  1372. * e1000_flash_cycle_ich8lan - Starts flash cycle (read/write/erase)
  1373. * @hw: pointer to the HW structure
  1374. * @timeout: maximum time to wait for completion
  1375. *
  1376. * This function starts a flash cycle and waits for its completion.
  1377. **/
  1378. static s32 e1000_flash_cycle_ich8lan(struct e1000_hw *hw, u32 timeout)
  1379. {
  1380. union ich8_hws_flash_ctrl hsflctl;
  1381. union ich8_hws_flash_status hsfsts;
  1382. s32 ret_val = -E1000_ERR_NVM;
  1383. u32 i = 0;
  1384. /* Start a cycle by writing 1 in Flash Cycle Go in Hw Flash Control */
  1385. hsflctl.regval = er16flash(ICH_FLASH_HSFCTL);
  1386. hsflctl.hsf_ctrl.flcgo = 1;
  1387. ew16flash(ICH_FLASH_HSFCTL, hsflctl.regval);
  1388. /* wait till FDONE bit is set to 1 */
  1389. do {
  1390. hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
  1391. if (hsfsts.hsf_status.flcdone == 1)
  1392. break;
  1393. udelay(1);
  1394. } while (i++ < timeout);
  1395. if (hsfsts.hsf_status.flcdone == 1 && hsfsts.hsf_status.flcerr == 0)
  1396. return 0;
  1397. return ret_val;
  1398. }
  1399. /**
  1400. * e1000_read_flash_word_ich8lan - Read word from flash
  1401. * @hw: pointer to the HW structure
  1402. * @offset: offset to data location
  1403. * @data: pointer to the location for storing the data
  1404. *
  1405. * Reads the flash word at offset into data. Offset is converted
  1406. * to bytes before read.
  1407. **/
  1408. static s32 e1000_read_flash_word_ich8lan(struct e1000_hw *hw, u32 offset,
  1409. u16 *data)
  1410. {
  1411. /* Must convert offset into bytes. */
  1412. offset <<= 1;
  1413. return e1000_read_flash_data_ich8lan(hw, offset, 2, data);
  1414. }
  1415. /**
  1416. * e1000_read_flash_byte_ich8lan - Read byte from flash
  1417. * @hw: pointer to the HW structure
  1418. * @offset: The offset of the byte to read.
  1419. * @data: Pointer to a byte to store the value read.
  1420. *
  1421. * Reads a single byte from the NVM using the flash access registers.
  1422. **/
  1423. static s32 e1000_read_flash_byte_ich8lan(struct e1000_hw *hw, u32 offset,
  1424. u8 *data)
  1425. {
  1426. s32 ret_val;
  1427. u16 word = 0;
  1428. ret_val = e1000_read_flash_data_ich8lan(hw, offset, 1, &word);
  1429. if (ret_val)
  1430. return ret_val;
  1431. *data = (u8)word;
  1432. return 0;
  1433. }
  1434. /**
  1435. * e1000_read_flash_data_ich8lan - Read byte or word from NVM
  1436. * @hw: pointer to the HW structure
  1437. * @offset: The offset (in bytes) of the byte or word to read.
  1438. * @size: Size of data to read, 1=byte 2=word
  1439. * @data: Pointer to the word to store the value read.
  1440. *
  1441. * Reads a byte or word from the NVM using the flash access registers.
  1442. **/
  1443. static s32 e1000_read_flash_data_ich8lan(struct e1000_hw *hw, u32 offset,
  1444. u8 size, u16 *data)
  1445. {
  1446. union ich8_hws_flash_status hsfsts;
  1447. union ich8_hws_flash_ctrl hsflctl;
  1448. u32 flash_linear_addr;
  1449. u32 flash_data = 0;
  1450. s32 ret_val = -E1000_ERR_NVM;
  1451. u8 count = 0;
  1452. if (size < 1 || size > 2 || offset > ICH_FLASH_LINEAR_ADDR_MASK)
  1453. return -E1000_ERR_NVM;
  1454. flash_linear_addr = (ICH_FLASH_LINEAR_ADDR_MASK & offset) +
  1455. hw->nvm.flash_base_addr;
  1456. do {
  1457. udelay(1);
  1458. /* Steps */
  1459. ret_val = e1000_flash_cycle_init_ich8lan(hw);
  1460. if (ret_val != 0)
  1461. break;
  1462. hsflctl.regval = er16flash(ICH_FLASH_HSFCTL);
  1463. /* 0b/1b corresponds to 1 or 2 byte size, respectively. */
  1464. hsflctl.hsf_ctrl.fldbcount = size - 1;
  1465. hsflctl.hsf_ctrl.flcycle = ICH_CYCLE_READ;
  1466. ew16flash(ICH_FLASH_HSFCTL, hsflctl.regval);
  1467. ew32flash(ICH_FLASH_FADDR, flash_linear_addr);
  1468. ret_val = e1000_flash_cycle_ich8lan(hw,
  1469. ICH_FLASH_READ_COMMAND_TIMEOUT);
  1470. /*
  1471. * Check if FCERR is set to 1, if set to 1, clear it
  1472. * and try the whole sequence a few more times, else
  1473. * read in (shift in) the Flash Data0, the order is
  1474. * least significant byte first msb to lsb
  1475. */
  1476. if (ret_val == 0) {
  1477. flash_data = er32flash(ICH_FLASH_FDATA0);
  1478. if (size == 1) {
  1479. *data = (u8)(flash_data & 0x000000FF);
  1480. } else if (size == 2) {
  1481. *data = (u16)(flash_data & 0x0000FFFF);
  1482. }
  1483. break;
  1484. } else {
  1485. /*
  1486. * If we've gotten here, then things are probably
  1487. * completely hosed, but if the error condition is
  1488. * detected, it won't hurt to give it another try...
  1489. * ICH_FLASH_CYCLE_REPEAT_COUNT times.
  1490. */
  1491. hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
  1492. if (hsfsts.hsf_status.flcerr == 1) {
  1493. /* Repeat for some time before giving up. */
  1494. continue;
  1495. } else if (hsfsts.hsf_status.flcdone == 0) {
  1496. e_dbg("Timeout error - flash cycle "
  1497. "did not complete.");
  1498. break;
  1499. }
  1500. }
  1501. } while (count++ < ICH_FLASH_CYCLE_REPEAT_COUNT);
  1502. return ret_val;
  1503. }
  1504. /**
  1505. * e1000_write_nvm_ich8lan - Write word(s) to the NVM
  1506. * @hw: pointer to the HW structure
  1507. * @offset: The offset (in bytes) of the word(s) to write.
  1508. * @words: Size of data to write in words
  1509. * @data: Pointer to the word(s) to write at offset.
  1510. *
  1511. * Writes a byte or word to the NVM using the flash access registers.
  1512. **/
  1513. static s32 e1000_write_nvm_ich8lan(struct e1000_hw *hw, u16 offset, u16 words,
  1514. u16 *data)
  1515. {
  1516. struct e1000_nvm_info *nvm = &hw->nvm;
  1517. struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
  1518. u16 i;
  1519. if ((offset >= nvm->word_size) || (words > nvm->word_size - offset) ||
  1520. (words == 0)) {
  1521. e_dbg("nvm parameter(s) out of bounds\n");
  1522. return -E1000_ERR_NVM;
  1523. }
  1524. nvm->ops.acquire(hw);
  1525. for (i = 0; i < words; i++) {
  1526. dev_spec->shadow_ram[offset+i].modified = true;
  1527. dev_spec->shadow_ram[offset+i].value = data[i];
  1528. }
  1529. nvm->ops.release(hw);
  1530. return 0;
  1531. }
  1532. /**
  1533. * e1000_update_nvm_checksum_ich8lan - Update the checksum for NVM
  1534. * @hw: pointer to the HW structure
  1535. *
  1536. * The NVM checksum is updated by calling the generic update_nvm_checksum,
  1537. * which writes the checksum to the shadow ram. The changes in the shadow
  1538. * ram are then committed to the EEPROM by processing each bank at a time
  1539. * checking for the modified bit and writing only the pending changes.
  1540. * After a successful commit, the shadow ram is cleared and is ready for
  1541. * future writes.
  1542. **/
  1543. static s32 e1000_update_nvm_checksum_ich8lan(struct e1000_hw *hw)
  1544. {
  1545. struct e1000_nvm_info *nvm = &hw->nvm;
  1546. struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
  1547. u32 i, act_offset, new_bank_offset, old_bank_offset, bank;
  1548. s32 ret_val;
  1549. u16 data;
  1550. ret_val = e1000e_update_nvm_checksum_generic(hw);
  1551. if (ret_val)
  1552. goto out;
  1553. if (nvm->type != e1000_nvm_flash_sw)
  1554. goto out;
  1555. nvm->ops.acquire(hw);
  1556. /*
  1557. * We're writing to the opposite bank so if we're on bank 1,
  1558. * write to bank 0 etc. We also need to erase the segment that
  1559. * is going to be written
  1560. */
  1561. ret_val = e1000_valid_nvm_bank_detect_ich8lan(hw, &bank);
  1562. if (ret_val) {
  1563. e_dbg("Could not detect valid bank, assuming bank 0\n");
  1564. bank = 0;
  1565. }
  1566. if (bank == 0) {
  1567. new_bank_offset = nvm->flash_bank_size;
  1568. old_bank_offset = 0;
  1569. ret_val = e1000_erase_flash_bank_ich8lan(hw, 1);
  1570. if (ret_val) {
  1571. nvm->ops.release(hw);
  1572. goto out;
  1573. }
  1574. } else {
  1575. old_bank_offset = nvm->flash_bank_size;
  1576. new_bank_offset = 0;
  1577. ret_val = e1000_erase_flash_bank_ich8lan(hw, 0);
  1578. if (ret_val) {
  1579. nvm->ops.release(hw);
  1580. goto out;
  1581. }
  1582. }
  1583. for (i = 0; i < E1000_ICH8_SHADOW_RAM_WORDS; i++) {
  1584. /*
  1585. * Determine whether to write the value stored
  1586. * in the other NVM bank or a modified value stored
  1587. * in the shadow RAM
  1588. */
  1589. if (dev_spec->shadow_ram[i].modified) {
  1590. data = dev_spec->shadow_ram[i].value;
  1591. } else {
  1592. ret_val = e1000_read_flash_word_ich8lan(hw, i +
  1593. old_bank_offset,
  1594. &data);
  1595. if (ret_val)
  1596. break;
  1597. }
  1598. /*
  1599. * If the word is 0x13, then make sure the signature bits
  1600. * (15:14) are 11b until the commit has completed.
  1601. * This will allow us to write 10b which indicates the
  1602. * signature is valid. We want to do this after the write
  1603. * has completed so that we don't mark the segment valid
  1604. * while the write is still in progress
  1605. */
  1606. if (i == E1000_ICH_NVM_SIG_WORD)
  1607. data |= E1000_ICH_NVM_SIG_MASK;
  1608. /* Convert offset to bytes. */
  1609. act_offset = (i + new_bank_offset) << 1;
  1610. udelay(100);
  1611. /* Write the bytes to the new bank. */
  1612. ret_val = e1000_retry_write_flash_byte_ich8lan(hw,
  1613. act_offset,
  1614. (u8)data);
  1615. if (ret_val)
  1616. break;
  1617. udelay(100);
  1618. ret_val = e1000_retry_write_flash_byte_ich8lan(hw,
  1619. act_offset + 1,
  1620. (u8)(data >> 8));
  1621. if (ret_val)
  1622. break;
  1623. }
  1624. /*
  1625. * Don't bother writing the segment valid bits if sector
  1626. * programming failed.
  1627. */
  1628. if (ret_val) {
  1629. /* Possibly read-only, see e1000e_write_protect_nvm_ich8lan() */
  1630. e_dbg("Flash commit failed.\n");
  1631. nvm->ops.release(hw);
  1632. goto out;
  1633. }
  1634. /*
  1635. * Finally validate the new segment by setting bit 15:14
  1636. * to 10b in word 0x13 , this can be done without an
  1637. * erase as well since these bits are 11 to start with
  1638. * and we need to change bit 14 to 0b
  1639. */
  1640. act_offset = new_bank_offset + E1000_ICH_NVM_SIG_WORD;
  1641. ret_val = e1000_read_flash_word_ich8lan(hw, act_offset, &data);
  1642. if (ret_val) {
  1643. nvm->ops.release(hw);
  1644. goto out;
  1645. }
  1646. data &= 0xBFFF;
  1647. ret_val = e1000_retry_write_flash_byte_ich8lan(hw,
  1648. act_offset * 2 + 1,
  1649. (u8)(data >> 8));
  1650. if (ret_val) {
  1651. nvm->ops.release(hw);
  1652. goto out;
  1653. }
  1654. /*
  1655. * And invalidate the previously valid segment by setting
  1656. * its signature word (0x13) high_byte to 0b. This can be
  1657. * done without an erase because flash erase sets all bits
  1658. * to 1's. We can write 1's to 0's without an erase
  1659. */
  1660. act_offset = (old_bank_offset + E1000_ICH_NVM_SIG_WORD) * 2 + 1;
  1661. ret_val = e1000_retry_write_flash_byte_ich8lan(hw, act_offset, 0);
  1662. if (ret_val) {
  1663. nvm->ops.release(hw);
  1664. goto out;
  1665. }
  1666. /* Great! Everything worked, we can now clear the cached entries. */
  1667. for (i = 0; i < E1000_ICH8_SHADOW_RAM_WORDS; i++) {
  1668. dev_spec->shadow_ram[i].modified = false;
  1669. dev_spec->shadow_ram[i].value = 0xFFFF;
  1670. }
  1671. nvm->ops.release(hw);
  1672. /*
  1673. * Reload the EEPROM, or else modifications will not appear
  1674. * until after the next adapter reset.
  1675. */
  1676. e1000e_reload_nvm(hw);
  1677. msleep(10);
  1678. out:
  1679. if (ret_val)
  1680. e_dbg("NVM update error: %d\n", ret_val);
  1681. return ret_val;
  1682. }
  1683. /**
  1684. * e1000_validate_nvm_checksum_ich8lan - Validate EEPROM checksum
  1685. * @hw: pointer to the HW structure
  1686. *
  1687. * Check to see if checksum needs to be fixed by reading bit 6 in word 0x19.
  1688. * If the bit is 0, that the EEPROM had been modified, but the checksum was not
  1689. * calculated, in which case we need to calculate the checksum and set bit 6.
  1690. **/
  1691. static s32 e1000_validate_nvm_checksum_ich8lan(struct e1000_hw *hw)
  1692. {
  1693. s32 ret_val;
  1694. u16 data;
  1695. /*
  1696. * Read 0x19 and check bit 6. If this bit is 0, the checksum
  1697. * needs to be fixed. This bit is an indication that the NVM
  1698. * was prepared by OEM software and did not calculate the
  1699. * checksum...a likely scenario.
  1700. */
  1701. ret_val = e1000_read_nvm(hw, 0x19, 1, &data);
  1702. if (ret_val)
  1703. return ret_val;
  1704. if ((data & 0x40) == 0) {
  1705. data |= 0x40;
  1706. ret_val = e1000_write_nvm(hw, 0x19, 1, &data);
  1707. if (ret_val)
  1708. return ret_val;
  1709. ret_val = e1000e_update_nvm_checksum(hw);
  1710. if (ret_val)
  1711. return ret_val;
  1712. }
  1713. return e1000e_validate_nvm_checksum_generic(hw);
  1714. }
  1715. /**
  1716. * e1000e_write_protect_nvm_ich8lan - Make the NVM read-only
  1717. * @hw: pointer to the HW structure
  1718. *
  1719. * To prevent malicious write/erase of the NVM, set it to be read-only
  1720. * so that the hardware ignores all write/erase cycles of the NVM via
  1721. * the flash control registers. The shadow-ram copy of the NVM will
  1722. * still be updated, however any updates to this copy will not stick
  1723. * across driver reloads.
  1724. **/
  1725. void e1000e_write_protect_nvm_ich8lan(struct e1000_hw *hw)
  1726. {
  1727. struct e1000_nvm_info *nvm = &hw->nvm;
  1728. union ich8_flash_protected_range pr0;
  1729. union ich8_hws_flash_status hsfsts;
  1730. u32 gfpreg;
  1731. nvm->ops.acquire(hw);
  1732. gfpreg = er32flash(ICH_FLASH_GFPREG);
  1733. /* Write-protect GbE Sector of NVM */
  1734. pr0.regval = er32flash(ICH_FLASH_PR0);
  1735. pr0.range.base = gfpreg & FLASH_GFPREG_BASE_MASK;
  1736. pr0.range.limit = ((gfpreg >> 16) & FLASH_GFPREG_BASE_MASK);
  1737. pr0.range.wpe = true;
  1738. ew32flash(ICH_FLASH_PR0, pr0.regval);
  1739. /*
  1740. * Lock down a subset of GbE Flash Control Registers, e.g.
  1741. * PR0 to prevent the write-protection from being lifted.
  1742. * Once FLOCKDN is set, the registers protected by it cannot
  1743. * be written until FLOCKDN is cleared by a hardware reset.
  1744. */
  1745. hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
  1746. hsfsts.hsf_status.flockdn = true;
  1747. ew32flash(ICH_FLASH_HSFSTS, hsfsts.regval);
  1748. nvm->ops.release(hw);
  1749. }
  1750. /**
  1751. * e1000_write_flash_data_ich8lan - Writes bytes to the NVM
  1752. * @hw: pointer to the HW structure
  1753. * @offset: The offset (in bytes) of the byte/word to read.
  1754. * @size: Size of data to read, 1=byte 2=word
  1755. * @data: The byte(s) to write to the NVM.
  1756. *
  1757. * Writes one/two bytes to the NVM using the flash access registers.
  1758. **/
  1759. static s32 e1000_write_flash_data_ich8lan(struct e1000_hw *hw, u32 offset,
  1760. u8 size, u16 data)
  1761. {
  1762. union ich8_hws_flash_status hsfsts;
  1763. union ich8_hws_flash_ctrl hsflctl;
  1764. u32 flash_linear_addr;
  1765. u32 flash_data = 0;
  1766. s32 ret_val;
  1767. u8 count = 0;
  1768. if (size < 1 || size > 2 || data > size * 0xff ||
  1769. offset > ICH_FLASH_LINEAR_ADDR_MASK)
  1770. return -E1000_ERR_NVM;
  1771. flash_linear_addr = (ICH_FLASH_LINEAR_ADDR_MASK & offset) +
  1772. hw->nvm.flash_base_addr;
  1773. do {
  1774. udelay(1);
  1775. /* Steps */
  1776. ret_val = e1000_flash_cycle_init_ich8lan(hw);
  1777. if (ret_val)
  1778. break;
  1779. hsflctl.regval = er16flash(ICH_FLASH_HSFCTL);
  1780. /* 0b/1b corresponds to 1 or 2 byte size, respectively. */
  1781. hsflctl.hsf_ctrl.fldbcount = size -1;
  1782. hsflctl.hsf_ctrl.flcycle = ICH_CYCLE_WRITE;
  1783. ew16flash(ICH_FLASH_HSFCTL, hsflctl.regval);
  1784. ew32flash(ICH_FLASH_FADDR, flash_linear_addr);
  1785. if (size == 1)
  1786. flash_data = (u32)data & 0x00FF;
  1787. else
  1788. flash_data = (u32)data;
  1789. ew32flash(ICH_FLASH_FDATA0, flash_data);
  1790. /*
  1791. * check if FCERR is set to 1 , if set to 1, clear it
  1792. * and try the whole sequence a few more times else done
  1793. */
  1794. ret_val = e1000_flash_cycle_ich8lan(hw,
  1795. ICH_FLASH_WRITE_COMMAND_TIMEOUT);
  1796. if (!ret_val)
  1797. break;
  1798. /*
  1799. * If we're here, then things are most likely
  1800. * completely hosed, but if the error condition
  1801. * is detected, it won't hurt to give it another
  1802. * try...ICH_FLASH_CYCLE_REPEAT_COUNT times.
  1803. */
  1804. hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
  1805. if (hsfsts.hsf_status.flcerr == 1)
  1806. /* Repeat for some time before giving up. */
  1807. continue;
  1808. if (hsfsts.hsf_status.flcdone == 0) {
  1809. e_dbg("Timeout error - flash cycle "
  1810. "did not complete.");
  1811. break;
  1812. }
  1813. } while (count++ < ICH_FLASH_CYCLE_REPEAT_COUNT);
  1814. return ret_val;
  1815. }
  1816. /**
  1817. * e1000_write_flash_byte_ich8lan - Write a single byte to NVM
  1818. * @hw: pointer to the HW structure
  1819. * @offset: The index of the byte to read.
  1820. * @data: The byte to write to the NVM.
  1821. *
  1822. * Writes a single byte to the NVM using the flash access registers.
  1823. **/
  1824. static s32 e1000_write_flash_byte_ich8lan(struct e1000_hw *hw, u32 offset,
  1825. u8 data)
  1826. {
  1827. u16 word = (u16)data;
  1828. return e1000_write_flash_data_ich8lan(hw, offset, 1, word);
  1829. }
  1830. /**
  1831. * e1000_retry_write_flash_byte_ich8lan - Writes a single byte to NVM
  1832. * @hw: pointer to the HW structure
  1833. * @offset: The offset of the byte to write.
  1834. * @byte: The byte to write to the NVM.
  1835. *
  1836. * Writes a single byte to the NVM using the flash access registers.
  1837. * Goes through a retry algorithm before giving up.
  1838. **/
  1839. static s32 e1000_retry_write_flash_byte_ich8lan(struct e1000_hw *hw,
  1840. u32 offset, u8 byte)
  1841. {
  1842. s32 ret_val;
  1843. u16 program_retries;
  1844. ret_val = e1000_write_flash_byte_ich8lan(hw, offset, byte);
  1845. if (!ret_val)
  1846. return ret_val;
  1847. for (program_retries = 0; program_retries < 100; program_retries++) {
  1848. e_dbg("Retrying Byte %2.2X at offset %u\n", byte, offset);
  1849. udelay(100);
  1850. ret_val = e1000_write_flash_byte_ich8lan(hw, offset, byte);
  1851. if (!ret_val)
  1852. break;
  1853. }
  1854. if (program_retries == 100)
  1855. return -E1000_ERR_NVM;
  1856. return 0;
  1857. }
  1858. /**
  1859. * e1000_erase_flash_bank_ich8lan - Erase a bank (4k) from NVM
  1860. * @hw: pointer to the HW structure
  1861. * @bank: 0 for first bank, 1 for second bank, etc.
  1862. *
  1863. * Erases the bank specified. Each bank is a 4k block. Banks are 0 based.
  1864. * bank N is 4096 * N + flash_reg_addr.
  1865. **/
  1866. static s32 e1000_erase_flash_bank_ich8lan(struct e1000_hw *hw, u32 bank)
  1867. {
  1868. struct e1000_nvm_info *nvm = &hw->nvm;
  1869. union ich8_hws_flash_status hsfsts;
  1870. union ich8_hws_flash_ctrl hsflctl;
  1871. u32 flash_linear_addr;
  1872. /* bank size is in 16bit words - adjust to bytes */
  1873. u32 flash_bank_size = nvm->flash_bank_size * 2;
  1874. s32 ret_val;
  1875. s32 count = 0;
  1876. s32 j, iteration, sector_size;
  1877. hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
  1878. /*
  1879. * Determine HW Sector size: Read BERASE bits of hw flash status
  1880. * register
  1881. * 00: The Hw sector is 256 bytes, hence we need to erase 16
  1882. * consecutive sectors. The start index for the nth Hw sector
  1883. * can be calculated as = bank * 4096 + n * 256
  1884. * 01: The Hw sector is 4K bytes, hence we need to erase 1 sector.
  1885. * The start index for the nth Hw sector can be calculated
  1886. * as = bank * 4096
  1887. * 10: The Hw sector is 8K bytes, nth sector = bank * 8192
  1888. * (ich9 only, otherwise error condition)
  1889. * 11: The Hw sector is 64K bytes, nth sector = bank * 65536
  1890. */
  1891. switch (hsfsts.hsf_status.berasesz) {
  1892. case 0:
  1893. /* Hw sector size 256 */
  1894. sector_size = ICH_FLASH_SEG_SIZE_256;
  1895. iteration = flash_bank_size / ICH_FLASH_SEG_SIZE_256;
  1896. break;
  1897. case 1:
  1898. sector_size = ICH_FLASH_SEG_SIZE_4K;
  1899. iteration = 1;
  1900. break;
  1901. case 2:
  1902. sector_size = ICH_FLASH_SEG_SIZE_8K;
  1903. iteration = 1;
  1904. break;
  1905. case 3:
  1906. sector_size = ICH_FLASH_SEG_SIZE_64K;
  1907. iteration = 1;
  1908. break;
  1909. default:
  1910. return -E1000_ERR_NVM;
  1911. }
  1912. /* Start with the base address, then add the sector offset. */
  1913. flash_linear_addr = hw->nvm.flash_base_addr;
  1914. flash_linear_addr += (bank) ? flash_bank_size : 0;
  1915. for (j = 0; j < iteration ; j++) {
  1916. do {
  1917. /* Steps */
  1918. ret_val = e1000_flash_cycle_init_ich8lan(hw);
  1919. if (ret_val)
  1920. return ret_val;
  1921. /*
  1922. * Write a value 11 (block Erase) in Flash
  1923. * Cycle field in hw flash control
  1924. */
  1925. hsflctl.regval = er16flash(ICH_FLASH_HSFCTL);
  1926. hsflctl.hsf_ctrl.flcycle = ICH_CYCLE_ERASE;
  1927. ew16flash(ICH_FLASH_HSFCTL, hsflctl.regval);
  1928. /*
  1929. * Write the last 24 bits of an index within the
  1930. * block into Flash Linear address field in Flash
  1931. * Address.
  1932. */
  1933. flash_linear_addr += (j * sector_size);
  1934. ew32flash(ICH_FLASH_FADDR, flash_linear_addr);
  1935. ret_val = e1000_flash_cycle_ich8lan(hw,
  1936. ICH_FLASH_ERASE_COMMAND_TIMEOUT);
  1937. if (ret_val == 0)
  1938. break;
  1939. /*
  1940. * Check if FCERR is set to 1. If 1,
  1941. * clear it and try the whole sequence
  1942. * a few more times else Done
  1943. */
  1944. hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
  1945. if (hsfsts.hsf_status.flcerr == 1)
  1946. /* repeat for some time before giving up */
  1947. continue;
  1948. else if (hsfsts.hsf_status.flcdone == 0)
  1949. return ret_val;
  1950. } while (++count < ICH_FLASH_CYCLE_REPEAT_COUNT);
  1951. }
  1952. return 0;
  1953. }
  1954. /**
  1955. * e1000_valid_led_default_ich8lan - Set the default LED settings
  1956. * @hw: pointer to the HW structure
  1957. * @data: Pointer to the LED settings
  1958. *
  1959. * Reads the LED default settings from the NVM to data. If the NVM LED
  1960. * settings is all 0's or F's, set the LED default to a valid LED default
  1961. * setting.
  1962. **/
  1963. static s32 e1000_valid_led_default_ich8lan(struct e1000_hw *hw, u16 *data)
  1964. {
  1965. s32 ret_val;
  1966. ret_val = e1000_read_nvm(hw, NVM_ID_LED_SETTINGS, 1, data);
  1967. if (ret_val) {
  1968. e_dbg("NVM Read Error\n");
  1969. return ret_val;
  1970. }
  1971. if (*data == ID_LED_RESERVED_0000 ||
  1972. *data == ID_LED_RESERVED_FFFF)
  1973. *data = ID_LED_DEFAULT_ICH8LAN;
  1974. return 0;
  1975. }
  1976. /**
  1977. * e1000_id_led_init_pchlan - store LED configurations
  1978. * @hw: pointer to the HW structure
  1979. *
  1980. * PCH does not control LEDs via the LEDCTL register, rather it uses
  1981. * the PHY LED configuration register.
  1982. *
  1983. * PCH also does not have an "always on" or "always off" mode which
  1984. * complicates the ID feature. Instead of using the "on" mode to indicate
  1985. * in ledctl_mode2 the LEDs to use for ID (see e1000e_id_led_init()),
  1986. * use "link_up" mode. The LEDs will still ID on request if there is no
  1987. * link based on logic in e1000_led_[on|off]_pchlan().
  1988. **/
  1989. static s32 e1000_id_led_init_pchlan(struct e1000_hw *hw)
  1990. {
  1991. struct e1000_mac_info *mac = &hw->mac;
  1992. s32 ret_val;
  1993. const u32 ledctl_on = E1000_LEDCTL_MODE_LINK_UP;
  1994. const u32 ledctl_off = E1000_LEDCTL_MODE_LINK_UP | E1000_PHY_LED0_IVRT;
  1995. u16 data, i, temp, shift;
  1996. /* Get default ID LED modes */
  1997. ret_val = hw->nvm.ops.valid_led_default(hw, &data);
  1998. if (ret_val)
  1999. goto out;
  2000. mac->ledctl_default = er32(LEDCTL);
  2001. mac->ledctl_mode1 = mac->ledctl_default;
  2002. mac->ledctl_mode2 = mac->ledctl_default;
  2003. for (i = 0; i < 4; i++) {
  2004. temp = (data >> (i << 2)) & E1000_LEDCTL_LED0_MODE_MASK;
  2005. shift = (i * 5);
  2006. switch (temp) {
  2007. case ID_LED_ON1_DEF2:
  2008. case ID_LED_ON1_ON2:
  2009. case ID_LED_ON1_OFF2:
  2010. mac->ledctl_mode1 &= ~(E1000_PHY_LED0_MASK << shift);
  2011. mac->ledctl_mode1 |= (ledctl_on << shift);
  2012. break;
  2013. case ID_LED_OFF1_DEF2:
  2014. case ID_LED_OFF1_ON2:
  2015. case ID_LED_OFF1_OFF2:
  2016. mac->ledctl_mode1 &= ~(E1000_PHY_LED0_MASK << shift);
  2017. mac->ledctl_mode1 |= (ledctl_off << shift);
  2018. break;
  2019. default:
  2020. /* Do nothing */
  2021. break;
  2022. }
  2023. switch (temp) {
  2024. case ID_LED_DEF1_ON2:
  2025. case ID_LED_ON1_ON2:
  2026. case ID_LED_OFF1_ON2:
  2027. mac->ledctl_mode2 &= ~(E1000_PHY_LED0_MASK << shift);
  2028. mac->ledctl_mode2 |= (ledctl_on << shift);
  2029. break;
  2030. case ID_LED_DEF1_OFF2:
  2031. case ID_LED_ON1_OFF2:
  2032. case ID_LED_OFF1_OFF2:
  2033. mac->ledctl_mode2 &= ~(E1000_PHY_LED0_MASK << shift);
  2034. mac->ledctl_mode2 |= (ledctl_off << shift);
  2035. break;
  2036. default:
  2037. /* Do nothing */
  2038. break;
  2039. }
  2040. }
  2041. out:
  2042. return ret_val;
  2043. }
  2044. /**
  2045. * e1000_get_bus_info_ich8lan - Get/Set the bus type and width
  2046. * @hw: pointer to the HW structure
  2047. *
  2048. * ICH8 use the PCI Express bus, but does not contain a PCI Express Capability
  2049. * register, so the the bus width is hard coded.
  2050. **/
  2051. static s32 e1000_get_bus_info_ich8lan(struct e1000_hw *hw)
  2052. {
  2053. struct e1000_bus_info *bus = &hw->bus;
  2054. s32 ret_val;
  2055. ret_val = e1000e_get_bus_info_pcie(hw);
  2056. /*
  2057. * ICH devices are "PCI Express"-ish. They have
  2058. * a configuration space, but do not contain
  2059. * PCI Express Capability registers, so bus width
  2060. * must be hardcoded.
  2061. */
  2062. if (bus->width == e1000_bus_width_unknown)
  2063. bus->width = e1000_bus_width_pcie_x1;
  2064. return ret_val;
  2065. }
  2066. /**
  2067. * e1000_reset_hw_ich8lan - Reset the hardware
  2068. * @hw: pointer to the HW structure
  2069. *
  2070. * Does a full reset of the hardware which includes a reset of the PHY and
  2071. * MAC.
  2072. **/
  2073. static s32 e1000_reset_hw_ich8lan(struct e1000_hw *hw)
  2074. {
  2075. struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
  2076. u16 reg;
  2077. u32 ctrl, icr, kab;
  2078. s32 ret_val;
  2079. /*
  2080. * Prevent the PCI-E bus from sticking if there is no TLP connection
  2081. * on the last TLP read/write transaction when MAC is reset.
  2082. */
  2083. ret_val = e1000e_disable_pcie_master(hw);
  2084. if (ret_val) {
  2085. e_dbg("PCI-E Master disable polling has failed.\n");
  2086. }
  2087. e_dbg("Masking off all interrupts\n");
  2088. ew32(IMC, 0xffffffff);
  2089. /*
  2090. * Disable the Transmit and Receive units. Then delay to allow
  2091. * any pending transactions to complete before we hit the MAC
  2092. * with the global reset.
  2093. */
  2094. ew32(RCTL, 0);
  2095. ew32(TCTL, E1000_TCTL_PSP);
  2096. e1e_flush();
  2097. msleep(10);
  2098. /* Workaround for ICH8 bit corruption issue in FIFO memory */
  2099. if (hw->mac.type == e1000_ich8lan) {
  2100. /* Set Tx and Rx buffer allocation to 8k apiece. */
  2101. ew32(PBA, E1000_PBA_8K);
  2102. /* Set Packet Buffer Size to 16k. */
  2103. ew32(PBS, E1000_PBS_16K);
  2104. }
  2105. if (hw->mac.type == e1000_pchlan) {
  2106. /* Save the NVM K1 bit setting*/
  2107. ret_val = e1000_read_nvm(hw, E1000_NVM_K1_CONFIG, 1, &reg);
  2108. if (ret_val)
  2109. return ret_val;
  2110. if (reg & E1000_NVM_K1_ENABLE)
  2111. dev_spec->nvm_k1_enabled = true;
  2112. else
  2113. dev_spec->nvm_k1_enabled = false;
  2114. }
  2115. ctrl = er32(CTRL);
  2116. if (!e1000_check_reset_block(hw)) {
  2117. /* Clear PHY Reset Asserted bit */
  2118. if (hw->mac.type >= e1000_pchlan) {
  2119. u32 status = er32(STATUS);
  2120. ew32(STATUS, status & ~E1000_STATUS_PHYRA);
  2121. }
  2122. /*
  2123. * PHY HW reset requires MAC CORE reset at the same
  2124. * time to make sure the interface between MAC and the
  2125. * external PHY is reset.
  2126. */
  2127. ctrl |= E1000_CTRL_PHY_RST;
  2128. }
  2129. ret_val = e1000_acquire_swflag_ich8lan(hw);
  2130. e_dbg("Issuing a global reset to ich8lan\n");
  2131. ew32(CTRL, (ctrl | E1000_CTRL_RST));
  2132. msleep(20);
  2133. if (!ret_val)
  2134. e1000_release_swflag_ich8lan(hw);
  2135. if (ctrl & E1000_CTRL_PHY_RST)
  2136. ret_val = hw->phy.ops.get_cfg_done(hw);
  2137. if (hw->mac.type >= e1000_ich10lan) {
  2138. e1000_lan_init_done_ich8lan(hw);
  2139. } else {
  2140. ret_val = e1000e_get_auto_rd_done(hw);
  2141. if (ret_val) {
  2142. /*
  2143. * When auto config read does not complete, do not
  2144. * return with an error. This can happen in situations
  2145. * where there is no eeprom and prevents getting link.
  2146. */
  2147. e_dbg("Auto Read Done did not complete\n");
  2148. }
  2149. }
  2150. /* Dummy read to clear the phy wakeup bit after lcd reset */
  2151. if (hw->mac.type == e1000_pchlan)
  2152. e1e_rphy(hw, BM_WUC, &reg);
  2153. ret_val = e1000_sw_lcd_config_ich8lan(hw);
  2154. if (ret_val)
  2155. goto out;
  2156. if (hw->mac.type == e1000_pchlan) {
  2157. ret_val = e1000_oem_bits_config_ich8lan(hw, true);
  2158. if (ret_val)
  2159. goto out;
  2160. }
  2161. /*
  2162. * For PCH, this write will make sure that any noise
  2163. * will be detected as a CRC error and be dropped rather than show up
  2164. * as a bad packet to the DMA engine.
  2165. */
  2166. if (hw->mac.type == e1000_pchlan)
  2167. ew32(CRC_OFFSET, 0x65656565);
  2168. ew32(IMC, 0xffffffff);
  2169. icr = er32(ICR);
  2170. kab = er32(KABGTXD);
  2171. kab |= E1000_KABGTXD_BGSQLBIAS;
  2172. ew32(KABGTXD, kab);
  2173. if (hw->mac.type == e1000_pchlan)
  2174. ret_val = e1000_hv_phy_workarounds_ich8lan(hw);
  2175. out:
  2176. return ret_val;
  2177. }
  2178. /**
  2179. * e1000_init_hw_ich8lan - Initialize the hardware
  2180. * @hw: pointer to the HW structure
  2181. *
  2182. * Prepares the hardware for transmit and receive by doing the following:
  2183. * - initialize hardware bits
  2184. * - initialize LED identification
  2185. * - setup receive address registers
  2186. * - setup flow control
  2187. * - setup transmit descriptors
  2188. * - clear statistics
  2189. **/
  2190. static s32 e1000_init_hw_ich8lan(struct e1000_hw *hw)
  2191. {
  2192. struct e1000_mac_info *mac = &hw->mac;
  2193. u32 ctrl_ext, txdctl, snoop;
  2194. s32 ret_val;
  2195. u16 i;
  2196. e1000_initialize_hw_bits_ich8lan(hw);
  2197. /* Initialize identification LED */
  2198. ret_val = mac->ops.id_led_init(hw);
  2199. if (ret_val)
  2200. e_dbg("Error initializing identification LED\n");
  2201. /* This is not fatal and we should not stop init due to this */
  2202. /* Setup the receive address. */
  2203. e1000e_init_rx_addrs(hw, mac->rar_entry_count);
  2204. /* Zero out the Multicast HASH table */
  2205. e_dbg("Zeroing the MTA\n");
  2206. for (i = 0; i < mac->mta_reg_count; i++)
  2207. E1000_WRITE_REG_ARRAY(hw, E1000_MTA, i, 0);
  2208. /*
  2209. * The 82578 Rx buffer will stall if wakeup is enabled in host and
  2210. * the ME. Reading the BM_WUC register will clear the host wakeup bit.
  2211. * Reset the phy after disabling host wakeup to reset the Rx buffer.
  2212. */
  2213. if (hw->phy.type == e1000_phy_82578) {
  2214. hw->phy.ops.read_reg(hw, BM_WUC, &i);
  2215. ret_val = e1000_phy_hw_reset_ich8lan(hw);
  2216. if (ret_val)
  2217. return ret_val;
  2218. }
  2219. /* Setup link and flow control */
  2220. ret_val = e1000_setup_link_ich8lan(hw);
  2221. /* Set the transmit descriptor write-back policy for both queues */
  2222. txdctl = er32(TXDCTL(0));
  2223. txdctl = (txdctl & ~E1000_TXDCTL_WTHRESH) |
  2224. E1000_TXDCTL_FULL_TX_DESC_WB;
  2225. txdctl = (txdctl & ~E1000_TXDCTL_PTHRESH) |
  2226. E1000_TXDCTL_MAX_TX_DESC_PREFETCH;
  2227. ew32(TXDCTL(0), txdctl);
  2228. txdctl = er32(TXDCTL(1));
  2229. txdctl = (txdctl & ~E1000_TXDCTL_WTHRESH) |
  2230. E1000_TXDCTL_FULL_TX_DESC_WB;
  2231. txdctl = (txdctl & ~E1000_TXDCTL_PTHRESH) |
  2232. E1000_TXDCTL_MAX_TX_DESC_PREFETCH;
  2233. ew32(TXDCTL(1), txdctl);
  2234. /*
  2235. * ICH8 has opposite polarity of no_snoop bits.
  2236. * By default, we should use snoop behavior.
  2237. */
  2238. if (mac->type == e1000_ich8lan)
  2239. snoop = PCIE_ICH8_SNOOP_ALL;
  2240. else
  2241. snoop = (u32) ~(PCIE_NO_SNOOP_ALL);
  2242. e1000e_set_pcie_no_snoop(hw, snoop);
  2243. ctrl_ext = er32(CTRL_EXT);
  2244. ctrl_ext |= E1000_CTRL_EXT_RO_DIS;
  2245. ew32(CTRL_EXT, ctrl_ext);
  2246. /*
  2247. * Clear all of the statistics registers (clear on read). It is
  2248. * important that we do this after we have tried to establish link
  2249. * because the symbol error count will increment wildly if there
  2250. * is no link.
  2251. */
  2252. e1000_clear_hw_cntrs_ich8lan(hw);
  2253. return 0;
  2254. }
  2255. /**
  2256. * e1000_initialize_hw_bits_ich8lan - Initialize required hardware bits
  2257. * @hw: pointer to the HW structure
  2258. *
  2259. * Sets/Clears required hardware bits necessary for correctly setting up the
  2260. * hardware for transmit and receive.
  2261. **/
  2262. static void e1000_initialize_hw_bits_ich8lan(struct e1000_hw *hw)
  2263. {
  2264. u32 reg;
  2265. /* Extended Device Control */
  2266. reg = er32(CTRL_EXT);
  2267. reg |= (1 << 22);
  2268. /* Enable PHY low-power state when MAC is at D3 w/o WoL */
  2269. if (hw->mac.type >= e1000_pchlan)
  2270. reg |= E1000_CTRL_EXT_PHYPDEN;
  2271. ew32(CTRL_EXT, reg);
  2272. /* Transmit Descriptor Control 0 */
  2273. reg = er32(TXDCTL(0));
  2274. reg |= (1 << 22);
  2275. ew32(TXDCTL(0), reg);
  2276. /* Transmit Descriptor Control 1 */
  2277. reg = er32(TXDCTL(1));
  2278. reg |= (1 << 22);
  2279. ew32(TXDCTL(1), reg);
  2280. /* Transmit Arbitration Control 0 */
  2281. reg = er32(TARC(0));
  2282. if (hw->mac.type == e1000_ich8lan)
  2283. reg |= (1 << 28) | (1 << 29);
  2284. reg |= (1 << 23) | (1 << 24) | (1 << 26) | (1 << 27);
  2285. ew32(TARC(0), reg);
  2286. /* Transmit Arbitration Control 1 */
  2287. reg = er32(TARC(1));
  2288. if (er32(TCTL) & E1000_TCTL_MULR)
  2289. reg &= ~(1 << 28);
  2290. else
  2291. reg |= (1 << 28);
  2292. reg |= (1 << 24) | (1 << 26) | (1 << 30);
  2293. ew32(TARC(1), reg);
  2294. /* Device Status */
  2295. if (hw->mac.type == e1000_ich8lan) {
  2296. reg = er32(STATUS);
  2297. reg &= ~(1 << 31);
  2298. ew32(STATUS, reg);
  2299. }
  2300. }
  2301. /**
  2302. * e1000_setup_link_ich8lan - Setup flow control and link settings
  2303. * @hw: pointer to the HW structure
  2304. *
  2305. * Determines which flow control settings to use, then configures flow
  2306. * control. Calls the appropriate media-specific link configuration
  2307. * function. Assuming the adapter has a valid link partner, a valid link
  2308. * should be established. Assumes the hardware has previously been reset
  2309. * and the transmitter and receiver are not enabled.
  2310. **/
  2311. static s32 e1000_setup_link_ich8lan(struct e1000_hw *hw)
  2312. {
  2313. s32 ret_val;
  2314. if (e1000_check_reset_block(hw))
  2315. return 0;
  2316. /*
  2317. * ICH parts do not have a word in the NVM to determine
  2318. * the default flow control setting, so we explicitly
  2319. * set it to full.
  2320. */
  2321. if (hw->fc.requested_mode == e1000_fc_default) {
  2322. /* Workaround h/w hang when Tx flow control enabled */
  2323. if (hw->mac.type == e1000_pchlan)
  2324. hw->fc.requested_mode = e1000_fc_rx_pause;
  2325. else
  2326. hw->fc.requested_mode = e1000_fc_full;
  2327. }
  2328. /*
  2329. * Save off the requested flow control mode for use later. Depending
  2330. * on the link partner's capabilities, we may or may not use this mode.
  2331. */
  2332. hw->fc.current_mode = hw->fc.requested_mode;
  2333. e_dbg("After fix-ups FlowControl is now = %x\n",
  2334. hw->fc.current_mode);
  2335. /* Continue to configure the copper link. */
  2336. ret_val = e1000_setup_copper_link_ich8lan(hw);
  2337. if (ret_val)
  2338. return ret_val;
  2339. ew32(FCTTV, hw->fc.pause_time);
  2340. if ((hw->phy.type == e1000_phy_82578) ||
  2341. (hw->phy.type == e1000_phy_82577)) {
  2342. ret_val = hw->phy.ops.write_reg(hw,
  2343. PHY_REG(BM_PORT_CTRL_PAGE, 27),
  2344. hw->fc.pause_time);
  2345. if (ret_val)
  2346. return ret_val;
  2347. }
  2348. return e1000e_set_fc_watermarks(hw);
  2349. }
  2350. /**
  2351. * e1000_setup_copper_link_ich8lan - Configure MAC/PHY interface
  2352. * @hw: pointer to the HW structure
  2353. *
  2354. * Configures the kumeran interface to the PHY to wait the appropriate time
  2355. * when polling the PHY, then call the generic setup_copper_link to finish
  2356. * configuring the copper link.
  2357. **/
  2358. static s32 e1000_setup_copper_link_ich8lan(struct e1000_hw *hw)
  2359. {
  2360. u32 ctrl;
  2361. s32 ret_val;
  2362. u16 reg_data;
  2363. ctrl = er32(CTRL);
  2364. ctrl |= E1000_CTRL_SLU;
  2365. ctrl &= ~(E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX);
  2366. ew32(CTRL, ctrl);
  2367. /*
  2368. * Set the mac to wait the maximum time between each iteration
  2369. * and increase the max iterations when polling the phy;
  2370. * this fixes erroneous timeouts at 10Mbps.
  2371. */
  2372. ret_val = e1000e_write_kmrn_reg(hw, E1000_KMRNCTRLSTA_TIMEOUTS, 0xFFFF);
  2373. if (ret_val)
  2374. return ret_val;
  2375. ret_val = e1000e_read_kmrn_reg(hw, E1000_KMRNCTRLSTA_INBAND_PARAM,
  2376. &reg_data);
  2377. if (ret_val)
  2378. return ret_val;
  2379. reg_data |= 0x3F;
  2380. ret_val = e1000e_write_kmrn_reg(hw, E1000_KMRNCTRLSTA_INBAND_PARAM,
  2381. reg_data);
  2382. if (ret_val)
  2383. return ret_val;
  2384. switch (hw->phy.type) {
  2385. case e1000_phy_igp_3:
  2386. ret_val = e1000e_copper_link_setup_igp(hw);
  2387. if (ret_val)
  2388. return ret_val;
  2389. break;
  2390. case e1000_phy_bm:
  2391. case e1000_phy_82578:
  2392. ret_val = e1000e_copper_link_setup_m88(hw);
  2393. if (ret_val)
  2394. return ret_val;
  2395. break;
  2396. case e1000_phy_82577:
  2397. ret_val = e1000_copper_link_setup_82577(hw);
  2398. if (ret_val)
  2399. return ret_val;
  2400. break;
  2401. case e1000_phy_ife:
  2402. ret_val = hw->phy.ops.read_reg(hw, IFE_PHY_MDIX_CONTROL,
  2403. &reg_data);
  2404. if (ret_val)
  2405. return ret_val;
  2406. reg_data &= ~IFE_PMC_AUTO_MDIX;
  2407. switch (hw->phy.mdix) {
  2408. case 1:
  2409. reg_data &= ~IFE_PMC_FORCE_MDIX;
  2410. break;
  2411. case 2:
  2412. reg_data |= IFE_PMC_FORCE_MDIX;
  2413. break;
  2414. case 0:
  2415. default:
  2416. reg_data |= IFE_PMC_AUTO_MDIX;
  2417. break;
  2418. }
  2419. ret_val = hw->phy.ops.write_reg(hw, IFE_PHY_MDIX_CONTROL,
  2420. reg_data);
  2421. if (ret_val)
  2422. return ret_val;
  2423. break;
  2424. default:
  2425. break;
  2426. }
  2427. return e1000e_setup_copper_link(hw);
  2428. }
  2429. /**
  2430. * e1000_get_link_up_info_ich8lan - Get current link speed and duplex
  2431. * @hw: pointer to the HW structure
  2432. * @speed: pointer to store current link speed
  2433. * @duplex: pointer to store the current link duplex
  2434. *
  2435. * Calls the generic get_speed_and_duplex to retrieve the current link
  2436. * information and then calls the Kumeran lock loss workaround for links at
  2437. * gigabit speeds.
  2438. **/
  2439. static s32 e1000_get_link_up_info_ich8lan(struct e1000_hw *hw, u16 *speed,
  2440. u16 *duplex)
  2441. {
  2442. s32 ret_val;
  2443. ret_val = e1000e_get_speed_and_duplex_copper(hw, speed, duplex);
  2444. if (ret_val)
  2445. return ret_val;
  2446. if ((hw->mac.type == e1000_ich8lan) &&
  2447. (hw->phy.type == e1000_phy_igp_3) &&
  2448. (*speed == SPEED_1000)) {
  2449. ret_val = e1000_kmrn_lock_loss_workaround_ich8lan(hw);
  2450. }
  2451. return ret_val;
  2452. }
  2453. /**
  2454. * e1000_kmrn_lock_loss_workaround_ich8lan - Kumeran workaround
  2455. * @hw: pointer to the HW structure
  2456. *
  2457. * Work-around for 82566 Kumeran PCS lock loss:
  2458. * On link status change (i.e. PCI reset, speed change) and link is up and
  2459. * speed is gigabit-
  2460. * 0) if workaround is optionally disabled do nothing
  2461. * 1) wait 1ms for Kumeran link to come up
  2462. * 2) check Kumeran Diagnostic register PCS lock loss bit
  2463. * 3) if not set the link is locked (all is good), otherwise...
  2464. * 4) reset the PHY
  2465. * 5) repeat up to 10 times
  2466. * Note: this is only called for IGP3 copper when speed is 1gb.
  2467. **/
  2468. static s32 e1000_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw *hw)
  2469. {
  2470. struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
  2471. u32 phy_ctrl;
  2472. s32 ret_val;
  2473. u16 i, data;
  2474. bool link;
  2475. if (!dev_spec->kmrn_lock_loss_workaround_enabled)
  2476. return 0;
  2477. /*
  2478. * Make sure link is up before proceeding. If not just return.
  2479. * Attempting this while link is negotiating fouled up link
  2480. * stability
  2481. */
  2482. ret_val = e1000e_phy_has_link_generic(hw, 1, 0, &link);
  2483. if (!link)
  2484. return 0;
  2485. for (i = 0; i < 10; i++) {
  2486. /* read once to clear */
  2487. ret_val = e1e_rphy(hw, IGP3_KMRN_DIAG, &data);
  2488. if (ret_val)
  2489. return ret_val;
  2490. /* and again to get new status */
  2491. ret_val = e1e_rphy(hw, IGP3_KMRN_DIAG, &data);
  2492. if (ret_val)
  2493. return ret_val;
  2494. /* check for PCS lock */
  2495. if (!(data & IGP3_KMRN_DIAG_PCS_LOCK_LOSS))
  2496. return 0;
  2497. /* Issue PHY reset */
  2498. e1000_phy_hw_reset(hw);
  2499. mdelay(5);
  2500. }
  2501. /* Disable GigE link negotiation */
  2502. phy_ctrl = er32(PHY_CTRL);
  2503. phy_ctrl |= (E1000_PHY_CTRL_GBE_DISABLE |
  2504. E1000_PHY_CTRL_NOND0A_GBE_DISABLE);
  2505. ew32(PHY_CTRL, phy_ctrl);
  2506. /*
  2507. * Call gig speed drop workaround on Gig disable before accessing
  2508. * any PHY registers
  2509. */
  2510. e1000e_gig_downshift_workaround_ich8lan(hw);
  2511. /* unable to acquire PCS lock */
  2512. return -E1000_ERR_PHY;
  2513. }
  2514. /**
  2515. * e1000_set_kmrn_lock_loss_workaround_ich8lan - Set Kumeran workaround state
  2516. * @hw: pointer to the HW structure
  2517. * @state: boolean value used to set the current Kumeran workaround state
  2518. *
  2519. * If ICH8, set the current Kumeran workaround state (enabled - true
  2520. * /disabled - false).
  2521. **/
  2522. void e1000e_set_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw *hw,
  2523. bool state)
  2524. {
  2525. struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
  2526. if (hw->mac.type != e1000_ich8lan) {
  2527. e_dbg("Workaround applies to ICH8 only.\n");
  2528. return;
  2529. }
  2530. dev_spec->kmrn_lock_loss_workaround_enabled = state;
  2531. }
  2532. /**
  2533. * e1000_ipg3_phy_powerdown_workaround_ich8lan - Power down workaround on D3
  2534. * @hw: pointer to the HW structure
  2535. *
  2536. * Workaround for 82566 power-down on D3 entry:
  2537. * 1) disable gigabit link
  2538. * 2) write VR power-down enable
  2539. * 3) read it back
  2540. * Continue if successful, else issue LCD reset and repeat
  2541. **/
  2542. void e1000e_igp3_phy_powerdown_workaround_ich8lan(struct e1000_hw *hw)
  2543. {
  2544. u32 reg;
  2545. u16 data;
  2546. u8 retry = 0;
  2547. if (hw->phy.type != e1000_phy_igp_3)
  2548. return;
  2549. /* Try the workaround twice (if needed) */
  2550. do {
  2551. /* Disable link */
  2552. reg = er32(PHY_CTRL);
  2553. reg |= (E1000_PHY_CTRL_GBE_DISABLE |
  2554. E1000_PHY_CTRL_NOND0A_GBE_DISABLE);
  2555. ew32(PHY_CTRL, reg);
  2556. /*
  2557. * Call gig speed drop workaround on Gig disable before
  2558. * accessing any PHY registers
  2559. */
  2560. if (hw->mac.type == e1000_ich8lan)
  2561. e1000e_gig_downshift_workaround_ich8lan(hw);
  2562. /* Write VR power-down enable */
  2563. e1e_rphy(hw, IGP3_VR_CTRL, &data);
  2564. data &= ~IGP3_VR_CTRL_DEV_POWERDOWN_MODE_MASK;
  2565. e1e_wphy(hw, IGP3_VR_CTRL, data | IGP3_VR_CTRL_MODE_SHUTDOWN);
  2566. /* Read it back and test */
  2567. e1e_rphy(hw, IGP3_VR_CTRL, &data);
  2568. data &= IGP3_VR_CTRL_DEV_POWERDOWN_MODE_MASK;
  2569. if ((data == IGP3_VR_CTRL_MODE_SHUTDOWN) || retry)
  2570. break;
  2571. /* Issue PHY reset and repeat at most one more time */
  2572. reg = er32(CTRL);
  2573. ew32(CTRL, reg | E1000_CTRL_PHY_RST);
  2574. retry++;
  2575. } while (retry);
  2576. }
  2577. /**
  2578. * e1000e_gig_downshift_workaround_ich8lan - WoL from S5 stops working
  2579. * @hw: pointer to the HW structure
  2580. *
  2581. * Steps to take when dropping from 1Gb/s (eg. link cable removal (LSC),
  2582. * LPLU, Gig disable, MDIC PHY reset):
  2583. * 1) Set Kumeran Near-end loopback
  2584. * 2) Clear Kumeran Near-end loopback
  2585. * Should only be called for ICH8[m] devices with IGP_3 Phy.
  2586. **/
  2587. void e1000e_gig_downshift_workaround_ich8lan(struct e1000_hw *hw)
  2588. {
  2589. s32 ret_val;
  2590. u16 reg_data;
  2591. if ((hw->mac.type != e1000_ich8lan) ||
  2592. (hw->phy.type != e1000_phy_igp_3))
  2593. return;
  2594. ret_val = e1000e_read_kmrn_reg(hw, E1000_KMRNCTRLSTA_DIAG_OFFSET,
  2595. &reg_data);
  2596. if (ret_val)
  2597. return;
  2598. reg_data |= E1000_KMRNCTRLSTA_DIAG_NELPBK;
  2599. ret_val = e1000e_write_kmrn_reg(hw, E1000_KMRNCTRLSTA_DIAG_OFFSET,
  2600. reg_data);
  2601. if (ret_val)
  2602. return;
  2603. reg_data &= ~E1000_KMRNCTRLSTA_DIAG_NELPBK;
  2604. ret_val = e1000e_write_kmrn_reg(hw, E1000_KMRNCTRLSTA_DIAG_OFFSET,
  2605. reg_data);
  2606. }
  2607. /**
  2608. * e1000e_disable_gig_wol_ich8lan - disable gig during WoL
  2609. * @hw: pointer to the HW structure
  2610. *
  2611. * During S0 to Sx transition, it is possible the link remains at gig
  2612. * instead of negotiating to a lower speed. Before going to Sx, set
  2613. * 'LPLU Enabled' and 'Gig Disable' to force link speed negotiation
  2614. * to a lower speed.
  2615. *
  2616. * Should only be called for applicable parts.
  2617. **/
  2618. void e1000e_disable_gig_wol_ich8lan(struct e1000_hw *hw)
  2619. {
  2620. u32 phy_ctrl;
  2621. switch (hw->mac.type) {
  2622. case e1000_ich8lan:
  2623. case e1000_ich9lan:
  2624. case e1000_ich10lan:
  2625. case e1000_pchlan:
  2626. phy_ctrl = er32(PHY_CTRL);
  2627. phy_ctrl |= E1000_PHY_CTRL_D0A_LPLU |
  2628. E1000_PHY_CTRL_GBE_DISABLE;
  2629. ew32(PHY_CTRL, phy_ctrl);
  2630. if (hw->mac.type == e1000_pchlan)
  2631. e1000_phy_hw_reset_ich8lan(hw);
  2632. default:
  2633. break;
  2634. }
  2635. return;
  2636. }
  2637. /**
  2638. * e1000_cleanup_led_ich8lan - Restore the default LED operation
  2639. * @hw: pointer to the HW structure
  2640. *
  2641. * Return the LED back to the default configuration.
  2642. **/
  2643. static s32 e1000_cleanup_led_ich8lan(struct e1000_hw *hw)
  2644. {
  2645. if (hw->phy.type == e1000_phy_ife)
  2646. return e1e_wphy(hw, IFE_PHY_SPECIAL_CONTROL_LED, 0);
  2647. ew32(LEDCTL, hw->mac.ledctl_default);
  2648. return 0;
  2649. }
  2650. /**
  2651. * e1000_led_on_ich8lan - Turn LEDs on
  2652. * @hw: pointer to the HW structure
  2653. *
  2654. * Turn on the LEDs.
  2655. **/
  2656. static s32 e1000_led_on_ich8lan(struct e1000_hw *hw)
  2657. {
  2658. if (hw->phy.type == e1000_phy_ife)
  2659. return e1e_wphy(hw, IFE_PHY_SPECIAL_CONTROL_LED,
  2660. (IFE_PSCL_PROBE_MODE | IFE_PSCL_PROBE_LEDS_ON));
  2661. ew32(LEDCTL, hw->mac.ledctl_mode2);
  2662. return 0;
  2663. }
  2664. /**
  2665. * e1000_led_off_ich8lan - Turn LEDs off
  2666. * @hw: pointer to the HW structure
  2667. *
  2668. * Turn off the LEDs.
  2669. **/
  2670. static s32 e1000_led_off_ich8lan(struct e1000_hw *hw)
  2671. {
  2672. if (hw->phy.type == e1000_phy_ife)
  2673. return e1e_wphy(hw, IFE_PHY_SPECIAL_CONTROL_LED,
  2674. (IFE_PSCL_PROBE_MODE | IFE_PSCL_PROBE_LEDS_OFF));
  2675. ew32(LEDCTL, hw->mac.ledctl_mode1);
  2676. return 0;
  2677. }
  2678. /**
  2679. * e1000_setup_led_pchlan - Configures SW controllable LED
  2680. * @hw: pointer to the HW structure
  2681. *
  2682. * This prepares the SW controllable LED for use.
  2683. **/
  2684. static s32 e1000_setup_led_pchlan(struct e1000_hw *hw)
  2685. {
  2686. return hw->phy.ops.write_reg(hw, HV_LED_CONFIG,
  2687. (u16)hw->mac.ledctl_mode1);
  2688. }
  2689. /**
  2690. * e1000_cleanup_led_pchlan - Restore the default LED operation
  2691. * @hw: pointer to the HW structure
  2692. *
  2693. * Return the LED back to the default configuration.
  2694. **/
  2695. static s32 e1000_cleanup_led_pchlan(struct e1000_hw *hw)
  2696. {
  2697. return hw->phy.ops.write_reg(hw, HV_LED_CONFIG,
  2698. (u16)hw->mac.ledctl_default);
  2699. }
  2700. /**
  2701. * e1000_led_on_pchlan - Turn LEDs on
  2702. * @hw: pointer to the HW structure
  2703. *
  2704. * Turn on the LEDs.
  2705. **/
  2706. static s32 e1000_led_on_pchlan(struct e1000_hw *hw)
  2707. {
  2708. u16 data = (u16)hw->mac.ledctl_mode2;
  2709. u32 i, led;
  2710. /*
  2711. * If no link, then turn LED on by setting the invert bit
  2712. * for each LED that's mode is "link_up" in ledctl_mode2.
  2713. */
  2714. if (!(er32(STATUS) & E1000_STATUS_LU)) {
  2715. for (i = 0; i < 3; i++) {
  2716. led = (data >> (i * 5)) & E1000_PHY_LED0_MASK;
  2717. if ((led & E1000_PHY_LED0_MODE_MASK) !=
  2718. E1000_LEDCTL_MODE_LINK_UP)
  2719. continue;
  2720. if (led & E1000_PHY_LED0_IVRT)
  2721. data &= ~(E1000_PHY_LED0_IVRT << (i * 5));
  2722. else
  2723. data |= (E1000_PHY_LED0_IVRT << (i * 5));
  2724. }
  2725. }
  2726. return hw->phy.ops.write_reg(hw, HV_LED_CONFIG, data);
  2727. }
  2728. /**
  2729. * e1000_led_off_pchlan - Turn LEDs off
  2730. * @hw: pointer to the HW structure
  2731. *
  2732. * Turn off the LEDs.
  2733. **/
  2734. static s32 e1000_led_off_pchlan(struct e1000_hw *hw)
  2735. {
  2736. u16 data = (u16)hw->mac.ledctl_mode1;
  2737. u32 i, led;
  2738. /*
  2739. * If no link, then turn LED off by clearing the invert bit
  2740. * for each LED that's mode is "link_up" in ledctl_mode1.
  2741. */
  2742. if (!(er32(STATUS) & E1000_STATUS_LU)) {
  2743. for (i = 0; i < 3; i++) {
  2744. led = (data >> (i * 5)) & E1000_PHY_LED0_MASK;
  2745. if ((led & E1000_PHY_LED0_MODE_MASK) !=
  2746. E1000_LEDCTL_MODE_LINK_UP)
  2747. continue;
  2748. if (led & E1000_PHY_LED0_IVRT)
  2749. data &= ~(E1000_PHY_LED0_IVRT << (i * 5));
  2750. else
  2751. data |= (E1000_PHY_LED0_IVRT << (i * 5));
  2752. }
  2753. }
  2754. return hw->phy.ops.write_reg(hw, HV_LED_CONFIG, data);
  2755. }
  2756. /**
  2757. * e1000_get_cfg_done_ich8lan - Read config done bit
  2758. * @hw: pointer to the HW structure
  2759. *
  2760. * Read the management control register for the config done bit for
  2761. * completion status. NOTE: silicon which is EEPROM-less will fail trying
  2762. * to read the config done bit, so an error is *ONLY* logged and returns
  2763. * 0. If we were to return with error, EEPROM-less silicon
  2764. * would not be able to be reset or change link.
  2765. **/
  2766. static s32 e1000_get_cfg_done_ich8lan(struct e1000_hw *hw)
  2767. {
  2768. u32 bank = 0;
  2769. if (hw->mac.type >= e1000_pchlan) {
  2770. u32 status = er32(STATUS);
  2771. if (status & E1000_STATUS_PHYRA)
  2772. ew32(STATUS, status & ~E1000_STATUS_PHYRA);
  2773. else
  2774. e_dbg("PHY Reset Asserted not set - needs delay\n");
  2775. }
  2776. e1000e_get_cfg_done(hw);
  2777. /* If EEPROM is not marked present, init the IGP 3 PHY manually */
  2778. if ((hw->mac.type != e1000_ich10lan) &&
  2779. (hw->mac.type != e1000_pchlan)) {
  2780. if (((er32(EECD) & E1000_EECD_PRES) == 0) &&
  2781. (hw->phy.type == e1000_phy_igp_3)) {
  2782. e1000e_phy_init_script_igp3(hw);
  2783. }
  2784. } else {
  2785. if (e1000_valid_nvm_bank_detect_ich8lan(hw, &bank)) {
  2786. /* Maybe we should do a basic PHY config */
  2787. e_dbg("EEPROM not present\n");
  2788. return -E1000_ERR_CONFIG;
  2789. }
  2790. }
  2791. return 0;
  2792. }
  2793. /**
  2794. * e1000_power_down_phy_copper_ich8lan - Remove link during PHY power down
  2795. * @hw: pointer to the HW structure
  2796. *
  2797. * In the case of a PHY power down to save power, or to turn off link during a
  2798. * driver unload, or wake on lan is not enabled, remove the link.
  2799. **/
  2800. static void e1000_power_down_phy_copper_ich8lan(struct e1000_hw *hw)
  2801. {
  2802. /* If the management interface is not enabled, then power down */
  2803. if (!(hw->mac.ops.check_mng_mode(hw) ||
  2804. hw->phy.ops.check_reset_block(hw)))
  2805. e1000_power_down_phy_copper(hw);
  2806. return;
  2807. }
  2808. /**
  2809. * e1000_clear_hw_cntrs_ich8lan - Clear statistical counters
  2810. * @hw: pointer to the HW structure
  2811. *
  2812. * Clears hardware counters specific to the silicon family and calls
  2813. * clear_hw_cntrs_generic to clear all general purpose counters.
  2814. **/
  2815. static void e1000_clear_hw_cntrs_ich8lan(struct e1000_hw *hw)
  2816. {
  2817. u16 phy_data;
  2818. e1000e_clear_hw_cntrs_base(hw);
  2819. er32(ALGNERRC);
  2820. er32(RXERRC);
  2821. er32(TNCRS);
  2822. er32(CEXTERR);
  2823. er32(TSCTC);
  2824. er32(TSCTFC);
  2825. er32(MGTPRC);
  2826. er32(MGTPDC);
  2827. er32(MGTPTC);
  2828. er32(IAC);
  2829. er32(ICRXOC);
  2830. /* Clear PHY statistics registers */
  2831. if ((hw->phy.type == e1000_phy_82578) ||
  2832. (hw->phy.type == e1000_phy_82577)) {
  2833. hw->phy.ops.read_reg(hw, HV_SCC_UPPER, &phy_data);
  2834. hw->phy.ops.read_reg(hw, HV_SCC_LOWER, &phy_data);
  2835. hw->phy.ops.read_reg(hw, HV_ECOL_UPPER, &phy_data);
  2836. hw->phy.ops.read_reg(hw, HV_ECOL_LOWER, &phy_data);
  2837. hw->phy.ops.read_reg(hw, HV_MCC_UPPER, &phy_data);
  2838. hw->phy.ops.read_reg(hw, HV_MCC_LOWER, &phy_data);
  2839. hw->phy.ops.read_reg(hw, HV_LATECOL_UPPER, &phy_data);
  2840. hw->phy.ops.read_reg(hw, HV_LATECOL_LOWER, &phy_data);
  2841. hw->phy.ops.read_reg(hw, HV_COLC_UPPER, &phy_data);
  2842. hw->phy.ops.read_reg(hw, HV_COLC_LOWER, &phy_data);
  2843. hw->phy.ops.read_reg(hw, HV_DC_UPPER, &phy_data);
  2844. hw->phy.ops.read_reg(hw, HV_DC_LOWER, &phy_data);
  2845. hw->phy.ops.read_reg(hw, HV_TNCRS_UPPER, &phy_data);
  2846. hw->phy.ops.read_reg(hw, HV_TNCRS_LOWER, &phy_data);
  2847. }
  2848. }
  2849. static struct e1000_mac_operations ich8_mac_ops = {
  2850. .id_led_init = e1000e_id_led_init,
  2851. .check_mng_mode = e1000_check_mng_mode_ich8lan,
  2852. .check_for_link = e1000_check_for_copper_link_ich8lan,
  2853. /* cleanup_led dependent on mac type */
  2854. .clear_hw_cntrs = e1000_clear_hw_cntrs_ich8lan,
  2855. .get_bus_info = e1000_get_bus_info_ich8lan,
  2856. .get_link_up_info = e1000_get_link_up_info_ich8lan,
  2857. /* led_on dependent on mac type */
  2858. /* led_off dependent on mac type */
  2859. .update_mc_addr_list = e1000e_update_mc_addr_list_generic,
  2860. .reset_hw = e1000_reset_hw_ich8lan,
  2861. .init_hw = e1000_init_hw_ich8lan,
  2862. .setup_link = e1000_setup_link_ich8lan,
  2863. .setup_physical_interface= e1000_setup_copper_link_ich8lan,
  2864. /* id_led_init dependent on mac type */
  2865. };
  2866. static struct e1000_phy_operations ich8_phy_ops = {
  2867. .acquire = e1000_acquire_swflag_ich8lan,
  2868. .check_reset_block = e1000_check_reset_block_ich8lan,
  2869. .commit = NULL,
  2870. .get_cfg_done = e1000_get_cfg_done_ich8lan,
  2871. .get_cable_length = e1000e_get_cable_length_igp_2,
  2872. .read_reg = e1000e_read_phy_reg_igp,
  2873. .release = e1000_release_swflag_ich8lan,
  2874. .reset = e1000_phy_hw_reset_ich8lan,
  2875. .set_d0_lplu_state = e1000_set_d0_lplu_state_ich8lan,
  2876. .set_d3_lplu_state = e1000_set_d3_lplu_state_ich8lan,
  2877. .write_reg = e1000e_write_phy_reg_igp,
  2878. };
  2879. static struct e1000_nvm_operations ich8_nvm_ops = {
  2880. .acquire = e1000_acquire_nvm_ich8lan,
  2881. .read = e1000_read_nvm_ich8lan,
  2882. .release = e1000_release_nvm_ich8lan,
  2883. .update = e1000_update_nvm_checksum_ich8lan,
  2884. .valid_led_default = e1000_valid_led_default_ich8lan,
  2885. .validate = e1000_validate_nvm_checksum_ich8lan,
  2886. .write = e1000_write_nvm_ich8lan,
  2887. };
  2888. struct e1000_info e1000_ich8_info = {
  2889. .mac = e1000_ich8lan,
  2890. .flags = FLAG_HAS_WOL
  2891. | FLAG_IS_ICH
  2892. | FLAG_RX_CSUM_ENABLED
  2893. | FLAG_HAS_CTRLEXT_ON_LOAD
  2894. | FLAG_HAS_AMT
  2895. | FLAG_HAS_FLASH
  2896. | FLAG_APME_IN_WUC,
  2897. .pba = 8,
  2898. .max_hw_frame_size = ETH_FRAME_LEN + ETH_FCS_LEN,
  2899. .get_variants = e1000_get_variants_ich8lan,
  2900. .mac_ops = &ich8_mac_ops,
  2901. .phy_ops = &ich8_phy_ops,
  2902. .nvm_ops = &ich8_nvm_ops,
  2903. };
  2904. struct e1000_info e1000_ich9_info = {
  2905. .mac = e1000_ich9lan,
  2906. .flags = FLAG_HAS_JUMBO_FRAMES
  2907. | FLAG_IS_ICH
  2908. | FLAG_HAS_WOL
  2909. | FLAG_RX_CSUM_ENABLED
  2910. | FLAG_HAS_CTRLEXT_ON_LOAD
  2911. | FLAG_HAS_AMT
  2912. | FLAG_HAS_ERT
  2913. | FLAG_HAS_FLASH
  2914. | FLAG_APME_IN_WUC,
  2915. .pba = 10,
  2916. .max_hw_frame_size = DEFAULT_JUMBO,
  2917. .get_variants = e1000_get_variants_ich8lan,
  2918. .mac_ops = &ich8_mac_ops,
  2919. .phy_ops = &ich8_phy_ops,
  2920. .nvm_ops = &ich8_nvm_ops,
  2921. };
  2922. struct e1000_info e1000_ich10_info = {
  2923. .mac = e1000_ich10lan,
  2924. .flags = FLAG_HAS_JUMBO_FRAMES
  2925. | FLAG_IS_ICH
  2926. | FLAG_HAS_WOL
  2927. | FLAG_RX_CSUM_ENABLED
  2928. | FLAG_HAS_CTRLEXT_ON_LOAD
  2929. | FLAG_HAS_AMT
  2930. | FLAG_HAS_ERT
  2931. | FLAG_HAS_FLASH
  2932. | FLAG_APME_IN_WUC,
  2933. .pba = 10,
  2934. .max_hw_frame_size = DEFAULT_JUMBO,
  2935. .get_variants = e1000_get_variants_ich8lan,
  2936. .mac_ops = &ich8_mac_ops,
  2937. .phy_ops = &ich8_phy_ops,
  2938. .nvm_ops = &ich8_nvm_ops,
  2939. };
  2940. struct e1000_info e1000_pch_info = {
  2941. .mac = e1000_pchlan,
  2942. .flags = FLAG_IS_ICH
  2943. | FLAG_HAS_WOL
  2944. | FLAG_RX_CSUM_ENABLED
  2945. | FLAG_HAS_CTRLEXT_ON_LOAD
  2946. | FLAG_HAS_AMT
  2947. | FLAG_HAS_FLASH
  2948. | FLAG_HAS_JUMBO_FRAMES
  2949. | FLAG_DISABLE_FC_PAUSE_TIME /* errata */
  2950. | FLAG_APME_IN_WUC,
  2951. .pba = 26,
  2952. .max_hw_frame_size = 4096,
  2953. .get_variants = e1000_get_variants_ich8lan,
  2954. .mac_ops = &ich8_mac_ops,
  2955. .phy_ops = &ich8_phy_ops,
  2956. .nvm_ops = &ich8_nvm_ops,
  2957. };