aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/ti/wl18xx/main.c
diff options
context:
space:
mode:
authorIdo Yariv <ido@wizery.com>2012-06-18 08:50:21 -0400
committerLuciano Coelho <coelho@ti.com>2012-06-22 03:49:33 -0400
commit6134323f42b0dbae8e8206414d26cb167b9bedfc (patch)
tree2c8f89b23e8f38f66af6396f17a0c3c5b7561550 /drivers/net/wireless/ti/wl18xx/main.c
parenteb96f841b9563ba34969be25615548635728faf5 (diff)
wlcore: Propagate errors from wl1271_raw_read32
Propagate errors from wl1271_raw_read32. Since the read functions had no way of returning errors in-band, change their prototypes. Also rename prefixes of wlcore functions which their prototypes had to be changed. Signed-off-by: Ido Yariv <ido@wizery.com> Signed-off-by: Luciano Coelho <coelho@ti.com>
Diffstat (limited to 'drivers/net/wireless/ti/wl18xx/main.c')
-rw-r--r--drivers/net/wireless/ti/wl18xx/main.c114
1 files changed, 82 insertions, 32 deletions
diff --git a/drivers/net/wireless/ti/wl18xx/main.c b/drivers/net/wireless/ti/wl18xx/main.c
index 974a6ff11f6d..f99f003ab182 100644
--- a/drivers/net/wireless/ti/wl18xx/main.c
+++ b/drivers/net/wireless/ti/wl18xx/main.c
@@ -636,45 +636,67 @@ out:
636 return ret; 636 return ret;
637} 637}
638 638
639static void wl18xx_set_clk(struct wl1271 *wl) 639static int wl18xx_set_clk(struct wl1271 *wl)
640{ 640{
641 u32 clk_freq; 641 u16 clk_freq;
642 int ret;
642 643
643 wlcore_set_partition(wl, &wl->ptable[PART_TOP_PRCM_ELP_SOC]); 644 wlcore_set_partition(wl, &wl->ptable[PART_TOP_PRCM_ELP_SOC]);
644 645
645 /* TODO: PG2: apparently we need to read the clk type */ 646 /* TODO: PG2: apparently we need to read the clk type */
646 647
647 clk_freq = wl18xx_top_reg_read(wl, PRIMARY_CLK_DETECT); 648 ret = wl18xx_top_reg_read(wl, PRIMARY_CLK_DETECT, &clk_freq);
649 if (ret < 0)
650 goto out;
651
648 wl1271_debug(DEBUG_BOOT, "clock freq %d (%d, %d, %d, %d, %s)", clk_freq, 652 wl1271_debug(DEBUG_BOOT, "clock freq %d (%d, %d, %d, %d, %s)", clk_freq,
649 wl18xx_clk_table[clk_freq].n, wl18xx_clk_table[clk_freq].m, 653 wl18xx_clk_table[clk_freq].n, wl18xx_clk_table[clk_freq].m,
650 wl18xx_clk_table[clk_freq].p, wl18xx_clk_table[clk_freq].q, 654 wl18xx_clk_table[clk_freq].p, wl18xx_clk_table[clk_freq].q,
651 wl18xx_clk_table[clk_freq].swallow ? "swallow" : "spit"); 655 wl18xx_clk_table[clk_freq].swallow ? "swallow" : "spit");
652 656
653 wl18xx_top_reg_write(wl, PLLSH_WCS_PLL_N, wl18xx_clk_table[clk_freq].n); 657 ret = wl18xx_top_reg_write(wl, PLLSH_WCS_PLL_N,
654 wl18xx_top_reg_write(wl, PLLSH_WCS_PLL_M, wl18xx_clk_table[clk_freq].m); 658 wl18xx_clk_table[clk_freq].n);
659 if (ret < 0)
660 goto out;
661
662 ret = wl18xx_top_reg_write(wl, PLLSH_WCS_PLL_M,
663 wl18xx_clk_table[clk_freq].m);
664 if (ret < 0)
665 goto out;
655 666
656 if (wl18xx_clk_table[clk_freq].swallow) { 667 if (wl18xx_clk_table[clk_freq].swallow) {
657 /* first the 16 lower bits */ 668 /* first the 16 lower bits */
658 wl18xx_top_reg_write(wl, PLLSH_WCS_PLL_Q_FACTOR_CFG_1, 669 ret = wl18xx_top_reg_write(wl, PLLSH_WCS_PLL_Q_FACTOR_CFG_1,
659 wl18xx_clk_table[clk_freq].q & 670 wl18xx_clk_table[clk_freq].q &
660 PLLSH_WCS_PLL_Q_FACTOR_CFG_1_MASK); 671 PLLSH_WCS_PLL_Q_FACTOR_CFG_1_MASK);
672 if (ret < 0)
673 goto out;
674
661 /* then the 16 higher bits, masked out */ 675 /* then the 16 higher bits, masked out */
662 wl18xx_top_reg_write(wl, PLLSH_WCS_PLL_Q_FACTOR_CFG_2, 676 ret = wl18xx_top_reg_write(wl, PLLSH_WCS_PLL_Q_FACTOR_CFG_2,
663 (wl18xx_clk_table[clk_freq].q >> 16) & 677 (wl18xx_clk_table[clk_freq].q >> 16) &
664 PLLSH_WCS_PLL_Q_FACTOR_CFG_2_MASK); 678 PLLSH_WCS_PLL_Q_FACTOR_CFG_2_MASK);
679 if (ret < 0)
680 goto out;
665 681
666 /* first the 16 lower bits */ 682 /* first the 16 lower bits */
667 wl18xx_top_reg_write(wl, PLLSH_WCS_PLL_P_FACTOR_CFG_1, 683 ret = wl18xx_top_reg_write(wl, PLLSH_WCS_PLL_P_FACTOR_CFG_1,
668 wl18xx_clk_table[clk_freq].p & 684 wl18xx_clk_table[clk_freq].p &
669 PLLSH_WCS_PLL_P_FACTOR_CFG_1_MASK); 685 PLLSH_WCS_PLL_P_FACTOR_CFG_1_MASK);
686 if (ret < 0)
687 goto out;
688
670 /* then the 16 higher bits, masked out */ 689 /* then the 16 higher bits, masked out */
671 wl18xx_top_reg_write(wl, PLLSH_WCS_PLL_P_FACTOR_CFG_2, 690 ret = wl18xx_top_reg_write(wl, PLLSH_WCS_PLL_P_FACTOR_CFG_2,
672 (wl18xx_clk_table[clk_freq].p >> 16) & 691 (wl18xx_clk_table[clk_freq].p >> 16) &
673 PLLSH_WCS_PLL_P_FACTOR_CFG_2_MASK); 692 PLLSH_WCS_PLL_P_FACTOR_CFG_2_MASK);
674 } else { 693 } else {
675 wl18xx_top_reg_write(wl, PLLSH_WCS_PLL_SWALLOW_EN, 694 ret = wl18xx_top_reg_write(wl, PLLSH_WCS_PLL_SWALLOW_EN,
676 PLLSH_WCS_PLL_SWALLOW_EN_VAL2); 695 PLLSH_WCS_PLL_SWALLOW_EN_VAL2);
677 } 696 }
697
698out:
699 return ret;
678} 700}
679 701
680static void wl18xx_boot_soft_reset(struct wl1271 *wl) 702static void wl18xx_boot_soft_reset(struct wl1271 *wl)
@@ -688,7 +710,11 @@ static void wl18xx_boot_soft_reset(struct wl1271 *wl)
688 710
689static int wl18xx_pre_boot(struct wl1271 *wl) 711static int wl18xx_pre_boot(struct wl1271 *wl)
690{ 712{
691 wl18xx_set_clk(wl); 713 int ret;
714
715 ret = wl18xx_set_clk(wl);
716 if (ret < 0)
717 goto out;
692 718
693 /* Continue the ELP wake up sequence */ 719 /* Continue the ELP wake up sequence */
694 wl1271_write32(wl, WL18XX_WELP_ARM_COMMAND, WELP_ARM_COMMAND_VAL); 720 wl1271_write32(wl, WL18XX_WELP_ARM_COMMAND, WELP_ARM_COMMAND_VAL);
@@ -701,23 +727,30 @@ static int wl18xx_pre_boot(struct wl1271 *wl)
701 727
702 wl18xx_boot_soft_reset(wl); 728 wl18xx_boot_soft_reset(wl);
703 729
704 return 0; 730out:
731 return ret;
705} 732}
706 733
707static void wl18xx_pre_upload(struct wl1271 *wl) 734static int wl18xx_pre_upload(struct wl1271 *wl)
708{ 735{
709 u32 tmp; 736 u32 tmp;
737 int ret;
710 738
711 wlcore_set_partition(wl, &wl->ptable[PART_BOOT]); 739 wlcore_set_partition(wl, &wl->ptable[PART_BOOT]);
712 740
713 /* TODO: check if this is all needed */ 741 /* TODO: check if this is all needed */
714 wl1271_write32(wl, WL18XX_EEPROMLESS_IND, WL18XX_EEPROMLESS_IND); 742 wl1271_write32(wl, WL18XX_EEPROMLESS_IND, WL18XX_EEPROMLESS_IND);
715 743
716 tmp = wlcore_read_reg(wl, REG_CHIP_ID_B); 744 ret = wlcore_read_reg(wl, REG_CHIP_ID_B, &tmp);
745 if (ret < 0)
746 goto out;
717 747
718 wl1271_debug(DEBUG_BOOT, "chip id 0x%x", tmp); 748 wl1271_debug(DEBUG_BOOT, "chip id 0x%x", tmp);
719 749
720 tmp = wl1271_read32(wl, WL18XX_SCR_PAD2); 750 ret = wlcore_read32(wl, WL18XX_SCR_PAD2, &tmp);
751
752out:
753 return ret;
721} 754}
722 755
723static int wl18xx_set_mac_and_phy(struct wl1271 *wl) 756static int wl18xx_set_mac_and_phy(struct wl1271 *wl)
@@ -766,7 +799,9 @@ static int wl18xx_boot(struct wl1271 *wl)
766 if (ret < 0) 799 if (ret < 0)
767 goto out; 800 goto out;
768 801
769 wl18xx_pre_upload(wl); 802 ret = wl18xx_pre_upload(wl);
803 if (ret < 0)
804 goto out;
770 805
771 ret = wlcore_boot_upload_firmware(wl); 806 ret = wlcore_boot_upload_firmware(wl);
772 if (ret < 0) 807 if (ret < 0)
@@ -998,18 +1033,24 @@ static u32 wl18xx_ap_get_mimo_wide_rate_mask(struct wl1271 *wl,
998 } 1033 }
999} 1034}
1000 1035
1001static s8 wl18xx_get_pg_ver(struct wl1271 *wl) 1036static int wl18xx_get_pg_ver(struct wl1271 *wl, s8 *ver)
1002{ 1037{
1003 u32 fuse; 1038 u32 fuse;
1039 int ret;
1004 1040
1005 wlcore_set_partition(wl, &wl->ptable[PART_TOP_PRCM_ELP_SOC]); 1041 wlcore_set_partition(wl, &wl->ptable[PART_TOP_PRCM_ELP_SOC]);
1006 1042
1007 fuse = wl1271_read32(wl, WL18XX_REG_FUSE_DATA_1_3); 1043 ret = wlcore_read32(wl, WL18XX_REG_FUSE_DATA_1_3, &fuse);
1008 fuse = (fuse & WL18XX_PG_VER_MASK) >> WL18XX_PG_VER_OFFSET; 1044 if (ret < 0)
1045 goto out;
1046
1047 if (ver)
1048 *ver = (fuse & WL18XX_PG_VER_MASK) >> WL18XX_PG_VER_OFFSET;
1009 1049
1010 wlcore_set_partition(wl, &wl->ptable[PART_BOOT]); 1050 wlcore_set_partition(wl, &wl->ptable[PART_BOOT]);
1011 1051
1012 return (s8)fuse; 1052out:
1053 return ret;
1013} 1054}
1014 1055
1015#define WL18XX_CONF_FILE_NAME "ti-connectivity/wl18xx-conf.bin" 1056#define WL18XX_CONF_FILE_NAME "ti-connectivity/wl18xx-conf.bin"
@@ -1080,14 +1121,20 @@ static int wl18xx_plt_init(struct wl1271 *wl)
1080 return wl->ops->boot(wl); 1121 return wl->ops->boot(wl);
1081} 1122}
1082 1123
1083static void wl18xx_get_mac(struct wl1271 *wl) 1124static int wl18xx_get_mac(struct wl1271 *wl)
1084{ 1125{
1085 u32 mac1, mac2; 1126 u32 mac1, mac2;
1127 int ret;
1086 1128
1087 wlcore_set_partition(wl, &wl->ptable[PART_TOP_PRCM_ELP_SOC]); 1129 wlcore_set_partition(wl, &wl->ptable[PART_TOP_PRCM_ELP_SOC]);
1088 1130
1089 mac1 = wl1271_read32(wl, WL18XX_REG_FUSE_BD_ADDR_1); 1131 ret = wlcore_read32(wl, WL18XX_REG_FUSE_BD_ADDR_1, &mac1);
1090 mac2 = wl1271_read32(wl, WL18XX_REG_FUSE_BD_ADDR_2); 1132 if (ret < 0)
1133 goto out;
1134
1135 ret = wlcore_read32(wl, WL18XX_REG_FUSE_BD_ADDR_2, &mac2);
1136 if (ret < 0)
1137 goto out;
1091 1138
1092 /* these are the two parts of the BD_ADDR */ 1139 /* these are the two parts of the BD_ADDR */
1093 wl->fuse_oui_addr = ((mac2 & 0xffff) << 8) + 1140 wl->fuse_oui_addr = ((mac2 & 0xffff) << 8) +
@@ -1095,6 +1142,9 @@ static void wl18xx_get_mac(struct wl1271 *wl)
1095 wl->fuse_nic_addr = (mac1 & 0xffffff); 1142 wl->fuse_nic_addr = (mac1 & 0xffffff);
1096 1143
1097 wlcore_set_partition(wl, &wl->ptable[PART_DOWN]); 1144 wlcore_set_partition(wl, &wl->ptable[PART_DOWN]);
1145
1146out:
1147 return ret;
1098} 1148}
1099 1149
1100static int wl18xx_handle_static_data(struct wl1271 *wl, 1150static int wl18xx_handle_static_data(struct wl1271 *wl,