static int mt7601u_init_bbp(struct mt7601u_dev *dev) { int ret; ret = mt7601u_wait_bbp_ready(dev); if (ret) return ret; ret = mt7601u_write_reg_pairs(dev, MT_MCU_MEMMAP_BBP, bbp_common_vals, ARRAY_SIZE(bbp_common_vals)); if (ret) return ret; return mt7601u_write_reg_pairs(dev, MT_MCU_MEMMAP_BBP, bbp_chip_vals, ARRAY_SIZE(bbp_chip_vals)); }
int mt7601u_write_reg_pairs(struct mt7601u_dev *dev, u32 base, const struct mt76_reg_pair *data, int n) { const int max_vals_per_cmd = INBAND_PACKET_MAX_LEN / 8; struct sk_buff *skb; int cnt, i, ret; if (!n) return 0; cnt = min(max_vals_per_cmd, n); skb = alloc_skb(cnt * 8 + MT_DMA_HDR_LEN + 4, GFP_KERNEL); if (!skb) return -ENOMEM; skb_reserve(skb, MT_DMA_HDR_LEN); for (i = 0; i < cnt; i++) { skb_put_le32(skb, base + data[i].reg); skb_put_le32(skb, data[i].value); } ret = mt7601u_mcu_msg_send(dev, skb, CMD_RANDOM_WRITE, cnt == n); if (ret) return ret; return mt7601u_write_reg_pairs(dev, base, data + cnt, n - cnt); }
static int mt7601u_write_mac_initvals(struct mt7601u_dev *dev) { int ret; ret = mt7601u_write_reg_pairs(dev, MT_MCU_MEMMAP_WLAN, mac_common_vals, ARRAY_SIZE(mac_common_vals)); if (ret) return ret; ret = mt7601u_write_reg_pairs(dev, MT_MCU_MEMMAP_WLAN, mac_chip_vals, ARRAY_SIZE(mac_chip_vals)); if (ret) return ret; mt76_init_beacon_offsets(dev); mt7601u_wr(dev, MT_AUX_CLK_CFG, 0); return 0; }