diff options
author | Krishna Gudipati <kgudipat@brocade.com> | 2012-09-21 20:24:52 -0400 |
---|---|---|
committer | James Bottomley <JBottomley@Parallels.com> | 2012-10-07 06:12:12 -0400 |
commit | 227fab90bff260f453d9da853b09679581bafd55 (patch) | |
tree | fcb8e46a2c1e03a1821a7c747ffdba3ad6db5a48 | |
parent | 7ac83b1fd027a07b159940ccc8b5d57aaad7cc5f (diff) |
[SCSI] bfa: Flash Controller PLL initialization fixes
- Made changes to check the flash controller status before IOC initialization.
- Made changes to poll on the FLASH_STS_REG bit to check if the flash controller
initialization is completed during the PLL init.
Signed-off-by: Vijaya Mohan Guvva <vmohan@brocade.com>
Signed-off-by: Krishna Gudipati <kgudipat@brocade.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
-rw-r--r-- | drivers/scsi/bfa/bfa_ioc_ct.c | 211 | ||||
-rw-r--r-- | drivers/scsi/bfa/bfi_reg.h | 3 |
2 files changed, 131 insertions, 83 deletions
diff --git a/drivers/scsi/bfa/bfa_ioc_ct.c b/drivers/scsi/bfa/bfa_ioc_ct.c index 29efbb7484ae..de4e726a1263 100644 --- a/drivers/scsi/bfa/bfa_ioc_ct.c +++ b/drivers/scsi/bfa/bfa_ioc_ct.c | |||
@@ -744,25 +744,6 @@ bfa_ioc_ct2_mem_init(void __iomem *rb) | |||
744 | void | 744 | void |
745 | bfa_ioc_ct2_mac_reset(void __iomem *rb) | 745 | bfa_ioc_ct2_mac_reset(void __iomem *rb) |
746 | { | 746 | { |
747 | u32 r32; | ||
748 | |||
749 | bfa_ioc_ct2_sclk_init(rb); | ||
750 | bfa_ioc_ct2_lclk_init(rb); | ||
751 | |||
752 | /* | ||
753 | * release soft reset on s_clk & l_clk | ||
754 | */ | ||
755 | r32 = readl((rb + CT2_APP_PLL_SCLK_CTL_REG)); | ||
756 | writel(r32 & ~__APP_PLL_SCLK_LOGIC_SOFT_RESET, | ||
757 | (rb + CT2_APP_PLL_SCLK_CTL_REG)); | ||
758 | |||
759 | /* | ||
760 | * release soft reset on s_clk & l_clk | ||
761 | */ | ||
762 | r32 = readl((rb + CT2_APP_PLL_LCLK_CTL_REG)); | ||
763 | writel(r32 & ~__APP_PLL_LCLK_LOGIC_SOFT_RESET, | ||
764 | (rb + CT2_APP_PLL_LCLK_CTL_REG)); | ||
765 | |||
766 | /* put port0, port1 MAC & AHB in reset */ | 747 | /* put port0, port1 MAC & AHB in reset */ |
767 | writel((__CSI_MAC_RESET | __CSI_MAC_AHB_RESET), | 748 | writel((__CSI_MAC_RESET | __CSI_MAC_AHB_RESET), |
768 | rb + CT2_CSI_MAC_CONTROL_REG(0)); | 749 | rb + CT2_CSI_MAC_CONTROL_REG(0)); |
@@ -770,8 +751,21 @@ bfa_ioc_ct2_mac_reset(void __iomem *rb) | |||
770 | rb + CT2_CSI_MAC_CONTROL_REG(1)); | 751 | rb + CT2_CSI_MAC_CONTROL_REG(1)); |
771 | } | 752 | } |
772 | 753 | ||
754 | static void | ||
755 | bfa_ioc_ct2_enable_flash(void __iomem *rb) | ||
756 | { | ||
757 | u32 r32; | ||
758 | |||
759 | r32 = readl((rb + PSS_GPIO_OUT_REG)); | ||
760 | writel(r32 & ~1, (rb + PSS_GPIO_OUT_REG)); | ||
761 | r32 = readl((rb + PSS_GPIO_OE_REG)); | ||
762 | writel(r32 | 1, (rb + PSS_GPIO_OE_REG)); | ||
763 | } | ||
764 | |||
773 | #define CT2_NFC_MAX_DELAY 1000 | 765 | #define CT2_NFC_MAX_DELAY 1000 |
774 | #define CT2_NFC_VER_VALID 0x143 | 766 | #define CT2_NFC_PAUSE_MAX_DELAY 4000 |
767 | #define CT2_NFC_VER_VALID 0x147 | ||
768 | #define CT2_NFC_STATE_RUNNING 0x20000001 | ||
775 | #define BFA_IOC_PLL_POLL 1000000 | 769 | #define BFA_IOC_PLL_POLL 1000000 |
776 | 770 | ||
777 | static bfa_boolean_t | 771 | static bfa_boolean_t |
@@ -787,6 +781,20 @@ bfa_ioc_ct2_nfc_halted(void __iomem *rb) | |||
787 | } | 781 | } |
788 | 782 | ||
789 | static void | 783 | static void |
784 | bfa_ioc_ct2_nfc_halt(void __iomem *rb) | ||
785 | { | ||
786 | int i; | ||
787 | |||
788 | writel(__HALT_NFC_CONTROLLER, rb + CT2_NFC_CSR_SET_REG); | ||
789 | for (i = 0; i < CT2_NFC_MAX_DELAY; i++) { | ||
790 | if (bfa_ioc_ct2_nfc_halted(rb)) | ||
791 | break; | ||
792 | udelay(1000); | ||
793 | } | ||
794 | WARN_ON(!bfa_ioc_ct2_nfc_halted(rb)); | ||
795 | } | ||
796 | |||
797 | static void | ||
790 | bfa_ioc_ct2_nfc_resume(void __iomem *rb) | 798 | bfa_ioc_ct2_nfc_resume(void __iomem *rb) |
791 | { | 799 | { |
792 | u32 r32; | 800 | u32 r32; |
@@ -802,105 +810,142 @@ bfa_ioc_ct2_nfc_resume(void __iomem *rb) | |||
802 | WARN_ON(1); | 810 | WARN_ON(1); |
803 | } | 811 | } |
804 | 812 | ||
805 | bfa_status_t | 813 | static void |
806 | bfa_ioc_ct2_pll_init(void __iomem *rb, enum bfi_asic_mode mode) | 814 | bfa_ioc_ct2_clk_reset(void __iomem *rb) |
807 | { | 815 | { |
808 | u32 wgn, r32, nfc_ver, i; | 816 | u32 r32; |
809 | 817 | ||
810 | wgn = readl(rb + CT2_WGN_STATUS); | 818 | bfa_ioc_ct2_sclk_init(rb); |
811 | nfc_ver = readl(rb + CT2_RSC_GPR15_REG); | 819 | bfa_ioc_ct2_lclk_init(rb); |
812 | 820 | ||
813 | if ((wgn == (__A2T_AHB_LOAD | __WGN_READY)) && | 821 | /* |
814 | (nfc_ver >= CT2_NFC_VER_VALID)) { | 822 | * release soft reset on s_clk & l_clk |
815 | if (bfa_ioc_ct2_nfc_halted(rb)) | 823 | */ |
816 | bfa_ioc_ct2_nfc_resume(rb); | 824 | r32 = readl((rb + CT2_APP_PLL_SCLK_CTL_REG)); |
825 | writel(r32 & ~__APP_PLL_SCLK_LOGIC_SOFT_RESET, | ||
826 | (rb + CT2_APP_PLL_SCLK_CTL_REG)); | ||
817 | 827 | ||
818 | writel(__RESET_AND_START_SCLK_LCLK_PLLS, | 828 | r32 = readl((rb + CT2_APP_PLL_LCLK_CTL_REG)); |
819 | rb + CT2_CSI_FW_CTL_SET_REG); | 829 | writel(r32 & ~__APP_PLL_LCLK_LOGIC_SOFT_RESET, |
830 | (rb + CT2_APP_PLL_LCLK_CTL_REG)); | ||
820 | 831 | ||
821 | for (i = 0; i < BFA_IOC_PLL_POLL; i++) { | 832 | } |
822 | r32 = readl(rb + CT2_APP_PLL_LCLK_CTL_REG); | ||
823 | if (r32 & __RESET_AND_START_SCLK_LCLK_PLLS) | ||
824 | break; | ||
825 | } | ||
826 | 833 | ||
827 | WARN_ON(!(r32 & __RESET_AND_START_SCLK_LCLK_PLLS)); | 834 | static void |
835 | bfa_ioc_ct2_nfc_clk_reset(void __iomem *rb) | ||
836 | { | ||
837 | u32 r32, i; | ||
828 | 838 | ||
829 | for (i = 0; i < BFA_IOC_PLL_POLL; i++) { | 839 | r32 = readl((rb + PSS_CTL_REG)); |
830 | r32 = readl(rb + CT2_APP_PLL_LCLK_CTL_REG); | 840 | r32 |= (__PSS_LPU0_RESET | __PSS_LPU1_RESET); |
831 | if (!(r32 & __RESET_AND_START_SCLK_LCLK_PLLS)) | 841 | writel(r32, (rb + PSS_CTL_REG)); |
832 | break; | 842 | |
833 | } | 843 | writel(__RESET_AND_START_SCLK_LCLK_PLLS, rb + CT2_CSI_FW_CTL_SET_REG); |
844 | |||
845 | for (i = 0; i < BFA_IOC_PLL_POLL; i++) { | ||
846 | r32 = readl(rb + CT2_NFC_FLASH_STS_REG); | ||
847 | |||
848 | if ((r32 & __FLASH_PLL_INIT_AND_RESET_IN_PROGRESS)) | ||
849 | break; | ||
850 | } | ||
851 | WARN_ON(!(r32 & __FLASH_PLL_INIT_AND_RESET_IN_PROGRESS)); | ||
852 | |||
853 | for (i = 0; i < BFA_IOC_PLL_POLL; i++) { | ||
854 | r32 = readl(rb + CT2_NFC_FLASH_STS_REG); | ||
855 | |||
856 | if (!(r32 & __FLASH_PLL_INIT_AND_RESET_IN_PROGRESS)) | ||
857 | break; | ||
858 | } | ||
859 | WARN_ON((r32 & __FLASH_PLL_INIT_AND_RESET_IN_PROGRESS)); | ||
860 | |||
861 | r32 = readl(rb + CT2_CSI_FW_CTL_REG); | ||
862 | WARN_ON((r32 & __RESET_AND_START_SCLK_LCLK_PLLS)); | ||
863 | } | ||
864 | |||
865 | static void | ||
866 | bfa_ioc_ct2_wait_till_nfc_running(void __iomem *rb) | ||
867 | { | ||
868 | u32 r32; | ||
869 | int i; | ||
834 | 870 | ||
835 | WARN_ON(r32 & __RESET_AND_START_SCLK_LCLK_PLLS); | 871 | if (bfa_ioc_ct2_nfc_halted(rb)) |
872 | bfa_ioc_ct2_nfc_resume(rb); | ||
873 | for (i = 0; i < CT2_NFC_PAUSE_MAX_DELAY; i++) { | ||
874 | r32 = readl(rb + CT2_NFC_STS_REG); | ||
875 | if (r32 == CT2_NFC_STATE_RUNNING) | ||
876 | return; | ||
836 | udelay(1000); | 877 | udelay(1000); |
878 | } | ||
837 | 879 | ||
838 | r32 = readl(rb + CT2_CSI_FW_CTL_REG); | 880 | r32 = readl(rb + CT2_NFC_STS_REG); |
839 | WARN_ON(r32 & __RESET_AND_START_SCLK_LCLK_PLLS); | 881 | WARN_ON(!(r32 == CT2_NFC_STATE_RUNNING)); |
840 | } else { | 882 | } |
841 | writel(__HALT_NFC_CONTROLLER, rb + CT2_NFC_CSR_SET_REG); | ||
842 | for (i = 0; i < CT2_NFC_MAX_DELAY; i++) { | ||
843 | r32 = readl(rb + CT2_NFC_CSR_SET_REG); | ||
844 | if (r32 & __NFC_CONTROLLER_HALTED) | ||
845 | break; | ||
846 | udelay(1000); | ||
847 | } | ||
848 | 883 | ||
849 | bfa_ioc_ct2_mac_reset(rb); | 884 | bfa_status_t |
850 | bfa_ioc_ct2_sclk_init(rb); | 885 | bfa_ioc_ct2_pll_init(void __iomem *rb, enum bfi_asic_mode mode) |
851 | bfa_ioc_ct2_lclk_init(rb); | 886 | { |
887 | u32 wgn, r32, nfc_ver; | ||
852 | 888 | ||
853 | /* | 889 | wgn = readl(rb + CT2_WGN_STATUS); |
854 | * release soft reset on s_clk & l_clk | ||
855 | */ | ||
856 | r32 = readl(rb + CT2_APP_PLL_SCLK_CTL_REG); | ||
857 | writel(r32 & ~__APP_PLL_SCLK_LOGIC_SOFT_RESET, | ||
858 | (rb + CT2_APP_PLL_SCLK_CTL_REG)); | ||
859 | 890 | ||
891 | if (wgn == (__WGN_READY | __GLBL_PF_VF_CFG_RDY)) { | ||
860 | /* | 892 | /* |
861 | * release soft reset on s_clk & l_clk | 893 | * If flash is corrupted, enable flash explicitly |
862 | */ | 894 | */ |
863 | r32 = readl(rb + CT2_APP_PLL_LCLK_CTL_REG); | 895 | bfa_ioc_ct2_clk_reset(rb); |
864 | writel(r32 & ~__APP_PLL_LCLK_LOGIC_SOFT_RESET, | 896 | bfa_ioc_ct2_enable_flash(rb); |
865 | (rb + CT2_APP_PLL_LCLK_CTL_REG)); | ||
866 | } | ||
867 | 897 | ||
868 | /* | 898 | bfa_ioc_ct2_mac_reset(rb); |
869 | * Announce flash device presence, if flash was corrupted. | 899 | |
870 | */ | 900 | bfa_ioc_ct2_clk_reset(rb); |
871 | if (wgn == (__WGN_READY | __GLBL_PF_VF_CFG_RDY)) { | 901 | bfa_ioc_ct2_enable_flash(rb); |
872 | r32 = readl(rb + PSS_GPIO_OUT_REG); | 902 | |
873 | writel(r32 & ~1, (rb + PSS_GPIO_OUT_REG)); | 903 | } else { |
874 | r32 = readl(rb + PSS_GPIO_OE_REG); | 904 | nfc_ver = readl(rb + CT2_RSC_GPR15_REG); |
875 | writel(r32 | 1, (rb + PSS_GPIO_OE_REG)); | 905 | |
906 | if ((nfc_ver >= CT2_NFC_VER_VALID) && | ||
907 | (wgn == (__A2T_AHB_LOAD | __WGN_READY))) { | ||
908 | |||
909 | bfa_ioc_ct2_wait_till_nfc_running(rb); | ||
910 | |||
911 | bfa_ioc_ct2_nfc_clk_reset(rb); | ||
912 | } else { | ||
913 | bfa_ioc_ct2_nfc_halt(rb); | ||
914 | |||
915 | bfa_ioc_ct2_clk_reset(rb); | ||
916 | bfa_ioc_ct2_mac_reset(rb); | ||
917 | bfa_ioc_ct2_clk_reset(rb); | ||
918 | |||
919 | } | ||
876 | } | 920 | } |
877 | 921 | ||
878 | /* | 922 | /* |
879 | * Mask the interrupts and clear any | 923 | * Mask the interrupts and clear any |
880 | * pending interrupts. | 924 | * pending interrupts left by BIOS/EFI |
881 | */ | 925 | */ |
926 | |||
882 | writel(1, (rb + CT2_LPU0_HOSTFN_MBOX0_MSK)); | 927 | writel(1, (rb + CT2_LPU0_HOSTFN_MBOX0_MSK)); |
883 | writel(1, (rb + CT2_LPU1_HOSTFN_MBOX0_MSK)); | 928 | writel(1, (rb + CT2_LPU1_HOSTFN_MBOX0_MSK)); |
884 | 929 | ||
885 | /* For first time initialization, no need to clear interrupts */ | 930 | /* For first time initialization, no need to clear interrupts */ |
886 | r32 = readl(rb + HOST_SEM5_REG); | 931 | r32 = readl(rb + HOST_SEM5_REG); |
887 | if (r32 & 0x1) { | 932 | if (r32 & 0x1) { |
888 | r32 = readl(rb + CT2_LPU0_HOSTFN_CMD_STAT); | 933 | r32 = readl((rb + CT2_LPU0_HOSTFN_CMD_STAT)); |
889 | if (r32 == 1) { | 934 | if (r32 == 1) { |
890 | writel(1, rb + CT2_LPU0_HOSTFN_CMD_STAT); | 935 | writel(1, (rb + CT2_LPU0_HOSTFN_CMD_STAT)); |
891 | readl((rb + CT2_LPU0_HOSTFN_CMD_STAT)); | 936 | readl((rb + CT2_LPU0_HOSTFN_CMD_STAT)); |
892 | } | 937 | } |
893 | r32 = readl(rb + CT2_LPU1_HOSTFN_CMD_STAT); | 938 | r32 = readl((rb + CT2_LPU1_HOSTFN_CMD_STAT)); |
894 | if (r32 == 1) { | 939 | if (r32 == 1) { |
895 | writel(1, rb + CT2_LPU1_HOSTFN_CMD_STAT); | 940 | writel(1, (rb + CT2_LPU1_HOSTFN_CMD_STAT)); |
896 | readl(rb + CT2_LPU1_HOSTFN_CMD_STAT); | 941 | readl((rb + CT2_LPU1_HOSTFN_CMD_STAT)); |
897 | } | 942 | } |
898 | } | 943 | } |
899 | 944 | ||
900 | bfa_ioc_ct2_mem_init(rb); | 945 | bfa_ioc_ct2_mem_init(rb); |
901 | 946 | ||
902 | writel(BFI_IOC_UNINIT, rb + CT2_BFA_IOC0_STATE_REG); | 947 | writel(BFI_IOC_UNINIT, (rb + CT2_BFA_IOC0_STATE_REG)); |
903 | writel(BFI_IOC_UNINIT, rb + CT2_BFA_IOC1_STATE_REG); | 948 | writel(BFI_IOC_UNINIT, (rb + CT2_BFA_IOC1_STATE_REG)); |
904 | 949 | ||
905 | return BFA_STATUS_OK; | 950 | return BFA_STATUS_OK; |
906 | } | 951 | } |
diff --git a/drivers/scsi/bfa/bfi_reg.h b/drivers/scsi/bfa/bfi_reg.h index ed5f159e1867..99133bcf53f9 100644 --- a/drivers/scsi/bfa/bfi_reg.h +++ b/drivers/scsi/bfa/bfi_reg.h | |||
@@ -338,6 +338,7 @@ enum { | |||
338 | #define __A2T_AHB_LOAD 0x00000800 | 338 | #define __A2T_AHB_LOAD 0x00000800 |
339 | #define __WGN_READY 0x00000400 | 339 | #define __WGN_READY 0x00000400 |
340 | #define __GLBL_PF_VF_CFG_RDY 0x00000200 | 340 | #define __GLBL_PF_VF_CFG_RDY 0x00000200 |
341 | #define CT2_NFC_STS_REG 0x00027410 | ||
341 | #define CT2_NFC_CSR_CLR_REG 0x00027420 | 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 |
@@ -355,6 +356,8 @@ enum { | |||
355 | (CT2_CSI_MAC0_CONTROL_REG + \ | 356 | (CT2_CSI_MAC0_CONTROL_REG + \ |
356 | (__n) * (CT2_CSI_MAC1_CONTROL_REG - CT2_CSI_MAC0_CONTROL_REG)) | 357 | (__n) * (CT2_CSI_MAC1_CONTROL_REG - CT2_CSI_MAC0_CONTROL_REG)) |
357 | 358 | ||
359 | #define CT2_NFC_FLASH_STS_REG 0x00014834 | ||
360 | #define __FLASH_PLL_INIT_AND_RESET_IN_PROGRESS 0x00000020 | ||
358 | /* | 361 | /* |
359 | * Name semaphore registers based on usage | 362 | * Name semaphore registers based on usage |
360 | */ | 363 | */ |