grub2: bring back build of aros-side grub2 tools
[AROS.git] / workbench / devs / networks / e1000 / e1000_api.c
blob56a11c41da822c973e975b0a9023aaf261589c8d
1 /*******************************************************************************
3 Intel PRO/1000 Linux driver
4 Copyright(c) 1999 - 2008 Intel Corporation.
6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License,
8 version 2, as published by the Free Software Foundation.
10 This program is distributed in the hope it will be useful, but WITHOUT
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 more details.
15 You should have received a copy of the GNU General Public License along with
16 this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
19 The full GNU General Public License is included in this distribution in
20 the file called "COPYING".
22 Contact Information:
23 Linux NICS <linux.nics@intel.com>
24 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
25 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
27 *******************************************************************************/
29 #include "e1000_api.h"
31 /**
32 * e1000_init_mac_params - Initialize MAC function pointers
33 * @hw: pointer to the HW structure
35 * This function initializes the function pointers for the MAC
36 * set of functions. Called by drivers or by e1000_setup_init_funcs.
37 **/
38 s32 e1000_init_mac_params(struct e1000_hw *hw)
40 s32 ret_val = E1000_SUCCESS;
42 if (hw->mac.ops.init_params) {
43 ret_val = hw->mac.ops.init_params(hw);
44 if (ret_val) {
45 DEBUGOUT("MAC Initialization Error\n");
46 goto out;
48 } else {
49 DEBUGOUT("mac.init_mac_params was NULL\n");
50 ret_val = -E1000_ERR_CONFIG;
53 out:
54 return ret_val;
57 /**
58 * e1000_init_nvm_params - Initialize NVM function pointers
59 * @hw: pointer to the HW structure
61 * This function initializes the function pointers for the NVM
62 * set of functions. Called by drivers or by e1000_setup_init_funcs.
63 **/
64 s32 e1000_init_nvm_params(struct e1000_hw *hw)
66 s32 ret_val = E1000_SUCCESS;
68 if (hw->nvm.ops.init_params) {
69 ret_val = hw->nvm.ops.init_params(hw);
70 if (ret_val) {
71 DEBUGOUT("NVM Initialization Error\n");
72 goto out;
74 } else {
75 DEBUGOUT("nvm.init_nvm_params was NULL\n");
76 ret_val = -E1000_ERR_CONFIG;
79 out:
80 return ret_val;
83 /**
84 * e1000_init_phy_params - Initialize PHY function pointers
85 * @hw: pointer to the HW structure
87 * This function initializes the function pointers for the PHY
88 * set of functions. Called by drivers or by e1000_setup_init_funcs.
89 **/
90 s32 e1000_init_phy_params(struct e1000_hw *hw)
92 s32 ret_val = E1000_SUCCESS;
94 if (hw->phy.ops.init_params) {
95 ret_val = hw->phy.ops.init_params(hw);
96 if (ret_val) {
97 DEBUGOUT("PHY Initialization Error\n");
98 goto out;
100 } else {
101 DEBUGOUT("phy.init_phy_params was NULL\n");
102 ret_val = -E1000_ERR_CONFIG;
105 out:
106 return ret_val;
111 * e1000_set_mac_type - Sets MAC type
112 * @hw: pointer to the HW structure
114 * This function sets the mac type of the adapter based on the
115 * device ID stored in the hw structure.
116 * MUST BE FIRST FUNCTION CALLED (explicitly or through
117 * e1000_setup_init_funcs()).
119 s32 e1000_set_mac_type(struct e1000_hw *hw)
121 struct e1000_mac_info *mac = &hw->mac;
122 s32 ret_val = E1000_SUCCESS;
124 DEBUGFUNC("e1000_set_mac_type");
126 switch (hw->device_id) {
127 case E1000_DEV_ID_82542:
128 mac->type = e1000_82542;
129 break;
130 case E1000_DEV_ID_82543GC_FIBER:
131 case E1000_DEV_ID_82543GC_COPPER:
132 mac->type = e1000_82543;
133 break;
134 case E1000_DEV_ID_82544EI_COPPER:
135 case E1000_DEV_ID_82544EI_FIBER:
136 case E1000_DEV_ID_82544GC_COPPER:
137 case E1000_DEV_ID_82544GC_LOM:
138 mac->type = e1000_82544;
139 break;
140 case E1000_DEV_ID_82540EM:
141 case E1000_DEV_ID_82540EM_LOM:
142 case E1000_DEV_ID_82540EP:
143 case E1000_DEV_ID_82540EP_LOM:
144 case E1000_DEV_ID_82540EP_LP:
145 mac->type = e1000_82540;
146 break;
147 case E1000_DEV_ID_82545EM_COPPER:
148 case E1000_DEV_ID_82545EM_FIBER:
149 mac->type = e1000_82545;
150 break;
151 case E1000_DEV_ID_82545GM_COPPER:
152 case E1000_DEV_ID_82545GM_FIBER:
153 case E1000_DEV_ID_82545GM_SERDES:
154 mac->type = e1000_82545_rev_3;
155 break;
156 case E1000_DEV_ID_82546EB_COPPER:
157 case E1000_DEV_ID_82546EB_FIBER:
158 case E1000_DEV_ID_82546EB_QUAD_COPPER:
159 mac->type = e1000_82546;
160 break;
161 case E1000_DEV_ID_82546GB_COPPER:
162 case E1000_DEV_ID_82546GB_FIBER:
163 case E1000_DEV_ID_82546GB_SERDES:
164 case E1000_DEV_ID_82546GB_PCIE:
165 case E1000_DEV_ID_82546GB_QUAD_COPPER:
166 case E1000_DEV_ID_82546GB_QUAD_COPPER_KSP3:
167 mac->type = e1000_82546_rev_3;
168 break;
169 case E1000_DEV_ID_82541EI:
170 case E1000_DEV_ID_82541EI_MOBILE:
171 case E1000_DEV_ID_82541ER_LOM:
172 mac->type = e1000_82541;
173 break;
174 case E1000_DEV_ID_82541ER:
175 case E1000_DEV_ID_82541GI:
176 case E1000_DEV_ID_82541GI_LF:
177 case E1000_DEV_ID_82541GI_MOBILE:
178 mac->type = e1000_82541_rev_2;
179 break;
180 case E1000_DEV_ID_82547EI:
181 case E1000_DEV_ID_82547EI_MOBILE:
182 mac->type = e1000_82547;
183 break;
184 case E1000_DEV_ID_82547GI:
185 mac->type = e1000_82547_rev_2;
186 break;
187 default:
188 /* Should never have loaded on this device */
189 ret_val = -E1000_ERR_MAC_INIT;
190 break;
193 return ret_val;
197 * e1000_setup_init_funcs - Initializes function pointers
198 * @hw: pointer to the HW structure
199 * @init_device: true will initialize the rest of the function pointers
200 * getting the device ready for use. false will only set
201 * MAC type and the function pointers for the other init
202 * functions. Passing false will not generate any hardware
203 * reads or writes.
205 * This function must be called by a driver in order to use the rest
206 * of the 'shared' code files. Called by drivers only.
208 s32 e1000_setup_init_funcs(struct e1000_hw *hw, bool init_device)
210 s32 ret_val;
212 /* Can't do much good without knowing the MAC type. */
213 ret_val = e1000_set_mac_type(hw);
214 if (ret_val) {
215 DEBUGOUT("ERROR: MAC type could not be set properly.\n");
216 goto out;
219 if (!hw->hw_addr) {
220 DEBUGOUT("ERROR: Registers not mapped\n");
221 ret_val = -E1000_ERR_CONFIG;
222 goto out;
226 * Init function pointers to generic implementations. We do this first
227 * allowing a driver module to override it afterward.
229 e1000_init_mac_ops_generic(hw);
230 e1000_init_phy_ops_generic(hw);
231 e1000_init_nvm_ops_generic(hw);
234 * Set up the init function pointers. These are functions within the
235 * adapter family file that sets up function pointers for the rest of
236 * the functions in that family.
238 switch (hw->mac.type) {
239 case e1000_82542:
240 e1000_init_function_pointers_82542(hw);
241 break;
242 case e1000_82543:
243 case e1000_82544:
244 e1000_init_function_pointers_82543(hw);
245 break;
246 case e1000_82540:
247 case e1000_82545:
248 case e1000_82545_rev_3:
249 case e1000_82546:
250 case e1000_82546_rev_3:
251 e1000_init_function_pointers_82540(hw);
252 break;
253 case e1000_82541:
254 case e1000_82541_rev_2:
255 case e1000_82547:
256 case e1000_82547_rev_2:
257 e1000_init_function_pointers_82541(hw);
258 break;
259 default:
260 DEBUGOUT("Hardware not supported\n");
261 ret_val = -E1000_ERR_CONFIG;
262 break;
266 * Initialize the rest of the function pointers. These require some
267 * register reads/writes in some cases.
269 if (!(ret_val) && init_device) {
270 ret_val = e1000_init_mac_params(hw);
271 if (ret_val)
272 goto out;
274 ret_val = e1000_init_nvm_params(hw);
275 if (ret_val)
276 goto out;
278 ret_val = e1000_init_phy_params(hw);
279 if (ret_val)
280 goto out;
283 out:
284 return ret_val;
288 * e1000_get_bus_info - Obtain bus information for adapter
289 * @hw: pointer to the HW structure
291 * This will obtain information about the HW bus for which the
292 * adapter is attached and stores it in the hw structure. This is a
293 * function pointer entry point called by drivers.
295 s32 e1000_get_bus_info(struct e1000_hw *hw)
297 if (hw->mac.ops.get_bus_info)
298 return hw->mac.ops.get_bus_info(hw);
300 return E1000_SUCCESS;
304 * e1000_clear_vfta - Clear VLAN filter table
305 * @hw: pointer to the HW structure
307 * This clears the VLAN filter table on the adapter. This is a function
308 * pointer entry point called by drivers.
310 void e1000_clear_vfta(struct e1000_hw *hw)
312 if (hw->mac.ops.clear_vfta)
313 hw->mac.ops.clear_vfta(hw);
317 * e1000_write_vfta - Write value to VLAN filter table
318 * @hw: pointer to the HW structure
319 * @offset: the 32-bit offset in which to write the value to.
320 * @value: the 32-bit value to write at location offset.
322 * This writes a 32-bit value to a 32-bit offset in the VLAN filter
323 * table. This is a function pointer entry point called by drivers.
325 void e1000_write_vfta(struct e1000_hw *hw, u32 offset, u32 value)
327 if (hw->mac.ops.write_vfta)
328 hw->mac.ops.write_vfta(hw, offset, value);
332 * e1000_update_mc_addr_list - Update Multicast addresses
333 * @hw: pointer to the HW structure
334 * @mc_addr_list: array of multicast addresses to program
335 * @mc_addr_count: number of multicast addresses to program
337 * Updates the Multicast Table Array.
338 * The caller must have a packed mc_addr_list of multicast addresses.
340 void e1000_update_mc_addr_list(struct e1000_hw *hw, u8 *mc_addr_list,
341 u32 mc_addr_count)
343 if (hw->mac.ops.update_mc_addr_list)
344 hw->mac.ops.update_mc_addr_list(hw, mc_addr_list,
345 mc_addr_count);
349 * e1000_force_mac_fc - Force MAC flow control
350 * @hw: pointer to the HW structure
352 * Force the MAC's flow control settings. Currently no func pointer exists
353 * and all implementations are handled in the generic version of this
354 * function.
356 s32 e1000_force_mac_fc(struct e1000_hw *hw)
358 return e1000_force_mac_fc_generic(hw);
362 * e1000_check_for_link - Check/Store link connection
363 * @hw: pointer to the HW structure
365 * This checks the link condition of the adapter and stores the
366 * results in the hw->mac structure. This is a function pointer entry
367 * point called by drivers.
369 s32 e1000_check_for_link(struct e1000_hw *hw)
371 if (hw->mac.ops.check_for_link)
372 return hw->mac.ops.check_for_link(hw);
374 return -E1000_ERR_CONFIG;
378 * e1000_check_mng_mode - Check management mode
379 * @hw: pointer to the HW structure
381 * This checks if the adapter has manageability enabled.
382 * This is a function pointer entry point called by drivers.
384 bool e1000_check_mng_mode(struct e1000_hw *hw)
386 if (hw->mac.ops.check_mng_mode)
387 return hw->mac.ops.check_mng_mode(hw);
389 return false;
393 * e1000_mng_write_dhcp_info - Writes DHCP info to host interface
394 * @hw: pointer to the HW structure
395 * @buffer: pointer to the host interface
396 * @length: size of the buffer
398 * Writes the DHCP information to the host interface.
400 s32 e1000_mng_write_dhcp_info(struct e1000_hw *hw, u8 *buffer, u16 length)
402 return e1000_mng_write_dhcp_info_generic(hw, buffer, length);
406 * e1000_reset_hw - Reset hardware
407 * @hw: pointer to the HW structure
409 * This resets the hardware into a known state. This is a function pointer
410 * entry point called by drivers.
412 s32 e1000_reset_hw(struct e1000_hw *hw)
414 if (hw->mac.ops.reset_hw)
415 return hw->mac.ops.reset_hw(hw);
417 return -E1000_ERR_CONFIG;
421 * e1000_init_hw - Initialize hardware
422 * @hw: pointer to the HW structure
424 * This inits the hardware readying it for operation. This is a function
425 * pointer entry point called by drivers.
427 s32 e1000_init_hw(struct e1000_hw *hw)
429 if (hw->mac.ops.init_hw)
430 return hw->mac.ops.init_hw(hw);
432 return -E1000_ERR_CONFIG;
436 * e1000_setup_link - Configures link and flow control
437 * @hw: pointer to the HW structure
439 * This configures link and flow control settings for the adapter. This
440 * is a function pointer entry point called by drivers. While modules can
441 * also call this, they probably call their own version of this function.
443 s32 e1000_setup_link(struct e1000_hw *hw)
445 if (hw->mac.ops.setup_link)
446 return hw->mac.ops.setup_link(hw);
448 return -E1000_ERR_CONFIG;
452 * e1000_get_speed_and_duplex - Returns current speed and duplex
453 * @hw: pointer to the HW structure
454 * @speed: pointer to a 16-bit value to store the speed
455 * @duplex: pointer to a 16-bit value to store the duplex.
457 * This returns the speed and duplex of the adapter in the two 'out'
458 * variables passed in. This is a function pointer entry point called
459 * by drivers.
461 s32 e1000_get_speed_and_duplex(struct e1000_hw *hw, u16 *speed, u16 *duplex)
463 if (hw->mac.ops.get_link_up_info)
464 return hw->mac.ops.get_link_up_info(hw, speed, duplex);
466 return -E1000_ERR_CONFIG;
470 * e1000_setup_led - Configures SW controllable LED
471 * @hw: pointer to the HW structure
473 * This prepares the SW controllable LED for use and saves the current state
474 * of the LED so it can be later restored. This is a function pointer entry
475 * point called by drivers.
477 s32 e1000_setup_led(struct e1000_hw *hw)
479 if (hw->mac.ops.setup_led)
480 return hw->mac.ops.setup_led(hw);
482 return E1000_SUCCESS;
486 * e1000_cleanup_led - Restores SW controllable LED
487 * @hw: pointer to the HW structure
489 * This restores the SW controllable LED to the value saved off by
490 * e1000_setup_led. This is a function pointer entry point called by drivers.
492 s32 e1000_cleanup_led(struct e1000_hw *hw)
494 if (hw->mac.ops.cleanup_led)
495 return hw->mac.ops.cleanup_led(hw);
497 return E1000_SUCCESS;
501 * e1000_blink_led - Blink SW controllable LED
502 * @hw: pointer to the HW structure
504 * This starts the adapter LED blinking. Request the LED to be setup first
505 * and cleaned up after. This is a function pointer entry point called by
506 * drivers.
508 s32 e1000_blink_led(struct e1000_hw *hw)
510 if (hw->mac.ops.blink_led)
511 return hw->mac.ops.blink_led(hw);
513 return E1000_SUCCESS;
517 * e1000_id_led_init - store LED configurations in SW
518 * @hw: pointer to the HW structure
520 * Initializes the LED config in SW. This is a function pointer entry point
521 * called by drivers.
523 s32 e1000_id_led_init(struct e1000_hw *hw)
525 if (hw->mac.ops.id_led_init)
526 return hw->mac.ops.id_led_init(hw);
528 return E1000_SUCCESS;
532 * e1000_led_on - Turn on SW controllable LED
533 * @hw: pointer to the HW structure
535 * Turns the SW defined LED on. This is a function pointer entry point
536 * called by drivers.
538 s32 e1000_led_on(struct e1000_hw *hw)
540 if (hw->mac.ops.led_on)
541 return hw->mac.ops.led_on(hw);
543 return E1000_SUCCESS;
547 * e1000_led_off - Turn off SW controllable LED
548 * @hw: pointer to the HW structure
550 * Turns the SW defined LED off. This is a function pointer entry point
551 * called by drivers.
553 s32 e1000_led_off(struct e1000_hw *hw)
555 if (hw->mac.ops.led_off)
556 return hw->mac.ops.led_off(hw);
558 return E1000_SUCCESS;
562 * e1000_reset_adaptive - Reset adaptive IFS
563 * @hw: pointer to the HW structure
565 * Resets the adaptive IFS. Currently no func pointer exists and all
566 * implementations are handled in the generic version of this function.
568 void e1000_reset_adaptive(struct e1000_hw *hw)
570 e1000_reset_adaptive_generic(hw);
574 * e1000_update_adaptive - Update adaptive IFS
575 * @hw: pointer to the HW structure
577 * Updates adapter IFS. Currently no func pointer exists and all
578 * implementations are handled in the generic version of this function.
580 void e1000_update_adaptive(struct e1000_hw *hw)
582 e1000_update_adaptive_generic(hw);
586 * e1000_disable_pcie_master - Disable PCI-Express master access
587 * @hw: pointer to the HW structure
589 * Disables PCI-Express master access and verifies there are no pending
590 * requests. Currently no func pointer exists and all implementations are
591 * handled in the generic version of this function.
593 s32 e1000_disable_pcie_master(struct e1000_hw *hw)
595 return e1000_disable_pcie_master_generic(hw);
599 * e1000_config_collision_dist - Configure collision distance
600 * @hw: pointer to the HW structure
602 * Configures the collision distance to the default value and is used
603 * during link setup.
605 void e1000_config_collision_dist(struct e1000_hw *hw)
607 if (hw->mac.ops.config_collision_dist)
608 hw->mac.ops.config_collision_dist(hw);
612 * e1000_rar_set - Sets a receive address register
613 * @hw: pointer to the HW structure
614 * @addr: address to set the RAR to
615 * @index: the RAR to set
617 * Sets a Receive Address Register (RAR) to the specified address.
619 void e1000_rar_set(struct e1000_hw *hw, u8 *addr, u32 index)
621 if (hw->mac.ops.rar_set)
622 hw->mac.ops.rar_set(hw, addr, index);
626 * e1000_validate_mdi_setting - Ensures valid MDI/MDIX SW state
627 * @hw: pointer to the HW structure
629 * Ensures that the MDI/MDIX SW state is valid.
631 s32 e1000_validate_mdi_setting(struct e1000_hw *hw)
633 if (hw->mac.ops.validate_mdi_setting)
634 return hw->mac.ops.validate_mdi_setting(hw);
636 return E1000_SUCCESS;
640 * e1000_mta_set - Sets multicast table bit
641 * @hw: pointer to the HW structure
642 * @hash_value: Multicast hash value.
644 * This sets the bit in the multicast table corresponding to the
645 * hash value. This is a function pointer entry point called by drivers.
647 void e1000_mta_set(struct e1000_hw *hw, u32 hash_value)
649 if (hw->mac.ops.mta_set)
650 hw->mac.ops.mta_set(hw, hash_value);
654 * e1000_hash_mc_addr - Determines address location in multicast table
655 * @hw: pointer to the HW structure
656 * @mc_addr: Multicast address to hash.
658 * This hashes an address to determine its location in the multicast
659 * table. Currently no func pointer exists and all implementations
660 * are handled in the generic version of this function.
662 u32 e1000_hash_mc_addr(struct e1000_hw *hw, u8 *mc_addr)
664 return e1000_hash_mc_addr_generic(hw, mc_addr);
668 * e1000_enable_tx_pkt_filtering - Enable packet filtering on TX
669 * @hw: pointer to the HW structure
671 * Enables packet filtering on transmit packets if manageability is enabled
672 * and host interface is enabled.
673 * Currently no func pointer exists and all implementations are handled in the
674 * generic version of this function.
676 bool e1000_enable_tx_pkt_filtering(struct e1000_hw *hw)
678 return e1000_enable_tx_pkt_filtering_generic(hw);
682 * e1000_mng_host_if_write - Writes to the manageability host interface
683 * @hw: pointer to the HW structure
684 * @buffer: pointer to the host interface buffer
685 * @length: size of the buffer
686 * @offset: location in the buffer to write to
687 * @sum: sum of the data (not checksum)
689 * This function writes the buffer content at the offset given on the host if.
690 * It also does alignment considerations to do the writes in most efficient
691 * way. Also fills up the sum of the buffer in *buffer parameter.
693 s32 e1000_mng_host_if_write(struct e1000_hw * hw, u8 *buffer, u16 length,
694 u16 offset, u8 *sum)
696 if (hw->mac.ops.mng_host_if_write)
697 return hw->mac.ops.mng_host_if_write(hw, buffer, length,
698 offset, sum);
700 return E1000_NOT_IMPLEMENTED;
704 * e1000_mng_write_cmd_header - Writes manageability command header
705 * @hw: pointer to the HW structure
706 * @hdr: pointer to the host interface command header
708 * Writes the command header after does the checksum calculation.
710 s32 e1000_mng_write_cmd_header(struct e1000_hw *hw,
711 struct e1000_host_mng_command_header *hdr)
713 if (hw->mac.ops.mng_write_cmd_header)
714 return hw->mac.ops.mng_write_cmd_header(hw, hdr);
716 return E1000_NOT_IMPLEMENTED;
720 * e1000_mng_enable_host_if - Checks host interface is enabled
721 * @hw: pointer to the HW structure
723 * Returns E1000_success upon success, else E1000_ERR_HOST_INTERFACE_COMMAND
725 * This function checks whether the HOST IF is enabled for command operation
726 * and also checks whether the previous command is completed. It busy waits
727 * in case of previous command is not completed.
729 s32 e1000_mng_enable_host_if(struct e1000_hw * hw)
731 if (hw->mac.ops.mng_enable_host_if)
732 return hw->mac.ops.mng_enable_host_if(hw);
734 return E1000_NOT_IMPLEMENTED;
738 * e1000_wait_autoneg - Waits for autonegotiation completion
739 * @hw: pointer to the HW structure
741 * Waits for autoneg to complete. Currently no func pointer exists and all
742 * implementations are handled in the generic version of this function.
744 s32 e1000_wait_autoneg(struct e1000_hw *hw)
746 if (hw->mac.ops.wait_autoneg)
747 return hw->mac.ops.wait_autoneg(hw);
749 return E1000_SUCCESS;
753 * e1000_check_reset_block - Verifies PHY can be reset
754 * @hw: pointer to the HW structure
756 * Checks if the PHY is in a state that can be reset or if manageability
757 * has it tied up. This is a function pointer entry point called by drivers.
759 s32 e1000_check_reset_block(struct e1000_hw *hw)
761 if (hw->phy.ops.check_reset_block)
762 return hw->phy.ops.check_reset_block(hw);
764 return E1000_SUCCESS;
768 * e1000_read_phy_reg - Reads PHY register
769 * @hw: pointer to the HW structure
770 * @offset: the register to read
771 * @data: the buffer to store the 16-bit read.
773 * Reads the PHY register and returns the value in data.
774 * This is a function pointer entry point called by drivers.
776 s32 e1000_read_phy_reg(struct e1000_hw *hw, u32 offset, u16 *data)
778 if (hw->phy.ops.read_reg)
779 return hw->phy.ops.read_reg(hw, offset, data);
781 return E1000_SUCCESS;
785 * e1000_write_phy_reg - Writes PHY register
786 * @hw: pointer to the HW structure
787 * @offset: the register to write
788 * @data: the value to write.
790 * Writes the PHY register at offset with the value in data.
791 * This is a function pointer entry point called by drivers.
793 s32 e1000_write_phy_reg(struct e1000_hw *hw, u32 offset, u16 data)
795 if (hw->phy.ops.write_reg)
796 return hw->phy.ops.write_reg(hw, offset, data);
798 return E1000_SUCCESS;
802 * e1000_release_phy - Generic release PHY
803 * @hw: pointer to the HW structure
805 * Return if silicon family does not require a semaphore when accessing the
806 * PHY.
808 void e1000_release_phy(struct e1000_hw *hw)
810 if (hw->phy.ops.release)
811 hw->phy.ops.release(hw);
815 * e1000_acquire_phy - Generic acquire PHY
816 * @hw: pointer to the HW structure
818 * Return success if silicon family does not require a semaphore when
819 * accessing the PHY.
821 s32 e1000_acquire_phy(struct e1000_hw *hw)
823 if (hw->phy.ops.acquire)
824 return hw->phy.ops.acquire(hw);
826 return E1000_SUCCESS;
830 * e1000_read_kmrn_reg - Reads register using Kumeran interface
831 * @hw: pointer to the HW structure
832 * @offset: the register to read
833 * @data: the location to store the 16-bit value read.
835 * Reads a register out of the Kumeran interface. Currently no func pointer
836 * exists and all implementations are handled in the generic version of
837 * this function.
839 s32 e1000_read_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 *data)
841 return e1000_read_kmrn_reg_generic(hw, offset, data);
845 * e1000_write_kmrn_reg - Writes register using Kumeran interface
846 * @hw: pointer to the HW structure
847 * @offset: the register to write
848 * @data: the value to write.
850 * Writes a register to the Kumeran interface. Currently no func pointer
851 * exists and all implementations are handled in the generic version of
852 * this function.
854 s32 e1000_write_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 data)
856 return e1000_write_kmrn_reg_generic(hw, offset, data);
860 * e1000_get_cable_length - Retrieves cable length estimation
861 * @hw: pointer to the HW structure
863 * This function estimates the cable length and stores them in
864 * hw->phy.min_length and hw->phy.max_length. This is a function pointer
865 * entry point called by drivers.
867 s32 e1000_get_cable_length(struct e1000_hw *hw)
869 if (hw->phy.ops.get_cable_length)
870 return hw->phy.ops.get_cable_length(hw);
872 return E1000_SUCCESS;
876 * e1000_get_phy_info - Retrieves PHY information from registers
877 * @hw: pointer to the HW structure
879 * This function gets some information from various PHY registers and
880 * populates hw->phy values with it. This is a function pointer entry
881 * point called by drivers.
883 s32 e1000_get_phy_info(struct e1000_hw *hw)
885 if (hw->phy.ops.get_info)
886 return hw->phy.ops.get_info(hw);
888 return E1000_SUCCESS;
892 * e1000_phy_hw_reset - Hard PHY reset
893 * @hw: pointer to the HW structure
895 * Performs a hard PHY reset. This is a function pointer entry point called
896 * by drivers.
898 s32 e1000_phy_hw_reset(struct e1000_hw *hw)
900 if (hw->phy.ops.reset)
901 return hw->phy.ops.reset(hw);
903 return E1000_SUCCESS;
907 * e1000_phy_commit - Soft PHY reset
908 * @hw: pointer to the HW structure
910 * Performs a soft PHY reset on those that apply. This is a function pointer
911 * entry point called by drivers.
913 s32 e1000_phy_commit(struct e1000_hw *hw)
915 if (hw->phy.ops.commit)
916 return hw->phy.ops.commit(hw);
918 return E1000_SUCCESS;
922 * e1000_set_d0_lplu_state - Sets low power link up state for D0
923 * @hw: pointer to the HW structure
924 * @active: boolean used to enable/disable lplu
926 * Success returns 0, Failure returns 1
928 * The low power link up (lplu) state is set to the power management level D0
929 * and SmartSpeed is disabled when active is true, else clear lplu for D0
930 * and enable Smartspeed. LPLU and Smartspeed are mutually exclusive. LPLU
931 * is used during Dx states where the power conservation is most important.
932 * During driver activity, SmartSpeed should be enabled so performance is
933 * maintained. This is a function pointer entry point called by drivers.
935 s32 e1000_set_d0_lplu_state(struct e1000_hw *hw, bool active)
937 if (hw->phy.ops.set_d0_lplu_state)
938 return hw->phy.ops.set_d0_lplu_state(hw, active);
940 return E1000_SUCCESS;
944 * e1000_set_d3_lplu_state - Sets low power link up state for D3
945 * @hw: pointer to the HW structure
946 * @active: boolean used to enable/disable lplu
948 * Success returns 0, Failure returns 1
950 * The low power link up (lplu) state is set to the power management level D3
951 * and SmartSpeed is disabled when active is true, else clear lplu for D3
952 * and enable Smartspeed. LPLU and Smartspeed are mutually exclusive. LPLU
953 * is used during Dx states where the power conservation is most important.
954 * During driver activity, SmartSpeed should be enabled so performance is
955 * maintained. This is a function pointer entry point called by drivers.
957 s32 e1000_set_d3_lplu_state(struct e1000_hw *hw, bool active)
959 if (hw->phy.ops.set_d3_lplu_state)
960 return hw->phy.ops.set_d3_lplu_state(hw, active);
962 return E1000_SUCCESS;
966 * e1000_read_mac_addr - Reads MAC address
967 * @hw: pointer to the HW structure
969 * Reads the MAC address out of the adapter and stores it in the HW structure.
970 * Currently no func pointer exists and all implementations are handled in the
971 * generic version of this function.
973 s32 e1000_read_mac_addr(struct e1000_hw *hw)
975 if (hw->mac.ops.read_mac_addr)
976 return hw->mac.ops.read_mac_addr(hw);
978 return e1000_read_mac_addr_generic(hw);
982 * e1000_read_pba_num - Read device part number
983 * @hw: pointer to the HW structure
984 * @pba_num: pointer to device part number
986 * Reads the product board assembly (PBA) number from the EEPROM and stores
987 * the value in pba_num.
988 * Currently no func pointer exists and all implementations are handled in the
989 * generic version of this function.
991 s32 e1000_read_pba_num(struct e1000_hw *hw, u32 *pba_num)
993 return e1000_read_pba_num_generic(hw, pba_num);
997 * e1000_validate_nvm_checksum - Verifies NVM (EEPROM) checksum
998 * @hw: pointer to the HW structure
1000 * Validates the NVM checksum is correct. This is a function pointer entry
1001 * point called by drivers.
1003 s32 e1000_validate_nvm_checksum(struct e1000_hw *hw)
1005 if (hw->nvm.ops.validate)
1006 return hw->nvm.ops.validate(hw);
1008 return -E1000_ERR_CONFIG;
1012 * e1000_update_nvm_checksum - Updates NVM (EEPROM) checksum
1013 * @hw: pointer to the HW structure
1015 * Updates the NVM checksum. Currently no func pointer exists and all
1016 * implementations are handled in the generic version of this function.
1018 s32 e1000_update_nvm_checksum(struct e1000_hw *hw)
1020 if (hw->nvm.ops.update)
1021 return hw->nvm.ops.update(hw);
1023 return -E1000_ERR_CONFIG;
1027 * e1000_reload_nvm - Reloads EEPROM
1028 * @hw: pointer to the HW structure
1030 * Reloads the EEPROM by setting the "Reinitialize from EEPROM" bit in the
1031 * extended control register.
1033 void e1000_reload_nvm(struct e1000_hw *hw)
1035 if (hw->nvm.ops.reload)
1036 hw->nvm.ops.reload(hw);
1040 * e1000_read_nvm - Reads NVM (EEPROM)
1041 * @hw: pointer to the HW structure
1042 * @offset: the word offset to read
1043 * @words: number of 16-bit words to read
1044 * @data: pointer to the properly sized buffer for the data.
1046 * Reads 16-bit chunks of data from the NVM (EEPROM). This is a function
1047 * pointer entry point called by drivers.
1049 s32 e1000_read_nvm(struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
1051 if (hw->nvm.ops.read)
1052 return hw->nvm.ops.read(hw, offset, words, data);
1054 return -E1000_ERR_CONFIG;
1058 * e1000_write_nvm - Writes to NVM (EEPROM)
1059 * @hw: pointer to the HW structure
1060 * @offset: the word offset to read
1061 * @words: number of 16-bit words to write
1062 * @data: pointer to the properly sized buffer for the data.
1064 * Writes 16-bit chunks of data to the NVM (EEPROM). This is a function
1065 * pointer entry point called by drivers.
1067 s32 e1000_write_nvm(struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
1069 if (hw->nvm.ops.write)
1070 return hw->nvm.ops.write(hw, offset, words, data);
1072 return E1000_SUCCESS;
1076 * e1000_power_up_phy - Restores link in case of PHY power down
1077 * @hw: pointer to the HW structure
1079 * The phy may be powered down to save power, to turn off link when the
1080 * driver is unloaded, or wake on lan is not enabled (among others).
1082 void e1000_power_up_phy(struct e1000_hw *hw)
1084 if (hw->phy.ops.power_up)
1085 hw->phy.ops.power_up(hw);
1087 e1000_setup_link(hw);
1091 * e1000_power_down_phy - Power down PHY
1092 * @hw: pointer to the HW structure
1094 * The phy may be powered down to save power, to turn off link when the
1095 * driver is unloaded, or wake on lan is not enabled (among others).
1097 void e1000_power_down_phy(struct e1000_hw *hw)
1099 if (hw->phy.ops.power_down)
1100 hw->phy.ops.power_down(hw);