aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/brocade
diff options
context:
space:
mode:
authorJing Huang <huangj@Brocade.COM>2012-04-04 01:42:31 -0400
committerDavid S. Miller <davem@davemloft.net>2012-04-04 18:19:17 -0400
commit4d58cd6470aca9cbddc630250305a2e9e6c0b792 (patch)
treeecf05925a13b057186312e0196aedbe42db303fd /drivers/net/ethernet/brocade
parente491c77ed37de43cc89cfb4930f80f9a36dff1b8 (diff)
bna: Flash controller ioc pll init fixes
Added NFC pause/resume logic. We only do NFC pause/resume if NFC version is greater than 0x143 and it was halted before, otherwise we revert to old NFC halt mechanism. Made changes to avoid clearing off the interrupts during the initial pll initialization. Signed-off-by: Jing Huang <huangj@brocade.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/brocade')
-rw-r--r--drivers/net/ethernet/brocade/bna/bfa_ioc_ct.c142
-rw-r--r--drivers/net/ethernet/brocade/bna/bfi_reg.h6
2 files changed, 102 insertions, 46 deletions
diff --git a/drivers/net/ethernet/brocade/bna/bfa_ioc_ct.c b/drivers/net/ethernet/brocade/bna/bfa_ioc_ct.c
index 348479bbfa3a..b6b036a143ae 100644
--- a/drivers/net/ethernet/brocade/bna/bfa_ioc_ct.c
+++ b/drivers/net/ethernet/brocade/bna/bfa_ioc_ct.c
@@ -199,9 +199,9 @@ bfa_ioc_ct_notify_fail(struct bfa_ioc *ioc)
199 * Host to LPU mailbox message addresses 199 * Host to LPU mailbox message addresses
200 */ 200 */
201static const struct { 201static const struct {
202 u32 hfn_mbox; 202 u32 hfn_mbox;
203 u32 lpu_mbox; 203 u32 lpu_mbox;
204 u32 hfn_pgn; 204 u32 hfn_pgn;
205} ct_fnreg[] = { 205} ct_fnreg[] = {
206 { HOSTFN0_LPU_MBOX0_0, LPU_HOSTFN0_MBOX0_0, HOST_PAGE_NUM_FN0 }, 206 { HOSTFN0_LPU_MBOX0_0, LPU_HOSTFN0_MBOX0_0, HOST_PAGE_NUM_FN0 },
207 { HOSTFN1_LPU_MBOX0_8, LPU_HOSTFN1_MBOX0_8, HOST_PAGE_NUM_FN1 }, 207 { HOSTFN1_LPU_MBOX0_8, LPU_HOSTFN1_MBOX0_8, HOST_PAGE_NUM_FN1 },
@@ -803,17 +803,72 @@ bfa_ioc_ct2_mac_reset(void __iomem *rb)
803} 803}
804 804
805#define CT2_NFC_MAX_DELAY 1000 805#define CT2_NFC_MAX_DELAY 1000
806#define CT2_NFC_VER_VALID 0x143
807#define BFA_IOC_PLL_POLL 1000000
808
809static bool
810bfa_ioc_ct2_nfc_halted(void __iomem *rb)
811{
812 volatile u32 r32;
813
814 r32 = readl(rb + CT2_NFC_CSR_SET_REG);
815 if (r32 & __NFC_CONTROLLER_HALTED)
816 return true;
817
818 return false;
819}
820
821static void
822bfa_ioc_ct2_nfc_resume(void __iomem *rb)
823{
824 volatile u32 r32;
825 int i;
826
827 writel(__HALT_NFC_CONTROLLER, rb + CT2_NFC_CSR_CLR_REG);
828 for (i = 0; i < CT2_NFC_MAX_DELAY; i++) {
829 r32 = readl(rb + CT2_NFC_CSR_SET_REG);
830 if (!(r32 & __NFC_CONTROLLER_HALTED))
831 return;
832 udelay(1000);
833 }
834 BUG_ON(1);
835}
836
806static enum bfa_status 837static enum bfa_status
807bfa_ioc_ct2_pll_init(void __iomem *rb, enum bfi_asic_mode asic_mode) 838bfa_ioc_ct2_pll_init(void __iomem *rb, enum bfi_asic_mode asic_mode)
808{ 839{
809 volatile u32 wgn, r32; 840 volatile u32 wgn, r32;
810 int i; 841 u32 nfc_ver, i;
811 842
812 /*
813 * Initialize PLL if not already done by NFC
814 */
815 wgn = readl(rb + CT2_WGN_STATUS); 843 wgn = readl(rb + CT2_WGN_STATUS);
816 if (!(wgn & __GLBL_PF_VF_CFG_RDY)) { 844
845 nfc_ver = readl(rb + CT2_RSC_GPR15_REG);
846
847 if ((wgn == (__A2T_AHB_LOAD | __WGN_READY)) &&
848 (nfc_ver >= CT2_NFC_VER_VALID)) {
849 if (bfa_ioc_ct2_nfc_halted(rb))
850 bfa_ioc_ct2_nfc_resume(rb);
851 writel(__RESET_AND_START_SCLK_LCLK_PLLS,
852 rb + CT2_CSI_FW_CTL_SET_REG);
853
854 for (i = 0; i < BFA_IOC_PLL_POLL; i++) {
855 r32 = readl(rb + CT2_APP_PLL_LCLK_CTL_REG);
856 if (r32 & __RESET_AND_START_SCLK_LCLK_PLLS)
857 break;
858 }
859 BUG_ON(!(r32 & __RESET_AND_START_SCLK_LCLK_PLLS));
860
861 for (i = 0; i < BFA_IOC_PLL_POLL; i++) {
862 r32 = readl(rb + CT2_APP_PLL_LCLK_CTL_REG);
863 if (!(r32 & __RESET_AND_START_SCLK_LCLK_PLLS))
864 break;
865 }
866 BUG_ON(r32 & __RESET_AND_START_SCLK_LCLK_PLLS);
867 udelay(1000);
868
869 r32 = readl(rb + CT2_CSI_FW_CTL_REG);
870 BUG_ON(r32 & __RESET_AND_START_SCLK_LCLK_PLLS);
871 } else {
817 writel(__HALT_NFC_CONTROLLER, (rb + CT2_NFC_CSR_SET_REG)); 872 writel(__HALT_NFC_CONTROLLER, (rb + CT2_NFC_CSR_SET_REG));
818 for (i = 0; i < CT2_NFC_MAX_DELAY; i++) { 873 for (i = 0; i < CT2_NFC_MAX_DELAY; i++) {
819 r32 = readl(rb + CT2_NFC_CSR_SET_REG); 874 r32 = readl(rb + CT2_NFC_CSR_SET_REG);
@@ -821,53 +876,48 @@ bfa_ioc_ct2_pll_init(void __iomem *rb, enum bfi_asic_mode asic_mode)
821 break; 876 break;
822 udelay(1000); 877 udelay(1000);
823 } 878 }
879
880 bfa_ioc_ct2_mac_reset(rb);
881 bfa_ioc_ct2_sclk_init(rb);
882 bfa_ioc_ct2_lclk_init(rb);
883
884 /* release soft reset on s_clk & l_clk */
885 r32 = readl((rb + CT2_APP_PLL_SCLK_CTL_REG));
886 writel(r32 & ~__APP_PLL_SCLK_LOGIC_SOFT_RESET,
887 rb + CT2_APP_PLL_SCLK_CTL_REG);
888 r32 = readl((rb + CT2_APP_PLL_LCLK_CTL_REG));
889 writel(r32 & ~__APP_PLL_LCLK_LOGIC_SOFT_RESET,
890 rb + CT2_APP_PLL_LCLK_CTL_REG);
891 }
892
893 /* Announce flash device presence, if flash was corrupted. */
894 if (wgn == (__WGN_READY | __GLBL_PF_VF_CFG_RDY)) {
895 r32 = readl((rb + PSS_GPIO_OUT_REG));
896 writel(r32 & ~1, rb + PSS_GPIO_OUT_REG);
897 r32 = readl((rb + PSS_GPIO_OE_REG));
898 writel(r32 | 1, rb + PSS_GPIO_OE_REG);
824 } 899 }
825 900
826 /* 901 /*
827 * Mask the interrupts and clear any 902 * Mask the interrupts and clear any
828 * pending interrupts left by BIOS/EFI 903 * pending interrupts left by BIOS/EFI
829 */ 904 */
830
831 writel(1, (rb + CT2_LPU0_HOSTFN_MBOX0_MSK)); 905 writel(1, (rb + CT2_LPU0_HOSTFN_MBOX0_MSK));
832 writel(1, (rb + CT2_LPU1_HOSTFN_MBOX0_MSK)); 906 writel(1, (rb + CT2_LPU1_HOSTFN_MBOX0_MSK));
833 907
834 r32 = readl((rb + CT2_LPU0_HOSTFN_CMD_STAT)); 908 /* For first time initialization, no need to clear interrupts */
835 if (r32 == 1) { 909 r32 = readl(rb + HOST_SEM5_REG);
836 writel(1, (rb + CT2_LPU0_HOSTFN_CMD_STAT)); 910 if (r32 & 0x1) {
837 readl((rb + CT2_LPU0_HOSTFN_CMD_STAT)); 911 r32 = readl((rb + CT2_LPU0_HOSTFN_CMD_STAT));
838 } 912 if (r32 == 1) {
839 r32 = readl((rb + CT2_LPU1_HOSTFN_CMD_STAT)); 913 writel(1, (rb + CT2_LPU0_HOSTFN_CMD_STAT));
840 if (r32 == 1) { 914 readl((rb + CT2_LPU0_HOSTFN_CMD_STAT));
841 writel(1, (rb + CT2_LPU1_HOSTFN_CMD_STAT)); 915 }
842 readl((rb + CT2_LPU1_HOSTFN_CMD_STAT)); 916 r32 = readl((rb + CT2_LPU1_HOSTFN_CMD_STAT));
843 } 917 if (r32 == 1) {
844 918 writel(1, (rb + CT2_LPU1_HOSTFN_CMD_STAT));
845 bfa_ioc_ct2_mac_reset(rb); 919 readl((rb + CT2_LPU1_HOSTFN_CMD_STAT));
846 bfa_ioc_ct2_sclk_init(rb); 920 }
847 bfa_ioc_ct2_lclk_init(rb);
848
849 /*
850 * release soft reset on s_clk & l_clk
851 */
852 r32 = readl((rb + CT2_APP_PLL_SCLK_CTL_REG));
853 writel((r32 & ~__APP_PLL_SCLK_LOGIC_SOFT_RESET),
854 (rb + CT2_APP_PLL_SCLK_CTL_REG));
855
856 /*
857 * release soft reset on s_clk & l_clk
858 */
859 r32 = readl((rb + CT2_APP_PLL_LCLK_CTL_REG));
860 writel(r32 & ~__APP_PLL_LCLK_LOGIC_SOFT_RESET,
861 (rb + CT2_APP_PLL_LCLK_CTL_REG));
862
863 /*
864 * Announce flash device presence, if flash was corrupted.
865 */
866 if (wgn == (__WGN_READY | __GLBL_PF_VF_CFG_RDY)) {
867 r32 = readl((rb + PSS_GPIO_OUT_REG));
868 writel((r32 & ~1), (rb + PSS_GPIO_OUT_REG));
869 r32 = readl((rb + PSS_GPIO_OE_REG));
870 writel((r32 | 1), (rb + PSS_GPIO_OE_REG));
871 } 921 }
872 922
873 bfa_ioc_ct2_mem_init(rb); 923 bfa_ioc_ct2_mem_init(rb);
diff --git a/drivers/net/ethernet/brocade/bna/bfi_reg.h b/drivers/net/ethernet/brocade/bna/bfi_reg.h
index efacff3ab51d..0e094fe46dfd 100644
--- a/drivers/net/ethernet/brocade/bna/bfi_reg.h
+++ b/drivers/net/ethernet/brocade/bna/bfi_reg.h
@@ -339,10 +339,16 @@ enum {
339#define __A2T_AHB_LOAD 0x00000800 339#define __A2T_AHB_LOAD 0x00000800
340#define __WGN_READY 0x00000400 340#define __WGN_READY 0x00000400
341#define __GLBL_PF_VF_CFG_RDY 0x00000200 341#define __GLBL_PF_VF_CFG_RDY 0x00000200
342#define CT2_NFC_CSR_CLR_REG 0x00027420
342#define CT2_NFC_CSR_SET_REG 0x00027424 343#define CT2_NFC_CSR_SET_REG 0x00027424
343#define __HALT_NFC_CONTROLLER 0x00000002 344#define __HALT_NFC_CONTROLLER 0x00000002
344#define __NFC_CONTROLLER_HALTED 0x00001000 345#define __NFC_CONTROLLER_HALTED 0x00001000
345 346
347#define CT2_RSC_GPR15_REG 0x0002765c
348#define CT2_CSI_FW_CTL_REG 0x00027080
349#define __RESET_AND_START_SCLK_LCLK_PLLS 0x00010000
350#define CT2_CSI_FW_CTL_SET_REG 0x00027088
351
346#define CT2_CSI_MAC0_CONTROL_REG 0x000270d0 352#define CT2_CSI_MAC0_CONTROL_REG 0x000270d0
347#define __CSI_MAC_RESET 0x00000010 353#define __CSI_MAC_RESET 0x00000010
348#define __CSI_MAC_AHB_RESET 0x00000008 354#define __CSI_MAC_AHB_RESET 0x00000008