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
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".
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 FILE_LICENCE ( GPL2_OR_LATER
);
31 #include "e1000_api.h"
34 * e1000_init_mac_params - Initialize MAC function pointers
35 * @hw: pointer to the HW structure
37 * This function initializes the function pointers for the MAC
38 * set of functions. Called by drivers or by e1000_setup_init_funcs.
40 s32
e1000_init_mac_params(struct e1000_hw
*hw
)
42 s32 ret_val
= E1000_SUCCESS
;
44 if (hw
->mac
.ops
.init_params
) {
45 ret_val
= hw
->mac
.ops
.init_params(hw
);
47 DEBUGOUT("MAC Initialization Error\n");
51 DEBUGOUT("mac.init_mac_params was NULL\n");
52 ret_val
= -E1000_ERR_CONFIG
;
60 * e1000_init_nvm_params - Initialize NVM function pointers
61 * @hw: pointer to the HW structure
63 * This function initializes the function pointers for the NVM
64 * set of functions. Called by drivers or by e1000_setup_init_funcs.
66 s32
e1000_init_nvm_params(struct e1000_hw
*hw
)
68 s32 ret_val
= E1000_SUCCESS
;
70 if (hw
->nvm
.ops
.init_params
) {
71 ret_val
= hw
->nvm
.ops
.init_params(hw
);
73 DEBUGOUT("NVM Initialization Error\n");
77 DEBUGOUT("nvm.init_nvm_params was NULL\n");
78 ret_val
= -E1000_ERR_CONFIG
;
86 * e1000_init_phy_params - Initialize PHY function pointers
87 * @hw: pointer to the HW structure
89 * This function initializes the function pointers for the PHY
90 * set of functions. Called by drivers or by e1000_setup_init_funcs.
92 s32
e1000_init_phy_params(struct e1000_hw
*hw
)
94 s32 ret_val
= E1000_SUCCESS
;
96 if (hw
->phy
.ops
.init_params
) {
97 ret_val
= hw
->phy
.ops
.init_params(hw
);
99 DEBUGOUT("PHY Initialization Error\n");
103 DEBUGOUT("phy.init_phy_params was NULL\n");
104 ret_val
= -E1000_ERR_CONFIG
;
112 * e1000_set_mac_type - Sets MAC type
113 * @hw: pointer to the HW structure
115 * This function sets the mac type of the adapter based on the
116 * device ID stored in the hw structure.
117 * MUST BE FIRST FUNCTION CALLED (explicitly or through
118 * e1000_setup_init_funcs()).
120 s32
e1000_set_mac_type(struct e1000_hw
*hw
)
122 struct e1000_mac_info
*mac
= &hw
->mac
;
123 s32 ret_val
= E1000_SUCCESS
;
125 DEBUGFUNC("e1000_set_mac_type");
127 switch (hw
->device_id
) {
128 case E1000_DEV_ID_82542
:
129 mac
->type
= e1000_82542
;
131 case E1000_DEV_ID_82543GC_FIBER
:
132 case E1000_DEV_ID_82543GC_COPPER
:
133 mac
->type
= e1000_82543
;
135 case E1000_DEV_ID_82544EI_COPPER
:
136 case E1000_DEV_ID_82544EI_FIBER
:
137 case E1000_DEV_ID_82544GC_COPPER
:
138 case E1000_DEV_ID_82544GC_LOM
:
139 mac
->type
= e1000_82544
;
141 case E1000_DEV_ID_82540EM
:
142 case E1000_DEV_ID_82540EM_LOM
:
143 case E1000_DEV_ID_82540EP
:
144 case E1000_DEV_ID_82540EP_LOM
:
145 case E1000_DEV_ID_82540EP_LP
:
146 mac
->type
= e1000_82540
;
148 case E1000_DEV_ID_82545EM_COPPER
:
149 case E1000_DEV_ID_82545EM_FIBER
:
150 mac
->type
= e1000_82545
;
152 case E1000_DEV_ID_82545GM_COPPER
:
153 case E1000_DEV_ID_82545GM_FIBER
:
154 case E1000_DEV_ID_82545GM_SERDES
:
155 mac
->type
= e1000_82545_rev_3
;
157 case E1000_DEV_ID_82546EB_COPPER
:
158 case E1000_DEV_ID_82546EB_FIBER
:
159 case E1000_DEV_ID_82546EB_QUAD_COPPER
:
160 mac
->type
= e1000_82546
;
162 case E1000_DEV_ID_82546GB_COPPER
:
163 case E1000_DEV_ID_82546GB_FIBER
:
164 case E1000_DEV_ID_82546GB_SERDES
:
165 case E1000_DEV_ID_82546GB_PCIE
:
166 case E1000_DEV_ID_82546GB_QUAD_COPPER
:
167 case E1000_DEV_ID_82546GB_QUAD_COPPER_KSP3
:
168 mac
->type
= e1000_82546_rev_3
;
170 case E1000_DEV_ID_82541EI
:
171 case E1000_DEV_ID_82541EI_MOBILE
:
172 case E1000_DEV_ID_82541ER_LOM
:
173 mac
->type
= e1000_82541
;
175 case E1000_DEV_ID_82541ER
:
176 case E1000_DEV_ID_82541GI
:
177 case E1000_DEV_ID_82541GI_LF
:
178 case E1000_DEV_ID_82541GI_MOBILE
:
179 mac
->type
= e1000_82541_rev_2
;
181 case E1000_DEV_ID_82547EI
:
182 case E1000_DEV_ID_82547EI_MOBILE
:
183 mac
->type
= e1000_82547
;
185 case E1000_DEV_ID_82547GI
:
186 mac
->type
= e1000_82547_rev_2
;
189 /* Should never have loaded on this device */
190 ret_val
= -E1000_ERR_MAC_INIT
;
198 * e1000_setup_init_funcs - Initializes function pointers
199 * @hw: pointer to the HW structure
200 * @init_device: true will initialize the rest of the function pointers
201 * getting the device ready for use. false will only set
202 * MAC type and the function pointers for the other init
203 * functions. Passing false will not generate any hardware
206 * This function must be called by a driver in order to use the rest
207 * of the 'shared' code files. Called by drivers only.
209 s32
e1000_setup_init_funcs(struct e1000_hw
*hw
, bool init_device
)
213 /* Can't do much good without knowing the MAC type. */
214 ret_val
= e1000_set_mac_type(hw
);
216 DEBUGOUT("ERROR: MAC type could not be set properly.\n");
221 DEBUGOUT("ERROR: Registers not mapped\n");
222 ret_val
= -E1000_ERR_CONFIG
;
227 * Init function pointers to generic implementations. We do this first
228 * allowing a driver module to override it afterward.
230 e1000_init_mac_ops_generic(hw
);
231 e1000_init_phy_ops_generic(hw
);
232 e1000_init_nvm_ops_generic(hw
);
235 * Set up the init function pointers. These are functions within the
236 * adapter family file that sets up function pointers for the rest of
237 * the functions in that family.
239 switch (hw
->mac
.type
) {
241 e1000_init_function_pointers_82542(hw
);
245 e1000_init_function_pointers_82543(hw
);
249 case e1000_82545_rev_3
:
251 case e1000_82546_rev_3
:
252 e1000_init_function_pointers_82540(hw
);
255 case e1000_82541_rev_2
:
257 case e1000_82547_rev_2
:
258 e1000_init_function_pointers_82541(hw
);
261 DEBUGOUT("Hardware not supported\n");
262 ret_val
= -E1000_ERR_CONFIG
;
267 * Initialize the rest of the function pointers. These require some
268 * register reads/writes in some cases.
270 if (!(ret_val
) && init_device
) {
271 ret_val
= e1000_init_mac_params(hw
);
275 ret_val
= e1000_init_nvm_params(hw
);
279 ret_val
= e1000_init_phy_params(hw
);
289 * e1000_get_bus_info - Obtain bus information for adapter
290 * @hw: pointer to the HW structure
292 * This will obtain information about the HW bus for which the
293 * adapter is attached and stores it in the hw structure. This is a
294 * function pointer entry point called by drivers.
296 s32
e1000_get_bus_info(struct e1000_hw
*hw
)
298 if (hw
->mac
.ops
.get_bus_info
)
299 return hw
->mac
.ops
.get_bus_info(hw
);
301 return E1000_SUCCESS
;
305 * e1000_clear_vfta - Clear VLAN filter table
306 * @hw: pointer to the HW structure
308 * This clears the VLAN filter table on the adapter. This is a function
309 * pointer entry point called by drivers.
311 void e1000_clear_vfta(struct e1000_hw
*hw
)
313 if (hw
->mac
.ops
.clear_vfta
)
314 hw
->mac
.ops
.clear_vfta(hw
);
318 * e1000_write_vfta - Write value to VLAN filter table
319 * @hw: pointer to the HW structure
320 * @offset: the 32-bit offset in which to write the value to.
321 * @value: the 32-bit value to write at location offset.
323 * This writes a 32-bit value to a 32-bit offset in the VLAN filter
324 * table. This is a function pointer entry point called by drivers.
326 void e1000_write_vfta(struct e1000_hw
*hw
, u32 offset
, u32 value
)
328 if (hw
->mac
.ops
.write_vfta
)
329 hw
->mac
.ops
.write_vfta(hw
, offset
, value
);
333 * e1000_update_mc_addr_list - Update Multicast addresses
334 * @hw: pointer to the HW structure
335 * @mc_addr_list: array of multicast addresses to program
336 * @mc_addr_count: number of multicast addresses to program
338 * Updates the Multicast Table Array.
339 * The caller must have a packed mc_addr_list of multicast addresses.
341 void e1000_update_mc_addr_list(struct e1000_hw
*hw
, u8
*mc_addr_list
,
344 if (hw
->mac
.ops
.update_mc_addr_list
)
345 hw
->mac
.ops
.update_mc_addr_list(hw
, mc_addr_list
,
350 * e1000_force_mac_fc - Force MAC flow control
351 * @hw: pointer to the HW structure
353 * Force the MAC's flow control settings. Currently no func pointer exists
354 * and all implementations are handled in the generic version of this
357 s32
e1000_force_mac_fc(struct e1000_hw
*hw
)
359 return e1000_force_mac_fc_generic(hw
);
363 * e1000_check_for_link - Check/Store link connection
364 * @hw: pointer to the HW structure
366 * This checks the link condition of the adapter and stores the
367 * results in the hw->mac structure. This is a function pointer entry
368 * point called by drivers.
370 s32
e1000_check_for_link(struct e1000_hw
*hw
)
372 if (hw
->mac
.ops
.check_for_link
)
373 return hw
->mac
.ops
.check_for_link(hw
);
375 return -E1000_ERR_CONFIG
;
380 * e1000_check_mng_mode - Check management mode
381 * @hw: pointer to the HW structure
383 * This checks if the adapter has manageability enabled.
384 * This is a function pointer entry point called by drivers.
386 bool e1000_check_mng_mode(struct e1000_hw
*hw
)
388 if (hw
->mac
.ops
.check_mng_mode
)
389 return hw
->mac
.ops
.check_mng_mode(hw
);
395 * e1000_mng_write_dhcp_info - Writes DHCP info to host interface
396 * @hw: pointer to the HW structure
397 * @buffer: pointer to the host interface
398 * @length: size of the buffer
400 * Writes the DHCP information to the host interface.
402 s32
e1000_mng_write_dhcp_info(struct e1000_hw
*hw
, u8
*buffer
, u16 length
)
404 return e1000_mng_write_dhcp_info_generic(hw
, buffer
, length
);
409 * e1000_reset_hw - Reset hardware
410 * @hw: pointer to the HW structure
412 * This resets the hardware into a known state. This is a function pointer
413 * entry point called by drivers.
415 s32
e1000_reset_hw(struct e1000_hw
*hw
)
417 if (hw
->mac
.ops
.reset_hw
)
418 return hw
->mac
.ops
.reset_hw(hw
);
420 return -E1000_ERR_CONFIG
;
424 * e1000_init_hw - Initialize hardware
425 * @hw: pointer to the HW structure
427 * This inits the hardware readying it for operation. This is a function
428 * pointer entry point called by drivers.
430 s32
e1000_init_hw(struct e1000_hw
*hw
)
432 if (hw
->mac
.ops
.init_hw
)
433 return hw
->mac
.ops
.init_hw(hw
);
435 return -E1000_ERR_CONFIG
;
439 * e1000_setup_link - Configures link and flow control
440 * @hw: pointer to the HW structure
442 * This configures link and flow control settings for the adapter. This
443 * is a function pointer entry point called by drivers. While modules can
444 * also call this, they probably call their own version of this function.
446 s32
e1000_setup_link(struct e1000_hw
*hw
)
448 if (hw
->mac
.ops
.setup_link
)
449 return hw
->mac
.ops
.setup_link(hw
);
451 return -E1000_ERR_CONFIG
;
455 * e1000_get_speed_and_duplex - Returns current speed and duplex
456 * @hw: pointer to the HW structure
457 * @speed: pointer to a 16-bit value to store the speed
458 * @duplex: pointer to a 16-bit value to store the duplex.
460 * This returns the speed and duplex of the adapter in the two 'out'
461 * variables passed in. This is a function pointer entry point called
464 s32
e1000_get_speed_and_duplex(struct e1000_hw
*hw
, u16
*speed
, u16
*duplex
)
466 if (hw
->mac
.ops
.get_link_up_info
)
467 return hw
->mac
.ops
.get_link_up_info(hw
, speed
, duplex
);
469 return -E1000_ERR_CONFIG
;
473 * e1000_setup_led - Configures SW controllable LED
474 * @hw: pointer to the HW structure
476 * This prepares the SW controllable LED for use and saves the current state
477 * of the LED so it can be later restored. This is a function pointer entry
478 * point called by drivers.
480 s32
e1000_setup_led(struct e1000_hw
*hw
)
482 if (hw
->mac
.ops
.setup_led
)
483 return hw
->mac
.ops
.setup_led(hw
);
485 return E1000_SUCCESS
;
489 * e1000_cleanup_led - Restores SW controllable LED
490 * @hw: pointer to the HW structure
492 * This restores the SW controllable LED to the value saved off by
493 * e1000_setup_led. This is a function pointer entry point called by drivers.
495 s32
e1000_cleanup_led(struct e1000_hw
*hw
)
497 if (hw
->mac
.ops
.cleanup_led
)
498 return hw
->mac
.ops
.cleanup_led(hw
);
500 return E1000_SUCCESS
;
504 * e1000_blink_led - Blink SW controllable LED
505 * @hw: pointer to the HW structure
507 * This starts the adapter LED blinking. Request the LED to be setup first
508 * and cleaned up after. This is a function pointer entry point called by
511 s32
e1000_blink_led(struct e1000_hw
*hw
)
513 if (hw
->mac
.ops
.blink_led
)
514 return hw
->mac
.ops
.blink_led(hw
);
516 return E1000_SUCCESS
;
520 * e1000_id_led_init - store LED configurations in SW
521 * @hw: pointer to the HW structure
523 * Initializes the LED config in SW. This is a function pointer entry point
526 s32
e1000_id_led_init(struct e1000_hw
*hw
)
528 if (hw
->mac
.ops
.id_led_init
)
529 return hw
->mac
.ops
.id_led_init(hw
);
531 return E1000_SUCCESS
;
535 * e1000_led_on - Turn on SW controllable LED
536 * @hw: pointer to the HW structure
538 * Turns the SW defined LED on. This is a function pointer entry point
541 s32
e1000_led_on(struct e1000_hw
*hw
)
543 if (hw
->mac
.ops
.led_on
)
544 return hw
->mac
.ops
.led_on(hw
);
546 return E1000_SUCCESS
;
550 * e1000_led_off - Turn off SW controllable LED
551 * @hw: pointer to the HW structure
553 * Turns the SW defined LED off. This is a function pointer entry point
556 s32
e1000_led_off(struct e1000_hw
*hw
)
558 if (hw
->mac
.ops
.led_off
)
559 return hw
->mac
.ops
.led_off(hw
);
561 return E1000_SUCCESS
;
565 * e1000_reset_adaptive - Reset adaptive IFS
566 * @hw: pointer to the HW structure
568 * Resets the adaptive IFS. Currently no func pointer exists and all
569 * implementations are handled in the generic version of this function.
571 void e1000_reset_adaptive(struct e1000_hw
*hw
)
573 e1000_reset_adaptive_generic(hw
);
577 * e1000_update_adaptive - Update adaptive IFS
578 * @hw: pointer to the HW structure
580 * Updates adapter IFS. Currently no func pointer exists and all
581 * implementations are handled in the generic version of this function.
583 void e1000_update_adaptive(struct e1000_hw
*hw
)
585 e1000_update_adaptive_generic(hw
);
589 * e1000_disable_pcie_master - Disable PCI-Express master access
590 * @hw: pointer to the HW structure
592 * Disables PCI-Express master access and verifies there are no pending
593 * requests. Currently no func pointer exists and all implementations are
594 * handled in the generic version of this function.
596 s32
e1000_disable_pcie_master(struct e1000_hw
*hw
)
598 return e1000_disable_pcie_master_generic(hw
);
602 * e1000_config_collision_dist - Configure collision distance
603 * @hw: pointer to the HW structure
605 * Configures the collision distance to the default value and is used
608 void e1000_config_collision_dist(struct e1000_hw
*hw
)
610 if (hw
->mac
.ops
.config_collision_dist
)
611 hw
->mac
.ops
.config_collision_dist(hw
);
615 * e1000_rar_set - Sets a receive address register
616 * @hw: pointer to the HW structure
617 * @addr: address to set the RAR to
618 * @index: the RAR to set
620 * Sets a Receive Address Register (RAR) to the specified address.
622 void e1000_rar_set(struct e1000_hw
*hw
, u8
*addr
, u32 index
)
624 if (hw
->mac
.ops
.rar_set
)
625 hw
->mac
.ops
.rar_set(hw
, addr
, index
);
629 * e1000_validate_mdi_setting - Ensures valid MDI/MDIX SW state
630 * @hw: pointer to the HW structure
632 * Ensures that the MDI/MDIX SW state is valid.
634 s32
e1000_validate_mdi_setting(struct e1000_hw
*hw
)
636 if (hw
->mac
.ops
.validate_mdi_setting
)
637 return hw
->mac
.ops
.validate_mdi_setting(hw
);
639 return E1000_SUCCESS
;
643 * e1000_mta_set - Sets multicast table bit
644 * @hw: pointer to the HW structure
645 * @hash_value: Multicast hash value.
647 * This sets the bit in the multicast table corresponding to the
648 * hash value. This is a function pointer entry point called by drivers.
650 void e1000_mta_set(struct e1000_hw
*hw
, u32 hash_value
)
652 if (hw
->mac
.ops
.mta_set
)
653 hw
->mac
.ops
.mta_set(hw
, hash_value
);
657 * e1000_hash_mc_addr - Determines address location in multicast table
658 * @hw: pointer to the HW structure
659 * @mc_addr: Multicast address to hash.
661 * This hashes an address to determine its location in the multicast
662 * table. Currently no func pointer exists and all implementations
663 * are handled in the generic version of this function.
665 u32
e1000_hash_mc_addr(struct e1000_hw
*hw
, u8
*mc_addr
)
667 return e1000_hash_mc_addr_generic(hw
, mc_addr
);
672 * e1000_enable_tx_pkt_filtering - Enable packet filtering on TX
673 * @hw: pointer to the HW structure
675 * Enables packet filtering on transmit packets if manageability is enabled
676 * and host interface is enabled.
677 * Currently no func pointer exists and all implementations are handled in the
678 * generic version of this function.
680 bool e1000_enable_tx_pkt_filtering(struct e1000_hw
*hw
)
682 return e1000_enable_tx_pkt_filtering_generic(hw
);
686 * e1000_mng_host_if_write - Writes to the manageability host interface
687 * @hw: pointer to the HW structure
688 * @buffer: pointer to the host interface buffer
689 * @length: size of the buffer
690 * @offset: location in the buffer to write to
691 * @sum: sum of the data (not checksum)
693 * This function writes the buffer content at the offset given on the host if.
694 * It also does alignment considerations to do the writes in most efficient
695 * way. Also fills up the sum of the buffer in *buffer parameter.
697 s32
e1000_mng_host_if_write(struct e1000_hw
* hw
, u8
*buffer
, u16 length
,
700 if (hw
->mac
.ops
.mng_host_if_write
)
701 return hw
->mac
.ops
.mng_host_if_write(hw
, buffer
, length
,
704 return E1000_NOT_IMPLEMENTED
;
708 * e1000_mng_write_cmd_header - Writes manageability command header
709 * @hw: pointer to the HW structure
710 * @hdr: pointer to the host interface command header
712 * Writes the command header after does the checksum calculation.
714 s32
e1000_mng_write_cmd_header(struct e1000_hw
*hw
,
715 struct e1000_host_mng_command_header
*hdr
)
717 if (hw
->mac
.ops
.mng_write_cmd_header
)
718 return hw
->mac
.ops
.mng_write_cmd_header(hw
, hdr
);
720 return E1000_NOT_IMPLEMENTED
;
724 * e1000_mng_enable_host_if - Checks host interface is enabled
725 * @hw: pointer to the HW structure
727 * Returns E1000_success upon success, else E1000_ERR_HOST_INTERFACE_COMMAND
729 * This function checks whether the HOST IF is enabled for command operation
730 * and also checks whether the previous command is completed. It busy waits
731 * in case of previous command is not completed.
733 s32
e1000_mng_enable_host_if(struct e1000_hw
* hw
)
735 if (hw
->mac
.ops
.mng_enable_host_if
)
736 return hw
->mac
.ops
.mng_enable_host_if(hw
);
738 return E1000_NOT_IMPLEMENTED
;
743 * e1000_wait_autoneg - Waits for autonegotiation completion
744 * @hw: pointer to the HW structure
746 * Waits for autoneg to complete. Currently no func pointer exists and all
747 * implementations are handled in the generic version of this function.
749 s32
e1000_wait_autoneg(struct e1000_hw
*hw
)
751 if (hw
->mac
.ops
.wait_autoneg
)
752 return hw
->mac
.ops
.wait_autoneg(hw
);
754 return E1000_SUCCESS
;
758 * e1000_check_reset_block - Verifies PHY can be reset
759 * @hw: pointer to the HW structure
761 * Checks if the PHY is in a state that can be reset or if manageability
762 * has it tied up. This is a function pointer entry point called by drivers.
764 s32
e1000_check_reset_block(struct e1000_hw
*hw
)
766 if (hw
->phy
.ops
.check_reset_block
)
767 return hw
->phy
.ops
.check_reset_block(hw
);
769 return E1000_SUCCESS
;
773 * e1000_read_phy_reg - Reads PHY register
774 * @hw: pointer to the HW structure
775 * @offset: the register to read
776 * @data: the buffer to store the 16-bit read.
778 * Reads the PHY register and returns the value in data.
779 * This is a function pointer entry point called by drivers.
781 s32
e1000_read_phy_reg(struct e1000_hw
*hw
, u32 offset
, u16
*data
)
783 if (hw
->phy
.ops
.read_reg
)
784 return hw
->phy
.ops
.read_reg(hw
, offset
, data
);
786 return E1000_SUCCESS
;
790 * e1000_write_phy_reg - Writes PHY register
791 * @hw: pointer to the HW structure
792 * @offset: the register to write
793 * @data: the value to write.
795 * Writes the PHY register at offset with the value in data.
796 * This is a function pointer entry point called by drivers.
798 s32
e1000_write_phy_reg(struct e1000_hw
*hw
, u32 offset
, u16 data
)
800 if (hw
->phy
.ops
.write_reg
)
801 return hw
->phy
.ops
.write_reg(hw
, offset
, data
);
803 return E1000_SUCCESS
;
807 * e1000_release_phy - Generic release PHY
808 * @hw: pointer to the HW structure
810 * Return if silicon family does not require a semaphore when accessing the
813 void e1000_release_phy(struct e1000_hw
*hw
)
815 if (hw
->phy
.ops
.release
)
816 hw
->phy
.ops
.release(hw
);
820 * e1000_acquire_phy - Generic acquire PHY
821 * @hw: pointer to the HW structure
823 * Return success if silicon family does not require a semaphore when
826 s32
e1000_acquire_phy(struct e1000_hw
*hw
)
828 if (hw
->phy
.ops
.acquire
)
829 return hw
->phy
.ops
.acquire(hw
);
831 return E1000_SUCCESS
;
835 * e1000_read_kmrn_reg - Reads register using Kumeran interface
836 * @hw: pointer to the HW structure
837 * @offset: the register to read
838 * @data: the location to store the 16-bit value read.
840 * Reads a register out of the Kumeran interface. Currently no func pointer
841 * exists and all implementations are handled in the generic version of
844 s32
e1000_read_kmrn_reg(struct e1000_hw
*hw
, u32 offset
, u16
*data
)
846 return e1000_read_kmrn_reg_generic(hw
, offset
, data
);
850 * e1000_write_kmrn_reg - Writes register using Kumeran interface
851 * @hw: pointer to the HW structure
852 * @offset: the register to write
853 * @data: the value to write.
855 * Writes a register to the Kumeran interface. Currently no func pointer
856 * exists and all implementations are handled in the generic version of
859 s32
e1000_write_kmrn_reg(struct e1000_hw
*hw
, u32 offset
, u16 data
)
861 return e1000_write_kmrn_reg_generic(hw
, offset
, data
);
866 * e1000_get_cable_length - Retrieves cable length estimation
867 * @hw: pointer to the HW structure
869 * This function estimates the cable length and stores them in
870 * hw->phy.min_length and hw->phy.max_length. This is a function pointer
871 * entry point called by drivers.
873 s32
e1000_get_cable_length(struct e1000_hw
*hw
)
875 if (hw
->phy
.ops
.get_cable_length
)
876 return hw
->phy
.ops
.get_cable_length(hw
);
878 return E1000_SUCCESS
;
883 * e1000_get_phy_info - Retrieves PHY information from registers
884 * @hw: pointer to the HW structure
886 * This function gets some information from various PHY registers and
887 * populates hw->phy values with it. This is a function pointer entry
888 * point called by drivers.
890 s32
e1000_get_phy_info(struct e1000_hw
*hw
)
892 if (hw
->phy
.ops
.get_info
)
893 return hw
->phy
.ops
.get_info(hw
);
895 return E1000_SUCCESS
;
899 * e1000_phy_hw_reset - Hard PHY reset
900 * @hw: pointer to the HW structure
902 * Performs a hard PHY reset. This is a function pointer entry point called
905 s32
e1000_phy_hw_reset(struct e1000_hw
*hw
)
907 if (hw
->phy
.ops
.reset
)
908 return hw
->phy
.ops
.reset(hw
);
910 return E1000_SUCCESS
;
914 * e1000_phy_commit - Soft PHY reset
915 * @hw: pointer to the HW structure
917 * Performs a soft PHY reset on those that apply. This is a function pointer
918 * entry point called by drivers.
920 s32
e1000_phy_commit(struct e1000_hw
*hw
)
922 if (hw
->phy
.ops
.commit
)
923 return hw
->phy
.ops
.commit(hw
);
925 return E1000_SUCCESS
;
929 * e1000_set_d0_lplu_state - Sets low power link up state for D0
930 * @hw: pointer to the HW structure
931 * @active: boolean used to enable/disable lplu
933 * Success returns 0, Failure returns 1
935 * The low power link up (lplu) state is set to the power management level D0
936 * and SmartSpeed is disabled when active is true, else clear lplu for D0
937 * and enable Smartspeed. LPLU and Smartspeed are mutually exclusive. LPLU
938 * is used during Dx states where the power conservation is most important.
939 * During driver activity, SmartSpeed should be enabled so performance is
940 * maintained. This is a function pointer entry point called by drivers.
942 s32
e1000_set_d0_lplu_state(struct e1000_hw
*hw
, bool active
)
944 if (hw
->phy
.ops
.set_d0_lplu_state
)
945 return hw
->phy
.ops
.set_d0_lplu_state(hw
, active
);
947 return E1000_SUCCESS
;
951 * e1000_set_d3_lplu_state - Sets low power link up state for D3
952 * @hw: pointer to the HW structure
953 * @active: boolean used to enable/disable lplu
955 * Success returns 0, Failure returns 1
957 * The low power link up (lplu) state is set to the power management level D3
958 * and SmartSpeed is disabled when active is true, else clear lplu for D3
959 * and enable Smartspeed. LPLU and Smartspeed are mutually exclusive. LPLU
960 * is used during Dx states where the power conservation is most important.
961 * During driver activity, SmartSpeed should be enabled so performance is
962 * maintained. This is a function pointer entry point called by drivers.
964 s32
e1000_set_d3_lplu_state(struct e1000_hw
*hw
, bool active
)
966 if (hw
->phy
.ops
.set_d3_lplu_state
)
967 return hw
->phy
.ops
.set_d3_lplu_state(hw
, active
);
969 return E1000_SUCCESS
;
973 * e1000_read_mac_addr - Reads MAC address
974 * @hw: pointer to the HW structure
976 * Reads the MAC address out of the adapter and stores it in the HW structure.
977 * Currently no func pointer exists and all implementations are handled in the
978 * generic version of this function.
980 s32
e1000_read_mac_addr(struct e1000_hw
*hw
)
982 if (hw
->mac
.ops
.read_mac_addr
)
983 return hw
->mac
.ops
.read_mac_addr(hw
);
985 return e1000_read_mac_addr_generic(hw
);
989 * e1000_read_pba_num - Read device part number
990 * @hw: pointer to the HW structure
991 * @pba_num: pointer to device part number
993 * Reads the product board assembly (PBA) number from the EEPROM and stores
994 * the value in pba_num.
995 * Currently no func pointer exists and all implementations are handled in the
996 * generic version of this function.
998 s32
e1000_read_pba_num(struct e1000_hw
*hw
, u32
*pba_num
)
1000 return e1000_read_pba_num_generic(hw
, pba_num
);
1004 * e1000_validate_nvm_checksum - Verifies NVM (EEPROM) checksum
1005 * @hw: pointer to the HW structure
1007 * Validates the NVM checksum is correct. This is a function pointer entry
1008 * point called by drivers.
1010 s32
e1000_validate_nvm_checksum(struct e1000_hw
*hw
)
1012 if (hw
->nvm
.ops
.validate
)
1013 return hw
->nvm
.ops
.validate(hw
);
1015 return -E1000_ERR_CONFIG
;
1019 * e1000_update_nvm_checksum - Updates NVM (EEPROM) checksum
1020 * @hw: pointer to the HW structure
1022 * Updates the NVM checksum. Currently no func pointer exists and all
1023 * implementations are handled in the generic version of this function.
1025 s32
e1000_update_nvm_checksum(struct e1000_hw
*hw
)
1027 if (hw
->nvm
.ops
.update
)
1028 return hw
->nvm
.ops
.update(hw
);
1030 return -E1000_ERR_CONFIG
;
1034 * e1000_reload_nvm - Reloads EEPROM
1035 * @hw: pointer to the HW structure
1037 * Reloads the EEPROM by setting the "Reinitialize from EEPROM" bit in the
1038 * extended control register.
1040 void e1000_reload_nvm(struct e1000_hw
*hw
)
1042 if (hw
->nvm
.ops
.reload
)
1043 hw
->nvm
.ops
.reload(hw
);
1047 * e1000_read_nvm - Reads NVM (EEPROM)
1048 * @hw: pointer to the HW structure
1049 * @offset: the word offset to read
1050 * @words: number of 16-bit words to read
1051 * @data: pointer to the properly sized buffer for the data.
1053 * Reads 16-bit chunks of data from the NVM (EEPROM). This is a function
1054 * pointer entry point called by drivers.
1056 s32
e1000_read_nvm(struct e1000_hw
*hw
, u16 offset
, u16 words
, u16
*data
)
1058 if (hw
->nvm
.ops
.read
)
1059 return hw
->nvm
.ops
.read(hw
, offset
, words
, data
);
1061 return -E1000_ERR_CONFIG
;
1065 * e1000_write_nvm - Writes to NVM (EEPROM)
1066 * @hw: pointer to the HW structure
1067 * @offset: the word offset to read
1068 * @words: number of 16-bit words to write
1069 * @data: pointer to the properly sized buffer for the data.
1071 * Writes 16-bit chunks of data to the NVM (EEPROM). This is a function
1072 * pointer entry point called by drivers.
1074 s32
e1000_write_nvm(struct e1000_hw
*hw
, u16 offset
, u16 words
, u16
*data
)
1076 if (hw
->nvm
.ops
.write
)
1077 return hw
->nvm
.ops
.write(hw
, offset
, words
, data
);
1079 return E1000_SUCCESS
;
1083 * e1000_power_up_phy - Restores link in case of PHY power down
1084 * @hw: pointer to the HW structure
1086 * The phy may be powered down to save power, to turn off link when the
1087 * driver is unloaded, or wake on lan is not enabled (among others).
1089 void e1000_power_up_phy(struct e1000_hw
*hw
)
1091 if (hw
->phy
.ops
.power_up
)
1092 hw
->phy
.ops
.power_up(hw
);
1094 e1000_setup_link(hw
);
1098 * e1000_power_down_phy - Power down PHY
1099 * @hw: pointer to the HW structure
1101 * The phy may be powered down to save power, to turn off link when the
1102 * driver is unloaded, or wake on lan is not enabled (among others).
1104 void e1000_power_down_phy(struct e1000_hw
*hw
)
1106 if (hw
->phy
.ops
.power_down
)
1107 hw
->phy
.ops
.power_down(hw
);