diff options
author | Krishna Gudipati <kgudipat@brocade.com> | 2012-03-13 20:39:22 -0400 |
---|---|---|
committer | James Bottomley <JBottomley@Parallels.com> | 2012-03-28 04:54:32 -0400 |
commit | a6b963db0de3c9aa22db2f872e38c2a12edf09a7 (patch) | |
tree | d5c68b277b7db6920992ca7b4133f2f9b589d8e4 /drivers/scsi/bfa | |
parent | 8919678eaaa2988000ff79341e42b656d5ca009b (diff) |
[SCSI] bfa: Flash controller IOC pll init fixes.
Made changes to resume the flash controller if it is halted before going
ahead with flash controller pause/resume logic.
Made changes to avoid clearing off the interrupts during the initial
pll initialization.
Signed-off-by: Krishna Gudipati <kgudipat@brocade.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Diffstat (limited to 'drivers/scsi/bfa')
-rw-r--r-- | drivers/scsi/bfa/bfa_ioc_ct.c | 151 | ||||
-rw-r--r-- | drivers/scsi/bfa/bfi_reg.h | 6 |
2 files changed, 112 insertions, 45 deletions
diff --git a/drivers/scsi/bfa/bfa_ioc_ct.c b/drivers/scsi/bfa/bfa_ioc_ct.c index d1b8f0caaa79..2eb0c6a2938d 100644 --- a/drivers/scsi/bfa/bfa_ioc_ct.c +++ b/drivers/scsi/bfa/bfa_ioc_ct.c | |||
@@ -786,17 +786,73 @@ bfa_ioc_ct2_mac_reset(void __iomem *rb) | |||
786 | } | 786 | } |
787 | 787 | ||
788 | #define CT2_NFC_MAX_DELAY 1000 | 788 | #define CT2_NFC_MAX_DELAY 1000 |
789 | #define CT2_NFC_VER_VALID 0x143 | ||
790 | #define BFA_IOC_PLL_POLL 1000000 | ||
791 | |||
792 | static bfa_boolean_t | ||
793 | bfa_ioc_ct2_nfc_halted(void __iomem *rb) | ||
794 | { | ||
795 | u32 r32; | ||
796 | |||
797 | r32 = readl(rb + CT2_NFC_CSR_SET_REG); | ||
798 | if (r32 & __NFC_CONTROLLER_HALTED) | ||
799 | return BFA_TRUE; | ||
800 | |||
801 | return BFA_FALSE; | ||
802 | } | ||
803 | |||
804 | static void | ||
805 | bfa_ioc_ct2_nfc_resume(void __iomem *rb) | ||
806 | { | ||
807 | u32 r32; | ||
808 | int i; | ||
809 | |||
810 | writel(__HALT_NFC_CONTROLLER, rb + CT2_NFC_CSR_CLR_REG); | ||
811 | for (i = 0; i < CT2_NFC_MAX_DELAY; i++) { | ||
812 | r32 = readl(rb + CT2_NFC_CSR_SET_REG); | ||
813 | if (!(r32 & __NFC_CONTROLLER_HALTED)) | ||
814 | return; | ||
815 | udelay(1000); | ||
816 | } | ||
817 | WARN_ON(1); | ||
818 | } | ||
819 | |||
789 | bfa_status_t | 820 | bfa_status_t |
790 | bfa_ioc_ct2_pll_init(void __iomem *rb, enum bfi_asic_mode mode) | 821 | bfa_ioc_ct2_pll_init(void __iomem *rb, enum bfi_asic_mode mode) |
791 | { | 822 | { |
792 | u32 wgn, r32; | 823 | u32 wgn, r32, nfc_ver, i; |
793 | int i; | ||
794 | 824 | ||
795 | /* | ||
796 | * Initialize PLL if not already done by NFC | ||
797 | */ | ||
798 | wgn = readl(rb + CT2_WGN_STATUS); | 825 | wgn = readl(rb + CT2_WGN_STATUS); |
799 | if (!(wgn & __GLBL_PF_VF_CFG_RDY)) { | 826 | nfc_ver = readl(rb + CT2_RSC_GPR15_REG); |
827 | |||
828 | if ((wgn == (__A2T_AHB_LOAD | __WGN_READY)) && | ||
829 | (nfc_ver >= CT2_NFC_VER_VALID)) { | ||
830 | if (bfa_ioc_ct2_nfc_halted(rb)) | ||
831 | bfa_ioc_ct2_nfc_resume(rb); | ||
832 | |||
833 | writel(__RESET_AND_START_SCLK_LCLK_PLLS, | ||
834 | rb + CT2_CSI_FW_CTL_SET_REG); | ||
835 | |||
836 | for (i = 0; i < BFA_IOC_PLL_POLL; i++) { | ||
837 | r32 = readl(rb + CT2_APP_PLL_LCLK_CTL_REG); | ||
838 | if (r32 & __RESET_AND_START_SCLK_LCLK_PLLS) | ||
839 | break; | ||
840 | } | ||
841 | |||
842 | WARN_ON(!(r32 & __RESET_AND_START_SCLK_LCLK_PLLS)); | ||
843 | |||
844 | for (i = 0; i < BFA_IOC_PLL_POLL; i++) { | ||
845 | r32 = readl(rb + CT2_APP_PLL_LCLK_CTL_REG); | ||
846 | if (!(r32 & __RESET_AND_START_SCLK_LCLK_PLLS)) | ||
847 | break; | ||
848 | } | ||
849 | |||
850 | WARN_ON(r32 & __RESET_AND_START_SCLK_LCLK_PLLS); | ||
851 | udelay(1000); | ||
852 | |||
853 | r32 = readl(rb + CT2_CSI_FW_CTL_REG); | ||
854 | WARN_ON(r32 & __RESET_AND_START_SCLK_LCLK_PLLS); | ||
855 | } else { | ||
800 | writel(__HALT_NFC_CONTROLLER, rb + CT2_NFC_CSR_SET_REG); | 856 | writel(__HALT_NFC_CONTROLLER, rb + CT2_NFC_CSR_SET_REG); |
801 | for (i = 0; i < CT2_NFC_MAX_DELAY; i++) { | 857 | for (i = 0; i < CT2_NFC_MAX_DELAY; i++) { |
802 | r32 = readl(rb + CT2_NFC_CSR_SET_REG); | 858 | r32 = readl(rb + CT2_NFC_CSR_SET_REG); |
@@ -804,57 +860,62 @@ bfa_ioc_ct2_pll_init(void __iomem *rb, enum bfi_asic_mode mode) | |||
804 | break; | 860 | break; |
805 | udelay(1000); | 861 | udelay(1000); |
806 | } | 862 | } |
807 | } | ||
808 | 863 | ||
809 | /* | 864 | bfa_ioc_ct2_mac_reset(rb); |
810 | * Mask the interrupts and clear any | 865 | bfa_ioc_ct2_sclk_init(rb); |
811 | * pending interrupts. | 866 | bfa_ioc_ct2_lclk_init(rb); |
812 | */ | 867 | |
813 | writel(1, (rb + CT2_LPU0_HOSTFN_MBOX0_MSK)); | 868 | /* |
814 | writel(1, (rb + CT2_LPU1_HOSTFN_MBOX0_MSK)); | 869 | * release soft reset on s_clk & l_clk |
815 | 870 | */ | |
816 | r32 = readl((rb + CT2_LPU0_HOSTFN_CMD_STAT)); | 871 | r32 = readl(rb + CT2_APP_PLL_SCLK_CTL_REG); |
817 | if (r32 == 1) { | 872 | writel(r32 & ~__APP_PLL_SCLK_LOGIC_SOFT_RESET, |
818 | writel(1, (rb + CT2_LPU0_HOSTFN_CMD_STAT)); | 873 | (rb + CT2_APP_PLL_SCLK_CTL_REG)); |
819 | readl((rb + CT2_LPU0_HOSTFN_CMD_STAT)); | 874 | |
875 | /* | ||
876 | * release soft reset on s_clk & l_clk | ||
877 | */ | ||
878 | r32 = readl(rb + CT2_APP_PLL_LCLK_CTL_REG); | ||
879 | writel(r32 & ~__APP_PLL_LCLK_LOGIC_SOFT_RESET, | ||
880 | (rb + CT2_APP_PLL_LCLK_CTL_REG)); | ||
820 | } | 881 | } |
821 | r32 = readl((rb + CT2_LPU1_HOSTFN_CMD_STAT)); | ||
822 | if (r32 == 1) { | ||
823 | writel(1, (rb + CT2_LPU1_HOSTFN_CMD_STAT)); | ||
824 | readl((rb + CT2_LPU1_HOSTFN_CMD_STAT)); | ||
825 | } | ||
826 | |||
827 | bfa_ioc_ct2_mac_reset(rb); | ||
828 | bfa_ioc_ct2_sclk_init(rb); | ||
829 | bfa_ioc_ct2_lclk_init(rb); | ||
830 | |||
831 | /* | ||
832 | * release soft reset on s_clk & l_clk | ||
833 | */ | ||
834 | r32 = readl((rb + CT2_APP_PLL_SCLK_CTL_REG)); | ||
835 | writel(r32 & ~__APP_PLL_SCLK_LOGIC_SOFT_RESET, | ||
836 | (rb + CT2_APP_PLL_SCLK_CTL_REG)); | ||
837 | |||
838 | /* | ||
839 | * release soft reset on s_clk & l_clk | ||
840 | */ | ||
841 | r32 = readl((rb + CT2_APP_PLL_LCLK_CTL_REG)); | ||
842 | writel(r32 & ~__APP_PLL_LCLK_LOGIC_SOFT_RESET, | ||
843 | (rb + CT2_APP_PLL_LCLK_CTL_REG)); | ||
844 | 882 | ||
845 | /* | 883 | /* |
846 | * Announce flash device presence, if flash was corrupted. | 884 | * Announce flash device presence, if flash was corrupted. |
847 | */ | 885 | */ |
848 | if (wgn == (__WGN_READY | __GLBL_PF_VF_CFG_RDY)) { | 886 | if (wgn == (__WGN_READY | __GLBL_PF_VF_CFG_RDY)) { |
849 | r32 = readl((rb + PSS_GPIO_OUT_REG)); | 887 | r32 = readl(rb + PSS_GPIO_OUT_REG); |
850 | writel(r32 & ~1, (rb + PSS_GPIO_OUT_REG)); | 888 | writel(r32 & ~1, (rb + PSS_GPIO_OUT_REG)); |
851 | r32 = readl((rb + PSS_GPIO_OE_REG)); | 889 | r32 = readl(rb + PSS_GPIO_OE_REG); |
852 | writel(r32 | 1, (rb + PSS_GPIO_OE_REG)); | 890 | writel(r32 | 1, (rb + PSS_GPIO_OE_REG)); |
853 | } | 891 | } |
854 | 892 | ||
893 | /* | ||
894 | * Mask the interrupts and clear any | ||
895 | * pending interrupts. | ||
896 | */ | ||
897 | writel(1, (rb + CT2_LPU0_HOSTFN_MBOX0_MSK)); | ||
898 | writel(1, (rb + CT2_LPU1_HOSTFN_MBOX0_MSK)); | ||
899 | |||
900 | /* For first time initialization, no need to clear interrupts */ | ||
901 | r32 = readl(rb + HOST_SEM5_REG); | ||
902 | if (r32 & 0x1) { | ||
903 | r32 = readl(rb + CT2_LPU0_HOSTFN_CMD_STAT); | ||
904 | if (r32 == 1) { | ||
905 | writel(1, rb + CT2_LPU0_HOSTFN_CMD_STAT); | ||
906 | readl((rb + CT2_LPU0_HOSTFN_CMD_STAT)); | ||
907 | } | ||
908 | r32 = readl(rb + CT2_LPU1_HOSTFN_CMD_STAT); | ||
909 | if (r32 == 1) { | ||
910 | writel(1, rb + CT2_LPU1_HOSTFN_CMD_STAT); | ||
911 | readl(rb + CT2_LPU1_HOSTFN_CMD_STAT); | ||
912 | } | ||
913 | } | ||
914 | |||
855 | bfa_ioc_ct2_mem_init(rb); | 915 | bfa_ioc_ct2_mem_init(rb); |
856 | 916 | ||
857 | writel(BFI_IOC_UNINIT, (rb + CT2_BFA_IOC0_STATE_REG)); | 917 | writel(BFI_IOC_UNINIT, rb + CT2_BFA_IOC0_STATE_REG); |
858 | writel(BFI_IOC_UNINIT, (rb + CT2_BFA_IOC1_STATE_REG)); | 918 | writel(BFI_IOC_UNINIT, rb + CT2_BFA_IOC1_STATE_REG); |
919 | |||
859 | return BFA_STATUS_OK; | 920 | return BFA_STATUS_OK; |
860 | } | 921 | } |
diff --git a/drivers/scsi/bfa/bfi_reg.h b/drivers/scsi/bfa/bfi_reg.h index d892064b64a8..ed5f159e1867 100644 --- a/drivers/scsi/bfa/bfi_reg.h +++ b/drivers/scsi/bfa/bfi_reg.h | |||
@@ -335,11 +335,17 @@ enum { | |||
335 | #define __PMM_1T_PNDB_P 0x00000002 | 335 | #define __PMM_1T_PNDB_P 0x00000002 |
336 | #define CT2_PMM_1T_CONTROL_REG_P1 0x00023c1c | 336 | #define CT2_PMM_1T_CONTROL_REG_P1 0x00023c1c |
337 | #define CT2_WGN_STATUS 0x00014990 | 337 | #define CT2_WGN_STATUS 0x00014990 |
338 | #define __A2T_AHB_LOAD 0x00000800 | ||
338 | #define __WGN_READY 0x00000400 | 339 | #define __WGN_READY 0x00000400 |
339 | #define __GLBL_PF_VF_CFG_RDY 0x00000200 | 340 | #define __GLBL_PF_VF_CFG_RDY 0x00000200 |
341 | #define CT2_NFC_CSR_CLR_REG 0x00027420 | ||
340 | #define CT2_NFC_CSR_SET_REG 0x00027424 | 342 | #define CT2_NFC_CSR_SET_REG 0x00027424 |
341 | #define __HALT_NFC_CONTROLLER 0x00000002 | 343 | #define __HALT_NFC_CONTROLLER 0x00000002 |
342 | #define __NFC_CONTROLLER_HALTED 0x00001000 | 344 | #define __NFC_CONTROLLER_HALTED 0x00001000 |
345 | #define CT2_RSC_GPR15_REG 0x0002765c | ||
346 | #define CT2_CSI_FW_CTL_REG 0x00027080 | ||
347 | #define CT2_CSI_FW_CTL_SET_REG 0x00027088 | ||
348 | #define __RESET_AND_START_SCLK_LCLK_PLLS 0x00010000 | ||
343 | 349 | ||
344 | #define CT2_CSI_MAC0_CONTROL_REG 0x000270d0 | 350 | #define CT2_CSI_MAC0_CONTROL_REG 0x000270d0 |
345 | #define __CSI_MAC_RESET 0x00000010 | 351 | #define __CSI_MAC_RESET 0x00000010 |