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 #include "e1000_api.h"
30 #include "e1000_mac.h"
31 #include "e1000_nvm.h"
32 #include "e1000_phy.h"
35 * e1000_init_mac_params - Initialize MAC function pointers
36 * @hw: pointer to the HW structure
38 * This function initializes the function pointers for the MAC
39 * set of functions. Called by drivers or by e1000_setup_init_funcs.
41 s32
e1000_init_mac_params(struct e1000_hw
*hw
)
43 s32 ret_val
= E1000_SUCCESS
;
45 if (hw
->mac
.ops
.init_params
) {
46 ret_val
= hw
->mac
.ops
.init_params(hw
);
48 DEBUGOUT("MAC Initialization Error\n");
52 DEBUGOUT("mac.init_mac_params was NULL\n");
53 ret_val
= -E1000_ERR_CONFIG
;
61 * e1000_init_nvm_params - Initialize NVM function pointers
62 * @hw: pointer to the HW structure
64 * This function initializes the function pointers for the NVM
65 * set of functions. Called by drivers or by e1000_setup_init_funcs.
67 s32
e1000_init_nvm_params(struct e1000_hw
*hw
)
69 s32 ret_val
= E1000_SUCCESS
;
71 if (hw
->nvm
.ops
.init_params
) {
72 ret_val
= hw
->nvm
.ops
.init_params(hw
);
74 DEBUGOUT("NVM Initialization Error\n");
78 DEBUGOUT("nvm.init_nvm_params was NULL\n");
79 ret_val
= -E1000_ERR_CONFIG
;
87 * e1000_init_phy_params - Initialize PHY function pointers
88 * @hw: pointer to the HW structure
90 * This function initializes the function pointers for the PHY
91 * set of functions. Called by drivers or by e1000_setup_init_funcs.
93 s32
e1000_init_phy_params(struct e1000_hw
*hw
)
95 s32 ret_val
= E1000_SUCCESS
;
97 if (hw
->phy
.ops
.init_params
) {
98 ret_val
= hw
->phy
.ops
.init_params(hw
);
100 DEBUGOUT("PHY Initialization Error\n");
104 DEBUGOUT("phy.init_phy_params was NULL\n");
105 ret_val
= -E1000_ERR_CONFIG
;
113 * e1000_set_mac_type - Sets MAC type
114 * @hw: pointer to the HW structure
116 * This function sets the mac type of the adapter based on the
117 * device ID stored in the hw structure.
118 * MUST BE FIRST FUNCTION CALLED (explicitly or through
119 * e1000_setup_init_funcs()).
121 s32
e1000_set_mac_type(struct e1000_hw
*hw
)
123 struct e1000_mac_info
*mac
= &hw
->mac
;
124 s32 ret_val
= E1000_SUCCESS
;
126 DEBUGFUNC("e1000_set_mac_type");
128 switch (hw
->device_id
) {
129 case E1000_DEV_ID_82542
:
130 mac
->type
= e1000_82542
;
132 case E1000_DEV_ID_82543GC_FIBER
:
133 case E1000_DEV_ID_82543GC_COPPER
:
134 mac
->type
= e1000_82543
;
136 case E1000_DEV_ID_82544EI_COPPER
:
137 case E1000_DEV_ID_82544EI_FIBER
:
138 case E1000_DEV_ID_82544GC_COPPER
:
139 case E1000_DEV_ID_82544GC_LOM
:
140 mac
->type
= e1000_82544
;
142 case E1000_DEV_ID_82540EM
:
143 case E1000_DEV_ID_82540EM_LOM
:
144 case E1000_DEV_ID_82540EP
:
145 case E1000_DEV_ID_82540EP_LOM
:
146 case E1000_DEV_ID_82540EP_LP
:
147 mac
->type
= e1000_82540
;
149 case E1000_DEV_ID_82545EM_COPPER
:
150 case E1000_DEV_ID_82545EM_FIBER
:
151 mac
->type
= e1000_82545
;
153 case E1000_DEV_ID_82545GM_COPPER
:
154 case E1000_DEV_ID_82545GM_FIBER
:
155 case E1000_DEV_ID_82545GM_SERDES
:
156 mac
->type
= e1000_82545_rev_3
;
158 case E1000_DEV_ID_82546EB_COPPER
:
159 case E1000_DEV_ID_82546EB_FIBER
:
160 case E1000_DEV_ID_82546EB_QUAD_COPPER
:
161 mac
->type
= e1000_82546
;
163 case E1000_DEV_ID_82546GB_COPPER
:
164 case E1000_DEV_ID_82546GB_FIBER
:
165 case E1000_DEV_ID_82546GB_SERDES
:
166 case E1000_DEV_ID_82546GB_PCIE
:
167 case E1000_DEV_ID_82546GB_QUAD_COPPER
:
168 case E1000_DEV_ID_82546GB_QUAD_COPPER_KSP3
:
169 mac
->type
= e1000_82546_rev_3
;
171 case E1000_DEV_ID_82541EI
:
172 case E1000_DEV_ID_82541EI_MOBILE
:
173 case E1000_DEV_ID_82541ER_LOM
:
174 mac
->type
= e1000_82541
;
176 case E1000_DEV_ID_82541ER
:
177 case E1000_DEV_ID_82541GI
:
178 case E1000_DEV_ID_82541GI_LF
:
179 case E1000_DEV_ID_82541GI_MOBILE
:
180 mac
->type
= e1000_82541_rev_2
;
182 case E1000_DEV_ID_82547EI
:
183 case E1000_DEV_ID_82547EI_MOBILE
:
184 mac
->type
= e1000_82547
;
186 case E1000_DEV_ID_82547GI
:
187 mac
->type
= e1000_82547_rev_2
;
190 /* Should never have loaded on this device */
191 ret_val
= -E1000_ERR_MAC_INIT
;
199 * e1000_setup_init_funcs - Initializes function pointers
200 * @hw: pointer to the HW structure
201 * @init_device: TRUE will initialize the rest of the function pointers
202 * getting the device ready for use. FALSE will only set
203 * MAC type and the function pointers for the other init
204 * functions. Passing FALSE will not generate any hardware
207 * This function must be called by a driver in order to use the rest
208 * of the 'shared' code files. Called by drivers only.
210 s32
e1000_setup_init_funcs(struct e1000_hw
*hw
, bool init_device
)
214 /* Can't do much good without knowing the MAC type. */
215 ret_val
= e1000_set_mac_type(hw
);
217 DEBUGOUT("ERROR: MAC type could not be set properly.\n");
222 DEBUGOUT("ERROR: Registers not mapped\n");
223 ret_val
= -E1000_ERR_CONFIG
;
228 * Init function pointers to generic implementations. We do this first
229 * allowing a driver module to override it afterward.
231 e1000_init_mac_ops_generic(hw
);
232 e1000_init_phy_ops_generic(hw
);
233 e1000_init_nvm_ops_generic(hw
);
236 * Set up the init function pointers. These are functions within the
237 * adapter family file that sets up function pointers for the rest of
238 * the functions in that family.
240 switch (hw
->mac
.type
) {
242 e1000_init_function_pointers_82542(hw
);
246 e1000_init_function_pointers_82543(hw
);
250 case e1000_82545_rev_3
:
252 case e1000_82546_rev_3
:
253 e1000_init_function_pointers_82540(hw
);
256 case e1000_82541_rev_2
:
258 case e1000_82547_rev_2
:
259 e1000_init_function_pointers_82541(hw
);
262 DEBUGOUT("Hardware not supported\n");
263 ret_val
= -E1000_ERR_CONFIG
;
268 * Initialize the rest of the function pointers. These require some
269 * register reads/writes in some cases.
271 if (!(ret_val
) && init_device
) {
272 ret_val
= e1000_init_mac_params(hw
);
276 ret_val
= e1000_init_nvm_params(hw
);
280 ret_val
= e1000_init_phy_params(hw
);
291 * e1000_remove_device - Free device specific structure
292 * @hw: pointer to the HW structure
294 * If a device specific structure was allocated, this function will
295 * free it. This is a function pointer entry point called by drivers.
297 void e1000_remove_device(struct e1000_hw
*hw
)
299 if (hw
->mac
.ops
.remove_device
)
300 hw
->mac
.ops
.remove_device(hw
);
304 * e1000_get_bus_info - Obtain bus information for adapter
305 * @hw: pointer to the HW structure
307 * This will obtain information about the HW bus for which the
308 * adapter is attached and stores it in the hw structure. This is a
309 * function pointer entry point called by drivers.
311 s32
e1000_get_bus_info(struct e1000_hw
*hw
)
313 if (hw
->mac
.ops
.get_bus_info
)
314 return hw
->mac
.ops
.get_bus_info(hw
);
316 return E1000_SUCCESS
;
320 * e1000_clear_vfta - Clear VLAN filter table
321 * @hw: pointer to the HW structure
323 * This clears the VLAN filter table on the adapter. This is a function
324 * pointer entry point called by drivers.
326 void e1000_clear_vfta(struct e1000_hw
*hw
)
328 if (hw
->mac
.ops
.clear_vfta
)
329 hw
->mac
.ops
.clear_vfta (hw
);
333 * e1000_write_vfta - Write value to VLAN filter table
334 * @hw: pointer to the HW structure
335 * @offset: the 32-bit offset in which to write the value to.
336 * @value: the 32-bit value to write at location offset.
338 * This writes a 32-bit value to a 32-bit offset in the VLAN filter
339 * table. This is a function pointer entry point called by drivers.
341 void e1000_write_vfta(struct e1000_hw
*hw
, u32 offset
, u32 value
)
343 if (hw
->mac
.ops
.write_vfta
)
344 hw
->mac
.ops
.write_vfta(hw
, offset
, value
);
348 * e1000_update_mc_addr_list - Update Multicast addresses
349 * @hw: pointer to the HW structure
350 * @mc_addr_list: array of multicast addresses to program
351 * @mc_addr_count: number of multicast addresses to program
352 * @rar_used_count: the first RAR register free to program
353 * @rar_count: total number of supported Receive Address Registers
355 * Updates the Receive Address Registers and Multicast Table Array.
356 * The caller must have a packed mc_addr_list of multicast addresses.
357 * The parameter rar_count will usually be hw->mac.rar_entry_count
358 * unless there are workarounds that change this. Currently no func pointer
359 * exists and all implementations are handled in the generic version of this
362 void e1000_update_mc_addr_list(struct e1000_hw
*hw
, u8
*mc_addr_list
,
363 u32 mc_addr_count
, u32 rar_used_count
,
366 if (hw
->mac
.ops
.update_mc_addr_list
)
367 hw
->mac
.ops
.update_mc_addr_list(hw
,
375 * e1000_force_mac_fc - Force MAC flow control
376 * @hw: pointer to the HW structure
378 * Force the MAC's flow control settings. Currently no func pointer exists
379 * and all implementations are handled in the generic version of this
382 s32
e1000_force_mac_fc(struct e1000_hw
*hw
)
384 return e1000_force_mac_fc_generic(hw
);
388 * e1000_check_for_link - Check/Store link connection
389 * @hw: pointer to the HW structure
391 * This checks the link condition of the adapter and stores the
392 * results in the hw->mac structure. This is a function pointer entry
393 * point called by drivers.
395 s32
e1000_check_for_link(struct e1000_hw
*hw
)
397 if (hw
->mac
.ops
.check_for_link
)
398 return hw
->mac
.ops
.check_for_link(hw
);
400 return -E1000_ERR_CONFIG
;
404 * e1000_check_mng_mode - Check management mode
405 * @hw: pointer to the HW structure
407 * This checks if the adapter has manageability enabled.
408 * This is a function pointer entry point called by drivers.
410 bool e1000_check_mng_mode(struct e1000_hw
*hw
)
412 if (hw
->mac
.ops
.check_mng_mode
)
413 return hw
->mac
.ops
.check_mng_mode(hw
);
419 * e1000_mng_write_dhcp_info - Writes DHCP info to host interface
420 * @hw: pointer to the HW structure
421 * @buffer: pointer to the host interface
422 * @length: size of the buffer
424 * Writes the DHCP information to the host interface.
426 s32
e1000_mng_write_dhcp_info(struct e1000_hw
*hw
, u8
*buffer
, u16 length
)
428 return e1000_mng_write_dhcp_info_generic(hw
, buffer
, length
);
432 * e1000_reset_hw - Reset hardware
433 * @hw: pointer to the HW structure
435 * This resets the hardware into a known state. This is a function pointer
436 * entry point called by drivers.
438 s32
e1000_reset_hw(struct e1000_hw
*hw
)
440 if (hw
->mac
.ops
.reset_hw
)
441 return hw
->mac
.ops
.reset_hw(hw
);
443 return -E1000_ERR_CONFIG
;
447 * e1000_init_hw - Initialize hardware
448 * @hw: pointer to the HW structure
450 * This inits the hardware readying it for operation. This is a function
451 * pointer entry point called by drivers.
453 s32
e1000_init_hw(struct e1000_hw
*hw
)
455 if (hw
->mac
.ops
.init_hw
)
456 return hw
->mac
.ops
.init_hw(hw
);
458 return -E1000_ERR_CONFIG
;
462 * e1000_setup_link - Configures link and flow control
463 * @hw: pointer to the HW structure
465 * This configures link and flow control settings for the adapter. This
466 * is a function pointer entry point called by drivers. While modules can
467 * also call this, they probably call their own version of this function.
469 s32
e1000_setup_link(struct e1000_hw
*hw
)
471 if (hw
->mac
.ops
.setup_link
)
472 return hw
->mac
.ops
.setup_link(hw
);
474 return -E1000_ERR_CONFIG
;
478 * e1000_get_speed_and_duplex - Returns current speed and duplex
479 * @hw: pointer to the HW structure
480 * @speed: pointer to a 16-bit value to store the speed
481 * @duplex: pointer to a 16-bit value to store the duplex.
483 * This returns the speed and duplex of the adapter in the two 'out'
484 * variables passed in. This is a function pointer entry point called
487 s32
e1000_get_speed_and_duplex(struct e1000_hw
*hw
, u16
*speed
, u16
*duplex
)
489 if (hw
->mac
.ops
.get_link_up_info
)
490 return hw
->mac
.ops
.get_link_up_info(hw
, speed
, duplex
);
492 return -E1000_ERR_CONFIG
;
496 * e1000_setup_led - Configures SW controllable LED
497 * @hw: pointer to the HW structure
499 * This prepares the SW controllable LED for use and saves the current state
500 * of the LED so it can be later restored. This is a function pointer entry
501 * point called by drivers.
503 s32
e1000_setup_led(struct e1000_hw
*hw
)
505 if (hw
->mac
.ops
.setup_led
)
506 return hw
->mac
.ops
.setup_led(hw
);
508 return E1000_SUCCESS
;
512 * e1000_cleanup_led - Restores SW controllable LED
513 * @hw: pointer to the HW structure
515 * This restores the SW controllable LED to the value saved off by
516 * e1000_setup_led. This is a function pointer entry point called by drivers.
518 s32
e1000_cleanup_led(struct e1000_hw
*hw
)
520 if (hw
->mac
.ops
.cleanup_led
)
521 return hw
->mac
.ops
.cleanup_led(hw
);
523 return E1000_SUCCESS
;
527 * e1000_blink_led - Blink SW controllable LED
528 * @hw: pointer to the HW structure
530 * This starts the adapter LED blinking. Request the LED to be setup first
531 * and cleaned up after. This is a function pointer entry point called by
534 s32
e1000_blink_led(struct e1000_hw
*hw
)
536 if (hw
->mac
.ops
.blink_led
)
537 return hw
->mac
.ops
.blink_led(hw
);
539 return E1000_SUCCESS
;
543 * e1000_led_on - Turn on SW controllable LED
544 * @hw: pointer to the HW structure
546 * Turns the SW defined LED on. This is a function pointer entry point
549 s32
e1000_led_on(struct e1000_hw
*hw
)
551 if (hw
->mac
.ops
.led_on
)
552 return hw
->mac
.ops
.led_on(hw
);
554 return E1000_SUCCESS
;
558 * e1000_led_off - Turn off SW controllable LED
559 * @hw: pointer to the HW structure
561 * Turns the SW defined LED off. This is a function pointer entry point
564 s32
e1000_led_off(struct e1000_hw
*hw
)
566 if (hw
->mac
.ops
.led_off
)
567 return hw
->mac
.ops
.led_off(hw
);
569 return E1000_SUCCESS
;
573 * e1000_reset_adaptive - Reset adaptive IFS
574 * @hw: pointer to the HW structure
576 * Resets the adaptive IFS. Currently no func pointer exists and all
577 * implementations are handled in the generic version of this function.
579 void e1000_reset_adaptive(struct e1000_hw
*hw
)
581 e1000_reset_adaptive_generic(hw
);
585 * e1000_update_adaptive - Update adaptive IFS
586 * @hw: pointer to the HW structure
588 * Updates adapter IFS. Currently no func pointer exists and all
589 * implementations are handled in the generic version of this function.
591 void e1000_update_adaptive(struct e1000_hw
*hw
)
593 e1000_update_adaptive_generic(hw
);
597 * e1000_disable_pcie_master - Disable PCI-Express master access
598 * @hw: pointer to the HW structure
600 * Disables PCI-Express master access and verifies there are no pending
601 * requests. Currently no func pointer exists and all implementations are
602 * handled in the generic version of this function.
604 s32
e1000_disable_pcie_master(struct e1000_hw
*hw
)
606 return e1000_disable_pcie_master_generic(hw
);
610 * e1000_config_collision_dist - Configure collision distance
611 * @hw: pointer to the HW structure
613 * Configures the collision distance to the default value and is used
616 void e1000_config_collision_dist(struct e1000_hw
*hw
)
618 if (hw
->mac
.ops
.config_collision_dist
)
619 hw
->mac
.ops
.config_collision_dist(hw
);
623 * e1000_rar_set - Sets a receive address register
624 * @hw: pointer to the HW structure
625 * @addr: address to set the RAR to
626 * @index: the RAR to set
628 * Sets a Receive Address Register (RAR) to the specified address.
630 void e1000_rar_set(struct e1000_hw
*hw
, u8
*addr
, u32 index
)
632 if (hw
->mac
.ops
.rar_set
)
633 hw
->mac
.ops
.rar_set(hw
, addr
, index
);
637 * e1000_validate_mdi_setting - Ensures valid MDI/MDIX SW state
638 * @hw: pointer to the HW structure
640 * Ensures that the MDI/MDIX SW state is valid.
642 s32
e1000_validate_mdi_setting(struct e1000_hw
*hw
)
644 if (hw
->mac
.ops
.validate_mdi_setting
)
645 return hw
->mac
.ops
.validate_mdi_setting(hw
);
647 return E1000_SUCCESS
;
651 * e1000_mta_set - Sets multicast table bit
652 * @hw: pointer to the HW structure
653 * @hash_value: Multicast hash value.
655 * This sets the bit in the multicast table corresponding to the
656 * hash value. This is a function pointer entry point called by drivers.
658 void e1000_mta_set(struct e1000_hw
*hw
, u32 hash_value
)
660 if (hw
->mac
.ops
.mta_set
)
661 hw
->mac
.ops
.mta_set(hw
, hash_value
);
665 * e1000_hash_mc_addr - Determines address location in multicast table
666 * @hw: pointer to the HW structure
667 * @mc_addr: Multicast address to hash.
669 * This hashes an address to determine its location in the multicast
670 * table. Currently no func pointer exists and all implementations
671 * are handled in the generic version of this function.
673 u32
e1000_hash_mc_addr(struct e1000_hw
*hw
, u8
*mc_addr
)
675 return e1000_hash_mc_addr_generic(hw
, mc_addr
);
679 * e1000_enable_tx_pkt_filtering - Enable packet filtering on TX
680 * @hw: pointer to the HW structure
682 * Enables packet filtering on transmit packets if manageability is enabled
683 * and host interface is enabled.
684 * Currently no func pointer exists and all implementations are handled in the
685 * generic version of this function.
687 bool e1000_enable_tx_pkt_filtering(struct e1000_hw
*hw
)
689 return e1000_enable_tx_pkt_filtering_generic(hw
);
693 * e1000_mng_host_if_write - Writes to the manageability host interface
694 * @hw: pointer to the HW structure
695 * @buffer: pointer to the host interface buffer
696 * @length: size of the buffer
697 * @offset: location in the buffer to write to
698 * @sum: sum of the data (not checksum)
700 * This function writes the buffer content at the offset given on the host if.
701 * It also does alignment considerations to do the writes in most efficient
702 * way. Also fills up the sum of the buffer in *buffer parameter.
704 s32
e1000_mng_host_if_write(struct e1000_hw
* hw
, u8
*buffer
, u16 length
,
707 if (hw
->mac
.ops
.mng_host_if_write
)
708 return hw
->mac
.ops
.mng_host_if_write(hw
, buffer
, length
,
711 return E1000_NOT_IMPLEMENTED
;
715 * e1000_mng_write_cmd_header - Writes manageability command header
716 * @hw: pointer to the HW structure
717 * @hdr: pointer to the host interface command header
719 * Writes the command header after does the checksum calculation.
721 s32
e1000_mng_write_cmd_header(struct e1000_hw
*hw
,
722 struct e1000_host_mng_command_header
*hdr
)
724 if (hw
->mac
.ops
.mng_write_cmd_header
)
725 return hw
->mac
.ops
.mng_write_cmd_header(hw
, hdr
);
727 return E1000_NOT_IMPLEMENTED
;
731 * e1000_mng_enable_host_if - Checks host interface is enabled
732 * @hw: pointer to the HW structure
734 * Returns E1000_success upon success, else E1000_ERR_HOST_INTERFACE_COMMAND
736 * This function checks whether the HOST IF is enabled for command operation
737 * and also checks whether the previous command is completed. It busy waits
738 * in case of previous command is not completed.
740 s32
e1000_mng_enable_host_if(struct e1000_hw
* hw
)
742 if (hw
->mac
.ops
.mng_enable_host_if
)
743 return hw
->mac
.ops
.mng_enable_host_if(hw
);
745 return E1000_NOT_IMPLEMENTED
;
749 * e1000_wait_autoneg - Waits for autonegotiation completion
750 * @hw: pointer to the HW structure
752 * Waits for autoneg to complete. Currently no func pointer exists and all
753 * implementations are handled in the generic version of this function.
755 s32
e1000_wait_autoneg(struct e1000_hw
*hw
)
757 if (hw
->mac
.ops
.wait_autoneg
)
758 return hw
->mac
.ops
.wait_autoneg(hw
);
760 return E1000_SUCCESS
;
764 * e1000_check_reset_block - Verifies PHY can be reset
765 * @hw: pointer to the HW structure
767 * Checks if the PHY is in a state that can be reset or if manageability
768 * has it tied up. This is a function pointer entry point called by drivers.
770 s32
e1000_check_reset_block(struct e1000_hw
*hw
)
772 if (hw
->phy
.ops
.check_reset_block
)
773 return hw
->phy
.ops
.check_reset_block(hw
);
775 return E1000_SUCCESS
;
779 * e1000_read_phy_reg - Reads PHY register
780 * @hw: pointer to the HW structure
781 * @offset: the register to read
782 * @data: the buffer to store the 16-bit read.
784 * Reads the PHY register and returns the value in data.
785 * This is a function pointer entry point called by drivers.
787 s32
e1000_read_phy_reg(struct e1000_hw
*hw
, u32 offset
, u16
*data
)
789 if (hw
->phy
.ops
.read_reg
)
790 return hw
->phy
.ops
.read_reg(hw
, offset
, data
);
792 return E1000_SUCCESS
;
796 * e1000_write_phy_reg - Writes PHY register
797 * @hw: pointer to the HW structure
798 * @offset: the register to write
799 * @data: the value to write.
801 * Writes the PHY register at offset with the value in data.
802 * This is a function pointer entry point called by drivers.
804 s32
e1000_write_phy_reg(struct e1000_hw
*hw
, u32 offset
, u16 data
)
806 if (hw
->phy
.ops
.write_reg
)
807 return hw
->phy
.ops
.write_reg(hw
, offset
, data
);
809 return E1000_SUCCESS
;
813 * e1000_release_phy - Generic release PHY
814 * @hw: pointer to the HW structure
816 * Return if silicon family does not require a semaphore when accessing the
819 void e1000_release_phy(struct e1000_hw
*hw
)
821 if (hw
->phy
.ops
.release
)
822 hw
->phy
.ops
.release(hw
);
826 * e1000_acquire_phy - Generic acquire PHY
827 * @hw: pointer to the HW structure
829 * Return success if silicon family does not require a semaphore when
832 s32
e1000_acquire_phy(struct e1000_hw
*hw
)
834 if (hw
->phy
.ops
.acquire
)
835 return hw
->phy
.ops
.acquire(hw
);
837 return E1000_SUCCESS
;
841 * e1000_read_kmrn_reg - Reads register using Kumeran interface
842 * @hw: pointer to the HW structure
843 * @offset: the register to read
844 * @data: the location to store the 16-bit value read.
846 * Reads a register out of the Kumeran interface. Currently no func pointer
847 * exists and all implementations are handled in the generic version of
850 s32
e1000_read_kmrn_reg(struct e1000_hw
*hw
, u32 offset
, u16
*data
)
852 return e1000_read_kmrn_reg_generic(hw
, offset
, data
);
856 * e1000_write_kmrn_reg - Writes register using Kumeran interface
857 * @hw: pointer to the HW structure
858 * @offset: the register to write
859 * @data: the value to write.
861 * Writes a register to the Kumeran interface. Currently no func pointer
862 * exists and all implementations are handled in the generic version of
865 s32
e1000_write_kmrn_reg(struct e1000_hw
*hw
, u32 offset
, u16 data
)
867 return e1000_write_kmrn_reg_generic(hw
, offset
, data
);
871 * e1000_get_cable_length - Retrieves cable length estimation
872 * @hw: pointer to the HW structure
874 * This function estimates the cable length and stores them in
875 * hw->phy.min_length and hw->phy.max_length. This is a function pointer
876 * entry point called by drivers.
878 s32
e1000_get_cable_length(struct e1000_hw
*hw
)
880 if (hw
->phy
.ops
.get_cable_length
)
881 return hw
->phy
.ops
.get_cable_length(hw
);
883 return E1000_SUCCESS
;
887 * e1000_get_phy_info - Retrieves PHY information from registers
888 * @hw: pointer to the HW structure
890 * This function gets some information from various PHY registers and
891 * populates hw->phy values with it. This is a function pointer entry
892 * point called by drivers.
894 s32
e1000_get_phy_info(struct e1000_hw
*hw
)
896 if (hw
->phy
.ops
.get_info
)
897 return hw
->phy
.ops
.get_info(hw
);
899 return E1000_SUCCESS
;
903 * e1000_phy_hw_reset - Hard PHY reset
904 * @hw: pointer to the HW structure
906 * Performs a hard PHY reset. This is a function pointer entry point called
909 s32
e1000_phy_hw_reset(struct e1000_hw
*hw
)
911 if (hw
->phy
.ops
.reset
)
912 return hw
->phy
.ops
.reset(hw
);
914 return E1000_SUCCESS
;
918 * e1000_phy_commit - Soft PHY reset
919 * @hw: pointer to the HW structure
921 * Performs a soft PHY reset on those that apply. This is a function pointer
922 * entry point called by drivers.
924 s32
e1000_phy_commit(struct e1000_hw
*hw
)
926 if (hw
->phy
.ops
.commit
)
927 return hw
->phy
.ops
.commit(hw
);
929 return E1000_SUCCESS
;
933 * e1000_set_d0_lplu_state - Sets low power link up state for D0
934 * @hw: pointer to the HW structure
935 * @active: boolean used to enable/disable lplu
937 * Success returns 0, Failure returns 1
939 * The low power link up (lplu) state is set to the power management level D0
940 * and SmartSpeed is disabled when active is true, else clear lplu for D0
941 * and enable Smartspeed. LPLU and Smartspeed are mutually exclusive. LPLU
942 * is used during Dx states where the power conservation is most important.
943 * During driver activity, SmartSpeed should be enabled so performance is
944 * maintained. This is a function pointer entry point called by drivers.
946 s32
e1000_set_d0_lplu_state(struct e1000_hw
*hw
, bool active
)
948 if (hw
->phy
.ops
.set_d0_lplu_state
)
949 return hw
->phy
.ops
.set_d0_lplu_state(hw
, active
);
951 return E1000_SUCCESS
;
955 * e1000_set_d3_lplu_state - Sets low power link up state for D3
956 * @hw: pointer to the HW structure
957 * @active: boolean used to enable/disable lplu
959 * Success returns 0, Failure returns 1
961 * The low power link up (lplu) state is set to the power management level D3
962 * and SmartSpeed is disabled when active is true, else clear lplu for D3
963 * and enable Smartspeed. LPLU and Smartspeed are mutually exclusive. LPLU
964 * is used during Dx states where the power conservation is most important.
965 * During driver activity, SmartSpeed should be enabled so performance is
966 * maintained. This is a function pointer entry point called by drivers.
968 s32
e1000_set_d3_lplu_state(struct e1000_hw
*hw
, bool active
)
970 if (hw
->phy
.ops
.set_d3_lplu_state
)
971 return hw
->phy
.ops
.set_d3_lplu_state(hw
, active
);
973 return E1000_SUCCESS
;
977 * e1000_read_mac_addr - Reads MAC address
978 * @hw: pointer to the HW structure
980 * Reads the MAC address out of the adapter and stores it in the HW structure.
981 * Currently no func pointer exists and all implementations are handled in the
982 * generic version of this function.
984 s32
e1000_read_mac_addr(struct e1000_hw
*hw
)
986 if (hw
->mac
.ops
.read_mac_addr
)
987 return hw
->mac
.ops
.read_mac_addr(hw
);
989 return e1000_read_mac_addr_generic(hw
);
993 * e1000_read_pba_num - Read device part number
994 * @hw: pointer to the HW structure
995 * @pba_num: pointer to device part number
997 * Reads the product board assembly (PBA) number from the EEPROM and stores
998 * the value in pba_num.
999 * Currently no func pointer exists and all implementations are handled in the
1000 * generic version of this function.
1002 s32
e1000_read_pba_num(struct e1000_hw
*hw
, u32
*pba_num
)
1004 return e1000_read_pba_num_generic(hw
, pba_num
);
1008 * e1000_validate_nvm_checksum - Verifies NVM (EEPROM) checksum
1009 * @hw: pointer to the HW structure
1011 * Validates the NVM checksum is correct. This is a function pointer entry
1012 * point called by drivers.
1014 s32
e1000_validate_nvm_checksum(struct e1000_hw
*hw
)
1016 if (hw
->nvm
.ops
.validate
)
1017 return hw
->nvm
.ops
.validate(hw
);
1019 return -E1000_ERR_CONFIG
;
1023 * e1000_update_nvm_checksum - Updates NVM (EEPROM) checksum
1024 * @hw: pointer to the HW structure
1026 * Updates the NVM checksum. Currently no func pointer exists and all
1027 * implementations are handled in the generic version of this function.
1029 s32
e1000_update_nvm_checksum(struct e1000_hw
*hw
)
1031 if (hw
->nvm
.ops
.update
)
1032 return hw
->nvm
.ops
.update(hw
);
1034 return -E1000_ERR_CONFIG
;
1038 * e1000_reload_nvm - Reloads EEPROM
1039 * @hw: pointer to the HW structure
1041 * Reloads the EEPROM by setting the "Reinitialize from EEPROM" bit in the
1042 * extended control register.
1044 void e1000_reload_nvm(struct e1000_hw
*hw
)
1046 if (hw
->nvm
.ops
.reload
)
1047 hw
->nvm
.ops
.reload(hw
);
1051 * e1000_read_nvm - Reads NVM (EEPROM)
1052 * @hw: pointer to the HW structure
1053 * @offset: the word offset to read
1054 * @words: number of 16-bit words to read
1055 * @data: pointer to the properly sized buffer for the data.
1057 * Reads 16-bit chunks of data from the NVM (EEPROM). This is a function
1058 * pointer entry point called by drivers.
1060 s32
e1000_read_nvm(struct e1000_hw
*hw
, u16 offset
, u16 words
, u16
*data
)
1062 if (hw
->nvm
.ops
.read
)
1063 return hw
->nvm
.ops
.read(hw
, offset
, words
, data
);
1065 return -E1000_ERR_CONFIG
;
1069 * e1000_write_nvm - Writes to NVM (EEPROM)
1070 * @hw: pointer to the HW structure
1071 * @offset: the word offset to read
1072 * @words: number of 16-bit words to write
1073 * @data: pointer to the properly sized buffer for the data.
1075 * Writes 16-bit chunks of data to the NVM (EEPROM). This is a function
1076 * pointer entry point called by drivers.
1078 s32
e1000_write_nvm(struct e1000_hw
*hw
, u16 offset
, u16 words
, u16
*data
)
1080 if (hw
->nvm
.ops
.write
)
1081 return hw
->nvm
.ops
.write(hw
, offset
, words
, data
);
1083 return E1000_SUCCESS
;
1087 * e1000_write_8bit_ctrl_reg - Writes 8bit Control register
1088 * @hw: pointer to the HW structure
1089 * @reg: 32bit register offset
1090 * @offset: the register to write
1091 * @data: the value to write.
1093 * Writes the PHY register at offset with the value in data.
1094 * This is a function pointer entry point called by drivers.
1096 s32
e1000_write_8bit_ctrl_reg(struct e1000_hw
*hw
, u32 reg
, u32 offset
,
1099 return e1000_write_8bit_ctrl_reg_generic(hw
, reg
, offset
, data
);
1103 * e1000_power_up_phy - Restores link in case of PHY power down
1104 * @hw: pointer to the HW structure
1106 * The phy may be powered down to save power, to turn off link when the
1107 * driver is unloaded, or wake on lan is not enabled (among others).
1109 void e1000_power_up_phy(struct e1000_hw
*hw
)
1111 if (hw
->phy
.ops
.power_up
)
1112 hw
->phy
.ops
.power_up(hw
);
1114 e1000_setup_link(hw
);
1118 * e1000_power_down_phy - Power down PHY
1119 * @hw: pointer to the HW structure
1121 * The phy may be powered down to save power, to turn off link when the
1122 * driver is unloaded, or wake on lan is not enabled (among others).
1124 void e1000_power_down_phy(struct e1000_hw
*hw
)
1126 if (hw
->phy
.ops
.power_down
)
1127 hw
->phy
.ops
.power_down(hw
);