aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/netxen/netxen_nic_init.c
diff options
context:
space:
mode:
authorDhananjay Phadke <dhananjay@netxen.com>2008-07-21 22:44:04 -0400
committerJeff Garzik <jgarzik@redhat.com>2008-07-22 17:51:53 -0400
commit2956640d4aaaecd42bd8ba800cc8c33bfe206b7e (patch)
tree78c0442fd1a382f5f01489d4f268c5876d243b95 /drivers/net/netxen/netxen_nic_init.c
parent3ce06a320f8d5a3f16960e63021cc372283efffb (diff)
netxen: pci probe and firmware init changes
Add initialization code in pci probe for new chip and retain compatibility with old revisions. Signed-off-by: Dhananjay Phadke <dhananjay@netxen.com> Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Diffstat (limited to 'drivers/net/netxen/netxen_nic_init.c')
-rw-r--r--drivers/net/netxen/netxen_nic_init.c404
1 files changed, 299 insertions, 105 deletions
diff --git a/drivers/net/netxen/netxen_nic_init.c b/drivers/net/netxen/netxen_nic_init.c
index 7323cd7b544a..c6e2bc71d8f3 100644
--- a/drivers/net/netxen/netxen_nic_init.c
+++ b/drivers/net/netxen/netxen_nic_init.c
@@ -130,7 +130,7 @@ int netxen_init_firmware(struct netxen_adapter *adapter)
130 return 0; 130 return 0;
131 131
132 while (state != PHAN_INITIALIZE_COMPLETE && loops < 2000) { 132 while (state != PHAN_INITIALIZE_COMPLETE && loops < 2000) {
133 udelay(100); 133 msleep(1);
134 /* Window 1 call */ 134 /* Window 1 call */
135 state = adapter->pci_read_normalize(adapter, CRB_CMDPEG_STATE); 135 state = adapter->pci_read_normalize(adapter, CRB_CMDPEG_STATE);
136 136
@@ -155,34 +155,165 @@ int netxen_init_firmware(struct netxen_adapter *adapter)
155 return err; 155 return err;
156} 156}
157 157
158void netxen_initialize_adapter_sw(struct netxen_adapter *adapter) 158void netxen_release_rx_buffers(struct netxen_adapter *adapter)
159{ 159{
160 int ctxid, ring; 160 struct netxen_recv_context *recv_ctx;
161 u32 i;
162 u32 num_rx_bufs = 0;
163 struct netxen_rcv_desc_ctx *rcv_desc; 161 struct netxen_rcv_desc_ctx *rcv_desc;
162 struct netxen_rx_buffer *rx_buf;
163 int i, ctxid, ring;
164 164
165 DPRINTK(INFO, "initializing some queues: %p\n", adapter);
166 for (ctxid = 0; ctxid < MAX_RCV_CTX; ++ctxid) { 165 for (ctxid = 0; ctxid < MAX_RCV_CTX; ++ctxid) {
166 recv_ctx = &adapter->recv_ctx[ctxid];
167 for (ring = 0; ring < NUM_RCV_DESC_RINGS; ring++) { 167 for (ring = 0; ring < NUM_RCV_DESC_RINGS; ring++) {
168 struct netxen_rx_buffer *rx_buf; 168 rcv_desc = &recv_ctx->rcv_desc[ring];
169 rcv_desc = &adapter->recv_ctx[ctxid].rcv_desc[ring]; 169 for (i = 0; i < rcv_desc->max_rx_desc_count; ++i) {
170 rx_buf = &(rcv_desc->rx_buf_arr[i]);
171 if (rx_buf->state == NETXEN_BUFFER_FREE)
172 continue;
173 pci_unmap_single(adapter->pdev,
174 rx_buf->dma,
175 rcv_desc->dma_size,
176 PCI_DMA_FROMDEVICE);
177 if (rx_buf->skb != NULL)
178 dev_kfree_skb_any(rx_buf->skb);
179 }
180 }
181 }
182}
183
184void netxen_release_tx_buffers(struct netxen_adapter *adapter)
185{
186 struct netxen_cmd_buffer *cmd_buf;
187 struct netxen_skb_frag *buffrag;
188 int i, j;
189
190 cmd_buf = adapter->cmd_buf_arr;
191 for (i = 0; i < adapter->max_tx_desc_count; i++) {
192 buffrag = cmd_buf->frag_array;
193 if (buffrag->dma) {
194 pci_unmap_single(adapter->pdev, buffrag->dma,
195 buffrag->length, PCI_DMA_TODEVICE);
196 buffrag->dma = 0ULL;
197 }
198 for (j = 0; j < cmd_buf->frag_count; j++) {
199 buffrag++;
200 if (buffrag->dma) {
201 pci_unmap_page(adapter->pdev, buffrag->dma,
202 buffrag->length,
203 PCI_DMA_TODEVICE);
204 buffrag->dma = 0ULL;
205 }
206 }
207 /* Free the skb we received in netxen_nic_xmit_frame */
208 if (cmd_buf->skb) {
209 dev_kfree_skb_any(cmd_buf->skb);
210 cmd_buf->skb = NULL;
211 }
212 cmd_buf++;
213 }
214}
215
216void netxen_free_sw_resources(struct netxen_adapter *adapter)
217{
218 struct netxen_recv_context *recv_ctx;
219 struct netxen_rcv_desc_ctx *rcv_desc;
220 int ctx, ring;
221
222 for (ctx = 0; ctx < MAX_RCV_CTX; ctx++) {
223 recv_ctx = &adapter->recv_ctx[ctx];
224 for (ring = 0; ring < NUM_RCV_DESC_RINGS; ring++) {
225 rcv_desc = &recv_ctx->rcv_desc[ring];
226 if (rcv_desc->rx_buf_arr) {
227 vfree(rcv_desc->rx_buf_arr);
228 rcv_desc->rx_buf_arr = NULL;
229 }
230 }
231 }
232 if (adapter->cmd_buf_arr)
233 vfree(adapter->cmd_buf_arr);
234 return;
235}
236
237int netxen_alloc_sw_resources(struct netxen_adapter *adapter)
238{
239 struct netxen_recv_context *recv_ctx;
240 struct netxen_rcv_desc_ctx *rcv_desc;
241 struct netxen_rx_buffer *rx_buf;
242 int ctx, ring, i, num_rx_bufs;
243
244 struct netxen_cmd_buffer *cmd_buf_arr;
245 struct net_device *netdev = adapter->netdev;
246
247 cmd_buf_arr = (struct netxen_cmd_buffer *)vmalloc(TX_RINGSIZE);
248 if (cmd_buf_arr == NULL) {
249 printk(KERN_ERR "%s: Failed to allocate cmd buffer ring\n",
250 netdev->name);
251 return -ENOMEM;
252 }
253 memset(cmd_buf_arr, 0, TX_RINGSIZE);
254 adapter->cmd_buf_arr = cmd_buf_arr;
255
256 for (ctx = 0; ctx < MAX_RCV_CTX; ctx++) {
257 recv_ctx = &adapter->recv_ctx[ctx];
258 for (ring = 0; ring < NUM_RCV_DESC_RINGS; ring++) {
259 rcv_desc = &recv_ctx->rcv_desc[ring];
260 switch (RCV_DESC_TYPE(ring)) {
261 case RCV_DESC_NORMAL:
262 rcv_desc->max_rx_desc_count =
263 adapter->max_rx_desc_count;
264 rcv_desc->flags = RCV_DESC_NORMAL;
265 rcv_desc->dma_size = RX_DMA_MAP_LEN;
266 rcv_desc->skb_size = MAX_RX_BUFFER_LENGTH;
267 break;
268
269 case RCV_DESC_JUMBO:
270 rcv_desc->max_rx_desc_count =
271 adapter->max_jumbo_rx_desc_count;
272 rcv_desc->flags = RCV_DESC_JUMBO;
273 rcv_desc->dma_size = RX_JUMBO_DMA_MAP_LEN;
274 rcv_desc->skb_size =
275 MAX_RX_JUMBO_BUFFER_LENGTH;
276 break;
277
278 case RCV_RING_LRO:
279 rcv_desc->max_rx_desc_count =
280 adapter->max_lro_rx_desc_count;
281 rcv_desc->flags = RCV_DESC_LRO;
282 rcv_desc->dma_size = RX_LRO_DMA_MAP_LEN;
283 rcv_desc->skb_size = MAX_RX_LRO_BUFFER_LENGTH;
284 break;
285
286 }
287 rcv_desc->rx_buf_arr = (struct netxen_rx_buffer *)
288 vmalloc(RCV_BUFFSIZE);
289 if (rcv_desc->rx_buf_arr == NULL) {
290 printk(KERN_ERR "%s: Failed to allocate "
291 "rx buffer ring %d\n",
292 netdev->name, ring);
293 /* free whatever was already allocated */
294 goto err_out;
295 }
296 memset(rcv_desc->rx_buf_arr, 0, RCV_BUFFSIZE);
170 rcv_desc->begin_alloc = 0; 297 rcv_desc->begin_alloc = 0;
171 rx_buf = rcv_desc->rx_buf_arr;
172 num_rx_bufs = rcv_desc->max_rx_desc_count;
173 /* 298 /*
174 * Now go through all of them, set reference handles 299 * Now go through all of them, set reference handles
175 * and put them in the queues. 300 * and put them in the queues.
176 */ 301 */
302 num_rx_bufs = rcv_desc->max_rx_desc_count;
303 rx_buf = rcv_desc->rx_buf_arr;
177 for (i = 0; i < num_rx_bufs; i++) { 304 for (i = 0; i < num_rx_bufs; i++) {
178 rx_buf->ref_handle = i; 305 rx_buf->ref_handle = i;
179 rx_buf->state = NETXEN_BUFFER_FREE; 306 rx_buf->state = NETXEN_BUFFER_FREE;
180 DPRINTK(INFO, "Rx buf:ctx%d i(%d) rx_buf:"
181 "%p\n", ctxid, i, rx_buf);
182 rx_buf++; 307 rx_buf++;
183 } 308 }
184 } 309 }
185 } 310 }
311
312 return 0;
313
314err_out:
315 netxen_free_sw_resources(adapter);
316 return -ENOMEM;
186} 317}
187 318
188void netxen_initialize_adapter_ops(struct netxen_adapter *adapter) 319void netxen_initialize_adapter_ops(struct netxen_adapter *adapter)
@@ -730,19 +861,18 @@ int netxen_flash_unlock(struct netxen_adapter *adapter)
730#define NETXEN_BOARDTYPE 0x4008 861#define NETXEN_BOARDTYPE 0x4008
731#define NETXEN_BOARDNUM 0x400c 862#define NETXEN_BOARDNUM 0x400c
732#define NETXEN_CHIPNUM 0x4010 863#define NETXEN_CHIPNUM 0x4010
733#define NETXEN_ROMBUS_RESET 0xFFFFFFFF
734 864
735int netxen_pinit_from_rom(struct netxen_adapter *adapter, int verbose) 865int netxen_pinit_from_rom(struct netxen_adapter *adapter, int verbose)
736{ 866{
737 int addr, val; 867 int addr, val;
738 int n, i; 868 int i, init_delay = 0;
739 int init_delay = 0;
740 struct crb_addr_pair *buf; 869 struct crb_addr_pair *buf;
870 unsigned offset, n;
741 u32 off; 871 u32 off;
742 872
743 /* resetall */ 873 /* resetall */
744 netxen_crb_writelit_adapter(adapter, NETXEN_ROMUSB_GLB_SW_RESET, 874 netxen_crb_writelit_adapter(adapter, NETXEN_ROMUSB_GLB_SW_RESET,
745 NETXEN_ROMBUS_RESET); 875 0xffffffff);
746 876
747 if (verbose) { 877 if (verbose) {
748 if (netxen_rom_fast_read(adapter, NETXEN_BOARDTYPE, &val) == 0) 878 if (netxen_rom_fast_read(adapter, NETXEN_BOARDTYPE, &val) == 0)
@@ -759,108 +889,141 @@ int netxen_pinit_from_rom(struct netxen_adapter *adapter, int verbose)
759 printk("Could not read chip number\n"); 889 printk("Could not read chip number\n");
760 } 890 }
761 891
762 if (netxen_rom_fast_read(adapter, 0, &n) == 0 && (n & 0x80000000)) { 892 if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) {
763 n &= ~0x80000000; 893 if (netxen_rom_fast_read(adapter, 0, &n) != 0 ||
764 if (n < 0x400) { 894 (n != 0xcafecafeUL) ||
765 if (verbose) 895 netxen_rom_fast_read(adapter, 4, &n) != 0) {
766 printk("%s: %d CRB init values found" 896 printk(KERN_ERR "%s: ERROR Reading crb_init area: "
767 " in ROM.\n", netxen_nic_driver_name, n); 897 "n: %08x\n", netxen_nic_driver_name, n);
768 } else {
769 printk("%s:n=0x%x Error! NetXen card flash not"
770 " initialized.\n", __FUNCTION__, n);
771 return -EIO; 898 return -EIO;
772 } 899 }
773 buf = kcalloc(n, sizeof(struct crb_addr_pair), GFP_KERNEL); 900 offset = n & 0xffffU;
774 if (buf == NULL) { 901 n = (n >> 16) & 0xffffU;
775 printk("%s: netxen_pinit_from_rom: Unable to calloc " 902 } else {
776 "memory.\n", netxen_nic_driver_name); 903 if (netxen_rom_fast_read(adapter, 0, &n) != 0 ||
777 return -ENOMEM; 904 !(n & 0x80000000)) {
778 } 905 printk(KERN_ERR "%s: ERROR Reading crb_init area: "
779 for (i = 0; i < n; i++) { 906 "n: %08x\n", netxen_nic_driver_name, n);
780 if (netxen_rom_fast_read(adapter, 8 * i + 4, &val) != 0 907 return -EIO;
781 || netxen_rom_fast_read(adapter, 8 * i + 8,
782 &addr) != 0)
783 return -EIO;
784
785 buf[i].addr = addr;
786 buf[i].data = val;
787
788 if (verbose)
789 printk("%s: PCI: 0x%08x == 0x%08x\n",
790 netxen_nic_driver_name, (unsigned int)
791 netxen_decode_crb_addr(addr), val);
792 } 908 }
793 for (i = 0; i < n; i++) { 909 offset = 1;
910 n &= ~0x80000000;
911 }
912
913 if (n < 1024) {
914 if (verbose)
915 printk(KERN_DEBUG "%s: %d CRB init values found"
916 " in ROM.\n", netxen_nic_driver_name, n);
917 } else {
918 printk(KERN_ERR "%s:n=0x%x Error! NetXen card flash not"
919 " initialized.\n", __func__, n);
920 return -EIO;
921 }
922
923 buf = kcalloc(n, sizeof(struct crb_addr_pair), GFP_KERNEL);
924 if (buf == NULL) {
925 printk("%s: netxen_pinit_from_rom: Unable to calloc memory.\n",
926 netxen_nic_driver_name);
927 return -ENOMEM;
928 }
929 for (i = 0; i < n; i++) {
930 if (netxen_rom_fast_read(adapter, 8*i + 4*offset, &val) != 0 ||
931 netxen_rom_fast_read(adapter, 8*i + 4*offset + 4, &addr) != 0)
932 return -EIO;
933
934 buf[i].addr = addr;
935 buf[i].data = val;
794 936
795 off = netxen_decode_crb_addr(buf[i].addr); 937 if (verbose)
796 if (off == NETXEN_ADDR_ERROR) { 938 printk(KERN_DEBUG "%s: PCI: 0x%08x == 0x%08x\n",
797 printk(KERN_ERR"CRB init value out of range %x\n", 939 netxen_nic_driver_name,
940 (u32)netxen_decode_crb_addr(addr), val);
941 }
942 for (i = 0; i < n; i++) {
943
944 off = netxen_decode_crb_addr(buf[i].addr);
945 if (off == NETXEN_ADDR_ERROR) {
946 printk(KERN_ERR"CRB init value out of range %x\n",
798 buf[i].addr); 947 buf[i].addr);
948 continue;
949 }
950 off += NETXEN_PCI_CRBSPACE;
951 /* skipping cold reboot MAGIC */
952 if (off == NETXEN_CAM_RAM(0x1fc))
953 continue;
954
955 if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) {
956 /* do not reset PCI */
957 if (off == (ROMUSB_GLB + 0xbc))
799 continue; 958 continue;
800 } 959 if (off == (NETXEN_CRB_PEG_NET_1 + 0x18))
801 off += NETXEN_PCI_CRBSPACE; 960 buf[i].data = 0x1020;
802 /* skipping cold reboot MAGIC */ 961 /* skip the function enable register */
803 if (off == NETXEN_CAM_RAM(0x1fc)) 962 if (off == NETXEN_PCIE_REG(PCIE_SETUP_FUNCTION))
804 continue; 963 continue;
964 if (off == NETXEN_PCIE_REG(PCIE_SETUP_FUNCTION2))
965 continue;
966 if ((off & 0x0ff00000) == NETXEN_CRB_SMB)
967 continue;
968 }
805 969
806 /* After writing this register, HW needs time for CRB */ 970 if (off == NETXEN_ADDR_ERROR) {
807 /* to quiet down (else crb_window returns 0xffffffff) */ 971 printk(KERN_ERR "%s: Err: Unknown addr: 0x%08x\n",
808 if (off == NETXEN_ROMUSB_GLB_SW_RESET) { 972 netxen_nic_driver_name, buf[i].addr);
809 init_delay = 1; 973 continue;
974 }
975
976 /* After writing this register, HW needs time for CRB */
977 /* to quiet down (else crb_window returns 0xffffffff) */
978 if (off == NETXEN_ROMUSB_GLB_SW_RESET) {
979 init_delay = 1;
980 if (NX_IS_REVISION_P2(adapter->ahw.revision_id)) {
810 /* hold xdma in reset also */ 981 /* hold xdma in reset also */
811 buf[i].data = NETXEN_NIC_XDMA_RESET; 982 buf[i].data = NETXEN_NIC_XDMA_RESET;
812 } 983 }
984 }
813 985
814 adapter->hw_write_wx(adapter, off, &buf[i].data, 4); 986 adapter->hw_write_wx(adapter, off, &buf[i].data, 4);
815 987
816 if (init_delay == 1) { 988 if (init_delay == 1) {
817 msleep(1000); 989 msleep(1000);
818 init_delay = 0; 990 init_delay = 0;
819 }
820 msleep(1);
821 } 991 }
822 kfree(buf); 992 msleep(1);
993 }
994 kfree(buf);
823 995
824 /* disable_peg_cache_all */ 996 /* disable_peg_cache_all */
825 997
826 /* unreset_net_cache */ 998 /* unreset_net_cache */
827 adapter->hw_read_wx(adapter, NETXEN_ROMUSB_GLB_SW_RESET, &val, 999 if (NX_IS_REVISION_P2(adapter->ahw.revision_id)) {
828 4); 1000 adapter->hw_read_wx(adapter,
829 netxen_crb_writelit_adapter(adapter, NETXEN_ROMUSB_GLB_SW_RESET, 1001 NETXEN_ROMUSB_GLB_SW_RESET, &val, 4);
830 (val & 0xffffff0f));
831 /* p2dn replyCount */
832 netxen_crb_writelit_adapter(adapter, 1002 netxen_crb_writelit_adapter(adapter,
833 NETXEN_CRB_PEG_NET_D + 0xec, 0x1e); 1003 NETXEN_ROMUSB_GLB_SW_RESET, (val & 0xffffff0f));
834 /* disable_peg_cache 0 */
835 netxen_crb_writelit_adapter(adapter,
836 NETXEN_CRB_PEG_NET_D + 0x4c, 8);
837 /* disable_peg_cache 1 */
838 netxen_crb_writelit_adapter(adapter,
839 NETXEN_CRB_PEG_NET_I + 0x4c, 8);
840
841 /* peg_clr_all */
842
843 /* peg_clr 0 */
844 netxen_crb_writelit_adapter(adapter, NETXEN_CRB_PEG_NET_0 + 0x8,
845 0);
846 netxen_crb_writelit_adapter(adapter, NETXEN_CRB_PEG_NET_0 + 0xc,
847 0);
848 /* peg_clr 1 */
849 netxen_crb_writelit_adapter(adapter, NETXEN_CRB_PEG_NET_1 + 0x8,
850 0);
851 netxen_crb_writelit_adapter(adapter, NETXEN_CRB_PEG_NET_1 + 0xc,
852 0);
853 /* peg_clr 2 */
854 netxen_crb_writelit_adapter(adapter, NETXEN_CRB_PEG_NET_2 + 0x8,
855 0);
856 netxen_crb_writelit_adapter(adapter, NETXEN_CRB_PEG_NET_2 + 0xc,
857 0);
858 /* peg_clr 3 */
859 netxen_crb_writelit_adapter(adapter, NETXEN_CRB_PEG_NET_3 + 0x8,
860 0);
861 netxen_crb_writelit_adapter(adapter, NETXEN_CRB_PEG_NET_3 + 0xc,
862 0);
863 } 1004 }
1005
1006 /* p2dn replyCount */
1007 netxen_crb_writelit_adapter(adapter, NETXEN_CRB_PEG_NET_D + 0xec, 0x1e);
1008 /* disable_peg_cache 0 */
1009 netxen_crb_writelit_adapter(adapter, NETXEN_CRB_PEG_NET_D + 0x4c, 8);
1010 /* disable_peg_cache 1 */
1011 netxen_crb_writelit_adapter(adapter, NETXEN_CRB_PEG_NET_I + 0x4c, 8);
1012
1013 /* peg_clr_all */
1014
1015 /* peg_clr 0 */
1016 netxen_crb_writelit_adapter(adapter, NETXEN_CRB_PEG_NET_0 + 0x8, 0);
1017 netxen_crb_writelit_adapter(adapter, NETXEN_CRB_PEG_NET_0 + 0xc, 0);
1018 /* peg_clr 1 */
1019 netxen_crb_writelit_adapter(adapter, NETXEN_CRB_PEG_NET_1 + 0x8, 0);
1020 netxen_crb_writelit_adapter(adapter, NETXEN_CRB_PEG_NET_1 + 0xc, 0);
1021 /* peg_clr 2 */
1022 netxen_crb_writelit_adapter(adapter, NETXEN_CRB_PEG_NET_2 + 0x8, 0);
1023 netxen_crb_writelit_adapter(adapter, NETXEN_CRB_PEG_NET_2 + 0xc, 0);
1024 /* peg_clr 3 */
1025 netxen_crb_writelit_adapter(adapter, NETXEN_CRB_PEG_NET_3 + 0x8, 0);
1026 netxen_crb_writelit_adapter(adapter, NETXEN_CRB_PEG_NET_3 + 0xc, 0);
864 return 0; 1027 return 0;
865} 1028}
866 1029
@@ -876,7 +1039,7 @@ int netxen_initialize_adapter_offload(struct netxen_adapter *adapter)
876 &adapter->dummy_dma.phys_addr); 1039 &adapter->dummy_dma.phys_addr);
877 if (adapter->dummy_dma.addr == NULL) { 1040 if (adapter->dummy_dma.addr == NULL) {
878 printk("%s: ERROR: Could not allocate dummy DMA memory\n", 1041 printk("%s: ERROR: Could not allocate dummy DMA memory\n",
879 __FUNCTION__); 1042 __func__);
880 return -ENOMEM; 1043 return -ENOMEM;
881 } 1044 }
882 1045
@@ -887,6 +1050,11 @@ int netxen_initialize_adapter_offload(struct netxen_adapter *adapter)
887 adapter->pci_write_normalize(adapter, CRB_HOST_DUMMY_BUF_ADDR_HI, hi); 1050 adapter->pci_write_normalize(adapter, CRB_HOST_DUMMY_BUF_ADDR_HI, hi);
888 adapter->pci_write_normalize(adapter, CRB_HOST_DUMMY_BUF_ADDR_LO, lo); 1051 adapter->pci_write_normalize(adapter, CRB_HOST_DUMMY_BUF_ADDR_LO, lo);
889 1052
1053 if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) {
1054 uint32_t temp = 0;
1055 adapter->hw_write_wx(adapter, CRB_HOST_DUMMY_BUF, &temp, 4);
1056 }
1057
890 return 0; 1058 return 0;
891} 1059}
892 1060
@@ -920,22 +1088,24 @@ void netxen_free_adapter_offload(struct netxen_adapter *adapter)
920int netxen_phantom_init(struct netxen_adapter *adapter, int pegtune_val) 1088int netxen_phantom_init(struct netxen_adapter *adapter, int pegtune_val)
921{ 1089{
922 u32 val = 0; 1090 u32 val = 0;
923 int retries = 30; 1091 int retries = 60;
924 1092
925 if (!pegtune_val) { 1093 if (!pegtune_val) {
926 do { 1094 do {
927 val = adapter->pci_read_normalize(adapter, 1095 val = adapter->pci_read_normalize(adapter,
928 CRB_CMDPEG_STATE); 1096 CRB_CMDPEG_STATE);
929 pegtune_val = adapter->pci_read_normalize(adapter,
930 NETXEN_ROMUSB_GLB_PEGTUNE_DONE);
931 1097
932 if (val == PHAN_INITIALIZE_COMPLETE || 1098 if (val == PHAN_INITIALIZE_COMPLETE ||
933 val == PHAN_INITIALIZE_ACK) 1099 val == PHAN_INITIALIZE_ACK)
934 return 0; 1100 return 0;
935 1101
936 msleep(1000); 1102 msleep(500);
1103
937 } while (--retries); 1104 } while (--retries);
1105
938 if (!retries) { 1106 if (!retries) {
1107 pegtune_val = adapter->pci_read_normalize(adapter,
1108 NETXEN_ROMUSB_GLB_PEGTUNE_DONE);
939 printk(KERN_WARNING "netxen_phantom_init: init failed, " 1109 printk(KERN_WARNING "netxen_phantom_init: init failed, "
940 "pegtune_val=%x\n", pegtune_val); 1110 "pegtune_val=%x\n", pegtune_val);
941 return -1; 1111 return -1;
@@ -945,6 +1115,30 @@ int netxen_phantom_init(struct netxen_adapter *adapter, int pegtune_val)
945 return 0; 1115 return 0;
946} 1116}
947 1117
1118int netxen_receive_peg_ready(struct netxen_adapter *adapter)
1119{
1120 u32 val = 0;
1121 int retries = 2000;
1122
1123 do {
1124 val = adapter->pci_read_normalize(adapter, CRB_RCVPEG_STATE);
1125
1126 if (val == PHAN_PEG_RCV_INITIALIZED)
1127 return 0;
1128
1129 msleep(10);
1130
1131 } while (--retries);
1132
1133 if (!retries) {
1134 printk(KERN_ERR "Receive Peg initialization not "
1135 "complete, state: 0x%x.\n", val);
1136 return -EIO;
1137 }
1138
1139 return 0;
1140}
1141
948static int netxen_nic_check_temp(struct netxen_adapter *adapter) 1142static int netxen_nic_check_temp(struct netxen_adapter *adapter)
949{ 1143{
950 struct net_device *netdev = adapter->netdev; 1144 struct net_device *netdev = adapter->netdev;