13859Sml29623 /* 23859Sml29623 * CDDL HEADER START 33859Sml29623 * 43859Sml29623 * The contents of this file are subject to the terms of the 53859Sml29623 * Common Development and Distribution License (the "License"). 63859Sml29623 * You may not use this file except in compliance with the License. 73859Sml29623 * 83859Sml29623 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 93859Sml29623 * or http://www.opensolaris.org/os/licensing. 103859Sml29623 * See the License for the specific language governing permissions 113859Sml29623 * and limitations under the License. 123859Sml29623 * 133859Sml29623 * When distributing Covered Code, include this CDDL HEADER in each 143859Sml29623 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 153859Sml29623 * If applicable, add the following below this CDDL HEADER, with the 163859Sml29623 * fields enclosed by brackets "[]" replaced with your own identifying 173859Sml29623 * information: Portions Copyright [yyyy] [name of copyright owner] 183859Sml29623 * 193859Sml29623 * CDDL HEADER END 203859Sml29623 */ 213859Sml29623 /* 224185Sspeer * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 233859Sml29623 * Use is subject to license terms. 243859Sml29623 */ 253859Sml29623 263859Sml29623 #ifndef _NPI_ESPC_H 273859Sml29623 #define _NPI_ESPC_H 283859Sml29623 293859Sml29623 #pragma ident "%Z%%M% %I% %E% SMI" 303859Sml29623 313859Sml29623 #ifdef __cplusplus 323859Sml29623 extern "C" { 333859Sml29623 #endif 343859Sml29623 353859Sml29623 #include <npi.h> 363859Sml29623 #include <nxge_espc_hw.h> 373859Sml29623 383859Sml29623 #define EPC_WAIT_RW_COMP(handle, val_p, comp_bit) {\ 393859Sml29623 uint32_t cnt = MAX_PIO_RETRIES;\ 403859Sml29623 do {\ 413859Sml29623 NXGE_DELAY(EPC_RW_WAIT);\ 423859Sml29623 NXGE_REG_RD64(handle, ESPC_REG_ADDR(ESPC_PIO_STATUS_REG),\ 433859Sml29623 val_p); cnt--;\ 443859Sml29623 } while (((val & comp_bit) == 0) && (cnt > 0));\ 453859Sml29623 } 463859Sml29623 473859Sml29623 /* ESPC specific errors */ 483859Sml29623 493859Sml29623 #define ESPC_EEPROM_ADDR_INVALID 0x51 503859Sml29623 #define ESPC_STR_LEN_INVALID 0x91 513859Sml29623 523859Sml29623 /* ESPC error return macros */ 533859Sml29623 543859Sml29623 #define NPI_ESPC_EEPROM_ADDR_INVALID ((ESPC_BLK_ID << 8) |\ 553859Sml29623 ESPC_EEPROM_ADDR_INVALID) 563859Sml29623 #define NPI_ESPC_EEPROM_WRITE_FAILED ((ESPC_BLK_ID << 8) | WRITE_FAILED) 573859Sml29623 #define NPI_ESPC_EEPROM_READ_FAILED ((ESPC_BLK_ID << 8) | READ_FAILED) 583859Sml29623 #define NPI_ESPC_OPCODE_INVALID ((ESPC_BLK_ID << 8) | OPCODE_INVALID) 593859Sml29623 #define NPI_ESPC_STR_LEN_INVALID ((ESPC_BLK_ID << 8) |\ 603859Sml29623 ESPC_STR_LEN_INVALID) 613859Sml29623 #define NPI_ESPC_PORT_INVALID ((ESPC_BLK_ID << 8) | PORT_INVALID) 623859Sml29623 634185Sspeer /* EEPROM size, Fcode and VPD definitions */ 644185Sspeer 654185Sspeer /* 664185Sspeer * VPD information. 674185Sspeer */ 684185Sspeer #define NXGE_VPD_MOD_LEN 32 694185Sspeer #define NXGE_VPD_BD_MOD_LEN 16 704185Sspeer #define NXGE_VPD_PHY_LEN 5 714185Sspeer #define NXGE_VPD_VER_LEN 60 724185Sspeer typedef struct _npi_vpd_info_t { 734185Sspeer uint8_t mac_addr[ETHERADDRL]; 744185Sspeer uint8_t num_macs; 754185Sspeer char model[NXGE_VPD_MOD_LEN]; 764185Sspeer char bd_model[NXGE_VPD_BD_MOD_LEN]; 774185Sspeer char phy_type[NXGE_VPD_PHY_LEN]; 784185Sspeer char ver[NXGE_VPD_VER_LEN]; 794185Sspeer boolean_t ver_valid; 80*4977Sraghus boolean_t present; 814185Sspeer } npi_vpd_info_t, *p_npi_vpd_info_t; 824185Sspeer 834185Sspeer #define NXGE_FCODE_ID_STR "FCode " 844185Sspeer #define NXGE_FCODE_VER_STR_LEN 5 854185Sspeer #define NXGE_VPD_VALID_VER_W 3 864185Sspeer #define NXGE_VPD_VALID_VER_F 4 874185Sspeer #define EXPANSION_ROM_SIZE 65536 884185Sspeer #define FD_MODEL 0x01 894185Sspeer #define FD_BD_MODEL 0x02 904185Sspeer #define FD_MAC_ADDR 0x04 914185Sspeer #define FD_NUM_MACS 0x08 924185Sspeer #define FD_PHY_TYPE 0x10 934185Sspeer #define FD_FW_VERSION 0x20 944185Sspeer #define FD_ALL 0x3f 954185Sspeer 963859Sml29623 npi_status_t npi_espc_pio_enable(npi_handle_t); 973859Sml29623 npi_status_t npi_espc_pio_disable(npi_handle_t); 983859Sml29623 npi_status_t npi_espc_eeprom_entry(npi_handle_t, io_op_t, 993859Sml29623 uint32_t, uint8_t *); 1003859Sml29623 npi_status_t npi_espc_mac_addr_get(npi_handle_t, uint8_t *); 1013859Sml29623 npi_status_t npi_espc_num_ports_get(npi_handle_t, uint8_t *); 1023859Sml29623 npi_status_t npi_espc_num_macs_get(npi_handle_t, uint8_t *); 1033859Sml29623 npi_status_t npi_espc_model_str_get(npi_handle_t, char *); 1043859Sml29623 npi_status_t npi_espc_bd_model_str_get(npi_handle_t, char *); 1053859Sml29623 npi_status_t npi_espc_phy_type_get(npi_handle_t, uint8_t *); 1063859Sml29623 npi_status_t npi_espc_port_phy_type_get(npi_handle_t, uint8_t *, 1073859Sml29623 uint8_t); 1083859Sml29623 npi_status_t npi_espc_max_frame_get(npi_handle_t, uint16_t *); 1093859Sml29623 npi_status_t npi_espc_version_get(npi_handle_t, uint16_t *); 1103859Sml29623 npi_status_t npi_espc_img_sz_get(npi_handle_t, uint16_t *); 1113859Sml29623 npi_status_t npi_espc_chksum_get(npi_handle_t, uint8_t *); 1123859Sml29623 npi_status_t npi_espc_intr_num_get(npi_handle_t, uint8_t *); 1133859Sml29623 uint32_t npi_espc_reg_get(npi_handle_t, int); 1143859Sml29623 void npi_espc_dump(npi_handle_t); 1154185Sspeer npi_status_t npi_espc_vpd_info_get(npi_handle_t, p_npi_vpd_info_t, uint32_t); 1163859Sml29623 1173859Sml29623 #ifdef __cplusplus 1183859Sml29623 } 1193859Sml29623 #endif 1203859Sml29623 1213859Sml29623 #endif /* _NPI_ESPC_H */ 122