ixgb_ee.c
来自「Linux Kernel 2.6.9 for OMAP1710」· C语言 代码 · 共 733 行 · 第 1/2 页
C
733 行
ixgb_shift_out_bits(hw, 0, 4); /* Prepare the EEPROM */ ixgb_standby_eeprom(hw); /* Send the Write command (3-bit opcode + 6-bit addr) */ ixgb_shift_out_bits(hw, EEPROM_WRITE_OPCODE, 3); ixgb_shift_out_bits(hw, offset, 6); /* Send the data */ ixgb_shift_out_bits(hw, data, 16); ixgb_wait_eeprom_command(hw); /* Recover from write */ ixgb_standby_eeprom(hw); /* Send the 9-bit EWDS (write disable) command to the EEPROM (5-bit * opcode plus 4-bit dummy). This takes the EEPROM out of write/erase * mode. */ ixgb_shift_out_bits(hw, EEPROM_EWDS_OPCODE, 5); ixgb_shift_out_bits(hw, 0, 4); /* Done with writing */ ixgb_cleanup_eeprom(hw); return;}/****************************************************************************** * Reads a 16 bit word from the EEPROM. * * hw - Struct containing variables accessed by shared code * offset - offset of 16 bit word in the EEPROM to read * * Returns: * The 16-bit value read from the eeprom *****************************************************************************/uint16_t ixgb_read_eeprom(struct ixgb_hw * hw, uint16_t offset){ uint16_t data; /* Prepare the EEPROM for reading */ ixgb_setup_eeprom(hw); /* Send the READ command (opcode + addr) */ ixgb_shift_out_bits(hw, EEPROM_READ_OPCODE, 3); /* * We have a 64 word EEPROM, there are 6 address bits */ ixgb_shift_out_bits(hw, offset, 6); /* Read the data */ data = ixgb_shift_in_bits(hw); /* End this read operation */ ixgb_standby_eeprom(hw); return (data);}/****************************************************************************** * Reads eeprom and stores data in shared structure. * Validates eeprom checksum and eeprom signature. * * hw - Struct containing variables accessed by shared code * * Returns: * TRUE: if eeprom read is successful * FALSE: otherwise. *****************************************************************************/boolean_t ixgb_get_eeprom_data(struct ixgb_hw * hw){ uint16_t i; uint16_t checksum = 0; struct ixgb_ee_map_type *ee_map; DEBUGFUNC("ixgb_get_eeprom_data"); ee_map = (struct ixgb_ee_map_type *)hw->eeprom; DEBUGOUT("ixgb_ee: Reading eeprom data\n"); for (i = 0; i < IXGB_EEPROM_SIZE; i++) { uint16_t ee_data; ee_data = ixgb_read_eeprom(hw, i); checksum += ee_data; hw->eeprom[i] = le16_to_cpu(ee_data); } if (checksum != (uint16_t) EEPROM_SUM) { DEBUGOUT("ixgb_ee: Checksum invalid.\n"); return (FALSE); } if ((ee_map->init_ctrl_reg_1 & le16_to_cpu(EEPROM_ICW1_SIGNATURE_MASK)) != le16_to_cpu(EEPROM_ICW1_SIGNATURE_VALID)) { DEBUGOUT("ixgb_ee: Signature invalid.\n"); return (FALSE); } return (TRUE);}/****************************************************************************** * Local function to check if the eeprom signature is good * If the eeprom signature is good, calls ixgb)get_eeprom_data. * * hw - Struct containing variables accessed by shared code * * Returns: * TRUE: eeprom signature was good and the eeprom read was successful * FALSE: otherwise. ******************************************************************************/static boolean_t ixgb_check_and_get_eeprom_data(struct ixgb_hw *hw){ struct ixgb_ee_map_type *ee_map = (struct ixgb_ee_map_type *)hw->eeprom; if ((ee_map->init_ctrl_reg_1 & le16_to_cpu(EEPROM_ICW1_SIGNATURE_MASK)) == le16_to_cpu(EEPROM_ICW1_SIGNATURE_VALID)) { return (TRUE); } else { return ixgb_get_eeprom_data(hw); }}/****************************************************************************** * return a word from the eeprom * * hw - Struct containing variables accessed by shared code * index - Offset of eeprom word * * Returns: * Word at indexed offset in eeprom, if valid, 0 otherwise. ******************************************************************************/uint16_t ixgb_get_eeprom_word(struct ixgb_hw * hw, uint16_t index){ if ((index < IXGB_EEPROM_SIZE) && (ixgb_check_and_get_eeprom_data(hw) == TRUE)) { return (hw->eeprom[index]); } return (0);}/****************************************************************************** * return the mac address from EEPROM * * hw - Struct containing variables accessed by shared code * mac_addr - Ethernet Address if EEPROM contents are valid, 0 otherwise * * Returns: None. ******************************************************************************/void ixgb_get_ee_mac_addr(struct ixgb_hw *hw, uint8_t * mac_addr){ int i; struct ixgb_ee_map_type *ee_map = (struct ixgb_ee_map_type *)hw->eeprom; DEBUGFUNC("ixgb_get_ee_mac_addr"); if (ixgb_check_and_get_eeprom_data(hw) == TRUE) { for (i = 0; i < IXGB_ETH_LENGTH_OF_ADDRESS; i++) { mac_addr[i] = ee_map->mac_addr[i]; DEBUGOUT2("mac(%d) = %.2X\n", i, mac_addr[i]); } }}/****************************************************************************** * return the compatibility flags from EEPROM * * hw - Struct containing variables accessed by shared code * * Returns: * compatibility flags if EEPROM contents are valid, 0 otherwise ******************************************************************************/uint16_t ixgb_get_ee_compatibility(struct ixgb_hw *hw){ struct ixgb_ee_map_type *ee_map = (struct ixgb_ee_map_type *)hw->eeprom; if (ixgb_check_and_get_eeprom_data(hw) == TRUE) return (ee_map->compatibility); return (0);}/****************************************************************************** * return the Printed Board Assembly number from EEPROM * * hw - Struct containing variables accessed by shared code * * Returns: * PBA number if EEPROM contents are valid, 0 otherwise ******************************************************************************/uint32_t ixgb_get_ee_pba_number(struct ixgb_hw * hw){ if (ixgb_check_and_get_eeprom_data(hw) == TRUE) return (le16_to_cpu(hw->eeprom[EEPROM_PBA_1_2_REG]) | (le16_to_cpu(hw->eeprom[EEPROM_PBA_3_4_REG]) << 16)); return (0);}/****************************************************************************** * return the Initialization Control Word 1 from EEPROM * * hw - Struct containing variables accessed by shared code * * Returns: * Initialization Control Word 1 if EEPROM contents are valid, 0 otherwise ******************************************************************************/uint16_t ixgb_get_ee_init_ctrl_reg_1(struct ixgb_hw * hw){ struct ixgb_ee_map_type *ee_map = (struct ixgb_ee_map_type *)hw->eeprom; if (ixgb_check_and_get_eeprom_data(hw) == TRUE) return (ee_map->init_ctrl_reg_1); return (0);}/****************************************************************************** * return the Initialization Control Word 2 from EEPROM * * hw - Struct containing variables accessed by shared code * * Returns: * Initialization Control Word 2 if EEPROM contents are valid, 0 otherwise ******************************************************************************/uint16_t ixgb_get_ee_init_ctrl_reg_2(struct ixgb_hw * hw){ struct ixgb_ee_map_type *ee_map = (struct ixgb_ee_map_type *)hw->eeprom; if (ixgb_check_and_get_eeprom_data(hw) == TRUE) return (ee_map->init_ctrl_reg_2); return (0);}/****************************************************************************** * return the Subsystem Id from EEPROM * * hw - Struct containing variables accessed by shared code * * Returns: * Subsystem Id if EEPROM contents are valid, 0 otherwise ******************************************************************************/uint16_t ixgb_get_ee_subsystem_id(struct ixgb_hw * hw){ struct ixgb_ee_map_type *ee_map = (struct ixgb_ee_map_type *)hw->eeprom; if (ixgb_check_and_get_eeprom_data(hw) == TRUE) return (ee_map->subsystem_id); return (0);}/****************************************************************************** * return the Sub Vendor Id from EEPROM * * hw - Struct containing variables accessed by shared code * * Returns: * Sub Vendor Id if EEPROM contents are valid, 0 otherwise ******************************************************************************/uint16_t ixgb_get_ee_subvendor_id(struct ixgb_hw * hw){ struct ixgb_ee_map_type *ee_map = (struct ixgb_ee_map_type *)hw->eeprom; if (ixgb_check_and_get_eeprom_data(hw) == TRUE) return (ee_map->subvendor_id); return (0);}/****************************************************************************** * return the Device Id from EEPROM * * hw - Struct containing variables accessed by shared code * * Returns: * Device Id if EEPROM contents are valid, 0 otherwise ******************************************************************************/uint16_t ixgb_get_ee_device_id(struct ixgb_hw * hw){ struct ixgb_ee_map_type *ee_map = (struct ixgb_ee_map_type *)hw->eeprom; if (ixgb_check_and_get_eeprom_data(hw) == TRUE) return (ee_map->device_id); return (0);}/****************************************************************************** * return the Vendor Id from EEPROM * * hw - Struct containing variables accessed by shared code * * Returns: * Device Id if EEPROM contents are valid, 0 otherwise ******************************************************************************/uint16_t ixgb_get_ee_vendor_id(struct ixgb_hw * hw){ struct ixgb_ee_map_type *ee_map = (struct ixgb_ee_map_type *)hw->eeprom; if (ixgb_check_and_get_eeprom_data(hw) == TRUE) return (ee_map->vendor_id); return (0);}/****************************************************************************** * return the Software Defined Pins Register from EEPROM * * hw - Struct containing variables accessed by shared code * * Returns: * SDP Register if EEPROM contents are valid, 0 otherwise ******************************************************************************/uint16_t ixgb_get_ee_swdpins_reg(struct ixgb_hw * hw){ struct ixgb_ee_map_type *ee_map = (struct ixgb_ee_map_type *)hw->eeprom; if (ixgb_check_and_get_eeprom_data(hw) == TRUE) return (ee_map->swdpins_reg); return (0);}/****************************************************************************** * return the D3 Power Management Bits from EEPROM * * hw - Struct containing variables accessed by shared code * * Returns: * D3 Power Management Bits if EEPROM contents are valid, 0 otherwise ******************************************************************************/uint8_t ixgb_get_ee_d3_power(struct ixgb_hw * hw){ struct ixgb_ee_map_type *ee_map = (struct ixgb_ee_map_type *)hw->eeprom; if (ixgb_check_and_get_eeprom_data(hw) == TRUE) return (ee_map->d3_power); return (0);}/****************************************************************************** * return the D0 Power Management Bits from EEPROM * * hw - Struct containing variables accessed by shared code * * Returns: * D0 Power Management Bits if EEPROM contents are valid, 0 otherwise ******************************************************************************/uint8_t ixgb_get_ee_d0_power(struct ixgb_hw * hw){ struct ixgb_ee_map_type *ee_map = (struct ixgb_ee_map_type *)hw->eeprom; if (ixgb_check_and_get_eeprom_data(hw) == TRUE) return (ee_map->d0_power); return (0);}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?