diff options
Diffstat (limited to 'drivers/net/wireless/ti/wl12xx/main.c')
-rw-r--r-- | drivers/net/wireless/ti/wl12xx/main.c | 350 |
1 files changed, 257 insertions, 93 deletions
diff --git a/drivers/net/wireless/ti/wl12xx/main.c b/drivers/net/wireless/ti/wl12xx/main.c index 85d1600ee340..47ba2e0017f4 100644 --- a/drivers/net/wireless/ti/wl12xx/main.c +++ b/drivers/net/wireless/ti/wl12xx/main.c | |||
@@ -246,6 +246,7 @@ static struct wlcore_conf wl12xx_conf = { | |||
246 | .forced_ps = false, | 246 | .forced_ps = false, |
247 | .keep_alive_interval = 55000, | 247 | .keep_alive_interval = 55000, |
248 | .max_listen_interval = 20, | 248 | .max_listen_interval = 20, |
249 | .sta_sleep_auth = WL1271_PSM_ILLEGAL, | ||
249 | }, | 250 | }, |
250 | .itrim = { | 251 | .itrim = { |
251 | .enable = false, | 252 | .enable = false, |
@@ -597,8 +598,10 @@ static const int wl12xx_rtable[REG_TABLE_LEN] = { | |||
597 | #define WL128X_FW_NAME_SINGLE "ti-connectivity/wl128x-fw-4-sr.bin" | 598 | #define WL128X_FW_NAME_SINGLE "ti-connectivity/wl128x-fw-4-sr.bin" |
598 | #define WL128X_PLT_FW_NAME "ti-connectivity/wl128x-fw-4-plt.bin" | 599 | #define WL128X_PLT_FW_NAME "ti-connectivity/wl128x-fw-4-plt.bin" |
599 | 600 | ||
600 | static void wl127x_prepare_read(struct wl1271 *wl, u32 rx_desc, u32 len) | 601 | static int wl127x_prepare_read(struct wl1271 *wl, u32 rx_desc, u32 len) |
601 | { | 602 | { |
603 | int ret; | ||
604 | |||
602 | if (wl->chip.id != CHIP_ID_1283_PG20) { | 605 | if (wl->chip.id != CHIP_ID_1283_PG20) { |
603 | struct wl1271_acx_mem_map *wl_mem_map = wl->target_mem_map; | 606 | struct wl1271_acx_mem_map *wl_mem_map = wl->target_mem_map; |
604 | struct wl127x_rx_mem_pool_addr rx_mem_addr; | 607 | struct wl127x_rx_mem_pool_addr rx_mem_addr; |
@@ -615,9 +618,13 @@ static void wl127x_prepare_read(struct wl1271 *wl, u32 rx_desc, u32 len) | |||
615 | 618 | ||
616 | rx_mem_addr.addr_extra = rx_mem_addr.addr + 4; | 619 | rx_mem_addr.addr_extra = rx_mem_addr.addr + 4; |
617 | 620 | ||
618 | wl1271_write(wl, WL1271_SLV_REG_DATA, | 621 | ret = wlcore_write(wl, WL1271_SLV_REG_DATA, &rx_mem_addr, |
619 | &rx_mem_addr, sizeof(rx_mem_addr), false); | 622 | sizeof(rx_mem_addr), false); |
623 | if (ret < 0) | ||
624 | return ret; | ||
620 | } | 625 | } |
626 | |||
627 | return 0; | ||
621 | } | 628 | } |
622 | 629 | ||
623 | static int wl12xx_identify_chip(struct wl1271 *wl) | 630 | static int wl12xx_identify_chip(struct wl1271 *wl) |
@@ -681,64 +688,95 @@ out: | |||
681 | return ret; | 688 | return ret; |
682 | } | 689 | } |
683 | 690 | ||
684 | static void wl12xx_top_reg_write(struct wl1271 *wl, int addr, u16 val) | 691 | static int __must_check wl12xx_top_reg_write(struct wl1271 *wl, int addr, |
692 | u16 val) | ||
685 | { | 693 | { |
694 | int ret; | ||
695 | |||
686 | /* write address >> 1 + 0x30000 to OCP_POR_CTR */ | 696 | /* write address >> 1 + 0x30000 to OCP_POR_CTR */ |
687 | addr = (addr >> 1) + 0x30000; | 697 | addr = (addr >> 1) + 0x30000; |
688 | wl1271_write32(wl, WL12XX_OCP_POR_CTR, addr); | 698 | ret = wlcore_write32(wl, WL12XX_OCP_POR_CTR, addr); |
699 | if (ret < 0) | ||
700 | goto out; | ||
689 | 701 | ||
690 | /* write value to OCP_POR_WDATA */ | 702 | /* write value to OCP_POR_WDATA */ |
691 | wl1271_write32(wl, WL12XX_OCP_DATA_WRITE, val); | 703 | ret = wlcore_write32(wl, WL12XX_OCP_DATA_WRITE, val); |
704 | if (ret < 0) | ||
705 | goto out; | ||
692 | 706 | ||
693 | /* write 1 to OCP_CMD */ | 707 | /* write 1 to OCP_CMD */ |
694 | wl1271_write32(wl, WL12XX_OCP_CMD, OCP_CMD_WRITE); | 708 | ret = wlcore_write32(wl, WL12XX_OCP_CMD, OCP_CMD_WRITE); |
709 | if (ret < 0) | ||
710 | goto out; | ||
711 | |||
712 | out: | ||
713 | return ret; | ||
695 | } | 714 | } |
696 | 715 | ||
697 | static u16 wl12xx_top_reg_read(struct wl1271 *wl, int addr) | 716 | static int __must_check wl12xx_top_reg_read(struct wl1271 *wl, int addr, |
717 | u16 *out) | ||
698 | { | 718 | { |
699 | u32 val; | 719 | u32 val; |
700 | int timeout = OCP_CMD_LOOP; | 720 | int timeout = OCP_CMD_LOOP; |
721 | int ret; | ||
701 | 722 | ||
702 | /* write address >> 1 + 0x30000 to OCP_POR_CTR */ | 723 | /* write address >> 1 + 0x30000 to OCP_POR_CTR */ |
703 | addr = (addr >> 1) + 0x30000; | 724 | addr = (addr >> 1) + 0x30000; |
704 | wl1271_write32(wl, WL12XX_OCP_POR_CTR, addr); | 725 | ret = wlcore_write32(wl, WL12XX_OCP_POR_CTR, addr); |
726 | if (ret < 0) | ||
727 | return ret; | ||
705 | 728 | ||
706 | /* write 2 to OCP_CMD */ | 729 | /* write 2 to OCP_CMD */ |
707 | wl1271_write32(wl, WL12XX_OCP_CMD, OCP_CMD_READ); | 730 | ret = wlcore_write32(wl, WL12XX_OCP_CMD, OCP_CMD_READ); |
731 | if (ret < 0) | ||
732 | return ret; | ||
708 | 733 | ||
709 | /* poll for data ready */ | 734 | /* poll for data ready */ |
710 | do { | 735 | do { |
711 | val = wl1271_read32(wl, WL12XX_OCP_DATA_READ); | 736 | ret = wlcore_read32(wl, WL12XX_OCP_DATA_READ, &val); |
737 | if (ret < 0) | ||
738 | return ret; | ||
712 | } while (!(val & OCP_READY_MASK) && --timeout); | 739 | } while (!(val & OCP_READY_MASK) && --timeout); |
713 | 740 | ||
714 | if (!timeout) { | 741 | if (!timeout) { |
715 | wl1271_warning("Top register access timed out."); | 742 | wl1271_warning("Top register access timed out."); |
716 | return 0xffff; | 743 | return -ETIMEDOUT; |
717 | } | 744 | } |
718 | 745 | ||
719 | /* check data status and return if OK */ | 746 | /* check data status and return if OK */ |
720 | if ((val & OCP_STATUS_MASK) == OCP_STATUS_OK) | 747 | if ((val & OCP_STATUS_MASK) != OCP_STATUS_OK) { |
721 | return val & 0xffff; | ||
722 | else { | ||
723 | wl1271_warning("Top register access returned error."); | 748 | wl1271_warning("Top register access returned error."); |
724 | return 0xffff; | 749 | return -EIO; |
725 | } | 750 | } |
751 | |||
752 | if (out) | ||
753 | *out = val & 0xffff; | ||
754 | |||
755 | return 0; | ||
726 | } | 756 | } |
727 | 757 | ||
728 | static int wl128x_switch_tcxo_to_fref(struct wl1271 *wl) | 758 | static int wl128x_switch_tcxo_to_fref(struct wl1271 *wl) |
729 | { | 759 | { |
730 | u16 spare_reg; | 760 | u16 spare_reg; |
761 | int ret; | ||
731 | 762 | ||
732 | /* Mask bits [2] & [8:4] in the sys_clk_cfg register */ | 763 | /* Mask bits [2] & [8:4] in the sys_clk_cfg register */ |
733 | spare_reg = wl12xx_top_reg_read(wl, WL_SPARE_REG); | 764 | ret = wl12xx_top_reg_read(wl, WL_SPARE_REG, &spare_reg); |
765 | if (ret < 0) | ||
766 | return ret; | ||
767 | |||
734 | if (spare_reg == 0xFFFF) | 768 | if (spare_reg == 0xFFFF) |
735 | return -EFAULT; | 769 | return -EFAULT; |
736 | spare_reg |= (BIT(3) | BIT(5) | BIT(6)); | 770 | spare_reg |= (BIT(3) | BIT(5) | BIT(6)); |
737 | wl12xx_top_reg_write(wl, WL_SPARE_REG, spare_reg); | 771 | ret = wl12xx_top_reg_write(wl, WL_SPARE_REG, spare_reg); |
772 | if (ret < 0) | ||
773 | return ret; | ||
738 | 774 | ||
739 | /* Enable FREF_CLK_REQ & mux MCS and coex PLLs to FREF */ | 775 | /* Enable FREF_CLK_REQ & mux MCS and coex PLLs to FREF */ |
740 | wl12xx_top_reg_write(wl, SYS_CLK_CFG_REG, | 776 | ret = wl12xx_top_reg_write(wl, SYS_CLK_CFG_REG, |
741 | WL_CLK_REQ_TYPE_PG2 | MCS_PLL_CLK_SEL_FREF); | 777 | WL_CLK_REQ_TYPE_PG2 | MCS_PLL_CLK_SEL_FREF); |
778 | if (ret < 0) | ||
779 | return ret; | ||
742 | 780 | ||
743 | /* Delay execution for 15msec, to let the HW settle */ | 781 | /* Delay execution for 15msec, to let the HW settle */ |
744 | mdelay(15); | 782 | mdelay(15); |
@@ -749,8 +787,12 @@ static int wl128x_switch_tcxo_to_fref(struct wl1271 *wl) | |||
749 | static bool wl128x_is_tcxo_valid(struct wl1271 *wl) | 787 | static bool wl128x_is_tcxo_valid(struct wl1271 *wl) |
750 | { | 788 | { |
751 | u16 tcxo_detection; | 789 | u16 tcxo_detection; |
790 | int ret; | ||
791 | |||
792 | ret = wl12xx_top_reg_read(wl, TCXO_CLK_DETECT_REG, &tcxo_detection); | ||
793 | if (ret < 0) | ||
794 | return false; | ||
752 | 795 | ||
753 | tcxo_detection = wl12xx_top_reg_read(wl, TCXO_CLK_DETECT_REG); | ||
754 | if (tcxo_detection & TCXO_DET_FAILED) | 796 | if (tcxo_detection & TCXO_DET_FAILED) |
755 | return false; | 797 | return false; |
756 | 798 | ||
@@ -760,8 +802,12 @@ static bool wl128x_is_tcxo_valid(struct wl1271 *wl) | |||
760 | static bool wl128x_is_fref_valid(struct wl1271 *wl) | 802 | static bool wl128x_is_fref_valid(struct wl1271 *wl) |
761 | { | 803 | { |
762 | u16 fref_detection; | 804 | u16 fref_detection; |
805 | int ret; | ||
806 | |||
807 | ret = wl12xx_top_reg_read(wl, FREF_CLK_DETECT_REG, &fref_detection); | ||
808 | if (ret < 0) | ||
809 | return false; | ||
763 | 810 | ||
764 | fref_detection = wl12xx_top_reg_read(wl, FREF_CLK_DETECT_REG); | ||
765 | if (fref_detection & FREF_CLK_DETECT_FAIL) | 811 | if (fref_detection & FREF_CLK_DETECT_FAIL) |
766 | return false; | 812 | return false; |
767 | 813 | ||
@@ -770,11 +816,21 @@ static bool wl128x_is_fref_valid(struct wl1271 *wl) | |||
770 | 816 | ||
771 | static int wl128x_manually_configure_mcs_pll(struct wl1271 *wl) | 817 | static int wl128x_manually_configure_mcs_pll(struct wl1271 *wl) |
772 | { | 818 | { |
773 | wl12xx_top_reg_write(wl, MCS_PLL_M_REG, MCS_PLL_M_REG_VAL); | 819 | int ret; |
774 | wl12xx_top_reg_write(wl, MCS_PLL_N_REG, MCS_PLL_N_REG_VAL); | ||
775 | wl12xx_top_reg_write(wl, MCS_PLL_CONFIG_REG, MCS_PLL_CONFIG_REG_VAL); | ||
776 | 820 | ||
777 | return 0; | 821 | ret = wl12xx_top_reg_write(wl, MCS_PLL_M_REG, MCS_PLL_M_REG_VAL); |
822 | if (ret < 0) | ||
823 | goto out; | ||
824 | |||
825 | ret = wl12xx_top_reg_write(wl, MCS_PLL_N_REG, MCS_PLL_N_REG_VAL); | ||
826 | if (ret < 0) | ||
827 | goto out; | ||
828 | |||
829 | ret = wl12xx_top_reg_write(wl, MCS_PLL_CONFIG_REG, | ||
830 | MCS_PLL_CONFIG_REG_VAL); | ||
831 | |||
832 | out: | ||
833 | return ret; | ||
778 | } | 834 | } |
779 | 835 | ||
780 | static int wl128x_configure_mcs_pll(struct wl1271 *wl, int clk) | 836 | static int wl128x_configure_mcs_pll(struct wl1271 *wl, int clk) |
@@ -783,13 +839,19 @@ static int wl128x_configure_mcs_pll(struct wl1271 *wl, int clk) | |||
783 | u16 pll_config; | 839 | u16 pll_config; |
784 | u8 input_freq; | 840 | u8 input_freq; |
785 | struct wl12xx_priv *priv = wl->priv; | 841 | struct wl12xx_priv *priv = wl->priv; |
842 | int ret; | ||
786 | 843 | ||
787 | /* Mask bits [3:1] in the sys_clk_cfg register */ | 844 | /* Mask bits [3:1] in the sys_clk_cfg register */ |
788 | spare_reg = wl12xx_top_reg_read(wl, WL_SPARE_REG); | 845 | ret = wl12xx_top_reg_read(wl, WL_SPARE_REG, &spare_reg); |
846 | if (ret < 0) | ||
847 | return ret; | ||
848 | |||
789 | if (spare_reg == 0xFFFF) | 849 | if (spare_reg == 0xFFFF) |
790 | return -EFAULT; | 850 | return -EFAULT; |
791 | spare_reg |= BIT(2); | 851 | spare_reg |= BIT(2); |
792 | wl12xx_top_reg_write(wl, WL_SPARE_REG, spare_reg); | 852 | ret = wl12xx_top_reg_write(wl, WL_SPARE_REG, spare_reg); |
853 | if (ret < 0) | ||
854 | return ret; | ||
793 | 855 | ||
794 | /* Handle special cases of the TCXO clock */ | 856 | /* Handle special cases of the TCXO clock */ |
795 | if (priv->tcxo_clock == WL12XX_TCXOCLOCK_16_8 || | 857 | if (priv->tcxo_clock == WL12XX_TCXOCLOCK_16_8 || |
@@ -799,14 +861,17 @@ static int wl128x_configure_mcs_pll(struct wl1271 *wl, int clk) | |||
799 | /* Set the input frequency according to the selected clock source */ | 861 | /* Set the input frequency according to the selected clock source */ |
800 | input_freq = (clk & 1) + 1; | 862 | input_freq = (clk & 1) + 1; |
801 | 863 | ||
802 | pll_config = wl12xx_top_reg_read(wl, MCS_PLL_CONFIG_REG); | 864 | ret = wl12xx_top_reg_read(wl, MCS_PLL_CONFIG_REG, &pll_config); |
865 | if (ret < 0) | ||
866 | return ret; | ||
867 | |||
803 | if (pll_config == 0xFFFF) | 868 | if (pll_config == 0xFFFF) |
804 | return -EFAULT; | 869 | return -EFAULT; |
805 | pll_config |= (input_freq << MCS_SEL_IN_FREQ_SHIFT); | 870 | pll_config |= (input_freq << MCS_SEL_IN_FREQ_SHIFT); |
806 | pll_config |= MCS_PLL_ENABLE_HP; | 871 | pll_config |= MCS_PLL_ENABLE_HP; |
807 | wl12xx_top_reg_write(wl, MCS_PLL_CONFIG_REG, pll_config); | 872 | ret = wl12xx_top_reg_write(wl, MCS_PLL_CONFIG_REG, pll_config); |
808 | 873 | ||
809 | return 0; | 874 | return ret; |
810 | } | 875 | } |
811 | 876 | ||
812 | /* | 877 | /* |
@@ -820,6 +885,7 @@ static int wl128x_boot_clk(struct wl1271 *wl, int *selected_clock) | |||
820 | { | 885 | { |
821 | struct wl12xx_priv *priv = wl->priv; | 886 | struct wl12xx_priv *priv = wl->priv; |
822 | u16 sys_clk_cfg; | 887 | u16 sys_clk_cfg; |
888 | int ret; | ||
823 | 889 | ||
824 | /* For XTAL-only modes, FREF will be used after switching from TCXO */ | 890 | /* For XTAL-only modes, FREF will be used after switching from TCXO */ |
825 | if (priv->ref_clock == WL12XX_REFCLOCK_26_XTAL || | 891 | if (priv->ref_clock == WL12XX_REFCLOCK_26_XTAL || |
@@ -830,7 +896,10 @@ static int wl128x_boot_clk(struct wl1271 *wl, int *selected_clock) | |||
830 | } | 896 | } |
831 | 897 | ||
832 | /* Query the HW, to determine which clock source we should use */ | 898 | /* Query the HW, to determine which clock source we should use */ |
833 | sys_clk_cfg = wl12xx_top_reg_read(wl, SYS_CLK_CFG_REG); | 899 | ret = wl12xx_top_reg_read(wl, SYS_CLK_CFG_REG, &sys_clk_cfg); |
900 | if (ret < 0) | ||
901 | return ret; | ||
902 | |||
834 | if (sys_clk_cfg == 0xFFFF) | 903 | if (sys_clk_cfg == 0xFFFF) |
835 | return -EINVAL; | 904 | return -EINVAL; |
836 | if (sys_clk_cfg & PRCM_CM_EN_MUX_WLAN_FREF) | 905 | if (sys_clk_cfg & PRCM_CM_EN_MUX_WLAN_FREF) |
@@ -865,6 +934,7 @@ static int wl127x_boot_clk(struct wl1271 *wl) | |||
865 | struct wl12xx_priv *priv = wl->priv; | 934 | struct wl12xx_priv *priv = wl->priv; |
866 | u32 pause; | 935 | u32 pause; |
867 | u32 clk; | 936 | u32 clk; |
937 | int ret; | ||
868 | 938 | ||
869 | if (WL127X_PG_GET_MAJOR(wl->hw_pg_ver) < 3) | 939 | if (WL127X_PG_GET_MAJOR(wl->hw_pg_ver) < 3) |
870 | wl->quirks |= WLCORE_QUIRK_END_OF_TRANSACTION; | 940 | wl->quirks |= WLCORE_QUIRK_END_OF_TRANSACTION; |
@@ -885,48 +955,74 @@ static int wl127x_boot_clk(struct wl1271 *wl) | |||
885 | if (priv->ref_clock != CONF_REF_CLK_19_2_E) { | 955 | if (priv->ref_clock != CONF_REF_CLK_19_2_E) { |
886 | u16 val; | 956 | u16 val; |
887 | /* Set clock type (open drain) */ | 957 | /* Set clock type (open drain) */ |
888 | val = wl12xx_top_reg_read(wl, OCP_REG_CLK_TYPE); | 958 | ret = wl12xx_top_reg_read(wl, OCP_REG_CLK_TYPE, &val); |
959 | if (ret < 0) | ||
960 | goto out; | ||
961 | |||
889 | val &= FREF_CLK_TYPE_BITS; | 962 | val &= FREF_CLK_TYPE_BITS; |
890 | wl12xx_top_reg_write(wl, OCP_REG_CLK_TYPE, val); | 963 | ret = wl12xx_top_reg_write(wl, OCP_REG_CLK_TYPE, val); |
964 | if (ret < 0) | ||
965 | goto out; | ||
891 | 966 | ||
892 | /* Set clock pull mode (no pull) */ | 967 | /* Set clock pull mode (no pull) */ |
893 | val = wl12xx_top_reg_read(wl, OCP_REG_CLK_PULL); | 968 | ret = wl12xx_top_reg_read(wl, OCP_REG_CLK_PULL, &val); |
969 | if (ret < 0) | ||
970 | goto out; | ||
971 | |||
894 | val |= NO_PULL; | 972 | val |= NO_PULL; |
895 | wl12xx_top_reg_write(wl, OCP_REG_CLK_PULL, val); | 973 | ret = wl12xx_top_reg_write(wl, OCP_REG_CLK_PULL, val); |
974 | if (ret < 0) | ||
975 | goto out; | ||
896 | } else { | 976 | } else { |
897 | u16 val; | 977 | u16 val; |
898 | /* Set clock polarity */ | 978 | /* Set clock polarity */ |
899 | val = wl12xx_top_reg_read(wl, OCP_REG_CLK_POLARITY); | 979 | ret = wl12xx_top_reg_read(wl, OCP_REG_CLK_POLARITY, &val); |
980 | if (ret < 0) | ||
981 | goto out; | ||
982 | |||
900 | val &= FREF_CLK_POLARITY_BITS; | 983 | val &= FREF_CLK_POLARITY_BITS; |
901 | val |= CLK_REQ_OUTN_SEL; | 984 | val |= CLK_REQ_OUTN_SEL; |
902 | wl12xx_top_reg_write(wl, OCP_REG_CLK_POLARITY, val); | 985 | ret = wl12xx_top_reg_write(wl, OCP_REG_CLK_POLARITY, val); |
986 | if (ret < 0) | ||
987 | goto out; | ||
903 | } | 988 | } |
904 | 989 | ||
905 | wl1271_write32(wl, WL12XX_PLL_PARAMETERS, clk); | 990 | ret = wlcore_write32(wl, WL12XX_PLL_PARAMETERS, clk); |
991 | if (ret < 0) | ||
992 | goto out; | ||
906 | 993 | ||
907 | pause = wl1271_read32(wl, WL12XX_PLL_PARAMETERS); | 994 | ret = wlcore_read32(wl, WL12XX_PLL_PARAMETERS, &pause); |
995 | if (ret < 0) | ||
996 | goto out; | ||
908 | 997 | ||
909 | wl1271_debug(DEBUG_BOOT, "pause1 0x%x", pause); | 998 | wl1271_debug(DEBUG_BOOT, "pause1 0x%x", pause); |
910 | 999 | ||
911 | pause &= ~(WU_COUNTER_PAUSE_VAL); | 1000 | pause &= ~(WU_COUNTER_PAUSE_VAL); |
912 | pause |= WU_COUNTER_PAUSE_VAL; | 1001 | pause |= WU_COUNTER_PAUSE_VAL; |
913 | wl1271_write32(wl, WL12XX_WU_COUNTER_PAUSE, pause); | 1002 | ret = wlcore_write32(wl, WL12XX_WU_COUNTER_PAUSE, pause); |
914 | 1003 | ||
915 | return 0; | 1004 | out: |
1005 | return ret; | ||
916 | } | 1006 | } |
917 | 1007 | ||
918 | static int wl1271_boot_soft_reset(struct wl1271 *wl) | 1008 | static int wl1271_boot_soft_reset(struct wl1271 *wl) |
919 | { | 1009 | { |
920 | unsigned long timeout; | 1010 | unsigned long timeout; |
921 | u32 boot_data; | 1011 | u32 boot_data; |
1012 | int ret = 0; | ||
922 | 1013 | ||
923 | /* perform soft reset */ | 1014 | /* perform soft reset */ |
924 | wl1271_write32(wl, WL12XX_SLV_SOFT_RESET, ACX_SLV_SOFT_RESET_BIT); | 1015 | ret = wlcore_write32(wl, WL12XX_SLV_SOFT_RESET, ACX_SLV_SOFT_RESET_BIT); |
1016 | if (ret < 0) | ||
1017 | goto out; | ||
925 | 1018 | ||
926 | /* SOFT_RESET is self clearing */ | 1019 | /* SOFT_RESET is self clearing */ |
927 | timeout = jiffies + usecs_to_jiffies(SOFT_RESET_MAX_TIME); | 1020 | timeout = jiffies + usecs_to_jiffies(SOFT_RESET_MAX_TIME); |
928 | while (1) { | 1021 | while (1) { |
929 | boot_data = wl1271_read32(wl, WL12XX_SLV_SOFT_RESET); | 1022 | ret = wlcore_read32(wl, WL12XX_SLV_SOFT_RESET, &boot_data); |
1023 | if (ret < 0) | ||
1024 | goto out; | ||
1025 | |||
930 | wl1271_debug(DEBUG_BOOT, "soft reset bootdata 0x%x", boot_data); | 1026 | wl1271_debug(DEBUG_BOOT, "soft reset bootdata 0x%x", boot_data); |
931 | if ((boot_data & ACX_SLV_SOFT_RESET_BIT) == 0) | 1027 | if ((boot_data & ACX_SLV_SOFT_RESET_BIT) == 0) |
932 | break; | 1028 | break; |
@@ -942,12 +1038,15 @@ static int wl1271_boot_soft_reset(struct wl1271 *wl) | |||
942 | } | 1038 | } |
943 | 1039 | ||
944 | /* disable Rx/Tx */ | 1040 | /* disable Rx/Tx */ |
945 | wl1271_write32(wl, WL12XX_ENABLE, 0x0); | 1041 | ret = wlcore_write32(wl, WL12XX_ENABLE, 0x0); |
1042 | if (ret < 0) | ||
1043 | goto out; | ||
946 | 1044 | ||
947 | /* disable auto calibration on start*/ | 1045 | /* disable auto calibration on start*/ |
948 | wl1271_write32(wl, WL12XX_SPARE_A2, 0xffff); | 1046 | ret = wlcore_write32(wl, WL12XX_SPARE_A2, 0xffff); |
949 | 1047 | ||
950 | return 0; | 1048 | out: |
1049 | return ret; | ||
951 | } | 1050 | } |
952 | 1051 | ||
953 | static int wl12xx_pre_boot(struct wl1271 *wl) | 1052 | static int wl12xx_pre_boot(struct wl1271 *wl) |
@@ -968,16 +1067,23 @@ static int wl12xx_pre_boot(struct wl1271 *wl) | |||
968 | } | 1067 | } |
969 | 1068 | ||
970 | /* Continue the ELP wake up sequence */ | 1069 | /* Continue the ELP wake up sequence */ |
971 | wl1271_write32(wl, WL12XX_WELP_ARM_COMMAND, WELP_ARM_COMMAND_VAL); | 1070 | ret = wlcore_write32(wl, WL12XX_WELP_ARM_COMMAND, WELP_ARM_COMMAND_VAL); |
1071 | if (ret < 0) | ||
1072 | goto out; | ||
1073 | |||
972 | udelay(500); | 1074 | udelay(500); |
973 | 1075 | ||
974 | wlcore_set_partition(wl, &wl->ptable[PART_DRPW]); | 1076 | ret = wlcore_set_partition(wl, &wl->ptable[PART_DRPW]); |
1077 | if (ret < 0) | ||
1078 | goto out; | ||
975 | 1079 | ||
976 | /* Read-modify-write DRPW_SCRATCH_START register (see next state) | 1080 | /* Read-modify-write DRPW_SCRATCH_START register (see next state) |
977 | to be used by DRPw FW. The RTRIM value will be added by the FW | 1081 | to be used by DRPw FW. The RTRIM value will be added by the FW |
978 | before taking DRPw out of reset */ | 1082 | before taking DRPw out of reset */ |
979 | 1083 | ||
980 | clk = wl1271_read32(wl, WL12XX_DRPW_SCRATCH_START); | 1084 | ret = wlcore_read32(wl, WL12XX_DRPW_SCRATCH_START, &clk); |
1085 | if (ret < 0) | ||
1086 | goto out; | ||
981 | 1087 | ||
982 | wl1271_debug(DEBUG_BOOT, "clk2 0x%x", clk); | 1088 | wl1271_debug(DEBUG_BOOT, "clk2 0x%x", clk); |
983 | 1089 | ||
@@ -986,12 +1092,18 @@ static int wl12xx_pre_boot(struct wl1271 *wl) | |||
986 | else | 1092 | else |
987 | clk |= (priv->ref_clock << 1) << 4; | 1093 | clk |= (priv->ref_clock << 1) << 4; |
988 | 1094 | ||
989 | wl1271_write32(wl, WL12XX_DRPW_SCRATCH_START, clk); | 1095 | ret = wlcore_write32(wl, WL12XX_DRPW_SCRATCH_START, clk); |
1096 | if (ret < 0) | ||
1097 | goto out; | ||
990 | 1098 | ||
991 | wlcore_set_partition(wl, &wl->ptable[PART_WORK]); | 1099 | ret = wlcore_set_partition(wl, &wl->ptable[PART_WORK]); |
1100 | if (ret < 0) | ||
1101 | goto out; | ||
992 | 1102 | ||
993 | /* Disable interrupts */ | 1103 | /* Disable interrupts */ |
994 | wlcore_write_reg(wl, REG_INTERRUPT_MASK, WL1271_ACX_INTR_ALL); | 1104 | ret = wlcore_write_reg(wl, REG_INTERRUPT_MASK, WL1271_ACX_INTR_ALL); |
1105 | if (ret < 0) | ||
1106 | goto out; | ||
995 | 1107 | ||
996 | ret = wl1271_boot_soft_reset(wl); | 1108 | ret = wl1271_boot_soft_reset(wl); |
997 | if (ret < 0) | 1109 | if (ret < 0) |
@@ -1001,47 +1113,72 @@ out: | |||
1001 | return ret; | 1113 | return ret; |
1002 | } | 1114 | } |
1003 | 1115 | ||
1004 | static void wl12xx_pre_upload(struct wl1271 *wl) | 1116 | static int wl12xx_pre_upload(struct wl1271 *wl) |
1005 | { | 1117 | { |
1006 | u32 tmp, polarity; | 1118 | u32 tmp; |
1119 | u16 polarity; | ||
1120 | int ret; | ||
1007 | 1121 | ||
1008 | /* write firmware's last address (ie. it's length) to | 1122 | /* write firmware's last address (ie. it's length) to |
1009 | * ACX_EEPROMLESS_IND_REG */ | 1123 | * ACX_EEPROMLESS_IND_REG */ |
1010 | wl1271_debug(DEBUG_BOOT, "ACX_EEPROMLESS_IND_REG"); | 1124 | wl1271_debug(DEBUG_BOOT, "ACX_EEPROMLESS_IND_REG"); |
1011 | 1125 | ||
1012 | wl1271_write32(wl, WL12XX_EEPROMLESS_IND, WL12XX_EEPROMLESS_IND); | 1126 | ret = wlcore_write32(wl, WL12XX_EEPROMLESS_IND, WL12XX_EEPROMLESS_IND); |
1127 | if (ret < 0) | ||
1128 | goto out; | ||
1013 | 1129 | ||
1014 | tmp = wlcore_read_reg(wl, REG_CHIP_ID_B); | 1130 | ret = wlcore_read_reg(wl, REG_CHIP_ID_B, &tmp); |
1131 | if (ret < 0) | ||
1132 | goto out; | ||
1015 | 1133 | ||
1016 | wl1271_debug(DEBUG_BOOT, "chip id 0x%x", tmp); | 1134 | wl1271_debug(DEBUG_BOOT, "chip id 0x%x", tmp); |
1017 | 1135 | ||
1018 | /* 6. read the EEPROM parameters */ | 1136 | /* 6. read the EEPROM parameters */ |
1019 | tmp = wl1271_read32(wl, WL12XX_SCR_PAD2); | 1137 | ret = wlcore_read32(wl, WL12XX_SCR_PAD2, &tmp); |
1138 | if (ret < 0) | ||
1139 | goto out; | ||
1020 | 1140 | ||
1021 | /* WL1271: The reference driver skips steps 7 to 10 (jumps directly | 1141 | /* WL1271: The reference driver skips steps 7 to 10 (jumps directly |
1022 | * to upload_fw) */ | 1142 | * to upload_fw) */ |
1023 | 1143 | ||
1024 | if (wl->chip.id == CHIP_ID_1283_PG20) | 1144 | if (wl->chip.id == CHIP_ID_1283_PG20) { |
1025 | wl12xx_top_reg_write(wl, SDIO_IO_DS, HCI_IO_DS_6MA); | 1145 | ret = wl12xx_top_reg_write(wl, SDIO_IO_DS, HCI_IO_DS_6MA); |
1146 | if (ret < 0) | ||
1147 | goto out; | ||
1148 | } | ||
1026 | 1149 | ||
1027 | /* polarity must be set before the firmware is loaded */ | 1150 | /* polarity must be set before the firmware is loaded */ |
1028 | polarity = wl12xx_top_reg_read(wl, OCP_REG_POLARITY); | 1151 | ret = wl12xx_top_reg_read(wl, OCP_REG_POLARITY, &polarity); |
1152 | if (ret < 0) | ||
1153 | goto out; | ||
1029 | 1154 | ||
1030 | /* We use HIGH polarity, so unset the LOW bit */ | 1155 | /* We use HIGH polarity, so unset the LOW bit */ |
1031 | polarity &= ~POLARITY_LOW; | 1156 | polarity &= ~POLARITY_LOW; |
1032 | wl12xx_top_reg_write(wl, OCP_REG_POLARITY, polarity); | 1157 | ret = wl12xx_top_reg_write(wl, OCP_REG_POLARITY, polarity); |
1033 | 1158 | ||
1159 | out: | ||
1160 | return ret; | ||
1034 | } | 1161 | } |
1035 | 1162 | ||
1036 | static void wl12xx_enable_interrupts(struct wl1271 *wl) | 1163 | static int wl12xx_enable_interrupts(struct wl1271 *wl) |
1037 | { | 1164 | { |
1038 | wlcore_write_reg(wl, REG_INTERRUPT_MASK, WL12XX_ACX_ALL_EVENTS_VECTOR); | 1165 | int ret; |
1166 | |||
1167 | ret = wlcore_write_reg(wl, REG_INTERRUPT_MASK, | ||
1168 | WL12XX_ACX_ALL_EVENTS_VECTOR); | ||
1169 | if (ret < 0) | ||
1170 | goto out; | ||
1039 | 1171 | ||
1040 | wlcore_enable_interrupts(wl); | 1172 | wlcore_enable_interrupts(wl); |
1041 | wlcore_write_reg(wl, REG_INTERRUPT_MASK, | 1173 | ret = wlcore_write_reg(wl, REG_INTERRUPT_MASK, |
1042 | WL1271_ACX_INTR_ALL & ~(WL12XX_INTR_MASK)); | 1174 | WL1271_ACX_INTR_ALL & ~(WL12XX_INTR_MASK)); |
1175 | if (ret < 0) | ||
1176 | goto out; | ||
1043 | 1177 | ||
1044 | wl1271_write32(wl, WL12XX_HI_CFG, HI_CFG_DEF_VAL); | 1178 | ret = wlcore_write32(wl, WL12XX_HI_CFG, HI_CFG_DEF_VAL); |
1179 | |||
1180 | out: | ||
1181 | return ret; | ||
1045 | } | 1182 | } |
1046 | 1183 | ||
1047 | static int wl12xx_boot(struct wl1271 *wl) | 1184 | static int wl12xx_boot(struct wl1271 *wl) |
@@ -1056,7 +1193,9 @@ static int wl12xx_boot(struct wl1271 *wl) | |||
1056 | if (ret < 0) | 1193 | if (ret < 0) |
1057 | goto out; | 1194 | goto out; |
1058 | 1195 | ||
1059 | wl12xx_pre_upload(wl); | 1196 | ret = wl12xx_pre_upload(wl); |
1197 | if (ret < 0) | ||
1198 | goto out; | ||
1060 | 1199 | ||
1061 | ret = wlcore_boot_upload_firmware(wl); | 1200 | ret = wlcore_boot_upload_firmware(wl); |
1062 | if (ret < 0) | 1201 | if (ret < 0) |
@@ -1066,22 +1205,30 @@ static int wl12xx_boot(struct wl1271 *wl) | |||
1066 | if (ret < 0) | 1205 | if (ret < 0) |
1067 | goto out; | 1206 | goto out; |
1068 | 1207 | ||
1069 | wl12xx_enable_interrupts(wl); | 1208 | ret = wl12xx_enable_interrupts(wl); |
1070 | 1209 | ||
1071 | out: | 1210 | out: |
1072 | return ret; | 1211 | return ret; |
1073 | } | 1212 | } |
1074 | 1213 | ||
1075 | static void wl12xx_trigger_cmd(struct wl1271 *wl, int cmd_box_addr, | 1214 | static int wl12xx_trigger_cmd(struct wl1271 *wl, int cmd_box_addr, |
1076 | void *buf, size_t len) | 1215 | void *buf, size_t len) |
1077 | { | 1216 | { |
1078 | wl1271_write(wl, cmd_box_addr, buf, len, false); | 1217 | int ret; |
1079 | wlcore_write_reg(wl, REG_INTERRUPT_TRIG, WL12XX_INTR_TRIG_CMD); | 1218 | |
1219 | ret = wlcore_write(wl, cmd_box_addr, buf, len, false); | ||
1220 | if (ret < 0) | ||
1221 | return ret; | ||
1222 | |||
1223 | ret = wlcore_write_reg(wl, REG_INTERRUPT_TRIG, WL12XX_INTR_TRIG_CMD); | ||
1224 | |||
1225 | return ret; | ||
1080 | } | 1226 | } |
1081 | 1227 | ||
1082 | static void wl12xx_ack_event(struct wl1271 *wl) | 1228 | static int wl12xx_ack_event(struct wl1271 *wl) |
1083 | { | 1229 | { |
1084 | wlcore_write_reg(wl, REG_INTERRUPT_TRIG, WL12XX_INTR_TRIG_EVENT_ACK); | 1230 | return wlcore_write_reg(wl, REG_INTERRUPT_TRIG, |
1231 | WL12XX_INTR_TRIG_EVENT_ACK); | ||
1085 | } | 1232 | } |
1086 | 1233 | ||
1087 | static u32 wl12xx_calc_tx_blocks(struct wl1271 *wl, u32 len, u32 spare_blks) | 1234 | static u32 wl12xx_calc_tx_blocks(struct wl1271 *wl, u32 len, u32 spare_blks) |
@@ -1161,13 +1308,13 @@ static u32 wl12xx_get_rx_packet_len(struct wl1271 *wl, void *rx_data, | |||
1161 | return data_len - sizeof(*desc) - desc->pad_len; | 1308 | return data_len - sizeof(*desc) - desc->pad_len; |
1162 | } | 1309 | } |
1163 | 1310 | ||
1164 | static void wl12xx_tx_delayed_compl(struct wl1271 *wl) | 1311 | static int wl12xx_tx_delayed_compl(struct wl1271 *wl) |
1165 | { | 1312 | { |
1166 | if (wl->fw_status_1->tx_results_counter == | 1313 | if (wl->fw_status_1->tx_results_counter == |
1167 | (wl->tx_results_count & 0xff)) | 1314 | (wl->tx_results_count & 0xff)) |
1168 | return; | 1315 | return 0; |
1169 | 1316 | ||
1170 | wl1271_tx_complete(wl); | 1317 | return wlcore_tx_complete(wl); |
1171 | } | 1318 | } |
1172 | 1319 | ||
1173 | static int wl12xx_hw_init(struct wl1271 *wl) | 1320 | static int wl12xx_hw_init(struct wl1271 *wl) |
@@ -1268,39 +1415,58 @@ static bool wl12xx_mac_in_fuse(struct wl1271 *wl) | |||
1268 | return supported; | 1415 | return supported; |
1269 | } | 1416 | } |
1270 | 1417 | ||
1271 | static void wl12xx_get_fuse_mac(struct wl1271 *wl) | 1418 | static int wl12xx_get_fuse_mac(struct wl1271 *wl) |
1272 | { | 1419 | { |
1273 | u32 mac1, mac2; | 1420 | u32 mac1, mac2; |
1421 | int ret; | ||
1274 | 1422 | ||
1275 | wlcore_set_partition(wl, &wl->ptable[PART_DRPW]); | 1423 | ret = wlcore_set_partition(wl, &wl->ptable[PART_DRPW]); |
1424 | if (ret < 0) | ||
1425 | goto out; | ||
1276 | 1426 | ||
1277 | mac1 = wl1271_read32(wl, WL12XX_REG_FUSE_BD_ADDR_1); | 1427 | ret = wlcore_read32(wl, WL12XX_REG_FUSE_BD_ADDR_1, &mac1); |
1278 | mac2 = wl1271_read32(wl, WL12XX_REG_FUSE_BD_ADDR_2); | 1428 | if (ret < 0) |
1429 | goto out; | ||
1430 | |||
1431 | ret = wlcore_read32(wl, WL12XX_REG_FUSE_BD_ADDR_2, &mac2); | ||
1432 | if (ret < 0) | ||
1433 | goto out; | ||
1279 | 1434 | ||
1280 | /* these are the two parts of the BD_ADDR */ | 1435 | /* these are the two parts of the BD_ADDR */ |
1281 | wl->fuse_oui_addr = ((mac2 & 0xffff) << 8) + | 1436 | wl->fuse_oui_addr = ((mac2 & 0xffff) << 8) + |
1282 | ((mac1 & 0xff000000) >> 24); | 1437 | ((mac1 & 0xff000000) >> 24); |
1283 | wl->fuse_nic_addr = mac1 & 0xffffff; | 1438 | wl->fuse_nic_addr = mac1 & 0xffffff; |
1284 | 1439 | ||
1285 | wlcore_set_partition(wl, &wl->ptable[PART_DOWN]); | 1440 | ret = wlcore_set_partition(wl, &wl->ptable[PART_DOWN]); |
1441 | |||
1442 | out: | ||
1443 | return ret; | ||
1286 | } | 1444 | } |
1287 | 1445 | ||
1288 | static s8 wl12xx_get_pg_ver(struct wl1271 *wl) | 1446 | static int wl12xx_get_pg_ver(struct wl1271 *wl, s8 *ver) |
1289 | { | 1447 | { |
1290 | u32 die_info; | 1448 | u16 die_info; |
1449 | int ret; | ||
1291 | 1450 | ||
1292 | if (wl->chip.id == CHIP_ID_1283_PG20) | 1451 | if (wl->chip.id == CHIP_ID_1283_PG20) |
1293 | die_info = wl12xx_top_reg_read(wl, WL128X_REG_FUSE_DATA_2_1); | 1452 | ret = wl12xx_top_reg_read(wl, WL128X_REG_FUSE_DATA_2_1, |
1453 | &die_info); | ||
1294 | else | 1454 | else |
1295 | die_info = wl12xx_top_reg_read(wl, WL127X_REG_FUSE_DATA_2_1); | 1455 | ret = wl12xx_top_reg_read(wl, WL127X_REG_FUSE_DATA_2_1, |
1456 | &die_info); | ||
1296 | 1457 | ||
1297 | return (s8) (die_info & PG_VER_MASK) >> PG_VER_OFFSET; | 1458 | if (ret >= 0 && ver) |
1459 | *ver = (s8)((die_info & PG_VER_MASK) >> PG_VER_OFFSET); | ||
1460 | |||
1461 | return ret; | ||
1298 | } | 1462 | } |
1299 | 1463 | ||
1300 | static void wl12xx_get_mac(struct wl1271 *wl) | 1464 | static int wl12xx_get_mac(struct wl1271 *wl) |
1301 | { | 1465 | { |
1302 | if (wl12xx_mac_in_fuse(wl)) | 1466 | if (wl12xx_mac_in_fuse(wl)) |
1303 | wl12xx_get_fuse_mac(wl); | 1467 | return wl12xx_get_fuse_mac(wl); |
1468 | |||
1469 | return 0; | ||
1304 | } | 1470 | } |
1305 | 1471 | ||
1306 | static void wl12xx_set_tx_desc_csum(struct wl1271 *wl, | 1472 | static void wl12xx_set_tx_desc_csum(struct wl1271 *wl, |
@@ -1448,10 +1614,8 @@ static int __devinit wl12xx_probe(struct platform_device *pdev) | |||
1448 | wl->hw_min_ht_rate = WL12XX_CONF_HW_RXTX_RATE_MCS0; | 1614 | wl->hw_min_ht_rate = WL12XX_CONF_HW_RXTX_RATE_MCS0; |
1449 | wl->fw_status_priv_len = 0; | 1615 | wl->fw_status_priv_len = 0; |
1450 | wl->stats.fw_stats_len = sizeof(struct wl12xx_acx_statistics); | 1616 | wl->stats.fw_stats_len = sizeof(struct wl12xx_acx_statistics); |
1451 | memcpy(&wl->ht_cap[IEEE80211_BAND_2GHZ], &wl12xx_ht_cap, | 1617 | wlcore_set_ht_cap(wl, IEEE80211_BAND_2GHZ, &wl12xx_ht_cap); |
1452 | sizeof(wl12xx_ht_cap)); | 1618 | wlcore_set_ht_cap(wl, IEEE80211_BAND_5GHZ, &wl12xx_ht_cap); |
1453 | memcpy(&wl->ht_cap[IEEE80211_BAND_5GHZ], &wl12xx_ht_cap, | ||
1454 | sizeof(wl12xx_ht_cap)); | ||
1455 | wl12xx_conf_init(wl); | 1619 | wl12xx_conf_init(wl); |
1456 | 1620 | ||
1457 | if (!fref_param) { | 1621 | if (!fref_param) { |