17956Sxiuyan.wang@Sun.COM /* 27956Sxiuyan.wang@Sun.COM * CDDL HEADER START 37956Sxiuyan.wang@Sun.COM * 47956Sxiuyan.wang@Sun.COM * The contents of this file are subject to the terms of the 57956Sxiuyan.wang@Sun.COM * Common Development and Distribution License (the "License"). 67956Sxiuyan.wang@Sun.COM * You may not use this file except in compliance with the License. 77956Sxiuyan.wang@Sun.COM * 87956Sxiuyan.wang@Sun.COM * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97956Sxiuyan.wang@Sun.COM * or http://www.opensolaris.org/os/licensing. 107956Sxiuyan.wang@Sun.COM * See the License for the specific language governing permissions 117956Sxiuyan.wang@Sun.COM * and limitations under the License. 127956Sxiuyan.wang@Sun.COM * 137956Sxiuyan.wang@Sun.COM * When distributing Covered Code, include this CDDL HEADER in each 147956Sxiuyan.wang@Sun.COM * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157956Sxiuyan.wang@Sun.COM * If applicable, add the following below this CDDL HEADER, with the 167956Sxiuyan.wang@Sun.COM * fields enclosed by brackets "[]" replaced with your own identifying 177956Sxiuyan.wang@Sun.COM * information: Portions Copyright [yyyy] [name of copyright owner] 187956Sxiuyan.wang@Sun.COM * 197956Sxiuyan.wang@Sun.COM * CDDL HEADER END 207956Sxiuyan.wang@Sun.COM */ 21*8687SJing.Xiong@Sun.COM 227956Sxiuyan.wang@Sun.COM /* 237956Sxiuyan.wang@Sun.COM * Copyright 2008 NetXen, Inc. All rights reserved. 247956Sxiuyan.wang@Sun.COM * Use is subject to license terms. 257956Sxiuyan.wang@Sun.COM */ 26*8687SJing.Xiong@Sun.COM 277956Sxiuyan.wang@Sun.COM #ifndef _UNM_NIC_HW_ 287956Sxiuyan.wang@Sun.COM #define _UNM_NIC_HW_ 297956Sxiuyan.wang@Sun.COM 30*8687SJing.Xiong@Sun.COM #ifdef __cplusplus 31*8687SJing.Xiong@Sun.COM extern "C" { 32*8687SJing.Xiong@Sun.COM #endif 33*8687SJing.Xiong@Sun.COM 347956Sxiuyan.wang@Sun.COM #include "unm_inc.h" 357956Sxiuyan.wang@Sun.COM 367956Sxiuyan.wang@Sun.COM /* Hardware memory size of 128 meg */ 377956Sxiuyan.wang@Sun.COM #define BAR0_SIZE (128 * 1024 * 1024) 387956Sxiuyan.wang@Sun.COM /* 397956Sxiuyan.wang@Sun.COM * It can be calculated by looking at the first 1 bit of the BAR0 addr after 407956Sxiuyan.wang@Sun.COM * bit 4 For us lets assume that BAR0 is D8000008, then the size is 0x8000000, 417956Sxiuyan.wang@Sun.COM * 8 represents first bit containing 1. FSL temp notes....pg 162 of PCI 427956Sxiuyan.wang@Sun.COM * systems arch... 437956Sxiuyan.wang@Sun.COM */ 447956Sxiuyan.wang@Sun.COM 457956Sxiuyan.wang@Sun.COM #define UNM_NIC_HW_BLOCK_WRITE_64(DATA_PTR, ADDR, NUM_WORDS) \ 467956Sxiuyan.wang@Sun.COM { \ 477956Sxiuyan.wang@Sun.COM int i; \ 487956Sxiuyan.wang@Sun.COM u64 *a = (u64 *) (DATA_PTR); \ 497956Sxiuyan.wang@Sun.COM u64 *b = (u64 *) (ADDR); \ 507956Sxiuyan.wang@Sun.COM u64 tmp; \ 517956Sxiuyan.wang@Sun.COM for (i = 0; i < (NUM_WORDS); i++, a++, b++) { \ 527956Sxiuyan.wang@Sun.COM tmp = UNM_NIC_PCI_READ_64(a); \ 537956Sxiuyan.wang@Sun.COM UNM_NIC_PCI_WRITE_64(tmp, b); \ 547956Sxiuyan.wang@Sun.COM } \ 557956Sxiuyan.wang@Sun.COM } 567956Sxiuyan.wang@Sun.COM 577956Sxiuyan.wang@Sun.COM #define UNM_NIC_HW_BLOCK_READ_64(DATA_PTR, ADDR, NUM_WORDS) \ 587956Sxiuyan.wang@Sun.COM { \ 597956Sxiuyan.wang@Sun.COM int i; \ 607956Sxiuyan.wang@Sun.COM u64 *a = (u64 *) (DATA_PTR); \ 617956Sxiuyan.wang@Sun.COM u64 *b = (u64 *) (ADDR); \ 627956Sxiuyan.wang@Sun.COM u64 tmp; \ 637956Sxiuyan.wang@Sun.COM for (i = 0; i < (NUM_WORDS); i++, a++, b++) { \ 647956Sxiuyan.wang@Sun.COM tmp = UNM_NIC_PCI_READ_64(b); \ 657956Sxiuyan.wang@Sun.COM UNM_NIC_PCI_WRITE_64(tmp, a); \ 667956Sxiuyan.wang@Sun.COM } \ 677956Sxiuyan.wang@Sun.COM } 687956Sxiuyan.wang@Sun.COM 697956Sxiuyan.wang@Sun.COM #define UNM_PCI_MAPSIZE_BYTES (UNM_PCI_MAPSIZE << 20) 707956Sxiuyan.wang@Sun.COM 717956Sxiuyan.wang@Sun.COM #define UNM_NIC_LOCKED_READ_REG(X, Y) \ 727956Sxiuyan.wang@Sun.COM addr = (void *)(pci_base_offset(adapter, (X))); \ 737956Sxiuyan.wang@Sun.COM *(uint32_t *)(Y) = UNM_NIC_PCI_READ_32(addr); 747956Sxiuyan.wang@Sun.COM 757956Sxiuyan.wang@Sun.COM #define UNM_NIC_LOCKED_WRITE_REG(X, Y) \ 767956Sxiuyan.wang@Sun.COM addr = (void *)(pci_base_offset(adapter, (X))); \ 777956Sxiuyan.wang@Sun.COM UNM_NIC_PCI_WRITE_32(*(uint32_t *)(Y), addr); 787956Sxiuyan.wang@Sun.COM 797956Sxiuyan.wang@Sun.COM /* For Multicard support */ 807956Sxiuyan.wang@Sun.COM #define UNM_CRB_READ_VAL_ADAPTER(ADDR, ADAPTER) \ 817956Sxiuyan.wang@Sun.COM unm_crb_read_val_adapter((ADDR), (struct unm_adapter_s *)ADAPTER) 827956Sxiuyan.wang@Sun.COM 837956Sxiuyan.wang@Sun.COM #define UNM_CRB_READ_CHECK_ADAPTER(ADDR, VALUE, ADAPTER) \ 847956Sxiuyan.wang@Sun.COM { \ 857956Sxiuyan.wang@Sun.COM if (unm_crb_read_adapter(ADDR, VALUE, \ 867956Sxiuyan.wang@Sun.COM (struct unm_adapter_s *)ADAPTER)) return -1; \ 877956Sxiuyan.wang@Sun.COM } 887956Sxiuyan.wang@Sun.COM 897956Sxiuyan.wang@Sun.COM #define UNM_CRB_WRITELIT_ADAPTER(ADDR, VALUE, ADAPTER) \ 907956Sxiuyan.wang@Sun.COM { \ 917956Sxiuyan.wang@Sun.COM adapter->unm_crb_writelit_adapter( \ 927956Sxiuyan.wang@Sun.COM (struct unm_adapter_s *)ADAPTER, \ 937956Sxiuyan.wang@Sun.COM (unsigned long)ADDR, (int)VALUE); \ 947956Sxiuyan.wang@Sun.COM } 957956Sxiuyan.wang@Sun.COM 967956Sxiuyan.wang@Sun.COM struct unm_adapter_s; 977956Sxiuyan.wang@Sun.COM void unm_nic_set_link_parameters(struct unm_adapter_s *adapter); 987956Sxiuyan.wang@Sun.COM long xge_mdio_init(struct unm_adapter_s *adapter); 997956Sxiuyan.wang@Sun.COM void unm_nic_flash_print(struct unm_adapter_s *adapter); 1007956Sxiuyan.wang@Sun.COM void unm_nic_get_serial_num(struct unm_adapter_s *adapter); 1017956Sxiuyan.wang@Sun.COM 1027956Sxiuyan.wang@Sun.COM typedef struct { 1037956Sxiuyan.wang@Sun.COM unsigned valid; 1047956Sxiuyan.wang@Sun.COM unsigned start_128M; 1057956Sxiuyan.wang@Sun.COM unsigned end_128M; 1067956Sxiuyan.wang@Sun.COM unsigned start_2M; 1077956Sxiuyan.wang@Sun.COM } crb_128M_2M_sub_block_map_t; 1087956Sxiuyan.wang@Sun.COM 1097956Sxiuyan.wang@Sun.COM typedef struct { 1107956Sxiuyan.wang@Sun.COM crb_128M_2M_sub_block_map_t sub_block[16]; 1117956Sxiuyan.wang@Sun.COM } crb_128M_2M_block_map_t; 1127956Sxiuyan.wang@Sun.COM 113*8687SJing.Xiong@Sun.COM #ifdef __cplusplus 114*8687SJing.Xiong@Sun.COM } 115*8687SJing.Xiong@Sun.COM #endif 116*8687SJing.Xiong@Sun.COM 1177956Sxiuyan.wang@Sun.COM #endif /* _UNM_NIC_HW_ */ 118