1 /*******************************************************************************
3 Copyright (c) 2001-2012, Intel Corporation
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions are met:
9 1. Redistributions of source code must retain the above copyright notice,
10 this list of conditions and the following disclaimer.
12 2. Redistributions in binary form must reproduce the above copyright
13 notice, this list of conditions and the following disclaimer in the
14 documentation and/or other materials provided with the distribution.
16 3. Neither the name of the Intel Corporation nor the names of its
17 contributors may be used to endorse or promote products derived from
18 this software without specific prior written permission.
20 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 POSSIBILITY OF SUCH DAMAGE.
32 ***************************************************************************/
34 #include "e1000_api.h"
37 * e1000_init_mac_params - Initialize MAC function pointers
38 * @hw: pointer to the HW structure
40 * This function initializes the function pointers for the MAC
41 * set of functions. Called by drivers or by e1000_setup_init_funcs.
43 s32 e1000_init_mac_params(struct e1000_hw *hw)
45 s32 ret_val = E1000_SUCCESS;
47 if (hw->mac.ops.init_params) {
48 ret_val = hw->mac.ops.init_params(hw);
50 DEBUGOUT("MAC Initialization Error\n");
54 DEBUGOUT("mac.init_mac_params was NULL\n");
55 ret_val = -E1000_ERR_CONFIG;
63 * e1000_init_nvm_params - Initialize NVM function pointers
64 * @hw: pointer to the HW structure
66 * This function initializes the function pointers for the NVM
67 * set of functions. Called by drivers or by e1000_setup_init_funcs.
69 s32 e1000_init_nvm_params(struct e1000_hw *hw)
71 s32 ret_val = E1000_SUCCESS;
73 if (hw->nvm.ops.init_params) {
74 ret_val = hw->nvm.ops.init_params(hw);
76 DEBUGOUT("NVM Initialization Error\n");
80 DEBUGOUT("nvm.init_nvm_params was NULL\n");
81 ret_val = -E1000_ERR_CONFIG;
89 * e1000_init_phy_params - Initialize PHY function pointers
90 * @hw: pointer to the HW structure
92 * This function initializes the function pointers for the PHY
93 * set of functions. Called by drivers or by e1000_setup_init_funcs.
95 s32 e1000_init_phy_params(struct e1000_hw *hw)
97 s32 ret_val = E1000_SUCCESS;
99 if (hw->phy.ops.init_params) {
100 ret_val = hw->phy.ops.init_params(hw);
102 DEBUGOUT("PHY Initialization Error\n");
106 DEBUGOUT("phy.init_phy_params was NULL\n");
107 ret_val = -E1000_ERR_CONFIG;
115 * e1000_init_mbx_params - Initialize mailbox function pointers
116 * @hw: pointer to the HW structure
118 * This function initializes the function pointers for the PHY
119 * set of functions. Called by drivers or by e1000_setup_init_funcs.
121 s32 e1000_init_mbx_params(struct e1000_hw *hw)
123 s32 ret_val = E1000_SUCCESS;
125 if (hw->mbx.ops.init_params) {
126 ret_val = hw->mbx.ops.init_params(hw);
128 DEBUGOUT("Mailbox Initialization Error\n");
132 DEBUGOUT("mbx.init_mbx_params was NULL\n");
133 ret_val = -E1000_ERR_CONFIG;
141 * e1000_set_mac_type - Sets MAC type
142 * @hw: pointer to the HW structure
144 * This function sets the mac type of the adapter based on the
145 * device ID stored in the hw structure.
146 * MUST BE FIRST FUNCTION CALLED (explicitly or through
147 * e1000_setup_init_funcs()).
149 s32 e1000_set_mac_type(struct e1000_hw *hw)
151 struct e1000_mac_info *mac = &hw->mac;
152 s32 ret_val = E1000_SUCCESS;
154 DEBUGFUNC("e1000_set_mac_type");
156 switch (hw->device_id) {
157 case E1000_DEV_ID_82575EB_COPPER:
158 case E1000_DEV_ID_82575EB_FIBER_SERDES:
159 case E1000_DEV_ID_82575GB_QUAD_COPPER:
160 mac->type = e1000_82575;
162 case E1000_DEV_ID_82576:
163 case E1000_DEV_ID_82576_FIBER:
164 case E1000_DEV_ID_82576_SERDES:
165 case E1000_DEV_ID_82576_QUAD_COPPER:
166 case E1000_DEV_ID_82576_QUAD_COPPER_ET2:
167 case E1000_DEV_ID_82576_NS:
168 case E1000_DEV_ID_82576_NS_SERDES:
169 case E1000_DEV_ID_82576_SERDES_QUAD:
170 mac->type = e1000_82576;
172 case E1000_DEV_ID_82580_COPPER:
173 case E1000_DEV_ID_82580_FIBER:
174 case E1000_DEV_ID_82580_SERDES:
175 case E1000_DEV_ID_82580_SGMII:
176 case E1000_DEV_ID_82580_COPPER_DUAL:
177 case E1000_DEV_ID_82580_QUAD_FIBER:
178 case E1000_DEV_ID_DH89XXCC_SGMII:
179 case E1000_DEV_ID_DH89XXCC_SERDES:
180 case E1000_DEV_ID_DH89XXCC_BACKPLANE:
181 case E1000_DEV_ID_DH89XXCC_SFP:
182 mac->type = e1000_82580;
184 case E1000_DEV_ID_I350_COPPER:
185 case E1000_DEV_ID_I350_FIBER:
186 case E1000_DEV_ID_I350_SERDES:
187 case E1000_DEV_ID_I350_SGMII:
188 case E1000_DEV_ID_I350_DA4:
189 mac->type = e1000_i350;
191 case E1000_DEV_ID_82576_VF:
192 mac->type = e1000_vfadapt;
194 case E1000_DEV_ID_I350_VF:
195 mac->type = e1000_vfadapt_i350;
198 /* Should never have loaded on this device */
199 ret_val = -E1000_ERR_MAC_INIT;
207 * e1000_setup_init_funcs - Initializes function pointers
208 * @hw: pointer to the HW structure
209 * @init_device: true will initialize the rest of the function pointers
210 * getting the device ready for use. false will only set
211 * MAC type and the function pointers for the other init
212 * functions. Passing false will not generate any hardware
215 * This function must be called by a driver in order to use the rest
216 * of the 'shared' code files. Called by drivers only.
218 s32 e1000_setup_init_funcs(struct e1000_hw *hw, bool init_device)
222 /* Can't do much good without knowing the MAC type. */
223 ret_val = e1000_set_mac_type(hw);
225 DEBUGOUT("ERROR: MAC type could not be set properly.\n");
230 DEBUGOUT("ERROR: Registers not mapped\n");
231 ret_val = -E1000_ERR_CONFIG;
236 * Init function pointers to generic implementations. We do this first
237 * allowing a driver module to override it afterward.
239 e1000_init_mac_ops_generic(hw);
240 e1000_init_phy_ops_generic(hw);
241 e1000_init_nvm_ops_generic(hw);
242 e1000_init_mbx_ops_generic(hw);
245 * Set up the init function pointers. These are functions within the
246 * adapter family file that sets up function pointers for the rest of
247 * the functions in that family.
249 switch (hw->mac.type) {
254 e1000_init_function_pointers_82575(hw);
257 e1000_init_function_pointers_vf(hw);
259 case e1000_vfadapt_i350:
260 e1000_init_function_pointers_vf(hw);
263 DEBUGOUT("Hardware not supported\n");
264 ret_val = -E1000_ERR_CONFIG;
269 * Initialize the rest of the function pointers. These require some
270 * register reads/writes in some cases.
272 if (!(ret_val) && init_device) {
273 ret_val = e1000_init_mac_params(hw);
277 ret_val = e1000_init_nvm_params(hw);
281 ret_val = e1000_init_phy_params(hw);
285 ret_val = e1000_init_mbx_params(hw);
295 * e1000_get_bus_info - Obtain bus information for adapter
296 * @hw: pointer to the HW structure
298 * This will obtain information about the HW bus for which the
299 * adapter is attached and stores it in the hw structure. This is a
300 * function pointer entry point called by drivers.
302 s32 e1000_get_bus_info(struct e1000_hw *hw)
304 if (hw->mac.ops.get_bus_info)
305 return hw->mac.ops.get_bus_info(hw);
307 return E1000_SUCCESS;
311 * e1000_clear_vfta - Clear VLAN filter table
312 * @hw: pointer to the HW structure
314 * This clears the VLAN filter table on the adapter. This is a function
315 * pointer entry point called by drivers.
317 void e1000_clear_vfta(struct e1000_hw *hw)
319 if (hw->mac.ops.clear_vfta)
320 hw->mac.ops.clear_vfta(hw);
324 * e1000_write_vfta - Write value to VLAN filter table
325 * @hw: pointer to the HW structure
326 * @offset: the 32-bit offset in which to write the value to.
327 * @value: the 32-bit value to write at location offset.
329 * This writes a 32-bit value to a 32-bit offset in the VLAN filter
330 * table. This is a function pointer entry point called by drivers.
332 void e1000_write_vfta(struct e1000_hw *hw, u32 offset, u32 value)
334 if (hw->mac.ops.write_vfta)
335 hw->mac.ops.write_vfta(hw, offset, value);
339 * e1000_update_mc_addr_list - Update Multicast addresses
340 * @hw: pointer to the HW structure
341 * @mc_addr_list: array of multicast addresses to program
342 * @mc_addr_count: number of multicast addresses to program
344 * Updates the Multicast Table Array.
345 * The caller must have a packed mc_addr_list of multicast addresses.
347 void e1000_update_mc_addr_list(struct e1000_hw *hw, u8 *mc_addr_list,
350 if (hw->mac.ops.update_mc_addr_list)
351 hw->mac.ops.update_mc_addr_list(hw, mc_addr_list,
356 * e1000_force_mac_fc - Force MAC flow control
357 * @hw: pointer to the HW structure
359 * Force the MAC's flow control settings. Currently no func pointer exists
360 * and all implementations are handled in the generic version of this
363 s32 e1000_force_mac_fc(struct e1000_hw *hw)
365 return e1000_force_mac_fc_generic(hw);
369 * e1000_check_for_link - Check/Store link connection
370 * @hw: pointer to the HW structure
372 * This checks the link condition of the adapter and stores the
373 * results in the hw->mac structure. This is a function pointer entry
374 * point called by drivers.
376 s32 e1000_check_for_link(struct e1000_hw *hw)
378 if (hw->mac.ops.check_for_link)
379 return hw->mac.ops.check_for_link(hw);
381 return -E1000_ERR_CONFIG;
385 * e1000_check_mng_mode - Check management mode
386 * @hw: pointer to the HW structure
388 * This checks if the adapter has manageability enabled.
389 * This is a function pointer entry point called by drivers.
391 bool e1000_check_mng_mode(struct e1000_hw *hw)
393 if (hw->mac.ops.check_mng_mode)
394 return hw->mac.ops.check_mng_mode(hw);
400 * e1000_mng_write_dhcp_info - Writes DHCP info to host interface
401 * @hw: pointer to the HW structure
402 * @buffer: pointer to the host interface
403 * @length: size of the buffer
405 * Writes the DHCP information to the host interface.
407 s32 e1000_mng_write_dhcp_info(struct e1000_hw *hw, u8 *buffer, u16 length)
409 return e1000_mng_write_dhcp_info_generic(hw, buffer, length);
413 * e1000_reset_hw - Reset hardware
414 * @hw: pointer to the HW structure
416 * This resets the hardware into a known state. This is a function pointer
417 * entry point called by drivers.
419 s32 e1000_reset_hw(struct e1000_hw *hw)
421 if (hw->mac.ops.reset_hw)
422 return hw->mac.ops.reset_hw(hw);
424 return -E1000_ERR_CONFIG;
428 * e1000_init_hw - Initialize hardware
429 * @hw: pointer to the HW structure
431 * This inits the hardware readying it for operation. This is a function
432 * pointer entry point called by drivers.
434 s32 e1000_init_hw(struct e1000_hw *hw)
436 if (hw->mac.ops.init_hw)
437 return hw->mac.ops.init_hw(hw);
439 return -E1000_ERR_CONFIG;
443 * e1000_setup_link - Configures link and flow control
444 * @hw: pointer to the HW structure
446 * This configures link and flow control settings for the adapter. This
447 * is a function pointer entry point called by drivers. While modules can
448 * also call this, they probably call their own version of this function.
450 s32 e1000_setup_link(struct e1000_hw *hw)
452 if (hw->mac.ops.setup_link)
453 return hw->mac.ops.setup_link(hw);
455 return -E1000_ERR_CONFIG;
459 * e1000_get_speed_and_duplex - Returns current speed and duplex
460 * @hw: pointer to the HW structure
461 * @speed: pointer to a 16-bit value to store the speed
462 * @duplex: pointer to a 16-bit value to store the duplex.
464 * This returns the speed and duplex of the adapter in the two 'out'
465 * variables passed in. This is a function pointer entry point called
468 s32 e1000_get_speed_and_duplex(struct e1000_hw *hw, u16 *speed, u16 *duplex)
470 if (hw->mac.ops.get_link_up_info)
471 return hw->mac.ops.get_link_up_info(hw, speed, duplex);
473 return -E1000_ERR_CONFIG;
477 * e1000_setup_led - Configures SW controllable LED
478 * @hw: pointer to the HW structure
480 * This prepares the SW controllable LED for use and saves the current state
481 * of the LED so it can be later restored. This is a function pointer entry
482 * point called by drivers.
484 s32 e1000_setup_led(struct e1000_hw *hw)
486 if (hw->mac.ops.setup_led)
487 return hw->mac.ops.setup_led(hw);
489 return E1000_SUCCESS;
493 * e1000_cleanup_led - Restores SW controllable LED
494 * @hw: pointer to the HW structure
496 * This restores the SW controllable LED to the value saved off by
497 * e1000_setup_led. This is a function pointer entry point called by drivers.
499 s32 e1000_cleanup_led(struct e1000_hw *hw)
501 if (hw->mac.ops.cleanup_led)
502 return hw->mac.ops.cleanup_led(hw);
504 return E1000_SUCCESS;
508 * e1000_blink_led - Blink SW controllable LED
509 * @hw: pointer to the HW structure
511 * This starts the adapter LED blinking. Request the LED to be setup first
512 * and cleaned up after. This is a function pointer entry point called by
515 s32 e1000_blink_led(struct e1000_hw *hw)
517 if (hw->mac.ops.blink_led)
518 return hw->mac.ops.blink_led(hw);
520 return E1000_SUCCESS;
524 * e1000_id_led_init - store LED configurations in SW
525 * @hw: pointer to the HW structure
527 * Initializes the LED config in SW. This is a function pointer entry point
530 s32 e1000_id_led_init(struct e1000_hw *hw)
532 if (hw->mac.ops.id_led_init)
533 return hw->mac.ops.id_led_init(hw);
535 return E1000_SUCCESS;
539 * e1000_led_on - Turn on SW controllable LED
540 * @hw: pointer to the HW structure
542 * Turns the SW defined LED on. This is a function pointer entry point
545 s32 e1000_led_on(struct e1000_hw *hw)
547 if (hw->mac.ops.led_on)
548 return hw->mac.ops.led_on(hw);
550 return E1000_SUCCESS;
554 * e1000_led_off - Turn off SW controllable LED
555 * @hw: pointer to the HW structure
557 * Turns the SW defined LED off. This is a function pointer entry point
560 s32 e1000_led_off(struct e1000_hw *hw)
562 if (hw->mac.ops.led_off)
563 return hw->mac.ops.led_off(hw);
565 return E1000_SUCCESS;
569 * e1000_reset_adaptive - Reset adaptive IFS
570 * @hw: pointer to the HW structure
572 * Resets the adaptive IFS. Currently no func pointer exists and all
573 * implementations are handled in the generic version of this function.
575 void e1000_reset_adaptive(struct e1000_hw *hw)
577 e1000_reset_adaptive_generic(hw);
581 * e1000_update_adaptive - Update adaptive IFS
582 * @hw: pointer to the HW structure
584 * Updates adapter IFS. Currently no func pointer exists and all
585 * implementations are handled in the generic version of this function.
587 void e1000_update_adaptive(struct e1000_hw *hw)
589 e1000_update_adaptive_generic(hw);
593 * e1000_disable_pcie_master - Disable PCI-Express master access
594 * @hw: pointer to the HW structure
596 * Disables PCI-Express master access and verifies there are no pending
597 * requests. Currently no func pointer exists and all implementations are
598 * handled in the generic version of this function.
600 s32 e1000_disable_pcie_master(struct e1000_hw *hw)
602 return e1000_disable_pcie_master_generic(hw);
606 * e1000_config_collision_dist - Configure collision distance
607 * @hw: pointer to the HW structure
609 * Configures the collision distance to the default value and is used
612 void e1000_config_collision_dist(struct e1000_hw *hw)
614 if (hw->mac.ops.config_collision_dist)
615 hw->mac.ops.config_collision_dist(hw);
619 * e1000_rar_set - Sets a receive address register
620 * @hw: pointer to the HW structure
621 * @addr: address to set the RAR to
622 * @index: the RAR to set
624 * Sets a Receive Address Register (RAR) to the specified address.
626 void e1000_rar_set(struct e1000_hw *hw, u8 *addr, u32 index)
628 if (hw->mac.ops.rar_set)
629 hw->mac.ops.rar_set(hw, addr, index);
633 * e1000_validate_mdi_setting - Ensures valid MDI/MDIX SW state
634 * @hw: pointer to the HW structure
636 * Ensures that the MDI/MDIX SW state is valid.
638 s32 e1000_validate_mdi_setting(struct e1000_hw *hw)
640 if (hw->mac.ops.validate_mdi_setting)
641 return hw->mac.ops.validate_mdi_setting(hw);
643 return E1000_SUCCESS;
647 * e1000_hash_mc_addr - Determines address location in multicast table
648 * @hw: pointer to the HW structure
649 * @mc_addr: Multicast address to hash.
651 * This hashes an address to determine its location in the multicast
652 * table. Currently no func pointer exists and all implementations
653 * are handled in the generic version of this function.
655 u32 e1000_hash_mc_addr(struct e1000_hw *hw, u8 *mc_addr)
657 return e1000_hash_mc_addr_generic(hw, mc_addr);
661 * e1000_enable_tx_pkt_filtering - Enable packet filtering on TX
662 * @hw: pointer to the HW structure
664 * Enables packet filtering on transmit packets if manageability is enabled
665 * and host interface is enabled.
666 * Currently no func pointer exists and all implementations are handled in the
667 * generic version of this function.
669 bool e1000_enable_tx_pkt_filtering(struct e1000_hw *hw)
671 return e1000_enable_tx_pkt_filtering_generic(hw);
675 * e1000_mng_host_if_write - Writes to the manageability host interface
676 * @hw: pointer to the HW structure
677 * @buffer: pointer to the host interface buffer
678 * @length: size of the buffer
679 * @offset: location in the buffer to write to
680 * @sum: sum of the data (not checksum)
682 * This function writes the buffer content at the offset given on the host if.
683 * It also does alignment considerations to do the writes in most efficient
684 * way. Also fills up the sum of the buffer in *buffer parameter.
686 s32 e1000_mng_host_if_write(struct e1000_hw *hw, u8 *buffer, u16 length,
689 if (hw->mac.ops.mng_host_if_write)
690 return hw->mac.ops.mng_host_if_write(hw, buffer, length,
693 return E1000_NOT_IMPLEMENTED;
697 * e1000_mng_write_cmd_header - Writes manageability command header
698 * @hw: pointer to the HW structure
699 * @hdr: pointer to the host interface command header
701 * Writes the command header after does the checksum calculation.
703 s32 e1000_mng_write_cmd_header(struct e1000_hw *hw,
704 struct e1000_host_mng_command_header *hdr)
706 if (hw->mac.ops.mng_write_cmd_header)
707 return hw->mac.ops.mng_write_cmd_header(hw, hdr);
709 return E1000_NOT_IMPLEMENTED;
713 * e1000_mng_enable_host_if - Checks host interface is enabled
714 * @hw: pointer to the HW structure
716 * Returns E1000_success upon success, else E1000_ERR_HOST_INTERFACE_COMMAND
718 * This function checks whether the HOST IF is enabled for command operation
719 * and also checks whether the previous command is completed. It busy waits
720 * in case of previous command is not completed.
722 s32 e1000_mng_enable_host_if(struct e1000_hw *hw)
724 if (hw->mac.ops.mng_enable_host_if)
725 return hw->mac.ops.mng_enable_host_if(hw);
727 return E1000_NOT_IMPLEMENTED;
731 * e1000_wait_autoneg - Waits for autonegotiation completion
732 * @hw: pointer to the HW structure
734 * Waits for autoneg to complete. Currently no func pointer exists and all
735 * implementations are handled in the generic version of this function.
737 s32 e1000_wait_autoneg(struct e1000_hw *hw)
739 if (hw->mac.ops.wait_autoneg)
740 return hw->mac.ops.wait_autoneg(hw);
742 return E1000_SUCCESS;
746 * e1000_check_reset_block - Verifies PHY can be reset
747 * @hw: pointer to the HW structure
749 * Checks if the PHY is in a state that can be reset or if manageability
750 * has it tied up. This is a function pointer entry point called by drivers.
752 s32 e1000_check_reset_block(struct e1000_hw *hw)
754 if (hw->phy.ops.check_reset_block)
755 return hw->phy.ops.check_reset_block(hw);
757 return E1000_SUCCESS;
761 * e1000_read_phy_reg - Reads PHY register
762 * @hw: pointer to the HW structure
763 * @offset: the register to read
764 * @data: the buffer to store the 16-bit read.
766 * Reads the PHY register and returns the value in data.
767 * This is a function pointer entry point called by drivers.
769 s32 e1000_read_phy_reg(struct e1000_hw *hw, u32 offset, u16 *data)
771 if (hw->phy.ops.read_reg)
772 return hw->phy.ops.read_reg(hw, offset, data);
774 return E1000_SUCCESS;
778 * e1000_write_phy_reg - Writes PHY register
779 * @hw: pointer to the HW structure
780 * @offset: the register to write
781 * @data: the value to write.
783 * Writes the PHY register at offset with the value in data.
784 * This is a function pointer entry point called by drivers.
786 s32 e1000_write_phy_reg(struct e1000_hw *hw, u32 offset, u16 data)
788 if (hw->phy.ops.write_reg)
789 return hw->phy.ops.write_reg(hw, offset, data);
791 return E1000_SUCCESS;
795 * e1000_release_phy - Generic release PHY
796 * @hw: pointer to the HW structure
798 * Return if silicon family does not require a semaphore when accessing the
801 void e1000_release_phy(struct e1000_hw *hw)
803 if (hw->phy.ops.release)
804 hw->phy.ops.release(hw);
808 * e1000_acquire_phy - Generic acquire PHY
809 * @hw: pointer to the HW structure
811 * Return success if silicon family does not require a semaphore when
814 s32 e1000_acquire_phy(struct e1000_hw *hw)
816 if (hw->phy.ops.acquire)
817 return hw->phy.ops.acquire(hw);
819 return E1000_SUCCESS;
823 * e1000_read_kmrn_reg - Reads register using Kumeran interface
824 * @hw: pointer to the HW structure
825 * @offset: the register to read
826 * @data: the location to store the 16-bit value read.
828 * Reads a register out of the Kumeran interface. Currently no func pointer
829 * exists and all implementations are handled in the generic version of
832 s32 e1000_read_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 *data)
834 return e1000_read_kmrn_reg_generic(hw, offset, data);
838 * e1000_write_kmrn_reg - Writes register using Kumeran interface
839 * @hw: pointer to the HW structure
840 * @offset: the register to write
841 * @data: the value to write.
843 * Writes a register to the Kumeran interface. Currently no func pointer
844 * exists and all implementations are handled in the generic version of
847 s32 e1000_write_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 data)
849 return e1000_write_kmrn_reg_generic(hw, offset, data);
853 * e1000_get_cable_length - Retrieves cable length estimation
854 * @hw: pointer to the HW structure
856 * This function estimates the cable length and stores them in
857 * hw->phy.min_length and hw->phy.max_length. This is a function pointer
858 * entry point called by drivers.
860 s32 e1000_get_cable_length(struct e1000_hw *hw)
862 if (hw->phy.ops.get_cable_length)
863 return hw->phy.ops.get_cable_length(hw);
865 return E1000_SUCCESS;
869 * e1000_get_phy_info - Retrieves PHY information from registers
870 * @hw: pointer to the HW structure
872 * This function gets some information from various PHY registers and
873 * populates hw->phy values with it. This is a function pointer entry
874 * point called by drivers.
876 s32 e1000_get_phy_info(struct e1000_hw *hw)
878 if (hw->phy.ops.get_info)
879 return hw->phy.ops.get_info(hw);
881 return E1000_SUCCESS;
885 * e1000_phy_hw_reset - Hard PHY reset
886 * @hw: pointer to the HW structure
888 * Performs a hard PHY reset. This is a function pointer entry point called
891 s32 e1000_phy_hw_reset(struct e1000_hw *hw)
893 if (hw->phy.ops.reset)
894 return hw->phy.ops.reset(hw);
896 return E1000_SUCCESS;
900 * e1000_phy_commit - Soft PHY reset
901 * @hw: pointer to the HW structure
903 * Performs a soft PHY reset on those that apply. This is a function pointer
904 * entry point called by drivers.
906 s32 e1000_phy_commit(struct e1000_hw *hw)
908 if (hw->phy.ops.commit)
909 return hw->phy.ops.commit(hw);
911 return E1000_SUCCESS;
915 * e1000_set_d0_lplu_state - Sets low power link up state for D0
916 * @hw: pointer to the HW structure
917 * @active: boolean used to enable/disable lplu
919 * Success returns 0, Failure returns 1
921 * The low power link up (lplu) state is set to the power management level D0
922 * and SmartSpeed is disabled when active is true, else clear lplu for D0
923 * and enable Smartspeed. LPLU and Smartspeed are mutually exclusive. LPLU
924 * is used during Dx states where the power conservation is most important.
925 * During driver activity, SmartSpeed should be enabled so performance is
926 * maintained. This is a function pointer entry point called by drivers.
928 s32 e1000_set_d0_lplu_state(struct e1000_hw *hw, bool active)
930 if (hw->phy.ops.set_d0_lplu_state)
931 return hw->phy.ops.set_d0_lplu_state(hw, active);
933 return E1000_SUCCESS;
937 * e1000_set_d3_lplu_state - Sets low power link up state for D3
938 * @hw: pointer to the HW structure
939 * @active: boolean used to enable/disable lplu
941 * Success returns 0, Failure returns 1
943 * The low power link up (lplu) state is set to the power management level D3
944 * and SmartSpeed is disabled when active is true, else clear lplu for D3
945 * and enable Smartspeed. LPLU and Smartspeed are mutually exclusive. LPLU
946 * is used during Dx states where the power conservation is most important.
947 * During driver activity, SmartSpeed should be enabled so performance is
948 * maintained. This is a function pointer entry point called by drivers.
950 s32 e1000_set_d3_lplu_state(struct e1000_hw *hw, bool active)
952 if (hw->phy.ops.set_d3_lplu_state)
953 return hw->phy.ops.set_d3_lplu_state(hw, active);
955 return E1000_SUCCESS;
959 * e1000_read_mac_addr - Reads MAC address
960 * @hw: pointer to the HW structure
962 * Reads the MAC address out of the adapter and stores it in the HW structure.
963 * Currently no func pointer exists and all implementations are handled in the
964 * generic version of this function.
966 s32 e1000_read_mac_addr(struct e1000_hw *hw)
968 if (hw->mac.ops.read_mac_addr)
969 return hw->mac.ops.read_mac_addr(hw);
971 return e1000_read_mac_addr_generic(hw);
975 * e1000_read_pba_string - Read device part number string
976 * @hw: pointer to the HW structure
977 * @pba_num: pointer to device part number
978 * @pba_num_size: size of part number buffer
980 * Reads the product board assembly (PBA) number from the EEPROM and stores
981 * the value in pba_num.
982 * Currently no func pointer exists and all implementations are handled in the
983 * generic version of this function.
985 s32 e1000_read_pba_string(struct e1000_hw *hw, u8 *pba_num, u32 pba_num_size)
987 return e1000_read_pba_string_generic(hw, pba_num, pba_num_size);
991 * e1000_read_pba_length - Read device part number string length
992 * @hw: pointer to the HW structure
993 * @pba_num_size: size of part number buffer
995 * Reads the product board assembly (PBA) number length from the EEPROM and
996 * stores the value in pba_num.
997 * Currently no func pointer exists and all implementations are handled in the
998 * generic version of this function.
1000 s32 e1000_read_pba_length(struct e1000_hw *hw, u32 *pba_num_size)
1002 return e1000_read_pba_length_generic(hw, pba_num_size);
1006 * e1000_validate_nvm_checksum - Verifies NVM (EEPROM) checksum
1007 * @hw: pointer to the HW structure
1009 * Validates the NVM checksum is correct. This is a function pointer entry
1010 * point called by drivers.
1012 s32 e1000_validate_nvm_checksum(struct e1000_hw *hw)
1014 if (hw->nvm.ops.validate)
1015 return hw->nvm.ops.validate(hw);
1017 return -E1000_ERR_CONFIG;
1021 * e1000_update_nvm_checksum - Updates NVM (EEPROM) checksum
1022 * @hw: pointer to the HW structure
1024 * Updates the NVM checksum. Currently no func pointer exists and all
1025 * implementations are handled in the generic version of this function.
1027 s32 e1000_update_nvm_checksum(struct e1000_hw *hw)
1029 if (hw->nvm.ops.update)
1030 return hw->nvm.ops.update(hw);
1032 return -E1000_ERR_CONFIG;
1036 * e1000_reload_nvm - Reloads EEPROM
1037 * @hw: pointer to the HW structure
1039 * Reloads the EEPROM by setting the "Reinitialize from EEPROM" bit in the
1040 * extended control register.
1042 void e1000_reload_nvm(struct e1000_hw *hw)
1044 if (hw->nvm.ops.reload)
1045 hw->nvm.ops.reload(hw);
1049 * e1000_read_nvm - Reads NVM (EEPROM)
1050 * @hw: pointer to the HW structure
1051 * @offset: the word offset to read
1052 * @words: number of 16-bit words to read
1053 * @data: pointer to the properly sized buffer for the data.
1055 * Reads 16-bit chunks of data from the NVM (EEPROM). This is a function
1056 * pointer entry point called by drivers.
1058 s32 e1000_read_nvm(struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
1060 if (hw->nvm.ops.read)
1061 return hw->nvm.ops.read(hw, offset, words, data);
1063 return -E1000_ERR_CONFIG;
1067 * e1000_write_nvm - Writes to NVM (EEPROM)
1068 * @hw: pointer to the HW structure
1069 * @offset: the word offset to read
1070 * @words: number of 16-bit words to write
1071 * @data: pointer to the properly sized buffer for the data.
1073 * Writes 16-bit chunks of data to the NVM (EEPROM). This is a function
1074 * pointer entry point called by drivers.
1076 s32 e1000_write_nvm(struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
1078 if (hw->nvm.ops.write)
1079 return hw->nvm.ops.write(hw, offset, words, data);
1081 return E1000_SUCCESS;
1085 * e1000_write_8bit_ctrl_reg - Writes 8bit Control register
1086 * @hw: pointer to the HW structure
1087 * @reg: 32bit register offset
1088 * @offset: the register to write
1089 * @data: the value to write.
1091 * Writes the PHY register at offset with the value in data.
1092 * This is a function pointer entry point called by drivers.
1094 s32 e1000_write_8bit_ctrl_reg(struct e1000_hw *hw, u32 reg, u32 offset,
1097 return e1000_write_8bit_ctrl_reg_generic(hw, reg, offset, data);
1101 * e1000_power_up_phy - Restores link in case of PHY power down
1102 * @hw: pointer to the HW structure
1104 * The phy may be powered down to save power, to turn off link when the
1105 * driver is unloaded, or wake on lan is not enabled (among others).
1107 void e1000_power_up_phy(struct e1000_hw *hw)
1109 if (hw->phy.ops.power_up)
1110 hw->phy.ops.power_up(hw);
1112 e1000_setup_link(hw);
1116 * e1000_power_down_phy - Power down PHY
1117 * @hw: pointer to the HW structure
1119 * The phy may be powered down to save power, to turn off link when the
1120 * driver is unloaded, or wake on lan is not enabled (among others).
1122 void e1000_power_down_phy(struct e1000_hw *hw)
1124 if (hw->phy.ops.power_down)
1125 hw->phy.ops.power_down(hw);
1129 * e1000_power_up_fiber_serdes_link - Power up serdes link
1130 * @hw: pointer to the HW structure
1132 * Power on the optics and PCS.
1134 void e1000_power_up_fiber_serdes_link(struct e1000_hw *hw)
1136 if (hw->mac.ops.power_up_serdes)
1137 hw->mac.ops.power_up_serdes(hw);
1141 * e1000_shutdown_fiber_serdes_link - Remove link during power down
1142 * @hw: pointer to the HW structure
1144 * Shutdown the optics and PCS on driver unload.
1146 void e1000_shutdown_fiber_serdes_link(struct e1000_hw *hw)
1148 if (hw->mac.ops.shutdown_serdes)
1149 hw->mac.ops.shutdown_serdes(hw);