diff options
Diffstat (limited to 'drivers/scsi/bfa/bfa_ioc_ct.c')
-rw-r--r-- | drivers/scsi/bfa/bfa_ioc_ct.c | 151 |
1 files changed, 106 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 | } |