aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/bnx2x_main.c
diff options
context:
space:
mode:
authorEilon Greenstein <eilong@broadcom.com>2009-08-12 04:24:14 -0400
committerDavid S. Miller <davem@davemloft.net>2009-08-13 02:02:59 -0400
commit573f203574581faaf80ca4fc079d33452327fc3b (patch)
tree1bd1cce6b130dc6a30fced46665d3a112a168bfb /drivers/net/bnx2x_main.c
parente4ed7113372a04df9b7aa985ce3860207dbb1141 (diff)
bnx2x: Re-factor the initialization code
Moving the code to a more logical place and beautifying it. No real change in behavior. Signed-off-by: Vladislav Zolotarov <vladz@broadcom.com> Signed-off-by: Eilon Greenstein <eilong@broadcom.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/bnx2x_main.c')
-rw-r--r--drivers/net/bnx2x_main.c79
1 files changed, 59 insertions, 20 deletions
diff --git a/drivers/net/bnx2x_main.c b/drivers/net/bnx2x_main.c
index b084e8b531af..8b6bb999d8e0 100644
--- a/drivers/net/bnx2x_main.c
+++ b/drivers/net/bnx2x_main.c
@@ -153,7 +153,7 @@ MODULE_DEVICE_TABLE(pci, bnx2x_pci_tbl);
153/* used only at init 153/* used only at init
154 * locking is done by mcp 154 * locking is done by mcp
155 */ 155 */
156static void bnx2x_reg_wr_ind(struct bnx2x *bp, u32 addr, u32 val) 156void bnx2x_reg_wr_ind(struct bnx2x *bp, u32 addr, u32 val)
157{ 157{
158 pci_write_config_dword(bp->pdev, PCICFG_GRC_ADDRESS, addr); 158 pci_write_config_dword(bp->pdev, PCICFG_GRC_ADDRESS, addr);
159 pci_write_config_dword(bp->pdev, PCICFG_GRC_DATA, val); 159 pci_write_config_dword(bp->pdev, PCICFG_GRC_DATA, val);
@@ -346,6 +346,21 @@ void bnx2x_read_dmae(struct bnx2x *bp, u32 src_addr, u32 len32)
346 mutex_unlock(&bp->dmae_mutex); 346 mutex_unlock(&bp->dmae_mutex);
347} 347}
348 348
349void bnx2x_write_dmae_phys_len(struct bnx2x *bp, dma_addr_t phys_addr,
350 u32 addr, u32 len)
351{
352 int offset = 0;
353
354 while (len > DMAE_LEN32_WR_MAX) {
355 bnx2x_write_dmae(bp, phys_addr + offset,
356 addr + offset, DMAE_LEN32_WR_MAX);
357 offset += DMAE_LEN32_WR_MAX * 4;
358 len -= DMAE_LEN32_WR_MAX;
359 }
360
361 bnx2x_write_dmae(bp, phys_addr + offset, addr + offset, len);
362}
363
349/* used only for slowpath so not inlined */ 364/* used only for slowpath so not inlined */
350static void bnx2x_wb_wr(struct bnx2x *bp, int reg, u32 val_hi, u32 val_lo) 365static void bnx2x_wb_wr(struct bnx2x *bp, int reg, u32 val_hi, u32 val_lo)
351{ 366{
@@ -5917,6 +5932,24 @@ static void bnx2x_reset_common(struct bnx2x *bp)
5917 REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_2_CLEAR, 0x1403); 5932 REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_2_CLEAR, 0x1403);
5918} 5933}
5919 5934
5935static void bnx2x_init_pxp(struct bnx2x *bp)
5936{
5937 u16 devctl;
5938 int r_order, w_order;
5939
5940 pci_read_config_word(bp->pdev,
5941 bp->pcie_cap + PCI_EXP_DEVCTL, &devctl);
5942 DP(NETIF_MSG_HW, "read 0x%x from devctl\n", devctl);
5943 w_order = ((devctl & PCI_EXP_DEVCTL_PAYLOAD) >> 5);
5944 if (bp->mrrs == -1)
5945 r_order = ((devctl & PCI_EXP_DEVCTL_READRQ) >> 12);
5946 else {
5947 DP(NETIF_MSG_HW, "force read order to %d\n", bp->mrrs);
5948 r_order = bp->mrrs;
5949 }
5950
5951 bnx2x_init_pxp_arb(bp, r_order, w_order);
5952}
5920 5953
5921static void bnx2x_setup_fan_failure_detection(struct bnx2x *bp) 5954static void bnx2x_setup_fan_failure_detection(struct bnx2x *bp)
5922{ 5955{
@@ -6479,9 +6512,15 @@ static int bnx2x_init_func(struct bnx2x *bp)
6479 6512
6480 6513
6481 if (CHIP_IS_E1H(bp)) { 6514 if (CHIP_IS_E1H(bp)) {
6482 for (i = 0; i < 9; i++) 6515 bnx2x_init_block(bp, MISC_BLOCK, FUNC0_STAGE + func);
6483 bnx2x_init_block(bp, 6516 bnx2x_init_block(bp, TCM_BLOCK, FUNC0_STAGE + func);
6484 cm_blocks[i], FUNC0_STAGE + func); 6517 bnx2x_init_block(bp, UCM_BLOCK, FUNC0_STAGE + func);
6518 bnx2x_init_block(bp, CCM_BLOCK, FUNC0_STAGE + func);
6519 bnx2x_init_block(bp, XCM_BLOCK, FUNC0_STAGE + func);
6520 bnx2x_init_block(bp, TSEM_BLOCK, FUNC0_STAGE + func);
6521 bnx2x_init_block(bp, USEM_BLOCK, FUNC0_STAGE + func);
6522 bnx2x_init_block(bp, CSEM_BLOCK, FUNC0_STAGE + func);
6523 bnx2x_init_block(bp, XSEM_BLOCK, FUNC0_STAGE + func);
6485 6524
6486 REG_WR(bp, NIG_REG_LLH0_FUNC_EN + port*8, 1); 6525 REG_WR(bp, NIG_REG_LLH0_FUNC_EN + port*8, 1);
6487 REG_WR(bp, NIG_REG_LLH0_FUNC_VLAN_ID + port*8, bp->e1hov); 6526 REG_WR(bp, NIG_REG_LLH0_FUNC_VLAN_ID + port*8, bp->e1hov);
@@ -11834,22 +11873,22 @@ static int __devinit bnx2x_init_firmware(struct bnx2x *bp, struct device *dev)
11834 BNX2X_ALLOC_AND_SET(init_ops_offsets, init_offsets_alloc_err, be16_to_cpu_n); 11873 BNX2X_ALLOC_AND_SET(init_ops_offsets, init_offsets_alloc_err, be16_to_cpu_n);
11835 11874
11836 /* STORMs firmware */ 11875 /* STORMs firmware */
11837 bp->tsem_int_table_data = bp->firmware->data + 11876 INIT_TSEM_INT_TABLE_DATA(bp) = bp->firmware->data +
11838 be32_to_cpu(fw_hdr->tsem_int_table_data.offset); 11877 be32_to_cpu(fw_hdr->tsem_int_table_data.offset);
11839 bp->tsem_pram_data = bp->firmware->data + 11878 INIT_TSEM_PRAM_DATA(bp) = bp->firmware->data +
11840 be32_to_cpu(fw_hdr->tsem_pram_data.offset); 11879 be32_to_cpu(fw_hdr->tsem_pram_data.offset);
11841 bp->usem_int_table_data = bp->firmware->data + 11880 INIT_USEM_INT_TABLE_DATA(bp) = bp->firmware->data +
11842 be32_to_cpu(fw_hdr->usem_int_table_data.offset); 11881 be32_to_cpu(fw_hdr->usem_int_table_data.offset);
11843 bp->usem_pram_data = bp->firmware->data + 11882 INIT_USEM_PRAM_DATA(bp) = bp->firmware->data +
11844 be32_to_cpu(fw_hdr->usem_pram_data.offset); 11883 be32_to_cpu(fw_hdr->usem_pram_data.offset);
11845 bp->xsem_int_table_data = bp->firmware->data + 11884 INIT_XSEM_INT_TABLE_DATA(bp) = bp->firmware->data +
11846 be32_to_cpu(fw_hdr->xsem_int_table_data.offset); 11885 be32_to_cpu(fw_hdr->xsem_int_table_data.offset);
11847 bp->xsem_pram_data = bp->firmware->data + 11886 INIT_XSEM_PRAM_DATA(bp) = bp->firmware->data +
11848 be32_to_cpu(fw_hdr->xsem_pram_data.offset); 11887 be32_to_cpu(fw_hdr->xsem_pram_data.offset);
11849 bp->csem_int_table_data = bp->firmware->data + 11888 INIT_CSEM_INT_TABLE_DATA(bp) = bp->firmware->data +
11850 be32_to_cpu(fw_hdr->csem_int_table_data.offset); 11889 be32_to_cpu(fw_hdr->csem_int_table_data.offset);
11851 bp->csem_pram_data = bp->firmware->data + 11890 INIT_CSEM_PRAM_DATA(bp) = bp->firmware->data +
11852 be32_to_cpu(fw_hdr->csem_pram_data.offset); 11891 be32_to_cpu(fw_hdr->csem_pram_data.offset);
11853 11892
11854 return 0; 11893 return 0;
11855init_offsets_alloc_err: 11894init_offsets_alloc_err: