revert between 56095 -> 55830 in arch
[AROS.git] / workbench / devs / networks / e1000 / e1000_api.c
blob0e25163f99894b8e5d3bdba8e65342b2a9d12c67
1 /*******************************************************************************
3 Intel PRO/1000 Linux driver
4 Copyright(c) 1999 - 2010 Intel Corporation.
6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License,
8 version 2, as published by the Free Software Foundation.
10 This program is distributed in the hope it will be useful, but WITHOUT
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 more details.
15 You should have received a copy of the GNU General Public License along with
16 this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
19 The full GNU General Public License is included in this distribution in
20 the file called "COPYING".
22 Contact Information:
23 Linux NICS <linux.nics@intel.com>
24 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
25 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
27 *******************************************************************************/
29 #include "e1000_api.h"
31 /**
32 * e1000_init_mac_params - Initialize MAC function pointers
33 * @hw: pointer to the HW structure
35 * This function initializes the function pointers for the MAC
36 * set of functions. Called by drivers or by e1000_setup_init_funcs.
37 **/
38 s32 e1000_init_mac_params(struct e1000_hw *hw)
40 s32 ret_val = E1000_SUCCESS;
42 if (hw->mac.ops.init_params) {
43 ret_val = hw->mac.ops.init_params(hw);
44 if (ret_val) {
45 DEBUGOUT("MAC Initialization Error\n");
46 goto out;
48 } else {
49 DEBUGOUT("mac.init_mac_params was NULL\n");
50 ret_val = -E1000_ERR_CONFIG;
53 out:
54 return ret_val;
57 /**
58 * e1000_init_nvm_params - Initialize NVM function pointers
59 * @hw: pointer to the HW structure
61 * This function initializes the function pointers for the NVM
62 * set of functions. Called by drivers or by e1000_setup_init_funcs.
63 **/
64 s32 e1000_init_nvm_params(struct e1000_hw *hw)
66 s32 ret_val = E1000_SUCCESS;
68 if (hw->nvm.ops.init_params) {
69 ret_val = hw->nvm.ops.init_params(hw);
70 if (ret_val) {
71 DEBUGOUT("NVM Initialization Error\n");
72 goto out;
74 } else {
75 DEBUGOUT("nvm.init_nvm_params was NULL\n");
76 ret_val = -E1000_ERR_CONFIG;
79 out:
80 return ret_val;
83 /**
84 * e1000_init_phy_params - Initialize PHY function pointers
85 * @hw: pointer to the HW structure
87 * This function initializes the function pointers for the PHY
88 * set of functions. Called by drivers or by e1000_setup_init_funcs.
89 **/
90 s32 e1000_init_phy_params(struct e1000_hw *hw)
92 s32 ret_val = E1000_SUCCESS;
94 if (hw->phy.ops.init_params) {
95 ret_val = hw->phy.ops.init_params(hw);
96 if (ret_val) {
97 DEBUGOUT("PHY Initialization Error\n");
98 goto out;
100 } else {
101 DEBUGOUT("phy.init_phy_params was NULL\n");
102 ret_val = -E1000_ERR_CONFIG;
105 out:
106 return ret_val;
110 * e1000_set_mac_type - Sets MAC type
111 * @hw: pointer to the HW structure
113 * This function sets the mac type of the adapter based on the
114 * device ID stored in the hw structure.
115 * MUST BE FIRST FUNCTION CALLED (explicitly or through
116 * e1000_setup_init_funcs()).
118 s32 e1000_set_mac_type(struct e1000_hw *hw)
120 struct e1000_mac_info *mac = &hw->mac;
121 s32 ret_val = E1000_SUCCESS;
123 DEBUGFUNC("e1000_set_mac_type");
125 switch (hw->device_id) {
126 case E1000_DEV_ID_82542:
127 mac->type = e1000_82542;
128 break;
129 case E1000_DEV_ID_82543GC_FIBER:
130 case E1000_DEV_ID_82543GC_COPPER:
131 mac->type = e1000_82543;
132 break;
133 case E1000_DEV_ID_82544EI_COPPER:
134 case E1000_DEV_ID_82544EI_FIBER:
135 case E1000_DEV_ID_82544GC_COPPER:
136 case E1000_DEV_ID_82544GC_LOM:
137 mac->type = e1000_82544;
138 break;
139 case E1000_DEV_ID_82540EM:
140 case E1000_DEV_ID_82540EM_LOM:
141 case E1000_DEV_ID_82540EP:
142 case E1000_DEV_ID_82540EP_LOM:
143 case E1000_DEV_ID_82540EP_LP:
144 mac->type = e1000_82540;
145 break;
146 case E1000_DEV_ID_82545EM_COPPER:
147 case E1000_DEV_ID_82545EM_FIBER:
148 mac->type = e1000_82545;
149 break;
150 case E1000_DEV_ID_82545GM_COPPER:
151 case E1000_DEV_ID_82545GM_FIBER:
152 case E1000_DEV_ID_82545GM_SERDES:
153 mac->type = e1000_82545_rev_3;
154 break;
155 case E1000_DEV_ID_82546EB_COPPER:
156 case E1000_DEV_ID_82546EB_FIBER:
157 case E1000_DEV_ID_82546EB_QUAD_COPPER:
158 mac->type = e1000_82546;
159 break;
160 case E1000_DEV_ID_82546GB_COPPER:
161 case E1000_DEV_ID_82546GB_FIBER:
162 case E1000_DEV_ID_82546GB_SERDES:
163 case E1000_DEV_ID_82546GB_PCIE:
164 case E1000_DEV_ID_82546GB_QUAD_COPPER:
165 case E1000_DEV_ID_82546GB_QUAD_COPPER_KSP3:
166 mac->type = e1000_82546_rev_3;
167 break;
168 case E1000_DEV_ID_82541EI:
169 case E1000_DEV_ID_82541EI_MOBILE:
170 case E1000_DEV_ID_82541ER_LOM:
171 mac->type = e1000_82541;
172 break;
173 case E1000_DEV_ID_82541ER:
174 case E1000_DEV_ID_82541GI:
175 case E1000_DEV_ID_82541GI_LF:
176 case E1000_DEV_ID_82541GI_MOBILE:
177 mac->type = e1000_82541_rev_2;
178 break;
179 case E1000_DEV_ID_82547EI:
180 case E1000_DEV_ID_82547EI_MOBILE:
181 mac->type = e1000_82547;
182 break;
183 case E1000_DEV_ID_82547GI:
184 mac->type = e1000_82547_rev_2;
185 break;
186 default:
187 /* Should never have loaded on this device */
188 ret_val = -E1000_ERR_MAC_INIT;
189 break;
192 return ret_val;
196 * e1000_setup_init_funcs - Initializes function pointers
197 * @hw: pointer to the HW structure
198 * @init_device: true will initialize the rest of the function pointers
199 * getting the device ready for use. false will only set
200 * MAC type and the function pointers for the other init
201 * functions. Passing false will not generate any hardware
202 * reads or writes.
204 * This function must be called by a driver in order to use the rest
205 * of the 'shared' code files. Called by drivers only.
207 s32 e1000_setup_init_funcs(struct e1000_hw *hw, bool init_device)
209 s32 ret_val;
211 /* Can't do much good without knowing the MAC type. */
212 ret_val = e1000_set_mac_type(hw);
213 if (ret_val) {
214 DEBUGOUT("ERROR: MAC type could not be set properly.\n");
215 goto out;
218 if (!hw->hw_addr) {
219 DEBUGOUT("ERROR: Registers not mapped\n");
220 ret_val = -E1000_ERR_CONFIG;
221 goto out;
225 * Init function pointers to generic implementations. We do this first
226 * allowing a driver module to override it afterward.
228 e1000_init_mac_ops_generic(hw);
229 e1000_init_phy_ops_generic(hw);
230 e1000_init_nvm_ops_generic(hw);
233 * Set up the init function pointers. These are functions within the
234 * adapter family file that sets up function pointers for the rest of
235 * the functions in that family.
237 switch (hw->mac.type) {
238 case e1000_82542:
239 e1000_init_function_pointers_82542(hw);
240 break;
241 case e1000_82543:
242 case e1000_82544:
243 e1000_init_function_pointers_82543(hw);
244 break;
245 case e1000_82540:
246 case e1000_82545:
247 case e1000_82545_rev_3:
248 case e1000_82546:
249 case e1000_82546_rev_3:
250 e1000_init_function_pointers_82540(hw);
251 break;
252 case e1000_82541:
253 case e1000_82541_rev_2:
254 case e1000_82547:
255 case e1000_82547_rev_2:
256 e1000_init_function_pointers_82541(hw);
257 break;
258 default:
259 DEBUGOUT("Hardware not supported\n");
260 ret_val = -E1000_ERR_CONFIG;
261 break;
265 * Initialize the rest of the function pointers. These require some
266 * register reads/writes in some cases.
268 if (!(ret_val) && init_device) {
269 ret_val = e1000_init_mac_params(hw);
270 if (ret_val)
271 goto out;
273 ret_val = e1000_init_nvm_params(hw);
274 if (ret_val)
275 goto out;
277 ret_val = e1000_init_phy_params(hw);
278 if (ret_val)
279 goto out;
282 out:
283 return ret_val;
287 * e1000_get_bus_info - Obtain bus information for adapter
288 * @hw: pointer to the HW structure
290 * This will obtain information about the HW bus for which the
291 * adapter is attached and stores it in the hw structure. This is a
292 * function pointer entry point called by drivers.
294 s32 e1000_get_bus_info(struct e1000_hw *hw)
296 if (hw->mac.ops.get_bus_info)
297 return hw->mac.ops.get_bus_info(hw);
299 return E1000_SUCCESS;
303 * e1000_clear_vfta - Clear VLAN filter table
304 * @hw: pointer to the HW structure
306 * This clears the VLAN filter table on the adapter. This is a function
307 * pointer entry point called by drivers.
309 void e1000_clear_vfta(struct e1000_hw *hw)
311 if (hw->mac.ops.clear_vfta)
312 hw->mac.ops.clear_vfta(hw);
316 * e1000_write_vfta - Write value to VLAN filter table
317 * @hw: pointer to the HW structure
318 * @offset: the 32-bit offset in which to write the value to.
319 * @value: the 32-bit value to write at location offset.
321 * This writes a 32-bit value to a 32-bit offset in the VLAN filter
322 * table. This is a function pointer entry point called by drivers.
324 void e1000_write_vfta(struct e1000_hw *hw, u32 offset, u32 value)
326 if (hw->mac.ops.write_vfta)
327 hw->mac.ops.write_vfta(hw, offset, value);
331 * e1000_update_mc_addr_list - Update Multicast addresses
332 * @hw: pointer to the HW structure
333 * @mc_addr_list: array of multicast addresses to program
334 * @mc_addr_count: number of multicast addresses to program
336 * Updates the Multicast Table Array.
337 * The caller must have a packed mc_addr_list of multicast addresses.
339 void e1000_update_mc_addr_list(struct e1000_hw *hw, u8 *mc_addr_list,
340 u32 mc_addr_count)
342 if (hw->mac.ops.update_mc_addr_list)
343 hw->mac.ops.update_mc_addr_list(hw, mc_addr_list,
344 mc_addr_count);
348 * e1000_force_mac_fc - Force MAC flow control
349 * @hw: pointer to the HW structure
351 * Force the MAC's flow control settings. Currently no func pointer exists
352 * and all implementations are handled in the generic version of this
353 * function.
355 s32 e1000_force_mac_fc(struct e1000_hw *hw)
357 return e1000_force_mac_fc_generic(hw);
361 * e1000_check_for_link - Check/Store link connection
362 * @hw: pointer to the HW structure
364 * This checks the link condition of the adapter and stores the
365 * results in the hw->mac structure. This is a function pointer entry
366 * point called by drivers.
368 s32 e1000_check_for_link(struct e1000_hw *hw)
370 if (hw->mac.ops.check_for_link)
371 return hw->mac.ops.check_for_link(hw);
373 return -E1000_ERR_CONFIG;
377 * e1000_check_mng_mode - Check management mode
378 * @hw: pointer to the HW structure
380 * This checks if the adapter has manageability enabled.
381 * This is a function pointer entry point called by drivers.
383 bool e1000_check_mng_mode(struct e1000_hw *hw)
385 if (hw->mac.ops.check_mng_mode)
386 return hw->mac.ops.check_mng_mode(hw);
388 return false;
392 * e1000_mng_write_dhcp_info - Writes DHCP info to host interface
393 * @hw: pointer to the HW structure
394 * @buffer: pointer to the host interface
395 * @length: size of the buffer
397 * Writes the DHCP information to the host interface.
399 s32 e1000_mng_write_dhcp_info(struct e1000_hw *hw, u8 *buffer, u16 length)
401 return e1000_mng_write_dhcp_info_generic(hw, buffer, length);
405 * e1000_reset_hw - Reset hardware
406 * @hw: pointer to the HW structure
408 * This resets the hardware into a known state. This is a function pointer
409 * entry point called by drivers.
411 s32 e1000_reset_hw(struct e1000_hw *hw)
413 if (hw->mac.ops.reset_hw)
414 return hw->mac.ops.reset_hw(hw);
416 return -E1000_ERR_CONFIG;
420 * e1000_init_hw - Initialize hardware
421 * @hw: pointer to the HW structure
423 * This inits the hardware readying it for operation. This is a function
424 * pointer entry point called by drivers.
426 s32 e1000_init_hw(struct e1000_hw *hw)
428 if (hw->mac.ops.init_hw)
429 return hw->mac.ops.init_hw(hw);
431 return -E1000_ERR_CONFIG;
435 * e1000_setup_link - Configures link and flow control
436 * @hw: pointer to the HW structure
438 * This configures link and flow control settings for the adapter. This
439 * is a function pointer entry point called by drivers. While modules can
440 * also call this, they probably call their own version of this function.
442 s32 e1000_setup_link(struct e1000_hw *hw)
444 if (hw->mac.ops.setup_link)
445 return hw->mac.ops.setup_link(hw);
447 return -E1000_ERR_CONFIG;
451 * e1000_get_speed_and_duplex - Returns current speed and duplex
452 * @hw: pointer to the HW structure
453 * @speed: pointer to a 16-bit value to store the speed
454 * @duplex: pointer to a 16-bit value to store the duplex.
456 * This returns the speed and duplex of the adapter in the two 'out'
457 * variables passed in. This is a function pointer entry point called
458 * by drivers.
460 s32 e1000_get_speed_and_duplex(struct e1000_hw *hw, u16 *speed, u16 *duplex)
462 if (hw->mac.ops.get_link_up_info)
463 return hw->mac.ops.get_link_up_info(hw, speed, duplex);
465 return -E1000_ERR_CONFIG;
469 * e1000_setup_led - Configures SW controllable LED
470 * @hw: pointer to the HW structure
472 * This prepares the SW controllable LED for use and saves the current state
473 * of the LED so it can be later restored. This is a function pointer entry
474 * point called by drivers.
476 s32 e1000_setup_led(struct e1000_hw *hw)
478 if (hw->mac.ops.setup_led)
479 return hw->mac.ops.setup_led(hw);
481 return E1000_SUCCESS;
485 * e1000_cleanup_led - Restores SW controllable LED
486 * @hw: pointer to the HW structure
488 * This restores the SW controllable LED to the value saved off by
489 * e1000_setup_led. This is a function pointer entry point called by drivers.
491 s32 e1000_cleanup_led(struct e1000_hw *hw)
493 if (hw->mac.ops.cleanup_led)
494 return hw->mac.ops.cleanup_led(hw);
496 return E1000_SUCCESS;
500 * e1000_blink_led - Blink SW controllable LED
501 * @hw: pointer to the HW structure
503 * This starts the adapter LED blinking. Request the LED to be setup first
504 * and cleaned up after. This is a function pointer entry point called by
505 * drivers.
507 s32 e1000_blink_led(struct e1000_hw *hw)
509 if (hw->mac.ops.blink_led)
510 return hw->mac.ops.blink_led(hw);
512 return E1000_SUCCESS;
516 * e1000_id_led_init - store LED configurations in SW
517 * @hw: pointer to the HW structure
519 * Initializes the LED config in SW. This is a function pointer entry point
520 * called by drivers.
522 s32 e1000_id_led_init(struct e1000_hw *hw)
524 if (hw->mac.ops.id_led_init)
525 return hw->mac.ops.id_led_init(hw);
527 return E1000_SUCCESS;
531 * e1000_led_on - Turn on SW controllable LED
532 * @hw: pointer to the HW structure
534 * Turns the SW defined LED on. This is a function pointer entry point
535 * called by drivers.
537 s32 e1000_led_on(struct e1000_hw *hw)
539 if (hw->mac.ops.led_on)
540 return hw->mac.ops.led_on(hw);
542 return E1000_SUCCESS;
546 * e1000_led_off - Turn off SW controllable LED
547 * @hw: pointer to the HW structure
549 * Turns the SW defined LED off. This is a function pointer entry point
550 * called by drivers.
552 s32 e1000_led_off(struct e1000_hw *hw)
554 if (hw->mac.ops.led_off)
555 return hw->mac.ops.led_off(hw);
557 return E1000_SUCCESS;
561 * e1000_reset_adaptive - Reset adaptive IFS
562 * @hw: pointer to the HW structure
564 * Resets the adaptive IFS. Currently no func pointer exists and all
565 * implementations are handled in the generic version of this function.
567 void e1000_reset_adaptive(struct e1000_hw *hw)
569 e1000_reset_adaptive_generic(hw);
573 * e1000_update_adaptive - Update adaptive IFS
574 * @hw: pointer to the HW structure
576 * Updates adapter IFS. Currently no func pointer exists and all
577 * implementations are handled in the generic version of this function.
579 void e1000_update_adaptive(struct e1000_hw *hw)
581 e1000_update_adaptive_generic(hw);
585 * e1000_disable_pcie_master - Disable PCI-Express master access
586 * @hw: pointer to the HW structure
588 * Disables PCI-Express master access and verifies there are no pending
589 * requests. Currently no func pointer exists and all implementations are
590 * handled in the generic version of this function.
592 s32 e1000_disable_pcie_master(struct e1000_hw *hw)
594 return e1000_disable_pcie_master_generic(hw);
598 * e1000_config_collision_dist - Configure collision distance
599 * @hw: pointer to the HW structure
601 * Configures the collision distance to the default value and is used
602 * during link setup.
604 void e1000_config_collision_dist(struct e1000_hw *hw)
606 if (hw->mac.ops.config_collision_dist)
607 hw->mac.ops.config_collision_dist(hw);
611 * e1000_rar_set - Sets a receive address register
612 * @hw: pointer to the HW structure
613 * @addr: address to set the RAR to
614 * @index: the RAR to set
616 * Sets a Receive Address Register (RAR) to the specified address.
618 void e1000_rar_set(struct e1000_hw *hw, u8 *addr, u32 index)
620 if (hw->mac.ops.rar_set)
621 hw->mac.ops.rar_set(hw, addr, index);
625 * e1000_validate_mdi_setting - Ensures valid MDI/MDIX SW state
626 * @hw: pointer to the HW structure
628 * Ensures that the MDI/MDIX SW state is valid.
630 s32 e1000_validate_mdi_setting(struct e1000_hw *hw)
632 if (hw->mac.ops.validate_mdi_setting)
633 return hw->mac.ops.validate_mdi_setting(hw);
635 return E1000_SUCCESS;
639 * e1000_hash_mc_addr - Determines address location in multicast table
640 * @hw: pointer to the HW structure
641 * @mc_addr: Multicast address to hash.
643 * This hashes an address to determine its location in the multicast
644 * table. Currently no func pointer exists and all implementations
645 * are handled in the generic version of this function.
647 u32 e1000_hash_mc_addr(struct e1000_hw *hw, u8 *mc_addr)
649 return e1000_hash_mc_addr_generic(hw, mc_addr);
653 * e1000_enable_tx_pkt_filtering - Enable packet filtering on TX
654 * @hw: pointer to the HW structure
656 * Enables packet filtering on transmit packets if manageability is enabled
657 * and host interface is enabled.
658 * Currently no func pointer exists and all implementations are handled in the
659 * generic version of this function.
661 bool e1000_enable_tx_pkt_filtering(struct e1000_hw *hw)
663 return e1000_enable_tx_pkt_filtering_generic(hw);
667 * e1000_mng_host_if_write - Writes to the manageability host interface
668 * @hw: pointer to the HW structure
669 * @buffer: pointer to the host interface buffer
670 * @length: size of the buffer
671 * @offset: location in the buffer to write to
672 * @sum: sum of the data (not checksum)
674 * This function writes the buffer content at the offset given on the host if.
675 * It also does alignment considerations to do the writes in most efficient
676 * way. Also fills up the sum of the buffer in *buffer parameter.
678 s32 e1000_mng_host_if_write(struct e1000_hw * hw, u8 *buffer, u16 length,
679 u16 offset, u8 *sum)
681 if (hw->mac.ops.mng_host_if_write)
682 return hw->mac.ops.mng_host_if_write(hw, buffer, length,
683 offset, sum);
685 return E1000_NOT_IMPLEMENTED;
689 * e1000_mng_write_cmd_header - Writes manageability command header
690 * @hw: pointer to the HW structure
691 * @hdr: pointer to the host interface command header
693 * Writes the command header after does the checksum calculation.
695 s32 e1000_mng_write_cmd_header(struct e1000_hw *hw,
696 struct e1000_host_mng_command_header *hdr)
698 if (hw->mac.ops.mng_write_cmd_header)
699 return hw->mac.ops.mng_write_cmd_header(hw, hdr);
701 return E1000_NOT_IMPLEMENTED;
705 * e1000_mng_enable_host_if - Checks host interface is enabled
706 * @hw: pointer to the HW structure
708 * Returns E1000_success upon success, else E1000_ERR_HOST_INTERFACE_COMMAND
710 * This function checks whether the HOST IF is enabled for command operation
711 * and also checks whether the previous command is completed. It busy waits
712 * in case of previous command is not completed.
714 s32 e1000_mng_enable_host_if(struct e1000_hw * hw)
716 if (hw->mac.ops.mng_enable_host_if)
717 return hw->mac.ops.mng_enable_host_if(hw);
719 return E1000_NOT_IMPLEMENTED;
723 * e1000_wait_autoneg - Waits for autonegotiation completion
724 * @hw: pointer to the HW structure
726 * Waits for autoneg to complete. Currently no func pointer exists and all
727 * implementations are handled in the generic version of this function.
729 s32 e1000_wait_autoneg(struct e1000_hw *hw)
731 if (hw->mac.ops.wait_autoneg)
732 return hw->mac.ops.wait_autoneg(hw);
734 return E1000_SUCCESS;
738 * e1000_check_reset_block - Verifies PHY can be reset
739 * @hw: pointer to the HW structure
741 * Checks if the PHY is in a state that can be reset or if manageability
742 * has it tied up. This is a function pointer entry point called by drivers.
744 s32 e1000_check_reset_block(struct e1000_hw *hw)
746 if (hw->phy.ops.check_reset_block)
747 return hw->phy.ops.check_reset_block(hw);
749 return E1000_SUCCESS;
753 * e1000_read_phy_reg - Reads PHY register
754 * @hw: pointer to the HW structure
755 * @offset: the register to read
756 * @data: the buffer to store the 16-bit read.
758 * Reads the PHY register and returns the value in data.
759 * This is a function pointer entry point called by drivers.
761 s32 e1000_read_phy_reg(struct e1000_hw *hw, u32 offset, u16 *data)
763 if (hw->phy.ops.read_reg)
764 return hw->phy.ops.read_reg(hw, offset, data);
766 return E1000_SUCCESS;
770 * e1000_write_phy_reg - Writes PHY register
771 * @hw: pointer to the HW structure
772 * @offset: the register to write
773 * @data: the value to write.
775 * Writes the PHY register at offset with the value in data.
776 * This is a function pointer entry point called by drivers.
778 s32 e1000_write_phy_reg(struct e1000_hw *hw, u32 offset, u16 data)
780 if (hw->phy.ops.write_reg)
781 return hw->phy.ops.write_reg(hw, offset, data);
783 return E1000_SUCCESS;
787 * e1000_release_phy - Generic release PHY
788 * @hw: pointer to the HW structure
790 * Return if silicon family does not require a semaphore when accessing the
791 * PHY.
793 void e1000_release_phy(struct e1000_hw *hw)
795 if (hw->phy.ops.release)
796 hw->phy.ops.release(hw);
800 * e1000_acquire_phy - Generic acquire PHY
801 * @hw: pointer to the HW structure
803 * Return success if silicon family does not require a semaphore when
804 * accessing the PHY.
806 s32 e1000_acquire_phy(struct e1000_hw *hw)
808 if (hw->phy.ops.acquire)
809 return hw->phy.ops.acquire(hw);
811 return E1000_SUCCESS;
815 * e1000_read_kmrn_reg - Reads register using Kumeran interface
816 * @hw: pointer to the HW structure
817 * @offset: the register to read
818 * @data: the location to store the 16-bit value read.
820 * Reads a register out of the Kumeran interface. Currently no func pointer
821 * exists and all implementations are handled in the generic version of
822 * this function.
824 s32 e1000_read_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 *data)
826 return e1000_read_kmrn_reg_generic(hw, offset, data);
830 * e1000_write_kmrn_reg - Writes register using Kumeran interface
831 * @hw: pointer to the HW structure
832 * @offset: the register to write
833 * @data: the value to write.
835 * Writes a register to the Kumeran interface. Currently no func pointer
836 * exists and all implementations are handled in the generic version of
837 * this function.
839 s32 e1000_write_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 data)
841 return e1000_write_kmrn_reg_generic(hw, offset, data);
845 * e1000_get_cable_length - Retrieves cable length estimation
846 * @hw: pointer to the HW structure
848 * This function estimates the cable length and stores them in
849 * hw->phy.min_length and hw->phy.max_length. This is a function pointer
850 * entry point called by drivers.
852 s32 e1000_get_cable_length(struct e1000_hw *hw)
854 if (hw->phy.ops.get_cable_length)
855 return hw->phy.ops.get_cable_length(hw);
857 return E1000_SUCCESS;
861 * e1000_get_phy_info - Retrieves PHY information from registers
862 * @hw: pointer to the HW structure
864 * This function gets some information from various PHY registers and
865 * populates hw->phy values with it. This is a function pointer entry
866 * point called by drivers.
868 s32 e1000_get_phy_info(struct e1000_hw *hw)
870 if (hw->phy.ops.get_info)
871 return hw->phy.ops.get_info(hw);
873 return E1000_SUCCESS;
877 * e1000_phy_hw_reset - Hard PHY reset
878 * @hw: pointer to the HW structure
880 * Performs a hard PHY reset. This is a function pointer entry point called
881 * by drivers.
883 s32 e1000_phy_hw_reset(struct e1000_hw *hw)
885 if (hw->phy.ops.reset)
886 return hw->phy.ops.reset(hw);
888 return E1000_SUCCESS;
892 * e1000_phy_commit - Soft PHY reset
893 * @hw: pointer to the HW structure
895 * Performs a soft PHY reset on those that apply. This is a function pointer
896 * entry point called by drivers.
898 s32 e1000_phy_commit(struct e1000_hw *hw)
900 if (hw->phy.ops.commit)
901 return hw->phy.ops.commit(hw);
903 return E1000_SUCCESS;
907 * e1000_set_d0_lplu_state - Sets low power link up state for D0
908 * @hw: pointer to the HW structure
909 * @active: boolean used to enable/disable lplu
911 * Success returns 0, Failure returns 1
913 * The low power link up (lplu) state is set to the power management level D0
914 * and SmartSpeed is disabled when active is true, else clear lplu for D0
915 * and enable Smartspeed. LPLU and Smartspeed are mutually exclusive. LPLU
916 * is used during Dx states where the power conservation is most important.
917 * During driver activity, SmartSpeed should be enabled so performance is
918 * maintained. This is a function pointer entry point called by drivers.
920 s32 e1000_set_d0_lplu_state(struct e1000_hw *hw, bool active)
922 if (hw->phy.ops.set_d0_lplu_state)
923 return hw->phy.ops.set_d0_lplu_state(hw, active);
925 return E1000_SUCCESS;
929 * e1000_set_d3_lplu_state - Sets low power link up state for D3
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 D3
936 * and SmartSpeed is disabled when active is true, else clear lplu for D3
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_d3_lplu_state(struct e1000_hw *hw, bool active)
944 if (hw->phy.ops.set_d3_lplu_state)
945 return hw->phy.ops.set_d3_lplu_state(hw, active);
947 return E1000_SUCCESS;
951 * e1000_read_mac_addr - Reads MAC address
952 * @hw: pointer to the HW structure
954 * Reads the MAC address out of the adapter and stores it in the HW structure.
955 * Currently no func pointer exists and all implementations are handled in the
956 * generic version of this function.
958 s32 e1000_read_mac_addr(struct e1000_hw *hw)
960 if (hw->mac.ops.read_mac_addr)
961 return hw->mac.ops.read_mac_addr(hw);
963 return e1000_read_mac_addr_generic(hw);
967 * e1000_read_pba_string - Read device part number string
968 * @hw: pointer to the HW structure
969 * @pba_num: pointer to device part number
970 * @pba_num_size: size of part number buffer
972 * Reads the product board assembly (PBA) number from the EEPROM and stores
973 * the value in pba_num.
974 * Currently no func pointer exists and all implementations are handled in the
975 * generic version of this function.
977 s32 e1000_read_pba_string(struct e1000_hw *hw, u8 *pba_num, u32 pba_num_size)
979 return e1000_read_pba_string_generic(hw, pba_num, pba_num_size);
983 * e1000_validate_nvm_checksum - Verifies NVM (EEPROM) checksum
984 * @hw: pointer to the HW structure
986 * Validates the NVM checksum is correct. This is a function pointer entry
987 * point called by drivers.
989 s32 e1000_validate_nvm_checksum(struct e1000_hw *hw)
991 if (hw->nvm.ops.validate)
992 return hw->nvm.ops.validate(hw);
994 return -E1000_ERR_CONFIG;
998 * e1000_update_nvm_checksum - Updates NVM (EEPROM) checksum
999 * @hw: pointer to the HW structure
1001 * Updates the NVM checksum. Currently no func pointer exists and all
1002 * implementations are handled in the generic version of this function.
1004 s32 e1000_update_nvm_checksum(struct e1000_hw *hw)
1006 if (hw->nvm.ops.update)
1007 return hw->nvm.ops.update(hw);
1009 return -E1000_ERR_CONFIG;
1013 * e1000_reload_nvm - Reloads EEPROM
1014 * @hw: pointer to the HW structure
1016 * Reloads the EEPROM by setting the "Reinitialize from EEPROM" bit in the
1017 * extended control register.
1019 void e1000_reload_nvm(struct e1000_hw *hw)
1021 if (hw->nvm.ops.reload)
1022 hw->nvm.ops.reload(hw);
1026 * e1000_read_nvm - Reads NVM (EEPROM)
1027 * @hw: pointer to the HW structure
1028 * @offset: the word offset to read
1029 * @words: number of 16-bit words to read
1030 * @data: pointer to the properly sized buffer for the data.
1032 * Reads 16-bit chunks of data from the NVM (EEPROM). This is a function
1033 * pointer entry point called by drivers.
1035 s32 e1000_read_nvm(struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
1037 if (hw->nvm.ops.read)
1038 return hw->nvm.ops.read(hw, offset, words, data);
1040 return -E1000_ERR_CONFIG;
1044 * e1000_write_nvm - Writes to NVM (EEPROM)
1045 * @hw: pointer to the HW structure
1046 * @offset: the word offset to read
1047 * @words: number of 16-bit words to write
1048 * @data: pointer to the properly sized buffer for the data.
1050 * Writes 16-bit chunks of data to the NVM (EEPROM). This is a function
1051 * pointer entry point called by drivers.
1053 s32 e1000_write_nvm(struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
1055 if (hw->nvm.ops.write)
1056 return hw->nvm.ops.write(hw, offset, words, data);
1058 return E1000_SUCCESS;
1062 * e1000_power_up_phy - Restores link in case of PHY power down
1063 * @hw: pointer to the HW structure
1065 * The phy may be powered down to save power, to turn off link when the
1066 * driver is unloaded, or wake on lan is not enabled (among others).
1068 void e1000_power_up_phy(struct e1000_hw *hw)
1070 if (hw->phy.ops.power_up)
1071 hw->phy.ops.power_up(hw);
1073 e1000_setup_link(hw);
1077 * e1000_power_down_phy - Power down PHY
1078 * @hw: pointer to the HW structure
1080 * The phy may be powered down to save power, to turn off link when the
1081 * driver is unloaded, or wake on lan is not enabled (among others).
1083 void e1000_power_down_phy(struct e1000_hw *hw)
1085 if (hw->phy.ops.power_down)
1086 hw->phy.ops.power_down(hw);